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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HostServices } from '../host/hostServices';
|
|
2
|
+
import type { SharedToolResult } from './schema';
|
|
3
|
+
export declare function queryInterfaceKnowledgeWithHost(_host: HostServices, args: Record<string, unknown>): Promise<SharedToolResult>;
|
|
4
|
+
export declare function findScopeBridgeWithHost(host: HostServices, args: Record<string, unknown>): Promise<SharedToolResult>;
|
|
5
|
+
export declare function findAssetCandidatesWithHost(host: HostServices, rawArgs: Record<string, unknown>, kind: 'sprite' | 'sound'): Promise<SharedToolResult>;
|
|
6
|
+
export declare function getIgnoredDiagnosticsWithHost(host: HostServices): Promise<SharedToolResult>;
|
|
7
|
+
export declare function removeIgnoredDiagnosticWithHost(host: HostServices, args: Record<string, unknown>): Promise<SharedToolResult>;
|
|
8
|
+
export declare function verifyPdxIdentifierWithHost(host: HostServices, args: Record<string, unknown>): Promise<SharedToolResult>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.queryInterfaceKnowledgeWithHost = queryInterfaceKnowledgeWithHost;
|
|
4
|
+
exports.findScopeBridgeWithHost = findScopeBridgeWithHost;
|
|
5
|
+
exports.findAssetCandidatesWithHost = findAssetCandidatesWithHost;
|
|
6
|
+
exports.getIgnoredDiagnosticsWithHost = getIgnoredDiagnosticsWithHost;
|
|
7
|
+
exports.removeIgnoredDiagnosticWithHost = removeIgnoredDiagnosticWithHost;
|
|
8
|
+
exports.verifyPdxIdentifierWithHost = verifyPdxIdentifierWithHost;
|
|
9
|
+
const interfaceKnowledge_1 = require("../knowledge/interfaceKnowledge");
|
|
10
|
+
const rules_1 = require("../knowledge/rules");
|
|
11
|
+
const scopeBridge_1 = require("./scopeBridge");
|
|
12
|
+
const symbols_1 = require("./symbols");
|
|
13
|
+
function asRecord(value) {
|
|
14
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
15
|
+
}
|
|
16
|
+
function result(data, source = 'cwtools-domain') {
|
|
17
|
+
return { ok: true, status: 'ready', source, data };
|
|
18
|
+
}
|
|
19
|
+
async function queryInterfaceKnowledgeWithHost(_host, args) {
|
|
20
|
+
return result((0, interfaceKnowledge_1.queryInterfaceKnowledge)(args), 'cwtools-interface-knowledge');
|
|
21
|
+
}
|
|
22
|
+
async function findScopeBridgeWithHost(host, args) {
|
|
23
|
+
const fromScope = typeof args.fromScope === 'string' ? args.fromScope.trim() : '';
|
|
24
|
+
const toScope = typeof args.toScope === 'string' ? args.toScope.trim() : '';
|
|
25
|
+
const intent = typeof args.context === 'string' ? args.context : '';
|
|
26
|
+
if (!fromScope || !toScope) {
|
|
27
|
+
return { ok: false, status: 'error', source: 'cwtools-scope-bridge', error: { code: 'invalid_arguments', message: 'fromScope and toScope are required.' } };
|
|
28
|
+
}
|
|
29
|
+
const [outgoing, incoming, intermediate] = await Promise.all([
|
|
30
|
+
(0, rules_1.searchRuleCapabilitiesWithHost)(host, { intent, category: 'scope_change', currentScope: fromScope, limit: 50 }),
|
|
31
|
+
(0, rules_1.searchRuleCapabilitiesWithHost)(host, { intent: intent + ' scope transition bridge', category: 'scope_change', desiredPushScope: toScope, limit: 50 }),
|
|
32
|
+
(0, rules_1.searchRuleCapabilitiesWithHost)(host, { intent: intent + ' intermediate scope transitions', category: 'scope_change', limit: 50 }),
|
|
33
|
+
]);
|
|
34
|
+
const evidence = [outgoing, intermediate, incoming].map(item => item.data).filter((item) => !!item);
|
|
35
|
+
const candidates = evidence.flatMap(pack => pack.candidates.flatMap(candidate => {
|
|
36
|
+
const file = candidate.rule.sourceFile ?? candidate.rule.hardFacts?.cwtSource?.file;
|
|
37
|
+
const line = candidate.rule.sourceLine ?? candidate.rule.hardFacts?.cwtSource?.line;
|
|
38
|
+
if (!file || line === undefined)
|
|
39
|
+
return [];
|
|
40
|
+
return [{
|
|
41
|
+
name: candidate.rule.name,
|
|
42
|
+
supportedScopes: candidate.rule.hardFacts?.supportedScopes ?? candidate.rule.scopes,
|
|
43
|
+
pushScope: candidate.rule.hardFacts?.pushScope,
|
|
44
|
+
evidence: [pack.source + ':' + file + ':' + line, ...(pack.rulesContentHash ? ['rules-sha256:' + pack.rulesContentHash] : [])],
|
|
45
|
+
}];
|
|
46
|
+
})).slice(0, 200);
|
|
47
|
+
return result({
|
|
48
|
+
...(0, scopeBridge_1.solveScopeBridge)({ fromScope, toScope, candidates }),
|
|
49
|
+
evidenceSource: 'cwtools-node-rules',
|
|
50
|
+
rulesContentHash: evidence.find(pack => pack.rulesContentHash)?.rulesContentHash,
|
|
51
|
+
}, 'cwtools-scope-bridge');
|
|
52
|
+
}
|
|
53
|
+
function unique(values) {
|
|
54
|
+
return [...new Set(values)].sort();
|
|
55
|
+
}
|
|
56
|
+
async function findAssetCandidatesWithHost(host, rawArgs, kind) {
|
|
57
|
+
if (!host.indexing) {
|
|
58
|
+
return { ok: false, status: 'unavailable', source: 'cwtools-assets', error: { code: 'index_unavailable', message: 'The active host has no workspace/vanilla asset index.' } };
|
|
59
|
+
}
|
|
60
|
+
const args = rawArgs;
|
|
61
|
+
const limit = Math.max(1, Math.min(typeof args.limit === 'number' ? Math.floor(args.limit) : 20, 50));
|
|
62
|
+
const searchContext = args.searchContext === 'mod' || args.searchContext === 'vanilla' ? args.searchContext : 'both';
|
|
63
|
+
const current = typeof args.currentValue === 'string' ? args.currentValue.trim().replace(/^"|"$/g, '') : '';
|
|
64
|
+
const rawQuery = typeof args.query === 'string' ? args.query.trim() : '';
|
|
65
|
+
const field = typeof args.fieldName === 'string' ? args.fieldName.toLowerCase() : '';
|
|
66
|
+
const stop = new Set(kind === 'sprite' ? ['gfx', 'sprite', 'type', 'picture', 'icon', 'image'] : ['sound', 'show', 'music', 'asset', 'event', 'audio', 'snd']);
|
|
67
|
+
const terms = unique((rawQuery + ' ' + current + ' ' + field).toLowerCase().replace(/[^a-z0-9]+/g, ' ').split(/\s+/)
|
|
68
|
+
.filter(term => term.length >= 3 && !stop.has(term)));
|
|
69
|
+
const query = rawQuery || current || terms.join(' ');
|
|
70
|
+
await host.indexing.ensureReady?.();
|
|
71
|
+
const origins = searchContext === 'both' ? ['workspace', 'vanilla'] : [searchContext === 'mod' ? 'workspace' : 'vanilla'];
|
|
72
|
+
const packs = await Promise.all(origins.map(origin => host.indexing.queryWorkspace({
|
|
73
|
+
name: current || terms[0] || rawQuery || undefined,
|
|
74
|
+
kind,
|
|
75
|
+
source: 'asset',
|
|
76
|
+
origin,
|
|
77
|
+
includeReferences: true,
|
|
78
|
+
limit: limit * 5,
|
|
79
|
+
})));
|
|
80
|
+
const candidates = new Map();
|
|
81
|
+
for (const pack of packs) {
|
|
82
|
+
for (const entry of pack.entries) {
|
|
83
|
+
const source = entry.origin === 'vanilla' ? 'vanilla' : 'mod';
|
|
84
|
+
const reference = entry.references?.map(item => item.context).find(value => kind === 'sprite' ? /texturefile/i.test(value) : /\bfiles?\s*=/i.test(value));
|
|
85
|
+
let score = source === 'mod' ? 55 : 35;
|
|
86
|
+
const matchedBy = ['workspace-index'];
|
|
87
|
+
const lowerName = entry.name.toLowerCase();
|
|
88
|
+
const lowerCurrent = current.toLowerCase().replace(/^gfx_/, '');
|
|
89
|
+
if (lowerCurrent && lowerName === current.toLowerCase()) {
|
|
90
|
+
score += 120;
|
|
91
|
+
matchedBy.push('exact-current-value');
|
|
92
|
+
}
|
|
93
|
+
else if (lowerCurrent && lowerName.includes(lowerCurrent)) {
|
|
94
|
+
score += 40;
|
|
95
|
+
matchedBy.push('current-value-fragment');
|
|
96
|
+
}
|
|
97
|
+
for (const term of terms) {
|
|
98
|
+
if (lowerName.includes(term)) {
|
|
99
|
+
score += 18;
|
|
100
|
+
matchedBy.push('name:' + term);
|
|
101
|
+
}
|
|
102
|
+
else if (reference?.toLowerCase().includes(term)) {
|
|
103
|
+
score += 8;
|
|
104
|
+
matchedBy.push('reference:' + term);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (kind === 'sound' && /show_sound|sound/.test(field) && /\.wav\b|sfx|event|ui|interface/i.test(reference ?? ''))
|
|
108
|
+
score += 15;
|
|
109
|
+
if (terms.length > 0 && matchedBy.length === 1 && lowerName !== current.toLowerCase())
|
|
110
|
+
continue;
|
|
111
|
+
const key = source + '|' + lowerName;
|
|
112
|
+
const candidate = {
|
|
113
|
+
name: entry.name, source, file: entry.file, line: entry.line, score,
|
|
114
|
+
matchedBy: unique(matchedBy), container: entry.container, reference,
|
|
115
|
+
};
|
|
116
|
+
const existing = candidates.get(key);
|
|
117
|
+
if (!existing || candidate.score > existing.score)
|
|
118
|
+
candidates.set(key, candidate);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const sorted = [...candidates.values()].sort((a, b) => b.score - a.score || a.name.localeCompare(b.name)).slice(0, limit);
|
|
122
|
+
const status = packs.some(pack => pack.status === 'error' || pack.status === 'unavailable') ? 'partial' : 'ready';
|
|
123
|
+
return {
|
|
124
|
+
ok: true,
|
|
125
|
+
status,
|
|
126
|
+
source: 'cwtools-index',
|
|
127
|
+
data: {
|
|
128
|
+
query,
|
|
129
|
+
candidates: sorted,
|
|
130
|
+
searchedRoots: packs.map(pack => pack.status === 'ready' ? 'IndexService:' + kind : 'IndexService:' + pack.status),
|
|
131
|
+
_warning: sorted.length === 0 ? 'No verified ' + kind + ' candidates found; broaden the query and searchContext before inventing an asset name.' : undefined,
|
|
132
|
+
},
|
|
133
|
+
warnings: sorted.length === 0 ? ['Do not guess a replacement asset identifier from a file name alone.'] : undefined,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async function getIgnoredDiagnosticsWithHost(host) {
|
|
137
|
+
if (!host.diagnosticSettings) {
|
|
138
|
+
return { ok: false, status: 'unavailable', source: 'cwtools-diagnostics', error: { code: 'settings_unavailable', message: 'The active host does not expose diagnostic ignore settings.' } };
|
|
139
|
+
}
|
|
140
|
+
const ignoredKeys = (await host.diagnosticSettings.getIgnoredKeys()).map(key => key.trim()).filter(Boolean).sort();
|
|
141
|
+
const diagnostics = await host.diagnostics.getDiagnostics({ limit: 1000 }).catch(() => undefined);
|
|
142
|
+
const all = diagnostics?.diagnostics ?? [];
|
|
143
|
+
const audit = ignoredKeys.map(key => {
|
|
144
|
+
const lower = key.toLowerCase();
|
|
145
|
+
const hits = all.filter(item => (item.code ?? '').toLowerCase() === lower || item.message.toLowerCase().includes(lower) || (item.source ?? '').toLowerCase().includes(lower));
|
|
146
|
+
return { key, stillHits: hits.length > 0, matchCount: hits.length, category: hits.length > 0 ? 'matched' : 'unmatched' };
|
|
147
|
+
});
|
|
148
|
+
return result({ success: true, count: ignoredKeys.length, ignoredKeys, audit }, 'cwtools-diagnostics');
|
|
149
|
+
}
|
|
150
|
+
async function removeIgnoredDiagnosticWithHost(host, args) {
|
|
151
|
+
const key = typeof args.diagnosticKey === 'string' ? args.diagnosticKey.trim() : '';
|
|
152
|
+
if (!key)
|
|
153
|
+
return { ok: false, status: 'error', source: 'cwtools-diagnostics', error: { code: 'invalid_arguments', message: 'diagnosticKey is required.' } };
|
|
154
|
+
if (!host.diagnosticSettings)
|
|
155
|
+
return { ok: false, status: 'unavailable', source: 'cwtools-diagnostics', error: { code: 'settings_unavailable', message: 'The active host does not expose diagnostic ignore settings.' } };
|
|
156
|
+
await host.diagnosticSettings.removeIgnoredKey(key);
|
|
157
|
+
return result({ success: true, diagnosticKey: key, message: 'Diagnostic key removed from the workspace ignore list.' }, 'cwtools-diagnostics');
|
|
158
|
+
}
|
|
159
|
+
function collectMatches(value, identifier, matches, depth = 0) {
|
|
160
|
+
if (matches.length >= 100 || depth > 6)
|
|
161
|
+
return;
|
|
162
|
+
if (Array.isArray(value)) {
|
|
163
|
+
for (const item of value.slice(0, 200))
|
|
164
|
+
collectMatches(item, identifier, matches, depth + 1);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const record = asRecord(value);
|
|
168
|
+
if (Object.keys(record).length === 0)
|
|
169
|
+
return;
|
|
170
|
+
const name = ['name', 'id', 'symbolName', 'key'].map(key => record[key]).find(item => typeof item === 'string');
|
|
171
|
+
if (typeof name === 'string' && name.toLowerCase() === identifier.toLowerCase())
|
|
172
|
+
matches.push(record);
|
|
173
|
+
for (const item of Object.values(record).slice(0, 100)) {
|
|
174
|
+
if (typeof item === 'object' && item !== null)
|
|
175
|
+
collectMatches(item, identifier, matches, depth + 1);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function verifyPdxIdentifierWithHost(host, args) {
|
|
179
|
+
const identifier = typeof args.identifier === 'string' ? args.identifier.trim() : '';
|
|
180
|
+
if (!identifier)
|
|
181
|
+
return { ok: false, status: 'error', source: 'cwtools-verify-id', error: { code: 'invalid_arguments', message: 'identifier is required.' } };
|
|
182
|
+
const limit = Math.max(1, Math.min(typeof args.limit === 'number' ? Math.floor(args.limit) : 20, 50));
|
|
183
|
+
const typeName = typeof args.typeName === 'string' ? args.typeName.trim() : '';
|
|
184
|
+
const [definition, symbols] = await Promise.all([
|
|
185
|
+
(0, symbols_1.queryDefinitionByNameWithHost)(host, { symbolName: identifier }).catch(error => ({ ok: false, error })),
|
|
186
|
+
(0, symbols_1.workspaceSymbolsWithHost)(host, { query: identifier, limit }).catch(error => ({ ok: false, error })),
|
|
187
|
+
]);
|
|
188
|
+
const matches = [];
|
|
189
|
+
const definitionData = 'data' in definition ? definition.data : undefined;
|
|
190
|
+
const symbolsData = 'data' in symbols ? symbols.data : undefined;
|
|
191
|
+
collectMatches(definitionData, identifier, matches);
|
|
192
|
+
collectMatches(symbolsData, identifier, matches);
|
|
193
|
+
const evidence = [
|
|
194
|
+
{ source: 'go_to_definition', status: definition.ok ? 'found' : 'not_found', summary: definition.ok ? 'Definition lookup returned an exact match.' : 'No authoritative definition match.' },
|
|
195
|
+
{ source: 'workspace_symbols', status: symbols.ok && collectSymbolMatch(symbolsData, identifier) ? 'found' : 'not_found', summary: 'Workspace symbol lookup completed.' },
|
|
196
|
+
];
|
|
197
|
+
if (typeName) {
|
|
198
|
+
const typed = await host.lsp.executeCommand('cwtools.ai.queryTypes', [typeName, identifier, limit, args.includeVanilla !== false]);
|
|
199
|
+
collectMatches(typed, identifier, matches);
|
|
200
|
+
evidence.push({ source: 'query_types', status: matches.length > 0 ? 'found' : 'not_found', summary: 'Queried exact ' + typeName + ' instances.' });
|
|
201
|
+
}
|
|
202
|
+
if (host.indexing) {
|
|
203
|
+
const indexed = await host.indexing.queryWorkspace({ name: identifier, exact: true, origin: args.includeVanilla === false ? 'workspace' : 'both', limit });
|
|
204
|
+
matches.push(...indexed.entries.map(entry => ({ ...entry })));
|
|
205
|
+
evidence.push({ source: 'workspace_index', status: indexed.entries.length > 0 ? 'found' : 'not_found', summary: 'Exact indexed identifier lookup completed.' });
|
|
206
|
+
}
|
|
207
|
+
const found = matches.length > 0 || evidence.some(item => item.status === 'found');
|
|
208
|
+
return result({
|
|
209
|
+
identifier,
|
|
210
|
+
status: found ? 'found' : 'not_found',
|
|
211
|
+
confidence: definition.ok || typeName ? 'high' : 'medium',
|
|
212
|
+
canTreatAsMissing: !found,
|
|
213
|
+
evidence,
|
|
214
|
+
matches: matches.slice(0, limit),
|
|
215
|
+
nextSteps: found ? [] : ['Only treat this as missing for the current project, selected type, and loaded vanilla context.'],
|
|
216
|
+
}, 'cwtools-verify-id');
|
|
217
|
+
}
|
|
218
|
+
function collectSymbolMatch(data, identifier) {
|
|
219
|
+
const matches = [];
|
|
220
|
+
collectMatches(data, identifier, matches);
|
|
221
|
+
return matches.length > 0;
|
|
222
|
+
}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import { type McpToolName } from './names';
|
|
1
2
|
import type { GeneratedMcpTool, McpToolSchema } from './schema';
|
|
2
|
-
|
|
3
|
-
export
|
|
3
|
+
import type { CwtoolsHostCapability } from '../host/hostServices';
|
|
4
|
+
export interface ToolSurfaceOptions {
|
|
4
5
|
includeWrites?: boolean;
|
|
5
|
-
|
|
6
|
+
cwtOnly?: boolean;
|
|
7
|
+
capabilities?: ReadonlySet<CwtoolsHostCapability>;
|
|
8
|
+
}
|
|
9
|
+
export declare function getGeneratedMcpTools(): readonly GeneratedMcpTool[];
|
|
10
|
+
export declare function listMcpToolSchemas(options?: ToolSurfaceOptions): McpToolSchema[];
|
|
11
|
+
export declare function isMcpToolAvailable(value: string, options?: ToolSurfaceOptions): value is McpToolName;
|
|
12
|
+
/**
|
|
13
|
+
* Transport-neutral aliases.
|
|
14
|
+
*
|
|
15
|
+
* The schema surface is consumed by hosts that have nothing to do with MCP (the
|
|
16
|
+
* Node host, an editor integration, an external agent runtime). Those callers ask
|
|
17
|
+
* for "CWTools tools", not "MCP tools", so the neutral names are the preferred
|
|
18
|
+
* spelling and the MCP-prefixed functions above remain for compatibility.
|
|
19
|
+
*/
|
|
20
|
+
export declare const listCwtoolsToolSchemas: typeof listMcpToolSchemas;
|
|
21
|
+
export declare function isCwtoolsToolAvailable(value: string, options?: ToolSurfaceOptions): value is McpToolName;
|
|
22
|
+
export declare function getCwtoolsToolSchema(name: string): McpToolSchema | undefined;
|
|
6
23
|
export declare function getMcpToolSchema(name: string): McpToolSchema | undefined;
|
|
7
24
|
export declare function getMcpToolRegistryMetadata(name: string): GeneratedMcpTool['registry'] | undefined;
|
package/dist/tools/mcpSchema.js
CHANGED
|
@@ -1,23 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listCwtoolsToolSchemas = void 0;
|
|
3
4
|
exports.getGeneratedMcpTools = getGeneratedMcpTools;
|
|
4
5
|
exports.listMcpToolSchemas = listMcpToolSchemas;
|
|
6
|
+
exports.isMcpToolAvailable = isMcpToolAvailable;
|
|
7
|
+
exports.isCwtoolsToolAvailable = isCwtoolsToolAvailable;
|
|
8
|
+
exports.getCwtoolsToolSchema = getCwtoolsToolSchema;
|
|
5
9
|
exports.getMcpToolSchema = getMcpToolSchema;
|
|
6
10
|
exports.getMcpToolRegistryMetadata = getMcpToolRegistryMetadata;
|
|
7
|
-
const
|
|
11
|
+
const catalog_1 = require("./catalog");
|
|
8
12
|
const names_1 = require("./names");
|
|
13
|
+
const TOOL_CAPABILITY_REQUIREMENTS = {
|
|
14
|
+
initialize_project: 'project_init',
|
|
15
|
+
typed_pdx_write: 'domain_writes',
|
|
16
|
+
candidate_transaction: 'domain_writes',
|
|
17
|
+
convert_image_to_dds: 'domain_writes',
|
|
18
|
+
convert_audio: 'domain_writes',
|
|
19
|
+
deploy_mod_asset: 'domain_writes',
|
|
20
|
+
extract_archetype_slots: 'archetypes',
|
|
21
|
+
instantiate_archetype: 'archetypes',
|
|
22
|
+
get_ignored_diagnostics: 'diagnostic_settings',
|
|
23
|
+
remove_ignored_diagnostic: 'diagnostic_settings',
|
|
24
|
+
get_ide_context: 'ide_context',
|
|
25
|
+
open_in_visual_editor: 'visual_editor',
|
|
26
|
+
capture_gui_preview: 'gui_capture',
|
|
27
|
+
};
|
|
28
|
+
function supportsHostCapability(name, capabilities) {
|
|
29
|
+
const required = TOOL_CAPABILITY_REQUIREMENTS[name];
|
|
30
|
+
return capabilities === undefined || required === undefined || capabilities.has(required);
|
|
31
|
+
}
|
|
9
32
|
function getGeneratedMcpTools() {
|
|
10
|
-
return
|
|
33
|
+
return catalog_1.GENERATED_MCP_TOOLS;
|
|
11
34
|
}
|
|
12
35
|
function listMcpToolSchemas(options) {
|
|
13
|
-
const includeWrites = options?.includeWrites
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
const includeWrites = options?.includeWrites !== false;
|
|
37
|
+
const cwtOnly = options?.cwtOnly === true;
|
|
38
|
+
return catalog_1.GENERATED_MCP_TOOLS
|
|
39
|
+
.filter(entry => (includeWrites || !(0, names_1.isMcpWriteToolName)(entry.tool.name))
|
|
40
|
+
&& (!cwtOnly || entry.registry.mcpSupportsCwtOnly)
|
|
41
|
+
&& supportsHostCapability(entry.tool.name, options?.capabilities))
|
|
16
42
|
.map(entry => ({ ...entry.tool }));
|
|
17
43
|
}
|
|
44
|
+
function isMcpToolAvailable(value, options) {
|
|
45
|
+
if (!(0, names_1.isMcpToolName)(value, options) || !supportsHostCapability(value, options?.capabilities))
|
|
46
|
+
return false;
|
|
47
|
+
if (!options?.cwtOnly)
|
|
48
|
+
return true;
|
|
49
|
+
return catalog_1.GENERATED_MCP_TOOLS.find(entry => entry.tool.name === value)?.registry.mcpSupportsCwtOnly === true;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Transport-neutral aliases.
|
|
53
|
+
*
|
|
54
|
+
* The schema surface is consumed by hosts that have nothing to do with MCP (the
|
|
55
|
+
* Node host, an editor integration, an external agent runtime). Those callers ask
|
|
56
|
+
* for "CWTools tools", not "MCP tools", so the neutral names are the preferred
|
|
57
|
+
* spelling and the MCP-prefixed functions above remain for compatibility.
|
|
58
|
+
*/
|
|
59
|
+
exports.listCwtoolsToolSchemas = listMcpToolSchemas;
|
|
60
|
+
function isCwtoolsToolAvailable(value, options) {
|
|
61
|
+
return isMcpToolAvailable(value, options);
|
|
62
|
+
}
|
|
63
|
+
function getCwtoolsToolSchema(name) {
|
|
64
|
+
return getMcpToolSchema(name);
|
|
65
|
+
}
|
|
18
66
|
function getMcpToolSchema(name) {
|
|
19
|
-
return
|
|
67
|
+
return catalog_1.GENERATED_MCP_TOOLS.find(entry => entry.tool.name === name)?.tool;
|
|
20
68
|
}
|
|
21
69
|
function getMcpToolRegistryMetadata(name) {
|
|
22
|
-
return
|
|
70
|
+
return catalog_1.GENERATED_MCP_TOOLS.find(entry => entry.registry.name === name)?.registry;
|
|
23
71
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ExternalCommandHost, HostServices, MediaToolSettingsHost } from '../host/hostServices';
|
|
2
|
+
import type { SharedToolResult } from './schema';
|
|
3
|
+
import type { DomainWriteContext } from './pdxWrites';
|
|
4
|
+
/**
|
|
5
|
+
* Transport-neutral media conversion and mod-asset deployment.
|
|
6
|
+
*
|
|
7
|
+
* ImageMagick/ffmpeg are reached through an injected port so this package never
|
|
8
|
+
* imports child_process, never builds a shell string, and never depends on the
|
|
9
|
+
* VS Code settings that configure the binaries in the extension. Every path is
|
|
10
|
+
* contained by the workspace, every output name is derived from a validated
|
|
11
|
+
* basename, and nothing is ever deleted recursively.
|
|
12
|
+
*/
|
|
13
|
+
/** Optional host ports on top of the common HostServices surface. */
|
|
14
|
+
export interface MediaWritesHost extends HostServices {
|
|
15
|
+
externalCommands?: ExternalCommandHost;
|
|
16
|
+
mediaTools?: MediaToolSettingsHost;
|
|
17
|
+
}
|
|
18
|
+
export interface ConvertImageToDdsArgs {
|
|
19
|
+
sourcePath: string;
|
|
20
|
+
outputDir?: string;
|
|
21
|
+
compression?: 'dxt5' | 'dxt1' | 'dxt3' | 'none';
|
|
22
|
+
generateMipmaps?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ConvertAudioArgs {
|
|
25
|
+
sourcePath: string;
|
|
26
|
+
outputDir?: string;
|
|
27
|
+
targetFormat: 'ogg' | 'wav';
|
|
28
|
+
sampleRate?: number;
|
|
29
|
+
channels?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface DeployModAssetArgs {
|
|
32
|
+
sourcePath: string;
|
|
33
|
+
targetRelativePath: string;
|
|
34
|
+
overwrite?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface MediaConversionResult {
|
|
37
|
+
success: boolean;
|
|
38
|
+
message: string;
|
|
39
|
+
outputFile?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface DeployModAssetResult {
|
|
42
|
+
success: boolean;
|
|
43
|
+
message: string;
|
|
44
|
+
finalPath?: string;
|
|
45
|
+
writtenFiles?: string[];
|
|
46
|
+
}
|
|
47
|
+
export declare const CONVERT_IMAGE_TO_DDS_FIELDS: readonly ["sourcePath", "outputDir", "compression", "generateMipmaps"];
|
|
48
|
+
export declare const CONVERT_AUDIO_FIELDS: readonly ["sourcePath", "outputDir", "targetFormat", "sampleRate", "channels"];
|
|
49
|
+
export declare const DEPLOY_MOD_ASSET_FIELDS: readonly ["sourcePath", "targetRelativePath", "overwrite"];
|
|
50
|
+
export declare function convertImageToDdsWithHost(host: HostServices, args: Record<string, unknown>, context?: DomainWriteContext): Promise<SharedToolResult<MediaConversionResult>>;
|
|
51
|
+
export declare function convertAudioWithHost(host: HostServices, args: Record<string, unknown>, context?: DomainWriteContext): Promise<SharedToolResult<MediaConversionResult>>;
|
|
52
|
+
export declare function deployModAssetWithHost(host: HostServices, args: Record<string, unknown>, context?: DomainWriteContext): Promise<SharedToolResult<DeployModAssetResult>>;
|