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.
Files changed (167) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/README.md +139 -16
  3. package/dist/cli.d.ts +7 -0
  4. package/dist/cli.js +7 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/check.d.ts +2 -0
  7. package/dist/commands/check.js +48 -0
  8. package/dist/commands/check.js.map +1 -0
  9. package/dist/commands/close.d.ts +3 -0
  10. package/dist/commands/close.js +82 -27
  11. package/dist/commands/close.js.map +1 -1
  12. package/dist/commands/commands.d.ts +3 -0
  13. package/dist/commands/commands.js +28 -0
  14. package/dist/commands/commands.js.map +1 -0
  15. package/dist/commands/exec.js +43 -28
  16. package/dist/commands/exec.js.map +1 -1
  17. package/dist/commands/export.d.ts +2 -0
  18. package/dist/commands/export.js +45 -0
  19. package/dist/commands/export.js.map +1 -0
  20. package/dist/commands/headless-common.d.ts +29 -0
  21. package/dist/commands/headless-common.js +69 -0
  22. package/dist/commands/headless-common.js.map +1 -0
  23. package/dist/commands/import.d.ts +2 -0
  24. package/dist/commands/import.js +32 -0
  25. package/dist/commands/import.js.map +1 -0
  26. package/dist/commands/open.js +38 -6
  27. package/dist/commands/open.js.map +1 -1
  28. package/dist/commands/rql.d.ts +2 -0
  29. package/dist/commands/rql.js +81 -0
  30. package/dist/commands/rql.js.map +1 -0
  31. package/dist/commands/run-script.d.ts +2 -0
  32. package/dist/commands/run-script.js +33 -0
  33. package/dist/commands/run-script.js.map +1 -0
  34. package/dist/commands/run-system-tool.js +0 -1
  35. package/dist/commands/run-system-tool.js.map +1 -1
  36. package/dist/commands/run-tool-builder.d.ts +38 -4
  37. package/dist/commands/run-tool-builder.js +179 -56
  38. package/dist/commands/run-tool-builder.js.map +1 -1
  39. package/dist/commands/run-tool.js +0 -1
  40. package/dist/commands/run-tool.js.map +1 -1
  41. package/dist/commands/setup-skills.js +3 -2
  42. package/dist/commands/setup-skills.js.map +1 -1
  43. package/dist/commands/status.js +25 -19
  44. package/dist/commands/status.js.map +1 -1
  45. package/dist/commands/test.d.ts +5 -0
  46. package/dist/commands/test.js +111 -0
  47. package/dist/commands/test.js.map +1 -0
  48. package/dist/commands/tools.d.ts +2 -0
  49. package/dist/commands/tools.js +120 -0
  50. package/dist/commands/tools.js.map +1 -0
  51. package/dist/commands/update.js +1 -1
  52. package/dist/commands/update.js.map +1 -1
  53. package/dist/commands/wait-for-ready.js +18 -20
  54. package/dist/commands/wait-for-ready.js.map +1 -1
  55. package/dist/index.js +48 -3
  56. package/dist/index.js.map +1 -1
  57. package/dist/lib/build.d.ts +1 -1
  58. package/dist/lib/build.js +21 -4
  59. package/dist/lib/build.js.map +1 -1
  60. package/dist/lib/check.d.ts +44 -0
  61. package/dist/lib/check.js +191 -0
  62. package/dist/lib/check.js.map +1 -0
  63. package/dist/lib/cli-guide.d.ts +26 -0
  64. package/dist/lib/cli-guide.js +51 -0
  65. package/dist/lib/cli-guide.js.map +1 -0
  66. package/dist/lib/exec.d.ts +19 -0
  67. package/dist/lib/exec.js +61 -10
  68. package/dist/lib/exec.js.map +1 -1
  69. package/dist/lib/export-project.d.ts +41 -0
  70. package/dist/lib/export-project.js +159 -0
  71. package/dist/lib/export-project.js.map +1 -0
  72. package/dist/lib/godot-log.d.ts +38 -0
  73. package/dist/lib/godot-log.js +145 -0
  74. package/dist/lib/godot-log.js.map +1 -0
  75. package/dist/lib/godot-run.d.ts +34 -0
  76. package/dist/lib/godot-run.js +113 -0
  77. package/dist/lib/godot-run.js.map +1 -0
  78. package/dist/lib/headless.d.ts +82 -0
  79. package/dist/lib/headless.js +117 -0
  80. package/dist/lib/headless.js.map +1 -0
  81. package/dist/lib/import-project.d.ts +9 -0
  82. package/dist/lib/import-project.js +15 -0
  83. package/dist/lib/import-project.js.map +1 -0
  84. package/dist/lib/junit.d.ts +36 -0
  85. package/dist/lib/junit.js +146 -0
  86. package/dist/lib/junit.js.map +1 -0
  87. package/dist/lib/list-tools.d.ts +51 -0
  88. package/dist/lib/list-tools.js +147 -0
  89. package/dist/lib/list-tools.js.map +1 -0
  90. package/dist/lib/open.js +3 -1
  91. package/dist/lib/open.js.map +1 -1
  92. package/dist/lib/progress.d.ts +1 -7
  93. package/dist/lib/progress.js +2 -15
  94. package/dist/lib/progress.js.map +1 -1
  95. package/dist/lib/rql.d.ts +32 -0
  96. package/dist/lib/rql.js +105 -0
  97. package/dist/lib/rql.js.map +1 -0
  98. package/dist/lib/run-script.d.ts +23 -0
  99. package/dist/lib/run-script.js +43 -0
  100. package/dist/lib/run-script.js.map +1 -0
  101. package/dist/lib/run-tests.d.ts +50 -0
  102. package/dist/lib/run-tests.js +181 -0
  103. package/dist/lib/run-tests.js.map +1 -0
  104. package/dist/lib/run-tool.js +6 -22
  105. package/dist/lib/run-tool.js.map +1 -1
  106. package/dist/lib/session.d.ts +8 -1
  107. package/dist/lib/session.js +36 -4
  108. package/dist/lib/session.js.map +1 -1
  109. package/dist/lib/setup-skills.d.ts +8 -13
  110. package/dist/lib/setup-skills.js +27 -24
  111. package/dist/lib/setup-skills.js.map +1 -1
  112. package/dist/lib/types.d.ts +7 -0
  113. package/dist/lib/update-project.js +1 -1
  114. package/dist/lib/update-project.js.map +1 -1
  115. package/dist/lib.d.ts +16 -0
  116. package/dist/lib.js +10 -0
  117. package/dist/lib.js.map +1 -1
  118. package/dist/utils/addon-deps.js +2 -2
  119. package/dist/utils/agents.d.ts +2 -6
  120. package/dist/utils/agents.js.map +1 -1
  121. package/dist/utils/connection.d.ts +59 -0
  122. package/dist/utils/connection.js +11 -10
  123. package/dist/utils/connection.js.map +1 -1
  124. package/dist/utils/csproj-deps.js +1 -1
  125. package/dist/utils/csproj-deps.js.map +1 -1
  126. package/dist/utils/editor-connection.d.ts +74 -0
  127. package/dist/utils/editor-connection.js +225 -0
  128. package/dist/utils/editor-connection.js.map +1 -0
  129. package/dist/utils/editor-mcp-server.d.ts +32 -0
  130. package/dist/utils/editor-mcp-server.js +134 -0
  131. package/dist/utils/editor-mcp-server.js.map +1 -0
  132. package/dist/utils/exit-codes.d.ts +2 -0
  133. package/dist/utils/exit-codes.js +4 -0
  134. package/dist/utils/exit-codes.js.map +1 -0
  135. package/dist/utils/godot-process.d.ts +5 -0
  136. package/dist/utils/godot-process.js +16 -0
  137. package/dist/utils/godot-process.js.map +1 -1
  138. package/dist/utils/godot-shutdown.d.ts +3 -1
  139. package/dist/utils/godot-shutdown.js +4 -2
  140. package/dist/utils/godot-shutdown.js.map +1 -1
  141. package/dist/utils/input.d.ts +3 -3
  142. package/dist/utils/input.js +22 -35
  143. package/dist/utils/input.js.map +1 -1
  144. package/dist/utils/output.d.ts +45 -0
  145. package/dist/utils/output.js +101 -0
  146. package/dist/utils/output.js.map +1 -0
  147. package/dist/utils/server-source.d.ts +1 -1
  148. package/dist/utils/server-source.js +1 -1
  149. package/dist/utils/skill-guides.d.ts +6 -9
  150. package/dist/utils/skill-guides.js +100 -43
  151. package/dist/utils/skill-guides.js.map +1 -1
  152. package/dist/utils/skills.d.ts +1 -14
  153. package/dist/utils/skills.js +0 -89
  154. package/dist/utils/skills.js.map +1 -1
  155. package/dist/utils/ui.d.ts +6 -1
  156. package/dist/utils/ui.js +72 -58
  157. package/dist/utils/ui.js.map +1 -1
  158. package/dist/utils/update-check.d.ts +6 -17
  159. package/dist/utils/update-check.js +10 -77
  160. package/dist/utils/update-check.js.map +1 -1
  161. package/package.json +2 -2
  162. package/dist/utils/json-parse.d.ts +0 -25
  163. package/dist/utils/json-parse.js +0 -83
  164. package/dist/utils/json-parse.js.map +0 -1
  165. package/dist/utils/semver.d.ts +0 -4
  166. package/dist/utils/semver.js +0 -25
  167. package/dist/utils/semver.js.map +0 -1
@@ -0,0 +1,191 @@
1
+ // `checkProject`: a CI gate without a running editor. Four separate processes (a cold single-process
2
+ // `--build-solutions --quit` SIGSEGVs on C# [Tool] plugins, godot #81790 / #100805):
3
+ // 1. `--headless --import` materialise .godot/ (global class cache)
4
+ // 2. `dotnet build` (C# projects) compiler errors with file(line,col)
5
+ // 3. `--headless --editor --quit` the editor boots; the Godot-MCP addon must print its load marker
6
+ // 4. `--headless -s <checker>` load every GDScript, report parse errors with res://file:line
7
+ // The verdict comes from the logs and markers, never from Godot's exit code. Library-safe.
8
+ import * as fs from 'fs';
9
+ import * as path from 'path';
10
+ import { buildProject, findProjectCsproj } from './build.js';
11
+ import { GODOT_MCP_PLUGIN_PATH, parseEnabledPlugins, projectGodotPath } from '../utils/project-godot.js';
12
+ import { ADDON_LOADED_MARKER, cliMarkerLines, parseGodotLog, parseMsbuildOutput, } from './godot-log.js';
13
+ import { engineRan, headlessFailure, stoppedRun, prepareHeadless, remainingMs, runGodotStep, runImportStep, writeCliScript, } from './headless.js';
14
+ /** Loads every `.gd` under res:// (addons only with --include-addons) and prints one marker per failing file. */
15
+ export const CHECK_SCRIPT = `extends SceneTree
16
+ # Written by godot-cli check. Loads every GDScript and prints a [godot-cli] marker per failure.
17
+
18
+ const MARK := "[godot-cli] "
19
+ const WARN_PREFIX := "debug/gdscript/warnings/"
20
+
21
+ func _walk(dir: String, out: Array, include_addons: bool) -> void:
22
+ \tvar d := DirAccess.open(dir)
23
+ \tif d == null:
24
+ \t\treturn
25
+ \td.list_dir_begin()
26
+ \tvar name := d.get_next()
27
+ \twhile name != "":
28
+ \t\tvar p := dir.path_join(name)
29
+ \t\tif name.begins_with("."):
30
+ \t\t\tpass
31
+ \t\telif d.current_is_dir() and FileAccess.file_exists(p.path_join(".gdignore")):
32
+ \t\t\tpass # Godot skips a folder with a .gdignore
33
+ \t\telif d.current_is_dir():
34
+ \t\t\tif include_addons or p != "res://addons":
35
+ \t\t\t\t_walk(p, out, include_addons)
36
+ \t\telif name.get_extension() == "gd":
37
+ \t\t\tout.append(p)
38
+ \t\tname = d.get_next()
39
+
40
+ func _load_ok(path: String) -> bool:
41
+ \tvar s = ResourceLoader.load(path, "", ResourceLoader.CACHE_MODE_IGNORE)
42
+ \tif s == null or not (s is Script):
43
+ \t\treturn false
44
+ \t# An @abstract script (4.5+) loads fine but cannot be instantiated.
45
+ \treturn s.can_instantiate() or (s.has_method("is_abstract") and s.is_abstract())
46
+
47
+ func _init() -> void:
48
+ \tvar args := OS.get_cmdline_user_args()
49
+ \tvar strict := args.has("--strict")
50
+ \tvar files: Array = []
51
+ \t_walk("res://", files, args.has("--include-addons"))
52
+ \tvar clean: Array = []
53
+ \tvar failed := 0
54
+ \tfor f in files:
55
+ \t\tif _load_ok(f):
56
+ \t\t\tclean.append(f)
57
+ \t\telse:
58
+ \t\t\tfailed += 1
59
+ \t\t\tprint(MARK + "script-failed " + f)
60
+ \tvar warned := 0
61
+ \tif strict and clean.size() > 0:
62
+ \t\t# GDScript warnings only show in the script editor: raise the Warn-level ones to Error in memory (never saved).
63
+ \t\tfor prop in ProjectSettings.get_property_list():
64
+ \t\t\tvar n: String = prop["name"]
65
+ \t\t\tif n.begins_with(WARN_PREFIX) and typeof(ProjectSettings.get_setting(n)) == TYPE_INT and ProjectSettings.get_setting(n) == 1:
66
+ \t\t\t\tProjectSettings.set_setting(n, 2)
67
+ \t\tprint(MARK + "warnings-pass")
68
+ \t\tfor f in clean:
69
+ \t\t\tif not _load_ok(f):
70
+ \t\t\t\twarned += 1
71
+ \t\t\t\tprint(MARK + "script-warned " + f)
72
+ \tprint(MARK + "check-done files=%d failed=%d warned=%d" % [files.size(), failed, warned])
73
+ \tquit(1 if failed > 0 else 0)
74
+ `;
75
+ /** True when project.godot enables the Godot-MCP addon. */
76
+ export function isAddonEnabled(projectPath) {
77
+ try {
78
+ return parseEnabledPlugins(fs.readFileSync(projectGodotPath(projectPath), 'utf-8')).includes(GODOT_MCP_PLUGIN_PATH)
79
+ && fs.existsSync(path.join(projectPath, 'addons', 'godot_mcp', 'plugin.cfg'));
80
+ }
81
+ catch {
82
+ return false;
83
+ }
84
+ }
85
+ export async function checkProject(options) {
86
+ const prepared = prepareHeadless(options);
87
+ if (prepared.kind === 'failure')
88
+ return prepared;
89
+ const ctx = prepared;
90
+ const progress = options.onProgress ?? (() => undefined);
91
+ const diagnostics = [];
92
+ const engineMessages = [];
93
+ const addon = { enabled: isAddonEnabled(ctx.projectPath), loaded: null };
94
+ let gdscript = null;
95
+ let csharp = null;
96
+ const report = () => ({ projectPath: ctx.projectPath, steps: ctx.steps, diagnostics, engineMessages, addon, gdscript, csharp });
97
+ const fail = (failure) => ({ ...failure, ...report() });
98
+ const collect = (list) => {
99
+ for (const d of list)
100
+ (d.source === 'engine' ? engineMessages : diagnostics).push(d);
101
+ };
102
+ // 1. Import.
103
+ progress('Importing the project (godot --headless --import)...');
104
+ const imported = await runImportStep(ctx);
105
+ // Informational only: the import runs before the C# build (a fresh checkout's C# plugin fails to load here), and
106
+ // the GDScript pass below reports every script error again with its line.
107
+ engineMessages.push(...imported.diagnostics);
108
+ if (imported.failure && imported.failure.reason !== 'script-errors')
109
+ return fail(imported.failure);
110
+ // 2. C# build.
111
+ let compileFailed = false;
112
+ if (findProjectCsproj(ctx.projectPath, []) !== null) {
113
+ progress('Building C# (dotnet build)...');
114
+ const started = Date.now();
115
+ const built = await (options.build ?? ((p, timeoutMs) => buildProject({ projectPath: p, timeoutMs })))(ctx.projectPath, remainingMs(ctx));
116
+ const output = built.kind === 'success' ? built.output ?? '' : built.errorMessage;
117
+ ctx.steps.push({ name: 'dotnet-build', command: ['dotnet', 'build'], exitCode: built.kind === 'success' ? 0 : 1, timedOut: false, durationMs: Date.now() - started });
118
+ const compiler = parseMsbuildOutput(output);
119
+ diagnostics.push(...compiler);
120
+ compileFailed = built.kind === 'failure';
121
+ if (compileFailed && !compiler.some((d) => d.severity === 'error')) {
122
+ diagnostics.push({ severity: 'error', source: 'csharp', message: output.split(/\r?\n/)[0] });
123
+ }
124
+ csharp = { built: !compileFailed, skipped: false };
125
+ if (remainingMs(ctx) <= 0)
126
+ return fail(headlessFailure('timeout', 'The check timed out during the C# build.'));
127
+ }
128
+ else {
129
+ csharp = { built: false, skipped: true };
130
+ }
131
+ // 3. Editor boot (skipped when C# does not compile: every C# script, the addon included, would fail to load).
132
+ if (!compileFailed) {
133
+ progress('Booting the editor (godot --headless --editor --quit)...');
134
+ const editor = await runGodotStep(ctx, 'editor', ['--editor', '--quit']);
135
+ const editorStopped = stoppedRun(editor, 'The editor boot');
136
+ if (editorStopped)
137
+ return fail(editorStopped);
138
+ if (!engineRan(editor))
139
+ return fail(headlessFailure('script-errors', `The editor did not start (exit ${editor.exitCode}).`));
140
+ collect(parseGodotLog(editor.output));
141
+ if (addon.enabled) {
142
+ addon.loaded = editor.output.includes(ADDON_LOADED_MARKER);
143
+ if (!addon.loaded) {
144
+ diagnostics.push({ severity: 'error', source: 'gdscript', file: GODOT_MCP_PLUGIN_PATH, message: `The Godot-MCP addon did not load (no "${ADDON_LOADED_MARKER}" line in the editor log).` });
145
+ }
146
+ }
147
+ }
148
+ // 4. GDScript load check.
149
+ progress('Checking GDScript (godot --headless -s)...');
150
+ const script = writeCliScript(ctx, 'check.gd', CHECK_SCRIPT);
151
+ const userArgs = [...(options.strict ? ['--strict'] : []), ...(options.includeAddons ? ['--include-addons'] : [])];
152
+ const checked = await runGodotStep(ctx, 'gdscript', ['-s', script, ...(userArgs.length > 0 ? ['--', ...userArgs] : [])]);
153
+ const checkStopped = stoppedRun(checked, 'The GDScript check');
154
+ if (checkStopped)
155
+ return fail(checkStopped);
156
+ const markers = cliMarkerLines(checked.output);
157
+ const done = markers.map((m) => /^check-done files=(\d+) failed=(\d+) warned=(\d+)/.exec(m)).find((m) => m !== null);
158
+ if (!engineRan(checked) || !done) {
159
+ diagnostics.push({ severity: 'error', source: 'gdscript', message: `The GDScript check did not finish (exit ${checked.exitCode}, no check-done marker).` });
160
+ }
161
+ else {
162
+ gdscript = { files: Number(done[1]), failed: Number(done[2]), warned: Number(done[3]) };
163
+ }
164
+ // The checker's own frames ("at: _load_ok (res://.godot/godot-cli/check.gd)") never name the failing script.
165
+ collect(parseGodotLog(checked.output).filter((d) => !d.file?.startsWith('res://.godot/')));
166
+ for (const marker of markers) {
167
+ const failed = /^script-failed (\S+)/.exec(marker);
168
+ if (failed && !diagnostics.some((d) => d.file === failed[1] && d.severity === 'error')) {
169
+ diagnostics.push({ severity: 'error', source: 'gdscript', file: failed[1], message: 'The script failed to load.' });
170
+ }
171
+ }
172
+ const failing = failingDiagnostics(diagnostics, options.strict === true);
173
+ const errors = failing.filter((d) => d.severity === 'error');
174
+ const compileErrors = errors.filter((d) => d.source === 'csharp').length;
175
+ if (compileErrors > 0)
176
+ return fail(headlessFailure('compilation-failed', `C# compilation failed with ${compileErrors} error(s).`));
177
+ if (errors.length > 0)
178
+ return fail(headlessFailure('script-errors', `${errors.length} script error(s).`));
179
+ if (failing.length > 0)
180
+ return fail(headlessFailure('script-errors', `${failing.length} warning(s) (--strict).`));
181
+ return { kind: 'success', success: true, ...report() };
182
+ }
183
+ /**
184
+ * The diagnostics that fail a check: every error, plus with `strict` the GDScript warnings and C# compiler (CS)
185
+ * warnings (package and engine warnings never).
186
+ */
187
+ export function failingDiagnostics(diagnostics, strict) {
188
+ return diagnostics.filter((d) => d.severity === 'error'
189
+ || (strict && (d.source === 'gdscript' || (d.source === 'csharp' && /^CS\d+$/.test(d.code ?? '')))));
190
+ }
191
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/lib/check.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,qFAAqF;AACrF,iFAAiF;AACjF,4EAA4E;AAC5E,yGAAyG;AACzG,sGAAsG;AACtG,2FAA2F;AAE3F,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;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AAQ,CAAC,CAAC,MAAM,CAAC;IACzE,IAAI,aAAa,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE,8BAA8B,aAAa,YAAY,CAAC,CAAC,CAAC;IACnI,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,mBAAmB,CAAC,CAAC,CAAC;IAC1G,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,GAAG,OAAO,CAAC,MAAM,yBAAyB,CAAC,CAAC,CAAC;IAClH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAyB,EAAE,MAAe;IAC3E,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO;WAClD,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzG,CAAC"}
@@ -0,0 +1,26 @@
1
+ /** RQL recipes: [query, what it does]. */
2
+ export type RqlRecipes = ReadonlyArray<readonly [string, string]>;
3
+ /** A featured command: [name, usage, what it does]. */
4
+ export type CommandRow = readonly [string, string, string];
5
+ /** The CLI's command name. */
6
+ export declare const CLI_NAME = "godot-cli";
7
+ /** The recipes `rql --help` and the skill show; the root help shows the first {@link ROOT_RQL_RECIPES}. */
8
+ export declare const RQL_RECIPES: RqlRecipes;
9
+ /** How many recipes the root help shows. */
10
+ export declare const ROOT_RQL_RECIPES = 7;
11
+ /** The RQL language in two lines (`rql --help`, the skill's RQL reference). */
12
+ export declare const RQL_LANGUAGE: string[];
13
+ /** The editor commands the root help and the skill feature. */
14
+ export declare const EDITOR_COMMANDS: readonly CommandRow[];
15
+ /** The code commands (no editor needed). */
16
+ export declare const CODE_COMMANDS: readonly CommandRow[];
17
+ /** How an editor command gets its editor (the root help's heading). */
18
+ export declare const EDITOR_START = "the first call starts a headless editor and keeps it warm; no open / status needed";
19
+ /** Where the addon lives in a project: absent means `install-plugin` comes first. */
20
+ export declare const PLUGIN_FOLDER = "addons/godot_mcp";
21
+ /**
22
+ * The rules an agent needs beyond the recipes (the skill's list). Each answers a stumble seen in agent transcripts.
23
+ * Kept terse: the agent re-reads every byte of the skill on every later turn, and a rule worded as a warning invites
24
+ * extra checks.
25
+ */
26
+ export declare const RQL_RULES: string[];
@@ -0,0 +1,51 @@
1
+ // The one source of the agent-facing usage text: the root --help, `rql --help` and the `godot-cli` agent skill
2
+ // (`setup-skills`) all render from these constants, so the three cannot drift apart.
3
+ // Example names stay neutral (forest, cave, Lamp, Tree, Rock, Enemy): never a name a test or evaluation task uses.
4
+ /** The CLI's command name. */
5
+ export const CLI_NAME = 'godot-cli';
6
+ /** The recipes `rql --help` and the skill show; the root help shows the first {@link ROOT_RQL_RECIPES}. */
7
+ export const RQL_RECIPES = [
8
+ ['editor | call OpenScene("res://scenes/forest.tscn")', 'open a scene (writes no file): nodes lists the EDITED scene only'],
9
+ ['editor | call NewScene("res://scenes/cave.tscn", "Node2D", "Cave")', 'create, save and open a scene (path, root class, root name)'],
10
+ ['editor | call CreateNode("OmniLight3D", {name: "Lamp", position: [1, 3, 0]})', 'a new node under the scene root (meters, Y up)'],
11
+ ['nodes | where name starts-with "Tree" | select name class Position', 'read'],
12
+ ['nodes | where name contains "Enemy" | count', 'count'],
13
+ ['nodes | where name starts-with "Rock" | set Scale = Scale * 1.5', 'change (vectors compute per axis)'],
14
+ ['editor | call SaveScene()', 'write the edited scene to its .tscn; prints the files written'],
15
+ ['nodes | where name == "Old" | call Free()', 'delete'],
16
+ ['godot.resources("StandardMaterial3D") | select path props["albedo_color"]', 'resources of a class'],
17
+ ['nodes | where name == "Lamp" | set props["light_energy"] = 2', 'a Godot property or exported script variable by name: props["..."]'],
18
+ ];
19
+ /** How many recipes the root help shows. */
20
+ export const ROOT_RQL_RECIPES = 7;
21
+ /** The RQL language in two lines (`rql --help`, the skill's RQL reference). */
22
+ export const RQL_LANGUAGE = [
23
+ 'Stages: where, select a b, sort x [desc], first N, count, get <member>, set a = expr, call Method(args).',
24
+ 'Operators: == != < <= > >= and or not, contains, starts-with, ends-with, x in [a, b], $ is Node3D.',
25
+ ];
26
+ /** The editor commands the root help and the skill feature. */
27
+ export const EDITOR_COMMANDS = [
28
+ ['rql', "rql '<query>'", 'read or change scenes, nodes, resources (RQL; recipes below)'],
29
+ ['exec', "exec '<C#>'", 'C# in the editor'],
30
+ ['tools', 'tools [name]', "the editor's AI tools, or one in detail; run-tool <name> --input '<json>' calls one"],
31
+ ];
32
+ /** The code commands (no editor needed). */
33
+ export const CODE_COMMANDS = [
34
+ ['check', 'check', 'GDScript and C# errors (file:line), no editor needed'],
35
+ ['test', 'test', 'run GUT / gdUnit4 tests'],
36
+ ];
37
+ /** How an editor command gets its editor (the root help's heading). */
38
+ export const EDITOR_START = 'the first call starts a headless editor and keeps it warm; no open / status needed';
39
+ /** Where the addon lives in a project: absent means `install-plugin` comes first. */
40
+ export const PLUGIN_FOLDER = 'addons/godot_mcp';
41
+ /**
42
+ * The rules an agent needs beyond the recipes (the skill's list). Each answers a stumble seen in agent transcripts.
43
+ * Kept terse: the agent re-reads every byte of the skill on every later turn, and a rule worded as a warning invites
44
+ * extra checks.
45
+ */
46
+ export const RQL_RULES = [
47
+ '`nodes` lists only the edited scene (OpenScene first). Scene edits stay unsaved until `SaveScene()`; `NewScene` saves itself.',
48
+ 'The output of `set` / `call` lists each change (old, new) and the files saved: that is the check, no re-read needed.',
49
+ 'A wrong source or member fails with the valid names.',
50
+ ];
51
+ //# sourceMappingURL=cli-guide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-guide.js","sourceRoot":"","sources":["../../src/lib/cli-guide.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,qFAAqF;AACrF,mHAAmH;AAOnH,8BAA8B;AAC9B,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAEpC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,WAAW,GAAe;IACrC,CAAC,qDAAqD,EAAE,kEAAkE,CAAC;IAC3H,CAAC,oEAAoE,EAAE,6DAA6D,CAAC;IACrI,CAAC,8EAA8E,EAAE,gDAAgD,CAAC;IAClI,CAAC,oEAAoE,EAAE,MAAM,CAAC;IAC9E,CAAC,6CAA6C,EAAE,OAAO,CAAC;IACxD,CAAC,iEAAiE,EAAE,mCAAmC,CAAC;IACxG,CAAC,2BAA2B,EAAE,+DAA+D,CAAC;IAC9F,CAAC,2CAA2C,EAAE,QAAQ,CAAC;IACvD,CAAC,2EAA2E,EAAE,sBAAsB,CAAC;IACrG,CAAC,8DAA8D,EAAE,oEAAoE,CAAC;CACvI,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,0GAA0G;IAC1G,oGAAoG;CACrG,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,eAAe,GAA0B;IACpD,CAAC,KAAK,EAAE,eAAe,EAAE,8DAA8D,CAAC;IACxF,CAAC,MAAM,EAAE,aAAa,EAAE,kBAAkB,CAAC;IAC3C,CAAC,OAAO,EAAE,cAAc,EAAE,qFAAqF,CAAC;CACjH,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,aAAa,GAA0B;IAClD,CAAC,OAAO,EAAE,OAAO,EAAE,sDAAsD,CAAC;IAC1E,CAAC,MAAM,EAAE,MAAM,EAAE,yBAAyB,CAAC;CAC5C,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG,oFAAoF,CAAC;AAEjH,qFAAqF;AACrF,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,+HAA+H;IAC/H,sHAAsH;IACtH,sDAAsD;CACvD,CAAC"}
@@ -13,6 +13,11 @@ export interface ExecDeps extends EnsureEditorDeps {
13
13
  invoke: (options: RunToolOptions) => Promise<RunToolResult>;
14
14
  }
15
15
  export interface ExecCodeOptions extends EnsureEditorOptions {
16
+ /**
17
+ * Run on this server as is, starting no editor (Cloud mode: the ai-game.dev hub, where only an editor the user
18
+ * connected answers).
19
+ */
20
+ remoteUrl?: string;
16
21
  code: string;
17
22
  usings?: string[];
18
23
  include?: string[];
@@ -37,6 +42,10 @@ export interface ExecCodeFailure {
37
42
  reason: Extract<EnsureEditorResult, {
38
43
  kind: 'failure';
39
44
  }>['reason'] | 'tool-failed';
45
+ /** {@link ensureEditor}'s session reason, when the editor session failed. */
46
+ sessionReason?: Extract<EnsureEditorResult, {
47
+ kind: 'failure';
48
+ }>['sessionReason'];
40
49
  /** The server that was called (`tool-failed` only). */
41
50
  baseUrl?: string;
42
51
  /** The underlying call failure (`tool-failed` only). */
@@ -53,6 +62,16 @@ export type ExecCodeResult = ExecCodeSuccess | ExecCodeFailure;
53
62
  export declare function execCode(options: ExecCodeOptions): Promise<ExecCodeResult>;
54
63
  /** Request body for `script-execute`; empty lists are left out. */
55
64
  export declare function buildScriptExecuteInput(code: string, usings: string[], include: string[]): Record<string, unknown>;
65
+ /**
66
+ * The text of a tool answer whose content is all text blocks, joined; `undefined` for any other answer (an image, no
67
+ * content), which keeps its JSON.
68
+ */
69
+ export declare function toolResponseText(data: unknown): string | undefined;
70
+ /**
71
+ * A tool answer for the text-mode JSON print: each image or audio block's base64 `data` (a screenshot is megabytes) is
72
+ * replaced by a note naming its size; everything else is kept. `--format json` / `--raw` keep the data. Pure.
73
+ */
74
+ export declare function withoutImageData(data: unknown): unknown;
56
75
  /** The tool's own error text when the server reports one (`{ error }` / text content), else the call failure. */
57
76
  export declare function toolErrorText(failure: RunToolFailure): string;
58
77
  /**
package/dist/lib/exec.js CHANGED
@@ -15,12 +15,20 @@ export const DEFAULT_EXEC_TIMEOUT_MS = 310000;
15
15
  * tool calls, so the next call stays warm.
16
16
  */
17
17
  export async function execCode(options) {
18
- const editor = await ensureEditor(options);
19
- if (editor.kind === 'failure')
20
- return editor;
21
- const { ensured } = editor;
18
+ let baseUrl;
19
+ let source;
20
+ if (options.remoteUrl) {
21
+ baseUrl = options.remoteUrl;
22
+ source = 'foreign';
23
+ }
24
+ else {
25
+ const editor = await ensureEditor(options);
26
+ if (editor.kind === 'failure')
27
+ return editor;
28
+ baseUrl = editor.ensured.ready;
29
+ source = editor.ensured.source;
30
+ }
22
31
  options.onStatus?.('Running...');
23
- const baseUrl = ensured.ready;
24
32
  const result = await (options.deps?.invoke ?? runTool)({
25
33
  toolName: SCRIPT_EXECUTE_TOOL,
26
34
  url: baseUrl,
@@ -31,7 +39,7 @@ export async function execCode(options) {
31
39
  if (result.kind === 'failure') {
32
40
  return { kind: 'failure', success: false, reason: 'tool-failed', baseUrl, toolFailure: result, message: toolErrorText(result), error: result.error };
33
41
  }
34
- return { kind: 'success', success: true, baseUrl, editor: ensured.source, data: result.data };
42
+ return { kind: 'success', success: true, baseUrl, editor: source, data: result.data };
35
43
  }
36
44
  /** Request body for `script-execute`; empty lists are left out. */
37
45
  export function buildScriptExecuteInput(code, usings, include) {
@@ -41,13 +49,56 @@ export function buildScriptExecuteInput(code, usings, include) {
41
49
  ...(include.length > 0 ? { include } : {}),
42
50
  };
43
51
  }
52
+ /** The text blocks of a tool answer's `content`, and how many blocks it has in all. */
53
+ function textBlocks(data) {
54
+ const content = data?.content;
55
+ const blocks = Array.isArray(content) ? content : [];
56
+ return { texts: blocks.filter((c) => c?.type === 'text' && typeof c.text === 'string').map((c) => c.text), blocks: blocks.length };
57
+ }
58
+ /**
59
+ * The text of a tool answer whose content is all text blocks, joined; `undefined` for any other answer (an image, no
60
+ * content), which keeps its JSON.
61
+ */
62
+ export function toolResponseText(data) {
63
+ const { texts, blocks } = textBlocks(data);
64
+ return texts.length > 0 && texts.length === blocks ? texts.join('\n') : undefined;
65
+ }
66
+ /**
67
+ * A tool answer for the text-mode JSON print: each image or audio block's base64 `data` (a screenshot is megabytes) is
68
+ * replaced by a note naming its size; everything else is kept. `--format json` / `--raw` keep the data. Pure.
69
+ */
70
+ export function withoutImageData(data) {
71
+ const content = data?.content;
72
+ if (!Array.isArray(content))
73
+ return data;
74
+ return {
75
+ ...data,
76
+ content: content.map((block) => (block?.type === 'image' || block?.type === 'audio') && typeof block.data === 'string'
77
+ ? { ...block, data: `<${block.data.length} base64 chars omitted: --format json keeps them>` }
78
+ : block),
79
+ };
80
+ }
44
81
  /** The tool's own error text when the server reports one (`{ error }` / text content), else the call failure. */
45
82
  export function toolErrorText(failure) {
46
83
  const data = failure.data;
47
84
  if (typeof data === 'string' && data.length > 0)
48
85
  return data;
49
- if (data && typeof data === 'object' && typeof data.error === 'string')
50
- return data.error;
86
+ if (data && typeof data === 'object') {
87
+ if (typeof data.error === 'string')
88
+ return data.error;
89
+ const { texts } = textBlocks(data);
90
+ if (texts.length > 0)
91
+ return texts.join('\n');
92
+ if (typeof data.message === 'string')
93
+ return data.message;
94
+ // ASP.NET ProblemDetails (a 400 for bad arguments): the title plus the field errors.
95
+ if (typeof data.title === 'string') {
96
+ const fields = data.errors && typeof data.errors === 'object'
97
+ ? Object.entries(data.errors).map(([k, v]) => `${k}: ${Array.isArray(v) ? v.join(' ') : String(v)}`)
98
+ : [];
99
+ return [data.title, typeof data.detail === 'string' ? data.detail : '', ...fields].filter(Boolean).join(' ');
100
+ }
101
+ }
51
102
  return failure.message;
52
103
  }
53
104
  /**
@@ -59,7 +110,7 @@ export function readToolResponse(data) {
59
110
  return { ok: true, text: data };
60
111
  const response = data;
61
112
  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);
113
+ const { texts } = textBlocks(response);
63
114
  if (texts.length > 0)
64
115
  return { ok, text: texts.join('\n') };
65
116
  const result = response?.structured?.result;
@@ -74,6 +125,6 @@ export function readToolResponse(data) {
74
125
  text += '\nlogs:\n' + result.logs.join('\n');
75
126
  return { ok, text };
76
127
  }
77
- return { ok, text: data === undefined ? '' : JSON.stringify(data) };
128
+ return { ok, text: data === undefined ? '' : JSON.stringify(withoutImageData(data)) };
78
129
  }
79
130
  //# sourceMappingURL=exec.js.map
@@ -1 +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,OA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,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,gBAAgB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;AACxF,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type Diagnostic } from './godot-log.js';
2
+ import { type HeadlessBaseOptions, type HeadlessResult, type HeadlessStep } from './headless.js';
3
+ export type ExportMode = 'release' | 'debug' | 'pack';
4
+ export interface ExportOptions extends HeadlessBaseOptions {
5
+ preset: string;
6
+ /** Output file (relative to the current directory). */
7
+ output: string;
8
+ mode?: ExportMode;
9
+ /** Tests: the editor's version string (`4.5.1.stable.mono.official.f62fdbde1`). */
10
+ godotVersion?: string;
11
+ }
12
+ export interface ExportReport {
13
+ projectPath: string;
14
+ preset: string;
15
+ mode: ExportMode;
16
+ output: string;
17
+ sizeBytes?: number;
18
+ templatesDir?: string;
19
+ steps: HeadlessStep[];
20
+ diagnostics: Diagnostic[];
21
+ }
22
+ export type ExportResult = HeadlessResult<ExportReport>;
23
+ export interface ExportPreset {
24
+ name: string;
25
+ platform: string;
26
+ customTemplateDebug: string;
27
+ customTemplateRelease: string;
28
+ }
29
+ /** The `[preset.N]` sections of export_presets.cfg. */
30
+ export declare function readExportPresets(projectPath: string): ExportPreset[];
31
+ /** Export templates folder name for a `--version` string: `4.5.1.stable.mono.official.f62fdbde1` → `4.5.1.stable.mono`. */
32
+ export declare function templatesVersionDir(version: string): string;
33
+ /** Godot's export templates root for this OS (or the self-contained `editor_data` next to the binary). */
34
+ export declare function templatesRoot(binary: string, platform?: NodeJS.Platform): string;
35
+ /**
36
+ * The editor's version: `--version` (stdout; a GUI build may print nothing to a pipe), else the official file name
37
+ * (`Godot_v4.5.1-stable_mono_win64.exe` → `4.5.1.stable.mono`).
38
+ */
39
+ export declare function godotVersion(binary: string, timeoutMs: number): string | undefined;
40
+ export declare function versionFromFileName(name: string): string | undefined;
41
+ export declare function exportProject(options: ExportOptions): Promise<ExportResult>;