cwtools-mcp 0.2.9 → 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 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,24 +145,11 @@ 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:
130
-
131
- - `query_types`
132
- - `query_rules`
133
- - `query_scope`
134
- - `get_diagnostics`
135
- - `explore_pdx_project` for a bounded live semantic graph with dependency edges and freshness
136
- - `query_workspace_index`
137
- - `query_localisation_index`
138
- - `get_pdx_block`
139
- - completion, document/workspace symbols, definition and reference lookup
140
- - deep semantic queries for scripted effects/triggers, enums, static modifiers,
141
- variables, and entity info
142
-
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.
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.
146
153
 
147
154
  ---
148
155
 
@@ -162,7 +169,7 @@ bridge,并复用该宿主中的:
162
169
  - 当前工作区根目录;
163
170
  - IDE Problems 面板诊断;
164
171
  - rules/cache/localisation/用户设置;
165
- - 共享索引和 AI 只读工具。
172
+ - 共享索引和语义工具。
166
173
 
167
174
  这样可以降低内存占用,并让 MCP 诊断数量与 IDE 保持一致。
168
175
 
@@ -230,6 +237,23 @@ node -e "const fs=require('fs'),os=require('os'),path=require('path');const p=pa
230
237
  如果兼容宿主未打开、工作区未激活、manifest 已失效,或客户端工作区与 bridge
231
238
  工作区不一致,工具调用会返回 `bridge_unavailable` 和恢复说明。代理不会静默回退并启动单独的语言服务。
232
239
 
240
+ ### 项目识别与能力模式
241
+
242
+ 服务端分开判断项目是否支持和具体游戏身份。强证据包括 `descriptor.mod`、有效的
243
+ `.cwtools/project/profile.json`、游戏专属嵌套目录、已知 Workshop App ID 和经过验证的
244
+ 游戏数据目录。通用内容目录必须至少有两个,并且包含真实 PDX 文件。祖先查找只接受
245
+ 非递归强证据;子项目查找只接受唯一匹配,多个匹配返回 `project_ambiguous`。
246
+
247
+ 非支持与歧义工作区返回空的 `tools/list` 和 `resources/list`,不启动 LSP,并拒绝
248
+ 缓存调用。游戏无法确定但确认是 Mod 时,使用不带 Stellaris 规则/缓存的通用
249
+ `paradox` 模式;`--game` 可显式指定游戏。`--force-start` 允许无标记项目进入通用模式,
250
+ 但不会伪造游戏,也不会从多个子项目中任选一个。
251
+
252
+ CWT-only 模式以 `cwt` 启动 LSP,只暴露 `get_diagnostics`、
253
+ `analyze_diagnostic_error`、`get_completion_at`、`document_symbols`、
254
+ `workspace_symbols`、`go_to_definition` 和 `find_references`。其他缓存工具调用返回
255
+ `tool_not_available_in_cwt_only`。
256
+
233
257
  ### 可选 Standalone 模式
234
258
 
235
259
  只有在明确需要旧行为时才使用 standalone 模式:MCP 进程会自行启动一份 CWTools
@@ -261,18 +285,8 @@ cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --rules "/pat
261
285
 
262
286
  ### 工具
263
287
 
264
- MCP 入口仍保持只读。它暴露生成出来的 CWTools 语义工具,例如:
265
-
266
- - `query_types`
267
- - `query_rules`
268
- - `query_scope`
269
- - `get_diagnostics`
270
- - `explore_pdx_project`:返回带依赖边与 freshness 的有界 live 语义图
271
- - `query_workspace_index`
272
- - `query_localisation_index`
273
- - `get_pdx_block`
274
- - 补全、document/workspace symbols、定义和引用查询
275
- - scripted effects/triggers、enums、static modifiers、variables、entity info 等深层语义查询
276
-
277
- 文件写入不会通过这个 MCP server 暴露。外部 Agent 应使用自己的环境编辑文件,
278
- 然后再调用 MCP 诊断或语义工具复查。
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/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
  }