castle-web-cli 0.4.53 → 0.4.55
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface PromptMessage {
|
|
2
|
-
role:
|
|
2
|
+
role: "user" | "assistant";
|
|
3
3
|
text: string;
|
|
4
4
|
}
|
|
5
5
|
export interface PromptTask {
|
|
@@ -28,6 +28,6 @@ export declare function buildTaskPrompt(opts: {
|
|
|
28
28
|
progressPath: string;
|
|
29
29
|
notesPath: string;
|
|
30
30
|
depsSummary?: string;
|
|
31
|
-
backend?:
|
|
31
|
+
backend?: "cursor" | "claude";
|
|
32
32
|
}): string;
|
|
33
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
|
@@ -14,9 +14,10 @@ Hard rules:
|
|
|
14
14
|
- You NEVER edit files or run state-changing commands. All building and fixing happens through background task agents -- always hand the longer work to them.
|
|
15
15
|
- You are the fast lane: get to your final reply as quickly as possible. When the user reports something broken, do NOT dig into the code to diagnose it first -- spawn a task whose job is to investigate AND fix it. Only read deck files when your reply itself needs them (answering a question about the deck, grounding a claim -- never make things up); never read as pre-work before spawning a task.
|
|
16
16
|
- Launch a SET of small steps the user tests one by one -- a pipeline, never one big task they wait on, never untestable fragments. One interacting mechanic = one task (paddle + ball + bricks = one playable core, not three). First step = the smallest genuinely playable thing; later steps build it out. Match breadth to ambition ("basic" = a few steps; "go wild" = many). You're optimizing the user's taste and feedback -- more small testable steps = more points where they steer it into something theirs.
|
|
17
|
-
- The whole goal:
|
|
17
|
+
- The whole goal: every piece of work TESTABLE in actual gameplay ASAP. Start every task as early as possible and run them in PARALLEL. Do NOT break tasks down by which files they touch, and never add \`after:\` just to avoid two tasks editing the same file -- tasks make surgical edits and overlap fine. The only real dependency between tasks is INFORMATION: a task is blocked only when it needs a fact it does not yet have.
|
|
18
|
+
- Dissolve those information-dependencies with a CONTRACT decided up front, instead of serializing tasks. Before spawning, pin the shared names the tasks will agree on -- scene file names, behavior names, drawing file names, tags -- and give each parallel task the exact names it must CREATE or REFERENCE. Then they all run at once and converge to a working game with NO follow-up wiring task: the scene task places actors referencing behaviors and drawings by their agreed names before those files even exist; the behavior tasks create those behavior names; the drawing tasks create those drawing files. (Art: pin drawings/ship.drawing up front -> the scene task points an actor at it while another task draws it, in parallel; no place-it-later task.) Fall back to a separate waiting wire-in task (\`after:\` the maker, on the least possible) ONLY when a task truly needs another's actual produced output, not just its agreed name. Working out this breakdown -- what to parallelize, which names to pin up front -- is the core of your job and differs per game.
|
|
18
19
|
- Write each task prompt for the quickest viable, testable change that still delivers a meaningful step up. Dive deep only if the user asked.
|
|
19
|
-
- Real, editable assets: drawings (drawings/*.drawing pixel art) for game objects, characters, and scenery
|
|
20
|
+
- Real, editable assets: drawings (drawings/*.drawing pixel art) for game objects, characters, and scenery as real actors; data-driven UI (health/score/HUD) and effects stay code. Get the game playable instantly with placeholder blocks (block.drawing + tint) -- even for pong/breakout -- then bring in the real drawings (wired in per the rule above). Never say "greybox" or other dev jargon to the user.
|
|
20
21
|
- To spawn a background task, include a fenced block in your reply:
|
|
21
22
|
|
|
22
23
|
\`\`\`castle-task
|
|
@@ -28,7 +29,7 @@ the deck's own docs for framework/API detail, so never restate recipes,
|
|
|
28
29
|
file layouts, or implementation steps.
|
|
29
30
|
\`\`\`
|
|
30
31
|
|
|
31
|
-
- Use \`after:\` only
|
|
32
|
+
- Use \`after:\` only for the fallback case above -- a task that genuinely needs another's produced output (it may reference tasks spawned in this same reply, by title). Never for file-contention; independent tasks must NOT wait on each other.
|
|
32
33
|
|
|
33
34
|
Keeping the board clean. The background-tasks list below IS the board the user sees -- every row, with its id and status. Be diligent about removing rows that no longer belong, using these two fences:
|
|
34
35
|
|
|
@@ -58,20 +59,20 @@ Conversation style:
|
|
|
58
59
|
function renderTranscript(messages) {
|
|
59
60
|
const recent = messages.slice(-TRANSCRIPT_LIMIT);
|
|
60
61
|
if (recent.length === 0)
|
|
61
|
-
return
|
|
62
|
+
return "(no conversation yet)";
|
|
62
63
|
return recent
|
|
63
|
-
.map((m) => `${m.role ===
|
|
64
|
-
.join(
|
|
64
|
+
.map((m) => `${m.role === "user" ? "user" : "you"}: ${m.text}`)
|
|
65
|
+
.join("\n\n");
|
|
65
66
|
}
|
|
66
67
|
function renderTasks(tasks) {
|
|
67
68
|
if (tasks.length === 0)
|
|
68
|
-
return
|
|
69
|
+
return "(none yet)";
|
|
69
70
|
return tasks
|
|
70
71
|
.map((t) => {
|
|
71
|
-
const notes = t.notes.trim() ? ` -- notes: ${t.notes.trim()}` :
|
|
72
|
+
const notes = t.notes.trim() ? ` -- notes: ${t.notes.trim()}` : "";
|
|
72
73
|
return `- [${t.status} ${t.progress}%] ${t.title} (${t.id})${notes}`;
|
|
73
74
|
})
|
|
74
|
-
.join(
|
|
75
|
+
.join("\n");
|
|
75
76
|
}
|
|
76
77
|
export function buildRouterPrompt(opts) {
|
|
77
78
|
return `${ROUTER_RULES}
|
|
@@ -97,14 +98,14 @@ export function userTurnInstruction(opts) {
|
|
|
97
98
|
}
|
|
98
99
|
parts.push(`The user just said:\n\n${opts.text}`);
|
|
99
100
|
if (opts.attachments && opts.attachments.length > 0) {
|
|
100
|
-
parts.push(`The user attached image file(s), saved in the deck at: ${opts.attachments.join(
|
|
101
|
+
parts.push(`The user attached image file(s), saved in the deck at: ${opts.attachments.join(", ")}. Open them with your read tool and take them into account; pass the paths along to task agents that need them.`);
|
|
101
102
|
}
|
|
102
|
-
return parts.join(
|
|
103
|
+
return parts.join("\n\n");
|
|
103
104
|
}
|
|
104
105
|
export function buildTaskPrompt(opts) {
|
|
105
106
|
const deps = opts.depsSummary
|
|
106
107
|
? `\n\nThis task waited on earlier tasks:\n${opts.depsSummary}\n`
|
|
107
|
-
:
|
|
108
|
+
: "";
|
|
108
109
|
// Claude-only: collapsing the wrap-up (progress 90 + restart + notes) into
|
|
109
110
|
// one shell call reliably saves 1-2 serial ~7s turns there. Cursor's
|
|
110
111
|
// composer sometimes reacts to the same rule with MORE calls, so it stays
|
|
@@ -112,9 +113,9 @@ export function buildTaskPrompt(opts) {
|
|
|
112
113
|
// (We deliberately do NOT tell agents to overwrite files via `cat > … <<EOF`
|
|
113
114
|
// -- blind whole-file rewrites made parallel agents clobber each other's
|
|
114
115
|
// edits. Read-then-edit is slower but safe; that is the right tradeoff.)
|
|
115
|
-
const wrapUp = opts.backend ===
|
|
116
|
+
const wrapUp = opts.backend === "claude"
|
|
116
117
|
? `\n- 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.`
|
|
117
|
-
:
|
|
118
|
+
: "";
|
|
118
119
|
return `You are a background build agent for the Castle deck "${opts.deckLabel}" (current directory). A separate conversation agent dispatched you with one task. Follow the deck's CLAUDE.md / AGENTS.md conventions, and reload the served deck after changes (\`npm run restart\`).
|
|
119
120
|
|
|
120
121
|
Your task (id ${opts.taskId}): ${opts.title}
|
|
@@ -136,4 +137,4 @@ Operating rules:
|
|
|
136
137
|
}
|
|
137
138
|
// Appended to claude task agents' system prompt (portable replacement for the
|
|
138
139
|
// machine-specific /goal slash command): commit to autonomous completion.
|
|
139
|
-
export const CLAUDE_TASK_SYSTEM_REMINDER =
|
|
140
|
+
export 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.";
|
|
@@ -19,13 +19,22 @@ export function ScenePlayer({ sceneData, drawings, behaviorClasses }) {
|
|
|
19
19
|
configureSceneCanvas(canvas, ctx);
|
|
20
20
|
const runtime = makeScene(sceneData, behaviorClasses, drawings).clone();
|
|
21
21
|
runtimeRef.current = runtime;
|
|
22
|
+
// Store BOTH the physical code ('KeyX', 'ArrowLeft', 'Space') and the
|
|
23
|
+
// logical key ('x', 'ArrowLeft', ' ') so behaviors can match either. Codes
|
|
24
|
+
// are what the kit docs/examples use; keeping key too is forgiving.
|
|
22
25
|
const onKeyDown = (event) => {
|
|
26
|
+
runtime.keys.add(event.code);
|
|
23
27
|
runtime.keys.add(event.key);
|
|
24
28
|
};
|
|
25
29
|
const onKeyUp = (event) => {
|
|
30
|
+
runtime.keys.delete(event.code);
|
|
26
31
|
runtime.keys.delete(event.key);
|
|
27
32
|
};
|
|
28
33
|
const onPointerDown = (event) => {
|
|
34
|
+
// The play surface listens on window keydown, so it only gets keys when
|
|
35
|
+
// its document/iframe holds focus. Grab focus on any click into the game
|
|
36
|
+
// (and on mount below) so the keyboard works inside the launcher embed.
|
|
37
|
+
canvas.focus();
|
|
29
38
|
runtime.setPointerFromScreen(canvas, event.clientX, event.clientY, true);
|
|
30
39
|
canvas.setPointerCapture(event.pointerId);
|
|
31
40
|
};
|
|
@@ -46,6 +55,7 @@ export function ScenePlayer({ sceneData, drawings, behaviorClasses }) {
|
|
|
46
55
|
canvas.addEventListener('pointermove', onPointerMove);
|
|
47
56
|
canvas.addEventListener('pointerup', onPointerUp);
|
|
48
57
|
canvas.addEventListener('pointercancel', onPointerUp);
|
|
58
|
+
canvas.focus();
|
|
49
59
|
const stopLoop = startPlayerLoop(canvas, ctx, runtime);
|
|
50
60
|
return () => {
|
|
51
61
|
stopLoop();
|
|
@@ -61,7 +71,11 @@ export function ScenePlayer({ sceneData, drawings, behaviorClasses }) {
|
|
|
61
71
|
}, []);
|
|
62
72
|
return (
|
|
63
73
|
<div style={{ position: 'fixed', inset: 0, background: '#000' }}>
|
|
64
|
-
<canvas
|
|
74
|
+
<canvas
|
|
75
|
+
ref={canvasRef}
|
|
76
|
+
tabIndex={0}
|
|
77
|
+
style={{ width: '100%', height: '100%', display: 'block', outline: 'none' }}
|
|
78
|
+
/>
|
|
65
79
|
<SceneUI getRuntime={getRuntime} />
|
|
66
80
|
<TouchControls getKeys={getKeys} />
|
|
67
81
|
</div>
|