cwtools-mcp 0.4.0 → 0.5.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/README.md +11 -38
- package/dist/cwtools-mcp.cjs +274 -49
- package/dist/mcp/resources.js +3 -3
- package/dist/mcp/toolRegistrar.d.ts +2 -5
- package/dist/server.js +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -145,26 +145,11 @@ using the active extension host's loaded state.
|
|
|
145
145
|
|
|
146
146
|
### Tools
|
|
147
147
|
|
|
148
|
-
The
|
|
149
|
-
|
|
150
|
-
`--allow-domain-writes` flags remain accepted but are no longer required.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
- `query_rules`
|
|
154
|
-
- `query_scope`
|
|
155
|
-
- `get_diagnostics`
|
|
156
|
-
- `explore_pdx_project` for a bounded live semantic graph with dependency edges and freshness
|
|
157
|
-
- `query_workspace_index`
|
|
158
|
-
- `query_localisation_index`
|
|
159
|
-
- `get_pdx_block`
|
|
160
|
-
- completion, document/workspace symbols, definition and reference lookup
|
|
161
|
-
- deep semantic queries for scripted effects/triggers, enums, static modifiers,
|
|
162
|
-
variables, and entity info
|
|
163
|
-
|
|
164
|
-
Default domain writes are `write_localisation`, `typed_pdx_write`,
|
|
165
|
-
`candidate_transaction`, `convert_image_to_dds`, `convert_audio`, and
|
|
166
|
-
`deploy_mod_asset`. Existing path containment, locks, and validation prechecks still
|
|
167
|
-
apply; non-whitelisted writes remain unavailable. Re-run diagnostics after writes.
|
|
148
|
+
The shared catalog covers CWTools semantic, project graph, localisation, asset, scope, Archetype, navigation, diagnostic, and Shader queries. `initialize_project` creates or incrementally refreshes the V4 profile and V7 SQLite knowledge pack in both Bridge and Standalone modes.
|
|
149
|
+
|
|
150
|
+
Default whitelisted write/initialization tools are `write_localisation`, `typed_pdx_write`, `candidate_transaction`, `convert_image_to_dds`, `convert_audio`, `deploy_mod_asset`, `remove_ignored_diagnostic`, and `initialize_project`. Existing path containment, locks, binary-safe asset deployment, cancellation, and validation prechecks apply. The legacy `--enable-writes` / `--allow-domain-writes` flags remain accepted but are no longer required.
|
|
151
|
+
|
|
152
|
+
`get_ide_context`, `open_in_visual_editor`, and `capture_gui_preview` are disclosed only when a real editor host supports them. Standalone mode does not advertise these IDE-only operations.
|
|
168
153
|
|
|
169
154
|
---
|
|
170
155
|
|
|
@@ -184,7 +169,7 @@ bridge,并复用该宿主中的:
|
|
|
184
169
|
- 当前工作区根目录;
|
|
185
170
|
- IDE Problems 面板诊断;
|
|
186
171
|
- rules/cache/localisation/用户设置;
|
|
187
|
-
-
|
|
172
|
+
- 共享索引和语义工具。
|
|
188
173
|
|
|
189
174
|
这样可以降低内存占用,并让 MCP 诊断数量与 IDE 保持一致。
|
|
190
175
|
|
|
@@ -300,20 +285,8 @@ cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --rules "/pat
|
|
|
300
285
|
|
|
301
286
|
### 工具
|
|
302
287
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
- `query_scope`
|
|
309
|
-
- `get_diagnostics`
|
|
310
|
-
- `explore_pdx_project`:返回带依赖边与 freshness 的有界 live 语义图
|
|
311
|
-
- `query_workspace_index`
|
|
312
|
-
- `query_localisation_index`
|
|
313
|
-
- `get_pdx_block`
|
|
314
|
-
- 补全、document/workspace symbols、定义和引用查询
|
|
315
|
-
- scripted effects/triggers、enums、static modifiers、variables、entity info 等深层语义查询
|
|
316
|
-
|
|
317
|
-
默认写入工具为 `write_localisation`、`typed_pdx_write`、`candidate_transaction`、
|
|
318
|
-
`convert_image_to_dds`、`convert_audio` 和 `deploy_mod_asset`。既有路径包含性、
|
|
319
|
-
锁和写入预检仍然生效,非白名单写入继续拒绝。写入后应重新调用诊断。
|
|
288
|
+
共享目录覆盖 CWTools 语义、项目图、本地化、资产、作用域、Archetype、导航、诊断与 Shader 查询。`initialize_project` 在 Bridge 与 Standalone 中均可创建或增量刷新 V4 画像和 V7 SQLite 知识库。
|
|
289
|
+
|
|
290
|
+
默认白名单写入/初始化工具包括 `write_localisation`、`typed_pdx_write`、`candidate_transaction`、`convert_image_to_dds`、`convert_audio`、`deploy_mod_asset`、`remove_ignored_diagnostic` 与 `initialize_project`。既有路径包含、锁、二进制资产安全复制、取消与写入预检继续生效。兼容参数 `--enable-writes` / `--allow-domain-writes` 仍接受,但不再是前提。
|
|
291
|
+
|
|
292
|
+
`get_ide_context`、`open_in_visual_editor` 与 `capture_gui_preview` 只在真实编辑器宿主支持时披露;Standalone 不广告这些 IDE 专属操作。
|
package/dist/cwtools-mcp.cjs
CHANGED
|
@@ -510,13 +510,13 @@ var require_mcpTools = __commonJS({
|
|
|
510
510
|
{
|
|
511
511
|
"tool": {
|
|
512
512
|
"name": "get_diagnostics",
|
|
513
|
-
"description": "Get errors, warnings, information, and hints from the VS Code Problems diagnostics snapshot, optionally filtered by file and severity.
|
|
513
|
+
"description": "Get errors, warnings, information, and hints from the VS Code Problems diagnostics snapshot, optionally filtered by file and severity. Counts are workspace-wide; diagnostics hidden by the workspace ignore list are reported through suppressedCount and still count in totalCount. Check truncated before treating the returned list as complete.",
|
|
514
514
|
"inputSchema": {
|
|
515
515
|
"type": "object",
|
|
516
516
|
"properties": {
|
|
517
517
|
"file": {
|
|
518
518
|
"type": "string",
|
|
519
|
-
"description": "Optional: restrict to
|
|
519
|
+
"description": "Optional: restrict to one file, as an absolute path or a workspace-relative path. Leave empty to get all workspace diagnostics."
|
|
520
520
|
},
|
|
521
521
|
"severity": {
|
|
522
522
|
"type": "string",
|
|
@@ -527,7 +527,7 @@ var require_mcpTools = __commonJS({
|
|
|
527
527
|
"hint",
|
|
528
528
|
"all"
|
|
529
529
|
],
|
|
530
|
-
"description": '
|
|
530
|
+
"description": 'Exact severity filter: "error" returns only errors. Default: "all"'
|
|
531
531
|
},
|
|
532
532
|
"limit": {
|
|
533
533
|
"type": "number",
|
|
@@ -815,7 +815,7 @@ var require_mcpTools = __commonJS({
|
|
|
815
815
|
},
|
|
816
816
|
"exact": {
|
|
817
817
|
"type": "boolean",
|
|
818
|
-
"description": "Require query to exactly match an entity ID. Default false."
|
|
818
|
+
"description": "Require query to exactly match an entity ID; needs a non-empty query. Default false."
|
|
819
819
|
},
|
|
820
820
|
"depth": {
|
|
821
821
|
"type": "number",
|
|
@@ -5452,6 +5452,13 @@ var require_readiness = __commonJS({
|
|
|
5452
5452
|
if (readiness.ready) {
|
|
5453
5453
|
return { ...result, readiness };
|
|
5454
5454
|
}
|
|
5455
|
+
if (readiness.reason === "lsp_unavailable") {
|
|
5456
|
+
return {
|
|
5457
|
+
...result,
|
|
5458
|
+
readiness,
|
|
5459
|
+
warnings: [...result.warnings ?? [], "CWTools backend is unavailable; this result carries no semantic model evidence."]
|
|
5460
|
+
};
|
|
5461
|
+
}
|
|
5455
5462
|
return {
|
|
5456
5463
|
...result,
|
|
5457
5464
|
ok: true,
|
|
@@ -8189,6 +8196,17 @@ var require_symbols = __commonJS({
|
|
|
8189
8196
|
return (0, schema_1.toolDenied)("invalid_arguments", "go_to_definition requires symbolName or a file position.");
|
|
8190
8197
|
const commandResult = await host.lsp.executeCommand("cwtools.ai.queryDefinitionByName", [symbolName], { timeoutMs: 1e4 });
|
|
8191
8198
|
if (!isUnavailable(commandResult)) {
|
|
8199
|
+
const record = commandResult && typeof commandResult === "object" && !Array.isArray(commandResult) ? commandResult : {};
|
|
8200
|
+
if (record.ok === false) {
|
|
8201
|
+
const message = typeof record.error === "string" && record.error.trim() ? record.error : `Symbol '${symbolName}' was not found.`;
|
|
8202
|
+
return {
|
|
8203
|
+
ok: false,
|
|
8204
|
+
status: "error",
|
|
8205
|
+
source: "cwtools-lsp-definition",
|
|
8206
|
+
data: commandResult,
|
|
8207
|
+
error: { code: "definition_not_found", message }
|
|
8208
|
+
};
|
|
8209
|
+
}
|
|
8192
8210
|
return {
|
|
8193
8211
|
ok: true,
|
|
8194
8212
|
status: "ready",
|
|
@@ -8256,13 +8274,14 @@ var require_symbols = __commonJS({
|
|
|
8256
8274
|
const references = await textSearchReferences(host, identifier, args.file, limit);
|
|
8257
8275
|
return {
|
|
8258
8276
|
ok: true,
|
|
8259
|
-
status: "
|
|
8277
|
+
status: "partial",
|
|
8260
8278
|
source: "cwtools-text-references",
|
|
8279
|
+
warnings: ["Fallback text references are lexical evidence, not semantic CWTools reference resolution."],
|
|
8261
8280
|
data: {
|
|
8262
8281
|
identifier,
|
|
8263
8282
|
references,
|
|
8264
8283
|
total: references.length,
|
|
8265
|
-
|
|
8284
|
+
evidence: "lexical"
|
|
8266
8285
|
}
|
|
8267
8286
|
};
|
|
8268
8287
|
}
|
|
@@ -9091,6 +9110,25 @@ var require_toolHandlers = __commonJS({
|
|
|
9091
9110
|
var targetingWeights_1 = require_targetingWeights();
|
|
9092
9111
|
var schema_1 = require_schema();
|
|
9093
9112
|
var symbols_1 = require_symbols();
|
|
9113
|
+
function invalidArguments(message) {
|
|
9114
|
+
return {
|
|
9115
|
+
ok: false,
|
|
9116
|
+
status: "error",
|
|
9117
|
+
source: "cwtools-shared",
|
|
9118
|
+
error: { code: "invalid_arguments", message }
|
|
9119
|
+
};
|
|
9120
|
+
}
|
|
9121
|
+
function errorMessageOf(record) {
|
|
9122
|
+
const error = record.error;
|
|
9123
|
+
if (typeof error === "string" && error.trim())
|
|
9124
|
+
return error;
|
|
9125
|
+
const nested = asRecord(error);
|
|
9126
|
+
if (typeof nested.message === "string" && nested.message.trim())
|
|
9127
|
+
return nested.message;
|
|
9128
|
+
if (typeof record.message === "string" && record.message.trim())
|
|
9129
|
+
return record.message;
|
|
9130
|
+
return "CWTools LSP command reported a failure.";
|
|
9131
|
+
}
|
|
9094
9132
|
function asRecord(value) {
|
|
9095
9133
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
9096
9134
|
}
|
|
@@ -9100,14 +9138,18 @@ var require_toolHandlers = __commonJS({
|
|
|
9100
9138
|
const record = asRecord(result);
|
|
9101
9139
|
const errorRecord = asRecord(record.error);
|
|
9102
9140
|
const unavailable = record.status === "unavailable" || errorRecord.code === "lsp_unavailable";
|
|
9141
|
+
const failed = !unavailable && record.ok === false;
|
|
9103
9142
|
return {
|
|
9104
|
-
ok: !unavailable,
|
|
9105
|
-
status: unavailable ? "unavailable" : "ready",
|
|
9143
|
+
ok: !unavailable && !failed,
|
|
9144
|
+
status: unavailable ? "unavailable" : failed ? "error" : "ready",
|
|
9106
9145
|
source: "cwtools-lsp",
|
|
9107
9146
|
data: result,
|
|
9108
9147
|
error: unavailable ? {
|
|
9109
9148
|
code: String(errorRecord.code ?? "lsp_unavailable"),
|
|
9110
9149
|
message: String(errorRecord.message ?? "LSP command is unavailable.")
|
|
9150
|
+
} : failed ? {
|
|
9151
|
+
code: String(errorRecord.code ?? "lsp_command_failed"),
|
|
9152
|
+
message: errorMessageOf(record)
|
|
9111
9153
|
} : void 0,
|
|
9112
9154
|
nextSteps: unavailable ? [unavailableNextStep] : void 0
|
|
9113
9155
|
};
|
|
@@ -9137,7 +9179,13 @@ var require_toolHandlers = __commonJS({
|
|
|
9137
9179
|
data
|
|
9138
9180
|
};
|
|
9139
9181
|
}
|
|
9140
|
-
case "explore_pdx_project":
|
|
9182
|
+
case "explore_pdx_project": {
|
|
9183
|
+
if (args.exact !== void 0 && typeof args.exact !== "boolean") {
|
|
9184
|
+
return invalidArguments("exact must be a boolean; pass the identifier in query.");
|
|
9185
|
+
}
|
|
9186
|
+
if (args.exact === true && (typeof args.query !== "string" || args.query.trim() === "")) {
|
|
9187
|
+
return invalidArguments("exact requires a non-empty query; omit exact to browse by typeName or file.");
|
|
9188
|
+
}
|
|
9141
9189
|
return lspTool("cwtools.ai.exploreProject", [
|
|
9142
9190
|
typeof args.query === "string" ? args.query : "",
|
|
9143
9191
|
typeof args.file === "string" && args.file ? toFileUri(args.file, host.workspaceRoot) : "",
|
|
@@ -9148,6 +9196,7 @@ var require_toolHandlers = __commonJS({
|
|
|
9148
9196
|
args.maxEdges ?? 80,
|
|
9149
9197
|
args.includeMetadata !== false
|
|
9150
9198
|
], "Start the CWTools LSP process and wait for the game model to load before exploring the semantic graph.");
|
|
9199
|
+
}
|
|
9151
9200
|
case "analyze_pdx_flow": {
|
|
9152
9201
|
const file = typeof args.file === "string" ? args.file.trim() : "";
|
|
9153
9202
|
const definitionId = typeof args.definitionId === "string" ? args.definitionId.trim() : "";
|
|
@@ -9238,12 +9287,18 @@ var require_toolHandlers = __commonJS({
|
|
|
9238
9287
|
}
|
|
9239
9288
|
case "get_diagnostics": {
|
|
9240
9289
|
const diagnostics = await host.diagnostics.getDiagnostics(args, signal ? { signal } : void 0);
|
|
9290
|
+
const suppressed = diagnostics.suppressedCount ?? 0;
|
|
9241
9291
|
return {
|
|
9242
9292
|
ok: diagnostics.ok,
|
|
9243
9293
|
status: diagnostics.status === "unavailable" ? "unavailable" : diagnostics.status === "stale" ? "stale" : diagnostics.status === "pending" ? "loading" : "ready",
|
|
9244
9294
|
source: "cwtools-diagnostics",
|
|
9245
9295
|
data: diagnostics,
|
|
9246
|
-
error: diagnostics.error
|
|
9296
|
+
error: diagnostics.error,
|
|
9297
|
+
// An empty page is not an empty project: say so when the workspace ignore
|
|
9298
|
+
// list removed entries, and point at the missing backend when it answered
|
|
9299
|
+
// "unavailable" instead of leaving a bare error behind.
|
|
9300
|
+
warnings: suppressed > 0 ? [`${suppressed} diagnostic(s) on this page were hidden by the workspace ignore list (stellarisLanguageServices.ai.ignoredDiagnostics); they still count in totalCount.`] : void 0,
|
|
9301
|
+
nextSteps: diagnostics.ok ? void 0 : ["Check that the CWTools backend is running (extension active, or a standalone server), then retry get_diagnostics."]
|
|
9247
9302
|
};
|
|
9248
9303
|
}
|
|
9249
9304
|
case "analyze_diagnostic_error":
|
|
@@ -9424,8 +9479,8 @@ var require_callHandler = __commonJS({
|
|
|
9424
9479
|
exports2.GENERIC_PARADOX_WARNING = "Generic Paradox mode: the exact game is unknown; no game-specific rules or vanilla data are assumed. Pass --game to select a game.";
|
|
9425
9480
|
function createToolCallHandler(host, dispatcher = toolHandlers_1.defaultSharedToolDispatcher) {
|
|
9426
9481
|
let ready = false;
|
|
9427
|
-
const probeReadiness = async (context) => {
|
|
9428
|
-
if (ready)
|
|
9482
|
+
const probeReadiness = async (context, force = false) => {
|
|
9483
|
+
if (ready && !force)
|
|
9429
9484
|
return { ready: true };
|
|
9430
9485
|
try {
|
|
9431
9486
|
const status = await host.lsp.executeCommand("cwtools.ai.getValidationStatus", [], {
|
|
@@ -9433,8 +9488,7 @@ var require_callHandler = __commonJS({
|
|
|
9433
9488
|
...context?.signal ? { signal: context.signal } : {}
|
|
9434
9489
|
});
|
|
9435
9490
|
const verdict = (0, readiness_1.parseReadiness)(status);
|
|
9436
|
-
|
|
9437
|
-
ready = true;
|
|
9491
|
+
ready = verdict.ready;
|
|
9438
9492
|
return verdict;
|
|
9439
9493
|
} catch (error) {
|
|
9440
9494
|
(0, lsp_1.throwIfAborted)(context?.signal);
|
|
@@ -9464,7 +9518,8 @@ var require_callHandler = __commonJS({
|
|
|
9464
9518
|
const withVanilla = (0, vanillaCache_1.annotateVanillaCache)(name, withGenericWarning, host.vanillaCache);
|
|
9465
9519
|
if (!readiness_1.LOAD_DEPENDENT_TOOLS.has(name))
|
|
9466
9520
|
return withVanilla;
|
|
9467
|
-
|
|
9521
|
+
const lostBackend = result.ok === false && result.status === "unavailable";
|
|
9522
|
+
return (0, readiness_1.annotateReadiness)(name, withVanilla, await probeReadiness(context, lostBackend));
|
|
9468
9523
|
};
|
|
9469
9524
|
}
|
|
9470
9525
|
function bindToolCallHandler(host, dispatcher = toolHandlers_1.defaultSharedToolDispatcher) {
|
|
@@ -14708,6 +14763,7 @@ var require_projectSettings = __commonJS({
|
|
|
14708
14763
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
14709
14764
|
exports2.getExtensionSetting = getExtensionSetting;
|
|
14710
14765
|
exports2.readIgnoredDiagnostics = readIgnoredDiagnostics;
|
|
14766
|
+
exports2.honouredIgnoredDiagnostics = honouredIgnoredDiagnostics;
|
|
14711
14767
|
exports2.resolveLocalisationLanguages = resolveLocalisationLanguages;
|
|
14712
14768
|
exports2.resolveGeneratedStrings = resolveGeneratedStrings;
|
|
14713
14769
|
exports2.resolveExperimental = resolveExperimental;
|
|
@@ -14830,6 +14886,9 @@ var require_projectSettings = __commonJS({
|
|
|
14830
14886
|
function readIgnoredDiagnostics(workspaceRoot) {
|
|
14831
14887
|
return asNonEmptyStringArray(getExtensionSetting(workspaceRoot, "ai.ignoredDiagnostics"));
|
|
14832
14888
|
}
|
|
14889
|
+
function honouredIgnoredDiagnostics(workspaceRoot, honor) {
|
|
14890
|
+
return honor ? readIgnoredDiagnostics(workspaceRoot) : [];
|
|
14891
|
+
}
|
|
14833
14892
|
var LANG_TAG_MAP = [
|
|
14834
14893
|
["English", "english"],
|
|
14835
14894
|
["French", "french"],
|
|
@@ -14914,8 +14973,7 @@ var require_projectSettings = __commonJS({
|
|
|
14914
14973
|
return {
|
|
14915
14974
|
...result,
|
|
14916
14975
|
diagnostics: kept,
|
|
14917
|
-
suppressedCount: (result.suppressedCount ?? 0) + suppressed
|
|
14918
|
-
totalCount: typeof result.totalCount === "number" ? Math.max(0, result.totalCount - suppressed) : result.totalCount
|
|
14976
|
+
suppressedCount: (result.suppressedCount ?? 0) + suppressed
|
|
14919
14977
|
};
|
|
14920
14978
|
}
|
|
14921
14979
|
}
|
|
@@ -14965,8 +15023,10 @@ var require_lspProcessHost = __commonJS({
|
|
|
14965
15023
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
14966
15024
|
exports2.LspProcessHost = exports2.BackendIncompatibleError = void 0;
|
|
14967
15025
|
exports2.resolveRulesCacheRoot = resolveRulesCacheRoot;
|
|
15026
|
+
exports2.buildCwtoolsConfiguration = buildCwtoolsConfiguration;
|
|
14968
15027
|
exports2.createLspProcessHost = createLspProcessHost;
|
|
14969
15028
|
exports2.resolveDefaultServerPath = resolveDefaultServerPath;
|
|
15029
|
+
exports2.rulesDirectoryCandidates = rulesDirectoryCandidates;
|
|
14970
15030
|
exports2.pathToFileUri = pathToFileUri;
|
|
14971
15031
|
exports2.isLspWatchedFile = isLspWatchedFile;
|
|
14972
15032
|
var fs = __importStar(require("fs"));
|
|
@@ -15010,7 +15070,7 @@ var require_lspProcessHost = __commonJS({
|
|
|
15010
15070
|
async executeCommand(command, args = [], options) {
|
|
15011
15071
|
try {
|
|
15012
15072
|
await this.ensureStarted(options?.signal);
|
|
15013
|
-
const result = await this.raceRequest("workspace/executeCommand", { command, arguments: args }, options?.timeoutMs ?? 2e4, `LSP command ${command} timed out`, options?.signal);
|
|
15073
|
+
const result = await this.raceRequest("workspace/executeCommand", { command, arguments: args }, options?.timeoutMs ?? this.options.requestTimeoutMs ?? 2e4, `LSP command ${command} timed out`, options?.signal);
|
|
15014
15074
|
return result;
|
|
15015
15075
|
} catch (error) {
|
|
15016
15076
|
if ((0, cwtools_shared_1.isAbortError)(error))
|
|
@@ -15020,7 +15080,7 @@ var require_lspProcessHost = __commonJS({
|
|
|
15020
15080
|
return this.unavailable(error instanceof Error ? error.message : String(error));
|
|
15021
15081
|
}
|
|
15022
15082
|
}
|
|
15023
|
-
async sendRequest(method, params, timeoutMs = 2e4, signal) {
|
|
15083
|
+
async sendRequest(method, params, timeoutMs = this.options.requestTimeoutMs ?? 2e4, signal) {
|
|
15024
15084
|
try {
|
|
15025
15085
|
await this.ensureStarted(signal);
|
|
15026
15086
|
return await this.raceRequest(method, params, timeoutMs, `LSP request ${method} timed out`, signal);
|
|
@@ -15070,6 +15130,15 @@ var require_lspProcessHost = __commonJS({
|
|
|
15070
15130
|
throw new Error(this.startError);
|
|
15071
15131
|
}
|
|
15072
15132
|
async start(generation, signal) {
|
|
15133
|
+
try {
|
|
15134
|
+
await this.startInternal(generation, signal);
|
|
15135
|
+
} catch (error) {
|
|
15136
|
+
if (this.generation === generation)
|
|
15137
|
+
this.dispose();
|
|
15138
|
+
throw error;
|
|
15139
|
+
}
|
|
15140
|
+
}
|
|
15141
|
+
async startInternal(generation, signal) {
|
|
15073
15142
|
(0, cwtools_shared_1.throwIfAborted)(signal);
|
|
15074
15143
|
const startupTimeoutMs = this.options.startupTimeoutMs ?? DEFAULT_STARTUP_TIMEOUT_MS;
|
|
15075
15144
|
const stale = () => this.generation !== generation;
|
|
@@ -15108,7 +15177,7 @@ var require_lspProcessHost = __commonJS({
|
|
|
15108
15177
|
const rootUri = pathToFileUri(this.options.workspaceRoot);
|
|
15109
15178
|
const game = this.options.game ?? "paradox";
|
|
15110
15179
|
const rulesCacheRoot = resolveRulesCacheRoot(this.options);
|
|
15111
|
-
const rulesFolder = game === "paradox" || game === "cwt" ? "" : this.options.bundledRulesPath ?? resolveBundledRulesPath(game, rulesCacheRoot);
|
|
15180
|
+
const rulesFolder = game === "paradox" || game === "cwt" ? "" : this.options.bundledRulesPath ?? resolveBundledRulesPath(game, rulesCacheRoot, this.options.workspaceRoot);
|
|
15112
15181
|
if (!rulesFolder) {
|
|
15113
15182
|
process.stderr.write("[cwtools-node] warning: no CWT rules found \u2014 install the VS Code extension or pass --rules <dir>; validation will be limited\n");
|
|
15114
15183
|
}
|
|
@@ -15159,7 +15228,11 @@ var require_lspProcessHost = __commonJS({
|
|
|
15159
15228
|
cwtools: buildCwtoolsConfiguration(game, this.options.gamePath, rulesFolder ?? "", {
|
|
15160
15229
|
languages: loc.languages,
|
|
15161
15230
|
generatedStrings: (0, projectSettings_1.resolveGeneratedStrings)(this.options.workspaceRoot)
|
|
15162
|
-
}, (0, projectSettings_1.resolveExperimental)(this.options.workspaceRoot)
|
|
15231
|
+
}, (0, projectSettings_1.resolveExperimental)(this.options.workspaceRoot), {
|
|
15232
|
+
ignoreCodes: this.options.errorIgnoreCodes ?? [],
|
|
15233
|
+
ignoreFiles: this.options.errorIgnoreFiles ?? [],
|
|
15234
|
+
localisationFilter: this.options.localisationDiagnosticFilter ?? "off"
|
|
15235
|
+
})
|
|
15163
15236
|
}
|
|
15164
15237
|
});
|
|
15165
15238
|
await this.waitForExecuteCommandsReady(Math.min(startupTimeoutMs, 2e4), signal, stale);
|
|
@@ -15330,7 +15403,7 @@ var require_lspProcessHost = __commonJS({
|
|
|
15330
15403
|
}
|
|
15331
15404
|
};
|
|
15332
15405
|
exports2.LspProcessHost = LspProcessHost;
|
|
15333
|
-
function buildCwtoolsConfiguration(game, gamePath, rulesFolder, localisation, experimental) {
|
|
15406
|
+
function buildCwtoolsConfiguration(game, gamePath, rulesFolder, localisation, experimental, noise = { ignoreCodes: [], ignoreFiles: [], localisationFilter: "off" }) {
|
|
15334
15407
|
const vanillaDir = gamePath ?? "";
|
|
15335
15408
|
return {
|
|
15336
15409
|
localisation: {
|
|
@@ -15339,8 +15412,9 @@ var require_lspProcessHost = __commonJS({
|
|
|
15339
15412
|
},
|
|
15340
15413
|
errors: {
|
|
15341
15414
|
vanilla: false,
|
|
15342
|
-
ignore: [],
|
|
15343
|
-
ignorefiles: []
|
|
15415
|
+
ignore: [...noise.ignoreCodes],
|
|
15416
|
+
ignorefiles: [...noise.ignoreFiles],
|
|
15417
|
+
localisationFilter: noise.localisationFilter
|
|
15344
15418
|
},
|
|
15345
15419
|
// On by default: enables incremental scripted-type refresh so revalidating a
|
|
15346
15420
|
// scripted_trigger/effect/value patches the type index fast instead of a full reload.
|
|
@@ -15391,20 +15465,20 @@ var require_lspProcessHost = __commonJS({
|
|
|
15391
15465
|
];
|
|
15392
15466
|
return candidates.find((candidate) => fs.existsSync(candidate)) ?? candidates[0];
|
|
15393
15467
|
}
|
|
15394
|
-
function resolveBundledRulesPath(game, cacheDir) {
|
|
15468
|
+
function resolveBundledRulesPath(game, cacheDir, workspaceRoot) {
|
|
15395
15469
|
const extracted = (0, vscodeCache_1.detectExtensionRulesDir)(cacheDir, game);
|
|
15396
15470
|
if (extracted)
|
|
15397
15471
|
return extracted;
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
|
|
15402
|
-
|
|
15403
|
-
path.join(
|
|
15404
|
-
path.join(
|
|
15405
|
-
|
|
15406
|
-
].filter(
|
|
15407
|
-
return
|
|
15472
|
+
return rulesDirectoryCandidates(game, workspaceRoot).find((candidate) => fs.existsSync(candidate));
|
|
15473
|
+
}
|
|
15474
|
+
function rulesDirectoryCandidates(game, workspaceRoot, cwd = process.cwd(), repoRoot = path.resolve(__dirname, "..", "..", "..", "..")) {
|
|
15475
|
+
const layouts = [
|
|
15476
|
+
(root) => path.join(root, "release", "rules", game, "config"),
|
|
15477
|
+
(root) => path.join(root, "submodules", `cwtools-${game}-config`, "config"),
|
|
15478
|
+
(root) => game === "stellaris" ? path.join(root, "submodules", "cwtools-stellaris-config", "config") : ""
|
|
15479
|
+
];
|
|
15480
|
+
const roots = [workspaceRoot, cwd, repoRoot].filter((root) => !!root);
|
|
15481
|
+
return roots.flatMap((root) => layouts.map((layout) => layout(root))).filter(Boolean);
|
|
15408
15482
|
}
|
|
15409
15483
|
function pathToFileUri(filePath) {
|
|
15410
15484
|
const resolved = path.resolve(filePath).replace(/\\/g, "/");
|
|
@@ -15438,6 +15512,110 @@ var require_lspProcessHost = __commonJS({
|
|
|
15438
15512
|
}
|
|
15439
15513
|
});
|
|
15440
15514
|
|
|
15515
|
+
// ../cwtools-node/dist/hosts/gameInstall.js
|
|
15516
|
+
var require_gameInstall = __commonJS({
|
|
15517
|
+
"../cwtools-node/dist/hosts/gameInstall.js"(exports2) {
|
|
15518
|
+
"use strict";
|
|
15519
|
+
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
15520
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
15521
|
+
};
|
|
15522
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15523
|
+
exports2.GAME_INSTALL_LAYOUT = void 0;
|
|
15524
|
+
exports2.detectSteamLibraries = detectSteamLibraries;
|
|
15525
|
+
exports2.detectGameInstall = detectGameInstall;
|
|
15526
|
+
var node_child_process_1 = require("node:child_process");
|
|
15527
|
+
var node_fs_1 = __importDefault(require("node:fs"));
|
|
15528
|
+
var node_os_1 = __importDefault(require("node:os"));
|
|
15529
|
+
var node_path_1 = __importDefault(require("node:path"));
|
|
15530
|
+
exports2.GAME_INSTALL_LAYOUT = {
|
|
15531
|
+
stellaris: { folder: "Stellaris", alternatives: [] },
|
|
15532
|
+
hoi4: { folder: "Hearts of Iron IV", alternatives: [] },
|
|
15533
|
+
eu4: { folder: "Europa Universalis IV", alternatives: [] },
|
|
15534
|
+
eu5: { folder: "Europa Universalis V", alternatives: [], subdir: "game" },
|
|
15535
|
+
ck2: { folder: "Crusader Kings II", alternatives: [] },
|
|
15536
|
+
ck3: { folder: "Crusader Kings III", alternatives: [], subdir: "game" },
|
|
15537
|
+
vic2: { folder: "Victoria 2", alternatives: ["Victoria II"] },
|
|
15538
|
+
vic3: { folder: "Victoria 3", alternatives: [], subdir: "game" },
|
|
15539
|
+
imperator: { folder: "ImperatorRome", alternatives: ["Imperator"], subdir: "game" }
|
|
15540
|
+
};
|
|
15541
|
+
function steamRoot(options) {
|
|
15542
|
+
const platform = options.platform ?? node_os_1.default.platform();
|
|
15543
|
+
const home = options.home ?? node_os_1.default.homedir();
|
|
15544
|
+
if (platform === "win32") {
|
|
15545
|
+
for (const key of ["HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam", "HKLM\\SOFTWARE\\Valve\\Steam"]) {
|
|
15546
|
+
try {
|
|
15547
|
+
const output = (0, node_child_process_1.execFileSync)("reg", ["query", key, "/v", "InstallPath"], {
|
|
15548
|
+
encoding: "utf8",
|
|
15549
|
+
timeout: 3e3,
|
|
15550
|
+
windowsHide: true
|
|
15551
|
+
});
|
|
15552
|
+
const match = /InstallPath\s+REG_SZ\s+(.+)/.exec(output);
|
|
15553
|
+
if (match?.[1])
|
|
15554
|
+
return match[1].trim();
|
|
15555
|
+
} catch {
|
|
15556
|
+
}
|
|
15557
|
+
}
|
|
15558
|
+
for (const candidate of ["C:\\Program Files (x86)\\Steam", "C:\\Program Files\\Steam", "D:\\Steam", "D:\\SteamLibrary"]) {
|
|
15559
|
+
if (node_fs_1.default.existsSync(node_path_1.default.join(candidate, "steam.exe")) || node_fs_1.default.existsSync(node_path_1.default.join(candidate, "steamapps"))) {
|
|
15560
|
+
return candidate;
|
|
15561
|
+
}
|
|
15562
|
+
}
|
|
15563
|
+
return void 0;
|
|
15564
|
+
}
|
|
15565
|
+
if (platform === "darwin") {
|
|
15566
|
+
const macPath = node_path_1.default.join(home, "Library", "Application Support", "Steam");
|
|
15567
|
+
return node_fs_1.default.existsSync(macPath) ? macPath : void 0;
|
|
15568
|
+
}
|
|
15569
|
+
for (const linuxPath of [node_path_1.default.join(home, ".steam", "steam"), node_path_1.default.join(home, ".local", "share", "Steam")]) {
|
|
15570
|
+
if (node_fs_1.default.existsSync(linuxPath))
|
|
15571
|
+
return linuxPath;
|
|
15572
|
+
}
|
|
15573
|
+
return void 0;
|
|
15574
|
+
}
|
|
15575
|
+
function detectSteamLibraries(options = {}) {
|
|
15576
|
+
const root = steamRoot(options);
|
|
15577
|
+
if (!root)
|
|
15578
|
+
return [];
|
|
15579
|
+
const libraries = [root];
|
|
15580
|
+
const vdfPath = node_path_1.default.join(root, "steamapps", "libraryfolders.vdf");
|
|
15581
|
+
try {
|
|
15582
|
+
const content = node_fs_1.default.readFileSync(vdfPath, "utf8");
|
|
15583
|
+
for (const match of content.matchAll(/"path"\s+"([^"]+)"/g)) {
|
|
15584
|
+
const raw = match[1];
|
|
15585
|
+
if (!raw)
|
|
15586
|
+
continue;
|
|
15587
|
+
const library = raw.replace(/\\\\/g, "\\");
|
|
15588
|
+
if (!libraries.includes(library) && node_fs_1.default.existsSync(library))
|
|
15589
|
+
libraries.push(library);
|
|
15590
|
+
}
|
|
15591
|
+
} catch {
|
|
15592
|
+
}
|
|
15593
|
+
return libraries;
|
|
15594
|
+
}
|
|
15595
|
+
function isGameInstall(dir) {
|
|
15596
|
+
try {
|
|
15597
|
+
return node_fs_1.default.statSync(node_path_1.default.join(dir, "common")).isDirectory();
|
|
15598
|
+
} catch {
|
|
15599
|
+
return false;
|
|
15600
|
+
}
|
|
15601
|
+
}
|
|
15602
|
+
function detectGameInstall(gameId, libraries = detectSteamLibraries()) {
|
|
15603
|
+
const layout = gameId === void 0 ? void 0 : exports2.GAME_INSTALL_LAYOUT[gameId];
|
|
15604
|
+
if (!layout)
|
|
15605
|
+
return void 0;
|
|
15606
|
+
for (const folder of [layout.folder, ...layout.alternatives]) {
|
|
15607
|
+
for (const library of libraries) {
|
|
15608
|
+
const root = node_path_1.default.join(library, "steamapps", "common", folder);
|
|
15609
|
+
const data = layout.subdir ? node_path_1.default.join(root, layout.subdir) : root;
|
|
15610
|
+
if (isGameInstall(data))
|
|
15611
|
+
return data;
|
|
15612
|
+
}
|
|
15613
|
+
}
|
|
15614
|
+
return void 0;
|
|
15615
|
+
}
|
|
15616
|
+
}
|
|
15617
|
+
});
|
|
15618
|
+
|
|
15441
15619
|
// ../cwtools-node/dist/hosts/projectDetect.js
|
|
15442
15620
|
var require_projectDetect = __commonJS({
|
|
15443
15621
|
"../cwtools-node/dist/hosts/projectDetect.js"(exports2) {
|
|
@@ -15680,6 +15858,7 @@ var require_nodeHostServices = __commonJS({
|
|
|
15680
15858
|
var path = __importStar(require("path"));
|
|
15681
15859
|
var cwtools_shared_1 = require_dist();
|
|
15682
15860
|
var lspProcessHost_1 = require_lspProcessHost();
|
|
15861
|
+
var gameInstall_1 = require_gameInstall();
|
|
15683
15862
|
var projectDetect_1 = require_projectDetect();
|
|
15684
15863
|
var projectSettings_1 = require_projectSettings();
|
|
15685
15864
|
var revalidation_1 = require_revalidation();
|
|
@@ -15691,22 +15870,28 @@ var require_nodeHostServices = __commonJS({
|
|
|
15691
15870
|
const enabled = support.supported || config.forceStart;
|
|
15692
15871
|
const projectKind = support.supported ? support.kind : config.forceStart ? "mod" : support.kind;
|
|
15693
15872
|
const game = support.kind === "cwt-only" ? "cwt" : config.game ?? support.gameId ?? "paradox";
|
|
15873
|
+
const gamePath = config.gamePath ?? (game === "paradox" || game === "cwt" ? void 0 : (0, gameInstall_1.detectGameInstall)(game));
|
|
15694
15874
|
const allowlist = config.allowedTools.length > 0 ? new Set(config.allowedTools) : new Set(cwtools_shared_1.MCP_WRITE_TOOL_NAMES);
|
|
15695
15875
|
const filesystem = new NodeFilesystemHost(workspaceRoot, config.enableWrites);
|
|
15696
15876
|
const autoCache = config.cachePath ?? (0, vscodeCache_1.detectExtensionCacheDir)(game);
|
|
15697
15877
|
const detectedRulesPath = (0, vscodeCache_1.detectExtensionRulesDir)(autoCache, game);
|
|
15698
15878
|
const rulesConfigDirs = uniqueStrings([config.rulesPath, detectedRulesPath].filter((item) => !!item));
|
|
15699
|
-
const lspProcess = enabled ? (0, lspProcessHost_1.createLspProcessHost)({
|
|
15879
|
+
const lspProcess = enabled && !config.lspHost ? (0, lspProcessHost_1.createLspProcessHost)({
|
|
15700
15880
|
workspaceRoot,
|
|
15701
15881
|
game,
|
|
15702
15882
|
serverPath: config.serverPath,
|
|
15883
|
+
...config.serverArgs === void 0 ? {} : { serverArgs: config.serverArgs },
|
|
15703
15884
|
cachePath: autoCache,
|
|
15704
|
-
gamePath: game === "paradox" || game === "cwt" ? void 0 :
|
|
15885
|
+
gamePath: game === "paradox" || game === "cwt" ? void 0 : gamePath,
|
|
15705
15886
|
bundledRulesPath: config.rulesPath,
|
|
15887
|
+
...config.errorIgnoreCodes === void 0 ? {} : { errorIgnoreCodes: config.errorIgnoreCodes },
|
|
15888
|
+
...config.errorIgnoreFiles === void 0 ? {} : { errorIgnoreFiles: config.errorIgnoreFiles },
|
|
15889
|
+
...config.localisationDiagnosticFilter === void 0 ? {} : { localisationDiagnosticFilter: config.localisationDiagnosticFilter },
|
|
15706
15890
|
...config.startupTimeoutMs === void 0 ? {} : { startupTimeoutMs: config.startupTimeoutMs },
|
|
15891
|
+
...config.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: config.requestTimeoutMs },
|
|
15707
15892
|
...config.debug === void 0 ? {} : { debug: config.debug }
|
|
15708
15893
|
}) : void 0;
|
|
15709
|
-
const lsp = lspProcess ?? (0, cwtools_shared_1.createUnavailableLspHost)("Workspace is not a recognised Paradox mod; CWTools is disabled here.");
|
|
15894
|
+
const lsp = enabled ? config.lspHost ?? lspProcess ?? (0, cwtools_shared_1.createUnavailableLspHost)("Workspace is not a recognised Paradox mod; CWTools is disabled here.") : (0, cwtools_shared_1.createUnavailableLspHost)("Workspace is not a recognised Paradox mod; CWTools is disabled here.");
|
|
15710
15895
|
const report = (message) => {
|
|
15711
15896
|
if (config.logger)
|
|
15712
15897
|
config.logger("info", message);
|
|
@@ -15723,6 +15908,9 @@ var require_nodeHostServices = __commonJS({
|
|
|
15723
15908
|
if (enabled && !config.cachePath && autoCache) {
|
|
15724
15909
|
report(`auto-detected VS Code extension cache at ${autoCache}`);
|
|
15725
15910
|
}
|
|
15911
|
+
if (enabled && !config.gamePath && gamePath) {
|
|
15912
|
+
report(`auto-detected ${game} install at ${gamePath}`);
|
|
15913
|
+
}
|
|
15726
15914
|
report(`workspace = ${workspaceRoot}${config.workspaceRoot === process.cwd() ? " (inherited cwd)" : ""}`);
|
|
15727
15915
|
return {
|
|
15728
15916
|
workspaceRoot,
|
|
@@ -15736,7 +15924,7 @@ var require_nodeHostServices = __commonJS({
|
|
|
15736
15924
|
projectEvidence: [...support.markers],
|
|
15737
15925
|
projectCandidates: support.candidates ? [...support.candidates] : void 0,
|
|
15738
15926
|
lsp,
|
|
15739
|
-
diagnostics: new LspDiagnosticsHost(lsp, workspaceRoot,
|
|
15927
|
+
diagnostics: new LspDiagnosticsHost(lsp, workspaceRoot, config.honorWorkspaceIgnoreList !== false, enabled ? new revalidation_1.RevalidationCoordinator(lsp, workspaceRoot, () => config.readyAtMs ?? lspProcess?.readyAtMs) : void 0),
|
|
15740
15928
|
filesystem,
|
|
15741
15929
|
indexing: new ThinNodeIndexHost(workspaceRoot),
|
|
15742
15930
|
rules: {
|
|
@@ -15760,7 +15948,7 @@ var require_nodeHostServices = __commonJS({
|
|
|
15760
15948
|
return results;
|
|
15761
15949
|
}
|
|
15762
15950
|
},
|
|
15763
|
-
vanillaCache: game === "cwt" ? void 0 : probeVanillaCache(workspaceRoot, { game, gamePath
|
|
15951
|
+
vanillaCache: game === "cwt" ? void 0 : probeVanillaCache(workspaceRoot, { game, gamePath, cachePath: autoCache, workspaceRoot }),
|
|
15764
15952
|
now: () => Date.now(),
|
|
15765
15953
|
log: (level, message, data) => {
|
|
15766
15954
|
if (level === "debug" && !config.debug)
|
|
@@ -15772,7 +15960,13 @@ var require_nodeHostServices = __commonJS({
|
|
|
15772
15960
|
const suffix = data === void 0 ? "" : ` ${JSON.stringify(data)}`;
|
|
15773
15961
|
console.error(`[cwtools-node] ${level}: ${message}${suffix}`);
|
|
15774
15962
|
},
|
|
15775
|
-
dispose: () =>
|
|
15963
|
+
dispose: () => {
|
|
15964
|
+
if (config.lspHost && "dispose" in config.lspHost && typeof config.lspHost.dispose === "function") {
|
|
15965
|
+
config.lspHost.dispose();
|
|
15966
|
+
} else {
|
|
15967
|
+
lspProcess?.dispose();
|
|
15968
|
+
}
|
|
15969
|
+
}
|
|
15776
15970
|
};
|
|
15777
15971
|
}
|
|
15778
15972
|
function uniqueStrings(values) {
|
|
@@ -15813,9 +16007,10 @@ var require_nodeHostServices = __commonJS({
|
|
|
15813
16007
|
};
|
|
15814
16008
|
}
|
|
15815
16009
|
var LspDiagnosticsHost = class {
|
|
15816
|
-
constructor(lsp, workspaceRoot, revalidation) {
|
|
16010
|
+
constructor(lsp, workspaceRoot, honorWorkspaceIgnoreList, revalidation) {
|
|
15817
16011
|
this.lsp = lsp;
|
|
15818
16012
|
this.workspaceRoot = workspaceRoot;
|
|
16013
|
+
this.honorWorkspaceIgnoreList = honorWorkspaceIgnoreList;
|
|
15819
16014
|
this.revalidation = revalidation;
|
|
15820
16015
|
}
|
|
15821
16016
|
async getDiagnostics(filter = {}, context) {
|
|
@@ -15829,36 +16024,66 @@ var require_nodeHostServices = __commonJS({
|
|
|
15829
16024
|
applyIgnoreList(result) {
|
|
15830
16025
|
if (!result.ok || result.diagnostics.length === 0)
|
|
15831
16026
|
return result;
|
|
15832
|
-
return (0, projectSettings_1.applyDiagnosticIgnoreList)(result, (0, projectSettings_1.
|
|
16027
|
+
return (0, projectSettings_1.applyDiagnosticIgnoreList)(result, (0, projectSettings_1.honouredIgnoredDiagnostics)(this.workspaceRoot, this.honorWorkspaceIgnoreList));
|
|
15833
16028
|
}
|
|
15834
16029
|
async queryDiagnostics(filter, signal) {
|
|
15835
16030
|
const file = filter.file;
|
|
15836
16031
|
if (file) {
|
|
15837
16032
|
const resolution = (0, cwtools_shared_1.resolveWorkspacePath)(this.workspaceRoot, file);
|
|
15838
16033
|
const filePath = resolution.resolvedPath ?? file;
|
|
15839
|
-
|
|
15840
|
-
|
|
16034
|
+
if (!resolution.ok || !resolution.resolvedPath || !fssync.existsSync(filePath)) {
|
|
16035
|
+
return {
|
|
16036
|
+
ok: false,
|
|
16037
|
+
status: "unavailable",
|
|
16038
|
+
diagnostics: [],
|
|
16039
|
+
error: {
|
|
16040
|
+
code: "file_not_found",
|
|
16041
|
+
message: `No file at '${filePath}'. Pass an absolute path or a workspace-relative path; omit 'file' for whole-workspace diagnostics.`
|
|
16042
|
+
}
|
|
16043
|
+
};
|
|
16044
|
+
}
|
|
16045
|
+
const value2 = await this.lsp.executeCommand("cwtools.ai.getDiagnosticsFresh", [(0, lspProcessHost_1.pathToFileUri)(filePath)], { timeoutMs: 2e4, ...signal ? { signal } : {} });
|
|
16046
|
+
if (value2 === null || value2 === void 0)
|
|
16047
|
+
return pendingDiagnostics();
|
|
16048
|
+
return normalizeDiagnosticsFresh(asRecord(value2));
|
|
15841
16049
|
}
|
|
15842
16050
|
const severity = filter.severity === "information" ? "info" : filter.severity ?? "all";
|
|
15843
16051
|
const limit = typeof filter.limit === "number" ? filter.limit : 1e3;
|
|
15844
|
-
const
|
|
16052
|
+
const value = await this.lsp.executeCommand("cwtools.ai.getAllDiagnostics", [severity, limit], { timeoutMs: 3e4, ...signal ? { signal } : {} });
|
|
16053
|
+
if (value === null || value === void 0)
|
|
16054
|
+
return pendingDiagnostics();
|
|
16055
|
+
const raw = asRecord(value);
|
|
15845
16056
|
if (raw.ok === false || raw.status === "unavailable") {
|
|
15846
16057
|
return unavailableDiagnostics(raw);
|
|
15847
16058
|
}
|
|
16059
|
+
const freshness = normalizeFreshnessValue(raw.freshness);
|
|
15848
16060
|
return {
|
|
15849
16061
|
ok: true,
|
|
15850
|
-
status:
|
|
16062
|
+
status: freshness,
|
|
15851
16063
|
diagnostics: Array.isArray(raw.diagnostics) ? raw.diagnostics.map(normalizeDiagnosticRecord) : [],
|
|
15852
16064
|
totalCount: numberOrUndefined(raw.totalCount),
|
|
16065
|
+
errorCount: numberOrUndefined(raw.errorCount),
|
|
16066
|
+
warningCount: numberOrUndefined(raw.warningCount),
|
|
15853
16067
|
truncated: raw.truncated === true,
|
|
15854
16068
|
freshness: {
|
|
15855
|
-
value:
|
|
15856
|
-
pendingKinds:
|
|
16069
|
+
value: freshness,
|
|
16070
|
+
pendingKinds: asStringArray(raw.pendingGlobalKinds),
|
|
15857
16071
|
epoch: numberOrUndefined(raw.epoch)
|
|
15858
16072
|
}
|
|
15859
16073
|
};
|
|
15860
16074
|
}
|
|
15861
16075
|
};
|
|
16076
|
+
function pendingDiagnostics() {
|
|
16077
|
+
return {
|
|
16078
|
+
ok: true,
|
|
16079
|
+
status: "pending",
|
|
16080
|
+
diagnostics: [],
|
|
16081
|
+
freshness: { value: "pending", pendingKinds: ["game_model"] }
|
|
16082
|
+
};
|
|
16083
|
+
}
|
|
16084
|
+
function normalizeFreshnessValue(value) {
|
|
16085
|
+
return value === "fresh" || value === "pending" || value === "stale" || value === "unavailable" ? value : "fresh";
|
|
16086
|
+
}
|
|
15862
16087
|
function normalizeDiagnosticsFresh(raw) {
|
|
15863
16088
|
if (raw.ok === false || raw.status === "unavailable") {
|
|
15864
16089
|
return unavailableDiagnostics(raw);
|
package/dist/mcp/resources.js
CHANGED
|
@@ -77,7 +77,7 @@ function listResources(host) {
|
|
|
77
77
|
{
|
|
78
78
|
uri: 'cwtools://project/knowledge-manifest',
|
|
79
79
|
name: 'CWTools project knowledge manifest',
|
|
80
|
-
description: 'Freshness, domains, counts, and fingerprints for the
|
|
80
|
+
description: 'Freshness, domains, counts, and fingerprints for the initialize_project semantic knowledge pack.',
|
|
81
81
|
mimeType: 'application/json',
|
|
82
82
|
},
|
|
83
83
|
{
|
|
@@ -230,7 +230,7 @@ async function readResourceData(host, uri) {
|
|
|
230
230
|
: {
|
|
231
231
|
status: 'missing',
|
|
232
232
|
profilePath,
|
|
233
|
-
_hint: '
|
|
233
|
+
_hint: 'Call initialize_project to generate the profile, then read this resource again.',
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
case 'cwtools://project/knowledge-manifest': {
|
|
@@ -241,7 +241,7 @@ async function readResourceData(host, uri) {
|
|
|
241
241
|
: {
|
|
242
242
|
status: 'missing',
|
|
243
243
|
manifestPath,
|
|
244
|
-
_hint: '
|
|
244
|
+
_hint: 'Call initialize_project and wait for the knowledge export to complete.',
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
case 'cwtools://skills/catalog': {
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { type McpToolSchema } from 'cwtools-shared';
|
|
2
|
-
export declare function listRegisteredTools(options?:
|
|
3
|
-
includeWrites?: boolean;
|
|
4
|
-
cwtOnly?: boolean;
|
|
5
|
-
}): McpToolSchema[];
|
|
1
|
+
import { type McpToolSchema, type ToolSurfaceOptions } from 'cwtools-shared';
|
|
2
|
+
export declare function listRegisteredTools(options?: ToolSurfaceOptions): McpToolSchema[];
|
package/dist/server.js
CHANGED
|
@@ -54,6 +54,7 @@ function listServerTools(host) {
|
|
|
54
54
|
return (0, toolRegistrar_1.listRegisteredTools)({
|
|
55
55
|
includeWrites: host.writesEnabled === true && host.readonlyMode === false,
|
|
56
56
|
cwtOnly: host.projectKind === 'cwt-only',
|
|
57
|
+
capabilities: host.capabilities,
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
function createCwtoolsMcpServer(host, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cwtools-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "MCP server exposing CWTools semantic tools and default-on whitelisted domain writes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
|
-
"cwtools-node": "0.
|
|
40
|
-
"cwtools-shared": "0.
|
|
39
|
+
"cwtools-node": "0.3.0",
|
|
40
|
+
"cwtools-shared": "0.4.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"esbuild": "^0.28.1"
|