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.
- package/dist/debug/zz.d.ts +1 -0
- package/dist/debug/zz.js +12 -0
- package/dist/generated/mcpTools.d.ts +4 -4
- package/dist/generated/mcpTools.js +4 -4
- package/dist/host/capabilities.js +4 -0
- package/dist/host/diagnostics.d.ts +3 -0
- package/dist/host/filesystem.d.ts +2 -0
- package/dist/host/hostServices.d.ts +42 -0
- package/dist/host/indexing.d.ts +3 -0
- package/dist/host/readiness.js +10 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +18 -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.js +11 -7
- 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 +8 -11
- package/dist/tools/mcpSchema.js +28 -8
- 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 +13 -0
- 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/scopeBridge.d.ts +36 -0
- package/dist/tools/scopeBridge.js +173 -0
- package/dist/tools/symbols.js +22 -2
- package/dist/tools/toolHandlers.js +98 -8
- package/package.json +1 -1
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DEPLOY_MOD_ASSET_FIELDS = exports.CONVERT_AUDIO_FIELDS = exports.CONVERT_IMAGE_TO_DDS_FIELDS = void 0;
|
|
37
|
+
exports.convertImageToDdsWithHost = convertImageToDdsWithHost;
|
|
38
|
+
exports.convertAudioWithHost = convertAudioWithHost;
|
|
39
|
+
exports.deployModAssetWithHost = deployModAssetWithHost;
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const lsp_1 = require("../host/lsp");
|
|
42
|
+
const paths_1 = require("../safety/paths");
|
|
43
|
+
const writes_1 = require("../safety/writes");
|
|
44
|
+
const SOURCE = 'cwtools-domain-writes';
|
|
45
|
+
const CONVERSION_TIMEOUT_MS = 60000;
|
|
46
|
+
const MAX_FILENAME_CHARS = 200;
|
|
47
|
+
const WAV_SAMPLE_RATES = new Set([8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000]);
|
|
48
|
+
const MAX_CHANNELS = 8;
|
|
49
|
+
exports.CONVERT_IMAGE_TO_DDS_FIELDS = ['sourcePath', 'outputDir', 'compression', 'generateMipmaps'];
|
|
50
|
+
exports.CONVERT_AUDIO_FIELDS = ['sourcePath', 'outputDir', 'targetFormat', 'sampleRate', 'channels'];
|
|
51
|
+
exports.DEPLOY_MOD_ASSET_FIELDS = ['sourcePath', 'targetRelativePath', 'overwrite'];
|
|
52
|
+
function failure(code, message) {
|
|
53
|
+
return { ok: false, status: 'error', source: SOURCE, error: { code, message } };
|
|
54
|
+
}
|
|
55
|
+
function rejected(code, message) {
|
|
56
|
+
return { ok: false, status: 'error', source: SOURCE, error: { code, message } };
|
|
57
|
+
}
|
|
58
|
+
function unsupported(message, nextSteps) {
|
|
59
|
+
return { ok: false, status: 'unavailable', source: SOURCE, error: { code: 'external_tool_unavailable', message }, nextSteps };
|
|
60
|
+
}
|
|
61
|
+
function errorText(error) {
|
|
62
|
+
return error instanceof Error ? error.message : String(error);
|
|
63
|
+
}
|
|
64
|
+
function isAbortLike(error) {
|
|
65
|
+
const name = error?.name;
|
|
66
|
+
return name === 'AbortError' || name === 'TimeoutError';
|
|
67
|
+
}
|
|
68
|
+
function unsupportedFields(args, allowed, tool) {
|
|
69
|
+
const extra = Object.keys(args).filter(key => !allowed.includes(key));
|
|
70
|
+
return extra.length > 0 ? tool + ' contains unsupported field(s): ' + extra.join(', ') : undefined;
|
|
71
|
+
}
|
|
72
|
+
function resolveInside(host, inputPath) {
|
|
73
|
+
const trimmed = typeof inputPath === 'string' ? inputPath.trim() : '';
|
|
74
|
+
if (!trimmed)
|
|
75
|
+
return { ok: false, message: 'A file path is required.' };
|
|
76
|
+
const root = (0, paths_1.normalizeWorkspaceRoot)(host.workspaceRoot);
|
|
77
|
+
const resolved = path.resolve(root, trimmed);
|
|
78
|
+
if (!(0, paths_1.isPathInsideOrEqual)(root, resolved))
|
|
79
|
+
return { ok: false, message: "Path '" + trimmed + "' is outside the workspace root." };
|
|
80
|
+
return { ok: true, resolvedPath: resolved, relativePath: path.relative(root, resolved).replace(/\\/g, '/') };
|
|
81
|
+
}
|
|
82
|
+
/** A derived output file name must stay a plain file name inside its directory. */
|
|
83
|
+
function safeBaseName(sourcePath) {
|
|
84
|
+
const raw = path.basename(sourcePath, path.extname(sourcePath)).trim();
|
|
85
|
+
if (!raw)
|
|
86
|
+
return { ok: false, message: 'Source file name is empty; cannot derive an output name.' };
|
|
87
|
+
if (raw.length > MAX_FILENAME_CHARS)
|
|
88
|
+
return { ok: false, message: 'Source file name exceeds ' + MAX_FILENAME_CHARS + ' characters.' };
|
|
89
|
+
if (/[\\/:*?"<>|\u0000-\u001f]/.test(raw) || raw === '.' || raw === '..') {
|
|
90
|
+
return { ok: false, message: "Source file name '" + raw + "' cannot be used as a safe output name." };
|
|
91
|
+
}
|
|
92
|
+
return { ok: true, name: raw };
|
|
93
|
+
}
|
|
94
|
+
function externalHost(host) {
|
|
95
|
+
const candidate = host;
|
|
96
|
+
return { commands: candidate.externalCommands, settings: candidate.mediaTools };
|
|
97
|
+
}
|
|
98
|
+
async function runCommand(host, request) {
|
|
99
|
+
const runner = externalHost(host).commands;
|
|
100
|
+
if (!runner) {
|
|
101
|
+
return { ok: false, message: 'This host does not expose an external command runner, so no conversion can be performed.' };
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const result = await runner.run({ ...request, timeoutMs: CONVERSION_TIMEOUT_MS, ...(request.signal ? { signal: request.signal } : {}) });
|
|
105
|
+
if (!result.success) {
|
|
106
|
+
return { ok: false, message: (result.stderr ?? '').trim() || result.message || request.command + ' reported a failure.' };
|
|
107
|
+
}
|
|
108
|
+
return { ok: true };
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (isAbortLike(error))
|
|
112
|
+
throw error;
|
|
113
|
+
return { ok: false, message: errorText(error) };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function resolveOutputDir(host, args, sourcePath) {
|
|
117
|
+
if (args.outputDir === undefined || args.outputDir === '') {
|
|
118
|
+
return { ok: true, outDir: path.dirname(sourcePath) };
|
|
119
|
+
}
|
|
120
|
+
const resolved = resolveInside(host, args.outputDir);
|
|
121
|
+
if (!resolved.ok)
|
|
122
|
+
return resolved;
|
|
123
|
+
if (resolved.resolvedPath === sourcePath) {
|
|
124
|
+
return { ok: false, message: 'outputDir must be a directory, not the source file.' };
|
|
125
|
+
}
|
|
126
|
+
return { ok: true, outDir: resolved.resolvedPath };
|
|
127
|
+
}
|
|
128
|
+
async function sourceExists(host, sourcePath) {
|
|
129
|
+
const read = await host.filesystem.readTextFile(sourcePath).catch(() => undefined);
|
|
130
|
+
if (read?.exists)
|
|
131
|
+
return true;
|
|
132
|
+
const parent = await host.filesystem.list(path.dirname(sourcePath)).catch(() => undefined);
|
|
133
|
+
return !!parent?.some(entry => entry.type === 'file' && path.join(path.dirname(sourcePath), entry.name) === sourcePath);
|
|
134
|
+
}
|
|
135
|
+
// ─── convert_image_to_dds ──────────────────────────────────────────────────
|
|
136
|
+
async function convertImageToDdsWithHost(host, args, context) {
|
|
137
|
+
const denied = (0, writes_1.ensureToolWriteAllowed)(host, 'convert_image_to_dds');
|
|
138
|
+
if (denied)
|
|
139
|
+
return denied;
|
|
140
|
+
(0, lsp_1.throwIfAborted)(context?.signal);
|
|
141
|
+
const unsupportedField = unsupportedFields(args, exports.CONVERT_IMAGE_TO_DDS_FIELDS, 'convert_image_to_dds');
|
|
142
|
+
if (unsupportedField)
|
|
143
|
+
return rejected('invalid_arguments', unsupportedField);
|
|
144
|
+
const compression = args.compression ?? 'dxt5';
|
|
145
|
+
if (compression !== 'dxt5' && compression !== 'dxt1' && compression !== 'dxt3' && compression !== 'none') {
|
|
146
|
+
return rejected('invalid_arguments', 'compression must be dxt5, dxt1, dxt3, or none.');
|
|
147
|
+
}
|
|
148
|
+
const generateMipmaps = args.generateMipmaps === true;
|
|
149
|
+
const source = resolveInside(host, args.sourcePath);
|
|
150
|
+
if (!source.ok)
|
|
151
|
+
return rejected('outside_workspace', source.message);
|
|
152
|
+
if (!(await sourceExists(host, source.resolvedPath))) {
|
|
153
|
+
return rejected('source_not_found', 'Source file not found: ' + String(args.sourcePath));
|
|
154
|
+
}
|
|
155
|
+
const output = await resolveOutputDir(host, args, source.resolvedPath);
|
|
156
|
+
if (!output.ok)
|
|
157
|
+
return rejected('outside_workspace', output.message);
|
|
158
|
+
const baseName = safeBaseName(source.resolvedPath);
|
|
159
|
+
if (!baseName.ok)
|
|
160
|
+
return rejected('invalid_source_name', baseName.message);
|
|
161
|
+
const outFile = path.join(output.outDir, baseName.name + '.dds');
|
|
162
|
+
if (!(0, paths_1.isPathInsideOrEqual)((0, paths_1.normalizeWorkspaceRoot)(host.workspaceRoot), outFile)) {
|
|
163
|
+
return rejected('outside_workspace', 'Derived output path escapes the workspace.');
|
|
164
|
+
}
|
|
165
|
+
if (context?.signal)
|
|
166
|
+
(0, lsp_1.throwIfAborted)(context.signal);
|
|
167
|
+
const { settings } = externalHost(host);
|
|
168
|
+
const magick = settings?.imageMagickPath?.trim() || 'magick';
|
|
169
|
+
const pass = await runCommand(host, {
|
|
170
|
+
command: magick,
|
|
171
|
+
args: ['convert', source.resolvedPath, '-define', 'dds:compression=' + compression, '-define', 'dds:mipmaps=' + (generateMipmaps ? 'true' : '0'), outFile],
|
|
172
|
+
signal: context?.signal,
|
|
173
|
+
});
|
|
174
|
+
if (!pass.ok) {
|
|
175
|
+
if (/ENOENT|not found|is not recognized/i.test(pass.message)) {
|
|
176
|
+
return unsupported('ImageMagick is not available: ' + pass.message, ['Install ImageMagick (https://imagemagick.org/) and put it on PATH, or configure the ImageMagick path for this host.']);
|
|
177
|
+
}
|
|
178
|
+
return rejected('conversion_failed', 'ImageMagick conversion failed: ' + pass.message);
|
|
179
|
+
}
|
|
180
|
+
if (!(await sourceExists(host, outFile))) {
|
|
181
|
+
return rejected('output_missing', 'Conversion completed but the output file was not found: ' + outFile);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
ok: true,
|
|
185
|
+
status: 'success',
|
|
186
|
+
source: SOURCE,
|
|
187
|
+
data: { success: true, message: 'Image converted to DDS (' + compression + ', mipmaps=' + generateMipmaps + '): ' + outFile, outputFile: outFile },
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// ─── convert_audio ─────────────────────────────────────────────────────────
|
|
191
|
+
async function convertAudioWithHost(host, args, context) {
|
|
192
|
+
const denied = (0, writes_1.ensureToolWriteAllowed)(host, 'convert_audio');
|
|
193
|
+
if (denied)
|
|
194
|
+
return denied;
|
|
195
|
+
(0, lsp_1.throwIfAborted)(context?.signal);
|
|
196
|
+
const unsupportedField = unsupportedFields(args, exports.CONVERT_AUDIO_FIELDS, 'convert_audio');
|
|
197
|
+
if (unsupportedField)
|
|
198
|
+
return rejected('invalid_arguments', unsupportedField);
|
|
199
|
+
const targetFormat = args.targetFormat;
|
|
200
|
+
if (targetFormat !== 'ogg' && targetFormat !== 'wav')
|
|
201
|
+
return rejected('invalid_arguments', 'targetFormat must be "ogg" or "wav".');
|
|
202
|
+
if (args.sampleRate !== undefined && (!Number.isSafeInteger(args.sampleRate) || !WAV_SAMPLE_RATES.has(args.sampleRate))) {
|
|
203
|
+
return rejected('invalid_arguments', 'sampleRate must be one of ' + [...WAV_SAMPLE_RATES].join(', ') + '.');
|
|
204
|
+
}
|
|
205
|
+
if (args.channels !== undefined && (!Number.isSafeInteger(args.channels) || args.channels < 1 || args.channels > MAX_CHANNELS)) {
|
|
206
|
+
return rejected('invalid_arguments', 'channels must be an integer between 1 and ' + MAX_CHANNELS + '.');
|
|
207
|
+
}
|
|
208
|
+
const source = resolveInside(host, args.sourcePath);
|
|
209
|
+
if (!source.ok)
|
|
210
|
+
return rejected('outside_workspace', source.message);
|
|
211
|
+
if (!(await sourceExists(host, source.resolvedPath))) {
|
|
212
|
+
return rejected('source_not_found', 'Source file not found: ' + String(args.sourcePath));
|
|
213
|
+
}
|
|
214
|
+
const output = await resolveOutputDir(host, args, source.resolvedPath);
|
|
215
|
+
if (!output.ok)
|
|
216
|
+
return rejected('outside_workspace', output.message);
|
|
217
|
+
const baseName = safeBaseName(source.resolvedPath);
|
|
218
|
+
if (!baseName.ok)
|
|
219
|
+
return rejected('invalid_source_name', baseName.message);
|
|
220
|
+
const outFile = path.join(output.outDir, baseName.name + '.' + targetFormat);
|
|
221
|
+
if (!(0, paths_1.isPathInsideOrEqual)((0, paths_1.normalizeWorkspaceRoot)(host.workspaceRoot), outFile)) {
|
|
222
|
+
return rejected('outside_workspace', 'Derived output path escapes the workspace.');
|
|
223
|
+
}
|
|
224
|
+
const { settings } = externalHost(host);
|
|
225
|
+
const ffmpeg = settings?.ffmpegPath?.trim() || 'ffmpeg';
|
|
226
|
+
const command = ['-y', '-i', source.resolvedPath];
|
|
227
|
+
if (targetFormat === 'ogg') {
|
|
228
|
+
command.push('-c:a', 'libvorbis', '-q:a', '4');
|
|
229
|
+
if (args.sampleRate !== undefined)
|
|
230
|
+
command.push('-ar', String(args.sampleRate));
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
command.push('-acodec', 'pcm_s16le', '-ar', String(args.sampleRate ?? 44100));
|
|
234
|
+
}
|
|
235
|
+
if (args.channels !== undefined)
|
|
236
|
+
command.push('-ac', String(args.channels));
|
|
237
|
+
command.push(outFile);
|
|
238
|
+
const pass = await runCommand(host, { command: ffmpeg, args: command, signal: context?.signal });
|
|
239
|
+
if (!pass.ok) {
|
|
240
|
+
if (/ENOENT|not found|is not recognized/i.test(pass.message)) {
|
|
241
|
+
return unsupported('ffmpeg is not available: ' + pass.message, ['Install ffmpeg (https://ffmpeg.org/) and put it on PATH, or configure the ffmpeg path for this host.']);
|
|
242
|
+
}
|
|
243
|
+
return rejected('conversion_failed', 'ffmpeg conversion failed: ' + pass.message);
|
|
244
|
+
}
|
|
245
|
+
if (!(await sourceExists(host, outFile))) {
|
|
246
|
+
return rejected('output_missing', 'Conversion completed but the output file was not found: ' + outFile);
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
ok: true,
|
|
250
|
+
status: 'success',
|
|
251
|
+
source: SOURCE,
|
|
252
|
+
data: { success: true, message: 'Audio converted to ' + targetFormat.toUpperCase() + ': ' + outFile, outputFile: outFile },
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// ─── deploy_mod_asset ──────────────────────────────────────────────────────
|
|
256
|
+
async function deployModAssetWithHost(host, args, context) {
|
|
257
|
+
const denied = (0, writes_1.ensureToolWriteAllowed)(host, 'deploy_mod_asset');
|
|
258
|
+
if (denied)
|
|
259
|
+
return denied;
|
|
260
|
+
(0, lsp_1.throwIfAborted)(context?.signal);
|
|
261
|
+
const unsupportedField = unsupportedFields(args, exports.DEPLOY_MOD_ASSET_FIELDS, 'deploy_mod_asset');
|
|
262
|
+
if (unsupportedField)
|
|
263
|
+
return rejected('invalid_arguments', unsupportedField);
|
|
264
|
+
if (args.overwrite !== undefined && typeof args.overwrite !== 'boolean') {
|
|
265
|
+
return rejected('invalid_arguments', 'overwrite must be a boolean.');
|
|
266
|
+
}
|
|
267
|
+
const source = resolveInside(host, args.sourcePath);
|
|
268
|
+
if (!source.ok)
|
|
269
|
+
return rejected('outside_workspace', source.message);
|
|
270
|
+
if (!(await sourceExists(host, source.resolvedPath))) {
|
|
271
|
+
return rejected('source_not_found', 'Source file not found: ' + String(args.sourcePath));
|
|
272
|
+
}
|
|
273
|
+
const target = resolveInside(host, args.targetRelativePath);
|
|
274
|
+
if (!target.ok)
|
|
275
|
+
return rejected('outside_workspace', target.message);
|
|
276
|
+
// A trailing separator or dot segment would aim at a directory; deployment copies one file.
|
|
277
|
+
if (/[\\/]$/.test(String(args.targetRelativePath).trim()) || target.resolvedPath === (0, paths_1.normalizeWorkspaceRoot)(host.workspaceRoot)) {
|
|
278
|
+
return rejected('invalid_target', 'targetRelativePath must name a file inside the workspace.');
|
|
279
|
+
}
|
|
280
|
+
const targetDir = path.dirname(target.resolvedPath);
|
|
281
|
+
const targetName = path.basename(target.resolvedPath);
|
|
282
|
+
if (!targetName || targetName === '.' || targetName === '..') {
|
|
283
|
+
return rejected('invalid_target', 'targetRelativePath must name a file.');
|
|
284
|
+
}
|
|
285
|
+
const listing = await host.filesystem.list(targetDir).catch(() => undefined);
|
|
286
|
+
const existing = listing?.find(entry => entry.name === targetName);
|
|
287
|
+
if (existing && existing.type === 'directory') {
|
|
288
|
+
return rejected('invalid_target', 'Target path is an existing directory: ' + target.relativePath);
|
|
289
|
+
}
|
|
290
|
+
if (existing && args.overwrite !== true) {
|
|
291
|
+
return rejected('target_exists', 'Target file already exists: ' + target.resolvedPath + '. Set overwrite=true to replace it.');
|
|
292
|
+
}
|
|
293
|
+
if (context?.signal)
|
|
294
|
+
(0, lsp_1.throwIfAborted)(context.signal);
|
|
295
|
+
try {
|
|
296
|
+
if (host.filesystem.readBinaryFile && host.filesystem.writeBinaryFile) {
|
|
297
|
+
const content = await host.filesystem.readBinaryFile(source.resolvedPath);
|
|
298
|
+
await host.filesystem.writeBinaryFile(target.resolvedPath, content);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
const content = await host.filesystem.readTextFile(source.resolvedPath);
|
|
302
|
+
if (!content.exists)
|
|
303
|
+
return rejected('source_unreadable', 'Source file could not be read: ' + source.relativePath);
|
|
304
|
+
await host.filesystem.writeTextFile(target.resolvedPath, content.content);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
return rejected('deploy_failed', 'Failed to deploy asset: ' + errorText(error));
|
|
309
|
+
}
|
|
310
|
+
await host.indexing?.invalidate?.(target.resolvedPath);
|
|
311
|
+
return {
|
|
312
|
+
ok: true,
|
|
313
|
+
status: 'success',
|
|
314
|
+
source: SOURCE,
|
|
315
|
+
data: {
|
|
316
|
+
success: true,
|
|
317
|
+
message: 'Asset deployed: ' + target.relativePath,
|
|
318
|
+
finalPath: target.resolvedPath,
|
|
319
|
+
writtenFiles: [target.resolvedPath],
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
}
|
package/dist/tools/names.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare const MCP_READONLY_TOOL_NAMES: readonly ["query_types", "query_rules", "query_cwt_schema", "search_rule_capabilities", "explain_scope", "parse_pdx_fragment", "query_scope", "get_diagnostics", "analyze_diagnostic_error", "query_project_profile", "query_project_knowledge", "query_workspace_index", "explore_pdx_project", "query_inline_instantiation", "analyze_pdx_flow", "compare_definition_with_vanilla", "query_targeting_weight", "query_localisation_index", "get_pdx_block", "get_completion_at", "document_symbols", "workspace_symbols", "go_to_definition", "find_references", "query_scripted_effects", "query_scripted_triggers", "query_enums", "query_static_modifiers", "query_variables", "get_entity_info", "query_shader_symbol", "query_shader_compile_unit", "query_shader_platform_variants", "query_shader_callers", "explain_shader_reachability", "validate_shader", "compare_shader_with_vanilla", "get_ide_context", "open_in_visual_editor"];
|
|
2
|
-
export declare const MCP_WRITE_TOOL_NAMES: readonly ["write_localisation", "typed_pdx_write", "candidate_transaction", "convert_image_to_dds", "convert_audio", "deploy_mod_asset"];
|
|
3
|
-
export declare const MCP_TOOL_NAMES: readonly ["query_types", "query_rules", "query_cwt_schema", "search_rule_capabilities", "explain_scope", "parse_pdx_fragment", "query_scope", "get_diagnostics", "analyze_diagnostic_error", "query_project_profile", "query_project_knowledge", "query_workspace_index", "explore_pdx_project", "query_inline_instantiation", "analyze_pdx_flow", "compare_definition_with_vanilla", "query_targeting_weight", "query_localisation_index", "get_pdx_block", "get_completion_at", "document_symbols", "workspace_symbols", "go_to_definition", "find_references", "query_scripted_effects", "query_scripted_triggers", "query_enums", "query_static_modifiers", "query_variables", "get_entity_info", "query_shader_symbol", "query_shader_compile_unit", "query_shader_platform_variants", "query_shader_callers", "explain_shader_reachability", "validate_shader", "compare_shader_with_vanilla", "get_ide_context", "open_in_visual_editor"];
|
|
4
|
-
export declare const MCP_ALL_TOOL_NAMES: readonly ["query_types", "query_rules", "query_cwt_schema", "search_rule_capabilities", "explain_scope", "parse_pdx_fragment", "query_scope", "get_diagnostics", "analyze_diagnostic_error", "query_project_profile", "query_project_knowledge", "query_workspace_index", "explore_pdx_project", "query_inline_instantiation", "analyze_pdx_flow", "compare_definition_with_vanilla", "query_targeting_weight", "query_localisation_index", "get_pdx_block", "get_completion_at", "document_symbols", "workspace_symbols", "go_to_definition", "find_references", "query_scripted_effects", "query_scripted_triggers", "query_enums", "query_static_modifiers", "query_variables", "get_entity_info", "query_shader_symbol", "query_shader_compile_unit", "query_shader_platform_variants", "query_shader_callers", "explain_shader_reachability", "validate_shader", "compare_shader_with_vanilla", "get_ide_context", "open_in_visual_editor", "write_localisation", "typed_pdx_write", "candidate_transaction", "convert_image_to_dds", "convert_audio", "deploy_mod_asset"];
|
|
1
|
+
export declare const MCP_READONLY_TOOL_NAMES: readonly ["query_types", "query_rules", "query_cwt_schema", "query_override_modes", "search_rule_capabilities", "explain_scope", "parse_pdx_fragment", "query_scope", "get_diagnostics", "analyze_diagnostic_error", "get_lsp_status", "get_ignored_diagnostics", "query_project_profile", "query_project_knowledge", "query_interface_knowledge", "query_workspace_index", "explore_pdx_project", "query_inline_instantiation", "analyze_pdx_flow", "compare_definition_with_vanilla", "query_targeting_weight", "query_localisation_index", "get_pdx_block", "verify_pdx_identifier", "find_scope_bridge", "extract_archetype_slots", "instantiate_archetype", "get_completion_at", "document_symbols", "workspace_symbols", "go_to_definition", "find_references", "query_scripted_effects", "query_scripted_triggers", "query_enums", "query_static_modifiers", "query_variables", "get_entity_info", "find_sprite_candidates", "find_sound_candidates", "query_shader_symbol", "query_shader_compile_unit", "query_shader_platform_variants", "query_shader_callers", "explain_shader_reachability", "validate_shader", "compare_shader_with_vanilla", "get_ide_context", "open_in_visual_editor", "capture_gui_preview"];
|
|
2
|
+
export declare const MCP_WRITE_TOOL_NAMES: readonly ["write_localisation", "typed_pdx_write", "candidate_transaction", "convert_image_to_dds", "convert_audio", "deploy_mod_asset", "remove_ignored_diagnostic", "initialize_project"];
|
|
3
|
+
export declare const MCP_TOOL_NAMES: readonly ["query_types", "query_rules", "query_cwt_schema", "query_override_modes", "search_rule_capabilities", "explain_scope", "parse_pdx_fragment", "query_scope", "get_diagnostics", "analyze_diagnostic_error", "get_lsp_status", "get_ignored_diagnostics", "query_project_profile", "query_project_knowledge", "query_interface_knowledge", "query_workspace_index", "explore_pdx_project", "query_inline_instantiation", "analyze_pdx_flow", "compare_definition_with_vanilla", "query_targeting_weight", "query_localisation_index", "get_pdx_block", "verify_pdx_identifier", "find_scope_bridge", "extract_archetype_slots", "instantiate_archetype", "get_completion_at", "document_symbols", "workspace_symbols", "go_to_definition", "find_references", "query_scripted_effects", "query_scripted_triggers", "query_enums", "query_static_modifiers", "query_variables", "get_entity_info", "find_sprite_candidates", "find_sound_candidates", "query_shader_symbol", "query_shader_compile_unit", "query_shader_platform_variants", "query_shader_callers", "explain_shader_reachability", "validate_shader", "compare_shader_with_vanilla", "get_ide_context", "open_in_visual_editor", "capture_gui_preview"];
|
|
4
|
+
export declare const MCP_ALL_TOOL_NAMES: readonly ["query_types", "query_rules", "query_cwt_schema", "query_override_modes", "search_rule_capabilities", "explain_scope", "parse_pdx_fragment", "query_scope", "get_diagnostics", "analyze_diagnostic_error", "get_lsp_status", "get_ignored_diagnostics", "query_project_profile", "query_project_knowledge", "query_interface_knowledge", "query_workspace_index", "explore_pdx_project", "query_inline_instantiation", "analyze_pdx_flow", "compare_definition_with_vanilla", "query_targeting_weight", "query_localisation_index", "get_pdx_block", "verify_pdx_identifier", "find_scope_bridge", "extract_archetype_slots", "instantiate_archetype", "get_completion_at", "document_symbols", "workspace_symbols", "go_to_definition", "find_references", "query_scripted_effects", "query_scripted_triggers", "query_enums", "query_static_modifiers", "query_variables", "get_entity_info", "find_sprite_candidates", "find_sound_candidates", "query_shader_symbol", "query_shader_compile_unit", "query_shader_platform_variants", "query_shader_callers", "explain_shader_reachability", "validate_shader", "compare_shader_with_vanilla", "get_ide_context", "open_in_visual_editor", "capture_gui_preview", "write_localisation", "typed_pdx_write", "candidate_transaction", "convert_image_to_dds", "convert_audio", "deploy_mod_asset", "remove_ignored_diagnostic", "initialize_project"];
|
|
5
5
|
export type McpToolName = typeof MCP_ALL_TOOL_NAMES[number];
|
|
6
6
|
export declare function isMcpToolName(value: string, options?: {
|
|
7
7
|
includeWrites?: boolean;
|
package/dist/tools/names.js
CHANGED
|
@@ -7,14 +7,18 @@ exports.MCP_READONLY_TOOL_NAMES = [
|
|
|
7
7
|
'query_types',
|
|
8
8
|
'query_rules',
|
|
9
9
|
'query_cwt_schema',
|
|
10
|
+
'query_override_modes',
|
|
10
11
|
'search_rule_capabilities',
|
|
11
12
|
'explain_scope',
|
|
12
13
|
'parse_pdx_fragment',
|
|
13
14
|
'query_scope',
|
|
14
15
|
'get_diagnostics',
|
|
15
16
|
'analyze_diagnostic_error',
|
|
17
|
+
'get_lsp_status',
|
|
18
|
+
'get_ignored_diagnostics',
|
|
16
19
|
'query_project_profile',
|
|
17
20
|
'query_project_knowledge',
|
|
21
|
+
'query_interface_knowledge',
|
|
18
22
|
'query_workspace_index',
|
|
19
23
|
'explore_pdx_project',
|
|
20
24
|
'query_inline_instantiation',
|
|
@@ -23,6 +27,10 @@ exports.MCP_READONLY_TOOL_NAMES = [
|
|
|
23
27
|
'query_targeting_weight',
|
|
24
28
|
'query_localisation_index',
|
|
25
29
|
'get_pdx_block',
|
|
30
|
+
'verify_pdx_identifier',
|
|
31
|
+
'find_scope_bridge',
|
|
32
|
+
'extract_archetype_slots',
|
|
33
|
+
'instantiate_archetype',
|
|
26
34
|
'get_completion_at',
|
|
27
35
|
'document_symbols',
|
|
28
36
|
'workspace_symbols',
|
|
@@ -34,6 +42,8 @@ exports.MCP_READONLY_TOOL_NAMES = [
|
|
|
34
42
|
'query_static_modifiers',
|
|
35
43
|
'query_variables',
|
|
36
44
|
'get_entity_info',
|
|
45
|
+
'find_sprite_candidates',
|
|
46
|
+
'find_sound_candidates',
|
|
37
47
|
'query_shader_symbol',
|
|
38
48
|
'query_shader_compile_unit',
|
|
39
49
|
'query_shader_platform_variants',
|
|
@@ -43,6 +53,7 @@ exports.MCP_READONLY_TOOL_NAMES = [
|
|
|
43
53
|
'compare_shader_with_vanilla',
|
|
44
54
|
'get_ide_context',
|
|
45
55
|
'open_in_visual_editor',
|
|
56
|
+
'capture_gui_preview',
|
|
46
57
|
];
|
|
47
58
|
exports.MCP_WRITE_TOOL_NAMES = [
|
|
48
59
|
'write_localisation',
|
|
@@ -51,6 +62,8 @@ exports.MCP_WRITE_TOOL_NAMES = [
|
|
|
51
62
|
'convert_image_to_dds',
|
|
52
63
|
'convert_audio',
|
|
53
64
|
'deploy_mod_asset',
|
|
65
|
+
'remove_ignored_diagnostic',
|
|
66
|
+
'initialize_project',
|
|
54
67
|
];
|
|
55
68
|
exports.MCP_TOOL_NAMES = exports.MCP_READONLY_TOOL_NAMES;
|
|
56
69
|
exports.MCP_ALL_TOOL_NAMES = [
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed PDXScript mutation builders (pure text -> candidate content transforms).
|
|
3
|
+
*
|
|
4
|
+
* Shared by the MCP server and the VS Code agent so both surfaces accept exactly
|
|
5
|
+
* the same operation vocabulary. Never performs I/O; the caller reads the file
|
|
6
|
+
* and commits the returned candidate through the write pipeline. Every
|
|
7
|
+
* operation is bounded and rejects raw code, unknown fields and duplicate
|
|
8
|
+
* targets instead of guessing a match.
|
|
9
|
+
*/
|
|
10
|
+
export type PdxValue = {
|
|
11
|
+
kind: 'identifier' | 'string';
|
|
12
|
+
value: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'number';
|
|
15
|
+
value: number;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'boolean';
|
|
18
|
+
value: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'list';
|
|
21
|
+
values: PdxValue[];
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'block';
|
|
24
|
+
entries: PdxEntry[];
|
|
25
|
+
};
|
|
26
|
+
export interface PdxEntry {
|
|
27
|
+
key: string;
|
|
28
|
+
value: PdxValue;
|
|
29
|
+
}
|
|
30
|
+
export interface PdxPathSegment {
|
|
31
|
+
key: string;
|
|
32
|
+
occurrence: number;
|
|
33
|
+
}
|
|
34
|
+
export interface TypedPdxCandidate {
|
|
35
|
+
filePath: string;
|
|
36
|
+
beforeHash: string;
|
|
37
|
+
contentHash: string;
|
|
38
|
+
content: string;
|
|
39
|
+
summary: string;
|
|
40
|
+
targetRange: {
|
|
41
|
+
start: number;
|
|
42
|
+
end: number;
|
|
43
|
+
};
|
|
44
|
+
operation: Record<string, unknown>;
|
|
45
|
+
diff: {
|
|
46
|
+
added: number;
|
|
47
|
+
removed: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare function sha256Text(text: string): string;
|
|
51
|
+
export declare function buildTypedPdxCandidate(filePath: string, text: string, operation: Record<string, unknown>, expectedHash?: string): TypedPdxCandidate;
|