pi-anchorloop 2.2.3 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-TW.md +2 -2
- package/package.json +1 -1
- package/pi/book.ts +215 -82
- package/pi/second-thought.ts +1 -1
- package/pi/support/book.ts +26 -9
- package/pi/support/phases.ts +98 -5
- package/pi/support/snapshot.ts +0 -3
- package/skills/anchorloop/SKILL.md +2 -2
- package/skills/coding/SKILL.md +7 -4
package/README.md
CHANGED
|
@@ -25,10 +25,10 @@ shared grilling · domain-modeling · human-feedback · agent-terse
|
|
|
25
25
|
|
|
26
26
|
| File | What it does |
|
|
27
27
|
| --- | --- |
|
|
28
|
-
| `pi/book.ts` | The loop book. The first `todo` create or `kind` call opens a loop; task records need the `todo` tool of [`@juicesharp/rpiv-todo`](https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-todo#readme) (its `tool_result` details `{tasks, nextId}` and `rpiv-todo-state` entries). The agent declares only what the extension cannot observe with `anchorloop_stage`: `kind` (`quick`, `inline`, `reviewed`, `durable`, with an intent and the anchor command), `verify` (a check not run in bash), `fresh-read`, `friction` (`tried`, `found`, `led_by`), `reflect`, `skip`, `back`, `close`, and the query `read`. Everything else is read from evidence: production edits (a write or edit in any git repo, outside its `scratch/` and `docs/specs/`; a linked child's edits and a successful `git merge`, `cherry-pick`, or `pull` count too), the exit code of the bash call that ran the anchor command (failed
|
|
28
|
+
| `pi/book.ts` | The loop book. The first `todo` create or `kind` call opens a loop; task records need the `todo` tool of [`@juicesharp/rpiv-todo`](https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-todo#readme) (its `tool_result` details `{tasks, nextId}` and `rpiv-todo-state` entries). The agent declares only what the extension cannot observe with `anchorloop_stage`: `kind` (`quick`, `inline`, `reviewed`, `durable`, with an intent and the anchor command; a later call changes the kind only with a `reason`), `verify` (a check not run in bash), `fresh-read`, `friction` (`tried`, `found`, `led_by`), `reflect`, `skip`, `back`, `close`, and the query `read`. Everything else is read from evidence: production edits (a write or edit in any git repo, outside its `scratch/` and `docs/specs/`; a linked child's edits and a successful `git merge`, `cherry-pick`, or `pull` count too), the exit code of the bash call that ran the anchor command (an anchor that passed, failed, and passed again records its own friction entry: the rerun command and the failed run's key line, at most 120 characters and never a stack trace, still waiting for a `reflect`), reviewer `Blocking: P0=<n> P1=<m>` counts, summaries of `docs/specs/*/` artifacts as they are edited, and a returned subagent that Jev judges to have been a fresh-context read of the spec. A phase machine over that evidence gives each kind a fixed sequence (`quick` act → check; `inline` anchor → act → verify; `reviewed` adds review; `durable` adds decide → grill → spec → read → approve → design; every kind ends with reflect → close), and `read` shows `<kind> · phase <current> ✓ → <next> (missing: …) · skipped: …`. The pi footer shows `anchorloop <kind> · <current> ✓ → <next>`, with the friction still to reflect, after every tool call and on `session_start`, and clears when the loop closes. An anchor run or declared verify of a `quick` or `inline` loop also measures the diff's reach: source files (not tests, lockfiles, specs, or prose), the top-level directories they sit in, and a README, changelog, or `*.schema.json` changed beside them. Files already changed when a repo joined the loop count only once their content changes, and a file at a repository root counts as a file, not a directory. At 3 source files, 2 directories, or one such file, the result carries one line asking to re-classify, and verify waits for a `kind` call with `reason` that answers each threshold crossed; a later threshold asks again. A phase that starts before an earlier one is complete warns once in one line and names the `skip` escape; phases regress when evidence changes or on `back`. The book also records each todo with its `anchor`, `ref` (`<path>#<heading>`, resolved to line ranges), and `followup` metadata. One YAML book per open loop lives under `~/.pi/agent/anchorloop/books/` (`ANCHORLOOP_BOOKS_DIR` overrides it; empty project and `agents/` directories are removed), subagent books under `agents/` (a child that closes keeps its book for the main session); `session_start` sweeps books whose session is gone or that have not changed in 7 days. `close` lists every phase as done, skipped, or auto-skipped and never refuses over phases or friction, only while a pending or in-progress todo lacks `metadata.followup` (a ticket id, `memory`, or `drop — <reason>`). |
|
|
29
29
|
| `pi/anchor-gate.ts` | Inside an open loop, shows one warning line when `write` or `edit` starts the `act` phase while an earlier phase of the loop kind is incomplete: no anchor (`anchor` on the `kind` call, a `Reality anchor:` line, or a skip), and in a `durable` loop a missing decision, spec, fresh read, approval, or design, read from the `docs/specs/<folder>/` files (found from the book, the intent, or a todo `ref`). It warns again only when a new phase goes missing; the call still goes through. Outside a loop and in `quick` loops it stays silent. `.md`, `.txt`, and `.html` files, `scratch/`, `docs/specs/`, and temp files outside the project pass silently. Edits made through `bash` are not checked. |
|
|
30
30
|
| `pi/decision-tool.ts` | The `anchorloop_decision` tool appends single-line, spreadsheet-safe rows to a decision trail TSV, or a `start` row when a run picks up another run's trail. |
|
|
31
|
-
| `pi/second-thought.ts` | Inside an open loop, asks Jev (TypeSafe's typed-decision model, through pi's classifier registry) to check the phase machine when a run settles and the loop book gained an entry since the last judgment, and at a `close` declaration. The program computes the next phase from the book; Jev sees the kind, intent, anchor, diff summary (≤1200 chars), `phase` (current, next, missing), verify state, open todos, the task list, and friction (a child's under its name), and judges only whether to `advance`, go `back`, or `ask-user`, plus `done`, the review tier still needed, and quality; phase completion comes from the program's evidence alone. The one-line advisory leads with `next → <phase
|
|
31
|
+
| `pi/second-thought.ts` | Inside an open loop, asks Jev (TypeSafe's typed-decision model, through pi's classifier registry) to check the phase machine when a run settles and the loop book gained an entry since the last judgment, and at a `close` declaration. The program computes the next phase from the book; Jev sees the kind, intent, anchor, diff summary (≤1200 chars), `phase` (current, next, missing), verify state, open todos, the task list, and friction (a child's under its name), and judges only whether to `advance`, go `back`, or `ask-user`, plus `done`, the review tier still needed, and quality; phase completion comes from the program's evidence alone. The one-line advisory leads with `next → <phase>`. The run continues once, only when Jev agrees to advance and the next phase is a verify, review, or fix; an advisory identical to the last one is not repeated, and a `full` rating after a clean review that follows the last change shows a note instead of a recheck. A run that called `MonitorCreate`, `LoopCreate`, `goal_wait`, or a `subagent` tool is waiting and is not judged. Without a TypeSafe key it does nothing, and outside a loop it never runs. In a subagent session (`PI_SUBAGENT_ID` from pi-herdr-agents, or `PI_SUBAGENT_CHILD` from pi-subagents) it registers nothing, since the agent that spawned it judges the result. |
|
|
32
32
|
| `pi/validate-tool-use.ts` | After each `write` or `edit`, validates the file in-process (`pi/support/validators.ts`, a port of `hooks/validators/`) and appends suggestions for `SKILL.md`, instruction files (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `rules/`), and `docs/specs/` artifacts. Needs no Python; the Python validators in `hooks/` remain for `validate_all.py` and the parity test. |
|
|
33
33
|
| `pi/ttsr.ts` | A port of oh-my-pi's Time Traveling Stream Rules. A Markdown rule in `~/.pi/agent/rules/` or `<project>/.pi/rules/` whose frontmatter has a `condition` regex is watched during the run. A match in streamed assistant text aborts the response, drops it, and retries with the rule injected; a match in tool arguments (the command for `bash`, the new text for `write` and `edit`) blocks the call with the rule as its reason. Frontmatter fields follow oh-my-pi: `condition`, `scope` (`text`, `thinking`, `tool`, `tool:bash`, `tool:edit(*.ts)`), `globs`, and `interruptMode` (`always`, `prose-only`, `tool-only`, `never`), plus `repeatMode` (`once` or `after-gap`) and `repeatGap`. A rule fires once per session by default. `astCondition`, `question`, and `agents` are not supported; a rule that uses them is skipped and reported. `/ttsr` lists the loaded rules. |
|
|
34
34
|
|
package/README.zh-TW.md
CHANGED
|
@@ -25,10 +25,10 @@ anchorloop 核心循環 · 原則 · playbook:autonomous-run、paus
|
|
|
25
25
|
|
|
26
26
|
| 檔案 | 作用 |
|
|
27
27
|
| --- | --- |
|
|
28
|
-
| `pi/book.ts` | Loop book。第一次 `todo` create 或 `kind` 呼叫會開啟一個 loop;任務紀錄需要 [`@juicesharp/rpiv-todo`](https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-todo#readme) 的 `todo` 工具(它的 `tool_result` details `{tasks, nextId}` 和 `rpiv-todo-state` 條目)。agent 只用 `anchorloop_stage` 宣告 extension 看不到的事:`kind`(`quick`、`inline`、`reviewed`、`durable`,附 intent 和 anchor
|
|
28
|
+
| `pi/book.ts` | Loop book。第一次 `todo` create 或 `kind` 呼叫會開啟一個 loop;任務紀錄需要 [`@juicesharp/rpiv-todo`](https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-todo#readme) 的 `todo` 工具(它的 `tool_result` details `{tasks, nextId}` 和 `rpiv-todo-state` 條目)。agent 只用 `anchorloop_stage` 宣告 extension 看不到的事:`kind`(`quick`、`inline`、`reviewed`、`durable`,附 intent 和 anchor 指令;之後要改種類,必須附 `reason`)、`verify`(不是指令的檢查)、`fresh-read`、`friction`(`tried`、`found`、`led_by`)、`reflect`、`skip`、`back`、`close`,以及查詢用的 `read`。其餘都從證據讀出:production 的修改(任何 git repo 內、`scratch/` 與 `docs/specs/` 以外的 write 或 edit;已連結 child 的修改,以及成功的 `git merge`、`cherry-pick`、`pull` 也算)、執行過 anchor 指令的那次 bash 的 exit code(anchor 通過後失敗、又再通過時,extension 會自己記一筆 friction:重跑的指令,加上失敗那次最關鍵的一行輸出,最多 120 字元,不放 stack trace;這筆仍要 `reflect` 分類)、reviewer 的 `Blocking: P0=<n> P1=<m>` 數字、`docs/specs/*/` 產出物每次編輯後的摘要,以及 Jev 判定為「全新 context 讀過 spec」的 subagent 回報。階段機依這些證據給每種 loop 固定的階段順序(`quick` 為 act → check;`inline` 為 anchor → act → verify;`reviewed` 加 review;`durable` 再加 decide → grill → spec → read → approve → design;每一種都以 reflect → close 結尾),`read` 顯示 `<種類> · phase <目前> ✓ → <下一個>(缺:…)· 已跳過:…`。pi 的 footer 會顯示 `anchorloop <種類> · <目前> ✓ → <下一個>`,以及還沒 reflect 的 friction 數;每次工具呼叫後和 `session_start` 時更新,loop 結案後清掉。`quick` 或 `inline` loop 跑 anchor 或宣告 verify 時,也會量 diff 的影響範圍:原始碼檔案(不含測試、lockfile、spec 與文字檔)、它們所在的頂層目錄,以及跟原始碼一起改的 README、changelog 或 `*.schema.json`。repo 加入 loop 時就已經改過的檔案,要等內容再變動才算;repo 根目錄的檔案只算檔案數,不算一個目錄。達到 3 個原始碼檔案、2 個目錄或 1 個這類檔案時,結果會附一行請 agent 重新分類;verify 要等到以 `reason` 呼叫 `kind`、回應每一個跨過的門檻才算完成,之後再跨過新的門檻會再問一次。前一個階段還沒完成就開始下一個階段,會用一行警告一次並指出 `skip` 的出口;證據改變或用 `back` 時階段會退回。book 也記錄每個 todo 的 `anchor`、`ref`(`<path>#<heading>`,解析成行號範圍)和 `followup` metadata。每個開啟中的 loop 有一份 YAML book,放在 `~/.pi/agent/anchorloop/books/`(可用 `ANCHORLOOP_BOOKS_DIR` 覆寫),subagent 的 book 放在 `agents/`(subagent 自己 close 時 book 留給主 session);`session_start` 會清掉 session 已不存在或 7 天沒有更新的 book。`close` 不會因為階段或 friction 而拒絕,只在還有 pending 或 in-progress 的 todo 沒有 `metadata.followup`(票號、`memory` 或 `drop — <原因>`)時拒絕。 |
|
|
29
29
|
| `pi/anchor-gate.ts` | 只在開啟的 loop 內:`write` 或 `edit` 開始 `act` 階段、而這種 loop 前面的階段還沒完成時,顯示一行警告:沒有 anchor(kind 呼叫的 `anchor`、`Reality anchor:` 這一行,或已跳過),`durable` loop 則還缺決策、spec、全新 context 的閱讀、核准或設計(從 `docs/specs/<資料夾>/` 的檔案判斷,資料夾由 book、intent 或 todo 的 `ref` 找出)。只有新缺了一個階段時才會再警告;呼叫仍會放行。沒有 loop 或是 `quick` loop 時保持安靜。`.md`、`.txt`、`.html` 檔、`scratch/`、`docs/specs/` 和專案外的暫存檔不會觸發。透過 `bash` 做的修改不檢查。 |
|
|
30
30
|
| `pi/decision-tool.ts` | `anchorloop_decision` 工具把一筆決策寫進 TSV 決策軌跡,每筆只佔一行,用試算表開啟也安全;接手別人的軌跡時寫一筆 `start`。 |
|
|
31
|
-
| `pi/second-thought.ts` | 只在開啟的 loop 內:一次執行結束且 book 自上次判斷後多了條目時,以及宣告 `close` 時,透過 pi 的 classifier registry 請 Jev(TypeSafe 的型別化決策模型)複核階段機。下一個階段由程式從 book 算出;Jev 看到種類、intent、anchor、diff 摘要(≤1200 字元)、`phase`(目前、下一個、缺什麼)、verify 狀態、未完成 todo、任務清單和 friction(子 agent 的以它的名字列出),只判斷要 `advance`、退回(`back`)還是 `ask-user`,另外還問 `done`、還需要哪一級 review 與品質;階段是否完成只由程式依證據判定。一行提醒以 `next → <階段>`
|
|
31
|
+
| `pi/second-thought.ts` | 只在開啟的 loop 內:一次執行結束且 book 自上次判斷後多了條目時,以及宣告 `close` 時,透過 pi 的 classifier registry 請 Jev(TypeSafe 的型別化決策模型)複核階段機。下一個階段由程式從 book 算出;Jev 看到種類、intent、anchor、diff 摘要(≤1200 字元)、`phase`(目前、下一個、缺什麼)、verify 狀態、未完成 todo、任務清單和 friction(子 agent 的以它的名字列出),只判斷要 `advance`、退回(`back`)還是 `ask-user`,另外還問 `done`、還需要哪一級 review 與品質;階段是否完成只由程式依證據判定。一行提醒以 `next → <階段>` 開頭。只有 Jev 同意前進、而下一個階段是 verify、review 或 fix 時,才讓 agent 多跑一輪;與上一則相同的提醒不重複,最後一次修改之後已有無 blocking 發現的 review 時,`full` 評等只顯示備註、不要求複查。呼叫過 `MonitorCreate`、`LoopCreate`、`goal_wait` 或 `subagent` 工具的執行在等待中,不被判斷。沒有 TypeSafe key 時什麼都不做,沒有 loop 時不會執行。subagent session(pi-herdr-agents 的 `PI_SUBAGENT_ID`,或 pi-subagents 的 `PI_SUBAGENT_CHILD`)不註冊任何東西,因為由派它的 agent 判斷結果。 |
|
|
32
32
|
| `pi/validate-tool-use.ts` | 每次 `write` 或 `edit` 後在行程內驗證該檔(`pi/support/validators.ts`,移植自 `hooks/validators/`),替 `SKILL.md`、指令檔(`AGENTS.md`、`CLAUDE.md`、`GEMINI.md`、`rules/`)和 `docs/specs/` 產出物附上建議。不需要 Python;`hooks/` 的 Python 驗證器仍供 `validate_all.py` 和對照測試使用。 |
|
|
33
33
|
| `pi/ttsr.ts` | 移植自 oh-my-pi 的 Time Traveling Stream Rules。`~/.pi/agent/rules/` 或 `<專案>/.pi/rules/` 裡 frontmatter 帶有 `condition` regex 的 Markdown 規則,會在執行過程中被監看。assistant 串流文字命中時,中斷回應、丟棄那段輸出,並注入規則後重試;工具參數命中時(`bash` 看指令,`write`/`edit` 看新寫入的文字),直接擋下呼叫,以規則內容作為理由。frontmatter 欄位沿用 oh-my-pi:`condition`、`scope`(`text`、`thinking`、`tool`、`tool:bash`、`tool:edit(*.ts)`)、`globs`、`interruptMode`(`always`、`prose-only`、`tool-only`、`never`),另加 `repeatMode`(`once` 或 `after-gap`)與 `repeatGap`。預設每條規則每個 session 只觸發一次。不支援 `astCondition`、`question`、`agents`,用到的規則會被跳過並回報。`/ttsr` 列出已載入的規則。 |
|
|
34
34
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-anchorloop",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Agent workflow skills for pi: one entry skill per task type, each with playbooks, over a shared Align → Anchor → Act → Verify loop, plus loop extensions (loop book, anchor gate, decision trail tool, Jev second thought, skill validator, stream rules).",
|
|
5
5
|
"author": "Wei Hung",
|
|
6
6
|
"license": "MIT",
|
package/pi/book.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { join, resolve } from "node:path";
|
|
|
13
13
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
14
14
|
import {
|
|
15
15
|
type Book,
|
|
16
|
+
type Entry,
|
|
16
17
|
KINDS,
|
|
17
18
|
allFriction,
|
|
18
19
|
anchorCommand,
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
openLoop,
|
|
35
36
|
replayTodos,
|
|
36
37
|
refsOf,
|
|
38
|
+
retryPairs,
|
|
37
39
|
resolveRef,
|
|
38
40
|
reviewTrend,
|
|
39
41
|
reviews,
|
|
@@ -50,7 +52,7 @@ import {
|
|
|
50
52
|
verifyAfterLastAct,
|
|
51
53
|
} from "./support/book.ts";
|
|
52
54
|
import { classify } from "./support/jev.ts";
|
|
53
|
-
import { SEQUENCES, computePhases, describe, incompleteBefore, outsideWork } from "./support/phases.ts";
|
|
55
|
+
import { REVIEWLESS, SEQUENCES, computePhases, describe, incompleteBefore, outsideWork, reachLine, reachOf, unansweredReach } from "./support/phases.ts";
|
|
54
56
|
import { type Snapshot, snapshot } from "./support/snapshot.ts";
|
|
55
57
|
import { isSubagent } from "./support/subagent.ts";
|
|
56
58
|
|
|
@@ -97,6 +99,38 @@ function textOf(content: unknown): string {
|
|
|
97
99
|
return (content as Block[]).map((block) => (block && typeof block.text === "string" ? block.text : "")).filter(Boolean).join("\n");
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
/** `text` cut to `limit` characters, the cut marked. */
|
|
103
|
+
function clip(text: string, limit = 120): string {
|
|
104
|
+
return text.length <= limit ? text : `${text.slice(0, limit - 1)}…`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const ANSI = /\x1b\[[0-9;]*[A-Za-z]/g;
|
|
108
|
+
// Stack frames and traceback headers say where, not what; the key line says what failed.
|
|
109
|
+
const FRAME = /^(?:at\s|File\s"|Traceback\b|\^+$)/;
|
|
110
|
+
const KEY_LINES = [
|
|
111
|
+
/^(?:FAILED|ERROR)\b/,
|
|
112
|
+
/^E\s+\S/,
|
|
113
|
+
/^[\w.]+(?:Error|Exception|Warning)\b:?/,
|
|
114
|
+
/\b(?:error|fatal|panic|exception)\b/i,
|
|
115
|
+
/\bfail(?:ed|ure|s)?\b/i,
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
/** The one line of a failed run's output that says what failed, at most 120 characters; the last line when none does. */
|
|
119
|
+
function keyLine(text: string): string {
|
|
120
|
+
const raw = text.replace(ANSI, "").split("\n");
|
|
121
|
+
// A Python frame's next line, indented under it, is the source it quotes, not the failure.
|
|
122
|
+
const quoted = (index: number) => /^\s/.test(raw[index]) && /^\s*File\s"/.test(raw[index - 1] ?? "");
|
|
123
|
+
const lines = raw.flatMap((line, index) => {
|
|
124
|
+
const trimmed = line.trim();
|
|
125
|
+
return trimmed && !FRAME.test(trimmed) && !quoted(index) ? [trimmed] : [];
|
|
126
|
+
});
|
|
127
|
+
for (const pattern of KEY_LINES) {
|
|
128
|
+
const hit = lines.find((line) => pattern.test(line));
|
|
129
|
+
if (hit) return clip(hit);
|
|
130
|
+
}
|
|
131
|
+
return clip(lines.at(-1) ?? "");
|
|
132
|
+
}
|
|
133
|
+
|
|
100
134
|
function lastLine(text: string): string {
|
|
101
135
|
return (
|
|
102
136
|
text
|
|
@@ -296,6 +330,8 @@ function statedAnchor(message: { role?: string; content?: unknown } | undefined)
|
|
|
296
330
|
return found ? found[1].trim().slice(0, 300) || "(stated on the next line)" : undefined;
|
|
297
331
|
}
|
|
298
332
|
|
|
333
|
+
const STATUS_KEY = "anchorloop";
|
|
334
|
+
|
|
299
335
|
const reply = (text: string) => ({ content: [{ type: "text" as const, text }], details: undefined });
|
|
300
336
|
|
|
301
337
|
export default function (pi: ExtensionAPI) {
|
|
@@ -327,7 +363,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
327
363
|
`reviews: ${reviewTrend(book.entries)}; open todos: ${open}; friction: ${friction.length} (${friction.filter((item) => !item.reflected).length} unreflected)`,
|
|
328
364
|
...childLines(book.entries).map((line) => `child ${line}`),
|
|
329
365
|
...friction.filter((item) => item.owner !== "main").map((item) => `friction ${item.ref}: ${item.tried} → ${item.found}${item.reflected ? ` [${item.class}]` : ""}`),
|
|
330
|
-
...phases.hints,
|
|
331
366
|
...freshReadLine(book, phases),
|
|
332
367
|
];
|
|
333
368
|
}
|
|
@@ -434,7 +469,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
434
469
|
label: "Loop stage",
|
|
435
470
|
description:
|
|
436
471
|
"Declare only what the extension cannot observe in the anchorloop loop book. " +
|
|
437
|
-
"`kind` (kind, intent, optional anchor command; call again to
|
|
472
|
+
"`kind` (kind, intent, optional anchor command; call again to set the anchor, or with `reason` to change the kind or answer a re-classification): quick (act, check), inline (anchor, act, verify), reviewed (adds review), durable (adds decide, grill, spec, read, approve, design); every kind ends with reflect, close. " +
|
|
473
|
+
"When an anchor run or declared verify of a quick or inline loop finds the change reaching 3 source files, 2 modules, or a README, changelog, or *.schema.json beside code, its verify waits for a `kind` call with `reason`. " +
|
|
438
474
|
"`verify` (note; only for an anchor that is not a command), `fresh-read` (a fresh-context read of the spec is done), `friction` (tried, found, led_by), `reflect` (friction ids, class misdirection|gap|resolved, action), " +
|
|
439
475
|
"`skip` / `back` (phase, reason), `close` (verdict), `read` (view the book). Edits, anchor runs, reviews, and spec files are read from evidence. " +
|
|
440
476
|
"A loop opens with the first `todo` create; `close` refuses while a pending or in-progress todo lacks metadata.followup.",
|
|
@@ -442,7 +478,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
442
478
|
type: "object",
|
|
443
479
|
properties: {
|
|
444
480
|
stage: { type: "string", enum: [...STAGES] },
|
|
445
|
-
kind: { type: "string", enum: [...KINDS], description: "stage kind: the loop kind; a
|
|
481
|
+
kind: { type: "string", enum: [...KINDS], description: "stage kind: the loop kind; a later call with `reason` changes it" },
|
|
446
482
|
intent: { type: "string", description: "stage kind: one line on what the loop delivers" },
|
|
447
483
|
anchor: { type: "string", description: "stage kind: the check command whose exit code observes the result" },
|
|
448
484
|
note: { type: "string", description: "stage verify: what was observed; stage fresh-read: who read the spec" },
|
|
@@ -454,88 +490,103 @@ export default function (pi: ExtensionAPI) {
|
|
|
454
490
|
class: { type: "string", enum: ["misdirection", "gap", "resolved"], description: "stage reflect" },
|
|
455
491
|
action: { type: "string", description: "stage reflect: what was done, such as solid-loop, memory, or a commit" },
|
|
456
492
|
phase: { type: "string", description: "stage skip or back: the phase" },
|
|
457
|
-
reason: { type: "string", description: "stage skip or back: why" },
|
|
493
|
+
reason: { type: "string", description: "stage skip or back: why; stage kind: why the kind changes, or why it still fits the measured reach" },
|
|
458
494
|
verdict: { type: "string", enum: ["landed", "blocked", "abandoned"], description: "stage close" },
|
|
459
495
|
view: { type: "string", enum: ["summary", "all"], description: "stage read; default summary" },
|
|
460
496
|
},
|
|
461
497
|
required: ["stage"],
|
|
462
498
|
additionalProperties: false,
|
|
463
499
|
},
|
|
464
|
-
async execute(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (!book && stage === "kind") {
|
|
470
|
-
// A todo create in the same batch may not have landed yet; whichever comes first opens the loop.
|
|
471
|
-
if (!params.kind || !params.intent) throw new Error("the first kind declaration needs `kind` and a one-line `intent`");
|
|
472
|
-
book = createBook(ctx);
|
|
473
|
-
recordPriorAnchor(book, ctx);
|
|
474
|
-
}
|
|
475
|
-
if (!book) return reply("No loop is open, so nothing was recorded. A loop opens with the first `todo` create or `kind`.");
|
|
476
|
-
const had = currentKind(book.entries);
|
|
477
|
-
const sequence = SEQUENCES[had ?? "inline"];
|
|
478
|
-
if (stage === "read") {
|
|
479
|
-
const lines = [...summaryLines(book, ctx), ...taskLines(book.entries, todosOf(ctx), ctx.cwd)];
|
|
480
|
-
if (params.view === "all") lines.push("entries:", ...book.entries.map((entry) => JSON.stringify(entry).slice(0, 300)));
|
|
481
|
-
return reply(lines.join("\n"));
|
|
482
|
-
}
|
|
483
|
-
if (stage === "close") {
|
|
484
|
-
if (!params.verdict) throw new Error("close needs a verdict: landed, blocked, or abandoned");
|
|
485
|
-
const closed = close(book, ctx, params.verdict);
|
|
486
|
-
return { content: [{ type: "text" as const, text: closed.text }], details: closed.snapshot ? { snapshot: closed.snapshot } : undefined };
|
|
487
|
-
}
|
|
488
|
-
if (stage === "kind") {
|
|
489
|
-
if (!params.kind && !params.intent && !params.anchor) throw new Error("kind needs `kind`, `intent`, or `anchor`");
|
|
490
|
-
if (!had && (!params.kind || !params.intent)) throw new Error("the first kind declaration needs `kind` and a one-line `intent`");
|
|
491
|
-
const notes: string[] = [];
|
|
492
|
-
if (params.kind || params.intent) {
|
|
493
|
-
appendEntry(book.path, "kind", { kind: params.kind ?? had, ...(params.intent ? { intent: params.intent } : {}) });
|
|
494
|
-
notes.push(had && params.kind && had !== params.kind ? `kind changed: ${had} → ${params.kind}` : `kind: ${params.kind ?? had}`);
|
|
495
|
-
}
|
|
496
|
-
if (params.anchor) {
|
|
497
|
-
appendEntry(book.path, "anchor", { check: params.anchor });
|
|
498
|
-
notes.push(`anchor: ${params.anchor}`);
|
|
499
|
-
}
|
|
500
|
-
touchRepo(book, join(ctx.cwd, "_"));
|
|
501
|
-
return reply(notes.join("\n"));
|
|
502
|
-
}
|
|
503
|
-
if (stage === "verify") {
|
|
504
|
-
if (!params.note) throw new Error("verify needs a `note` saying what was observed");
|
|
505
|
-
const result = params.result ?? "pass";
|
|
506
|
-
const recorded = childId() !== undefined || had === "quick" ? "check" : "verify";
|
|
507
|
-
appendEntry(book.path, recorded, { declared: true, note: params.note, result, exit: result === "pass" ? 0 : 1 });
|
|
508
|
-
return reply(`${recorded} declared: ${result} — ${params.note}`);
|
|
509
|
-
}
|
|
510
|
-
if (stage === "fresh-read") {
|
|
511
|
-
appendEntry(book.path, "goldfish", { source: "declared", ...(params.note ? { note: params.note } : {}) });
|
|
512
|
-
return reply("fresh-read recorded.");
|
|
513
|
-
}
|
|
514
|
-
if (stage === "friction") {
|
|
515
|
-
if (!params.tried || !params.found) throw new Error("friction needs `tried` and `found`");
|
|
516
|
-
const id = frictionOf(book.entries).length + 1;
|
|
517
|
-
appendEntry(book.path, "friction", { id, tried: params.tried, found: params.found, led_by: params.led_by || "none" });
|
|
518
|
-
return reply(`friction #${id} recorded.`);
|
|
519
|
-
}
|
|
520
|
-
if (stage === "reflect") {
|
|
521
|
-
const known = allFriction(book.entries).map((item) => item.ref);
|
|
522
|
-
const ids = (params.friction ?? []).map(String);
|
|
523
|
-
if (ids.length === 0 || !params.class) throw new Error(`reflect needs \`friction\` ids (${known.join(", ") || "none recorded"}) and \`class\``);
|
|
524
|
-
const unknown = ids.filter((id) => !known.includes(id));
|
|
525
|
-
if (unknown.length) throw new Error(`unknown friction ${unknown.join(", ")}; known: ${known.join(", ") || "none"}`);
|
|
526
|
-
appendEntry(book.path, "reflect", { friction: ids, class: params.class, ...(params.action ? { action: params.action } : {}) });
|
|
527
|
-
return reply(`reflect recorded for ${ids.join(", ")} (${params.class}).`);
|
|
500
|
+
async execute(toolCallId: string, raw: unknown, signal: unknown, onUpdate: unknown, ctx: ExtensionContext) {
|
|
501
|
+
try {
|
|
502
|
+
return await stageTool(toolCallId, raw, signal, onUpdate, ctx);
|
|
503
|
+
} finally {
|
|
504
|
+
guarded(showStatus)(ctx);
|
|
528
505
|
}
|
|
529
|
-
// skip and back
|
|
530
|
-
const phase = params.phase;
|
|
531
|
-
const known = sequence.filter((name) => name !== "close");
|
|
532
|
-
if (!phase || !known.includes(phase)) throw new Error(`${stage} needs \`phase\`, one of ${known.join(", ")} for a ${had ?? "undeclared"} loop`);
|
|
533
|
-
if (!params.reason) throw new Error(`${stage} needs a \`reason\``);
|
|
534
|
-
appendEntry(book.path, stage, { phase, reason: params.reason });
|
|
535
|
-
return reply(stage === "skip" ? `${phase}: skipped (${params.reason}).` : `back to ${phase} (${params.reason}); later phases count as incomplete until their conditions hold again.`);
|
|
536
506
|
},
|
|
537
507
|
});
|
|
538
508
|
|
|
509
|
+
async function stageTool(_toolCallId: string, raw: unknown, _signal: unknown, _onUpdate: unknown, ctx: ExtensionContext) {
|
|
510
|
+
const params = raw as Params;
|
|
511
|
+
const { stage } = params;
|
|
512
|
+
if (!(STAGES as readonly string[]).includes(stage)) throw new Error(`unknown stage \`${String(stage)}\`; declare one of ${STAGES.join(", ")}`);
|
|
513
|
+
let book = openLoop(ctx);
|
|
514
|
+
if (!book && stage === "kind") {
|
|
515
|
+
// A todo create in the same batch may not have landed yet; whichever comes first opens the loop.
|
|
516
|
+
if (!params.kind || !params.intent) throw new Error("the first kind declaration needs `kind` and a one-line `intent`");
|
|
517
|
+
book = createBook(ctx);
|
|
518
|
+
recordPriorAnchor(book, ctx);
|
|
519
|
+
}
|
|
520
|
+
if (!book) return reply("No loop is open, so nothing was recorded. A loop opens with the first `todo` create or `kind`.");
|
|
521
|
+
const had = currentKind(book.entries);
|
|
522
|
+
const sequence = SEQUENCES[had ?? "inline"];
|
|
523
|
+
if (stage === "read") {
|
|
524
|
+
const lines = [...summaryLines(book, ctx), ...taskLines(book.entries, todosOf(ctx), ctx.cwd)];
|
|
525
|
+
if (params.view === "all") lines.push("entries:", ...book.entries.map((entry) => JSON.stringify(entry).slice(0, 300)));
|
|
526
|
+
return reply(lines.join("\n"));
|
|
527
|
+
}
|
|
528
|
+
if (stage === "close") {
|
|
529
|
+
if (!params.verdict) throw new Error("close needs a verdict: landed, blocked, or abandoned");
|
|
530
|
+
const closed = close(book, ctx, params.verdict);
|
|
531
|
+
return { content: [{ type: "text" as const, text: closed.text }], details: closed.snapshot ? { snapshot: closed.snapshot } : undefined };
|
|
532
|
+
}
|
|
533
|
+
if (stage === "kind") {
|
|
534
|
+
if (!params.kind && !params.intent && !params.anchor && !params.reason) throw new Error("kind needs `kind`, `intent`, `anchor`, or `reason`");
|
|
535
|
+
if (!had && (!params.kind || !params.intent)) throw new Error("the first kind declaration needs `kind` and a one-line `intent`");
|
|
536
|
+
const changed = had !== undefined && params.kind !== undefined && had !== params.kind;
|
|
537
|
+
if (changed && !params.reason) throw new Error(`changing the kind from ${had} to ${params.kind} needs \`reason\`: the reach grew, the user added scope, a user-owned decision appeared, or the change turned out smaller`);
|
|
538
|
+
touchRepo(book, join(ctx.cwd, "_"));
|
|
539
|
+
const notes: string[] = [];
|
|
540
|
+
if (params.kind || params.intent || params.reason) {
|
|
541
|
+
// A reason answers the reach measured now, so a later threshold asks again.
|
|
542
|
+
const answer = params.reason ? { reason: params.reason, crossed: reachOf(book.entries, ctx.cwd).crossed } : {};
|
|
543
|
+
appendEntry(book.path, "kind", { kind: params.kind ?? had, ...(params.intent ? { intent: params.intent } : {}), ...answer });
|
|
544
|
+
const why = params.reason ? ` (${params.reason})` : "";
|
|
545
|
+
notes.push(changed ? `kind changed: ${had} → ${params.kind}${why}` : `kind: ${params.kind ?? had}${why}`);
|
|
546
|
+
}
|
|
547
|
+
if (params.anchor) {
|
|
548
|
+
appendEntry(book.path, "anchor", { check: params.anchor });
|
|
549
|
+
notes.push(`anchor: ${params.anchor}`);
|
|
550
|
+
}
|
|
551
|
+
return reply(notes.join("\n"));
|
|
552
|
+
}
|
|
553
|
+
if (stage === "verify") {
|
|
554
|
+
if (!params.note) throw new Error("verify needs a `note` saying what was observed");
|
|
555
|
+
const result = params.result ?? "pass";
|
|
556
|
+
const recorded = childId() !== undefined || had === "quick" ? "check" : "verify";
|
|
557
|
+
const entry = appendEntry(book.path, recorded, { declared: true, note: params.note, result, exit: result === "pass" ? 0 : 1, ...reachField(book, ctx.cwd) });
|
|
558
|
+
book.entries.push(entry);
|
|
559
|
+
const notice = reachNotice(book, entry);
|
|
560
|
+
return reply(`${recorded} declared: ${result} — ${params.note}${notice ? `\n${notice}` : ""}`);
|
|
561
|
+
}
|
|
562
|
+
if (stage === "fresh-read") {
|
|
563
|
+
appendEntry(book.path, "goldfish", { source: "declared", ...(params.note ? { note: params.note } : {}) });
|
|
564
|
+
return reply("fresh-read recorded.");
|
|
565
|
+
}
|
|
566
|
+
if (stage === "friction") {
|
|
567
|
+
if (!params.tried || !params.found) throw new Error("friction needs `tried` and `found`");
|
|
568
|
+
const id = frictionOf(book.entries).length + 1;
|
|
569
|
+
appendEntry(book.path, "friction", { id, tried: params.tried, found: params.found, led_by: params.led_by || "none" });
|
|
570
|
+
return reply(`friction #${id} recorded.`);
|
|
571
|
+
}
|
|
572
|
+
if (stage === "reflect") {
|
|
573
|
+
const known = allFriction(book.entries).map((item) => item.ref);
|
|
574
|
+
const ids = (params.friction ?? []).map(String);
|
|
575
|
+
if (ids.length === 0 || !params.class) throw new Error(`reflect needs \`friction\` ids (${known.join(", ") || "none recorded"}) and \`class\``);
|
|
576
|
+
const unknown = ids.filter((id) => !known.includes(id));
|
|
577
|
+
if (unknown.length) throw new Error(`unknown friction ${unknown.join(", ")}; known: ${known.join(", ") || "none"}`);
|
|
578
|
+
appendEntry(book.path, "reflect", { friction: ids, class: params.class, ...(params.action ? { action: params.action } : {}) });
|
|
579
|
+
return reply(`reflect recorded for ${ids.join(", ")} (${params.class}).`);
|
|
580
|
+
}
|
|
581
|
+
// skip and back
|
|
582
|
+
const phase = params.phase;
|
|
583
|
+
const known = sequence.filter((name) => name !== "close");
|
|
584
|
+
if (!phase || !known.includes(phase)) throw new Error(`${stage} needs \`phase\`, one of ${known.join(", ")} for a ${had ?? "undeclared"} loop`);
|
|
585
|
+
if (!params.reason) throw new Error(`${stage} needs a \`reason\``);
|
|
586
|
+
appendEntry(book.path, stage, { phase, reason: params.reason });
|
|
587
|
+
return reply(stage === "skip" ? `${phase}: skipped (${params.reason}).` : `back to ${phase} (${params.reason}); later phases count as incomplete until their conditions hold again.`);
|
|
588
|
+
}
|
|
589
|
+
|
|
539
590
|
pi.on(
|
|
540
591
|
"session_start",
|
|
541
592
|
guarded((_event, ctx) => {
|
|
@@ -545,6 +596,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
545
596
|
...swept.open.map((path) => `open loop book: ${path}`),
|
|
546
597
|
];
|
|
547
598
|
if (lines.length > 0) ctx.ui.notify(`anchorloop books\n${lines.join("\n")}`, "info");
|
|
599
|
+
showStatus(ctx);
|
|
548
600
|
}),
|
|
549
601
|
);
|
|
550
602
|
|
|
@@ -558,21 +610,45 @@ export default function (pi: ExtensionAPI) {
|
|
|
558
610
|
}),
|
|
559
611
|
);
|
|
560
612
|
|
|
561
|
-
/**
|
|
562
|
-
function
|
|
613
|
+
/** The reach of an unreviewed loop's diff, recorded on its verify or check entry; a reviewed loop is never measured. */
|
|
614
|
+
function reachField(book: Book, cwd: string): { reach?: ReturnType<typeof reachOf> } {
|
|
615
|
+
return REVIEWLESS.has(currentKind(book.entries) ?? "inline") ? { reach: reachOf(book.entries, cwd) } : {};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** The line that asks the loop to re-classify after a verify or check entry whose reach no `kind` answer covers. */
|
|
619
|
+
function reachNotice(book: Book, entry: Entry): string | undefined {
|
|
620
|
+
const reach = entry.reach as ReturnType<typeof reachOf> | undefined;
|
|
621
|
+
return reach && unansweredReach(book.entries, reach).length > 0 ? `anchorloop: ${reachLine(reach, currentKind(book.entries))}.` : undefined;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Records what a finished bash call shows: runs of the loop anchor, of task anchors, and a first commit as the change.
|
|
626
|
+
* Returns the re-classification line when an anchor run of an unreviewed loop measured a reach no `kind` answer covers.
|
|
627
|
+
*/
|
|
628
|
+
function recordBash(book: Book, event: { input: unknown; isError?: boolean; structuredContent?: unknown; content?: unknown }, cwd: string): string | undefined {
|
|
563
629
|
const structured = event.structuredContent as { output?: unknown } | undefined;
|
|
564
630
|
const output = typeof structured?.output === "string" ? structured.output : textOf(event.content);
|
|
565
631
|
const command = String((event.input as { command?: unknown }).command ?? "");
|
|
566
632
|
const exit = bashExit(event);
|
|
567
633
|
const last = lastLine(output);
|
|
568
634
|
const anchor = anchorCommand(book.entries);
|
|
635
|
+
const notices: string[] = [];
|
|
636
|
+
// A failed run keeps its key line, so a rerun that passes can name what failed without the whole output.
|
|
637
|
+
const keyOf = (code: unknown) => (typeof code === "number" && code !== 0 ? { key: keyLine(output) } : {});
|
|
569
638
|
if (anchor && anchorRun(command, anchor)) {
|
|
570
639
|
const recorded = childId() !== undefined || currentKind(book.entries) === "quick" ? "check" : "verify";
|
|
571
|
-
|
|
640
|
+
const code = anchorExit(command, anchor, exit);
|
|
641
|
+
const entry = appendEntry(book.path, recorded, { command: anchor.slice(0, 200), exit: code, last, ...keyOf(code), ...reachField(book, cwd) });
|
|
642
|
+
book.entries.push(entry);
|
|
643
|
+
const reach = reachNotice(book, entry);
|
|
644
|
+
if (reach) notices.push(reach);
|
|
572
645
|
}
|
|
573
646
|
for (const task of latestTasks(book.entries)) {
|
|
574
|
-
if (typeof task.anchor
|
|
647
|
+
if (typeof task.anchor !== "string" || !anchorRun(command, task.anchor)) continue;
|
|
648
|
+
const code = anchorExit(command, task.anchor, exit);
|
|
649
|
+
book.entries.push(appendEntry(book.path, "taskrun", { id: task.id, command: task.anchor.slice(0, 200), exit: code, last, ...keyOf(code) }));
|
|
575
650
|
}
|
|
651
|
+
notices.push(...autoFriction(book));
|
|
576
652
|
const merged = mergeRun(command);
|
|
577
653
|
if (exit === 0 && merged && !/Already up[ -]to[ -]date/i.test(last ?? "") && book.entries.at(-1)?.stage !== "edit") {
|
|
578
654
|
touchRepoBeforeMerge(book, resolve(String(book.header.cwd ?? process.cwd()), merged.dir), merged.verb);
|
|
@@ -582,6 +658,54 @@ export default function (pi: ExtensionAPI) {
|
|
|
582
658
|
const cwd = String(book.header.cwd ?? "");
|
|
583
659
|
if (diffAgainstBases(book.entries).paths.some((path) => !outsideWork(path, cwd))) appendEntry(book.path, "edit", { via: "commit" });
|
|
584
660
|
}
|
|
661
|
+
return notices.join("\n") || undefined;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Records one friction line for each anchor that passed again after it had passed and then failed. A pair is recorded
|
|
666
|
+
* once, and not at all when the agent recorded a friction entry itself after the failure. The pairs one command
|
|
667
|
+
* completes in one bash call (it is both the loop and a task anchor) share one entry. Returns the lines that tell the agent.
|
|
668
|
+
*/
|
|
669
|
+
function autoFriction(book: Book): string[] {
|
|
670
|
+
const lines: string[] = [];
|
|
671
|
+
const open = new Map<string, string[]>();
|
|
672
|
+
for (const pair of retryPairs(book.entries)) {
|
|
673
|
+
const id = `${pair.key}#${pair.fail}`;
|
|
674
|
+
const recorded = book.entries.some(
|
|
675
|
+
(entry, index) =>
|
|
676
|
+
entry.stage === "friction" && ((Array.isArray(entry.pairs) && entry.pairs.includes(id)) || (index > pair.fail && entry.auto !== true)),
|
|
677
|
+
);
|
|
678
|
+
if (recorded) continue;
|
|
679
|
+
const command = String(book.entries[pair.fail].command ?? pair.key);
|
|
680
|
+
open.set(command, [...(open.get(command) ?? []), id]);
|
|
681
|
+
}
|
|
682
|
+
for (const [command, pairs] of open) {
|
|
683
|
+
// The newest failure speaks for the entry; an older pair it backfills is listed in `pairs`.
|
|
684
|
+
const newest = pairs.at(-1) as string;
|
|
685
|
+
const failed = book.entries[Number(newest.slice(newest.lastIndexOf("#") + 1))];
|
|
686
|
+
const tried = clip(`rerun of ${command}`, 80);
|
|
687
|
+
// A failure recorded before 2.4 has no key line; its last line gets the same filter.
|
|
688
|
+
const found = clip(String(failed.key ?? keyLine(String(failed.last ?? ""))) || "failed with no output");
|
|
689
|
+
const number = frictionOf(book.entries).length + 1;
|
|
690
|
+
book.entries.push(appendEntry(book.path, "friction", { id: number, tried, found, led_by: "none", auto: true, pairs }));
|
|
691
|
+
lines.push(`anchorloop: friction #${number} recorded from the ${tried}: ${found}. Classify it with \`reflect\` before close.`);
|
|
692
|
+
}
|
|
693
|
+
return lines;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** The footer line: the loop's kind, its last complete phase, the next one, and the friction still to reflect. */
|
|
697
|
+
function showStatus(ctx: ExtensionContext): void {
|
|
698
|
+
if (typeof ctx.ui?.setStatus !== "function") return;
|
|
699
|
+
const book = openLoop(ctx);
|
|
700
|
+
if (!book) {
|
|
701
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
const phases = phasesOf(book, ctx);
|
|
705
|
+
const open = allFriction(book.entries).filter((item) => !item.reflected).length;
|
|
706
|
+
const kind = phases.kind === "undeclared" ? "no kind" : phases.kind;
|
|
707
|
+
const at = `${phases.current}${phases.current === "start" ? "" : " ✓"} → ${phases.next}`;
|
|
708
|
+
ctx.ui.setStatus(STATUS_KEY, `anchorloop ${kind} · ${at}${open ? ` · ${open} friction to reflect` : ""}`);
|
|
585
709
|
}
|
|
586
710
|
|
|
587
711
|
pi.on(
|
|
@@ -589,8 +713,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
589
713
|
guarded((event, ctx) => {
|
|
590
714
|
if (event.toolName === "bash") {
|
|
591
715
|
const book = openLoop(ctx);
|
|
592
|
-
|
|
593
|
-
|
|
716
|
+
const notice = book ? recordBash(book, event, ctx.cwd) : undefined;
|
|
717
|
+
// The line only appends text, so the bash call's structured output passes on unchanged.
|
|
718
|
+
return notice ? { content: [...((event.content as unknown[]) ?? []), { type: "text", text: notice }], structuredContent: event.structuredContent } : undefined;
|
|
594
719
|
}
|
|
595
720
|
if (event.isError) return;
|
|
596
721
|
if (event.toolName === "todo") {
|
|
@@ -633,6 +758,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
633
758
|
}),
|
|
634
759
|
);
|
|
635
760
|
|
|
761
|
+
// Registered after the recording handler, so the footer reads what that tool call just recorded.
|
|
762
|
+
pi.on(
|
|
763
|
+
"tool_result",
|
|
764
|
+
guarded((_event, ctx) => {
|
|
765
|
+
showStatus(ctx);
|
|
766
|
+
}),
|
|
767
|
+
);
|
|
768
|
+
|
|
636
769
|
async function recordReview(ctx: ExtensionContext, book: Book, name: string, text: string, failed: boolean): Promise<void> {
|
|
637
770
|
const counts = parseBlocking(text);
|
|
638
771
|
let blocking: boolean | null = null;
|
package/pi/second-thought.ts
CHANGED
|
@@ -106,7 +106,7 @@ export function continues(verdict: Verdict, snap: Snapshot): boolean {
|
|
|
106
106
|
|
|
107
107
|
/** One line: the program's next phase and its gap, Jev's move and scores, and, away from close, the call to act. */
|
|
108
108
|
export function message(verdict: Verdict, snap: Snapshot, found: string[], notes: string[], atClose = false): string {
|
|
109
|
-
const extra = [...found, ...notes
|
|
109
|
+
const extra = [...found, ...notes];
|
|
110
110
|
return (
|
|
111
111
|
`Second thought (Jev, advisory): next → ${snap.next}${snap.missing ? ` (missing: ${snap.missing})` : ""}; ` +
|
|
112
112
|
`${verdict.move}; done ${verdict.done.toFixed(2)}, review ${verdict.review}, quality ${verdict.quality.toFixed(2)}/3` +
|
package/pi/support/book.ts
CHANGED
|
@@ -499,12 +499,6 @@ export function retryPairs(entries: Entry[]): RetryPair[] {
|
|
|
499
499
|
return pairs;
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
/** A retry pair that no friction entry follows. */
|
|
503
|
-
export function retryWithoutFriction(entries: Entry[]): boolean {
|
|
504
|
-
const lastFriction = lastIndex(entries, "friction");
|
|
505
|
-
return retryPairs(entries).some((pair) => pair.pass > lastFriction);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
502
|
// --- todos ---------------------------------------------------------------------------------------
|
|
509
503
|
|
|
510
504
|
export type Task = { id: number; subject: string; status: string; metadata?: Record<string, unknown> };
|
|
@@ -579,12 +573,34 @@ export function bases(entries: Entry[]): { repo: string; head: string }[] {
|
|
|
579
573
|
return entries.filter((entry) => entry.stage === "base").map((entry) => ({ repo: String(entry.repo), head: String(entry.head) }));
|
|
580
574
|
}
|
|
581
575
|
|
|
582
|
-
/**
|
|
576
|
+
/**
|
|
577
|
+
* The content hash of each of `names` in `repo`, `deleted` for a path that is gone, and `unknown` for one git cannot hash
|
|
578
|
+
* (a directory or submodule). One such path fails the batch, so the batch falls back to hashing each path alone.
|
|
579
|
+
*/
|
|
580
|
+
export function contentHashes(repo: string, names: string[]): Record<string, string> {
|
|
581
|
+
const found: Record<string, string> = {};
|
|
582
|
+
const present = names.filter((name) => existsSync(join(repo, name)));
|
|
583
|
+
for (const name of names) if (!present.includes(name)) found[name] = "deleted";
|
|
584
|
+
const batch = present.length ? git(repo, ["hash-object", "--", ...present])?.split("\n") : [];
|
|
585
|
+
present.forEach((name, index) => {
|
|
586
|
+
found[name] = (batch ? batch[index] : git(repo, ["hash-object", "--", name])) || "unknown";
|
|
587
|
+
});
|
|
588
|
+
return found;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/** The paths already changed or untracked in `repo` against `head`, with their content hashes: work the loop found, not made. */
|
|
592
|
+
function dirtyAt(repo: string, head: string): Record<string, string> {
|
|
593
|
+
const changed = git(repo, ["diff", "--name-only", head])?.split("\n") ?? [];
|
|
594
|
+
const untracked = git(repo, ["ls-files", "--others", "--exclude-standard"])?.split("\n") ?? [];
|
|
595
|
+
return contentHashes(repo, [...new Set([...changed, ...untracked].filter(Boolean))].slice(0, 500));
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/** Adds the repo of `path` to the book with its HEAD, and the paths already dirty there, when the book has no base for it yet. */
|
|
583
599
|
export function touchRepo(book: Book, path: string): boolean {
|
|
584
600
|
const found = repoOf(path);
|
|
585
601
|
if (!found) return false;
|
|
586
602
|
if (bases(book.entries).some((base) => base.repo === found.repo)) return false;
|
|
587
|
-
const entry = appendEntry(book.path, "base", found);
|
|
603
|
+
const entry = appendEntry(book.path, "base", { ...found, dirty: dirtyAt(found.repo, found.head) });
|
|
588
604
|
book.entries.push(entry);
|
|
589
605
|
return true;
|
|
590
606
|
}
|
|
@@ -602,8 +618,9 @@ export function touchRepoBeforeMerge(book: Book, dir: string, verb: string): boo
|
|
|
602
618
|
const first = reflog.findIndex((line) => !ofVerb(line));
|
|
603
619
|
const before = reflog.length > 0 && ofVerb(reflog[0]) && first > 0 ? reflog[first].slice(0, 40) : undefined;
|
|
604
620
|
// A rebasing pull leaves the old HEAD off HEAD's history; their merge base keeps the pulled commits in the diff.
|
|
621
|
+
// The dirty snapshot is the uncommitted work against HEAD, so the merged files stay the loop's change.
|
|
605
622
|
const base = before === undefined ? undefined : git(found.repo, ["merge-base", before, "HEAD"]);
|
|
606
|
-
book.entries.push(appendEntry(book.path, "base", { repo: found.repo, head: base || found.head }));
|
|
623
|
+
book.entries.push(appendEntry(book.path, "base", { repo: found.repo, head: base || found.head, dirty: dirtyAt(found.repo, found.head) }));
|
|
607
624
|
return true;
|
|
608
625
|
}
|
|
609
626
|
|
package/pi/support/phases.ts
CHANGED
|
@@ -16,11 +16,13 @@ import {
|
|
|
16
16
|
allFriction,
|
|
17
17
|
anchorCommand,
|
|
18
18
|
artifactOnDisk,
|
|
19
|
+
bases,
|
|
20
|
+
contentHashes,
|
|
19
21
|
currentKind,
|
|
22
|
+
diffAgainstBases,
|
|
20
23
|
lastActIndex,
|
|
21
24
|
lastIndex,
|
|
22
25
|
repoRootOf,
|
|
23
|
-
retryWithoutFriction,
|
|
24
26
|
specFolder,
|
|
25
27
|
withChildActs,
|
|
26
28
|
} from "./book.ts";
|
|
@@ -44,8 +46,6 @@ export type Phases = {
|
|
|
44
46
|
missing: string;
|
|
45
47
|
skipped: string[];
|
|
46
48
|
backs: string[];
|
|
47
|
-
/** Advisory hints that are not phases. */
|
|
48
|
-
hints: string[];
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export type Inputs = { entries: Entry[]; cwd: string; todos: Task[]; env?: NodeJS.ProcessEnv };
|
|
@@ -87,6 +87,99 @@ export function exempt(filePath: string, cwd: string): boolean {
|
|
|
87
87
|
return EXEMPT_EXTENSIONS.includes(extname(filePath).toLowerCase()) || outsideWork(filePath, cwd);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// --- reach -----------------------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
/** What a change reaches, measured from its diff: the count an unreviewed loop is re-classified at, not the author's confidence. */
|
|
93
|
+
export type Reach = { source: string[]; modules: string[]; behavior: string[]; crossed: string[] };
|
|
94
|
+
|
|
95
|
+
/** The kinds that never run a review; a change past the reach thresholds asks them to re-classify. */
|
|
96
|
+
export const REVIEWLESS: ReadonlySet<string> = new Set(["quick", "inline"]);
|
|
97
|
+
const REACH_FILES = 3;
|
|
98
|
+
const REACH_MODULES = 2;
|
|
99
|
+
|
|
100
|
+
// `spec/` and `specs/` count as tests, the RSpec and Jasmine layout; a durable spec folder is outside work anyway.
|
|
101
|
+
const TEST_PATH = /(?:^|\/)(?:tests?|__tests__|testdata|fixtures|specs?)\/|\.(?:test|spec)\.[^/]+$|(?:^|\/)(?:test_[^/]+|conftest)\.py$|_test\.(?:py|go)$/i;
|
|
102
|
+
const LOCKFILE =
|
|
103
|
+
/(?:^|\/)(?:package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|uv\.lock|poetry\.lock|Pipfile\.lock|Cargo\.lock|go\.sum|Gemfile\.lock|composer\.lock|flake\.lock|pubspec\.lock|mix\.lock|packages\.lock\.json|Package\.resolved)$/;
|
|
104
|
+
/** Files that describe behavior to its users: a change to one beside source code changes what users were told. */
|
|
105
|
+
const BEHAVIOR = /(?:^|\/)(?:(?:README|CHANGELOG)(?:\.[a-z0-9]+)?|\.changelog\/[^/]+|[^/]+\.schema\.json)$/i;
|
|
106
|
+
|
|
107
|
+
/** Each path of the diff with its repo and repo-relative POSIX name, leaving out work outside the loop's code and paths still as the loop found them. */
|
|
108
|
+
function loopPaths(entries: Entry[], cwd: string): { repo: string; rel: string }[] {
|
|
109
|
+
const repos = bases(entries).map((base) => base.repo);
|
|
110
|
+
const found = new Map<string, Record<string, string>>();
|
|
111
|
+
for (const entry of entries) if (entry.stage === "base" && entry.dirty && typeof entry.dirty === "object") found.set(String(entry.repo), entry.dirty as Record<string, string>);
|
|
112
|
+
const paths = diffAgainstBases(entries)
|
|
113
|
+
.paths.filter((path) => !outsideWork(path, cwd))
|
|
114
|
+
.map((path) => {
|
|
115
|
+
const repo = repos.find((root) => within(root, path)) ?? cwd;
|
|
116
|
+
return { repo, rel: relative(repo, path).split("\\").join("/") };
|
|
117
|
+
});
|
|
118
|
+
const unchanged = new Set<string>();
|
|
119
|
+
for (const repo of repos) {
|
|
120
|
+
const dirty = found.get(repo) ?? {};
|
|
121
|
+
const names = paths.filter((path) => path.repo === repo && path.rel in dirty).map((path) => path.rel);
|
|
122
|
+
const now = names.length ? contentHashes(repo, names) : {};
|
|
123
|
+
// An `unknown` hash proves nothing, so that path counts.
|
|
124
|
+
for (const name of names) if (dirty[name] !== "unknown" && now[name] === dirty[name]) unchanged.add(`${repo}\0${name}`);
|
|
125
|
+
}
|
|
126
|
+
return paths.filter((path) => !unchanged.has(`${path.repo}\0${path.rel}`));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The reach of the loop's diff against its bases: source files (not tests, lockfiles, behavior files, or what `exempt`
|
|
131
|
+
* names), the top-level directories they sit in, and the behavior files changed beside them. Paths already dirty when
|
|
132
|
+
* a base was recorded count once their content changes. A file at a repository root counts as a file, not a module.
|
|
133
|
+
* `crossed` names each threshold passed: `files` at three source files, `modules` at two directories, `behavior` at one
|
|
134
|
+
* behavior file.
|
|
135
|
+
*/
|
|
136
|
+
export function reachOf(entries: Entry[], cwd: string): Reach {
|
|
137
|
+
const several = bases(entries).length > 1;
|
|
138
|
+
const source: string[] = [];
|
|
139
|
+
const behavior: string[] = [];
|
|
140
|
+
const modules = new Set<string>();
|
|
141
|
+
for (const { repo, rel } of loopPaths(entries, cwd)) {
|
|
142
|
+
const shown = several ? `${basename(repo)}/${rel}` : rel;
|
|
143
|
+
if (BEHAVIOR.test(rel)) behavior.push(shown);
|
|
144
|
+
else if (!TEST_PATH.test(rel) && !LOCKFILE.test(rel) && !exempt(join(repo, rel), cwd)) {
|
|
145
|
+
source.push(shown);
|
|
146
|
+
if (rel.includes("/")) modules.add(`${several ? `${basename(repo)}/` : ""}${rel.slice(0, rel.indexOf("/"))}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const counted = source.length > 0 ? behavior : [];
|
|
150
|
+
const crossed = [
|
|
151
|
+
...(source.length >= REACH_FILES ? ["files"] : []),
|
|
152
|
+
...(modules.size >= REACH_MODULES ? ["modules"] : []),
|
|
153
|
+
...(counted.length > 0 ? ["behavior"] : []),
|
|
154
|
+
];
|
|
155
|
+
return { source: source.sort(), modules: [...modules].sort(), behavior: counted.sort(), crossed };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** The thresholds a `kind` call with a `reason` has answered so far. */
|
|
159
|
+
function answeredReach(entries: Entry[]): Set<string> {
|
|
160
|
+
const answered = new Set<string>();
|
|
161
|
+
for (const entry of entries) if (entry.stage === "kind" && typeof entry.reason === "string" && Array.isArray(entry.crossed)) for (const name of entry.crossed) answered.add(String(name));
|
|
162
|
+
return answered;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The thresholds the reach crossed that no `kind` answer covers yet; empty for a reviewed or durable loop. */
|
|
166
|
+
export function unansweredReach(entries: Entry[], reach: Reach | undefined): string[] {
|
|
167
|
+
if (!reach || !REVIEWLESS.has(currentKind(entries) ?? "inline")) return [];
|
|
168
|
+
const answered = answeredReach(entries);
|
|
169
|
+
return reach.crossed.filter((name) => !answered.has(name));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The one line that asks an unreviewed loop to re-classify; an undeclared loop is asked to declare its kind. */
|
|
173
|
+
export function reachLine(reach: Reach, kind: string | undefined): string {
|
|
174
|
+
const files = `${reach.source.length} source file${reach.source.length === 1 ? "" : "s"}`;
|
|
175
|
+
const modules = `${reach.modules.length} module${reach.modules.length === 1 ? "" : "s"} (${reach.modules.slice(0, 4).join(", ")}${reach.modules.length > 4 ? ", …" : ""})`;
|
|
176
|
+
const told = reach.behavior.length ? ` and changes ${reach.behavior.slice(0, 3).join(", ")}${reach.behavior.length > 3 ? ", …" : ""}` : "";
|
|
177
|
+
const ask = kind
|
|
178
|
+
? `call \`kind\` with \`reason\`: upgrade to reviewed, or say why ${kind} still fits`
|
|
179
|
+
: "declare `kind` with `intent` and `reason`: reviewed when it reaches past its files, or inline and why it still fits";
|
|
180
|
+
return `the change reaches ${files} across ${modules}${told}; ${ask}`;
|
|
181
|
+
}
|
|
182
|
+
|
|
90
183
|
// --- evidence ------------------------------------------------------------------------------------
|
|
91
184
|
|
|
92
185
|
type Ctx = Inputs & { seq: readonly string[]; folder?: string; lastAct: number };
|
|
@@ -206,6 +299,8 @@ function evaluate(name: string, ctx: Ctx): Status {
|
|
|
206
299
|
if (entry.declared === true && entry.result === "fail") return missing(name, "the declared verify failed");
|
|
207
300
|
if (entry.declared !== true && entry.exit !== 0) return missing(name, `the anchor exited ${entry.exit ?? "unknown"} after the last change`);
|
|
208
301
|
if (ctx.seq.includes("decide") && !artifact(ctx, "verification", from)) return missing(name, `${ctx.folder ?? "docs/specs/<folder>"}/verification.md (a durable loop's verify also needs it)`);
|
|
302
|
+
const reach = entry.reach as Reach | undefined;
|
|
303
|
+
if (unansweredReach(entries, reach).length > 0) return missing(name, reachLine(reach as Reach, currentKind(entries)));
|
|
209
304
|
return done(name, entry.declared === true ? "declared" : "");
|
|
210
305
|
}
|
|
211
306
|
case "review": {
|
|
@@ -249,7 +344,6 @@ export function computePhases(book: Pick<Book, "entries">, inputs: Omit<Inputs,
|
|
|
249
344
|
if (next === "fix") note = first?.note ?? "";
|
|
250
345
|
const skipped = statuses.filter((status) => status.state === "skipped" && status.note !== "no friction").map((status) => `${status.name} (${status.note})`);
|
|
251
346
|
const backs = book.entries.filter((entry) => entry.stage === "back").map((entry) => `${entry.phase} (${entry.reason})`);
|
|
252
|
-
const hints = retryWithoutFriction(book.entries) ? ["friction: a failed run was retried and passed, with no friction entry after it"] : [];
|
|
253
347
|
return {
|
|
254
348
|
kind: kind ?? "undeclared",
|
|
255
349
|
statuses,
|
|
@@ -258,7 +352,6 @@ export function computePhases(book: Pick<Book, "entries">, inputs: Omit<Inputs,
|
|
|
258
352
|
missing: note,
|
|
259
353
|
skipped,
|
|
260
354
|
backs,
|
|
261
|
-
hints,
|
|
262
355
|
};
|
|
263
356
|
}
|
|
264
357
|
|
package/pi/support/snapshot.ts
CHANGED
|
@@ -25,8 +25,6 @@ export type Snapshot = {
|
|
|
25
25
|
/** The program's next phase and what it lacks, in a few words. */
|
|
26
26
|
next: string;
|
|
27
27
|
missing: string;
|
|
28
|
-
/** Advisory hints that are not phases, such as an unrecorded friction. */
|
|
29
|
-
hints: string[];
|
|
30
28
|
/** The last phase the book shows complete. */
|
|
31
29
|
current: string;
|
|
32
30
|
/** A review recorded after the last change with no blocking finding on it. */
|
|
@@ -64,7 +62,6 @@ export function snapshot(book: Book, ctx: { cwd: string; sessionManager: { getBr
|
|
|
64
62
|
},
|
|
65
63
|
next: phases.next,
|
|
66
64
|
missing: phases.missing,
|
|
67
|
-
hints: phases.hints,
|
|
68
65
|
current: phases.current,
|
|
69
66
|
reviewClear: reviewClearAfterLastAct(entries),
|
|
70
67
|
};
|
|
@@ -9,7 +9,7 @@ Every entry skill (`answering`, `investigating`, `inspecting`, `coding`, `writin
|
|
|
9
9
|
|
|
10
10
|
## Align
|
|
11
11
|
|
|
12
|
-
Pick the entry's playbook from its index; with none fitting, run the loop bare. `todo` holds real work items only, optionally with `metadata.anchor` (a task's own check) and `metadata.ref` (`<path>#<heading>`). The first `todo` create opens a loop. Declare with `anchorloop_stage` only what the extension cannot observe: `kind` (`quick`, `inline`, `reviewed`, `durable`; `intent`, the task and its outcome in one line; `anchor`, the check command), `verify` (a check not run in bash), `fresh-read`, `friction`, `reflect`, `skip` or `back` (phase, reason), and `close`. Edits, anchor runs, reviews, and spec files are read from evidence; a phase that starts before an earlier one is complete warns once (`read` if you disagree), and `close` refuses only while an open todo lacks `metadata.followup` (a ticket id, `memory`, or `drop — <reason>`).
|
|
12
|
+
Pick the entry's playbook from its index; with none fitting, run the loop bare. `todo` holds real work items only, optionally with `metadata.anchor` (a task's own check) and `metadata.ref` (`<path>#<heading>`). The first `todo` create opens a loop. Declare with `anchorloop_stage` only what the extension cannot observe: `kind` (`quick`, `inline`, `reviewed`, `durable`; `intent`, the task and its outcome in one line; `anchor`, the check command; `reason` when a later call changes the kind or answers the reach an anchor run reports), `verify` (a check not run in bash), `fresh-read`, `friction`, `reflect`, `skip` or `back` (phase, reason), and `close`. Edits, anchor runs, reviews, and spec files are read from evidence; a phase that starts before an earlier one is complete warns once (`read` if you disagree), and `close` refuses only while an open todo lacks `metadata.followup` (a ticket id, `memory`, or `drop — <reason>`).
|
|
13
13
|
|
|
14
14
|
## Anchor
|
|
15
15
|
|
|
@@ -29,7 +29,7 @@ The reply names a [principle](PRINCIPLES.md) only with the decision it changed.
|
|
|
29
29
|
|
|
30
30
|
### Friction Notes
|
|
31
31
|
|
|
32
|
-
Each time an attempt fails and a later attempt reveals why, record it with `anchorloop_stage friction` before continuing.
|
|
32
|
+
Each time an attempt fails and a later attempt reveals why, record it with `anchorloop_stage friction` before continuing. An anchor that passed, failed, and passed again is recorded by the extension; reflect on that entry like any other.
|
|
33
33
|
|
|
34
34
|
### Decision Trail
|
|
35
35
|
|
package/skills/coding/SKILL.md
CHANGED
|
@@ -9,14 +9,17 @@ Run the loop in [../anchorloop/SKILL.md](../anchorloop/SKILL.md) with one of the
|
|
|
9
9
|
|
|
10
10
|
## Classify
|
|
11
11
|
|
|
12
|
-
Before the first production edit,
|
|
12
|
+
Before the first production edit, classify the change by what it reaches, not by how settled the approach feels:
|
|
13
13
|
|
|
14
|
-
- **Inline:**
|
|
15
|
-
- **
|
|
14
|
+
- **Inline:** the change stays inside the files it edits: no export another file uses, no behavior its users are told about, and no behavior the requirement leaves open. The `intent` on the `kind` call states the observable behavior after the change; the user's source-change request approves it, and approval already given is not asked again.
|
|
15
|
+
- **Reviewed:** the change reaches past its files without a decision the user owns: it changes an export other files use, a behavior users see (config keys, output, notices, command flags), or a behavior the requirement leaves open, which the reply names; or it touches a shared contract, authorization or permission data, a migration, or security. Before the first edit, write its premises in the todo's `metadata.premises`: three to five lines on what the change assumes holds, such as where its results land, what names may contain, and how paths are spelled. It needs no spec and no further approval.
|
|
16
|
+
- **Durable:** the work needs a persistent design record because of material ambiguity, a trade-off the user owns, cross-component coordination, migration risk, or a user-requested spec. Read [MINI-SDD.md](MINI-SDD.md) and create or resume its folder, which keeps no `tasks.md`; Spec waits for the user's approval before any production edit.
|
|
17
|
+
|
|
18
|
+
Re-classify when the reach changes: the user adds scope, an anchor run reports the diff's reach, or the change turns out smaller. Call `kind` with a `reason` naming the kind that now fits, or why the current one still fits. Verified work carries over; an upgrade adds only the new kind's phases, the premises and review for Reviewed, and for Durable the record from decide on, with the code so far as prototype evidence.
|
|
16
19
|
|
|
17
20
|
## Anchor
|
|
18
21
|
|
|
19
|
-
Point the anchor at what the change touches: a one-line edit anchors on the tests that assert that file; a shared code path anchors on its callers' tests. For Inline work, a green anchor plus a read of your own diff completes Verify; report the contract with its observed output in one line. Durable work verifies into `verification.md` as MINI-SDD describes.
|
|
22
|
+
Point the anchor at what the change touches: a one-line edit anchors on the tests that assert that file; a shared code path anchors on its callers' tests and the repository's tree-wide checks, such as lint, config sweeps, ratchets, and changelog checks. For Inline work, a green anchor plus a read of your own diff completes Verify; report the contract with its observed output in one line. Reviewed work adds an independent review whose brief carries the premises and asks the reviewer to test each premise against the code, to sweep each finding's class across the change, and to confirm the tree-wide checks ran. Durable work verifies into `verification.md` as MINI-SDD describes.
|
|
20
23
|
|
|
21
24
|
## Playbooks
|
|
22
25
|
|