@air-jam/cli 0.0.0-stage → 1.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +273 -2
- package/bin/airjam.mjs +66 -0
- package/dist/ai-pack.d.ts +44 -0
- package/dist/ai-pack.js +15 -0
- package/dist/ai-pack.js.map +1 -0
- package/dist/auth-profile.d.ts +5 -0
- package/dist/auth-profile.js +7 -0
- package/dist/auth-profile.js.map +1 -0
- package/dist/auth-sessions.d.ts +5 -0
- package/dist/auth-sessions.js +7 -0
- package/dist/auth-sessions.js.map +1 -0
- package/dist/chunk-7D4AYBAV.js +64 -0
- package/dist/chunk-7D4AYBAV.js.map +1 -0
- package/dist/chunk-J5MAU4QZ.js +102 -0
- package/dist/chunk-J5MAU4QZ.js.map +1 -0
- package/dist/chunk-LH7UO57C.js +23 -0
- package/dist/chunk-LH7UO57C.js.map +1 -0
- package/dist/chunk-N7AI7HZK.js +529 -0
- package/dist/chunk-N7AI7HZK.js.map +1 -0
- package/dist/chunk-PKTLVQXZ.js +82 -0
- package/dist/chunk-PKTLVQXZ.js.map +1 -0
- package/dist/chunk-SQE4NPZP.js +31 -0
- package/dist/chunk-SQE4NPZP.js.map +1 -0
- package/dist/chunk-U6V3HEBB.js +939 -0
- package/dist/chunk-U6V3HEBB.js.map +1 -0
- package/dist/chunk-VEHNFPEO.js +224 -0
- package/dist/chunk-VEHNFPEO.js.map +1 -0
- package/dist/development.d.ts +102 -0
- package/dist/development.js +33 -0
- package/dist/development.js.map +1 -0
- package/dist/documentation.d.ts +27 -0
- package/dist/documentation.js +7 -0
- package/dist/documentation.js.map +1 -0
- package/dist/game-analytics.d.ts +5 -0
- package/dist/game-analytics.js +7 -0
- package/dist/game-analytics.js.map +1 -0
- package/dist/game-app-id.d.ts +5 -0
- package/dist/game-app-id.js +7 -0
- package/dist/game-app-id.js.map +1 -0
- package/dist/game-media.d.ts +5 -0
- package/dist/game-media.js +7 -0
- package/dist/game-media.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2468 -0
- package/dist/index.js.map +1 -0
- package/dist/scaffold.d.ts +6 -0
- package/dist/scaffold.js +20 -0
- package/dist/scaffold.js.map +1 -0
- package/package.json +82 -3
- package/runtime/local-network.d.mts +6 -0
- package/runtime/local-network.mjs +9 -0
- package/runtime/public-assets.mjs +62 -0
- package/runtime/source-fence.mjs +182 -0
- package/runtime/vite-config.d.mts +43 -0
- package/runtime/vite-config.mjs +134 -0
- package/runtime/vite-dev.mjs +18 -0
- package/runtime/vite-https.d.mts +11 -0
- package/runtime/vite-https.mjs +40 -0
- package/template-assets/bootstrap/.claude/launch.json +12 -0
- package/template-assets/bootstrap/AGENTS.md +290 -0
- package/template-assets/bootstrap/CLAUDE.md +55 -0
- package/template-assets/bootstrap/_gitignore +6 -0
- package/template-assets/bootstrap/skills/airjam-docs-workflow/SKILL.md +49 -0
- package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +100 -0
- package/template-assets/bootstrap/skills/canvas-2d-gameplay/SKILL.md +47 -0
- package/template-assets/bootstrap/skills/controller-ui/SKILL.md +71 -0
- package/template-assets/bootstrap/skills/debug-and-test/SKILL.md +72 -0
- package/template-assets/bootstrap/skills/game-architecture/SKILL.md +102 -0
- package/template-assets/bootstrap/skills/game-state-and-rendering/SKILL.md +44 -0
- package/template-assets/bootstrap/skills/host-surface/SKILL.md +52 -0
- package/template-assets/bootstrap/skills/index.md +36 -0
- package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +58 -0
- package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +61 -0
- package/template-assets/documentation/for-agents/controller-ui/page.mdx +99 -0
- package/template-assets/documentation/for-agents/page.mdx +120 -0
- package/template-assets/documentation/for-agents/project-structure/page.mdx +170 -0
- package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +77 -0
- package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
- package/template-assets/documentation/getting-started/debugging/page.mdx +164 -0
- package/template-assets/documentation/getting-started/dev-logs/page.mdx +169 -0
- package/template-assets/documentation/getting-started/game-ideas/page.mdx +114 -0
- package/template-assets/documentation/getting-started/introduction/page.mdx +200 -0
- package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +673 -0
- package/template-assets/documentation/getting-started/quick-start/page.mdx +310 -0
- package/template-assets/documentation/how-it-works/architecture/page.mdx +230 -0
- package/template-assets/documentation/how-it-works/host-system/page.mdx +270 -0
- package/template-assets/documentation/manifest.json +500 -0
- package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
- package/template-assets/documentation/sdk/hooks/page.mdx +435 -0
- package/template-assets/documentation/sdk/input-system/page.mdx +240 -0
- package/template-assets/documentation/sdk/networked-state/page.mdx +295 -0
- package/template-assets/documentation/sdk/settings/page.mdx +155 -0
- package/template-assets/documentation/sdk/ui-components/page.mdx +268 -0
- package/template-assets/managed/.airjam/ai-pack.json +209 -0
- package/template-assets/managed/docs/airjam/agent-gold-path.md +115 -0
- package/template-assets/managed/docs/airjam/agent-mcp.md +179 -0
- package/template-assets/managed/docs/airjam/canvas-2d-gameplay.md +82 -0
- package/template-assets/managed/docs/airjam/composition-shell-contract.md +87 -0
- package/template-assets/managed/docs/airjam/debug-and-testing.md +104 -0
- package/template-assets/managed/docs/airjam/development-loop.md +51 -0
- package/template-assets/managed/docs/airjam/docs-index.md +64 -0
- package/template-assets/managed/docs/airjam/generated/architecture.md +223 -0
- package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
- package/template-assets/managed/docs/airjam/generated/controller-ui.md +102 -0
- package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +165 -0
- package/template-assets/managed/docs/airjam/generated/for-agents.md +123 -0
- package/template-assets/managed/docs/airjam/generated/game-ideas.md +107 -0
- package/template-assets/managed/docs/airjam/generated/host-system.md +261 -0
- package/template-assets/managed/docs/airjam/generated/input-system.md +241 -0
- package/template-assets/managed/docs/airjam/generated/introduction.md +195 -0
- package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +674 -0
- package/template-assets/managed/docs/airjam/generated/networked-state.md +298 -0
- package/template-assets/managed/docs/airjam/generated/project-structure.md +171 -0
- package/template-assets/managed/docs/airjam/generated/quick-start.md +311 -0
- package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +430 -0
- package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
- package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +80 -0
- package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
- package/template-assets/managed/docs/airjam/generated/ui-components.md +265 -0
- package/template-assets/managed/docs/airjam/generated/unified-dev-logs.md +170 -0
- package/template-assets/managed/docs/airjam/iconography.md +55 -0
- package/template-assets/managed/docs/airjam/prefab-authoring.md +212 -0
- package/template-assets/managed/docs/airjam/preview-controllers.md +129 -0
- package/template-assets/managed/docs/airjam/r3f-3d-scene.md +163 -0
- package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +101 -0
- package/template-assets/managed/docs/airjam/visual-system.md +103 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Air Jam contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,274 @@
|
|
|
1
|
-
|
|
1
|
+
> **Prerelease `1.0.0-beta.1`** from Air Jam's `beta` channel. It is not stable and may change or break between prereleases; install `@latest` for the stable release.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# `@air-jam/cli`
|
|
4
|
+
|
|
5
|
+
The canonical project and operator CLI for Air Jam.
|
|
6
|
+
|
|
7
|
+
`create-airjam` only creates a project. The generated project then depends on
|
|
8
|
+
this package for its complete ongoing lifecycle: development, inspection,
|
|
9
|
+
semantic game control, AI-pack maintenance, MCP setup, hosted game records,
|
|
10
|
+
and releases.
|
|
11
|
+
|
|
12
|
+
## Discover the contract
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm exec airjam --help
|
|
16
|
+
pnpm exec airjam session --help
|
|
17
|
+
pnpm exec airjam mcp --help
|
|
18
|
+
pnpm exec airjam release --help
|
|
19
|
+
pnpm exec airjam game analytics --help
|
|
20
|
+
pnpm exec airjam game media --help
|
|
21
|
+
pnpm exec airjam docs --help
|
|
22
|
+
pnpm exec airjam rooms check --help
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Machine-first local lifecycle
|
|
26
|
+
|
|
27
|
+
These commands return stable JSON documents and are safe for terminal agents
|
|
28
|
+
to compose:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm exec airjam status --dir .
|
|
32
|
+
pnpm exec airjam evaluate --dir .
|
|
33
|
+
pnpm exec airjam dev start --dir .
|
|
34
|
+
pnpm exec airjam session open --dir .
|
|
35
|
+
pnpm exec airjam session read <session-id> --dir .
|
|
36
|
+
pnpm exec airjam session invoke <session-id> <action-id> --payload '{}'
|
|
37
|
+
pnpm exec airjam session capture <session-id> --dir .
|
|
38
|
+
pnpm exec airjam session close <session-id> --dir .
|
|
39
|
+
pnpm exec airjam dev stop --dir .
|
|
40
|
+
pnpm exec airjam reset local --dir .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`airjam evaluate` is the canonical complete evaluation contract. It runs
|
|
44
|
+
typecheck, lint, tests, and the production build, then returns every gate in one
|
|
45
|
+
stable `air-jam-complete-evaluation/v1` JSON document. The MCP equivalent is
|
|
46
|
+
`airjam.evaluate`; use individual quality gates only to narrow a failure.
|
|
47
|
+
|
|
48
|
+
A semantic session starts or reuses the canonical Air Jam dev process, opens a
|
|
49
|
+
real controller/runtime connection, exposes the game's published semantic
|
|
50
|
+
actions and authoritative snapshot, and releases processes it created when the
|
|
51
|
+
last session closes. The project-local broker is authenticated, loopback-only,
|
|
52
|
+
and can capture canonical desktop-host and phone-controller screenshots into
|
|
53
|
+
the owning project's `.airjam/artifacts/session-visuals` directory. It can be
|
|
54
|
+
inspected or stopped explicitly:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pnpm exec airjam session broker status --dir .
|
|
58
|
+
pnpm exec airjam session broker stop --dir .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Agent clients
|
|
62
|
+
|
|
63
|
+
The Air Jam MCP exposes the same underlying project, development, semantic
|
|
64
|
+
session, quality, and release services to Codex, Claude, and other MCP clients.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm exec airjam mcp doctor --dir . --json
|
|
68
|
+
pnpm exec airjam mcp init --dir .
|
|
69
|
+
pnpm exec airjam mcp config --profile portable --dir .
|
|
70
|
+
pnpm exec airjam mcp config --profile codex --dir .
|
|
71
|
+
pnpm exec airjam mcp config --profile claude-desktop --dir .
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The portable declaration is `.mcp.json`. Codex and Claude Desktop use their
|
|
75
|
+
own client registration formats; `mcp doctor` reports declarations and actual
|
|
76
|
+
client registrations separately.
|
|
77
|
+
|
|
78
|
+
The Claude Desktop profile targets the selected game's absolute directory.
|
|
79
|
+
Merge its `airjam` entry into Desktop's configuration through **Settings >
|
|
80
|
+
Developer > Edit config**, preserving other connectors, then restart Desktop
|
|
81
|
+
and check its connection status. Rendering a profile does not register it;
|
|
82
|
+
`claude mcp add` is a Claude Code command, not a Desktop installer. See the
|
|
83
|
+
[`@air-jam/mcp-server` setup guide](https://github.com/vucinatim/air-jam/tree/main/packages/mcp-server#discover-and-connect) for details.
|
|
84
|
+
|
|
85
|
+
## Platform machine authentication
|
|
86
|
+
|
|
87
|
+
Sign in, change the creator name shown on games and in rooms, then inspect the current profile:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pnpm exec airjam auth login
|
|
91
|
+
pnpm exec airjam auth profile --display-name "Party Maker" --json
|
|
92
|
+
pnpm exec airjam auth whoami
|
|
93
|
+
pnpm exec airjam auth sessions --json
|
|
94
|
+
pnpm exec airjam auth sessions revoke <session-id> --json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`auth profile` trims the name and requires 1–50 characters. It returns the updated
|
|
98
|
+
user (`id`, `name`, `email`, `role`) with `--json`, or prints the display name.
|
|
99
|
+
Validation errors and missing or expired sessions fail with a nonzero exit.
|
|
100
|
+
`auth whoami` reads the current name from the platform. Both commands accept
|
|
101
|
+
`--platform-url <url>` for the signed-in platform; `auth logout` revokes the session.
|
|
102
|
+
|
|
103
|
+
Access tokens expire after one hour. CLI and MCP automatically exchange the
|
|
104
|
+
refresh token and atomically save the new pair in the existing credential file.
|
|
105
|
+
Refresh tokens rotate after each use and expire after 30 idle days; replaying a
|
|
106
|
+
spent token revokes the whole session. Concurrent processes serialize refreshes
|
|
107
|
+
through a credential-file lock. Existing logins convert on their first use
|
|
108
|
+
without browser approval. Explicit access tokens are caller-managed.
|
|
109
|
+
|
|
110
|
+
`auth sessions` lists this account’s live machine sessions (ID, client name,
|
|
111
|
+
creation and last use); `auth sessions revoke <id>` revokes one. Both support
|
|
112
|
+
`--json` and `--platform-url`. Logout revokes the current session and removes
|
|
113
|
+
the saved credential. A revoked or idle-expired session requires `auth login`.
|
|
114
|
+
The machine contract currently grants one fixed account scope; client names
|
|
115
|
+
are display metadata.
|
|
116
|
+
|
|
117
|
+
CLI and MCP platform operations share one authentication transport. A saved
|
|
118
|
+
login is bound to the platform origin that issued it: changing the platform URL
|
|
119
|
+
cannot silently send that saved token to another server. Log in to the other
|
|
120
|
+
platform, or deliberately supply its own explicit token and target instead.
|
|
121
|
+
Equivalent host casing, default ports, and trailing slashes do not change the
|
|
122
|
+
origin. Self-hosted HTTPS targets are supported; HTTP is limited to loopback
|
|
123
|
+
development addresses.
|
|
124
|
+
|
|
125
|
+
Invalid target URLs fail rather than falling back to localhost. API paths stay
|
|
126
|
+
on the selected origin, and redirects are rejected rather than replaying
|
|
127
|
+
tokens or device codes elsewhere. Device login stores the requested platform
|
|
128
|
+
only after the response confirms the same origin. This destination boundary
|
|
129
|
+
does not change token scopes, expiry, or server-side ownership checks.
|
|
130
|
+
|
|
131
|
+
## Framework guidance ownership
|
|
132
|
+
|
|
133
|
+
The CLI owns the canonical managed framework pack under `docs/airjam/`.
|
|
134
|
+
Project instructions (`AGENTS.md`, `CLAUDE.md`, and `skills/`) are copied only
|
|
135
|
+
during bootstrap and belong to the project afterward.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pnpm exec airjam ai-pack status --dir . --json
|
|
139
|
+
pnpm exec airjam ai-pack diff --dir . --json
|
|
140
|
+
pnpm exec airjam ai-pack update --dir . --json
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
AI-pack updates replace managed framework guidance only. They never overwrite
|
|
144
|
+
project-owned agent instructions or skills.
|
|
145
|
+
|
|
146
|
+
## Programmatic assets
|
|
147
|
+
|
|
148
|
+
The installed package includes all public creator pages and their portable
|
|
149
|
+
metadata. Read them without an account, network request or source checkout:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pnpm exec airjam docs list --json
|
|
153
|
+
pnpm exec airjam docs read sdk/ui-components --json
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`readDocumentationSnapshot()` from `@air-jam/cli/documentation` returns the
|
|
157
|
+
package version and verified MDX content, page identities and navigation
|
|
158
|
+
metadata. Content and metadata originate in the public repository's
|
|
159
|
+
`content/docs/` catalog. The private website supplies rendering components and
|
|
160
|
+
generates its build inputs from this snapshot; it does not maintain a second
|
|
161
|
+
authored copy. MDX component names are presentation slots, not imports of private
|
|
162
|
+
application code. Only trusted package documentation is compiled this way,
|
|
163
|
+
never creator-uploaded MDX. The API reads do not write project files.
|
|
164
|
+
|
|
165
|
+
Scaffolding code can resolve the two explicit asset roots and portable MCP
|
|
166
|
+
declaration through `@air-jam/cli/scaffold`. Vite projects use
|
|
167
|
+
`@air-jam/cli/vite-config`.
|
|
168
|
+
|
|
169
|
+
`AIR_JAM_BUILD_BASE` optionally sets the Vite build base for immutable hosted
|
|
170
|
+
artifacts, for example `/v/<generation>/`. It defaults to `/` and must be an
|
|
171
|
+
absolute directory path ending in `/`. The embedding application supplies the
|
|
172
|
+
matching public runtime topology; ordinary local development is unchanged.
|
|
173
|
+
|
|
174
|
+
Repository-owned development orchestration can use the typed
|
|
175
|
+
`@air-jam/cli/development` entrypoint for local network discovery, environment
|
|
176
|
+
loading, runtime topology construction and secure-development state. It shares
|
|
177
|
+
the CLI implementation; consumers do not import files inside its source tree.
|
|
178
|
+
Reading state or constructing a topology does not initialize certificates or
|
|
179
|
+
change tunnel configuration. `runSecureInitCli()` is the explicit setup action,
|
|
180
|
+
with the same arguments and effects as `airjam secure:init`.
|
|
181
|
+
|
|
182
|
+
`readAiPackSnapshot()` from `@air-jam/cli/ai-pack` returns the verified
|
|
183
|
+
packaged manifest and a `Map<string, Buffer>` of managed file contents. Consumers
|
|
184
|
+
can serve that exact snapshot without a CLI source checkout, network request or
|
|
185
|
+
second pack generator. Invalid manifests, paths or content hashes fail the read;
|
|
186
|
+
it does not modify the package or a creator's project.
|
|
187
|
+
|
|
188
|
+
## Hosted release lifecycle
|
|
189
|
+
|
|
190
|
+
`airjam release inspect --release <id>` and `airjam release list --game <slug-or-id>`
|
|
191
|
+
include the exact play link for hidden and listed releases.
|
|
192
|
+
`airjam release archive --release <id>` retires an owned release and prints its
|
|
193
|
+
updated summary as JSON. Each accepts `--platform-url`; authentication uses the
|
|
194
|
+
existing machine session. See the [hosted release guide](../../docs/guides/hosted-release-guide.md).
|
|
195
|
+
|
|
196
|
+
## Hosted catalog media
|
|
197
|
+
|
|
198
|
+
Inspect all existing thumbnails, covers and preview clips, restore an earlier
|
|
199
|
+
asset as current for its kind, or archive an asset by ID:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
pnpm exec airjam game media list --game my-game --json
|
|
203
|
+
pnpm exec airjam game media assign --game my-game --asset-id <asset-id> --json
|
|
204
|
+
pnpm exec airjam game media archive --game my-game --asset-id <asset-id> --json
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
`list` is an alias for `inspect`. The game accepts its slug or ID. All three
|
|
208
|
+
commands accept `--platform-url` and use the saved machine session. Each has
|
|
209
|
+
`--help`; omit `--json` for readable terminal output.
|
|
210
|
+
|
|
211
|
+
Listing returns `{ game, active, assets }`. Each asset includes `id`, `kind`
|
|
212
|
+
(`thumbnail`, `cover`, `preview_video`), `status`, `isActive`, and its file
|
|
213
|
+
metadata. `active` holds the current asset ID for each kind. Assign and archive
|
|
214
|
+
return `{ game, active, asset }` from the same platform service. With `--json`,
|
|
215
|
+
stdout contains exactly that JSON document. Missing games or assets fail with
|
|
216
|
+
the platform's not-found message and a nonzero exit status.
|
|
217
|
+
|
|
218
|
+
Assignment reuses an existing asset without uploading it again. The platform
|
|
219
|
+
validates ownership and whether the asset can be assigned. Archiving clears
|
|
220
|
+
the slot if the asset is current. Use `upload` to add new files and `clear`
|
|
221
|
+
to archive whichever asset is current for a kind.
|
|
222
|
+
|
|
223
|
+
## Creator gameplay analytics
|
|
224
|
+
|
|
225
|
+
Sign in with `airjam auth login`, then read the analytics from your game's **Analytics** section in Create:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
airjam game analytics overview --game my-game --days 14 --json
|
|
229
|
+
airjam game analytics sessions --game my-game --limit 8 --json
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`--game` accepts an owned slug or ID. `--platform-url` selects the platform.
|
|
233
|
+
Overview days are 1–90 (default 14); session limits are 1–25 (default 8).
|
|
234
|
+
Without `--json`, the command prints a readable summary.
|
|
235
|
+
The overview JSON contains `days`, `totals` and UTC `daily` buckets; sessions JSON
|
|
236
|
+
is an array of recent session records, newest first. Dates are ISO strings and
|
|
237
|
+
missing dates remain null. Empty games return zero totals and an empty session
|
|
238
|
+
array. Session records retain room IDs, controller seconds, eligible playtime
|
|
239
|
+
and trust flags; these are recorded runtime facts, not unique-player counts.
|
|
240
|
+
Unauthenticated requests fail and games belonging to someone else return not-found.
|
|
241
|
+
|
|
242
|
+
## Game App IDs and slugs
|
|
243
|
+
|
|
244
|
+
Sign in with `airjam auth login` to inspect or manage an owned game's App ID:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
airjam game app-id inspect --game my-game --json
|
|
248
|
+
airjam game app-id origins --game my-game --origin https://game.example --origin http://localhost:5173 --json
|
|
249
|
+
airjam game app-id origins --game my-game --clear --json
|
|
250
|
+
airjam game app-id regenerate --game my-game --yes --json
|
|
251
|
+
airjam game slug-available --slug new-name --game my-game --json
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Inspection returns the key, allowed origins, active state, creation time and last
|
|
255
|
+
use. Origins replace the full allowlist; URLs are normalized to origins and
|
|
256
|
+
deduplicated by the platform. `--clear` removes restrictions. Regeneration breaks
|
|
257
|
+
deployed games using the previous key and refuses without `--yes`.
|
|
258
|
+
Slug availability returns `{ "available": true | false }`; omit `--game` for a
|
|
259
|
+
new game, or supply an owned slug or ID to exclude that game when renaming.
|
|
260
|
+
These commands call the hosted platform; they do not publish or deploy a game.
|
|
261
|
+
|
|
262
|
+
## Keeping local setting defaults
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
airjam game settings keep --set ballSpeed=400 --dir ./pong --json
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Repeat `--set name=value` to keep several settings together. Values are parsed
|
|
269
|
+
using each declared kind. This rewrites only the `default:` literals in the
|
|
270
|
+
`defineAirJamSettings` selected by `src/airjam.config.ts`, preserving comments
|
|
271
|
+
and formatting. The game must have its own `typescript` dependency. The JSON
|
|
272
|
+
result contains `file` and `kept: [{ key, from, to }]`; equal values are reported
|
|
273
|
+
unchanged and write nothing. Unknown keys, invalid values and ambiguous or
|
|
274
|
+
computed defaults fail with an `AJ_*` refusal before any source is written.
|
package/bin/airjam.mjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
|
|
8
|
+
const packageRoot = path.resolve(
|
|
9
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
10
|
+
"..",
|
|
11
|
+
);
|
|
12
|
+
const distEntry = path.join(packageRoot, "dist", "index.js");
|
|
13
|
+
const repoRoot = path.resolve(packageRoot, "../..");
|
|
14
|
+
const workspaceBuildScript = path.join(
|
|
15
|
+
repoRoot,
|
|
16
|
+
"scripts",
|
|
17
|
+
"ensure-workspace-package-build.mjs",
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const buildWorkspacePackage = async () => {
|
|
21
|
+
if (!existsSync(workspaceBuildScript)) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"The installed @air-jam/cli package is missing its built CLI entrypoint.",
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
await new Promise((resolve, reject) => {
|
|
28
|
+
const child = spawn(
|
|
29
|
+
process.execPath,
|
|
30
|
+
[workspaceBuildScript, "@air-jam/cli"],
|
|
31
|
+
{
|
|
32
|
+
cwd: repoRoot,
|
|
33
|
+
stdio: "inherit",
|
|
34
|
+
env: process.env,
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
child.on("exit", (code, signal) => {
|
|
39
|
+
if (code === 0) {
|
|
40
|
+
resolve(undefined);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
reject(
|
|
45
|
+
new Error(
|
|
46
|
+
signal
|
|
47
|
+
? `Workspace CLI build terminated by signal ${signal}.`
|
|
48
|
+
: `Workspace CLI build exited with code ${code}.`,
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
child.on("error", reject);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
if (!existsSync(distEntry)) {
|
|
57
|
+
await buildWorkspacePackage();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!existsSync(distEntry)) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
"The @air-jam/cli build completed without producing dist/index.js.",
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await import(pathToFileURL(distEntry).href);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type AiPackFile = {
|
|
2
|
+
path: string;
|
|
3
|
+
kind: "docs-local" | "docs-generated";
|
|
4
|
+
size: number;
|
|
5
|
+
sha256: string;
|
|
6
|
+
};
|
|
7
|
+
type AiPackManifest = {
|
|
8
|
+
schemaVersion: 2;
|
|
9
|
+
packVersion: string;
|
|
10
|
+
channel: "stable" | "canary";
|
|
11
|
+
releaseDate: string;
|
|
12
|
+
source: {
|
|
13
|
+
mode: "packaged-snapshot";
|
|
14
|
+
package: "@air-jam/cli";
|
|
15
|
+
};
|
|
16
|
+
scaffold: {
|
|
17
|
+
template: string | null;
|
|
18
|
+
createAirjamVersion: string | null;
|
|
19
|
+
};
|
|
20
|
+
managedFiles: AiPackFile[];
|
|
21
|
+
contentDigest: string;
|
|
22
|
+
};
|
|
23
|
+
declare const readAiPackSnapshot: () => Promise<{
|
|
24
|
+
manifest: AiPackManifest;
|
|
25
|
+
contents: Map<string, Buffer<ArrayBufferLike>>;
|
|
26
|
+
}>;
|
|
27
|
+
declare function runAiPackStatus({ dir, json, }: {
|
|
28
|
+
dir?: string;
|
|
29
|
+
json?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
declare function runAiPackDiff({ dir, json, }: {
|
|
32
|
+
dir?: string;
|
|
33
|
+
json?: boolean;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
declare function runAiPackUpdate({ dir, json, }: {
|
|
36
|
+
dir?: string;
|
|
37
|
+
json?: boolean;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
declare function runAiPackRepair({ dir, json, }: {
|
|
40
|
+
dir?: string;
|
|
41
|
+
json?: boolean;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
|
|
44
|
+
export { readAiPackSnapshot, runAiPackDiff, runAiPackRepair, runAiPackStatus, runAiPackUpdate };
|
package/dist/ai-pack.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readAiPackSnapshot,
|
|
3
|
+
runAiPackDiff,
|
|
4
|
+
runAiPackRepair,
|
|
5
|
+
runAiPackStatus,
|
|
6
|
+
runAiPackUpdate
|
|
7
|
+
} from "./chunk-N7AI7HZK.js";
|
|
8
|
+
export {
|
|
9
|
+
readAiPackSnapshot,
|
|
10
|
+
runAiPackDiff,
|
|
11
|
+
runAiPackRepair,
|
|
12
|
+
runAiPackStatus,
|
|
13
|
+
runAiPackUpdate
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=ai-pack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/game-analytics.ts
|
|
2
|
+
import {
|
|
3
|
+
getPlatformGameAnalyticsOverview,
|
|
4
|
+
getPlatformGameAnalyticsSessions
|
|
5
|
+
} from "@air-jam/devtools/platform-game-analytics";
|
|
6
|
+
var registerGameAnalyticsCommand = (gameCommand) => {
|
|
7
|
+
const analyticsCommand = gameCommand.command("analytics").description("Read creator gameplay analytics for an owned game");
|
|
8
|
+
analyticsCommand.command("overview").description("Read the gameplay overview").requiredOption("--game <slug-or-id>", "Owned game slug or ID").option("--platform-url <url>", "Hosted Air Jam platform base URL").option("--days <days>", "Overview window, 1\u201390 days (default: 14)", Number).option("--json", "Print one machine-readable JSON document", false).action(
|
|
9
|
+
async (options) => {
|
|
10
|
+
const overview = await getPlatformGameAnalyticsOverview({
|
|
11
|
+
platformUrl: options.platformUrl,
|
|
12
|
+
slugOrId: options.game,
|
|
13
|
+
days: options.days
|
|
14
|
+
});
|
|
15
|
+
if (options.json) {
|
|
16
|
+
process.stdout.write(`${JSON.stringify(overview, null, 2)}
|
|
17
|
+
`);
|
|
18
|
+
} else {
|
|
19
|
+
console.log(`Gameplay over ${overview.days} days`);
|
|
20
|
+
console.log(`Sessions: ${overview.totals.sessionCount}`);
|
|
21
|
+
console.log(
|
|
22
|
+
`Peak controllers: ${overview.totals.peakConcurrentControllers}`
|
|
23
|
+
);
|
|
24
|
+
console.log(
|
|
25
|
+
`Game active seconds: ${overview.totals.totalGameActiveSeconds}`
|
|
26
|
+
);
|
|
27
|
+
console.log(
|
|
28
|
+
`Controller seconds: ${overview.totals.totalControllerSeconds}`
|
|
29
|
+
);
|
|
30
|
+
console.log(
|
|
31
|
+
`Eligible playtime seconds: ${overview.totals.totalEligiblePlaytimeSeconds}`
|
|
32
|
+
);
|
|
33
|
+
console.log(
|
|
34
|
+
`Last activity: ${overview.totals.lastActivityAt ?? "none"}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
analyticsCommand.command("sessions").description("Read recent gameplay sessions").requiredOption("--game <slug-or-id>", "Owned game slug or ID").option("--platform-url <url>", "Hosted Air Jam platform base URL").option("--limit <limit>", "Recent sessions, 1\u201325 (default: 8)", Number).option("--json", "Print one machine-readable JSON document", false).action(
|
|
40
|
+
async (options) => {
|
|
41
|
+
const sessions = await getPlatformGameAnalyticsSessions({
|
|
42
|
+
platformUrl: options.platformUrl,
|
|
43
|
+
slugOrId: options.game,
|
|
44
|
+
limit: options.limit
|
|
45
|
+
});
|
|
46
|
+
if (options.json) {
|
|
47
|
+
process.stdout.write(`${JSON.stringify(sessions, null, 2)}
|
|
48
|
+
`);
|
|
49
|
+
} else {
|
|
50
|
+
console.log(`Recent sessions: ${sessions.length}`);
|
|
51
|
+
for (const session of sessions) {
|
|
52
|
+
console.log(
|
|
53
|
+
`${session.roomId} ${session.startedAt} peak controllers: ${session.peakConcurrentControllers} controller seconds: ${session.controllerSeconds}`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
registerGameAnalyticsCommand
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=chunk-7D4AYBAV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/game-analytics.ts"],"sourcesContent":["import {\n getPlatformGameAnalyticsOverview,\n getPlatformGameAnalyticsSessions,\n} from \"@air-jam/devtools/platform-game-analytics\";\nimport { Command } from \"commander\";\n\nexport const registerGameAnalyticsCommand = (gameCommand: Command) => {\n const analyticsCommand = gameCommand\n .command(\"analytics\")\n .description(\"Read creator gameplay analytics for an owned game\");\n\n analyticsCommand\n .command(\"overview\")\n .description(\"Read the gameplay overview\")\n .requiredOption(\"--game <slug-or-id>\", \"Owned game slug or ID\")\n .option(\"--platform-url <url>\", \"Hosted Air Jam platform base URL\")\n .option(\"--days <days>\", \"Overview window, 1–90 days (default: 14)\", Number)\n .option(\"--json\", \"Print one machine-readable JSON document\", false)\n .action(\n async (options: {\n game: string;\n platformUrl?: string;\n days?: number;\n json: boolean;\n }) => {\n const overview = await getPlatformGameAnalyticsOverview({\n platformUrl: options.platformUrl,\n slugOrId: options.game,\n days: options.days,\n });\n if (options.json) {\n process.stdout.write(`${JSON.stringify(overview, null, 2)}\\n`);\n } else {\n console.log(`Gameplay over ${overview.days} days`);\n console.log(`Sessions: ${overview.totals.sessionCount}`);\n console.log(\n `Peak controllers: ${overview.totals.peakConcurrentControllers}`,\n );\n console.log(\n `Game active seconds: ${overview.totals.totalGameActiveSeconds}`,\n );\n console.log(\n `Controller seconds: ${overview.totals.totalControllerSeconds}`,\n );\n console.log(\n `Eligible playtime seconds: ${overview.totals.totalEligiblePlaytimeSeconds}`,\n );\n console.log(\n `Last activity: ${overview.totals.lastActivityAt ?? \"none\"}`,\n );\n }\n },\n );\n\n analyticsCommand\n .command(\"sessions\")\n .description(\"Read recent gameplay sessions\")\n .requiredOption(\"--game <slug-or-id>\", \"Owned game slug or ID\")\n .option(\"--platform-url <url>\", \"Hosted Air Jam platform base URL\")\n .option(\"--limit <limit>\", \"Recent sessions, 1–25 (default: 8)\", Number)\n .option(\"--json\", \"Print one machine-readable JSON document\", false)\n .action(\n async (options: {\n game: string;\n platformUrl?: string;\n limit?: number;\n json: boolean;\n }) => {\n const sessions = await getPlatformGameAnalyticsSessions({\n platformUrl: options.platformUrl,\n slugOrId: options.game,\n limit: options.limit,\n });\n if (options.json) {\n process.stdout.write(`${JSON.stringify(sessions, null, 2)}\\n`);\n } else {\n console.log(`Recent sessions: ${sessions.length}`);\n for (const session of sessions) {\n console.log(\n `${session.roomId} ${session.startedAt} peak controllers: ${session.peakConcurrentControllers} controller seconds: ${session.controllerSeconds}`,\n );\n }\n }\n },\n );\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAGA,IAAM,+BAA+B,CAAC,gBAAyB;AACpE,QAAM,mBAAmB,YACtB,QAAQ,WAAW,EACnB,YAAY,mDAAmD;AAElE,mBACG,QAAQ,UAAU,EAClB,YAAY,4BAA4B,EACxC,eAAe,uBAAuB,uBAAuB,EAC7D,OAAO,wBAAwB,kCAAkC,EACjE,OAAO,iBAAiB,iDAA4C,MAAM,EAC1E,OAAO,UAAU,4CAA4C,KAAK,EAClE;AAAA,IACC,OAAO,YAKD;AACJ,YAAM,WAAW,MAAM,iCAAiC;AAAA,QACtD,aAAa,QAAQ;AAAA,QACrB,UAAU,QAAQ;AAAA,QAClB,MAAM,QAAQ;AAAA,MAChB,CAAC;AACD,UAAI,QAAQ,MAAM;AAChB,gBAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA,CAAI;AAAA,MAC/D,OAAO;AACL,gBAAQ,IAAI,iBAAiB,SAAS,IAAI,OAAO;AACjD,gBAAQ,IAAI,aAAa,SAAS,OAAO,YAAY,EAAE;AACvD,gBAAQ;AAAA,UACN,qBAAqB,SAAS,OAAO,yBAAyB;AAAA,QAChE;AACA,gBAAQ;AAAA,UACN,wBAAwB,SAAS,OAAO,sBAAsB;AAAA,QAChE;AACA,gBAAQ;AAAA,UACN,uBAAuB,SAAS,OAAO,sBAAsB;AAAA,QAC/D;AACA,gBAAQ;AAAA,UACN,8BAA8B,SAAS,OAAO,4BAA4B;AAAA,QAC5E;AACA,gBAAQ;AAAA,UACN,kBAAkB,SAAS,OAAO,kBAAkB,MAAM;AAAA,QAC5D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEF,mBACG,QAAQ,UAAU,EAClB,YAAY,+BAA+B,EAC3C,eAAe,uBAAuB,uBAAuB,EAC7D,OAAO,wBAAwB,kCAAkC,EACjE,OAAO,mBAAmB,2CAAsC,MAAM,EACtE,OAAO,UAAU,4CAA4C,KAAK,EAClE;AAAA,IACC,OAAO,YAKD;AACJ,YAAM,WAAW,MAAM,iCAAiC;AAAA,QACtD,aAAa,QAAQ;AAAA,QACrB,UAAU,QAAQ;AAAA,QAClB,OAAO,QAAQ;AAAA,MACjB,CAAC;AACD,UAAI,QAAQ,MAAM;AAChB,gBAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA,CAAI;AAAA,MAC/D,OAAO;AACL,gBAAQ,IAAI,oBAAoB,SAAS,MAAM,EAAE;AACjD,mBAAW,WAAW,UAAU;AAC9B,kBAAQ;AAAA,YACN,GAAG,QAAQ,MAAM,KAAK,QAAQ,SAAS,uBAAuB,QAAQ,yBAAyB,yBAAyB,QAAQ,iBAAiB;AAAA,UACnJ;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACJ;","names":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/documentation.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
import fs from "fs/promises";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
var documentationPageSchema = z.object({
|
|
8
|
+
title: z.string().min(1),
|
|
9
|
+
href: z.string().regex(/^\/docs\/[a-z0-9-]+(?:\/[a-z0-9-]+)*$/),
|
|
10
|
+
description: z.string().min(1),
|
|
11
|
+
section: z.string().min(1),
|
|
12
|
+
icon: z.enum([
|
|
13
|
+
"info",
|
|
14
|
+
"rocket",
|
|
15
|
+
"lightbulb",
|
|
16
|
+
"layers",
|
|
17
|
+
"cpu",
|
|
18
|
+
"code",
|
|
19
|
+
"zap",
|
|
20
|
+
"network",
|
|
21
|
+
"bot"
|
|
22
|
+
]),
|
|
23
|
+
keywords: z.array(z.string().min(1)),
|
|
24
|
+
docType: z.enum([
|
|
25
|
+
"concept",
|
|
26
|
+
"guide",
|
|
27
|
+
"reference",
|
|
28
|
+
"contract",
|
|
29
|
+
"migration",
|
|
30
|
+
"agent"
|
|
31
|
+
]),
|
|
32
|
+
order: z.number().int().nonnegative(),
|
|
33
|
+
sinceVersion: z.string().min(1).optional(),
|
|
34
|
+
lastVerifiedVersion: z.string().min(1).optional(),
|
|
35
|
+
stability: z.enum(["stable", "evolving", "experimental"]).optional(),
|
|
36
|
+
audience: z.enum(["user", "maintainer", "agent", "studio"]).optional()
|
|
37
|
+
}).strict();
|
|
38
|
+
var documentationManifestSchema = z.object({
|
|
39
|
+
schemaVersion: z.literal(1),
|
|
40
|
+
packageVersion: z.string().min(1),
|
|
41
|
+
requiredComponents: z.array(z.string().regex(/^[A-Z][A-Za-z0-9]*$/)).min(1),
|
|
42
|
+
documents: z.array(
|
|
43
|
+
z.object({
|
|
44
|
+
source: z.string().regex(/^[a-z0-9-]+(?:\/[a-z0-9-]+)*\/page\.mdx$/),
|
|
45
|
+
page: documentationPageSchema,
|
|
46
|
+
size: z.number().int().nonnegative(),
|
|
47
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/)
|
|
48
|
+
}).strict()
|
|
49
|
+
).min(1)
|
|
50
|
+
}).strict();
|
|
51
|
+
async function readDocumentationSnapshot() {
|
|
52
|
+
const root = fileURLToPath(
|
|
53
|
+
new URL("../template-assets/documentation/", import.meta.url)
|
|
54
|
+
);
|
|
55
|
+
const manifest = documentationManifestSchema.parse(
|
|
56
|
+
JSON.parse(await fs.readFile(path.join(root, "manifest.json"), "utf8"))
|
|
57
|
+
);
|
|
58
|
+
const seen = /* @__PURE__ */ new Set();
|
|
59
|
+
const documents = [];
|
|
60
|
+
for (const document of manifest.documents) {
|
|
61
|
+
const expectedHref = `/docs/${document.source.replace(/\/page\.mdx$/, "")}`;
|
|
62
|
+
if (seen.has(document.source) || document.page.href !== expectedHref) {
|
|
63
|
+
throw new Error(`Invalid documentation identity: ${document.source}.`);
|
|
64
|
+
}
|
|
65
|
+
seen.add(document.source);
|
|
66
|
+
const content = await fs.readFile(path.join(root, document.source));
|
|
67
|
+
const digest = createHash("sha256").update(content).digest("hex");
|
|
68
|
+
if (content.length !== document.size || digest !== document.sha256) {
|
|
69
|
+
throw new Error(`Documentation integrity failed for ${document.source}.`);
|
|
70
|
+
}
|
|
71
|
+
let fence = null;
|
|
72
|
+
for (const line of content.toString("utf8").split("\n")) {
|
|
73
|
+
const fenceMatch = line.match(/^\s*(`{3,}|~{3,})/);
|
|
74
|
+
if (fenceMatch) {
|
|
75
|
+
if (fence === null) fence = fenceMatch[1][0];
|
|
76
|
+
else if (fenceMatch[1][0] === fence) fence = null;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (fence !== null) continue;
|
|
80
|
+
const prose = line.replace(/(`+)[\s\S]*?\1/g, "");
|
|
81
|
+
for (const match of prose.matchAll(/<\/?([A-Z][A-Za-z0-9]*)\b/g)) {
|
|
82
|
+
if (!manifest.requiredComponents.includes(match[1])) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Undeclared documentation component ${match[1]} in ${document.source}.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
documents.push({ ...document, content: content.toString("utf8") });
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
schemaVersion: manifest.schemaVersion,
|
|
93
|
+
packageVersion: manifest.packageVersion,
|
|
94
|
+
requiredComponents: manifest.requiredComponents,
|
|
95
|
+
documents
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
readDocumentationSnapshot
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=chunk-J5MAU4QZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/documentation.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { z } from \"zod\";\n\nconst documentationPageSchema = z\n .object({\n title: z.string().min(1),\n href: z.string().regex(/^\\/docs\\/[a-z0-9-]+(?:\\/[a-z0-9-]+)*$/),\n description: z.string().min(1),\n section: z.string().min(1),\n icon: z.enum([\n \"info\",\n \"rocket\",\n \"lightbulb\",\n \"layers\",\n \"cpu\",\n \"code\",\n \"zap\",\n \"network\",\n \"bot\",\n ]),\n keywords: z.array(z.string().min(1)),\n docType: z.enum([\n \"concept\",\n \"guide\",\n \"reference\",\n \"contract\",\n \"migration\",\n \"agent\",\n ]),\n order: z.number().int().nonnegative(),\n sinceVersion: z.string().min(1).optional(),\n lastVerifiedVersion: z.string().min(1).optional(),\n stability: z.enum([\"stable\", \"evolving\", \"experimental\"]).optional(),\n audience: z.enum([\"user\", \"maintainer\", \"agent\", \"studio\"]).optional(),\n })\n .strict();\n\nconst documentationManifestSchema = z\n .object({\n schemaVersion: z.literal(1),\n packageVersion: z.string().min(1),\n requiredComponents: z.array(z.string().regex(/^[A-Z][A-Za-z0-9]*$/)).min(1),\n documents: z\n .array(\n z\n .object({\n source: z\n .string()\n .regex(/^[a-z0-9-]+(?:\\/[a-z0-9-]+)*\\/page\\.mdx$/),\n page: documentationPageSchema,\n size: z.number().int().nonnegative(),\n sha256: z.string().regex(/^[a-f0-9]{64}$/),\n })\n .strict(),\n )\n .min(1),\n })\n .strict();\n\nexport async function readDocumentationSnapshot() {\n const root = fileURLToPath(\n new URL(\"../template-assets/documentation/\", import.meta.url),\n );\n const manifest = documentationManifestSchema.parse(\n JSON.parse(await fs.readFile(path.join(root, \"manifest.json\"), \"utf8\")),\n );\n const seen = new Set<string>();\n const documents = [];\n for (const document of manifest.documents) {\n const expectedHref = `/docs/${document.source.replace(/\\/page\\.mdx$/, \"\")}`;\n if (seen.has(document.source) || document.page.href !== expectedHref) {\n throw new Error(`Invalid documentation identity: ${document.source}.`);\n }\n seen.add(document.source);\n const content = await fs.readFile(path.join(root, document.source));\n const digest = createHash(\"sha256\").update(content).digest(\"hex\");\n if (content.length !== document.size || digest !== document.sha256) {\n throw new Error(`Documentation integrity failed for ${document.source}.`);\n }\n let fence: string | null = null;\n for (const line of content.toString(\"utf8\").split(\"\\n\")) {\n const fenceMatch = line.match(/^\\s*(`{3,}|~{3,})/);\n if (fenceMatch) {\n if (fence === null) fence = fenceMatch[1][0];\n else if (fenceMatch[1][0] === fence) fence = null;\n continue;\n }\n if (fence !== null) continue;\n const prose = line.replace(/(`+)[\\s\\S]*?\\1/g, \"\");\n for (const match of prose.matchAll(/<\\/?([A-Z][A-Za-z0-9]*)\\b/g)) {\n if (!manifest.requiredComponents.includes(match[1])) {\n throw new Error(\n `Undeclared documentation component ${match[1]} in ${document.source}.`,\n );\n }\n }\n }\n documents.push({ ...document, content: content.toString(\"utf8\") });\n }\n return {\n schemaVersion: manifest.schemaVersion,\n packageVersion: manifest.packageVersion,\n requiredComponents: manifest.requiredComponents,\n documents,\n };\n}\n"],"mappings":"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","names":[]}
|