@craft_eco/craft-mcp 0.1.31 → 0.1.32
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/README.md +4 -4
- package/dist-server/game-workflow/check.mjs +35 -13
- package/dist-server/game-workflow/draft-archive.mjs +14 -5
- package/dist-server/game-workflow/draft-uploads.mjs +22 -9
- package/dist-server/game-workflow/upload-security-policy.mjs +241 -0
- package/dist-server/game-workflow/upload-security.mjs +41 -0
- package/dist-server/integrations/runtime-gc.mjs +131 -35
- package/dist-server/mcp/server.mjs +31 -19
- package/package.json +3 -1
- package/resources/craft-create/SKILL.md +2 -0
- package/resources/craft-update/SKILL.md +2 -0
- package/resources/targets/claude/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/claude/js/js/bundle.json +5 -5
- package/resources/targets/claude/js/target.json +1 -1
- package/resources/targets/claude/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/claude/js3d/js3d/bundle.json +5 -5
- package/resources/targets/claude/js3d/target.json +1 -1
- package/resources/targets/codebuddy/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/codebuddy/js/js/bundle.json +5 -5
- package/resources/targets/codebuddy/js/target.json +1 -1
- package/resources/targets/codebuddy/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/codebuddy/js3d/js3d/bundle.json +5 -5
- package/resources/targets/codebuddy/js3d/target.json +1 -1
- package/resources/targets/codex/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/codex/js/js/bundle.json +5 -5
- package/resources/targets/codex/js/target.json +1 -1
- package/resources/targets/codex/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/codex/js3d/js3d/bundle.json +5 -5
- package/resources/targets/codex/js3d/target.json +1 -1
- package/resources/targets/comate/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/comate/js/js/bundle.json +5 -5
- package/resources/targets/comate/js/target.json +1 -1
- package/resources/targets/comate/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/comate/js3d/js3d/bundle.json +5 -5
- package/resources/targets/comate/js3d/target.json +1 -1
- package/resources/targets/cursor/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/cursor/js/js/bundle.json +5 -5
- package/resources/targets/cursor/js/target.json +1 -1
- package/resources/targets/cursor/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/cursor/js3d/js3d/bundle.json +5 -5
- package/resources/targets/cursor/js3d/target.json +1 -1
- package/resources/targets/dsh/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/dsh/js/js/bundle.json +5 -5
- package/resources/targets/dsh/js/target.json +1 -1
- package/resources/targets/dsh/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/dsh/js3d/js3d/bundle.json +5 -5
- package/resources/targets/dsh/js3d/target.json +1 -1
- package/resources/targets/index.json +56 -56
- package/resources/targets/kimi/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/kimi/js/js/bundle.json +5 -5
- package/resources/targets/kimi/js/target.json +1 -1
- package/resources/targets/kimi/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/kimi/js3d/js3d/bundle.json +5 -5
- package/resources/targets/kimi/js3d/target.json +1 -1
- package/resources/targets/opencode/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/opencode/js/js/bundle.json +5 -5
- package/resources/targets/opencode/js/target.json +1 -1
- package/resources/targets/opencode/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/opencode/js3d/js3d/bundle.json +5 -5
- package/resources/targets/opencode/js3d/target.json +1 -1
- package/resources/targets/qoder/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/qoder/js/js/bundle.json +5 -5
- package/resources/targets/qoder/js/target.json +1 -1
- package/resources/targets/qoder/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/qoder/js3d/js3d/bundle.json +5 -5
- package/resources/targets/qoder/js3d/target.json +1 -1
- package/resources/targets/qoder-cn/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/qoder-cn/js/js/bundle.json +5 -5
- package/resources/targets/qoder-cn/js/target.json +1 -1
- package/resources/targets/qoder-cn/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/qoder-cn/js3d/js3d/bundle.json +5 -5
- package/resources/targets/qoder-cn/js3d/target.json +1 -1
- package/resources/targets/qwen/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/qwen/js/js/bundle.json +5 -5
- package/resources/targets/qwen/js/target.json +1 -1
- package/resources/targets/qwen/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/qwen/js3d/js3d/bundle.json +5 -5
- package/resources/targets/qwen/js3d/target.json +1 -1
- package/resources/targets/trae/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/trae/js/js/bundle.json +5 -5
- package/resources/targets/trae/js/target.json +1 -1
- package/resources/targets/trae/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/trae/js3d/js3d/bundle.json +5 -5
- package/resources/targets/trae/js3d/target.json +1 -1
- package/resources/targets/workbuddy/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/workbuddy/js/js/bundle.json +5 -5
- package/resources/targets/workbuddy/js/target.json +1 -1
- package/resources/targets/workbuddy/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/workbuddy/js3d/js3d/bundle.json +5 -5
- package/resources/targets/workbuddy/js3d/target.json +1 -1
- package/resources/targets/zcode/js/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/zcode/js/js/bundle.json +5 -5
- package/resources/targets/zcode/js/target.json +1 -1
- package/resources/targets/zcode/js3d/craft-game-maker/SKILL.md +3 -3
- package/resources/targets/zcode/js3d/js3d/bundle.json +5 -5
- package/resources/targets/zcode/js3d/target.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { readdir, readFile, mkdir, writeFile, unlink, lstat, realpath, rm } from 'node:fs/promises';
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readdir, readFile, mkdir, writeFile, unlink, lstat, realpath, rm, rename, rmdir } from 'node:fs/promises';
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
4
4
|
import { execFile } from 'node:child_process';
|
|
5
5
|
import { promisify } from 'node:util';
|
|
6
6
|
import lockfile from 'proper-lockfile';
|
|
@@ -72,19 +72,94 @@ async function ownedRuntimes(root, packageName) {
|
|
|
72
72
|
const directory = path.join(root, entry.name);
|
|
73
73
|
try {
|
|
74
74
|
await safeDirectory(directory);
|
|
75
|
-
const
|
|
75
|
+
const metadataText = await readFile(path.join(directory, 'craft-runtime.json'), 'utf8');
|
|
76
|
+
const metadata = JSON.parse(metadataText);
|
|
76
77
|
if (metadata.package !== packageName || !/^[a-f0-9]{64}$/.test(metadata.sha256 ?? '') || !/^[a-f0-9]{64}$/.test(metadata.build_id ?? '') || entry.name !== metadata.version + '-' + metadata.sha256.slice(0, 16)) continue;
|
|
77
78
|
compareVersions(metadata.version, metadata.version);
|
|
78
79
|
const packageRoot = path.join(directory, 'node_modules', ...packageName.split('/'));
|
|
79
80
|
await assertPlainPath(path.join(packageRoot, 'package.json'));
|
|
80
81
|
const pkg = JSON.parse(await readFile(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
81
82
|
if (pkg.name !== packageName || pkg.version !== metadata.version) continue;
|
|
82
|
-
owned.push({ directory, packageRoot, metadata });
|
|
83
|
+
owned.push({ directory, packageRoot, metadata, metadataText, stamp: await directoryStamp(directory) });
|
|
83
84
|
} catch { /* Unrecognized, linked or partial directories are not ours to remove. */ }
|
|
84
85
|
}
|
|
85
86
|
return owned;
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
async function directoryStamp(directory) {
|
|
90
|
+
const info = await lstat(directory);
|
|
91
|
+
return [info.dev, info.ino, info.birthtimeMs, info.mtimeMs].map(String).join(':');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const retiredName = /^gc-[a-f0-9-]{36}$/;
|
|
95
|
+
async function retiredRuntimes(root, packageName) {
|
|
96
|
+
const directory = path.join(root, '.retired');
|
|
97
|
+
try { await safeDirectory(directory); }
|
|
98
|
+
catch (error) { if (error.code === 'ENOENT') return []; throw error; }
|
|
99
|
+
const retired = [];
|
|
100
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
101
|
+
if (!entry.isDirectory() || entry.isSymbolicLink() || !retiredName.test(entry.name)) continue;
|
|
102
|
+
const container = path.join(directory, entry.name);
|
|
103
|
+
try {
|
|
104
|
+
await safeDirectory(container);
|
|
105
|
+
const manifestFile = path.join(container, 'retirement.json');
|
|
106
|
+
await assertPlainPath(manifestFile);
|
|
107
|
+
const manifestText = await readFile(manifestFile, 'utf8'), manifest = JSON.parse(manifestText);
|
|
108
|
+
if (manifest.schema !== 1 || manifest.package !== packageName || !/^[a-f0-9]{64}$/.test(manifest.sha256 ?? '') || !/^[a-f0-9]{64}$/.test(manifest.build_id ?? '') ||
|
|
109
|
+
manifest.source_name !== manifest.version + '-' + manifest.sha256.slice(0, 16)) continue;
|
|
110
|
+
compareVersions(manifest.version, manifest.version);
|
|
111
|
+
// The manifest authorizes only this private child. It never supplies a
|
|
112
|
+
// deletion path. Keep it outside runtime/ so interrupted deletion can
|
|
113
|
+
// resume even after the package's own metadata has been removed.
|
|
114
|
+
const names = await readdir(container);
|
|
115
|
+
if (names.some(name => !['retirement.json', 'runtime'].includes(name))) continue;
|
|
116
|
+
const runtime = path.join(container, 'runtime');
|
|
117
|
+
if (names.includes('runtime')) await safeDirectory(runtime);
|
|
118
|
+
retired.push({ container, directory: runtime, manifestFile, manifestText, metadata: manifest });
|
|
119
|
+
} catch { /* Unknown, linked or partial ownership records stay untouched. */ }
|
|
120
|
+
}
|
|
121
|
+
return retired;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function installationNames(directory) {
|
|
125
|
+
const entries = (await readdir(directory, { withFileTypes: true })).filter(entry => entry.name.endsWith('.json'));
|
|
126
|
+
if (entries.some(entry => !entry.isFile() || entry.isSymbolicLink())) throw new Error('Unknown installation reference');
|
|
127
|
+
return entries.map(entry => entry.name).sort();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function preserveConnectionLeases(root, preserve, isAlive) {
|
|
131
|
+
const leaseRoot = path.join(root, '.connections');
|
|
132
|
+
let leases;
|
|
133
|
+
try { await safeDirectory(leaseRoot); leases = await readdir(leaseRoot, { withFileTypes: true }); }
|
|
134
|
+
catch (error) { if (error.code === 'ENOENT') return; throw error; }
|
|
135
|
+
for (const entry of leases) {
|
|
136
|
+
if (!entry.isFile() || entry.isSymbolicLink() || !entry.name.endsWith('.json')) throw new Error('Unknown connection reference');
|
|
137
|
+
const file = path.join(leaseRoot, entry.name);
|
|
138
|
+
let lease;
|
|
139
|
+
try { lease = JSON.parse(await readFile(file, 'utf8')); }
|
|
140
|
+
catch (error) { if (error.code === 'ENOENT') continue; throw error; }
|
|
141
|
+
if (!Number.isSafeInteger(lease.pid) || lease.pid <= 0 || !path.isAbsolute(lease.package_root ?? '')) throw new Error('Invalid connection reference');
|
|
142
|
+
if (isAlive(lease.pid)) preserve(lease.package_root);
|
|
143
|
+
else await unlink(file).catch(error => { if (error.code !== 'ENOENT') throw error; });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function removeRetired(root, item, removeDirectory) {
|
|
148
|
+
const retiredRoot = path.join(root, '.retired'), { container, directory, manifestFile, manifestText } = item;
|
|
149
|
+
if (path.dirname(container) !== retiredRoot || !retiredName.test(path.basename(container)) || directory !== path.join(container, 'runtime')) throw new Error('Runtime cleanup escaped its retirement directory');
|
|
150
|
+
await safeDirectory(retiredRoot); await safeDirectory(container);
|
|
151
|
+
await assertPlainPath(manifestFile);
|
|
152
|
+
if (await readFile(manifestFile, 'utf8') !== manifestText) throw new Error('Runtime retirement ownership changed');
|
|
153
|
+
const names = await readdir(container);
|
|
154
|
+
if (names.some(name => !['retirement.json', 'runtime'].includes(name))) throw new Error('Unknown runtime retirement contents');
|
|
155
|
+
if (names.includes('runtime')) {
|
|
156
|
+
await safeDirectory(directory);
|
|
157
|
+
await removeDirectory(directory, { recursive: true, force: false });
|
|
158
|
+
}
|
|
159
|
+
await unlink(manifestFile);
|
|
160
|
+
await rmdir(container);
|
|
161
|
+
}
|
|
162
|
+
|
|
88
163
|
async function scopedState(installationFile, current) {
|
|
89
164
|
const state = await readInstallation(installationFile);
|
|
90
165
|
if (!path.isAbsolute(state.runtime_root ?? '') || current.package !== state.source.package) throw new Error('Invalid runtime cleanup scope');
|
|
@@ -94,30 +169,31 @@ async function scopedState(installationFile, current) {
|
|
|
94
169
|
|
|
95
170
|
/** Only confirmed host connections collect installer-owned, unreferenced
|
|
96
171
|
* runtime directories. Unknown references always defer deletion. */
|
|
97
|
-
export async function collectRetiredRuntimes({ installationFile, current, processReferences = runtimeProcessReferences, isAlive = pidAlive, keepPrevious = 1 }) {
|
|
172
|
+
export async function collectRetiredRuntimes({ installationFile, current, processReferences = runtimeProcessReferences, isAlive = pidAlive, keepPrevious = 1, removeDirectory = rm }) {
|
|
98
173
|
let unlock;
|
|
99
174
|
const skipped = reason => ({ status: 'deferred', reason, removed: [] });
|
|
100
175
|
try {
|
|
101
176
|
let state = await scopedState(installationFile, current);
|
|
102
177
|
const root = state.runtime_root;
|
|
103
|
-
unlock = await lockfile.lock(root, { stale: 120000, retries: 0 });
|
|
104
|
-
state = await readInstallation(installationFile);
|
|
105
|
-
if (!samePath(root, state.runtime_root)) return skipped('installation_changed');
|
|
106
178
|
const receipt = state.connection_verification;
|
|
107
179
|
if (state.schema !== 2 || activationStatus(current, state.target).status !== 'active_verified' || !receipt || receipt.instance_id !== current.instance_id || receipt.version !== current.version || receipt.build_id !== current.build_id) return skipped('connection_not_verified');
|
|
180
|
+
// Maintenance is never part of connection initialization. Enumeration,
|
|
181
|
+
// process inspection and recursive removal must not own the same lock a
|
|
182
|
+
// new fixed-entry connection needs to select and lease its package.
|
|
108
183
|
const candidates = await ownedRuntimes(root, state.source.package);
|
|
184
|
+
const previousRetirements = await retiredRuntimes(root, state.source.package);
|
|
185
|
+
const references = [...candidates, ...previousRetirements];
|
|
109
186
|
const protectedPaths = new Set(), preserve = value => {
|
|
110
|
-
for (const candidate of
|
|
187
|
+
for (const candidate of references) if (referencesDirectory(value, candidate.container ?? candidate.directory)) protectedPaths.add(canonical(candidate.directory));
|
|
111
188
|
};
|
|
112
189
|
preserve(current);
|
|
113
190
|
const stateRoot = path.dirname(installationFile);
|
|
114
191
|
// Check every managed installation sharing this state directory. Invalid
|
|
115
192
|
// state/config means ownership cannot be established, so collect nothing.
|
|
116
193
|
const snapshots = [];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const file = path.join(stateRoot, entry.name), text = await readFile(file, 'utf8');
|
|
194
|
+
const names = await installationNames(stateRoot);
|
|
195
|
+
for (const name of names) {
|
|
196
|
+
const file = path.join(stateRoot, name), text = await readFile(file, 'utf8');
|
|
121
197
|
const installation = await readInstallation(file);
|
|
122
198
|
snapshots.push({ file, text });
|
|
123
199
|
preserve(installation.anchor); preserve(installation.target); preserve(installation.skills_runtime);
|
|
@@ -125,41 +201,61 @@ export async function collectRetiredRuntimes({ installationFile, current, proces
|
|
|
125
201
|
preserve(readConfig(configText, installation.host));
|
|
126
202
|
snapshots.push({ file: installation.config, text: configText });
|
|
127
203
|
}
|
|
128
|
-
const
|
|
129
|
-
let leases = [];
|
|
130
|
-
try { await safeDirectory(leaseRoot); leases = await readdir(leaseRoot, { withFileTypes: true }); }
|
|
131
|
-
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
132
|
-
for (const entry of leases) {
|
|
133
|
-
if (!entry.isFile() || entry.isSymbolicLink() || !entry.name.endsWith('.json')) return skipped('unknown_connection_reference');
|
|
134
|
-
const file = path.join(leaseRoot, entry.name), lease = JSON.parse(await readFile(file, 'utf8'));
|
|
135
|
-
if (!Number.isSafeInteger(lease.pid) || lease.pid <= 0 || !path.isAbsolute(lease.package_root ?? '')) return skipped('invalid_connection_reference');
|
|
136
|
-
if (isAlive(lease.pid)) preserve(lease.package_root);
|
|
137
|
-
else await unlink(file);
|
|
138
|
-
}
|
|
139
|
-
const processes = await processReferences(candidates.map(candidate => candidate.directory));
|
|
204
|
+
const processes = await processReferences(references.map(candidate => candidate.container ?? candidate.directory));
|
|
140
205
|
if (!processes.complete) return skipped('process_inventory_unavailable');
|
|
141
206
|
preserve(processes.directories);
|
|
207
|
+
// Retain the legacy-process recheck, outside the shared lock. A legacy
|
|
208
|
+
// direct launch does not participate in leases; process inventory is a
|
|
209
|
+
// conservative check, not a claim that all external launch races vanish.
|
|
210
|
+
const recheck = references.filter(candidate => !protectedPaths.has(canonical(candidate.directory))).map(candidate => candidate.container ?? candidate.directory);
|
|
211
|
+
if (recheck.length) {
|
|
212
|
+
const latestProcesses = await processReferences(recheck);
|
|
213
|
+
if (!latestProcesses.complete) return skipped('process_inventory_unavailable');
|
|
214
|
+
preserve(latestProcesses.directories);
|
|
215
|
+
}
|
|
216
|
+
unlock = await lockfile.lock(root, { stale: 120000, retries: 0 });
|
|
217
|
+
if (JSON.stringify(await installationNames(stateRoot)) !== JSON.stringify(names)) return skipped('references_changed');
|
|
218
|
+
for (const snapshot of snapshots) if (await readFile(snapshot.file, 'utf8') !== snapshot.text) return skipped('references_changed');
|
|
219
|
+
state = await readInstallation(installationFile);
|
|
220
|
+
if (!samePath(root, state.runtime_root)) return skipped('installation_changed');
|
|
221
|
+
await preserveConnectionLeases(root, preserve, isAlive);
|
|
142
222
|
const retired = candidates.filter(candidate => !protectedPaths.has(canonical(candidate.directory)));
|
|
143
223
|
// A higher unreferenced candidate may belong to an interrupted update; do
|
|
144
224
|
// not remove it as an old release. Keep one previous build for recovery.
|
|
145
225
|
const older = retired.filter(candidate => compareVersions(candidate.metadata.version, current.version) <= 0)
|
|
146
226
|
.sort((a, b) => compareVersions(b.metadata.version, a.metadata.version) || b.directory.localeCompare(a.directory));
|
|
147
227
|
const keep = older.slice(0, Math.max(1, keepPrevious));
|
|
148
|
-
const removed = [], failures = [];
|
|
228
|
+
const removed = [], failures = [], moved = [];
|
|
149
229
|
for (const candidate of older.slice(keep.length)) {
|
|
150
|
-
// Recheck just before each removal: a legacy host can start a cached
|
|
151
|
-
// command after the initial inventory without creating a connection lease.
|
|
152
|
-
const latestProcesses = await processReferences([candidate.directory]);
|
|
153
|
-
if (!latestProcesses.complete) return { ...skipped('process_inventory_unavailable'), removed };
|
|
154
|
-
if (referencesDirectory(latestProcesses.directories, candidate.directory)) continue;
|
|
155
|
-
for (const snapshot of snapshots) if (await readFile(snapshot.file, 'utf8') !== snapshot.text) return { ...skipped('references_changed'), removed };
|
|
156
230
|
const directory = path.resolve(candidate.directory);
|
|
157
231
|
if (!within(root, directory) || !samePath(path.dirname(directory), root)) throw new Error('Runtime cleanup escaped its managed root');
|
|
158
232
|
await safeDirectory(directory);
|
|
159
|
-
|
|
160
|
-
|
|
233
|
+
if (await directoryStamp(directory) !== candidate.stamp || await readFile(path.join(directory, 'craft-runtime.json'), 'utf8') !== candidate.metadataText) return skipped('runtime_changed');
|
|
234
|
+
const retiredRoot = path.join(root, '.retired');
|
|
235
|
+
await mkdir(retiredRoot, { recursive: true }); await safeDirectory(retiredRoot);
|
|
236
|
+
const container = path.join(retiredRoot, 'gc-' + randomUUID());
|
|
237
|
+
await mkdir(container); await safeDirectory(container);
|
|
238
|
+
const manifestFile = path.join(container, 'retirement.json');
|
|
239
|
+
const manifestText = JSON.stringify({ schema: 1, package: state.source.package, version: candidate.metadata.version,
|
|
240
|
+
sha256: candidate.metadata.sha256, build_id: candidate.metadata.build_id, source_name: path.basename(directory) });
|
|
241
|
+
await writeFile(manifestFile, manifestText, { flag: 'wx', mode: 0o600 });
|
|
242
|
+
const item = { container, directory: path.join(container, 'runtime'), manifestFile, manifestText, metadata: candidate.metadata, source: directory };
|
|
243
|
+
try { await rename(directory, item.directory); moved.push(item); }
|
|
244
|
+
catch { failures.push(directory); moved.push({ ...item, source: undefined }); }
|
|
245
|
+
}
|
|
246
|
+
// Retirement is committed by rename while new launches/installers are
|
|
247
|
+
// excluded. They can now create/lease a different directory at the old
|
|
248
|
+
// path without the slow removal below touching that new package.
|
|
249
|
+
await unlock(); unlock = undefined;
|
|
250
|
+
const reaped = [];
|
|
251
|
+
for (const item of [...previousRetirements.filter(item => !protectedPaths.has(canonical(item.directory)) && compareVersions(item.metadata.version, current.version) <= 0), ...moved]) {
|
|
252
|
+
try {
|
|
253
|
+
await removeRetired(root, item, removeDirectory);
|
|
254
|
+
if (item.source) removed.push(item.source); else reaped.push(item.container);
|
|
255
|
+
} catch { failures.push(item.container); }
|
|
161
256
|
}
|
|
162
|
-
return { status: failures.length ? 'partial' : 'completed', removed, retained_backup: keep.map(item => item.directory),
|
|
257
|
+
return { status: failures.length ? 'partial' : 'completed', removed, retained_backup: keep.map(item => item.directory),
|
|
258
|
+
...(reaped.length ? { reaped } : {}), ...(failures.length ? { deferred: failures } : {}) };
|
|
163
259
|
} catch { return skipped('references_unavailable_or_busy'); }
|
|
164
260
|
finally { await unlock?.(); }
|
|
165
261
|
}
|
|
@@ -73,6 +73,7 @@ const resourcePaths = { capture:path.join(resources,'game_visual_qa.mjs'), evide
|
|
|
73
73
|
const drafts = new DraftUploads(platform,uploadStore,resourcePaths.evidence,new DraftBindings(getProjectBindingsDir(),root));
|
|
74
74
|
const mutations = new Set();
|
|
75
75
|
let closing = false;
|
|
76
|
+
let runtimeMaintenance;
|
|
76
77
|
let authInteraction=false;
|
|
77
78
|
async function validateWork(work,{preparing=false}={}) {
|
|
78
79
|
await leases.assert(work.name,work.work_id,{ready:!preparing,context_revision:work.context_revision});
|
|
@@ -83,7 +84,8 @@ function runtimeBusy({excludeUpdate=false}={}) {
|
|
|
83
84
|
if(platform.store.getSession().loggedIn) authInteraction=false;
|
|
84
85
|
const busy={work_count:leases.activeCount,task_count:tasks.activeCount,mutation_count:mutations.size,
|
|
85
86
|
interaction_count:panel.activeRequests+Number(authInteraction),
|
|
86
|
-
update_count:Math.max(0,updates.activeOperations-Number(excludeUpdate))
|
|
87
|
+
update_count:Math.max(0,updates.activeOperations-Number(excludeUpdate)),
|
|
88
|
+
maintenance_count:Number(Boolean(runtimeMaintenance))};
|
|
87
89
|
return {...busy,can_reconnect:!closing && Object.values(busy).every(count=>count===0)};
|
|
88
90
|
}
|
|
89
91
|
const updates=new UpdateSession({installationFile:process.env.CRAFT_INSTALLATION_FILE,current:runtimeIdentity,projects,host,workspace:root,platform:platform.base,busy:runtimeBusy});
|
|
@@ -104,7 +106,7 @@ const engineField = { engine:{ type:'string',enum:['js','js3d'],description:'Cho
|
|
|
104
106
|
const taskField = { task_id:{ type:'string' } };
|
|
105
107
|
const workField = {work_id:{type:'string',description:'Exact work_id from the completed prepare. Keep it for this editing work; release when finished.'}};
|
|
106
108
|
const workTools=new Set(['craft_assets_generate','craft_assets_search','craft_assets_import','craft_game_check','craft_game_review','craft_game_deliver','craft_game_upload','craft_preview_stop','craft_task_cancel']);
|
|
107
|
-
const draftFields = { ...nameField, check_task_id:{ type:'string', description:'ID of the
|
|
109
|
+
const draftFields = { ...nameField, check_task_id:{ type:'string', description:'ID of the completed check that froze this source and dist. Reuse the same ID to recover an upload.' },
|
|
108
110
|
upload_mode:{type:'string',enum:['current_project','new_project'],description:'Defaults to current_project: append a version using local source/dist and make it current, without merging Web edits. Use new_project only when the user explicitly asks for a new cloud project; success switches the local binding.'},
|
|
109
111
|
request_key:{type:'string',pattern:'^[A-Za-z0-9_-]{1,80}$',description:'Required for new_project. Create a new key for an explicitly new upload operation; reuse the exact key, mode and check_task_id on retry or status queries.'} };
|
|
110
112
|
const tool = (name,description,properties={},required=[])=>({ name,description,inputSchema:{ type:'object',properties:{...properties,...(workTools.has(name)?workField:{})},required:[...required,...(workTools.has(name)?['work_id']:[])],additionalProperties:false },...(['craft_game_info','craft_update_check'].includes(name)?{annotations:{readOnlyHint:true,destructiveHint:false,idempotentHint:true}}:name==='craft_update'?{annotations:{readOnlyHint:false,destructiveHint:false}}:{}) });
|
|
@@ -118,7 +120,7 @@ const tools = [
|
|
|
118
120
|
tool('craft_assets_search','Search the Craft asset library without generating assets. Read craft_game_info.library for categories matching the saved engine. Submit 1 to 8 slot/category/query entries; inspect candidates, scores, metadata and per-slot errors. Poll craft_task_status, then import chosen source=library with search_id/candidate_id. No arbitrary URLs or external search credentials.',{...nameField,...searchFields},['name','queries']),
|
|
119
121
|
tool('craft_assets_import','Import existing AIGC outputs by resource_id, or selected library candidates with source=library, search_id and candidate_id. One source per batch. Never generates assets. Preserves the original AIGC URL or library Path and updates engine configs/controls without downloading payloads. Poll craft_task_status.',{...nameField,...importFields},['name','assets']),
|
|
120
122
|
tool('craft_assets_status','Read durable asset requests and import results for the current account and project.',nameField,['name']),
|
|
121
|
-
tool('craft_game_check','Finalize engine exports, build, exercise the core loop, settlement and restart
|
|
123
|
+
tool('craft_game_check','Finalize engine exports, freeze the source and build, and perform the mandatory upload security check. If it passes, exercise the core loop, settlement and restart and capture screenshots. Each step must assert real snapshot().game fields. Poll craft_task_status. If security fails, report the findings and stop the upload. Gameplay and visual findings affect verified preview delivery.',{
|
|
122
124
|
...nameField, brief:{ type:'string' }, steps:{ type:'array',minItems:3,maxItems:3,items:{ type:'object',properties:{
|
|
123
125
|
phase:{ type:'string',enum:['loop','settlement','restart'] },action:{ type:'string',enum:['click','press','drag','wait'] },
|
|
124
126
|
target:{ type:'string' },key:{ type:'string' },x:{ type:'number' },y:{ type:'number' },to_x:{ type:'number' },to_y:{ type:'number' },ms:{ type:'integer',minimum:1,maximum:30000 },expected:{ type:'string' },
|
|
@@ -127,11 +129,11 @@ const tools = [
|
|
|
127
129
|
},['name','brief','steps']),
|
|
128
130
|
tool('craft_task_status','Wait up to 15 seconds and read background progress. Continue polling while running; do not end the user task while assets/checks are running.',{ ...taskField,wait_ms:{ type:'integer',minimum:0,maximum:15000 } },['task_id']),
|
|
129
131
|
tool('craft_task_cancel','Stop this local task and wait for cleanup. For generation tasks also attempt remote queued-task cancellation; processing tasks may continue remotely. Import cancellation stops only the local import.',taskField,['task_id']),
|
|
130
|
-
tool('craft_game_review','Return
|
|
132
|
+
tool('craft_game_review','Return available check screenshots as images, including when the check reported issues. Inspect actual visuals and referenced resources, composition, clipping, readability and requested transparency.',taskField,['task_id']),
|
|
131
133
|
tool('craft_game_deliver','Prepare a verified preview after a current passing check and visual review. Craft does not launch the process. Run result.start.script with the external host terminal tool in the background, then poll craft_game_info(name).preview until running=true and snapshot matches this delivery. Verify the page before reporting its URL. The host or OS may reclaim it; restart using the returned command.',{
|
|
132
134
|
...taskField,visual_passed:{ type:'boolean' },visual_notes:{ type:'string',minLength:10,maxLength:2000 },
|
|
133
135
|
},['task_id','visual_passed','visual_notes']),
|
|
134
|
-
tool('craft_game_upload','Before uploading, tell the user that local source/dist will become the current cloud version and Web edits not synced locally are not included
|
|
136
|
+
tool('craft_game_upload','Upload a completed check with frozen source and dist. Upload rechecks both snapshots for security and blocks when the check fails. Report the findings and rerun the game check after fixing them. Gameplay, capture and visual findings are advisory for upload. Before uploading, tell the user that local source/dist will become the current cloud version and Web edits not synced locally are not included. History remains available for rollback. Default: append to the bound project (create on first upload). Only explicit user requests select new_project. Poll craft_task_status and use the same check_task_id, upload_mode and request_key for a retry. On success report version_number (vN), appid and project_url. Publication remains in Craft Web.',draftFields,['name','check_task_id']),
|
|
135
137
|
tool('craft_game_upload_status','Read the private upload receipt for this check, including the Craft Web project link when complete.',draftFields,['name','check_task_id']),
|
|
136
138
|
tool('craft_preview_stop','Stop this project host-launched preview and cancel pending starts, including an earlier session preview.',nameField,['name']),
|
|
137
139
|
tool('craft_auth_open','Check login first. Return a login URL only when unauthenticated; an authenticated account continues without a login URL. Image generation uses automatic platform billing. Never read credentials or automate login.'),
|
|
@@ -143,13 +145,9 @@ const server = new Server({ name:'craft-local',version },{ capabilities:{ tools:
|
|
|
143
145
|
let connectionReady=Promise.resolve();
|
|
144
146
|
server.oninitialized=()=>{
|
|
145
147
|
if(closing) return;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
try { await runtimeConnection?.collect(); }
|
|
150
|
-
catch { process.stderr.write('[craft] Runtime cleanup skipped; MCP remains active.\n'); }
|
|
151
|
-
}
|
|
152
|
-
})();
|
|
148
|
+
// Hosts also initialize short-lived discovery probes. They can close or kill
|
|
149
|
+
// the child immediately after tools/list, so readiness must never start GC.
|
|
150
|
+
connectionReady=updates.connected();
|
|
153
151
|
};
|
|
154
152
|
server.setRequestHandler(ListToolsRequestSchema,async()=>({ tools }));
|
|
155
153
|
function viewTask(task) {
|
|
@@ -162,9 +160,9 @@ function viewTask(task) {
|
|
|
162
160
|
const { artifacts,snapshot_id,source_snapshot,...result } = task.result;
|
|
163
161
|
return { ...task,result };
|
|
164
162
|
}
|
|
165
|
-
async function
|
|
163
|
+
async function completedCheck(id, name, resumeUpload = false) {
|
|
166
164
|
const task = await tasks.get(id);
|
|
167
|
-
if (task.kind !== 'check' || task.status !== 'completed' || !task.result
|
|
165
|
+
if (task.kind !== 'check' || task.status !== 'completed' || !task.result) throw new Error('A completed game check is required');
|
|
168
166
|
if (name !== undefined && task.name !== name) throw new Error('Game check belongs to a different project');
|
|
169
167
|
const work=currentWork();
|
|
170
168
|
if(!work || work.name!==task.name) throw new Error('A prepared work for this project is required');
|
|
@@ -264,7 +262,17 @@ server.setRequestHandler(CallToolRequestSchema,async request=>{
|
|
|
264
262
|
}
|
|
265
263
|
case 'craft_game_release': {
|
|
266
264
|
if(mutations.has(args.name) || tasks.busy(args.name)) throw new Error('Background work is running; wait or cancel and wait for cleanup before release');
|
|
267
|
-
result=await leases.release(args.name,args.work_id);
|
|
265
|
+
result=await leases.release(args.name,args.work_id);
|
|
266
|
+
// Maintenance belongs to an awaited end-of-work operation, never a
|
|
267
|
+
// handshake, read-only query, shutdown callback or detached timer.
|
|
268
|
+
if(runtimeConnection && runtimeBusy().can_reconnect) {
|
|
269
|
+
const maintenance=runtimeConnection.collect();
|
|
270
|
+
runtimeMaintenance=maintenance;
|
|
271
|
+
try { await maintenance; }
|
|
272
|
+
catch { process.stderr.write('[craft] Runtime cleanup skipped; released work remains complete.\n'); }
|
|
273
|
+
finally { if(runtimeMaintenance===maintenance) runtimeMaintenance=undefined; }
|
|
274
|
+
}
|
|
275
|
+
break;
|
|
268
276
|
}
|
|
269
277
|
case 'craft_assets_generate': {
|
|
270
278
|
const inputs=generationInputs(args);
|
|
@@ -318,8 +326,10 @@ server.setRequestHandler(CallToolRequestSchema,async request=>{
|
|
|
318
326
|
break;
|
|
319
327
|
}
|
|
320
328
|
case 'craft_game_review': {
|
|
321
|
-
const { task } = await
|
|
322
|
-
const
|
|
329
|
+
const { task } = await completedCheck(args.task_id);
|
|
330
|
+
const review = task.result.screenshots.length ? 'Inspect every available screenshot. Report visual_passed and concrete findings; a browser pass alone is not visual acceptance.' :
|
|
331
|
+
'No screenshots were captured. Report the capture issues from craft_task_status.';
|
|
332
|
+
const content = [{ type:'text',text:JSON.stringify({ task_id:args.task_id, review }) }];
|
|
323
333
|
for (const file of task.result.screenshots) {
|
|
324
334
|
const data = await readFile(file); if (data.length > 4 * 1024 * 1024) throw new Error('Screenshot too large');
|
|
325
335
|
content.push({ type:'image',mimeType:'image/jpeg',data:data.toString('base64') });
|
|
@@ -327,7 +337,8 @@ server.setRequestHandler(CallToolRequestSchema,async request=>{
|
|
|
327
337
|
reviewed.add(args.task_id); return { content };
|
|
328
338
|
}
|
|
329
339
|
case 'craft_game_deliver': {
|
|
330
|
-
const { task,project } = await
|
|
340
|
+
const { task,project } = await completedCheck(args.task_id);
|
|
341
|
+
if (!task.result.gate?.passed) throw new Error('A passing game check is required for a verified preview');
|
|
331
342
|
if (!reviewed.has(args.task_id) || args.visual_passed !== true || args.visual_notes.trim().length < 10 || args.visual_notes.length > 2000) throw new Error('Read and review the screenshots before delivery');
|
|
332
343
|
result = { ...await previews.prepare(project,task.result.artifacts), project, name:task.name, check_task_id:args.task_id, visual_notes:args.visual_notes }; break;
|
|
333
344
|
}
|
|
@@ -336,7 +347,7 @@ server.setRequestHandler(CallToolRequestSchema,async request=>{
|
|
|
336
347
|
if (!status.authenticated) { result = loginAction(); break; }
|
|
337
348
|
// An already authorized upload resumes its frozen check, even after later source edits.
|
|
338
349
|
const resume = await drafts.hasRequest(args.name,args.check_task_id,status.user_id,args);
|
|
339
|
-
const { task } = await
|
|
350
|
+
const { task } = await completedCheck(args.check_task_id,args.name,resume);
|
|
340
351
|
result = viewTask(await tasks.start(args.name,'upload',signal=>drafts.upload(task,status.user_id,signal,args),
|
|
341
352
|
{ owner:status.user_id, platform:platform.base, check_task_id:args.check_task_id,upload_mode:args.upload_mode ?? 'current_project',request_key:args.request_key }));
|
|
342
353
|
break;
|
|
@@ -379,6 +390,7 @@ function shutdown() {
|
|
|
379
390
|
shutdownPromise=(async()=>{
|
|
380
391
|
await updates.close();
|
|
381
392
|
await connectionReady.catch(()=>{});
|
|
393
|
+
await runtimeMaintenance?.catch(()=>{});
|
|
382
394
|
await tasks.close(); await leases.close(); await panel.close(); await server.close();
|
|
383
395
|
try { await runtimeConnection?.close(); }
|
|
384
396
|
catch { process.stderr.write('[craft] Runtime cleanup skipped during shutdown.\n'); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@craft_eco/craft-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.12.0"
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
"start": "node bin/craft-mcp.mjs"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@babel/parser": "7.28.5",
|
|
15
16
|
"jsonc-parser": "3.3.1",
|
|
16
17
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
18
|
+
"parse5": "7.3.0",
|
|
17
19
|
"playwright": "1.63.0",
|
|
18
20
|
"proper-lockfile": "4.1.2",
|
|
19
21
|
"smol-toml": "1.9.1",
|
|
@@ -6,6 +6,8 @@ description: 使用 Craft 新建 2D、3D 游戏或玩法原型。Create a new ga
|
|
|
6
6
|
<!-- craft-mcp:bootstrap:v1 -->
|
|
7
7
|
# 创建 Craft 游戏
|
|
8
8
|
|
|
9
|
+
先使用当前聊天实际可用的 Craft 工具。工具未暴露时,通过宿主提供的工具发现机制定位 Craft 及准确工具名;仍在连接中则等待就绪后重试一次。仍不可用或调用失败时,报告原始错误,区分连接超时、工具未暴露和工具执行失败,停止新的准备并诊断连接;不能仅据工具缺失判断未安装或升级失败。保持用户选择的 Craft 流程,不擅自改用造化或其他游戏插件,也不混用它们的创建指南。
|
|
10
|
+
|
|
9
11
|
调用当前宿主的 `craft_game_info`,核对 host、workspace、platform 和实际 runtime,读取返回的创建 instructions。选项为 **2D / Phaser**(js)、**3D / Three.js**(js3d);已有项目按根 AGENTS.md 和 craft-project 恢复。
|
|
10
12
|
|
|
11
13
|
新会话首次处理 Craft 创建请求时,自动调用只读 `craft_update_check(request_key)`。若 update_available=true 且 automatic_update_enabled=true,调用 `craft_update(mode:"auto",request_key)` 安装兼容新版;两个工具与 prepare 复用同一 request_key。有既有工作时先完成并 release,再开始新的准备。pending_reconnect 表示新版已安装、本次准备未开始,等待下次启动或用户重连;查询不写安装记录或项目。prepare 仍会兜底检查与更新。
|
|
@@ -6,6 +6,8 @@ description: 检查或更新 Craft MCP,核对当前连接的运行版本,恢
|
|
|
6
6
|
<!-- craft-mcp:update:v1 -->
|
|
7
7
|
# 更新 Craft
|
|
8
8
|
|
|
9
|
+
先确认当前聊天能发现并调用 Craft 工具。工具未暴露时,使用宿主实际提供的工具发现机制定位准确工具名;仍在连接中则等待就绪后重试一次。仍不可用或调用失败时,保留更新目标和当前工作,报告原始错误并诊断连接,停止新的准备;不能仅据工具缺失判断未安装或升级失败。用户选择的 Craft 流程不能自行改用造化或其他游戏插件替代。
|
|
10
|
+
|
|
9
11
|
新会话首次处理 Craft 制作或恢复请求时自动检查,不需要用户另说“检查更新”。只在首次相关请求或新一轮准备检查,同一工作内不逐条消息查 npm;纯查看只检查。检查返回 update_available=true 且 automatic_update_enabled=true 时自动安装,检查与安装复用本次 request_key。自动模式尊重 off 策略;只有用户明确要求升级时才使用 mode:"manual"。
|
|
10
12
|
|
|
11
13
|
读取当前连接的 `craft_game_info`,区分实际运行版本、安装目标和项目上下文版本,沿用已配置的 npm 渠道、平台和 workspace。
|
|
@@ -28,11 +28,11 @@ prepare 会维护项目根 `AGENTS.md` 的 Craft 段,并为已选择的宿主
|
|
|
28
28
|
1. **先读引擎说明,再制作游戏。** 新建时仅展示 2D / Phaser(js)和 3D / Three.js(js3d)。沿用用户明确选择;尚未明确时按玩法推荐并收集选择,用户授权代选时直接决定并说明。选定后调用 `craft_game_info(engine)`;继续游戏用 `craft_game_info(name)` 获取已保存的引擎,不重新选择。开始设计、编码或修改前完整读取 `context.engine.entrypoint`,其余参考文档按需加载。
|
|
29
29
|
2. 调用 `craft_game_prepare`:新建传 `mode:"create"`、engine 和新的 request_key;继续已有工程传 `mode:"resume"`,沿用 name 和引擎。重试复用同一 request_key,已结束或中断的制作使用新的 key。轮询成功后保存 work_id 和 context_revision,再读取本地上下文并使用宿主文件工具编辑工程。素材、验收、预览、取消及上传工具均传入此 work_id。期间不重新同步上下文;同一 work_id 的 prepare 只验证并复用当前结果。遇到 CRAFT_PROJECT_IN_USE 时可只读查询,须等原任务释放后再制作,不绕过占用锁写文件。保留模板依赖、runtime、Vite、预览接线和配置结构。
|
|
30
30
|
3. 按需求实现场景、玩法和真实输入交互;需要领域操作时,按当前技能索引的 description 选择并读取适用技能。资源地址及可调参数放入项目配置,由实际消费者读取并按引擎规则加载。配置有值不代表资源已被使用,必要资源就绪后再进入玩法。
|
|
31
|
-
4. 调用 `craft_game_check`
|
|
32
|
-
5.
|
|
31
|
+
4. 调用 `craft_game_check` 执行引擎收尾和构建,再检查冻结的源码和 dist。安全检查结果见 `security`,未通过时跳过浏览器采集。依次提供 `loop`、`settlement`、`restart` 三步,每步包含 action、expected 和真实玩法断言。
|
|
32
|
+
5. 调用 `craft_game_review` 查看已采集的截图,检查初始、主循环、结算、重开画面的素材、构图、比例、文字、遮挡、透明边缘和玩法反馈。报告检查发现的问题及因浏览器或截图不可用而未验证的画面。本地预览交付前修复并重验。
|
|
33
33
|
6. 玩法和视觉均通过后,调用 `craft_game_deliver(task_id,visual_passed:true,visual_notes,work_id)`,填写实际观察。返回 awaiting_host_start 时,由 AI IDE 使用后台终端执行 `start.script` 并保持该任务运行;这是持续服务命令,不等待终端退出才查询状态。Craft 不启动预览。轮询 `craft_game_info(name).preview`,直到 running=true 且 snapshot 与此次交付一致,打开返回 URL 确认画布能启动后才交付链接;直接打开源码 index.html 不能替代预览。预览可能被宿主或系统回收;失效时查看 start.logs,重跑启动命令并验证,用 `craft_preview_stop(name,work_id)` 停止。源码或构建产物变化后重新检查、交付。
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
用户要求上传或发布时,使用 `craft_game_check` 冻结的源码和 dist。`craft_game_upload` 在发送文件前复查同一快照。安全检查失败或收到 `UPLOAD_SECURITY_BLOCKED` 时,向用户报告文件和原因并停止上传,修复后重新检查。安全检查通过后,向用户报告玩法和截图审阅问题,并继续上传。上传前明确告知用户:“本次上传会以本地源码和 dist 新增云端版本,并将它设为当前版本;不会合并或保留 Web 侧尚未同步到本地的修改。原有历史版本仍保留,可在 Web 回退。”默认调用 `craft_game_upload(name,check_task_id,work_id,upload_mode:"current_project")`,同一工程、账号和平台沿用绑定的 appid,首次未绑定时创建项目。
|
|
36
36
|
|
|
37
37
|
仅当用户明确要求“新建项目”或“上传为新项目”时,传 `upload_mode:"new_project"`,并为这次操作生成唯一 `request_key`。这会创建新 appid,成功后自动切换本地绑定;后续默认上传进入新项目,原项目及其历史保留。新建云端项目不需要重建本地工程。
|
|
38
38
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schema": 2,
|
|
3
3
|
"engine": "js",
|
|
4
4
|
"host": "claude",
|
|
5
|
-
"version": "1.0.
|
|
6
|
-
"source_revision": "sha256:
|
|
5
|
+
"version": "1.0.8",
|
|
6
|
+
"source_revision": "sha256:8043d6330fc64ba6ebd167529d944a9a3614455d2e26973d1f56982d03c0171b",
|
|
7
7
|
"contracts": {
|
|
8
8
|
"export": 1,
|
|
9
9
|
"skills": 1,
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"js/project/tsconfig.json": "ff460bbe00552390594da800297aa4d1bcd0c21e07ebe2794d7fc94cf5debd58",
|
|
88
88
|
"js/project/unified_data_control_config.json": "713e928403c10e069dc2d43b74da0a5ca4323f616ee84917d7df8f2e9bc48b21",
|
|
89
89
|
"js/project/vite.config.ts": "3446dbee391e5c15aa3fa1770cadf16c4214d11715881784ed879c2f317d9f8f",
|
|
90
|
-
"craft-game-maker/SKILL.md": "
|
|
90
|
+
"craft-game-maker/SKILL.md": "95501a50676022145388aa8de4c35086efa8d114cf63f5b5c686f00375bfc540",
|
|
91
91
|
"craft-game-maker/js.md": "d69b3635771045ab232fffe001652348046e54484e21ba4babcdb65cf9395f69",
|
|
92
|
-
"target.json": "
|
|
92
|
+
"target.json": "28eb077833fec15968140f275b04651ba2d417bd809485b6408bf1fd49fe50b3",
|
|
93
93
|
"bootstrap/SKILL.md": "d822f390c7ea13838edd3e88a3f47fef7608aecff48488fdc4d7efccbe43af70",
|
|
94
94
|
"recovery.md": "99975cf7a14aa7f517a0d100d175cb28954ff933d71e0df678fe66fbefaa921b"
|
|
95
95
|
},
|
|
96
|
-
"id": "
|
|
96
|
+
"id": "f1027d04afba72301f4312e38df1cfc05e429409a41dd2640fbbfcc281797584"
|
|
97
97
|
}
|
|
@@ -28,11 +28,11 @@ prepare 会维护项目根 `AGENTS.md` 的 Craft 段,并为已选择的宿主
|
|
|
28
28
|
1. **先读引擎说明,再制作游戏。** 新建时仅展示 2D / Phaser(js)和 3D / Three.js(js3d)。沿用用户明确选择;尚未明确时按玩法推荐并收集选择,用户授权代选时直接决定并说明。选定后调用 `craft_game_info(engine)`;继续游戏用 `craft_game_info(name)` 获取已保存的引擎,不重新选择。开始设计、编码或修改前完整读取 `context.engine.entrypoint`,其余参考文档按需加载。
|
|
29
29
|
2. 调用 `craft_game_prepare`:新建传 `mode:"create"`、engine 和新的 request_key;继续已有工程传 `mode:"resume"`,沿用 name 和引擎。重试复用同一 request_key,已结束或中断的制作使用新的 key。轮询成功后保存 work_id 和 context_revision,再读取本地上下文并使用宿主文件工具编辑工程。素材、验收、预览、取消及上传工具均传入此 work_id。期间不重新同步上下文;同一 work_id 的 prepare 只验证并复用当前结果。遇到 CRAFT_PROJECT_IN_USE 时可只读查询,须等原任务释放后再制作,不绕过占用锁写文件。保留模板依赖、runtime、Vite、预览接线和配置结构。
|
|
30
30
|
3. 按需求实现场景、玩法和真实输入交互;需要领域操作时,按当前技能索引的 description 选择并读取适用技能。资源地址及可调参数放入项目配置,由实际消费者读取并按引擎规则加载。配置有值不代表资源已被使用,必要资源就绪后再进入玩法。
|
|
31
|
-
4. 调用 `craft_game_check`
|
|
32
|
-
5.
|
|
31
|
+
4. 调用 `craft_game_check` 执行引擎收尾和构建,再检查冻结的源码和 dist。安全检查结果见 `security`,未通过时跳过浏览器采集。依次提供 `loop`、`settlement`、`restart` 三步,每步包含 action、expected 和真实玩法断言。
|
|
32
|
+
5. 调用 `craft_game_review` 查看已采集的截图,检查初始、主循环、结算、重开画面的素材、构图、比例、文字、遮挡、透明边缘和玩法反馈。报告检查发现的问题及因浏览器或截图不可用而未验证的画面。本地预览交付前修复并重验。
|
|
33
33
|
6. 玩法和视觉均通过后,调用 `craft_game_deliver(task_id,visual_passed:true,visual_notes,work_id)`,填写实际观察。返回 awaiting_host_start 时,由 AI IDE 使用后台终端执行 `start.script` 并保持该任务运行;这是持续服务命令,不等待终端退出才查询状态。Craft 不启动预览。轮询 `craft_game_info(name).preview`,直到 running=true 且 snapshot 与此次交付一致,打开返回 URL 确认画布能启动后才交付链接;直接打开源码 index.html 不能替代预览。预览可能被宿主或系统回收;失效时查看 start.logs,重跑启动命令并验证,用 `craft_preview_stop(name,work_id)` 停止。源码或构建产物变化后重新检查、交付。
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
用户要求上传或发布时,使用 `craft_game_check` 冻结的源码和 dist。`craft_game_upload` 在发送文件前复查同一快照。安全检查失败或收到 `UPLOAD_SECURITY_BLOCKED` 时,向用户报告文件和原因并停止上传,修复后重新检查。安全检查通过后,向用户报告玩法和截图审阅问题,并继续上传。上传前明确告知用户:“本次上传会以本地源码和 dist 新增云端版本,并将它设为当前版本;不会合并或保留 Web 侧尚未同步到本地的修改。原有历史版本仍保留,可在 Web 回退。”默认调用 `craft_game_upload(name,check_task_id,work_id,upload_mode:"current_project")`,同一工程、账号和平台沿用绑定的 appid,首次未绑定时创建项目。
|
|
36
36
|
|
|
37
37
|
仅当用户明确要求“新建项目”或“上传为新项目”时,传 `upload_mode:"new_project"`,并为这次操作生成唯一 `request_key`。这会创建新 appid,成功后自动切换本地绑定;后续默认上传进入新项目,原项目及其历史保留。新建云端项目不需要重建本地工程。
|
|
38
38
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schema": 2,
|
|
3
3
|
"engine": "js3d",
|
|
4
4
|
"host": "claude",
|
|
5
|
-
"version": "1.0.
|
|
6
|
-
"source_revision": "sha256:
|
|
5
|
+
"version": "1.0.9",
|
|
6
|
+
"source_revision": "sha256:0fa038efff45cea6cc4dd6c6618eaca7804712f60cacd11b3edcbf108633db47",
|
|
7
7
|
"contracts": {
|
|
8
8
|
"export": 1,
|
|
9
9
|
"skills": 1,
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
"js3d/project/tsconfig.json": "ff460bbe00552390594da800297aa4d1bcd0c21e07ebe2794d7fc94cf5debd58",
|
|
99
99
|
"js3d/project/unified_data_control_config.json": "713e928403c10e069dc2d43b74da0a5ca4323f616ee84917d7df8f2e9bc48b21",
|
|
100
100
|
"js3d/project/vite.config.ts": "3446dbee391e5c15aa3fa1770cadf16c4214d11715881784ed879c2f317d9f8f",
|
|
101
|
-
"craft-game-maker/SKILL.md": "
|
|
101
|
+
"craft-game-maker/SKILL.md": "95501a50676022145388aa8de4c35086efa8d114cf63f5b5c686f00375bfc540",
|
|
102
102
|
"craft-game-maker/js3d.md": "30463613fbfb1bcdd0999debc1b1584b111b621fd4d26bf4ce72a51678616c34",
|
|
103
|
-
"target.json": "
|
|
103
|
+
"target.json": "7cb0f3ab25acc3a5bb1fb3f4fe9b76bb49079e3791fa67b4a26856d9c8e22fb0",
|
|
104
104
|
"bootstrap/SKILL.md": "d822f390c7ea13838edd3e88a3f47fef7608aecff48488fdc4d7efccbe43af70",
|
|
105
105
|
"recovery.md": "30038c0fa12bf245eb08cae424852d9c1d12839dde20926f7e667f8815011b87"
|
|
106
106
|
},
|
|
107
|
-
"id": "
|
|
107
|
+
"id": "cc9477c931f607574edd4225eac5ccf351f2a95dd97ef4c393c835508eef3881"
|
|
108
108
|
}
|
|
@@ -28,11 +28,11 @@ prepare 会维护项目根 `AGENTS.md` 的 Craft 段,并为已选择的宿主
|
|
|
28
28
|
1. **先读引擎说明,再制作游戏。** 新建时仅展示 2D / Phaser(js)和 3D / Three.js(js3d)。沿用用户明确选择;尚未明确时按玩法推荐并收集选择,用户授权代选时直接决定并说明。选定后调用 `craft_game_info(engine)`;继续游戏用 `craft_game_info(name)` 获取已保存的引擎,不重新选择。开始设计、编码或修改前完整读取 `context.engine.entrypoint`,其余参考文档按需加载。
|
|
29
29
|
2. 调用 `craft_game_prepare`:新建传 `mode:"create"`、engine 和新的 request_key;继续已有工程传 `mode:"resume"`,沿用 name 和引擎。重试复用同一 request_key,已结束或中断的制作使用新的 key。轮询成功后保存 work_id 和 context_revision,再读取本地上下文并使用宿主文件工具编辑工程。素材、验收、预览、取消及上传工具均传入此 work_id。期间不重新同步上下文;同一 work_id 的 prepare 只验证并复用当前结果。遇到 CRAFT_PROJECT_IN_USE 时可只读查询,须等原任务释放后再制作,不绕过占用锁写文件。保留模板依赖、runtime、Vite、预览接线和配置结构。
|
|
30
30
|
3. 按需求实现场景、玩法和真实输入交互;需要领域操作时,按当前技能索引的 description 选择并读取适用技能。资源地址及可调参数放入项目配置,由实际消费者读取并按引擎规则加载。配置有值不代表资源已被使用,必要资源就绪后再进入玩法。
|
|
31
|
-
4. 调用 `craft_game_check`
|
|
32
|
-
5.
|
|
31
|
+
4. 调用 `craft_game_check` 执行引擎收尾和构建,再检查冻结的源码和 dist。安全检查结果见 `security`,未通过时跳过浏览器采集。依次提供 `loop`、`settlement`、`restart` 三步,每步包含 action、expected 和真实玩法断言。
|
|
32
|
+
5. 调用 `craft_game_review` 查看已采集的截图,检查初始、主循环、结算、重开画面的素材、构图、比例、文字、遮挡、透明边缘和玩法反馈。报告检查发现的问题及因浏览器或截图不可用而未验证的画面。本地预览交付前修复并重验。
|
|
33
33
|
6. 玩法和视觉均通过后,调用 `craft_game_deliver(task_id,visual_passed:true,visual_notes,work_id)`,填写实际观察。返回 awaiting_host_start 时,由 AI IDE 使用后台终端执行 `start.script` 并保持该任务运行;这是持续服务命令,不等待终端退出才查询状态。Craft 不启动预览。轮询 `craft_game_info(name).preview`,直到 running=true 且 snapshot 与此次交付一致,打开返回 URL 确认画布能启动后才交付链接;直接打开源码 index.html 不能替代预览。预览可能被宿主或系统回收;失效时查看 start.logs,重跑启动命令并验证,用 `craft_preview_stop(name,work_id)` 停止。源码或构建产物变化后重新检查、交付。
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
用户要求上传或发布时,使用 `craft_game_check` 冻结的源码和 dist。`craft_game_upload` 在发送文件前复查同一快照。安全检查失败或收到 `UPLOAD_SECURITY_BLOCKED` 时,向用户报告文件和原因并停止上传,修复后重新检查。安全检查通过后,向用户报告玩法和截图审阅问题,并继续上传。上传前明确告知用户:“本次上传会以本地源码和 dist 新增云端版本,并将它设为当前版本;不会合并或保留 Web 侧尚未同步到本地的修改。原有历史版本仍保留,可在 Web 回退。”默认调用 `craft_game_upload(name,check_task_id,work_id,upload_mode:"current_project")`,同一工程、账号和平台沿用绑定的 appid,首次未绑定时创建项目。
|
|
36
36
|
|
|
37
37
|
仅当用户明确要求“新建项目”或“上传为新项目”时,传 `upload_mode:"new_project"`,并为这次操作生成唯一 `request_key`。这会创建新 appid,成功后自动切换本地绑定;后续默认上传进入新项目,原项目及其历史保留。新建云端项目不需要重建本地工程。
|
|
38
38
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schema": 2,
|
|
3
3
|
"engine": "js",
|
|
4
4
|
"host": "codebuddy",
|
|
5
|
-
"version": "1.4.
|
|
6
|
-
"source_revision": "sha256:
|
|
5
|
+
"version": "1.4.9",
|
|
6
|
+
"source_revision": "sha256:60dfa27bcb1ec53d14345c029caf508ebf6be87f996583a1f8650709da408649",
|
|
7
7
|
"contracts": {
|
|
8
8
|
"export": 1,
|
|
9
9
|
"skills": 1,
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"js/project/tsconfig.json": "ff460bbe00552390594da800297aa4d1bcd0c21e07ebe2794d7fc94cf5debd58",
|
|
88
88
|
"js/project/unified_data_control_config.json": "713e928403c10e069dc2d43b74da0a5ca4323f616ee84917d7df8f2e9bc48b21",
|
|
89
89
|
"js/project/vite.config.ts": "3446dbee391e5c15aa3fa1770cadf16c4214d11715881784ed879c2f317d9f8f",
|
|
90
|
-
"craft-game-maker/SKILL.md": "
|
|
90
|
+
"craft-game-maker/SKILL.md": "95501a50676022145388aa8de4c35086efa8d114cf63f5b5c686f00375bfc540",
|
|
91
91
|
"craft-game-maker/js.md": "d69b3635771045ab232fffe001652348046e54484e21ba4babcdb65cf9395f69",
|
|
92
|
-
"target.json": "
|
|
92
|
+
"target.json": "0865d328f4a63d77aa1c888c0c7d013985e42895b62d2e5e5f5630ac71d7858d",
|
|
93
93
|
"bootstrap/SKILL.md": "f0ad8b7bf7cc5eb54f63d802e234e5a92c35fe16cdc43535a00a78f0eee826a6",
|
|
94
94
|
"recovery.md": "1737cb049ead035c4080cd89c0125ce0132039661a2975bebed03cf76a05b71e"
|
|
95
95
|
},
|
|
96
|
-
"id": "
|
|
96
|
+
"id": "0fac41850231725688828d2dba19dbf493b68a408d43627cc75daafd8d68b959"
|
|
97
97
|
}
|