dsh-coding 0.0.1 → 0.1.1-rc1
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 +65 -58
- package/cordis.patch.yml +231 -4
- package/docs/DETAIL.md +183 -0
- package/docs/DEVELOPMENT.md +189 -0
- package/icon.svg +4 -4
- package/lib/apply-patch.js +268 -0
- package/lib/client/capsule.js +120 -0
- package/lib/client/card.js +220 -0
- package/lib/client/command-row.js +76 -0
- package/lib/client/config-page.js +392 -0
- package/lib/client/definition.js +164 -0
- package/lib/client/index.js +129 -0
- package/lib/client/locales.js +156 -0
- package/lib/client/mode-picker.js +77 -0
- package/lib/client/styles.js +283 -0
- package/lib/client.js +1691 -0
- package/lib/coding-projection.js +349 -0
- package/lib/config.js +204 -0
- package/lib/contract.js +124 -0
- package/lib/editor.js +23 -0
- package/lib/failures.js +142 -0
- package/lib/handoff.js +312 -0
- package/lib/index.js +109 -7
- package/lib/language.js +136 -0
- package/lib/messages.js +43 -0
- package/lib/models.js +154 -0
- package/lib/patch.js +235 -0
- package/lib/preset.js +1488 -0
- package/lib/reasoning-levels.js +28 -0
- package/lib/reasoning-projection.js +178 -0
- package/lib/reasoning.js +585 -0
- package/lib/stages.js +306 -0
- package/lib/state.js +550 -0
- package/lib/system-language.js +56 -0
- package/lib/types/apply-patch.d.ts +13 -0
- package/lib/types/client/capsule.d.ts +9 -0
- package/lib/types/client/card.d.ts +72 -0
- package/lib/types/client/command-row.d.ts +42 -0
- package/lib/types/client/config-page.d.ts +136 -0
- package/lib/types/client/definition.d.ts +51 -0
- package/lib/types/client/index.d.ts +10 -0
- package/lib/types/client/locales.d.ts +18 -0
- package/lib/types/client/mode-picker.d.ts +25 -0
- package/lib/types/client/styles.d.ts +28 -0
- package/lib/types/coding-projection.d.ts +116 -0
- package/lib/types/config.d.ts +193 -0
- package/lib/types/contract.d.ts +33 -0
- package/lib/types/editor.d.ts +9 -0
- package/lib/types/failures.d.ts +62 -0
- package/lib/types/handoff.d.ts +112 -0
- package/lib/types/index.d.ts +144 -0
- package/lib/types/language.d.ts +56 -0
- package/lib/types/messages.d.ts +27 -0
- package/lib/types/models.d.ts +82 -0
- package/lib/types/patch.d.ts +37 -0
- package/lib/types/preset.d.ts +22 -0
- package/lib/types/reasoning-levels.d.ts +20 -0
- package/lib/types/reasoning-projection.d.ts +64 -0
- package/lib/types/reasoning.d.ts +141 -0
- package/lib/types/stages.d.ts +164 -0
- package/lib/types/state.d.ts +261 -0
- package/lib/types/system-language.d.ts +10 -0
- package/lib/types/verification-tool.d.ts +32 -0
- package/lib/types/verification.d.ts +77 -0
- package/lib/types/verifier.d.ts +9 -0
- package/lib/types/volatile.d.ts +17 -0
- package/lib/verification-tool.js +176 -0
- package/lib/verification.js +337 -0
- package/lib/verifier.js +25 -0
- package/lib/volatile.js +20 -0
- package/locale/en.json +3 -2
- package/locale/zh.json +3 -2
- package/package.json +83 -9
- package/lib/index.d.ts +0 -11
package/lib/client.js
ADDED
|
@@ -0,0 +1,1691 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-coding",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
"use strict";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/client/index.ts
|
|
26
|
+
var index_exports = {};
|
|
27
|
+
__export(index_exports, {
|
|
28
|
+
NS: () => NS,
|
|
29
|
+
apply: () => apply,
|
|
30
|
+
inject: () => inject
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
var import_react6 = require("react");
|
|
34
|
+
|
|
35
|
+
// src/failures.ts
|
|
36
|
+
var FAILURE_TEXT_LIMIT = 600;
|
|
37
|
+
var FAILURE_POINTS = [
|
|
38
|
+
"projection",
|
|
39
|
+
"restore",
|
|
40
|
+
"tool-table",
|
|
41
|
+
"reasoning",
|
|
42
|
+
"delegate",
|
|
43
|
+
"verification",
|
|
44
|
+
"handoff",
|
|
45
|
+
"command"
|
|
46
|
+
];
|
|
47
|
+
function asFailure(value) {
|
|
48
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
49
|
+
const raw = value;
|
|
50
|
+
const point = raw["point"];
|
|
51
|
+
if (typeof point !== "string" || !FAILURE_POINTS.includes(point)) return void 0;
|
|
52
|
+
const reason = raw["reason"];
|
|
53
|
+
const action = raw["action"];
|
|
54
|
+
const at = raw["at"];
|
|
55
|
+
if (typeof reason !== "string" || typeof action !== "string") return void 0;
|
|
56
|
+
if (typeof at !== "number" || !Number.isFinite(at)) return void 0;
|
|
57
|
+
return {
|
|
58
|
+
point,
|
|
59
|
+
reason: reason.trim().slice(0, FAILURE_TEXT_LIMIT),
|
|
60
|
+
action: action.trim().slice(0, FAILURE_TEXT_LIMIT),
|
|
61
|
+
at
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/handoff.ts
|
|
66
|
+
var HANDOFF_VERSION = 1;
|
|
67
|
+
var HANDOFF_TEXT_LIMIT = 600;
|
|
68
|
+
var HANDOFF_ITEMS_LIMIT = 10;
|
|
69
|
+
var HANDOFF_TASKS_LIMIT = 8;
|
|
70
|
+
var HANDOFF_CHANGES_LIMIT = 20;
|
|
71
|
+
function asHandoff(value) {
|
|
72
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
73
|
+
const raw = value;
|
|
74
|
+
if (raw["version"] !== HANDOFF_VERSION) return void 0;
|
|
75
|
+
const goal = boundedText(raw["goal"], HANDOFF_TEXT_LIMIT);
|
|
76
|
+
const updatedAt = raw["updatedAt"];
|
|
77
|
+
return {
|
|
78
|
+
version: HANDOFF_VERSION,
|
|
79
|
+
...goal === "" ? {} : { goal },
|
|
80
|
+
constraints: mergeItems([], listOf(raw["constraints"])),
|
|
81
|
+
acceptance: mergeItems([], listOf(raw["acceptance"])),
|
|
82
|
+
findings: mergeItems([], listOf(raw["findings"])),
|
|
83
|
+
decisions: mergeItems([], listOf(raw["decisions"])),
|
|
84
|
+
open: mergeItems([], listOf(raw["open"])),
|
|
85
|
+
tasks: boundedTasks(listOf(raw["tasks"])),
|
|
86
|
+
changes: mergeChanges([], listOf(raw["changes"])),
|
|
87
|
+
updatedAt: typeof updatedAt === "number" && Number.isFinite(updatedAt) ? updatedAt : Date.now()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function listOf(value) {
|
|
91
|
+
return Array.isArray(value) ? value : [];
|
|
92
|
+
}
|
|
93
|
+
function boundedText(value, limit) {
|
|
94
|
+
return typeof value === "string" ? value.trim().slice(0, limit) : "";
|
|
95
|
+
}
|
|
96
|
+
function mergeItems(base, added) {
|
|
97
|
+
const seen = /* @__PURE__ */ new Set();
|
|
98
|
+
for (const raw of [...base, ...added]) {
|
|
99
|
+
const value = boundedText(raw, HANDOFF_TEXT_LIMIT);
|
|
100
|
+
if (value !== "") seen.add(value);
|
|
101
|
+
}
|
|
102
|
+
const items = [...seen];
|
|
103
|
+
return items.slice(Math.max(0, items.length - HANDOFF_ITEMS_LIMIT));
|
|
104
|
+
}
|
|
105
|
+
function cleanTask(value) {
|
|
106
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
107
|
+
const raw = value;
|
|
108
|
+
const goal = boundedText(raw["goal"], HANDOFF_TEXT_LIMIT);
|
|
109
|
+
if (goal === "") return void 0;
|
|
110
|
+
const avoid = boundedText(raw["avoid"], HANDOFF_TEXT_LIMIT);
|
|
111
|
+
return {
|
|
112
|
+
goal,
|
|
113
|
+
files: mergeItems([], listOf(raw["files"])),
|
|
114
|
+
acceptance: boundedText(raw["acceptance"], HANDOFF_TEXT_LIMIT),
|
|
115
|
+
...avoid === "" ? {} : { avoid }
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function boundedTasks(values) {
|
|
119
|
+
const byGoal = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const value of values) {
|
|
121
|
+
const task = cleanTask(value);
|
|
122
|
+
if (task !== void 0 && !byGoal.has(task.goal)) byGoal.set(task.goal, task);
|
|
123
|
+
}
|
|
124
|
+
const tasks = [...byGoal.values()];
|
|
125
|
+
return tasks.slice(Math.max(0, tasks.length - HANDOFF_TASKS_LIMIT));
|
|
126
|
+
}
|
|
127
|
+
function cleanChange(value) {
|
|
128
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
129
|
+
const raw = value;
|
|
130
|
+
const file = boundedText(raw["file"], HANDOFF_TEXT_LIMIT);
|
|
131
|
+
if (file === "") return void 0;
|
|
132
|
+
return { file, summary: boundedText(raw["summary"], HANDOFF_TEXT_LIMIT) };
|
|
133
|
+
}
|
|
134
|
+
function mergeChanges(base, added) {
|
|
135
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
136
|
+
for (const raw of [...base, ...added]) {
|
|
137
|
+
const change = cleanChange(raw);
|
|
138
|
+
if (change !== void 0) byFile.set(change.file, change);
|
|
139
|
+
}
|
|
140
|
+
const changes = [...byFile.values()];
|
|
141
|
+
return changes.slice(Math.max(0, changes.length - HANDOFF_CHANGES_LIMIT));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/stages.ts
|
|
145
|
+
var CODING_STAGES = ["requirements", "plan", "implement", "verify", "deliver"];
|
|
146
|
+
var CODING_MODES = ["auto", "consult", "review", "codex"];
|
|
147
|
+
var STAGES_BY_MODE = {
|
|
148
|
+
// Auto opens only requirements because the requirements stage chooses a concrete workflow
|
|
149
|
+
// with `coding_mode`; the chosen mode then supplies its own stage set.
|
|
150
|
+
auto: ["requirements"],
|
|
151
|
+
consult: ["requirements", "plan", "deliver"],
|
|
152
|
+
review: ["requirements", "verify", "deliver"],
|
|
153
|
+
codex: ["requirements", "plan", "implement", "verify", "deliver"]
|
|
154
|
+
};
|
|
155
|
+
var TOOL = {
|
|
156
|
+
stage: "coding_stage",
|
|
157
|
+
mode: "coding_mode",
|
|
158
|
+
reasoning: "coding_reasoning",
|
|
159
|
+
handoff: "coding_handoff",
|
|
160
|
+
implement: "delegate_implement",
|
|
161
|
+
verify: "delegate_verify",
|
|
162
|
+
plan: "delegate_plan",
|
|
163
|
+
verification: "run_verification"
|
|
164
|
+
};
|
|
165
|
+
var CODING_TOOLS = Object.values(TOOL);
|
|
166
|
+
function isCodingTool(name) {
|
|
167
|
+
return CODING_TOOLS.includes(name);
|
|
168
|
+
}
|
|
169
|
+
var IMPLEMENT_TABLE = [
|
|
170
|
+
TOOL.implement,
|
|
171
|
+
TOOL.handoff,
|
|
172
|
+
"todo_write",
|
|
173
|
+
TOOL.stage,
|
|
174
|
+
TOOL.mode,
|
|
175
|
+
TOOL.reasoning
|
|
176
|
+
];
|
|
177
|
+
var CHECKPOINT_VERSION = 1;
|
|
178
|
+
function asCheckpoint(value) {
|
|
179
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
180
|
+
const v = value;
|
|
181
|
+
if (v["v"] !== CHECKPOINT_VERSION) return void 0;
|
|
182
|
+
if (typeof v["runId"] !== "string" || v["runId"] === "") return void 0;
|
|
183
|
+
if (!isFiniteNumber(v["turn"]) || !isFiniteNumber(v["step"])) return void 0;
|
|
184
|
+
if (!isMode(v["mode"])) return void 0;
|
|
185
|
+
const stage = asStage(v["stage"]);
|
|
186
|
+
if (stage === void 0) return void 0;
|
|
187
|
+
const allowedStages = Array.isArray(v["allowedStages"]) ? v["allowedStages"].map(asStage) : void 0;
|
|
188
|
+
if (allowedStages === void 0 || allowedStages.some((item) => item === void 0)) return void 0;
|
|
189
|
+
if (!isFiniteNumber(v["planItems"]) || !isFiniteNumber(v["openPlanItems"])) return void 0;
|
|
190
|
+
if (!isFiniteNumber(v["edits"]) || !isFiniteNumber(v["updatedAt"])) return void 0;
|
|
191
|
+
const files = v["files"];
|
|
192
|
+
if (files !== void 0 && (!Array.isArray(files) || !files.every((item) => typeof item === "string" && item !== ""))) return void 0;
|
|
193
|
+
const verification = asVerification(v["verification"]);
|
|
194
|
+
const worker = asWorker(v["worker"]);
|
|
195
|
+
const refusal = asRefusal(v["refusal"]);
|
|
196
|
+
const handoff = asHandoff(v["handoff"]);
|
|
197
|
+
const failure = asFailure(v["failure"]);
|
|
198
|
+
const attemptsValue = v["verifyAttempts"];
|
|
199
|
+
const verifyAttempts = isFiniteNumber(attemptsValue) && attemptsValue >= 0 ? attemptsValue : void 0;
|
|
200
|
+
if (attemptsValue !== void 0 && verifyAttempts === void 0) return void 0;
|
|
201
|
+
const blockedValue = v["verifyBlocked"];
|
|
202
|
+
const verifyBlocked = asVerifyBlocked(blockedValue);
|
|
203
|
+
if (blockedValue !== void 0 && verifyBlocked === void 0) return void 0;
|
|
204
|
+
return {
|
|
205
|
+
v: CHECKPOINT_VERSION,
|
|
206
|
+
runId: v["runId"],
|
|
207
|
+
turn: v["turn"],
|
|
208
|
+
step: v["step"],
|
|
209
|
+
mode: v["mode"],
|
|
210
|
+
stage,
|
|
211
|
+
allowedStages,
|
|
212
|
+
planItems: v["planItems"],
|
|
213
|
+
openPlanItems: v["openPlanItems"],
|
|
214
|
+
edits: v["edits"],
|
|
215
|
+
...files === void 0 ? {} : { files },
|
|
216
|
+
...verification === void 0 ? {} : { verification },
|
|
217
|
+
...handoff === void 0 ? {} : { handoff },
|
|
218
|
+
...verifyAttempts === void 0 ? {} : { verifyAttempts },
|
|
219
|
+
...verifyBlocked === void 0 ? {} : { verifyBlocked },
|
|
220
|
+
...worker === void 0 ? {} : { worker },
|
|
221
|
+
...refusal === void 0 ? {} : { refusal },
|
|
222
|
+
...failure === void 0 ? {} : { failure },
|
|
223
|
+
updatedAt: v["updatedAt"]
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
var LEGACY_STAGES = { recon: "requirements" };
|
|
227
|
+
function asStage(value) {
|
|
228
|
+
if (typeof value !== "string") return void 0;
|
|
229
|
+
if (CODING_STAGES.includes(value)) return value;
|
|
230
|
+
return LEGACY_STAGES[value];
|
|
231
|
+
}
|
|
232
|
+
function isFiniteNumber(value) {
|
|
233
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
234
|
+
}
|
|
235
|
+
function isMode(value) {
|
|
236
|
+
return typeof value === "string" && CODING_MODES.includes(value);
|
|
237
|
+
}
|
|
238
|
+
function asVerification(value) {
|
|
239
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
240
|
+
const v = value;
|
|
241
|
+
if (typeof v["passed"] !== "boolean") return void 0;
|
|
242
|
+
if (typeof v["kind"] !== "string" || typeof v["scope"] !== "string") return void 0;
|
|
243
|
+
if (v["source"] !== "lead" && v["source"] !== "worker") return void 0;
|
|
244
|
+
if (typeof v["command"] !== "string" || typeof v["durationMs"] !== "number") return void 0;
|
|
245
|
+
if (!isFiniteNumber(v["ranAt"])) return void 0;
|
|
246
|
+
const exitCode = v["exitCode"];
|
|
247
|
+
if (exitCode !== null && typeof exitCode !== "number") return void 0;
|
|
248
|
+
return {
|
|
249
|
+
passed: v["passed"],
|
|
250
|
+
kind: v["kind"],
|
|
251
|
+
scope: v["scope"],
|
|
252
|
+
source: v["source"],
|
|
253
|
+
command: v["command"],
|
|
254
|
+
exitCode,
|
|
255
|
+
durationMs: v["durationMs"],
|
|
256
|
+
failedTests: stringArray(v["failedTests"]),
|
|
257
|
+
errors: stringArray(v["errors"]),
|
|
258
|
+
ranAt: v["ranAt"]
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function asWorker(value) {
|
|
262
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
263
|
+
const v = value;
|
|
264
|
+
if (v["role"] !== "plan" && v["role"] !== "implement" && v["role"] !== "verify") return void 0;
|
|
265
|
+
if (v["status"] !== "running" && v["status"] !== "completed" && v["status"] !== "failed") return void 0;
|
|
266
|
+
if (!isFiniteNumber(v["startedAt"])) return void 0;
|
|
267
|
+
return {
|
|
268
|
+
role: v["role"],
|
|
269
|
+
status: v["status"],
|
|
270
|
+
...typeof v["childId"] === "string" ? { childId: v["childId"] } : {},
|
|
271
|
+
...typeof v["summary"] === "string" ? { summary: v["summary"] } : {},
|
|
272
|
+
...Array.isArray(v["files"]) ? { files: stringArray(v["files"]) } : {},
|
|
273
|
+
startedAt: v["startedAt"],
|
|
274
|
+
...isFiniteNumber(v["finishedAt"]) ? { finishedAt: v["finishedAt"] } : {}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function asRefusal(value) {
|
|
278
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
279
|
+
const v = value;
|
|
280
|
+
const target = asStage(v["target"]);
|
|
281
|
+
if (target === void 0 || typeof v["reason"] !== "string" || !isFiniteNumber(v["at"])) return void 0;
|
|
282
|
+
return { target, reason: v["reason"], at: v["at"] };
|
|
283
|
+
}
|
|
284
|
+
function asVerifyBlocked(value) {
|
|
285
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
286
|
+
const v = value;
|
|
287
|
+
if (!isFiniteNumber(v["attempts"]) || typeof v["reason"] !== "string" || !isFiniteNumber(v["at"])) return void 0;
|
|
288
|
+
return { attempts: v["attempts"], reason: v["reason"], at: v["at"] };
|
|
289
|
+
}
|
|
290
|
+
function stringArray(value) {
|
|
291
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/client/definition.ts
|
|
295
|
+
var CAPSULE_KIND = "coding-stage";
|
|
296
|
+
var CAPSULE_TARGET = "chat";
|
|
297
|
+
function contextId(turn) {
|
|
298
|
+
return `coding-turn-${turn}`;
|
|
299
|
+
}
|
|
300
|
+
function checkpointOf(event) {
|
|
301
|
+
if (event.type !== "tool/result") return void 0;
|
|
302
|
+
const meta = event.data.meta;
|
|
303
|
+
const checkpoint = asCheckpoint(meta);
|
|
304
|
+
if (checkpoint === void 0) return void 0;
|
|
305
|
+
const turn = event.data.turn;
|
|
306
|
+
if (typeof turn === "number" && checkpoint.turn !== turn) return void 0;
|
|
307
|
+
return checkpoint;
|
|
308
|
+
}
|
|
309
|
+
function requestedOf(event) {
|
|
310
|
+
if (event.type !== "tool/call") return void 0;
|
|
311
|
+
const data = event.data;
|
|
312
|
+
if (typeof data.name !== "string" || !isCodingTool(data.name)) return void 0;
|
|
313
|
+
if (typeof data.turn !== "number") return void 0;
|
|
314
|
+
let requested;
|
|
315
|
+
if (typeof data.arguments === "string") {
|
|
316
|
+
try {
|
|
317
|
+
const parsed = JSON.parse(data.arguments);
|
|
318
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
319
|
+
if (typeof parsed["stage"] === "string") requested = parsed["stage"];
|
|
320
|
+
else if (typeof parsed["mode"] === "string") requested = parsed["mode"];
|
|
321
|
+
else if (typeof parsed["kind"] === "string") requested = parsed["kind"];
|
|
322
|
+
}
|
|
323
|
+
} catch {
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return { tool: data.name, ...requested === void 0 ? {} : { requested }, turn: data.turn };
|
|
327
|
+
}
|
|
328
|
+
function endedTurn(event) {
|
|
329
|
+
if (event.type !== "turn/end") return void 0;
|
|
330
|
+
const turn = event.data.turn;
|
|
331
|
+
return typeof turn === "number" ? turn : void 0;
|
|
332
|
+
}
|
|
333
|
+
function fromCheckpoint(checkpoint, inherited) {
|
|
334
|
+
return {
|
|
335
|
+
runId: checkpoint.runId,
|
|
336
|
+
turn: checkpoint.turn,
|
|
337
|
+
mode: checkpoint.mode,
|
|
338
|
+
stage: checkpoint.stage,
|
|
339
|
+
checkpoint,
|
|
340
|
+
...inherited === void 0 ? {} : { inherited },
|
|
341
|
+
partial: false
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function fromCall(call, at, previous) {
|
|
345
|
+
return {
|
|
346
|
+
runId: previous?.runId ?? "",
|
|
347
|
+
turn: call.turn,
|
|
348
|
+
mode: previous?.mode ?? "auto",
|
|
349
|
+
stage: previous?.stage ?? "requirements",
|
|
350
|
+
...previous === void 0 ? {} : { inherited: previous },
|
|
351
|
+
pending: { tool: call.tool, ...call.requested === void 0 ? {} : { requested: call.requested }, at },
|
|
352
|
+
partial: true
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function fromTurnEnd(turn, previous, current) {
|
|
356
|
+
if (current !== void 0) {
|
|
357
|
+
const { pending: _pending, ...rest } = current;
|
|
358
|
+
return { ...rest, partial: current.checkpoint === void 0 && previous === void 0 };
|
|
359
|
+
}
|
|
360
|
+
if (previous !== void 0) {
|
|
361
|
+
return {
|
|
362
|
+
...fromCheckpoint(previous, previous),
|
|
363
|
+
turn,
|
|
364
|
+
partial: false
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
return { runId: "", turn, mode: "auto", stage: "requirements", partial: true };
|
|
368
|
+
}
|
|
369
|
+
var match = (event) => {
|
|
370
|
+
const checkpoint = checkpointOf(event);
|
|
371
|
+
if (checkpoint !== void 0) return { id: contextId(checkpoint.turn), role: "start" };
|
|
372
|
+
const call = requestedOf(event);
|
|
373
|
+
if (call !== void 0) return { id: contextId(call.turn), role: "start" };
|
|
374
|
+
const turn = endedTurn(event);
|
|
375
|
+
if (turn !== void 0) return { id: contextId(turn), role: "start" };
|
|
376
|
+
return null;
|
|
377
|
+
};
|
|
378
|
+
var capsuleDefinition = {
|
|
379
|
+
kind: CAPSULE_KIND,
|
|
380
|
+
target: CAPSULE_TARGET,
|
|
381
|
+
match,
|
|
382
|
+
start(context, matchResult, reader) {
|
|
383
|
+
const event = matchResult.event;
|
|
384
|
+
const checkpoint = checkpointOf(event);
|
|
385
|
+
if (checkpoint !== void 0) return fromCheckpoint(checkpoint);
|
|
386
|
+
const call = requestedOf(event);
|
|
387
|
+
if (call !== void 0) {
|
|
388
|
+
const previous2 = reader.previous(CAPSULE_KIND)?.state.checkpoint;
|
|
389
|
+
return fromCall(call, event.time, previous2);
|
|
390
|
+
}
|
|
391
|
+
const turn = endedTurn(event);
|
|
392
|
+
const previous = reader.previous(CAPSULE_KIND)?.state.checkpoint;
|
|
393
|
+
return fromTurnEnd(turn ?? 0, previous);
|
|
394
|
+
},
|
|
395
|
+
update(context, updateMatch) {
|
|
396
|
+
const event = updateMatch.event;
|
|
397
|
+
const current = context.state;
|
|
398
|
+
const checkpoint = checkpointOf(event);
|
|
399
|
+
if (checkpoint !== void 0) return fromCheckpoint(checkpoint, current.inherited);
|
|
400
|
+
const call = requestedOf(event);
|
|
401
|
+
if (call !== void 0) {
|
|
402
|
+
return { ...current, ...fromCall(call, event.time, current.checkpoint ?? current.inherited) };
|
|
403
|
+
}
|
|
404
|
+
const turn = endedTurn(event);
|
|
405
|
+
if (turn !== void 0) {
|
|
406
|
+
return fromTurnEnd(turn, current.checkpoint ?? current.inherited, current);
|
|
407
|
+
}
|
|
408
|
+
return current;
|
|
409
|
+
},
|
|
410
|
+
buildViewNode(context) {
|
|
411
|
+
const data = context.state;
|
|
412
|
+
const startMatch = context.start;
|
|
413
|
+
if (data === void 0 || startMatch === void 0) return null;
|
|
414
|
+
return {
|
|
415
|
+
key: context.key,
|
|
416
|
+
kind: CAPSULE_KIND,
|
|
417
|
+
id: context.id,
|
|
418
|
+
target: CAPSULE_TARGET,
|
|
419
|
+
anchorSeq: startMatch.event.seq,
|
|
420
|
+
location: startMatch.location,
|
|
421
|
+
visibility: "visible",
|
|
422
|
+
data
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
// src/client/capsule.ts
|
|
428
|
+
var import_react = require("react");
|
|
429
|
+
var ALL_STAGES = ["requirements", "plan", "implement", "verify", "deliver"];
|
|
430
|
+
var CodingStageCapsule = (0, import_react.memo)(function CodingStageCapsule2({ node, t }) {
|
|
431
|
+
const data = node.data;
|
|
432
|
+
const checkpoint = data.checkpoint;
|
|
433
|
+
const admitted = checkpoint?.allowedStages ?? ALL_STAGES;
|
|
434
|
+
const activeIndex = admitted.indexOf(data.stage);
|
|
435
|
+
const children = [
|
|
436
|
+
(0, import_react.createElement)("span", {
|
|
437
|
+
key: "mode",
|
|
438
|
+
className: "dsh-coding-faint",
|
|
439
|
+
"data-mode": data.mode,
|
|
440
|
+
// The card owns switching; the capsule only states the current mode.
|
|
441
|
+
title: t("hint.mode")
|
|
442
|
+
}, t(`mode.${data.mode}`)),
|
|
443
|
+
(0, import_react.createElement)("span", { key: "mode-sep", className: "dsh-coding-faint", "aria-hidden": "true" }, "\xB7")
|
|
444
|
+
];
|
|
445
|
+
for (const [index, stage] of ALL_STAGES.entries()) {
|
|
446
|
+
if (index > 0) {
|
|
447
|
+
children.push((0, import_react.createElement)("span", { key: `arrow-${stage}`, className: "dsh-coding-arrow", "aria-hidden": "true" }, "\u2192"));
|
|
448
|
+
}
|
|
449
|
+
const stageIndex = admitted.indexOf(stage);
|
|
450
|
+
const isActive = stage === data.stage;
|
|
451
|
+
children.push((0, import_react.createElement)("span", {
|
|
452
|
+
key: stage,
|
|
453
|
+
className: "dsh-coding-stage",
|
|
454
|
+
"data-stage": stage,
|
|
455
|
+
...isActive ? { "data-active": "true", "data-current": "true" } : {},
|
|
456
|
+
...stageIndex >= 0 && activeIndex >= 0 && stageIndex < activeIndex ? { "data-done": "true" } : {}
|
|
457
|
+
}, t(`stage.${stage}`)));
|
|
458
|
+
}
|
|
459
|
+
const verification = checkpoint?.verification;
|
|
460
|
+
children.push((0, import_react.createElement)("span", { key: "verify-sep", className: "dsh-coding-faint", "aria-hidden": "true" }, "\xB7"));
|
|
461
|
+
if (verification !== void 0) {
|
|
462
|
+
children.push((0, import_react.createElement)("span", {
|
|
463
|
+
key: "verification",
|
|
464
|
+
className: verification.passed ? "dsh-coding-success" : "dsh-coding-warn",
|
|
465
|
+
title: verification.command,
|
|
466
|
+
"data-verification": verification.passed ? "passed" : "failed"
|
|
467
|
+
}, t(verification.passed ? "verification.passed" : "verification.failed")));
|
|
468
|
+
} else {
|
|
469
|
+
children.push((0, import_react.createElement)("span", {
|
|
470
|
+
key: "verification",
|
|
471
|
+
className: "dsh-coding-faint",
|
|
472
|
+
"data-verification": "none"
|
|
473
|
+
}, t("verification.none")));
|
|
474
|
+
}
|
|
475
|
+
if (checkpoint !== void 0 && checkpoint.planItems > 0) {
|
|
476
|
+
const done = checkpoint.planItems - checkpoint.openPlanItems;
|
|
477
|
+
children.push((0, import_react.createElement)("span", {
|
|
478
|
+
key: "plan",
|
|
479
|
+
className: "dsh-coding-muted",
|
|
480
|
+
"data-plan": String(checkpoint.planItems)
|
|
481
|
+
}, t("plan.progress", { done, total: checkpoint.planItems })));
|
|
482
|
+
}
|
|
483
|
+
if (checkpoint !== void 0 && checkpoint.edits > 0) {
|
|
484
|
+
children.push((0, import_react.createElement)("span", {
|
|
485
|
+
key: "files",
|
|
486
|
+
className: "dsh-coding-muted"
|
|
487
|
+
}, t("files", { count: checkpoint.edits })));
|
|
488
|
+
}
|
|
489
|
+
const worker = checkpoint?.worker;
|
|
490
|
+
if (worker !== void 0) {
|
|
491
|
+
const label = worker.status === "running" ? "worker.running" : worker.status === "completed" ? "worker.completed" : "worker.failed";
|
|
492
|
+
children.push((0, import_react.createElement)("span", {
|
|
493
|
+
key: "worker",
|
|
494
|
+
className: worker.status === "failed" ? "dsh-coding-warn" : "dsh-coding-muted",
|
|
495
|
+
"data-worker": worker.status
|
|
496
|
+
}, t(label, { role: worker.role })));
|
|
497
|
+
}
|
|
498
|
+
if (data.pending !== void 0) {
|
|
499
|
+
children.push((0, import_react.createElement)("span", {
|
|
500
|
+
key: "pending",
|
|
501
|
+
className: "dsh-coding-muted",
|
|
502
|
+
"data-pending": data.pending.tool
|
|
503
|
+
}, t("pending", { tool: data.pending.requested === void 0 ? data.pending.tool : `${data.pending.tool} \u2192 ${data.pending.requested}` })));
|
|
504
|
+
}
|
|
505
|
+
const refusal = checkpoint?.refusal;
|
|
506
|
+
if (refusal !== void 0) {
|
|
507
|
+
children.push((0, import_react.createElement)("span", {
|
|
508
|
+
key: "refusal",
|
|
509
|
+
className: "dsh-coding-warn",
|
|
510
|
+
title: refusal.reason,
|
|
511
|
+
"data-refusal": refusal.target
|
|
512
|
+
}, `${t("refused")}: ${refusal.target}`));
|
|
513
|
+
}
|
|
514
|
+
return (0, import_react.createElement)("div", {
|
|
515
|
+
className: "dsh-coding-capsule",
|
|
516
|
+
role: "group",
|
|
517
|
+
"aria-label": t("aria"),
|
|
518
|
+
"data-coding-capsule": "",
|
|
519
|
+
"data-stage": data.stage,
|
|
520
|
+
"data-mode": data.mode,
|
|
521
|
+
...data.partial ? { "data-partial": "true" } : {}
|
|
522
|
+
}, ...children);
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// src/client/card.ts
|
|
526
|
+
var import_react3 = require("react");
|
|
527
|
+
|
|
528
|
+
// src/coding-projection.ts
|
|
529
|
+
var CODING_PROJECTION_KEY = "dshCodingStage";
|
|
530
|
+
|
|
531
|
+
// src/reasoning-projection.ts
|
|
532
|
+
var REASONING_PROJECTION_KEY = "dshCodingReasoning";
|
|
533
|
+
|
|
534
|
+
// src/reasoning-levels.ts
|
|
535
|
+
function levelForEffort(effort) {
|
|
536
|
+
if (effort === "max" || effort === "xhigh") return "max";
|
|
537
|
+
if (effort === "high" || effort === "medium") return "high";
|
|
538
|
+
return "low";
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// src/client/command-row.ts
|
|
542
|
+
var import_react2 = require("react");
|
|
543
|
+
var SWITCH_WORDS = ["auto", "consult", "review", "codex"];
|
|
544
|
+
function commandRowOf(node) {
|
|
545
|
+
const line = `/${node.name ?? "coding"}${node.args ?? ""}`;
|
|
546
|
+
const words = (node.args ?? "").trim().toLowerCase().split(/\s+/u).filter(Boolean);
|
|
547
|
+
const switches = words[0] === "set" || words.length === 1 && SWITCH_WORDS.includes(words[0]);
|
|
548
|
+
if (switches) return { hidden: true, line, text: null, failed: false };
|
|
549
|
+
const outcome = node.outcome;
|
|
550
|
+
if (outcome == null) return { hidden: true, line, text: null, failed: false };
|
|
551
|
+
const text = typeof outcome.text === "string" && outcome.text.length > 0 ? outcome.text : null;
|
|
552
|
+
return { hidden: false, line, text, failed: outcome.kind === "error" };
|
|
553
|
+
}
|
|
554
|
+
function commandRejected(result) {
|
|
555
|
+
if (result === null || typeof result !== "object") return false;
|
|
556
|
+
if (result.ok === false) return true;
|
|
557
|
+
const value = result.value;
|
|
558
|
+
if (value === null || typeof value !== "object") return false;
|
|
559
|
+
const inner = value.result;
|
|
560
|
+
if (inner === null || typeof inner !== "object") return false;
|
|
561
|
+
return inner.kind === "error";
|
|
562
|
+
}
|
|
563
|
+
var CodingCommandRow = (0, import_react2.memo)(function CodingCommandRow2(props) {
|
|
564
|
+
const view = commandRowOf(props.node);
|
|
565
|
+
if (view.hidden) return null;
|
|
566
|
+
return (0, import_react2.createElement)(
|
|
567
|
+
"div",
|
|
568
|
+
{
|
|
569
|
+
className: "dsh-coding-command",
|
|
570
|
+
"data-command": props.node.name ?? "coding",
|
|
571
|
+
...view.failed ? { "data-error": "true" } : {}
|
|
572
|
+
},
|
|
573
|
+
(0, import_react2.createElement)("span", { className: "dsh-coding-label" }, view.line),
|
|
574
|
+
view.text === null ? null : (0, import_react2.createElement)("span", { className: view.failed ? "dsh-coding-error" : "dsh-coding-value" }, view.text)
|
|
575
|
+
);
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
// src/client/card.ts
|
|
579
|
+
var MODES = ["auto", "consult", "review", "codex"];
|
|
580
|
+
function cardState(view, turn) {
|
|
581
|
+
const turns = Array.isArray(view.turns) ? view.turns : [];
|
|
582
|
+
const frozen = turn === void 0 ? void 0 : turns.find((item) => item.turn === turn);
|
|
583
|
+
const live = turn === void 0 || turn >= view.latest;
|
|
584
|
+
const mode = live ? view.mode : frozen?.mode ?? view.mode;
|
|
585
|
+
const stage = live ? view.stage : frozen?.stage ?? view.stage;
|
|
586
|
+
const verification = (live ? view.verification : frozen?.verification ?? view.verification) ?? null;
|
|
587
|
+
const numbers = live || frozen === void 0 ? { planItems: view.planItems, openPlanItems: view.openPlanItems, edits: view.edits } : { planItems: frozen.planItems, openPlanItems: frozen.openPlanItems, edits: frozen.edits };
|
|
588
|
+
return { live, mode, stage, verification, allowed: STAGES_BY_MODE[mode] ?? STAGES_BY_MODE.codex, ...numbers };
|
|
589
|
+
}
|
|
590
|
+
function commandFor(mode) {
|
|
591
|
+
return `/coding set ${mode}`;
|
|
592
|
+
}
|
|
593
|
+
function turnOf(value) {
|
|
594
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
595
|
+
const turn = value?.turn;
|
|
596
|
+
return typeof turn === "number" && Number.isFinite(turn) ? turn : void 0;
|
|
597
|
+
}
|
|
598
|
+
function verificationText(verification, t) {
|
|
599
|
+
if (verification === null) {
|
|
600
|
+
return { text: t("verification.none"), className: "dsh-coding-value" };
|
|
601
|
+
}
|
|
602
|
+
return verification.passed ? { text: t("verification.passed"), className: "dsh-coding-success" } : { text: t("verification.failed"), className: "dsh-coding-warn" };
|
|
603
|
+
}
|
|
604
|
+
function sliceDisplay(slice) {
|
|
605
|
+
if (slice.override === "low" || slice.override === "high" || slice.override === "max") {
|
|
606
|
+
return { level: slice.override, source: "override" };
|
|
607
|
+
}
|
|
608
|
+
if (typeof slice.userEffort === "string" && slice.userEffort.trim() !== "") {
|
|
609
|
+
return { level: levelForEffort(slice.userEffort.trim()), source: "pick" };
|
|
610
|
+
}
|
|
611
|
+
if (typeof slice.effort === "string" && slice.effort.trim() !== "") {
|
|
612
|
+
return { level: levelForEffort(slice.effort.trim()), source: "auto" };
|
|
613
|
+
}
|
|
614
|
+
return { level: null, source: "pending" };
|
|
615
|
+
}
|
|
616
|
+
function reasoningDisplay(state, turn, settings) {
|
|
617
|
+
const pinned = settings === "low" || settings === "high" || settings === "max" ? settings : void 0;
|
|
618
|
+
if (state === void 0) {
|
|
619
|
+
return pinned === void 0 ? { level: null, source: "pending" } : { level: pinned, source: "settings" };
|
|
620
|
+
}
|
|
621
|
+
const turns = Array.isArray(state.turns) ? state.turns : [];
|
|
622
|
+
const frozen = turn === void 0 ? void 0 : turns.find((item) => item.turn === turn);
|
|
623
|
+
if (frozen !== void 0) {
|
|
624
|
+
const display = sliceDisplay(frozen);
|
|
625
|
+
return pinned !== void 0 && display.level === pinned ? { level: pinned, source: "settings" } : display;
|
|
626
|
+
}
|
|
627
|
+
const latest = typeof state.latest === "number" ? state.latest : 0;
|
|
628
|
+
if (turn !== void 0 && turn < latest) return { level: null, source: "pending" };
|
|
629
|
+
if (pinned !== void 0) return { level: pinned, source: "settings" };
|
|
630
|
+
return sliceDisplay(state);
|
|
631
|
+
}
|
|
632
|
+
var REASONING_SOURCE_KEY = {
|
|
633
|
+
settings: "reasoning.sourceSettings",
|
|
634
|
+
override: "reasoning.sourceOverride",
|
|
635
|
+
pick: "reasoning.sourcePick",
|
|
636
|
+
auto: "reasoning.sourceAuto",
|
|
637
|
+
pending: "reasoning.pending"
|
|
638
|
+
};
|
|
639
|
+
function levelLabel(level) {
|
|
640
|
+
return level === null ? null : level === "low" ? "Low" : level === "high" ? "High" : "Max";
|
|
641
|
+
}
|
|
642
|
+
var CodingTurnCard = (0, import_react3.memo)(function CodingTurnCard2(props) {
|
|
643
|
+
const { t } = props;
|
|
644
|
+
const raw = props.useProjection?.(CODING_PROJECTION_KEY);
|
|
645
|
+
const reasoningRaw = props.useProjection?.(REASONING_PROJECTION_KEY);
|
|
646
|
+
const view = raw === null || typeof raw !== "object" ? void 0 : raw;
|
|
647
|
+
const [busy, setBusy] = (0, import_react3.useState)(null);
|
|
648
|
+
const [error, setError] = (0, import_react3.useState)(null);
|
|
649
|
+
if (view === void 0 || view.active !== true) return null;
|
|
650
|
+
const turn = turnOf(props.turn);
|
|
651
|
+
const { live, mode, stage, verification, allowed, ...numbers } = cardState(view, turn);
|
|
652
|
+
const reasoningState = reasoningRaw === null || typeof reasoningRaw !== "object" ? void 0 : reasoningRaw;
|
|
653
|
+
const reasoning = reasoningDisplay(reasoningState, turn, props.settings?.());
|
|
654
|
+
const stageIndex = allowed.indexOf(stage);
|
|
655
|
+
const number = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
656
|
+
const planItems = number(numbers.planItems);
|
|
657
|
+
const openPlanItems = number(numbers.openPlanItems);
|
|
658
|
+
const state = verificationText(verification, t);
|
|
659
|
+
const enabled = live && busy === null;
|
|
660
|
+
async function choose(next) {
|
|
661
|
+
if (next === mode || busy !== null || !live) return;
|
|
662
|
+
setBusy(next);
|
|
663
|
+
setError(null);
|
|
664
|
+
try {
|
|
665
|
+
const result = await props.execute?.(commandFor(next));
|
|
666
|
+
if (commandRejected(result)) setError(t("card.switchFailed"));
|
|
667
|
+
} catch {
|
|
668
|
+
setError(t("card.switchFailed"));
|
|
669
|
+
} finally {
|
|
670
|
+
setBusy(null);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return (0, import_react3.createElement)(
|
|
674
|
+
"div",
|
|
675
|
+
{
|
|
676
|
+
className: "dsh-coding-card",
|
|
677
|
+
"data-dsh-coding-card": "true",
|
|
678
|
+
"data-live": live ? "true" : "false",
|
|
679
|
+
"aria-label": t("aria")
|
|
680
|
+
},
|
|
681
|
+
(0, import_react3.createElement)(
|
|
682
|
+
"div",
|
|
683
|
+
{ className: "dsh-coding-row" },
|
|
684
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-label" }, t("card.mode")),
|
|
685
|
+
(0, import_react3.createElement)(
|
|
686
|
+
"div",
|
|
687
|
+
{ className: "dsh-coding-actions" },
|
|
688
|
+
...MODES.map((option) => (0, import_react3.createElement)(
|
|
689
|
+
"button",
|
|
690
|
+
{
|
|
691
|
+
key: option,
|
|
692
|
+
type: "button",
|
|
693
|
+
className: "dsh-coding-button",
|
|
694
|
+
disabled: !enabled,
|
|
695
|
+
"aria-pressed": option === mode,
|
|
696
|
+
onClick: () => {
|
|
697
|
+
void choose(option);
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
t(`mode.${option}`)
|
|
701
|
+
))
|
|
702
|
+
),
|
|
703
|
+
live ? null : (0, import_react3.createElement)("span", { className: "dsh-coding-hint" }, t("card.stale"))
|
|
704
|
+
),
|
|
705
|
+
(0, import_react3.createElement)(
|
|
706
|
+
"div",
|
|
707
|
+
{ className: "dsh-coding-row" },
|
|
708
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-label" }, t("card.stage")),
|
|
709
|
+
...allowed.flatMap((item, index) => [
|
|
710
|
+
...index === 0 ? [] : [(0, import_react3.createElement)("span", { key: `${item}-arrow`, className: "dsh-coding-arrow", "aria-hidden": "true" }, "\u2192")],
|
|
711
|
+
(0, import_react3.createElement)(
|
|
712
|
+
"span",
|
|
713
|
+
{
|
|
714
|
+
key: item,
|
|
715
|
+
className: "dsh-coding-stage",
|
|
716
|
+
"data-current": item === stage ? "true" : void 0,
|
|
717
|
+
"data-done": index < stageIndex ? "true" : void 0,
|
|
718
|
+
"data-stage": item
|
|
719
|
+
},
|
|
720
|
+
t(`stage.${item}`)
|
|
721
|
+
)
|
|
722
|
+
]),
|
|
723
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-hint" }, t("card.stageHint"))
|
|
724
|
+
),
|
|
725
|
+
(0, import_react3.createElement)(
|
|
726
|
+
"div",
|
|
727
|
+
{ className: "dsh-coding-row" },
|
|
728
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-label" }, t("card.reasoning")),
|
|
729
|
+
(0, import_react3.createElement)(
|
|
730
|
+
"span",
|
|
731
|
+
{
|
|
732
|
+
className: reasoning.level === null ? "dsh-coding-hint" : "dsh-coding-value",
|
|
733
|
+
"data-reasoning-level": reasoning.level ?? "pending",
|
|
734
|
+
"data-reasoning-source": reasoning.source
|
|
735
|
+
},
|
|
736
|
+
levelLabel(reasoning.level) ?? t("reasoning.pending")
|
|
737
|
+
),
|
|
738
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-faint", "aria-hidden": "true" }, "\xB7"),
|
|
739
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-hint" }, t(REASONING_SOURCE_KEY[reasoning.source]))
|
|
740
|
+
),
|
|
741
|
+
(0, import_react3.createElement)(
|
|
742
|
+
"div",
|
|
743
|
+
{ className: "dsh-coding-row" },
|
|
744
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-label" }, t("card.verify")),
|
|
745
|
+
(0, import_react3.createElement)("span", { className: state.className }, state.text),
|
|
746
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-faint", "aria-hidden": "true" }, "\xB7"),
|
|
747
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-value" }, planItems === 0 ? t("plan.none") : t("plan.progress").replace("{done}", String(Math.max(0, planItems - openPlanItems))).replace("{total}", String(planItems))),
|
|
748
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-faint", "aria-hidden": "true" }, "\xB7"),
|
|
749
|
+
(0, import_react3.createElement)("span", { className: "dsh-coding-value" }, t("files").replace("{count}", String(number(numbers.edits)))),
|
|
750
|
+
view.pending === null ? null : (0, import_react3.createElement)("span", { className: "dsh-coding-value" }, t("pending").replace("{tool}", view.pending.tool))
|
|
751
|
+
),
|
|
752
|
+
error === null ? null : (0, import_react3.createElement)("p", { className: "dsh-coding-error" }, error)
|
|
753
|
+
);
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
// src/client/mode-picker.ts
|
|
757
|
+
var import_react4 = require("react");
|
|
758
|
+
var MODES2 = ["auto", "consult", "review", "codex"];
|
|
759
|
+
function pickerCommandFor(mode) {
|
|
760
|
+
return `/coding set ${mode}`;
|
|
761
|
+
}
|
|
762
|
+
function pickerState(view) {
|
|
763
|
+
if (view === void 0 || view.active !== true) return null;
|
|
764
|
+
return { mode: MODES2.includes(view.mode) ? view.mode : "auto", modes: MODES2 };
|
|
765
|
+
}
|
|
766
|
+
var CodingModePicker = (0, import_react4.memo)(function CodingModePicker2(props) {
|
|
767
|
+
const raw = props.useProjection?.(CODING_PROJECTION_KEY);
|
|
768
|
+
const view = raw === null || typeof raw !== "object" ? void 0 : raw;
|
|
769
|
+
const state = pickerState(view);
|
|
770
|
+
const [busy, setBusy] = (0, import_react4.useState)(null);
|
|
771
|
+
const [failed, setFailed] = (0, import_react4.useState)(false);
|
|
772
|
+
if (state === null) return null;
|
|
773
|
+
async function choose(next) {
|
|
774
|
+
if (busy !== null || next === state?.mode) return;
|
|
775
|
+
setBusy(next);
|
|
776
|
+
setFailed(false);
|
|
777
|
+
try {
|
|
778
|
+
const result = await props.execute?.(pickerCommandFor(next));
|
|
779
|
+
if (commandRejected(result)) setFailed(true);
|
|
780
|
+
} catch {
|
|
781
|
+
setFailed(true);
|
|
782
|
+
} finally {
|
|
783
|
+
setBusy(null);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return (0, import_react4.createElement)(
|
|
787
|
+
"div",
|
|
788
|
+
{
|
|
789
|
+
className: "dsh-coding-picker",
|
|
790
|
+
"data-dsh-coding-picker": "true",
|
|
791
|
+
role: "group",
|
|
792
|
+
"aria-label": props.t("picker.aria")
|
|
793
|
+
},
|
|
794
|
+
(0, import_react4.createElement)("span", { className: "dsh-coding-label" }, props.t("picker.label")),
|
|
795
|
+
...state.modes.map((option) => (0, import_react4.createElement)(
|
|
796
|
+
"button",
|
|
797
|
+
{
|
|
798
|
+
key: option,
|
|
799
|
+
type: "button",
|
|
800
|
+
className: "dsh-coding-button",
|
|
801
|
+
disabled: busy !== null,
|
|
802
|
+
"aria-pressed": option === state.mode,
|
|
803
|
+
onClick: () => {
|
|
804
|
+
void choose(option);
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
props.t(`mode.${option}`)
|
|
808
|
+
)),
|
|
809
|
+
failed ? (0, import_react4.createElement)("span", { className: "dsh-coding-error" }, props.t("card.switchFailed")) : null
|
|
810
|
+
);
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
// src/client/config-page.ts
|
|
814
|
+
var import_react5 = require("react");
|
|
815
|
+
var SETTINGS_NAMESPACE = "dsh-coding";
|
|
816
|
+
var MODES3 = ["auto", "consult", "review", "codex"];
|
|
817
|
+
var LANGUAGES = ["auto", "zh", "en"];
|
|
818
|
+
var REASONING_MODES = ["auto", "low", "high", "max"];
|
|
819
|
+
var ROUTE = /^[^/\s]+\/[^/\s]+$/u;
|
|
820
|
+
function fieldOf(value, key, fallback = "") {
|
|
821
|
+
const raw = value?.[key];
|
|
822
|
+
return typeof raw === "string" ? raw : fallback;
|
|
823
|
+
}
|
|
824
|
+
var DEFAULT_DRAFT = {
|
|
825
|
+
defaultMode: "auto",
|
|
826
|
+
plannerWorkerModel: "deepseek-account/deepseek-v4-pro",
|
|
827
|
+
implementWorkerModel: "deepseek-account/deepseek-flash",
|
|
828
|
+
verifyWorkerModel: "deepseek-account/deepseek-flash",
|
|
829
|
+
language: "auto",
|
|
830
|
+
reasoning: "auto"
|
|
831
|
+
};
|
|
832
|
+
var BUILTIN_MODELS = {
|
|
833
|
+
"deepseek-account": [
|
|
834
|
+
{ id: "deepseek-v4-pro", name: "DeepSeek V4 Pro" },
|
|
835
|
+
{ id: "deepseek-flash", name: "DeepSeek Flash" }
|
|
836
|
+
]
|
|
837
|
+
};
|
|
838
|
+
function draftOf(value) {
|
|
839
|
+
return {
|
|
840
|
+
defaultMode: fieldOf(value, "defaultMode", "auto"),
|
|
841
|
+
implementWorkerModel: fieldOf(value, "implementWorkerModel"),
|
|
842
|
+
plannerWorkerModel: fieldOf(value, "plannerWorkerModel"),
|
|
843
|
+
verifyWorkerModel: fieldOf(value, "verifyWorkerModel"),
|
|
844
|
+
language: fieldOf(value, "language", "auto"),
|
|
845
|
+
reasoning: fieldOf(value, "reasoning", "auto")
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function draftIsValid(draft) {
|
|
849
|
+
return ROUTE.test(draft.implementWorkerModel.trim()) && ROUTE.test(draft.plannerWorkerModel.trim()) && ROUTE.test(draft.verifyWorkerModel.trim());
|
|
850
|
+
}
|
|
851
|
+
function messageOf(error) {
|
|
852
|
+
if (error instanceof Error) return error.message;
|
|
853
|
+
return typeof error === "string" ? error : "Unknown error.";
|
|
854
|
+
}
|
|
855
|
+
function resultList(result, fallback) {
|
|
856
|
+
if (result.ok !== true || !Array.isArray(result.value)) {
|
|
857
|
+
throw new Error(result.error?.message || fallback);
|
|
858
|
+
}
|
|
859
|
+
return result.value;
|
|
860
|
+
}
|
|
861
|
+
async function loadModelOptions(remote) {
|
|
862
|
+
const listProviders = remote?.listProviders?.bind(remote);
|
|
863
|
+
const listConfigurableProviders = remote?.listConfigurableProviders?.bind(remote);
|
|
864
|
+
const discoverModels = remote?.discoverModels?.bind(remote);
|
|
865
|
+
if (listProviders === void 0 || listConfigurableProviders === void 0 || discoverModels === void 0) {
|
|
866
|
+
throw new Error("The Host does not expose the LLM model Remote.");
|
|
867
|
+
}
|
|
868
|
+
const [registered, configurable] = await Promise.all([listProviders(), listConfigurableProviders()]);
|
|
869
|
+
const providers = resultList(registered, "Could not read the configured providers.");
|
|
870
|
+
const entries = resultList(configurable, "Could not read the configured providers.");
|
|
871
|
+
const known = new Set(providers.map((provider) => provider.id));
|
|
872
|
+
const usable = entries.filter((entry) => known.has(entry.provider) && typeof entry.settingsNs === "string" && entry.settingsNs.trim() !== "");
|
|
873
|
+
const errors = [];
|
|
874
|
+
const discovered = await Promise.all(usable.map(async (entry) => {
|
|
875
|
+
try {
|
|
876
|
+
const result = await discoverModels(entry.settingsNs, { provider: entry.provider });
|
|
877
|
+
if (result.ok !== true || !Array.isArray(result.value)) {
|
|
878
|
+
errors.push(result.error?.message || `Could not read the models of ${entry.provider}.`);
|
|
879
|
+
return { entry, models: [] };
|
|
880
|
+
}
|
|
881
|
+
return { entry, models: result.value };
|
|
882
|
+
} catch (error) {
|
|
883
|
+
errors.push(messageOf(error));
|
|
884
|
+
return { entry, models: [] };
|
|
885
|
+
}
|
|
886
|
+
}));
|
|
887
|
+
const byValue = /* @__PURE__ */ new Map();
|
|
888
|
+
for (const item of discovered) {
|
|
889
|
+
const models = item.models.length > 0 ? item.models : BUILTIN_MODELS[item.entry.provider] ?? [];
|
|
890
|
+
for (const model of models) {
|
|
891
|
+
if (typeof model?.id !== "string" || model.id.trim() === "") continue;
|
|
892
|
+
const value = `${item.entry.provider}/${model.id}`;
|
|
893
|
+
if (byValue.has(value)) continue;
|
|
894
|
+
byValue.set(value, {
|
|
895
|
+
value,
|
|
896
|
+
provider: item.entry.provider,
|
|
897
|
+
model: model.id,
|
|
898
|
+
label: `${item.entry.displayName || item.entry.provider} \xB7 ${model.name?.trim() || model.id}`
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
const options = [...byValue.values()];
|
|
903
|
+
options.sort((left, right) => left.provider === right.provider ? left.label.localeCompare(right.label) : left.provider.localeCompare(right.provider));
|
|
904
|
+
if (options.length === 0) {
|
|
905
|
+
throw new Error(errors[0] || "No configured provider advertised a model.");
|
|
906
|
+
}
|
|
907
|
+
return options;
|
|
908
|
+
}
|
|
909
|
+
function mergeCurrentModels(options, current) {
|
|
910
|
+
const merged = [...options];
|
|
911
|
+
const values = new Set(options.map((option) => option.value));
|
|
912
|
+
for (const route of current) {
|
|
913
|
+
const value = route.trim();
|
|
914
|
+
if (value === "" || values.has(value)) continue;
|
|
915
|
+
values.add(value);
|
|
916
|
+
const [provider = "", ...rest] = value.split("/");
|
|
917
|
+
merged.push({ value, provider, model: rest.join("/"), label: value, missing: true });
|
|
918
|
+
}
|
|
919
|
+
return merged;
|
|
920
|
+
}
|
|
921
|
+
function draftModelsValid(draft, options) {
|
|
922
|
+
const values = new Set(options.map((option) => option.value));
|
|
923
|
+
return [draft.plannerWorkerModel, draft.implementWorkerModel, draft.verifyWorkerModel].every((route) => {
|
|
924
|
+
const value = route.trim();
|
|
925
|
+
return value !== "" && values.has(value);
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
function buildConfigOps(draft, served = { language: draft.language, reasoning: draft.reasoning }) {
|
|
929
|
+
const ops = [
|
|
930
|
+
{ op: "set", path: ["defaultMode"], value: draft.defaultMode },
|
|
931
|
+
{ op: "set", path: ["implementWorkerModel"], value: draft.implementWorkerModel.trim() },
|
|
932
|
+
{ op: "set", path: ["plannerWorkerModel"], value: draft.plannerWorkerModel.trim() },
|
|
933
|
+
{ op: "set", path: ["verifyWorkerModel"], value: draft.verifyWorkerModel.trim() }
|
|
934
|
+
];
|
|
935
|
+
if ("language" in served) ops.push({ op: "set", path: ["language"], value: draft.language });
|
|
936
|
+
if ("reasoning" in served) ops.push({ op: "set", path: ["reasoning"], value: draft.reasoning });
|
|
937
|
+
return ops;
|
|
938
|
+
}
|
|
939
|
+
function commandLines(value) {
|
|
940
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return [];
|
|
941
|
+
return Object.entries(value).filter((entry) => typeof entry[1] === "string").map(([key, command]) => `${key} = ${command}`);
|
|
942
|
+
}
|
|
943
|
+
function field(id, label, hint, input) {
|
|
944
|
+
return (0, import_react5.createElement)(
|
|
945
|
+
"div",
|
|
946
|
+
{ className: "dsh-coding-field" },
|
|
947
|
+
(0, import_react5.createElement)("label", { htmlFor: id }, label),
|
|
948
|
+
input,
|
|
949
|
+
(0, import_react5.createElement)("span", { className: "dsh-coding-hint" }, hint)
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
function modelField(id, label, hint, value, options, invalid, readOnly, onChange, t) {
|
|
953
|
+
return field(
|
|
954
|
+
id,
|
|
955
|
+
label,
|
|
956
|
+
hint,
|
|
957
|
+
(0, import_react5.createElement)(
|
|
958
|
+
"select",
|
|
959
|
+
{
|
|
960
|
+
id,
|
|
961
|
+
className: "dsh-coding-input" + (invalid ? " dsh-coding-input-warn" : ""),
|
|
962
|
+
value,
|
|
963
|
+
disabled: readOnly,
|
|
964
|
+
"aria-invalid": invalid,
|
|
965
|
+
onChange: (event) => {
|
|
966
|
+
onChange(event.target.value);
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
(0, import_react5.createElement)("option", { key: "", value: "", disabled: true }, t("config.modelPlaceholder")),
|
|
970
|
+
...options.map((option) => (0, import_react5.createElement)(
|
|
971
|
+
"option",
|
|
972
|
+
{ key: option.value, value: option.value },
|
|
973
|
+
option.missing ? `${option.label} \u2014 ${t("config.modelMissing")}` : option.label
|
|
974
|
+
))
|
|
975
|
+
)
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
function CodingConfigPage(props) {
|
|
979
|
+
const { form, t } = props;
|
|
980
|
+
if (props.view === "summary") return (0, import_react5.createElement)("span", null, t("config.title"));
|
|
981
|
+
const subscribe = (0, import_react5.useCallback)((listener) => form.subscribe(listener), [form]);
|
|
982
|
+
const getSnapshot = (0, import_react5.useCallback)(() => form.getSnapshot(), [form]);
|
|
983
|
+
const snapshot = (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot);
|
|
984
|
+
const [draft, setDraft] = (0, import_react5.useState)(() => draftOf(snapshot.value));
|
|
985
|
+
const [status, setStatus] = (0, import_react5.useState)("idle");
|
|
986
|
+
const [catalog, setCatalog] = (0, import_react5.useState)({ status: "loading" });
|
|
987
|
+
const [catalogRevision, setCatalogRevision] = (0, import_react5.useState)(0);
|
|
988
|
+
(0, import_react5.useEffect)(() => {
|
|
989
|
+
setDraft(draftOf(snapshot.value));
|
|
990
|
+
}, [snapshot.value]);
|
|
991
|
+
(0, import_react5.useEffect)(() => {
|
|
992
|
+
let cancelled = false;
|
|
993
|
+
setCatalog({ status: "loading" });
|
|
994
|
+
loadModelOptions(props.remote).then((options2) => {
|
|
995
|
+
if (!cancelled) setCatalog({ status: "ready", options: options2 });
|
|
996
|
+
}).catch((error) => {
|
|
997
|
+
if (!cancelled) setCatalog({ status: "error", message: messageOf(error) });
|
|
998
|
+
});
|
|
999
|
+
return () => {
|
|
1000
|
+
cancelled = true;
|
|
1001
|
+
};
|
|
1002
|
+
}, [props.remote, catalogRevision]);
|
|
1003
|
+
if (snapshot.status === "loading") {
|
|
1004
|
+
return (0, import_react5.createElement)("p", { className: "dsh-coding-hint" }, t("config.loading"));
|
|
1005
|
+
}
|
|
1006
|
+
if (snapshot.status === "unavailable") {
|
|
1007
|
+
return (0, import_react5.createElement)("p", { className: "dsh-coding-hint" }, t("config.unavailable"));
|
|
1008
|
+
}
|
|
1009
|
+
const value = snapshot.value ?? {};
|
|
1010
|
+
const routesValid = draftIsValid(draft);
|
|
1011
|
+
const options = catalog.status === "ready" ? catalog.options : [];
|
|
1012
|
+
const modelOptions = mergeCurrentModels(options, [
|
|
1013
|
+
draft.plannerWorkerModel,
|
|
1014
|
+
draft.implementWorkerModel,
|
|
1015
|
+
draft.verifyWorkerModel
|
|
1016
|
+
]);
|
|
1017
|
+
const modelsValid = catalog.status === "ready" && draftModelsValid(draft, options);
|
|
1018
|
+
const routeKnown = (route) => options.some((option) => option.value === route.trim());
|
|
1019
|
+
const dirty = draft.defaultMode !== fieldOf(value, "defaultMode", "auto") || draft.implementWorkerModel !== fieldOf(value, "implementWorkerModel") || draft.plannerWorkerModel !== fieldOf(value, "plannerWorkerModel") || draft.verifyWorkerModel !== fieldOf(value, "verifyWorkerModel") || draft.language !== fieldOf(value, "language", "auto") || draft.reasoning !== fieldOf(value, "reasoning", "auto");
|
|
1020
|
+
const commands = commandLines(value["verificationCommands"]);
|
|
1021
|
+
const readOnly = snapshot.writable !== true;
|
|
1022
|
+
const modelNotice = catalog.status === "ready" ? {
|
|
1023
|
+
text: t("config.modelWarning"),
|
|
1024
|
+
className: modelsValid ? "dsh-coding-hint dsh-coding-notice" : "dsh-coding-warn dsh-coding-notice"
|
|
1025
|
+
} : catalog.status === "error" ? {
|
|
1026
|
+
text: `${t("config.modelsUnavailable")} ${catalog.message}`,
|
|
1027
|
+
className: "dsh-coding-warn dsh-coding-notice"
|
|
1028
|
+
} : { text: t("config.modelsLoading"), className: "dsh-coding-hint dsh-coding-notice" };
|
|
1029
|
+
async function save() {
|
|
1030
|
+
if (status === "saving" || !routesValid || !modelsValid || readOnly) return;
|
|
1031
|
+
setStatus("saving");
|
|
1032
|
+
try {
|
|
1033
|
+
const accepted = await form.mutate(buildConfigOps(draft, value), snapshot.revision);
|
|
1034
|
+
setStatus(accepted ? "saved" : "error");
|
|
1035
|
+
} catch {
|
|
1036
|
+
setStatus("error");
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function resetDefaults() {
|
|
1040
|
+
setDraft(DEFAULT_DRAFT);
|
|
1041
|
+
setStatus("idle");
|
|
1042
|
+
}
|
|
1043
|
+
const statusText = status === "saving" ? t("config.saving") : status === "saved" ? t("config.saved") : status === "error" ? t("config.saveFailed") : routesValid ? "" : t("config.invalidRoute");
|
|
1044
|
+
const statusClass = status === "error" ? "dsh-coding-error" : status === "saved" ? "dsh-coding-success" : "dsh-coding-hint";
|
|
1045
|
+
return (0, import_react5.createElement)(
|
|
1046
|
+
"div",
|
|
1047
|
+
{ className: "dsh-coding-form", "data-dsh-coding-config": "true" },
|
|
1048
|
+
(0, import_react5.createElement)("p", { className: "dsh-coding-warn dsh-coding-notice" }, t("config.presetWarning")),
|
|
1049
|
+
field(
|
|
1050
|
+
"dsh-coding-mode",
|
|
1051
|
+
t("config.mode"),
|
|
1052
|
+
t("config.modeHint"),
|
|
1053
|
+
(0, import_react5.createElement)(
|
|
1054
|
+
"select",
|
|
1055
|
+
{
|
|
1056
|
+
id: "dsh-coding-mode",
|
|
1057
|
+
className: "dsh-coding-input",
|
|
1058
|
+
value: draft.defaultMode,
|
|
1059
|
+
disabled: readOnly,
|
|
1060
|
+
onChange: (event) => {
|
|
1061
|
+
setDraft((current) => ({ ...current, defaultMode: event.target.value }));
|
|
1062
|
+
setStatus("idle");
|
|
1063
|
+
}
|
|
1064
|
+
},
|
|
1065
|
+
...MODES3.map((option) => (0, import_react5.createElement)("option", { key: option, value: option }, t(`mode.${option}`)))
|
|
1066
|
+
)
|
|
1067
|
+
),
|
|
1068
|
+
"language" in value ? field(
|
|
1069
|
+
"dsh-coding-language",
|
|
1070
|
+
t("config.language"),
|
|
1071
|
+
t("config.languageHint"),
|
|
1072
|
+
(0, import_react5.createElement)(
|
|
1073
|
+
"select",
|
|
1074
|
+
{
|
|
1075
|
+
id: "dsh-coding-language",
|
|
1076
|
+
className: "dsh-coding-input",
|
|
1077
|
+
value: draft.language,
|
|
1078
|
+
disabled: readOnly,
|
|
1079
|
+
onChange: (event) => {
|
|
1080
|
+
setDraft((current) => ({ ...current, language: event.target.value }));
|
|
1081
|
+
setStatus("idle");
|
|
1082
|
+
}
|
|
1083
|
+
},
|
|
1084
|
+
...LANGUAGES.map((option) => {
|
|
1085
|
+
const label = option === "auto" ? t("config.languageAuto") : option === "zh" ? "\u4E2D\u6587" : "English";
|
|
1086
|
+
return (0, import_react5.createElement)("option", { key: option, value: option }, label);
|
|
1087
|
+
})
|
|
1088
|
+
)
|
|
1089
|
+
) : null,
|
|
1090
|
+
"reasoning" in value ? field(
|
|
1091
|
+
"dsh-coding-reasoning",
|
|
1092
|
+
t("config.reasoning"),
|
|
1093
|
+
t("config.reasoningHint"),
|
|
1094
|
+
(0, import_react5.createElement)(
|
|
1095
|
+
"select",
|
|
1096
|
+
{
|
|
1097
|
+
id: "dsh-coding-reasoning",
|
|
1098
|
+
className: "dsh-coding-input",
|
|
1099
|
+
value: draft.reasoning,
|
|
1100
|
+
disabled: readOnly,
|
|
1101
|
+
onChange: (event) => {
|
|
1102
|
+
setDraft((current) => ({ ...current, reasoning: event.target.value }));
|
|
1103
|
+
setStatus("idle");
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
...REASONING_MODES.map((option) => {
|
|
1107
|
+
const label = option === "auto" ? t("config.reasoningAuto") : option === "low" ? "Low" : option === "high" ? "High" : "Max";
|
|
1108
|
+
return (0, import_react5.createElement)("option", { key: option, value: option }, label);
|
|
1109
|
+
})
|
|
1110
|
+
)
|
|
1111
|
+
) : null,
|
|
1112
|
+
(0, import_react5.createElement)(
|
|
1113
|
+
"div",
|
|
1114
|
+
{ className: "dsh-coding-notice-row" },
|
|
1115
|
+
(0, import_react5.createElement)("p", { className: modelNotice.className }, modelNotice.text),
|
|
1116
|
+
catalog.status === "error" ? (0, import_react5.createElement)(
|
|
1117
|
+
"button",
|
|
1118
|
+
{
|
|
1119
|
+
type: "button",
|
|
1120
|
+
className: "dsh-coding-button",
|
|
1121
|
+
onClick: () => {
|
|
1122
|
+
setCatalogRevision((current) => current + 1);
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
t("config.modelsRetry")
|
|
1126
|
+
) : null
|
|
1127
|
+
),
|
|
1128
|
+
modelField(
|
|
1129
|
+
"dsh-coding-planner",
|
|
1130
|
+
t("config.plannerModel"),
|
|
1131
|
+
t("config.plannerModelHint"),
|
|
1132
|
+
draft.plannerWorkerModel,
|
|
1133
|
+
modelOptions,
|
|
1134
|
+
catalog.status === "ready" && !routeKnown(draft.plannerWorkerModel),
|
|
1135
|
+
readOnly,
|
|
1136
|
+
(next) => {
|
|
1137
|
+
setDraft((current) => ({ ...current, plannerWorkerModel: next }));
|
|
1138
|
+
setStatus("idle");
|
|
1139
|
+
},
|
|
1140
|
+
t
|
|
1141
|
+
),
|
|
1142
|
+
modelField(
|
|
1143
|
+
"dsh-coding-implement",
|
|
1144
|
+
t("config.implementModel"),
|
|
1145
|
+
t("config.implementModelHint"),
|
|
1146
|
+
draft.implementWorkerModel,
|
|
1147
|
+
modelOptions,
|
|
1148
|
+
catalog.status === "ready" && !routeKnown(draft.implementWorkerModel),
|
|
1149
|
+
readOnly,
|
|
1150
|
+
(next) => {
|
|
1151
|
+
setDraft((current) => ({ ...current, implementWorkerModel: next }));
|
|
1152
|
+
setStatus("idle");
|
|
1153
|
+
},
|
|
1154
|
+
t
|
|
1155
|
+
),
|
|
1156
|
+
modelField(
|
|
1157
|
+
"dsh-coding-verify",
|
|
1158
|
+
t("config.verifyModel"),
|
|
1159
|
+
t("config.verifyModelHint"),
|
|
1160
|
+
draft.verifyWorkerModel,
|
|
1161
|
+
modelOptions,
|
|
1162
|
+
catalog.status === "ready" && !routeKnown(draft.verifyWorkerModel),
|
|
1163
|
+
readOnly,
|
|
1164
|
+
(next) => {
|
|
1165
|
+
setDraft((current) => ({ ...current, verifyWorkerModel: next }));
|
|
1166
|
+
setStatus("idle");
|
|
1167
|
+
},
|
|
1168
|
+
t
|
|
1169
|
+
),
|
|
1170
|
+
(0, import_react5.createElement)(
|
|
1171
|
+
"div",
|
|
1172
|
+
{ className: "dsh-coding-field" },
|
|
1173
|
+
(0, import_react5.createElement)("label", null, t("config.commands")),
|
|
1174
|
+
(0, import_react5.createElement)("span", { className: "dsh-coding-mono" }, commands.length === 0 ? t("config.verification") : commands.join("\n")),
|
|
1175
|
+
(0, import_react5.createElement)("span", { className: "dsh-coding-hint" }, t("config.commandsHint"))
|
|
1176
|
+
),
|
|
1177
|
+
(0, import_react5.createElement)(
|
|
1178
|
+
"div",
|
|
1179
|
+
{ className: "dsh-coding-footer" },
|
|
1180
|
+
(0, import_react5.createElement)(
|
|
1181
|
+
"button",
|
|
1182
|
+
{
|
|
1183
|
+
type: "button",
|
|
1184
|
+
className: "dsh-coding-button dsh-coding-button-lg",
|
|
1185
|
+
disabled: readOnly || status === "saving" || !routesValid || !modelsValid || !dirty,
|
|
1186
|
+
onClick: () => {
|
|
1187
|
+
void save();
|
|
1188
|
+
}
|
|
1189
|
+
},
|
|
1190
|
+
status === "saving" ? t("config.saving") : t("config.save")
|
|
1191
|
+
),
|
|
1192
|
+
(0, import_react5.createElement)(
|
|
1193
|
+
"button",
|
|
1194
|
+
{
|
|
1195
|
+
type: "button",
|
|
1196
|
+
className: "dsh-coding-button",
|
|
1197
|
+
disabled: readOnly || status === "saving",
|
|
1198
|
+
onClick: () => {
|
|
1199
|
+
resetDefaults();
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
t("config.reset")
|
|
1203
|
+
),
|
|
1204
|
+
statusText === "" ? null : (0, import_react5.createElement)("span", { className: statusClass }, statusText),
|
|
1205
|
+
readOnly ? (0, import_react5.createElement)("span", { className: "dsh-coding-hint" }, t("config.readOnly")) : null
|
|
1206
|
+
)
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// src/client/styles.ts
|
|
1211
|
+
var STYLE_ID = "dsh-coding/ui.css";
|
|
1212
|
+
var PLUGIN_ID = "dsh-coding";
|
|
1213
|
+
var CSS = `
|
|
1214
|
+
/* Card: the shipped plan-card surface recipe. */
|
|
1215
|
+
.dsh-coding-card {
|
|
1216
|
+
box-sizing: border-box;
|
|
1217
|
+
display: flex;
|
|
1218
|
+
flex-direction: column;
|
|
1219
|
+
gap: 6px;
|
|
1220
|
+
margin: 0;
|
|
1221
|
+
padding: 8px 10px;
|
|
1222
|
+
border: 0.5px solid var(--dsw-alias-border-l1);
|
|
1223
|
+
border-radius: var(--dsw-radius-lg);
|
|
1224
|
+
background: var(--dsw-alias-card-fill);
|
|
1225
|
+
color: var(--dsw-alias-label-primary);
|
|
1226
|
+
font: inherit;
|
|
1227
|
+
/* One base type for the whole card: the shipped status-row size. Without it
|
|
1228
|
+
a color-only utility (verification, separator, history hint) inherits the
|
|
1229
|
+
chat body size and the last row mixes two sizes. */
|
|
1230
|
+
font-size: 12px;
|
|
1231
|
+
line-height: 18px;
|
|
1232
|
+
}
|
|
1233
|
+
.dsh-coding-row {
|
|
1234
|
+
display: flex;
|
|
1235
|
+
flex-wrap: wrap;
|
|
1236
|
+
align-items: baseline;
|
|
1237
|
+
gap: 6px;
|
|
1238
|
+
margin: 0;
|
|
1239
|
+
}
|
|
1240
|
+
.dsh-coding-label {
|
|
1241
|
+
font-size: 12px;
|
|
1242
|
+
font-weight: 500;
|
|
1243
|
+
line-height: 18px;
|
|
1244
|
+
color: var(--dsw-alias-label-primary);
|
|
1245
|
+
}
|
|
1246
|
+
.dsh-coding-value {
|
|
1247
|
+
font-size: 12px;
|
|
1248
|
+
line-height: 18px;
|
|
1249
|
+
color: var(--dsw-alias-label-secondary);
|
|
1250
|
+
}
|
|
1251
|
+
.dsh-coding-hint {
|
|
1252
|
+
margin: 0;
|
|
1253
|
+
font-size: 12px;
|
|
1254
|
+
line-height: 18px;
|
|
1255
|
+
color: var(--dsw-alias-label-tertiary);
|
|
1256
|
+
}
|
|
1257
|
+
.dsh-coding-error {
|
|
1258
|
+
margin: 0;
|
|
1259
|
+
font-size: 12px;
|
|
1260
|
+
line-height: 18px;
|
|
1261
|
+
color: var(--dsw-alias-state-error-primary);
|
|
1262
|
+
}
|
|
1263
|
+
.dsh-coding-actions {
|
|
1264
|
+
display: flex;
|
|
1265
|
+
flex-wrap: wrap;
|
|
1266
|
+
gap: 6px;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/* One coding command receipt: the line, then its own text. */
|
|
1270
|
+
.dsh-coding-command {
|
|
1271
|
+
display: flex;
|
|
1272
|
+
flex-direction: column;
|
|
1273
|
+
gap: 2px;
|
|
1274
|
+
margin: 0;
|
|
1275
|
+
font-size: 12px;
|
|
1276
|
+
line-height: 18px;
|
|
1277
|
+
}
|
|
1278
|
+
.dsh-coding-command .dsh-coding-value,
|
|
1279
|
+
.dsh-coding-command .dsh-coding-error {
|
|
1280
|
+
white-space: pre-wrap;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/* First-message mode picker: the same status-row type as the card. */
|
|
1284
|
+
.dsh-coding-picker {
|
|
1285
|
+
display: flex;
|
|
1286
|
+
flex-wrap: wrap;
|
|
1287
|
+
align-items: center;
|
|
1288
|
+
gap: 6px;
|
|
1289
|
+
font-size: 12px;
|
|
1290
|
+
line-height: 18px;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/* Button: the shipped secondary-button recipe. */
|
|
1294
|
+
.dsh-coding-button {
|
|
1295
|
+
box-sizing: border-box;
|
|
1296
|
+
height: 28px;
|
|
1297
|
+
padding: 4px 8px;
|
|
1298
|
+
border: 0.5px solid var(--dsw-alias-border-l3);
|
|
1299
|
+
border-radius: var(--dsw-radius-sm);
|
|
1300
|
+
background: var(--dsw-alias-button-floating-fill);
|
|
1301
|
+
color: var(--dsw-alias-label-secondary);
|
|
1302
|
+
font: inherit;
|
|
1303
|
+
font-size: 12px;
|
|
1304
|
+
line-height: 18px;
|
|
1305
|
+
cursor: pointer;
|
|
1306
|
+
transition: background-color 0.12s, color 0.12s;
|
|
1307
|
+
}
|
|
1308
|
+
@media (hover: hover) {
|
|
1309
|
+
.dsh-coding-button:hover:not(:disabled) {
|
|
1310
|
+
color: var(--dsw-alias-label-primary);
|
|
1311
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
.dsh-coding-button[aria-pressed="true"] {
|
|
1315
|
+
border-color: var(--dsw-alias-state-business-primary);
|
|
1316
|
+
background: var(--dsw-alias-state-business-tertiary);
|
|
1317
|
+
color: var(--dsw-alias-state-business-primary);
|
|
1318
|
+
}
|
|
1319
|
+
.dsh-coding-button:focus-visible {
|
|
1320
|
+
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
|
1321
|
+
outline-offset: 2px;
|
|
1322
|
+
}
|
|
1323
|
+
.dsh-coding-button:disabled {
|
|
1324
|
+
opacity: 0.6;
|
|
1325
|
+
cursor: default;
|
|
1326
|
+
}
|
|
1327
|
+
/* The page's primary action: one step up from the card's compact button. */
|
|
1328
|
+
.dsh-coding-button-lg {
|
|
1329
|
+
height: 40px;
|
|
1330
|
+
padding: 8px 20px;
|
|
1331
|
+
border-radius: var(--dsw-radius-md);
|
|
1332
|
+
font-size: 14px;
|
|
1333
|
+
line-height: 20px;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/* Stage path: plain text at the shipped caption size, never a chip. */
|
|
1337
|
+
.dsh-coding-stage {
|
|
1338
|
+
font-size: 12px;
|
|
1339
|
+
line-height: 18px;
|
|
1340
|
+
color: var(--dsw-alias-label-tertiary);
|
|
1341
|
+
}
|
|
1342
|
+
.dsh-coding-stage[data-current="true"] {
|
|
1343
|
+
color: var(--dsw-alias-label-primary);
|
|
1344
|
+
font-weight: 500;
|
|
1345
|
+
}
|
|
1346
|
+
.dsh-coding-stage[data-done="true"] {
|
|
1347
|
+
color: var(--dsw-alias-label-secondary);
|
|
1348
|
+
}
|
|
1349
|
+
.dsh-coding-arrow {
|
|
1350
|
+
font-size: 12px;
|
|
1351
|
+
line-height: 18px;
|
|
1352
|
+
color: var(--dsw-alias-label-caption);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/* Capsule: one status line in the transcript, same type as the rows around it. */
|
|
1356
|
+
.dsh-coding-capsule {
|
|
1357
|
+
display: flex;
|
|
1358
|
+
flex-wrap: wrap;
|
|
1359
|
+
align-items: baseline;
|
|
1360
|
+
gap: 6px;
|
|
1361
|
+
padding: 2px 0;
|
|
1362
|
+
font: inherit;
|
|
1363
|
+
font-size: 12px;
|
|
1364
|
+
line-height: 18px;
|
|
1365
|
+
color: var(--dsw-alias-label-secondary);
|
|
1366
|
+
}
|
|
1367
|
+
.dsh-coding-capsule .dsh-coding-stage,
|
|
1368
|
+
.dsh-coding-capsule .dsh-coding-arrow,
|
|
1369
|
+
.dsh-coding-capsule .dsh-coding-muted,
|
|
1370
|
+
.dsh-coding-capsule .dsh-coding-faint,
|
|
1371
|
+
.dsh-coding-capsule .dsh-coding-success,
|
|
1372
|
+
.dsh-coding-capsule .dsh-coding-warn {
|
|
1373
|
+
font-size: inherit;
|
|
1374
|
+
line-height: inherit;
|
|
1375
|
+
}
|
|
1376
|
+
/* Color utilities also state the type role, so a bare span never inherits a
|
|
1377
|
+
different size from its container. */
|
|
1378
|
+
.dsh-coding-muted,
|
|
1379
|
+
.dsh-coding-faint,
|
|
1380
|
+
.dsh-coding-success,
|
|
1381
|
+
.dsh-coding-warn {
|
|
1382
|
+
font-size: 12px;
|
|
1383
|
+
line-height: 18px;
|
|
1384
|
+
}
|
|
1385
|
+
.dsh-coding-muted { color: var(--dsw-alias-label-secondary); }
|
|
1386
|
+
.dsh-coding-faint { color: var(--dsw-alias-label-tertiary); }
|
|
1387
|
+
/* The raw success token is a saturated green-500; at 12px on the card it reads
|
|
1388
|
+
too bright. Mixing in the theme's own label color keeps it green while giving
|
|
1389
|
+
light themes a deeper shade and dark themes a slightly lighter one. */
|
|
1390
|
+
.dsh-coding-success {
|
|
1391
|
+
color: color-mix(in srgb, var(--dsw-alias-state-success-primary) 72%, var(--dsw-alias-label-primary));
|
|
1392
|
+
}
|
|
1393
|
+
.dsh-coding-warn { color: var(--dsw-alias-state-warn-primary); }
|
|
1394
|
+
|
|
1395
|
+
/* Configuration page: shipped field and control recipes. */
|
|
1396
|
+
.dsh-coding-form {
|
|
1397
|
+
display: flex;
|
|
1398
|
+
flex-direction: column;
|
|
1399
|
+
gap: 16px;
|
|
1400
|
+
padding: 4px 0;
|
|
1401
|
+
font: inherit;
|
|
1402
|
+
}
|
|
1403
|
+
.dsh-coding-field {
|
|
1404
|
+
display: flex;
|
|
1405
|
+
flex-direction: column;
|
|
1406
|
+
gap: 6px;
|
|
1407
|
+
}
|
|
1408
|
+
.dsh-coding-field > label {
|
|
1409
|
+
font-size: 13px;
|
|
1410
|
+
line-height: 20px;
|
|
1411
|
+
color: var(--dsw-alias-label-primary);
|
|
1412
|
+
}
|
|
1413
|
+
.dsh-coding-field > .dsh-coding-hint {
|
|
1414
|
+
font-size: 12px;
|
|
1415
|
+
line-height: 18px;
|
|
1416
|
+
}
|
|
1417
|
+
.dsh-coding-input {
|
|
1418
|
+
box-sizing: border-box;
|
|
1419
|
+
width: 100%;
|
|
1420
|
+
height: 40px;
|
|
1421
|
+
padding: 0 14px;
|
|
1422
|
+
border: 0.5px solid var(--dsw-alias-border-l4);
|
|
1423
|
+
border-radius: var(--dsw-radius-md);
|
|
1424
|
+
outline: none;
|
|
1425
|
+
background: var(--dsw-alias-bg-layer-3);
|
|
1426
|
+
font: inherit;
|
|
1427
|
+
font-size: 13px;
|
|
1428
|
+
color: var(--dsw-alias-label-primary);
|
|
1429
|
+
}
|
|
1430
|
+
.dsh-coding-input:focus {
|
|
1431
|
+
border-color: var(--dsw-alias-state-business-primary);
|
|
1432
|
+
box-shadow: inset 0 0 0 0.5px var(--dsw-alias-state-business-primary);
|
|
1433
|
+
}
|
|
1434
|
+
.dsh-coding-input-warn {
|
|
1435
|
+
border-color: var(--dsw-alias-state-warn-primary);
|
|
1436
|
+
box-shadow: inset 0 0 0 0.5px var(--dsw-alias-state-warn-primary);
|
|
1437
|
+
}
|
|
1438
|
+
.dsh-coding-notice { margin: 0; font-size: 12px; line-height: 18px; }
|
|
1439
|
+
.dsh-coding-notice-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
1440
|
+
.dsh-coding-mono {
|
|
1441
|
+
font-family: var(--ds-font-family-code);
|
|
1442
|
+
font-size: 12px;
|
|
1443
|
+
line-height: 18px;
|
|
1444
|
+
color: var(--dsw-alias-label-secondary);
|
|
1445
|
+
white-space: pre-wrap;
|
|
1446
|
+
}
|
|
1447
|
+
.dsh-coding-footer {
|
|
1448
|
+
display: flex;
|
|
1449
|
+
flex-wrap: wrap;
|
|
1450
|
+
align-items: center;
|
|
1451
|
+
gap: 10px;
|
|
1452
|
+
}
|
|
1453
|
+
`;
|
|
1454
|
+
function installStyles() {
|
|
1455
|
+
if (typeof document === "undefined") return () => {
|
|
1456
|
+
};
|
|
1457
|
+
document.querySelector(`style[data-plugin-css=${JSON.stringify(STYLE_ID)}]`)?.remove();
|
|
1458
|
+
const tag = document.createElement("style");
|
|
1459
|
+
tag.dataset.plugin = PLUGIN_ID;
|
|
1460
|
+
tag.dataset.pluginCss = STYLE_ID;
|
|
1461
|
+
tag.textContent = CSS;
|
|
1462
|
+
document.head.append(tag);
|
|
1463
|
+
return () => {
|
|
1464
|
+
tag.remove();
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/client/locales.ts
|
|
1469
|
+
var en = {
|
|
1470
|
+
aria: "Coding runtime stage",
|
|
1471
|
+
"hint.mode": "Switch mode with /coding auto, /coding consult, /coding review, or /coding codex",
|
|
1472
|
+
"picker.label": "Mode",
|
|
1473
|
+
"picker.aria": "Coding mode for the first message",
|
|
1474
|
+
"mode.consult": "Q&A",
|
|
1475
|
+
"mode.review": "Review",
|
|
1476
|
+
"mode.auto": "Auto",
|
|
1477
|
+
"mode.codex": "Codex",
|
|
1478
|
+
"stage.requirements": "Requirements",
|
|
1479
|
+
"stage.plan": "Plan",
|
|
1480
|
+
"stage.implement": "Implement",
|
|
1481
|
+
"stage.verify": "Verify",
|
|
1482
|
+
"stage.deliver": "Deliver",
|
|
1483
|
+
"verification.none": "not verified",
|
|
1484
|
+
"verification.passed": "verified",
|
|
1485
|
+
"verification.failed": "verification failed",
|
|
1486
|
+
"plan.none": "no task list",
|
|
1487
|
+
"plan.progress": "{done}/{total} plan steps",
|
|
1488
|
+
"worker.running": "{role} worker running",
|
|
1489
|
+
"worker.completed": "{role} worker done",
|
|
1490
|
+
"worker.failed": "{role} worker failed",
|
|
1491
|
+
pending: "running {tool}",
|
|
1492
|
+
refused: "advance refused",
|
|
1493
|
+
files: "{count} files changed",
|
|
1494
|
+
"card.mode": "Mode",
|
|
1495
|
+
"card.stage": "Stage",
|
|
1496
|
+
"card.verify": "Verification",
|
|
1497
|
+
"card.stageHint": "Edit with /coding stage <stage>",
|
|
1498
|
+
"card.switchFailed": "The mode was not changed. Try /coding <mode>.",
|
|
1499
|
+
"card.stale": "history",
|
|
1500
|
+
"card.reasoning": "Reasoning",
|
|
1501
|
+
"reasoning.pending": "pending",
|
|
1502
|
+
"reasoning.sourceAuto": "automatic",
|
|
1503
|
+
"reasoning.sourceOverride": "session override",
|
|
1504
|
+
"reasoning.sourcePick": "chat-box pick",
|
|
1505
|
+
"reasoning.sourceSettings": "pinned by settings",
|
|
1506
|
+
"config.title": "Coding runtime",
|
|
1507
|
+
"config.hint": "These values are validated when saved and used by every later stage decision and worker dispatch.",
|
|
1508
|
+
"config.mode": "Default mode",
|
|
1509
|
+
"config.modeHint": "Mode a new Coding session starts in; auto chooses the workflow during the requirements stage.",
|
|
1510
|
+
"config.implementModel": "Implement worker model",
|
|
1511
|
+
"config.implementModelHint": "Required provider/model route. Never inherited from the lead.",
|
|
1512
|
+
"config.plannerModel": "Planner worker model",
|
|
1513
|
+
"config.plannerModelHint": "Required provider/model route for the pro planner; it plans, it never edits.",
|
|
1514
|
+
"config.verifyModel": "Verify worker model",
|
|
1515
|
+
"config.verifyModelHint": "Required provider/model route for the read-only verify worker.",
|
|
1516
|
+
"config.language": "Conversation language",
|
|
1517
|
+
"config.languageHint": "Auto follows the DSH interface, then the host locale. Only Chinese and English ship.",
|
|
1518
|
+
"config.languageAuto": "Automatic (follow DSH)",
|
|
1519
|
+
"config.reasoning": "Reasoning level",
|
|
1520
|
+
"config.reasoningHint": "Auto classifies each turn from the request; low, high, or max pins every turn. A chat-box effort pick or coding_reasoning overrides automatic only.",
|
|
1521
|
+
"config.reasoningAuto": "Automatic (recommended)",
|
|
1522
|
+
"config.verification": "Verification",
|
|
1523
|
+
"config.verificationHint": "The verify stage runs these checks; the deliver gate needs a passing result.",
|
|
1524
|
+
"config.commands": "Verification command overrides",
|
|
1525
|
+
"config.commandsHint": "Keyed by kind or kind:scope. Edit them in the bundle patch configuration.",
|
|
1526
|
+
"config.save": "Save",
|
|
1527
|
+
"config.saving": "Saving\u2026",
|
|
1528
|
+
"config.saved": "Saved.",
|
|
1529
|
+
"config.saveFailed": "The configuration was rejected. Check the values and Host authorization.",
|
|
1530
|
+
"config.invalidRoute": "Use provider/model, for example deepseek-account/deepseek-flash.",
|
|
1531
|
+
"config.readOnly": "This deployment stores settings read-only.",
|
|
1532
|
+
"config.loading": "Loading configuration\u2026",
|
|
1533
|
+
"config.unavailable": "This Host does not expose the configuration form for this entry.",
|
|
1534
|
+
"config.reset": "Restore defaults",
|
|
1535
|
+
"config.presetWarning": "Keep every plugin of the Coding preset enabled, or this plugin cannot work.",
|
|
1536
|
+
"config.modelWarning": "Select the worker models carefully. An invalid choice is highlighted and disables Save.",
|
|
1537
|
+
"config.modelsLoading": "Loading models\u2026",
|
|
1538
|
+
"config.modelsUnavailable": "Could not load the configured model list:",
|
|
1539
|
+
"config.modelsRetry": "Reload models",
|
|
1540
|
+
"config.modelPlaceholder": "Select a model",
|
|
1541
|
+
"config.modelMissing": "not in the current model list"
|
|
1542
|
+
};
|
|
1543
|
+
var zh = {
|
|
1544
|
+
aria: "Coding \u8FD0\u884C\u65F6\u9636\u6BB5",
|
|
1545
|
+
"hint.mode": "\u7528 /coding auto\u3001/coding consult\u3001/coding review\u3001/coding codex \u5207\u6362\u6A21\u5F0F",
|
|
1546
|
+
"picker.label": "\u5DE5\u4F5C\u6A21\u5F0F",
|
|
1547
|
+
"picker.aria": "\u9996\u6761\u6D88\u606F\u7684\u5DE5\u4F5C\u6A21\u5F0F",
|
|
1548
|
+
"mode.consult": "\u95EE\u7B54",
|
|
1549
|
+
"mode.review": "\u5BA1\u67E5",
|
|
1550
|
+
"mode.auto": "\u81EA\u52A8",
|
|
1551
|
+
"mode.codex": "Codex",
|
|
1552
|
+
"stage.requirements": "\u9700\u6C42\u5206\u6790",
|
|
1553
|
+
"stage.plan": "\u89C4\u5212",
|
|
1554
|
+
"stage.implement": "\u5B9E\u73B0",
|
|
1555
|
+
"stage.verify": "\u9A8C\u8BC1",
|
|
1556
|
+
"stage.deliver": "\u4EA4\u4ED8",
|
|
1557
|
+
"verification.none": "\u672A\u9A8C\u8BC1",
|
|
1558
|
+
"verification.passed": "\u5DF2\u9A8C\u8BC1",
|
|
1559
|
+
"verification.failed": "\u9A8C\u8BC1\u5931\u8D25",
|
|
1560
|
+
"plan.none": "\u65E0\u4EFB\u52A1\u5355",
|
|
1561
|
+
"plan.progress": "\u4EFB\u52A1 {done}/{total}",
|
|
1562
|
+
"worker.running": "{role} \u5B50\u4EE3\u7406\u8FD0\u884C\u4E2D",
|
|
1563
|
+
"worker.completed": "{role} \u5B50\u4EE3\u7406\u5B8C\u6210",
|
|
1564
|
+
"worker.failed": "{role} \u5B50\u4EE3\u7406\u5931\u8D25",
|
|
1565
|
+
pending: "\u6B63\u5728\u6267\u884C {tool}",
|
|
1566
|
+
refused: "\u9636\u6BB5\u63A8\u8FDB\u88AB\u62D2\u7EDD",
|
|
1567
|
+
files: "\u5DF2\u6539 {count} \u4E2A\u6587\u4EF6",
|
|
1568
|
+
"card.mode": "\u6A21\u5F0F",
|
|
1569
|
+
"card.stage": "\u9636\u6BB5",
|
|
1570
|
+
"card.verify": "\u9A8C\u8BC1",
|
|
1571
|
+
"card.stageHint": "\u7528 /coding stage <\u9636\u6BB5> \u8C03\u6574",
|
|
1572
|
+
"card.switchFailed": "\u6A21\u5F0F\u672A\u5207\u6362\u6210\u529F\uFF0C\u8BF7\u91CD\u8BD5\u6216\u76F4\u63A5\u6267\u884C /coding <\u6A21\u5F0F>\u3002",
|
|
1573
|
+
"card.stale": "\u5386\u53F2",
|
|
1574
|
+
"card.reasoning": "\u63A8\u7406",
|
|
1575
|
+
"reasoning.pending": "\u5F85\u786E\u5B9A",
|
|
1576
|
+
"reasoning.sourceAuto": "\u81EA\u52A8",
|
|
1577
|
+
"reasoning.sourceOverride": "\u4F1A\u8BDD\u8986\u76D6",
|
|
1578
|
+
"reasoning.sourcePick": "\u5BF9\u8BDD\u6846\u9009\u62E9",
|
|
1579
|
+
"reasoning.sourceSettings": "\u8BBE\u7F6E\u56FA\u5B9A",
|
|
1580
|
+
"config.title": "Coding \u8FD0\u884C\u65F6",
|
|
1581
|
+
"config.hint": "\u4FDD\u5B58\u540E\u7ACB\u5373\u6821\u9A8C\uFF1B\u540E\u7EED\u6BCF\u6B21\u9636\u6BB5\u5224\u5B9A\u4E0E\u5B50\u4EE3\u7406\u6D3E\u53D1\u90FD\u4F1A\u4F7F\u7528\u65B0\u503C\u3002",
|
|
1582
|
+
"config.mode": "\u9ED8\u8BA4\u6A21\u5F0F",
|
|
1583
|
+
"config.modeHint": "\u65B0\u5EFA Coding \u4F1A\u8BDD\u7684\u521D\u59CB\u6A21\u5F0F\uFF1B\u81EA\u52A8\u6A21\u5F0F\u5728\u9700\u6C42\u5206\u6790\u9636\u6BB5\u9009\u62E9\u5DE5\u4F5C\u6D41\u3002",
|
|
1584
|
+
"config.implementModel": "\u5B9E\u73B0 worker \u6A21\u578B",
|
|
1585
|
+
"config.implementModelHint": "\u5FC5\u586B provider/model \u8DEF\u7531\uFF0C\u4E0D\u4F1A\u7EE7\u627F\u4E3B\u4EE3\u7406\u6A21\u578B\u3002",
|
|
1586
|
+
"config.plannerModel": "\u89C4\u5212 worker \u6A21\u578B\uFF08pro\uFF09",
|
|
1587
|
+
"config.plannerModelHint": "pro \u89C4\u5212 worker \u7684\u5FC5\u586B provider/model \u8DEF\u7531\uFF1B\u53EA\u505A\u89C4\u5212\uFF0C\u4E0D\u6539\u6587\u4EF6\u3002",
|
|
1588
|
+
"config.verifyModel": "\u9A8C\u8BC1 worker \u6A21\u578B",
|
|
1589
|
+
"config.verifyModelHint": "\u53EA\u8BFB\u9A8C\u8BC1 worker \u7684\u5FC5\u586B provider/model \u8DEF\u7531\u3002",
|
|
1590
|
+
"config.language": "\u4F1A\u8BDD\u8BED\u8A00",
|
|
1591
|
+
"config.languageHint": "\u81EA\u52A8\u6A21\u5F0F\u5148\u8DDF\u968F DSH \u754C\u9762\u8BED\u8A00\uFF0C\u518D\u8DDF\u968F\u5BBF\u4E3B\u73AF\u5883\u8BED\u8A00\uFF1B\u63D2\u4EF6\u53EA\u5E26\u4E2D\u6587\u548C\u82F1\u6587\u3002",
|
|
1592
|
+
"config.languageAuto": "\u81EA\u52A8\uFF08\u8DDF\u968F DSH\uFF09",
|
|
1593
|
+
"config.reasoning": "\u63A8\u7406\u7B49\u7EA7",
|
|
1594
|
+
"config.reasoningHint": "\u81EA\u52A8\u4F1A\u6309\u6BCF\u8F6E\u8BF7\u6C42\u5206\u7C7B\uFF1Blow/high/max \u56FA\u5B9A\u6240\u6709\u8F6E\u6B21\u3002\u804A\u5929\u6846\u9009\u62E9 effort \u6216 coding_reasoning \u53EA\u5728\u81EA\u52A8\u65F6\u751F\u6548\u3002",
|
|
1595
|
+
"config.reasoningAuto": "\u81EA\u52A8\uFF08\u63A8\u8350\uFF09",
|
|
1596
|
+
"config.verification": "\u9A8C\u8BC1\u95E8\u7981",
|
|
1597
|
+
"config.verificationHint": "\u9A8C\u8BC1\u9636\u6BB5\u8FD0\u884C\u8FD9\u4E9B\u68C0\u67E5\uFF1B\u4EA4\u4ED8\u95E8\u7981\u8981\u6C42\u4E00\u6B21\u901A\u8FC7\u7684\u7ED3\u679C\u3002",
|
|
1598
|
+
"config.commands": "\u9A8C\u8BC1\u547D\u4EE4\u8986\u76D6",
|
|
1599
|
+
"config.commandsHint": "\u6309 kind \u6216 kind:scope \u6307\u5B9A\uFF1B\u9700\u5728\u63D2\u4EF6\u5305\u914D\u7F6E\u4E2D\u4FEE\u6539\u3002",
|
|
1600
|
+
"config.save": "\u4FDD\u5B58",
|
|
1601
|
+
"config.saving": "\u4FDD\u5B58\u4E2D\u2026",
|
|
1602
|
+
"config.saved": "\u5DF2\u4FDD\u5B58\u3002",
|
|
1603
|
+
"config.saveFailed": "\u914D\u7F6E\u88AB\u62D2\u7EDD\uFF0C\u8BF7\u68C0\u67E5\u53D6\u503C\u4E0E Host \u6388\u6743\u3002",
|
|
1604
|
+
"config.invalidRoute": "\u8BF7\u586B\u5199 provider/model\uFF0C\u4F8B\u5982 deepseek-account/deepseek-flash\u3002",
|
|
1605
|
+
"config.readOnly": "\u5F53\u524D\u90E8\u7F72\u7684\u8BBE\u7F6E\u662F\u53EA\u8BFB\u7684\u3002",
|
|
1606
|
+
"config.loading": "\u6B63\u5728\u52A0\u8F7D\u914D\u7F6E\u2026",
|
|
1607
|
+
"config.unavailable": "\u5F53\u524D Host \u672A\u4E3A\u6B64\u63D2\u4EF6\u6761\u76EE\u63D0\u4F9B\u914D\u7F6E\u8868\u5355\u3002",
|
|
1608
|
+
"config.reset": "\u6062\u590D\u9ED8\u8BA4",
|
|
1609
|
+
"config.presetWarning": "\u8BF7\u4FDD\u6301 Coding \u9884\u8BBE\u5168\u90E8\u5F00\u542F\u72B6\u6001\uFF0C\u5426\u5219\u672C\u63D2\u4EF6\u65E0\u6CD5\u5DE5\u4F5C\u3002",
|
|
1610
|
+
"config.modelWarning": "\u8BF7\u6B63\u786E\u52FE\u9009\u5B50\u4EFB\u52A1\u667A\u80FD\u4F53\u6A21\u578B\uFF0C\u5982\u679C\u586B\u5199\u9519\u8BEF\u6216\u9009\u62E9\u9519\u8BEF\u5C31\u7528\u8B66\u544A\u8272\u8FDB\u884C\u63D0\u793A\uFF08\u7981\u7528\u4FDD\u5B58\u6309\u94AE\uFF09\u3002",
|
|
1611
|
+
"config.modelsLoading": "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u5217\u8868\u2026",
|
|
1612
|
+
"config.modelsUnavailable": "\u65E0\u6CD5\u52A0\u8F7D\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u5217\u8868\uFF1A",
|
|
1613
|
+
"config.modelsRetry": "\u91CD\u65B0\u52A0\u8F7D\u6A21\u578B",
|
|
1614
|
+
"config.modelPlaceholder": "\u8BF7\u9009\u62E9\u6A21\u578B",
|
|
1615
|
+
"config.modelMissing": "\u4E0D\u5728\u5F53\u524D\u6A21\u578B\u5217\u8868"
|
|
1616
|
+
};
|
|
1617
|
+
|
|
1618
|
+
// src/client/index.ts
|
|
1619
|
+
var NS = "dsh-coding";
|
|
1620
|
+
var PACKAGE_NAME = "dsh-coding";
|
|
1621
|
+
var inject = ["slots", "locale", "uiConversation", "configForms", "remote", "remote.commands", "remote.llm"];
|
|
1622
|
+
function apply(ctx) {
|
|
1623
|
+
const translate = ctx.locale.bind(NS);
|
|
1624
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-coding: dictionaries");
|
|
1625
|
+
ctx.effect(() => installStyles(), "dsh-coding: styles");
|
|
1626
|
+
const runCommand = (sessionId, line) => {
|
|
1627
|
+
const commands = ctx.remote?.commands;
|
|
1628
|
+
if (typeof commands?.execute !== "function" || typeof sessionId !== "string") return void 0;
|
|
1629
|
+
return commands.execute(sessionId, line, []);
|
|
1630
|
+
};
|
|
1631
|
+
const forms = ctx.configForms;
|
|
1632
|
+
const form = forms.get(SETTINGS_NAMESPACE);
|
|
1633
|
+
const llmRemote = ctx.remote?.llm;
|
|
1634
|
+
const settingsValue = () => {
|
|
1635
|
+
try {
|
|
1636
|
+
return form?.getSnapshot?.()?.value?.reasoning;
|
|
1637
|
+
} catch {
|
|
1638
|
+
return void 0;
|
|
1639
|
+
}
|
|
1640
|
+
};
|
|
1641
|
+
const turnCard = (props) => (0, import_react6.createElement)(CodingTurnCard, {
|
|
1642
|
+
...props,
|
|
1643
|
+
t: props.t ?? translate,
|
|
1644
|
+
execute: (line) => runCommand(props.sessionId, line),
|
|
1645
|
+
settings: settingsValue
|
|
1646
|
+
});
|
|
1647
|
+
const slots = ctx.slots;
|
|
1648
|
+
ctx.effect(() => slots.inject("conversation.chat.turnTail", () => slots.register({
|
|
1649
|
+
name: "conversation.chat.turnTail",
|
|
1650
|
+
id: "dsh-coding/turn-card",
|
|
1651
|
+
order: 50,
|
|
1652
|
+
locale: NS
|
|
1653
|
+
}, turnCard)), "dsh-coding: turn card");
|
|
1654
|
+
const modePicker = (props) => (0, import_react6.createElement)(CodingModePicker, {
|
|
1655
|
+
...props,
|
|
1656
|
+
t: props.t ?? translate,
|
|
1657
|
+
execute: (line) => runCommand(props.sessionId, line)
|
|
1658
|
+
});
|
|
1659
|
+
ctx.effect(() => slots.inject("conversation.hero.options", () => slots.register({
|
|
1660
|
+
name: "conversation.hero.options",
|
|
1661
|
+
id: "dsh-coding/mode-picker",
|
|
1662
|
+
order: 20,
|
|
1663
|
+
locale: NS
|
|
1664
|
+
}, modePicker)), "dsh-coding: mode picker");
|
|
1665
|
+
ctx.effect(() => ctx.uiConversation.events.register(capsuleDefinition), "dsh-coding: capsule definition");
|
|
1666
|
+
ctx.effect(() => slots.inject("conversation.chat.node", () => slots.register({
|
|
1667
|
+
name: "conversation.chat.node",
|
|
1668
|
+
key: CAPSULE_KIND,
|
|
1669
|
+
locale: NS
|
|
1670
|
+
}, CodingStageCapsule)), "dsh-coding: capsule node");
|
|
1671
|
+
ctx.effect(() => slots.inject("conversation.chat.commandview", () => slots.register({
|
|
1672
|
+
name: "conversation.chat.commandview",
|
|
1673
|
+
key: "coding",
|
|
1674
|
+
locale: NS
|
|
1675
|
+
}, CodingCommandRow)), "dsh-coding: command row");
|
|
1676
|
+
const configPage = (props) => (0, import_react6.createElement)(CodingConfigPage, {
|
|
1677
|
+
...props,
|
|
1678
|
+
form,
|
|
1679
|
+
remote: llmRemote,
|
|
1680
|
+
t: props.t ?? translate
|
|
1681
|
+
});
|
|
1682
|
+
ctx.effect(() => slots.inject("plugins.bundle.config", () => slots.register({
|
|
1683
|
+
name: "plugins.bundle.config",
|
|
1684
|
+
key: PACKAGE_NAME,
|
|
1685
|
+
locale: NS
|
|
1686
|
+
}, configPage)), "dsh-coding: configuration page");
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
return module.exports;
|
|
1690
|
+
},
|
|
1691
|
+
});
|