cwtools-shared 0.2.9 → 0.4.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/dist/debug/zz.d.ts +1 -0
- package/dist/debug/zz.js +12 -0
- package/dist/generated/mcpTools.d.ts +49 -4
- package/dist/generated/mcpTools.js +94 -49
- package/dist/generated/workshopDetection.d.ts +22 -0
- package/dist/generated/workshopDetection.js +50 -0
- package/dist/generated/workspaceDetectionProfiles.d.ts +2 -0
- package/dist/generated/workspaceDetectionProfiles.js +84 -0
- package/dist/generated/workspaceGameDetection.d.ts +39 -0
- package/dist/generated/workspaceGameDetection.js +424 -0
- package/dist/host/capabilities.d.ts +39 -0
- package/dist/host/capabilities.js +128 -0
- package/dist/host/diagnostics.d.ts +8 -1
- package/dist/host/filesystem.d.ts +2 -0
- package/dist/host/hostServices.d.ts +47 -0
- package/dist/host/indexing.d.ts +3 -0
- package/dist/host/lsp.d.ts +9 -0
- package/dist/host/lsp.js +27 -0
- package/dist/host/readiness.js +10 -0
- package/dist/host/vanillaCache.js +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +22 -1
- package/dist/knowledge/interfaceKnowledge.d.ts +8 -0
- package/dist/knowledge/interfaceKnowledge.js +222 -0
- package/dist/project/descriptor.d.ts +12 -0
- package/dist/project/descriptor.js +69 -0
- package/dist/project/init.d.ts +11 -0
- package/dist/project/init.js +356 -0
- package/dist/project/knowledge.d.ts +6 -0
- package/dist/project/knowledge.js +20 -8
- package/dist/project/profile.d.ts +62 -7
- package/dist/project/profile.js +4 -3
- package/dist/project/profileBuilder.d.ts +31 -0
- package/dist/project/profileBuilder.js +989 -0
- package/dist/tools/archetypeArtifacts.d.ts +29 -0
- package/dist/tools/archetypeArtifacts.js +136 -0
- package/dist/tools/archetypeSlots.d.ts +32 -0
- package/dist/tools/archetypeSlots.js +257 -0
- package/dist/tools/archetypeTools.d.ts +4 -0
- package/dist/tools/archetypeTools.js +118 -0
- package/dist/tools/callHandler.d.ts +10 -0
- package/dist/tools/callHandler.js +76 -0
- package/dist/tools/catalog.d.ts +4094 -0
- package/dist/tools/catalog.js +5031 -0
- package/dist/tools/domainTools.d.ts +8 -0
- package/dist/tools/domainTools.js +222 -0
- package/dist/tools/mcpSchema.d.ts +20 -3
- package/dist/tools/mcpSchema.js +55 -7
- package/dist/tools/mediaWrites.d.ts +52 -0
- package/dist/tools/mediaWrites.js +322 -0
- package/dist/tools/names.d.ts +4 -4
- package/dist/tools/names.js +14 -1
- package/dist/tools/pdxWriteCore.d.ts +51 -0
- package/dist/tools/pdxWriteCore.js +628 -0
- package/dist/tools/pdxWrites.d.ts +88 -0
- package/dist/tools/pdxWrites.js +629 -0
- package/dist/tools/registry.d.ts +1 -0
- package/dist/tools/scopeBridge.d.ts +36 -0
- package/dist/tools/scopeBridge.js +173 -0
- package/dist/tools/symbols.js +22 -2
- package/dist/tools/targetingWeights.d.ts +206 -0
- package/dist/tools/targetingWeights.js +350 -0
- package/dist/tools/toolHandlers.d.ts +5 -1
- package/dist/tools/toolHandlers.js +146 -33
- package/package.json +1 -1
|
@@ -35,27 +35,60 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.defaultSharedToolDispatcher = void 0;
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
|
+
const lsp_1 = require("../host/lsp");
|
|
38
39
|
const diagnosticRouting_1 = require("../knowledge/diagnosticRouting");
|
|
39
40
|
const rules_1 = require("../knowledge/rules");
|
|
40
41
|
const profile_1 = require("../project/profile");
|
|
42
|
+
const init_1 = require("../project/init");
|
|
41
43
|
const knowledge_1 = require("../project/knowledge");
|
|
44
|
+
const archetypeTools_1 = require("./archetypeTools");
|
|
45
|
+
const domainTools_1 = require("./domainTools");
|
|
42
46
|
const localisation_1 = require("../safety/localisation");
|
|
43
47
|
const pdxBlock_1 = require("./pdxBlock");
|
|
48
|
+
const pdxWrites_1 = require("./pdxWrites");
|
|
49
|
+
const mediaWrites_1 = require("./mediaWrites");
|
|
50
|
+
const targetingWeights_1 = require("./targetingWeights");
|
|
44
51
|
const schema_1 = require("./schema");
|
|
45
52
|
const symbols_1 = require("./symbols");
|
|
53
|
+
function invalidArguments(message) {
|
|
54
|
+
return {
|
|
55
|
+
ok: false,
|
|
56
|
+
status: 'error',
|
|
57
|
+
source: 'cwtools-shared',
|
|
58
|
+
error: { code: 'invalid_arguments', message },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function errorMessageOf(record) {
|
|
62
|
+
const error = record.error;
|
|
63
|
+
if (typeof error === 'string' && error.trim())
|
|
64
|
+
return error;
|
|
65
|
+
const nested = asRecord(error);
|
|
66
|
+
if (typeof nested.message === 'string' && nested.message.trim())
|
|
67
|
+
return nested.message;
|
|
68
|
+
if (typeof record.message === 'string' && record.message.trim())
|
|
69
|
+
return record.message;
|
|
70
|
+
return 'CWTools LSP command reported a failure.';
|
|
71
|
+
}
|
|
46
72
|
function asRecord(value) {
|
|
47
73
|
return value && typeof value === 'object' && !Array.isArray(value)
|
|
48
74
|
? value
|
|
49
75
|
: {};
|
|
50
76
|
}
|
|
51
|
-
async function executeLspTool(host, command, args, unavailableNextStep) {
|
|
52
|
-
|
|
77
|
+
async function executeLspTool(host, command, args, unavailableNextStep, signal) {
|
|
78
|
+
// Cancellation must not be laundered into `unavailable`: the caller asked to
|
|
79
|
+
// stop, so the abort error propagates untouched.
|
|
80
|
+
(0, lsp_1.throwIfAborted)(signal);
|
|
81
|
+
const result = await host.lsp.executeCommand(command, args, signal ? { signal } : undefined);
|
|
53
82
|
const record = asRecord(result);
|
|
54
83
|
const errorRecord = asRecord(record.error);
|
|
55
84
|
const unavailable = record.status === 'unavailable' || errorRecord.code === 'lsp_unavailable';
|
|
85
|
+
// A command that answered `ok: false` (unknown symbol, unsupported argument) is a
|
|
86
|
+
// failure, not an empty success: wrapping it in `ok: true` made callers report
|
|
87
|
+
// "found nothing" for "could not look".
|
|
88
|
+
const failed = !unavailable && record.ok === false;
|
|
56
89
|
return {
|
|
57
|
-
ok: !unavailable,
|
|
58
|
-
status: unavailable ? 'unavailable' : 'ready',
|
|
90
|
+
ok: !unavailable && !failed,
|
|
91
|
+
status: unavailable ? 'unavailable' : failed ? 'error' : 'ready',
|
|
59
92
|
source: 'cwtools-lsp',
|
|
60
93
|
data: result,
|
|
61
94
|
error: unavailable
|
|
@@ -63,17 +96,29 @@ async function executeLspTool(host, command, args, unavailableNextStep) {
|
|
|
63
96
|
code: String(errorRecord.code ?? 'lsp_unavailable'),
|
|
64
97
|
message: String(errorRecord.message ?? 'LSP command is unavailable.'),
|
|
65
98
|
}
|
|
66
|
-
:
|
|
99
|
+
: failed
|
|
100
|
+
? {
|
|
101
|
+
code: String(errorRecord.code ?? 'lsp_command_failed'),
|
|
102
|
+
message: errorMessageOf(record),
|
|
103
|
+
}
|
|
104
|
+
: undefined,
|
|
67
105
|
nextSteps: unavailable ? [unavailableNextStep] : undefined,
|
|
68
106
|
};
|
|
69
107
|
}
|
|
70
|
-
const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
108
|
+
const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
|
|
71
109
|
const args = asRecord(rawArgs);
|
|
110
|
+
const signal = context?.signal;
|
|
111
|
+
const lspTool = (command, args, unavailableNextStep) => executeLspTool(host, command, args, unavailableNextStep, signal);
|
|
112
|
+
(0, lsp_1.throwIfAborted)(signal);
|
|
72
113
|
switch (name) {
|
|
114
|
+
case 'initialize_project':
|
|
115
|
+
return (0, init_1.initializeProjectWithHost)(host, args, context);
|
|
73
116
|
case 'query_project_profile':
|
|
74
117
|
return (0, profile_1.queryProjectProfileWithHost)(host, args);
|
|
75
118
|
case 'query_project_knowledge':
|
|
76
119
|
return (0, knowledge_1.queryProjectKnowledgeWithHost)(host, args);
|
|
120
|
+
case 'query_interface_knowledge':
|
|
121
|
+
return (0, domainTools_1.queryInterfaceKnowledgeWithHost)(host, args);
|
|
77
122
|
case 'query_workspace_index': {
|
|
78
123
|
if (!host.indexing) {
|
|
79
124
|
return (0, schema_1.toolUnavailable)(name, 'Workspace index is not available in this host.', [
|
|
@@ -97,8 +142,14 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
97
142
|
data,
|
|
98
143
|
};
|
|
99
144
|
}
|
|
100
|
-
case 'explore_pdx_project':
|
|
101
|
-
|
|
145
|
+
case 'explore_pdx_project': {
|
|
146
|
+
if (args.exact !== undefined && typeof args.exact !== 'boolean') {
|
|
147
|
+
return invalidArguments('exact must be a boolean; pass the identifier in query.');
|
|
148
|
+
}
|
|
149
|
+
if (args.exact === true && (typeof args.query !== 'string' || args.query.trim() === '')) {
|
|
150
|
+
return invalidArguments('exact requires a non-empty query; omit exact to browse by typeName or file.');
|
|
151
|
+
}
|
|
152
|
+
return lspTool('cwtools.ai.exploreProject', [
|
|
102
153
|
typeof args.query === 'string' ? args.query : '',
|
|
103
154
|
typeof args.file === 'string' && args.file ? toFileUri(args.file, host.workspaceRoot) : '',
|
|
104
155
|
typeof args.typeName === 'string' ? args.typeName : '',
|
|
@@ -108,6 +159,7 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
108
159
|
args.maxEdges ?? 80,
|
|
109
160
|
args.includeMetadata !== false,
|
|
110
161
|
], 'Start the CWTools LSP process and wait for the game model to load before exploring the semantic graph.');
|
|
162
|
+
}
|
|
111
163
|
case 'analyze_pdx_flow': {
|
|
112
164
|
const file = typeof args.file === 'string' ? args.file.trim() : '';
|
|
113
165
|
const definitionId = typeof args.definitionId === 'string' ? args.definitionId.trim() : '';
|
|
@@ -122,7 +174,7 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
122
174
|
},
|
|
123
175
|
};
|
|
124
176
|
}
|
|
125
|
-
return
|
|
177
|
+
return lspTool('cwtools.ai.analyzePdxFlow', [{
|
|
126
178
|
...(file ? { file } : {}),
|
|
127
179
|
...(definitionId ? { definitionId } : {}),
|
|
128
180
|
...(typeof args.entityType === 'string' && args.entityType.trim() ? { entityType: args.entityType.trim() } : {}),
|
|
@@ -141,7 +193,7 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
141
193
|
},
|
|
142
194
|
};
|
|
143
195
|
}
|
|
144
|
-
return
|
|
196
|
+
return lspTool('cwtools.ai.compareDefinitionWithVanilla', [args.entityType.trim(), args.symbolId.trim()], 'Start the CWTools LSP process and wait for the game model to load before comparing the definition with vanilla.');
|
|
145
197
|
}
|
|
146
198
|
case 'query_inline_instantiation': {
|
|
147
199
|
const template = typeof args.template === 'string' ? args.template.trim() : '';
|
|
@@ -157,13 +209,28 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
157
209
|
},
|
|
158
210
|
};
|
|
159
211
|
}
|
|
160
|
-
return
|
|
212
|
+
return lspTool('cwtools.ai.exploreInlineGraph', [{
|
|
161
213
|
...(template ? { template } : {}),
|
|
162
214
|
...(file ? { file } : {}),
|
|
163
215
|
...(Number.isInteger(args.line) ? { line: Number(args.line) } : {}),
|
|
164
216
|
limit: Math.max(1, Math.min(Number(args.limit ?? 50) || 50, 200)),
|
|
165
217
|
}], 'Start the CWTools LSP process and wait for the game model to load before resolving the inline template instantiation.');
|
|
166
218
|
}
|
|
219
|
+
case 'query_targeting_weight': {
|
|
220
|
+
// Pure computation: no host, no I/O, and no backend to wait for. The shared
|
|
221
|
+
// implementation is the single source of truth for the formula, so the MCP
|
|
222
|
+
// surface, the in-extension agent and the panel produce identical numbers
|
|
223
|
+
// for the same inputs.
|
|
224
|
+
const data = (0, targetingWeights_1.executeTargetingWeightQuery)(args);
|
|
225
|
+
const failure = typeof data.error === 'string' ? data.error : undefined;
|
|
226
|
+
return {
|
|
227
|
+
ok: failure === undefined,
|
|
228
|
+
status: failure === undefined ? 'ready' : 'error',
|
|
229
|
+
source: 'cwtools-shared',
|
|
230
|
+
data,
|
|
231
|
+
error: failure === undefined ? undefined : { code: 'invalid_arguments', message: failure },
|
|
232
|
+
};
|
|
233
|
+
}
|
|
167
234
|
case 'query_localisation_index': {
|
|
168
235
|
if (!host.indexing) {
|
|
169
236
|
return (0, schema_1.toolUnavailable)(name, 'Localisation index is not available in this host.', [
|
|
@@ -172,7 +239,7 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
172
239
|
}
|
|
173
240
|
const data = await host.indexing.queryLocalisation(args);
|
|
174
241
|
const semanticAudit = args.auditMode === true
|
|
175
|
-
? await
|
|
242
|
+
? await lspTool('cwtools.ai.queryLocalisationAudit', [{
|
|
176
243
|
...(typeof args.key === 'string' ? { key: args.key } : {}),
|
|
177
244
|
prefix: args.prefix === true,
|
|
178
245
|
contains: args.contains === true,
|
|
@@ -187,15 +254,31 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
187
254
|
data: semanticAudit ? { ...data, semanticAudit } : data,
|
|
188
255
|
};
|
|
189
256
|
}
|
|
257
|
+
case 'get_lsp_status':
|
|
258
|
+
return lspTool('cwtools.ai.getValidationStatus', [], 'Start the CWTools LSP process before requesting its status.');
|
|
259
|
+
case 'get_ignored_diagnostics':
|
|
260
|
+
return (0, domainTools_1.getIgnoredDiagnosticsWithHost)(host);
|
|
261
|
+
case 'remove_ignored_diagnostic':
|
|
262
|
+
return (0, domainTools_1.removeIgnoredDiagnosticWithHost)(host, args);
|
|
190
263
|
case 'get_diagnostics':
|
|
191
264
|
{
|
|
192
|
-
const diagnostics = await host.diagnostics.getDiagnostics(args);
|
|
265
|
+
const diagnostics = await host.diagnostics.getDiagnostics(args, signal ? { signal } : undefined);
|
|
266
|
+
const suppressed = diagnostics.suppressedCount ?? 0;
|
|
193
267
|
return {
|
|
194
268
|
ok: diagnostics.ok,
|
|
195
269
|
status: diagnostics.status === 'unavailable' ? 'unavailable' : diagnostics.status === 'stale' ? 'stale' : diagnostics.status === 'pending' ? 'loading' : 'ready',
|
|
196
270
|
source: 'cwtools-diagnostics',
|
|
197
271
|
data: diagnostics,
|
|
198
272
|
error: diagnostics.error,
|
|
273
|
+
// An empty page is not an empty project: say so when the workspace ignore
|
|
274
|
+
// list removed entries, and point at the missing backend when it answered
|
|
275
|
+
// "unavailable" instead of leaving a bare error behind.
|
|
276
|
+
warnings: suppressed > 0
|
|
277
|
+
? [`${suppressed} diagnostic(s) on this page were hidden by the workspace ignore list (stellarisLanguageServices.ai.ignoredDiagnostics); they still count in totalCount.`]
|
|
278
|
+
: undefined,
|
|
279
|
+
nextSteps: diagnostics.ok
|
|
280
|
+
? undefined
|
|
281
|
+
: ['Check that the CWTools backend is running (extension active, or a standalone server), then retry get_diagnostics.'],
|
|
199
282
|
};
|
|
200
283
|
}
|
|
201
284
|
case 'analyze_diagnostic_error':
|
|
@@ -247,15 +330,17 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
247
330
|
limit: typeof args.limit === 'number' ? args.limit : undefined,
|
|
248
331
|
});
|
|
249
332
|
case 'query_scope':
|
|
250
|
-
return
|
|
333
|
+
return lspTool('cwtools.ai.getScopeAtPosition', [toFileUri(String(args.file ?? ''), host.workspaceRoot), args.line, args.column], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
251
334
|
case 'query_types':
|
|
252
|
-
return
|
|
335
|
+
return lspTool('cwtools.ai.queryTypes', [args.typeName, args.filter ?? '', args.limit ?? 30, args.vanilla === true], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
253
336
|
case 'query_rules':
|
|
254
337
|
return (0, rules_1.queryRulesWithHost)(host, {
|
|
255
338
|
category: String(args.category ?? 'trigger'),
|
|
256
339
|
name: typeof args.name === 'string' ? args.name : undefined,
|
|
257
340
|
scope: typeof args.scope === 'string' ? args.scope : undefined,
|
|
258
341
|
});
|
|
342
|
+
case 'query_override_modes':
|
|
343
|
+
return lspTool('cwtools.ai.queryOverrideModes', [typeof args.path === 'string' ? args.path : '', args.limit ?? 250], 'Start the CWTools LSP process before querying path override modes.');
|
|
259
344
|
case 'query_cwt_schema':
|
|
260
345
|
return (0, rules_1.queryCwtSchemaWithHost)(host, {
|
|
261
346
|
target: typeof args.target === 'string' ? args.target : undefined,
|
|
@@ -273,24 +358,36 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
273
358
|
desiredPushScope: typeof args.desiredPushScope === 'string' ? args.desiredPushScope : undefined,
|
|
274
359
|
limit: typeof args.limit === 'number' ? args.limit : undefined,
|
|
275
360
|
});
|
|
361
|
+
case 'find_scope_bridge':
|
|
362
|
+
return (0, domainTools_1.findScopeBridgeWithHost)(host, args);
|
|
363
|
+
case 'verify_pdx_identifier':
|
|
364
|
+
return (0, domainTools_1.verifyPdxIdentifierWithHost)(host, args);
|
|
276
365
|
case 'explain_scope':
|
|
277
366
|
return (0, rules_1.explainScopeWithHost)(host, {
|
|
278
367
|
scope: String(args.scope ?? ''),
|
|
279
368
|
});
|
|
369
|
+
case 'extract_archetype_slots':
|
|
370
|
+
return (0, archetypeTools_1.extractArchetypeWithHost)(host, args);
|
|
371
|
+
case 'instantiate_archetype':
|
|
372
|
+
return (0, archetypeTools_1.instantiateArchetypeWithHost)(host, args);
|
|
280
373
|
case 'parse_pdx_fragment':
|
|
281
|
-
return
|
|
374
|
+
return lspTool('cwtools.ai.parseFragment', [String(args.code ?? '')], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
375
|
+
case 'find_sprite_candidates':
|
|
376
|
+
return (0, domainTools_1.findAssetCandidatesWithHost)(host, args, 'sprite');
|
|
377
|
+
case 'find_sound_candidates':
|
|
378
|
+
return (0, domainTools_1.findAssetCandidatesWithHost)(host, args, 'sound');
|
|
282
379
|
case 'query_scripted_effects':
|
|
283
|
-
return
|
|
380
|
+
return lspTool('cwtools.ai.queryScriptedEffects', [args.filter ?? '', args.limit ?? 50], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
284
381
|
case 'query_scripted_triggers':
|
|
285
|
-
return
|
|
382
|
+
return lspTool('cwtools.ai.queryScriptedTriggers', [args.filter ?? '', args.limit ?? 50], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
286
383
|
case 'query_enums':
|
|
287
|
-
return
|
|
384
|
+
return lspTool('cwtools.ai.queryEnums', [args.enumName ?? '', args.limit ?? 500], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
288
385
|
case 'query_static_modifiers':
|
|
289
|
-
return
|
|
386
|
+
return lspTool('cwtools.ai.queryStaticModifiers', [args.filter ?? '', args.limit ?? 300], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
290
387
|
case 'query_variables':
|
|
291
|
-
return
|
|
388
|
+
return lspTool('cwtools.ai.queryVariables', [args.filter ?? ''], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
292
389
|
case 'get_entity_info':
|
|
293
|
-
return
|
|
390
|
+
return lspTool('cwtools.ai.getEntityInfo', [toFileUri(String(args.file ?? ''), host.workspaceRoot)], 'Start the CWTools LSP process or connect this host to an existing language server.');
|
|
294
391
|
case 'get_pdx_block':
|
|
295
392
|
return (0, pdxBlock_1.getPdxBlockWithHost)(host, {
|
|
296
393
|
file: String(args.file ?? ''),
|
|
@@ -299,23 +396,23 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
299
396
|
// Shader knowledge tools: each LSP command takes a single JSON record
|
|
300
397
|
// argument and returns { ok, ... } / { ok: false, status: 'error', ... }.
|
|
301
398
|
case 'query_shader_symbol':
|
|
302
|
-
return
|
|
399
|
+
return lspTool('cwtools.ai.shader.symbols', [shaderRecord({
|
|
303
400
|
filter: typeof args.filter === 'string' ? args.filter : undefined,
|
|
304
401
|
kind: typeof args.kind === 'string' ? args.kind : undefined,
|
|
305
402
|
limit: typeof args.limit === 'number' ? args.limit : undefined,
|
|
306
403
|
cursor: typeof args.cursor === 'number' ? args.cursor : undefined,
|
|
307
404
|
})], 'Start the CWTools LSP process and wait for the shader model to load before querying shader symbols.');
|
|
308
405
|
case 'query_shader_compile_unit':
|
|
309
|
-
return
|
|
406
|
+
return lspTool('cwtools.ai.shader.compileUnit', [{ uri: toFileUri(String(args.file ?? ''), host.workspaceRoot) }], 'Start the CWTools LSP process and wait for the shader model to load before resolving compile units.');
|
|
310
407
|
case 'query_shader_platform_variants':
|
|
311
|
-
return
|
|
408
|
+
return lspTool('cwtools.ai.shader.variants', [{ uri: toFileUri(String(args.file ?? ''), host.workspaceRoot) }], 'Start the CWTools LSP process and wait for the shader model to load before comparing shader platform variants.');
|
|
312
409
|
case 'query_shader_callers':
|
|
313
|
-
return
|
|
410
|
+
return lspTool('cwtools.ai.shader.callers', [shaderRecord({
|
|
314
411
|
effectName: String(args.effectName ?? ''),
|
|
315
412
|
limit: typeof args.limit === 'number' ? args.limit : undefined,
|
|
316
413
|
})], 'Start the CWTools LSP process and wait for the shader model to load before querying Effect callers.');
|
|
317
414
|
case 'explain_shader_reachability':
|
|
318
|
-
return
|
|
415
|
+
return lspTool('cwtools.ai.shader.reachability', [typeof args.effectName === 'string' && args.effectName
|
|
319
416
|
? { effectName: args.effectName }
|
|
320
417
|
: shaderRecord({
|
|
321
418
|
uri: toFileUri(String(args.file ?? ''), host.workspaceRoot),
|
|
@@ -323,20 +420,36 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs) => {
|
|
|
323
420
|
cursor: typeof args.cursor === 'number' ? args.cursor : undefined,
|
|
324
421
|
})], 'Start the CWTools LSP process and wait for the shader model to load before explaining Effect reachability.');
|
|
325
422
|
case 'validate_shader':
|
|
326
|
-
return
|
|
423
|
+
return lspTool('cwtools.ai.shader.validate', [{ uri: toFileUri(String(args.file ?? ''), host.workspaceRoot) }], 'Start the CWTools LSP process and wait for the shader model to load before validating shader files.');
|
|
327
424
|
case 'compare_shader_with_vanilla':
|
|
328
|
-
return
|
|
425
|
+
return lspTool('cwtools.ai.shader.compareVanilla', [typeof args.effectName === 'string' && args.effectName
|
|
329
426
|
? { effectName: args.effectName }
|
|
330
427
|
: { uri: toFileUri(String(args.file ?? ''), host.workspaceRoot) }], 'Start the CWTools LSP process and wait for the shader model to load before comparing with vanilla.');
|
|
331
|
-
case 'get_ide_context':
|
|
332
|
-
|
|
333
|
-
|
|
428
|
+
case 'get_ide_context': {
|
|
429
|
+
if (!host.ide)
|
|
430
|
+
return (0, schema_1.toolUnavailable)(name, 'IDE context requires an active editor host.');
|
|
431
|
+
return { ok: true, status: 'ready', source: 'cwtools-ide-host', data: await host.ide.getContext(args, context) };
|
|
432
|
+
}
|
|
433
|
+
case 'open_in_visual_editor': {
|
|
434
|
+
if (!host.ide)
|
|
435
|
+
return (0, schema_1.toolUnavailable)(name, 'Visual editors require an active editor host.');
|
|
436
|
+
return { ok: true, status: 'ready', source: 'cwtools-ide-host', data: await host.ide.openVisualEditor(args, context) };
|
|
437
|
+
}
|
|
438
|
+
case 'capture_gui_preview': {
|
|
439
|
+
if (!host.ide?.captureGuiPreview)
|
|
440
|
+
return (0, schema_1.toolUnavailable)(name, 'GUI capture requires an active editor host with a GUI preview.');
|
|
441
|
+
return { ok: true, status: 'ready', source: 'cwtools-ide-host', data: await host.ide.captureGuiPreview(args, context) };
|
|
442
|
+
}
|
|
334
443
|
case 'typed_pdx_write':
|
|
444
|
+
return (0, pdxWrites_1.typedPdxWriteWithHost)(host, args, context);
|
|
335
445
|
case 'candidate_transaction':
|
|
446
|
+
return (0, pdxWrites_1.candidateTransactionWithHost)(host, args, context);
|
|
336
447
|
case 'convert_image_to_dds':
|
|
448
|
+
return (0, mediaWrites_1.convertImageToDdsWithHost)(host, args, context);
|
|
337
449
|
case 'convert_audio':
|
|
450
|
+
return (0, mediaWrites_1.convertAudioWithHost)(host, args, context);
|
|
338
451
|
case 'deploy_mod_asset':
|
|
339
|
-
return (0,
|
|
452
|
+
return (0, mediaWrites_1.deployModAssetWithHost)(host, args, context);
|
|
340
453
|
default:
|
|
341
454
|
return {
|
|
342
455
|
ok: false,
|