castle-web-cli 0.4.83 → 0.4.85

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.
Files changed (85) hide show
  1. package/dist/agent-failures.d.ts +17 -0
  2. package/dist/agent-failures.js +151 -0
  3. package/dist/agent.d.ts +26 -0
  4. package/dist/agent.js +317 -74
  5. package/dist/ide.js +35 -13
  6. package/dist/native/loop.js +35 -0
  7. package/dist/native/openrouter.d.ts +7 -0
  8. package/dist/native/openrouter.js +25 -1
  9. package/dist/native/types.d.ts +2 -0
  10. package/dist/native/types.js +0 -38
  11. package/dist/openrouter-catalog.d.ts +28 -0
  12. package/dist/openrouter-catalog.js +299 -0
  13. package/dist/shell/assets/{index-C9Zhmien.js → index-BJLaUTJE.js} +60 -58
  14. package/dist/shell/assets/{index-BMkQt27u.css → index-DonnH--m.css} +1 -1
  15. package/dist/shell/index.html +2 -2
  16. package/kits/physics-2d/.prettierrc +8 -0
  17. package/kits/physics-2d/CLAUDE.md +329 -0
  18. package/kits/physics-2d/behaviors/Camera.jsx +43 -0
  19. package/kits/physics-2d/behaviors/Collider.jsx +199 -0
  20. package/kits/physics-2d/behaviors/Goal.jsx +29 -0
  21. package/kits/physics-2d/behaviors/Layout.jsx +53 -0
  22. package/kits/physics-2d/behaviors/Sprite.jsx +352 -0
  23. package/kits/physics-2d/behaviors/tint.js +47 -0
  24. package/kits/physics-2d/blueprints/ball.scene +14 -0
  25. package/kits/physics-2d/blueprints/block.scene +12 -0
  26. package/kits/physics-2d/blueprints/cauldron.scene +18 -0
  27. package/kits/physics-2d/blueprints/crate.scene +14 -0
  28. package/kits/physics-2d/blueprints/goal.scene +12 -0
  29. package/kits/physics-2d/castle.json +13 -0
  30. package/kits/physics-2d/docs/pxart-format.md +377 -0
  31. package/kits/physics-2d/drawings/block.pxart +25 -0
  32. package/kits/physics-2d/drawings/cauldron.pxart +113 -0
  33. package/kits/physics-2d/editors/BlueprintLibrary.jsx +247 -0
  34. package/kits/physics-2d/editors/ErrorBoundary.jsx +59 -0
  35. package/kits/physics-2d/editors/PlayOnly.jsx +31 -0
  36. package/kits/physics-2d/editors/PxArtEditor.jsx +954 -0
  37. package/kits/physics-2d/editors/SceneEditor.jsx +1681 -0
  38. package/kits/physics-2d/editors/SelectionOverlay.jsx +909 -0
  39. package/kits/physics-2d/editors/SingleEditor.jsx +122 -0
  40. package/kits/physics-2d/editors/behaviorRegistry.js +30 -0
  41. package/kits/physics-2d/editors/editorHistory.js +157 -0
  42. package/kits/physics-2d/editors/inspectorSheet.js +13 -0
  43. package/kits/physics-2d/editors/pixelCanvas.js +11 -0
  44. package/kits/physics-2d/editors/pixelEditorChrome.jsx +74 -0
  45. package/kits/physics-2d/editors/pixelGeometry.js +140 -0
  46. package/kits/physics-2d/editors/pixelInspector.jsx +633 -0
  47. package/kits/physics-2d/editors/pxArtEditorModel.js +732 -0
  48. package/kits/physics-2d/editors/pxArtPlayback.js +92 -0
  49. package/kits/physics-2d/editors/pxArtTimeline.jsx +752 -0
  50. package/kits/physics-2d/editors/pxArtTimeline.module.css +506 -0
  51. package/kits/physics-2d/editors/pxArtTools.js +232 -0
  52. package/kits/physics-2d/editors/useArtboardFit.js +102 -0
  53. package/kits/physics-2d/engine/ScenePlayer.jsx +196 -0
  54. package/kits/physics-2d/engine/SceneUI.jsx +59 -0
  55. package/kits/physics-2d/engine/assets.js +15 -0
  56. package/kits/physics-2d/engine/autoInspector.jsx +70 -0
  57. package/kits/physics-2d/engine/blueprint.js +521 -0
  58. package/kits/physics-2d/engine/collider.js +196 -0
  59. package/kits/physics-2d/engine/files.js +117 -0
  60. package/kits/physics-2d/engine/liveReload.js +88 -0
  61. package/kits/physics-2d/engine/pxart.js +1032 -0
  62. package/kits/physics-2d/engine/pxartSmooth.js +222 -0
  63. package/kits/physics-2d/engine/scene.js +686 -0
  64. package/kits/physics-2d/engine/spriteGeometry.js +32 -0
  65. package/kits/physics-2d/engine/ui.jsx +688 -0
  66. package/kits/physics-2d/engine/ui.module.css +2287 -0
  67. package/kits/physics-2d/eslint.config.js +71 -0
  68. package/kits/physics-2d/index.html +24 -0
  69. package/kits/physics-2d/main.jsx +24 -0
  70. package/kits/physics-2d/package-lock.json +2706 -0
  71. package/kits/physics-2d/package.json +42 -0
  72. package/kits/physics-2d/physics/PhysicsSystem.js +290 -0
  73. package/kits/physics-2d/physics/behaviors/AnalogStick.jsx +101 -0
  74. package/kits/physics-2d/physics/behaviors/Draggable.jsx +79 -0
  75. package/kits/physics-2d/physics/behaviors/RigidBody.jsx +55 -0
  76. package/kits/physics-2d/physics/behaviors/Slingshot.jsx +118 -0
  77. package/kits/physics-2d/physics/controls.js +79 -0
  78. package/kits/physics-2d/physics/index.js +26 -0
  79. package/kits/physics-2d/physics/matterBridge.js +126 -0
  80. package/kits/physics-2d/pnpm-lock.yaml +1761 -0
  81. package/kits/physics-2d/scenes/main.scene +12 -0
  82. package/kits/physics-2d/scenes/sandbox.scene +13 -0
  83. package/kits/physics-2d/scripts/draw.mjs +121 -0
  84. package/kits/physics-2d/vite.config.js +1 -0
  85. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "Main",
3
+ "background": "#1a1932",
4
+ "physics": { "gravity": 1 },
5
+ "actors": [
6
+ { "id": "ball", "blueprint": "blueprints/ball.scene", "components": { "Layout": { "x": 70, "y": 560 } } },
7
+ { "id": "floor", "blueprint": "blueprints/block.scene", "components": { "Layout": { "x": 0, "y": 640, "width": 500, "height": 60 } } },
8
+ { "id": "leftWall", "blueprint": "blueprints/block.scene", "components": { "Layout": { "x": 0, "y": 0, "width": 50, "height": 700 } } },
9
+ { "id": "rightWall", "blueprint": "blueprints/block.scene", "components": { "Layout": { "x": 450, "y": 0, "width": 50, "height": 700 } } },
10
+ { "id": "goal", "blueprint": "blueprints/goal.scene", "components": { "Layout": { "x": 300, "y": 420 } } }
11
+ ]
12
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "Sandbox",
3
+ "background": "#161a2b",
4
+ "physics": { "gravity": 1 },
5
+ "actors": [
6
+ { "id": "floor", "blueprint": "blueprints/block.scene", "components": { "Layout": { "x": 0, "y": 640, "width": 500, "height": 60 } } },
7
+ { "id": "leftWall", "blueprint": "blueprints/block.scene", "components": { "Layout": { "x": 0, "y": 0, "width": 50, "height": 700 } } },
8
+ { "id": "rightWall", "blueprint": "blueprints/block.scene", "components": { "Layout": { "x": 450, "y": 0, "width": 50, "height": 700 } } },
9
+ { "id": "crate1", "blueprint": "blueprints/crate.scene", "components": { "Layout": { "x": 150, "y": 300 } } },
10
+ { "id": "crate2", "blueprint": "blueprints/crate.scene", "components": { "Layout": { "x": 230, "y": 180 } } },
11
+ { "id": "crate3", "blueprint": "blueprints/crate.scene", "components": { "Layout": { "x": 300, "y": 300 } } }
12
+ ]
13
+ }
@@ -0,0 +1,121 @@
1
+ // `npm run draw -- <name>` — turn a terse svg-rect emission into a sprite.
2
+ //
3
+ // Reads an <svg> with one <rect> per pixel from stdin (or `--from <file>`),
4
+ // decodes + palette-quantizes it onto the agent 16-color subset, and writes a
5
+ // single-frame `drawings/<name>.pxart` in the deck (the script's cwd).
6
+ //
7
+ // This is a kit-layer concern: the `.pxart` format lives entirely in the kit
8
+ // (engine/pxart.js); the harness has no knowledge of it.
9
+
10
+ import * as fs from 'fs';
11
+ import * as path from 'path';
12
+ import {
13
+ svgRectToPxArt,
14
+ serializeCompact,
15
+ AGENT_PALETTE_16,
16
+ DEFAULT_RESOLUTION,
17
+ } from '../engine/pxart.js';
18
+
19
+ // Read all of stdin as a UTF-8 string. Resolves '' if stdin is a TTY with no
20
+ // piped input so we can give a clear "no input" error instead of hanging.
21
+ function readStdin() {
22
+ return new Promise((resolve, reject) => {
23
+ if (process.stdin.isTTY) {
24
+ resolve('');
25
+ return;
26
+ }
27
+ const chunks = [];
28
+ process.stdin.on('data', (c) => chunks.push(c));
29
+ process.stdin.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
30
+ process.stdin.on('error', reject);
31
+ });
32
+ }
33
+
34
+ // Normalize a requested sprite name into a relative `drawings/<...>.pxart`
35
+ // path. Tolerates a leading `drawings/` and/or a trailing `.pxart`/`.px.json`
36
+ // so `draw ship`, `draw ship.pxart`, and `draw drawings/ship.pxart` all land in
37
+ // the same place.
38
+ function resolveSpritePath(dir, name) {
39
+ let rel = name.trim().replace(/\\/g, '/');
40
+ rel = rel.replace(/^\.?\/*/, '');
41
+ if (rel.startsWith('drawings/')) rel = rel.slice('drawings/'.length);
42
+ rel = rel.replace(/\.px\.json$/i, '').replace(/\.pxart$/i, '');
43
+ if (!rel) return null;
44
+
45
+ const drawingsDir = path.resolve(dir, 'drawings');
46
+ const filepath = path.resolve(drawingsDir, `${rel}.pxart`);
47
+ const within = path.relative(drawingsDir, filepath);
48
+ if (within.startsWith('..') || path.isAbsolute(within)) return null;
49
+ return filepath;
50
+ }
51
+
52
+ function getFlagValue(flag) {
53
+ const idx = process.argv.indexOf(flag);
54
+ return idx >= 0 ? process.argv[idx + 1] : undefined;
55
+ }
56
+
57
+ // All positional (non-flag) args after the script, in order.
58
+ function positionals() {
59
+ const args = process.argv.slice(2);
60
+ const withValues = new Set(['--from']);
61
+ const out = [];
62
+ for (let i = 0; i < args.length; i++) {
63
+ if (args[i].startsWith('--')) {
64
+ if (withValues.has(args[i])) i++;
65
+ continue;
66
+ }
67
+ out.push(args[i]);
68
+ }
69
+ return out;
70
+ }
71
+
72
+ async function main() {
73
+ const name = positionals()[0];
74
+ if (!name) {
75
+ console.error('Usage: npm run draw -- <name> [--from FILE] (svg-rect on stdin -> drawings/<name>.pxart)');
76
+ process.exit(1);
77
+ }
78
+
79
+ // The script's cwd is the deck; sprites land under <deck>/drawings/.
80
+ const dir = process.cwd();
81
+ const filepath = resolveSpritePath(dir, name);
82
+ if (!filepath) {
83
+ console.error(`Invalid sprite name: ${name}`);
84
+ process.exit(1);
85
+ }
86
+
87
+ const fromFile = getFlagValue('--from');
88
+ let svg;
89
+ if (fromFile) {
90
+ try {
91
+ svg = fs.readFileSync(path.resolve(fromFile), 'utf-8');
92
+ } catch (e) {
93
+ console.error(`Could not read --from file ${fromFile}: ${e instanceof Error ? e.message : String(e)}`);
94
+ process.exit(1);
95
+ }
96
+ } else {
97
+ svg = await readStdin();
98
+ }
99
+
100
+ if (!svg.trim()) {
101
+ console.error('No svg-rect input. Pipe an <svg> with <rect> cells via stdin or pass --from <file>.');
102
+ process.exit(1);
103
+ }
104
+
105
+ const art = svgRectToPxArt(svg, { resolution: DEFAULT_RESOLUTION, palette: AGENT_PALETTE_16 });
106
+ if (!art) {
107
+ console.error('Could not decode any pixels from the svg-rect input (no usable <rect fill="...">). Emit one <rect> per filled pixel on a 16x16 viewBox.');
108
+ process.exit(1);
109
+ }
110
+
111
+ fs.mkdirSync(path.dirname(filepath), { recursive: true });
112
+ fs.writeFileSync(filepath, serializeCompact(art), 'utf-8');
113
+
114
+ const rel = path.relative(path.resolve(dir), filepath);
115
+ console.log(`Wrote ${rel}`);
116
+ }
117
+
118
+ main().catch((e) => {
119
+ console.error(e instanceof Error ? e.message : String(e));
120
+ process.exit(1);
121
+ });
@@ -0,0 +1 @@
1
+ export default {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.83",
3
+ "version": "0.4.85",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "castle-web": "./dist/index.js"