godot-cli 0.1.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 (110) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +101 -0
  3. package/bin/godot-cli.js +2 -0
  4. package/dist/cli.d.ts +11 -0
  5. package/dist/cli.js +17 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/close.d.ts +18 -0
  8. package/dist/commands/close.js +112 -0
  9. package/dist/commands/close.js.map +1 -0
  10. package/dist/commands/configure.d.ts +2 -0
  11. package/dist/commands/configure.js +92 -0
  12. package/dist/commands/configure.js.map +1 -0
  13. package/dist/commands/install-plugin.d.ts +2 -0
  14. package/dist/commands/install-plugin.js +35 -0
  15. package/dist/commands/install-plugin.js.map +1 -0
  16. package/dist/commands/open.d.ts +16 -0
  17. package/dist/commands/open.js +124 -0
  18. package/dist/commands/open.js.map +1 -0
  19. package/dist/commands/remove-plugin.d.ts +2 -0
  20. package/dist/commands/remove-plugin.js +31 -0
  21. package/dist/commands/remove-plugin.js.map +1 -0
  22. package/dist/commands/run-system-tool.d.ts +1 -0
  23. package/dist/commands/run-system-tool.js +13 -0
  24. package/dist/commands/run-system-tool.js.map +1 -0
  25. package/dist/commands/run-tool-builder.d.ts +25 -0
  26. package/dist/commands/run-tool-builder.js +119 -0
  27. package/dist/commands/run-tool-builder.js.map +1 -0
  28. package/dist/commands/run-tool.d.ts +1 -0
  29. package/dist/commands/run-tool.js +13 -0
  30. package/dist/commands/run-tool.js.map +1 -0
  31. package/dist/commands/setup-mcp.d.ts +2 -0
  32. package/dist/commands/setup-mcp.js +58 -0
  33. package/dist/commands/setup-mcp.js.map +1 -0
  34. package/dist/commands/status.d.ts +2 -0
  35. package/dist/commands/status.js +64 -0
  36. package/dist/commands/status.js.map +1 -0
  37. package/dist/commands/update.d.ts +2 -0
  38. package/dist/commands/update.js +75 -0
  39. package/dist/commands/update.js.map +1 -0
  40. package/dist/commands/wait-for-ready.d.ts +2 -0
  41. package/dist/commands/wait-for-ready.js +57 -0
  42. package/dist/commands/wait-for-ready.js.map +1 -0
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.js +69 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/lib/install-plugin.d.ts +22 -0
  47. package/dist/lib/install-plugin.js +118 -0
  48. package/dist/lib/install-plugin.js.map +1 -0
  49. package/dist/lib/open.d.ts +34 -0
  50. package/dist/lib/open.js +198 -0
  51. package/dist/lib/open.js.map +1 -0
  52. package/dist/lib/progress.d.ts +7 -0
  53. package/dist/lib/progress.js +16 -0
  54. package/dist/lib/progress.js.map +1 -0
  55. package/dist/lib/run-tool.d.ts +12 -0
  56. package/dist/lib/run-tool.js +192 -0
  57. package/dist/lib/run-tool.js.map +1 -0
  58. package/dist/lib/setup-mcp.d.ts +16 -0
  59. package/dist/lib/setup-mcp.js +118 -0
  60. package/dist/lib/setup-mcp.js.map +1 -0
  61. package/dist/lib/types.d.ts +210 -0
  62. package/dist/lib/types.js +8 -0
  63. package/dist/lib/types.js.map +1 -0
  64. package/dist/lib/validation.d.ts +30 -0
  65. package/dist/lib/validation.js +44 -0
  66. package/dist/lib/validation.js.map +1 -0
  67. package/dist/lib.d.ts +5 -0
  68. package/dist/lib.js +19 -0
  69. package/dist/lib.js.map +1 -0
  70. package/dist/utils/agents.d.ts +31 -0
  71. package/dist/utils/agents.js +188 -0
  72. package/dist/utils/agents.js.map +1 -0
  73. package/dist/utils/config.d.ts +40 -0
  74. package/dist/utils/config.js +97 -0
  75. package/dist/utils/config.js.map +1 -0
  76. package/dist/utils/connection.d.ts +57 -0
  77. package/dist/utils/connection.js +129 -0
  78. package/dist/utils/connection.js.map +1 -0
  79. package/dist/utils/godot-editor.d.ts +42 -0
  80. package/dist/utils/godot-editor.js +184 -0
  81. package/dist/utils/godot-editor.js.map +1 -0
  82. package/dist/utils/godot-process.d.ts +10 -0
  83. package/dist/utils/godot-process.js +93 -0
  84. package/dist/utils/godot-process.js.map +1 -0
  85. package/dist/utils/godot-shutdown.d.ts +16 -0
  86. package/dist/utils/godot-shutdown.js +67 -0
  87. package/dist/utils/godot-shutdown.js.map +1 -0
  88. package/dist/utils/input.d.ts +13 -0
  89. package/dist/utils/input.js +72 -0
  90. package/dist/utils/input.js.map +1 -0
  91. package/dist/utils/json-parse.d.ts +25 -0
  92. package/dist/utils/json-parse.js +83 -0
  93. package/dist/utils/json-parse.js.map +1 -0
  94. package/dist/utils/probe.d.ts +18 -0
  95. package/dist/utils/probe.js +61 -0
  96. package/dist/utils/probe.js.map +1 -0
  97. package/dist/utils/project-godot.d.ts +41 -0
  98. package/dist/utils/project-godot.js +126 -0
  99. package/dist/utils/project-godot.js.map +1 -0
  100. package/dist/utils/semver.d.ts +4 -0
  101. package/dist/utils/semver.js +25 -0
  102. package/dist/utils/semver.js.map +1 -0
  103. package/dist/utils/ui.d.ts +61 -0
  104. package/dist/utils/ui.js +238 -0
  105. package/dist/utils/ui.js.map +1 -0
  106. package/dist/utils/update-check.d.ts +19 -0
  107. package/dist/utils/update-check.js +92 -0
  108. package/dist/utils/update-check.js.map +1 -0
  109. package/docs/README.md +7 -0
  110. package/package.json +73 -0
@@ -0,0 +1,118 @@
1
+ import * as path from 'path';
2
+ import { CLOUD_MCP_URL, DEFAULT_CUSTOM_HOST, ENV_HOST, ENV_TOKEN, MCP_HUB_PATH, } from '../utils/connection.js';
3
+ import { getAgentById, getAgentIds, writeJsonAgentConfig, MCP_SERVER_NAME, } from '../utils/agents.js';
4
+ import { emitProgress } from './progress.js';
5
+ import { requireExistingPath } from './validation.js';
6
+ /**
7
+ * Normalize an env-supplied value (trim + strip a single wrapping double-quote
8
+ * pair), mirroring the addon's `GodotMcpConfig.NormalizeEnv`.
9
+ */
10
+ function normalizeEnv(raw) {
11
+ if (raw === undefined)
12
+ return undefined;
13
+ const trimmed = raw.trim();
14
+ if (trimmed.length === 0)
15
+ return undefined;
16
+ return trimmed.replace(/^"(.*)"$/, '$1');
17
+ }
18
+ /**
19
+ * Resolve the MCP-client URL an external AI agent should connect to. This is
20
+ * the `<host>/mcp` streamable-HTTP endpoint (NOT the plugin's
21
+ * `<host>/hub/mcp-server` SignalR endpoint), matching the addon's
22
+ * `GodotMcpConfig.ResolveMcpClientUrl`:
23
+ * 1. explicit `--url` override (host) → `<host>/mcp`
24
+ * 2. GODOT_MCP_HOST env (Custom host) → `<host>/mcp`
25
+ * 3. default cloud MCP URL (https://ai-game.dev/mcp)
26
+ */
27
+ function resolveMcpClientUrl(optUrl) {
28
+ const host = optUrl ?? normalizeEnv(process.env[ENV_HOST]);
29
+ if (!host)
30
+ return CLOUD_MCP_URL;
31
+ const trimmed = host.replace(/\/$/, '');
32
+ if (trimmed.toLowerCase().endsWith(MCP_HUB_PATH))
33
+ return trimmed;
34
+ return trimmed + MCP_HUB_PATH;
35
+ }
36
+ /**
37
+ * Write MCP configuration for the given AI agent so it can talk to a Godot-MCP
38
+ * server. Library-safe: no stdout noise, no process.exit, no throws past the
39
+ * public boundary.
40
+ *
41
+ * Writes an HTTP server entry pointing at the resolved MCP-client URL. The
42
+ * Godot config body shape mirrors the addon's `AgentConfigJson` / `AgentConfigPaths`
43
+ * conventions (`.mcp.json` under `mcpServers` for Claude Code, `.vscode/mcp.json`
44
+ * under `servers` for VS Code, etc.).
45
+ */
46
+ export async function setupMcp(opts) {
47
+ const warnings = [];
48
+ try {
49
+ if (!opts || typeof opts.agentId !== 'string' || opts.agentId.length === 0) {
50
+ return {
51
+ kind: 'failure',
52
+ success: false,
53
+ warnings,
54
+ error: new Error(`agentId is required. Available agent IDs: ${getAgentIds().join(', ')}`),
55
+ };
56
+ }
57
+ const agent = getAgentById(opts.agentId);
58
+ if (!agent) {
59
+ return {
60
+ kind: 'failure',
61
+ success: false,
62
+ warnings,
63
+ error: new Error(`Unknown agent: "${opts.agentId}". Available agent IDs: ${getAgentIds().join(', ')}`),
64
+ };
65
+ }
66
+ // Resolve project path. If supplied it must exist; otherwise fall back to cwd.
67
+ let projectPath;
68
+ if (opts.godotProjectPath) {
69
+ const validated = requireExistingPath(opts.godotProjectPath);
70
+ if (!validated.ok) {
71
+ return { kind: 'failure', success: false, warnings, error: validated.error };
72
+ }
73
+ projectPath = validated.projectPath;
74
+ }
75
+ else {
76
+ projectPath = path.resolve(process.cwd());
77
+ }
78
+ emitProgress(opts.onProgress, {
79
+ phase: 'start',
80
+ message: `Configuring ${agent.name} for ${projectPath}`,
81
+ });
82
+ const serverUrl = resolveMcpClientUrl(opts.url);
83
+ const token = opts.token ?? normalizeEnv(process.env[ENV_TOKEN]) ?? '';
84
+ const authRequired = token.length > 0;
85
+ const configPath = agent.getConfigPath(projectPath);
86
+ const props = agent.getHttpProps(serverUrl, token, authRequired);
87
+ writeJsonAgentConfig(configPath, agent.bodyPath, MCP_SERVER_NAME, props, agent.httpRemoveKeys);
88
+ emitProgress(opts.onProgress, {
89
+ phase: 'manifest-patched',
90
+ message: `Wrote ${configPath}`,
91
+ manifestPath: configPath,
92
+ });
93
+ emitProgress(opts.onProgress, { phase: 'done', message: `${agent.name} configured successfully.` });
94
+ return {
95
+ kind: 'success',
96
+ success: true,
97
+ agentId: agent.id,
98
+ configPath,
99
+ serverUrl,
100
+ warnings,
101
+ };
102
+ }
103
+ catch (err) {
104
+ return {
105
+ kind: 'failure',
106
+ success: false,
107
+ warnings,
108
+ error: err instanceof Error ? err : new Error(String(err)),
109
+ };
110
+ }
111
+ }
112
+ /** List every agent id known to `setupMcp`. */
113
+ export function listAgentIds() {
114
+ return getAgentIds();
115
+ }
116
+ // Re-export the constants so the CLI command can surface the default URL in help.
117
+ export { CLOUD_MCP_URL, DEFAULT_CUSTOM_HOST };
118
+ //# sourceMappingURL=setup-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-mcp.js","sourceRoot":"","sources":["../../src/lib/setup-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,aAAa,EACb,mBAA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F;AAClF,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Discriminated union describing every progress event the library can emit to
3
+ * the optional `onProgress` callback. Consumers narrow on `event.phase`.
4
+ */
5
+ export type ProgressEvent = {
6
+ phase: 'start';
7
+ message: string;
8
+ } | {
9
+ phase: 'manifest-patched';
10
+ message: string;
11
+ manifestPath: string;
12
+ } | {
13
+ phase: 'editor-resolved';
14
+ message: string;
15
+ editorPath: string;
16
+ } | {
17
+ phase: 'connection-details';
18
+ message: string;
19
+ projectPath: string;
20
+ editorPath: string;
21
+ envVars: Record<string, string>;
22
+ } | {
23
+ phase: 'launching-editor';
24
+ message: string;
25
+ editorPath: string;
26
+ projectPath: string;
27
+ } | {
28
+ phase: 'editor-launched';
29
+ message: string;
30
+ pid?: number;
31
+ } | {
32
+ phase: 'done';
33
+ message: string;
34
+ };
35
+ export type ProgressCallback = (event: ProgressEvent) => void;
36
+ export type ResultKind = 'success' | 'failure';
37
+ export interface SetupMcpOptions {
38
+ /** Agent to configure. Use `listAgentIds()` to discover valid values. */
39
+ agentId: string;
40
+ /** Optional Godot project path. Defaults to `process.cwd()` if omitted. */
41
+ godotProjectPath?: string;
42
+ /** Explicit MCP server URL override (the `<host>/mcp` client endpoint). */
43
+ url?: string;
44
+ /** Auth token override. */
45
+ token?: string;
46
+ onProgress?: ProgressCallback;
47
+ }
48
+ export interface SetupMcpSuccess {
49
+ kind: 'success';
50
+ success: true;
51
+ agentId: string;
52
+ configPath: string;
53
+ serverUrl: string;
54
+ warnings: string[];
55
+ }
56
+ export interface SetupMcpFailure {
57
+ kind: 'failure';
58
+ success: false;
59
+ warnings: string[];
60
+ error: Error;
61
+ }
62
+ export type SetupMcpResult = SetupMcpSuccess | SetupMcpFailure;
63
+ /** Auth option propagated to the editor as `GODOT_MCP_AUTH_OPTION`. */
64
+ export type OpenProjectAuthOption = 'None' | 'Required';
65
+ /** Connection mode propagated to the editor as `GODOT_MCP_CONNECTION_MODE`. */
66
+ export type OpenProjectConnectionMode = 'Cloud' | 'Custom';
67
+ export interface OpenProjectOptions {
68
+ /** Path to the Godot project to open. Defaults to `process.cwd()`. */
69
+ projectPath?: string;
70
+ /** Explicit Godot editor executable path (skips resolution). */
71
+ editorPath?: string;
72
+ /** If `true`, skip wiring the GODOT_MCP_* env vars onto the editor process. */
73
+ noConnect?: boolean;
74
+ /** MCP server host — sets `GODOT_MCP_HOST`. */
75
+ url?: string;
76
+ /** Cloud base URL override — sets `GODOT_MCP_CLOUD_URL`. */
77
+ cloudUrl?: string;
78
+ /** Auth token — sets `GODOT_MCP_TOKEN`. */
79
+ token?: string;
80
+ /** Auth option — sets `GODOT_MCP_AUTH_OPTION`. */
81
+ auth?: OpenProjectAuthOption;
82
+ /** Connection mode — sets `GODOT_MCP_CONNECTION_MODE`. */
83
+ mode?: OpenProjectConnectionMode;
84
+ /** Log level — sets `GODOT_MCP_LOG_LEVEL`. */
85
+ logLevel?: string;
86
+ onProgress?: ProgressCallback;
87
+ }
88
+ export interface OpenProjectSuccess {
89
+ kind: 'success';
90
+ success: true;
91
+ editorPath: string;
92
+ editorPid?: number;
93
+ projectPath: string;
94
+ warnings: string[];
95
+ /** True when an editor was already running for this project; launch skipped. */
96
+ alreadyRunning?: boolean;
97
+ }
98
+ export interface OpenProjectFailure {
99
+ kind: 'failure';
100
+ success: false;
101
+ projectPath?: string;
102
+ editorPath?: string;
103
+ warnings: string[];
104
+ errorMessage: string;
105
+ error: Error;
106
+ }
107
+ export type OpenProjectResult = OpenProjectSuccess | OpenProjectFailure;
108
+ /**
109
+ * Subset of `OpenProjectOptions` consumed by `buildOpenEnv` — every field here
110
+ * maps to a `GODOT_MCP_*` environment variable.
111
+ */
112
+ export interface OpenEnvInputs {
113
+ noConnect?: OpenProjectOptions['noConnect'];
114
+ url?: OpenProjectOptions['url'];
115
+ cloudUrl?: OpenProjectOptions['cloudUrl'];
116
+ token?: OpenProjectOptions['token'];
117
+ auth?: OpenProjectOptions['auth'];
118
+ mode?: OpenProjectOptions['mode'];
119
+ logLevel?: OpenProjectOptions['logLevel'];
120
+ }
121
+ export type RunToolFailureReason = 'invalid-input' | 'connection-refused' | 'connection-reset' | 'network-error' | 'timeout' | 'http-error' | 'unknown';
122
+ /**
123
+ * Options accepted by both {@link runTool} and {@link runSystemTool}.
124
+ *
125
+ * `url` (the MCP server base URL) MUST be provided — unlike the Unity CLI there
126
+ * is no deterministic project-path→port fallback, because the Godot plugin is a
127
+ * server-less client whose persisted config lives in `user://` (outside the
128
+ * project tree).
129
+ */
130
+ export interface RunToolOptions {
131
+ /** Tool name to invoke. URL-encoded into the `{name}` route segment. */
132
+ toolName: string;
133
+ /** MCP server base URL (no trailing slash required). REQUIRED. */
134
+ url?: string;
135
+ /** Bearer token override. */
136
+ token?: string;
137
+ /** Tool arguments serialized as the JSON request body. Defaults to `{}`. */
138
+ input?: unknown;
139
+ /** Per-request timeout in milliseconds. Defaults to `60000`. */
140
+ timeoutMs?: number;
141
+ /** Optional abort signal. */
142
+ signal?: AbortSignal;
143
+ /** Optional fetch injection point for tests. */
144
+ fetchImpl?: typeof fetch;
145
+ }
146
+ export interface RunToolSuccess {
147
+ kind: 'success';
148
+ success: true;
149
+ endpoint: string;
150
+ httpStatus: number;
151
+ data: unknown;
152
+ }
153
+ export interface RunToolFailure {
154
+ kind: 'failure';
155
+ success: false;
156
+ endpoint: string;
157
+ reason: RunToolFailureReason;
158
+ httpStatus?: number;
159
+ data?: unknown;
160
+ message: string;
161
+ error?: Error;
162
+ }
163
+ export type RunToolResult = RunToolSuccess | RunToolFailure;
164
+ export type RunSystemToolOptions = RunToolOptions;
165
+ export type RunSystemToolResult = RunToolResult;
166
+ export type RunSystemToolSuccess = RunToolSuccess;
167
+ export type RunSystemToolFailure = RunToolFailure;
168
+ export interface InstallPluginOptions {
169
+ /** Absolute or relative path to the Godot project root. */
170
+ godotProjectPath: string;
171
+ onProgress?: ProgressCallback;
172
+ }
173
+ export interface InstallPluginSuccess {
174
+ kind: 'success';
175
+ success: true;
176
+ /** True when the plugin was newly enabled; false when it was already enabled. */
177
+ changed: boolean;
178
+ projectGodotPath: string;
179
+ enabledPlugins: string[];
180
+ warnings: string[];
181
+ }
182
+ export interface InstallPluginFailure {
183
+ kind: 'failure';
184
+ success: false;
185
+ projectGodotPath?: string;
186
+ warnings: string[];
187
+ error: Error;
188
+ }
189
+ export type InstallPluginResult = InstallPluginSuccess | InstallPluginFailure;
190
+ export interface RemovePluginOptions {
191
+ godotProjectPath: string;
192
+ onProgress?: ProgressCallback;
193
+ }
194
+ export interface RemovePluginSuccess {
195
+ kind: 'success';
196
+ success: true;
197
+ /** True when the plugin was disabled; false when it was already absent. */
198
+ changed: boolean;
199
+ projectGodotPath: string;
200
+ enabledPlugins: string[];
201
+ warnings: string[];
202
+ }
203
+ export interface RemovePluginFailure {
204
+ kind: 'failure';
205
+ success: false;
206
+ projectGodotPath?: string;
207
+ warnings: string[];
208
+ error: Error;
209
+ }
210
+ export type RemovePluginResult = RemovePluginSuccess | RemovePluginFailure;
@@ -0,0 +1,8 @@
1
+ // Shared public types for the godot-cli library API.
2
+ //
3
+ // This file is re-exported from `lib.ts` — consumers should import
4
+ // from `godot-cli` (the package root), NOT from deep paths.
5
+ //
6
+ // No top-level side effects, no runtime deps beyond TypeScript types.
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,mEAAmE;AACnE,4DAA4D;AAC5D,EAAE;AACF,sEAAsE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Small, side-effect-free input-validation helpers shared by the
3
+ * library-facing API functions. Each helper returns a discriminated union so
4
+ * call sites can pattern-match without throwing across the public boundary.
5
+ */
6
+ export type ValidatedPath = {
7
+ ok: true;
8
+ projectPath: string;
9
+ } | {
10
+ ok: false;
11
+ error: Error;
12
+ };
13
+ export type ValidatedGodotProject = {
14
+ ok: true;
15
+ projectPath: string;
16
+ projectGodotPath: string;
17
+ } | {
18
+ ok: false;
19
+ projectGodotPath?: string;
20
+ error: Error;
21
+ };
22
+ /** Require a non-empty string and resolve it to an absolute path. */
23
+ export declare function requireProjectPath(raw: unknown): ValidatedPath;
24
+ /**
25
+ * Require a non-empty path AND that the path hosts a Godot project (identified
26
+ * by the presence of `project.godot`).
27
+ */
28
+ export declare function requireGodotProject(raw: unknown): ValidatedGodotProject;
29
+ /** Require that the given path exists on disk (need not host a project.godot). */
30
+ export declare function requireExistingPath(raw: unknown): ValidatedPath;
@@ -0,0 +1,44 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ /** Require a non-empty string and resolve it to an absolute path. */
4
+ export function requireProjectPath(raw) {
5
+ if (typeof raw !== 'string' || raw.length === 0) {
6
+ return {
7
+ ok: false,
8
+ error: new Error('godotProjectPath is required and must be a non-empty string.'),
9
+ };
10
+ }
11
+ return { ok: true, projectPath: path.resolve(raw) };
12
+ }
13
+ /**
14
+ * Require a non-empty path AND that the path hosts a Godot project (identified
15
+ * by the presence of `project.godot`).
16
+ */
17
+ export function requireGodotProject(raw) {
18
+ const outer = requireProjectPath(raw);
19
+ if (!outer.ok)
20
+ return outer;
21
+ const projectGodotPath = path.join(outer.projectPath, 'project.godot');
22
+ if (!fs.existsSync(projectGodotPath)) {
23
+ return {
24
+ ok: false,
25
+ projectGodotPath,
26
+ error: new Error(`Not a valid Godot project (missing project.godot): ${outer.projectPath}`),
27
+ };
28
+ }
29
+ return { ok: true, projectPath: outer.projectPath, projectGodotPath };
30
+ }
31
+ /** Require that the given path exists on disk (need not host a project.godot). */
32
+ export function requireExistingPath(raw) {
33
+ const outer = requireProjectPath(raw);
34
+ if (!outer.ok)
35
+ return outer;
36
+ if (!fs.existsSync(outer.projectPath)) {
37
+ return {
38
+ ok: false,
39
+ error: new Error(`Project path does not exist: ${outer.projectPath}`),
40
+ };
41
+ }
42
+ return outer;
43
+ }
44
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/lib/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAgB7B,qEAAqE;AACrE,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,IAAI,KAAK,CAAC,8DAA8D,CAAC;SACjF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IAC5B,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IACvE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrC,OAAO;YACL,EAAE,EAAE,KAAK;YACT,gBAAgB;YAChB,KAAK,EAAE,IAAI,KAAK,CAAC,sDAAsD,KAAK,CAAC,WAAW,EAAE,CAAC;SAC5F,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,gBAAgB,EAAE,CAAC;AACxE,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IAC5B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,IAAI,KAAK,CAAC,gCAAgC,KAAK,CAAC,WAAW,EAAE,CAAC;SACtE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/lib.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { openProject } from './lib/open.js';
2
+ export { runTool, runSystemTool } from './lib/run-tool.js';
3
+ export { setupMcp, listAgentIds } from './lib/setup-mcp.js';
4
+ export { installPlugin, removePlugin } from './lib/install-plugin.js';
5
+ export type { ProgressEvent, ProgressCallback, ResultKind, OpenProjectOptions, OpenProjectResult, OpenProjectSuccess, OpenProjectFailure, OpenProjectAuthOption, OpenProjectConnectionMode, RunToolOptions, RunToolResult, RunToolSuccess, RunToolFailure, RunToolFailureReason, RunSystemToolOptions, RunSystemToolResult, RunSystemToolSuccess, RunSystemToolFailure, SetupMcpOptions, SetupMcpResult, SetupMcpSuccess, SetupMcpFailure, InstallPluginOptions, InstallPluginResult, InstallPluginSuccess, InstallPluginFailure, RemovePluginOptions, RemovePluginResult, RemovePluginSuccess, RemovePluginFailure, } from './lib/types.js';
package/dist/lib.js ADDED
@@ -0,0 +1,19 @@
1
+ // Library entry point for `godot-cli`.
2
+ //
3
+ // Constraints:
4
+ // - NO top-level side effects. Importing this file must not open sockets, spin
5
+ // up spinners, write to stdout/stderr, or parse argv.
6
+ // - NO `commander` import reachable from this file.
7
+ // - Every result is a discriminated union keyed on `kind`. Successes are
8
+ // `{ kind: 'success', success: true, ... }`; failures are
9
+ // `{ kind: 'failure', success: false, error }`. Errors are never thrown past
10
+ // the public boundary. Narrow on `kind` for type-safe access.
11
+ // - Progress is surfaced via an optional `onProgress` callback, not globals.
12
+ //
13
+ // Consumers: `import { openProject } from 'godot-cli'` (maps to this file
14
+ // via the `exports` field in package.json).
15
+ export { openProject } from './lib/open.js';
16
+ export { runTool, runSystemTool } from './lib/run-tool.js';
17
+ export { setupMcp, listAgentIds } from './lib/setup-mcp.js';
18
+ export { installPlugin, removePlugin } from './lib/install-plugin.js';
19
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +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,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * An AI-agent MCP-client configurator. Mirrors the Godot addon's
3
+ * `GodotAgentConfigurator` registry (`addons/godot_mcp/UI/Agents/`), adapted
4
+ * to the CLI's file-writing surface. Each agent knows where its MCP-client
5
+ * config lives and what HTTP-transport server entry to write.
6
+ *
7
+ * Godot is a server-less client: the plugin connects out to a server, and an
8
+ * external AI client connects to the same server's `<host>/mcp` streamable-HTTP
9
+ * endpoint. So every configurator here writes an HTTP server entry pointing at
10
+ * the resolved MCP-client URL (NOT the plugin's `<host>/hub/mcp-server` SignalR
11
+ * endpoint).
12
+ */
13
+ export interface AgentDefinition {
14
+ id: string;
15
+ name: string;
16
+ configPathDisplay: string;
17
+ bodyPath: string;
18
+ /** Resolve the absolute config-file path for a given project root. */
19
+ getConfigPath(projectPath: string): string;
20
+ /** Build the HTTP server entry written under `bodyPath[MCP_SERVER_NAME]`. */
21
+ getHttpProps(url: string, token: string, authRequired: boolean): Record<string, unknown>;
22
+ /** Keys to delete from a pre-existing entry before merging new props. */
23
+ httpRemoveKeys: string[];
24
+ }
25
+ declare const MCP_SERVER_NAME = "ai-game-developer";
26
+ export declare const agentRegistry: readonly AgentDefinition[];
27
+ export declare function getAgentById(id: string): AgentDefinition | undefined;
28
+ export declare function getAgentIds(): string[];
29
+ export declare function listAgentTable(heading: string, locationLabel: string, locationFn: (agent: AgentDefinition) => string): void;
30
+ export declare function writeJsonAgentConfig(configPath: string, bodyPath: string, serverName: string, props: Record<string, unknown>, removeKeys: string[]): void;
31
+ export { MCP_SERVER_NAME };