Skip to content

feat(commands): WS2 堆叠 slash-skill 调用 (最多 5 前导, 对齐 CC 2.1.199) - #74

Merged
dahai80 merged 1 commit into
mainfrom
feat/stacked-slash-skills
Aug 20, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/stacked-slash-skills

Conversation

@dahai80

@dahai80 dahai80 commented Aug 19, 2026

Copy link
Copy Markdown
Owner

背景

对齐 Claude Code 2.1.199 新特性 stacked slash-skills: 用户可输入
/skill-a /skill-b do XYZ, 前导技能串联注入 context, 终末命令 (最后一条
`/cmd`) 或 free-text 生实际 turn。追踪 issue: #72

语义

  • 前导 (leading) slash 命令: 仅注入 context (其 prompt content 串联),
    不生独立 turn。须为 prompt-type skill。
  • 终末 (terminal): 最后一条 `/cmd` 以 free-text 作 args 走标准分发,
    或无终末命令时 free-text 自身作 turn。
  • 上限: 最多 5 个前导 (对齐 CC 2.1.199 "最多 5 前导技能"), 第 6 个起
    并入 freeText (拒绝堆叠)。
  • 兼容: 单 `/cmd args` 行为完全不变 (commands 长度 1, freeText 空)。
  • 回退: 前导有非 prompt-type (local-jsx 无法静默注入 context) 或终末
    非 prompt-type 时返回 null, 回退单命令路径。

改动 (3 files, +383/-43)

文件 改动
`src/utils/slashCommandParsing.ts` +`MAX_STACKED_LEADING_COMMANDS`, `StackedSlashParse` 类型, `parseStackedSlashCommands` 解析器; 一并对齐 Biome (tab + double-quote), 消除该文件历史 2-space/单引号离群格式
`src/utils/processUserInput/processSlashCommand.tsx` +`processStackedSlashCommands` 分发 helper + 堆叠检测入口; import 块对齐 Biome organize-imports
`tests/utils/slashCommandParsing.test.ts` 新增 15 用例: 单命令兼容 / 两前导 / 三前导 / 首 non-/ 停止 / 超 5 溢出 / 恰 5 / non-/ null / 仅 / null / 路径 token null / MCP 冒号 / 多空格归一

验证

  • `bun run typecheck` — 0 错误
  • `bun run build` + `bun run build:dev:full` — 通过
  • `bun test src/tests/ tests/utils/` — 151 pass / 0 fail (含新增 15)
  • `bunx biome check` (WS2 三文件) — 仅 `noNonNullAssertion` 警告,
    与仓库既有基线一致 (`r!` 镜像现有 `words[0]!`/`newMessages[1]!` 模式)

设计决策

  1. 解析与分发分离: `parseStackedSlashCommands` 纯函数, 仅决定哪些
    token 是 leading 命令、哪些是 freeText; 分发逻辑集中在
    `processStackedSlashCommands`, 失败回退单命令路径 (`return null`)。
  2. local-jsx 不参与堆叠: local-jsx 命令渲染即时 UI, 无法静默注入
    context。前导或终末为 local-jsx 时整体回退。
  3. context 合并: 累积 context 作 `isMeta` 的
    `` 消息插入终末 mainContent (index 1) 之前,
    不污染 visible 历史。
  4. 超限软拒绝: 超 5 前导不报错, 第 6 个起并入 freeText (非抛错),
    对齐 CC 宽松上限语义。

Closes #72

Co-Authored-By: Claude Fable 5 [email protected]

新增解析器 parseStackedSlashCommands: 从输入开头连续提取 leading
/cmd (最多 MAX_STACKED_LEADING_COMMANDS=5), 遇首个非 / token 停止,
剩余作终末 freeText。单命令行为不变 (向后兼容)。

分发 processStackedSlashCommands: 前 N-1 条 prompt-type skill 串联
注入 context (getPromptForCommand 取空 args, 注册 hooks + 记录调用),
终末命令以 freeText 作 args 走标准 getMessagesForSlashCommand, 累积
context 作 isMeta <stacked-skill-context> 前缀插入。local-jsx 终末
或前导非 prompt-type 时返回 null, 回退单命令路径。

slashCommandParsing.ts 一并对齐 Biome (tab + double-quote), 消除该
文件历史 2-space/单引号离群格式。

验证: typecheck 0 错; build + build:dev:full 通过; tests/utils +
src/__tests__ 151 pass / 0 fail; 新增 15 堆叠解析用例全绿。

Closes #72

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit a36d2b7 into main Aug 20, 2026
1 check passed
@dahai80
dahai80 deleted the feat/stacked-slash-skills branch August 20, 2026 12:00
dahai80 added a commit that referenced this pull request Aug 20, 2026
追 CC 2.1.196→2.1.234 Tier-1 特性批量落地 (13 PR):

变更自 v0.4.22:
- WS1 DirectoryAdded hook + Notification agent_* 类型 (#73)
- WS2 堆叠 slash-skill 调用, 最多 5 前导 (#74)
- LSP+filecache 内存泄漏 cap, 对齐 CC 2.1.208 (#76)
- skill body-defer 懒加载, item 9 (#78)
- SessionStart source "fork" 区分 fork 与 resume (#80)
- P2.1 子代理护栏 — 并发/会话/深度三限 (#82)
- P1.1 大输出 tool_result tail 预览 (#84)
- P4.1 --ax-screen-reader 入口点对齐 — env 别名 + settings key (#86)
- item 13 WebSearch per-session 搜索次数上限 (#88)
- P4.2 §6 /doctor FUSION_* vs ANTHROPIC_* 环境变量冲突检测 (#90)
- P4.2 #1+#3 /doctor MLX 网关连通 + 模型加载探测 (#92)
- item 4 MCP 工具自动后台化 FUSION_MCP_AUTO_BACKGROUND_MS (#94)
- item 22 审计日志凭证脱敏 (#96)

- package.json: version 0.4.22 → 0.4.23

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(commands): 堆叠 slash-skill 调用 (最多 5 前导)

1 participant