@playcraft/cli 0.0.29 → 0.0.31
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/dist/commands/prefab.js
CHANGED
|
@@ -294,12 +294,53 @@ function writeMetaDataDefaults(projectDir, extensionName, values) {
|
|
|
294
294
|
}
|
|
295
295
|
writeFileSync(metaPath, JSON.stringify(metaData, null, 2), 'utf-8');
|
|
296
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Get the main scene ID from manifest.json.
|
|
299
|
+
*
|
|
300
|
+
* Priority:
|
|
301
|
+
* 1. Scene with isMain: true
|
|
302
|
+
* 2. If only one scene exists, use that scene
|
|
303
|
+
* 3. If multiple scenes without isMain, return null (caller should fallback)
|
|
304
|
+
*/
|
|
305
|
+
function getMainSceneId(projectDir) {
|
|
306
|
+
if (!fileExists(projectDir, MANIFEST_PATH))
|
|
307
|
+
return null;
|
|
308
|
+
try {
|
|
309
|
+
const manifestJson = JSON.parse(readLocalFile(projectDir, MANIFEST_PATH));
|
|
310
|
+
const scenes = manifestJson?.scenes;
|
|
311
|
+
if (!Array.isArray(scenes) || scenes.length === 0)
|
|
312
|
+
return null;
|
|
313
|
+
// Priority 1: Find scene with isMain: true
|
|
314
|
+
const mainScene = scenes.find((s) => s.isMain === true);
|
|
315
|
+
if (mainScene?.id)
|
|
316
|
+
return String(mainScene.id);
|
|
317
|
+
// Priority 2: If only one scene, use it
|
|
318
|
+
if (scenes.length === 1 && scenes[0]?.id) {
|
|
319
|
+
return String(scenes[0].id);
|
|
320
|
+
}
|
|
321
|
+
// Multiple scenes without isMain → cannot determine
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Resolve the GameConfig file path for a given variant (scene).
|
|
330
|
+
*
|
|
331
|
+
* If variantId is not provided, automatically detect the current scene:
|
|
332
|
+
* 1. Scene with isMain: true in manifest.json
|
|
333
|
+
* 2. If only one scene exists, use that scene
|
|
334
|
+
* 3. If multiple scenes without isMain, return null (fallback to MetaData.json)
|
|
335
|
+
*/
|
|
297
336
|
function resolveGameConfigPathForVariant(projectDir, variantId) {
|
|
298
|
-
if
|
|
337
|
+
// Auto-detect scene if not specified
|
|
338
|
+
const sceneId = variantId ?? getMainSceneId(projectDir);
|
|
339
|
+
if (!sceneId)
|
|
299
340
|
return null;
|
|
300
|
-
if (!fileExists(projectDir, scenePath(
|
|
341
|
+
if (!fileExists(projectDir, scenePath(sceneId)))
|
|
301
342
|
return null;
|
|
302
|
-
const sceneJson = JSON.parse(readLocalFile(projectDir, scenePath(
|
|
343
|
+
const sceneJson = JSON.parse(readLocalFile(projectDir, scenePath(sceneId)));
|
|
303
344
|
if (!fileExists(projectDir, ASSETS_JSON_PATH))
|
|
304
345
|
return null;
|
|
305
346
|
const assetsJson = JSON.parse(readLocalFile(projectDir, ASSETS_JSON_PATH));
|
|
@@ -479,8 +520,17 @@ export function registerPrefabCommands(program) {
|
|
|
479
520
|
return;
|
|
480
521
|
}
|
|
481
522
|
for (const s of scenes) {
|
|
523
|
+
const mark = s.isActive ? ' *' : '';
|
|
482
524
|
const gc = s.gameConfigPath ? ` [${s.gameConfigPath}]` : '';
|
|
483
|
-
console.log(` ${s.name} (${s.id})${gc}`);
|
|
525
|
+
console.log(` ${s.name} (${s.id})${mark}${gc}`);
|
|
526
|
+
}
|
|
527
|
+
if (scenes.some((s) => s.isActive)) {
|
|
528
|
+
console.log('');
|
|
529
|
+
console.log('标 * 为 manifest 中的主场景(isMain)。其他场景请用 --variant <sceneId> 指定上下文。');
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
console.log('');
|
|
533
|
+
console.log('(manifest 未标记主场景;操作其他场景请用 --variant <sceneId>)');
|
|
484
534
|
}
|
|
485
535
|
});
|
|
486
536
|
}
|
|
@@ -62,12 +62,24 @@ export class AgentApiClient {
|
|
|
62
62
|
return res.json();
|
|
63
63
|
}
|
|
64
64
|
static loadConfig() {
|
|
65
|
+
// 兜底覆盖三类常见沙箱运行用户:
|
|
66
|
+
// - AGS 镜像(ccr.ccs.tencentyun.com/ags-image/sandbox-code)默认运行用户为 `user`,HOME=/home/user
|
|
67
|
+
// - 自建 docker/Dockerfile 沙箱 runtime stage 用户为 `opencode`,HOME=/home/opencode
|
|
68
|
+
// - 以 root 启动 CLI 的旁路场景,HOME=/root
|
|
69
|
+
// 第一条 cwd 与第二条 /project 是与运行用户无关的硬编码命中点。
|
|
65
70
|
const searchPaths = [
|
|
66
71
|
join(process.cwd(), '.playcraft.json'),
|
|
67
72
|
'/project/.playcraft.json',
|
|
73
|
+
'/home/user/.playcraft.json',
|
|
74
|
+
'/home/opencode/.playcraft.json',
|
|
75
|
+
'/root/.playcraft.json',
|
|
68
76
|
join(homedir(), '.playcraft.json'),
|
|
69
77
|
];
|
|
78
|
+
const seen = new Set();
|
|
70
79
|
for (const p of searchPaths) {
|
|
80
|
+
if (seen.has(p))
|
|
81
|
+
continue;
|
|
82
|
+
seen.add(p);
|
|
71
83
|
if (existsSync(p)) {
|
|
72
84
|
try {
|
|
73
85
|
return JSON.parse(readFileSync(p, 'utf-8'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcraft/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"release": "node scripts/release.js"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@playcraft/build": "^0.0.
|
|
27
|
-
"@playcraft/common": "^0.0.
|
|
26
|
+
"@playcraft/build": "^0.0.32",
|
|
27
|
+
"@playcraft/common": "^0.0.20",
|
|
28
28
|
"chokidar": "^4.0.3",
|
|
29
29
|
"commander": "^13.1.0",
|
|
30
30
|
"cors": "^2.8.6",
|