cwtools-mcp 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/README.md CHANGED
@@ -93,6 +93,26 @@ stale, or the client workspace differs from the bridge workspace, tool
93
93
  calls return `bridge_unavailable` with recovery instructions. The proxy
94
94
  intentionally does not silently fall back to a separate language server.
95
95
 
96
+ ### Project Detection And Capability Modes
97
+
98
+ The server separates project support from game identity. Strong evidence includes
99
+ `descriptor.mod`, a valid `.cwtools/project/profile.json`, distinctive nested game
100
+ directories, known Workshop App IDs, and validated game-data paths. Generic content
101
+ directories require at least two directories plus a real PDX payload file. Parent
102
+ lookup accepts only strong non-recursive evidence; child lookup accepts exactly one
103
+ project and returns `project_ambiguous` when several exist.
104
+
105
+ Unsupported and ambiguous workspaces return empty `tools/list` and
106
+ `resources/list`, never start an LSP, and reject cached calls. A supported mod with
107
+ an inconclusive game uses generic `paradox` mode with no Stellaris rules/cache;
108
+ `--game` supplies an explicit game. `--force-start` permits generic mode without
109
+ markers but does not invent a game or select among multiple child projects.
110
+
111
+ CWT-only mode starts the LSP as `cwt` and exposes only `get_diagnostics`,
112
+ `analyze_diagnostic_error`, `get_completion_at`, `document_symbols`,
113
+ `workspace_symbols`, `go_to_definition`, and `find_references`. Other cached tool
114
+ calls fail with `tool_not_available_in_cwt_only`.
115
+
96
116
  ### Optional Standalone Mode
97
117
 
98
118
  Use standalone mode only when you explicitly want the MCP process to start its
@@ -125,8 +145,9 @@ using the active extension host's loaded state.
125
145
 
126
146
  ### Tools
127
147
 
128
- The MCP surface remains read-only. It exposes the generated CWTools semantic
129
- tools such as:
148
+ The MCP surface exposes generated CWTools semantic tools plus six whitelisted
149
+ domain-write tools by default. The legacy `--enable-writes` /
150
+ `--allow-domain-writes` flags remain accepted but are no longer required.
130
151
 
131
152
  - `query_types`
132
153
  - `query_rules`
@@ -140,9 +161,10 @@ tools such as:
140
161
  - deep semantic queries for scripted effects/triggers, enums, static modifiers,
141
162
  variables, and entity info
142
163
 
143
- File edits are intentionally not exposed through this MCP server. External agents
144
- should edit files through their own environment and then call MCP diagnostics or
145
- semantic tools again.
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.
146
168
 
147
169
  ---
148
170
 
@@ -230,6 +252,23 @@ node -e "const fs=require('fs'),os=require('os'),path=require('path');const p=pa
230
252
  如果兼容宿主未打开、工作区未激活、manifest 已失效,或客户端工作区与 bridge
231
253
  工作区不一致,工具调用会返回 `bridge_unavailable` 和恢复说明。代理不会静默回退并启动单独的语言服务。
232
254
 
255
+ ### 项目识别与能力模式
256
+
257
+ 服务端分开判断项目是否支持和具体游戏身份。强证据包括 `descriptor.mod`、有效的
258
+ `.cwtools/project/profile.json`、游戏专属嵌套目录、已知 Workshop App ID 和经过验证的
259
+ 游戏数据目录。通用内容目录必须至少有两个,并且包含真实 PDX 文件。祖先查找只接受
260
+ 非递归强证据;子项目查找只接受唯一匹配,多个匹配返回 `project_ambiguous`。
261
+
262
+ 非支持与歧义工作区返回空的 `tools/list` 和 `resources/list`,不启动 LSP,并拒绝
263
+ 缓存调用。游戏无法确定但确认是 Mod 时,使用不带 Stellaris 规则/缓存的通用
264
+ `paradox` 模式;`--game` 可显式指定游戏。`--force-start` 允许无标记项目进入通用模式,
265
+ 但不会伪造游戏,也不会从多个子项目中任选一个。
266
+
267
+ CWT-only 模式以 `cwt` 启动 LSP,只暴露 `get_diagnostics`、
268
+ `analyze_diagnostic_error`、`get_completion_at`、`document_symbols`、
269
+ `workspace_symbols`、`go_to_definition` 和 `find_references`。其他缓存工具调用返回
270
+ `tool_not_available_in_cwt_only`。
271
+
233
272
  ### 可选 Standalone 模式
234
273
 
235
274
  只有在明确需要旧行为时才使用 standalone 模式:MCP 进程会自行启动一份 CWTools
@@ -261,7 +300,8 @@ cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --rules "/pat
261
300
 
262
301
  ### 工具
263
302
 
264
- MCP 入口仍保持只读。它暴露生成出来的 CWTools 语义工具,例如:
303
+ MCP 入口默认提供生成的 CWTools 语义工具和六个白名单领域写入工具。
304
+ 兼容参数 `--enable-writes` / `--allow-domain-writes` 仍可使用,但不再是启用前提。
265
305
 
266
306
  - `query_types`
267
307
  - `query_rules`
@@ -274,5 +314,6 @@ MCP 入口仍保持只读。它暴露生成出来的 CWTools 语义工具,例
274
314
  - 补全、document/workspace symbols、定义和引用查询
275
315
  - scripted effects/triggers、enums、static modifiers、variables、entity info 等深层语义查询
276
316
 
277
- 文件写入不会通过这个 MCP server 暴露。外部 Agent 应使用自己的环境编辑文件,
278
- 然后再调用 MCP 诊断或语义工具复查。
317
+ 默认写入工具为 `write_localisation`、`typed_pdx_write`、`candidate_transaction`、
318
+ `convert_image_to_dds`、`convert_audio` 和 `deploy_mod_asset`。既有路径包含性、
319
+ 锁和写入预检仍然生效,非白名单写入继续拒绝。写入后应重新调用诊断。
package/dist/config.js CHANGED
@@ -43,7 +43,7 @@ function parseCliArgs(argv) {
43
43
  http: false,
44
44
  host: '127.0.0.1',
45
45
  port: 3000,
46
- enableWrites: false,
46
+ enableWrites: true,
47
47
  allowedTools: [],
48
48
  forceStart: false,
49
49
  standalone: false,
@@ -206,11 +206,20 @@ function helpText() {
206
206
  ' --rules <dir> Explicit CWT rules directory (a .zip is rejected). When omitted, the',
207
207
  ' rules the installed VS Code extension pulled into globalStorage are used.',
208
208
  '',
209
+ 'Domain writes:',
210
+ ' (default) Six whitelisted domain-write tools are enabled in bridge and standalone modes.',
211
+ ' --enable-writes Compatibility alias; writes are already enabled by default.',
212
+ ' --allow-domain-writes Equivalent compatibility alias. No CLI read-only switch is provided.',
213
+ ' --allow-tool <name> Restrict standalone write tools to an explicit allowlist.',
214
+ '',
209
215
  'Project gate:',
210
- ' (default) Tools are always listed. The language server starts only when the',
211
- ' workspace is (or sits in/above) a Paradox mod (descriptor.mod, common/,',
212
- ' events/, localisation/, .cwtools/). On other workspaces tool calls are',
213
- ' rejected with a reason and no server spawns.',
214
- ' --force-start Treat the workspace as supported even without mod markers.',
216
+ ' (default) Reliable evidence is required: descriptor.mod, a valid CWTools profile,',
217
+ ' distinctive game directories, Workshop App ID, or multiple PDX content',
218
+ ' directories with real payload files. Unsupported/ambiguous workspaces',
219
+ ' disclose no tools/resources and never spawn the language server.',
220
+ ' A unique child mod is used as the effective root; multiple child projects',
221
+ ' require --workspace. Unknown games use generic paradox mode, never an',
222
+ ' implicit Stellaris model. CWT-only workspaces expose seven CWT tools.',
223
+ ' --force-start Use generic mode without project evidence; does not invent a game id',
215
224
  ].join('\n');
216
225
  }