godot-cli 0.38.0 → 0.39.0
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/CHANGELOG.md +99 -0
- package/README.md +139 -16
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/check.d.ts +2 -0
- package/dist/commands/check.js +48 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/close.d.ts +3 -0
- package/dist/commands/close.js +82 -27
- package/dist/commands/close.js.map +1 -1
- package/dist/commands/commands.d.ts +3 -0
- package/dist/commands/commands.js +28 -0
- package/dist/commands/commands.js.map +1 -0
- package/dist/commands/exec.js +43 -28
- package/dist/commands/exec.js.map +1 -1
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/export.js +45 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/headless-common.d.ts +29 -0
- package/dist/commands/headless-common.js +69 -0
- package/dist/commands/headless-common.js.map +1 -0
- package/dist/commands/import.d.ts +2 -0
- package/dist/commands/import.js +32 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/open.js +38 -6
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/rql.d.ts +2 -0
- package/dist/commands/rql.js +81 -0
- package/dist/commands/rql.js.map +1 -0
- package/dist/commands/run-script.d.ts +2 -0
- package/dist/commands/run-script.js +33 -0
- package/dist/commands/run-script.js.map +1 -0
- package/dist/commands/run-system-tool.js +0 -1
- package/dist/commands/run-system-tool.js.map +1 -1
- package/dist/commands/run-tool-builder.d.ts +38 -4
- package/dist/commands/run-tool-builder.js +179 -56
- package/dist/commands/run-tool-builder.js.map +1 -1
- package/dist/commands/run-tool.js +0 -1
- package/dist/commands/run-tool.js.map +1 -1
- package/dist/commands/setup-skills.js +3 -2
- package/dist/commands/setup-skills.js.map +1 -1
- package/dist/commands/status.js +25 -19
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/test.d.ts +5 -0
- package/dist/commands/test.js +111 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/tools.d.ts +2 -0
- package/dist/commands/tools.js +120 -0
- package/dist/commands/tools.js.map +1 -0
- package/dist/commands/update.js +1 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/wait-for-ready.js +18 -20
- package/dist/commands/wait-for-ready.js.map +1 -1
- package/dist/index.js +48 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/build.d.ts +1 -1
- package/dist/lib/build.js +21 -4
- package/dist/lib/build.js.map +1 -1
- package/dist/lib/check.d.ts +44 -0
- package/dist/lib/check.js +191 -0
- package/dist/lib/check.js.map +1 -0
- package/dist/lib/cli-guide.d.ts +26 -0
- package/dist/lib/cli-guide.js +51 -0
- package/dist/lib/cli-guide.js.map +1 -0
- package/dist/lib/exec.d.ts +19 -0
- package/dist/lib/exec.js +61 -10
- package/dist/lib/exec.js.map +1 -1
- package/dist/lib/export-project.d.ts +41 -0
- package/dist/lib/export-project.js +159 -0
- package/dist/lib/export-project.js.map +1 -0
- package/dist/lib/godot-log.d.ts +38 -0
- package/dist/lib/godot-log.js +145 -0
- package/dist/lib/godot-log.js.map +1 -0
- package/dist/lib/godot-run.d.ts +34 -0
- package/dist/lib/godot-run.js +113 -0
- package/dist/lib/godot-run.js.map +1 -0
- package/dist/lib/headless.d.ts +82 -0
- package/dist/lib/headless.js +117 -0
- package/dist/lib/headless.js.map +1 -0
- package/dist/lib/import-project.d.ts +9 -0
- package/dist/lib/import-project.js +15 -0
- package/dist/lib/import-project.js.map +1 -0
- package/dist/lib/junit.d.ts +36 -0
- package/dist/lib/junit.js +146 -0
- package/dist/lib/junit.js.map +1 -0
- package/dist/lib/list-tools.d.ts +51 -0
- package/dist/lib/list-tools.js +147 -0
- package/dist/lib/list-tools.js.map +1 -0
- package/dist/lib/open.js +3 -1
- package/dist/lib/open.js.map +1 -1
- package/dist/lib/progress.d.ts +1 -7
- package/dist/lib/progress.js +2 -15
- package/dist/lib/progress.js.map +1 -1
- package/dist/lib/rql.d.ts +32 -0
- package/dist/lib/rql.js +105 -0
- package/dist/lib/rql.js.map +1 -0
- package/dist/lib/run-script.d.ts +23 -0
- package/dist/lib/run-script.js +43 -0
- package/dist/lib/run-script.js.map +1 -0
- package/dist/lib/run-tests.d.ts +50 -0
- package/dist/lib/run-tests.js +181 -0
- package/dist/lib/run-tests.js.map +1 -0
- package/dist/lib/run-tool.js +6 -22
- package/dist/lib/run-tool.js.map +1 -1
- package/dist/lib/session.d.ts +8 -1
- package/dist/lib/session.js +36 -4
- package/dist/lib/session.js.map +1 -1
- package/dist/lib/setup-skills.d.ts +8 -13
- package/dist/lib/setup-skills.js +27 -24
- package/dist/lib/setup-skills.js.map +1 -1
- package/dist/lib/types.d.ts +7 -0
- package/dist/lib/update-project.js +1 -1
- package/dist/lib/update-project.js.map +1 -1
- package/dist/lib.d.ts +16 -0
- package/dist/lib.js +10 -0
- package/dist/lib.js.map +1 -1
- package/dist/utils/addon-deps.js +2 -2
- package/dist/utils/agents.d.ts +2 -6
- package/dist/utils/agents.js.map +1 -1
- package/dist/utils/connection.d.ts +59 -0
- package/dist/utils/connection.js +11 -10
- package/dist/utils/connection.js.map +1 -1
- package/dist/utils/csproj-deps.js +1 -1
- package/dist/utils/csproj-deps.js.map +1 -1
- package/dist/utils/editor-connection.d.ts +74 -0
- package/dist/utils/editor-connection.js +225 -0
- package/dist/utils/editor-connection.js.map +1 -0
- package/dist/utils/editor-mcp-server.d.ts +32 -0
- package/dist/utils/editor-mcp-server.js +134 -0
- package/dist/utils/editor-mcp-server.js.map +1 -0
- package/dist/utils/exit-codes.d.ts +2 -0
- package/dist/utils/exit-codes.js +4 -0
- package/dist/utils/exit-codes.js.map +1 -0
- package/dist/utils/godot-process.d.ts +5 -0
- package/dist/utils/godot-process.js +16 -0
- package/dist/utils/godot-process.js.map +1 -1
- package/dist/utils/godot-shutdown.d.ts +3 -1
- package/dist/utils/godot-shutdown.js +4 -2
- package/dist/utils/godot-shutdown.js.map +1 -1
- package/dist/utils/input.d.ts +3 -3
- package/dist/utils/input.js +22 -35
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/output.d.ts +45 -0
- package/dist/utils/output.js +101 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/server-source.d.ts +1 -1
- package/dist/utils/server-source.js +1 -1
- package/dist/utils/skill-guides.d.ts +6 -9
- package/dist/utils/skill-guides.js +100 -43
- package/dist/utils/skill-guides.js.map +1 -1
- package/dist/utils/skills.d.ts +1 -14
- package/dist/utils/skills.js +0 -89
- package/dist/utils/skills.js.map +1 -1
- package/dist/utils/ui.d.ts +6 -1
- package/dist/utils/ui.js +72 -58
- package/dist/utils/ui.js.map +1 -1
- package/dist/utils/update-check.d.ts +6 -17
- package/dist/utils/update-check.js +10 -77
- package/dist/utils/update-check.js.map +1 -1
- package/package.json +2 -2
- package/dist/utils/json-parse.d.ts +0 -25
- package/dist/utils/json-parse.js +0 -83
- package/dist/utils/json-parse.js.map +0 -1
- package/dist/utils/semver.d.ts +0 -4
- package/dist/utils/semver.js +0 -25
- package/dist/utils/semver.js.map +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { execFileSync } from 'child_process';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { platform } from 'os';
|
|
4
|
+
import { isProcessAlive, killProcessTree, readProcessStart } from '@baizor/gamedev-cli-core';
|
|
5
|
+
import { waitForExit } from './godot-shutdown.js';
|
|
6
|
+
import { verbose } from './ui.js';
|
|
7
|
+
/**
|
|
8
|
+
* The local MCP server is launched by the addon (`GodotMcpServerManager.StartServer`) as a child process of the
|
|
9
|
+
* editor. The plugin stops it when the editor quits cleanly, but a hard-killed editor leaves it running. `close`
|
|
10
|
+
* finds it BEFORE the editor goes away — by process parentage, never by command line — and stops it afterwards.
|
|
11
|
+
* A stopgap for `close` only: a server that watched its parent PID itself would also cover editor crashes.
|
|
12
|
+
*/
|
|
13
|
+
/** File name of the server binary (`GodotMcpServerView.ExecutableName`), without `.exe`. */
|
|
14
|
+
const MCP_SERVER_EXECUTABLE = 'gamedev-mcp-server';
|
|
15
|
+
/** True for the server binary's process name: `gamedev-mcp-server[.exe]`, a full path, or Linux's 15-char `comm`. */
|
|
16
|
+
export function isMcpServerName(name) {
|
|
17
|
+
const base = path.basename(name.trim().replace(/\\/g, '/')).toLowerCase().replace(/\.exe$/, '');
|
|
18
|
+
return base === MCP_SERVER_EXECUTABLE || (base.length === 15 && MCP_SERVER_EXECUTABLE.startsWith(base));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Every process below `rootPid`: children, grandchildren (the `_console` wrapper runs the editor as its child). A
|
|
22
|
+
* Windows parent PID can name a dead process whose PID was reused, so a child that started before its supposed parent
|
|
23
|
+
* is not its child.
|
|
24
|
+
*/
|
|
25
|
+
function descendantsOf(table, rootPid) {
|
|
26
|
+
const byPid = new Map(table.map((e) => [e.pid, e]));
|
|
27
|
+
const children = new Map();
|
|
28
|
+
for (const e of table)
|
|
29
|
+
children.set(e.ppid, [...(children.get(e.ppid) ?? []), e]);
|
|
30
|
+
const found = [];
|
|
31
|
+
const seen = new Set([rootPid]);
|
|
32
|
+
const queue = [rootPid];
|
|
33
|
+
while (queue.length > 0) {
|
|
34
|
+
const parent = queue.shift();
|
|
35
|
+
const parentStarted = byPid.get(parent)?.startedMs;
|
|
36
|
+
for (const entry of children.get(parent) ?? []) {
|
|
37
|
+
if (seen.has(entry.pid))
|
|
38
|
+
continue;
|
|
39
|
+
if (parentStarted !== undefined && entry.startedMs !== undefined && entry.startedMs < parentStarted)
|
|
40
|
+
continue;
|
|
41
|
+
seen.add(entry.pid);
|
|
42
|
+
queue.push(entry.pid);
|
|
43
|
+
found.push(entry);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return found;
|
|
47
|
+
}
|
|
48
|
+
/** The PIDs of the processes below `rootPid` that run the server binary. */
|
|
49
|
+
export function findServerDescendants(table, rootPid) {
|
|
50
|
+
return descendantsOf(table, rootPid).filter((e) => isMcpServerName(e.name)).map((e) => e.pid);
|
|
51
|
+
}
|
|
52
|
+
/** Parse `pid ppid [startedTicks] name` lines (Windows rows carry UTC .NET ticks). */
|
|
53
|
+
export function parseProcessTable(output, withStart) {
|
|
54
|
+
const rows = [];
|
|
55
|
+
const pattern = withStart ? /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.+?)\s*$/ : /^\s*(\d+)\s+(\d+)\s+(.+?)\s*$/;
|
|
56
|
+
for (const line of output.split(/\r?\n/)) {
|
|
57
|
+
const m = line.match(pattern);
|
|
58
|
+
if (!m)
|
|
59
|
+
continue;
|
|
60
|
+
const entry = { pid: Number(m[1]), ppid: Number(m[2]), name: withStart ? m[4] : m[3] };
|
|
61
|
+
// .NET ticks (100 ns since 0001-01-01) to epoch ms; only ever compared with each other.
|
|
62
|
+
if (withStart)
|
|
63
|
+
entry.startedMs = Number((BigInt(m[3]) - 621355968000000000n) / 10000n);
|
|
64
|
+
rows.push(entry);
|
|
65
|
+
}
|
|
66
|
+
return rows;
|
|
67
|
+
}
|
|
68
|
+
const EXEC_OPTIONS = { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 16 * 1024 * 1024 };
|
|
69
|
+
/**
|
|
70
|
+
* The process table (PID, parent PID, name), or empty when it cannot be read. On Windows only Godot and server rows:
|
|
71
|
+
* the addon starts the server straight from the editor, which the `_console` wrapper runs, so no other process sits
|
|
72
|
+
* between them.
|
|
73
|
+
*/
|
|
74
|
+
export function listProcessTable() {
|
|
75
|
+
try {
|
|
76
|
+
if (platform() === 'win32') {
|
|
77
|
+
const script = `Get-CimInstance Win32_Process -Filter "Name LIKE '%godot%' OR Name LIKE '${MCP_SERVER_EXECUTABLE}%'" | ` +
|
|
78
|
+
'ForEach-Object { "$($_.ProcessId) $($_.ParentProcessId) ' +
|
|
79
|
+
'$(if ($_.CreationDate) { $_.CreationDate.ToUniversalTime().Ticks } else { 0 }) $($_.Name)" }';
|
|
80
|
+
const out = execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script], { ...EXEC_OPTIONS, timeout: 20000 });
|
|
81
|
+
return parseProcessTable(out, true);
|
|
82
|
+
}
|
|
83
|
+
const out = execFileSync('ps', ['-A', '-o', 'pid=,ppid=,comm='], { ...EXEC_OPTIONS, timeout: 10000 });
|
|
84
|
+
return parseProcessTable(out, false);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
verbose(`Failed to list processes: ${err instanceof Error ? err.message : String(err)}`);
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** The MCP server processes the editor `editorPid` started (its own descendants only), with their start tokens. */
|
|
92
|
+
export async function findEditorServers(editorPid) {
|
|
93
|
+
const pids = findServerDescendants(listProcessTable(), editorPid);
|
|
94
|
+
const servers = await Promise.all(pids.map(async (pid) => ({ pid, start: await readProcessStart(pid) })));
|
|
95
|
+
for (const s of servers)
|
|
96
|
+
verbose(`Editor PID ${editorPid} runs MCP server PID ${s.pid}`);
|
|
97
|
+
return servers;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Once the editor `editorPid` is gone, kill each of its servers still running, with the processes it started. A server
|
|
101
|
+
* is skipped while its editor is alive, and when its PID now belongs to another process (start token changed). Returns
|
|
102
|
+
* the PIDs stopped.
|
|
103
|
+
*/
|
|
104
|
+
export async function stopOrphanedServers(editorPid, servers) {
|
|
105
|
+
if (servers.length === 0 || isProcessAlive(editorPid))
|
|
106
|
+
return [];
|
|
107
|
+
const stopped = [];
|
|
108
|
+
for (const server of servers) {
|
|
109
|
+
if (!isProcessAlive(server.pid))
|
|
110
|
+
continue;
|
|
111
|
+
if (server.start === undefined || (await readProcessStart(server.pid)) !== server.start) {
|
|
112
|
+
verbose(`MCP server PID ${server.pid} cannot be proven to be the same process; left alone`);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
// POSIX: the server leads no process group (.NET's Process.Start keeps the editor's), so killProcessTree reaches only
|
|
116
|
+
// the server itself; its children are taken from the table. Windows: `taskkill /T` covers them.
|
|
117
|
+
const children = platform() === 'win32' ? [] : descendantsOf(listProcessTable(), server.pid);
|
|
118
|
+
await killProcessTree(server.pid);
|
|
119
|
+
for (const child of children) {
|
|
120
|
+
try {
|
|
121
|
+
process.kill(child.pid, 'SIGKILL');
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
/* already gone */
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (await waitForExit(server.pid, 5000))
|
|
128
|
+
stopped.push(server.pid);
|
|
129
|
+
else
|
|
130
|
+
verbose(`MCP server PID ${server.pid} is still alive after the kill`);
|
|
131
|
+
}
|
|
132
|
+
return stopped;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=editor-mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-mcp-server.js","sourceRoot":"","sources":["../../src/utils/editor-mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8C,MAAM,eAAe,CAAC;AACzF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;GAKG;AAEH,4FAA4F;AAC5F,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAgBnD,qHAAqH;AACrH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EA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AgB,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7F,MAAM,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YACrC,CAAC;YAAC,MAAM,CAAC;gBACP,kBAAkB;YACpB,CAAC;QACH,CAAC;QACD,IAAI,MAAM,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;;YAC7D,OAAO,CAAC,kBAAkB,MAAM,CAAC,GAAG,gCAAgC,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../../src/utils/exit-codes.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,4BAA4B;AAE5B,OAAO,EAAE,QAAQ,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -8,3 +8,8 @@ export interface GodotProcess {
|
|
|
8
8
|
* Returns process info if found, null otherwise.
|
|
9
9
|
*/
|
|
10
10
|
export declare function findGodotProcess(projectPath: string): GodotProcess | null;
|
|
11
|
+
/**
|
|
12
|
+
* Windows: the PIDs of a process's direct Godot children (the `_console` wrapper's editor; not its conhost).
|
|
13
|
+
* Empty elsewhere or on error.
|
|
14
|
+
*/
|
|
15
|
+
export declare function childProcessIds(pid: number): number[];
|
|
@@ -36,6 +36,22 @@ export function findGodotProcess(projectPath) {
|
|
|
36
36
|
verbose(`No Godot process found for project: ${projectPath}`);
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Windows: the PIDs of a process's direct Godot children (the `_console` wrapper's editor; not its conhost).
|
|
41
|
+
* Empty elsewhere or on error.
|
|
42
|
+
*/
|
|
43
|
+
export function childProcessIds(pid) {
|
|
44
|
+
if (platform() !== 'win32')
|
|
45
|
+
return [];
|
|
46
|
+
try {
|
|
47
|
+
const filter = `ParentProcessId=${pid} AND Name LIKE '%godot%'`;
|
|
48
|
+
const out = execFileSync('powershell.exe', ['-NoProfile', '-Command', `(Get-CimInstance Win32_Process -Filter "${filter}").ProcessId`], { encoding: 'utf-8', timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
49
|
+
return out.split(/\s+/).map((s) => parseInt(s, 10)).filter((n) => Number.isFinite(n) && n > 0);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
39
55
|
/**
|
|
40
56
|
* List all running Godot editor processes with their project paths. Matches
|
|
41
57
|
* any process whose name contains "godot" (covers `Godot.exe`, `Godot_mono.exe`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"godot-process.js","sourceRoot":"","sources":["../../src/utils/godot-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,WAAmB;IAC7C,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACxD,IAAI,MAAM;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACtD,IAAI,QAAQ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,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAEpE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK;oBAAE,SAAS;gBAErB,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACnC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC7B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC;oBAAE,SAAS;gBAE3C,MAAM,WAAW,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;gBACpD,IAAI,WAAW,EAAE,CAAC;oBAChB,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,mCAAmC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,CAAC,SAAS,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -8,7 +8,9 @@ export declare function isProcessAlive(pid: number, os?: SupportedPlatform): boo
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function sendGracefulShutdown(pid: number, os?: SupportedPlatform): boolean;
|
|
10
10
|
/** Hard-kill the process. SIGKILL on POSIX; `taskkill /F` on Windows. */
|
|
11
|
-
export declare function sendForceKill(pid: number, os?: SupportedPlatform
|
|
11
|
+
export declare function sendForceKill(pid: number, os?: SupportedPlatform,
|
|
12
|
+
/** Windows: also its child processes (`/T`) — for the `_console` wrapper, whose child is the editor itself. */
|
|
13
|
+
tree?: boolean): boolean;
|
|
12
14
|
/**
|
|
13
15
|
* Poll for the process to exit, up to `timeoutMs`. Resolves true when the
|
|
14
16
|
* process is gone, false on timeout.
|
|
@@ -37,10 +37,12 @@ export function sendGracefulShutdown(pid, os = platform()) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
/** Hard-kill the process. SIGKILL on POSIX; `taskkill /F` on Windows. */
|
|
40
|
-
export function sendForceKill(pid, os = platform()
|
|
40
|
+
export function sendForceKill(pid, os = platform(),
|
|
41
|
+
/** Windows: also its child processes (`/T`) — for the `_console` wrapper, whose child is the editor itself. */
|
|
42
|
+
tree = false) {
|
|
41
43
|
try {
|
|
42
44
|
if (os === 'win32') {
|
|
43
|
-
execFileSync('taskkill', ['/PID', String(pid), '/F'], { encoding: 'utf-8', timeout: 5000, stdio: 'pipe' });
|
|
45
|
+
execFileSync('taskkill', tree ? ['/PID', String(pid), '/T', '/F'] : ['/PID', String(pid), '/F'], { encoding: 'utf-8', timeout: 5000, stdio: 'pipe' });
|
|
44
46
|
return true;
|
|
45
47
|
}
|
|
46
48
|
process.kill(pid, 'SIGKILL');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"godot-shutdown.js","sourceRoot":"","sources":["../../src/utils/godot-shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAI9B,mEAAmE;AACnE,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,KAAwB,QAAQ,EAAuB;IACjG,IAAI,CAAC;QACH,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,YAAY,CAAC,UAAU,EAAE,CAAC,K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AM,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACtJ,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAW,EACX,SAAiB,EACjB,KAAwB,QAAQ,EAAuB;IAEvD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,QAAQ,GAAG,GAAG,CAAC;IACrB,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,SAAS,EAAE,CAAC;QACtC,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC;YAAE,OAAO,IAAI,CAAC;QAC1C,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/utils/input.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export interface InputOptions {
|
|
|
3
3
|
inputFile?: string;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Parse tool input from --input, --input-file, or stdin.
|
|
6
|
+
* Parse tool input from --input, --input-file, or stdin. Bad input is a usage error (exit 2).
|
|
7
7
|
*
|
|
8
8
|
* - `--input-file -` or `--input-file /dev/stdin` reads from stdin (cross-platform).
|
|
9
9
|
* - `--input-file <path>` reads from a file.
|
|
@@ -11,5 +11,5 @@ export interface InputOptions {
|
|
|
11
11
|
* - Falls back to `{}` if nothing provided.
|
|
12
12
|
*/
|
|
13
13
|
export declare function parseInput(options: InputOptions): string;
|
|
14
|
-
/**
|
|
15
|
-
export declare function
|
|
14
|
+
/** Commander accumulator for a repeatable option. */
|
|
15
|
+
export declare function collect(value: string, previous: string[]): string[];
|
package/dist/utils/input.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import * as ui from './ui.js';
|
|
4
3
|
import { verbose } from './ui.js';
|
|
5
|
-
import { parseJsonStrict, JsonParseError } from '
|
|
4
|
+
import { parseJsonStrict, JsonParseError } from '@baizor/gamedev-cli-core';
|
|
5
|
+
import { ExitCode } from './exit-codes.js';
|
|
6
|
+
import { exitWithError } from './output.js';
|
|
7
|
+
function usage(message) {
|
|
8
|
+
return exitWithError(ExitCode.Usage, 'USAGE', message);
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
|
-
* Parse tool input from --input, --input-file, or stdin.
|
|
11
|
+
* Parse tool input from --input, --input-file, or stdin. Bad input is a usage error (exit 2).
|
|
8
12
|
*
|
|
9
13
|
* - `--input-file -` or `--input-file /dev/stdin` reads from stdin (cross-platform).
|
|
10
14
|
* - `--input-file <path>` reads from a file.
|
|
@@ -21,34 +25,28 @@ export function parseInput(options) {
|
|
|
21
25
|
content = fs.readFileSync(0, 'utf-8');
|
|
22
26
|
}
|
|
23
27
|
catch {
|
|
24
|
-
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
if (!content.trim()) {
|
|
28
|
-
ui.error('No input received from stdin.');
|
|
29
|
-
process.exit(1);
|
|
28
|
+
usage('Failed to read from stdin.');
|
|
30
29
|
}
|
|
30
|
+
if (!content.trim())
|
|
31
|
+
usage('No input received from stdin.');
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
const filePath = path.resolve(options.inputFile);
|
|
34
|
-
if (!fs.existsSync(filePath))
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (!fs.existsSync(filePath))
|
|
36
|
+
usage(`Input file does not exist: ${filePath}`);
|
|
37
|
+
try {
|
|
38
|
+
content = fs.readFileSync(filePath, 'utf-8');
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
usage(`Cannot read --input-file ${filePath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
37
42
|
}
|
|
38
|
-
content = fs.readFileSync(filePath, 'utf-8');
|
|
39
43
|
}
|
|
40
44
|
try {
|
|
41
45
|
parseJsonStrict(content);
|
|
42
46
|
}
|
|
43
47
|
catch (err) {
|
|
44
48
|
const source = isStdin ? 'stdin' : options.inputFile;
|
|
45
|
-
|
|
46
|
-
ui.error(`--input-file content from '${source}' must be valid JSON\n${err.message}`);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
ui.error(`--input-file content from '${source}' must be valid JSON`);
|
|
50
|
-
}
|
|
51
|
-
process.exit(1);
|
|
49
|
+
usage(`--input-file content from '${source}' must be valid JSON` + (err instanceof JsonParseError ? `\n${err.message}` : ''));
|
|
52
50
|
}
|
|
53
51
|
return content;
|
|
54
52
|
}
|
|
@@ -58,24 +56,13 @@ export function parseInput(options) {
|
|
|
58
56
|
return result.raw;
|
|
59
57
|
}
|
|
60
58
|
catch (err) {
|
|
61
|
-
|
|
62
|
-
ui.error(`--input must be valid JSON\n${err.message}`);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
ui.error('--input must be valid JSON');
|
|
66
|
-
}
|
|
67
|
-
process.exit(1);
|
|
59
|
+
usage('--input must be valid JSON' + (err instanceof JsonParseError ? `\n${err.message}` : ''));
|
|
68
60
|
}
|
|
69
61
|
}
|
|
70
62
|
return '{}';
|
|
71
63
|
}
|
|
72
|
-
/**
|
|
73
|
-
export function
|
|
74
|
-
|
|
75
|
-
if (!Number.isInteger(value) || value < 0 || (value === 0 && !allowZero)) {
|
|
76
|
-
ui.error(`${flagName} must be a ${allowZero ? 'non-negative' : 'positive'} whole number, got "${raw}"`);
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
return value;
|
|
64
|
+
/** Commander accumulator for a repeatable option. */
|
|
65
|
+
export function collect(value, previous) {
|
|
66
|
+
return [...previous, value];
|
|
80
67
|
}
|
|
81
68
|
//# sourceMappingURL=input.js.map
|
package/dist/utils/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,SAAS,KAAK,CAAC,OAAe;IAC5B,OAAO,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqB;IAC9C,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,KAAK,GAAG,IAAI,OAAO,CAAC,SAAS,KAAK,YAAY,CAAC;QAChF,IAA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O,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO,MAAM,CAAC,GAAG,CAAC;QACpB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,KAAK,CAAC,4BAA4B,GAAG,CAAC,GAAG,YAAY,cAAc,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,QAAkB;IACvD,OAAO,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { CommandOutput as ContractOutput, type EnvelopeError as ContractEnvelopeError, type OutputFormat } from '@baizor/gamedev-cli-core';
|
|
3
|
+
import { type ExitCodeValue } from './exit-codes.js';
|
|
4
|
+
export { CommandExit, OUTPUT_FORMATS, formatFromArgv } from '@baizor/gamedev-cli-core';
|
|
5
|
+
export type { OutputFormat } from '@baizor/gamedev-cli-core';
|
|
6
|
+
/** Upper-snake error codes of the envelope. */
|
|
7
|
+
export type ErrorCode = 'USAGE' | 'TOOL_FAILED' | 'UNREACHABLE' | 'TIMEOUT' | 'BUSY' | 'AWAITING_INPUT' | 'TESTS_FAILED' | 'TEST_RUN_ERROR' | 'COMPILATION_FAILED' | 'SCRIPT_ERRORS' | 'IMPORT_FAILED' | 'PROJECT_OPEN' | 'NOT_FOUND' | 'EXPORT_FAILED' | 'NOT_AUTHENTICATED' | 'ERROR';
|
|
8
|
+
/** One envelope error (`{code, message, httpStatus?}`): the shared contract's, with this CLI's codes. */
|
|
9
|
+
export type EnvelopeError = ContractEnvelopeError<ErrorCode>;
|
|
10
|
+
/** Add `--format` to a command. `extra` lists command-specific formats (e.g. `github`). */
|
|
11
|
+
export declare function addFormatOption(cmd: Command, extra?: readonly string[]): Command;
|
|
12
|
+
/**
|
|
13
|
+
* The output of one command run. Created at the start of an action; in json/ndjson it switches `ui` to stderr so
|
|
14
|
+
* stdout carries only the envelope. Exactly one `finish` per run.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CommandOutput<F extends string = OutputFormat> extends ContractOutput<ErrorCode> {
|
|
17
|
+
readonly format: F;
|
|
18
|
+
constructor(command: string, format: F);
|
|
19
|
+
/** A progress line: ndjson event on stderr, plain stderr line in json, `ui.info` in text. */
|
|
20
|
+
progress(message: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Emit the envelope (machine formats) and end the command. Text output is the caller's job before calling this.
|
|
23
|
+
* The process exits once stdout is flushed; until then a `CommandExit` unwinds the action.
|
|
24
|
+
*/
|
|
25
|
+
finish(exitCode: ExitCodeValue, data?: unknown, errors?: EnvelopeError[]): never;
|
|
26
|
+
/** Fail with one error: printed with `ui.error` in text, in the envelope otherwise. */
|
|
27
|
+
fail(exitCode: ExitCodeValue, code: ErrorCode, message: string, data?: unknown): never;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* An unexpected error escaped a command: report it through the active command's envelope (exit 1) when one runs
|
|
31
|
+
* in a machine format. Returns false when there is none (the caller prints it).
|
|
32
|
+
*/
|
|
33
|
+
export declare function failActive(err: unknown): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Exit from a shared helper (path / input validation): through the active command's envelope when one runs in a
|
|
36
|
+
* machine format, else `ui.error`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function exitWithError(exitCode: ExitCodeValue, code: ErrorCode, message: string): never;
|
|
39
|
+
/**
|
|
40
|
+
* Parse a `--format` value. An unknown value is a usage error (exit 2), reported in text since the format itself
|
|
41
|
+
* is what is wrong.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseFormat<F extends string = never>(raw: string | undefined, extra?: readonly F[]): OutputFormat | F;
|
|
44
|
+
/** Parse a positive (or, with `allowZero`, non-negative) whole-number flag, or exit 2. */
|
|
45
|
+
export declare function parseIntFlag(raw: string | undefined, flagName: string, allowZero?: boolean): number;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// `--format text|json|ndjson` output contract shared by godot-cli, unity-mcp-cli and unreal-mcp-cli (it lives in
|
|
2
|
+
// @baizor/gamedev-cli-core).
|
|
3
|
+
//
|
|
4
|
+
// json: stdout carries exactly one pretty-printed envelope; every human-readable line goes to stderr.
|
|
5
|
+
// ndjson: progress lines `{"type":"progress",...}` on stderr, the envelope as one line on stdout.
|
|
6
|
+
// text: the usual human output.
|
|
7
|
+
import { CommandOutput as ContractOutput, OUTPUT_FORMATS, UsageError, activeCommandOutput, exitAfterFlush, parseFormat as parseContractFormat, } from '@baizor/gamedev-cli-core';
|
|
8
|
+
import * as ui from './ui.js';
|
|
9
|
+
import { ExitCode } from './exit-codes.js';
|
|
10
|
+
export { CommandExit, OUTPUT_FORMATS, formatFromArgv } from '@baizor/gamedev-cli-core';
|
|
11
|
+
/** Add `--format` to a command. `extra` lists command-specific formats (e.g. `github`). */
|
|
12
|
+
export function addFormatOption(cmd, extra = []) {
|
|
13
|
+
const formats = [...OUTPUT_FORMATS, ...extra].join('|');
|
|
14
|
+
return cmd.option('--format <format>', `Output format: ${formats}`, 'text');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The output of one command run. Created at the start of an action; in json/ndjson it switches `ui` to stderr so
|
|
18
|
+
* stdout carries only the envelope. Exactly one `finish` per run.
|
|
19
|
+
*/
|
|
20
|
+
export class CommandOutput extends ContractOutput {
|
|
21
|
+
constructor(command, format) {
|
|
22
|
+
super(command, format);
|
|
23
|
+
// ndjson: every human line on stderr is an event too, so stderr stays parseable line by line.
|
|
24
|
+
ui.setMachineOutput(this.machine, format === 'ndjson'
|
|
25
|
+
? (level, message) => JSON.stringify({ type: 'log', command, level, message })
|
|
26
|
+
: undefined);
|
|
27
|
+
}
|
|
28
|
+
/** A progress line: ndjson event on stderr, plain stderr line in json, `ui.info` in text. */
|
|
29
|
+
progress(message) {
|
|
30
|
+
if (this.format === 'ndjson')
|
|
31
|
+
super.progress(message);
|
|
32
|
+
else if (this.format === 'json')
|
|
33
|
+
process.stderr.write(message + '\n');
|
|
34
|
+
else
|
|
35
|
+
ui.info(message);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Emit the envelope (machine formats) and end the command. Text output is the caller's job before calling this.
|
|
39
|
+
* The process exits once stdout is flushed; until then a `CommandExit` unwinds the action.
|
|
40
|
+
*/
|
|
41
|
+
finish(exitCode, data = null, errors = []) {
|
|
42
|
+
for (const err of errors)
|
|
43
|
+
this.record(err.code, err.message, err.httpStatus);
|
|
44
|
+
this.emit(exitCode, data);
|
|
45
|
+
exitAfterFlush(exitCode);
|
|
46
|
+
}
|
|
47
|
+
/** Fail with one error: printed with `ui.error` in text, in the envelope otherwise. */
|
|
48
|
+
fail(exitCode, code, message, data = null) {
|
|
49
|
+
if (!this.machine)
|
|
50
|
+
ui.error(message);
|
|
51
|
+
return this.finish(exitCode, data, [{ code, message }]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** The godot-cli output of the command being run, if one was created. */
|
|
55
|
+
function active() {
|
|
56
|
+
const output = activeCommandOutput();
|
|
57
|
+
return output instanceof CommandOutput ? output : undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* An unexpected error escaped a command: report it through the active command's envelope (exit 1) when one runs
|
|
61
|
+
* in a machine format. Returns false when there is none (the caller prints it).
|
|
62
|
+
*/
|
|
63
|
+
export function failActive(err) {
|
|
64
|
+
const output = active();
|
|
65
|
+
if (!output?.machine)
|
|
66
|
+
return false;
|
|
67
|
+
return output.fail(ExitCode.Error, 'ERROR', err instanceof Error ? err.message : String(err));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Exit from a shared helper (path / input validation): through the active command's envelope when one runs in a
|
|
71
|
+
* machine format, else `ui.error`.
|
|
72
|
+
*/
|
|
73
|
+
export function exitWithError(exitCode, code, message) {
|
|
74
|
+
active()?.fail(exitCode, code, message);
|
|
75
|
+
ui.error(message);
|
|
76
|
+
process.exit(exitCode);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse a `--format` value. An unknown value is a usage error (exit 2), reported in text since the format itself
|
|
80
|
+
* is what is wrong.
|
|
81
|
+
*/
|
|
82
|
+
export function parseFormat(raw, extra = []) {
|
|
83
|
+
try {
|
|
84
|
+
return parseContractFormat(raw, extra);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (!(err instanceof UsageError))
|
|
88
|
+
throw err;
|
|
89
|
+
ui.error(err.message);
|
|
90
|
+
process.exit(ExitCode.Usage);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Parse a positive (or, with `allowZero`, non-negative) whole-number flag, or exit 2. */
|
|
94
|
+
export function parseIntFlag(raw, flagName, allowZero = false) {
|
|
95
|
+
const value = Number(raw);
|
|
96
|
+
if (raw === undefined || raw.trim() === '' || !Number.isInteger(value) || value < 0 || (value === 0 && !allowZero)) {
|
|
97
|
+
exitWithError(ExitCode.Usage, 'USAGE', `Invalid ${flagName} value: "${raw}". Must be a ${allowZero ? 'non-negative' : 'positive'} whole number.`);
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,6BAA6B;AAC7B,EAAE;AACF,wGAAwG;AACxG,kGAAkG;AAClG,kCAAkC;AAGlC,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,cAAc,EACd,UAAU,EACV,mBAAmB,E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ping the addon's server pin requires
|
|
6
6
|
* bumping this in the same PR or the parity test goes red.
|
|
7
7
|
*/
|
|
8
|
-
export declare const DEFAULT_SERVER_VERSION = "9.
|
|
8
|
+
export declare const DEFAULT_SERVER_VERSION = "9.5.0";
|
|
9
9
|
/** GitHub-release host the server zip + manifest are downloaded from. NOTHING else is trusted. */
|
|
10
10
|
export declare const TRUSTED_DOWNLOAD_HOST = "github.com";
|
|
11
11
|
/** The `owner/repo` the shared server releases live under. */
|
|
@@ -18,7 +18,7 @@ import { createHash } from 'crypto';
|
|
|
18
18
|
* download entirely (offline / CI). Bumping the addon's server pin requires
|
|
19
19
|
* bumping this in the same PR or the parity test goes red.
|
|
20
20
|
*/
|
|
21
|
-
export const DEFAULT_SERVER_VERSION = '9.
|
|
21
|
+
export const DEFAULT_SERVER_VERSION = '9.5.0';
|
|
22
22
|
/** GitHub-release host the server zip + manifest are downloaded from. NOTHING else is trusted. */
|
|
23
23
|
export const TRUSTED_DOWNLOAD_HOST = 'github.com';
|
|
24
24
|
/** The `owner/repo` the shared server releases live under. */
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
export declare const APP_SKILL_DESCRIPTION = "AI Game Dev App: image, texture, 3D model, audio and video generation; animation, rigging, Blender, music and sound effects. Consult when a game-development task needs creative tools unavailable in the current environment, or an integrated workflow for Unity, Unreal Engine or Godot.";
|
|
4
|
-
export declare const CLI_SKILL_DESCRIPTION = "Install and use godot-cli: Node.js requirements, npm installation, npx, tool calls, JSON input files and troubleshooting.";
|
|
1
|
+
/** Skill folders earlier versions generated from a hand-written catalog (`godot-mcp`, `godot-mcp-<family>`). */
|
|
2
|
+
export declare function isRetiredSkillName(name: string): boolean;
|
|
5
3
|
export declare const SKILL_METADATA: {
|
|
6
4
|
readonly 'generated-by': "godot-mcp";
|
|
7
5
|
readonly 'ai-game-dev': "exclude";
|
|
8
6
|
};
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
export declare function
|
|
12
|
-
|
|
13
|
-
export declare const APP_GUIDE: string;
|
|
7
|
+
/** What each failing exit code asks of the agent (0 and 1 need nothing). A test keeps the codes in the core contract. */
|
|
8
|
+
export declare const EXIT_CODE_ACTIONS: Readonly<Record<number, string>>;
|
|
9
|
+
export declare function buildInstallGuide(platform?: NodeJS.Platform): string;
|
|
10
|
+
/** Every file `setup-skills` writes, relative to the agent's skills folder. Pure and deterministic. */
|
|
14
11
|
export declare function buildGuideFiles(platform?: NodeJS.Platform): {
|
|
15
12
|
relativePath: string;
|
|
16
13
|
content: string;
|