pi-dev 0.1.6 → 0.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "An autonomous engineering skill framework for the pi runtime — built on Matt Pocock's skills.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,6 +27,22 @@ The point: **never edit a SKILL.md from gut feeling.** Edit because session N sh
27
27
  - **Target repo path** (or its sessions directory). Defaults: the user names a repo; you resolve it.
28
28
  - Optional: a specific skill name to focus the audit on (`do`, `migrate`, `triage`, …).
29
29
  - Optional: a date range.
30
+ - **Install scope** for any fixes that come out of the audit — `global` or `project`. Auto-detected (see Step 5.5); user can override per finding.
31
+
32
+ ## Install scopes
33
+
34
+ pi-runtime today loads skill bodies from a single location: `~/.pi/agent/skills/<name>/SKILL.md`. The framework's 3-layer override is on **preferences**, not on SKILL bodies. So a finding lands in one of two places:
35
+
36
+ | scope | lands in | reaches | propagation | when to pick |
37
+ | --- | --- | --- | --- | --- |
38
+ | **global** | `pi-dev`'s `skills/<name>/SKILL.md` | every consumer after the next `npx pi-dev update` | release-please → npm publish | the SKILL.md wording itself is wrong; gap shows up generically |
39
+ | **project** | consumer repo's `docs/agents/preferences.md` (Project taboos / Diagnosis posture / Local-live playbook / Free notes — whichever section fits) | only this repo, on every `/do` bootstrap | regular consumer-repo commit | gap is the repo's domain / paths / conventions, not the SKILL.md |
40
+
41
+ Notes:
42
+
43
+ - A `global` apply is **always** mirrored into `~/.pi/agent/skills/<name>/` on the operator's machine so the next session picks it up immediately, without waiting for npm.
44
+ - A `project` apply touches no pi-dev files. It is committed to the consumer repo only.
45
+ - A single audit may produce a mix of global and project findings. Decide scope per finding, not per audit.
30
46
 
31
47
  ## Session-data location & format
32
48
 
@@ -141,33 +157,131 @@ For every 🔴 / 🟡 row, quote the smallest piece of evidence that makes the g
141
157
 
142
158
  If a finding cannot be backed by an excerpt, it is not actionable yet — demote to a TODO and keep digging.
143
159
 
144
- ### 6Propose SKILL.md edits
160
+ ### 5.5Decide install scope per finding (auto + user-overridable)
161
+
162
+ For each 🔴 / 🟡 finding, pick a default scope using this two-step heuristic, then show the table to the user once and let them flip individual rows before applying.
163
+
164
+ **Step A — detect operator context.** Run once at the start of this step:
165
+
166
+ ```bash
167
+ origin=$(git -C "$PWD" remote get-url origin 2>/dev/null || echo "")
168
+ pkg_name=$(jq -r '.name // empty' package.json 2>/dev/null)
169
+ is_maintainer=false
170
+ case "$origin" in *pi-dev*|*pi-dev.git) is_maintainer=true ;; esac
171
+ [ "$pkg_name" = "pi-dev" ] && is_maintainer=true
172
+ echo "operator_context=$([ \"$is_maintainer\" = true ] && echo maintainer || echo consumer)"
173
+ ```
174
+
175
+ - `operator_context=maintainer` → cwd is the pi-dev repo itself; the release path is available.
176
+ - `operator_context=consumer` → cwd is a downstream repo; no release path. `global` findings here become "draft a patch + open an upstream PR / issue" rather than "push and release".
177
+
178
+ **Step B — score each finding.** Default to `global` if the finding matches **any** of:
179
+
180
+ - Cites SKILL.md wording / phase / predicate / rule numbers.
181
+ - The proposed fix is a generic anti-pattern string, a terminator literal, a runway line, or a lockout that any repo would benefit from.
182
+ - The same gap would plausibly show up in two or more consumer repos.
183
+
184
+ Default to `project` if the finding matches **any** of:
185
+
186
+ - Cites a repo-specific path (`src/core/...`, `bin/...-smoke.ts`), brand, schema, table, or domain term.
187
+ - The fix is a taboo, a smoke convention, an env / boot detail, or a glossary entry.
188
+ - The fix would not apply (or would be wrong) in another consumer repo.
189
+
190
+ Present the scope-decision table:
191
+
192
+ ```
193
+ | # | finding (short) | default scope | target file | flip? |
194
+ | - | ---------------------------------------- | ------------- | ------------------------------------ | ----- |
195
+ | 1 | /do hands flow back between phases | global | pi-dev:skills/do/SKILL.md | |
196
+ | 2 | docs/handoff/ resurrected after marker | global | pi-dev:skills/migrate/SKILL.md | |
197
+ | 3 | retro-action-item label still alive | project | hugn:docs/agents/preferences.md | |
198
+ | 4 | smoke command name changed in S058 | project | hugn:docs/agents/preferences.md | |
199
+ ```
200
+
201
+ Ask the user once: "OK to proceed with these scopes? Reply with row numbers to flip, or `go`." Apply their flips and move on. If `operator_context=consumer`, any rows still marked `global` get the suffix `(via upstream PR — cannot release locally)` and the apply step adjusts accordingly.
202
+
203
+ ### 6 — Propose edits (per-finding, scoped)
204
+
205
+ For each 🔴 / 🟡 finding, draft the smallest possible edit that, **if it had been in place at session time, would have prevented the gap.** The shape of the draft depends on the scope from Step 5.5:
145
206
 
146
- For each 🔴 finding, draft the smallest possible edit that, **if it had been in the SKILL.md at session time, would have prevented the gap.** Constraints:
207
+ **Global findings (target: pi-dev SKILL.md):**
147
208
 
148
209
  - Edit a **rule** or a **step**, not a flavour sentence. The model must be able to detect the constraint in its own draft output.
149
210
  - Prefer **explicit anti-pattern strings** ("Do not say 'shall I continue?'") over abstract injunctions ("be decisive"). The hugn-2026-05 audit showed that named anti-patterns work.
150
211
  - Prefer **terminal markers** ("the summary's last line must be one of these two literals: …") over qualitative descriptions of "good wrap-up".
151
212
  - Update **at most three skills per run.** More than that means findings aren't anchored well enough.
152
213
 
153
- Show the edits as a unified diff before applying.
214
+ **Project findings (target: consumer's `docs/agents/preferences.md`):**
154
215
 
155
- ### 7 Apply, release, verify
216
+ - Pick the *narrowest* existing section that fits before adding a new one. Mapping:
156
217
 
157
- Standard pi-dev release loop:
218
+ | finding flavour | preferences section |
219
+ | --- | --- |
220
+ | forbidden path / file / module / command | `## Project taboos` |
221
+ | label / state / triage rule | `## Side-effect gates` or `## Project taboos` |
222
+ | smoke / test / endpoint convention | `## Smoke / test conventions` |
223
+ | boot / env / probe change | `## Local-live playbook` |
224
+ | error taxonomy / 5-axes / domain rule | `## Diagnosis posture` |
225
+ | glossary / context term clarification | `## Glossary alignment` |
226
+ | rationale that doesn't fit elsewhere | `## Free notes` (one paragraph max, dated) |
158
227
 
159
- 1. `git add skills/<name>/SKILL.md && git commit -m "<conventional commit anchoring the evidence>"` the commit body should cite the signal that motivated each change.
160
- 2. `cp` the edited SKILL.md into `~/.pi/agent/skills/<name>/` so the **next** session in any repo picks up the change immediately (release-please takes a minute and a half).
228
+ - One bullet per finding. Reference the evidence ticket ("S058 smoke name", "#103 missing disclaimer") so the line stays auditable.
229
+ - Do **not** invent new top-level sections unless three findings legitimately share one.
230
+
231
+ Show all drafts as one unified diff per target file before applying. Group by target file: pi-dev's `skills/<name>/SKILL.md` first (global), then consumer's `docs/agents/preferences.md` (project).
232
+
233
+ ### 7 — Apply, release, verify (branches on scope)
234
+
235
+ Run both branches if the audit produced mixed-scope findings. Each branch has its own terminal state.
236
+
237
+ **7a. Global branch** — only if any finding was approved as `global` **and** `operator_context=maintainer`:
238
+
239
+ 1. From the pi-dev checkout: `git add skills/<name>/SKILL.md && git commit -m "<conventional commit anchoring the evidence>"`. Commit body must cite the signal that motivated each change.
240
+ 2. `cp` each edited SKILL.md into `~/.pi/agent/skills/<name>/` so the **next** session anywhere picks up the change immediately (release-please takes a minute and a half).
161
241
  3. `git push origin main`; release-please opens the version-bump PR; merge it; npm publish runs automatically.
162
- 4. After the next consumer session lands, re-run **this skill** and confirm the targeted signals moved.
242
+ 4. Confirm `npm view pi-dev@latest version` matches the bumped tag.
243
+
244
+ **7a' — Global findings when `operator_context=consumer`:** you cannot release. Instead:
245
+
246
+ 1. Stash the proposed diffs to `/tmp/pi-dev-upstream-<date>.patch` with one file per skill.
247
+ 2. Open an issue on `pi-dev` (or a PR if the operator has clone+push rights) with the evidence excerpts and the patch attached.
248
+ 3. As a hotfix for this machine only, optionally `cp` the edited bodies into `~/.pi/agent/skills/<name>/` and note in the issue that the next `pi-dev update` will overwrite them — which is the desired end state once the upstream change lands.
249
+
250
+ **7b. Project branch** — only if any finding was approved as `project`:
251
+
252
+ 1. In the consumer repo: edit `docs/agents/preferences.md` per the drafts from Step 6. Keep the migration marker at the very end of the file undisturbed.
253
+ 2. Bump the `last-updated` line at the top of the file to today's UTC date.
254
+ 3. `git add docs/agents/preferences.md && git commit -m "docs(agents): <one-liner per finding>"`. Conventional Commits apply.
255
+ 4. Push per the repo's normal workflow. No release-please involvement — preferences are not packaged.
256
+
257
+ **Verification (both branches).** After the next pi session in the affected repo:
258
+
259
+ 1. Re-run **this skill** scoped to the last 24 h.
260
+ 2. Confirm each previously-🔴 signal has moved (chain depth up, intervention rate down, taboo writes gone, disclaimer coverage at 100%, etc.).
261
+ 3. If a signal did not move, the fix wording was too weak — file a follow-up audit, do not re-write from scratch.
163
262
 
164
263
  ## Terminal predicate
165
264
 
166
- This skill is done when **all three** are true:
265
+ This skill is done when **all four** are true:
167
266
 
168
267
  1. A signal table with severities and evidence excerpts has been presented.
169
- 2. Either (a) zero 🔴 findings flow is healthy, recorded as "no change this cycle", OR (b) a unified diff for each 🔴 finding has been applied to `skills/<name>/SKILL.md` AND mirrored into `~/.pi/agent/skills/<name>/`.
170
- 3. If diffs landed, the release loop (commit push merge release PR npm publish) finished and the new version is `npm view pi-dev@latest version`.
268
+ 2. Each finding has an approved scope (`global` / `project` / `defer`) on record, defaulted by Step 5.5 and confirmed by the user.
269
+ 3. Either (a) zero 🔴 findings — flow is healthy, recorded as "no change this cycle", OR (b) each 🔴 finding has landed in its scope's target file (or been stashed + filed upstream when an operator-context mismatch prevents release).
270
+ 4. For any landed change: if `global` and `maintainer`, the npm version has bumped (`npm view pi-dev@latest version`); if `project`, the consumer repo has the commit on its push-stream. Either way, the next-session re-audit plan is stated.
271
+
272
+ The summary's **last line** must be one of:
273
+
274
+ ```
275
+ audit complete — no changes this cycle.
276
+ ```
277
+
278
+ ```
279
+ audit complete — global v<X.Y.Z> released, project commit <sha>, next re-audit after the next session.
280
+ ```
281
+
282
+ ```
283
+ audit complete — upstream issue <#N> filed, project commit <sha>, hotfix mirrored to ~/.pi.
284
+ ```
171
285
 
172
286
  ## What this skill does not do
173
287