@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,13 +1,18 @@
1
1
  /**
2
2
  * First user message for a spec → plan handoff.
3
- * Bundles the full planning workflow with the spec to plan.
3
+ *
4
+ * Thin prompt: the worker discovers the full planning workflow by running
5
+ * `crtr flow plan new -h`, then saves the plan via `crtr flow plan new`. This avoids
6
+ * embedding the planPrompt() blob here and keeps the prompt in sync with the
7
+ * live CLI without any coupling.
4
8
  */
5
- export declare function planHandoffPrompt(specPath: string, plansDir: string): string;
9
+ export declare function planHandoffPrompt(specPath: string, jobId: string): string;
6
10
  /**
7
11
  * First user message for a plan → implementation handoff.
8
12
  */
9
- export declare function implementHandoffPrompt(planPath: string): string;
13
+ export declare function implementHandoffPrompt(planPath: string, jobId: string): string;
10
14
  /**
11
- * First user message for a handoff to code review of the working tree.
15
+ * First user message for a reviewer agent.
16
+ * The reviewer submits via `crtr job submit` rather than `crtr agent submit`.
12
17
  */
13
- export declare function reviewHandoffPrompt(): string;
18
+ export declare function reviewerHandoffPrompt(artifactPath: string, artifactKind: 'plan' | 'spec', specPath: string | null, jobId: string): string;
@@ -1,30 +1,40 @@
1
- import { planPrompt } from './plan.js';
1
+ import { planReviewPrompt, specReviewPrompt } from './review.js';
2
2
  /**
3
3
  * First user message for a spec → plan handoff.
4
- * Bundles the full planning workflow with the spec to plan.
4
+ *
5
+ * Thin prompt: the worker discovers the full planning workflow by running
6
+ * `crtr flow plan new -h`, then saves the plan via `crtr flow plan new`. This avoids
7
+ * embedding the planPrompt() blob here and keeps the prompt in sync with the
8
+ * live CLI without any coupling.
5
9
  */
6
- export function planHandoffPrompt(specPath, plansDir) {
7
- return `${planPrompt(plansDir)}
10
+ export function planHandoffPrompt(specPath, jobId) {
11
+ return `You were launched in a new tmux pane to turn an approved spec into a plan.
8
12
 
9
- ---
13
+ **Spec:** ${specPath}
10
14
 
11
- ## Your task
15
+ 1. Run \`crtr flow plan new -h\` to load the planning workflow and output schema.
16
+ 2. Read the spec end-to-end.
17
+ 3. Follow the workflow from step 1 and save the plan by passing the plan markdown to \`crtr flow plan new\` on stdin.
18
+ 4. When done, submit your result:
12
19
 
13
- You were just launched in a new tmux pane via \`crtr agent plan\`. A spec
14
- has been approved upstream and you are responsible for turning it into a plan.
20
+ \`\`\`bash
21
+ echo '{"status":"done","plan_saved":true}' > /tmp/crtr-result-${jobId}.json
22
+ crtr job submit ${jobId} --context-file /tmp/crtr-result-${jobId}.json
23
+ \`\`\`
15
24
 
16
- **Spec to plan:** ${specPath}
25
+ If you cannot complete the plan, still submit:
17
26
 
18
- Read the spec end-to-end before anything else. Then proceed through the
19
- workflow above. When you save the plan, pass \`--spec <spec-name>\` so the
20
- plan reviewer can check alignment.
27
+ \`\`\`bash
28
+ echo '{"status":"failed","reason":"<why>"}' > /tmp/crtr-result-${jobId}.json
29
+ crtr job submit ${jobId} --context-file /tmp/crtr-result-${jobId}.json
30
+ \`\`\`
21
31
 
22
- The originating pane has closed; the user is watching you here. Begin now.`;
32
+ Begin now.`;
23
33
  }
24
34
  /**
25
35
  * First user message for a plan → implementation handoff.
26
36
  */
27
- export function implementHandoffPrompt(planPath) {
37
+ export function implementHandoffPrompt(planPath, jobId) {
28
38
  return `You are executing an approved plan. For small plans, implement directly.
29
39
  For plans with parallelizable scale, orchestrate parallel subagents and
30
40
  coordinate them — don't write all the code yourself when the plan is
@@ -34,11 +44,9 @@ structured to fan out.
34
44
 
35
45
  ## Phase 1: Read
36
46
 
37
- 1. Read the plan end-to-end. If it references a spec (\`--spec\` was passed
38
- at save time), read that too it's the contract you are realizing.
39
- 2. Read the files the plan names under "Files to modify / create" (or the
40
- per-task \`Files:\` lines) and "Existing utilities to reuse" to ground
41
- yourself in current code.
47
+ 1. Read the plan end-to-end. If it references a spec, read that too.
48
+ 2. Read the files the plan names under "Files to modify / create" and
49
+ "Existing utilities to reuse" to ground yourself in current code.
42
50
  3. If the plan has task blocks with dependencies, extract the task list,
43
51
  dependency graph, and integration contracts.
44
52
 
@@ -101,11 +109,20 @@ Wait for all subagents in the current layer. Then:
101
109
  subagent returns blocked work and the fix is small enough that re-dispatch
102
110
  would be slower.
103
111
 
104
- ## Phase 6: Report
112
+ ## Phase 6: Report and submit
113
+
114
+ When all tasks complete and verification passes, submit your result:
105
115
 
106
- When all tasks complete and verification passes, write one short message:
107
- files touched per group, tests run, what works. The user may then ask for
108
- a code review via \`crtr agent review\`.
116
+ \`\`\`bash
117
+ echo '{"status":"done","summary":"<one-line summary of files touched>"}' > /tmp/crtr-result-${jobId}.json
118
+ crtr job submit ${jobId} --context-file /tmp/crtr-result-${jobId}.json
119
+ \`\`\`
120
+
121
+ If implementation fails, still submit:
122
+ \`\`\`bash
123
+ echo '{"status":"failed","reason":"<why>"}' > /tmp/crtr-result-${jobId}.json
124
+ crtr job submit ${jobId} --context-file /tmp/crtr-result-${jobId}.json
125
+ \`\`\`
109
126
 
110
127
  ## Guardrails (apply to you AND your subagents)
111
128
 
@@ -117,58 +134,18 @@ a code review via \`crtr agent review\`.
117
134
  patterns. Use the utilities the plan named.
118
135
  - **Commit only if the user asks.**
119
136
 
120
- You were launched in a new tmux pane via \`crtr agent implement\`. The
121
- originating pane has closed; the user is watching you here. Begin by reading
122
- the plan.`;
137
+ Begin by reading the plan.`;
123
138
  }
124
139
  /**
125
- * First user message for a handoff to code review of the working tree.
140
+ * First user message for a reviewer agent.
141
+ * The reviewer submits via `crtr job submit` rather than `crtr agent submit`.
126
142
  */
127
- export function reviewHandoffPrompt() {
128
- return `You are a code reviewer. A change has just been implemented and your job is
129
- to review it before it lands.
130
-
131
- ## Scope
132
-
133
- Review the **uncommitted** changes in the working tree of the current
134
- directory. Use \`git status\` and \`git diff\` (including staged changes via
135
- \`git diff --cached\`) to enumerate what changed. If there are zero changes,
136
- say so and stop.
137
-
138
- ## What to check
139
-
140
- | Category | What to look for |
141
- |----------|------------------|
142
- | Correctness | Does the code do what it claims? Off-by-ones, wrong branches, missed cases. |
143
- | Security | Injection, auth bypass, leaking secrets, unsafe defaults. |
144
- | Style fit | Matches the file's existing conventions, naming, error-handling style. |
145
- | Tests | Are there tests for new behavior? Do they actually exercise the change? |
146
- | Scope | Did the change stay within its mandate, or sneak in unrelated edits? |
147
- | Reuse | Are there existing utilities that should have been used? |
148
-
149
- ## Calibration
150
-
151
- Only flag issues that would matter to the next reader, on-call, or future
152
- maintainer. Nits are fine in a "Recommendations" section, but **do not block
153
- on style preferences**. Approve unless something is wrong, missing, or risky.
154
-
155
- ## Output
156
-
157
- \`\`\`
158
- ## Code Review
159
-
160
- **Status:** Approved | Issues Found
161
-
162
- **Issues (if any):**
163
- - [file:line]: [specific issue] — [why it matters]
164
-
165
- **Recommendations (advisory):**
166
- - [suggestions]
167
- \`\`\`
168
-
169
- After printing the review, your turn ends.
170
-
171
- You were launched in a new tmux pane via \`crtr agent review\`. The
172
- originating pane has closed; the user is watching you here. Begin by checking
173
- the working tree.`;
143
+ export function reviewerHandoffPrompt(artifactPath, artifactKind, specPath, jobId) {
144
+ const reviewBody = artifactKind === 'spec'
145
+ ? specReviewPrompt(artifactPath)
146
+ : planReviewPrompt(artifactPath, specPath);
147
+ const patched = reviewBody.replace('__CRTR_SUBMIT_INSTRUCTION__', `the submit command injected below. The \`--kill-pane\` flag closes this reviewer pane after submission — keep it, do not drop it.\n\n\`\`\`bash\ncat > /tmp/crtr-result-${jobId}.json <<'JSON'\n{"status":"done","review":"<your full review markdown>"}\nJSON\ncrtr job submit ${jobId} --context-file /tmp/crtr-result-${jobId}.json --kill-pane\n\`\`\``);
148
+ return `${patched}
149
+
150
+ After calling \`crtr job submit\`, your turn ends and the pane closes itself. Do NOT chat or summarize after submission.`;
174
151
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * First user message for a reproduction-only debug handoff.
3
+ *
4
+ * The agent's sole job is ONE failing integration test that reproduces the
5
+ * reported bug. It never fixes the bug. Symmetric with the agent.ts handoff
6
+ * builders: thin prompt, exact submit contract, turn ends after submit.
7
+ */
8
+ export declare function reproHandoffPrompt(issue: string, jobId: string): string;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * First user message for a reproduction-only debug handoff.
3
+ *
4
+ * The agent's sole job is ONE failing integration test that reproduces the
5
+ * reported bug. It never fixes the bug. Symmetric with the agent.ts handoff
6
+ * builders: thin prompt, exact submit contract, turn ends after submit.
7
+ */
8
+ export function reproHandoffPrompt(issue, jobId) {
9
+ return `You were spawned solely to write ONE integration test that fails *because of this bug*:
10
+
11
+ ${issue}
12
+
13
+ Rules — follow exactly:
14
+
15
+ - Do NOT fix the bug. Do NOT modify product code to make a test pass. Your only output is a test.
16
+ - The test must fail against the current code, and the failure must BE the reported bug — not an import error, a typo, or an unrelated assertion. Run it; paste the real failing output; confirm the failure mode matches the issue.
17
+ - Prefer an integration test against real dependencies. Mocking away the broken component is theater and does NOT count as reproduction.
18
+ - If you cannot produce a faithful failing test, GIVE UP. Never weaken assertions, hardcode expected values, or fabricate a clean-looking run — a tautological or over-mocked test is worse than none.
19
+
20
+ Submit exactly one of the following via \`crtr job submit\`, then your turn ends — do not chat:
21
+
22
+ Reproduced:
23
+ \`\`\`bash
24
+ cat > /tmp/crtr-result-${jobId}.json <<'JSON'
25
+ {"status":"done","reproduces":true,"test_path":"<path>","test_command":"<exact cmd>","failure_output":"<pasted failing output>"}
26
+ JSON
27
+ crtr job submit ${jobId} --context-file /tmp/crtr-result-${jobId}.json
28
+ \`\`\`
29
+
30
+ Gave up (no faithful repro achievable):
31
+ \`\`\`bash
32
+ echo '{"status":"failed","reproduces":false,"reason":"<why a faithful repro was not achievable>"}' > /tmp/crtr-result-${jobId}.json
33
+ crtr job submit ${jobId} --context-file /tmp/crtr-result-${jobId}.json
34
+ \`\`\`
35
+
36
+ Begin now.`;
37
+ }
@@ -1,20 +1,13 @@
1
1
  const SUBMIT_INSTRUCTIONS = `## Delivering your review
2
2
 
3
- When your review is complete, run a single Bash command to submit it back to
4
- the parent agent:
5
-
6
- \`\`\`bash
7
- crtr agent submit "$(cat <<'EOF'
8
- <your full review markdown here, using the Output Format below>
9
- EOF
10
- )"
11
- \`\`\`
3
+ When your review is complete, deliver your verdict as instructed by
4
+ __CRTR_SUBMIT_INSTRUCTION__
12
5
 
13
6
  The pane will close automatically once your review is delivered. Do NOT
14
- summarize or chat after submission — \`crtr agent submit\` IS the response.
7
+ summarize or chat after submission — the submit call IS the response.
15
8
 
16
9
  If you cannot complete the review (file missing, totally malformed, etc.),
17
- still call \`crtr agent submit\` with a brief explanation of why.`;
10
+ still submit with a brief explanation of why.`;
18
11
  export function specReviewPrompt(specPath) {
19
12
  return `You are reviewing a spec document. Verify it is complete and ready for
20
13
  planning.
@@ -1,3 +1,2 @@
1
- export declare function skillPrompt(): string;
2
1
  export declare function skillCreatePrompt(topic: string): string;
3
2
  export declare function skillTemplatePrompt(type: string, topic: string): string;