@jyyyeung/pi-retro

中文文档
0.1.3发布于 2026/11/01MITES Module零依赖

Retrospective loop for your pi coding-agent setup: cost-filtered friction ledger, trials verdicts, weekly adopt/evaluate/reject review.

原始使用文档
文档目录15 节
  1. What it does
  2. Install
  3. Quick start
  4. Scopes
  5. Ledger format
  6. Config lives in the file
  7. Tools
  8. The weekly ritual ( /retro )
  9. Scope and non-goals
  10. Security & trust
  11. Requirements
  12. Troubleshooting
  13. Related packages
  14. Development
  15. License

pi-retro

npm CI License: MIT Pi Node

A retrospective loop for your pi coding-agent setup — so friction turns into changes instead of a memory of vibes.

What it does

Agents collect friction all week — tooling misbehavior, token/context pain, hallucination or spec drift, git trouble, security near-misses, workflow gaps — into a cost-filtered ledger. Once a week, a review aggregates it, verdicts your active trials, and proposes adopt / evaluate / reject changes. You approve; nothing auto-applies.

Install it if you keep noticing the same friction every week and never change anything, or if you are running several extensions and cannot say which of them are earning their keep.

Not a memory store (no verified facts), not observability (no call traces) — a curated improvement queue with a human in the loop.

Install

pi install npm:@jyyyeung/pi-retro

Then restart pi (or /reload).

From a local checkout:

pi install ./pi-retro
pi -e ./pi-retro/extensions/retro.ts

Quick start

  1. Hit friction in any session → the agent calls log_friction (the bundled friction-log skill triggers it on real friction, without asking).
  2. Run /retro weekly. The review writes a dated report and proposes changes.
  3. Approve → apply, then friction_archive clears the reviewed ledger.

The first log_friction call bootstraps the ledger file with a header you can edit (areas are config — see below). friction_stats works before that: it reports zeros and the path it would create, and never throws just because nothing has been logged yet.

/retro-stats prints the aggregate without invoking a model turn — the cheap way to check whether a weekly review is due. (/retro is the review itself, delivered by the bundled prompt template plus the weekly-review skill.)

Scopes

user (default)project
Path~/.pi/agent/meta/problems-ledger.md<repo>/.pi/retro/ledger.md
Audienceyou, cross-projectthe team
Forpersonal-setup friction (quota, host, your extensions)friction the team can act on (CI, tests, review, workflow)

Privacy rule: entries are never copied between scopes. The project ledger is not created until someone logs with scope: "project" inside the repo; team sharing (committing it) is the team's explicit decision — gitignore it until then.

Ledger format

One line per event:

YYYY-MM-DD | project | area | phase | problem | fix?

Managed markers (tools write them; they stay human-readable):

  • [x3 last 2026-10-15] — recurrence: the same friction hit again within 30 days bumps the counter instead of adding a line.
  • → RESOLVED 2026-10-14: note — resolution: the strongest positive signal the review gets.

A literal | inside a field is escaped (\|) on write and unescaped on read, so a || b fails stays exactly as written instead of being rewritten to a / b. Entries written by older versions (unescaped pipes) still parse. Lines that look like entries but fail to parse are reported by friction_stats (with line numbers) instead of being silently dropped from the totals.

Config lives in the file

<!-- pi-retro: areas = tooling|tokens|hallucination|isolation|security|workflow|quality -->

Edit that header line to change the area taxonomy. The file is self-describing, survives package updates, and can differ per scope.

Tools

ToolWhat it does
log_frictionAppend one entry (or bump a recurrence). Params: project, area, phase, problem, optional fix, cost (S/M/L), scope, force.
friction_statsRead-only aggregate: counts by area/project, open vs resolved, top recurring, malformed-line count. Use instead of reading whole files.
friction_resolveAppend a resolution marker to one unambiguously-matched open entry.
friction_archiveMove resolved entries to archive/YYYY-MM-DD.md; resolvedOnly: false also moves unresolved entries idle longer than days (default 30).

The weekly ritual (/retro)

  1. friction_stats both scopes; read unresolved entries.
  2. Evaluate ACTIVE trials from your trials registry (convention: ~/.pi/agent/meta/extension-trials.md) against their pre-registered success criteria → KEEP / REMOVE / EXTEND per trial.
  3. Optionally research trends for the top friction areas.
  4. Write a dated report (~/.pi/agent/meta/weekly-reviews/YYYY-MM-DD.md) with adopt / evaluate / reject buckets — rejections carry reasons, and future suggestions bounce against them.
  5. Propose. The owner approves. Then apply, archive, and promote durable lessons into project docs.

Suggestions stay evidence-tethered: the fix field on a friction entry IS the suggestion, with the friction as its reason. There is deliberately no free-form suggestion inbox.

Scope and non-goals

  • Not memory. Nothing in the ledger is treated as a verified fact; the agent's memory system is a separate concern.
  • Not observability. No call traces, timings, or token accounting — one line per friction event, and only when it actually cost you something.
  • Not automatic. The review proposes; you approve. No package configures itself because a retro said so.
  • Not a shared inbox. Scopes never merge: personal friction stays personal, team friction stays in the repo you chose to share.

Security & trust

  • No network access, no telemetry, no dependencies beyond pi's host-provided packages (peerDependencies only).
  • Writes are confined to the ledger file and its archive/ directory; no tool accepts a path parameter.
  • Appends use O_APPEND; rewrites write a temp file and rename, so a crash mid-write cannot truncate the ledger.
  • Small enough to read in one sitting (~850 lines across the extension and its ledger module) — please do.

Requirements

RequirementNeeded forIf missing
pi ≥ 1.3the tools and /retro—
Node ≥ 20 (22.6+ to run the tests)everything—
a writable ~/.pi/agent/meta/ (or PI_RETRO_LEDGER)the user ledgerlog_friction reports the path it could not write

Troubleshooting

friction_stats says the ledger does not exist. Expected before the first log: it reports zeros plus the path it would create. log_friction bootstraps the file (with its editable header) on first use.

My hand-edited line is missing from the totals. It failed to parse. Run friction_stats again — malformed lines are now listed with line numbers instead of being dropped silently. The usual cause is a field order change; the format is date | project | area | phase | problem | fix?.

/retro produced no report. /retro is a prompt template plus the weekly-review skill, so it needs a model turn. /retro-stats gives you the same aggregate with no model involvement, and friction_stats gives it as a tool call.

The ledger went to the wrong repo. Project entries resolve from the session cwd. PI_RETRO_LEDGER overrides the user ledger path; project ledgers are <repo>/.pi/retro/ledger.md and only appear once you log with scope: "project".

Five extensions for the same problem — agent sessions sharing a checkout — covering different moments:

PackageMomentGuards against
pi-rc-gateat executionthe failure signal being destroyed, so a red command is reported green
pi-checkout-guardduringconcurrent sessions wiping each other's uncommitted work
pi-closeoutat session endthe dirty state a session leaves for the next one
pi-retro (this)weeklyfriction that keeps recurring because nobody wrote it down
pi-handoffbetween sessionscontext lost when a session ends

Development

npm install
npm run typecheck   # tsc --noEmit
npm test            # node --test (type-stripped TS, node >= 22.6)

License

MIT © jyyyeung

版本与发布记录

@jyyyeung/pi-retro 共发布 3 个版本,首次发布于 2026/11/01;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.1.3latest2026/11/012 天前
0.1.22026/11/012 天前
0.0.0-stage2026/11/012 天前

关于 @jyyyeung/pi-retro 的常见问题

@jyyyeung/pi-retro 是什么?

pi编码代理设置的回顾循环:成本过滤的摩擦分类账,试验裁决,每周采用/评估/拒绝审查。

如何安装 @jyyyeung/pi-retro?

在项目目录运行 npm install @jyyyeung/pi-retro,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typebox(>=0.32.0)、@earendil-works/pi-coding-agent(>=1.3.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@jyyyeung/pi-retro 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/jyyyeung__pi-retro 是否存在。

@jyyyeung/pi-retro 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@jyyyeung/pi-retro 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@jyyyeung/pi-retro 可以商用吗?

@jyyyeung/pi-retro 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@jyyyeung/pi-retro 还在维护吗?

最新版本 0.1.3 发布于 2026/11/01(2 天前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/11/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。