castle-web-cli 0.4.32 → 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.
- package/dist/agent-prompts.d.ts +1 -0
- package/dist/agent-prompts.js +15 -3
- package/dist/agent.js +8 -3
- package/package.json +1 -1
package/dist/agent-prompts.d.ts
CHANGED
|
@@ -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.";
|
package/dist/agent-prompts.js
CHANGED
|
@@ -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
|
|
25
|
-
what to build or fix
|
|
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,10 +428,15 @@ 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
|
-
//
|
|
434
|
-
|
|
433
|
+
// No /goal wrapper: it makes a fresh evaluator re-check the WHOLE task
|
|
434
|
+
// prompt (including user-only "done when you reach wave 5"-style play
|
|
435
|
+
// criteria) after every turn, which traps the agent in an endless
|
|
436
|
+
// can't-verify-live-play loop. A single message + the autonomy reminder
|
|
437
|
+
// appended to the system prompt (CLAUDE_TASK_SYSTEM_REMINDER) is enough to
|
|
438
|
+
// get the work done; the agent stops when the code is in, the user verifies.
|
|
439
|
+
const invocation = buildAgentInvocation(ctx.backend, 'task', taskPrompt, ctx.claudeModel);
|
|
435
440
|
let result = { ok: false, finalText: '', error: 'not run' };
|
|
436
441
|
let lineBuf = '';
|
|
437
442
|
const flushFeedLines = (delta) => {
|