@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.
- package/LICENSE +21 -0
- package/README.md +52 -2
- package/dist/agent.d.ts +15 -0
- package/dist/agent.js +19 -0
- package/dist/agent.js.map +1 -0
- package/dist/chunk-5YAARMW5.js +36 -0
- package/dist/chunk-5YAARMW5.js.map +1 -0
- package/dist/chunk-6WQODT37.js +1019 -0
- package/dist/chunk-6WQODT37.js.map +1 -0
- package/dist/chunk-CKFT2ZJE.js +801 -0
- package/dist/chunk-CKFT2ZJE.js.map +1 -0
- package/dist/chunk-ER3Q2C4G.js +358 -0
- package/dist/chunk-ER3Q2C4G.js.map +1 -0
- package/dist/chunk-GUEZP773.js +851 -0
- package/dist/chunk-GUEZP773.js.map +1 -0
- package/dist/chunk-HIDNI56E.js +33 -0
- package/dist/chunk-HIDNI56E.js.map +1 -0
- package/dist/chunk-QKXS5D35.js +43 -0
- package/dist/chunk-QKXS5D35.js.map +1 -0
- package/dist/chunk-S4LSCEVE.js +261 -0
- package/dist/chunk-S4LSCEVE.js.map +1 -0
- package/dist/chunk-VKMJO6VN.js +360 -0
- package/dist/chunk-VKMJO6VN.js.map +1 -0
- package/dist/chunk-WFUR3MXY.js +67 -0
- package/dist/chunk-WFUR3MXY.js.map +1 -0
- package/dist/chunk-XEMR7KUE.js +361 -0
- package/dist/chunk-XEMR7KUE.js.map +1 -0
- package/dist/chunk-ZLPD7FY5.js +191 -0
- package/dist/chunk-ZLPD7FY5.js.map +1 -0
- package/dist/context.d.ts +13 -0
- package/dist/context.js +9 -0
- package/dist/context.js.map +1 -0
- package/dist/controller.d.ts +41 -0
- package/dist/controller.js +30 -0
- package/dist/controller.js.map +1 -0
- package/dist/dev.d.ts +15 -0
- package/dist/dev.js +20 -0
- package/dist/dev.js.map +1 -0
- package/dist/game-session-broker.d.ts +57 -0
- package/dist/game-session-broker.js +235 -0
- package/dist/game-session-broker.js.map +1 -0
- package/dist/game-session.d.ts +13 -0
- package/dist/game-session.js +24 -0
- package/dist/game-session.js.map +1 -0
- package/dist/games.d.ts +21 -0
- package/dist/games.js +14 -0
- package/dist/games.js.map +1 -0
- package/dist/harness/visual.d.ts +321 -0
- package/dist/harness/visual.js +41 -0
- package/dist/harness/visual.js.map +1 -0
- package/dist/logs.d.ts +9 -0
- package/dist/logs.js +58 -0
- package/dist/logs.js.map +1 -0
- package/dist/mcp-config.d.ts +63 -0
- package/dist/mcp-config.js +190 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/platform-auth.d.ts +112 -0
- package/dist/platform-auth.js +37 -0
- package/dist/platform-auth.js.map +1 -0
- package/dist/platform-game-media.d.ts +309 -0
- package/dist/platform-game-media.js +168 -0
- package/dist/platform-game-media.js.map +1 -0
- package/dist/platform-games.d.ts +65 -0
- package/dist/platform-games.js +251 -0
- package/dist/platform-games.js.map +1 -0
- package/dist/quality.d.ts +10 -0
- package/dist/quality.js +63 -0
- package/dist/quality.js.map +1 -0
- package/dist/release.d.ts +1094 -0
- package/dist/release.js +1347 -0
- package/dist/release.js.map +1 -0
- package/dist/tooling/agent-contract.d.ts +2 -0
- package/dist/tooling/agent-contract.js +193 -0
- package/dist/tooling/agent-contract.js.map +1 -0
- package/dist/tooling/hold-runtime-host.d.ts +2 -0
- package/dist/tooling/hold-runtime-host.js +229 -0
- package/dist/tooling/hold-runtime-host.js.map +1 -0
- package/dist/tooling/inspect-airjam-agent.d.ts +2 -0
- package/dist/tooling/inspect-airjam-agent.js +37 -0
- package/dist/tooling/inspect-airjam-agent.js.map +1 -0
- package/dist/tooling/list-visual-scenarios.d.ts +2 -0
- package/dist/tooling/list-visual-scenarios.js +62 -0
- package/dist/tooling/list-visual-scenarios.js.map +1 -0
- package/dist/tooling/managed-dev-supervisor.d.ts +2 -0
- package/dist/tooling/managed-dev-supervisor.js +51 -0
- package/dist/tooling/managed-dev-supervisor.js.map +1 -0
- package/dist/tooling/run-visual-capture.d.ts +2 -0
- package/dist/tooling/run-visual-capture.js +167 -0
- package/dist/tooling/run-visual-capture.js.map +1 -0
- package/dist/types-C6NrHt88.d.ts +775 -0
- package/dist/visual.d.ts +15 -0
- package/dist/visual.js +263 -0
- package/dist/visual.js.map +1 -0
- package/package.json +113 -3
- package/src/agent.ts +380 -0
- package/src/commands.ts +40 -0
- package/src/context.ts +229 -0
- package/src/controller.ts +1376 -0
- package/src/dev.ts +999 -0
- package/src/fs-utils.ts +93 -0
- package/src/game-action-observation.ts +96 -0
- package/src/game-session-broker.ts +301 -0
- package/src/game-session.ts +459 -0
- package/src/games.ts +266 -0
- package/src/harness/visual/prefab-contract.ts +29 -0
- package/src/harness/visual/prefab-runner.ts +178 -0
- package/src/harness/visual/runner.ts +546 -0
- package/src/harness/visual/scenario-contract.ts +9 -0
- package/src/harness/visual/scenario-helpers.ts +63 -0
- package/src/harness/visual/session.ts +369 -0
- package/src/harness/visual/types.ts +181 -0
- package/src/harness/visual.ts +7 -0
- package/src/helper-scripts.ts +49 -0
- package/src/logs.ts +67 -0
- package/src/mcp-config.ts +262 -0
- package/src/platform-auth.ts +455 -0
- package/src/platform-game-media.ts +209 -0
- package/src/platform-games.ts +315 -0
- package/src/quality.ts +82 -0
- package/src/release.ts +1697 -0
- package/src/runtime-owner-protocol.ts +130 -0
- package/src/tooling/agent-contract.ts +232 -0
- package/src/tooling/agent-declaration.ts +36 -0
- package/src/tooling/airjam-agent-inspection.ts +45 -0
- package/src/tooling/airjam-agent.ts +118 -0
- package/src/tooling/hold-runtime-host.ts +224 -0
- package/src/tooling/inspect-airjam-agent.ts +20 -0
- package/src/tooling/list-visual-scenarios.ts +64 -0
- package/src/tooling/managed-dev-supervisor.ts +71 -0
- package/src/tooling/run-visual-capture.ts +217 -0
- package/src/tooling/runtime-owner-actions.ts +42 -0
- package/src/tooling/visual-pack.ts +46 -0
- package/src/types.ts +951 -0
- package/src/visual.ts +304 -0
- package/src/workspace-contract.ts +32 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ad as AirJamLocalHostedGameDefaults, ae as ListPlatformGamesOptions, af as InspectPlatformGameOptions, ag as CreatePlatformGameOptions, ah as UpdatePlatformGameOptions } from './types-C6NrHt88.js';
|
|
2
|
+
import '@air-jam/sdk';
|
|
3
|
+
import '@air-jam/sdk/platform-machine';
|
|
4
|
+
|
|
5
|
+
declare const readLocalHostedGameDefaults: ({ cwd, }?: {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
}) => Promise<AirJamLocalHostedGameDefaults>;
|
|
8
|
+
declare const listPlatformGames: ({ platformUrl, token, }?: ListPlatformGamesOptions) => Promise<{
|
|
9
|
+
games: {
|
|
10
|
+
id: string;
|
|
11
|
+
slug: string | null;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string | null;
|
|
14
|
+
url: string | null;
|
|
15
|
+
arcadeVisibility: "hidden" | "listed";
|
|
16
|
+
sourceUrl: string | null;
|
|
17
|
+
templateId: string | null;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
}[];
|
|
21
|
+
}>;
|
|
22
|
+
declare const inspectPlatformGame: ({ platformUrl, token, slugOrId, }: InspectPlatformGameOptions) => Promise<{
|
|
23
|
+
game: {
|
|
24
|
+
id: string;
|
|
25
|
+
slug: string | null;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
url: string | null;
|
|
29
|
+
arcadeVisibility: "hidden" | "listed";
|
|
30
|
+
sourceUrl: string | null;
|
|
31
|
+
templateId: string | null;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
declare const createPlatformGame: ({ platformUrl, token, input, }: CreatePlatformGameOptions) => Promise<{
|
|
37
|
+
game: {
|
|
38
|
+
id: string;
|
|
39
|
+
slug: string | null;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string | null;
|
|
42
|
+
url: string | null;
|
|
43
|
+
arcadeVisibility: "hidden" | "listed";
|
|
44
|
+
sourceUrl: string | null;
|
|
45
|
+
templateId: string | null;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
updatedAt: string;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
declare const updatePlatformGame: ({ platformUrl, token, slugOrId, input, }: UpdatePlatformGameOptions) => Promise<{
|
|
51
|
+
game: {
|
|
52
|
+
id: string;
|
|
53
|
+
slug: string | null;
|
|
54
|
+
name: string;
|
|
55
|
+
description: string | null;
|
|
56
|
+
url: string | null;
|
|
57
|
+
arcadeVisibility: "hidden" | "listed";
|
|
58
|
+
sourceUrl: string | null;
|
|
59
|
+
templateId: string | null;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
export { AirJamLocalHostedGameDefaults, CreatePlatformGameOptions, InspectPlatformGameOptions, ListPlatformGamesOptions, UpdatePlatformGameOptions, createPlatformGame, inspectPlatformGame, listPlatformGames, readLocalHostedGameDefaults, updatePlatformGame };
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requestPlatformMachineApi,
|
|
3
|
+
resolvePlatformMachineAuth
|
|
4
|
+
} from "./chunk-VKMJO6VN.js";
|
|
5
|
+
import {
|
|
6
|
+
inspectGame
|
|
7
|
+
} from "./chunk-ZLPD7FY5.js";
|
|
8
|
+
import {
|
|
9
|
+
runCommandResult
|
|
10
|
+
} from "./chunk-5YAARMW5.js";
|
|
11
|
+
import {
|
|
12
|
+
findUp,
|
|
13
|
+
pathExists,
|
|
14
|
+
readJsonFile,
|
|
15
|
+
readPackageJson
|
|
16
|
+
} from "./chunk-S4LSCEVE.js";
|
|
17
|
+
|
|
18
|
+
// src/platform-games.ts
|
|
19
|
+
import {
|
|
20
|
+
airJamGameMetadataSchema
|
|
21
|
+
} from "@air-jam/sdk/metadata";
|
|
22
|
+
import {
|
|
23
|
+
platformMachineCreateOwnedGameResultSchema,
|
|
24
|
+
platformMachineGetOwnedGameResultSchema,
|
|
25
|
+
platformMachineListOwnedGamesResultSchema,
|
|
26
|
+
platformMachineUpdateOwnedGameResultSchema
|
|
27
|
+
} from "@air-jam/sdk/platform-machine";
|
|
28
|
+
import { readFile } from "fs/promises";
|
|
29
|
+
import { createRequire } from "module";
|
|
30
|
+
import path from "path";
|
|
31
|
+
import { pathToFileURL } from "url";
|
|
32
|
+
var require2 = createRequire(import.meta.url);
|
|
33
|
+
var resolveTsxLoaderPath = () => {
|
|
34
|
+
try {
|
|
35
|
+
return require2.resolve("tsx/esm");
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var normalizeGithubRemoteUrl = (value) => {
|
|
41
|
+
const trimmed = value.trim();
|
|
42
|
+
if (!trimmed) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (trimmed.startsWith("git@github.com:")) {
|
|
46
|
+
const repoPath = trimmed.slice("git@github.com:".length).replace(/\.git$/, "");
|
|
47
|
+
return repoPath ? `https://github.com/${repoPath}` : null;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const url = new URL(trimmed);
|
|
51
|
+
if (url.hostname !== "github.com") {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return `https://github.com${url.pathname.replace(/\.git$/, "")}`.replace(
|
|
55
|
+
/\/$/,
|
|
56
|
+
""
|
|
57
|
+
);
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var readGitRemoteFromConfig = async (gitDirOrFilePath) => {
|
|
63
|
+
let configPath = null;
|
|
64
|
+
const statsFile = await readFile(gitDirOrFilePath, "utf8").catch(() => null);
|
|
65
|
+
if (statsFile?.startsWith("gitdir:")) {
|
|
66
|
+
const relativeGitDir = statsFile.slice("gitdir:".length).trim();
|
|
67
|
+
const resolvedGitDir = path.resolve(
|
|
68
|
+
path.dirname(gitDirOrFilePath),
|
|
69
|
+
relativeGitDir
|
|
70
|
+
);
|
|
71
|
+
configPath = path.join(resolvedGitDir, "config");
|
|
72
|
+
} else {
|
|
73
|
+
configPath = path.join(gitDirOrFilePath, "config");
|
|
74
|
+
}
|
|
75
|
+
if (!await pathExists(configPath)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const config = await readFile(configPath, "utf8");
|
|
79
|
+
const remoteBlockMatch = config.match(
|
|
80
|
+
/\[remote "origin"\][\s\S]*?(?:\n\[|$)/
|
|
81
|
+
);
|
|
82
|
+
if (!remoteBlockMatch) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const urlMatch = remoteBlockMatch[0].match(/^\s*url\s*=\s*(.+)$/m);
|
|
86
|
+
return urlMatch?.[1]?.trim() || null;
|
|
87
|
+
};
|
|
88
|
+
var resolveRepoSourceUrl = async ({
|
|
89
|
+
projectDir
|
|
90
|
+
}) => {
|
|
91
|
+
const gitMarkerPath = await findUp(projectDir, ".git");
|
|
92
|
+
if (!gitMarkerPath) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const repoRoot = path.dirname(gitMarkerPath);
|
|
96
|
+
const remoteUrl = await readGitRemoteFromConfig(gitMarkerPath);
|
|
97
|
+
const normalizedRemoteUrl = remoteUrl ? normalizeGithubRemoteUrl(remoteUrl) : null;
|
|
98
|
+
if (!normalizedRemoteUrl) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const relativeProjectPath = path.relative(repoRoot, projectDir);
|
|
102
|
+
if (!relativeProjectPath || relativeProjectPath.startsWith("..")) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return `${normalizedRemoteUrl}/tree/main/${relativeProjectPath.replaceAll(path.sep, "/")}`;
|
|
106
|
+
};
|
|
107
|
+
var toOptionalString = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
108
|
+
var resolveTemplateManifestPath = (projectDir) => path.join(projectDir, "airjam-template.json");
|
|
109
|
+
var loadTemplateManifest = async (projectDir) => {
|
|
110
|
+
const manifestPath = resolveTemplateManifestPath(projectDir);
|
|
111
|
+
try {
|
|
112
|
+
return {
|
|
113
|
+
path: manifestPath,
|
|
114
|
+
value: await readJsonFile(manifestPath)
|
|
115
|
+
};
|
|
116
|
+
} catch {
|
|
117
|
+
return {
|
|
118
|
+
path: null,
|
|
119
|
+
value: null
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var loadGameMetadataFromConfig = async (configPath) => {
|
|
124
|
+
if (!configPath) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const tsxLoaderPath = resolveTsxLoaderPath();
|
|
128
|
+
if (!tsxLoaderPath) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const configUrl = pathToFileURL(configPath).href;
|
|
132
|
+
const script = `
|
|
133
|
+
const moduleUrl = ${JSON.stringify(configUrl)};
|
|
134
|
+
const mod = await import(moduleUrl);
|
|
135
|
+
const value = mod.gameMetadata ?? mod.airjam?.metadata ?? null;
|
|
136
|
+
process.stdout.write(JSON.stringify(value));
|
|
137
|
+
`;
|
|
138
|
+
const result = runCommandResult({
|
|
139
|
+
command: process.execPath,
|
|
140
|
+
args: ["--import", tsxLoaderPath, "--input-type=module", "--eval", script],
|
|
141
|
+
cwd: path.dirname(configPath)
|
|
142
|
+
});
|
|
143
|
+
if (!result.ok) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const raw = result.stdout.trim();
|
|
147
|
+
if (!raw) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
return airJamGameMetadataSchema.parse(JSON.parse(raw));
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var readLocalHostedGameDefaults = async ({
|
|
157
|
+
cwd = process.cwd()
|
|
158
|
+
} = {}) => {
|
|
159
|
+
const game = await inspectGame({ cwd });
|
|
160
|
+
const [template, packageJson, metadata, sourceUrl] = await Promise.all([
|
|
161
|
+
loadTemplateManifest(game.rootDir),
|
|
162
|
+
readPackageJson(game.rootDir),
|
|
163
|
+
loadGameMetadataFromConfig(game.configPath),
|
|
164
|
+
resolveRepoSourceUrl({ projectDir: game.rootDir })
|
|
165
|
+
]);
|
|
166
|
+
return {
|
|
167
|
+
projectDir: game.rootDir,
|
|
168
|
+
configPath: game.configPath,
|
|
169
|
+
manifestPath: template.path,
|
|
170
|
+
packageJsonPath: packageJson?.path ?? null,
|
|
171
|
+
packageName: game.packageName,
|
|
172
|
+
sourceUrl,
|
|
173
|
+
metadata: {
|
|
174
|
+
name: metadata?.name ?? null,
|
|
175
|
+
slug: metadata?.slug ?? null,
|
|
176
|
+
description: metadata?.tagline ?? null,
|
|
177
|
+
category: metadata?.category ?? null,
|
|
178
|
+
tags: metadata?.tags ? [...metadata.tags] : []
|
|
179
|
+
},
|
|
180
|
+
template: {
|
|
181
|
+
id: toOptionalString(template.value?.id),
|
|
182
|
+
name: toOptionalString(template.value?.name),
|
|
183
|
+
description: toOptionalString(template.value?.description),
|
|
184
|
+
category: toOptionalString(template.value?.category)
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
var listPlatformGames = async ({
|
|
189
|
+
platformUrl,
|
|
190
|
+
token
|
|
191
|
+
} = {}) => {
|
|
192
|
+
const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
|
|
193
|
+
return requestPlatformMachineApi({
|
|
194
|
+
baseUrl: resolved.baseUrl,
|
|
195
|
+
pathname: "/api/cli/games",
|
|
196
|
+
token: resolved.token,
|
|
197
|
+
schema: platformMachineListOwnedGamesResultSchema
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
var inspectPlatformGame = async ({
|
|
201
|
+
platformUrl,
|
|
202
|
+
token,
|
|
203
|
+
slugOrId
|
|
204
|
+
}) => {
|
|
205
|
+
const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
|
|
206
|
+
return requestPlatformMachineApi({
|
|
207
|
+
baseUrl: resolved.baseUrl,
|
|
208
|
+
pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}`,
|
|
209
|
+
token: resolved.token,
|
|
210
|
+
schema: platformMachineGetOwnedGameResultSchema
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
var createPlatformGame = async ({
|
|
214
|
+
platformUrl,
|
|
215
|
+
token,
|
|
216
|
+
input
|
|
217
|
+
}) => {
|
|
218
|
+
const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
|
|
219
|
+
return requestPlatformMachineApi({
|
|
220
|
+
baseUrl: resolved.baseUrl,
|
|
221
|
+
pathname: "/api/cli/games",
|
|
222
|
+
method: "POST",
|
|
223
|
+
token: resolved.token,
|
|
224
|
+
body: input,
|
|
225
|
+
schema: platformMachineCreateOwnedGameResultSchema
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
var updatePlatformGame = async ({
|
|
229
|
+
platformUrl,
|
|
230
|
+
token,
|
|
231
|
+
slugOrId,
|
|
232
|
+
input
|
|
233
|
+
}) => {
|
|
234
|
+
const resolved = await resolvePlatformMachineAuth({ platformUrl, token });
|
|
235
|
+
return requestPlatformMachineApi({
|
|
236
|
+
baseUrl: resolved.baseUrl,
|
|
237
|
+
pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}`,
|
|
238
|
+
method: "PATCH",
|
|
239
|
+
token: resolved.token,
|
|
240
|
+
body: input,
|
|
241
|
+
schema: platformMachineUpdateOwnedGameResultSchema
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
export {
|
|
245
|
+
createPlatformGame,
|
|
246
|
+
inspectPlatformGame,
|
|
247
|
+
listPlatformGames,
|
|
248
|
+
readLocalHostedGameDefaults,
|
|
249
|
+
updatePlatformGame
|
|
250
|
+
};
|
|
251
|
+
//# sourceMappingURL=platform-games.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/platform-games.ts"],"sourcesContent":["import {\n airJamGameMetadataSchema,\n type AirJamGameMetadata,\n} from \"@air-jam/sdk/metadata\";\nimport {\n platformMachineCreateOwnedGameResultSchema,\n platformMachineGetOwnedGameResultSchema,\n platformMachineListOwnedGamesResultSchema,\n platformMachineUpdateOwnedGameResultSchema,\n} from \"@air-jam/sdk/platform-machine\";\nimport { readFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { runCommandResult } from \"./commands.js\";\nimport {\n findUp,\n pathExists,\n readJsonFile,\n readPackageJson,\n} from \"./fs-utils.js\";\nimport { inspectGame } from \"./games.js\";\nimport {\n requestPlatformMachineApi,\n resolvePlatformMachineAuth,\n} from \"./platform-auth.js\";\nimport type {\n AirJamLocalHostedGameDefaults,\n CreatePlatformGameOptions,\n InspectPlatformGameOptions,\n ListPlatformGamesOptions,\n UpdatePlatformGameOptions,\n} from \"./types.js\";\n\nexport type {\n AirJamLocalHostedGameDefaults,\n CreatePlatformGameOptions,\n InspectPlatformGameOptions,\n ListPlatformGamesOptions,\n UpdatePlatformGameOptions,\n} from \"./types.js\";\n\nconst require = createRequire(import.meta.url);\n\nconst resolveTsxLoaderPath = (): string | null => {\n try {\n return require.resolve(\"tsx/esm\");\n } catch {\n return null;\n }\n};\n\nconst normalizeGithubRemoteUrl = (value: string): string | null => {\n const trimmed = value.trim();\n if (!trimmed) {\n return null;\n }\n\n if (trimmed.startsWith(\"git@github.com:\")) {\n const repoPath = trimmed\n .slice(\"git@github.com:\".length)\n .replace(/\\.git$/, \"\");\n return repoPath ? `https://github.com/${repoPath}` : null;\n }\n\n try {\n const url = new URL(trimmed);\n if (url.hostname !== \"github.com\") {\n return null;\n }\n\n return `https://github.com${url.pathname.replace(/\\.git$/, \"\")}`.replace(\n /\\/$/,\n \"\",\n );\n } catch {\n return null;\n }\n};\n\nconst readGitRemoteFromConfig = async (\n gitDirOrFilePath: string,\n): Promise<string | null> => {\n let configPath: string | null = null;\n\n const statsFile = await readFile(gitDirOrFilePath, \"utf8\").catch(() => null);\n if (statsFile?.startsWith(\"gitdir:\")) {\n const relativeGitDir = statsFile.slice(\"gitdir:\".length).trim();\n const resolvedGitDir = path.resolve(\n path.dirname(gitDirOrFilePath),\n relativeGitDir,\n );\n configPath = path.join(resolvedGitDir, \"config\");\n } else {\n configPath = path.join(gitDirOrFilePath, \"config\");\n }\n\n if (!(await pathExists(configPath))) {\n return null;\n }\n\n const config = await readFile(configPath, \"utf8\");\n const remoteBlockMatch = config.match(\n /\\[remote \"origin\"\\][\\s\\S]*?(?:\\n\\[|$)/,\n );\n if (!remoteBlockMatch) {\n return null;\n }\n\n const urlMatch = remoteBlockMatch[0].match(/^\\s*url\\s*=\\s*(.+)$/m);\n return urlMatch?.[1]?.trim() || null;\n};\n\nconst resolveRepoSourceUrl = async ({\n projectDir,\n}: {\n projectDir: string;\n}): Promise<string | null> => {\n const gitMarkerPath = await findUp(projectDir, \".git\");\n if (!gitMarkerPath) {\n return null;\n }\n\n const repoRoot = path.dirname(gitMarkerPath);\n const remoteUrl = await readGitRemoteFromConfig(gitMarkerPath);\n const normalizedRemoteUrl = remoteUrl\n ? normalizeGithubRemoteUrl(remoteUrl)\n : null;\n\n if (!normalizedRemoteUrl) {\n return null;\n }\n\n const relativeProjectPath = path.relative(repoRoot, projectDir);\n if (!relativeProjectPath || relativeProjectPath.startsWith(\"..\")) {\n return null;\n }\n\n return `${normalizedRemoteUrl}/tree/main/${relativeProjectPath.replaceAll(path.sep, \"/\")}`;\n};\n\ntype LocalTemplateManifest = {\n id?: unknown;\n name?: unknown;\n description?: unknown;\n category?: unknown;\n};\n\nconst toOptionalString = (value: unknown): string | null =>\n typeof value === \"string\" && value.trim() ? value.trim() : null;\n\nconst resolveTemplateManifestPath = (projectDir: string) =>\n path.join(projectDir, \"airjam-template.json\");\n\nconst loadTemplateManifest = async (\n projectDir: string,\n): Promise<{\n path: string | null;\n value: LocalTemplateManifest | null;\n}> => {\n const manifestPath = resolveTemplateManifestPath(projectDir);\n try {\n return {\n path: manifestPath,\n value: await readJsonFile<LocalTemplateManifest>(manifestPath),\n };\n } catch {\n return {\n path: null,\n value: null,\n };\n }\n};\n\nconst loadGameMetadataFromConfig = async (\n configPath: string | null,\n): Promise<AirJamGameMetadata | null> => {\n if (!configPath) {\n return null;\n }\n\n const tsxLoaderPath = resolveTsxLoaderPath();\n if (!tsxLoaderPath) {\n return null;\n }\n\n const configUrl = pathToFileURL(configPath).href;\n const script = `\n const moduleUrl = ${JSON.stringify(configUrl)};\n const mod = await import(moduleUrl);\n const value = mod.gameMetadata ?? mod.airjam?.metadata ?? null;\n process.stdout.write(JSON.stringify(value));\n `;\n\n const result = runCommandResult({\n command: process.execPath,\n args: [\"--import\", tsxLoaderPath, \"--input-type=module\", \"--eval\", script],\n cwd: path.dirname(configPath),\n });\n\n if (!result.ok) {\n return null;\n }\n\n const raw = result.stdout.trim();\n if (!raw) {\n return null;\n }\n\n try {\n return airJamGameMetadataSchema.parse(JSON.parse(raw) as unknown);\n } catch {\n return null;\n }\n};\n\nexport const readLocalHostedGameDefaults = async ({\n cwd = process.cwd(),\n}: {\n cwd?: string;\n} = {}): Promise<AirJamLocalHostedGameDefaults> => {\n const game = await inspectGame({ cwd });\n const [template, packageJson, metadata, sourceUrl] = await Promise.all([\n loadTemplateManifest(game.rootDir),\n readPackageJson(game.rootDir),\n loadGameMetadataFromConfig(game.configPath),\n resolveRepoSourceUrl({ projectDir: game.rootDir }),\n ]);\n\n return {\n projectDir: game.rootDir,\n configPath: game.configPath,\n manifestPath: template.path,\n packageJsonPath: packageJson?.path ?? null,\n packageName: game.packageName,\n sourceUrl,\n metadata: {\n name: metadata?.name ?? null,\n slug: metadata?.slug ?? null,\n description: metadata?.tagline ?? null,\n category: metadata?.category ?? null,\n tags: metadata?.tags ? [...metadata.tags] : [],\n },\n template: {\n id: toOptionalString(template.value?.id),\n name: toOptionalString(template.value?.name),\n description: toOptionalString(template.value?.description),\n category: toOptionalString(template.value?.category),\n },\n };\n};\n\nexport const listPlatformGames = async ({\n platformUrl,\n token,\n}: ListPlatformGamesOptions = {}) => {\n const resolved = await resolvePlatformMachineAuth({ platformUrl, token });\n\n return requestPlatformMachineApi({\n baseUrl: resolved.baseUrl,\n pathname: \"/api/cli/games\",\n token: resolved.token,\n schema: platformMachineListOwnedGamesResultSchema,\n });\n};\n\nexport const inspectPlatformGame = async ({\n platformUrl,\n token,\n slugOrId,\n}: InspectPlatformGameOptions) => {\n const resolved = await resolvePlatformMachineAuth({ platformUrl, token });\n\n return requestPlatformMachineApi({\n baseUrl: resolved.baseUrl,\n pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}`,\n token: resolved.token,\n schema: platformMachineGetOwnedGameResultSchema,\n });\n};\n\nexport const createPlatformGame = async ({\n platformUrl,\n token,\n input,\n}: CreatePlatformGameOptions) => {\n const resolved = await resolvePlatformMachineAuth({ platformUrl, token });\n\n return requestPlatformMachineApi({\n baseUrl: resolved.baseUrl,\n pathname: \"/api/cli/games\",\n method: \"POST\",\n token: resolved.token,\n body: input,\n schema: platformMachineCreateOwnedGameResultSchema,\n });\n};\n\nexport const updatePlatformGame = async ({\n platformUrl,\n token,\n slugOrId,\n input,\n}: UpdatePlatformGameOptions) => {\n const resolved = await resolvePlatformMachineAuth({ platformUrl, token });\n\n return requestPlatformMachineApi({\n baseUrl: resolved.baseUrl,\n pathname: `/api/cli/games/${encodeURIComponent(slugOrId)}`,\n method: \"PATCH\",\n token: resolved.token,\n body: input,\n schema: platformMachineUpdateOwnedGameResultSchema,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AACjB,SAAS,qBAAqB;AA6B9B,IAA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BAA0B;AAAA,IAC/B,SAAS,SAAS;AAAA,IAClB,UAAU,kBAAkB,mBAAmB,QAAQ,CAAC;AAAA,IACxD,QAAQ;AAAA,IACR,OAAO,SAAS;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,EACV,CAAC;AACH;","names":["require"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ai as RunQualityGateOptions, a1 as CommandResult, aj as RunCompleteEvaluationOptions, ak as AirJamCompleteEvaluationResult } from './types-C6NrHt88.js';
|
|
2
|
+
export { al as AirJamQualityGate } from './types-C6NrHt88.js';
|
|
3
|
+
import '@air-jam/sdk';
|
|
4
|
+
import '@air-jam/sdk/platform-machine';
|
|
5
|
+
|
|
6
|
+
declare const AIR_JAM_COMPLETE_EVALUATION_GATES: readonly ["typecheck", "lint", "test", "build"];
|
|
7
|
+
declare const runQualityGate: (options: RunQualityGateOptions) => Promise<CommandResult>;
|
|
8
|
+
declare const runCompleteEvaluation: ({ cwd, }?: RunCompleteEvaluationOptions) => Promise<AirJamCompleteEvaluationResult>;
|
|
9
|
+
|
|
10
|
+
export { AIR_JAM_COMPLETE_EVALUATION_GATES, AirJamCompleteEvaluationResult, CommandResult, RunCompleteEvaluationOptions, RunQualityGateOptions, runCompleteEvaluation, runQualityGate };
|
package/dist/quality.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runCommandResult
|
|
3
|
+
} from "./chunk-5YAARMW5.js";
|
|
4
|
+
import {
|
|
5
|
+
detectProjectContext
|
|
6
|
+
} from "./chunk-S4LSCEVE.js";
|
|
7
|
+
|
|
8
|
+
// src/quality.ts
|
|
9
|
+
var AIR_JAM_COMPLETE_EVALUATION_GATES = [
|
|
10
|
+
"typecheck",
|
|
11
|
+
"lint",
|
|
12
|
+
"test",
|
|
13
|
+
"build"
|
|
14
|
+
];
|
|
15
|
+
var GATE_TO_SCRIPT = {
|
|
16
|
+
typecheck: "typecheck",
|
|
17
|
+
lint: "lint",
|
|
18
|
+
test: "test",
|
|
19
|
+
build: "build",
|
|
20
|
+
"format-check": "format:check",
|
|
21
|
+
"scaffold-smoke": "test:scaffold",
|
|
22
|
+
"release-check": "check:release"
|
|
23
|
+
};
|
|
24
|
+
var runQualityGate = async (options) => {
|
|
25
|
+
const context = await detectProjectContext({ cwd: options.cwd });
|
|
26
|
+
const script = GATE_TO_SCRIPT[options.gate];
|
|
27
|
+
if (context.mode !== "monorepo" && (options.gate === "scaffold-smoke" || options.gate === "release-check")) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Quality gate "${options.gate}" is only available in the Air Jam monorepo.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const args = options.packageFilter ? ["--filter", options.packageFilter, "run", script] : ["run", script];
|
|
33
|
+
return runCommandResult({
|
|
34
|
+
command: "pnpm",
|
|
35
|
+
args,
|
|
36
|
+
cwd: context.rootDir
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var runCompleteEvaluation = async ({
|
|
40
|
+
cwd
|
|
41
|
+
} = {}) => {
|
|
42
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
43
|
+
const gates = [];
|
|
44
|
+
for (const gate of AIR_JAM_COMPLETE_EVALUATION_GATES) {
|
|
45
|
+
gates.push({
|
|
46
|
+
gate,
|
|
47
|
+
result: await runQualityGate({ cwd, gate })
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
contract: "air-jam-complete-evaluation/v1",
|
|
52
|
+
status: gates.every(({ result }) => result.ok) ? "passed" : "failed",
|
|
53
|
+
startedAt,
|
|
54
|
+
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
55
|
+
gates
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
AIR_JAM_COMPLETE_EVALUATION_GATES,
|
|
60
|
+
runCompleteEvaluation,
|
|
61
|
+
runQualityGate
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=quality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/quality.ts"],"sourcesContent":["import { runCommandResult } from \"./commands.js\";\nimport { detectProjectContext } from \"./context.js\";\nimport type {\n AirJamCompleteEvaluationResult,\n AirJamQualityGate,\n CommandResult,\n RunCompleteEvaluationOptions,\n RunQualityGateOptions,\n} from \"./types.js\";\n\nexport type {\n AirJamCompleteEvaluationResult,\n AirJamQualityGate,\n CommandResult,\n RunCompleteEvaluationOptions,\n RunQualityGateOptions,\n} from \"./types.js\";\n\nexport const AIR_JAM_COMPLETE_EVALUATION_GATES = [\n \"typecheck\",\n \"lint\",\n \"test\",\n \"build\",\n] as const satisfies readonly AirJamQualityGate[];\n\nconst GATE_TO_SCRIPT: Record<RunQualityGateOptions[\"gate\"], string> = {\n typecheck: \"typecheck\",\n lint: \"lint\",\n test: \"test\",\n build: \"build\",\n \"format-check\": \"format:check\",\n \"scaffold-smoke\": \"test:scaffold\",\n \"release-check\": \"check:release\",\n};\n\nexport const runQualityGate = async (\n options: RunQualityGateOptions,\n): Promise<CommandResult> => {\n const context = await detectProjectContext({ cwd: options.cwd });\n const script = GATE_TO_SCRIPT[options.gate];\n\n if (\n context.mode !== \"monorepo\" &&\n (options.gate === \"scaffold-smoke\" || options.gate === \"release-check\")\n ) {\n throw new Error(\n `Quality gate \"${options.gate}\" is only available in the Air Jam monorepo.`,\n );\n }\n\n const args = options.packageFilter\n ? [\"--filter\", options.packageFilter, \"run\", script]\n : [\"run\", script];\n\n return runCommandResult({\n command: \"pnpm\",\n args,\n cwd: context.rootDir,\n });\n};\n\nexport const runCompleteEvaluation = async ({\n cwd,\n}: RunCompleteEvaluationOptions = {}): Promise<AirJamCompleteEvaluationResult> => {\n const startedAt = new Date().toISOString();\n const gates: AirJamCompleteEvaluationResult[\"gates\"] = [];\n\n for (const gate of AIR_JAM_COMPLETE_EVALUATION_GATES) {\n gates.push({\n gate,\n result: await runQualityGate({ cwd, gate }),\n });\n }\n\n return {\n contract: \"air-jam-complete-evaluation/v1\",\n status: gates.every(({ result }) => result.ok) ? \"passed\" : \"failed\",\n startedAt,\n endedAt: new Date().toISOString(),\n gates,\n };\n};\n"],"mappings":";;;;;;;;AAkBO,IAAM,oCAAoC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,iBAAgE;AAAA,EACpE,WAAW;AAAA,EACX,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,iBAAiB;AACnB;AAEO,IAAM,iBAAiB,OAC5B,YAC2B;AAC3B,QAAM,UAAU,MAAM,qBAAqB,EAAE,KAAK,QAAQ,IAAI,CAAC;AAC/D,QAAM,SAAS,eAAe,QAAQ,IAAI;AAE1C,MACE,QAAQ,SAAS,eAChB,QAAQ,SAAS,oBAAoB,QAAQ,SAAS,kBACvD;AACA,UAAM,IAAI;AAAA,MACR,iBAAiB,QAAQ,IAAI;AAAA,IAC/B;AAAA,EACF;AAEA,QAAM,OAAO,QAAQ,gBACjB,CAAC,YAAY,QAAQ,eAAe,OAAO,MAAM,IACjD,CAAC,OAAO,MAAM;AAElB,SAAO,iBAAiB;AAAA,IACtB,SAAS;AAAA,IACT;AAAA,IACA,KAAK,QAAQ;AAAA,EACf,CAAC;AACH;AAEO,IAAM,wBAAwB,OAAO;AAAA,EAC1C;AACF,IAAkC,CAAC,MAA+C;AAChF,QAAM,aAAY,oBAAI,KAAK,GAAE,YAAY;AACzC,QAAM,QAAiD,CAAC;AAExD,aAAW,QAAQ,mCAAmC;AACpD,UAAM,KAAK;AAAA,MACT;AAAA,MACA,QAAQ,MAAM,eAAe,EAAE,KAAK,KAAK,CAAC;AAAA,IAC5C,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV,QAAQ,MAAM,MAAM,CAAC,EAAE,OAAO,MAAM,OAAO,EAAE,IAAI,WAAW;AA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