dsh-coding 0.1.1-rc1 → 0.1.1-rc2
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/AGENTS.md +80 -0
- package/LICENSE +21 -21
- package/README.md +96 -37
- package/cordis.patch.yml +51 -8
- package/docs/CHANGELOG.md +47 -0
- package/docs/DETAIL.md +143 -54
- package/icon.svg +6 -6
- package/lib/client/card.js +92 -4
- package/lib/client/locales.js +14 -0
- package/lib/client/styles.js +240 -240
- package/lib/client.js +114 -3
- package/lib/config.js +14 -0
- package/lib/contract.js +20 -6
- package/lib/handoff.js +37 -2
- package/lib/index.js +3 -2
- package/lib/memory.js +336 -0
- package/lib/preset.js +75 -11
- package/lib/stages.js +45 -7
- package/lib/state.js +40 -5
- package/lib/types/client/card.d.ts +5 -1
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config.d.ts +15 -0
- package/lib/types/handoff.d.ts +20 -0
- package/lib/types/index.d.ts +8 -2
- package/lib/types/memory.d.ts +71 -0
- package/lib/types/stages.d.ts +29 -0
- package/lib/types/state.d.ts +14 -2
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +3 -2
- package/docs/DEVELOPMENT.md +0 -189
package/lib/state.js
CHANGED
|
@@ -74,20 +74,40 @@ export function restoreFromView(state, view) {
|
|
|
74
74
|
state.verifyBlocked = checkpoint.verifyBlocked;
|
|
75
75
|
if (checkpoint.worker !== undefined)
|
|
76
76
|
state.worker = checkpoint.worker;
|
|
77
|
+
if (checkpoint.planner !== undefined)
|
|
78
|
+
state.planner = checkpoint.planner;
|
|
77
79
|
state.updatedAt = Math.max(checkpoint.updatedAt, view.updatedAt);
|
|
78
80
|
}
|
|
79
81
|
/** Stage at which this mode's own gates can be satisfied, one line. */
|
|
80
82
|
export function stageGuidance(mode) {
|
|
81
83
|
return `stages: ${stagePath(mode)}`;
|
|
82
84
|
}
|
|
85
|
+
/** 强制 planner 的任务单阈值:严格大于三条即为“复杂任务”。 */
|
|
86
|
+
export const PLANNER_TODO_THRESHOLD = 3;
|
|
87
|
+
/**
|
|
88
|
+
* 是否需要先派发 planner:仅 codex、任务单超过阈值、还没有尝试过、且主 Agent
|
|
89
|
+
* 自身不是 planner 路由;配置关闭时永不要求。
|
|
90
|
+
*/
|
|
91
|
+
function plannerGateOpen(state, options) {
|
|
92
|
+
if (state.mode !== 'codex')
|
|
93
|
+
return false;
|
|
94
|
+
if (options.plannerGate === false)
|
|
95
|
+
return false;
|
|
96
|
+
if (options.leadIsPlanner === true)
|
|
97
|
+
return false;
|
|
98
|
+
if (state.planner !== undefined)
|
|
99
|
+
return false;
|
|
100
|
+
return (state.plan?.items.length ?? 0) > PLANNER_TODO_THRESHOLD;
|
|
101
|
+
}
|
|
83
102
|
/**
|
|
84
103
|
* Decide whether the model may move to `target` now. Conditions are checked by
|
|
85
104
|
* plugin code, never taken from the model's assertion.
|
|
86
105
|
* @param state - live session state.
|
|
87
106
|
* @param target - requested stage.
|
|
107
|
+
* @param options - 调用方提供的运行时事实(主 Agent 是否即 planner 路由、门禁是否开启)。
|
|
88
108
|
* @returns whether the move is allowed, and why not when it is refused.
|
|
89
109
|
*/
|
|
90
|
-
export function checkAdvance(state, target) {
|
|
110
|
+
export function checkAdvance(state, target, options = {}) {
|
|
91
111
|
if (!stageInMode(state.mode, target)) {
|
|
92
112
|
if (state.mode === 'auto') {
|
|
93
113
|
return {
|
|
@@ -123,8 +143,20 @@ export function checkAdvance(state, target) {
|
|
|
123
143
|
if (target === 'implement' && (state.plan === undefined || state.plan.items.length === 0)) {
|
|
124
144
|
return {
|
|
125
145
|
ok: false,
|
|
126
|
-
reason: 'no structured task list yet: call todo_write with 3
|
|
127
|
-
+ 'then advance to implement.',
|
|
146
|
+
reason: 'no structured task list yet: call todo_write with 1-3 verifiable steps for a small single-file change, '
|
|
147
|
+
+ 'or 4-6 for a multi-file change (exactly one in_progress), then advance to implement.',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// 可机器验证的复杂度判据只有一条:任务单超过三条。这个规模在 codex 下必须
|
|
151
|
+
// 先让 planner worker(pro 模型)勘探并拆分任务;派发失败也算尝试。
|
|
152
|
+
if (target === 'implement' && plannerGateOpen(state, options)) {
|
|
153
|
+
const items = state.plan?.items.length ?? 0;
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
reason: `the task list has ${items} items, which is complex enough to plan with the planner worker: `
|
|
157
|
+
+ 'call delegate_plan in the plan stage (pro model) first, then write the task list from its sub-tasks. '
|
|
158
|
+
+ 'A dispatch that fails still opens this gate, so fix the route and retry once. '
|
|
159
|
+
+ 'A small single-file change needs three items or fewer and skips this gate.',
|
|
128
160
|
};
|
|
129
161
|
}
|
|
130
162
|
// In codex mode verification follows an applied edit; in review mode the
|
|
@@ -393,8 +425,8 @@ function remedy(stage, kind, mode) {
|
|
|
393
425
|
if (kind === 'verify') {
|
|
394
426
|
return 'Verification runs in the verify stage: advance with coding_stage, then call run_verification.';
|
|
395
427
|
}
|
|
396
|
-
if (kind === 'exec' &&
|
|
397
|
-
return '
|
|
428
|
+
if (kind === 'exec' && stage === 'deliver') {
|
|
429
|
+
return 'Delivery reports the run; it does not execute commands. Run checks in the verify stage with run_verification.';
|
|
398
430
|
}
|
|
399
431
|
if (kind === 'read' && mode === 'consult') {
|
|
400
432
|
return 'Consult mode answers from inspection only; keep reading, or advance to deliver.';
|
|
@@ -455,6 +487,7 @@ export function statusLine(state) {
|
|
|
455
487
|
const handoff = `handoff goal=${goalRecorded(state) ? 'set' : 'missing'}, `
|
|
456
488
|
+ `acceptance=${state.handoff?.acceptance.length ?? 0}`;
|
|
457
489
|
const worker = state.worker === undefined ? undefined : `${state.worker.role}-worker ${state.worker.status}`;
|
|
490
|
+
const planner = state.planner === undefined ? undefined : `planner ${state.planner.outcome}`;
|
|
458
491
|
return [
|
|
459
492
|
`stage ${state.stage} of ${stagePath(state.mode)}; mode ${state.mode}`,
|
|
460
493
|
`plan ${plan}`,
|
|
@@ -464,6 +497,7 @@ export function statusLine(state) {
|
|
|
464
497
|
...state.stage === 'deliver' && state.deliveryBlocked ? ['delivery BLOCKED'] : [],
|
|
465
498
|
...state.failure === undefined ? [] : [`failure ${state.failure.point}`],
|
|
466
499
|
...worker === undefined ? [] : [worker],
|
|
500
|
+
...planner === undefined ? [] : [planner],
|
|
467
501
|
].join(' | ');
|
|
468
502
|
}
|
|
469
503
|
/** Build the whole-value checkpoint published with a Coding tool result. */
|
|
@@ -486,6 +520,7 @@ export function checkpointOf(state) {
|
|
|
486
520
|
verifyAttempts: state.verificationAttempts,
|
|
487
521
|
...state.verifyBlocked === undefined ? {} : { verifyBlocked: state.verifyBlocked },
|
|
488
522
|
...state.worker === undefined ? {} : { worker: state.worker },
|
|
523
|
+
...state.planner === undefined ? {} : { planner: state.planner },
|
|
489
524
|
...state.refusal === undefined ? {} : { refusal: state.refusal },
|
|
490
525
|
...state.failure === undefined ? {} : { failure: state.failure },
|
|
491
526
|
updatedAt: state.updatedAt,
|
|
@@ -21,7 +21,8 @@ export interface CodingCardProps {
|
|
|
21
21
|
* control card and a history card is testable without React.
|
|
22
22
|
* @param view - current projection value.
|
|
23
23
|
* @param turn - Turn the card belongs to, when the owner declares one.
|
|
24
|
-
* @returns the values rendered, plus whether this card may switch the mode
|
|
24
|
+
* @returns the values rendered, plus whether this card may switch the mode
|
|
25
|
+
* (`live`) and whether it may write the handoff document (`canMemory`).
|
|
25
26
|
*/
|
|
26
27
|
export declare function cardState(view: CodingStageView, turn: number | undefined): {
|
|
27
28
|
live: boolean;
|
|
@@ -32,6 +33,7 @@ export declare function cardState(view: CodingStageView, turn: number | undefine
|
|
|
32
33
|
planItems: number;
|
|
33
34
|
openPlanItems: number;
|
|
34
35
|
edits: number;
|
|
36
|
+
canMemory: boolean;
|
|
35
37
|
};
|
|
36
38
|
/**
|
|
37
39
|
* The command line one mode switch sends back through the Host. A card sits at
|
|
@@ -41,6 +43,8 @@ export declare function cardState(view: CodingStageView, turn: number | undefine
|
|
|
41
43
|
* its "switch and open a turn" meaning.
|
|
42
44
|
*/
|
|
43
45
|
export declare function commandFor(mode: CodingMode): string;
|
|
46
|
+
/** 生成交接文档要回流 Host 的命令行。 */
|
|
47
|
+
export declare function memoryCommand(): string;
|
|
44
48
|
/** Verification text for one card. */
|
|
45
49
|
/**
|
|
46
50
|
* The card's verification cell: status only, never the command. The command
|
|
@@ -11,7 +11,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
/** Every dictionary key this client half uses. */
|
|
14
|
-
export type CodingKey = 'aria' | 'hint.mode' | 'picker.label' | 'picker.aria' | 'mode.consult' | 'mode.review' | 'mode.auto' | 'mode.codex' | 'stage.requirements' | 'stage.plan' | 'stage.implement' | 'stage.verify' | 'stage.deliver' | 'verification.none' | 'verification.passed' | 'verification.failed' | 'plan.none' | 'plan.progress' | 'worker.running' | 'worker.completed' | 'worker.failed' | 'pending' | 'refused' | 'files' | 'card.mode' | 'card.stage' | 'card.verify' | 'card.stageHint' | 'card.switchFailed' | 'card.stale' | 'card.reasoning' | 'reasoning.pending' | 'reasoning.sourceAuto' | 'reasoning.sourceOverride' | 'reasoning.sourcePick' | 'reasoning.sourceSettings' | 'config.title' | 'config.hint' | 'config.mode' | 'config.modeHint' | 'config.implementModel' | 'config.implementModelHint' | 'config.plannerModel' | 'config.plannerModelHint' | 'config.verifyModel' | 'config.verifyModelHint' | 'config.language' | 'config.languageHint' | 'config.languageAuto' | 'config.reasoning' | 'config.reasoningHint' | 'config.reasoningAuto' | 'config.verification' | 'config.verificationHint' | 'config.commands' | 'config.commandsHint' | 'config.save' | 'config.saving' | 'config.saved' | 'config.saveFailed' | 'config.invalidRoute' | 'config.readOnly' | 'config.loading' | 'config.unavailable' | 'config.reset' | 'config.presetWarning' | 'config.modelWarning' | 'config.modelsLoading' | 'config.modelsUnavailable' | 'config.modelsRetry' | 'config.modelPlaceholder' | 'config.modelMissing';
|
|
14
|
+
export type CodingKey = 'aria' | 'hint.mode' | 'picker.label' | 'picker.aria' | 'mode.consult' | 'mode.review' | 'mode.auto' | 'mode.codex' | 'stage.requirements' | 'stage.plan' | 'stage.implement' | 'stage.verify' | 'stage.deliver' | 'verification.none' | 'verification.passed' | 'verification.failed' | 'plan.none' | 'plan.progress' | 'worker.running' | 'worker.completed' | 'worker.failed' | 'pending' | 'refused' | 'files' | 'card.mode' | 'card.stage' | 'card.verify' | 'card.stageHint' | 'card.switchFailed' | 'card.memory' | 'card.memoryHint' | 'card.memoryConfirm' | 'card.memoryCancel' | 'card.memoryBusy' | 'card.memoryDone' | 'card.memoryFailed' | 'card.stale' | 'card.reasoning' | 'reasoning.pending' | 'reasoning.sourceAuto' | 'reasoning.sourceOverride' | 'reasoning.sourcePick' | 'reasoning.sourceSettings' | 'config.title' | 'config.hint' | 'config.mode' | 'config.modeHint' | 'config.implementModel' | 'config.implementModelHint' | 'config.plannerModel' | 'config.plannerModelHint' | 'config.verifyModel' | 'config.verifyModelHint' | 'config.language' | 'config.languageHint' | 'config.languageAuto' | 'config.reasoning' | 'config.reasoningHint' | 'config.reasoningAuto' | 'config.verification' | 'config.verificationHint' | 'config.commands' | 'config.commandsHint' | 'config.save' | 'config.saving' | 'config.saved' | 'config.saveFailed' | 'config.invalidRoute' | 'config.readOnly' | 'config.loading' | 'config.unavailable' | 'config.reset' | 'config.presetWarning' | 'config.modelWarning' | 'config.modelsLoading' | 'config.modelsUnavailable' | 'config.modelsRetry' | 'config.modelPlaceholder' | 'config.modelMissing';
|
|
15
15
|
/** English copy. */
|
|
16
16
|
export declare const en: Record<CodingKey, string>;
|
|
17
17
|
/** Chinese copy. */
|
package/lib/types/config.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export { volatileValue };
|
|
|
20
20
|
export declare const REASONING_MODES: readonly ["auto", "low", "high", "max"];
|
|
21
21
|
/** One reasoning-level policy: auto classifies, the others pin. */
|
|
22
22
|
export type ReasoningMode = typeof REASONING_MODES[number];
|
|
23
|
+
/** planner 门禁策略:`complex` 对复杂 codex 任务强制 planner,`off` 关闭该门禁。 */
|
|
24
|
+
export declare const PLANNER_GATE_MODES: readonly ["complex", "off"];
|
|
25
|
+
/** 一条 planner 门禁策略。 */
|
|
26
|
+
export type PlannerGateMode = typeof PLANNER_GATE_MODES[number];
|
|
23
27
|
/** One resolved `provider/model` route for a worker subagent. */
|
|
24
28
|
export interface WorkerRoute {
|
|
25
29
|
readonly provider: string;
|
|
@@ -42,6 +46,11 @@ export interface CodingConfig {
|
|
|
42
46
|
* `provider/model` route for the planner worker (pro model). Required.
|
|
43
47
|
*/
|
|
44
48
|
readonly plannerWorkerModel: string;
|
|
49
|
+
/**
|
|
50
|
+
* planner 门禁:`complex` 时 codex 任务单超过三条且未派发过 `delegate_plan`
|
|
51
|
+
* 就不能进入 implement;`off` 关闭该门禁。
|
|
52
|
+
*/
|
|
53
|
+
readonly requirePlanner: PlannerGateMode;
|
|
45
54
|
/**
|
|
46
55
|
* Conversation language: `auto` follows the DSH interface, then the host
|
|
47
56
|
* locale; `zh` / `en` pin it. The prompt fixes replies, todo items, and
|
|
@@ -117,6 +126,12 @@ export declare const configJsonSchema: {
|
|
|
117
126
|
readonly pattern: "^[^/\\s]+/[^/\\s]+$";
|
|
118
127
|
readonly description: "provider/model route for the planner worker (pro model); never inherited from the lead.";
|
|
119
128
|
};
|
|
129
|
+
readonly requirePlanner: {
|
|
130
|
+
readonly type: "string";
|
|
131
|
+
readonly enum: readonly ["complex", "off"];
|
|
132
|
+
readonly default: "complex";
|
|
133
|
+
readonly description: "Require the planner worker for a complex codex run; complex or off.";
|
|
134
|
+
};
|
|
120
135
|
readonly language: {
|
|
121
136
|
readonly type: "string";
|
|
122
137
|
readonly enum: readonly LanguageMode[];
|
package/lib/types/handoff.d.ts
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* than the timestamp default. The Host runtime, the worker presets, and the Web
|
|
11
11
|
* client can therefore import it directly.
|
|
12
12
|
*
|
|
13
|
+
* 交付段的写入约定:`delivered` / `followUps` 只由 deliver 阶段经 coding_handoff 写入,
|
|
14
|
+
* 记录本轮交付了什么与对应证据;它们随 checkpoint 的 handoff 持久化,由下一轮的 plan /
|
|
15
|
+
* implement worker 读取(verify 分片不渲染该段以控制提示词体积),因此重开会话也能直接
|
|
16
|
+
* 看到上一轮的交付结果,而不必回头翻对话正文。
|
|
17
|
+
*
|
|
13
18
|
* @module dsh-coding/handoff
|
|
14
19
|
*/
|
|
15
20
|
/** Version of the persisted {@link CodingHandoff} shape. */
|
|
@@ -44,6 +49,8 @@ export interface CodingHandoff {
|
|
|
44
49
|
readonly version: typeof HANDOFF_VERSION;
|
|
45
50
|
/** What the run is for; cleared by patching it with an empty string. */
|
|
46
51
|
readonly goal?: string;
|
|
52
|
+
/** 一条紧凑的交付记录(本轮交付了什么 + 证据);空串表示清除,由模型在 deliver 阶段写入。 */
|
|
53
|
+
readonly delivered?: string;
|
|
47
54
|
readonly constraints: readonly string[];
|
|
48
55
|
/** Acceptance criteria: the definition of done `verify` and `deliver` check. */
|
|
49
56
|
readonly acceptance: readonly string[];
|
|
@@ -51,6 +58,8 @@ export interface CodingHandoff {
|
|
|
51
58
|
readonly decisions: readonly string[];
|
|
52
59
|
/** Questions still open; the next stage answers or escalates them. */
|
|
53
60
|
readonly open: readonly string[];
|
|
61
|
+
/** 残余风险与后续跟进项,下一轮的 plan / implement worker 会读到。 */
|
|
62
|
+
readonly followUps: readonly string[];
|
|
54
63
|
readonly tasks: readonly HandoffTask[];
|
|
55
64
|
readonly changes: readonly HandoffChange[];
|
|
56
65
|
readonly updatedAt: number;
|
|
@@ -58,11 +67,15 @@ export interface CodingHandoff {
|
|
|
58
67
|
/** A partial update applied by {@link mergeHandoff}; absent fields are untouched. */
|
|
59
68
|
export interface HandoffPatch {
|
|
60
69
|
readonly goal?: string;
|
|
70
|
+
/** 覆盖交付记录;传空串表示清除,不传则保留上一条。 */
|
|
71
|
+
readonly delivered?: string;
|
|
61
72
|
readonly constraints?: readonly string[];
|
|
62
73
|
readonly acceptance?: readonly string[];
|
|
63
74
|
readonly findings?: readonly string[];
|
|
64
75
|
readonly decisions?: readonly string[];
|
|
65
76
|
readonly open?: readonly string[];
|
|
77
|
+
/** 追加残余风险 / 跟进项(去重后保留下限内的最新条目)。 */
|
|
78
|
+
readonly followUps?: readonly string[];
|
|
66
79
|
/** Replaces the task list wholesale when present. */
|
|
67
80
|
readonly tasks?: readonly HandoffTask[];
|
|
68
81
|
/** Merged by `file` when present, so a later stage refines a summary. */
|
|
@@ -76,6 +89,9 @@ export declare function emptyHandoff(at?: number): CodingHandoff;
|
|
|
76
89
|
* Merge one patch into a handoff. A list patch appends (dropping exact
|
|
77
90
|
* duplicates, keeping the newest {@link HANDOFF_ITEMS_LIMIT} entries); a task
|
|
78
91
|
* patch replaces the list; a change patch refines entries by `file`.
|
|
92
|
+
*
|
|
93
|
+
* `delivered` 与 goal 同语义:给值即覆盖,空串清除;`followUps` 与其余列表字段
|
|
94
|
+
* 同语义:追加、去重,并保留最新的 {@link HANDOFF_ITEMS_LIMIT} 条。
|
|
79
95
|
* @param base - the record being updated, or undefined to start empty.
|
|
80
96
|
* @param patch - the sections this stage contributes.
|
|
81
97
|
* @param at - timestamp to stamp, defaults to now.
|
|
@@ -86,6 +102,9 @@ export declare function mergeHandoff(base: CodingHandoff | undefined, patch: Han
|
|
|
86
102
|
* Validate one untyped value as a {@link CodingHandoff}. The record is persisted
|
|
87
103
|
* in checkpoints and restored from durable JSON, so every field is re-checked
|
|
88
104
|
* here rather than trusted from the writer's build.
|
|
105
|
+
*
|
|
106
|
+
* 旧 checkpoint 可能没有 `delivered` / `followUps`(与 `files` 字段先例一致,不 bump
|
|
107
|
+
* {@link HANDOFF_VERSION}):缺字段按空值处理,损坏值被丢弃,返回的记录始终可用。
|
|
89
108
|
* @param value - decoded JSON or any other untyped value.
|
|
90
109
|
* @returns the normalized record, or undefined when it is not version 1.
|
|
91
110
|
*/
|
|
@@ -100,6 +119,7 @@ export declare function asHandoff(value: unknown): CodingHandoff | undefined;
|
|
|
100
119
|
export declare function handoffDigest(handoff: CodingHandoff | undefined, limit?: number): string;
|
|
101
120
|
/**
|
|
102
121
|
* Render the sections one worker role receives, as a prompt fragment.
|
|
122
|
+
* 只有 plan / implement 分片包含 `Delivered:` 段,见 {@link WORKER_SECTIONS}。
|
|
103
123
|
* @param handoff - record to render, or undefined.
|
|
104
124
|
* @param role - worker about to run.
|
|
105
125
|
* @returns the fragment, or '' when nothing applies to this role.
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Host-side settings service of the `dsh-coding` bundle.
|
|
3
3
|
*
|
|
4
4
|
* This row is the bundle's only Host contribution: it owns the verified
|
|
5
|
-
* configuration the Coding preset and its
|
|
5
|
+
* configuration the Coding preset and its four worker presets read, and it
|
|
6
6
|
* performs no agent work by itself. Installing the bundle therefore changes no
|
|
7
7
|
* existing session; only a session that selects the Coding preset runs the
|
|
8
8
|
* enforced runtime.
|
|
9
9
|
*
|
|
10
|
-
* It also filters this bundle's
|
|
10
|
+
* It also filters this bundle's four internal worker presets out of the exported
|
|
11
11
|
* preset roster: no client offers them, while the Host roster keeps resolving
|
|
12
12
|
* the compositions `delegate_implement` and `delegate_verify` dispatch to.
|
|
13
13
|
*
|
|
@@ -51,6 +51,12 @@ export declare const configSchema: {
|
|
|
51
51
|
readonly pattern: "^[^/\\s]+/[^/\\s]+$";
|
|
52
52
|
readonly description: "provider/model route for the planner worker (pro model); never inherited from the lead.";
|
|
53
53
|
};
|
|
54
|
+
readonly requirePlanner: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
readonly enum: readonly ["complex", "off"];
|
|
57
|
+
readonly default: "complex";
|
|
58
|
+
readonly description: "Require the planner worker for a complex codex run; complex or off.";
|
|
59
|
+
};
|
|
54
60
|
readonly language: {
|
|
55
61
|
readonly type: "string";
|
|
56
62
|
readonly enum: readonly import("./language.js").LanguageMode[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { CodingHandoff } from './handoff.js';
|
|
2
|
+
import type { CodingState, PlanItem } from './state.js';
|
|
3
|
+
import type { VerificationOutcome } from './stages.js';
|
|
4
|
+
/** 文档最大字符数;超出后截断到最后一个完整行。 */
|
|
5
|
+
export declare const MEMORY_LIMIT = 20000;
|
|
6
|
+
/** 交接文档在项目根下的目录。 */
|
|
7
|
+
export declare const MEMORY_DIR: string;
|
|
8
|
+
/** 交接文档的输入:只取状态机与 handoff 的有界数据,不含 I/O 与对话正文。 */
|
|
9
|
+
export interface MemoryInput {
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
readonly cwd?: string;
|
|
12
|
+
readonly mode: string;
|
|
13
|
+
readonly stage: string;
|
|
14
|
+
readonly turn: number;
|
|
15
|
+
readonly blocked: boolean;
|
|
16
|
+
readonly handoff?: CodingHandoff;
|
|
17
|
+
readonly plan: readonly PlanItem[];
|
|
18
|
+
readonly verification?: VerificationOutcome;
|
|
19
|
+
readonly files: readonly string[];
|
|
20
|
+
readonly transitions: readonly {
|
|
21
|
+
readonly from: string;
|
|
22
|
+
readonly to: string;
|
|
23
|
+
readonly at: number;
|
|
24
|
+
readonly reason: string;
|
|
25
|
+
}[];
|
|
26
|
+
readonly now: number;
|
|
27
|
+
}
|
|
28
|
+
/** 写盘结果:成功给出文件名与展示路径;失败给出原因与处理办法,从不抛错。 */
|
|
29
|
+
export type MemoryWriteResult = {
|
|
30
|
+
readonly ok: true;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly displayPath: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly ok: false;
|
|
35
|
+
readonly reason: string;
|
|
36
|
+
readonly action: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 生成一篇交接文档的文件名:`<清洗后的 sessionId>-<YYYYMMDD-HHmmss>.md`。
|
|
40
|
+
*
|
|
41
|
+
* sessionId 只保留 `[A-Za-z0-9._-]`,其余字符换成 `-`,清洗后为空则退回 `session`;
|
|
42
|
+
* 时间戳取 UTC,非法 `at` 按 epoch 处理而不抛错。
|
|
43
|
+
* @param sessionId - 会话 id。
|
|
44
|
+
* @param at - 时间戳(毫秒)。
|
|
45
|
+
* @returns 文件名,不含目录。
|
|
46
|
+
*/
|
|
47
|
+
export declare function memoryFileName(sessionId: string, at: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* 组装整篇交接文档。
|
|
50
|
+
*
|
|
51
|
+
* 纯字符串拼接:不读文件、不取时钟(时间来自 {@link MemoryInput.now}),因此可以直接单测。
|
|
52
|
+
* 空数组与缺失字段对应的整节省略,不输出「无」。
|
|
53
|
+
* @param input - 状态机与 handoff 的有界快照。
|
|
54
|
+
* @returns 文档正文,超过 {@link MEMORY_LIMIT} 时截断并标注。
|
|
55
|
+
*/
|
|
56
|
+
export declare function composeMemoryDocument(input: MemoryInput): string;
|
|
57
|
+
/**
|
|
58
|
+
* 写出本轮的任务交接文档,返回一条可回报给用户的收据。
|
|
59
|
+
*
|
|
60
|
+
* 写盘只走注入的 fs 服务:`resolve` 解析 `.agents/memory` 下的目标,`writeText` 以
|
|
61
|
+
* `createIfAbsent` 语义写入,因此重复点击生成新文件而不覆盖旧文档;目录缺失由 Host 的
|
|
62
|
+
* 原子写入自动创建。任何一步抛错都收成 `{ ok:false, … }` 收据,绝不外泄异常。
|
|
63
|
+
* @param ctx - 插件作用域。
|
|
64
|
+
* @param agent - 触发写入的 lead agent(`agent.ctx` 的作用域优先级更高)。
|
|
65
|
+
* @param state - 本轮结束时的状态机快照。
|
|
66
|
+
* @param options - 取消信号。
|
|
67
|
+
* @returns 成功时给出文件名与展示路径,失败时给出原因与处理办法。
|
|
68
|
+
*/
|
|
69
|
+
export declare function writeMemoryDocument(ctx: any, agent: any, state: CodingState, options?: {
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
}): Promise<MemoryWriteResult>;
|
package/lib/types/stages.d.ts
CHANGED
|
@@ -63,6 +63,9 @@ export declare function stageAdmissions(stage: CodingStage): string;
|
|
|
63
63
|
* The lead's tool table during `implement`: exactly these names remain visible.
|
|
64
64
|
* Naming the allow-list (rather than denying individual tools) is what makes the
|
|
65
65
|
* trim total, including tools a later plugin registers.
|
|
66
|
+
* `bash` and `pwsh` are both listed because only one exists per platform;
|
|
67
|
+
* `syncTable` drops the absent one, since `tools.restrict` rejects names the
|
|
68
|
+
* scope does not register.
|
|
66
69
|
*/
|
|
67
70
|
export declare const IMPLEMENT_TABLE: readonly string[];
|
|
68
71
|
/** The worker presets this package declares and dispatches to. */
|
|
@@ -70,7 +73,23 @@ export declare const WORKER_PRESETS: {
|
|
|
70
73
|
readonly planner: "dsh-coding-planner";
|
|
71
74
|
readonly implement: "dsh-coding-implement";
|
|
72
75
|
readonly verify: "dsh-coding-verify";
|
|
76
|
+
readonly verifyWithInstructions: "dsh-coding-verify-instructions";
|
|
73
77
|
};
|
|
78
|
+
/** 触发 verify 注入仓库指令的最小子任务数:多个子任务意味着跨任务依赖。 */
|
|
79
|
+
export declare const VERIFY_INSTRUCTION_TASK_THRESHOLD = 2;
|
|
80
|
+
/** 触发 verify 注入仓库指令的最小改动文件数:改动面大时需要仓库规则。 */
|
|
81
|
+
export declare const VERIFY_INSTRUCTION_FILE_THRESHOLD = 3;
|
|
82
|
+
/** 决定 verify worker 是否加载仓库指令的输入。 */
|
|
83
|
+
export interface WorkspaceInstructionDemand {
|
|
84
|
+
readonly mode: CodingMode;
|
|
85
|
+
readonly taskCount: number;
|
|
86
|
+
readonly changedFiles: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* verify 是否应加载仓库指令:仅 codex 模式,且(多子任务)或(改动文件多)。
|
|
90
|
+
* 单任务单文件的核查不注入,避免为一次检查付出整份 AGENTS.md 的上下文。
|
|
91
|
+
*/
|
|
92
|
+
export declare function needsWorkspaceInstructions(demand: WorkspaceInstructionDemand): boolean;
|
|
74
93
|
/** The stable route identity a session's coding run is checkpointed under. */
|
|
75
94
|
export declare const CHECKPOINT_VERSION = 1;
|
|
76
95
|
/** One stage transition recorded by the state machine. */
|
|
@@ -104,6 +123,14 @@ export interface WorkerRecord {
|
|
|
104
123
|
readonly startedAt: number;
|
|
105
124
|
readonly finishedAt?: number;
|
|
106
125
|
}
|
|
126
|
+
/** 一次 planner 派发尝试:失败也算尝试,避免 worker 路由不可用时把 codex 流程锁死。 */
|
|
127
|
+
export interface PlannerAttempt {
|
|
128
|
+
/** 本次尝试使用的配置路由 `provider/model`。 */
|
|
129
|
+
readonly route: string;
|
|
130
|
+
/** 只有 worker 完成并回报 ok 才是 `completed`;失败的尝试同样打开门禁。 */
|
|
131
|
+
readonly outcome: 'completed' | 'failed';
|
|
132
|
+
readonly at: number;
|
|
133
|
+
}
|
|
107
134
|
/**
|
|
108
135
|
* Whole-value checkpoint emitted with every Coding tool result. The Web
|
|
109
136
|
* projection stores exactly this shape, so a history page that starts in the
|
|
@@ -139,6 +166,8 @@ export interface CodingCheckpoint {
|
|
|
139
166
|
readonly at: number;
|
|
140
167
|
};
|
|
141
168
|
readonly worker?: WorkerRecord;
|
|
169
|
+
/** planner 派发尝试;旧 checkpoint 没有该字段,读取时视为“未尝试”。 */
|
|
170
|
+
readonly planner?: PlannerAttempt;
|
|
142
171
|
readonly refusal?: {
|
|
143
172
|
readonly target: CodingStage;
|
|
144
173
|
readonly reason: string;
|
package/lib/types/state.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import type { CodingConfig } from './config.js';
|
|
14
14
|
import type { CodingFailure } from './failures.js';
|
|
15
15
|
import { type CodingHandoff } from './handoff.js';
|
|
16
|
-
import { type CodingCheckpoint, type CodingMode, type CodingStage, type StageTransition, type VerificationOutcome, type WorkerRecord } from './stages.js';
|
|
16
|
+
import { type CodingCheckpoint, type CodingMode, type CodingStage, type PlannerAttempt, type StageTransition, type VerificationOutcome, type WorkerRecord } from './stages.js';
|
|
17
17
|
/** One structured task-list entry, as `todo_write` records it. */
|
|
18
18
|
export interface PlanItem {
|
|
19
19
|
readonly content: string;
|
|
@@ -45,6 +45,8 @@ export interface CodingState {
|
|
|
45
45
|
/** Edit count inherited from a checkpoint that carried no `files` list. */
|
|
46
46
|
baseEdits: number;
|
|
47
47
|
worker?: WorkerRecord;
|
|
48
|
+
/** planner 派发尝试;有值即表示这个会话已经尝试过 planner(成功或失败)。 */
|
|
49
|
+
planner?: PlannerAttempt;
|
|
48
50
|
verification?: VerificationOutcome;
|
|
49
51
|
refusal?: {
|
|
50
52
|
readonly target: CodingStage;
|
|
@@ -118,14 +120,24 @@ export interface RestoreView {
|
|
|
118
120
|
export declare function restoreFromView(state: CodingState, view: RestoreView): void;
|
|
119
121
|
/** Stage at which this mode's own gates can be satisfied, one line. */
|
|
120
122
|
export declare function stageGuidance(mode: CodingMode): string;
|
|
123
|
+
/** 强制 planner 的任务单阈值:严格大于三条即为“复杂任务”。 */
|
|
124
|
+
export declare const PLANNER_TODO_THRESHOLD = 3;
|
|
125
|
+
/** 调用方提供的运行时事实:纯函数拿不到主 Agent 的模型与配置。 */
|
|
126
|
+
export interface AdvanceOptions {
|
|
127
|
+
/** 主 Agent 自身模型就是配置的 planner 路由,planner 因此是多余的。 */
|
|
128
|
+
readonly leadIsPlanner?: boolean;
|
|
129
|
+
/** 配置 `requirePlanner: 'off'` 时整条门禁关闭。 */
|
|
130
|
+
readonly plannerGate?: boolean;
|
|
131
|
+
}
|
|
121
132
|
/**
|
|
122
133
|
* Decide whether the model may move to `target` now. Conditions are checked by
|
|
123
134
|
* plugin code, never taken from the model's assertion.
|
|
124
135
|
* @param state - live session state.
|
|
125
136
|
* @param target - requested stage.
|
|
137
|
+
* @param options - 调用方提供的运行时事实(主 Agent 是否即 planner 路由、门禁是否开启)。
|
|
126
138
|
* @returns whether the move is allowed, and why not when it is refused.
|
|
127
139
|
*/
|
|
128
|
-
export declare function checkAdvance(state: CodingState, target: CodingStage): AdvanceCheck;
|
|
140
|
+
export declare function checkAdvance(state: CodingState, target: CodingStage, options?: AdvanceOptions): AdvanceCheck;
|
|
129
141
|
/**
|
|
130
142
|
* Apply one granted stage transition.
|
|
131
143
|
* @param state - live session state (mutated).
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "DSH Coding agent",
|
|
4
|
-
"description": "
|
|
5
|
-
"detail": "
|
|
4
|
+
"description": "DSH programming intelligent agent plugin, engineering task orchestration mechanism, Codex five-stage contract progressing layer by layer, Pro model responsible for analyzing requirements/orchestrating tasks, delegating to sub-agents to isolate various tasks and using Flash model to perform work, ensuring task delivery quality and maximizing Token value.",
|
|
5
|
+
"detail": "README.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "DSH Coding 编程智能体",
|
|
4
|
-
"description": "DSH
|
|
5
|
-
"detail": "
|
|
4
|
+
"description": "DSH 编程智能体插件,工程化任务编排机制,Codex 五段式契约层层推进,Pro 模型负责分析需求/编排任务,交由子代理隔离各项任务使用 Flash 模型干活,确保任务交付质量和 Token 价值最大化。",
|
|
5
|
+
"detail": "README.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-coding",
|
|
3
|
-
"version": "0.1.1-
|
|
4
|
-
"description": "DSH
|
|
3
|
+
"version": "0.1.1-rc2",
|
|
4
|
+
"description": "DSH 编程智能体插件,工程化任务编排机制,Codex 五段式契约层层推进,Pro 模型负责分析需求/编排任务,交由子代理隔离各项任务使用 Flash 模型干活,确保任务交付质量和 Token 价值最大化。DSH programming intelligent agent plugin, engineering task orchestration mechanism, Codex five-stage contract progressing layer by layer, Pro model responsible for analyzing requirements/orchestrating tasks, delegating to sub-agents to isolate various tasks and using Flash model to perform work, ensuring task delivery quality and maximizing Token value.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/types/index.d.ts",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"icon.svg",
|
|
38
38
|
"cordis.patch.yml",
|
|
39
39
|
"README.md",
|
|
40
|
+
"AGENTS.md",
|
|
40
41
|
"LICENSE"
|
|
41
42
|
],
|
|
42
43
|
"dsh": {
|