godot-cli 0.29.0 → 0.31.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 +36 -0
- package/README.md +42 -3
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/close.d.ts +3 -0
- package/dist/commands/close.js +40 -1
- package/dist/commands/close.js.map +1 -1
- package/dist/commands/exec.d.ts +2 -0
- package/dist/commands/exec.js +101 -0
- package/dist/commands/exec.js.map +1 -0
- package/dist/commands/open.js +60 -1
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/run-tool-builder.d.ts +9 -1
- package/dist/commands/run-tool-builder.js +1 -1
- package/dist/commands/run-tool-builder.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/exec.d.ts +65 -0
- package/dist/lib/exec.js +79 -0
- package/dist/lib/exec.js.map +1 -0
- package/dist/lib/session.d.ts +79 -0
- package/dist/lib/session.js +168 -0
- package/dist/lib/session.js.map +1 -0
- package/dist/lib.d.ts +4 -0
- package/dist/lib.js +2 -0
- package/dist/lib.js.map +1 -1
- package/dist/utils/addon-deps.d.ts +12 -1
- package/dist/utils/addon-deps.js +16 -4
- package/dist/utils/addon-deps.js.map +1 -1
- package/dist/utils/addon-nuget-deps.d.ts +7 -3
- package/dist/utils/addon-nuget-deps.js +12 -8
- package/dist/utils/addon-nuget-deps.js.map +1 -1
- package/dist/utils/connection.d.ts +18 -0
- package/dist/utils/connection.js +22 -3
- package/dist/utils/connection.js.map +1 -1
- package/dist/utils/csproj-deps.d.ts +2 -1
- package/dist/utils/csproj-deps.js +50 -8
- package/dist/utils/csproj-deps.js.map +1 -1
- package/dist/utils/input.d.ts +2 -0
- package/dist/utils/input.js +9 -0
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/machine-store.js +2 -22
- package/dist/utils/machine-store.js.map +1 -1
- package/dist/utils/server-source.d.ts +1 -1
- package/dist/utils/server-source.js +1 -1
- package/dist/utils/skills.js +16 -1
- package/dist/utils/skills.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { EnsureResult } from '@baizor/gamedev-cli-core';
|
|
2
|
+
import { type EnsureEditorDeps, type EnsureEditorOptions, type EnsureEditorResult } from './session.js';
|
|
3
|
+
import type { RunToolFailure, RunToolOptions, RunToolResult } from './types.js';
|
|
4
|
+
export declare const SCRIPT_EXECUTE_TOOL = "script-execute";
|
|
5
|
+
/**
|
|
6
|
+
* Default `script-execute` call timeout. Longer than the server `tool-timeout` the addon passes
|
|
7
|
+
* (`GodotMcpServerView.ToolTimeoutMs`, parity-tested), so a call the server gives up on returns the server's
|
|
8
|
+
* timeout error instead of a client abort.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_EXEC_TIMEOUT_MS = 310000;
|
|
11
|
+
/** Injection points for tests. */
|
|
12
|
+
export interface ExecDeps extends EnsureEditorDeps {
|
|
13
|
+
invoke: (options: RunToolOptions) => Promise<RunToolResult>;
|
|
14
|
+
}
|
|
15
|
+
export interface ExecCodeOptions extends EnsureEditorOptions {
|
|
16
|
+
code: string;
|
|
17
|
+
usings?: string[];
|
|
18
|
+
include?: string[];
|
|
19
|
+
/** Tool call timeout. Default {@link DEFAULT_EXEC_TIMEOUT_MS}. */
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
deps?: Partial<ExecDeps>;
|
|
22
|
+
}
|
|
23
|
+
export interface ExecCodeSuccess {
|
|
24
|
+
kind: 'success';
|
|
25
|
+
success: true;
|
|
26
|
+
/** The server that ran the code. */
|
|
27
|
+
baseUrl: string;
|
|
28
|
+
/** How the editor was obtained (cli-core EditorSession): `running`, `foreign`, `owned` or `started`. */
|
|
29
|
+
editor: EnsureResult<string>['source'];
|
|
30
|
+
/** Parsed `script-execute` response body. */
|
|
31
|
+
data: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface ExecCodeFailure {
|
|
34
|
+
kind: 'failure';
|
|
35
|
+
success: false;
|
|
36
|
+
/** {@link ensureEditor}'s reasons, or `tool-failed`: the call failed. */
|
|
37
|
+
reason: Extract<EnsureEditorResult, {
|
|
38
|
+
kind: 'failure';
|
|
39
|
+
}>['reason'] | 'tool-failed';
|
|
40
|
+
/** The server that was called (`tool-failed` only). */
|
|
41
|
+
baseUrl?: string;
|
|
42
|
+
/** The underlying call failure (`tool-failed` only). */
|
|
43
|
+
toolFailure?: RunToolFailure;
|
|
44
|
+
message: string;
|
|
45
|
+
error?: Error;
|
|
46
|
+
}
|
|
47
|
+
export type ExecCodeResult = ExecCodeSuccess | ExecCodeFailure;
|
|
48
|
+
/**
|
|
49
|
+
* Run C# in the project's editor. A running editor (GUI or headless) is reused and never closed; otherwise one is
|
|
50
|
+
* started headless (or windowed) on the project's local server that quits by itself after `idleSeconds` without
|
|
51
|
+
* tool calls, so the next call stays warm.
|
|
52
|
+
*/
|
|
53
|
+
export declare function execCode(options: ExecCodeOptions): Promise<ExecCodeResult>;
|
|
54
|
+
/** Request body for `script-execute`; empty lists are left out. */
|
|
55
|
+
export declare function buildScriptExecuteInput(code: string, usings: string[], include: string[]): Record<string, unknown>;
|
|
56
|
+
/** The tool's own error text when the server reports one (`{ error }` / text content), else the call failure. */
|
|
57
|
+
export declare function toolErrorText(failure: RunToolFailure): string;
|
|
58
|
+
/**
|
|
59
|
+
* The tool's text output and whether it reported success. RQL tool format (the default): the text content
|
|
60
|
+
* (`System.Int32: 3`, then `logs:` lines). JSON format: `{ structured: { result: { result, logs } } }`, shown the same way.
|
|
61
|
+
*/
|
|
62
|
+
export declare function readToolResponse(data: unknown): {
|
|
63
|
+
ok: boolean;
|
|
64
|
+
text: string;
|
|
65
|
+
};
|
package/dist/lib/exec.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Library-safe `execCode`: run C# in a project's Godot editor through `script-execute`, starting a warm headless
|
|
2
|
+
// editor (cli-core EditorSession) when none is running. No console output, no `process.exit`.
|
|
3
|
+
import { runTool } from './run-tool.js';
|
|
4
|
+
import { ensureEditor } from './session.js';
|
|
5
|
+
export const SCRIPT_EXECUTE_TOOL = 'script-execute';
|
|
6
|
+
/**
|
|
7
|
+
* Default `script-execute` call timeout. Longer than the server `tool-timeout` the addon passes
|
|
8
|
+
* (`GodotMcpServerView.ToolTimeoutMs`, parity-tested), so a call the server gives up on returns the server's
|
|
9
|
+
* timeout error instead of a client abort.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_EXEC_TIMEOUT_MS = 310000;
|
|
12
|
+
/**
|
|
13
|
+
* Run C# in the project's editor. A running editor (GUI or headless) is reused and never closed; otherwise one is
|
|
14
|
+
* started headless (or windowed) on the project's local server that quits by itself after `idleSeconds` without
|
|
15
|
+
* tool calls, so the next call stays warm.
|
|
16
|
+
*/
|
|
17
|
+
export async function execCode(options) {
|
|
18
|
+
const editor = await ensureEditor(options);
|
|
19
|
+
if (editor.kind === 'failure')
|
|
20
|
+
return editor;
|
|
21
|
+
const { ensured } = editor;
|
|
22
|
+
options.onStatus?.('Running...');
|
|
23
|
+
const baseUrl = ensured.ready;
|
|
24
|
+
const result = await (options.deps?.invoke ?? runTool)({
|
|
25
|
+
toolName: SCRIPT_EXECUTE_TOOL,
|
|
26
|
+
url: baseUrl,
|
|
27
|
+
...(options.token ? { token: options.token } : {}),
|
|
28
|
+
input: buildScriptExecuteInput(options.code, options.usings ?? [], options.include ?? []),
|
|
29
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_EXEC_TIMEOUT_MS,
|
|
30
|
+
});
|
|
31
|
+
if (result.kind === 'failure') {
|
|
32
|
+
return { kind: 'failure', success: false, reason: 'tool-failed', baseUrl, toolFailure: result, message: toolErrorText(result), error: result.error };
|
|
33
|
+
}
|
|
34
|
+
return { kind: 'success', success: true, baseUrl, editor: ensured.source, data: result.data };
|
|
35
|
+
}
|
|
36
|
+
/** Request body for `script-execute`; empty lists are left out. */
|
|
37
|
+
export function buildScriptExecuteInput(code, usings, include) {
|
|
38
|
+
return {
|
|
39
|
+
csharpCode: code,
|
|
40
|
+
...(usings.length > 0 ? { usings } : {}),
|
|
41
|
+
...(include.length > 0 ? { include } : {}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** The tool's own error text when the server reports one (`{ error }` / text content), else the call failure. */
|
|
45
|
+
export function toolErrorText(failure) {
|
|
46
|
+
const data = failure.data;
|
|
47
|
+
if (typeof data === 'string' && data.length > 0)
|
|
48
|
+
return data;
|
|
49
|
+
if (data && typeof data === 'object' && typeof data.error === 'string')
|
|
50
|
+
return data.error;
|
|
51
|
+
return failure.message;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The tool's text output and whether it reported success. RQL tool format (the default): the text content
|
|
55
|
+
* (`System.Int32: 3`, then `logs:` lines). JSON format: `{ structured: { result: { result, logs } } }`, shown the same way.
|
|
56
|
+
*/
|
|
57
|
+
export function readToolResponse(data) {
|
|
58
|
+
if (typeof data === 'string')
|
|
59
|
+
return { ok: true, text: data };
|
|
60
|
+
const response = data;
|
|
61
|
+
const ok = response?.status === undefined || response.status === 'success';
|
|
62
|
+
const texts = (response?.content ?? []).filter((c) => c?.type === 'text' && typeof c.text === 'string').map((c) => c.text);
|
|
63
|
+
if (texts.length > 0)
|
|
64
|
+
return { ok, text: texts.join('\n') };
|
|
65
|
+
const result = response?.structured?.result;
|
|
66
|
+
if (result && typeof result === 'object' && 'result' in result) {
|
|
67
|
+
const member = result.result;
|
|
68
|
+
// A scalar member carries `value`; an object (Node, Vector3, ...) its `fields` / `props`.
|
|
69
|
+
const value = member?.value !== undefined ? member.value : member?.fields !== undefined || member?.props !== undefined
|
|
70
|
+
? { ...(member.fields !== undefined ? { fields: member.fields } : {}), ...(member.props !== undefined ? { props: member.props } : {}) }
|
|
71
|
+
: null;
|
|
72
|
+
let text = member ? `${member.typeName ?? 'object'}: ${typeof value === 'string' ? value : JSON.stringify(value)}` : 'null';
|
|
73
|
+
if (Array.isArray(result.logs) && result.logs.length > 0)
|
|
74
|
+
text += '\nlogs:\n' + result.logs.join('\n');
|
|
75
|
+
return { ok, text };
|
|
76
|
+
}
|
|
77
|
+
return { ok, text: data === undefined ? '' : JSON.stringify(data) };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/lib/exec.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,8FAA8F;AAG9F,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAA4E,MAAM,cAAc,CAAC;AAGtH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAO,CAAC;AA0C/C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAwB;IACrD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE3B,OAAO,CAAC,QAAQ,EAAE,CAAC,YAAY,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,OAAO,CAAC,CAAC;QACrD,QAAQ,EAAE,mBAAmB;QAC7B,GAAG,EAAE,OAAO;QACZ,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,KAAK,EAAE,uBAAuB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,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C,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;YACvI,CAAC,CAAC,IAAI,CAAC;QACT,IAAI,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,IAAI,QAAQ,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAC5H,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,IAAI,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvG,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IACtB,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { EditorSession, type EditorSessionOptions, type EngineAdapter, type EnsureResult, type SessionProcessOps } from '@baizor/gamedev-cli-core';
|
|
2
|
+
import type { BuildProjectResult } from './types.js';
|
|
3
|
+
/** The plugin's system tool that saves and quits a CLI-started editor (a windowless one gets no WM_CLOSE). */
|
|
4
|
+
export declare const SESSION_CLOSE_TOOL = "session-close";
|
|
5
|
+
export interface GodotSessionOptions {
|
|
6
|
+
projectPath: string;
|
|
7
|
+
/**
|
|
8
|
+
* The server the editor's plugin connects to and the session probes. Default: the project's local port
|
|
9
|
+
* (`http://localhost:<derived>`). A non-loopback URL is rejected: headless sessions are local only.
|
|
10
|
+
* {@link ensureEditor} prefers the server of a verified live CLI editor of the project (its lease).
|
|
11
|
+
*/
|
|
12
|
+
url?: string;
|
|
13
|
+
/** Bearer token: the started editor uses it (auth Required) and every probe / call sends it. */
|
|
14
|
+
token?: string;
|
|
15
|
+
/** Explicit Godot executable (else GODOT_BIN / PATH / common install locations). */
|
|
16
|
+
editorPath?: string;
|
|
17
|
+
/** A started editor quits after this many seconds without tool calls. `0` = never. Default 300. */
|
|
18
|
+
idleSeconds?: number;
|
|
19
|
+
/** How long to wait for a started editor's MCP server. Default 300000. */
|
|
20
|
+
readyTimeoutMs?: number;
|
|
21
|
+
/** Runs under the session's startup lock right before it starts an editor (the C# build). */
|
|
22
|
+
beforeLaunch?: EditorSessionOptions<string>['beforeLaunch'];
|
|
23
|
+
onStatus?: (message: string) => void;
|
|
24
|
+
/** Tests: OS process primitives. */
|
|
25
|
+
processOps?: Partial<SessionProcessOps>;
|
|
26
|
+
}
|
|
27
|
+
export interface GodotSession {
|
|
28
|
+
session: EditorSession<string>;
|
|
29
|
+
/** The local server URL the session probes and a started editor binds. */
|
|
30
|
+
url: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Environment of an editor the session starts: Custom mode on the local URL, the plugin starts the local server
|
|
34
|
+
* (there is no dock button to press in a headless editor), and the token when one is given.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sessionEditorEnv(url: string, token: string | undefined): Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* The Godot adapter with the CLI's hooks: running-editor detection (its pid, so the session notices when it exits)
|
|
39
|
+
* and the plugin-side graceful close through the verified lease (its nonce, and the server it was started on;
|
|
40
|
+
* `url` serves a lease written before cli-core 0.7.1, which has no `serverUrl`).
|
|
41
|
+
*/
|
|
42
|
+
export declare function godotSessionAdapter(url: string, token: string | undefined): EngineAdapter;
|
|
43
|
+
/** Build the session of a Godot project. Throws when `url` is not local. */
|
|
44
|
+
export declare function createGodotSession(options: GodotSessionOptions): GodotSession;
|
|
45
|
+
/** Injection points for tests. */
|
|
46
|
+
export interface EnsureEditorDeps {
|
|
47
|
+
ensure: (session: EditorSession<string>, mode: 'headless' | 'window') => Promise<EnsureResult<string>>;
|
|
48
|
+
build: (projectPath: string) => Promise<BuildProjectResult>;
|
|
49
|
+
}
|
|
50
|
+
export interface EnsureEditorOptions extends Omit<GodotSessionOptions, 'beforeLaunch'> {
|
|
51
|
+
/** Start the editor with a window instead of headless (only when none is running yet). */
|
|
52
|
+
window?: boolean;
|
|
53
|
+
/** Build the C# assembly before starting an editor. Default true. */
|
|
54
|
+
build?: boolean;
|
|
55
|
+
deps?: Partial<EnsureEditorDeps>;
|
|
56
|
+
}
|
|
57
|
+
export type EnsureEditorResult = {
|
|
58
|
+
kind: 'success';
|
|
59
|
+
success: true;
|
|
60
|
+
godot: GodotSession;
|
|
61
|
+
ensured: EnsureResult<string>;
|
|
62
|
+
} | {
|
|
63
|
+
kind: 'failure';
|
|
64
|
+
success: false;
|
|
65
|
+
/**
|
|
66
|
+
* `invalid-options`: e.g. a non-local URL; `build-failed`: the C# build before the start failed;
|
|
67
|
+
* `launch-failed`: no editor could be started; `not-ready`: its server never answered.
|
|
68
|
+
*/
|
|
69
|
+
reason: 'invalid-options' | 'build-failed' | 'launch-failed' | 'not-ready';
|
|
70
|
+
message: string;
|
|
71
|
+
error?: Error;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A ready editor of the project (the `exec` / `open --headless` policy): reuse a running one, otherwise build the
|
|
75
|
+
* C# assembly (Godot does not build it in a headless editor, and a missing assembly disables the addon) and start
|
|
76
|
+
* ours. The build runs under the session's startup lock, only when this call starts the editor: parallel cold calls
|
|
77
|
+
* build once and join that editor.
|
|
78
|
+
*/
|
|
79
|
+
export declare function ensureEditor(options: EnsureEditorOptions): Promise<EnsureEditorResult>;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Godot editor sessions on the shared cli-core EditorSession (Code-Exec plan §4.6): reuse any running editor of
|
|
2
|
+
// the project, otherwise start our own (headless by default) connected to the project's LOCAL MCP server, with a
|
|
3
|
+
// lease so only our own editor is ever closed. Library-safe: no console output, no `process.exit`.
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { EditorSession, EditorSessionError, godotAdapter, mcpReadinessProbe, } from '@baizor/gamedev-cli-core';
|
|
6
|
+
import { buildProject } from './build.js';
|
|
7
|
+
import { runSystemTool } from './run-tool.js';
|
|
8
|
+
import { findGodotBinary } from '../utils/godot-editor.js';
|
|
9
|
+
import { findGodotProcess } from '../utils/godot-process.js';
|
|
10
|
+
import { isLocalhostUrl } from '../utils/project-marker.js';
|
|
11
|
+
import { ENV_AUTH_OPTION, ENV_CONNECTION_MODE, ENV_HOST, ENV_START_SERVER, ENV_TOKEN, localProjectUrl, } from '../utils/connection.js';
|
|
12
|
+
/** The plugin's system tool that saves and quits a CLI-started editor (a windowless one gets no WM_CLOSE). */
|
|
13
|
+
export const SESSION_CLOSE_TOOL = 'session-close';
|
|
14
|
+
/** How long to wait for a user's own editor whose local server does not answer yet (it may still be loading). */
|
|
15
|
+
const FOREIGN_READY_TIMEOUT_MS = 60000;
|
|
16
|
+
/** The connection mode of an editor the session starts (a local server), in its env and its lease. */
|
|
17
|
+
const SESSION_CONNECTION_MODE = 'Custom';
|
|
18
|
+
/**
|
|
19
|
+
* Environment of an editor the session starts: Custom mode on the local URL, the plugin starts the local server
|
|
20
|
+
* (there is no dock button to press in a headless editor), and the token when one is given.
|
|
21
|
+
*/
|
|
22
|
+
export function sessionEditorEnv(url, token) {
|
|
23
|
+
return {
|
|
24
|
+
[ENV_CONNECTION_MODE]: SESSION_CONNECTION_MODE,
|
|
25
|
+
[ENV_HOST]: url,
|
|
26
|
+
[ENV_START_SERVER]: 'true',
|
|
27
|
+
...(token ? { [ENV_TOKEN]: token, [ENV_AUTH_OPTION]: 'Required' } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The Godot adapter with the CLI's hooks: running-editor detection (its pid, so the session notices when it exits)
|
|
32
|
+
* and the plugin-side graceful close through the verified lease (its nonce, and the server it was started on;
|
|
33
|
+
* `url` serves a lease written before cli-core 0.7.1, which has no `serverUrl`).
|
|
34
|
+
*/
|
|
35
|
+
export function godotSessionAdapter(url, token) {
|
|
36
|
+
return {
|
|
37
|
+
...godotAdapter,
|
|
38
|
+
editor: {
|
|
39
|
+
...godotAdapter.editor,
|
|
40
|
+
findRunningEditor: async (projectRoot) => findGodotProcess(projectRoot)?.pid ?? false,
|
|
41
|
+
requestClose: async (_pid, _projectRoot, lease) => {
|
|
42
|
+
if (lease === undefined)
|
|
43
|
+
return false;
|
|
44
|
+
const result = await runSystemTool({
|
|
45
|
+
toolName: SESSION_CLOSE_TOOL,
|
|
46
|
+
url: lease.serverUrl ?? url,
|
|
47
|
+
...(token ? { token } : {}),
|
|
48
|
+
input: { nonce: lease.nonce },
|
|
49
|
+
timeoutMs: 15000,
|
|
50
|
+
});
|
|
51
|
+
// A refusing tool (wrong nonce, an addon without session-close) answers 200 with status "error".
|
|
52
|
+
return result.kind === 'success' && result.data?.status !== 'error';
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function normalizeUrl(url) {
|
|
58
|
+
return url.replace(/\/+$/, '');
|
|
59
|
+
}
|
|
60
|
+
/** Build the session of a Godot project. Throws when `url` is not local. */
|
|
61
|
+
export function createGodotSession(options) {
|
|
62
|
+
const projectRoot = path.resolve(options.projectPath);
|
|
63
|
+
const url = normalizeUrl(options.url ?? localProjectUrl(projectRoot));
|
|
64
|
+
if (!isLocalhostUrl(url)) {
|
|
65
|
+
throw new Error(`editor sessions connect to a local server only; ${url} is not on this machine`);
|
|
66
|
+
}
|
|
67
|
+
const session = new EditorSession({
|
|
68
|
+
adapter: godotSessionAdapter(url, options.token),
|
|
69
|
+
projectRoot,
|
|
70
|
+
probeReady: mcpReadinessProbe({ urls: [url], ...(options.token ? { token: options.token } : {}) }),
|
|
71
|
+
editorBinary: () => {
|
|
72
|
+
const binary = findGodotBinary(options.editorPath);
|
|
73
|
+
if (!binary)
|
|
74
|
+
throw new Error('no Godot editor binary found (pass --editor-path or set GODOT_BIN)');
|
|
75
|
+
return binary;
|
|
76
|
+
},
|
|
77
|
+
env: sessionEditorEnv(url, options.token),
|
|
78
|
+
// The resolved, normalised connection the started editor gets (env above), recorded in the lease.
|
|
79
|
+
serverUrl: url,
|
|
80
|
+
connectionMode: SESSION_CONNECTION_MODE,
|
|
81
|
+
// The user's editor without a reachable local server: it may still be loading, but do not wait the full start budget.
|
|
82
|
+
foreignReadyTimeoutMs: Math.min(options.readyTimeoutMs ?? FOREIGN_READY_TIMEOUT_MS, FOREIGN_READY_TIMEOUT_MS),
|
|
83
|
+
...(options.beforeLaunch ? { beforeLaunch: options.beforeLaunch } : {}),
|
|
84
|
+
...(options.idleSeconds !== undefined ? { idleSeconds: options.idleSeconds } : {}),
|
|
85
|
+
...(options.readyTimeoutMs !== undefined ? { readyTimeoutMs: options.readyTimeoutMs } : {}),
|
|
86
|
+
...(options.onStatus ? { onStatus: options.onStatus } : {}),
|
|
87
|
+
...(options.processOps ? { processOps: options.processOps } : {}),
|
|
88
|
+
});
|
|
89
|
+
return { session, url };
|
|
90
|
+
}
|
|
91
|
+
/** The pre-launch C# build failed (thrown from `beforeLaunch`, which `ensure` propagates unchanged). */
|
|
92
|
+
class BuildFailedError extends Error {
|
|
93
|
+
constructor(buildError) {
|
|
94
|
+
super(buildError.message);
|
|
95
|
+
this.buildError = buildError;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A ready editor of the project (the `exec` / `open --headless` policy): reuse a running one, otherwise build the
|
|
100
|
+
* C# assembly (Godot does not build it in a headless editor, and a missing assembly disables the addon) and start
|
|
101
|
+
* ours. The build runs under the session's startup lock, only when this call starts the editor: parallel cold calls
|
|
102
|
+
* build once and join that editor.
|
|
103
|
+
*/
|
|
104
|
+
export async function ensureEditor(options) {
|
|
105
|
+
const deps = {
|
|
106
|
+
ensure: (session, mode) => session.ensure({ mode }),
|
|
107
|
+
build: (projectPath) => buildProject({ projectPath }),
|
|
108
|
+
...options.deps,
|
|
109
|
+
};
|
|
110
|
+
const fail = (reason, err, hint = '') => {
|
|
111
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
112
|
+
return { kind: 'failure', success: false, reason, message: error.message + hint, error };
|
|
113
|
+
};
|
|
114
|
+
const beforeLaunch = async (projectRoot) => {
|
|
115
|
+
options.onStatus?.('Building C# assembly...');
|
|
116
|
+
let built;
|
|
117
|
+
try {
|
|
118
|
+
built = await deps.build(projectRoot);
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
throw new BuildFailedError(err instanceof Error ? err : new Error(String(err)));
|
|
122
|
+
}
|
|
123
|
+
if (built.kind === 'failure')
|
|
124
|
+
throw new BuildFailedError(built.error);
|
|
125
|
+
};
|
|
126
|
+
const sessionOptions = { ...options, ...(options.build !== false ? { beforeLaunch } : {}) };
|
|
127
|
+
let godot;
|
|
128
|
+
try {
|
|
129
|
+
godot = createGodotSession(sessionOptions);
|
|
130
|
+
// Our editor of this project runs: talk to the server it was started on (it may differ from --url /
|
|
131
|
+
// GODOT_MCP_HOST). Only a lease cli-core verified live counts: a crashed editor's lease may name a port that
|
|
132
|
+
// another project's editor serves now.
|
|
133
|
+
const leasedUrl = (await godot.session.ownedSession())?.serverUrl;
|
|
134
|
+
if (leasedUrl !== undefined && isLocalhostUrl(leasedUrl) && normalizeUrl(leasedUrl) !== godot.url) {
|
|
135
|
+
godot = createGodotSession({ ...sessionOptions, url: leasedUrl });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
return fail('invalid-options', err);
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
return { kind: 'success', success: true, godot, ensured: await deps.ensure(godot.session, options.window ? 'window' : 'headless') };
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
if (err instanceof BuildFailedError)
|
|
146
|
+
return fail('build-failed', err.buildError);
|
|
147
|
+
const sessionError = err instanceof EditorSessionError ? err : undefined;
|
|
148
|
+
let hint = '';
|
|
149
|
+
if (sessionError?.reason === 'not-ready') {
|
|
150
|
+
if (sessionError.source === 'foreign') {
|
|
151
|
+
// Core's message says what is wrong; add only how to fix it in Godot.
|
|
152
|
+
hint = ` (Godot: in that editor's AI Game Developer dock choose Custom mode and start the server on ${godot.url})`;
|
|
153
|
+
}
|
|
154
|
+
else if (sessionError.source === 'started') {
|
|
155
|
+
// The editor this call started never answered (e.g. the addon failed to load): it would never idle out.
|
|
156
|
+
const closed = await godot.session.closeOwned({ timeoutMs: 5000, force: true });
|
|
157
|
+
hint = closed.kind === 'closed' ? ` (stopped the unresponsive editor, PID ${closed.pid}; see its log)` : '';
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// Another call's editor: that call may still be waiting for it, so it is not stopped here.
|
|
161
|
+
hint = ' (an editor started by another godot-cli call; `godot-cli close --owned-only --force` stops it)';
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const notReady = sessionError?.reason === 'exited' || sessionError?.reason === 'not-ready';
|
|
165
|
+
return fail(notReady ? 'not-ready' : 'launch-failed', err, hint);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/lib/session.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,iHAAiH;AACjH,mGAAmG;AAEnG,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,YAA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-1,4 +1,8 @@
|
|
|
1
1
|
export { openProject } from './lib/open.js';
|
|
2
|
+
export { execCode, readToolResponse, buildScriptExecuteInput, SCRIPT_EXECUTE_TOOL } from './lib/exec.js';
|
|
3
|
+
export type { ExecCodeOptions, ExecCodeResult, ExecCodeSuccess, ExecCodeFailure } from './lib/exec.js';
|
|
4
|
+
export { createGodotSession, ensureEditor, SESSION_CLOSE_TOOL } from './lib/session.js';
|
|
5
|
+
export type { GodotSession, GodotSessionOptions, EnsureEditorOptions, EnsureEditorResult } from './lib/session.js';
|
|
2
6
|
export { buildProject } from './lib/build.js';
|
|
3
7
|
export { createProject } from './lib/create-project.js';
|
|
4
8
|
export { runTool, runSystemTool } from './lib/run-tool.js';
|
package/dist/lib.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
// Consumers: `import { openProject } from 'godot-cli'` (maps to this file
|
|
14
14
|
// via the `exports` field in package.json).
|
|
15
15
|
export { openProject } from './lib/open.js';
|
|
16
|
+
export { execCode, readToolResponse, buildScriptExecuteInput, SCRIPT_EXECUTE_TOOL } from './lib/exec.js';
|
|
17
|
+
export { createGodotSession, ensureEditor, SESSION_CLOSE_TOOL } from './lib/session.js';
|
|
16
18
|
export { buildProject } from './lib/build.js';
|
|
17
19
|
export { createProject } from './lib/create-project.js';
|
|
18
20
|
export { runTool, runSystemTool } from './lib/run-tool.js';
|
package/dist/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,EAAE;AACF,eAAe;AACf,+EAA+E;AAC/E,wDAAwD;AACxD,oDAAoD;AACpD,yEAAyE;AACzE,4DAA4D;AAC5D,+EAA+E;AAC/E,gEAAgE;AAChE,6EAA6E;AAC7E,EAAE;AACF,0EAA0E;AAC1E,4CAA4C;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE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yB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,0FAA0F;AAC1F,yFAAyF;AACzF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -4,7 +4,18 @@ export interface AddonPackageReference {
|
|
|
4
4
|
id: string;
|
|
5
5
|
/** The pinned version (the `Version=` attribute). */
|
|
6
6
|
version: string;
|
|
7
|
+
/**
|
|
8
|
+
* Only editor (`#if TOOLS`) code uses the package: it is written with `EDITOR_ONLY_CONDITION`, so Godot's
|
|
9
|
+
* export builds leave it out (an exported game ships no RQL / Roslyn).
|
|
10
|
+
*/
|
|
11
|
+
editorOnly?: boolean;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* The MSBuild condition of an editor-only `<PackageReference>`: every configuration except Godot's two export
|
|
15
|
+
* builds (`ExportDebug` / `ExportRelease`, the ones without `TOOLS`). The Godot SDK applies the same rule to
|
|
16
|
+
* GodotSharpEditor. Godot-MCP.csproj marks its editor-only packages with this exact attribute.
|
|
17
|
+
*/
|
|
18
|
+
export declare const EDITOR_ONLY_CONDITION = "'$(Configuration)' != 'ExportDebug' and '$(Configuration)' != 'ExportRelease'";
|
|
8
19
|
/**
|
|
9
20
|
* A single `<EmbeddedResource>` the consumer csproj must declare so an asset the
|
|
10
21
|
* addon reads at editor runtime via `GetManifestResourceStream` is embedded into
|
|
@@ -21,7 +32,7 @@ export interface AddonEmbeddedResource {
|
|
|
21
32
|
/**
|
|
22
33
|
* The NuGet `PackageReference`s the addon of THIS CLI's version needs (fallback when
|
|
23
34
|
* the installed addon carries no `nuget-deps.json`), mirroring `Godot-MCP.csproj`.
|
|
24
|
-
* Order matches the addon csproj (ReflectorNet, McpPlugin, then
|
|
35
|
+
* Order matches the addon csproj (ReflectorNet, McpPlugin, Rql, then Code-Exec and its Roslyn).
|
|
25
36
|
*/
|
|
26
37
|
export declare const ADDON_PACKAGE_REFERENCES: readonly AddonPackageReference[];
|
|
27
38
|
/**
|
package/dist/utils/addon-deps.js
CHANGED
|
@@ -9,21 +9,33 @@
|
|
|
9
9
|
// addon zips that predate that manifest. They mirror the addon's own reused pins in
|
|
10
10
|
// `Godot-MCP.csproj` (`com.IvanMurzak.ReflectorNet`, `com.IvanMurzak.McpPlugin`) at
|
|
11
11
|
// this CLI's version — the SAME values, never a bump of those pins. `com.IvanMurzak.Rql` (the RQL data layer of
|
|
12
|
-
// the editor tools, PolyForm Shield 1.0.0) is a direct dependency of the addon sources since 1.0
|
|
12
|
+
// the editor tools, PolyForm Shield 1.0.0) is a direct dependency of the addon sources since 1.0; Code-Exec
|
|
13
|
+
// (`com.IvanMurzak.CodeExec` + the source-only `.Roslyn` adapter, compiled against the pinned
|
|
14
|
+
// `Microsoft.CodeAnalysis.CSharp`) runs `script-execute`. Those four are `editorOnly`: only `#if TOOLS` code
|
|
15
|
+
// uses them, so exported games ship neither RQL nor Roslyn. A parity test
|
|
13
16
|
// (`cli/tests/addon-deps-parity.test.ts`) reads `Godot-MCP.csproj` and FAILS the
|
|
14
17
|
// build if these constants ever drift from the addon's pins, so the scaffold can
|
|
15
18
|
// never silently install a mismatched version.
|
|
16
19
|
//
|
|
17
20
|
// No top-level side effects; pure data + pure string transforms only.
|
|
21
|
+
/**
|
|
22
|
+
* The MSBuild condition of an editor-only `<PackageReference>`: every configuration except Godot's two export
|
|
23
|
+
* builds (`ExportDebug` / `ExportRelease`, the ones without `TOOLS`). The Godot SDK applies the same rule to
|
|
24
|
+
* GodotSharpEditor. Godot-MCP.csproj marks its editor-only packages with this exact attribute.
|
|
25
|
+
*/
|
|
26
|
+
export const EDITOR_ONLY_CONDITION = "'$(Configuration)' != 'ExportDebug' and '$(Configuration)' != 'ExportRelease'";
|
|
18
27
|
/**
|
|
19
28
|
* The NuGet `PackageReference`s the addon of THIS CLI's version needs (fallback when
|
|
20
29
|
* the installed addon carries no `nuget-deps.json`), mirroring `Godot-MCP.csproj`.
|
|
21
|
-
* Order matches the addon csproj (ReflectorNet, McpPlugin, then
|
|
30
|
+
* Order matches the addon csproj (ReflectorNet, McpPlugin, Rql, then Code-Exec and its Roslyn).
|
|
22
31
|
*/
|
|
23
32
|
export const ADDON_PACKAGE_REFERENCES = [
|
|
24
33
|
{ id: 'com.IvanMurzak.ReflectorNet', version: '5.4.3' },
|
|
25
|
-
{ id: 'com.IvanMurzak.McpPlugin', version: '8.
|
|
26
|
-
{ id: 'com.IvanMurzak.Rql', version: '0.1.1' },
|
|
34
|
+
{ id: 'com.IvanMurzak.McpPlugin', version: '8.11.0' },
|
|
35
|
+
{ id: 'com.IvanMurzak.Rql', version: '0.1.1', editorOnly: true },
|
|
36
|
+
{ id: 'com.IvanMurzak.CodeExec', version: '0.2.1', editorOnly: true },
|
|
37
|
+
{ id: 'com.IvanMurzak.CodeExec.Roslyn', version: '0.2.1', editorOnly: true },
|
|
38
|
+
{ id: 'Microsoft.CodeAnalysis.CSharp', version: '4.12.0', editorOnly: true },
|
|
27
39
|
];
|
|
28
40
|
/**
|
|
29
41
|
* The exact `<EmbeddedResource>`s the consumer's project `.csproj` needs, single-sourced
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addon-deps.js","sourceRoot":"","sources":["../../src/utils/addon-deps.ts"],"names":[],"mappings":"AAAA,gFAAg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,WAAW,EAAE,mCAAmC;KACjD;CACO,CAAC;AAEX,wFAAwF;AACxF,MAAM,CAAC,MAAM,yBAAyB,GAAG,mCAAmC,CAAC"}
|
|
@@ -7,11 +7,15 @@ export interface ResolvedAddonNugetDeps {
|
|
|
7
7
|
file?: string;
|
|
8
8
|
warnings: string[];
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Every `<PackageReference Include=".." Version="..">` in a csproj text, in document order. A reference whose
|
|
12
|
+
* `Condition` is `EDITOR_ONLY_CONDITION` is editor-only.
|
|
13
|
+
*/
|
|
11
14
|
export declare function parseCsprojPackageReferences(csprojText: string): AddonPackageReference[];
|
|
12
15
|
/**
|
|
13
|
-
* Parse a `nuget-deps.json` manifest (`{ "packageReferences": [{ "id", "version" }] }`).
|
|
14
|
-
*
|
|
16
|
+
* Parse a `nuget-deps.json` manifest (`{ "packageReferences": [{ "id", "version", "editorOnly"? }] }`).
|
|
17
|
+
* Manifests that predate `editorOnly` mark nothing editor-only, which those addons need (their RQL sources
|
|
18
|
+
* compile into export builds). Throws on malformed JSON, a missing/empty list, or an invalid entry.
|
|
15
19
|
*/
|
|
16
20
|
export declare function parseAddonNugetDeps(text: string): AddonPackageReference[];
|
|
17
21
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import { ADDON_PACKAGE_REFERENCES } from './addon-deps.js';
|
|
3
|
+
import { ADDON_PACKAGE_REFERENCES, EDITOR_ONLY_CONDITION } from './addon-deps.js';
|
|
4
4
|
// Resolve the NuGet PackageReferences the INSTALLED addon needs, so `install-plugin`
|
|
5
5
|
// pins the consumer csproj to what that addon release was built against — not to the
|
|
6
6
|
// constants baked into this CLI build (they differ whenever the addon version differs
|
|
@@ -22,24 +22,28 @@ const ADDON_CSPROJ_FILE = 'Godot-MCP.csproj';
|
|
|
22
22
|
// NuGet-shaped ids and versions are accepted (no quotes, `<`, `&`, whitespace).
|
|
23
23
|
const NUGET_ID_RE = /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/;
|
|
24
24
|
const NUGET_VERSION_RE = /^[0-9A-Za-z][0-9A-Za-z.+-]*$/;
|
|
25
|
-
function validRef(id, version) {
|
|
25
|
+
function validRef(id, version, editorOnly) {
|
|
26
26
|
return typeof id === 'string' && typeof version === 'string' && NUGET_ID_RE.test(id) && NUGET_VERSION_RE.test(version)
|
|
27
|
-
? { id, version }
|
|
27
|
+
? { id, version, ...(editorOnly && { editorOnly }) }
|
|
28
28
|
: null;
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Every `<PackageReference Include=".." Version="..">` in a csproj text, in document order. A reference whose
|
|
32
|
+
* `Condition` is `EDITOR_ONLY_CONDITION` is editor-only.
|
|
33
|
+
*/
|
|
31
34
|
export function parseCsprojPackageReferences(csprojText) {
|
|
32
35
|
const refs = [];
|
|
33
36
|
for (const element of csprojText.match(/<PackageReference\b[^>]*>/gi) ?? []) {
|
|
34
|
-
const ref = validRef(/\bInclude\s*=\s*"([^"]+)"/i.exec(element)?.[1], /\bVersion\s*=\s*"([^"]+)"/i.exec(element)?.[1]);
|
|
37
|
+
const ref = validRef(/\bInclude\s*=\s*"([^"]+)"/i.exec(element)?.[1], /\bVersion\s*=\s*"([^"]+)"/i.exec(element)?.[1], /\bCondition\s*=\s*"([^"]*)"/i.exec(element)?.[1] === EDITOR_ONLY_CONDITION);
|
|
35
38
|
if (ref !== null)
|
|
36
39
|
refs.push(ref);
|
|
37
40
|
}
|
|
38
41
|
return refs;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
|
-
* Parse a `nuget-deps.json` manifest (`{ "packageReferences": [{ "id", "version" }] }`).
|
|
42
|
-
*
|
|
44
|
+
* Parse a `nuget-deps.json` manifest (`{ "packageReferences": [{ "id", "version", "editorOnly"? }] }`).
|
|
45
|
+
* Manifests that predate `editorOnly` mark nothing editor-only, which those addons need (their RQL sources
|
|
46
|
+
* compile into export builds). Throws on malformed JSON, a missing/empty list, or an invalid entry.
|
|
43
47
|
*/
|
|
44
48
|
export function parseAddonNugetDeps(text) {
|
|
45
49
|
const parsed = JSON.parse(text);
|
|
@@ -49,7 +53,7 @@ export function parseAddonNugetDeps(text) {
|
|
|
49
53
|
}
|
|
50
54
|
return list.map((entry, i) => {
|
|
51
55
|
const e = entry;
|
|
52
|
-
const ref = validRef(e?.id, e?.version);
|
|
56
|
+
const ref = validRef(e?.id, e?.version, e?.editorOnly === true);
|
|
53
57
|
if (ref === null)
|
|
54
58
|
throw new Error(`packageReferences[${i}] is not a valid { id, version } pair`);
|
|
55
59
|
return ref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addon-nuget-deps.js","sourceRoot":"","sources":["../../src/utils/addon-nuget-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAA8B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"addon-nuget-deps.js","sourceRoot":"","sources":["../../src/utils/addon-nuget-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAE9G,qFAAqF;AACrF,qFAAqF;AACrF,sFAAsF;AACtF,yEAAyE;AACzE,EAAE;AACF,qBAAqB;AACrB,sFAAsF;AACtF,2EAA2E;AAC3E,iFAAiF;AACjF,uFAAuF;AACvF,0DAA0D;AAC1D,oFAAoF;AACpF,yCAAyC;AAEzC,sEAAsE;AACtE,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AA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