@air-jam/devtools 0.0.0-stage → 0.9.3

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 (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -2
  3. package/dist/agent.d.ts +15 -0
  4. package/dist/agent.js +19 -0
  5. package/dist/agent.js.map +1 -0
  6. package/dist/chunk-5YAARMW5.js +36 -0
  7. package/dist/chunk-5YAARMW5.js.map +1 -0
  8. package/dist/chunk-6WQODT37.js +1019 -0
  9. package/dist/chunk-6WQODT37.js.map +1 -0
  10. package/dist/chunk-CKFT2ZJE.js +801 -0
  11. package/dist/chunk-CKFT2ZJE.js.map +1 -0
  12. package/dist/chunk-ER3Q2C4G.js +358 -0
  13. package/dist/chunk-ER3Q2C4G.js.map +1 -0
  14. package/dist/chunk-GUEZP773.js +851 -0
  15. package/dist/chunk-GUEZP773.js.map +1 -0
  16. package/dist/chunk-HIDNI56E.js +33 -0
  17. package/dist/chunk-HIDNI56E.js.map +1 -0
  18. package/dist/chunk-QKXS5D35.js +43 -0
  19. package/dist/chunk-QKXS5D35.js.map +1 -0
  20. package/dist/chunk-S4LSCEVE.js +261 -0
  21. package/dist/chunk-S4LSCEVE.js.map +1 -0
  22. package/dist/chunk-VKMJO6VN.js +360 -0
  23. package/dist/chunk-VKMJO6VN.js.map +1 -0
  24. package/dist/chunk-WFUR3MXY.js +67 -0
  25. package/dist/chunk-WFUR3MXY.js.map +1 -0
  26. package/dist/chunk-XEMR7KUE.js +361 -0
  27. package/dist/chunk-XEMR7KUE.js.map +1 -0
  28. package/dist/chunk-ZLPD7FY5.js +191 -0
  29. package/dist/chunk-ZLPD7FY5.js.map +1 -0
  30. package/dist/context.d.ts +13 -0
  31. package/dist/context.js +9 -0
  32. package/dist/context.js.map +1 -0
  33. package/dist/controller.d.ts +41 -0
  34. package/dist/controller.js +30 -0
  35. package/dist/controller.js.map +1 -0
  36. package/dist/dev.d.ts +15 -0
  37. package/dist/dev.js +20 -0
  38. package/dist/dev.js.map +1 -0
  39. package/dist/game-session-broker.d.ts +57 -0
  40. package/dist/game-session-broker.js +235 -0
  41. package/dist/game-session-broker.js.map +1 -0
  42. package/dist/game-session.d.ts +13 -0
  43. package/dist/game-session.js +24 -0
  44. package/dist/game-session.js.map +1 -0
  45. package/dist/games.d.ts +21 -0
  46. package/dist/games.js +14 -0
  47. package/dist/games.js.map +1 -0
  48. package/dist/harness/visual.d.ts +321 -0
  49. package/dist/harness/visual.js +41 -0
  50. package/dist/harness/visual.js.map +1 -0
  51. package/dist/logs.d.ts +9 -0
  52. package/dist/logs.js +58 -0
  53. package/dist/logs.js.map +1 -0
  54. package/dist/mcp-config.d.ts +63 -0
  55. package/dist/mcp-config.js +190 -0
  56. package/dist/mcp-config.js.map +1 -0
  57. package/dist/platform-auth.d.ts +112 -0
  58. package/dist/platform-auth.js +37 -0
  59. package/dist/platform-auth.js.map +1 -0
  60. package/dist/platform-game-media.d.ts +309 -0
  61. package/dist/platform-game-media.js +168 -0
  62. package/dist/platform-game-media.js.map +1 -0
  63. package/dist/platform-games.d.ts +65 -0
  64. package/dist/platform-games.js +251 -0
  65. package/dist/platform-games.js.map +1 -0
  66. package/dist/quality.d.ts +10 -0
  67. package/dist/quality.js +63 -0
  68. package/dist/quality.js.map +1 -0
  69. package/dist/release.d.ts +1094 -0
  70. package/dist/release.js +1347 -0
  71. package/dist/release.js.map +1 -0
  72. package/dist/tooling/agent-contract.d.ts +2 -0
  73. package/dist/tooling/agent-contract.js +193 -0
  74. package/dist/tooling/agent-contract.js.map +1 -0
  75. package/dist/tooling/hold-runtime-host.d.ts +2 -0
  76. package/dist/tooling/hold-runtime-host.js +229 -0
  77. package/dist/tooling/hold-runtime-host.js.map +1 -0
  78. package/dist/tooling/inspect-airjam-agent.d.ts +2 -0
  79. package/dist/tooling/inspect-airjam-agent.js +37 -0
  80. package/dist/tooling/inspect-airjam-agent.js.map +1 -0
  81. package/dist/tooling/list-visual-scenarios.d.ts +2 -0
  82. package/dist/tooling/list-visual-scenarios.js +62 -0
  83. package/dist/tooling/list-visual-scenarios.js.map +1 -0
  84. package/dist/tooling/managed-dev-supervisor.d.ts +2 -0
  85. package/dist/tooling/managed-dev-supervisor.js +51 -0
  86. package/dist/tooling/managed-dev-supervisor.js.map +1 -0
  87. package/dist/tooling/run-visual-capture.d.ts +2 -0
  88. package/dist/tooling/run-visual-capture.js +167 -0
  89. package/dist/tooling/run-visual-capture.js.map +1 -0
  90. package/dist/types-C6NrHt88.d.ts +775 -0
  91. package/dist/visual.d.ts +15 -0
  92. package/dist/visual.js +263 -0
  93. package/dist/visual.js.map +1 -0
  94. package/package.json +113 -3
  95. package/src/agent.ts +380 -0
  96. package/src/commands.ts +40 -0
  97. package/src/context.ts +229 -0
  98. package/src/controller.ts +1376 -0
  99. package/src/dev.ts +999 -0
  100. package/src/fs-utils.ts +93 -0
  101. package/src/game-action-observation.ts +96 -0
  102. package/src/game-session-broker.ts +301 -0
  103. package/src/game-session.ts +459 -0
  104. package/src/games.ts +266 -0
  105. package/src/harness/visual/prefab-contract.ts +29 -0
  106. package/src/harness/visual/prefab-runner.ts +178 -0
  107. package/src/harness/visual/runner.ts +546 -0
  108. package/src/harness/visual/scenario-contract.ts +9 -0
  109. package/src/harness/visual/scenario-helpers.ts +63 -0
  110. package/src/harness/visual/session.ts +369 -0
  111. package/src/harness/visual/types.ts +181 -0
  112. package/src/harness/visual.ts +7 -0
  113. package/src/helper-scripts.ts +49 -0
  114. package/src/logs.ts +67 -0
  115. package/src/mcp-config.ts +262 -0
  116. package/src/platform-auth.ts +455 -0
  117. package/src/platform-game-media.ts +209 -0
  118. package/src/platform-games.ts +315 -0
  119. package/src/quality.ts +82 -0
  120. package/src/release.ts +1697 -0
  121. package/src/runtime-owner-protocol.ts +130 -0
  122. package/src/tooling/agent-contract.ts +232 -0
  123. package/src/tooling/agent-declaration.ts +36 -0
  124. package/src/tooling/airjam-agent-inspection.ts +45 -0
  125. package/src/tooling/airjam-agent.ts +118 -0
  126. package/src/tooling/hold-runtime-host.ts +224 -0
  127. package/src/tooling/inspect-airjam-agent.ts +20 -0
  128. package/src/tooling/list-visual-scenarios.ts +64 -0
  129. package/src/tooling/managed-dev-supervisor.ts +71 -0
  130. package/src/tooling/run-visual-capture.ts +217 -0
  131. package/src/tooling/runtime-owner-actions.ts +42 -0
  132. package/src/tooling/visual-pack.ts +46 -0
  133. package/src/types.ts +951 -0
  134. package/src/visual.ts +304 -0
  135. package/src/workspace-contract.ts +32 -0
@@ -0,0 +1,209 @@
1
+ import {
2
+ platformMachineGetOwnedGameMediaResultSchema,
3
+ platformMachineMutateOwnedGameMediaAssetResultSchema,
4
+ platformMachineRequestOwnedGameMediaUploadTargetResultSchema,
5
+ } from "@air-jam/sdk/platform-machine";
6
+ import { readFile, stat } from "node:fs/promises";
7
+ import path from "node:path";
8
+ import {
9
+ requestPlatformMachineApi,
10
+ resolvePlatformMachineAuth,
11
+ } from "./platform-auth.js";
12
+ import type {
13
+ InspectPlatformGameMediaOptions,
14
+ MutatePlatformGameMediaAssetOptions,
15
+ RequestPlatformGameMediaUploadTargetOptions,
16
+ UploadPlatformGameMediaFileOptions,
17
+ } from "./types.js";
18
+
19
+ export type {
20
+ InspectPlatformGameMediaOptions,
21
+ MutatePlatformGameMediaAssetOptions,
22
+ RequestPlatformGameMediaUploadTargetOptions,
23
+ UploadPlatformGameMediaFileOptions,
24
+ } from "./types.js";
25
+
26
+ const MEDIA_FILE_CONTENT_TYPES: Record<
27
+ "thumbnail" | "cover" | "preview_video",
28
+ Record<string, string>
29
+ > = {
30
+ thumbnail: {
31
+ ".jpg": "image/jpeg",
32
+ ".jpeg": "image/jpeg",
33
+ ".png": "image/png",
34
+ ".webp": "image/webp",
35
+ },
36
+ cover: {
37
+ ".jpg": "image/jpeg",
38
+ ".jpeg": "image/jpeg",
39
+ ".png": "image/png",
40
+ ".webp": "image/webp",
41
+ },
42
+ preview_video: {
43
+ ".mp4": "video/mp4",
44
+ ".webm": "video/webm",
45
+ },
46
+ };
47
+
48
+ const inferMediaContentType = ({
49
+ kind,
50
+ filePath,
51
+ }: {
52
+ kind: "thumbnail" | "cover" | "preview_video";
53
+ filePath: string;
54
+ }): string => {
55
+ const extension = path.extname(filePath).toLowerCase();
56
+ const contentType = MEDIA_FILE_CONTENT_TYPES[kind][extension];
57
+
58
+ if (!contentType) {
59
+ throw new Error(
60
+ `Unsupported file extension for ${kind.replaceAll("_", " ")}: ${extension || "(none)"}`,
61
+ );
62
+ }
63
+
64
+ return contentType;
65
+ };
66
+
67
+ export const inspectPlatformGameMedia = async ({
68
+ platformUrl,
69
+ token,
70
+ slugOrId,
71
+ }: InspectPlatformGameMediaOptions) => {
72
+ const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
73
+
74
+ return requestPlatformMachineApi({
75
+ baseUrl: resolved.baseUrl,
76
+ pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}/media`,
77
+ token: resolved.token,
78
+ schema: platformMachineGetOwnedGameMediaResultSchema,
79
+ });
80
+ };
81
+
82
+ export const requestPlatformGameMediaUploadTarget = async ({
83
+ platformUrl,
84
+ token,
85
+ slugOrId,
86
+ input,
87
+ }: RequestPlatformGameMediaUploadTargetOptions) => {
88
+ const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
89
+
90
+ return requestPlatformMachineApi({
91
+ baseUrl: resolved.baseUrl,
92
+ pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}/media`,
93
+ method: "POST",
94
+ token: resolved.token,
95
+ body: input,
96
+ schema: platformMachineRequestOwnedGameMediaUploadTargetResultSchema,
97
+ });
98
+ };
99
+
100
+ const mutatePlatformGameMediaAsset = async ({
101
+ platformUrl,
102
+ token,
103
+ slugOrId,
104
+ assetId,
105
+ action,
106
+ }: MutatePlatformGameMediaAssetOptions & {
107
+ action: "finalize" | "assign" | "archive";
108
+ }) => {
109
+ const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
110
+
111
+ return requestPlatformMachineApi({
112
+ baseUrl: resolved.baseUrl,
113
+ pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}/media/${encodeURIComponent(assetId)}/${action}`,
114
+ method: "POST",
115
+ token: resolved.token,
116
+ schema: platformMachineMutateOwnedGameMediaAssetResultSchema,
117
+ });
118
+ };
119
+
120
+ export const finalizePlatformGameMediaUpload = (
121
+ options: MutatePlatformGameMediaAssetOptions,
122
+ ) =>
123
+ mutatePlatformGameMediaAsset({
124
+ ...options,
125
+ action: "finalize",
126
+ });
127
+
128
+ export const assignPlatformGameMediaAsset = (
129
+ options: MutatePlatformGameMediaAssetOptions,
130
+ ) =>
131
+ mutatePlatformGameMediaAsset({
132
+ ...options,
133
+ action: "assign",
134
+ });
135
+
136
+ export const archivePlatformGameMediaAsset = (
137
+ options: MutatePlatformGameMediaAssetOptions,
138
+ ) =>
139
+ mutatePlatformGameMediaAsset({
140
+ ...options,
141
+ action: "archive",
142
+ });
143
+
144
+ export const uploadPlatformGameMediaFile = async ({
145
+ platformUrl,
146
+ token,
147
+ slugOrId,
148
+ kind,
149
+ filePath,
150
+ }: UploadPlatformGameMediaFileOptions) => {
151
+ const resolvedFilePath = path.resolve(filePath);
152
+ const fileStats = await stat(resolvedFilePath);
153
+
154
+ if (!fileStats.isFile()) {
155
+ throw new Error(`Media path is not a file: ${resolvedFilePath}`);
156
+ }
157
+
158
+ const contentType = inferMediaContentType({
159
+ kind,
160
+ filePath: resolvedFilePath,
161
+ });
162
+
163
+ const created = await requestPlatformGameMediaUploadTarget({
164
+ platformUrl,
165
+ token,
166
+ slugOrId,
167
+ input: {
168
+ kind,
169
+ originalFilename: path.basename(resolvedFilePath),
170
+ contentType,
171
+ sizeBytes: fileStats.size,
172
+ },
173
+ });
174
+
175
+ const uploadResponse = await fetch(created.upload.url, {
176
+ method: created.upload.method,
177
+ headers: created.upload.headers,
178
+ body: await readFile(resolvedFilePath),
179
+ });
180
+
181
+ if (!uploadResponse.ok) {
182
+ throw new Error(
183
+ `Media upload failed with status ${uploadResponse.status}.`,
184
+ );
185
+ }
186
+
187
+ const finalized = await finalizePlatformGameMediaUpload({
188
+ platformUrl,
189
+ token,
190
+ slugOrId,
191
+ assetId: created.asset.id,
192
+ });
193
+
194
+ const assigned = await assignPlatformGameMediaAsset({
195
+ platformUrl,
196
+ token,
197
+ slugOrId,
198
+ assetId: created.asset.id,
199
+ });
200
+
201
+ return {
202
+ requested: created,
203
+ finalized,
204
+ assigned,
205
+ filePath: resolvedFilePath,
206
+ sizeBytes: fileStats.size,
207
+ contentType,
208
+ };
209
+ };
@@ -0,0 +1,315 @@
1
+ import {
2
+ airJamGameMetadataSchema,
3
+ type AirJamGameMetadata,
4
+ } from "@air-jam/sdk/metadata";
5
+ import {
6
+ platformMachineCreateOwnedGameResultSchema,
7
+ platformMachineGetOwnedGameResultSchema,
8
+ platformMachineListOwnedGamesResultSchema,
9
+ platformMachineUpdateOwnedGameResultSchema,
10
+ } from "@air-jam/sdk/platform-machine";
11
+ import { readFile } from "node:fs/promises";
12
+ import { createRequire } from "node:module";
13
+ import path from "node:path";
14
+ import { pathToFileURL } from "node:url";
15
+ import { runCommandResult } from "./commands.js";
16
+ import {
17
+ findUp,
18
+ pathExists,
19
+ readJsonFile,
20
+ readPackageJson,
21
+ } from "./fs-utils.js";
22
+ import { inspectGame } from "./games.js";
23
+ import {
24
+ requestPlatformMachineApi,
25
+ resolvePlatformMachineAuth,
26
+ } from "./platform-auth.js";
27
+ import type {
28
+ AirJamLocalHostedGameDefaults,
29
+ CreatePlatformGameOptions,
30
+ InspectPlatformGameOptions,
31
+ ListPlatformGamesOptions,
32
+ UpdatePlatformGameOptions,
33
+ } from "./types.js";
34
+
35
+ export type {
36
+ AirJamLocalHostedGameDefaults,
37
+ CreatePlatformGameOptions,
38
+ InspectPlatformGameOptions,
39
+ ListPlatformGamesOptions,
40
+ UpdatePlatformGameOptions,
41
+ } from "./types.js";
42
+
43
+ const require = createRequire(import.meta.url);
44
+
45
+ const resolveTsxLoaderPath = (): string | null => {
46
+ try {
47
+ return require.resolve("tsx/esm");
48
+ } catch {
49
+ return null;
50
+ }
51
+ };
52
+
53
+ const normalizeGithubRemoteUrl = (value: string): string | null => {
54
+ const trimmed = value.trim();
55
+ if (!trimmed) {
56
+ return null;
57
+ }
58
+
59
+ if (trimmed.startsWith("git@github.com:")) {
60
+ const repoPath = trimmed
61
+ .slice("git@github.com:".length)
62
+ .replace(/\.git$/, "");
63
+ return repoPath ? `https://github.com/${repoPath}` : null;
64
+ }
65
+
66
+ try {
67
+ const url = new URL(trimmed);
68
+ if (url.hostname !== "github.com") {
69
+ return null;
70
+ }
71
+
72
+ return `https://github.com${url.pathname.replace(/\.git$/, "")}`.replace(
73
+ /\/$/,
74
+ "",
75
+ );
76
+ } catch {
77
+ return null;
78
+ }
79
+ };
80
+
81
+ const readGitRemoteFromConfig = async (
82
+ gitDirOrFilePath: string,
83
+ ): Promise<string | null> => {
84
+ let configPath: string | null = null;
85
+
86
+ const statsFile = await readFile(gitDirOrFilePath, "utf8").catch(() => null);
87
+ if (statsFile?.startsWith("gitdir:")) {
88
+ const relativeGitDir = statsFile.slice("gitdir:".length).trim();
89
+ const resolvedGitDir = path.resolve(
90
+ path.dirname(gitDirOrFilePath),
91
+ relativeGitDir,
92
+ );
93
+ configPath = path.join(resolvedGitDir, "config");
94
+ } else {
95
+ configPath = path.join(gitDirOrFilePath, "config");
96
+ }
97
+
98
+ if (!(await pathExists(configPath))) {
99
+ return null;
100
+ }
101
+
102
+ const config = await readFile(configPath, "utf8");
103
+ const remoteBlockMatch = config.match(
104
+ /\[remote "origin"\][\s\S]*?(?:\n\[|$)/,
105
+ );
106
+ if (!remoteBlockMatch) {
107
+ return null;
108
+ }
109
+
110
+ const urlMatch = remoteBlockMatch[0].match(/^\s*url\s*=\s*(.+)$/m);
111
+ return urlMatch?.[1]?.trim() || null;
112
+ };
113
+
114
+ const resolveRepoSourceUrl = async ({
115
+ projectDir,
116
+ }: {
117
+ projectDir: string;
118
+ }): Promise<string | null> => {
119
+ const gitMarkerPath = await findUp(projectDir, ".git");
120
+ if (!gitMarkerPath) {
121
+ return null;
122
+ }
123
+
124
+ const repoRoot = path.dirname(gitMarkerPath);
125
+ const remoteUrl = await readGitRemoteFromConfig(gitMarkerPath);
126
+ const normalizedRemoteUrl = remoteUrl
127
+ ? normalizeGithubRemoteUrl(remoteUrl)
128
+ : null;
129
+
130
+ if (!normalizedRemoteUrl) {
131
+ return null;
132
+ }
133
+
134
+ const relativeProjectPath = path.relative(repoRoot, projectDir);
135
+ if (!relativeProjectPath || relativeProjectPath.startsWith("..")) {
136
+ return null;
137
+ }
138
+
139
+ return `${normalizedRemoteUrl}/tree/main/${relativeProjectPath.replaceAll(path.sep, "/")}`;
140
+ };
141
+
142
+ type LocalTemplateManifest = {
143
+ id?: unknown;
144
+ name?: unknown;
145
+ description?: unknown;
146
+ category?: unknown;
147
+ };
148
+
149
+ const toOptionalString = (value: unknown): string | null =>
150
+ typeof value === "string" && value.trim() ? value.trim() : null;
151
+
152
+ const resolveTemplateManifestPath = (projectDir: string) =>
153
+ path.join(projectDir, "airjam-template.json");
154
+
155
+ const loadTemplateManifest = async (
156
+ projectDir: string,
157
+ ): Promise<{
158
+ path: string | null;
159
+ value: LocalTemplateManifest | null;
160
+ }> => {
161
+ const manifestPath = resolveTemplateManifestPath(projectDir);
162
+ try {
163
+ return {
164
+ path: manifestPath,
165
+ value: await readJsonFile<LocalTemplateManifest>(manifestPath),
166
+ };
167
+ } catch {
168
+ return {
169
+ path: null,
170
+ value: null,
171
+ };
172
+ }
173
+ };
174
+
175
+ const loadGameMetadataFromConfig = async (
176
+ configPath: string | null,
177
+ ): Promise<AirJamGameMetadata | null> => {
178
+ if (!configPath) {
179
+ return null;
180
+ }
181
+
182
+ const tsxLoaderPath = resolveTsxLoaderPath();
183
+ if (!tsxLoaderPath) {
184
+ return null;
185
+ }
186
+
187
+ const configUrl = pathToFileURL(configPath).href;
188
+ const script = `
189
+ const moduleUrl = ${JSON.stringify(configUrl)};
190
+ const mod = await import(moduleUrl);
191
+ const value = mod.gameMetadata ?? mod.airjam?.metadata ?? null;
192
+ process.stdout.write(JSON.stringify(value));
193
+ `;
194
+
195
+ const result = runCommandResult({
196
+ command: process.execPath,
197
+ args: ["--import", tsxLoaderPath, "--input-type=module", "--eval", script],
198
+ cwd: path.dirname(configPath),
199
+ });
200
+
201
+ if (!result.ok) {
202
+ return null;
203
+ }
204
+
205
+ const raw = result.stdout.trim();
206
+ if (!raw) {
207
+ return null;
208
+ }
209
+
210
+ try {
211
+ return airJamGameMetadataSchema.parse(JSON.parse(raw) as unknown);
212
+ } catch {
213
+ return null;
214
+ }
215
+ };
216
+
217
+ export const readLocalHostedGameDefaults = async ({
218
+ cwd = process.cwd(),
219
+ }: {
220
+ cwd?: string;
221
+ } = {}): Promise<AirJamLocalHostedGameDefaults> => {
222
+ const game = await inspectGame({ cwd });
223
+ const [template, packageJson, metadata, sourceUrl] = await Promise.all([
224
+ loadTemplateManifest(game.rootDir),
225
+ readPackageJson(game.rootDir),
226
+ loadGameMetadataFromConfig(game.configPath),
227
+ resolveRepoSourceUrl({ projectDir: game.rootDir }),
228
+ ]);
229
+
230
+ return {
231
+ projectDir: game.rootDir,
232
+ configPath: game.configPath,
233
+ manifestPath: template.path,
234
+ packageJsonPath: packageJson?.path ?? null,
235
+ packageName: game.packageName,
236
+ sourceUrl,
237
+ metadata: {
238
+ name: metadata?.name ?? null,
239
+ slug: metadata?.slug ?? null,
240
+ description: metadata?.tagline ?? null,
241
+ category: metadata?.category ?? null,
242
+ tags: metadata?.tags ? [...metadata.tags] : [],
243
+ },
244
+ template: {
245
+ id: toOptionalString(template.value?.id),
246
+ name: toOptionalString(template.value?.name),
247
+ description: toOptionalString(template.value?.description),
248
+ category: toOptionalString(template.value?.category),
249
+ },
250
+ };
251
+ };
252
+
253
+ export const listPlatformGames = async ({
254
+ platformUrl,
255
+ token,
256
+ }: ListPlatformGamesOptions = {}) => {
257
+ const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
258
+
259
+ return requestPlatformMachineApi({
260
+ baseUrl: resolved.baseUrl,
261
+ pathname: "/api/cli/games",
262
+ token: resolved.token,
263
+ schema: platformMachineListOwnedGamesResultSchema,
264
+ });
265
+ };
266
+
267
+ export const inspectPlatformGame = async ({
268
+ platformUrl,
269
+ token,
270
+ slugOrId,
271
+ }: InspectPlatformGameOptions) => {
272
+ const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
273
+
274
+ return requestPlatformMachineApi({
275
+ baseUrl: resolved.baseUrl,
276
+ pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}`,
277
+ token: resolved.token,
278
+ schema: platformMachineGetOwnedGameResultSchema,
279
+ });
280
+ };
281
+
282
+ export const createPlatformGame = async ({
283
+ platformUrl,
284
+ token,
285
+ input,
286
+ }: CreatePlatformGameOptions) => {
287
+ const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
288
+
289
+ return requestPlatformMachineApi({
290
+ baseUrl: resolved.baseUrl,
291
+ pathname: "/api/cli/games",
292
+ method: "POST",
293
+ token: resolved.token,
294
+ body: input,
295
+ schema: platformMachineCreateOwnedGameResultSchema,
296
+ });
297
+ };
298
+
299
+ export const updatePlatformGame = async ({
300
+ platformUrl,
301
+ token,
302
+ slugOrId,
303
+ input,
304
+ }: UpdatePlatformGameOptions) => {
305
+ const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
306
+
307
+ return requestPlatformMachineApi({
308
+ baseUrl: resolved.baseUrl,
309
+ pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}`,
310
+ method: "PATCH",
311
+ token: resolved.token,
312
+ body: input,
313
+ schema: platformMachineUpdateOwnedGameResultSchema,
314
+ });
315
+ };
package/src/quality.ts ADDED
@@ -0,0 +1,82 @@
1
+ import { runCommandResult } from "./commands.js";
2
+ import { detectProjectContext } from "./context.js";
3
+ import type {
4
+ AirJamCompleteEvaluationResult,
5
+ AirJamQualityGate,
6
+ CommandResult,
7
+ RunCompleteEvaluationOptions,
8
+ RunQualityGateOptions,
9
+ } from "./types.js";
10
+
11
+ export type {
12
+ AirJamCompleteEvaluationResult,
13
+ AirJamQualityGate,
14
+ CommandResult,
15
+ RunCompleteEvaluationOptions,
16
+ RunQualityGateOptions,
17
+ } from "./types.js";
18
+
19
+ export const AIR_JAM_COMPLETE_EVALUATION_GATES = [
20
+ "typecheck",
21
+ "lint",
22
+ "test",
23
+ "build",
24
+ ] as const satisfies readonly AirJamQualityGate[];
25
+
26
+ const GATE_TO_SCRIPT: Record<RunQualityGateOptions["gate"], string> = {
27
+ typecheck: "typecheck",
28
+ lint: "lint",
29
+ test: "test",
30
+ build: "build",
31
+ "format-check": "format:check",
32
+ "scaffold-smoke": "test:scaffold",
33
+ "release-check": "check:release",
34
+ };
35
+
36
+ export const runQualityGate = async (
37
+ options: RunQualityGateOptions,
38
+ ): Promise<CommandResult> => {
39
+ const context = await detectProjectContext({ cwd: options.cwd });
40
+ const script = GATE_TO_SCRIPT[options.gate];
41
+
42
+ if (
43
+ context.mode !== "monorepo" &&
44
+ (options.gate === "scaffold-smoke" || options.gate === "release-check")
45
+ ) {
46
+ throw new Error(
47
+ `Quality gate "${options.gate}" is only available in the Air Jam monorepo.`,
48
+ );
49
+ }
50
+
51
+ const args = options.packageFilter
52
+ ? ["--filter", options.packageFilter, "run", script]
53
+ : ["run", script];
54
+
55
+ return runCommandResult({
56
+ command: "pnpm",
57
+ args,
58
+ cwd: context.rootDir,
59
+ });
60
+ };
61
+
62
+ export const runCompleteEvaluation = async ({
63
+ cwd,
64
+ }: RunCompleteEvaluationOptions = {}): Promise<AirJamCompleteEvaluationResult> => {
65
+ const startedAt = new Date().toISOString();
66
+ const gates: AirJamCompleteEvaluationResult["gates"] = [];
67
+
68
+ for (const gate of AIR_JAM_COMPLETE_EVALUATION_GATES) {
69
+ gates.push({
70
+ gate,
71
+ result: await runQualityGate({ cwd, gate }),
72
+ });
73
+ }
74
+
75
+ return {
76
+ contract: "air-jam-complete-evaluation/v1",
77
+ status: gates.every(({ result }) => result.ok) ? "passed" : "failed",
78
+ startedAt,
79
+ endedAt: new Date().toISOString(),
80
+ gates,
81
+ };
82
+ };