castle-web-cli 0.4.33 → 0.4.34

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.
@@ -28,5 +28,6 @@ export declare function buildTaskPrompt(opts: {
28
28
  progressPath: string;
29
29
  notesPath: string;
30
30
  depsSummary?: string;
31
+ backend?: 'cursor' | 'claude';
31
32
  }): string;
32
33
  export declare const CLAUDE_TASK_SYSTEM_REMINDER = "Castle background task agent: work autonomously to completion -- never pause to ask questions or wait for confirmation; finish the task end-to-end, then stop. Prefer the quickest viable change that fully does the job.";
@@ -21,8 +21,10 @@ Hard rules:
21
21
  short imperative title on the first line
22
22
  after: comma-separated titles or ids this task must wait for (optional line)
23
23
  supersedes: comma-separated titles or ids this task replaces (optional line)
24
- Then a detailed, self-contained prompt for the implementing agent:
25
- what to build or fix, which files matter, and what "done" looks like.
24
+ Then a SHORT self-contained prompt -- one tight paragraph (aim under 100
25
+ words): what to build or fix and what "done" looks like. Task agents read
26
+ the deck's own docs for framework/API detail, so never restate recipes,
27
+ file layouts, or implementation steps.
26
28
  \`\`\`
27
29
 
28
30
  - Use \`after:\` only when a task truly builds on or would conflict with another (it may reference tasks spawned in this same reply, by title). Independent tasks must NOT wait on each other.
@@ -101,6 +103,16 @@ export function buildTaskPrompt(opts) {
101
103
  const deps = opts.depsSummary
102
104
  ? `\n\nThis task waited on earlier tasks:\n${opts.depsSummary}\n`
103
105
  : '';
106
+ // Claude-only: collapsing the wrap-up (progress 90 + restart + notes) into
107
+ // one shell call reliably saves 1-2 serial ~7s turns there. Cursor's
108
+ // composer sometimes reacts to the same rule with MORE calls, so it stays
109
+ // on the plain instructions. Read-before-overwrite likewise targets
110
+ // claude's Write-tool precondition (a blind Write to an existing file is
111
+ // rejected, forcing a wasted failed-call + Read + retry cycle).
112
+ const wrapUp = opts.backend === 'claude'
113
+ ? `\n- NEVER point your Write tool at a file that already exists (scenes/main.scene especially): it rejects files it has not Read, and the failed call + forced Read wastes two turns. Replace existing files with ONE shell command instead (\`cat > scenes/main.scene <<'EOF' ... EOF\`); reserve the Write tool for brand-new files.
114
+ - Wrap up in ONE tool call, not several: once your last file edit is done, combine the 90-progress write, the final \`npm run restart\`, and writing the notes file into a single shell command (\`;\`-separated so the notes land even if the restart hiccups). Then stop -- no extra turns after it.`
115
+ : '';
104
116
  return `You are a background build agent for the Castle deck "${opts.deckLabel}" (current directory). A separate conversation agent dispatched you with one task. Read the deck's CLAUDE.md / AGENTS.md first and follow its workflow (including reloading the served deck after changes, e.g. \`npm run restart\`).
105
117
 
106
118
  Your task (id ${opts.taskId}): ${opts.title}
@@ -113,7 +125,7 @@ Operating rules:
113
125
  - The moment implementation is complete and you switch to verifying, write 90 to the progress file -- verification time must not read as stalled progress.
114
126
  - Do this one task completely, then stop. Do not expand scope.
115
127
  - Update your progress VERY frequently: write a bare integer 0-100 to ${opts.progressPath} (e.g. \`echo 30 > ${opts.progressPath}\`) every time you advance -- at least every 10 points, or every 20 for properly small tasks. Start near 10, write 90 just before wrapping up. Never let it sit stale while you work.
116
- - Before finishing, write ${opts.notesPath}: a SHORT test guide for the user -- 2-4 brief sentences. Lead with exactly what to try in the running deck; mention a blocker or open question if you hit one. NO file-by-file implementation detail, no code names unless the user needs them to test. The user reads this verbatim when checking your work off.
128
+ - Before finishing, write ${opts.notesPath}: a SHORT test guide for the user -- 2-4 brief sentences. Lead with exactly what to try in the running deck; mention a blocker or open question if you hit one. NO file-by-file implementation detail, no code names unless the user needs them to test. The user reads this verbatim when checking your work off.${wrapUp}
117
129
  - If you are truly blocked, write the blocker to the notes file and stop rather than guessing wildly.
118
130
  - Never touch files under .castle/ other than those two paths.`;
119
131
  }
package/dist/agent.js CHANGED
@@ -428,6 +428,7 @@ async function runTaskAgentIn(ctx, task) {
428
428
  progressPath: path.join(relDir, 'progress'),
429
429
  notesPath: path.join(relDir, 'notes.md'),
430
430
  depsSummary: ctx.depsSummary,
431
+ backend: ctx.backend,
431
432
  });
432
433
  // No /goal wrapper: it makes a fresh evaluator re-check the WHOLE task
433
434
  // prompt (including user-only "done when you reach wave 5"-style play
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.33",
3
+ "version": "0.4.34",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "castle-web": "./dist/index.js"