@crouton-kit/crouter 0.2.6 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/builtin-skills/skills/crouter-development/marketplaces/SKILL.md +9 -9
  2. package/dist/builtin-skills/skills/crouter-development/plugins/SKILL.md +19 -19
  3. package/dist/cli.js +42 -37
  4. package/dist/commands/__tests__/human.test.d.ts +1 -0
  5. package/dist/commands/__tests__/human.test.js +214 -0
  6. package/dist/commands/__tests__/skill.test.d.ts +1 -0
  7. package/dist/commands/__tests__/skill.test.js +287 -0
  8. package/dist/commands/debug.d.ts +3 -0
  9. package/dist/commands/debug.js +179 -0
  10. package/dist/commands/flow.d.ts +2 -0
  11. package/dist/commands/flow.js +24 -0
  12. package/dist/commands/human.d.ts +2 -0
  13. package/dist/commands/human.js +480 -0
  14. package/dist/commands/job.d.ts +2 -0
  15. package/dist/commands/job.js +669 -0
  16. package/dist/commands/pkg.d.ts +2 -0
  17. package/dist/commands/pkg.js +1021 -0
  18. package/dist/commands/plan.d.ts +4 -2
  19. package/dist/commands/plan.js +306 -22
  20. package/dist/commands/skill.d.ts +2 -2
  21. package/dist/commands/skill.js +607 -456
  22. package/dist/commands/spec.d.ts +3 -2
  23. package/dist/commands/spec.js +283 -10
  24. package/dist/commands/sys.d.ts +2 -0
  25. package/dist/commands/sys.js +712 -0
  26. package/dist/core/__tests__/argv-parser.test.d.ts +1 -0
  27. package/dist/core/__tests__/argv-parser.test.js +199 -0
  28. package/dist/core/__tests__/flow-leaves.test.d.ts +1 -0
  29. package/dist/core/__tests__/flow-leaves.test.js +248 -0
  30. package/dist/core/__tests__/job.test.d.ts +1 -0
  31. package/dist/core/__tests__/job.test.js +346 -0
  32. package/dist/core/__tests__/pkg.test.d.ts +1 -0
  33. package/dist/core/__tests__/pkg.test.js +218 -0
  34. package/dist/core/__tests__/sys.test.d.ts +1 -0
  35. package/dist/core/__tests__/sys.test.js +208 -0
  36. package/dist/core/artifact.d.ts +29 -18
  37. package/dist/core/artifact.js +78 -221
  38. package/dist/core/auto-update.js +11 -3
  39. package/dist/core/command.d.ts +36 -0
  40. package/dist/core/command.js +287 -0
  41. package/dist/core/errors.d.ts +3 -0
  42. package/dist/core/errors.js +5 -0
  43. package/dist/core/fs-utils.d.ts +1 -0
  44. package/dist/core/fs-utils.js +4 -0
  45. package/dist/core/help.d.ts +98 -0
  46. package/dist/core/help.js +163 -0
  47. package/dist/core/io.d.ts +29 -0
  48. package/dist/core/io.js +83 -0
  49. package/dist/core/jobs.d.ts +87 -0
  50. package/dist/core/jobs.js +353 -0
  51. package/dist/core/pagination.d.ts +33 -0
  52. package/dist/core/pagination.js +89 -0
  53. package/dist/core/self-update.d.ts +21 -0
  54. package/dist/{commands/update.js → core/self-update.js} +28 -63
  55. package/dist/core/spawn.d.ts +47 -65
  56. package/dist/core/spawn.js +78 -228
  57. package/dist/prompts/agent.d.ts +10 -5
  58. package/dist/prompts/agent.js +51 -74
  59. package/dist/prompts/debug.d.ts +8 -0
  60. package/dist/prompts/debug.js +37 -0
  61. package/dist/prompts/review.js +4 -11
  62. package/dist/prompts/skill.d.ts +0 -1
  63. package/dist/prompts/skill.js +95 -149
  64. package/package.json +4 -2
  65. package/dist/commands/agent.d.ts +0 -2
  66. package/dist/commands/agent.js +0 -265
  67. package/dist/commands/config.d.ts +0 -2
  68. package/dist/commands/config.js +0 -146
  69. package/dist/commands/doctor.d.ts +0 -2
  70. package/dist/commands/doctor.js +0 -268
  71. package/dist/commands/marketplace.d.ts +0 -2
  72. package/dist/commands/marketplace.js +0 -365
  73. package/dist/commands/plugin.d.ts +0 -2
  74. package/dist/commands/plugin.js +0 -367
  75. package/dist/commands/update.d.ts +0 -4
  76. package/dist/prompts/plan.d.ts +0 -1
  77. package/dist/prompts/plan.js +0 -175
  78. package/dist/prompts/spec.d.ts +0 -1
  79. package/dist/prompts/spec.js +0 -153
@@ -1,2 +1,4 @@
1
- import { Command } from 'commander';
2
- export declare function registerPlanCommand(program: Command): void;
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 flow plan new`:\n\n echo '<plan markdown>' | crtr flow 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 job start reviewer`.\nIf the user is ready to build, ask once whether to hand off; if yes, run:\n`crtr job start 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,25 +1,309 @@
1
- import { artifactPath, registerArtifactCommand } from '../core/artifact.js';
2
- import { planPrompt } from '../prompts/plan.js';
3
- import { planReviewPrompt } from '../prompts/review.js';
4
- export function registerPlanCommand(program) {
5
- registerArtifactCommand(program, {
6
- command: 'plan',
7
- kind: 'plans',
8
- promptFn: planPrompt,
9
- oversizeWarnLines: 250,
10
- reviewer: {
11
- extraSaveOptions: [
12
- {
13
- flag: '--spec <name>',
14
- description: 'name of the spec this plan implements (enables alignment check)',
15
- key: 'spec',
16
- },
17
- ],
18
- buildPrompt: (planPath, opts) => {
19
- const specName = opts.spec;
20
- const specPath = specName === undefined ? null : artifactPath('specs', specName);
21
- return planReviewPrompt(planPath, specPath);
22
- },
1
+ // `crtr flow 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 flow plan new\`:
78
+
79
+ echo '<plan markdown>' | crtr flow 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 job start reviewer\`.
103
+ If the user is ready to build, ask once whether to hand off; if yes, run:
104
+ \`crtr job start 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: '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 job start).',
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 job start reviewer --artifact-path ${path} --artifact-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: '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: '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: '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
+ ],
23
306
  },
307
+ children: [planNew, planShow, planList],
24
308
  });
25
309
  }
@@ -1,2 +1,2 @@
1
- import { Command } from 'commander';
2
- export declare function registerSkillCommands(program: Command): void;
1
+ import type { BranchDef } from '../core/command.js';
2
+ export declare function registerSkill(): BranchDef;