iterate-plugin 2.12.2 → 3.2.1
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 +28 -12
- package/README.zh-CN.md +2 -1
- package/dist/approval-gate.js +16 -2
- package/dist/config-loader.js +5 -0
- package/dist/git-scope.js +61 -7
- package/dist/index.js +16 -6
- package/dist/session-hooks.js +36 -11
- package/dist/skill-prompt.js +3 -0
- package/dist/tools/decision-log.js +10 -1
- package/dist/tools/defense-events.js +260 -0
- package/dist/tools/defense-store.js +97 -0
- package/dist/tools/experience-bank.js +248 -0
- package/dist/tools/experience-store.js +132 -0
- package/dist/tools/quality-gate.js +180 -0
- package/dist/tools/quality-store.js +174 -0
- package/lib/client.js +662 -103
- package/lib/parse.js +93 -0
- package/package.json +7 -6
- package/src/approval-gate.ts +14 -2
- package/src/client/index.ts +542 -49
- package/src/config-loader.ts +5 -0
- package/src/git-scope.ts +48 -7
- package/src/index.ts +16 -6
- package/src/session-hooks.ts +33 -11
- package/src/skill-prompt.ts +3 -0
- package/src/tools/checkpoint.ts +1 -1
- package/src/tools/config.ts +1 -1
- package/src/tools/decision-log.ts +11 -2
- package/src/tools/defense-events.ts +295 -0
- package/src/tools/defense-store.ts +113 -0
- package/src/tools/experience-bank.ts +264 -0
- package/src/tools/experience-store.ts +160 -0
- package/src/tools/fix.ts +1 -1
- package/src/tools/history.ts +1 -1
- package/src/tools/prune.ts +1 -1
- package/src/tools/quality-gate.ts +193 -0
- package/src/tools/quality-store.ts +199 -0
- package/src/tools/review.ts +1 -1
- package/src/tools/transcript.ts +1 -1
- package/src/tools/triage.ts +1 -1
- package/src/types.ts +118 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# iterate-plugin for DeepSeek Harness (dsh)
|
|
2
2
|
|
|
3
|
-
> dsh 桌面端的 iterate
|
|
4
|
-
> The iterate ecosystem's
|
|
3
|
+
> dsh 桌面端的 iterate 质量指挥中心 + 经验银行插件(v3.1)。把 iterate 生态的同一套 review/fix loop 直接搬进 dsh 界面,新增质量门禁、经验银行、防御事件流与原生指挥操作。
|
|
4
|
+
> The iterate ecosystem's quality command center + experience bank plugin for dsh (v3.1). Natively embedded inside the DeepSeek Harness (dsh) desktop client with quality gates, experience bank, defense events stream, and native command buttons.
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
7
|
<a href="README.md"><strong>English</strong></a> ·
|
|
@@ -61,7 +61,9 @@ dsh plugin --profile web add iterate-plugin
|
|
|
61
61
|
|
|
62
62
|
`iterate-plugin` is the [iterate](https://github.com/jingzhao-l/iterate-skill) integration for the [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness) desktop client. It brings iterate's review loop (review → triage → fix → validate → converge) directly into the dsh UI, offering **autonomous closed-loop code iteration** (normal mode) and **dry-run read-only multi-round review**.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
**v3.1 Quality Command Center**: The plugin has been upgraded from a "passive observation panel" to an "active command center + knowledge base". New features include quality gate view, experience bank, defense events stream, native command buttons, and task_mode indicator.
|
|
65
|
+
|
|
66
|
+
Besides 17 pure-function tools, it ships a **build-free Web UI layer** (convergence dashboard, triage panel, stats card, observatory panel with 10 tabs, theme skin, etc.) that plugs straight into dsh's existing UI slots. Configuration (`iterate.config.yaml` and the review dimensions) is identical across the other two components of the iterate ecosystem ([skill](https://github.com/jingzhao-l/iterate-skill) / [headless engine](https://github.com/jingzhao-l/iterate-harness)) — zero migration cost.
|
|
65
67
|
|
|
66
68
|
## Features
|
|
67
69
|
|
|
@@ -81,22 +83,28 @@ Besides 13 pure-function tools, it ships a **build-free Web UI layer** (triage p
|
|
|
81
83
|
| Fix atomic findings only, keep architectural for later | ❌ | ✅ |
|
|
82
84
|
| Breakpoint save / resume (long iterations) | ✅ | ✅ |
|
|
83
85
|
|
|
84
|
-
### Tool layer
|
|
86
|
+
### Tool layer (v3.1: 17 tools)
|
|
85
87
|
|
|
86
|
-
- **
|
|
88
|
+
- **17 registered tools** (14 original + 3 v3.1 quality command center tools):
|
|
89
|
+
- Original: `iterate_config` / `iterate_validate` / `iterate_decision_log` / `iterate_context` / `iterate_review` / `iterate_triage` / `iterate_fix` / `iterate_diff` / `iterate_rollback` / `iterate_checkpoint` / `iterate_status` / `iterate_history` / `iterate_prune` / `iterate_transcript`
|
|
90
|
+
- v3.1/v3.2: `iterate_experience` (list/search/get/**add**) / `iterate_quality_gate` (read/**compute**) / `iterate_defense_events` (list/counts/**record**)
|
|
87
91
|
- **Findings triage loop**: review → UI triage (y/n/a) → `iterate_triage` writes back `known_intentional` → auto-filtered next round
|
|
88
92
|
- **Structured fix system**: each fix backs up first, writes a registry entry, records the diff; a failed validation can be reverted with `iterate_rollback`
|
|
89
93
|
- **Breakpoint resume**: checkpoints saved at the start of each round; interrupted long iterations can resume
|
|
90
94
|
- **History audit**: `iterate_history` reads the decision log (filtered by type / time / count) and the fix registry summary to audit run process and fix details
|
|
91
95
|
- **Runtime cleanup**: `iterate_prune` removes stale decision-log entries, stale checkpoints, orphaned fix backups and empty rounds; dry-run by default (report-only), real cleanup requires `dryRun:false`, and every cleanup is logged
|
|
92
96
|
- **Config read / write**: `iterate_config` supports validated, backed-up, rollback-capable partial writes
|
|
97
|
+
- **v3.1/v3.2 Experience Bank**: `iterate_experience` queries historical fixes and patterns with search/filter/adopt, and can persist new verified fixes (`add`) — re-adding the same pattern+dimension bumps its hit count instead of duplicating it
|
|
98
|
+
- **v3.1/v3.2 Quality Gate**: `iterate_quality_gate` reads quality gate status with dimension convergence rates and PASS/FAIL, and can recompute + persist a fresh certificate (`compute`) from this round's findings/validation results (real convergence from `findingsByRound`)
|
|
99
|
+
- **v3.1/v3.2 Defense Events**: `iterate_defense_events` queries defense events (precondition failures, rollbacks, invariant violations, assumption falsifications) and can `record` new ones; readable labels follow the project language (en/zh)
|
|
93
100
|
|
|
94
|
-
### UI layer (build-free client slots)
|
|
101
|
+
### UI layer (build-free client slots, v3.1: 10 tabs)
|
|
95
102
|
|
|
96
103
|
| UI component | Mounted slot | Function |
|
|
97
104
|
| --- | --- | --- |
|
|
98
|
-
| ConvergenceDashboard | `conversation.input.dock` | Live round progress bar, severity stats, dimension badges, trend mini-chart above the input; normal mode also shows fix-count badges |
|
|
99
|
-
|
|
|
105
|
+
| ConvergenceDashboard | `conversation.input.dock` | Live round progress bar, severity stats, dimension badges, trend mini-chart above the input; normal mode also shows fix-count badges; plus a live workflow-phase chip (current phase + running/stopped); **v3.1: task_mode indicator (code/iterate)** |
|
|
106
|
+
| ObservatoryPanel | `conversation.input.dock` | **Ten-tab** runtime observatory below the input: live activity stream (type filter), review threads (expand/collapse all), convergence trend, finding locations (severity/dimension/search filter), fixes + rollback, checkpoint resume, decision timeline (type/round filter + search); **v3.1: Quality Gate (F8)**, **Experience Bank (F9)**, **Defense Events (F10)**; one-click export of all observatory data to JSON (download, copy fallback) |
|
|
107
|
+
| TriagePanel | `conversation.chat.turnTail` | Per-finding y/n/a triage, filtering, batch (incl. select-all), keyboard shortcuts, localStorage persistence, copy-YAML / apply-instruction; **v3.1: Native command buttons (approve architectural fix, trigger new round, rollback to checkpoint)** |
|
|
100
108
|
| StatsCard | `conversation.chat.turnTail` | When no findings remain: convergence stats, round history table, trend chart, completion summary |
|
|
101
109
|
| iterate theme skin | `theme.overrideTokens` | Warm-amber 13-dsw-token override, light/dark modes, togglable in settings |
|
|
102
110
|
| ProgressCapsule | `shell.overlay` | Popup notification on each round completion / convergence (incl. convergence confirm) |
|
|
@@ -211,7 +219,7 @@ validation:
|
|
|
211
219
|
|
|
212
220
|
> The config can be read and **validated-partially-written** via `iterate_config` (auto backup, auto rollback on write failure).
|
|
213
221
|
|
|
214
|
-
## Registered tools (
|
|
222
|
+
## Registered tools (v3.1: 17)
|
|
215
223
|
|
|
216
224
|
| Tool | Function |
|
|
217
225
|
| --- | --- |
|
|
@@ -228,6 +236,10 @@ validation:
|
|
|
228
236
|
| `iterate_status` | Summarize current iteration state: mode, current/last round, fixes applied, remaining architectural, decision-log entry count, whether a checkpoint exists |
|
|
229
237
|
| `iterate_history` | Read iteration history (read-only): decision-log entries (filter by `type` / `since` / `limit`, default latest 50, cap 200) + fix-registry summary (per-round fixed/failed counts). For auditing the run, tracing logs, and inventorying fixes |
|
|
230
238
|
| `iterate_prune` | Clean runtime artifacts: stale decision-log entries (by `retainDays`, default 30), stale checkpoints, orphaned fix backups, empty rounds. Dry-run by default (report-only); real cleanup with `dryRun:false`, each cleanup logged |
|
|
239
|
+
| `iterate_transcript` | Runtime observatory: persist review transcripts, threads, fixes, and nudge directions to `.iterate/transcript.json` for the client observatory |
|
|
240
|
+
| `iterate_experience` | **v3.1/v3.2** Query the experience bank (list/search/get), or `add` a new verified fix: re-adding the same pattern+dimension bumps its hit count instead of duplicating it. Persists to `.iterate/experience.json` |
|
|
241
|
+
| `iterate_quality_gate` | **v3.1/v3.2** Read the quality certificate (`read`), or recompute + persist a fresh one (`compute`) from findings, validation results, `findingsByRound`, and `fixedByDimension`. Real per-dimension convergence rates |
|
|
242
|
+
| `iterate_defense_events` | **v3.1/v3.2** Query defense events (list/counts), or `record` a new one. Human-readable labels follow the project language (en/zh) |
|
|
231
243
|
|
|
232
244
|
## Runtime artifact layout
|
|
233
245
|
|
|
@@ -239,6 +251,9 @@ All runtime state lives under `.iterate/` at the project root (can be excluded v
|
|
|
239
251
|
checkpoint.json # iteration breakpoint (resume)
|
|
240
252
|
transcript.json # runtime-observatory manifest (per-reviewer threads, trend, fixes, timeline, nudge)
|
|
241
253
|
transcript-live.ndjson # append-only near-real-time reviewer-activity feed (read/fix/rollback/validate…), byte-capped
|
|
254
|
+
experience.json # v3.1: experience bank (historical fixes and patterns, accumulated across sessions)
|
|
255
|
+
quality-gate.json # v3.1: quality gate snapshot (dimension convergence, verification pass rates, PASS/FAIL)
|
|
256
|
+
defense-events.json # v3.1: defense events stream (precondition failures, rollbacks, invariant violations, assumption falsifications)
|
|
242
257
|
fixes/
|
|
243
258
|
registry.json # fix registry (list of FixRecords, grouped by round)
|
|
244
259
|
<fix-id>_<ts>.bak # original file backup before each fix
|
|
@@ -248,11 +263,12 @@ All runtime state lives under `.iterate/` at the project root (can be excluded v
|
|
|
248
263
|
|
|
249
264
|
The plugin follows dsh's "everything-is-a-plugin" architecture:
|
|
250
265
|
|
|
251
|
-
- **Does exactly two things**: injects the system prompt teaching the model the iterate workflow + registers
|
|
266
|
+
- **Does exactly two things**: injects the system prompt teaching the model the iterate workflow + registers 17 pure-function tools
|
|
252
267
|
- **All orchestration runs through dsh native `workflow` + `agent` + `parallel`**
|
|
253
268
|
- **Core logic is entirely pure functions** (dedupe / filter / sort / converge / meta-audit / diff computation / history filtering / cleanup reporting) — unit-testable, no I/O
|
|
254
269
|
- **Security model**: file writes confined to the resolved project root (path-traversal protection); always back up before writing, roll back on failure; config writes also back up + roll back; `iterate_prune` is dry-run by default and only clears artifacts under `.iterate/` with every cleanup logged; `iterate_fix` caps content length and `iterate_triage` caps entry count to fend off abnormal oversized payloads
|
|
255
270
|
- **Build-free UI**: `lib/client.js` uses a `React.createElement` tree + injected `<style>` tags, all colors via `--dsw-*` tokens, degrading gracefully when a service is missing
|
|
271
|
+
- **v3.1 Quality Command Center**: extends the plugin from "passive observation panel" to "active command center + knowledge base" with quality gates, experience bank, defense events, and native command buttons
|
|
256
272
|
- Follows the iterate skill's design principles: deterministic convergence, auditable, least privilege
|
|
257
273
|
|
|
258
274
|
## Running the tests
|
|
@@ -266,8 +282,8 @@ npm test
|
|
|
266
282
|
|
|
267
283
|
All tests pass:
|
|
268
284
|
|
|
269
|
-
- **
|
|
270
|
-
- Coverage: dedupe, filter, sort, multi-round convergence, meta-review audit, path safety, timeout clamping, config read/write + rollback, triage merge, diff computation, checkpoint validation, fix registry, history read + filter, prune cleanup report + dry-run semantics, UI pure functions (select-all key, runtime status guide).
|
|
285
|
+
- **426 unit tests green**, type-check clean
|
|
286
|
+
- Coverage: dedupe, filter, sort, multi-round convergence, meta-review audit, path safety, timeout clamping, config read/write + rollback, triage merge, diff computation, checkpoint validation, fix registry, history read + filter, prune cleanup report + dry-run semantics, UI pure functions (select-all key, runtime status guide), **v3.1: experience bank, quality gate, defense events**.
|
|
271
287
|
|
|
272
288
|
## ⚠️ Disclaimer
|
|
273
289
|
|
package/README.zh-CN.md
CHANGED
|
@@ -95,7 +95,8 @@ dsh plugin --profile web add iterate-plugin
|
|
|
95
95
|
|
|
96
96
|
| UI 组件 | 挂载槽位 | 功能 |
|
|
97
97
|
|---------|---------|------|
|
|
98
|
-
| 收敛看板 `ConvergenceDashboard` | `conversation.input.dock` | 输入框上方实时显示轮次进度条、严重度统计、维度徽章、趋势迷你图,normal
|
|
98
|
+
| 收敛看板 `ConvergenceDashboard` | `conversation.input.dock` | 输入框上方实时显示轮次进度条、严重度统计、维度徽章、趋势迷你图,normal 模式另显示修复计数徽章;并显示运行阶段芯片(当前工作流阶段 + 运行中/已结束) |
|
|
99
|
+
| 运行时观测台 `ObservatoryPanel` | `conversation.input.dock` | 输入框下方七个标签页:实时活动流(支持按活动类型筛选)、审查线程(支持全部展开/全部收起)、收敛趋势、发现定位(支持按严重度/维度/关键词筛选)、修复与回滚、断点恢复、决策时间线(支持按类型/轮次筛选与关键词搜索);支持一键导出全部观测数据为 JSON(优先下载,失败回退复制) |
|
|
99
100
|
| Findings 分诊面板 `TriagePanel` | `conversation.chat.turnTail` | 逐条 y/n/a 判定,支持筛选、批量(含一键全选所有 findings)、键盘快捷键、localStorage 持久化、复制 YAML/应用指令 |
|
|
100
101
|
| 收敛统计卡片 `StatsCard` | `conversation.chat.turnTail` | 无 findings 时显示收敛统计、历史轮次表、趋势图、完成摘要 |
|
|
101
102
|
| iterate 主题皮肤 | `theme.overrideTokens` | 暖琥珀配色的 13 个 dsw token 覆盖,明暗双模式,可在设置页开关 |
|
package/dist/approval-gate.js
CHANGED
|
@@ -46,12 +46,26 @@ function describe(toolName, arguments0) {
|
|
|
46
46
|
* deployments, and for any non-iterate tool.
|
|
47
47
|
*/
|
|
48
48
|
export function decideApproval(execution, policy) {
|
|
49
|
-
|
|
49
|
+
// Defensive reads: a hostile/proxied execution object must degrade to "not
|
|
50
|
+
// our tool" (allow) rather than throw inside the gate.
|
|
51
|
+
let name = '';
|
|
52
|
+
try {
|
|
53
|
+
name = typeof execution?.name === 'string' ? execution.name : '';
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
name = '';
|
|
57
|
+
}
|
|
50
58
|
if (!name)
|
|
51
59
|
return { kind: 'allow' };
|
|
52
60
|
if (!DESTRUCTIVE_TOOLS.has(name))
|
|
53
61
|
return { kind: 'allow' };
|
|
54
|
-
|
|
62
|
+
let rawArgs;
|
|
63
|
+
try {
|
|
64
|
+
rawArgs = execution.arguments;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
rawArgs = undefined;
|
|
68
|
+
}
|
|
55
69
|
const args = rawArgs && typeof rawArgs === 'object' && !Array.isArray(rawArgs)
|
|
56
70
|
? rawArgs
|
|
57
71
|
: {};
|
package/dist/config-loader.js
CHANGED
|
@@ -191,6 +191,11 @@ export function validateConfig(config) {
|
|
|
191
191
|
*/
|
|
192
192
|
export function resolveProjectRoot(input, sessionCwd) {
|
|
193
193
|
const raw = (input ?? '').trim();
|
|
194
|
+
// A NUL byte can never name a real path and makes `resolve()` (and every
|
|
195
|
+
// downstream fs call) throw — treat it as unsafe input, not a throw path.
|
|
196
|
+
if (raw.includes('\0')) {
|
|
197
|
+
return { ok: false, reason: 'Refusing project root containing NUL bytes.' };
|
|
198
|
+
}
|
|
194
199
|
const root = raw ? resolve(raw) : resolve(effectiveCwd(sessionCwd));
|
|
195
200
|
if (!root || root === sep) {
|
|
196
201
|
return { ok: false, reason: 'Refusing filesystem root as project root.' };
|
package/dist/git-scope.js
CHANGED
|
@@ -29,6 +29,64 @@ import { join } from 'node:path';
|
|
|
29
29
|
* NUL is present (callers that did not pass -z) fall back to newline-split
|
|
30
30
|
* with C-style quote/escape unescaping for core.quotePath output.
|
|
31
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* Decode the quoted body of a git core.quotePath output line into the real
|
|
34
|
+
* filename bytes, then interpret them as UTF-8.
|
|
35
|
+
*
|
|
36
|
+
* Single-pass and escape-atomic: each `\` consumes exactly one escape (\" \\
|
|
37
|
+
* \t \n or a 3-digit octal for a raw byte), so a literal `\\303` in a filename
|
|
38
|
+
* (escaped backslash + literal "303") is decoded as the byte `\` followed by
|
|
39
|
+
* ASCII "303" rather than as the single byte 0xC3. Ordinary characters in the
|
|
40
|
+
* quoted body are ASCII (git always octal-escapes non-ASCII bytes), so they map
|
|
41
|
+
* 1:1 to bytes.
|
|
42
|
+
*/
|
|
43
|
+
function decodeQuotedPath(content) {
|
|
44
|
+
const bytes = [];
|
|
45
|
+
let i = 0;
|
|
46
|
+
while (i < content.length) {
|
|
47
|
+
const ch = content[i];
|
|
48
|
+
if (ch !== '\\') {
|
|
49
|
+
bytes.push(ch.charCodeAt(0));
|
|
50
|
+
i++;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const next = content[i + 1];
|
|
54
|
+
if (next === '"') {
|
|
55
|
+
bytes.push(0x22);
|
|
56
|
+
i += 2;
|
|
57
|
+
}
|
|
58
|
+
else if (next === '\\') {
|
|
59
|
+
bytes.push(0x5c);
|
|
60
|
+
i += 2;
|
|
61
|
+
}
|
|
62
|
+
else if (next === 't') {
|
|
63
|
+
bytes.push(0x09);
|
|
64
|
+
i += 2;
|
|
65
|
+
}
|
|
66
|
+
else if (next === 'n') {
|
|
67
|
+
bytes.push(0x0a);
|
|
68
|
+
i += 2;
|
|
69
|
+
}
|
|
70
|
+
else if (next !== undefined && next >= '0' && next <= '7') {
|
|
71
|
+
const oct = content.slice(i + 1, i + 4);
|
|
72
|
+
if (oct.length === 3 && /^[0-7]{3}$/.test(oct)) {
|
|
73
|
+
bytes.push(parseInt(oct, 8));
|
|
74
|
+
i += 4;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Malformed octal — keep the backslash literally.
|
|
78
|
+
bytes.push(0x5c);
|
|
79
|
+
i++;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Unknown escape — keep the backslash literally.
|
|
84
|
+
bytes.push(0x5c);
|
|
85
|
+
i++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return Buffer.from(bytes).toString('utf-8');
|
|
89
|
+
}
|
|
32
90
|
export function parseChangedFiles(stdout) {
|
|
33
91
|
if (stdout.includes('\0')) {
|
|
34
92
|
return stdout.split('\0').map((s) => s.trim()).filter((s) => s.length > 0);
|
|
@@ -38,16 +96,12 @@ export function parseChangedFiles(stdout) {
|
|
|
38
96
|
.map((line) => {
|
|
39
97
|
const trimmed = line.trim();
|
|
40
98
|
// git core.quotePath wraps paths with special characters in "..."; the
|
|
41
|
-
// content uses C-style escapes (\" \\ \t \n and \ooo octal for
|
|
99
|
+
// content uses C-style escapes (\" \\ \t \n) and \ooo octal escapes for
|
|
100
|
+
// non-ASCII bytes (which are raw UTF-8 BYTES, not Latin-1 code points).
|
|
42
101
|
const quoted = trimmed.match(/^"(.*)"$/);
|
|
43
102
|
if (!quoted)
|
|
44
103
|
return trimmed;
|
|
45
|
-
return quoted[1]
|
|
46
|
-
.replace(/\\"/g, '"')
|
|
47
|
-
.replace(/\\\\/g, '\\')
|
|
48
|
-
.replace(/\\t/g, '\t')
|
|
49
|
-
.replace(/\\n/g, '\n')
|
|
50
|
-
.replace(/\\([0-7]{3})/g, (_m, oct) => String.fromCharCode(parseInt(oct, 8)));
|
|
104
|
+
return decodeQuotedPath(quoted[1]);
|
|
51
105
|
})
|
|
52
106
|
.filter((line) => line.length > 0);
|
|
53
107
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
* iterate-plugin — dsh plugin for the iterate autonomous closed-loop workflow
|
|
3
3
|
*
|
|
4
4
|
* Architecture:
|
|
5
|
-
* - The plugin registers
|
|
6
|
-
*
|
|
5
|
+
* - The plugin registers 17 tools (14 original + 3 v3.0 quality command center tools)
|
|
6
|
+
* Original: config, validate, decision-log, context, review, triage, fix, diff,
|
|
7
|
+
* rollback, checkpoint, status, history, prune, transcript
|
|
8
|
+
* v3.0: experience, quality_gate, defense_events
|
|
7
9
|
* - The plugin injects a system prompt section teaching the iterate workflow pattern
|
|
8
10
|
* - The model (prompted by the skill) writes a workflow script using dsh's `workflow` tool
|
|
9
11
|
* - The workflow script uses `agent()` / `parallel()` / `phase()` / `log()` to orchestrate
|
|
10
|
-
* - Subagents use the
|
|
11
|
-
* review, triage, apply/rollback/fixing, checkpoint, status, history, prune, transcript
|
|
12
|
+
* - Subagents use the 17 tools to do real work (read config, run validation, log decisions,
|
|
13
|
+
* review, triage, apply/rollback/fixing, checkpoint, status, history, prune, transcript,
|
|
14
|
+
* query experience bank, check quality gates, query defense events)
|
|
12
15
|
* - A `tools/pre-execute` hook gates destructive iterate calls behind human approval
|
|
13
16
|
* (F8 observatory approval policy: ask / deny / allow).
|
|
14
17
|
*
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
*
|
|
21
24
|
* Key files:
|
|
22
25
|
* - src/index.ts — Plugin entry: register tools + inject skill prompt
|
|
23
|
-
* - src/tools/ —
|
|
26
|
+
* - src/tools/ — 17 tool implementations (14 original + 3 v3.0)
|
|
24
27
|
* - src/config-loader.ts — YAML config loading
|
|
25
28
|
* - src/types.ts — Shared types
|
|
26
29
|
*/
|
|
@@ -35,13 +38,16 @@ import { registerCheckpointTool, registerStatusTool } from "./tools/checkpoint.j
|
|
|
35
38
|
import { registerHistoryTool } from "./tools/history.js";
|
|
36
39
|
import { registerPruneTool } from "./tools/prune.js";
|
|
37
40
|
import { registerTranscriptTool } from "./tools/transcript.js";
|
|
41
|
+
import { registerExperienceBankTool } from "./tools/experience-bank.js";
|
|
42
|
+
import { registerQualityGateTool } from "./tools/quality-gate.js";
|
|
43
|
+
import { registerDefenseEventsTool } from "./tools/defense-events.js";
|
|
38
44
|
import { registerSessionHooks } from "./session-hooks.js";
|
|
39
45
|
import { registerLiveCapture } from "./live.js";
|
|
40
46
|
import { ITERATE_SKILL_PROMPT } from "./skill-prompt.js";
|
|
41
47
|
export const name = 'iterate-plugin';
|
|
42
48
|
export const inject = ['tools', 'systemPrompt'];
|
|
43
49
|
export function apply(ctx) {
|
|
44
|
-
// 1. Register the 14
|
|
50
|
+
// 1. Register the 17 tools (14 original + 3 v3.0)
|
|
45
51
|
registerConfigTool(ctx);
|
|
46
52
|
registerValidateTool(ctx);
|
|
47
53
|
registerDecisionLogTool(ctx);
|
|
@@ -56,6 +62,10 @@ export function apply(ctx) {
|
|
|
56
62
|
registerHistoryTool(ctx);
|
|
57
63
|
registerPruneTool(ctx);
|
|
58
64
|
registerTranscriptTool(ctx);
|
|
65
|
+
// v3.0: Quality Command Center tools
|
|
66
|
+
registerExperienceBankTool(ctx);
|
|
67
|
+
registerQualityGateTool(ctx);
|
|
68
|
+
registerDefenseEventsTool(ctx);
|
|
59
69
|
// 2. Wire the observatory approval gate onto dsh's tools/pre-execute waterfall,
|
|
60
70
|
// and the live reviewer-activity feed onto tools/result.
|
|
61
71
|
registerSessionHooks(ctx);
|
package/dist/session-hooks.js
CHANGED
|
@@ -32,17 +32,36 @@ import { decideApproval, isDestructiveIterateTool } from "./approval-gate.js";
|
|
|
32
32
|
* Returns a dsh `PreToolDecision` so the caller can short-circuit the caller.
|
|
33
33
|
*/
|
|
34
34
|
export function gateDecision(exec) {
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
|
|
35
|
+
// Defensively read the tool name: an exec handed to the waterfall is an
|
|
36
|
+
// ordinary object, but a hostile/proxied exec must degrade to "not our tool"
|
|
37
|
+
// (allow) instead of throwing before classification. The gate only ever
|
|
38
|
+
// inspects iterate tools, so an unreadable name also must not alter
|
|
39
|
+
// unrelated tooling.
|
|
40
|
+
let name = '';
|
|
41
|
+
try {
|
|
42
|
+
name = exec?.name ?? '';
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
name = '';
|
|
46
|
+
}
|
|
47
|
+
if (!isDestructiveIterateTool(name))
|
|
38
48
|
return { kind: 'allow' };
|
|
39
49
|
// Resolve the project root (use the call's own `path` arg, else the agent's
|
|
40
50
|
// session cwd) to read the effective observatory policy.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
let argPath;
|
|
52
|
+
let sessionCwd;
|
|
53
|
+
try {
|
|
54
|
+
const args = exec?.arguments;
|
|
55
|
+
if (args && typeof args === 'object' && !Array.isArray(args)) {
|
|
56
|
+
const p = args.path;
|
|
57
|
+
if (typeof p === 'string')
|
|
58
|
+
argPath = p;
|
|
59
|
+
}
|
|
60
|
+
sessionCwd = exec?.agent?.session?.header?.cwd;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// hostile/proxied exec — fall through with both undefined (defaults to ask)
|
|
64
|
+
}
|
|
46
65
|
const resolved = resolveProjectRoot(argPath, sessionCwd);
|
|
47
66
|
let policy = 'ask';
|
|
48
67
|
if (resolved.ok) {
|
|
@@ -67,13 +86,19 @@ export function gateDecision(exec) {
|
|
|
67
86
|
*/
|
|
68
87
|
export function registerSessionHooks(ctx) {
|
|
69
88
|
ctx.on('tools/pre-execute', (exec, next) => {
|
|
70
|
-
//
|
|
89
|
+
// Fail-safe: a throwing gate must never fail OPEN. Degrade to `ask` so a
|
|
90
|
+
// destructive call still routes through human consent instead of running
|
|
91
|
+
// via `next()`'s allow default (matches the header's documented contract).
|
|
71
92
|
let decision;
|
|
72
93
|
try {
|
|
73
94
|
decision = gateDecision(exec);
|
|
74
95
|
}
|
|
75
|
-
catch {
|
|
76
|
-
|
|
96
|
+
catch (err) {
|
|
97
|
+
console.warn('[iterate] approval gate failed; degrading to ask.', err);
|
|
98
|
+
return Promise.resolve({
|
|
99
|
+
kind: 'ask',
|
|
100
|
+
reason: 'iterate approval gate unavailable — require consent',
|
|
101
|
+
});
|
|
77
102
|
}
|
|
78
103
|
if (decision.kind === 'ask') {
|
|
79
104
|
// Delegate the actual human-consent prompt + audit to dsh's approval
|
package/dist/skill-prompt.js
CHANGED
|
@@ -23,6 +23,9 @@ You have the iterate plugin installed, which registers these tools:
|
|
|
23
23
|
- \`iterate_history\` — inspect the runtime state in detail: decision-log entries and applied fixes (optionally scoped to a round or a fixed file)
|
|
24
24
|
- \`iterate_prune\` — remove stale runtime artifacts (\`.iterate/\` entries). Defaults to a read-only dry-run that reports what WOULD be removed; pass \`dryRun:false\` to actually prune.
|
|
25
25
|
- \`iterate_transcript\` — runtime observatory file (\`.iterate/transcript.json\`). \`read\` fetches the persisted manifest including any steering \`nudge\` for this run's reviewers; \`capture\` (call once after the final report) persists the per-reviewer threads, convergence trend, findings, fixes, checkpoint, and timeline so the client observatory panel reflects the run; \`nudge\` sets/clears steering text the next round's reviewers read. Purely local, never touches source files.
|
|
26
|
+
- \`iterate_experience\` — experience bank (\`.iterate/experience.json\`): \`list\`/\`search\`/\`get\` recall verified fixes and patterns from past sessions (read the bank before fixing so proven fixes are applied first); \`add\` records a new verified fix — re-adding the same pattern+dimension bumps its hit count instead of duplicating it.
|
|
27
|
+
- \`iterate_quality_gate\` — quality certificate: \`read\` loads the persisted dimension convergence rates / verification pass rate / PASS-FAIL status; \`compute\` recomputes a fresh snapshot from this round's findings + validation results (supply \`findingsByRound\` for real convergence) and persists it to \`.iterate/quality-gate.json\`.
|
|
28
|
+
- \`iterate_defense_events\` — defense event stream (\`.iterate/defense-events.json\`): \`list\`/\`counts\` review precondition failures, rollbacks, invariant violations, and falsified assumptions; \`record\` logs a new event when a defense fires. Human-readable labels follow the project \`language\` (en/zh).
|
|
26
29
|
|
|
27
30
|
### When to use
|
|
28
31
|
When the user asks to review or iterate on the project (e.g. "review this project", "iterate on error handling", "check the codebase for issues", "dry-run review", "反复审查"), run an iterate **workflow** by calling the \`workflow\` tool.
|
|
@@ -57,7 +57,7 @@ export function appendDecisionEntry(projectRoot, entry) {
|
|
|
57
57
|
appendFileSync(filePath, line, 'utf-8');
|
|
58
58
|
}
|
|
59
59
|
catch (err) {
|
|
60
|
-
return { count:
|
|
60
|
+
return { count: 0, path: join(projectRoot, LOG_DIR, LOG_FILE), error: `failed to append decision log: ${String(err)}` };
|
|
61
61
|
}
|
|
62
62
|
// Count entries
|
|
63
63
|
let count = 0;
|
|
@@ -202,6 +202,15 @@ export function registerDecisionLogTool(ctx) {
|
|
|
202
202
|
data,
|
|
203
203
|
};
|
|
204
204
|
const result = appendDecisionEntry(projectRoot, entry);
|
|
205
|
+
if (result.error) {
|
|
206
|
+
return {
|
|
207
|
+
operation: 'append',
|
|
208
|
+
success: false,
|
|
209
|
+
entryCount: 0,
|
|
210
|
+
logPath: result.path,
|
|
211
|
+
error: result.error,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
205
214
|
return {
|
|
206
215
|
operation: 'append',
|
|
207
216
|
success: true,
|