castle-web-cli 0.4.206 → 0.4.208
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 +1 -0
- package/dist/ide.d.ts +18 -0
- package/dist/ide.js +44 -1
- package/dist/serve.js +24 -0
- package/dist/shell/assets/{index-hWQTC8q6.js → index-C6SXXPwm.js} +23 -23
- package/dist/shell/index.html +1 -1
- package/package.json +1 -1
package/dist/agent-prompts.js
CHANGED
|
@@ -987,6 +987,7 @@ Operating rules:
|
|
|
987
987
|
- The USER is the verifier -- the whole tasks system exists so the user playtests every change themselves. Your first priority is to finish as soon as possible with the change genuinely in place and reachable in the running deck, so the user can test it right away. Do NOT run verification (screenshots especially) unless ${opts.playtest ? "this task's brief asks for it or " : ""}you are really sure it will catch something a re-read of your own change cannot -- and even then at most one cheap check, never a retry loop. Time spent verifying is time the user is left waiting.
|
|
988
988
|
- The moment implementation is complete and you switch to verifying, write 90 to the progress file -- verification time must not read as stalled progress.
|
|
989
989
|
- Do this one task completely, then stop. Do not expand scope.
|
|
990
|
+
- A fix that comes down to choosing a new number for a value already in the code is a tune, and a tune is a guess the user will keep adjusting. Make that value a key in the file's \`PARAMS\` object as part of the same edit -- the new value as its default, read through \`PARAMS.key\` at the use site, a \`PARAMS_META\` range where one is obvious -- so it reaches the Parameters panel and your notes can link it. Move only the value you tuned, not the file's other constants, and only a value the whole deck shares: a setting each placed thing carries for itself, so two of them can differ, stays where the deck's guide puts it and never goes in \`PARAMS\`. A number the user stated goes in the same way, set exactly as they said it.
|
|
990
991
|
- If the task is to SHOW HOW something is done or to give an example, answer it -- in your streamed output and notes, with a standalone snippet if that helps -- and do NOT insert a demo behavior, blueprint, or actor into their scene; that only happens when the user asked for it in their game. Anything you did add to a scene must be named in your notes by file path and by the actor or blueprint it attached to, so they can find it and take it out.${planRules}
|
|
991
992
|
- SAVE A VERSION when your change is done, so the user can see and undo it: \`castle-web save-version -m "<short description of what you changed>" <each path you touched>\`. Name those paths explicitly -- a bare \`save-version\` with no paths records the WHOLE deck, including files a sibling agent is still working on. One version for the whole task, at the end; not one per file.
|
|
992
993
|
- Overlap with the other agents working in this deck is fine and expected -- do not try to avoid it or wait for them. Saving only your own paths is all that is asked of you; nothing anyone has written is lost by your save.
|
package/dist/ide.d.ts
CHANGED
|
@@ -4,6 +4,24 @@ import { COVER_FILE } from './localPaths.js';
|
|
|
4
4
|
import { type TuneLedger } from './paramsTunes.js';
|
|
5
5
|
/** Cache only Vite's content-fingerprinted executable, style, and font output. */
|
|
6
6
|
export declare function shellAssetCacheControl(asset: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The CDN origin that carries this CLI's fingerprinted shell assets, when the
|
|
9
|
+
* environment names one (the sandbox image sets CASTLE_SHELL_ASSET_ORIGIN; its
|
|
10
|
+
* build uploads the assets there first). Only a bare https origin counts.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shellAssetOrigin(value: string | undefined): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Point the shell's fingerprinted script and stylesheet at the CDN, falling back
|
|
15
|
+
* to this serve's own copy if the CDN copy fails to load.
|
|
16
|
+
*
|
|
17
|
+
* Each deck serve is its own origin (`<port>-<sandbox>`), so without this the
|
|
18
|
+
* browser caches the 1.5 MB bundle once per deck port and downloads it again on
|
|
19
|
+
* the first open of every deck: 2.0 s vs 0.83 s to shell load on mobile. The CDN
|
|
20
|
+
* URL is the same for every deck and sandbox, and it is keyed by content hash, so
|
|
21
|
+
* a CLI release that leaves the shell alone keeps the cached copy too. Only names
|
|
22
|
+
* the immutable-asset rule accepts are moved; everything else stays local.
|
|
23
|
+
*/
|
|
24
|
+
export declare function withShellAssetOrigin(html: string, origin: string | null): string;
|
|
7
25
|
export declare const IDE_ASSET_PREFIX = "/__castle/ide/";
|
|
8
26
|
export declare const PTY_WS_PATH = "/__castle/pty";
|
|
9
27
|
export declare const VENDOR_PREFIX = "/__castle/vendor/";
|
package/dist/ide.js
CHANGED
|
@@ -58,6 +58,49 @@ const IMMUTABLE_SHELL_ASSET = /^assets\/[^/\\]+-[A-Za-z0-9_-]{8}\.(?:css|js|woff
|
|
|
58
58
|
export function shellAssetCacheControl(asset) {
|
|
59
59
|
return IMMUTABLE_SHELL_ASSET.test(asset) ? 'public, max-age=31536000, immutable' : 'no-store';
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The CDN origin that carries this CLI's fingerprinted shell assets, when the
|
|
63
|
+
* environment names one (the sandbox image sets CASTLE_SHELL_ASSET_ORIGIN; its
|
|
64
|
+
* build uploads the assets there first). Only a bare https origin counts.
|
|
65
|
+
*/
|
|
66
|
+
export function shellAssetOrigin(value) {
|
|
67
|
+
if (!value)
|
|
68
|
+
return null;
|
|
69
|
+
try {
|
|
70
|
+
const url = new URL(value);
|
|
71
|
+
if (url.protocol !== 'https:' || url.pathname !== '/' || url.search || url.hash)
|
|
72
|
+
return null;
|
|
73
|
+
if (url.username || url.password)
|
|
74
|
+
return null;
|
|
75
|
+
return url.origin;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Point the shell's fingerprinted script and stylesheet at the CDN, falling back
|
|
83
|
+
* to this serve's own copy if the CDN copy fails to load.
|
|
84
|
+
*
|
|
85
|
+
* Each deck serve is its own origin (`<port>-<sandbox>`), so without this the
|
|
86
|
+
* browser caches the 1.5 MB bundle once per deck port and downloads it again on
|
|
87
|
+
* the first open of every deck: 2.0 s vs 0.83 s to shell load on mobile. The CDN
|
|
88
|
+
* URL is the same for every deck and sandbox, and it is keyed by content hash, so
|
|
89
|
+
* a CLI release that leaves the shell alone keeps the cached copy too. Only names
|
|
90
|
+
* the immutable-asset rule accepts are moved; everything else stays local.
|
|
91
|
+
*/
|
|
92
|
+
export function withShellAssetOrigin(html, origin) {
|
|
93
|
+
if (!origin)
|
|
94
|
+
return html;
|
|
95
|
+
const local = (name) => `${IDE_ASSET_PREFIX}assets/${name}`;
|
|
96
|
+
const isMovable = (name) => IMMUTABLE_SHELL_ASSET.test(`assets/${name}`);
|
|
97
|
+
html = html.replace(/<script type="module" crossorigin src="\/__castle\/ide\/assets\/([^"\/]+)"><\/script>/g, (tag, name) => isMovable(name) && name.endsWith('.js')
|
|
98
|
+
? `<script type="module" crossorigin src="${origin}${local(name)}" onerror="var s=document.createElement('script');s.type='module';s.src='${local(name)}';document.head.appendChild(s)"></script>`
|
|
99
|
+
: tag);
|
|
100
|
+
return html.replace(/<link rel="stylesheet" crossorigin href="\/__castle\/ide\/assets\/([^"\/]+)">/g, (tag, name) => isMovable(name) && name.endsWith('.css')
|
|
101
|
+
? `<link rel="stylesheet" crossorigin href="${origin}${local(name)}" onerror="this.onerror=null;this.href='${local(name)}'">`
|
|
102
|
+
: tag);
|
|
103
|
+
}
|
|
61
104
|
// Does the deck serve this root-level file itself? Vite serves both the deck
|
|
62
105
|
// root and its `public/` dir at `/`, so either location counts.
|
|
63
106
|
function deckHasFile(deckDir, name) {
|
|
@@ -118,7 +161,7 @@ function serveShellIndex(req, res, bootstrap) {
|
|
|
118
161
|
res.writeHead(404).end();
|
|
119
162
|
return true;
|
|
120
163
|
}
|
|
121
|
-
let html = fs.readFileSync(filePath, 'utf8');
|
|
164
|
+
let html = withShellAssetOrigin(fs.readFileSync(filePath, 'utf8'), shellAssetOrigin(process.env.CASTLE_SHELL_ASSET_ORIGIN));
|
|
122
165
|
if (bootstrap)
|
|
123
166
|
html = html.replace(/<head(\s[^>]*)?>/i, (head) => `${head}${bootstrap(req)}`);
|
|
124
167
|
res.writeHead(200, {
|
package/dist/serve.js
CHANGED
|
@@ -547,8 +547,32 @@ window.__castleShellOrigin=(function(){
|
|
|
547
547
|
(function(){
|
|
548
548
|
var role=new URLSearchParams(location.search).get('edit')==='0'?'play':'edit';
|
|
549
549
|
var target=window.__castleShellOrigin||'*';
|
|
550
|
+
// How this page's own load went, measured once it has loaded: the host logs it
|
|
551
|
+
// beside its click-to-frame-ready timing, to tell network fan-out (request count,
|
|
552
|
+
// bytes) apart from the deck's own startup work (script time before load).
|
|
553
|
+
var metrics=null;
|
|
554
|
+
var measure=function(){
|
|
555
|
+
try{
|
|
556
|
+
var n=performance.getEntriesByType('navigation')[0];
|
|
557
|
+
if(!n||!n.loadEventEnd)return null;
|
|
558
|
+
var r=performance.getEntriesByType('resource');
|
|
559
|
+
var scripts=0,bytes=0;
|
|
560
|
+
for(var i=0;i<r.length;i++){if(r[i].initiatorType==='script')scripts++;bytes+=r[i].transferSize||0;}
|
|
561
|
+
var fcp=performance.getEntriesByName('first-contentful-paint')[0];
|
|
562
|
+
var ms=function(v){return Math.max(0,Math.round(v));};
|
|
563
|
+
return {ttfbMs:ms(n.responseStart),domContentLoadedMs:ms(n.domContentLoadedEventEnd),loadMs:ms(n.loadEventEnd),firstContentfulPaintMs:fcp?ms(fcp.startTime):null,resources:r.length,scripts:scripts,transferKb:ms(bytes/1024)};
|
|
564
|
+
}catch(e){return null;}
|
|
565
|
+
};
|
|
550
566
|
var announce=function(){
|
|
551
567
|
if(window.parent===window)return;
|
|
568
|
+
if(!metrics)metrics=measure();
|
|
569
|
+
// Deck code ran first and may have replaced performance with something that
|
|
570
|
+
// does not clone; a measurement that cannot be posted must never cost the
|
|
571
|
+
// readiness announcement itself.
|
|
572
|
+
if(metrics){
|
|
573
|
+
try{window.parent.postMessage({type:'castle-content-frame-ready',role:role,metrics:metrics},target);return;}
|
|
574
|
+
catch(e){metrics=null;}
|
|
575
|
+
}
|
|
552
576
|
window.parent.postMessage({type:'castle-content-frame-ready',role:role},target);
|
|
553
577
|
};
|
|
554
578
|
window.addEventListener('message',function(event){
|