castle-web-cli 0.4.16 → 0.4.19
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.js +2 -0
- package/dist/init.js +31 -20
- package/package.json +1 -1
package/dist/agent-prompts.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
const TRANSCRIPT_LIMIT = 40;
|
|
9
9
|
const ROUTER_RULES = `You are Castle's create assistant: the fast conversational router for a game-making session. The deck (game project) lives in the current directory and runs live in a pane right next to this chat.
|
|
10
10
|
|
|
11
|
+
What a deck is: a normal web project served by vite -- index.html plus plain JS/JSX modules, with real npm dependencies (more can be installed), the castle-web-sdk package, and usually a kit framework whose engine, behaviors, scenes, editors, and drawings are ordinary files in this directory. The web platform is fully available (DOM, canvas, npm libraries like react, three, etc.). The deck's CLAUDE.md / AGENTS.md describes the specific setup. NEVER claim something is impossible or unsupported on the platform without checking the deck's files first.
|
|
12
|
+
|
|
11
13
|
Hard rules:
|
|
12
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.
|
|
13
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.
|
package/dist/init.js
CHANGED
|
@@ -39,8 +39,27 @@ const PUBLISHED_SDK_VERSION = '0.4.3';
|
|
|
39
39
|
// Never copied into a fresh deck: build/dependency junk, and castle.json (a
|
|
40
40
|
// fresh deck has no deckId until its first save-deck).
|
|
41
41
|
const KIT_COPY_EXCLUDE = new Set(['node_modules', '.castle', 'dist', '.git', 'castle.json']);
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
// Resolve how a scaffolded deck should reference the sdk + cli. Both the bare
|
|
43
|
+
// and kit scaffold paths go through here so they stay in sync.
|
|
44
|
+
// workspace mode (sdk/ sits next to cli/, i.e. running from a checkout):
|
|
45
|
+
// sdk -> file: absolute path to sdk/, scripts -> `node <abs cli dist>/index.js`
|
|
46
|
+
// published mode (globally-installed castle-web, no sibling sdk/):
|
|
47
|
+
// sdk -> registry `^${PUBLISHED_SDK_VERSION}`, scripts -> the `castle-web` binary
|
|
48
|
+
function resolveScaffoldRefs() {
|
|
49
|
+
const sdkPath = getSdkPackagePath();
|
|
50
|
+
// "Workspace mode" = the cli is running from a castle-experimental-web
|
|
51
|
+
// checkout (sdk/ exists next to cli/). Otherwise we're a globally-installed
|
|
52
|
+
// npm package and need the published refs + `castle-web` binary.
|
|
53
|
+
const workspaceMode = fs.existsSync(sdkPath);
|
|
54
|
+
const sdkPathPosix = workspaceMode ? toPosixPath(sdkPath) : null;
|
|
55
|
+
const cliDistAbs = workspaceMode ? toPosixPath(path.dirname(getCliEntryPath())) : null;
|
|
56
|
+
return {
|
|
57
|
+
workspaceMode,
|
|
58
|
+
sdkRef: workspaceMode ? `file:${sdkPathPosix}` : `^${PUBLISHED_SDK_VERSION}`,
|
|
59
|
+
cliCommand: workspaceMode ? `node ${toPosixPath(getCliEntryPath())}` : 'castle-web',
|
|
60
|
+
cliDistAbs,
|
|
61
|
+
sdkPathPosix,
|
|
62
|
+
};
|
|
44
63
|
}
|
|
45
64
|
function makeClaudeMd() {
|
|
46
65
|
// Inline the upstream CLAUDE.md content. An @-import works inside the
|
|
@@ -72,19 +91,18 @@ function tryMakeAgentsSymlink(agentsPath) {
|
|
|
72
91
|
}
|
|
73
92
|
}
|
|
74
93
|
function makePackageJson(projectDir) {
|
|
75
|
-
const
|
|
76
|
-
const sdkPackage = relativeFromProject(projectDir, getSdkPackagePath());
|
|
94
|
+
const { sdkRef, cliCommand } = resolveScaffoldRefs();
|
|
77
95
|
return {
|
|
78
96
|
name: path.basename(projectDir),
|
|
79
97
|
private: true,
|
|
80
98
|
type: 'module',
|
|
81
99
|
scripts: {
|
|
82
|
-
restart:
|
|
83
|
-
screenshot:
|
|
84
|
-
'save-deck':
|
|
100
|
+
restart: `${cliCommand} restart .`,
|
|
101
|
+
screenshot: `${cliCommand} screenshot .`,
|
|
102
|
+
'save-deck': `${cliCommand} save-deck .`,
|
|
85
103
|
},
|
|
86
104
|
dependencies: {
|
|
87
|
-
'castle-web-sdk':
|
|
105
|
+
'castle-web-sdk': sdkRef,
|
|
88
106
|
},
|
|
89
107
|
};
|
|
90
108
|
}
|
|
@@ -151,16 +169,9 @@ function scaffoldFromKit(kit, projectDir) {
|
|
|
151
169
|
// Local-dev paths (`file:../../sdk` / `node ../../cli/dist/index.js`) only
|
|
152
170
|
// work when the deck lives inside the castle-experimental-web workspace.
|
|
153
171
|
// For a deck scaffolded from a globally-installed castle-web, rewrite to
|
|
154
|
-
// the published packages instead.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// checkout (sdk/ exists next to cli/). Otherwise we're a globally-
|
|
158
|
-
// installed npm package and need to use the published refs + binary.
|
|
159
|
-
const workspaceMode = fs.existsSync(sdkPath);
|
|
160
|
-
const sdkRef = workspaceMode ? `file:${toPosixPath(sdkPath)}` : `^${PUBLISHED_SDK_VERSION}`;
|
|
161
|
-
const cliDistAbs = workspaceMode
|
|
162
|
-
? toPosixPath(path.dirname(getCliEntryPath()))
|
|
163
|
-
: null;
|
|
172
|
+
// the published packages instead. Same workspace-vs-published resolution
|
|
173
|
+
// the bare scaffold path uses.
|
|
174
|
+
const { workspaceMode, sdkRef, cliDistAbs, sdkPathPosix } = resolveScaffoldRefs();
|
|
164
175
|
if (pkg.dependencies &&
|
|
165
176
|
typeof pkg.dependencies['castle-web-sdk'] === 'string' &&
|
|
166
177
|
pkg.dependencies['castle-web-sdk'].startsWith('file:')) {
|
|
@@ -170,10 +181,10 @@ function scaffoldFromKit(kit, projectDir) {
|
|
|
170
181
|
for (const k of Object.keys(pkg.scripts)) {
|
|
171
182
|
if (typeof pkg.scripts[k] !== 'string')
|
|
172
183
|
continue;
|
|
173
|
-
if (
|
|
184
|
+
if (workspaceMode) {
|
|
174
185
|
pkg.scripts[k] = pkg.scripts[k]
|
|
175
186
|
.replace(/\.\.\/\.\.\/cli\/dist/g, cliDistAbs)
|
|
176
|
-
.replace(/\.\.\/\.\.\/sdk/g,
|
|
187
|
+
.replace(/\.\.\/\.\.\/sdk/g, sdkPathPosix);
|
|
177
188
|
}
|
|
178
189
|
else {
|
|
179
190
|
// Globally-installed: route through the `castle-web` binary on PATH.
|