@crouton-kit/crouter 0.3.11 → 0.3.13

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 (182) hide show
  1. package/bin/crtrd +2 -0
  2. package/dist/builtin-personas/design/base.md +9 -0
  3. package/dist/builtin-personas/design/orchestrator.md +10 -0
  4. package/dist/builtin-personas/developer/base.md +9 -0
  5. package/dist/builtin-personas/developer/orchestrator.md +12 -0
  6. package/dist/builtin-personas/explore/base.md +9 -0
  7. package/dist/builtin-personas/explore/orchestrator.md +9 -0
  8. package/dist/builtin-personas/general/base.md +5 -0
  9. package/dist/builtin-personas/general/orchestrator.md +7 -0
  10. package/dist/builtin-personas/orchestration-kernel.md +71 -0
  11. package/dist/builtin-personas/plan/base.md +7 -0
  12. package/dist/builtin-personas/plan/orchestrator.md +12 -0
  13. package/dist/builtin-personas/review/base.md +7 -0
  14. package/dist/builtin-personas/review/orchestrator.md +9 -0
  15. package/dist/builtin-personas/runtime-base.md +39 -0
  16. package/dist/builtin-personas/spec/base.md +7 -0
  17. package/dist/builtin-personas/spec/orchestrator.md +10 -0
  18. package/dist/builtin-skills/skills/design/SKILL.md +51 -0
  19. package/dist/builtin-skills/skills/development/SKILL.md +109 -0
  20. package/dist/builtin-skills/skills/planning/SKILL.md +59 -0
  21. package/dist/builtin-skills/skills/spec/SKILL.md +83 -0
  22. package/dist/cli.js +14 -6
  23. package/dist/commands/{mode.d.ts → attention.d.ts} +1 -1
  24. package/dist/commands/attention.js +152 -0
  25. package/dist/commands/canvas.d.ts +2 -0
  26. package/dist/commands/canvas.js +35 -0
  27. package/dist/commands/daemon.d.ts +2 -0
  28. package/dist/commands/daemon.js +111 -0
  29. package/dist/commands/dashboard.d.ts +2 -0
  30. package/dist/commands/dashboard.js +65 -0
  31. package/dist/commands/human/prompts.d.ts +5 -0
  32. package/dist/commands/human/prompts.js +269 -0
  33. package/dist/commands/human/queue.d.ts +3 -0
  34. package/dist/commands/human/queue.js +133 -0
  35. package/dist/commands/human/shared.d.ts +43 -0
  36. package/dist/commands/human/shared.js +107 -0
  37. package/dist/commands/human.js +10 -454
  38. package/dist/commands/node.d.ts +2 -0
  39. package/dist/commands/node.js +407 -0
  40. package/dist/commands/pkg/market-inspect.d.ts +1 -0
  41. package/dist/commands/pkg/market-inspect.js +157 -0
  42. package/dist/commands/pkg/market-manage.d.ts +1 -0
  43. package/dist/commands/pkg/market-manage.js +316 -0
  44. package/dist/commands/pkg/market.d.ts +1 -0
  45. package/dist/commands/pkg/market.js +16 -0
  46. package/dist/commands/pkg/plugin-inspect.d.ts +1 -0
  47. package/dist/commands/pkg/plugin-inspect.js +142 -0
  48. package/dist/commands/pkg/plugin-manage.d.ts +1 -0
  49. package/dist/commands/pkg/plugin-manage.js +294 -0
  50. package/dist/commands/pkg/plugin.d.ts +1 -0
  51. package/dist/commands/pkg/plugin.js +16 -0
  52. package/dist/commands/pkg/shared.d.ts +5 -0
  53. package/dist/commands/pkg/shared.js +61 -0
  54. package/dist/commands/pkg.js +3 -1004
  55. package/dist/commands/push.d.ts +3 -0
  56. package/dist/commands/push.js +159 -0
  57. package/dist/commands/revive.d.ts +2 -0
  58. package/dist/commands/revive.js +64 -0
  59. package/dist/commands/skill/author.d.ts +3 -0
  60. package/dist/commands/skill/author.js +147 -0
  61. package/dist/commands/skill/find.d.ts +4 -0
  62. package/dist/commands/skill/find.js +254 -0
  63. package/dist/commands/skill/read.d.ts +1 -0
  64. package/dist/commands/skill/read.js +89 -0
  65. package/dist/commands/skill/shared.d.ts +19 -0
  66. package/dist/commands/skill/shared.js +207 -0
  67. package/dist/commands/skill/state.d.ts +3 -0
  68. package/dist/commands/skill/state.js +69 -0
  69. package/dist/commands/skill.js +6 -691
  70. package/dist/commands/sys/config.d.ts +1 -0
  71. package/dist/commands/sys/config.js +186 -0
  72. package/dist/commands/sys/doctor.d.ts +1 -0
  73. package/dist/commands/sys/doctor.js +369 -0
  74. package/dist/commands/sys/shared.d.ts +3 -0
  75. package/dist/commands/sys/shared.js +24 -0
  76. package/dist/commands/sys/update.d.ts +2 -0
  77. package/dist/commands/sys/update.js +114 -0
  78. package/dist/commands/sys.js +4 -694
  79. package/dist/core/__tests__/argv-parser.test.js +19 -1
  80. package/dist/core/__tests__/canvas-inbox-watcher.test.js +100 -0
  81. package/dist/core/__tests__/canvas.test.js +154 -0
  82. package/dist/core/__tests__/reset.test.js +105 -0
  83. package/dist/core/canvas/attention.d.ts +24 -0
  84. package/dist/core/canvas/attention.js +94 -0
  85. package/dist/core/canvas/canvas.d.ts +40 -0
  86. package/dist/core/canvas/canvas.js +210 -0
  87. package/dist/core/canvas/db.d.ts +7 -0
  88. package/dist/core/canvas/db.js +61 -0
  89. package/dist/core/canvas/index.d.ts +4 -0
  90. package/dist/core/canvas/index.js +6 -0
  91. package/dist/core/canvas/paths.d.ts +16 -0
  92. package/dist/core/canvas/paths.js +62 -0
  93. package/dist/core/canvas/render.d.ts +30 -0
  94. package/dist/core/canvas/render.js +186 -0
  95. package/dist/core/canvas/types.d.ts +87 -0
  96. package/dist/core/canvas/types.js +8 -0
  97. package/dist/core/command.d.ts +5 -0
  98. package/dist/core/command.js +35 -10
  99. package/dist/core/feed/feed.d.ts +43 -0
  100. package/dist/core/feed/feed.js +116 -0
  101. package/dist/core/feed/inbox.d.ts +50 -0
  102. package/dist/core/feed/inbox.js +124 -0
  103. package/dist/core/help.js +5 -3
  104. package/dist/core/io.d.ts +15 -1
  105. package/dist/core/io.js +56 -6
  106. package/dist/core/personas/index.d.ts +12 -0
  107. package/dist/core/personas/index.js +10 -0
  108. package/dist/core/personas/loader.d.ts +44 -0
  109. package/dist/core/personas/loader.js +157 -0
  110. package/dist/core/personas/resolve.d.ts +36 -0
  111. package/dist/core/personas/resolve.js +110 -0
  112. package/dist/core/render.d.ts +11 -0
  113. package/dist/core/render.js +126 -0
  114. package/dist/core/resolver.d.ts +10 -0
  115. package/dist/core/resolver.js +109 -1
  116. package/dist/core/runtime/front-door.d.ts +10 -0
  117. package/dist/core/runtime/front-door.js +97 -0
  118. package/dist/core/runtime/kickoff.d.ts +23 -0
  119. package/dist/core/runtime/kickoff.js +134 -0
  120. package/dist/core/runtime/launch.d.ts +34 -0
  121. package/dist/core/runtime/launch.js +85 -0
  122. package/dist/core/runtime/nodes.d.ts +38 -0
  123. package/dist/core/runtime/nodes.js +95 -0
  124. package/dist/core/runtime/presence.d.ts +55 -0
  125. package/dist/core/runtime/presence.js +198 -0
  126. package/dist/core/runtime/promote.d.ts +30 -0
  127. package/dist/core/runtime/promote.js +105 -0
  128. package/dist/core/runtime/reset.d.ts +13 -0
  129. package/dist/core/runtime/reset.js +97 -0
  130. package/dist/core/runtime/revive.d.ts +26 -0
  131. package/dist/core/runtime/revive.js +87 -0
  132. package/dist/core/runtime/roadmap.d.ts +12 -0
  133. package/dist/core/runtime/roadmap.js +52 -0
  134. package/dist/core/runtime/spawn.d.ts +31 -0
  135. package/dist/core/runtime/spawn.js +123 -0
  136. package/dist/core/runtime/stop-guard.d.ts +18 -0
  137. package/dist/core/runtime/stop-guard.js +33 -0
  138. package/dist/core/runtime/tmux.d.ts +107 -0
  139. package/dist/core/runtime/tmux.js +244 -0
  140. package/dist/core/spawn.d.ts +17 -197
  141. package/dist/core/spawn.js +16 -539
  142. package/dist/daemon/crtrd-cli.js +4 -0
  143. package/dist/daemon/crtrd.d.ts +20 -0
  144. package/dist/daemon/crtrd.js +200 -0
  145. package/dist/daemon/manage.d.ts +17 -0
  146. package/dist/daemon/manage.js +57 -0
  147. package/dist/pi-extensions/canvas-inbox-watcher.d.ts +16 -0
  148. package/dist/pi-extensions/canvas-inbox-watcher.js +229 -0
  149. package/dist/pi-extensions/canvas-nav.d.ts +32 -0
  150. package/dist/pi-extensions/canvas-nav.js +536 -0
  151. package/dist/pi-extensions/canvas-stophook.d.ts +17 -0
  152. package/dist/pi-extensions/canvas-stophook.js +396 -0
  153. package/package.json +6 -5
  154. package/dist/commands/agent.d.ts +0 -6
  155. package/dist/commands/agent.js +0 -585
  156. package/dist/commands/debug.d.ts +0 -3
  157. package/dist/commands/debug.js +0 -192
  158. package/dist/commands/job.d.ts +0 -11
  159. package/dist/commands/job.js +0 -384
  160. package/dist/commands/mode.js +0 -231
  161. package/dist/commands/plan.d.ts +0 -4
  162. package/dist/commands/plan.js +0 -322
  163. package/dist/commands/spec.d.ts +0 -3
  164. package/dist/commands/spec.js +0 -299
  165. package/dist/core/__tests__/flow-leaves.test.js +0 -248
  166. package/dist/core/__tests__/job.test.js +0 -310
  167. package/dist/core/__tests__/jobs.test.js +0 -98
  168. package/dist/core/__tests__/spawn.test.js +0 -138
  169. package/dist/core/__tests__/subagents.test.d.ts +0 -1
  170. package/dist/core/__tests__/subagents.test.js +0 -75
  171. package/dist/core/jobs.d.ts +0 -107
  172. package/dist/core/jobs.js +0 -565
  173. package/dist/core/subagents.d.ts +0 -18
  174. package/dist/core/subagents.js +0 -163
  175. package/dist/prompts/agent.d.ts +0 -27
  176. package/dist/prompts/agent.js +0 -184
  177. package/dist/prompts/debug.d.ts +0 -8
  178. package/dist/prompts/debug.js +0 -44
  179. /package/dist/core/__tests__/{flow-leaves.test.d.ts → canvas-inbox-watcher.test.d.ts} +0 -0
  180. /package/dist/core/__tests__/{job.test.d.ts → canvas.test.d.ts} +0 -0
  181. /package/dist/core/__tests__/{jobs.test.d.ts → reset.test.d.ts} +0 -0
  182. /package/dist/{core/__tests__/spawn.test.d.ts → daemon/crtrd-cli.d.ts} +0 -0
@@ -1,231 +0,0 @@
1
- // `crtr mode` umbrella — modes of operation: spec, plan, implement, review, debug.
2
- //
3
- // Collects the workflow-oriented commands:
4
- // spec / plan / debug — the artifact and root-cause workflows (from their
5
- // own files); planner, implementer, reviewer — the
6
- // handoff-spawn leaves previously under `agent new`.
7
- //
8
- // The spawn primitives (agent new / fork) and subagent management remain under
9
- // `crtr agent`. Results from spawned workers are collected at `crtr job`.
10
- import { defineBranch, defineLeaf } from '../core/command.js';
11
- import { InputError } from '../core/io.js';
12
- import { existsSync } from 'node:fs';
13
- import { createJob, appendEvent, recordJobPane } from '../core/jobs.js';
14
- import { spawnAndDetach, spawnAgent } from '../core/spawn.js';
15
- import { planHandoffPrompt, implementHandoffPrompt, reviewerHandoffPrompt, } from '../prompts/agent.js';
16
- import { assertTmux, resolveMaxPanes, followUpResult, } from './agent.js';
17
- import { registerSpec } from './spec.js';
18
- import { registerPlan } from './plan.js';
19
- import { registerDebug } from './debug.js';
20
- const DEFAULT_KILL_SECS = 2;
21
- // ---------------------------------------------------------------------------
22
- // mode planner
23
- // ---------------------------------------------------------------------------
24
- const newPlanner = defineLeaf({
25
- name: 'planner',
26
- help: {
27
- name: 'mode planner',
28
- summary: 'launch a planning agent for an approved spec; closes the originating pane after handoff',
29
- params: [
30
- { kind: 'positional', name: 'spec_path', type: 'path', required: true, constraint: 'Absolute path to the spec file.' },
31
- { kind: 'flag', name: 'cwd', type: 'path', required: false, constraint: 'Working directory. Defaults to process.cwd().' },
32
- { kind: 'flag', name: 'name', type: 'string', required: true, constraint: 'Display name passed to the agent CLI (`-n`); surfaces in pane title and resume picker.' },
33
- ],
34
- output: [
35
- { name: 'job_id', type: 'string', required: true, constraint: 'Use with `crtr job read *` and `crtr job cancel`.' },
36
- { name: 'follow_up', type: 'string', required: true, constraint: 'Your own next call — run it and report the worker\'s result; do not relay it to the user.' },
37
- ],
38
- outputKind: 'object',
39
- effects: [
40
- 'Spawns a planner agent in a sibling tmux pane.',
41
- 'Closes the originating pane after a short delay.',
42
- 'Creates a job entry and result sidecar.',
43
- ],
44
- },
45
- run: async (input) => {
46
- assertTmux();
47
- const specPath = input['spec_path'];
48
- const cwd = typeof input['cwd'] === 'string' ? input['cwd'] : process.cwd();
49
- const name = input['name'];
50
- if (!existsSync(specPath)) {
51
- throw new InputError({
52
- error: 'not_found',
53
- message: `spec not found: ${specPath}`,
54
- field: 'spec_path',
55
- next: 'Provide an absolute path to an existing spec file.',
56
- });
57
- }
58
- const { jobId } = createJob('planner', { cwd });
59
- const result = spawnAndDetach({
60
- prompt: planHandoffPrompt(specPath, jobId),
61
- cwd,
62
- jobId,
63
- placement: 'split-h',
64
- killAfterSeconds: DEFAULT_KILL_SECS,
65
- name,
66
- });
67
- if (result.status === 'not-in-tmux') {
68
- throw new InputError({ error: 'not_in_tmux', message: result.message, next: 'Run inside a tmux session.' });
69
- }
70
- if (result.status === 'spawn-failed') {
71
- throw new InputError({ error: 'spawn_failed', message: result.message, next: 'Check tmux is running and try again.' });
72
- }
73
- if (result.paneId !== undefined)
74
- recordJobPane(jobId, result.paneId);
75
- const plannerPaneLabel = result.paneId !== undefined ? result.paneId : 'unknown';
76
- appendEvent(jobId, { level: 'info', event: 'worker_started', message: `planner pane ${plannerPaneLabel} spawned` });
77
- return { job_id: jobId, follow_up: followUpResult(jobId) };
78
- },
79
- });
80
- // ---------------------------------------------------------------------------
81
- // mode implementer
82
- // ---------------------------------------------------------------------------
83
- const newImplementer = defineLeaf({
84
- name: 'implementer',
85
- help: {
86
- name: 'mode implementer',
87
- summary: 'launch an implementation agent for an approved plan; closes the originating pane after handoff',
88
- params: [
89
- { kind: 'positional', name: 'plan_path', type: 'path', required: true, constraint: 'Absolute path to the plan file.' },
90
- { kind: 'flag', name: 'cwd', type: 'path', required: false, constraint: 'Working directory. Defaults to process.cwd().' },
91
- { kind: 'flag', name: 'name', type: 'string', required: true, constraint: 'Display name passed to the agent CLI (`-n`); surfaces in pane title and resume picker.' },
92
- ],
93
- output: [
94
- { name: 'job_id', type: 'string', required: true, constraint: 'Use with `crtr job read *` and `crtr job cancel`.' },
95
- { name: 'follow_up', type: 'string', required: true, constraint: 'Your own next call — run it and report the worker\'s result; do not relay it to the user.' },
96
- ],
97
- outputKind: 'object',
98
- effects: [
99
- 'Spawns an implementer agent in a sibling tmux pane.',
100
- 'Closes the originating pane after a short delay.',
101
- 'Creates a job entry and result sidecar.',
102
- ],
103
- },
104
- run: async (input) => {
105
- assertTmux();
106
- const planPath = input['plan_path'];
107
- const cwd = typeof input['cwd'] === 'string' ? input['cwd'] : process.cwd();
108
- const name = input['name'];
109
- if (!existsSync(planPath)) {
110
- throw new InputError({
111
- error: 'not_found',
112
- message: `plan not found: ${planPath}`,
113
- field: 'plan_path',
114
- next: 'Provide an absolute path to an existing plan file.',
115
- });
116
- }
117
- const { jobId } = createJob('implementer', { cwd });
118
- const result = spawnAndDetach({
119
- prompt: implementHandoffPrompt(planPath, jobId),
120
- cwd,
121
- jobId,
122
- placement: 'split-h',
123
- killAfterSeconds: DEFAULT_KILL_SECS,
124
- name,
125
- });
126
- if (result.status === 'not-in-tmux') {
127
- throw new InputError({ error: 'not_in_tmux', message: result.message, next: 'Check tmux is running and try again.' });
128
- }
129
- if (result.status === 'spawn-failed') {
130
- throw new InputError({ error: 'spawn_failed', message: result.message, next: 'Check tmux is running and try again.' });
131
- }
132
- if (result.paneId !== undefined)
133
- recordJobPane(jobId, result.paneId);
134
- const implPaneLabel = result.paneId !== undefined ? result.paneId : 'unknown';
135
- appendEvent(jobId, { level: 'info', event: 'worker_started', message: `implementer pane ${implPaneLabel} spawned` });
136
- return { job_id: jobId, follow_up: followUpResult(jobId) };
137
- },
138
- });
139
- // ---------------------------------------------------------------------------
140
- // mode reviewer
141
- // ---------------------------------------------------------------------------
142
- const newReviewer = defineLeaf({
143
- name: 'reviewer',
144
- help: {
145
- name: 'mode reviewer',
146
- summary: 'launch a reviewer agent for a plan or spec artifact; the originating pane stays alive to collect the verdict',
147
- params: [
148
- { kind: 'positional', name: 'artifact_path', type: 'path', required: true, constraint: 'Absolute path to the artifact to review.' },
149
- { kind: 'flag', name: 'kind', type: 'enum', choices: ['plan', 'spec'], required: true, constraint: 'Artifact kind to review.' },
150
- { kind: 'flag', name: 'spec-path', type: 'path', required: false, constraint: 'Absolute path to the spec, for plan reviews. Omit for spec reviews.' },
151
- { kind: 'flag', name: 'cwd', type: 'path', required: false, constraint: 'Working directory. Defaults to process.cwd().' },
152
- { kind: 'flag', name: 'name', type: 'string', required: true, constraint: 'Display name passed to the agent CLI (`-n`); surfaces in pane title and resume picker.' },
153
- ],
154
- output: [
155
- { name: 'job_id', type: 'string', required: true, constraint: 'Use with `crtr job read *` and `crtr job cancel`.' },
156
- { name: 'follow_up', type: 'string', required: true, constraint: 'Your own next call — run it and report the worker\'s result; do not relay it to the user.' },
157
- ],
158
- outputKind: 'object',
159
- effects: [
160
- 'Spawns a reviewer agent in a sibling tmux pane.',
161
- 'The originating pane stays alive — wait on the result and act on the verdict.',
162
- 'Creates a job entry and result sidecar.',
163
- ],
164
- },
165
- run: async (input) => {
166
- assertTmux();
167
- const artifactPath = input['artifact_path'];
168
- const artifactKind = input['kind'];
169
- const specPath = typeof input['specPath'] === 'string' ? input['specPath'] : undefined;
170
- const cwd = typeof input['cwd'] === 'string' ? input['cwd'] : process.cwd();
171
- const name = input['name'];
172
- if (!existsSync(artifactPath)) {
173
- throw new InputError({
174
- error: 'not_found',
175
- message: `artifact not found: ${artifactPath}`,
176
- field: 'artifact_path',
177
- next: 'Provide an absolute path to an existing artifact file.',
178
- });
179
- }
180
- const { jobId } = createJob('reviewer', { cwd });
181
- // The reviewer is a subordinate the caller waits on (verdict → revise or
182
- // hand off), NOT a handoff successor. Use spawnAgent so the originating
183
- // pane (planner/orchestrator) stays alive to collect the result; do not
184
- // self-kill the caller the way planner/implementer handoffs do.
185
- const result = spawnAgent({
186
- prompt: reviewerHandoffPrompt(artifactPath, artifactKind, specPath !== undefined ? specPath : null, jobId),
187
- cwd,
188
- jobId,
189
- maxPanesPerWindow: resolveMaxPanes(),
190
- name,
191
- });
192
- if (result.status === 'not-in-tmux') {
193
- throw new InputError({ error: 'not_in_tmux', message: result.message, next: 'Run inside a tmux session.' });
194
- }
195
- if (result.status === 'spawn-failed') {
196
- throw new InputError({ error: 'spawn_failed', message: result.message, next: 'Check tmux is running and try again.' });
197
- }
198
- if (result.paneId !== undefined)
199
- recordJobPane(jobId, result.paneId);
200
- const reviewerPaneLabel = result.paneId !== undefined ? result.paneId : 'unknown';
201
- appendEvent(jobId, { level: 'info', event: 'worker_started', message: `reviewer pane ${reviewerPaneLabel} spawned` });
202
- return { job_id: jobId, follow_up: followUpResult(jobId) };
203
- },
204
- });
205
- // ---------------------------------------------------------------------------
206
- // mode (root umbrella)
207
- // ---------------------------------------------------------------------------
208
- export function registerMode() {
209
- return defineBranch({
210
- name: 'mode',
211
- rootEntry: {
212
- concept: 'modes of operation: spec → plan → implement → review → debug. Workflow commands for the full agentic development lifecycle',
213
- desc: 'spec, plan, implement, review, debug workflows',
214
- useWhen: 'running any structured workflow phase — writing a spec, decomposing into a plan, handing off to an implementer or reviewer, or root-causing a bug. These are the "what to do next" commands; `crtr agent new` is the raw spawn primitive.',
215
- },
216
- help: {
217
- name: 'mode',
218
- summary: 'modes of operation: spec, plan, implement, review, debug',
219
- model: 'Full agentic development lifecycle in one subtree. spec captures requirements; plan decomposes them into executable steps; planner/implementer/reviewer are the handoff-spawn leaves that delegate each phase to a fresh worker and return a job handle; debug root-causes failures with a reproduce-first workflow. Spawned workers register as jobs — monitor and collect at `crtr job`.',
220
- children: [
221
- { name: 'spec', desc: 'create, read, list specifications', useWhen: 'capturing requirements before planning' },
222
- { name: 'plan', desc: 'create, read, list plans', useWhen: 'shaping or inspecting work' },
223
- { name: 'debug', desc: 'reproduce-first root-cause workflow', useWhen: 'a bug, test failure, or unexpected behavior needs root-causing' },
224
- { name: 'planner', desc: 'planning agent for an approved spec', useWhen: 'handing off spec → plan decomposition to a fresh agent' },
225
- { name: 'implementer', desc: 'implementation agent for an approved plan', useWhen: 'handing off plan → code implementation to a fresh agent' },
226
- { name: 'reviewer', desc: 'review agent for a plan or spec artifact', useWhen: 'launching a review of a plan or spec artifact' },
227
- ],
228
- },
229
- children: [registerSpec(), registerPlan(), registerDebug(), newPlanner, newImplementer, newReviewer],
230
- });
231
- }
@@ -1,4 +0,0 @@
1
- export declare const PLAN_NEW_GUIDE = "## Planning workflow\n\nBuild and save an implementation plan: a map another agent can execute without\nre-discovering context. Work through these phases before saving.\n\n### Phase 1: Understand\n\nBuild a full picture of the request and the code. Search for reusable\nfunctions, patterns, and existing implementations before proposing new ones.\n\nLaunch up to 3 Explore subagents IN PARALLEL (single message, multiple tool\ncalls). Use 1 agent for isolated, small-scope tasks; use more when scope is\nuncertain or multiple subsystems are involved. Give each a distinct focus so\nthey don't duplicate work.\n\n### Phase 2: Design\n\nDesign the implementation from Phase 1 findings. Default to launching at least\n1 Plan agent to validate your understanding and surface alternatives. Skip only\nfor trivially small tasks (typo fixes, single-line renames). Use up to 3 agents\nfor large refactors or architectural changes.\n\nIn the Plan agent prompt: include file paths, code-path traces, requirements,\nand constraints from Phase 1. Request a detailed implementation plan.\n\n### Phase 3: Review findings\n\nRead the critical files identified by agents. Confirm the plan aligns with the\nuser's request. Use AskUserQuestion ONLY to clarify requirements or choose\nbetween approaches \u2014 never to ask \"is this okay?\" or \"should I proceed?\".\n\n### Phase 4: Compose the plan body\n\nQuality bar \u2014 every item below is cheap to satisfy and saves the implementer\nfrom re-deciding:\n\n- Every decision pinned. No \"if X then Y\" branches, no \"investigate whether\u2026\",\n no deferred choices. If you don't know, find out or ask now.\n- No timelines, no fallbacks, no magic values, no \"for now\" shortcuts.\n- Where the plan creates a new interface, schema, or contract, write the actual\n shape, not \"design a Foo type.\"\n\nRequired sections:\n\n # Plan: <one-line title>\n\n ## Context\n <why this change is being made \u2014 the problem, what prompted it, intended outcome>\n\n ## Recommended approach\n <your chosen approach only. Concise enough to scan, detailed enough to execute.>\n\n ## Files to modify / create\n - `path/to/file.ts` \u2014 <what changes>\n\n ## Existing utilities to reuse\n - `functionName` from `path/to/file.ts:LL` \u2014 <why it fits>\n\n ## Verification\n <how to test end-to-end \u2014 run the code, run tests, etc.>\n\nFor plans touching 4+ files across distinct concerns, structure parallel tasks:\n\n ## Tasks\n - **Task 1**: <name>\n - Files: `a.ts`, `b.ts` (disjoint from other tasks)\n - Depends on: (none) | Task N\n - Integration: <shared types/APIs with exact shape>\n - Changes: <bullets>\n\nSkip the Tasks structure for small plans; it's noise when there's no\nparallelism to unlock.\n\n### Phase 5: Save\n\nRun `crtr mode plan new`:\n\n echo '<plan markdown>' | crtr mode plan new <kebab-case-name> [--spec <spec-name>]\n\n- NAME: short kebab-case slug. Nested names become subdirectories\n (e.g. `auth/jwt-refresh`).\n- Pipe the full plan markdown composed in Phase 4 on stdin.\n- `--spec` (optional): name of the spec this plan implements. Enables alignment\n check by the reviewer.\n\nOutput: `{path, follow_up}`. The `follow_up` field names the exact next call\n\u2014 run it.\n\n### Phase 6: Oversize check\n\nIf `follow_up` contains an oversize advisory (plan exceeds 200 lines), split\ninto a short index plan plus nested part plans, each under the threshold.\nRe-save. The implementer executes parts one at a time; long monolithic plans\nare under-decomposed.\n\n### Phase 7: Done\n\nAfter the reviewer approves the plan, your turn ends. Do not summarize in chat.\nFor a human gate, optionally put the plan in front of a person with `crtr\nhuman review` (anchored comments) and gate the handoff with `crtr human\napprove`. This complements \u2014 it does not replace \u2014 `crtr mode reviewer`.\nIf the user is ready to build, ask once whether to hand off; if yes, run:\n`crtr mode implementer` with the plan path.";
2
- export declare const PLAN_SHOW_GUIDE = "";
3
- import type { BranchDef } from '../core/command.js';
4
- export declare function registerPlan(): BranchDef;
@@ -1,322 +0,0 @@
1
- // `crtr mode plan` subtree — plan new / show / list handlers.
2
- export const PLAN_NEW_GUIDE = `## Planning workflow
3
-
4
- Build and save an implementation plan: a map another agent can execute without
5
- re-discovering context. Work through these phases before saving.
6
-
7
- ### Phase 1: Understand
8
-
9
- Build a full picture of the request and the code. Search for reusable
10
- functions, patterns, and existing implementations before proposing new ones.
11
-
12
- Launch up to 3 Explore subagents IN PARALLEL (single message, multiple tool
13
- calls). Use 1 agent for isolated, small-scope tasks; use more when scope is
14
- uncertain or multiple subsystems are involved. Give each a distinct focus so
15
- they don't duplicate work.
16
-
17
- ### Phase 2: Design
18
-
19
- Design the implementation from Phase 1 findings. Default to launching at least
20
- 1 Plan agent to validate your understanding and surface alternatives. Skip only
21
- for trivially small tasks (typo fixes, single-line renames). Use up to 3 agents
22
- for large refactors or architectural changes.
23
-
24
- In the Plan agent prompt: include file paths, code-path traces, requirements,
25
- and constraints from Phase 1. Request a detailed implementation plan.
26
-
27
- ### Phase 3: Review findings
28
-
29
- Read the critical files identified by agents. Confirm the plan aligns with the
30
- user's request. Use AskUserQuestion ONLY to clarify requirements or choose
31
- between approaches — never to ask "is this okay?" or "should I proceed?".
32
-
33
- ### Phase 4: Compose the plan body
34
-
35
- Quality bar — every item below is cheap to satisfy and saves the implementer
36
- from re-deciding:
37
-
38
- - Every decision pinned. No "if X then Y" branches, no "investigate whether…",
39
- no deferred choices. If you don't know, find out or ask now.
40
- - No timelines, no fallbacks, no magic values, no "for now" shortcuts.
41
- - Where the plan creates a new interface, schema, or contract, write the actual
42
- shape, not "design a Foo type."
43
-
44
- Required sections:
45
-
46
- # Plan: <one-line title>
47
-
48
- ## Context
49
- <why this change is being made — the problem, what prompted it, intended outcome>
50
-
51
- ## Recommended approach
52
- <your chosen approach only. Concise enough to scan, detailed enough to execute.>
53
-
54
- ## Files to modify / create
55
- - \`path/to/file.ts\` — <what changes>
56
-
57
- ## Existing utilities to reuse
58
- - \`functionName\` from \`path/to/file.ts:LL\` — <why it fits>
59
-
60
- ## Verification
61
- <how to test end-to-end — run the code, run tests, etc.>
62
-
63
- For plans touching 4+ files across distinct concerns, structure parallel tasks:
64
-
65
- ## Tasks
66
- - **Task 1**: <name>
67
- - Files: \`a.ts\`, \`b.ts\` (disjoint from other tasks)
68
- - Depends on: (none) | Task N
69
- - Integration: <shared types/APIs with exact shape>
70
- - Changes: <bullets>
71
-
72
- Skip the Tasks structure for small plans; it's noise when there's no
73
- parallelism to unlock.
74
-
75
- ### Phase 5: Save
76
-
77
- Run \`crtr mode plan new\`:
78
-
79
- echo '<plan markdown>' | crtr mode plan new <kebab-case-name> [--spec <spec-name>]
80
-
81
- - NAME: short kebab-case slug. Nested names become subdirectories
82
- (e.g. \`auth/jwt-refresh\`).
83
- - Pipe the full plan markdown composed in Phase 4 on stdin.
84
- - \`--spec\` (optional): name of the spec this plan implements. Enables alignment
85
- check by the reviewer.
86
-
87
- Output: \`{path, follow_up}\`. The \`follow_up\` field names the exact next call
88
- — run it.
89
-
90
- ### Phase 6: Oversize check
91
-
92
- If \`follow_up\` contains an oversize advisory (plan exceeds 200 lines), split
93
- into a short index plan plus nested part plans, each under the threshold.
94
- Re-save. The implementer executes parts one at a time; long monolithic plans
95
- are under-decomposed.
96
-
97
- ### Phase 7: Done
98
-
99
- After the reviewer approves the plan, your turn ends. Do not summarize in chat.
100
- For a human gate, optionally put the plan in front of a person with \`crtr
101
- human review\` (anchored comments) and gate the handoff with \`crtr human
102
- approve\`. This complements — it does not replace — \`crtr mode reviewer\`.
103
- If the user is ready to build, ask once whether to hand off; if yes, run:
104
- \`crtr mode implementer\` with the plan path.`;
105
- export const PLAN_SHOW_GUIDE = '';
106
- import { defineBranch, defineLeaf } from '../core/command.js';
107
- import { saveArtifact, readArtifact, listArtifacts, OVERSIZE_WARN_LINES } from '../core/artifact.js';
108
- import { paginate } from '../core/pagination.js';
109
- export function registerPlan() {
110
- const planNew = defineLeaf({
111
- name: 'new',
112
- help: {
113
- name: 'mode plan new',
114
- summary: 'draft a plan from intent and optional spec alignment',
115
- guide: PLAN_NEW_GUIDE,
116
- params: [
117
- {
118
- kind: 'positional',
119
- name: 'name',
120
- type: 'string',
121
- required: true,
122
- constraint: 'Kebab-case slug used as the artifact filename. No spaces; use hyphens.',
123
- },
124
- {
125
- kind: 'stdin',
126
- name: 'body',
127
- required: true,
128
- constraint: "Full planning prose. Treated as the planner's north star; not parsed further.",
129
- },
130
- {
131
- kind: 'flag',
132
- name: 'spec',
133
- type: 'string',
134
- required: false,
135
- constraint: 'Name of the spec this plan implements. Enables alignment check on write. Must reference an existing spec artifact.',
136
- },
137
- ],
138
- output: [
139
- {
140
- name: 'path',
141
- type: 'string',
142
- required: true,
143
- constraint: 'Absolute path to the written plan artifact.',
144
- },
145
- {
146
- name: 'follow_up',
147
- type: 'string',
148
- required: true,
149
- constraint: 'Recommended next call (reviewer spawn via `crtr mode reviewer`).',
150
- },
151
- ],
152
- outputKind: 'object',
153
- effects: [
154
- 'Writes a plan artifact to the plans artifact directory.',
155
- 'If `--spec` is provided, records the spec alignment reference in the artifact frontmatter.',
156
- ],
157
- },
158
- run: async (input) => {
159
- const name = input['name'];
160
- const body = input['body'];
161
- const spec = input['spec'];
162
- const meta = {};
163
- if (spec !== undefined)
164
- meta['spec'] = spec;
165
- const { path, oversize, lineCount } = saveArtifact('plans', name, body, meta);
166
- let follow_up = `Review it: crtr mode reviewer ${path} --kind plan (returns {job_id}), then crtr job read result <job_id> --wait.`;
167
- follow_up +=
168
- ` Optional human gate (complements, does not replace the agent reviewer): crtr human review --file ${path} for anchored comments, then gate handoff with crtr human approve --title "Approve this plan?".`;
169
- if (oversize) {
170
- follow_up +=
171
- ` OVERSIZE ADVISORY: this plan is ${lineCount} lines (> ${OVERSIZE_WARN_LINES}). Split into a short index plan plus nested part plans before reviewing.`;
172
- }
173
- return { path, follow_up };
174
- },
175
- });
176
- const planShow = defineLeaf({
177
- name: 'show',
178
- help: {
179
- name: 'mode plan show',
180
- summary: 'read a plan artifact by name',
181
- params: [
182
- {
183
- kind: 'positional',
184
- name: 'name',
185
- type: 'string',
186
- required: true,
187
- constraint: 'Exact artifact name (no path extension). Use `plan list` to enumerate.',
188
- },
189
- ],
190
- output: [
191
- {
192
- name: 'name',
193
- type: 'string',
194
- required: true,
195
- constraint: 'Artifact name as stored.',
196
- },
197
- {
198
- name: 'path',
199
- type: 'string',
200
- required: true,
201
- constraint: 'Absolute path to the artifact file.',
202
- },
203
- {
204
- name: 'body',
205
- type: 'string',
206
- required: true,
207
- constraint: 'Full plan body text.',
208
- },
209
- {
210
- name: 'spec',
211
- type: 'string | null',
212
- required: true,
213
- constraint: 'Associated spec name, or null if none.',
214
- },
215
- ],
216
- outputKind: 'object',
217
- effects: ['None. Read-only.'],
218
- },
219
- run: async (input) => {
220
- const name = input['name'];
221
- const record = readArtifact('plans', name);
222
- return { name: record.name, path: record.path, body: record.body, spec: record.spec };
223
- },
224
- });
225
- const planList = defineLeaf({
226
- name: 'list',
227
- help: {
228
- name: 'mode plan list',
229
- summary: 'paginated list of plan artifacts, sorted ascending by name',
230
- params: [
231
- {
232
- kind: 'flag',
233
- name: 'scope',
234
- type: 'enum',
235
- choices: ['user', 'project', 'all'],
236
- required: false,
237
- constraint: 'Filter by scope. Omit to list all.',
238
- },
239
- {
240
- kind: 'flag',
241
- name: 'limit',
242
- type: 'int',
243
- required: false,
244
- default: 20,
245
- constraint: 'Default 20, max 100.',
246
- },
247
- {
248
- kind: 'flag',
249
- name: 'cursor',
250
- type: 'string',
251
- required: false,
252
- constraint: "Opaque token from a previous response's next_cursor. Omit on first call.",
253
- },
254
- ],
255
- output: [
256
- {
257
- name: 'items',
258
- type: 'object[]',
259
- required: true,
260
- constraint: 'Each: {name, path, updated_at}. Sorted ascending by name.',
261
- },
262
- {
263
- name: 'next_cursor',
264
- type: 'string | null',
265
- required: true,
266
- constraint: 'Pass on the next call to continue. null means no more items.',
267
- },
268
- {
269
- name: 'total',
270
- type: 'integer | null',
271
- required: true,
272
- constraint: 'Total plans matching the query. Exact when cheap; null on large/filtered sets — do not retry to force it.',
273
- },
274
- ],
275
- outputKind: 'object',
276
- effects: ['None. Read-only.'],
277
- },
278
- run: async (input) => {
279
- const limit = input['limit'] ?? 20;
280
- const cursor = input['cursor'];
281
- const all = listArtifacts('plans');
282
- const result = paginate(all, { limit, cursor }, {
283
- defaultLimit: 20,
284
- maxLimit: 100,
285
- keyOf: (item) => item.name,
286
- total: 'count',
287
- });
288
- return {
289
- items: result.items,
290
- next_cursor: result.next_cursor,
291
- total: result.total,
292
- };
293
- },
294
- });
295
- return defineBranch({
296
- name: 'plan',
297
- help: {
298
- name: 'mode plan',
299
- summary: 'create and read plan artifacts',
300
- model: 'Lifecycle: draft -> active -> handed-off.',
301
- children: [
302
- { name: 'new', desc: 'draft a plan from intent', useWhen: 'starting fresh work or decomposing a spec' },
303
- { name: 'show', desc: 'read a plan by name', useWhen: 'reasoning about an existing plan' },
304
- { name: 'list', desc: 'enumerate plans', useWhen: 'discovering what plans exist' },
305
- ],
306
- },
307
- slash: {
308
- name: 'plan',
309
- description: 'Plan mode — decompose intent (and an optional spec) into an executable plan.',
310
- argumentHint: '[what to plan]',
311
- body: `You are entering **plan mode**: decompose work into an executable plan.
312
-
313
- 1. Run \`crtr mode plan new -h\` to load the planning workflow and output schema.
314
- 2. Follow it to draft the plan, then save by piping the markdown to \`crtr mode plan new <name>\` on stdin (pass \`--spec <path>\` if an approved spec exists).
315
-
316
- The request: $ARGUMENTS
317
-
318
- If no request was given, ask the user what to plan before starting.`,
319
- },
320
- children: [planNew, planShow, planList],
321
- });
322
- }
@@ -1,3 +0,0 @@
1
- export declare const SPEC_NEW_GUIDE = "## Spec workflow\n\nBuild and save a design + requirements spec: a document describing what to\nbuild, the shape of the solution, and the behaviors it must satisfy. A spec is\nupstream of a plan \u2014 it captures decisions, not implementation steps.\n\nAnti-pattern: do not fish for clarifications upfront. Draft a concrete spec\nfirst based on your investigation, then iterate. A specific draft the user can\nreact to converges faster than a list of questions in a vacuum.\n\n### Phase 1: Shape\n\nBuild a comprehensive picture of the problem and the relevant code. Surface\nexisting patterns, constraints, and prior decisions.\n\nLaunch up to 3 Explore subagents IN PARALLEL (single message, multiple tool\ncalls). Use 1 agent for narrow, well-scoped problems; use more when the spec\ntouches several subsystems or you need to compare existing implementations.\nQuality over quantity \u2014 3 agents maximum.\n\nAfter exploration, draft a high-level design: the shape of the solution, new or\nchanged pieces, the boundaries.\n\n### Phase 2: Requirements\n\nTranslate the shape into concrete behavioral requirements. Each requirement\nmust be:\n\n- Testable \u2014 has a clear pass/fail condition.\n- Behavior-focused \u2014 describes what the system does, not how.\n- Scoped \u2014 covers one observable behavior.\n\nGroup requirements by capability. Plain English is fine. For conditional or\nstateful behaviors, EARS templates sharpen phrasing:\n`When <trigger>, the system shall <behavior>` or\n`If <condition>, then the system shall <response>`.\n\nFor larger / multi-component designs, walk the design end-to-end: at each step\nfrom trigger to final state, verify preconditions, state, failure handling, and\nhandoffs between components are specified. Skip this for small self-contained\nspecs.\n\n### Phase 3: Deepen\n\nRead the critical files identified during Phase 1. Reconcile requirements\nagainst the shape \u2014 if a requirement reveals a gap in the design, refine the\ndesign before saving.\n\nUse AskUserQuestion ONLY to clarify requirements or choose between approaches.\nNever use it to ask \"is this spec okay?\" or \"should I save?\".\n\n### Phase 4: Compose the spec body\n\nRequired sections:\n\n # Spec: <one-line title>\n\n ## Context\n <the problem this spec addresses, what motivates it, and the intended outcome.\n Include relevant constraints \u2014 user goals, stakeholders, deadlines.>\n\n ## Design\n <the shape of the solution. Components, data flow, key decisions and why they\n were chosen. Reference existing code with `file_path:line_number`.>\n\n ## Requirements\n <grouped behavioral requirements. Each one testable. Plain English is fine.>\n\n ### <Capability A>\n - <one observable behavior>\n\n ### <Capability B>\n - ...\n\n ## Out of scope\n <things explicitly NOT covered, so the next reader knows where the edges are.>\n\n ## Open questions\n <anything you could not resolve. Empty if all decisions are pinned.>\n\n### Phase 5: Save\n\nRun `crtr mode spec new`:\n\n echo '<spec markdown>' | crtr mode spec new <kebab-case-name>\n\n- NAME: short kebab-case slug. Nested names become subdirectories\n (e.g. `auth/refresh-tokens`).\n- Pipe the full spec markdown composed in Phase 4 on stdin.\n\nOutput: `{path, follow_up}`. The `follow_up` field names the exact next call\n\u2014 run it.\n\n### Phase 6: Done\n\nAfter the reviewer approves the spec, your turn ends. Do not summarize in chat.\nFor a human gate, optionally run `crtr human review` on the spec for anchored\ncomments and `crtr human approve` to gate the handoff \u2014 this complements, not\nreplaces, `crtr mode reviewer`.\nIf the user is ready to plan, ask once whether to hand off; if yes, follow the\n`follow_up` instructions from the save output.";
2
- import type { BranchDef } from '../core/command.js';
3
- export declare function registerSpec(): BranchDef;