cwtools-shared 0.3.0 → 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.
Files changed (50) hide show
  1. package/dist/debug/zz.d.ts +1 -0
  2. package/dist/debug/zz.js +12 -0
  3. package/dist/generated/mcpTools.d.ts +4 -4
  4. package/dist/generated/mcpTools.js +4 -4
  5. package/dist/host/capabilities.js +4 -0
  6. package/dist/host/diagnostics.d.ts +3 -0
  7. package/dist/host/filesystem.d.ts +2 -0
  8. package/dist/host/hostServices.d.ts +42 -0
  9. package/dist/host/indexing.d.ts +3 -0
  10. package/dist/host/readiness.js +10 -0
  11. package/dist/index.d.ts +12 -1
  12. package/dist/index.js +18 -1
  13. package/dist/knowledge/interfaceKnowledge.d.ts +8 -0
  14. package/dist/knowledge/interfaceKnowledge.js +222 -0
  15. package/dist/project/descriptor.d.ts +12 -0
  16. package/dist/project/descriptor.js +69 -0
  17. package/dist/project/init.d.ts +11 -0
  18. package/dist/project/init.js +356 -0
  19. package/dist/project/knowledge.d.ts +6 -0
  20. package/dist/project/knowledge.js +20 -8
  21. package/dist/project/profile.d.ts +62 -7
  22. package/dist/project/profile.js +4 -3
  23. package/dist/project/profileBuilder.d.ts +31 -0
  24. package/dist/project/profileBuilder.js +989 -0
  25. package/dist/tools/archetypeArtifacts.d.ts +29 -0
  26. package/dist/tools/archetypeArtifacts.js +136 -0
  27. package/dist/tools/archetypeSlots.d.ts +32 -0
  28. package/dist/tools/archetypeSlots.js +257 -0
  29. package/dist/tools/archetypeTools.d.ts +4 -0
  30. package/dist/tools/archetypeTools.js +118 -0
  31. package/dist/tools/callHandler.js +11 -7
  32. package/dist/tools/catalog.d.ts +4094 -0
  33. package/dist/tools/catalog.js +5031 -0
  34. package/dist/tools/domainTools.d.ts +8 -0
  35. package/dist/tools/domainTools.js +222 -0
  36. package/dist/tools/mcpSchema.d.ts +8 -11
  37. package/dist/tools/mcpSchema.js +28 -8
  38. package/dist/tools/mediaWrites.d.ts +52 -0
  39. package/dist/tools/mediaWrites.js +322 -0
  40. package/dist/tools/names.d.ts +4 -4
  41. package/dist/tools/names.js +13 -0
  42. package/dist/tools/pdxWriteCore.d.ts +51 -0
  43. package/dist/tools/pdxWriteCore.js +628 -0
  44. package/dist/tools/pdxWrites.d.ts +88 -0
  45. package/dist/tools/pdxWrites.js +629 -0
  46. package/dist/tools/scopeBridge.d.ts +36 -0
  47. package/dist/tools/scopeBridge.js +173 -0
  48. package/dist/tools/symbols.js +22 -2
  49. package/dist/tools/toolHandlers.js +98 -8
  50. package/package.json +1 -1
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_SCOPE_BRIDGE_CANDIDATES = exports.MAX_SCOPE_BRIDGE_HOPS = void 0;
4
+ exports.solveScopeBridge = solveScopeBridge;
5
+ exports.MAX_SCOPE_BRIDGE_HOPS = 4;
6
+ exports.MAX_SCOPE_BRIDGE_CANDIDATES = 200;
7
+ const REJECTED_SCOPES = new Set(['', 'unknown', 'unresolved', 'none', 'null', 'undefined']);
8
+ const MAX_RETURNED_PATHS = 200;
9
+ /**
10
+ * Finds evidence-backed scope transitions without consulting a registry or any
11
+ * process state. Inputs are normalized so output is independent of candidate
12
+ * order and spelling case.
13
+ */
14
+ function solveScopeBridge(input) {
15
+ if (!input || typeof input !== 'object' || !Array.isArray(input.candidates) || input.candidates.length > exports.MAX_SCOPE_BRIDGE_CANDIDATES)
16
+ return emptyResult();
17
+ const fromScopes = parseScopes(input.fromScope);
18
+ const toScopes = parseScopes(input.toScope);
19
+ if (fromScopes.length === 0 || toScopes.length === 0 || !Array.isArray(input.candidates)) {
20
+ return emptyResult();
21
+ }
22
+ if (scopesMatch(fromScopes, toScopes)) {
23
+ const path = { rank: 1, steps: [], confidence: 1, evidence: [] };
24
+ return { paths: [path], confidence: path.confidence, evidence: [] };
25
+ }
26
+ const candidates = input.candidates
27
+ .map(normalizeCandidate)
28
+ .filter((candidate) => candidate !== undefined)
29
+ .sort(compareCandidates)
30
+ .slice(0, exports.MAX_SCOPE_BRIDGE_CANDIDATES);
31
+ let frontier = [{
32
+ scopes: fromScopes,
33
+ steps: [],
34
+ usedCandidates: new Set(),
35
+ usedUnion: fromScopes.length > 1,
36
+ usedAny: fromScopes.includes('any'),
37
+ }];
38
+ const found = [];
39
+ for (let depth = 0; depth < exports.MAX_SCOPE_BRIDGE_HOPS && frontier.length > 0; depth += 1) {
40
+ const next = [];
41
+ for (const node of frontier) {
42
+ for (const candidate of candidates) {
43
+ const candidateKey = candidateIdentity(candidate);
44
+ if (node.usedCandidates.has(candidateKey)
45
+ || !scopesMatch(node.scopes, candidate.supportedScopes))
46
+ continue;
47
+ const step = {
48
+ name: candidate.name,
49
+ fromScopes: [...node.scopes],
50
+ toScopes: [...candidate.pushScopes],
51
+ evidence: [...candidate.evidence],
52
+ };
53
+ const usedCandidates = new Set(node.usedCandidates);
54
+ usedCandidates.add(candidateKey);
55
+ const child = {
56
+ scopes: candidate.pushScopes,
57
+ steps: [...node.steps, step],
58
+ usedCandidates,
59
+ usedUnion: node.usedUnion
60
+ || candidate.supportedScopes.length > 1
61
+ || candidate.pushScopes.length > 1,
62
+ usedAny: node.usedAny
63
+ || candidate.supportedScopes.includes('any')
64
+ || candidate.pushScopes.includes('any'),
65
+ };
66
+ if (scopesMatch(child.scopes, toScopes)) {
67
+ found.push(child);
68
+ }
69
+ else if (found.length < MAX_RETURNED_PATHS) {
70
+ next.push(child);
71
+ }
72
+ }
73
+ }
74
+ if (found.length > 0)
75
+ break; // BFS: longer paths cannot outrank shortest paths.
76
+ frontier = deduplicateNodes(next).slice(0, MAX_RETURNED_PATHS);
77
+ }
78
+ const paths = found
79
+ .map(nodeToPath)
80
+ .sort(comparePaths)
81
+ .slice(0, MAX_RETURNED_PATHS)
82
+ .map((path, index) => ({ ...path, rank: index + 1 }));
83
+ const best = paths[0];
84
+ return best
85
+ ? { paths, confidence: best.confidence, evidence: [...best.evidence] }
86
+ : emptyResult();
87
+ }
88
+ function normalizeCandidate(candidate) {
89
+ if (!candidate || typeof candidate.name !== 'string' || !Array.isArray(candidate.supportedScopes))
90
+ return undefined;
91
+ const name = candidate.name.trim();
92
+ const parsedSupportedScopes = candidate.supportedScopes.map(parseScopes);
93
+ if (parsedSupportedScopes.some(scopes => scopes.length === 0))
94
+ return undefined;
95
+ const supportedScopes = uniqueSorted(parsedSupportedScopes.flat());
96
+ const pushScopes = parseScopes(candidate.pushScope ?? '');
97
+ const evidence = normalizeEvidence(candidate.evidence);
98
+ if (!name || supportedScopes.length === 0 || pushScopes.length === 0 || evidence.length === 0)
99
+ return undefined;
100
+ return { name, supportedScopes, pushScopes, evidence };
101
+ }
102
+ function parseScopes(value) {
103
+ if (typeof value !== 'string')
104
+ return [];
105
+ const normalized = value.trim().toLowerCase().replace(/^union\s*[:(]\s*/, '').replace(/\)$/, '');
106
+ const scopes = normalized
107
+ .split(/\s*(?:\||,|\/)\s*/)
108
+ .map(scope => scope.trim());
109
+ if (scopes.some(scope => REJECTED_SCOPES.has(scope)))
110
+ return [];
111
+ return uniqueSorted(scopes);
112
+ }
113
+ function normalizeEvidence(value) {
114
+ const entries = typeof value === 'string' ? [value] : Array.isArray(value) ? value : [];
115
+ return uniqueSorted(entries
116
+ .filter((item) => typeof item === 'string')
117
+ .map(item => item.trim())
118
+ .filter(Boolean));
119
+ }
120
+ function uniqueSorted(values) {
121
+ return [...new Set(values)].sort((left, right) => left.localeCompare(right));
122
+ }
123
+ function scopesMatch(left, right) {
124
+ return left.includes('any') || right.includes('any') || left.some(scope => right.includes(scope));
125
+ }
126
+ function candidateIdentity(candidate) {
127
+ return [candidate.name.toLowerCase(), candidate.supportedScopes.join('|'), candidate.pushScopes.join('|'), candidate.evidence.join('|')].join('\u0000');
128
+ }
129
+ function compareCandidates(left, right) {
130
+ return candidateIdentity(left).localeCompare(candidateIdentity(right));
131
+ }
132
+ function deduplicateNodes(nodes) {
133
+ const sorted = [...nodes].sort((left, right) => nodeIdentity(left).localeCompare(nodeIdentity(right)));
134
+ const seen = new Set();
135
+ return sorted.filter(node => {
136
+ const key = nodeIdentity(node);
137
+ if (seen.has(key))
138
+ return false;
139
+ seen.add(key);
140
+ return true;
141
+ });
142
+ }
143
+ function nodeIdentity(node) {
144
+ return node.steps.map(step => [step.name.toLowerCase(), step.toScopes.join('|'), step.evidence.join('|')].join(':')).join('>');
145
+ }
146
+ function nodeToPath(node) {
147
+ const hopPenalty = Math.max(0, node.steps.length - 1) * 0.1;
148
+ const unionPenalty = node.usedUnion ? 0.05 : 0;
149
+ const anyPenalty = node.usedAny ? 0.15 : 0;
150
+ const confidence = Math.max(0, Number((1 - hopPenalty - unionPenalty - anyPenalty).toFixed(2)));
151
+ return {
152
+ rank: 0,
153
+ steps: node.steps.map(step => ({
154
+ ...step,
155
+ fromScopes: [...step.fromScopes],
156
+ toScopes: [...step.toScopes],
157
+ evidence: [...step.evidence],
158
+ })),
159
+ confidence,
160
+ evidence: uniqueSorted(node.steps.flatMap(step => step.evidence)),
161
+ };
162
+ }
163
+ function comparePaths(left, right) {
164
+ return right.confidence - left.confidence
165
+ || left.steps.length - right.steps.length
166
+ || pathIdentity(left).localeCompare(pathIdentity(right));
167
+ }
168
+ function pathIdentity(path) {
169
+ return path.steps.map(step => step.name.toLowerCase()).join('>');
170
+ }
171
+ function emptyResult() {
172
+ return { paths: [], confidence: 0, evidence: [] };
173
+ }
@@ -244,6 +244,23 @@ async function queryDefinitionByNameWithHost(host, args) {
244
244
  return (0, schema_1.toolDenied)('invalid_arguments', 'go_to_definition requires symbolName or a file position.');
245
245
  const commandResult = await host.lsp.executeCommand('cwtools.ai.queryDefinitionByName', [symbolName], { timeoutMs: 10000 });
246
246
  if (!isUnavailable(commandResult)) {
247
+ // The command reports a miss as `{ ok: false, error }`; returning that inside
248
+ // `ok: true` made "symbol not found" look like a successful definition lookup.
249
+ const record = commandResult && typeof commandResult === 'object' && !Array.isArray(commandResult)
250
+ ? commandResult
251
+ : {};
252
+ if (record.ok === false) {
253
+ const message = typeof record.error === 'string' && record.error.trim()
254
+ ? record.error
255
+ : `Symbol '${symbolName}' was not found.`;
256
+ return {
257
+ ok: false,
258
+ status: 'error',
259
+ source: 'cwtools-lsp-definition',
260
+ data: commandResult,
261
+ error: { code: 'definition_not_found', message },
262
+ };
263
+ }
247
264
  return {
248
265
  ok: true,
249
266
  status: 'ready',
@@ -318,15 +335,18 @@ async function queryReferencesWithHost(host, args) {
318
335
  }
319
336
  }
320
337
  const references = await textSearchReferences(host, identifier, args.file, limit);
338
+ // Lexical hits are partial evidence: they include comments and strings, so the
339
+ // result must not claim the readiness of semantic reference resolution.
321
340
  return {
322
341
  ok: true,
323
- status: 'ready',
342
+ status: 'partial',
324
343
  source: 'cwtools-text-references',
344
+ warnings: ['Fallback text references are lexical evidence, not semantic CWTools reference resolution.'],
325
345
  data: {
326
346
  identifier,
327
347
  references,
328
348
  total: references.length,
329
- _warning: 'Fallback text references are lexical evidence, not semantic CWTools reference resolution.',
349
+ evidence: 'lexical',
330
350
  },
331
351
  };
332
352
  }
@@ -39,12 +39,36 @@ const lsp_1 = require("../host/lsp");
39
39
  const diagnosticRouting_1 = require("../knowledge/diagnosticRouting");
40
40
  const rules_1 = require("../knowledge/rules");
41
41
  const profile_1 = require("../project/profile");
42
+ const init_1 = require("../project/init");
42
43
  const knowledge_1 = require("../project/knowledge");
44
+ const archetypeTools_1 = require("./archetypeTools");
45
+ const domainTools_1 = require("./domainTools");
43
46
  const localisation_1 = require("../safety/localisation");
44
47
  const pdxBlock_1 = require("./pdxBlock");
48
+ const pdxWrites_1 = require("./pdxWrites");
49
+ const mediaWrites_1 = require("./mediaWrites");
45
50
  const targetingWeights_1 = require("./targetingWeights");
46
51
  const schema_1 = require("./schema");
47
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
+ }
48
72
  function asRecord(value) {
49
73
  return value && typeof value === 'object' && !Array.isArray(value)
50
74
  ? value
@@ -58,9 +82,13 @@ async function executeLspTool(host, command, args, unavailableNextStep, signal)
58
82
  const record = asRecord(result);
59
83
  const errorRecord = asRecord(record.error);
60
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;
61
89
  return {
62
- ok: !unavailable,
63
- status: unavailable ? 'unavailable' : 'ready',
90
+ ok: !unavailable && !failed,
91
+ status: unavailable ? 'unavailable' : failed ? 'error' : 'ready',
64
92
  source: 'cwtools-lsp',
65
93
  data: result,
66
94
  error: unavailable
@@ -68,7 +96,12 @@ async function executeLspTool(host, command, args, unavailableNextStep, signal)
68
96
  code: String(errorRecord.code ?? 'lsp_unavailable'),
69
97
  message: String(errorRecord.message ?? 'LSP command is unavailable.'),
70
98
  }
71
- : undefined,
99
+ : failed
100
+ ? {
101
+ code: String(errorRecord.code ?? 'lsp_command_failed'),
102
+ message: errorMessageOf(record),
103
+ }
104
+ : undefined,
72
105
  nextSteps: unavailable ? [unavailableNextStep] : undefined,
73
106
  };
74
107
  }
@@ -78,10 +111,14 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
78
111
  const lspTool = (command, args, unavailableNextStep) => executeLspTool(host, command, args, unavailableNextStep, signal);
79
112
  (0, lsp_1.throwIfAborted)(signal);
80
113
  switch (name) {
114
+ case 'initialize_project':
115
+ return (0, init_1.initializeProjectWithHost)(host, args, context);
81
116
  case 'query_project_profile':
82
117
  return (0, profile_1.queryProjectProfileWithHost)(host, args);
83
118
  case 'query_project_knowledge':
84
119
  return (0, knowledge_1.queryProjectKnowledgeWithHost)(host, args);
120
+ case 'query_interface_knowledge':
121
+ return (0, domainTools_1.queryInterfaceKnowledgeWithHost)(host, args);
85
122
  case 'query_workspace_index': {
86
123
  if (!host.indexing) {
87
124
  return (0, schema_1.toolUnavailable)(name, 'Workspace index is not available in this host.', [
@@ -105,7 +142,13 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
105
142
  data,
106
143
  };
107
144
  }
108
- case 'explore_pdx_project':
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
+ }
109
152
  return lspTool('cwtools.ai.exploreProject', [
110
153
  typeof args.query === 'string' ? args.query : '',
111
154
  typeof args.file === 'string' && args.file ? toFileUri(args.file, host.workspaceRoot) : '',
@@ -116,6 +159,7 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
116
159
  args.maxEdges ?? 80,
117
160
  args.includeMetadata !== false,
118
161
  ], 'Start the CWTools LSP process and wait for the game model to load before exploring the semantic graph.');
162
+ }
119
163
  case 'analyze_pdx_flow': {
120
164
  const file = typeof args.file === 'string' ? args.file.trim() : '';
121
165
  const definitionId = typeof args.definitionId === 'string' ? args.definitionId.trim() : '';
@@ -210,15 +254,31 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
210
254
  data: semanticAudit ? { ...data, semanticAudit } : data,
211
255
  };
212
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);
213
263
  case 'get_diagnostics':
214
264
  {
215
265
  const diagnostics = await host.diagnostics.getDiagnostics(args, signal ? { signal } : undefined);
266
+ const suppressed = diagnostics.suppressedCount ?? 0;
216
267
  return {
217
268
  ok: diagnostics.ok,
218
269
  status: diagnostics.status === 'unavailable' ? 'unavailable' : diagnostics.status === 'stale' ? 'stale' : diagnostics.status === 'pending' ? 'loading' : 'ready',
219
270
  source: 'cwtools-diagnostics',
220
271
  data: diagnostics,
221
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.'],
222
282
  };
223
283
  }
224
284
  case 'analyze_diagnostic_error':
@@ -279,6 +339,8 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
279
339
  name: typeof args.name === 'string' ? args.name : undefined,
280
340
  scope: typeof args.scope === 'string' ? args.scope : undefined,
281
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.');
282
344
  case 'query_cwt_schema':
283
345
  return (0, rules_1.queryCwtSchemaWithHost)(host, {
284
346
  target: typeof args.target === 'string' ? args.target : undefined,
@@ -296,12 +358,24 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
296
358
  desiredPushScope: typeof args.desiredPushScope === 'string' ? args.desiredPushScope : undefined,
297
359
  limit: typeof args.limit === 'number' ? args.limit : undefined,
298
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);
299
365
  case 'explain_scope':
300
366
  return (0, rules_1.explainScopeWithHost)(host, {
301
367
  scope: String(args.scope ?? ''),
302
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);
303
373
  case 'parse_pdx_fragment':
304
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');
305
379
  case 'query_scripted_effects':
306
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.');
307
381
  case 'query_scripted_triggers':
@@ -351,15 +425,31 @@ const defaultSharedToolDispatcher = async (host, name, rawArgs, context) => {
351
425
  return lspTool('cwtools.ai.shader.compareVanilla', [typeof args.effectName === 'string' && args.effectName
352
426
  ? { effectName: args.effectName }
353
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.');
354
- case 'get_ide_context':
355
- case 'open_in_visual_editor':
356
- return (0, schema_1.toolUnavailable)(name, `${name} requires the active VS Code extension bridge (default mode without --standalone).`, ['Open the project in VS Code / Cursor / Antigravity with the CWTools extension active and connect via bridge mode.']);
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
+ }
357
443
  case 'typed_pdx_write':
444
+ return (0, pdxWrites_1.typedPdxWriteWithHost)(host, args, context);
358
445
  case 'candidate_transaction':
446
+ return (0, pdxWrites_1.candidateTransactionWithHost)(host, args, context);
359
447
  case 'convert_image_to_dds':
448
+ return (0, mediaWrites_1.convertImageToDdsWithHost)(host, args, context);
360
449
  case 'convert_audio':
450
+ return (0, mediaWrites_1.convertAudioWithHost)(host, args, context);
361
451
  case 'deploy_mod_asset':
362
- return (0, schema_1.toolUnavailable)(name, `${name} requires the active VS Code extension bridge started with --allow-domain-writes (or --enable-writes).`, ['Connect to the active VS Code extension bridge with --allow-domain-writes enabled.']);
452
+ return (0, mediaWrites_1.deployModAssetWithHost)(host, args, context);
363
453
  default:
364
454
  return {
365
455
  ok: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cwtools-shared",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shared protocol and tool contracts for the CWTools MCP server",
5
5
  "license": "MIT",
6
6
  "repository": {