@air-jam/cli 0.9.3 → 1.0.0-beta.2

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 (97) hide show
  1. package/README.md +128 -0
  2. package/dist/auth-profile.d.ts +5 -0
  3. package/dist/auth-profile.js +7 -0
  4. package/dist/auth-profile.js.map +1 -0
  5. package/dist/auth-sessions.d.ts +5 -0
  6. package/dist/auth-sessions.js +7 -0
  7. package/dist/auth-sessions.js.map +1 -0
  8. package/dist/chunk-7D4AYBAV.js +64 -0
  9. package/dist/chunk-7D4AYBAV.js.map +1 -0
  10. package/dist/chunk-LH7UO57C.js +23 -0
  11. package/dist/chunk-LH7UO57C.js.map +1 -0
  12. package/dist/chunk-PKTLVQXZ.js +82 -0
  13. package/dist/chunk-PKTLVQXZ.js.map +1 -0
  14. package/dist/chunk-SQE4NPZP.js +31 -0
  15. package/dist/chunk-SQE4NPZP.js.map +1 -0
  16. package/dist/{chunk-A4V2N4LX.js → chunk-U6V3HEBB.js} +6 -5
  17. package/dist/chunk-U6V3HEBB.js.map +1 -0
  18. package/dist/chunk-VEHNFPEO.js +224 -0
  19. package/dist/chunk-VEHNFPEO.js.map +1 -0
  20. package/dist/development.d.ts +4 -0
  21. package/dist/development.js +1 -1
  22. package/dist/game-analytics.d.ts +5 -0
  23. package/dist/game-analytics.js +7 -0
  24. package/dist/game-analytics.js.map +1 -0
  25. package/dist/game-app-id.d.ts +5 -0
  26. package/dist/game-app-id.js +7 -0
  27. package/dist/game-app-id.js.map +1 -0
  28. package/dist/game-media.d.ts +5 -0
  29. package/dist/game-media.js +7 -0
  30. package/dist/game-media.js.map +1 -0
  31. package/dist/index.js +688 -404
  32. package/dist/index.js.map +1 -1
  33. package/dist/scaffold.d.ts +8 -1
  34. package/dist/scaffold.js +6 -1
  35. package/dist/scaffold.js.map +1 -1
  36. package/package.json +8 -4
  37. package/runtime/local-network.d.mts +4 -6
  38. package/runtime/public-assets.mjs +62 -0
  39. package/runtime/source-fence.mjs +182 -0
  40. package/runtime/vite-config.d.mts +2 -1
  41. package/runtime/vite-config.mjs +6 -2
  42. package/runtime/vite-dev.mjs +18 -0
  43. package/runtime/vite-https.mjs +2 -3
  44. package/template-assets/bootstrap/AGENTS.md +56 -14
  45. package/template-assets/bootstrap/CLAUDE.md +0 -8
  46. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
  47. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
  48. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
  49. package/template-assets/bootstrap/skills/index.md +1 -1
  50. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
  51. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
  52. package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
  53. package/template-assets/documentation/for-agents/page.mdx +24 -2
  54. package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
  55. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +0 -2
  56. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  57. package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
  58. package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
  59. package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
  60. package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
  61. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
  62. package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
  63. package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
  64. package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
  65. package/template-assets/documentation/manifest.json +112 -42
  66. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  67. package/template-assets/documentation/sdk/hooks/page.mdx +106 -171
  68. package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
  69. package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
  70. package/template-assets/documentation/sdk/settings/page.mdx +155 -0
  71. package/template-assets/documentation/sdk/ui-components/page.mdx +45 -4
  72. package/template-assets/managed/.airjam/ai-pack.json +61 -43
  73. package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
  74. package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
  75. package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
  76. package/template-assets/managed/docs/airjam/docs-index.md +18 -12
  77. package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
  78. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  79. package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
  80. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
  81. package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
  82. package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
  83. package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
  84. package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
  85. package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
  86. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
  87. package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
  88. package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
  89. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +106 -166
  90. package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
  91. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  92. package/template-assets/managed/docs/airjam/generated/ui-components.md +45 -2
  93. package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
  94. package/template-assets/managed/docs/airjam/preview-controllers.md +4 -1
  95. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
  96. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
  97. package/dist/chunk-A4V2N4LX.js.map +0 -1
@@ -1,6 +1,13 @@
1
1
  export { AIRJAM_PROJECT_MCP_FILE, createProjectLocalMcpConfig } from '@air-jam/devtools/mcp-config';
2
+ import { AirJamHostedEnvironment } from '@air-jam/sdk/core';
2
3
 
3
4
  declare const resolveAirJamManagedAssetsDir: () => string;
4
5
  declare const resolveAirJamBootstrapAssetsDir: () => string;
5
6
 
6
- export { resolveAirJamBootstrapAssetsDir, resolveAirJamManagedAssetsDir };
7
+ /**
8
+ * The hosted Air Jam a new game publishes to: a prerelease scaffolder builds
9
+ * against beta, a release against production.
10
+ */
11
+ declare const resolveScaffoldHostedEnvironment: (createAirJamVersion: string) => AirJamHostedEnvironment;
12
+
13
+ export { resolveAirJamBootstrapAssetsDir, resolveAirJamManagedAssetsDir, resolveScaffoldHostedEnvironment };
package/dist/scaffold.js CHANGED
@@ -3,6 +3,9 @@ import {
3
3
  AIRJAM_PROJECT_MCP_FILE,
4
4
  createProjectLocalMcpConfig
5
5
  } from "@air-jam/devtools/mcp-config";
6
+ import {
7
+ AIR_JAM_HOSTED_ENVIRONMENTS
8
+ } from "@air-jam/sdk/core";
6
9
  import path from "path";
7
10
  import { fileURLToPath } from "url";
8
11
  var packageRoot = path.resolve(
@@ -11,10 +14,12 @@ var packageRoot = path.resolve(
11
14
  );
12
15
  var resolveAirJamManagedAssetsDir = () => path.join(packageRoot, "template-assets", "managed");
13
16
  var resolveAirJamBootstrapAssetsDir = () => path.join(packageRoot, "template-assets", "bootstrap");
17
+ var resolveScaffoldHostedEnvironment = (createAirJamVersion) => AIR_JAM_HOSTED_ENVIRONMENTS[createAirJamVersion.includes("-") ? 1 : 0];
14
18
  export {
15
19
  AIRJAM_PROJECT_MCP_FILE,
16
20
  createProjectLocalMcpConfig,
17
21
  resolveAirJamBootstrapAssetsDir,
18
- resolveAirJamManagedAssetsDir
22
+ resolveAirJamManagedAssetsDir,
23
+ resolveScaffoldHostedEnvironment
19
24
  };
20
25
  //# sourceMappingURL=scaffold.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scaffold.ts"],"sourcesContent":["import {\n AIRJAM_PROJECT_MCP_FILE,\n createProjectLocalMcpConfig,\n} from \"@air-jam/devtools/mcp-config\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst packageRoot = path.resolve(\n path.dirname(fileURLToPath(import.meta.url)),\n \"..\",\n);\n\nexport const resolveAirJamManagedAssetsDir = (): string =>\n path.join(packageRoot, \"template-assets\", \"managed\");\n\nexport const resolveAirJamBootstrapAssetsDir = (): string =>\n path.join(packageRoot, \"template-assets\", \"bootstrap\");\n\nexport { AIRJAM_PROJECT_MCP_FILE, createProjectLocalMcpConfig };\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,IAAM,cAAc,KAAK;AAAA,EACvB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAAA,EAC3C;AACF;AAEO,IAAM,gCAAgC,MAC3C,KAAK,KAAK,aAAa,mBAAmB,SAAS;AAE9C,IAAM,kCAAkC,MAC7C,KAAK,KAAK,aAAa,mBAAmB,WAAW;","names":[]}
1
+ {"version":3,"sources":["../src/scaffold.ts"],"sourcesContent":["import {\n AIRJAM_PROJECT_MCP_FILE,\n createProjectLocalMcpConfig,\n} from \"@air-jam/devtools/mcp-config\";\nimport {\n AIR_JAM_HOSTED_ENVIRONMENTS,\n type AirJamHostedEnvironment,\n} from \"@air-jam/sdk/core\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst packageRoot = path.resolve(\n path.dirname(fileURLToPath(import.meta.url)),\n \"..\",\n);\n\nexport const resolveAirJamManagedAssetsDir = (): string =>\n path.join(packageRoot, \"template-assets\", \"managed\");\n\nexport const resolveAirJamBootstrapAssetsDir = (): string =>\n path.join(packageRoot, \"template-assets\", \"bootstrap\");\n\nexport { AIRJAM_PROJECT_MCP_FILE, createProjectLocalMcpConfig };\n\n/**\n * The hosted Air Jam a new game publishes to: a prerelease scaffolder builds\n * against beta, a release against production.\n */\nexport const resolveScaffoldHostedEnvironment = (\n createAirJamVersion: string,\n): AirJamHostedEnvironment =>\n AIR_JAM_HOSTED_ENVIRONMENTS[createAirJamVersion.includes(\"-\") ? 1 : 0];\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AACP,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,IAAM,cAAc,KAAK;AAAA,EACvB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAAA,EAC3C;AACF;AAEO,IAAM,gCAAgC,MAC3C,KAAK,KAAK,aAAa,mBAAmB,SAAS;AAE9C,IAAM,kCAAkC,MAC7C,KAAK,KAAK,aAAa,mBAAmB,WAAW;AAQhD,IAAM,mCAAmC,CAC9C,wBAEA,4BAA4B,oBAAoB,SAAS,GAAG,IAAI,IAAI,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@air-jam/cli",
3
- "version": "0.9.3",
3
+ "version": "1.0.0-beta.2",
4
4
  "engines": {
5
- "node": ">=22.0.0"
5
+ "node": ">=22.15.0"
6
6
  },
7
7
  "description": "Canonical project and operator CLI for Air Jam game development, agent sessions, and hosted releases",
8
8
  "type": "module",
@@ -48,6 +48,9 @@
48
48
  "bin",
49
49
  "dist",
50
50
  "runtime/vite-config.mjs",
51
+ "runtime/source-fence.mjs",
52
+ "runtime/public-assets.mjs",
53
+ "runtime/vite-dev.mjs",
51
54
  "runtime/vite-config.d.mts",
52
55
  "runtime/vite-https.mjs",
53
56
  "runtime/vite-https.d.mts",
@@ -56,12 +59,13 @@
56
59
  "template-assets"
57
60
  ],
58
61
  "dependencies": {
59
- "@air-jam/devtools": "0.9.3",
60
- "@air-jam/sdk": "^0.9.3",
62
+ "@air-jam/devtools": "1.0.0-beta.2",
63
+ "@air-jam/sdk": "^1.0.0-beta.2",
61
64
  "commander": "^14.0.0",
62
65
  "cross-spawn": "^7.0.6",
63
66
  "fs-extra": "^11.3.0",
64
67
  "kleur": "^4.1.5",
68
+ "sirv": "^3.0.2",
65
69
  "zod": "^4.2.1"
66
70
  },
67
71
  "devDependencies": {
@@ -1,8 +1,6 @@
1
1
  export const DEFAULT_AIR_JAM_SERVER_PORT: number;
2
2
 
3
- export function resolveLocalBackendOrigin(
4
- env?: {
5
- AIR_JAM_SERVER_PORT?: string | number;
6
- VITE_AIR_JAM_SERVER_URL?: string;
7
- },
8
- ): string;
3
+ export function resolveLocalBackendOrigin(env?: {
4
+ AIR_JAM_SERVER_PORT?: string | number;
5
+ VITE_AIR_JAM_SERVER_URL?: string;
6
+ }): string;
@@ -0,0 +1,62 @@
1
+ import { realpathSync, statSync } from "node:fs";
2
+ import { isAbsolute, relative, resolve, sep } from "node:path";
3
+ import sirv from "sirv";
4
+
5
+ function contains(directory, file) {
6
+ const path = relative(directory, file);
7
+ return path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path);
8
+ }
9
+
10
+ export function publicAssetFallback(server) {
11
+ const { publicDir, base } = server.config;
12
+ if (!publicDir) return (_request, _response, next) => next();
13
+ const serve = sirv(publicDir, {
14
+ dev: true,
15
+ etag: true,
16
+ extensions: [],
17
+ setHeaders(response, path) {
18
+ if (/\.(?:[tj]sx?|[cm][tj]s)$/.test(path))
19
+ response.setHeader("Content-Type", "text/javascript");
20
+ for (const [name, value] of Object.entries(
21
+ server.config.server.headers ?? {},
22
+ ))
23
+ response.setHeader(name, value);
24
+ },
25
+ });
26
+ return (request, response, next) => {
27
+ if (!["GET", "HEAD"].includes(request.method)) return next();
28
+ // Vite's HTML fallback rewrites url before configureServer's post hook.
29
+ const original = request.originalUrl;
30
+ if (!original?.startsWith(base)) return next();
31
+ const url = `/${original.slice(base.length)}`;
32
+ const [encodedPath, query] = url.split("?");
33
+ const parameters = new URLSearchParams(query);
34
+ if (["import", "raw", "url"].some((name) => parameters.has(name)))
35
+ return next();
36
+ let path;
37
+ try {
38
+ path = decodeURI(encodedPath);
39
+ } catch {
40
+ return next();
41
+ }
42
+ if (path.includes("\0")) return next();
43
+ const file = resolve(publicDir, `.${path}`);
44
+ if (!contains(publicDir, file)) return next();
45
+ try {
46
+ if (
47
+ !contains(realpathSync(publicDir), realpathSync(file)) ||
48
+ !statSync(file).isFile()
49
+ )
50
+ return next();
51
+ } catch (error) {
52
+ if (["ENOENT", "ENOTDIR"].includes(error.code)) return next();
53
+ return next(error);
54
+ }
55
+ const previous = request.url;
56
+ request.url = url;
57
+ serve(request, response, (error) => {
58
+ request.url = previous;
59
+ next(error);
60
+ });
61
+ };
62
+ }
@@ -0,0 +1,182 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { createHash } from "node:crypto";
3
+ import { readFileSync } from "node:fs";
4
+ import { resolve } from "node:path";
5
+ import { publicAssetFallback } from "./public-assets.mjs";
6
+
7
+ function read(path) {
8
+ try {
9
+ return readFileSync(path);
10
+ } catch (error) {
11
+ if (error.code === "ENOENT") return null;
12
+ throw error;
13
+ }
14
+ }
15
+
16
+ // Replay final watcher events for Vite's caches, but batch their browser delivery.
17
+ export function sourceFencePlugin() {
18
+ const replay = new AsyncLocalStorage();
19
+ return {
20
+ name: "airjam-source-fence",
21
+ apply: "serve",
22
+ hotUpdate: {
23
+ order: "post",
24
+ handler() {
25
+ // Public-file registration and module bookkeeping precede this hook.
26
+ replay.getStore()?.resolve();
27
+ },
28
+ },
29
+ configureServer(server) {
30
+ const marker = resolve(
31
+ server.config.root,
32
+ ".airjam/devtools/source-change.json",
33
+ );
34
+ const watcher = server.watcher;
35
+ const emit = watcher.emit;
36
+ const expected = new Map();
37
+ const queued = new Map();
38
+ const waiting = new Set();
39
+ const restore = [];
40
+ let seen;
41
+ let held = false;
42
+ let settling = false;
43
+ for (const channel of new Set([
44
+ server.ws,
45
+ ...Object.values(server.environments).map(
46
+ (environment) => environment.hot,
47
+ ),
48
+ ])) {
49
+ const send = channel.send;
50
+ channel.send = function (message, ...argumentsList) {
51
+ const context = replay.getStore();
52
+ if (context) {
53
+ if (message.type === "error")
54
+ context.reject(new Error(message.err.message));
55
+ if (
56
+ ["update", "full-reload", "prune", "error"].includes(message.type)
57
+ )
58
+ return;
59
+ }
60
+ return send.call(this, message, ...argumentsList);
61
+ };
62
+ restore.push(() => {
63
+ channel.send = send;
64
+ });
65
+ }
66
+ function dispatch(event, argumentsList) {
67
+ return new Promise((resolvePromise, reject) => {
68
+ replay.run({ resolve: resolvePromise, reject }, () =>
69
+ emit.call(watcher, event, ...argumentsList),
70
+ );
71
+ });
72
+ }
73
+ async function settle(state) {
74
+ const events = new Map(queued);
75
+ queued.clear();
76
+ for (const file of state.files ?? []) {
77
+ const path = resolve(server.config.root, file.path);
78
+ expected.set(path, file.hash);
79
+ // Explicit final events also cover OS notifications arriving after release.
80
+ events.set(path, [file.event, [path]]);
81
+ }
82
+ if (state.phase !== "applying" && !state.committed) return;
83
+ if (server.config.server.hmr === false) {
84
+ await server.restart();
85
+ return;
86
+ }
87
+ const configFiles = new Set([
88
+ server.config.configFile,
89
+ ...server.config.configFileDependencies,
90
+ ...(server.config.envDir === false
91
+ ? []
92
+ : [
93
+ ".env",
94
+ ".env.local",
95
+ `.env.${server.config.mode}`,
96
+ `.env.${server.config.mode}.local`,
97
+ ].map((name) => resolve(server.config.envDir, name))),
98
+ ]);
99
+ let changedConfig;
100
+ const pending = [];
101
+ for (const [path, [event, argumentsList]] of events) {
102
+ if (configFiles.has(path)) changedConfig = path;
103
+ else pending.push(dispatch(event, argumentsList));
104
+ }
105
+ await Promise.all(pending);
106
+ if (changedConfig) {
107
+ // Let Vite reload its own config once, including plugin and env caches.
108
+ emit.call(watcher, "change", changedConfig);
109
+ } else {
110
+ for (const environment of Object.values(server.environments))
111
+ environment.moduleGraph.invalidateAll();
112
+ server.ws.send({ type: "full-reload", path: "*" });
113
+ }
114
+ }
115
+ function reconcile() {
116
+ const bytes = read(marker);
117
+ const state = bytes && JSON.parse(bytes.toString());
118
+ held = state?.phase === "applying" && state.expiresAt > Date.now();
119
+ if (held || settling) return;
120
+ if (state && state.id !== seen) {
121
+ seen = state.id;
122
+ settling = true;
123
+ return settle(state)
124
+ .catch((error) => {
125
+ server.ws.send({
126
+ type: "error",
127
+ err: { message: error.message, stack: error.stack },
128
+ });
129
+ })
130
+ .finally(() => {
131
+ settling = false;
132
+ reconcile();
133
+ });
134
+ }
135
+ for (const next of waiting) next();
136
+ waiting.clear();
137
+ }
138
+ // A settled marker from before this server started needs no reload.
139
+ const initial = read(marker);
140
+ if (initial) {
141
+ const state = JSON.parse(initial.toString());
142
+ if (state.phase === "settled") seen = state.id;
143
+ }
144
+ watcher.emit = function (event, ...argumentsList) {
145
+ if (["change", "add", "unlink"].includes(event)) {
146
+ reconcile();
147
+ const path = resolve(argumentsList[0]);
148
+ if (expected.has(path)) {
149
+ const content = read(path);
150
+ const hash =
151
+ content === null
152
+ ? null
153
+ : createHash("sha256").update(content).digest("hex");
154
+ if (hash === expected.get(path)) return false;
155
+ expected.delete(path);
156
+ }
157
+ if (held) {
158
+ queued.set(path, [event, argumentsList]);
159
+ return false;
160
+ }
161
+ }
162
+ return emit.call(this, event, ...argumentsList);
163
+ };
164
+ server.middlewares.use((_request, _response, next) => {
165
+ reconcile();
166
+ if (held || settling) waiting.add(next);
167
+ else next();
168
+ });
169
+ const timer = setInterval(reconcile, 25);
170
+ timer.unref();
171
+ const cleanup = () => {
172
+ clearInterval(timer);
173
+ watcher.emit = emit;
174
+ for (const reset of restore) reset();
175
+ for (const next of waiting) next();
176
+ waiting.clear();
177
+ };
178
+ server.httpServer?.once("close", cleanup);
179
+ return () => server.middlewares.use(publicAssetFallback(server));
180
+ },
181
+ };
182
+ }
@@ -16,7 +16,7 @@ export declare const AIR_JAM_IFRAME_HEADERS: {
16
16
  };
17
17
 
18
18
  type AirJamViteServerConfig = {
19
- host: true;
19
+ host: string | true;
20
20
  allowedHosts: true;
21
21
  https: ReturnType<typeof getAirJamHttpsServerOptions>;
22
22
  port: number;
@@ -28,6 +28,7 @@ type AirJamViteServerConfig = {
28
28
  export declare function createAirJamViteConfig(
29
29
  options?: CreateAirJamViteConfigOptions,
30
30
  ): {
31
+ base: string;
31
32
  build: {
32
33
  chunkSizeWarningLimit: number;
33
34
  rollupOptions?: {
@@ -61,7 +61,6 @@ const resolveThreeProfileManualChunk = (id) => {
61
61
  if (
62
62
  id.includes("/zustand/") ||
63
63
  id.includes("/howler/") ||
64
- id.includes("/socket.io-client/") ||
65
64
  id.includes("/qrcode/")
66
65
  ) {
67
66
  return "app-runtime";
@@ -88,7 +87,7 @@ const resolveBuildConfig = (profile) => {
88
87
  };
89
88
 
90
89
  const createSharedDevServerConfig = ({ env, port }) => ({
91
- host: true,
90
+ host: env.AIR_JAM_BIND_HOST?.trim() || true,
92
91
  allowedHosts: true,
93
92
  https: getAirJamHttpsServerOptions(env),
94
93
  port,
@@ -111,8 +110,13 @@ export const createAirJamViteConfig = ({
111
110
  }
112
111
 
113
112
  const build = resolveBuildConfig(profile);
113
+ const base = env.AIR_JAM_BUILD_BASE || "/";
114
+ if (!/^\/(?:[a-zA-Z0-9_-]+\/)*$/.test(base)) {
115
+ throw new Error("AIR_JAM_BUILD_BASE must be an absolute directory path.");
116
+ }
114
117
 
115
118
  return {
119
+ base,
116
120
  build,
117
121
  server: {
118
122
  ...createSharedDevServerConfig({ env, port }),
@@ -0,0 +1,18 @@
1
+ import { createRequire } from "node:module";
2
+ import { resolve } from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import { sourceFencePlugin } from "./source-fence.mjs";
5
+
6
+ // Resolve the game's Vite, keeping it an app dependency rather than a CLI copy.
7
+ const require = createRequire(resolve("package.json"));
8
+ const { createServer } = await import(
9
+ pathToFileURL(require.resolve("vite")).href
10
+ );
11
+ const host = process.env.AIR_JAM_BIND_HOST?.trim();
12
+ const server = await createServer({
13
+ plugins: [sourceFencePlugin()],
14
+ ...(host ? { server: { host } } : {}),
15
+ });
16
+ await server.listen();
17
+ server.printUrls();
18
+ server.bindCLIShortcuts({ print: true });
@@ -21,14 +21,13 @@ export const getAirJamHttpsServerOptions = (env = process.env) => {
21
21
  };
22
22
 
23
23
  export const getAirJamDevBackendUrl = (env = process.env) =>
24
- env.AIR_JAM_DEV_PROXY_BACKEND_URL?.trim() ||
25
- resolveLocalBackendOrigin(env);
24
+ env.AIR_JAM_DEV_PROXY_BACKEND_URL?.trim() || resolveLocalBackendOrigin(env);
26
25
 
27
26
  export const getAirJamDevProxyOptions = (env = process.env) => {
28
27
  const target = getAirJamDevBackendUrl(env);
29
28
 
30
29
  return {
31
- "/socket.io": {
30
+ "/v1": {
32
31
  target,
33
32
  ws: true,
34
33
  changeOrigin: true,
@@ -108,20 +108,16 @@ If the current game does not expose the action an agent needs, add a small game-
108
108
 
109
109
  ## Browser And Machine Workflow Rule
110
110
 
111
- For local host/controller UI work:
112
-
113
- 1. use the current agent or client's built-in browser or in-app browser tooling first when available
114
- 2. prefer a visible local browser session for real host/controller verification
115
- 3. use the Air Jam MCP alongside browser work for logs, topology, host staging actions, runtime inspection, and quality gates
116
- 4. use secondary browser MCPs such as Chrome DevTools only when the built-in browser tooling is unavailable or when low-level DOM, network, or performance inspection is required
117
- 5. do not treat browser automation as the primary game-control path when a host staging action or semantic game action can express the intent directly
118
- 6. if Claude Code Desktop preview launches the app, use the committed `.claude/launch.json`; it runs the normal dev command with the preview-managed adapter Claude Preview needs
119
- 7. for other browser/preview tools that ask for a launch command, use `pnpm run dev`; do not fall back to raw `vite` or a separate preview-only script
120
- 8. for Claude Code or similar preview surfaces, keep host and preview controllers in the same visible preview screen when possible; add multiple preview controllers from the host preview workspace instead of opening unrelated OS browser tabs unless the user asks for tabs
121
- 9. for visible controller UI smoke tests, interact with preview controllers through real browser click/drag/release gestures; do not synthesize pointer events into controller iframes from parent-page eval
122
- 10. for reliable gameplay, physics, scoring, reset, and state assertions, use the semantic agent contract and Air Jam MCP game-session actions
123
- 11. if local runtime state feels stale, use Air Jam status/log/reset tooling before debugging gameplay code: `pnpm exec airjam status`, `pnpm exec airjam reset local`, and `pnpm exec air-jam-server logs --view=signal`
124
- 12. after editing host-only runtime refs, physics loops, or `useHostActionListener` side effects, hard refresh the host or run `pnpm exec airjam reset local` if actions appear duplicated or rendered state no longer matches replicated state
111
+ For local host/controller UI work, follow the environment's global browser policy:
112
+
113
+ 1. use the Air Jam MCP alongside browser work for logs, topology, host staging actions, runtime inspection, and quality gates
114
+ 2. do not treat browser automation as the primary game-control path when a host staging action or semantic game action can express the intent directly
115
+ 3. start the app with `pnpm run dev`; do not fall back to raw `vite` or a separate preview-only script
116
+ 4. keep host and preview controllers in the same host screen when possible; add multiple preview controllers from the host workspace instead of opening unrelated browser tabs
117
+ 5. for visible controller UI smoke tests, interact with preview controllers through real browser click/drag/release gestures; do not synthesize pointer events into controller iframes from parent-page eval
118
+ 6. for reliable gameplay, physics, scoring, reset, and state assertions, use the semantic agent contract and Air Jam MCP game-session actions
119
+ 7. if local runtime state feels stale, use Air Jam status/log/reset tooling before debugging gameplay code: `pnpm exec airjam status`, `pnpm exec airjam reset local`, and `pnpm exec air-jam-server logs --view=signal`
120
+ 8. after editing host-only runtime refs, physics loops, or `useHostActionListener` side effects, hard refresh the host or run `pnpm exec airjam reset local` if actions appear duplicated or rendered state no longer matches replicated state
125
121
 
126
122
  When a clean-slate game stops being trivial:
127
123
 
@@ -183,6 +179,8 @@ If the project uses canvas:
183
179
 
184
180
  ### Controller
185
181
 
182
+ A game whose `inputModalities` include `'joystick'` always gets a landscape controller; the SDK applies it, so do not set orientation; lay it out with `GamepadLayout` from `@air-jam/sdk/ui`: the stick under the left thumb, the actions under the right in a square the same size, and only short status between them.
183
+
186
184
  1. gameplay controller UI should live inside an absolute `inset-0` root
187
185
  2. prefer large touch targets
188
186
  3. disable accidental text selection
@@ -246,3 +244,47 @@ If a requested change clearly requires a cleaner boundary, say so directly and d
246
244
  Do not preserve a weak structure just because the short-term patch looks smaller.
247
245
 
248
246
  Always suggest the next highest long term value task at the end of your response.
247
+
248
+ ## One game declaration
249
+
250
+ Read `airjam.inspect_game` for the versioned `declaration`, including
251
+ `declaration.agent`, controls, controller path and metadata. The game's
252
+ `src/airjam.config.ts` exports `airjam = defineAirJamGame(...)` from
253
+ `@air-jam/sdk/core`; agent helpers also come from core. Keep React, the SDK
254
+ root, TSX and CSS out of its graph. `app.tsx` alone binds it with
255
+ `createAirJamApp(airjam, { runtime })`.
256
+
257
+ Capacity comes from `metadata.maxPlayers`. The `testing` path names a module
258
+ exporting `testing = defineAirJamTesting({ player, profiles, visual })` from
259
+ `@air-jam/devtools/testing`. Profiles author scripted policies only; a declared
260
+ player is offered as the reserved `model` policy in every profile. Optional
261
+ `visual.scenarios` uses the game's declared agent. A profile's `setup` brings
262
+ the room to where its test starts; its `handBack` returns the creator's room,
263
+ usually with `return_to_lobby`, once the test ends and before its players
264
+ leave, so the game never plays on without them. Profiles that join play already
265
+ under way hand it back too. Declare `handBack: []` only when the game has no
266
+ phase to leave, such as a shared counter; a missing one is reported as
267
+ `undeclared` in the run record. Do not duplicate identity in template flags or read config source with
268
+ regular expressions.
269
+
270
+ ## Declared settings
271
+
272
+ Declare creator tuning values with `defineAirJamSettings` and `setting` from
273
+ `@air-jam/sdk/core`, in the game declaration's `settings` field. Remove the
274
+ constants they replace. Read values in simulation create/step/observe contexts
275
+ and typed action contexts; host rendering uses `useAirJamSettings`. Controllers
276
+ show copies in replicated state. Lobby player choices stay store state.
277
+
278
+ Inspect descriptors in `airjam.inspect_game` → `declaration.settings`.
279
+ Use `airjam.read_game_settings({ gameSessionId })` for live values and revision,
280
+ then `airjam.update_game_settings({ gameSessionId, patch, expectedRevision })`
281
+ under host authority. Only `live: true` values can change; non-live values go
282
+ in `airjam.start_game_run({ settings, ... })` for a fresh room. Stale revisions
283
+ require a fresh read. Input log version 2 records initial values and ordered
284
+ settings updates for replay. See `docs/airjam/generated/settings.md`.
285
+
286
+ Declared assets and theme are read through `airjam.inspect_game` in
287
+ `declaration.assets` and `declaration.theme`. Keep sounds, images and loaded
288
+ files in `defineAirJamAssets`, colours and font families in `defineAirJamTheme`,
289
+ and pass both to `defineAirJamGame`. The React binding owns audio mounts and
290
+ theme CSS variables; games consume the declared objects and never duplicate them.
@@ -16,14 +16,6 @@ Do not use raw `vite` for normal Air Jam work. It skips the local Air Jam server
16
16
 
17
17
  Do not create or prefer a separate preview-specific package script.
18
18
 
19
- Claude Code Desktop preview is already configured through `.claude/launch.json`. Use that preview configuration when opening the embedded preview. It runs:
20
-
21
- ```bash
22
- pnpm run dev -- --preview-managed
23
- ```
24
-
25
- This keeps Vite as the foreground process for Claude Preview while Air Jam manages the local server in the background. Humans and normal terminal workflows should still use `pnpm run dev`.
26
-
27
19
  Use these recovery commands before debugging gameplay code when local runtime state looks stale:
28
20
 
29
21
  ```bash
@@ -54,3 +54,47 @@ Prefer direct shell commands for:
54
54
  1. raw git operations
55
55
  2. arbitrary file inspection not covered by the MCP
56
56
  3. repo maintenance outside Air Jam devtools boundaries
57
+
58
+ ## One game declaration
59
+
60
+ Read `airjam.inspect_game` for the versioned `declaration`, including
61
+ `declaration.agent`, controls, controller path and metadata. The game's
62
+ `src/airjam.config.ts` exports `airjam = defineAirJamGame(...)` from
63
+ `@air-jam/sdk/core`; agent helpers also come from core. Keep React, the SDK
64
+ root, TSX and CSS out of its graph. `app.tsx` alone binds it with
65
+ `createAirJamApp(airjam, { runtime })`.
66
+
67
+ Capacity comes from `metadata.maxPlayers`. The `testing` path names a module
68
+ exporting `testing = defineAirJamTesting({ player, profiles, visual })` from
69
+ `@air-jam/devtools/testing`. Profiles author scripted policies only; a declared
70
+ player is offered as the reserved `model` policy in every profile. Optional
71
+ `visual.scenarios` uses the game's declared agent. A profile's `setup` brings
72
+ the room to where its test starts; its `handBack` returns the creator's room,
73
+ usually with `return_to_lobby`, once the test ends and before its players
74
+ leave, so the game never plays on without them. Profiles that join play already
75
+ under way hand it back too. Declare `handBack: []` only when the game has no
76
+ phase to leave, such as a shared counter; a missing one is reported as
77
+ `undeclared` in the run record. Do not duplicate identity in template flags or read config source with
78
+ regular expressions.
79
+
80
+ ## Declared settings
81
+
82
+ Declare creator tuning values with `defineAirJamSettings` and `setting` from
83
+ `@air-jam/sdk/core`, in the game declaration's `settings` field. Remove the
84
+ constants they replace. Read values in simulation create/step/observe contexts
85
+ and typed action contexts; host rendering uses `useAirJamSettings`. Controllers
86
+ show copies in replicated state. Lobby player choices stay store state.
87
+
88
+ Inspect descriptors in `airjam.inspect_game` → `declaration.settings`.
89
+ Use `airjam.read_game_settings({ gameSessionId })` for live values and revision,
90
+ then `airjam.update_game_settings({ gameSessionId, patch, expectedRevision })`
91
+ under host authority. Only `live: true` values can change; non-live values go
92
+ in `airjam.start_game_run({ settings, ... })` for a fresh room. Stale revisions
93
+ require a fresh read. Input log version 2 records initial values and ordered
94
+ settings updates for replay. See `docs/airjam/generated/settings.md`.
95
+
96
+ Declared assets and theme are read through `airjam.inspect_game` in
97
+ `declaration.assets` and `declaration.theme`. Keep sounds, images and loaded
98
+ files in `defineAirJamAssets`, colours and font families in `defineAirJamTheme`,
99
+ and pass both to `defineAirJamGame`. The React binding owns audio mounts and
100
+ theme CSS variables; games consume the declared objects and never duplicate them.
@@ -16,6 +16,8 @@ Use this skill for controller gameplay and lobby surfaces.
16
16
 
17
17
  ## Gameplay Rules
18
18
 
19
+ A game whose `inputModalities` include `'joystick'` always gets a sideways controller; lay it out with `GamepadLayout` as the Sideways Controllers section of `docs/airjam/generated/controller-ui.md` describes.
20
+
19
21
  1. gameplay controller UI should live inside an absolute `inset-0` root
20
22
  2. avoid scroll during active gameplay
21
23
  3. use large touch targets