dsh-coding 0.0.1 → 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 +120 -54
- package/cordis.patch.yml +274 -4
- package/docs/CHANGELOG.md +47 -0
- package/docs/DETAIL.md +272 -0
- package/icon.svg +6 -6
- package/lib/apply-patch.js +268 -0
- package/lib/client/capsule.js +120 -0
- package/lib/client/card.js +308 -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 +170 -0
- package/lib/client/mode-picker.js +77 -0
- package/lib/client/styles.js +283 -0
- package/lib/client.js +1802 -0
- package/lib/coding-projection.js +349 -0
- package/lib/config.js +218 -0
- package/lib/contract.js +138 -0
- package/lib/editor.js +23 -0
- package/lib/failures.js +142 -0
- package/lib/handoff.js +347 -0
- package/lib/index.js +110 -7
- package/lib/language.js +136 -0
- package/lib/memory.js +336 -0
- package/lib/messages.js +43 -0
- package/lib/models.js +154 -0
- package/lib/patch.js +235 -0
- package/lib/preset.js +1552 -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 +344 -0
- package/lib/state.js +585 -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 +76 -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 +208 -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 +132 -0
- package/lib/types/index.d.ts +150 -0
- package/lib/types/language.d.ts +56 -0
- package/lib/types/memory.d.ts +71 -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 +193 -0
- package/lib/types/state.d.ts +273 -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 +84 -9
- package/lib/index.d.ts +0 -11
package/lib/contract.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The delivery contract, split into the stage that owns each rule.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here is a global system prompt: one fragment is injected as
|
|
5
|
+
* per-step context for the stage actually in force, so the model reads the rule
|
|
6
|
+
* it can act on now. That also keeps a long session from carrying every rule of
|
|
7
|
+
* every stage in its system prompt.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-coding/contract
|
|
10
|
+
*/
|
|
11
|
+
import { stagePath } from './stages.js';
|
|
12
|
+
/** One paragraph per mode, injected with every stage fragment. */
|
|
13
|
+
export const MODE_CONTRACT = {
|
|
14
|
+
auto: 'Mode `auto`: the requirements stage decides the workflow for this request. Understand what the user is '
|
|
15
|
+
+ 'asking and inspect enough of the project to classify it: a question, explanation, or advice → `consult` '
|
|
16
|
+
+ '(also the fallback when the request is unclear or you are unsure); a review of existing behavior → '
|
|
17
|
+
+ '`review`; a change to the codebase → `codex`. Do not over-interpret the request, widen its scope, or '
|
|
18
|
+
+ 'design beyond it. State the chosen workflow in one line, call `coding_mode` with that mode, then follow '
|
|
19
|
+
+ 'the chosen mode\'s stages and rules. Auto opens only requirements; `coding_stage` cannot advance until '
|
|
20
|
+
+ 'a mode is chosen.',
|
|
21
|
+
consult: 'Mode `consult` (Q&A): answer the question directly. Give 1-3 options with tradeoffs, one '
|
|
22
|
+
+ 'recommendation, a short plan, and the decision you need from the user. Do not edit files, run '
|
|
23
|
+
+ 'tests, or create a todo list unless the user asks for implementation.',
|
|
24
|
+
review: 'Mode `review`: report concrete findings with `file:line` and a reproducible scenario, ordered by '
|
|
25
|
+
+ 'impact. Do not edit files unless the user explicitly asks for a fix; use the verify stage to '
|
|
26
|
+
+ 'check the claims you make.',
|
|
27
|
+
codex: 'Mode `codex`: inspect, plan the work, delegate the edit to the implement worker, verify the result, '
|
|
28
|
+
+ 'then deliver. The runtime enforces this order; a skipped gate is refused. The handoff recorded in '
|
|
29
|
+
+ 'requirements is the context every worker receives; keep it current instead of repeating history.',
|
|
30
|
+
};
|
|
31
|
+
/** The rule set owned by each stage. */
|
|
32
|
+
export const STAGE_CONTRACT = {
|
|
33
|
+
requirements: [
|
|
34
|
+
'### requirements — analyse the request and the ground truth',
|
|
35
|
+
'- Read every applicable `AGENTS.md`, then the files the task touches. Never rely on remembered code.',
|
|
36
|
+
'- Name the request before deciding: what the user wants, the deliverable, and the constraints. Ask only '
|
|
37
|
+
+ 'when a wrong guess would waste real work; otherwise record the assumption and keep moving.',
|
|
38
|
+
'- Note the project state that matters to this request: entry points, existing patterns, the package '
|
|
39
|
+
+ 'manager, and the narrowest check that will prove the work.',
|
|
40
|
+
'- Use `read`, `grep`, and `glob`; one inspection command is fine. Do not edit, plan, or verify yet.',
|
|
41
|
+
'- Record the handoff with `coding_handoff({ goal, constraints, acceptance })` before advancing: codex '
|
|
42
|
+
+ 'cannot enter plan without a goal, and the planner only sees this text.',
|
|
43
|
+
'- Advance with `coding_stage({"stage":"plan"})` once you can name the affected files; in `auto` mode, '
|
|
44
|
+
+ 'choose the workflow with `coding_mode` first.',
|
|
45
|
+
].join('\n'),
|
|
46
|
+
plan: [
|
|
47
|
+
'### plan — define done',
|
|
48
|
+
'- A `Delivered` section in the handoff means this is a follow-up round: start from that record and its '
|
|
49
|
+
+ 'follow-ups; do not re-derive or redo the earlier change.',
|
|
50
|
+
'- Record what requirements established in the handoff: what the user asked for (goal, deliverable, '
|
|
51
|
+
+ 'constraints) and what the project actually looks like (entry points, patterns, checks). If either is '
|
|
52
|
+
+ 'missing, inspect now instead of guessing; a fact that stays in the conversation never reaches a worker.',
|
|
53
|
+
'- Call `delegate_plan` for every multi-file or cross-module change in codex: it explores read-only and '
|
|
54
|
+
+ 'returns single-purpose sub-tasks. A task list that would exceed three items makes it mandatory — the '
|
|
55
|
+
+ 'runtime refuses `implement` until a `delegate_plan` dispatch is recorded (a dispatch that fails counts '
|
|
56
|
+
+ 'too), and skips that gate when the lead itself runs the planner route. For each task settle the '
|
|
57
|
+
+ 'boundary and handoff first: goal, files in scope, acceptance check, and what it must not touch. Order '
|
|
58
|
+
+ 'tasks so each depends only on earlier ones.',
|
|
59
|
+
'- Every todo item and every planner task must name an observable acceptance check; record the definition '
|
|
60
|
+
+ 'of done with `coding_handoff({ acceptance: [...] })`. codex cannot enter verify without it.',
|
|
61
|
+
'- Call `todo_write` with one verifiable item per task (1-3 for a small single-file change, 4-6 for a '
|
|
62
|
+
+ 'multi-file one) and exactly one `in_progress`. Keep each implement brief self-contained so the '
|
|
63
|
+
+ 'worker\'s context and tokens stay bounded.',
|
|
64
|
+
'- Choose the smallest approach: reuse existing functions, types, and patterns. Add no abstraction, '
|
|
65
|
+
+ 'dependency, or drive-by refactor the task does not need.',
|
|
66
|
+
'- `coding_stage` refuses `implement` until the list is written, and a list over three items also needs a '
|
|
67
|
+
+ '`delegate_plan` dispatch first.',
|
|
68
|
+
].join('\n'),
|
|
69
|
+
implement: [
|
|
70
|
+
'### implement — delegate the edit',
|
|
71
|
+
'- You cannot edit files in this stage: `apply_patch`, `edit`, and `write` are not in your tool table.',
|
|
72
|
+
'- You do run shell commands yourself (`bash` on POSIX, `pwsh` on Windows) for installs, git, and '
|
|
73
|
+
+ 'one-off inspection the worker cannot do; editing files is still the worker\'s job.',
|
|
74
|
+
'- Call `delegate_implement` with a self-contained task: goal, acceptance criteria, exact files, and '
|
|
75
|
+
+ 'the excerpts the worker needs. The worker has a fresh context and only the editing tools.',
|
|
76
|
+
'- Pass the handoff\'s goal, constraints, and the current task\'s acceptance into the brief; do not make '
|
|
77
|
+
+ 'the worker re-derive them.',
|
|
78
|
+
'- The worker returns a structured report (files, summary, notes). The runtime counts only reported '
|
|
79
|
+
+ 'edits toward the verify gate; you can inspect the files yourself in the verify stage.',
|
|
80
|
+
'- One worker call per coherent change; split unrelated changes instead of batching them.',
|
|
81
|
+
].join('\n'),
|
|
82
|
+
verify: [
|
|
83
|
+
'### verify — prove it',
|
|
84
|
+
'- Run the narrowest check first: `run_verification` with `scope:"targeted"`, then `package`, then '
|
|
85
|
+
+ '`full` when the change reaches across packages.',
|
|
86
|
+
'- Ad-hoc shell commands are available here for reproducing a failure; project checks still go through '
|
|
87
|
+
+ '`run_verification` so the outcome is recorded as evidence.',
|
|
88
|
+
'- A behavior change needs a test that would have failed before it. `delegate_verify` investigates a '
|
|
89
|
+
+ 'failure without editing.',
|
|
90
|
+
'- A task without an acceptance check cannot enter verify; record it with `coding_handoff` first.',
|
|
91
|
+
'- The runtime caps fix/verify retries (`maxVerifyAttempts` / `maxSameFailure`). When the budget is '
|
|
92
|
+
+ 'exhausted, stop: advance to deliver and report a BLOCKED delivery naming the failing check, or ask the user.',
|
|
93
|
+
'- Keep the task list current: mark a finished check completed with `todo_write`; the deliver gate '
|
|
94
|
+
+ 'reads recorded evidence, not the list.',
|
|
95
|
+
'- A failing check means: go back to implement, fix it, verify again. The deliver gate reads the '
|
|
96
|
+
+ 'recorded verification result, so an unrun or failed check cannot be talked past.',
|
|
97
|
+
].join('\n'),
|
|
98
|
+
deliver: [
|
|
99
|
+
'### deliver — report compactly',
|
|
100
|
+
'- Close the task list first: mark the finished items completed with `todo_write`, so no step stays '
|
|
101
|
+
+ 'in_progress after delivery.',
|
|
102
|
+
'- Record the delivery in the handoff before you finish: `coding_handoff({ delivered, followUps })` — one '
|
|
103
|
+
+ 'line naming what changed, the files touched, and the check that proved it. The next turn and a '
|
|
104
|
+
+ 'resumed session read this record, not this conversation.',
|
|
105
|
+
'- Lead with the outcome: what changed and why. Then the files touched as backticked paths, the '
|
|
106
|
+
+ 'verification evidence (command and result), and residual risk.',
|
|
107
|
+
'- If the last check failed and the retry budget is exhausted, this is a BLOCKED delivery: state the '
|
|
108
|
+
+ 'failing check, command, exit code, and last error; never claim success.',
|
|
109
|
+
'- Do not dump diffs, logs, or large files; refer to paths. No step-by-step narration.',
|
|
110
|
+
'- If something could not be verified, say what and why. Never report a passing check you did not run.',
|
|
111
|
+
].join('\n'),
|
|
112
|
+
};
|
|
113
|
+
/** One-line communication rule shared by every stage. */
|
|
114
|
+
export const COMMUNICATION_RULE = 'Send at most one short sentence before a group of tool calls, and only when it helps. Do not narrate '
|
|
115
|
+
+ 'deliberation or restate tool output.';
|
|
116
|
+
/**
|
|
117
|
+
* Render the per-step context message. Kept terse: it rides in every request of
|
|
118
|
+
* the session, so each line must earn its tokens.
|
|
119
|
+
* @param input - mode, stage, and the rendered status line.
|
|
120
|
+
* @returns the injected context text.
|
|
121
|
+
*/
|
|
122
|
+
export function stageContext(input) {
|
|
123
|
+
const lines = [
|
|
124
|
+
'## dsh-coding runtime (enforced by the plugin, not advice)',
|
|
125
|
+
`${MODE_CONTRACT[input.mode]}`,
|
|
126
|
+
`Stage path for this mode: ${stagePath(input.mode)}. Current stage: **${input.stage}**.`,
|
|
127
|
+
`Status: ${input.status}`,
|
|
128
|
+
...input.handoff === undefined || input.handoff === ''
|
|
129
|
+
? []
|
|
130
|
+
: ['', '## Handoff (recorded by earlier stages)', input.handoff],
|
|
131
|
+
...input.rejection === undefined ? [] : [`The last stage advance was refused: ${input.rejection}`],
|
|
132
|
+
'',
|
|
133
|
+
STAGE_CONTRACT[input.stage],
|
|
134
|
+
'',
|
|
135
|
+
COMMUNICATION_RULE,
|
|
136
|
+
];
|
|
137
|
+
return lines.join('\n');
|
|
138
|
+
}
|
package/lib/editor.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Codex `apply_patch` editor as a preset entry.
|
|
3
|
+
*
|
|
4
|
+
* It is mounted by the Coding preset (so the stage gate has an edit tool to
|
|
5
|
+
* refuse, and so the `implement` table trim has something to remove) **and** by
|
|
6
|
+
* the implement worker preset (where it is the core editing tool). The parser
|
|
7
|
+
* and the expected-excerpt mismatch report are the original Codex dialect,
|
|
8
|
+
* unchanged.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-coding/editor
|
|
11
|
+
*/
|
|
12
|
+
import { registerApplyPatch } from './apply-patch.js';
|
|
13
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
14
|
+
export const name = 'dsh-coding-editor';
|
|
15
|
+
/** The editor needs the tool registry and the composed filesystem. */
|
|
16
|
+
export const inject = ['tools', 'fs'];
|
|
17
|
+
/**
|
|
18
|
+
* Register `apply_patch` in this preset's scope.
|
|
19
|
+
* @param ctx - preset scope that owns the registration.
|
|
20
|
+
*/
|
|
21
|
+
export function apply(ctx) {
|
|
22
|
+
registerApplyPatch(ctx);
|
|
23
|
+
}
|
package/lib/failures.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured failure reports: the reason a blocking step could not finish, and
|
|
3
|
+
* what the operator can do about it.
|
|
4
|
+
*
|
|
5
|
+
* The runtime catches its own blocking exceptions at a small, fixed set of
|
|
6
|
+
* dispatch points. Catching them silently would leave the user watching a card
|
|
7
|
+
* that stopped moving, so each one becomes a {@link CodingFailure} that travels
|
|
8
|
+
* with the checkpoint and reaches the next step as a one-shot notice. The note
|
|
9
|
+
* never becomes a Turn and never adds a Session event: it rides the message
|
|
10
|
+
* channel the Host already injects into.
|
|
11
|
+
*
|
|
12
|
+
* This module is pure and browser safe: no I/O, no dependencies, and no clock
|
|
13
|
+
* other than the timestamp default, so the Host preset, the worker presets, and
|
|
14
|
+
* the Web client can all import it.
|
|
15
|
+
*
|
|
16
|
+
* @module dsh-coding/failures
|
|
17
|
+
*/
|
|
18
|
+
/** Longest reason or action kept in a report. */
|
|
19
|
+
const FAILURE_TEXT_LIMIT = 600;
|
|
20
|
+
/** Every failure point, in report order. */
|
|
21
|
+
export const FAILURE_POINTS = [
|
|
22
|
+
'projection',
|
|
23
|
+
'restore',
|
|
24
|
+
'tool-table',
|
|
25
|
+
'reasoning',
|
|
26
|
+
'delegate',
|
|
27
|
+
'verification',
|
|
28
|
+
'handoff',
|
|
29
|
+
'command',
|
|
30
|
+
];
|
|
31
|
+
/** Human-readable name of each point, for the notice heading. */
|
|
32
|
+
const FAILURE_LABEL = {
|
|
33
|
+
projection: { zh: '会话投影', en: 'Session projection' },
|
|
34
|
+
restore: { zh: '会话恢复', en: 'Session restore' },
|
|
35
|
+
'tool-table': { zh: '工具表裁剪', en: 'Tool table' },
|
|
36
|
+
reasoning: { zh: '推理等级', en: 'Reasoning level' },
|
|
37
|
+
delegate: { zh: '子代理派发', en: 'Worker dispatch' },
|
|
38
|
+
verification: { zh: '验证执行', en: 'Verification' },
|
|
39
|
+
handoff: { zh: '交接记录', en: 'Handoff' },
|
|
40
|
+
command: { zh: '控制命令', en: 'Command' },
|
|
41
|
+
};
|
|
42
|
+
/** The concrete next move for each point, so a notice never only reports. */
|
|
43
|
+
const FAILURE_ACTION = {
|
|
44
|
+
projection: {
|
|
45
|
+
zh: '会话仍可继续,但卡片和阶段胶囊可能缺失。确认 sessionProjections 服务可用后重启 DSH。',
|
|
46
|
+
en: 'The session can continue, but the card and stage capsule may be missing. Confirm the sessionProjections service is available, then restart DSH.',
|
|
47
|
+
},
|
|
48
|
+
restore: {
|
|
49
|
+
zh: '会话可能从 requirements 重新开始,已记录的阶段和任务单可能丢失。确认投影插件可用后重启 DSH;仍失败请新建会话并重新描述需求。',
|
|
50
|
+
en: 'The session may restart at requirements and lose its recorded stage or task list. Confirm the projection plugin is available and restart DSH; if it still fails, start a new session and restate the request.',
|
|
51
|
+
},
|
|
52
|
+
'tool-table': {
|
|
53
|
+
zh: '阶段工具表无法裁剪,编辑工具仍会被门禁拒绝。确认 delegate_implement 已注册并重启 DSH;必要时用 /coding stage 控制阶段。',
|
|
54
|
+
en: 'The stage tool table could not be trimmed; edits are still denied by the gate. Confirm delegate_implement is registered and restart DSH; use /coding stage to control the stage if needed.',
|
|
55
|
+
},
|
|
56
|
+
reasoning: {
|
|
57
|
+
zh: '本轮沿用当前推理等级。检查模型是否支持 reasoning effort,或在插件配置中把 reasoning 设为 auto。',
|
|
58
|
+
en: 'This turn keeps the current reasoning level. Check that the model supports reasoning effort, or set reasoning to auto in the plugin configuration.',
|
|
59
|
+
},
|
|
60
|
+
delegate: {
|
|
61
|
+
zh: '按错误中的字段检查 worker 模型路由和 provider,修好后重试同一派发。worker 不会回退主代理模型;必要时在插件页更换模型。',
|
|
62
|
+
en: 'Check the worker model route and provider named in the error, fix them, then retry the same dispatch. A worker never falls back to the lead model; change the model on the plugin page if needed.',
|
|
63
|
+
},
|
|
64
|
+
verification: {
|
|
65
|
+
zh: '检查 verificationCommands 与 verificationTimeoutMs,也可手动运行命令定位。启动失败或超时会计入验证预算。',
|
|
66
|
+
en: 'Check verificationCommands and verificationTimeoutMs, or run the command manually to diagnose. A start failure or timeout counts against the verification budget.',
|
|
67
|
+
},
|
|
68
|
+
handoff: {
|
|
69
|
+
zh: '重试 coding_handoff;仍失败用 /coding 查看状态,必要时新建会话。',
|
|
70
|
+
en: 'Retry coding_handoff; if it still fails, inspect /coding and start a new session if needed.',
|
|
71
|
+
},
|
|
72
|
+
command: {
|
|
73
|
+
zh: '按错误信息处理;命令持续失败时重启 DSH 后重试。',
|
|
74
|
+
en: 'Follow the error message; if the command keeps failing, restart DSH and retry.',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Build a report for one blocking exception.
|
|
79
|
+
* @param point - dispatch point that threw.
|
|
80
|
+
* @param error - the caught value, usually an `Error`.
|
|
81
|
+
* @param language - conversation language of the session.
|
|
82
|
+
* @param at - timestamp to stamp, defaults to now.
|
|
83
|
+
* @returns the report; its action is drawn from {@link FAILURE_ACTION}.
|
|
84
|
+
*/
|
|
85
|
+
export function makeFailure(point, error, language, at) {
|
|
86
|
+
const reason = (error instanceof Error ? error.message : String(error)).trim().slice(0, FAILURE_TEXT_LIMIT);
|
|
87
|
+
return {
|
|
88
|
+
point,
|
|
89
|
+
reason: reason === '' ? 'unknown error' : reason,
|
|
90
|
+
action: FAILURE_ACTION[point][language],
|
|
91
|
+
at: at ?? Date.now(),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Validate one untyped value as a {@link CodingFailure}. The report is persisted
|
|
96
|
+
* in checkpoints and restored from durable JSON written by an arbitrary earlier
|
|
97
|
+
* build, so every field is re-checked here rather than trusted.
|
|
98
|
+
* @param value - decoded JSON or any other untyped value.
|
|
99
|
+
* @returns the normalized report, or undefined when it is not one.
|
|
100
|
+
*/
|
|
101
|
+
export function asFailure(value) {
|
|
102
|
+
if (typeof value !== 'object' || value === null)
|
|
103
|
+
return undefined;
|
|
104
|
+
const raw = value;
|
|
105
|
+
const point = raw['point'];
|
|
106
|
+
if (typeof point !== 'string' || !FAILURE_POINTS.includes(point))
|
|
107
|
+
return undefined;
|
|
108
|
+
const reason = raw['reason'];
|
|
109
|
+
const action = raw['action'];
|
|
110
|
+
const at = raw['at'];
|
|
111
|
+
if (typeof reason !== 'string' || typeof action !== 'string')
|
|
112
|
+
return undefined;
|
|
113
|
+
if (typeof at !== 'number' || !Number.isFinite(at))
|
|
114
|
+
return undefined;
|
|
115
|
+
return {
|
|
116
|
+
point: point,
|
|
117
|
+
reason: reason.trim().slice(0, FAILURE_TEXT_LIMIT),
|
|
118
|
+
action: action.trim().slice(0, FAILURE_TEXT_LIMIT),
|
|
119
|
+
at,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Render the user-facing notice for one report: what broke and what to do.
|
|
124
|
+
* @param failure - the report to render.
|
|
125
|
+
* @param language - conversation language of the session.
|
|
126
|
+
* @returns the notice as a short Markdown block.
|
|
127
|
+
*/
|
|
128
|
+
export function failureNotice(failure, language) {
|
|
129
|
+
const label = FAILURE_LABEL[failure.point][language];
|
|
130
|
+
if (language === 'zh') {
|
|
131
|
+
return [`## dsh-coding 运行中断(${label})`, `原因:${failure.reason}`, `处理:${failure.action}`].join('\n');
|
|
132
|
+
}
|
|
133
|
+
return [`## dsh-coding runtime failure (${label})`, `Reason: ${failure.reason}`, `What to do: ${failure.action}`].join('\n');
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Render the one-fragment form used by the status line.
|
|
137
|
+
* @param failure - the report to render.
|
|
138
|
+
* @returns `failure <point>`.
|
|
139
|
+
*/
|
|
140
|
+
export function failureStatus(failure) {
|
|
141
|
+
return `failure ${failure.point}`;
|
|
142
|
+
}
|
package/lib/handoff.js
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-stage handoff: the bounded record one stage gives the next.
|
|
3
|
+
*
|
|
4
|
+
* The record is a summary, never a transcript: every list and every free-text
|
|
5
|
+
* value has a fixed cap, so a long run cannot flood the next worker's prompt. A
|
|
6
|
+
* patch is merged into the previous record instead of replacing it, because the
|
|
7
|
+
* planner, implementer, and verifier each contribute their own section.
|
|
8
|
+
*
|
|
9
|
+
* This module is pure and browser safe: no I/O, no dependencies, no clock other
|
|
10
|
+
* than the timestamp default. The Host runtime, the worker presets, and the Web
|
|
11
|
+
* client can therefore import it directly.
|
|
12
|
+
*
|
|
13
|
+
* 交付段的写入约定:`delivered` / `followUps` 只由 deliver 阶段经 coding_handoff 写入,
|
|
14
|
+
* 记录本轮交付了什么与对应证据;它们随 checkpoint 的 handoff 持久化,由下一轮的 plan /
|
|
15
|
+
* implement worker 读取(verify 分片不渲染该段以控制提示词体积),因此重开会话也能直接
|
|
16
|
+
* 看到上一轮的交付结果,而不必回头翻对话正文。
|
|
17
|
+
*
|
|
18
|
+
* @module dsh-coding/handoff
|
|
19
|
+
*/
|
|
20
|
+
/** Version of the persisted {@link CodingHandoff} shape. */
|
|
21
|
+
export const HANDOFF_VERSION = 1;
|
|
22
|
+
/** Longest single free-text value (goal, one list item, acceptance, avoid note). */
|
|
23
|
+
export const HANDOFF_TEXT_LIMIT = 600;
|
|
24
|
+
/** Most entries kept per bullet section (`constraints`, `findings`, …). */
|
|
25
|
+
export const HANDOFF_ITEMS_LIMIT = 10;
|
|
26
|
+
/** Most plan tasks the handoff carries. */
|
|
27
|
+
export const HANDOFF_TASKS_LIMIT = 8;
|
|
28
|
+
/** Most changed-file entries the handoff carries. */
|
|
29
|
+
export const HANDOFF_CHANGES_LIMIT = 20;
|
|
30
|
+
/** Default length of {@link handoffDigest}. */
|
|
31
|
+
export const HANDOFF_DIGEST_LIMIT = 1200;
|
|
32
|
+
/** Longest worker-facing rendering of the handoff. */
|
|
33
|
+
export const HANDOFF_WORKER_LIMIT = 2000;
|
|
34
|
+
/**
|
|
35
|
+
* Sections each role receives, in order. The planner needs the problem, the
|
|
36
|
+
* implementer needs the decisions and the task list, and the verifier needs the
|
|
37
|
+
* definition of done plus what already changed.
|
|
38
|
+
*
|
|
39
|
+
* 交付段只给 plan / implement:这两个角色需要知道上一轮交付了什么,才能接着规划与实现。
|
|
40
|
+
* verify 只核对本次改动(goal / done / changes / decisions / findings),不读上一轮交付
|
|
41
|
+
* 记录,以控制提示词体积。
|
|
42
|
+
*/
|
|
43
|
+
const WORKER_SECTIONS = {
|
|
44
|
+
plan: ['goal', 'delivered', 'constraints', 'done', 'findings', 'open'],
|
|
45
|
+
implement: ['goal', 'delivered', 'constraints', 'done', 'decisions', 'findings', 'tasks', 'open'],
|
|
46
|
+
verify: ['goal', 'done', 'changes', 'decisions', 'findings'],
|
|
47
|
+
};
|
|
48
|
+
/** An empty handoff stamped at `at`, defaulting to now. */
|
|
49
|
+
export function emptyHandoff(at) {
|
|
50
|
+
return {
|
|
51
|
+
version: HANDOFF_VERSION,
|
|
52
|
+
constraints: [],
|
|
53
|
+
acceptance: [],
|
|
54
|
+
findings: [],
|
|
55
|
+
decisions: [],
|
|
56
|
+
open: [],
|
|
57
|
+
followUps: [],
|
|
58
|
+
tasks: [],
|
|
59
|
+
changes: [],
|
|
60
|
+
updatedAt: at ?? Date.now(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Merge one patch into a handoff. A list patch appends (dropping exact
|
|
65
|
+
* duplicates, keeping the newest {@link HANDOFF_ITEMS_LIMIT} entries); a task
|
|
66
|
+
* patch replaces the list; a change patch refines entries by `file`.
|
|
67
|
+
*
|
|
68
|
+
* `delivered` 与 goal 同语义:给值即覆盖,空串清除;`followUps` 与其余列表字段
|
|
69
|
+
* 同语义:追加、去重,并保留最新的 {@link HANDOFF_ITEMS_LIMIT} 条。
|
|
70
|
+
* @param base - the record being updated, or undefined to start empty.
|
|
71
|
+
* @param patch - the sections this stage contributes.
|
|
72
|
+
* @param at - timestamp to stamp, defaults to now.
|
|
73
|
+
* @returns a new record; the inputs are not mutated.
|
|
74
|
+
*/
|
|
75
|
+
export function mergeHandoff(base, patch, at) {
|
|
76
|
+
const previous = base ?? emptyHandoff(at);
|
|
77
|
+
const goal = boundedText(patch.goal === undefined ? previous.goal : patch.goal, HANDOFF_TEXT_LIMIT);
|
|
78
|
+
const delivered = boundedText(patch.delivered === undefined ? previous.delivered : patch.delivered, HANDOFF_TEXT_LIMIT);
|
|
79
|
+
return {
|
|
80
|
+
version: HANDOFF_VERSION,
|
|
81
|
+
...goal === '' ? {} : { goal },
|
|
82
|
+
...delivered === '' ? {} : { delivered },
|
|
83
|
+
constraints: mergeItems(previous.constraints, listOf(patch.constraints)),
|
|
84
|
+
acceptance: mergeItems(previous.acceptance, listOf(patch.acceptance)),
|
|
85
|
+
findings: mergeItems(previous.findings, listOf(patch.findings)),
|
|
86
|
+
decisions: mergeItems(previous.decisions, listOf(patch.decisions)),
|
|
87
|
+
open: mergeItems(previous.open, listOf(patch.open)),
|
|
88
|
+
// 旧数据与测试手工构造的记录可能没有 followUps,先兜底成空列表再合并。
|
|
89
|
+
followUps: mergeItems(previous.followUps ?? [], listOf(patch.followUps)),
|
|
90
|
+
tasks: patch.tasks === undefined ? cleanTasks(previous.tasks) : boundedTasks(listOf(patch.tasks)),
|
|
91
|
+
changes: patch.changes === undefined ? cleanChanges(previous.changes) : mergeChanges(previous.changes, listOf(patch.changes)),
|
|
92
|
+
updatedAt: at ?? Date.now(),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Validate one untyped value as a {@link CodingHandoff}. The record is persisted
|
|
97
|
+
* in checkpoints and restored from durable JSON, so every field is re-checked
|
|
98
|
+
* here rather than trusted from the writer's build.
|
|
99
|
+
*
|
|
100
|
+
* 旧 checkpoint 可能没有 `delivered` / `followUps`(与 `files` 字段先例一致,不 bump
|
|
101
|
+
* {@link HANDOFF_VERSION}):缺字段按空值处理,损坏值被丢弃,返回的记录始终可用。
|
|
102
|
+
* @param value - decoded JSON or any other untyped value.
|
|
103
|
+
* @returns the normalized record, or undefined when it is not version 1.
|
|
104
|
+
*/
|
|
105
|
+
export function asHandoff(value) {
|
|
106
|
+
if (typeof value !== 'object' || value === null)
|
|
107
|
+
return undefined;
|
|
108
|
+
const raw = value;
|
|
109
|
+
if (raw['version'] !== HANDOFF_VERSION)
|
|
110
|
+
return undefined;
|
|
111
|
+
const goal = boundedText(raw['goal'], HANDOFF_TEXT_LIMIT);
|
|
112
|
+
const delivered = boundedText(raw['delivered'], HANDOFF_TEXT_LIMIT);
|
|
113
|
+
const updatedAt = raw['updatedAt'];
|
|
114
|
+
return {
|
|
115
|
+
version: HANDOFF_VERSION,
|
|
116
|
+
...goal === '' ? {} : { goal },
|
|
117
|
+
...delivered === '' ? {} : { delivered },
|
|
118
|
+
constraints: mergeItems([], listOf(raw['constraints'])),
|
|
119
|
+
acceptance: mergeItems([], listOf(raw['acceptance'])),
|
|
120
|
+
findings: mergeItems([], listOf(raw['findings'])),
|
|
121
|
+
decisions: mergeItems([], listOf(raw['decisions'])),
|
|
122
|
+
open: mergeItems([], listOf(raw['open'])),
|
|
123
|
+
followUps: mergeItems([], listOf(raw['followUps'])),
|
|
124
|
+
tasks: boundedTasks(listOf(raw['tasks'])),
|
|
125
|
+
changes: mergeChanges([], listOf(raw['changes'])),
|
|
126
|
+
updatedAt: typeof updatedAt === 'number' && Number.isFinite(updatedAt) ? updatedAt : Date.now(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Render the handoff as a compact multi-line digest for logs and status text.
|
|
131
|
+
* Only the sections carrying content are rendered, one short line each.
|
|
132
|
+
* @param handoff - record to render, or undefined.
|
|
133
|
+
* @param limit - maximum length, whole lines preferred.
|
|
134
|
+
* @returns the digest, or '' when the record is empty.
|
|
135
|
+
*/
|
|
136
|
+
export function handoffDigest(handoff, limit = HANDOFF_DIGEST_LIMIT) {
|
|
137
|
+
if (handoff === undefined)
|
|
138
|
+
return '';
|
|
139
|
+
const lines = [];
|
|
140
|
+
const goal = boundedText(handoff.goal, HANDOFF_TEXT_LIMIT);
|
|
141
|
+
if (goal !== '')
|
|
142
|
+
lines.push(`goal: ${goal}`);
|
|
143
|
+
const delivered = boundedText(handoff.delivered, HANDOFF_TEXT_LIMIT);
|
|
144
|
+
if (delivered !== '')
|
|
145
|
+
lines.push(`delivered: ${delivered}`);
|
|
146
|
+
pushItems(lines, 'constraints', handoff.constraints);
|
|
147
|
+
pushItems(lines, 'done', handoff.acceptance);
|
|
148
|
+
pushItems(lines, 'decisions', handoff.decisions);
|
|
149
|
+
pushItems(lines, 'findings', handoff.findings);
|
|
150
|
+
pushItems(lines, 'open', handoff.open);
|
|
151
|
+
pushItems(lines, 'follow-ups', handoff.followUps);
|
|
152
|
+
const tasks = cleanTasks(handoff.tasks);
|
|
153
|
+
if (tasks.length > 0) {
|
|
154
|
+
lines.push('tasks:');
|
|
155
|
+
tasks.forEach((task, index) => {
|
|
156
|
+
const files = task.files.length === 0 ? '(none)' : task.files.join(', ');
|
|
157
|
+
const avoid = task.avoid === undefined ? '' : `; avoid: ${task.avoid}`;
|
|
158
|
+
lines.push(`${index + 1}. ${task.goal} — files: ${files}; done: ${task.acceptance}${avoid}`);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const changes = cleanChanges(handoff.changes);
|
|
162
|
+
if (changes.length > 0) {
|
|
163
|
+
lines.push(`changes: ${changes.map(change => `${change.file}: ${change.summary}`).join('; ')}`);
|
|
164
|
+
}
|
|
165
|
+
return truncateText(lines.join('\n'), limit);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Render the sections one worker role receives, as a prompt fragment.
|
|
169
|
+
* 只有 plan / implement 分片包含 `Delivered:` 段,见 {@link WORKER_SECTIONS}。
|
|
170
|
+
* @param handoff - record to render, or undefined.
|
|
171
|
+
* @param role - worker about to run.
|
|
172
|
+
* @returns the fragment, or '' when nothing applies to this role.
|
|
173
|
+
*/
|
|
174
|
+
export function handoffForWorker(handoff, role) {
|
|
175
|
+
if (handoff === undefined)
|
|
176
|
+
return '';
|
|
177
|
+
const sections = {
|
|
178
|
+
goal: goalSection(handoff.goal),
|
|
179
|
+
delivered: deliveredSection(handoff.delivered),
|
|
180
|
+
constraints: bulletSection('Constraints:', cleanItems(handoff.constraints)),
|
|
181
|
+
done: bulletSection('Definition of done:', cleanItems(handoff.acceptance)),
|
|
182
|
+
decisions: bulletSection('Decisions:', cleanItems(handoff.decisions)),
|
|
183
|
+
findings: bulletSection('Findings:', cleanItems(handoff.findings)),
|
|
184
|
+
open: bulletSection('Open questions:', cleanItems(handoff.open)),
|
|
185
|
+
followUps: bulletSection('Follow-ups:', cleanItems(handoff.followUps)),
|
|
186
|
+
tasks: taskSection(cleanTasks(handoff.tasks)),
|
|
187
|
+
changes: changeSection(cleanChanges(handoff.changes)),
|
|
188
|
+
};
|
|
189
|
+
const parts = WORKER_SECTIONS[role]
|
|
190
|
+
.map(section => sections[section])
|
|
191
|
+
.filter((part) => part !== undefined);
|
|
192
|
+
return parts.length === 0 ? '' : truncateText(parts.join('\n\n'), HANDOFF_WORKER_LIMIT);
|
|
193
|
+
}
|
|
194
|
+
/** Whether the handoff states a goal, which `plan` requires before planning. */
|
|
195
|
+
export function hasGoal(handoff) {
|
|
196
|
+
return boundedText(handoff.goal, HANDOFF_TEXT_LIMIT) !== '';
|
|
197
|
+
}
|
|
198
|
+
/** Whether the handoff states at least one acceptance criterion, which `verify` and `deliver` require. */
|
|
199
|
+
export function hasDefinitionOfDone(handoff) {
|
|
200
|
+
return cleanItems(handoff.acceptance).length > 0;
|
|
201
|
+
}
|
|
202
|
+
/** Read one array-valued field, ignoring anything that is not an array. */
|
|
203
|
+
function listOf(value) {
|
|
204
|
+
return Array.isArray(value) ? value : [];
|
|
205
|
+
}
|
|
206
|
+
/** Trim one value to `limit` characters; anything that is not a string becomes ''. */
|
|
207
|
+
function boundedText(value, limit) {
|
|
208
|
+
return typeof value === 'string' ? value.trim().slice(0, limit) : '';
|
|
209
|
+
}
|
|
210
|
+
/** Cut `text` to `limit` characters, preferring the last whole line. */
|
|
211
|
+
function truncateText(text, limit) {
|
|
212
|
+
if (limit <= 0)
|
|
213
|
+
return '';
|
|
214
|
+
if (text.length <= limit)
|
|
215
|
+
return text;
|
|
216
|
+
const cut = text.slice(0, limit);
|
|
217
|
+
const lastBreak = cut.lastIndexOf('\n');
|
|
218
|
+
return lastBreak > 0 ? cut.slice(0, lastBreak) : cut;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Cleaned items of one bullet section: trimmed, empty dropped, exact duplicates
|
|
222
|
+
* collapsed in insertion order, oldest entries cut past the limit.
|
|
223
|
+
*/
|
|
224
|
+
function mergeItems(base, added) {
|
|
225
|
+
const seen = new Set();
|
|
226
|
+
for (const raw of [...base, ...added]) {
|
|
227
|
+
const value = boundedText(raw, HANDOFF_TEXT_LIMIT);
|
|
228
|
+
if (value !== '')
|
|
229
|
+
seen.add(value);
|
|
230
|
+
}
|
|
231
|
+
const items = [...seen];
|
|
232
|
+
return items.slice(Math.max(0, items.length - HANDOFF_ITEMS_LIMIT));
|
|
233
|
+
}
|
|
234
|
+
/** Clean every item of a bullet section, for rendering only. */
|
|
235
|
+
function cleanItems(values) {
|
|
236
|
+
return mergeItems([], values);
|
|
237
|
+
}
|
|
238
|
+
/** Clean one task, or undefined when it names no goal. */
|
|
239
|
+
function cleanTask(value) {
|
|
240
|
+
if (typeof value !== 'object' || value === null)
|
|
241
|
+
return undefined;
|
|
242
|
+
const raw = value;
|
|
243
|
+
const goal = boundedText(raw['goal'], HANDOFF_TEXT_LIMIT);
|
|
244
|
+
if (goal === '')
|
|
245
|
+
return undefined;
|
|
246
|
+
const avoid = boundedText(raw['avoid'], HANDOFF_TEXT_LIMIT);
|
|
247
|
+
return {
|
|
248
|
+
goal,
|
|
249
|
+
files: mergeItems([], listOf(raw['files'])),
|
|
250
|
+
acceptance: boundedText(raw['acceptance'], HANDOFF_TEXT_LIMIT),
|
|
251
|
+
...avoid === '' ? {} : { avoid },
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/** Clean every task, dropping the ones without a goal. */
|
|
255
|
+
function cleanTasks(values) {
|
|
256
|
+
const tasks = [];
|
|
257
|
+
for (const value of values) {
|
|
258
|
+
const task = cleanTask(value);
|
|
259
|
+
if (task !== undefined)
|
|
260
|
+
tasks.push(task);
|
|
261
|
+
}
|
|
262
|
+
return tasks;
|
|
263
|
+
}
|
|
264
|
+
/** Clean a task list, keeping one task per goal in order, up to the limit. */
|
|
265
|
+
function boundedTasks(values) {
|
|
266
|
+
const byGoal = new Map();
|
|
267
|
+
for (const value of values) {
|
|
268
|
+
const task = cleanTask(value);
|
|
269
|
+
if (task !== undefined && !byGoal.has(task.goal))
|
|
270
|
+
byGoal.set(task.goal, task);
|
|
271
|
+
}
|
|
272
|
+
const tasks = [...byGoal.values()];
|
|
273
|
+
return tasks.slice(Math.max(0, tasks.length - HANDOFF_TASKS_LIMIT));
|
|
274
|
+
}
|
|
275
|
+
/** Clean one change entry, or undefined when it names no file. */
|
|
276
|
+
function cleanChange(value) {
|
|
277
|
+
if (typeof value !== 'object' || value === null)
|
|
278
|
+
return undefined;
|
|
279
|
+
const raw = value;
|
|
280
|
+
const file = boundedText(raw['file'], HANDOFF_TEXT_LIMIT);
|
|
281
|
+
if (file === '')
|
|
282
|
+
return undefined;
|
|
283
|
+
return { file, summary: boundedText(raw['summary'], HANDOFF_TEXT_LIMIT) };
|
|
284
|
+
}
|
|
285
|
+
/** Clean every change entry, dropping the ones without a file. */
|
|
286
|
+
function cleanChanges(values) {
|
|
287
|
+
const changes = [];
|
|
288
|
+
for (const value of values) {
|
|
289
|
+
const change = cleanChange(value);
|
|
290
|
+
if (change !== undefined)
|
|
291
|
+
changes.push(change);
|
|
292
|
+
}
|
|
293
|
+
return changes;
|
|
294
|
+
}
|
|
295
|
+
/** Merge change lists by file: the newest summary wins, in first-seen order. */
|
|
296
|
+
function mergeChanges(base, added) {
|
|
297
|
+
const byFile = new Map();
|
|
298
|
+
for (const raw of [...base, ...added]) {
|
|
299
|
+
const change = cleanChange(raw);
|
|
300
|
+
if (change !== undefined)
|
|
301
|
+
byFile.set(change.file, change);
|
|
302
|
+
}
|
|
303
|
+
const changes = [...byFile.values()];
|
|
304
|
+
return changes.slice(Math.max(0, changes.length - HANDOFF_CHANGES_LIMIT));
|
|
305
|
+
}
|
|
306
|
+
/** `label: a; b` for one non-empty bullet section, or nothing. */
|
|
307
|
+
function pushItems(lines, label, values) {
|
|
308
|
+
const items = cleanItems(values);
|
|
309
|
+
if (items.length > 0)
|
|
310
|
+
lines.push(`${label}: ${items.join('; ')}`);
|
|
311
|
+
}
|
|
312
|
+
/** The `Goal:` fragment, or nothing when no goal is stated. */
|
|
313
|
+
function goalSection(goal) {
|
|
314
|
+
const text = boundedText(goal, HANDOFF_TEXT_LIMIT);
|
|
315
|
+
return text === '' ? undefined : `Goal:\n${text}`;
|
|
316
|
+
}
|
|
317
|
+
/** The `Delivered:` fragment(上一轮交付了什么 + 证据),or nothing when absent. */
|
|
318
|
+
function deliveredSection(value) {
|
|
319
|
+
const text = boundedText(value, HANDOFF_TEXT_LIMIT);
|
|
320
|
+
return text === '' ? undefined : `Delivered:\n${text}`;
|
|
321
|
+
}
|
|
322
|
+
/** A titled list, one `- item` per line, or nothing when the list is empty. */
|
|
323
|
+
function bulletSection(title, values) {
|
|
324
|
+
if (values.length === 0)
|
|
325
|
+
return undefined;
|
|
326
|
+
return `${title}\n${values.map(value => `- ${value}`).join('\n')}`;
|
|
327
|
+
}
|
|
328
|
+
/** The `Plan tasks:` fragment, three lines per task plus an avoid note. */
|
|
329
|
+
function taskSection(tasks) {
|
|
330
|
+
if (tasks.length === 0)
|
|
331
|
+
return undefined;
|
|
332
|
+
const lines = ['Plan tasks:'];
|
|
333
|
+
tasks.forEach((task, index) => {
|
|
334
|
+
lines.push(`${index + 1}. ${task.goal}`);
|
|
335
|
+
lines.push(` files: ${task.files.length === 0 ? '(none)' : task.files.join(', ')}`);
|
|
336
|
+
lines.push(` done: ${task.acceptance}`);
|
|
337
|
+
if (task.avoid !== undefined)
|
|
338
|
+
lines.push(` avoid: ${task.avoid}`);
|
|
339
|
+
});
|
|
340
|
+
return lines.join('\n');
|
|
341
|
+
}
|
|
342
|
+
/** The `Changes:` fragment, one `- file — summary` line per entry. */
|
|
343
|
+
function changeSection(changes) {
|
|
344
|
+
if (changes.length === 0)
|
|
345
|
+
return undefined;
|
|
346
|
+
return `Changes:\n${changes.map(change => `- ${change.file} — ${change.summary}`).join('\n')}`;
|
|
347
|
+
}
|