@oyasmi/pipiclaw 0.9.1-beta.1 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/agent/channel-runner.d.ts +7 -1
  2. package/dist/agent/channel-runner.js +42 -15
  3. package/dist/agent/command-extension.js +24 -27
  4. package/dist/agent/commands.d.ts +51 -7
  5. package/dist/agent/commands.js +199 -59
  6. package/dist/agent/prompt/manifest.js +5 -6
  7. package/dist/agent/prompt/sections.js +1 -0
  8. package/dist/agent/reply-limits.d.ts +16 -0
  9. package/dist/agent/reply-limits.js +17 -0
  10. package/dist/agent/runner-factory.d.ts +0 -2
  11. package/dist/agent/session-events.js +2 -2
  12. package/dist/agent/status-render.js +12 -12
  13. package/dist/executor.d.ts +14 -0
  14. package/dist/executor.js +36 -6
  15. package/dist/main.js +3 -4
  16. package/dist/memory/commands.js +79 -38
  17. package/dist/memory/consolidation.d.ts +5 -1
  18. package/dist/memory/consolidation.js +33 -12
  19. package/dist/memory/extraction.d.ts +8 -1
  20. package/dist/memory/extraction.js +47 -4
  21. package/dist/memory/files.d.ts +0 -1
  22. package/dist/memory/files.js +24 -5
  23. package/dist/memory/lifecycle.js +9 -2
  24. package/dist/memory/maintenance-jobs.js +14 -4
  25. package/dist/memory/metadata.d.ts +3 -0
  26. package/dist/memory/metadata.js +7 -0
  27. package/dist/memory/recall.d.ts +9 -0
  28. package/dist/memory/recall.js +101 -17
  29. package/dist/memory/review-log.d.ts +0 -2
  30. package/dist/memory/review-log.js +0 -0
  31. package/dist/memory/session-corpus.js +5 -0
  32. package/dist/memory/session-search.js +9 -0
  33. package/dist/memory/sidecar-worker.js +4 -0
  34. package/dist/memory/source-window.d.ts +0 -1
  35. package/dist/memory/source-window.js +0 -5
  36. package/dist/memory/task-digest.js +0 -2
  37. package/dist/playbooks/agent-delegation.md +32 -24
  38. package/dist/playbooks/background-jobs.md +8 -16
  39. package/dist/playbooks/event-scheduling.md +13 -15
  40. package/dist/playbooks/memory-and-learning.md +29 -22
  41. package/dist/playbooks/outbound-media.md +15 -8
  42. package/dist/playbooks/runtime-orientation.md +40 -37
  43. package/dist/playbooks/task-driving.md +34 -38
  44. package/dist/playbooks/task-planning.md +18 -20
  45. package/dist/runtime/app-home.d.ts +6 -0
  46. package/dist/runtime/app-home.js +15 -6
  47. package/dist/runtime/bootstrap.d.ts +1 -1
  48. package/dist/runtime/bootstrap.js +57 -62
  49. package/dist/runtime/channel-context.d.ts +2 -1
  50. package/dist/runtime/channel-event.d.ts +0 -6
  51. package/dist/runtime/delivery.js +3 -3
  52. package/dist/runtime/dingtalk.d.ts +9 -1
  53. package/dist/runtime/dingtalk.js +27 -13
  54. package/dist/runtime/event-commands.d.ts +15 -0
  55. package/dist/runtime/event-commands.js +48 -40
  56. package/dist/runtime/project-commands.d.ts +16 -0
  57. package/dist/runtime/project-commands.js +13 -17
  58. package/dist/runtime/subagent-commands.d.ts +20 -0
  59. package/dist/runtime/subagent-commands.js +61 -58
  60. package/dist/runtime/task-commands.d.ts +38 -1
  61. package/dist/runtime/task-commands.js +135 -234
  62. package/dist/runtime/task-driver.d.ts +1 -3
  63. package/dist/runtime/task-driver.js +34 -40
  64. package/dist/runtime/task-migration.d.ts +7 -6
  65. package/dist/runtime/task-migration.js +85 -19
  66. package/dist/runtime/task-wake.d.ts +3 -5
  67. package/dist/runtime/task-wake.js +7 -15
  68. package/dist/security/path-guard.js +33 -2
  69. package/dist/security/types.d.ts +9 -0
  70. package/dist/subagents/discovery.d.ts +7 -2
  71. package/dist/subagents/discovery.js +31 -7
  72. package/dist/subagents/external/claude-code.js +42 -2
  73. package/dist/subagents/external/run.js +72 -2
  74. package/dist/subagents/runs.js +28 -3
  75. package/dist/subagents/tool.d.ts +11 -0
  76. package/dist/subagents/tool.js +89 -55
  77. package/dist/subagents/verification-outcome.js +17 -10
  78. package/dist/tasks/control.d.ts +18 -67
  79. package/dist/tasks/control.js +44 -176
  80. package/dist/tasks/ledger.d.ts +7 -13
  81. package/dist/tasks/ledger.js +13 -49
  82. package/dist/tasks/store.d.ts +15 -48
  83. package/dist/tasks/store.js +22 -154
  84. package/dist/tasks/transitions.d.ts +3 -4
  85. package/dist/tasks/transitions.js +8 -27
  86. package/dist/tasks/verification.d.ts +7 -5
  87. package/dist/tools/bash.d.ts +1 -1
  88. package/dist/tools/bash.js +77 -59
  89. package/dist/tools/edit.js +17 -4
  90. package/dist/tools/grep.js +3 -2
  91. package/dist/tools/index.d.ts +0 -2
  92. package/dist/tools/index.js +6 -1
  93. package/dist/tools/job.js +2 -1
  94. package/dist/tools/memory-manage.d.ts +1 -0
  95. package/dist/tools/memory-manage.js +54 -16
  96. package/dist/tools/read.js +21 -5
  97. package/dist/tools/registry.d.ts +0 -1
  98. package/dist/tools/registry.js +0 -1
  99. package/dist/tools/send-media.js +17 -6
  100. package/dist/tools/skill-manage.js +12 -11
  101. package/dist/tools/skill-security.js +1 -1
  102. package/dist/tools/subagent-manage.d.ts +8 -1
  103. package/dist/tools/subagent-manage.js +77 -7
  104. package/dist/tools/task-manage/lifecycle.js +19 -17
  105. package/dist/tools/task-manage/schema.d.ts +2 -6
  106. package/dist/tools/task-manage/schema.js +4 -17
  107. package/dist/tools/task-manage/shared.js +1 -6
  108. package/dist/tools/task-manage/types.d.ts +0 -3
  109. package/dist/tools/task-manage/verification.d.ts +9 -6
  110. package/dist/tools/task-manage/verification.js +19 -71
  111. package/dist/tools/task-manage.d.ts +1 -1
  112. package/dist/tools/task-manage.js +3 -5
  113. package/dist/tools/truncate.d.ts +8 -0
  114. package/dist/tools/truncate.js +8 -0
  115. package/dist/tools/web-fetch.js +9 -1
  116. package/dist/tools/write-content.js +11 -1
  117. package/dist/tui/app.js +1 -1
  118. package/dist/tui/commands.d.ts +1 -1
  119. package/dist/tui/commands.js +1 -1
  120. package/dist/tui/turn-controller.d.ts +1 -1
  121. package/dist/tui/turn-controller.js +14 -4
  122. package/dist/usage/ledger.d.ts +4 -0
  123. package/dist/usage/ledger.js +3 -0
  124. package/dist/usage/render.js +10 -8
  125. package/examples/sub-agents/README.md +2 -0
  126. package/package.json +3 -2
@@ -15,7 +15,6 @@ export declare class ChannelRunner implements AgentRunner {
15
15
  private readonly modelsConfigPath;
16
16
  private readonly onSessionEvent?;
17
17
  private readonly mediaSender?;
18
- private readonly dispatchVerification?;
19
18
  private readonly workspaceDir;
20
19
  /**
21
20
  * Frozen for the lifetime of this runner generation (spec 043, D4.2): AgentSession, the
@@ -114,6 +113,13 @@ export declare class ChannelRunner implements AgentRunner {
114
113
  * often the larger half), and the last turn's dynamic context.
115
114
  */
116
115
  renderContextReport(args?: string): string;
116
+ /**
117
+ * `/help` — the static per-command listing from `commands.ts`, plus (top-level only) the
118
+ * workspace skills and prompt templates this session can actually invoke via `/skill:name` and
119
+ * `/<template-name>`. Neither list is knowable to `renderBuiltInHelp` itself (it is a pure
120
+ * function with no session state), so the runner appends it here (review 2026-08-24 §1.9).
121
+ */
122
+ private renderHelpWithDiscovery;
117
123
  /** `/subagents list`'s role-directory health tail — whatever this runner already discovered. */
118
124
  getSubAgentDiscoverySnapshot(): SubAgentDiscoveryResult;
119
125
  /**
@@ -11,7 +11,7 @@ import { handleMemoryCommand } from "../memory/commands.js";
11
11
  import { getChannelMemoryPath } from "../memory/files.js";
12
12
  import { MemoryLifecycle } from "../memory/lifecycle.js";
13
13
  import { createMemoryActivityRecorder, } from "../memory/maintenance-state.js";
14
- import { MEMORY_RECALL_MAX_UNITS, recallRelevantMemory } from "../memory/recall.js";
14
+ import { findPreviousUserText, MEMORY_RECALL_MAX_UNITS, recallRelevantMemory } from "../memory/recall.js";
15
15
  import { buildTaskDigest, TASK_AGENDA_MAX_UNITS } from "../memory/task-digest.js";
16
16
  import { getApiKeyForModel } from "../models/api-keys.js";
17
17
  import { createModelRuntime, defaultModel, findExactModelReferenceMatch, formatModelReference, hasKnownModelPricing, resolveInitialModel, wrapModelRegistry, } from "../models/utils.js";
@@ -109,7 +109,6 @@ export class ChannelRunner {
109
109
  this.modelsConfigPath = paths.modelsConfigPath;
110
110
  this.onSessionEvent = paths.onSessionEvent;
111
111
  this.mediaSender = paths.mediaSender;
112
- this.dispatchVerification = paths.dispatchVerification;
113
112
  const executor = createExecutor();
114
113
  this.executor = executor;
115
114
  this.workspaceDir = resolve(dirname(channelDir));
@@ -299,6 +298,7 @@ export class ChannelRunner {
299
298
  if (recallSettings.enabled) {
300
299
  const recall = await recallRelevantMemory({
301
300
  query: clippedInput,
301
+ contextQuery: findPreviousUserText(this.session.messages),
302
302
  channelId: this.channelId,
303
303
  workspaceDir: this.workspaceDir,
304
304
  channelDir: this.channelDir,
@@ -589,26 +589,27 @@ export class ChannelRunner {
589
589
  try {
590
590
  switch (command.name) {
591
591
  case "help":
592
- await this.sendCommandReply(ctx, renderBuiltInHelp());
592
+ await this.sendCommandReply(ctx, this.renderHelpWithDiscovery(command.args), "help");
593
593
  return;
594
594
  case "context":
595
- await this.sendCommandReply(ctx, this.renderContextReport(command.args));
595
+ await this.sendCommandReply(ctx, this.renderContextReport(command.args), "context");
596
596
  return;
597
597
  case "stop":
598
- await this.sendCommandReply(ctx, "当前没有运行中的回合,`/stop` 只在回合进行中有意义。");
598
+ await this.sendCommandReply(ctx, "当前没有运行中的回合,`/stop` 只在回合进行中有意义。", "stop");
599
599
  return;
600
600
  case "steer":
601
601
  this.requireQueuedMessage(command.args, "steer");
602
- await this.sendCommandReply(ctx, "当前没有运行中的回合,直接发消息即可,不用 `/steer`。");
602
+ await this.sendCommandReply(ctx, "当前没有运行中的回合,直接发消息即可,不用 `/steer`。", "steer");
603
603
  return;
604
604
  case "followup":
605
605
  this.requireQueuedMessage(command.args, "followup");
606
- await this.sendCommandReply(ctx, "当前没有运行中的回合,直接发消息即可;`/followup` 用于回合进行中排队。");
606
+ await this.sendCommandReply(ctx, "当前没有运行中的回合,直接发消息即可;`/followup` 用于回合进行中排队。", "followup");
607
607
  return;
608
608
  default: {
609
- // The four session/query commands (events/tasks/status/usage) are
610
- // routed to their own handlers upstream and never reach here; the
611
- // narrowed parameter type makes that a compile-time guarantee.
609
+ // The stateless report commands (events/tasks/status/usage/subagents/project — see
610
+ // `BUILT_IN_COMMANDS`'s `runnerHandled: false` entries) are routed to their own
611
+ // handlers upstream and never reach here; the narrowed parameter type makes that a
612
+ // compile-time guarantee.
612
613
  const _exhaustive = command.name;
613
614
  throw new Error(`Unhandled built-in command: ${String(_exhaustive)}`);
614
615
  }
@@ -617,7 +618,7 @@ export class ChannelRunner {
617
618
  catch (err) {
618
619
  const errMsg = errorMessage(err);
619
620
  log.logWarning(`[${this.channelId}] Built-in command failed`, errMsg);
620
- await this.sendCommandReply(ctx, `命令执行失败:${errMsg}`);
621
+ await this.sendCommandReply(ctx, `命令执行失败:${errMsg}`, command.name);
621
622
  }
622
623
  }
623
624
  /**
@@ -632,7 +633,7 @@ export class ChannelRunner {
632
633
  if (!name) {
633
634
  return false;
634
635
  }
635
- if (isKnownCommandName(name)) {
636
+ if (isKnownCommandName(name, this.currentSkills.skills.map((skill) => skill.name.toLowerCase()))) {
636
637
  return true;
637
638
  }
638
639
  return this.session.promptTemplates.some((template) => template.name.toLowerCase() === name);
@@ -755,6 +756,30 @@ export class ChannelRunner {
755
756
  detail: args.trim().toLowerCase() === "detail",
756
757
  });
757
758
  }
759
+ /**
760
+ * `/help` — the static per-command listing from `commands.ts`, plus (top-level only) the
761
+ * workspace skills and prompt templates this session can actually invoke via `/skill:name` and
762
+ * `/<template-name>`. Neither list is knowable to `renderBuiltInHelp` itself (it is a pure
763
+ * function with no session state), so the runner appends it here (review 2026-08-24 §1.9).
764
+ */
765
+ renderHelpWithDiscovery(args) {
766
+ const help = renderBuiltInHelp(args);
767
+ if (args.trim()) {
768
+ return help;
769
+ }
770
+ const sections = [help];
771
+ if (this.currentSkills.skills.length > 0) {
772
+ sections.push(`**Workspace skills** · 用 \`/skill:<名称>\` 调用\n\n${this.currentSkills.skills
773
+ .map((skill) => `- \`/skill:${skill.name}\` — ${skill.description}`)
774
+ .join("\n")}`);
775
+ }
776
+ if (this.session.promptTemplates.length > 0) {
777
+ sections.push(`**Prompt templates**\n\n${this.session.promptTemplates
778
+ .map((template) => `- \`/${template.name}\``)
779
+ .join("\n")}`);
780
+ }
781
+ return sections.join("\n\n");
782
+ }
758
783
  /** `/subagents list`'s role-directory health tail — whatever this runner already discovered. */
759
784
  getSubAgentDiscoverySnapshot() {
760
785
  return this.subAgentDiscovery;
@@ -773,8 +798,11 @@ export class ChannelRunner {
773
798
  "</runtime_turn_context>",
774
799
  ].join("\n");
775
800
  }
776
- async sendCommandReply(ctx, text) {
777
- const delivered = await ctx.respondPlain(text);
801
+ async sendCommandReply(ctx, text, commandName) {
802
+ // Command echoes are ephemeral control-plane traffic, not conversation: keep them out of
803
+ // log.jsonl so they are never re-consumed as memory-extraction input (review 2026-08-24 §1.2).
804
+ const title = commandName ? `/${commandName}` : undefined;
805
+ const delivered = await ctx.respondPlain(text, false, title);
778
806
  if (!delivered) {
779
807
  await ctx.replaceMessage(text);
780
808
  await ctx.flush();
@@ -1261,7 +1289,6 @@ export class ChannelRunner {
1261
1289
  securityConfig: securityLoad.config,
1262
1290
  toolsConfig: toolsLoad.config,
1263
1291
  mediaSender: this.mediaSender,
1264
- dispatchVerification: this.dispatchVerification,
1265
1292
  });
1266
1293
  this.currentTools = tools;
1267
1294
  // Tool schemas are billed with the system prompt and, unlike it, nothing trims them.
@@ -9,19 +9,16 @@ function buildSessionText(stats, currentModel, thinkingLevel, lastResponseModel)
9
9
  ? ` (actual: \`${lastResponseModel}\`)`
10
10
  : "";
11
11
  const sessionFile = stats.sessionFile ? `\`${basename(stats.sessionFile)}\`` : "(none)";
12
- return `# Session
12
+ return `**会话**
13
13
 
14
- - Session ID: \`${stats.sessionId}\`
15
- - Session file: ${sessionFile}
16
- - Model: ${modelText}${actualText}
17
- - Thinking level: \`${thinkingLevel}\`
18
- - User messages: \`${stats.userMessages}\`
19
- - Assistant messages: \`${stats.assistantMessages}\`
20
- - Tool calls: \`${stats.toolCalls}\`
21
- - Tool results: \`${stats.toolResults}\`
22
- - Total messages: \`${stats.totalMessages}\`
23
- - Tokens: \`${stats.tokens.total}\` (input \`${stats.tokens.input}\`, output \`${stats.tokens.output}\`, cache read \`${stats.tokens.cacheRead}\`, cache write \`${stats.tokens.cacheWrite}\`)
24
- - Cost: \`$${stats.cost.toFixed(4)}\``;
14
+ - Session ID:\`${stats.sessionId}\`
15
+ - Session file:${sessionFile}
16
+ - 模型:${modelText}${actualText}
17
+ - Thinking level:\`${thinkingLevel}\`
18
+ - 消息:用户 \`${stats.userMessages}\` · 助手 \`${stats.assistantMessages}\` · 共 \`${stats.totalMessages}\`
19
+ - 工具调用:\`${stats.toolCalls}\` · 工具结果:\`${stats.toolResults}\`
20
+ - Tokens:\`${stats.tokens.total}\`(input \`${stats.tokens.input}\`,output \`${stats.tokens.output}\`,cache read \`${stats.tokens.cacheRead}\`,cache write \`${stats.tokens.cacheWrite}\`)
21
+ - Cost:\`$${stats.cost.toFixed(4)}\``;
25
22
  }
26
23
  async function runCompact(ctx, customInstructions) {
27
24
  return await new Promise((resolve, reject) => {
@@ -40,12 +37,12 @@ function sendCommandResult(sender, text) {
40
37
  });
41
38
  }
42
39
  function buildThinkingText(current, available) {
43
- return `# Thinking
40
+ return `**Thinking**
44
41
 
45
- Current level: \`${current}\`
46
- Available levels: ${available.map((level) => `\`${level}\``).join(", ")}
42
+ - 当前档位:\`${current}\`
43
+ - 可用档位:${available.map((level) => `\`${level}\``).join(", ")}
47
44
 
48
- Use \`/thinking <level>\` to set a level, or \`/thinking cycle\` to select the next supported level.`;
45
+ 用 \`/thinking <level>\` 设置档位,或 \`/thinking cycle\` 切到下一个支持的档位。`;
49
46
  }
50
47
  export function createCommandExtension(options) {
51
48
  return (pi) => {
@@ -98,13 +95,13 @@ export function createCommandExtension(options) {
98
95
  if (!args.trim()) {
99
96
  const current = currentModel ? `\`${formatModelReference(currentModel)}\`` : "(none)";
100
97
  const available = availableModels.length > 0 ? formatModelList(availableModels, currentModel) : "- (none)";
101
- sendCommandResult(pi, `# Model
98
+ sendCommandResult(pi, `**模型**
102
99
 
103
- Current model: ${current}
100
+ 当前模型:${current}
104
101
 
105
- Use \`/model <provider/modelId>\`, \`/model <modelId>\`, or any uniquely matching substring to switch.
102
+ 用 \`/model <provider/modelId>\`、\`/model <modelId>\` 或任意能唯一匹配的子串切换。
106
103
 
107
- Available models:
104
+ 可用模型:
108
105
  ${available}`);
109
106
  return;
110
107
  }
@@ -112,19 +109,19 @@ ${available}`);
112
109
  const available = availableModels.length > 0 ? formatModelList(availableModels, currentModel, 10) : "- (none)";
113
110
  if (match.match) {
114
111
  await options.switchModel(match.match);
115
- sendCommandResult(pi, `已切换模型到 \`${formatModelReference(match.match)}\`.`);
112
+ sendCommandResult(pi, `已切换模型到 \`${formatModelReference(match.match)}\``);
116
113
  return;
117
114
  }
118
115
  if (match.ambiguous) {
119
116
  sendCommandResult(pi, `未切换模型:\`${args.trim()}\` 匹配到多个模型。请提供更精确的 \`provider/modelId\`、\`modelId\` 或更长的片段。
120
117
 
121
- Available models:
118
+ 可用模型:
122
119
  ${available}`);
123
120
  return;
124
121
  }
125
122
  sendCommandResult(pi, `未找到模型 \`${args.trim()}\`。请使用精确的 \`provider/modelId\`、唯一的 \`modelId\`,或能唯一命中的片段字符串。
126
123
 
127
- Available models:
124
+ 可用模型:
128
125
  ${available}`);
129
126
  },
130
127
  });
@@ -136,7 +133,7 @@ ${available}`);
136
133
  withSession: async (nextCtx) => {
137
134
  sentFromReplacement = true;
138
135
  await options.refreshSessionResources();
139
- await sendCommandResult(nextCtx, `已开启新会话。\n\nSession ID: \`${nextCtx.sessionManager.getSessionId()}\``);
136
+ await sendCommandResult(nextCtx, `已开启新会话。\n\nSession ID:\`${nextCtx.sessionManager.getSessionId()}\``);
140
137
  },
141
138
  });
142
139
  if (result.cancelled) {
@@ -144,7 +141,7 @@ ${available}`);
144
141
  }
145
142
  else if (!sentFromReplacement) {
146
143
  await options.refreshSessionResources();
147
- sendCommandResult(pi, `已开启新会话。\n\nSession ID: \`${ctx.sessionManager.getSessionId()}\``);
144
+ sendCommandResult(pi, `已开启新会话。\n\nSession ID:\`${ctx.sessionManager.getSessionId()}\``);
148
145
  }
149
146
  },
150
147
  });
@@ -155,8 +152,8 @@ ${available}`);
155
152
  const result = await runCompact(ctx, customInstructions);
156
153
  sendCommandResult(pi, `已压缩当前会话上下文。
157
154
 
158
- - Tokens before compaction: \`${result.tokensBefore}\`
159
- - Summary:
155
+ - 压缩前 tokens:\`${result.tokensBefore}\`
156
+ - 摘要:
160
157
 
161
158
  \`\`\`text
162
159
  ${result.summary}
@@ -16,10 +16,25 @@ export interface BuiltInCommand {
16
16
  export type RunnerBuiltInCommand = BuiltInCommand & {
17
17
  name: RunnerBuiltInCommandName;
18
18
  };
19
+ /** One subcommand entry, as broadcast by `/help <name>` and consumed by `renderSubcommandUsage`. */
20
+ export interface CommandSubSpec {
21
+ name: string;
22
+ /** Argument syntax after the subcommand name, e.g. `<id>` or `<id> <wake|next|deadline> <值>`. */
23
+ args?: string;
24
+ description: string;
25
+ /** A concrete invocation; omitted only for the bare "no args" form. */
26
+ example?: string;
27
+ }
19
28
  /**
20
29
  * Single source of truth for a slash command's metadata. `HELP_TEXT`, the TUI
21
30
  * autocomplete list, the busy-time hint, and the known-command set are all
22
31
  * derived from these tables — do not hand-maintain those in parallel.
32
+ *
33
+ * `subcommands`, where present, is *also* the single source for that command's own `usage()`
34
+ * text (via `renderSubcommandUsage`) and for `/help <name>`'s detail view — see
35
+ * `test/commands-subcommands.test.ts`, which feeds every `subcommands[].example` back into the
36
+ * matching parser so the broadcast list and the parser can never drift apart again (review
37
+ * 2026-08-24 §1.1).
23
38
  */
24
39
  export interface CommandSpec {
25
40
  name: string;
@@ -27,10 +42,19 @@ export interface CommandSpec {
27
42
  argumentHint?: string;
28
43
  /** One-line description; used for `/help` and for editor autocomplete. */
29
44
  description: string;
30
- /** Concrete invocations shown under the command in `/help`. */
45
+ /** Concrete invocations shown under the command in `/help`; only used when `subcommands` is absent. */
31
46
  examples?: string[];
32
47
  /** Whether the command is accepted while a task is streaming. */
33
48
  availableWhileBusy?: boolean;
49
+ /**
50
+ * True for the built-ins `ChannelRunner.handleBuiltinCommand` handles directly (help/stop/
51
+ * steer/followup/context); false for the stateless runtime reports (events/tasks/status/
52
+ * usage/subagents/project) dispatched through `runRuntimeCommand`. Meaningful only within
53
+ * `BUILT_IN_COMMANDS`.
54
+ */
55
+ runnerHandled?: boolean;
56
+ /** Broadcast list of this command's subcommands, for commands with a `/<name> <action> ...` shape. */
57
+ subcommands?: CommandSubSpec[];
34
58
  }
35
59
  /**
36
60
  * Transport commands: handled directly by the runtime layer (never sent to the
@@ -46,19 +70,39 @@ export declare const SESSION_COMMANDS: readonly CommandSpec[];
46
70
  /** Look up the shared description for a session command (used by the SDK extension). */
47
71
  export declare function sessionCommandDescription(name: string): string;
48
72
  export declare function isBuiltInCommandName(name: string): name is BuiltInCommandName;
73
+ /** True for a session-layer command name (`/model`, `/compact`, …) — needs the idle session layer. */
74
+ export declare function isSessionCommandName(name: string): boolean;
49
75
  /** Narrow a parsed built-in to one `ChannelRunner.handleBuiltinCommand` accepts. */
50
76
  export declare function isRunnerBuiltInCommand(command: BuiltInCommand): command is RunnerBuiltInCommand;
51
77
  /** Comma-separated list of commands usable while a task is streaming (names only). */
52
78
  export declare function formatBusyCommandList(): string;
79
+ /**
80
+ * Renders a command's subcommand table as its `usage()` text — the single source `task-commands.ts`,
81
+ * `event-commands.ts`, `subagent-commands.ts`, `project-commands.ts`, and `memory/commands.ts` call
82
+ * on a parse error, replacing five hand-written `usage()` bodies (review 2026-08-24 §3.1).
83
+ */
84
+ export declare function renderSubcommandUsage(name: string): string;
85
+ /** `/help <name>`'s content, or `undefined` for an unknown command name. */
86
+ export declare function renderCommandHelp(name: string): string | undefined;
53
87
  /** Extract the lower-cased command name from a slash input, or `null` if not a slash command. */
54
88
  export declare function slashCommandName(text: string): string | null;
55
89
  /**
56
- * True if `text` is a slash command the runtime or session layer knows how to
57
- * handle: a built-in transport command, a session command, or a skill
58
- * invocation (`/skill:name`). Prompt-template names are resolved separately by
59
- * the runner, which has the session's live template list.
90
+ * True if `text` is a slash command the runtime or session layer knows how to handle: a built-in
91
+ * transport command, a session command, or a skill invocation (`/skill:name`) naming a skill
92
+ * actually present in `knownSkillNames`. Prompt-template names are resolved separately by the
93
+ * runner, which has the session's live template list.
94
+ *
95
+ * `knownSkillNames` used to be unchecked — any `/skill:<anything>` counted as known and got a full
96
+ * LLM turn, bypassing the "unknown command never reaches the model" guarantee this function exists
97
+ * to provide (review 2026-08-24 §1.9). Omitting `knownSkillNames` (no roster available) rejects
98
+ * every `skill:` name rather than trusting it.
60
99
  */
61
- export declare function isKnownCommandName(name: string): boolean;
100
+ export declare function isKnownCommandName(name: string, knownSkillNames?: Iterable<string>): boolean;
62
101
  export declare function formatUnknownCommandMessage(name: string): string;
63
102
  export declare function parseBuiltInCommand(text: string): BuiltInCommand | null;
64
- export declare function renderBuiltInHelp(): string;
103
+ /**
104
+ * `/help` (top-level command listing) or `/help <name>` (that command's subcommands/examples) —
105
+ * two-level help so the top level stays scannable instead of the ~40-line wall of every example
106
+ * (review 2026-08-24 §2.2.1). `args` is the raw text after `/help`.
107
+ */
108
+ export declare function renderBuiltInHelp(args?: string): string;