@pugi/cli 0.1.0-beta.8 → 0.1.0-beta.87

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 (402) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/THIRD_PARTY_NOTICES.md +40 -0
  3. package/assets/pugi-prozr2-mascot.ansi +9 -0
  4. package/bin/run.js +33 -1
  5. package/dist/commands/deploy.js +40 -40
  6. package/dist/commands/flatten.js +191 -0
  7. package/dist/commands/jobs-watch.js +201 -0
  8. package/dist/commands/jobs.js +42 -27
  9. package/dist/commands/smoke.js +133 -0
  10. package/dist/core/agent-progress/cleanup.js +134 -0
  11. package/dist/core/agent-progress/schema.js +144 -0
  12. package/dist/core/agent-progress/writer.js +101 -0
  13. package/dist/core/agents/adaptive-router.js +330 -0
  14. package/dist/core/agents/query-decomposer.js +297 -0
  15. package/dist/core/agents/registry.js +2 -2
  16. package/dist/core/approvals/shortcut-resolver.js +98 -0
  17. package/dist/core/artifact-chain/dispatcher.js +148 -0
  18. package/dist/core/artifact-chain/exporter.js +164 -0
  19. package/dist/core/artifact-chain/state.js +243 -0
  20. package/dist/core/artifact-chain/steps.js +169 -0
  21. package/dist/core/ask-user/question.js +92 -0
  22. package/dist/core/audit/audit-trail.js +275 -0
  23. package/dist/core/auth/ensure-authenticated.js +129 -0
  24. package/dist/core/auth/env-provider.js +238 -0
  25. package/dist/core/auto-open-browser.js +4 -4
  26. package/dist/core/auto-update/channels.js +122 -0
  27. package/dist/core/auto-update/checker.js +241 -0
  28. package/dist/core/auto-update/state.js +235 -0
  29. package/dist/core/bare-mode/index.js +107 -0
  30. package/dist/core/bash/redirect.js +281 -0
  31. package/dist/core/bash-classifier.js +436 -40
  32. package/dist/core/checkpoint/resumer.js +149 -0
  33. package/dist/core/checkpoint/rewinder.js +291 -0
  34. package/dist/core/checkpoints/shadow-git.js +670 -0
  35. package/dist/core/citations/parser.js +109 -0
  36. package/dist/core/classifier/yolo-classifier.js +88 -0
  37. package/dist/core/codegraph/decision-store.js +248 -0
  38. package/dist/core/codegraph/detect-repo.js +459 -0
  39. package/dist/core/codegraph/install.js +134 -0
  40. package/dist/core/codegraph/offer-hook.js +220 -0
  41. package/dist/core/compact/auto-trigger.js +96 -0
  42. package/dist/core/compact/buffer-rewriter.js +115 -0
  43. package/dist/core/compact/summarizer.js +208 -0
  44. package/dist/core/compact/token-counter.js +108 -0
  45. package/dist/core/consensus/anvil-fanout.js +25 -25
  46. package/dist/core/consensus/diff-capture.js +121 -12
  47. package/dist/core/consensus/rubric.js +21 -21
  48. package/dist/core/context/builder.js +6 -6
  49. package/dist/core/context/compaction-events.js +8 -8
  50. package/dist/core/context/compaction.js +31 -31
  51. package/dist/core/context/index.js +15 -8
  52. package/dist/core/context/invariants.js +51 -51
  53. package/dist/core/context/markdown-loader.js +28 -10
  54. package/dist/core/context/markdown-traverse.js +255 -0
  55. package/dist/core/context/pugiignore.js +41 -41
  56. package/dist/core/context/repo-skeleton.js +37 -37
  57. package/dist/core/context/tool-eviction.js +55 -0
  58. package/dist/core/context/watcher.js +32 -32
  59. package/dist/core/context/working-set.js +23 -23
  60. package/dist/core/coordinator/agent-tools.js +77 -0
  61. package/dist/core/coordinator/agent-toolset.js +65 -0
  62. package/dist/core/coordinator/fsm.js +73 -0
  63. package/dist/core/coordinator/mode-fsm.js +70 -0
  64. package/dist/core/cost/rate-card.js +129 -0
  65. package/dist/core/cost/tracker.js +221 -0
  66. package/dist/core/credentials.js +12 -12
  67. package/dist/core/cron/scheduler.js +138 -0
  68. package/dist/core/denial-tracking/index.js +8 -0
  69. package/dist/core/denial-tracking/state.js +264 -0
  70. package/dist/core/diagnostics/probe-runner.js +93 -0
  71. package/dist/core/diagnostics/probes/api.js +46 -0
  72. package/dist/core/diagnostics/probes/auth.js +93 -0
  73. package/dist/core/diagnostics/probes/bare-mode.js +42 -0
  74. package/dist/core/diagnostics/probes/cli-version.js +127 -0
  75. package/dist/core/diagnostics/probes/config.js +72 -0
  76. package/dist/core/diagnostics/probes/denial-tracking.js +57 -0
  77. package/dist/core/diagnostics/probes/disk.js +81 -0
  78. package/dist/core/diagnostics/probes/engine-live.js +46 -0
  79. package/dist/core/diagnostics/probes/git.js +65 -0
  80. package/dist/core/diagnostics/probes/hooks.js +118 -0
  81. package/dist/core/diagnostics/probes/mcp.js +75 -0
  82. package/dist/core/diagnostics/probes/node.js +59 -0
  83. package/dist/core/diagnostics/probes/pnpm.js +36 -0
  84. package/dist/core/diagnostics/probes/pugi-md.js +89 -0
  85. package/dist/core/diagnostics/probes/sandbox.js +40 -0
  86. package/dist/core/diagnostics/probes/session.js +74 -0
  87. package/dist/core/diagnostics/probes/status-snapshot.js +488 -0
  88. package/dist/core/diagnostics/probes/workspace.js +63 -0
  89. package/dist/core/diagnostics/types.js +70 -0
  90. package/dist/core/dispatch/cache-cleanup.js +197 -0
  91. package/dist/core/dispatch/cache-handoff.js +295 -0
  92. package/dist/core/edits/apply-patch-layer-e.js +189 -0
  93. package/dist/core/edits/dispatch.js +293 -7
  94. package/dist/core/edits/format-matrix.js +26 -0
  95. package/dist/core/edits/fuzzy-ladder.js +650 -0
  96. package/dist/core/edits/index.js +3 -1
  97. package/dist/core/edits/journal.js +199 -0
  98. package/dist/core/edits/layer-a-apply.js +15 -15
  99. package/dist/core/edits/layer-a-fuzzy-apply.js +198 -0
  100. package/dist/core/edits/layer-b-apply.js +9 -9
  101. package/dist/core/edits/layer-c-apply.js +6 -6
  102. package/dist/core/edits/layer-d-ast.js +557 -14
  103. package/dist/core/edits/marker-parser.js +12 -12
  104. package/dist/core/edits/security-gate.js +27 -27
  105. package/dist/core/edits/verify-hook.js +273 -0
  106. package/dist/core/edits/worktree.js +322 -0
  107. package/dist/core/engine/anvil-client.js +140 -26
  108. package/dist/core/engine/auto-compact.js +179 -0
  109. package/dist/core/engine/budgets.js +186 -0
  110. package/dist/core/engine/context-prefix.js +155 -0
  111. package/dist/core/engine/index.js +1 -1
  112. package/dist/core/engine/intensity.js +158 -0
  113. package/dist/core/engine/intent.js +260 -0
  114. package/dist/core/engine/native-pugi.js +1295 -227
  115. package/dist/core/engine/prompts.js +134 -16
  116. package/dist/core/engine/strip-internal-fields.js +124 -0
  117. package/dist/core/engine/tool-bridge.js +1295 -59
  118. package/dist/core/evaluation/golden-dataset.js +293 -0
  119. package/dist/core/feedback/queue.js +177 -0
  120. package/dist/core/feedback/submitter.js +145 -0
  121. package/dist/core/file-cache.js +113 -1
  122. package/dist/core/flatten/flatten-repo.js +439 -0
  123. package/dist/core/format/osc8-link.js +28 -0
  124. package/dist/core/hook-chains.js +392 -0
  125. package/dist/core/hooks/citation-verify-hook.js +138 -0
  126. package/dist/core/hooks/citation-verify.js +112 -0
  127. package/dist/core/hooks/events.js +44 -0
  128. package/dist/core/hooks/index.js +15 -0
  129. package/dist/core/hooks/registry.js +213 -0
  130. package/dist/core/hooks/runner.js +236 -0
  131. package/dist/core/hooks/v2/event-emitter.js +115 -0
  132. package/dist/core/hooks/v2/executor.js +282 -0
  133. package/dist/core/hooks/v2/index.js +25 -0
  134. package/dist/core/hooks/v2/lifecycle.js +104 -0
  135. package/dist/core/hooks/v2/loader.js +216 -0
  136. package/dist/core/hooks/v2/matcher.js +125 -0
  137. package/dist/core/hooks/v2/trust.js +143 -0
  138. package/dist/core/hooks/v2/types.js +86 -0
  139. package/dist/core/image/renderer.js +71 -0
  140. package/dist/core/init/detector.js +582 -0
  141. package/dist/core/init/template-renderer.js +242 -0
  142. package/dist/core/jobs/registry.js +18 -18
  143. package/dist/core/ledger/results-tsv.js +142 -0
  144. package/dist/core/log-discipline/stdout-redirect.js +51 -0
  145. package/dist/core/lsp/cache.js +105 -0
  146. package/dist/core/lsp/client.js +776 -0
  147. package/dist/core/lsp/language-detect.js +66 -0
  148. package/dist/core/lsp/post-edit-diagnostics.js +171 -0
  149. package/dist/core/lsp/symbol-tools.js +372 -0
  150. package/dist/core/mcp/client.js +97 -28
  151. package/dist/core/mcp/http-server.js +553 -0
  152. package/dist/core/mcp/orchestrator-tools.js +662 -0
  153. package/dist/core/mcp/permission.js +190 -0
  154. package/dist/core/mcp/registry.js +39 -17
  155. package/dist/core/mcp/server-tools.js +219 -0
  156. package/dist/core/mcp/server.js +397 -0
  157. package/dist/core/mcp/trust.js +10 -10
  158. package/dist/core/memory/dual-write.js +416 -0
  159. package/dist/core/memory/passive-extract.js +130 -0
  160. package/dist/core/memory/phase1-kinds.js +20 -0
  161. package/dist/core/memory/secret-scanner.js +304 -0
  162. package/dist/core/memory-sync/queue.js +170 -0
  163. package/dist/core/metrics/extract.js +113 -0
  164. package/dist/core/modes/roo-modes.js +68 -0
  165. package/dist/core/onboarding/ensure-initialized.js +133 -0
  166. package/dist/core/onboarding/marker.js +111 -0
  167. package/dist/core/onboarding/telemetry-state.js +108 -0
  168. package/dist/core/output-style/presets.js +176 -0
  169. package/dist/core/output-style/state.js +185 -0
  170. package/dist/core/path-security.js +287 -5
  171. package/dist/core/permission.js +82 -22
  172. package/dist/core/permissions/auto-classifier.js +124 -0
  173. package/dist/core/permissions/bash-parser.js +371 -0
  174. package/dist/core/permissions/circuit-breaker.js +83 -0
  175. package/dist/core/permissions/constrained-edit.js +91 -0
  176. package/dist/core/permissions/gate.js +278 -0
  177. package/dist/core/permissions/index.js +20 -0
  178. package/dist/core/permissions/mode.js +174 -0
  179. package/dist/core/permissions/network-egress.js +137 -0
  180. package/dist/core/permissions/state.js +241 -0
  181. package/dist/core/permissions/tool-class.js +93 -0
  182. package/dist/core/plan-mode/ui-state.js +51 -0
  183. package/dist/core/plans/plan-artifact.js +721 -0
  184. package/dist/core/policy-limits/etag-store.js +122 -0
  185. package/dist/core/prd-check/parser.js +215 -0
  186. package/dist/core/prd-check/reporter.js +127 -0
  187. package/dist/core/prd-check/session-review.js +557 -0
  188. package/dist/core/prd-check/verifiers.js +223 -0
  189. package/dist/core/prompt-cache/client-cache.js +99 -0
  190. package/dist/core/prompts/assembly.js +29 -0
  191. package/dist/core/prompts/registry.js +364 -0
  192. package/dist/core/pugi-md/cc-compat-rules.js +735 -0
  193. package/dist/core/pugi-md/context-injector.js +76 -0
  194. package/dist/core/pugi-md/walk-up.js +207 -0
  195. package/dist/core/python/uv-installer.js +270 -0
  196. package/dist/core/python/uv-resolver.js +83 -0
  197. package/dist/core/rate-limit/narrator.js +146 -0
  198. package/dist/core/recipes/cli-types.js +20 -0
  199. package/dist/core/recipes/loader.js +103 -0
  200. package/dist/core/recipes/runner.js +345 -0
  201. package/dist/core/recipes/schema.js +587 -0
  202. package/dist/core/release-notes/parser.js +241 -0
  203. package/dist/core/release-notes/state.js +116 -0
  204. package/dist/core/repl/ask.js +37 -37
  205. package/dist/core/repl/cancellation.js +26 -26
  206. package/dist/core/repl/cap-warning.js +4 -4
  207. package/dist/core/repl/clipboard-read.js +11 -11
  208. package/dist/core/repl/dispatch-fsm.js +12 -12
  209. package/dist/core/repl/history-search.js +15 -15
  210. package/dist/core/repl/history.js +28 -18
  211. package/dist/core/repl/kill-ring.js +5 -5
  212. package/dist/core/repl/model-pricing.js +135 -0
  213. package/dist/core/repl/privacy-banner.js +22 -22
  214. package/dist/core/repl/session.js +2157 -214
  215. package/dist/core/repl/slash-commands.js +533 -40
  216. package/dist/core/repl/store/index.js +1 -1
  217. package/dist/core/repl/store/jsonl-log.js +22 -22
  218. package/dist/core/repl/store/lockfile.js +10 -10
  219. package/dist/core/repl/store/session-store.js +136 -107
  220. package/dist/core/repl/store/types.js +15 -15
  221. package/dist/core/repl/store/uuid-v7.js +12 -12
  222. package/dist/core/repl/workspace-context.js +43 -21
  223. package/dist/core/repo-map/build.js +125 -0
  224. package/dist/core/repo-map/cache.js +185 -0
  225. package/dist/core/repo-map/extractor.js +254 -0
  226. package/dist/core/repo-map/formatter.js +145 -0
  227. package/dist/core/repo-map/page-rank.js +105 -0
  228. package/dist/core/repo-map/scanner.js +211 -0
  229. package/dist/core/retry-budget/budget.js +284 -0
  230. package/dist/core/retry-budget/index.js +5 -0
  231. package/dist/core/retry-budget/retry-cap.js +74 -0
  232. package/dist/core/routing/lead-worker.js +43 -0
  233. package/dist/core/routing/pre-flight-estimator.js +108 -0
  234. package/dist/core/runs/run-tree.js +103 -0
  235. package/dist/core/security/injection-scanner.js +367 -0
  236. package/dist/core/security/output-filter.js +418 -0
  237. package/dist/core/session/env-file.js +105 -0
  238. package/dist/core/session/section-budgets.js +140 -0
  239. package/dist/core/session.js +92 -0
  240. package/dist/core/settings.js +286 -5
  241. package/dist/core/share/formatter.js +271 -0
  242. package/dist/core/share/redactor.js +221 -0
  243. package/dist/core/share/uploader.js +267 -0
  244. package/dist/core/skills/defaults.js +457 -0
  245. package/dist/core/skills/loader.js +22 -22
  246. package/dist/core/skills/sources.js +27 -27
  247. package/dist/core/smoke/headless-driver.js +174 -0
  248. package/dist/core/smoke/orchestrator.js +194 -0
  249. package/dist/core/smoke/runner.js +238 -0
  250. package/dist/core/smoke/scenario-parser.js +316 -0
  251. package/dist/core/statusline.js +99 -0
  252. package/dist/core/subagents/dispatcher-real.js +600 -0
  253. package/dist/core/subagents/dispatcher.js +132 -43
  254. package/dist/core/subagents/index.js +19 -6
  255. package/dist/core/subagents/isolation-matrix.js +213 -0
  256. package/dist/core/subagents/spawn.js +19 -4
  257. package/dist/core/telemetry/emitter.js +229 -0
  258. package/dist/core/telemetry/queue.js +251 -0
  259. package/dist/core/theme/context.js +91 -0
  260. package/dist/core/theme/presets.js +228 -0
  261. package/dist/core/theme/state.js +181 -0
  262. package/dist/core/todos/invariant.js +10 -0
  263. package/dist/core/todos/state.js +177 -0
  264. package/dist/core/tool-schema/compressor.js +89 -0
  265. package/dist/core/transport/version-interceptor.js +166 -0
  266. package/dist/core/trust.js +2 -2
  267. package/dist/core/tui/thinking-block.js +64 -0
  268. package/dist/core/vim/keymap.js +288 -0
  269. package/dist/core/vim/state.js +92 -0
  270. package/dist/core/watch-markers/marker-watcher.js +133 -0
  271. package/dist/core/worktree-manager/cleanup.js +123 -0
  272. package/dist/core/worktree-manager/manager.js +303 -0
  273. package/dist/index.js +28 -0
  274. package/dist/runtime/bootstrap.js +190 -0
  275. package/dist/runtime/cli.js +4151 -489
  276. package/dist/runtime/commands/agents.js +30 -30
  277. package/dist/runtime/commands/budget.js +5 -5
  278. package/dist/runtime/commands/cancel.js +231 -0
  279. package/dist/runtime/commands/chain.js +489 -0
  280. package/dist/runtime/commands/codegraph-status.js +227 -0
  281. package/dist/runtime/commands/compact.js +297 -0
  282. package/dist/runtime/commands/config.js +32 -32
  283. package/dist/runtime/commands/cost.js +199 -0
  284. package/dist/runtime/commands/delegate.js +244 -13
  285. package/dist/runtime/commands/dispatch.js +126 -0
  286. package/dist/runtime/commands/doctor.js +579 -0
  287. package/dist/runtime/commands/feedback.js +184 -0
  288. package/dist/runtime/commands/hooks.js +184 -0
  289. package/dist/runtime/commands/init.js +254 -0
  290. package/dist/runtime/commands/lsp.js +368 -0
  291. package/dist/runtime/commands/mcp.js +879 -0
  292. package/dist/runtime/commands/memory.js +582 -0
  293. package/dist/runtime/commands/model.js +237 -0
  294. package/dist/runtime/commands/onboarding.js +275 -0
  295. package/dist/runtime/commands/patch.js +128 -0
  296. package/dist/runtime/commands/permissions.js +112 -0
  297. package/dist/runtime/commands/plan.js +143 -0
  298. package/dist/runtime/commands/prd-check.js +285 -0
  299. package/dist/runtime/commands/privacy.js +17 -17
  300. package/dist/runtime/commands/recipe.js +325 -0
  301. package/dist/runtime/commands/redo-blob-store.js +92 -0
  302. package/dist/runtime/commands/redo.js +361 -0
  303. package/dist/runtime/commands/release-notes.js +229 -0
  304. package/dist/runtime/commands/repo-map.js +95 -0
  305. package/dist/runtime/commands/report.js +299 -0
  306. package/dist/runtime/commands/resume.js +118 -0
  307. package/dist/runtime/commands/review-consensus.js +68 -53
  308. package/dist/runtime/commands/rewind.js +333 -0
  309. package/dist/runtime/commands/roster.js +14 -14
  310. package/dist/runtime/commands/sessions.js +163 -0
  311. package/dist/runtime/commands/share.js +316 -0
  312. package/dist/runtime/commands/skills.js +31 -31
  313. package/dist/runtime/commands/status.js +186 -0
  314. package/dist/runtime/commands/stickers.js +82 -0
  315. package/dist/runtime/commands/style.js +194 -0
  316. package/dist/runtime/commands/theme.js +196 -0
  317. package/dist/runtime/commands/undo.js +54 -22
  318. package/dist/runtime/commands/update.js +289 -0
  319. package/dist/runtime/commands/vim.js +140 -0
  320. package/dist/runtime/commands/worktree.js +177 -0
  321. package/dist/runtime/commands/worktrees.js +155 -0
  322. package/dist/runtime/headless-repl.js +195 -0
  323. package/dist/runtime/headless.js +543 -0
  324. package/dist/runtime/load-hooks-or-exit.js +71 -0
  325. package/dist/runtime/plan-decompose.js +531 -0
  326. package/dist/runtime/update-check.js +28 -28
  327. package/dist/runtime/version.js +65 -0
  328. package/dist/skills/bundled/batch.js +617 -0
  329. package/dist/skills/bundled/index.js +45 -0
  330. package/dist/skills/bundled/loop.js +358 -0
  331. package/dist/skills/bundled/remember.js +383 -0
  332. package/dist/skills/bundled/simplify.js +289 -0
  333. package/dist/skills/bundled/skillify.js +373 -0
  334. package/dist/skills/bundled/stuck.js +558 -0
  335. package/dist/skills/bundled/verify.js +439 -0
  336. package/dist/testing/vcr.js +486 -0
  337. package/dist/tools/agent-tool.js +229 -0
  338. package/dist/tools/apply-patch.js +556 -0
  339. package/dist/tools/ask-user-question.js +222 -0
  340. package/dist/tools/ask-user.js +115 -0
  341. package/dist/tools/bash.js +623 -45
  342. package/dist/tools/brief.js +224 -0
  343. package/dist/tools/enter-worktree.js +250 -0
  344. package/dist/tools/exit-worktree.js +147 -0
  345. package/dist/tools/file-tools.js +161 -44
  346. package/dist/tools/lsp-tools.js +189 -0
  347. package/dist/tools/mcp-tool.js +260 -0
  348. package/dist/tools/multi-edit.js +361 -0
  349. package/dist/tools/powershell.js +268 -0
  350. package/dist/tools/registry.js +85 -0
  351. package/dist/tools/skill-tool.js +96 -0
  352. package/dist/tools/sleep.js +99 -0
  353. package/dist/tools/synthetic-output.js +133 -0
  354. package/dist/tools/tasks.js +208 -0
  355. package/dist/tools/todo-write.js +184 -0
  356. package/dist/tools/verify-plan-execution.js +295 -0
  357. package/dist/tools/web-fetch-injection-scanner.js +207 -0
  358. package/dist/tools/web-fetch.js +195 -10
  359. package/dist/tools/web-search.js +458 -0
  360. package/dist/tui/agent-progress-card.js +111 -0
  361. package/dist/tui/agent-tree.js +11 -1
  362. package/dist/tui/ask-modal.js +14 -14
  363. package/dist/tui/ask-user-question-prompt.js +203 -0
  364. package/dist/tui/compact-banner.js +81 -0
  365. package/dist/tui/conversation-pane.js +85 -11
  366. package/dist/tui/cost-table.js +111 -0
  367. package/dist/tui/device-flow.js +2 -2
  368. package/dist/tui/doctor-table.js +46 -0
  369. package/dist/tui/feedback-prompt.js +156 -0
  370. package/dist/tui/input-box.js +247 -32
  371. package/dist/tui/login-picker.js +3 -3
  372. package/dist/tui/markdown-render.js +6 -6
  373. package/dist/tui/onboarding-wizard.js +240 -0
  374. package/dist/tui/permissions-picker.js +86 -0
  375. package/dist/tui/render.js +35 -0
  376. package/dist/tui/repl-render.js +332 -54
  377. package/dist/tui/repl-splash-art.js +16 -16
  378. package/dist/tui/repl-splash-mascot.js +48 -24
  379. package/dist/tui/repl-splash.js +22 -22
  380. package/dist/tui/repl.js +124 -44
  381. package/dist/tui/slash-palette.js +6 -6
  382. package/dist/tui/splash.js +2 -2
  383. package/dist/tui/status-bar.js +109 -31
  384. package/dist/tui/status-table.js +7 -0
  385. package/dist/tui/stickers-art.js +136 -0
  386. package/dist/tui/style-table.js +28 -0
  387. package/dist/tui/theme-table.js +29 -0
  388. package/dist/tui/thinking-spinner.js +123 -0
  389. package/dist/tui/tool-stream-pane.js +53 -4
  390. package/dist/tui/update-banner.js +27 -2
  391. package/dist/tui/vim-input.js +267 -0
  392. package/dist/tui/welcome-banner.js +107 -0
  393. package/dist/tui/welcome-data.js +293 -0
  394. package/dist/tui/workspace-context.js +2 -2
  395. package/docs/examples/codegraph.mcp.json +10 -0
  396. package/package.json +23 -6
  397. package/test/scenarios/codegen-create-file.scenario.txt +13 -0
  398. package/test/scenarios/compact-force.scenario.txt +11 -0
  399. package/test/scenarios/identity.scenario.txt +11 -0
  400. package/test/scenarios/persona-handoff.scenario.txt +11 -0
  401. package/test/scenarios/walkback.scenario.txt +12 -0
  402. package/dist/core/engine/compaction-hook.js +0 -154
@@ -1,10 +1,10 @@
1
1
  /**
2
- * REPL slash command registry - Sprint α5.7, expanded α6.14 wave 2.
2
+ * REPL slash command registry - Sprint , expanded wave 2.
3
3
  *
4
4
  * The REPL input box surfaces a palette of slash commands the operator
5
5
  * can run from inside a persistent session. The wave-2 expansion (CEO
6
- * 2026-05-25) grows the surface from 6 to 20 commands so the `/help`
7
- * overlay matches the breadth Claude Code / Codex CLI operators expect.
6
+ *) grows the surface from 6 to 20 commands so the `/help`
7
+ * overlay matches the breadth the upstream tool / Codex CLI operators expect.
8
8
  *
9
9
  * The registry is pure: each `parseSlashCommand` call returns a
10
10
  * `SlashCommandResult` describing what the REPL session should do next.
@@ -15,20 +15,21 @@
15
15
  *
16
16
  * Tiering (per CEO wave-2 spec):
17
17
  *
18
- * Tier 1 - wired against real state (3 + existing 6 = 9 wired):
19
- * brief, agents, stop, help, quit, web, clear, version, jobs.
18
+ * Tier 1 - wired against real state (3 + existing 6 = 9 wired):
19
+ * brief, agents, stop, help, quit, web, clear, version, jobs.
20
20
  *
21
- * Tier 2 - best-effort wiring against existing surfaces (3):
22
- * diff, cost, status.
21
+ * Tier 2 - best-effort wiring against existing surfaces (3):
22
+ * diff, cost, status.
23
23
  *
24
- * Tier 3 - deterministic stubs ("coming in αX.Y") (8):
25
- * compact, resume, memory, config, privacy, budget, mcp, undo.
24
+ * Tier 3 - deterministic stubs ("coming in αX.Y") (8):
25
+ * compact, resume, memory, config, privacy, budget, mcp, undo.
26
26
  *
27
27
  * Brand voice (brandbook §08): power words `brief / dispatch / stop /
28
28
  * agents / quit / shipped`. Tagline `Brief it. It ships.` reserved for
29
29
  * `/quit` confirmation and `/help` footer - never inline.
30
30
  */
31
31
  import { listRoles } from '../agents/registry.js';
32
+ import { PERMISSION_MODES, parsePermissionMode, } from '../permissions/index.js';
32
33
  /**
33
34
  * Deterministic stub copy returned by the Tier 3 commands. Spec'd
34
35
  * inline so the unit test can pin the exact text without poking at
@@ -38,44 +39,76 @@ import { listRoles } from '../agents/registry.js';
38
39
  * silently appear here with empty placeholders.
39
40
  */
40
41
  export const SLASH_STUB_MESSAGES = Object.freeze({
41
- compact: 'Manual context compaction lands in α6.5b.',
42
- memory: 'Session memory editor lands in α6.5b.',
43
- config: 'Run `pugi config list` from a fresh shell for the full surface; in-REPL editor lands in α6.5.',
42
+ // /compact graduated from stub. The session
43
+ // module now owns the summariser round-trip + boundary marker append
44
+ // via `dispatchCompact`. Keep the type record exhaustive so a future
45
+ // stub addition cannot silently overlap the wired set.
46
+ memory: 'Session memory editor lands in .',
47
+ config: 'Run `pugi config list` from a fresh shell for the full surface; in-REPL editor lands in .',
44
48
  // alpha 6.13: /privacy graduated from stub; nothing reads this at
45
49
  // runtime but the type record stays exhaustive.
46
50
  privacy: '',
47
- budget: 'Run `pugi budget` from a fresh shell; in-REPL summary lands in α6.5.',
48
- mcp: 'Run `pugi config mcp list` from a fresh shell; in-REPL palette lands in α6.5.',
49
- undo: 'Run `pugi undo` from a fresh shell; in-REPL undo lands in α6.5.',
51
+ budget: 'Run `pugi budget` from a fresh shell; in-REPL summary lands in .',
52
+ // β4 Sl7 : /mcp graduated from stub to a real handler
53
+ // that forwards to `runMcpCommand`. Stub message removed from the
54
+ // exhaustive record so the type narrows correctly.
55
+ //
56
+ // final : /undo graduated from stub to a real
57
+ // handler that forwards to `runUndoCommand` (Aider walk-back —
58
+ // single-step revert of the last mutating tool result, with
59
+ // mtime+hash external-modification gate). Stub message removed.
50
60
  });
51
61
  export const SLASH_COMMAND_HELP = Object.freeze([
52
62
  // Workforce dispatch
53
63
  { name: 'brief', args: '<text>', gloss: 'Dispatch a brief to the workforce', group: 'Workforce dispatch' },
54
64
  { name: 'agents', args: '', gloss: 'List the on-watch agent roster', group: 'Workforce dispatch' },
65
+ { name: 'delegate', args: '<slug> <brief>', gloss: 'Dispatch a brief to one Tier 1 specialist ', group: 'Workforce dispatch' },
55
66
  { name: 'stop', args: '<persona>', gloss: 'Stop one agent by persona slug', group: 'Workforce dispatch' },
56
- { name: 'jobs', args: '', gloss: 'List background jobs', group: 'Workforce dispatch' },
57
- { name: 'ask', args: '<question>', gloss: 'Surface a yes/no modal locally (α6.3 forcing question)', group: 'Workforce dispatch' },
67
+ { name: 'jobs', args: '[--watch]', gloss: 'List background jobs + agent-progress; --watch mounts the live Ink TUI', group: 'Workforce dispatch' },
68
+ { name: 'cancel', args: '[<id> | all]', gloss: 'Halt active dispatch by id ', group: 'Workforce dispatch' },
69
+ { name: 'ask', args: '<question>', gloss: 'Surface a yes/no modal locally ', group: 'Workforce dispatch' },
58
70
  // Session
59
71
  { name: 'clear', args: '', gloss: 'Clear conversation pane', group: 'Session' },
60
72
  { name: 'resume', args: '', gloss: 'Pick a stored session to restore', group: 'Session' },
61
73
  { name: 'context', args: '', gloss: 'Show three-tier context summary (Tier 0 skeleton + Tier 1 working set)', group: 'Session' },
62
- { name: 'compact', args: '', gloss: 'Manual context compaction (α6.5b)', group: 'Session', stub: true },
63
- { name: 'memory', args: '', gloss: 'Session memory editor (α6.5b)', group: 'Session', stub: true },
74
+ { name: 'compact', args: '[--force]', gloss: 'Summarise older turns into a boundary marker . --force bypasses the noop-empty guard', group: 'Session' },
75
+ { name: 'rewind', args: '[N | --to <id>]', gloss: 'Roll the conversation back to a checkpoint ', group: 'Session' },
76
+ { name: 'memory', args: '', gloss: 'Session memory editor ', group: 'Session', stub: true },
77
+ { name: 'init', args: '', gloss: 'Scaffold .pugi/ in the current workspace (β1 Sl11)', group: 'Session' },
64
78
  // Pugi tools
65
79
  { name: 'web', args: '<url>', gloss: 'Fetch a URL into context', group: 'Pugi tools' },
66
80
  { name: 'diff', args: '', gloss: 'Show pending diff', group: 'Pugi tools' },
67
- { name: 'cost', args: '', gloss: 'Token usage + budget', group: 'Pugi tools' },
68
- { name: 'status', args: '', gloss: 'Backend + tenant status', group: 'Pugi tools' },
81
+ { name: 'cost', args: '', gloss: 'Session token + USD totals + last 5 turn breakdown', group: 'Pugi tools' },
82
+ { name: 'quota', args: '', gloss: 'Plan tier + monthly usage caps (sync / review / engine)', group: 'Pugi tools' },
83
+ { name: 'status', args: '', gloss: 'Session snapshot — id · cwd · mode · tokens · dispatches · auth', group: 'Pugi tools' },
69
84
  { name: 'consensus', args: '[ref]', gloss: '3-model consensus review (codex · claude · deepseek)', group: 'Pugi tools' },
85
+ { name: 'repo-map', args: '[refresh]', gloss: 'AST-light symbol summary of the workspace ', group: 'Pugi tools' },
86
+ { name: 'codegraph-status', args: '[--install|--reindex|--offer]', gloss: 'Codegraph MCP — install state, index age, symbol count, refresh CTA ', group: 'Pugi tools' },
70
87
  // Settings
71
88
  { name: 'config', args: '', gloss: 'Show config', group: 'Settings', stub: true },
72
89
  { name: 'privacy', args: '', gloss: 'Show privacy mode + contract', group: 'Settings' },
90
+ { name: 'permissions', args: '[mode] [--persist]', gloss: 'Show or flip permission mode (default / acceptEdits / plan / auto / dontAsk / bypassPermissions) (also: /plan, Shift+Tab cycle)', group: 'Settings' },
91
+ { name: 'plan', args: '[--back | --persist] [<prompt>]', gloss: 'Switch to plan mode (read-only). Same as /permissions plan, slicker UX.', group: 'Settings' },
92
+ { name: 'model', args: '[<slug>]', gloss: 'Show or select the active model. Bare /model lists tier-gated options', group: 'Settings' },
73
93
  { name: 'budget', args: '', gloss: 'Show usage budget', group: 'Settings', stub: true },
74
- { name: 'mcp', args: '', gloss: 'List MCP servers', group: 'Settings', stub: true },
75
- { name: 'undo', args: '', gloss: 'Undo last write', group: 'Settings', stub: true },
94
+ { name: 'mcp', args: '[sub]', gloss: 'MCP servers — list / trust / deny / install / serve / perms', group: 'Settings' },
95
+ { name: 'style', args: '[name] [--persist|--reset|--list]', gloss: 'Output-style preset (default / terse / explanatory / russian-formal / casual)', group: 'Settings' },
96
+ { name: 'theme', args: '[name] [--persist|--reset|--list]', gloss: 'TUI color palette (default / dark / light / colorblind)', group: 'Settings' },
97
+ { name: 'onboarding', args: '[--reset|--non-interactive]', gloss: 'First-run wizard — auth / mode / style / MCP / telemetry ', group: 'Settings' },
98
+ { name: 'vim', args: '[on|off|status]', gloss: 'Toggle vim-style modal editing in the input buffer ', group: 'Settings' },
99
+ { name: 'undo', args: '', gloss: 'Revert the last successful write / edit / multi_edit (Aider walk-back, )', group: 'Settings' },
100
+ { name: 'redo', args: '', gloss: 'Reapply the most recent /undo (LIFO stack, cleanup)', group: 'Settings' },
76
101
  // Meta
77
102
  { name: 'help', args: '', gloss: 'Show this help overlay', group: 'Meta' },
78
103
  { name: 'version', args: '', gloss: 'Show CLI version', group: 'Meta' },
104
+ { name: 'doctor', args: '', gloss: 'Environment health report (auth · API · Node · disk · MCP · …)', group: 'Meta' },
105
+ { name: 'prd-check', args: '<prd-path | --all | --session> [--json]', gloss: 'Verify PRD against code (default) or session work (--session, final)', group: 'Meta' },
106
+ { name: 'chain', args: '<new|status|next|show|export|list> [...args]', gloss: 'Artifact chain — PRD → ADR → mindmap → ER → sequence → tests → code ', group: 'Meta' },
107
+ { name: 'stickers', args: '', gloss: 'show Pugi brand stickers (gimmick)', group: 'Meta' },
108
+ { name: 'feedback', args: '', gloss: 'file a bug / feature / general comment without leaving the REPL', group: 'Meta' },
109
+ { name: 'share', args: '[--gist|--pugi] [--redact] [--preview]', gloss: 'Export session transcript to gist / pugi.io ', group: 'Meta' },
110
+ { name: 'release-notes', args: '[--reset]', gloss: 'Show changelog diff since last upgrade ', group: 'Meta' },
111
+ { name: 'update', args: '[--check|--apply [--yes]] [--channel <name>]', gloss: 'Check for / apply CLI update on stable / beta / canary ', group: 'Meta' },
79
112
  { name: 'quit', args: '', gloss: 'Exit the REPL', group: 'Meta' },
80
113
  ]);
81
114
  /**
@@ -92,20 +125,88 @@ export const SLASH_COMMAND_GROUPS = Object.freeze([
92
125
  /**
93
126
  * Parse one line of input from the REPL. The contract:
94
127
  *
95
- * - Empty / whitespace-only input returns `noop` with the original
96
- * text so the REPL can ignore it without printing anything.
97
- * - Input that does not start with `/` is treated as an implicit
98
- * `/brief <text>` - the most-common operator action.
99
- * - `/<name> [args]` resolves the name against the registry; unknown
100
- * names return `error` so the REPL can render a one-line tip
101
- * instead of silently dropping the input.
102
- * - Tier 3 stubs return `{ kind: 'stub', name, message }` so the REPL
103
- * can render the deterministic "coming in αX.Y" copy uniformly.
128
+ * - Empty / whitespace-only input returns `noop` with the original
129
+ * text so the REPL can ignore it without printing anything.
130
+ * - Input that does not start with `/` is treated as an implicit
131
+ * `/brief <text>` - the most-common operator action.
132
+ * - `/<name> [args]` resolves the name against the registry; unknown
133
+ * names return `error` so the REPL can render a one-line tip
134
+ * instead of silently dropping the input.
135
+ * - Tier 3 stubs return `{ kind: 'stub', name, message }` so the REPL
136
+ * can render the deterministic "coming in αX.Y" copy uniformly.
104
137
  *
105
138
  * The function never throws. Bad input maps to a structured result the
106
139
  * REPL can render - the alternative (throwing from a keystroke handler)
107
140
  * would unmount Ink mid-frame.
108
141
  */
142
+ /**
143
+ * Pugi backlog : parse the artifact-store subcommands
144
+ * of `/plan`. Kept module-local because the legacy mode-toggle parser
145
+ * already owns the `case 'plan':` branch — this helper is the
146
+ * dispatch tail when the first arg is `show / list / diff / prune`.
147
+ *
148
+ * Argument grammar:
149
+ * /plan show <planId>
150
+ * /plan list [<taskId>]
151
+ * /plan diff <planId> [<otherId>]
152
+ * /plan prune [<maxAgeDays>]
153
+ *
154
+ * Validation:
155
+ * - `planId` is required for show + diff; surfaced as a structured
156
+ * error verdict when missing so the REPL renders one line of
157
+ * guidance instead of falling through to the mode-toggle path.
158
+ * - `maxAgeDays` is parsed as a positive integer; missing leaves the
159
+ * core module's default in place. Negative / NaN inputs become
160
+ * errors so the operator does not silently wipe their plan store.
161
+ */
162
+ function parsePlanArtifactSubcommand(op, rest) {
163
+ if (op === 'show') {
164
+ const planId = rest[0];
165
+ if (!planId) {
166
+ return {
167
+ kind: 'error',
168
+ message: '/plan show <plan-id> — plan-id is required.',
169
+ };
170
+ }
171
+ return { kind: 'plan-artifact', sub: { op: 'show', planId } };
172
+ }
173
+ if (op === 'list') {
174
+ const taskId = rest[0];
175
+ return {
176
+ kind: 'plan-artifact',
177
+ sub: taskId ? { op: 'list', taskId } : { op: 'list' },
178
+ };
179
+ }
180
+ if (op === 'diff') {
181
+ const planId = rest[0];
182
+ if (!planId) {
183
+ return {
184
+ kind: 'error',
185
+ message: '/plan diff <plan-id> [<other-id>] — plan-id is required.',
186
+ };
187
+ }
188
+ const otherId = rest[1];
189
+ return {
190
+ kind: 'plan-artifact',
191
+ sub: otherId
192
+ ? { op: 'diff', planId, otherId }
193
+ : { op: 'diff', planId },
194
+ };
195
+ }
196
+ // prune
197
+ const raw = rest[0];
198
+ if (raw === undefined) {
199
+ return { kind: 'plan-artifact', sub: { op: 'prune' } };
200
+ }
201
+ const parsed = Number(raw);
202
+ if (!Number.isFinite(parsed) || parsed <= 0 || !Number.isInteger(parsed)) {
203
+ return {
204
+ kind: 'error',
205
+ message: `/plan prune [<days>] — expected positive integer, got '${raw}'.`,
206
+ };
207
+ }
208
+ return { kind: 'plan-artifact', sub: { op: 'prune', maxAgeDays: parsed } };
209
+ }
109
210
  export function parseSlashCommand(input) {
110
211
  const trimmed = input.trim();
111
212
  if (trimmed.length === 0) {
@@ -135,6 +236,38 @@ export function parseSlashCommand(input) {
135
236
  case 'roster': {
136
237
  return { kind: 'roster' };
137
238
  }
239
+ case 'delegate': {
240
+ // tail must start with the persona slug followed by the brief.
241
+ // Slug accepts only the closed-set lowercase ASCII pattern the
242
+ // server-side persona registry enforces; anything else surfaces
243
+ // as a usage error so the operator sees the typo before the
244
+ // round-trip.
245
+ const innerSpace = tail.indexOf(' ');
246
+ if (innerSpace === -1 || innerSpace === 0) {
247
+ return {
248
+ kind: 'error',
249
+ message: 'Usage: /delegate <slug> <one-sentence brief>',
250
+ };
251
+ }
252
+ const persona = tail.slice(0, innerSpace).toLowerCase();
253
+ const brief = tail.slice(innerSpace + 1).trim();
254
+ // Pattern intentionally mirrors server-side PUGI_DELEGATE_REGEX in
255
+ // sessions.controller.ts (^[a-z]+$). Keeping them lockstep means
256
+ // the REPL surfaces typos locally instead of round-tripping a 4xx.
257
+ if (!/^[a-z]+$/.test(persona)) {
258
+ return {
259
+ kind: 'error',
260
+ message: `/delegate slug must be lowercase ASCII (a-z only); got '${persona}'`,
261
+ };
262
+ }
263
+ if (brief.length === 0) {
264
+ return {
265
+ kind: 'error',
266
+ message: 'Usage: /delegate <slug> <one-sentence brief>',
267
+ };
268
+ }
269
+ return { kind: 'delegate', persona, brief };
270
+ }
138
271
  case 'stop':
139
272
  case 'kill': {
140
273
  if (tail.length === 0) {
@@ -170,7 +303,48 @@ export function parseSlashCommand(input) {
170
303
  return { kind: 'version' };
171
304
  }
172
305
  case 'jobs': {
173
- return { kind: 'jobs' };
306
+ // cleanup : tokenise the tail so the slash
307
+ // can route `--watch` к the live Ink TUI (same renderer as
308
+ // `pugi jobs --watch`). Unknown tokens fall through silently —
309
+ // the slash surface is intentionally minimal vs. the shell
310
+ // command (which supports list/status/tail/kill subcommands
311
+ // through `runJobsCommand`).
312
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
313
+ const watch = tokens.includes('--watch') || tokens.includes('-w') || tokens[0] === 'watch';
314
+ return { kind: 'jobs', watch };
315
+ }
316
+ case 'cancel':
317
+ case 'halt': {
318
+ // small-CC-parity batch :
319
+ //
320
+ // /cancel -> list active dispatches
321
+ // /cancel all -> halt every running dispatch
322
+ // /cancel <id> -> halt one (id may be a prefix; runner
323
+ // does startsWith lookup)
324
+ //
325
+ // The `halt` alias matches operator muscle memory from systemd /
326
+ // brand voice (`stop` is already taken by /stop <persona>; cancel
327
+ // is dispatch-id-keyed, stop is persona-keyed). Unknown extra
328
+ // tokens are tolerated — the runner reads only the first.
329
+ const trimmedTail = tail.trim();
330
+ if (trimmedTail.length === 0) {
331
+ return { kind: 'cancel', mode: 'list', dispatchId: '' };
332
+ }
333
+ const firstToken = trimmedTail.split(/\s+/)[0].toLowerCase();
334
+ if (firstToken === 'all' || firstToken === '*') {
335
+ return { kind: 'cancel', mode: 'all', dispatchId: 'all' };
336
+ }
337
+ // Defensive: dispatch ids are filename-safe per the
338
+ // `validateAgentProgress` agentId regex (`[a-zA-Z0-9_-]+`).
339
+ // Reject anything outside that range with a usage tip so the
340
+ // operator sees the typo before the round-trip.
341
+ if (!/^[A-Za-z0-9_-]+$/.test(firstToken)) {
342
+ return {
343
+ kind: 'error',
344
+ message: `/cancel: invalid dispatch id '${firstToken}'. Use letters / digits / '-' / '_' only.`,
345
+ };
346
+ }
347
+ return { kind: 'cancel', mode: 'one', dispatchId: firstToken };
174
348
  }
175
349
  case 'ask': {
176
350
  if (tail.length === 0) {
@@ -181,9 +355,19 @@ export function parseSlashCommand(input) {
181
355
  case 'diff': {
182
356
  return { kind: 'diff' };
183
357
  }
184
- case 'cost': {
358
+ case 'cost':
359
+ case 'usage': {
360
+ // L19 : `/usage` is an alias of `/cost` per the cost-
361
+ // command spec. The previous mapping routed `/usage` to the
362
+ // network-backed `/quota` surface, but operators trained on Claude
363
+ // Code expect `/usage` to surface the per-model token breakdown
364
+ // (same shape as `/cost`). `/quota` remains the canonical name
365
+ // for the tier + monthly-cap fetch.
185
366
  return { kind: 'cost' };
186
367
  }
368
+ case 'quota': {
369
+ return { kind: 'quota' };
370
+ }
187
371
  case 'status': {
188
372
  return { kind: 'status' };
189
373
  }
@@ -195,14 +379,14 @@ export function parseSlashCommand(input) {
195
379
  return { kind: 'consensus', ref: tail };
196
380
  }
197
381
  case 'resume': {
198
- // α6.4: wired against the local SessionStore. The REPL session
382
+ // : wired against the local SessionStore. The REPL session
199
383
  // owns the picker UI (Ink select over the 10 most recent rows)
200
384
  // so the slash-command layer stays UI-agnostic.
201
385
  return { kind: 'resume' };
202
386
  }
203
387
  case 'context':
204
388
  case 'ctx': {
205
- // α6.5: surface Tier 0 + Tier 1 status. The session module
389
+ // : surface Tier 0 + Tier 1 status. The session module
206
390
  // renders the summary as system lines so the operator can see
207
391
  // skeleton size + working-set utilisation at a glance.
208
392
  return { kind: 'context' };
@@ -215,12 +399,321 @@ export function parseSlashCommand(input) {
215
399
  // device flow + audit identity are wired correctly).
216
400
  return { kind: 'privacy' };
217
401
  }
218
- case 'compact':
402
+ case 'permissions':
403
+ case 'perms': {
404
+ // : `/permissions [mode] [--persist] [--confirm]`.
405
+ //
406
+ // Argument grammar (single line, no quoting):
407
+ // /permissions -> show + table
408
+ // /permissions default|acceptEdits|plan|auto|dontAsk -> flip mode
409
+ // /permissions bypassPermissions --confirm -> flip to
410
+ // bypassPermissions (refused
411
+ // без --confirm — safety)
412
+ // /permissions <mode> --persist -> also write to ~/.pugi/config.json
413
+ //
414
+ // aliases (`ask`, `allow`, `bypass`) are accepted и mapped to
415
+ // their canonical names via `parsePermissionMode`.
416
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
417
+ if (tokens.length === 0) {
418
+ return { kind: 'permissions', persist: false, confirmBypass: false };
419
+ }
420
+ const headRaw = tokens[0] ?? '';
421
+ const mode = parsePermissionMode(headRaw);
422
+ if (!mode) {
423
+ const modeList = [...PERMISSION_MODES].join('|');
424
+ return {
425
+ kind: 'error',
426
+ message: `Usage: /permissions [${modeList}] [--persist] [--confirm]; unknown mode '${headRaw}'`,
427
+ };
428
+ }
429
+ const flags = tokens.slice(1);
430
+ let persist = false;
431
+ let confirmBypass = false;
432
+ for (const flag of flags) {
433
+ if (flag === '--persist') {
434
+ persist = true;
435
+ }
436
+ else if (flag === '--confirm') {
437
+ confirmBypass = true;
438
+ }
439
+ else {
440
+ return {
441
+ kind: 'error',
442
+ message: `/permissions: unknown flag '${flag}' (allowed: --persist, --confirm)`,
443
+ };
444
+ }
445
+ }
446
+ return { kind: 'permissions', mode, persist, confirmBypass };
447
+ }
448
+ case 'init': {
449
+ // β1 Sl11: surface the init flow inside the REPL. Tail args
450
+ // are ignored — the init handler is parameterless today; `pugi
451
+ // init --no-defaults` is the CLI surface for skipping bundled
452
+ // skills.
453
+ return { kind: 'init' };
454
+ }
455
+ case 'plan': {
456
+ // `/plan [--back | --persist] [<prompt>]`.
457
+ //
458
+ // Argument grammar (single line, no quoting):
459
+ // /plan -> enter plan mode + banner
460
+ // /plan --back -> restore previous mode
461
+ // /plan --persist -> enter + write global config
462
+ // /plan <prompt...> -> enter + run one-shot engine
463
+ // /plan --auto-back <prompt...> -> enter + run + restore mode
464
+ //
465
+ // The parser pulls the flags off the head of the tail; whatever
466
+ // remains is the prompt. `--back` + a non-empty prompt and
467
+ // `--back` + `--auto-back` are both refused as `error` because
468
+ // they conflict at the verb level.
469
+ //
470
+ // Pugi backlog : when the FIRST token of the
471
+ // tail is one of the artifact subcommands (`show / list / diff /
472
+ // prune`), the parser hands off to the plan-as-FILE surface
473
+ // instead of the mode-toggle. This keeps both feature sets under
474
+ // one `/plan` namespace without overloading the verb table.
475
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
476
+ const head = tokens[0];
477
+ if (head === 'show' || head === 'list' || head === 'diff' || head === 'prune') {
478
+ return parsePlanArtifactSubcommand(head, tokens.slice(1));
479
+ }
480
+ let back = false;
481
+ let persist = false;
482
+ let autoBack = false;
483
+ const promptTokens = [];
484
+ for (const token of tokens) {
485
+ if (token === '--back') {
486
+ back = true;
487
+ }
488
+ else if (token === '--persist') {
489
+ persist = true;
490
+ }
491
+ else if (token === '--auto-back') {
492
+ autoBack = true;
493
+ }
494
+ else {
495
+ promptTokens.push(token);
496
+ }
497
+ }
498
+ const prompt = promptTokens.join(' ');
499
+ if (back && prompt.length > 0) {
500
+ return {
501
+ kind: 'error',
502
+ message: '/plan --back does not accept a prompt; revert first, then dispatch.',
503
+ };
504
+ }
505
+ if (back && autoBack) {
506
+ return {
507
+ kind: 'error',
508
+ message: '/plan --back and --auto-back cannot be combined.',
509
+ };
510
+ }
511
+ return { kind: 'plan', back, persist, autoBack, prompt };
512
+ }
513
+ case 'model': {
514
+ // BT 8 (the upstream tool parity): `/model [<slug>]`. Bare form
515
+ // prints the tier-gated model menu + current selection; with a
516
+ // slug it flips workspace selection. Slug grammar (loose): alnum
517
+ // + dash + dot + slash. Anything outside that range becomes an
518
+ // error verdict so the operator sees a clear message instead of a
519
+ // silent no-op. Whitespace inside the tail = multiple tokens = we
520
+ // take the first; the help gloss documents single-slug usage.
521
+ const trimmedTail = tail.trim();
522
+ if (trimmedTail.length === 0) {
523
+ return { kind: 'model', slug: undefined };
524
+ }
525
+ const firstToken = trimmedTail.split(/\s+/)[0] ?? '';
526
+ if (!/^[A-Za-z0-9][A-Za-z0-9._\-\/]{0,63}$/.test(firstToken)) {
527
+ return {
528
+ kind: 'error',
529
+ message: `/model: invalid slug '${firstToken}'. Use letters / digits / '-' / '.' / '/' only.`,
530
+ };
531
+ }
532
+ return { kind: 'model', slug: firstToken };
533
+ }
534
+ case 'mcp': {
535
+ // β4 Sl7: tokenize the tail. Empty tail -> `list` (matches CLI).
536
+ // Quoting / shell-escapes are NOT supported — the slash surface is
537
+ // intentionally simple; complex installs (env vars, multi-word
538
+ // args) go through `pugi mcp install` from a fresh shell.
539
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
540
+ return { kind: 'mcp', args: tokens };
541
+ }
542
+ case 'style':
543
+ case 'output-style': {
544
+ // forward the tokenized tail unchanged so
545
+ // the slash + top-level CLI surfaces share one parser inside
546
+ // `runStyleCommand`. Quoting / multi-word args are not used (the
547
+ // preset slugs are single tokens by contract).
548
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
549
+ return { kind: 'style', args: tokens };
550
+ }
551
+ case 'theme':
552
+ case 'palette':
553
+ case 'colors': {
554
+ // forward the tokenized tail unchanged so
555
+ // the slash + top-level `pugi theme` surfaces share one parser
556
+ // inside `runThemeCommand`. Aliases `/palette` and `/colors`
557
+ // exist because the leak-landscape audit found operators reach
558
+ // for either word interchangeably — same surface, same handler.
559
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
560
+ return { kind: 'theme', args: tokens };
561
+ }
562
+ case 'onboarding':
563
+ case 'onboard':
564
+ case 'setup': {
565
+ // forward the tokenized tail unchanged.
566
+ // The slash always routes through the non-interactive snapshot
567
+ // path (the REPL already owns the Ink tree); the runner picks
568
+ // it up from `ctx.interactive = false` in the session
569
+ // dispatcher.
570
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
571
+ return { kind: 'onboarding', args: tokens };
572
+ }
573
+ case 'vim': {
574
+ // forward the tokenized tail unchanged so
575
+ // the slash + top-level CLI surfaces share one parser inside
576
+ // `runVimCommand`. Subcommands are single tokens (on / off /
577
+ // status); a bare `/vim` toggles.
578
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
579
+ return { kind: 'vim', args: tokens };
580
+ }
581
+ case 'doctor':
582
+ case 'health': {
583
+ // L17 : run the probe sweep inline. Tail is ignored —
584
+ // the doctor command has no operator-facing arguments (every
585
+ // probe runs unconditionally; per-probe disable lives on the CLI
586
+ // shell surface, not the slash one).
587
+ return { kind: 'doctor' };
588
+ }
589
+ case 'prd-check':
590
+ case 'prdcheck': {
591
+ // : tokenise the tail and forward verbatim
592
+ // so the slash + shell surfaces share one `parsePrdCheckArgs`.
593
+ // Supports `<prd-path>`, `--all`, and `--json`.
594
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
595
+ return { kind: 'prd-check', args: tokens };
596
+ }
597
+ case 'chain': {
598
+ // : forward the tokenized argv to
599
+ // `runChainCommand` via the session module. Subcommands are
600
+ // single tokens (new / status / next / show / export / list);
601
+ // the `new` subcommand accepts the intent as the joined tail so
602
+ // operators can write `/chain new add auth flow` без quoting.
603
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
604
+ return { kind: 'chain', args: tokens };
605
+ }
606
+ case 'codegraph-status':
607
+ case 'codegraph': {
608
+ // BT 9 Phase 2 : forward the tokenized argv
609
+ // to `runCodegraphStatusCommand`. Flags handled by the runner:
610
+ // --install — merge codegraph into .pugi/mcp.json (accept)
611
+ // --reindex — stamp lastIndexedAt + hint runtime to refresh
612
+ // --offer — surface the install prompt even after a decline
613
+ // `/codegraph` is the short alias; same handler.
614
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
615
+ return { kind: 'codegraph-status', args: tokens };
616
+ }
617
+ case 'compact': {
618
+ // graduated from stub. The session module
619
+ // owns the summariser round-trip. BT 8: `--force` overrides
620
+ // the noop-empty guard. Unknown flags fall through silently per
621
+ // the existing tail-tolerance behaviour (operators wanting a
622
+ // per-session compact run `pugi compact --session <id>` from a
623
+ // fresh shell).
624
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
625
+ const force = tokens.some((t) => t === '--force' || t === '-f');
626
+ return { kind: 'compact', force };
627
+ }
628
+ case 'rewind': {
629
+ // `/rewind [N | --to <id>]`. Tokenize the
630
+ // tail unchanged so `runRewindCommand` (in `runtime/commands/
631
+ // rewind.ts`) handles every mode (picker / turns / to-event)
632
+ // through one parser. The slash + top-level CLI surfaces stay
633
+ // single-sourced — same separation as `/compact`.
634
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
635
+ return { kind: 'rewind', args: tokens };
636
+ }
637
+ case 'stickers': {
638
+ // brand-personality gimmick. Tail args
639
+ // are ignored — the surface is intentionally parameterless. The
640
+ // session module delegates to the shared `runStickersCommand`
641
+ // so the slash + top-level paths stay single-sourced.
642
+ return { kind: 'stickers' };
643
+ }
644
+ case 'feedback': {
645
+ // in-CLI feedback collector. The wizard
646
+ // collects category/rating/comment/context/confirm interactively
647
+ // so the slash surface is parameterless. Tail args are reserved
648
+ // for a future `--message=...` quick-path; today they are
649
+ // accepted but ignored so the operator-level UX matches
650
+ // the upstream tool's `/feedback`.
651
+ return { kind: 'feedback' };
652
+ }
653
+ case 'share': {
654
+ // forward the tokenized arg list verbatim
655
+ // so the session module (which owns the network + readline
656
+ // affordances) can hand them to runShareCommand. Defaults: no
657
+ // tokens means "auto-pick target + prompt for confirmation".
658
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
659
+ return { kind: 'share', args: tokens };
660
+ }
661
+ case 'repo-map':
662
+ case 'repomap': {
663
+ // build + show the AST-light symbol
664
+ // summary. Accepts `refresh` as a positional или `--refresh`
665
+ // flag so muscle memory from both shells lands the same way.
666
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
667
+ const refresh = tokens.includes('--refresh') || tokens.includes('refresh') || tokens.includes('-r');
668
+ return { kind: 'repo-map', refresh };
669
+ }
670
+ case 'release-notes':
671
+ case 'releasenotes':
672
+ case 'changelog': {
673
+ // changelog diff between last-seen +
674
+ // installed CLI version. Tail args are tokenized so `--reset`
675
+ // can flip the marker-clear bit; no other flags are honoured —
676
+ // the surface mirrors the CLI top-level's intentional minimalism.
677
+ // `changelog` alias matches operator muscle memory from npm /
678
+ // cargo / brew, all of which ship `changelog` subcommands.
679
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
680
+ const reset = tokens.includes('--reset') || tokens.includes('-r');
681
+ return { kind: 'release-notes', reset };
682
+ }
683
+ case 'update': {
684
+ // forward the tokenized argv to the
685
+ // session module which delegates to `runUpdateCommand`. The
686
+ // dispatcher owns argv validation (unknown channel / flag) so
687
+ // the slash parser stays as thin as the rest of the surface.
688
+ // The slash form does NOT support `--apply` because spawning
689
+ // `npm install -g` from inside a running REPL session would
690
+ // corrupt the operator's running binary — the dispatcher treats
691
+ // `--apply` from a slash as a non-interactive offer (probe +
692
+ // install command, no shell-out). Top-level `pugi update --apply`
693
+ // remains the recommended path for the actual install.
694
+ const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
695
+ return { kind: 'update', args: tokens };
696
+ }
697
+ case 'undo': {
698
+ // final : graduated from stub. Tail args are
699
+ // ignored — `runUndoCommand` is parameterless (single-step revert
700
+ // of the most recent successful mutating tool result). Multiple
701
+ // undos = stack of single-step undos. `/redo` is the counterpart
702
+ // — operators ping-pong через undo/redo on the
703
+ // event-log stack without re-running the underlying tool.
704
+ return { kind: 'undo' };
705
+ }
706
+ case 'redo': {
707
+ // cleanup : counterpart к /undo. Tail args
708
+ // are ignored — `runRedoCommand` is parameterless. Each /redo
709
+ // pops one entry from the LIFO undo stack (the runner tracks
710
+ // which undos have already been consumed by previous redos so
711
+ // double-/redo is a noop, not a double-write).
712
+ return { kind: 'redo' };
713
+ }
219
714
  case 'memory':
220
715
  case 'config':
221
- case 'budget':
222
- case 'mcp':
223
- case 'undo': {
716
+ case 'budget': {
224
717
  const stubName = name;
225
718
  return {
226
719
  kind: 'stub',