dsh-cwtools 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +100 -2
- package/cordis.patch.yml +4 -0
- package/icon.svg +7 -0
- package/lib/client.js +1097 -0
- package/lib/index.js +539 -0
- package/lib/types/client/CwtoolsSection.d.ts +10 -0
- package/lib/types/client/CwtoolsSectionIcon.d.ts +8 -0
- package/lib/types/client/cwtools-controller.d.ts +82 -0
- package/lib/types/client/index.d.ts +27 -0
- package/lib/types/client/locales.d.ts +25 -0
- package/lib/types/config.d.ts +7 -0
- package/lib/types/contract/configTypes.d.ts +37 -0
- package/lib/types/contract/toolCatalog.d.ts +19 -0
- package/lib/types/host/activeBackend.d.ts +8 -0
- package/lib/types/host/contracts.d.ts +22 -0
- package/lib/types/host/errors.d.ts +9 -0
- package/lib/types/host/nativeTools.d.ts +4 -0
- package/lib/types/host/prompt.d.ts +1 -0
- package/lib/types/host/results.d.ts +7 -0
- package/lib/types/host/runtime.d.ts +22 -0
- package/lib/types/index.d.ts +7 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +91 -3
package/lib/client.js
ADDED
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-cwtools",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
// src/contract/toolCatalog.ts
|
|
11
|
+
const CWTOOLS_READ_TOOL_GROUPS = {
|
|
12
|
+
project: [
|
|
13
|
+
"query_project_profile",
|
|
14
|
+
"query_project_knowledge",
|
|
15
|
+
"query_workspace_index",
|
|
16
|
+
"explore_pdx_project",
|
|
17
|
+
"analyze_pdx_flow",
|
|
18
|
+
"query_inline_instantiation",
|
|
19
|
+
"compare_definition_with_vanilla"
|
|
20
|
+
],
|
|
21
|
+
localisation: ["query_localisation_index"],
|
|
22
|
+
semantic: [
|
|
23
|
+
"query_types",
|
|
24
|
+
"query_rules",
|
|
25
|
+
"query_cwt_schema",
|
|
26
|
+
"search_rule_capabilities",
|
|
27
|
+
"explain_scope",
|
|
28
|
+
"parse_pdx_fragment",
|
|
29
|
+
"query_scope",
|
|
30
|
+
"query_scripted_effects",
|
|
31
|
+
"query_scripted_triggers",
|
|
32
|
+
"query_enums",
|
|
33
|
+
"query_static_modifiers",
|
|
34
|
+
"query_variables",
|
|
35
|
+
"get_entity_info",
|
|
36
|
+
"get_pdx_block",
|
|
37
|
+
"query_targeting_weight"
|
|
38
|
+
],
|
|
39
|
+
navigation: [
|
|
40
|
+
"get_completion_at",
|
|
41
|
+
"document_symbols",
|
|
42
|
+
"workspace_symbols",
|
|
43
|
+
"go_to_definition",
|
|
44
|
+
"find_references"
|
|
45
|
+
],
|
|
46
|
+
diagnostics: ["get_diagnostics", "analyze_diagnostic_error"],
|
|
47
|
+
shader: [
|
|
48
|
+
"query_shader_symbol",
|
|
49
|
+
"query_shader_compile_unit",
|
|
50
|
+
"query_shader_platform_variants",
|
|
51
|
+
"query_shader_callers",
|
|
52
|
+
"explain_shader_reachability",
|
|
53
|
+
"validate_shader",
|
|
54
|
+
"compare_shader_with_vanilla"
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
const CWTOOLS_READ_GROUP_ORDER = [
|
|
58
|
+
"project",
|
|
59
|
+
"localisation",
|
|
60
|
+
"semantic",
|
|
61
|
+
"navigation",
|
|
62
|
+
"diagnostics",
|
|
63
|
+
"shader"
|
|
64
|
+
];
|
|
65
|
+
const CWTOOLS_READ_TOOL_NAMES = Object.freeze(CWTOOLS_READ_GROUP_ORDER.flatMap((group) => [...CWTOOLS_READ_TOOL_GROUPS[group]]));
|
|
66
|
+
const CWTOOLS_WRITE_TOOL_NAMES = ["write_localisation"];
|
|
67
|
+
[...CWTOOLS_READ_TOOL_NAMES, ...CWTOOLS_WRITE_TOOL_NAMES];
|
|
68
|
+
const groupByTool = /* @__PURE__ */ new Map();
|
|
69
|
+
for (const group of CWTOOLS_READ_GROUP_ORDER) for (const name of CWTOOLS_READ_TOOL_GROUPS[group]) groupByTool.set(name, group);
|
|
70
|
+
function cwtoolsReadGroupFor(name) {
|
|
71
|
+
const group = groupByTool.get(name);
|
|
72
|
+
if (group === void 0) throw new Error("Unknown CWTools read tool: " + name);
|
|
73
|
+
return group;
|
|
74
|
+
}
|
|
75
|
+
// src/client/cwtools-controller.ts
|
|
76
|
+
/** Settings namespace of the Host entry this section edits. */
|
|
77
|
+
const CWTOOLS_SETTINGS_NAMESPACE = "cwtools";
|
|
78
|
+
/** Absolute paths and the game identifier of the backend block. */
|
|
79
|
+
const TEXT_FIELDS = [
|
|
80
|
+
{
|
|
81
|
+
field: "backend.serverPath",
|
|
82
|
+
block: "backend"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
field: "backend.gamePath",
|
|
86
|
+
block: "backend"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
field: "backend.rulesPath",
|
|
90
|
+
block: "backend"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
field: "backend.cachePath",
|
|
94
|
+
block: "backend"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
field: "backend.activeManifestPath",
|
|
98
|
+
block: "backend"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
field: "backend.game",
|
|
102
|
+
block: "backend"
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
/**
|
|
106
|
+
* Whole-number fields with the bounds the Host schema enforces.
|
|
107
|
+
*
|
|
108
|
+
* The Host owns these bounds (`src/config.ts`); the copy here only decides
|
|
109
|
+
* whether a draft is worth sending, so a typo fails in the form instead of
|
|
110
|
+
* becoming a refused write. A draft the Host rejects anyway is refused there
|
|
111
|
+
* and keeps its drafts.
|
|
112
|
+
*/
|
|
113
|
+
const NUMBER_FIELDS = [
|
|
114
|
+
{
|
|
115
|
+
field: "backend.startupTimeoutMs",
|
|
116
|
+
block: "backend",
|
|
117
|
+
min: 1,
|
|
118
|
+
max: 2147483647
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
field: "backend.requestTimeoutMs",
|
|
122
|
+
block: "backend",
|
|
123
|
+
min: 1,
|
|
124
|
+
max: 2147483647
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
field: "backend.idleShutdownMs",
|
|
128
|
+
block: "backend",
|
|
129
|
+
min: 1,
|
|
130
|
+
max: 2147483647
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
field: "backend.maxWorkspaceRuntimes",
|
|
134
|
+
block: "backend",
|
|
135
|
+
min: 1,
|
|
136
|
+
max: 8
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
field: "output.maxResultChars",
|
|
140
|
+
block: "output",
|
|
141
|
+
min: 1e3,
|
|
142
|
+
max: 2e5
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
/** Switches that are off until someone stores them. */
|
|
146
|
+
const DEFAULT_OFF_FIELDS = [
|
|
147
|
+
{
|
|
148
|
+
field: "backend.forceStart",
|
|
149
|
+
block: "backend"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
field: "backend.debug",
|
|
153
|
+
block: "backend"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
field: "writeTools.write_localisation",
|
|
157
|
+
block: "writeTools"
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
/** Switches whose absent value means on: the master switch and every read grant. */
|
|
161
|
+
const DEFAULT_ON_FIELDS = [
|
|
162
|
+
{
|
|
163
|
+
field: "enabled",
|
|
164
|
+
block: "enabled"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
field: "backend.preferActiveBackend",
|
|
168
|
+
block: "backend"
|
|
169
|
+
},
|
|
170
|
+
...CWTOOLS_READ_GROUP_ORDER.map((group) => ({
|
|
171
|
+
field: `readGroups.${group}`,
|
|
172
|
+
block: "readGroups"
|
|
173
|
+
})),
|
|
174
|
+
...CWTOOLS_READ_TOOL_NAMES.map((tool) => ({
|
|
175
|
+
field: `readTools.${tool}`,
|
|
176
|
+
block: "readTools"
|
|
177
|
+
}))
|
|
178
|
+
];
|
|
179
|
+
/** Master switch and backend fields, in the order the page renders them. */
|
|
180
|
+
const topLevel = (block) => [
|
|
181
|
+
...TEXT_FIELDS,
|
|
182
|
+
...DEFAULT_OFF_FIELDS,
|
|
183
|
+
...NUMBER_FIELDS,
|
|
184
|
+
...DEFAULT_ON_FIELDS
|
|
185
|
+
].filter((ref) => ref.block === block);
|
|
186
|
+
/** Every control on the page, in rendering order. */
|
|
187
|
+
const CWTOOLS_FIELDS = [
|
|
188
|
+
...topLevel("enabled"),
|
|
189
|
+
...topLevel("backend"),
|
|
190
|
+
...topLevel("readGroups"),
|
|
191
|
+
...topLevel("readTools"),
|
|
192
|
+
...topLevel("writeTools"),
|
|
193
|
+
...topLevel("output")
|
|
194
|
+
];
|
|
195
|
+
/**
|
|
196
|
+
* Expand one level of block nesting into dotted leaf paths.
|
|
197
|
+
* @param section - an accepted section or one of its composition layers.
|
|
198
|
+
* @returns its leaves by dotted path; a nested object is expanded, not kept.
|
|
199
|
+
*/
|
|
200
|
+
function flatten(section) {
|
|
201
|
+
const flat = {};
|
|
202
|
+
if (typeof section !== "object" || section === null || Array.isArray(section)) return flat;
|
|
203
|
+
for (const [key, value] of Object.entries(section)) if (typeof value === "object" && value !== null && !Array.isArray(value)) for (const [child, leaf] of Object.entries(value)) flat[`${key}.${child}`] = leaf;
|
|
204
|
+
else flat[key] = value;
|
|
205
|
+
return flat;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The conversion spec of one switch.
|
|
209
|
+
* @param field - dotted path of the switch.
|
|
210
|
+
* @param fallback - the text an absent value renders as.
|
|
211
|
+
* @returns the field's conversion spec.
|
|
212
|
+
*/
|
|
213
|
+
function switchField(field, fallback) {
|
|
214
|
+
return {
|
|
215
|
+
field,
|
|
216
|
+
format: (value) => typeof value === "boolean" ? String(value) : fallback,
|
|
217
|
+
parse: (text) => text === "true" ? {
|
|
218
|
+
kind: "set",
|
|
219
|
+
value: true
|
|
220
|
+
} : text === "false" ? {
|
|
221
|
+
kind: "set",
|
|
222
|
+
value: false
|
|
223
|
+
} : void 0
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* A whole-number field that also refuses drafts outside the Host's bounds.
|
|
228
|
+
* @param ref - the field and its inclusive bounds.
|
|
229
|
+
* @returns the field's conversion spec.
|
|
230
|
+
*/
|
|
231
|
+
function boundedNumberField(ref) {
|
|
232
|
+
const numeric = (0, _deepseek_ai_dsh_client_ui_primitives.settingsNumberField)(ref.field);
|
|
233
|
+
return {
|
|
234
|
+
...numeric,
|
|
235
|
+
parse: (text) => {
|
|
236
|
+
const write = numeric.parse(text);
|
|
237
|
+
if (write?.kind !== "set") return write;
|
|
238
|
+
const value = write.value;
|
|
239
|
+
return Number.isSafeInteger(value) && value >= ref.min && value <= ref.max ? write : void 0;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/** The conversion spec of every control on the page. */
|
|
244
|
+
const SPECS = [
|
|
245
|
+
...topLevel("enabled").map((ref) => switchField(ref.field, "true")),
|
|
246
|
+
...DEFAULT_ON_FIELDS.filter((ref) => ref.block === "backend").map((ref) => switchField(ref.field, "true")),
|
|
247
|
+
...TEXT_FIELDS.map((ref) => (0, _deepseek_ai_dsh_client_ui_primitives.settingsTextField)(ref.field)),
|
|
248
|
+
...DEFAULT_OFF_FIELDS.filter((ref) => ref.block === "backend").map((ref) => switchField(ref.field, "false")),
|
|
249
|
+
...NUMBER_FIELDS.filter((ref) => ref.block === "backend").map(boundedNumberField),
|
|
250
|
+
...topLevel("readGroups").map((ref) => switchField(ref.field, "true")),
|
|
251
|
+
...topLevel("readTools").map((ref) => switchField(ref.field, "true")),
|
|
252
|
+
...DEFAULT_OFF_FIELDS.filter((ref) => ref.block === "writeTools").map((ref) => switchField(ref.field, "false")),
|
|
253
|
+
...NUMBER_FIELDS.filter((ref) => ref.block === "output").map(boundedNumberField)
|
|
254
|
+
];
|
|
255
|
+
/** Read the spec of one field. */
|
|
256
|
+
const specOf = (field) => SPECS.find((candidate) => candidate.field === field);
|
|
257
|
+
/**
|
|
258
|
+
* Present one Host entry as a flat section, and translate its single-element
|
|
259
|
+
* write paths back into the nested paths the document stores.
|
|
260
|
+
*/
|
|
261
|
+
var FlatSectionScope = class {
|
|
262
|
+
form;
|
|
263
|
+
/** The last write attempted, so the section can tell a refusal from a conflict. */
|
|
264
|
+
lastWrite;
|
|
265
|
+
cache;
|
|
266
|
+
listeners = /* @__PURE__ */ new Set();
|
|
267
|
+
/** @param form - the shared configuration form of this Host entry. */
|
|
268
|
+
constructor(form) {
|
|
269
|
+
this.form = form;
|
|
270
|
+
}
|
|
271
|
+
/** @returns the entry's current snapshot with every block flattened. */
|
|
272
|
+
getSnapshot() {
|
|
273
|
+
const source = this.form.getSnapshot();
|
|
274
|
+
if (this.cache?.source === source) return this.cache.flat;
|
|
275
|
+
const flat = {
|
|
276
|
+
status: source.status,
|
|
277
|
+
value: source.value === void 0 ? void 0 : flatten(source.value),
|
|
278
|
+
base: flatten(source.base),
|
|
279
|
+
user: flatten(source.user),
|
|
280
|
+
writable: source.writable,
|
|
281
|
+
revision: source.revision
|
|
282
|
+
};
|
|
283
|
+
this.cache = {
|
|
284
|
+
source,
|
|
285
|
+
flat
|
|
286
|
+
};
|
|
287
|
+
return flat;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Observe snapshot replacements, keeping this adapter's own listeners so a
|
|
291
|
+
* settled write republishes the refusal bookkeeping.
|
|
292
|
+
* @param listener - invoked after each change.
|
|
293
|
+
* @returns the disposer removing this listener.
|
|
294
|
+
*/
|
|
295
|
+
subscribe(listener) {
|
|
296
|
+
const unsubscribe = this.form.subscribe(listener);
|
|
297
|
+
this.listeners.add(listener);
|
|
298
|
+
return () => {
|
|
299
|
+
this.listeners.delete(listener);
|
|
300
|
+
unsubscribe();
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Write one save's operations as a single revision-fenced mutation.
|
|
305
|
+
* @param ops - the staged operations, addressed by dotted path.
|
|
306
|
+
* @param expectedRevision - the revision the drafts were staged against.
|
|
307
|
+
* @returns whether the Host accepted the mutation.
|
|
308
|
+
*/
|
|
309
|
+
async mutate(ops, expectedRevision) {
|
|
310
|
+
const revision = expectedRevision ?? this.form.getSnapshot().revision;
|
|
311
|
+
this.lastWrite = {
|
|
312
|
+
fields: ops.map((op) => op.path.join(".")),
|
|
313
|
+
revision,
|
|
314
|
+
accepted: false
|
|
315
|
+
};
|
|
316
|
+
const accepted = await this.form.mutate(ops.map(toWireOp), revision);
|
|
317
|
+
this.lastWrite = {
|
|
318
|
+
fields: this.lastWrite.fields,
|
|
319
|
+
revision,
|
|
320
|
+
accepted
|
|
321
|
+
};
|
|
322
|
+
for (const listener of [...this.listeners]) listener();
|
|
323
|
+
return accepted;
|
|
324
|
+
}
|
|
325
|
+
/** Release this view of the shared form. */
|
|
326
|
+
dispose() {
|
|
327
|
+
this.listeners.clear();
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Translate one staged operation into the wire shape the Host accepts: the
|
|
332
|
+
* single dotted segment the shared model uses becomes the nested path the
|
|
333
|
+
* Host document stores.
|
|
334
|
+
* @param op - the staged operation.
|
|
335
|
+
* @returns the same operation addressed inside the document.
|
|
336
|
+
*/
|
|
337
|
+
function toWireOp(op) {
|
|
338
|
+
const path = [...op.path].flatMap((segment) => segment.split("."));
|
|
339
|
+
return op.op === "set" ? {
|
|
340
|
+
op: "set",
|
|
341
|
+
path,
|
|
342
|
+
value: op.value
|
|
343
|
+
} : {
|
|
344
|
+
op: "unset",
|
|
345
|
+
path
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Bind the whole CWTools section to one staged form.
|
|
350
|
+
*
|
|
351
|
+
* Every control is staged; a save writes the staged edits together; leaving the
|
|
352
|
+
* page drops them. A refused save keeps its drafts, reports the values the Host
|
|
353
|
+
* still holds, and says whether the document moved underneath.
|
|
354
|
+
*/
|
|
355
|
+
var CwtoolsSettingsController = class {
|
|
356
|
+
scope;
|
|
357
|
+
form;
|
|
358
|
+
store;
|
|
359
|
+
/** @param form - the shared configuration form of the `cwtools` entry. */
|
|
360
|
+
constructor(form) {
|
|
361
|
+
this.scope = new FlatSectionScope(form);
|
|
362
|
+
this.form = new _deepseek_ai_dsh_client_ui_primitives.SettingsFormModel(this.scope, [...SPECS]);
|
|
363
|
+
this.store = this.form.bind(() => this.project());
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Bind the section to the slot renderer.
|
|
367
|
+
* @returns the section snapshot and its staged actions.
|
|
368
|
+
*/
|
|
369
|
+
inject() {
|
|
370
|
+
return {
|
|
371
|
+
hooks: { cwtoolsSection: this.store },
|
|
372
|
+
...this.form.actions(),
|
|
373
|
+
toggle: (field, next) => {
|
|
374
|
+
this.form.actions().edit(field, String(next));
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
/** Release the accepted-value subscription and the flattened view. */
|
|
379
|
+
dispose() {
|
|
380
|
+
this.form.dispose();
|
|
381
|
+
this.scope.dispose();
|
|
382
|
+
}
|
|
383
|
+
/** Rebuild everything the component renders from the current reads and drafts. */
|
|
384
|
+
project() {
|
|
385
|
+
const shell = this.form.shell();
|
|
386
|
+
const fields = {};
|
|
387
|
+
for (const ref of CWTOOLS_FIELDS) fields[ref.field] = this.form.field(ref.field);
|
|
388
|
+
const stored = (field) => fields[field]?.text === "true";
|
|
389
|
+
const groups = {};
|
|
390
|
+
for (const group of CWTOOLS_READ_GROUP_ORDER) groups[group] = stored(`readGroups.${group}`);
|
|
391
|
+
const tools = {};
|
|
392
|
+
for (const tool of CWTOOLS_READ_TOOL_NAMES) tools[tool] = groups[cwtoolsReadGroupFor(tool)] && stored(`readTools.${tool}`);
|
|
393
|
+
return {
|
|
394
|
+
...shell,
|
|
395
|
+
fields,
|
|
396
|
+
groups,
|
|
397
|
+
tools,
|
|
398
|
+
conflict: shell.failed && this.conflict(),
|
|
399
|
+
accepted: shell.failed ? this.acceptedValues() : []
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
/** Whether the refused write lost a revision race rather than failing validation. */
|
|
403
|
+
conflict() {
|
|
404
|
+
const write = this.scope.lastWrite;
|
|
405
|
+
if (write === void 0 || write.accepted) return false;
|
|
406
|
+
const revision = this.scope.getSnapshot().revision;
|
|
407
|
+
return write.revision !== void 0 && revision !== void 0 && revision !== write.revision;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* The values the Host still holds for the fields the refused save tried to
|
|
411
|
+
* write. Read from the accepted section, never from the draft, so the notice
|
|
412
|
+
* shows what a reload would restore.
|
|
413
|
+
*/
|
|
414
|
+
acceptedValues() {
|
|
415
|
+
const write = this.scope.lastWrite;
|
|
416
|
+
if (write === void 0) return [];
|
|
417
|
+
const accepted = this.scope.getSnapshot().value ?? {};
|
|
418
|
+
return write.fields.flatMap((field) => {
|
|
419
|
+
const spec = specOf(field);
|
|
420
|
+
if (spec === void 0) return [];
|
|
421
|
+
return [{
|
|
422
|
+
field,
|
|
423
|
+
text: spec.format(accepted[field])
|
|
424
|
+
}];
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
// src/client/locales.ts
|
|
429
|
+
/** English copy. */
|
|
430
|
+
const en = {
|
|
431
|
+
nav: "CWTools",
|
|
432
|
+
title: "CWTools",
|
|
433
|
+
intro: "Configure the CWTools language server and which semantic tools this bundle exposes. Every control on this page is saved together.",
|
|
434
|
+
sectionBackend: "Backend and project",
|
|
435
|
+
sectionReadAccess: "Read tools",
|
|
436
|
+
sectionWriteAccess: "Write access",
|
|
437
|
+
sectionOutput: "Output",
|
|
438
|
+
enabled: "Enable CWTools tools",
|
|
439
|
+
enabledHint: "Turning this off withdraws every CWTools tool while keeping the settings below.",
|
|
440
|
+
serverPath: "Server path",
|
|
441
|
+
serverPathHint: "Path to the CWTools language server executable. When empty, the backend is discovered automatically: an installed CWTools extension or a development build. This bundle does not ship one.",
|
|
442
|
+
gamePath: "Game path",
|
|
443
|
+
gamePathHint: "Path to the Paradox game installation.",
|
|
444
|
+
rulesPath: "Rules path",
|
|
445
|
+
rulesPathHint: "Path to the CWTools rules directory. Empty uses the server default.",
|
|
446
|
+
cachePath: "Cache path",
|
|
447
|
+
cachePathHint: "Directory for the server cache. Empty uses the workspace default.",
|
|
448
|
+
activeManifestPath: "Active bridge manifest (optional)",
|
|
449
|
+
activeManifestPathHint: "Explicit bridge-manifest.json for active-first reuse. Empty auto-discovers the current workspace host.",
|
|
450
|
+
preferActiveBackend: "Prefer the active backend",
|
|
451
|
+
preferActiveBackendHint: "Reuse a healthy active host for this workspace. If none is reusable, start a standalone backend; an incompatible active host never causes a second one.",
|
|
452
|
+
game: "Game",
|
|
453
|
+
gameHint: "Paradox game identifier such as stellaris or ck3. Empty detects it from the project.",
|
|
454
|
+
forceStart: "Force start",
|
|
455
|
+
forceStartHint: "Start the language server even when the project does not look like a supported game.",
|
|
456
|
+
debug: "Debug logging",
|
|
457
|
+
debugHint: "Keep verbose server diagnostics in the log.",
|
|
458
|
+
startupTimeoutMs: "Startup timeout (ms)",
|
|
459
|
+
startupTimeoutMsHint: "How long to wait for the language server to become ready.",
|
|
460
|
+
requestTimeoutMs: "Request timeout (ms)",
|
|
461
|
+
requestTimeoutMsHint: "How long one tool request may wait for the server.",
|
|
462
|
+
idleShutdownMs: "Idle shutdown (ms)",
|
|
463
|
+
idleShutdownMsHint: "How long an unused project runtime is kept before it stops.",
|
|
464
|
+
maxWorkspaceRuntimes: "Runtime limit",
|
|
465
|
+
maxWorkspaceRuntimesHint: "How many project runtimes may live at once, from 1 to 8.",
|
|
466
|
+
maxResultChars: "Result preview limit",
|
|
467
|
+
maxResultCharsHint: "Characters of each tool result shown to the model; stored values stay complete, from 1000 to 200000.",
|
|
468
|
+
writeLocalisation: "Allow write_localisation",
|
|
469
|
+
writeLocalisationHint: "When off, localisation writes are refused.",
|
|
470
|
+
writePolicyNote: "This page never grants a write on its own: every write still passes the DSH tool policy of the active session.",
|
|
471
|
+
groupProject: "Project queries",
|
|
472
|
+
groupLocalisation: "Localisation",
|
|
473
|
+
groupSemantic: "Semantic queries",
|
|
474
|
+
groupNavigation: "Navigation",
|
|
475
|
+
groupDiagnostics: "Diagnostics",
|
|
476
|
+
groupShader: "Shader",
|
|
477
|
+
groupDisabledNote: "Tool choices inside a disabled group are kept.",
|
|
478
|
+
readAccessIntro: "A group gates its tools. A tool runs only when the group and the tool are both on.",
|
|
479
|
+
overridden: "Overridden",
|
|
480
|
+
reset: "Reset to default",
|
|
481
|
+
invalidNumber: "Enter a whole number in the allowed range.",
|
|
482
|
+
readOnly: "This deployment stores settings read-only.",
|
|
483
|
+
unavailable: "The CWTools plugin is not loaded, so it cannot be configured right now.",
|
|
484
|
+
save: "Save",
|
|
485
|
+
saving: "Saving…",
|
|
486
|
+
saveFailed: "The Host did not accept these values.",
|
|
487
|
+
failedTitle: "The Host kept its own values; your draft is still here.",
|
|
488
|
+
acceptedValue: "Host accepted",
|
|
489
|
+
retryHint: "Correct the draft and save again, or leave the page to discard it.",
|
|
490
|
+
conflictNotice: "Settings changed elsewhere while you were editing, so this save was refused.",
|
|
491
|
+
emptyValue: "Empty",
|
|
492
|
+
on: "On",
|
|
493
|
+
off: "Off"
|
|
494
|
+
};
|
|
495
|
+
/** Simplified Chinese copy, checked against the English keys. */
|
|
496
|
+
const zh = {
|
|
497
|
+
nav: "CWTools",
|
|
498
|
+
title: "CWTools",
|
|
499
|
+
intro: "配置 CWTools 语言服务器,以及本组合包开放哪些语义工具。本页所有控件会一起保存。",
|
|
500
|
+
sectionBackend: "后端与项目",
|
|
501
|
+
sectionReadAccess: "只读工具",
|
|
502
|
+
sectionWriteAccess: "写入权限",
|
|
503
|
+
sectionOutput: "输出",
|
|
504
|
+
enabled: "启用 CWTools 工具",
|
|
505
|
+
enabledHint: "关闭后不再提供任何 CWTools 工具,下方的设置仍然保留。",
|
|
506
|
+
serverPath: "服务器路径",
|
|
507
|
+
serverPathHint: "CWTools 语言服务器可执行文件路径。留空时自动发现后端:已安装的 CWTools 扩展或开发构建。本组合包不自带后端。",
|
|
508
|
+
gamePath: "游戏路径",
|
|
509
|
+
gamePathHint: "Paradox 游戏安装目录。",
|
|
510
|
+
rulesPath: "规则路径",
|
|
511
|
+
rulesPathHint: "CWTools 规则目录。留空使用服务器默认值。",
|
|
512
|
+
cachePath: "缓存路径",
|
|
513
|
+
cachePathHint: "服务器缓存目录。留空使用工作区默认值。",
|
|
514
|
+
activeManifestPath: "活跃桥接清单(可选)",
|
|
515
|
+
activeManifestPathHint: "指定活跃优先复用的 bridge-manifest.json。留空时自动发现当前工作区宿主。",
|
|
516
|
+
preferActiveBackend: "优先复用活跃后端",
|
|
517
|
+
preferActiveBackendHint: "复用当前工作区健康的活跃宿主,没有可复用宿主时才启动独立后端;活跃宿主不兼容时不会再启动第二个实例。",
|
|
518
|
+
game: "游戏",
|
|
519
|
+
gameHint: "Paradox 游戏标识,例如 stellaris 或 ck3。留空时从项目自动识别。",
|
|
520
|
+
forceStart: "强制启动",
|
|
521
|
+
forceStartHint: "即使项目不像受支持的游戏,也启动语言服务器。",
|
|
522
|
+
debug: "调试日志",
|
|
523
|
+
debugHint: "在日志中保留详细的服务端诊断。",
|
|
524
|
+
startupTimeoutMs: "启动超时(毫秒)",
|
|
525
|
+
startupTimeoutMsHint: "等待语言服务器就绪的最长时间。",
|
|
526
|
+
requestTimeoutMs: "请求超时(毫秒)",
|
|
527
|
+
requestTimeoutMsHint: "单次工具请求等待服务器的最长时间。",
|
|
528
|
+
idleShutdownMs: "空闲关闭(毫秒)",
|
|
529
|
+
idleShutdownMsHint: "无人使用的项目运行时保留多久后停止。",
|
|
530
|
+
maxWorkspaceRuntimes: "运行时上限",
|
|
531
|
+
maxWorkspaceRuntimesHint: "同时存活的项目运行时数量,1 到 8。",
|
|
532
|
+
maxResultChars: "结果预览上限",
|
|
533
|
+
maxResultCharsHint: "展示给模型的每份工具结果字符数;存储值始终完整,1000 到 200000。",
|
|
534
|
+
writeLocalisation: "允许 write_localisation",
|
|
535
|
+
writeLocalisationHint: "关闭时拒绝本地化写入。",
|
|
536
|
+
writePolicyNote: "本页不会单方面授予写入:每次写入仍要通过当前会话的 DSH 工具策略。",
|
|
537
|
+
groupProject: "项目查询",
|
|
538
|
+
groupLocalisation: "本地化",
|
|
539
|
+
groupSemantic: "语义查询",
|
|
540
|
+
groupNavigation: "导航",
|
|
541
|
+
groupDiagnostics: "诊断",
|
|
542
|
+
groupShader: "着色器",
|
|
543
|
+
groupDisabledNote: "组关闭时,组内工具的选择仍然保留。",
|
|
544
|
+
readAccessIntro: "组是其工具的开关。只有组和工具同时开启,工具才会运行。",
|
|
545
|
+
overridden: "已覆盖",
|
|
546
|
+
reset: "恢复默认",
|
|
547
|
+
invalidNumber: "请输入允许范围内的整数。",
|
|
548
|
+
readOnly: "本部署的设置为只读。",
|
|
549
|
+
unavailable: "CWTools 插件当前未加载,暂时无法配置。",
|
|
550
|
+
save: "保存",
|
|
551
|
+
saving: "保存中…",
|
|
552
|
+
saveFailed: "本部署没有接受这些值。",
|
|
553
|
+
failedTitle: "本部署保留了它自己的值,你的草稿仍在。",
|
|
554
|
+
acceptedValue: "本部署已接受",
|
|
555
|
+
retryHint: "修改草稿后再次保存,或离开本页放弃草稿。",
|
|
556
|
+
conflictNotice: "编辑期间设置已在别处更新,因此本次保存被拒绝。",
|
|
557
|
+
emptyValue: "空",
|
|
558
|
+
on: "开启",
|
|
559
|
+
off: "关闭"
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* The shared settings frame's copy, read from this section's dictionary.
|
|
563
|
+
* @param t - the section's locale reader.
|
|
564
|
+
* @returns the labels the shared form frame renders.
|
|
565
|
+
*/
|
|
566
|
+
function formLabels(t) {
|
|
567
|
+
return {
|
|
568
|
+
unavailable: t("unavailable"),
|
|
569
|
+
readOnly: t("readOnly"),
|
|
570
|
+
saveFailed: t("saveFailed"),
|
|
571
|
+
save: t("save"),
|
|
572
|
+
saving: t("saving")
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
// \0dsh-cwtools-css:C:\Users\A\Documents\cwtools-vscode\submodules\dsh-cwtool\src\client\CwtoolsSection.module.css.mjs
|
|
576
|
+
const css = ".cwtools-PxssPq_section{max-width:720px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:20px;display:flex}.cwtools-PxssPq_title{margin:0;font-size:18px;font-weight:600;line-height:26px}.cwtools-PxssPq_intro{color:var(--dsw-alias-label-tertiary);margin:0;font-size:13px;line-height:1.6}.cwtools-PxssPq_block{flex-direction:column;gap:12px;display:flex}.cwtools-PxssPq_blockHead{letter-spacing:.06em;text-transform:uppercase;color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;font-weight:600}.cwtools-PxssPq_row{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-settings-card-fill);align-items:flex-start;gap:16px;padding:10px 12px;display:flex}.cwtools-PxssPq_rowText{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.cwtools-PxssPq_rowLabel{overflow-wrap:anywhere;font-size:14px;line-height:22px}.cwtools-PxssPq_rowHint{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;font-size:12px;line-height:1.55}.cwtools-PxssPq_rowMark{flex-shrink:0;align-items:center;gap:6px;display:flex}.cwtools-PxssPq_reset{appearance:none;font:inherit;border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;padding:2px 4px;font-size:12px}@media (hover:hover){.cwtools-PxssPq_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}}.cwtools-PxssPq_reset:disabled{opacity:.5;cursor:default}.cwtools-PxssPq_reset:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}.cwtools-PxssPq_fields{grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;display:grid}.cwtools-PxssPq_groups{flex-direction:column;gap:12px;display:flex}.cwtools-PxssPq_group{border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);flex-direction:column;gap:4px;padding:10px 12px 12px;display:flex}.cwtools-PxssPq_groupHead{justify-content:space-between;align-items:center;gap:12px;display:flex}.cwtools-PxssPq_groupTitle{margin:0;font-size:14px;font-weight:600;line-height:22px}.cwtools-PxssPq_groupCount{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);color:var(--dsw-alias-label-tertiary);font-size:11px}.cwtools-PxssPq_tools{flex-wrap:wrap;gap:6px 16px;margin:0;padding:0;list-style:none;display:flex}.cwtools-PxssPq_tool{align-items:center;gap:8px;min-width:0;display:flex}.cwtools-PxssPq_toolName{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;font-size:12px;line-height:20px}.cwtools-PxssPq_toolOff .cwtools-PxssPq_toolName{color:var(--dsw-alias-label-tertiary)}.cwtools-PxssPq_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.6}.cwtools-PxssPq_failure{border:.5px solid var(--dsw-alias-state-error-primary);border-radius:var(--dsw-radius-lg);flex-direction:column;gap:8px;padding:10px 12px;display:flex}.cwtools-PxssPq_failureTitle{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px;font-weight:600;line-height:20px}.cwtools-PxssPq_accepted{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:4px 16px;margin:0;font-size:12px;line-height:1.6;display:flex}.cwtools-PxssPq_accepted dt{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);color:var(--dsw-alias-label-tertiary)}.cwtools-PxssPq_accepted dd{overflow-wrap:anywhere;margin:0}@media (width<=560px){.cwtools-PxssPq_fields{grid-template-columns:minmax(0,1fr)}}";
|
|
577
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify("dsh-cwtools/CwtoolsSection.module.css") + "]") === null) {
|
|
578
|
+
const tag = document.createElement("style");
|
|
579
|
+
tag.dataset.plugin = "dsh-cwtools";
|
|
580
|
+
tag.dataset.pluginCss = "dsh-cwtools/CwtoolsSection.module.css";
|
|
581
|
+
tag.textContent = css;
|
|
582
|
+
document.head.appendChild(tag);
|
|
583
|
+
}
|
|
584
|
+
var CwtoolsSection_module_css_default = {
|
|
585
|
+
"groups": "cwtools-PxssPq_groups",
|
|
586
|
+
"tool": "cwtools-PxssPq_tool",
|
|
587
|
+
"toolOff": "cwtools-PxssPq_toolOff",
|
|
588
|
+
"toolName": "cwtools-PxssPq_toolName",
|
|
589
|
+
"rowText": "cwtools-PxssPq_rowText",
|
|
590
|
+
"rowMark": "cwtools-PxssPq_rowMark",
|
|
591
|
+
"groupCount": "cwtools-PxssPq_groupCount",
|
|
592
|
+
"failureTitle": "cwtools-PxssPq_failureTitle",
|
|
593
|
+
"rowHint": "cwtools-PxssPq_rowHint",
|
|
594
|
+
"tools": "cwtools-PxssPq_tools",
|
|
595
|
+
"failure": "cwtools-PxssPq_failure",
|
|
596
|
+
"fields": "cwtools-PxssPq_fields",
|
|
597
|
+
"group": "cwtools-PxssPq_group",
|
|
598
|
+
"groupHead": "cwtools-PxssPq_groupHead",
|
|
599
|
+
"accepted": "cwtools-PxssPq_accepted",
|
|
600
|
+
"section": "cwtools-PxssPq_section",
|
|
601
|
+
"row": "cwtools-PxssPq_row",
|
|
602
|
+
"title": "cwtools-PxssPq_title",
|
|
603
|
+
"block": "cwtools-PxssPq_block",
|
|
604
|
+
"groupTitle": "cwtools-PxssPq_groupTitle",
|
|
605
|
+
"intro": "cwtools-PxssPq_intro",
|
|
606
|
+
"rowLabel": "cwtools-PxssPq_rowLabel",
|
|
607
|
+
"reset": "cwtools-PxssPq_reset",
|
|
608
|
+
"note": "cwtools-PxssPq_note",
|
|
609
|
+
"blockHead": "cwtools-PxssPq_blockHead"
|
|
610
|
+
};
|
|
611
|
+
// src/client/CwtoolsSection.tsx
|
|
612
|
+
/**
|
|
613
|
+
* The CWTools settings section.
|
|
614
|
+
*
|
|
615
|
+
* One page over the `cwtools` Host entry: the backend and project paths, the
|
|
616
|
+
* timeout and runtime bounds, the six read groups with their 37 tools, the one
|
|
617
|
+
* write this release ships, and the result preview bound.
|
|
618
|
+
*
|
|
619
|
+
* The page stages nothing itself: every control reports what the user typed to
|
|
620
|
+
* the controller, and the shared `SettingsForm` frame is the single place a
|
|
621
|
+
* draft becomes a document mutation. Leaving the page drops the drafts.
|
|
622
|
+
*/
|
|
623
|
+
/** Locale keys of every group heading. */
|
|
624
|
+
const GROUP_LABEL = {
|
|
625
|
+
project: "groupProject",
|
|
626
|
+
localisation: "groupLocalisation",
|
|
627
|
+
semantic: "groupSemantic",
|
|
628
|
+
navigation: "groupNavigation",
|
|
629
|
+
diagnostics: "groupDiagnostics",
|
|
630
|
+
shader: "groupShader"
|
|
631
|
+
};
|
|
632
|
+
/** Label and hint of every named field, keyed by dotted path. */
|
|
633
|
+
const FIELD_COPY = {
|
|
634
|
+
"enabled": {
|
|
635
|
+
label: "enabled",
|
|
636
|
+
hint: "enabledHint"
|
|
637
|
+
},
|
|
638
|
+
"backend.serverPath": {
|
|
639
|
+
label: "serverPath",
|
|
640
|
+
hint: "serverPathHint"
|
|
641
|
+
},
|
|
642
|
+
"backend.gamePath": {
|
|
643
|
+
label: "gamePath",
|
|
644
|
+
hint: "gamePathHint"
|
|
645
|
+
},
|
|
646
|
+
"backend.rulesPath": {
|
|
647
|
+
label: "rulesPath",
|
|
648
|
+
hint: "rulesPathHint"
|
|
649
|
+
},
|
|
650
|
+
"backend.cachePath": {
|
|
651
|
+
label: "cachePath",
|
|
652
|
+
hint: "cachePathHint"
|
|
653
|
+
},
|
|
654
|
+
"backend.activeManifestPath": {
|
|
655
|
+
label: "activeManifestPath",
|
|
656
|
+
hint: "activeManifestPathHint"
|
|
657
|
+
},
|
|
658
|
+
"backend.game": {
|
|
659
|
+
label: "game",
|
|
660
|
+
hint: "gameHint"
|
|
661
|
+
},
|
|
662
|
+
"backend.preferActiveBackend": {
|
|
663
|
+
label: "preferActiveBackend",
|
|
664
|
+
hint: "preferActiveBackendHint"
|
|
665
|
+
},
|
|
666
|
+
"backend.forceStart": {
|
|
667
|
+
label: "forceStart",
|
|
668
|
+
hint: "forceStartHint"
|
|
669
|
+
},
|
|
670
|
+
"backend.debug": {
|
|
671
|
+
label: "debug",
|
|
672
|
+
hint: "debugHint"
|
|
673
|
+
},
|
|
674
|
+
"backend.startupTimeoutMs": {
|
|
675
|
+
label: "startupTimeoutMs",
|
|
676
|
+
hint: "startupTimeoutMsHint"
|
|
677
|
+
},
|
|
678
|
+
"backend.requestTimeoutMs": {
|
|
679
|
+
label: "requestTimeoutMs",
|
|
680
|
+
hint: "requestTimeoutMsHint"
|
|
681
|
+
},
|
|
682
|
+
"backend.idleShutdownMs": {
|
|
683
|
+
label: "idleShutdownMs",
|
|
684
|
+
hint: "idleShutdownMsHint"
|
|
685
|
+
},
|
|
686
|
+
"backend.maxWorkspaceRuntimes": {
|
|
687
|
+
label: "maxWorkspaceRuntimes",
|
|
688
|
+
hint: "maxWorkspaceRuntimesHint"
|
|
689
|
+
},
|
|
690
|
+
"writeTools.write_localisation": {
|
|
691
|
+
label: "writeLocalisation",
|
|
692
|
+
hint: "writeLocalisationHint"
|
|
693
|
+
},
|
|
694
|
+
"output.maxResultChars": {
|
|
695
|
+
label: "maxResultChars",
|
|
696
|
+
hint: "maxResultCharsHint"
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
/** Text and number fields of the page, in rendering order. */
|
|
700
|
+
const TEXT_ROW_FIELDS = [
|
|
701
|
+
"backend.serverPath",
|
|
702
|
+
"backend.gamePath",
|
|
703
|
+
"backend.rulesPath",
|
|
704
|
+
"backend.cachePath",
|
|
705
|
+
"backend.activeManifestPath",
|
|
706
|
+
"backend.game"
|
|
707
|
+
];
|
|
708
|
+
/** Number fields of the backend block. */
|
|
709
|
+
const BACKEND_NUMBER_FIELDS = [
|
|
710
|
+
"backend.startupTimeoutMs",
|
|
711
|
+
"backend.requestTimeoutMs",
|
|
712
|
+
"backend.idleShutdownMs",
|
|
713
|
+
"backend.maxWorkspaceRuntimes"
|
|
714
|
+
];
|
|
715
|
+
/** Switches of the backend block. */
|
|
716
|
+
const BACKEND_SWITCH_FIELDS = [
|
|
717
|
+
"backend.preferActiveBackend",
|
|
718
|
+
"backend.forceStart",
|
|
719
|
+
"backend.debug"
|
|
720
|
+
];
|
|
721
|
+
/** One switch row: its copy, the reset a stored override offers, and the control. */
|
|
722
|
+
function SwitchRow({ id, checked, overridden, disabled, copy, t, onToggle, onReset }) {
|
|
723
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
724
|
+
className: CwtoolsSection_module_css_default.row,
|
|
725
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
726
|
+
className: CwtoolsSection_module_css_default.rowText,
|
|
727
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
728
|
+
className: CwtoolsSection_module_css_default.rowLabel,
|
|
729
|
+
id: id + "-label",
|
|
730
|
+
children: t(copy.label)
|
|
731
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
732
|
+
className: CwtoolsSection_module_css_default.rowHint,
|
|
733
|
+
children: t(copy.hint)
|
|
734
|
+
})]
|
|
735
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
736
|
+
className: CwtoolsSection_module_css_default.rowMark,
|
|
737
|
+
children: [
|
|
738
|
+
overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
739
|
+
tone: "neutral",
|
|
740
|
+
children: t("overridden")
|
|
741
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
742
|
+
type: "button",
|
|
743
|
+
className: CwtoolsSection_module_css_default.reset,
|
|
744
|
+
disabled,
|
|
745
|
+
onClick: onReset,
|
|
746
|
+
children: t("reset")
|
|
747
|
+
})] }) : null,
|
|
748
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
|
|
749
|
+
checked,
|
|
750
|
+
label: t(copy.label),
|
|
751
|
+
disabled,
|
|
752
|
+
onChange: (next) => {
|
|
753
|
+
onToggle(next);
|
|
754
|
+
}
|
|
755
|
+
}),
|
|
756
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
757
|
+
className: CwtoolsSection_module_css_default.rowHint,
|
|
758
|
+
children: checked ? t("on") : t("off")
|
|
759
|
+
})
|
|
760
|
+
]
|
|
761
|
+
})]
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
/** One read group: its switch, and every tool it owns. */
|
|
765
|
+
function GroupBlock({ group, state, disabled, t, onToggle, onReset }) {
|
|
766
|
+
const groupField = "readGroups." + group;
|
|
767
|
+
const active = state.groups[group];
|
|
768
|
+
const tools = CWTOOLS_READ_TOOL_GROUPS[group];
|
|
769
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
770
|
+
className: CwtoolsSection_module_css_default.group,
|
|
771
|
+
"aria-label": t(GROUP_LABEL[group]),
|
|
772
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
773
|
+
className: CwtoolsSection_module_css_default.groupHead,
|
|
774
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
|
|
775
|
+
className: CwtoolsSection_module_css_default.groupTitle,
|
|
776
|
+
children: t(GROUP_LABEL[group])
|
|
777
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
778
|
+
className: CwtoolsSection_module_css_default.rowMark,
|
|
779
|
+
children: [
|
|
780
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
781
|
+
className: CwtoolsSection_module_css_default.groupCount,
|
|
782
|
+
children: tools.length
|
|
783
|
+
}),
|
|
784
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
|
|
785
|
+
checked: active,
|
|
786
|
+
label: t(GROUP_LABEL[group]),
|
|
787
|
+
disabled,
|
|
788
|
+
onChange: (next) => {
|
|
789
|
+
onToggle(groupField, next);
|
|
790
|
+
}
|
|
791
|
+
}),
|
|
792
|
+
state.fields[groupField]?.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
793
|
+
type: "button",
|
|
794
|
+
className: CwtoolsSection_module_css_default.reset,
|
|
795
|
+
disabled,
|
|
796
|
+
onClick: () => {
|
|
797
|
+
onReset(groupField);
|
|
798
|
+
},
|
|
799
|
+
children: t("reset")
|
|
800
|
+
}) : null
|
|
801
|
+
]
|
|
802
|
+
})]
|
|
803
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
804
|
+
className: CwtoolsSection_module_css_default.tools,
|
|
805
|
+
children: tools.map((tool) => {
|
|
806
|
+
const toolField = "readTools." + tool;
|
|
807
|
+
const granted = state.fields[toolField]?.text === "true";
|
|
808
|
+
const toolDisabled = disabled || !active;
|
|
809
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
810
|
+
className: state.tools[tool] ? CwtoolsSection_module_css_default.tool : CwtoolsSection_module_css_default.tool + " " + CwtoolsSection_module_css_default.toolOff,
|
|
811
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
|
|
812
|
+
checked: granted,
|
|
813
|
+
label: tool,
|
|
814
|
+
disabled: toolDisabled,
|
|
815
|
+
title: toolDisabled ? t("groupDisabledNote") : tool,
|
|
816
|
+
onChange: (next) => {
|
|
817
|
+
onToggle(toolField, next);
|
|
818
|
+
}
|
|
819
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
820
|
+
className: CwtoolsSection_module_css_default.toolName,
|
|
821
|
+
children: tool
|
|
822
|
+
})]
|
|
823
|
+
}, tool);
|
|
824
|
+
})
|
|
825
|
+
})]
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Render the CWTools settings section.
|
|
830
|
+
* @param props - the section snapshot, its staged actions, and localized copy.
|
|
831
|
+
* @returns the page inside the shared settings form frame.
|
|
832
|
+
*/
|
|
833
|
+
function CwtoolsSection(props) {
|
|
834
|
+
const { t } = props;
|
|
835
|
+
const state = props.useCwtoolsSection((value) => value);
|
|
836
|
+
const id = (0, react.useId)();
|
|
837
|
+
const locked = !state.writable || state.saving;
|
|
838
|
+
const controlId = (field) => id + "-" + field.replaceAll(".", "-");
|
|
839
|
+
const copyOf = (field) => FIELD_COPY[field];
|
|
840
|
+
const fieldOf = (path) => state.fields[path] ?? {
|
|
841
|
+
text: "",
|
|
842
|
+
overridden: false,
|
|
843
|
+
invalid: false
|
|
844
|
+
};
|
|
845
|
+
const switchRow = (path, disabled) => {
|
|
846
|
+
const copy = copyOf(path);
|
|
847
|
+
/* v8 ignore next 2 -- every rendered switch is declared in FIELD_COPY. */
|
|
848
|
+
if (copy === void 0) return null;
|
|
849
|
+
const current = fieldOf(path);
|
|
850
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
851
|
+
id: controlId(path),
|
|
852
|
+
checked: current.text === "true",
|
|
853
|
+
overridden: current.overridden,
|
|
854
|
+
disabled,
|
|
855
|
+
copy,
|
|
856
|
+
t,
|
|
857
|
+
onToggle: (next) => {
|
|
858
|
+
props.toggle(path, next);
|
|
859
|
+
},
|
|
860
|
+
onReset: () => {
|
|
861
|
+
props.resetField(path);
|
|
862
|
+
}
|
|
863
|
+
}, path);
|
|
864
|
+
};
|
|
865
|
+
const valueRow = (path, numeric) => {
|
|
866
|
+
const copy = copyOf(path);
|
|
867
|
+
/* v8 ignore next 2 -- every rendered value field is declared in FIELD_COPY. */
|
|
868
|
+
if (copy === void 0) return null;
|
|
869
|
+
const current = fieldOf(path);
|
|
870
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.SettingsValueField, {
|
|
871
|
+
id: controlId(path),
|
|
872
|
+
label: t(copy.label),
|
|
873
|
+
hint: t(copy.hint),
|
|
874
|
+
numeric,
|
|
875
|
+
disabled: locked,
|
|
876
|
+
...current,
|
|
877
|
+
overriddenLabel: t("overridden"),
|
|
878
|
+
resetLabel: t("reset"),
|
|
879
|
+
invalidLabel: t("invalidNumber"),
|
|
880
|
+
onEdit: (text) => {
|
|
881
|
+
props.edit(path, text);
|
|
882
|
+
},
|
|
883
|
+
onReset: () => {
|
|
884
|
+
props.resetField(path);
|
|
885
|
+
}
|
|
886
|
+
}, path);
|
|
887
|
+
};
|
|
888
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
889
|
+
className: CwtoolsSection_module_css_default.section,
|
|
890
|
+
children: [
|
|
891
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
892
|
+
className: CwtoolsSection_module_css_default.title,
|
|
893
|
+
children: t("title")
|
|
894
|
+
}),
|
|
895
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
896
|
+
className: CwtoolsSection_module_css_default.intro,
|
|
897
|
+
children: t("intro")
|
|
898
|
+
}),
|
|
899
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.SettingsForm, {
|
|
900
|
+
labels: formLabels(t),
|
|
901
|
+
state,
|
|
902
|
+
onSave: props.save,
|
|
903
|
+
onDiscard: props.discard,
|
|
904
|
+
children: [
|
|
905
|
+
state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
906
|
+
className: CwtoolsSection_module_css_default.failure,
|
|
907
|
+
role: "alert",
|
|
908
|
+
children: [
|
|
909
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
910
|
+
className: CwtoolsSection_module_css_default.failureTitle,
|
|
911
|
+
children: t("failedTitle")
|
|
912
|
+
}),
|
|
913
|
+
state.conflict ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
914
|
+
className: CwtoolsSection_module_css_default.note,
|
|
915
|
+
children: t("conflictNotice")
|
|
916
|
+
}) : null,
|
|
917
|
+
state.accepted.length === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dl", {
|
|
918
|
+
className: CwtoolsSection_module_css_default.accepted,
|
|
919
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("acceptedValue") }), state.accepted.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dd", { children: [
|
|
920
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: entry.field }),
|
|
921
|
+
" ",
|
|
922
|
+
entry.text === "" ? t("emptyValue") : entry.text
|
|
923
|
+
] }, entry.field))]
|
|
924
|
+
}),
|
|
925
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
926
|
+
className: CwtoolsSection_module_css_default.note,
|
|
927
|
+
children: t("retryHint")
|
|
928
|
+
})
|
|
929
|
+
]
|
|
930
|
+
}) : null,
|
|
931
|
+
switchRow("enabled", locked),
|
|
932
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
933
|
+
className: CwtoolsSection_module_css_default.block,
|
|
934
|
+
children: [
|
|
935
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
936
|
+
className: CwtoolsSection_module_css_default.blockHead,
|
|
937
|
+
children: t("sectionBackend")
|
|
938
|
+
}),
|
|
939
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
940
|
+
className: CwtoolsSection_module_css_default.fields,
|
|
941
|
+
children: TEXT_ROW_FIELDS.map((path) => valueRow(path, false))
|
|
942
|
+
}),
|
|
943
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
944
|
+
className: CwtoolsSection_module_css_default.fields,
|
|
945
|
+
children: BACKEND_NUMBER_FIELDS.map((path) => valueRow(path, true))
|
|
946
|
+
}),
|
|
947
|
+
BACKEND_SWITCH_FIELDS.map((path) => switchRow(path, locked))
|
|
948
|
+
]
|
|
949
|
+
}),
|
|
950
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
951
|
+
className: CwtoolsSection_module_css_default.block,
|
|
952
|
+
children: [
|
|
953
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
954
|
+
className: CwtoolsSection_module_css_default.blockHead,
|
|
955
|
+
children: t("sectionReadAccess")
|
|
956
|
+
}),
|
|
957
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
958
|
+
className: CwtoolsSection_module_css_default.note,
|
|
959
|
+
children: t("readAccessIntro")
|
|
960
|
+
}),
|
|
961
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
962
|
+
className: CwtoolsSection_module_css_default.groups,
|
|
963
|
+
children: CWTOOLS_READ_GROUP_ORDER.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupBlock, {
|
|
964
|
+
group,
|
|
965
|
+
state,
|
|
966
|
+
disabled: locked,
|
|
967
|
+
t,
|
|
968
|
+
onToggle: props.toggle,
|
|
969
|
+
onReset: props.resetField
|
|
970
|
+
}, group))
|
|
971
|
+
}),
|
|
972
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
973
|
+
className: CwtoolsSection_module_css_default.note,
|
|
974
|
+
children: t("groupDisabledNote")
|
|
975
|
+
})
|
|
976
|
+
]
|
|
977
|
+
}),
|
|
978
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
979
|
+
className: CwtoolsSection_module_css_default.block,
|
|
980
|
+
children: [
|
|
981
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
982
|
+
className: CwtoolsSection_module_css_default.blockHead,
|
|
983
|
+
children: t("sectionWriteAccess")
|
|
984
|
+
}),
|
|
985
|
+
switchRow("writeTools.write_localisation", locked),
|
|
986
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
987
|
+
className: CwtoolsSection_module_css_default.note,
|
|
988
|
+
children: t("writePolicyNote")
|
|
989
|
+
})
|
|
990
|
+
]
|
|
991
|
+
}),
|
|
992
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
993
|
+
className: CwtoolsSection_module_css_default.block,
|
|
994
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
995
|
+
className: CwtoolsSection_module_css_default.blockHead,
|
|
996
|
+
children: t("sectionOutput")
|
|
997
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
998
|
+
className: CwtoolsSection_module_css_default.fields,
|
|
999
|
+
children: valueRow("output.maxResultChars", true)
|
|
1000
|
+
})]
|
|
1001
|
+
})
|
|
1002
|
+
]
|
|
1003
|
+
})
|
|
1004
|
+
]
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
// src/client/CwtoolsSectionIcon.tsx
|
|
1008
|
+
/**
|
|
1009
|
+
* Render the CWTools navigation icon.
|
|
1010
|
+
* @param props - requested edge in pixels and whether this section is selected.
|
|
1011
|
+
* @returns a decorative SVG in the current text color.
|
|
1012
|
+
*/
|
|
1013
|
+
function CwtoolsSectionIcon({ size, active }) {
|
|
1014
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1015
|
+
width: size,
|
|
1016
|
+
height: size,
|
|
1017
|
+
viewBox: "0 0 16 16",
|
|
1018
|
+
fill: "none",
|
|
1019
|
+
"aria-hidden": "true",
|
|
1020
|
+
"data-cwtools-icon": active ? "active" : "idle",
|
|
1021
|
+
children: [
|
|
1022
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1023
|
+
d: "M11.6 4.2A5.4 5.4 0 1 0 11.6 11.8",
|
|
1024
|
+
stroke: "currentColor",
|
|
1025
|
+
strokeWidth: "1.6",
|
|
1026
|
+
strokeLinecap: "round"
|
|
1027
|
+
}),
|
|
1028
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1029
|
+
d: "M6.1 6.6 4.7 8l1.4 1.4M9.9 6.6 11.3 8l-1.4 1.4",
|
|
1030
|
+
stroke: "currentColor",
|
|
1031
|
+
strokeWidth: "1.2",
|
|
1032
|
+
strokeLinecap: "round",
|
|
1033
|
+
strokeLinejoin: "round",
|
|
1034
|
+
opacity: "0.75"
|
|
1035
|
+
}),
|
|
1036
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
1037
|
+
cx: "8",
|
|
1038
|
+
cy: "8",
|
|
1039
|
+
r: "0.95",
|
|
1040
|
+
fill: "currentColor"
|
|
1041
|
+
})
|
|
1042
|
+
]
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
// src/client/index.ts
|
|
1046
|
+
/** Dictionary namespace owned by this plugin. */
|
|
1047
|
+
const NS = "settings.cwtools";
|
|
1048
|
+
/** Slot id shared by the section and its navigation icon. */
|
|
1049
|
+
const SECTION_ID = "cwtools";
|
|
1050
|
+
/** Required services (cordis fiber inject). */
|
|
1051
|
+
const inject = [
|
|
1052
|
+
"slots",
|
|
1053
|
+
"locale",
|
|
1054
|
+
"configForms"
|
|
1055
|
+
];
|
|
1056
|
+
/**
|
|
1057
|
+
* Mount the settings section while the Host serves the `cwtools` entry.
|
|
1058
|
+
* @param ctx - the browser plugin context.
|
|
1059
|
+
*/
|
|
1060
|
+
function apply(ctx) {
|
|
1061
|
+
const t = ctx.locale.bind(NS);
|
|
1062
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
1063
|
+
en,
|
|
1064
|
+
zh
|
|
1065
|
+
}), "dsh-cwtools: settings dictionaries");
|
|
1066
|
+
const controller = new CwtoolsSettingsController(ctx.configForms.get(CWTOOLS_SETTINGS_NAMESPACE));
|
|
1067
|
+
ctx.effect(() => () => {
|
|
1068
|
+
controller.dispose();
|
|
1069
|
+
}, "dsh-cwtools: settings form subscription");
|
|
1070
|
+
const face = () => controller.inject();
|
|
1071
|
+
ctx.effect(() => ctx.configForms.whileServed([CWTOOLS_SETTINGS_NAMESPACE], () => {
|
|
1072
|
+
const section = ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
1073
|
+
name: "settings.section",
|
|
1074
|
+
id: SECTION_ID,
|
|
1075
|
+
order: 40,
|
|
1076
|
+
label: () => t("nav"),
|
|
1077
|
+
locale: NS,
|
|
1078
|
+
inject: face
|
|
1079
|
+
}, CwtoolsSection));
|
|
1080
|
+
const icon = ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
|
|
1081
|
+
name: "settings.section.icon",
|
|
1082
|
+
id: SECTION_ID,
|
|
1083
|
+
locale: NS
|
|
1084
|
+
}, CwtoolsSectionIcon));
|
|
1085
|
+
return () => {
|
|
1086
|
+
section();
|
|
1087
|
+
icon();
|
|
1088
|
+
};
|
|
1089
|
+
}), "dsh-cwtools: settings section");
|
|
1090
|
+
}
|
|
1091
|
+
exports.apply = apply;
|
|
1092
|
+
exports.inject = inject;
|
|
1093
|
+
return module.exports;
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
//# sourceMappingURL=client.js.map
|