pi-dev-flow 0.59.0 → 0.60.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/CHANGELOG.md +13 -0
- package/README.md +4 -0
- package/docs/guardrails.md +3 -3
- package/extensions/dev-flow.ts +63 -35
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +1 -1
- package/src/core.ts +30 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.60.0] - 2026-10-23
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- **dev-flow is fully dormant until the playbook exists — and fully present after.** *Initiated* now means exactly one thing: `.dev-flow/project.md` (written by `flow init`) exists. Until then a folder hears nothing at all: no context injection, no footer, and no guards — the stage discipline, main-branch git rules and the bash-timeout refusal and its silent arming included (`flow init` is the opt-in; a stray `.dev-flow/` without the playbook keeps the folder asleep), and every gate verb but `flow init`/`flow version` says so plainly instead of half-running. Once initiated, the footer never goes silent: bound sessions see the stage glyph + slug as before, unbound ones the `⧖ N flow(s) open` count, and a repo with nothing in flight now shows `⧖ no flows` instead of nothing — you can see dev-flow is watching. The footer also repaints at the **start** of every agent run, not just at session start and turn end: `setStatus` is a fire-and-forget push in pi-web, and run start is the earliest moment a late-attaching web client is certainly listening (a push the browser missed before attaching could leave the bar blank until the next gate).
|
|
12
|
+
|
|
13
|
+
## [0.59.1] - 2026-10-23
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **A session running an older dev-flow build than the checkout now says so — including in the dev-flow repo, where it never could.** `flow start` carried a behind-the-checkout warning and `flow release` carried the update-or-proceed question, but both compared the loaded build against `pluginVersion(import.meta.dirname)` — the `package.json` sitting beside the running code, which is the same file `loadedVersion()` reads — so the comparison was X against X and only the `DEV_FLOW_LOADED_VERSION` test seam ever made it unequal. A session that loaded 0.54.0 while this checkout already shipped 0.58.1 started, released and finished looking current, and the gate proofs shipped in between silently did not run. `checkoutBuild(root)` now answers what the disk says to run: this checkout's own manifest in the dev-flow repo, the installed package's everywhere else. `start`, `status`, `version`, `release` and `release-done` read it, the stamp in `state.json` records the build that actually ran rather than the one the disk claims, and `flow version` names the directory the stale code lives in. The stale release question stays a question — an operator who ships from behind is a choice, never a block.
|
|
18
|
+
- **Scratch outside the checkout is stage-free.** With a flow bound at `implement` or `pre-release`, the write guard refused every path that was not the worktree or `.dev-flow/` — `/tmp/split_skill.py` included — so an agent doing a mechanical multi-file rewrite had nowhere to keep a throwaway script and learned to park junk inside the checkout instead. A path whose realpath is under the OS temp dir is now allowed at every stage and with no flow bound, checked after the dev-flow-owned refusals and after per-path owner attribution, so neither a symlink out of the temp dir nor a `worktreeDir` an operator parked there reaches those rules; a repository that merely lives under the temp dir (every smoke-test repo) keeps the stage rules untouched. The refusal that remains names the temp dir as its own way out.
|
|
19
|
+
|
|
7
20
|
## [0.59.0] - 2026-10-23
|
|
8
21
|
|
|
9
22
|
### Added
|
package/README.md
CHANGED
|
@@ -56,6 +56,10 @@ package — so keep the one you actually update from: `flow version` lists every
|
|
|
56
56
|
registered in the process, and the on-disk session claim keeps the guard of a copy that never served
|
|
57
57
|
a flow call attributing your commands correctly.
|
|
58
58
|
|
|
59
|
+
Until `flow init` writes the playbook (`.dev-flow/project.md`), dev-flow says nothing in a repo — no
|
|
60
|
+
injections, no guards, no footer: the playbook is the opt-in. A stray `.dev-flow/` without it keeps
|
|
61
|
+
the folder dormant.
|
|
62
|
+
|
|
59
63
|
Then, once per project repo, `/flow init`. It reads the repo (default branch and forge from git,
|
|
60
64
|
package manager, test/build/run conventions, version manifest) and writes **`.dev-flow/project.md`
|
|
61
65
|
— your playbook**: the commands that count as checks, the manual checklist, the version and tag
|
package/docs/guardrails.md
CHANGED
|
@@ -6,16 +6,16 @@ While a feature is active, the extension intercepts every tool call:
|
|
|
6
6
|
|
|
7
7
|
- **Nothing on main, ever** (until release): `git commit` on the default branch is blocked at every stage except `release` — where release chores commit in the main checkout (prefixed `DEV_FLOW_ALLOW_MAIN=1` for the hook) — and except one chore that needs no flow: a commit whose **only** change in the checkout is `.dev-flow/project.md`, because tracking the operator's playbook is setup, not feature work (any other dirty path closes that lane). pushes are judged by the ref they write — only pushing *to* the default branch (or a bare push while on it) requires stage `release`, so tag pushes and feature-branch pushes pass from any stage; `git merge` onto the default branch also requires stage `release`. Plus the standalone pre-commit hook for commits made outside Pi.
|
|
8
8
|
- **No code before an approved plan**: at stage `plan`, edits are confined to `.dev-flow/<slug>/` — the session's **own** feature directory, so one session cannot write another feature's plan and have its gate rubber-stamp what it never wrote.
|
|
9
|
-
- **Work stays in the worktree**: at stages `implement` and `pre-release`, edits are confined to that feature's worktree — judged per-path by the owning feature, so one session can never write into another session's worktree or into the main checkout.
|
|
9
|
+
- **Work stays in the worktree**: at stages `implement` and `pre-release`, edits are confined to that feature's worktree — judged per-path by the owning feature, so one session can never write into another session's worktree or into the main checkout. A throwaway **outside** the checkout is not feature work and stays free at every stage (the OS temp dir, e.g. a one-off rewrite script): both sides are realpath'd, so a symlink out of the temp dir is still judged as the repo path it writes, and a repository that merely lives under the temp dir (a test repo) keeps the stage rules.
|
|
10
10
|
- **Flow by default**: in a repo with `.dev-flow/`, an unbound session cannot touch source files at all — every request goes through `flow start`/`flow use`; there is no bypass. `flow start` refuses when the main checkout isn't on the default branch, worktrees are always created from the default branch, and the agent cannot check feature branches out in the main checkout.
|
|
11
11
|
- **Gates can't be skipped**: flow state is untouchable by the agent (edit tool and bash) — writing `state.json`, moving it away, or deleting a feature directory or the whole `.dev-flow/` folder all block; the `project.md` playbook is operator-owned — the main-checkout copy is blocked for the agent outright, and only a **docs or patch flow's** worktree copy may be edited (normal features route playbook changes to their own flow); every sanctioned playbook overwrite keeps the previous file as `project.md.bak`; editing worktree code invalidates a passing test check until `flow test` reruns.
|
|
12
12
|
- **Your project's own rules**: every `deny`/`confirm`/`protect`/`forbid` rule from the `flow-guard` block in project.md `## global` runs on every bash command and every edit/write path — in every stage and binding, ahead of dev-flow's own verdicts. A block always carries the reason you wrote.
|
|
13
13
|
- **The rules reach the agent, they are not left in a file it may never read**: pi advertises a skill and loads it only if the model chooses to, so the ground rules of the dev-flow skill are injected into every session once (and again after a compaction that summarized them away), and each stage's turn names the one playbook file that stage needs. The guards enforce the same discipline either way — this is what makes the agent follow it without being stuck.
|
|
14
14
|
- **A forced push asks the operator**: `git push` carrying `--force`, `--force-with-lease…` or `-f` is confirmed before it runs — a rewritten branch is history CI and other sessions already have. The one spelling that answers for it is the prefix the refusal prints (`DEV_FLOW_ALLOW_REWRITE=1 git push -f …`), the same "the operator said so" contract as `DEV_FLOW_ALLOW_MAIN`. Local history rewrites (`git filter-branch --force`) are not pushes and stay free, so a project never needs a blunt flag-only deny of its own.
|
|
15
|
-
- **Shell calls can't hang forever**: pi kills a shell command only when the model passed a `timeout` — it omits one in ~75% of calls, so a `gh` waiting on a prompt or a dead `curl` froze sessions for hours.
|
|
15
|
+
- **Shell calls can't hang forever**: pi kills a shell command only when the model passed a `timeout` — it omits one in ~75% of calls, so a `gh` waiting on a prompt or a dead `curl` froze sessions for hours. In an initiated repo (`.dev-flow/project.md` exists) the call is therefore by default **refused** until the model states one (`bashTimeout = require`): the refusal names the exact value the class table would have armed, so the retry is a one-token fix and the call line in the transcript shows the timeout that is actually running. The injected class default (30s quick inspection · 120s local git and unknown · 180s network · 300s containers/services · 900s builds/tests/installs · 1,200s watchers like `gh run watch`) stays armed underneath either way, and absurd explicit values clamp to 1,800s. A project that would rather not nag sets `bashTimeout = inject` in `## global` — then the default is armed silently and the call passes. Uninitiated folders hear nothing at all: without the playbook dev-flow enforces no rules.
|
|
16
16
|
- **Compact-aware**: dev-flow paces compaction the way pi counts it: the self-compaction trigger uses the *effective* `reserveTokens` (settings and per-model overrides, not the built-in default) and is checked at every turn end, not only when a run settles. When pi force-compacts on its threshold anyway — the chat-only states (open tier-2 dialog, plan discussion not yet in `plan/`) refuse to self-compact by design — dev-flow takes the compaction over and redoes it with flow-aware summary instructions (overflow recovery keeps pi's compact-and-retry and is left alone). Auto-compaction turned off in settings is honored; a note about any compaction dev-flow could not shape still lands in `reflections.md`.
|
|
17
17
|
- The active stage is injected into the model's context every turn; the bundled `dev-flow` skill is the agent's playbook, including the recommended sequences: pre-release — review (`/flow-review`) → fixes → docs → changelog/version bump; release — PR → merge → tag → `release-done`. The package also bundles the review skills themselves — `/flow-review` (a change, read against its `plan/plan.md`) and `/flow-audit` (the whole repo) — and injects a built-in senior-discipline guidance at implement stage unless the playbook sets its own `prose.implement`.
|
|
18
|
-
- **Status bar**: while the session **is bound** to a feature
|
|
18
|
+
- **Status bar**: an initiated repo (`.dev-flow/project.md` exists) always carries the dev-flow footer; while the session **is bound** to a feature it shows `<stage glyph> <slug>` plus mode markers — stages 📝 plan, 🔨 implement, 🔍 pre-release, 🚀 release; markers ⚡ patch, 📚 docs, 🎱 yolo, and `⚠️` while a check of the bound feature fails (emoji render in their own color, so the footer carries no theme coloring). An **unbound** session never sees a slug — it shows `⧖ N flow(s) open` (unfinished-feature count only, no warning marker) or `⧖ no flows` when nothing is in flight; a session binds only via `flow start`/`flow use`, never by opening. The footer repaints at session start, at the start of every agent run (the earliest a late-attaching web client is listening) and after every gate; an uninitiated folder gets no footer at all. `flow status` is the spelled-out surface: `stage=implement`, the per-feature mode tags (`[ui]`, `[yolo]`, `[no-version]`) and the `flow=<ver>` stamp of the build that started the feature.
|
|
19
19
|
|
|
20
20
|
## Limitations (deliberate, v1)
|
|
21
21
|
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -133,6 +133,17 @@ function loadedVersion(): string | null {
|
|
|
133
133
|
/** This build's own identity, read once (the guard hot path must not re-walk the fs per call). */
|
|
134
134
|
const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
135
135
|
|
|
136
|
+
/** The dev-flow build this session *should* be running, as the disk describes it, and how to call it.
|
|
137
|
+
* In the dev-flow repo that is the checkout's own manifest: main moves ahead of the installed copy at
|
|
138
|
+
* every release, while `loadedVersion()` and the plugin's own package.json are the same file — so a
|
|
139
|
+
* session running 0.54.0 in a checkout already at 0.58.1 compared equal and nothing anywhere said so.
|
|
140
|
+
* In a normal project the only manifest is the installed package's, which a mid-session update moves. */
|
|
141
|
+
function checkoutBuild(root: string): { version: string | null; dir: string; repo: string; label: string } {
|
|
142
|
+
return isSelfRepo(root)
|
|
143
|
+
? { ...pluginVersion(root), label: "this checkout" }
|
|
144
|
+
: { ...SELF_BUILD, label: "the dev-flow install" };
|
|
145
|
+
}
|
|
146
|
+
|
|
136
147
|
/** Cross-copy registry: one process can register dev-flow more than once (the documented
|
|
137
148
|
* two-sources-at-once hazard: a project dogfood pointer plus an installed copy), and EVERY copy
|
|
138
149
|
* evaluates every guard hook. The flow-tool binding belongs to whichever copy served the call,
|
|
@@ -186,6 +197,10 @@ async function sh(command: string, cwd: string): Promise<{ ok: boolean; out: str
|
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
const dfDir = (root: string) => path.join(root, ".dev-flow");
|
|
200
|
+
/** dev-flow is initiated once the operator playbook exists: before flow init writes project.md the
|
|
201
|
+
* extension is silent in that folder — no injections, no guards (not even the no-playbook bash-timeout
|
|
202
|
+
* default), no footer. The flow tool itself stays registered so flow init remains callable. */
|
|
203
|
+
const initiated = (root: string): boolean => existsSync(path.join(dfDir(root), "project.md"));
|
|
189
204
|
|
|
190
205
|
/** A `--merge=squash` style flag, or null when absent. Returned as the raw string: the caller validates it
|
|
191
206
|
* with parseMergeStyle so a typo is reported instead of ignored. */
|
|
@@ -289,7 +304,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
289
304
|
}
|
|
290
305
|
|
|
291
306
|
const GATE_HELP =
|
|
292
|
-
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>|tidy] | roadmap [add <text>|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui] [--force] [--patch|--docs --confirmed] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version|--no-fold-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version [--check-upstream] — start preflights the playbook before creating anything: it prints playbook gaps and warns when the session runs an older dev-flow build, and it refuses until a merge policy is set (ask the operator squash / merge / rebase / any in chat, then re-run with --merge=<style> --confirmed — the answer is written into project.md and enforced from then on: gh/glab merges that contradict it are blocked, and release-done proves what actually landed); version prints the
|
|
307
|
+
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>|tidy] | roadmap [add <text>|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui] [--force] [--patch|--docs --confirmed] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version|--no-fold-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version [--check-upstream] — start preflights the playbook before creating anything: it prints playbook gaps and warns when the session runs an older dev-flow build than the disk ships (in the dev-flow repo, an older build than this checkout's own manifest), and it refuses until a merge policy is set (ask the operator squash / merge / rebase / any in chat, then re-run with --merge=<style> --confirmed — the answer is written into project.md and enforced from then on: gh/glab merges that contradict it are blocked, and release-done proves what actually landed); version prints the build the disk says to run (this checkout's own manifest in the dev-flow repo, the installed package's elsewhere) and names any other dev-flow copies registered in the same process (--check-upstream also asks the registry for the published one) — reflect <note> queues a suggestion in reflections.md (gate flags like --confirmed are ignored there); reflect tidy drops the closed (`- [x]`) items from reflections.md — every surface that queues or reviews reflections nudges when the checked-off pile grows; bare reflect prints the full session-reflection protocol (review the session log, re-check open items against shipped fixes and newer dev-flow versions, dedupe and report new findings, put the fix decision to the operator); roadmap manages .dev-flow/roadmap.md, the gitignored backlog of future features (bare lists open items; add appends one; pick <n> <slug> stamps open item <n> with the slug a later flow start uses — flow finish checks it off when that feature ships; done <n> checks off by hand; tidy drops done items); bare doctor reviews structure, git consistency and open reflections (routes each fix to a flow; it never writes); doctor <note> prints an investigation brief for a fresh observation; state gates take [slug] and --confirmed (the operator already answered in chat); --patch/--docs likewise need --confirmed (the operator granted the mode); --yolo on any state gate (approve/verify/release/finish) = the operator said \"yolo\" at that checkpoint: it answers that question and pre-confirms every later one (needs --confirmed; checks and guardrails stay); release --no-fold-check = operator-granted escape from the changelog fold proofs (the entries pending before the release are not line-checked; the entry heading and the 'this branch touched the changelog' proofs stay); release --no-version = this flow ships merge + changelog only — no bump, tag or forge release; the entry rides under Unreleased until the next versioned release folds it (default: versioned); when the session runs an older dev-flow build than the checkout, release names both builds, lists what the running code can no longer prove, and asks the operator update (/reload) or proceed with the old release — an operator decision recorded in state and repeated by release-done, never a block";
|
|
293
308
|
const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
294
309
|
const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
295
310
|
const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -448,7 +463,7 @@ const flowCompactInstructions = (st: FlowState) =>
|
|
|
448
463
|
* never while chat-only state is pending (open dialog, undigested plan) — see shouldSelfCompact.
|
|
449
464
|
*/
|
|
450
465
|
function maybeCompactNow(ctx: ExtensionContext): void {
|
|
451
|
-
if (!
|
|
466
|
+
if (!initiated(ctx.cwd)) return;
|
|
452
467
|
const u = ctx.getContextUsage?.(); // minimal/fake contexts may lack usage info — treat as unknown
|
|
453
468
|
if (!u || u.tokens === null) return;
|
|
454
469
|
const key = sessionKey(ctx);
|
|
@@ -657,7 +672,8 @@ async function runFlow(args: string[], root: string, ui: Ui, sess: Session): Pro
|
|
|
657
672
|
const [sub = "status", ...rest] = args;
|
|
658
673
|
// help and version are questions about the plugin, not the repo: answerable with no .dev-flow/ at all
|
|
659
674
|
if (sub === "help" || sub === "--help" || sub === "-h") return { text: rest.includes("--json") ? gateHelpJson(GATE_HELP, loadedVersion()) : `usage: flow <sub> — ${GATE_HELP}` };
|
|
660
|
-
|
|
675
|
+
// an uninitiated folder is dormant: every gate verb but init and version needs the operator playbook (project.md)
|
|
676
|
+
if (!initiated(root) && sub !== "init" && sub !== "version") return { text: "dev-flow is not initiated here — no .dev-flow/project.md — run flow init first", isError: true };
|
|
661
677
|
const cfg = loadProject(dfDir(root)).cfg;
|
|
662
678
|
const flag = (name: string) => rest.includes(`--${name}`);
|
|
663
679
|
const slugArg = rest.find((a) => !a.startsWith("--"));
|
|
@@ -809,15 +825,15 @@ ${mdDigest(draftRefresh)}`))
|
|
|
809
825
|
if (curBr !== cfg.defaultBranch && !flag("force")) return { text: `main checkout is on ${curBr}, not ${cfg.defaultBranch} — check out ${cfg.defaultBranch} first (git checkout ${cfg.defaultBranch} && git pull) or flow use an unfinished feature; --force to override`, isError: true };
|
|
810
826
|
// --- preflight: is this session running the current build, and is the playbook complete? ---
|
|
811
827
|
const notes: string[] = [];
|
|
812
|
-
const
|
|
813
|
-
const behind = sessionRunsOlderBuild(loadedVersion(),
|
|
814
|
-
if (behind) notes.push(`warning: this session runs dev-flow ${behind},
|
|
828
|
+
const disk = checkoutBuild(root);
|
|
829
|
+
const behind = sessionRunsOlderBuild(loadedVersion(), disk.version);
|
|
830
|
+
if (behind) notes.push(`warning: this session runs dev-flow ${behind}, ${disk.label} ships ${disk.version} — /reload before trusting what a gate prints`);
|
|
815
831
|
const dupStart = copyWarning();
|
|
816
832
|
if (dupStart) notes.push(dupStart);
|
|
817
833
|
if (flag("check-upstream")) {
|
|
818
834
|
const pub = await sh("npm view pi-dev-flow version", root);
|
|
819
835
|
const newest = pub.ok ? pub.out.trim().split("\n").pop() : "";
|
|
820
|
-
notes.push(newest ? `published dev-flow: ${newest} (this build: ${
|
|
836
|
+
notes.push(newest ? `published dev-flow: ${newest} (this build: ${loadedVersion() ?? "?"})${loadedVersion() && newest !== loadedVersion() ? " — an update is available" : ""}` : "could not read the published dev-flow version (offline?)");
|
|
821
837
|
}
|
|
822
838
|
// missing playbook parameters are printed at the moment they start to matter, not promised to a later doctor run
|
|
823
839
|
const gaps = doctorFindings(root, cfg, loadProject(dfDir(root)).md).filter((x) => !x.startsWith("no merge policy"));
|
|
@@ -849,12 +865,13 @@ ${mdDigest(draftRefresh)}`))
|
|
|
849
865
|
cfg.release.merge = style;
|
|
850
866
|
notes.push(written.note);
|
|
851
867
|
}
|
|
852
|
-
// stamp the dev-flow build that started this feature — a stuck flow can later be read against its tooling
|
|
853
|
-
|
|
868
|
+
// stamp the dev-flow build that started this feature — a stuck flow can later be read against its tooling.
|
|
869
|
+
// the stamp is what ran, not what the disk claims (that mismatch is the warning above).
|
|
870
|
+
const state = newState(slugArg, flag("ui"), flag("patch"), flag("docs"), loadedVersion() ?? undefined);
|
|
854
871
|
mkdirSync(path.join(featDir(root, slugArg), "plan"), { recursive: true });
|
|
855
872
|
writeState(root, state);
|
|
856
873
|
sess.bind(slugArg);
|
|
857
|
-
return { text: `feature ${slugArg} started at stage plan (ui=${state.ui}${state.patch ? ", patch" : state.docs ? ", docs" : ""}${
|
|
874
|
+
return { text: `feature ${slugArg} started at stage plan (ui=${state.ui}${state.patch ? ", patch" : state.docs ? ", docs" : ""}${state.flowVersion ? `, dev-flow ${state.flowVersion}` : ""}).${notes.length ? `\n${notes.join("\n")}` : ""}\n${nextHint(state, cfg)}` };
|
|
858
875
|
}
|
|
859
876
|
|
|
860
877
|
case "status": {
|
|
@@ -862,7 +879,11 @@ ${mdDigest(draftRefresh)}`))
|
|
|
862
879
|
const { md } = loadProject(df);
|
|
863
880
|
// cheap fs probes only (no git subprocesses) — status is a glance, `flow doctor` is the full list
|
|
864
881
|
const findings = md ? doctorFindings(root, cfg, md) : [];
|
|
865
|
-
|
|
882
|
+
// a session running an older build than the disk ships is the one thing a glance must say: every
|
|
883
|
+
// gate proof printed since the drift began belongs to the older code.
|
|
884
|
+
const disk = checkoutBuild(root);
|
|
885
|
+
const staleBuild = sessionRunsOlderBuild(loadedVersion(), disk.version);
|
|
886
|
+
const warn = [...(findings.length ? [`⚠ doctor: ${findings.length} finding(s) — run flow doctor`] : []), ...(staleBuild ? [`⚠ this session runs dev-flow ${staleBuild}, ${disk.label} ships ${disk.version} — /reload`] : []), ...(copyWarning() ? [copyWarning()!] : [])];
|
|
866
887
|
// the backlog nudge belongs to the no-features answer too — that is when a pick is most useful
|
|
867
888
|
const rmap = roadmapOpenCount(readRoadmap(root));
|
|
868
889
|
const rmapLine = rmap ? [`◇ ${rmap} roadmap item(s) open — flow roadmap`] : [];
|
|
@@ -968,9 +989,11 @@ ${mdDigest(draftRefresh)}`))
|
|
|
968
989
|
|
|
969
990
|
case "version": {
|
|
970
991
|
// the plugin's own version — separate from the project's versioning.file version the release gates use
|
|
971
|
-
const self =
|
|
992
|
+
const self = checkoutBuild(root);
|
|
972
993
|
const behind = sessionRunsOlderBuild(loadedVersion(), self.version);
|
|
973
994
|
const head = self.version ? `dev-flow ${self.version} (pi-dev-flow at ${self.dir})` : `dev-flow version unknown — no pi-dev-flow package.json above ${self.dir}`;
|
|
995
|
+
// in the dev-flow repo head names the checkout, so name where the stale code actually lives
|
|
996
|
+
const from = SELF_BUILD.dir !== self.dir ? ` (from ${SELF_BUILD.dir})` : "";
|
|
974
997
|
const dupNote = copyWarning();
|
|
975
998
|
// --check-upstream is the one that asks the registry; plain flow version stays offline and instant
|
|
976
999
|
if (flag("check-upstream")) {
|
|
@@ -978,7 +1001,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
978
1001
|
const newest = pub.ok ? pub.out.trim().split("\n").pop() : "";
|
|
979
1002
|
return { text: newest ? `${head} — published: ${newest}${self.version && newest !== self.version ? " (update available)" : ""}` : `${head} — could not read the published version (offline?)` };
|
|
980
1003
|
}
|
|
981
|
-
return { text: `${behind ? `${head} — but this session runs ${behind}; /reload to run ${self.version}` : head}${dupNote ? `\n${dupNote}` : ""}` };
|
|
1004
|
+
return { text: `${behind ? `${head} — but this session runs ${behind}${from}; /reload to run ${self.version}` : head}${dupNote ? `\n${dupNote}` : ""}` };
|
|
982
1005
|
}
|
|
983
1006
|
|
|
984
1007
|
case "approve": {
|
|
@@ -1206,7 +1229,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1206
1229
|
// legitimate choice (hotfix, offline reload), and refusing would close exactly the emergency the relaxed
|
|
1207
1230
|
// modes exist for. The gate names both builds, lists what the running code is missing, and folds the
|
|
1208
1231
|
// update-or-proceed question into the Release? checkpoint — the operator's word, recorded in state.
|
|
1209
|
-
const selfBuild =
|
|
1232
|
+
const selfBuild = checkoutBuild(root);
|
|
1210
1233
|
const behind = sessionRunsOlderBuild(loadedVersion(), selfBuild.version);
|
|
1211
1234
|
// truly behind, not merely different: a session whose loaded build is NEWER than the checkout's manifest
|
|
1212
1235
|
// has every proof the checkout would run, and asking about it would be noise.
|
|
@@ -1217,12 +1240,12 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1217
1240
|
const clPath = path.join(selfBuild.dir, "CHANGELOG.md");
|
|
1218
1241
|
const missing = existsSync(clPath) && selfBuild.version ? changelogVersionsBetween(readFileSync(clPath, "utf8"), behind, selfBuild.version) : [];
|
|
1219
1242
|
staleAsk =
|
|
1220
|
-
` This session runs dev-flow ${behind},
|
|
1243
|
+
` This session runs dev-flow ${behind}, ${selfBuild.label} ships ${selfBuild.version ?? "?"} — gate proofs shipped between the two will NOT run. ` +
|
|
1221
1244
|
(missing.length
|
|
1222
1245
|
? `Shipped since ${behind}: ${missing.slice(0, 8).join(", ")}${missing.length > 8 ? ` …(${missing.length} total)` : ""} — see ${clPath}. `
|
|
1223
1246
|
: `What shipped between them is not readable from the checkout's CHANGELOG.md — read it before deciding. `) +
|
|
1224
1247
|
`Update (/reload, then re-run flow release on the current build) or proceed with the old release?`;
|
|
1225
|
-
staleNote = `released under dev-flow ${behind} (
|
|
1248
|
+
staleNote = `released under dev-flow ${behind} (${selfBuild.label} ${selfBuild.version ?? "?"}) by operator choice — proofs newer than ${behind} did not run`;
|
|
1226
1249
|
}
|
|
1227
1250
|
const audit = flag("confirmed") ? " (confirmed by operator instruction)" : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
1228
1251
|
if (!flag("confirmed") && !state!.yolo) {
|
|
@@ -1244,7 +1267,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1244
1267
|
// the version of record is fixed here, from the manifest this gate validated: release-done must not
|
|
1245
1268
|
// re-read a checkout that may still be behind (#52)
|
|
1246
1269
|
if (!state!.noVersion && manifestVer) state!.releaseVersion = manifestVer;
|
|
1247
|
-
if (stale) state!.staleBuild = `${behind} (
|
|
1270
|
+
if (stale) state!.staleBuild = `${behind} (${selfBuild.label} ${selfBuild.version ?? "?"})`;
|
|
1248
1271
|
writeState(root, state!);
|
|
1249
1272
|
return { text: `release approved${audit}${state!.noVersion ? " — unversioned: no bump or tag; your changelog entry rides under Unreleased until the next versioned release folds it" : ""} — entering release stage.${manifestVer ? ` Version ${manifestVer}.` : ""}${foldNote}${staleNote ? ` ${staleNote}.` : ""}\n${nextHint(state!, cfg)}` };
|
|
1250
1273
|
}
|
|
@@ -1357,7 +1380,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1357
1380
|
ghNote = gr.ok ? `${forge} release ${tag} created. ${notesNote}`.trim() : `${forge} release skipped: ${tail(gr.out)}`;
|
|
1358
1381
|
}
|
|
1359
1382
|
}
|
|
1360
|
-
const behind = sessionRunsOlderBuild(loadedVersion(),
|
|
1383
|
+
const behind = sessionRunsOlderBuild(loadedVersion(), checkoutBuild(root).version);
|
|
1361
1384
|
const openRelease = checklistPending(cfg, state!, "release");
|
|
1362
1385
|
// release-stage items have no gate of their own: the operator's Finish? answer is what closes them, so
|
|
1363
1386
|
// name them at the last objective gate — on the way out too, or the refusal hides half the story
|
|
@@ -1394,7 +1417,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1394
1417
|
state!.staleBuild
|
|
1395
1418
|
? `stale build acknowledged at release gate: this session ran dev-flow ${state!.staleBuild} — proofs newer than it did not run.`
|
|
1396
1419
|
: behind
|
|
1397
|
-
? `warning: this session runs dev-flow ${behind}, not the build
|
|
1420
|
+
? `warning: this session runs dev-flow ${behind}, not the build the disk ships — /reload before trusting what it printed.`
|
|
1398
1421
|
: "",
|
|
1399
1422
|
mergeNote,
|
|
1400
1423
|
openNote,
|
|
@@ -1594,12 +1617,16 @@ function tail(out: string, n = 15): string {
|
|
|
1594
1617
|
// ------------------------------------------------------------------ extension
|
|
1595
1618
|
|
|
1596
1619
|
/** Compact footer: bound flow = stage glyph, slug, mode markers, ⚠️ on its failing checks; unbound = the
|
|
1597
|
-
*
|
|
1620
|
+
* unfinished-flow count, or `⧖ no flows` — an initiated repo always carries the footer. An uninitiated
|
|
1621
|
+
* folder gets nothing: the status is cleared. Pure read — rendering never binds or claims anything. */
|
|
1598
1622
|
function refreshStatus(ctx: ExtensionContext): void {
|
|
1599
1623
|
if (!ctx.hasUI) return;
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1624
|
+
if (!initiated(ctx.cwd)) {
|
|
1625
|
+
ctx.ui.setStatus("dev-flow", undefined);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
const s = statusFor(boundFeature(ctx.cwd, sessionKey(ctx)), unfinishedStates(ctx.cwd).length);
|
|
1629
|
+
ctx.ui.setStatus("dev-flow", s.text);
|
|
1603
1630
|
}
|
|
1604
1631
|
|
|
1605
1632
|
|
|
@@ -1739,7 +1766,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1739
1766
|
// reaches the provider). If our summary fails we return undefined and pi's own compaction proceeds.
|
|
1740
1767
|
// overflow is never taken over (cancelling it would drop pi's compact-and-retry); manual is the operator's or ours.
|
|
1741
1768
|
pi.on("session_before_compact", async (event, ctx) => {
|
|
1742
|
-
if (!
|
|
1769
|
+
if (!initiated(ctx.cwd)) return undefined;
|
|
1743
1770
|
const key = sessionKey(ctx);
|
|
1744
1771
|
const st = boundFeature(ctx.cwd, key);
|
|
1745
1772
|
if (!shouldTakeOverCompaction({ reason: event.reason, bound: !!st, inFlight: compacting.has(key) })) return undefined;
|
|
@@ -1762,7 +1789,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1762
1789
|
});
|
|
1763
1790
|
// pi forcing its own compaction while a flow is bound means the pacing was wrong — park a note for the operator.
|
|
1764
1791
|
pi.on("session_compact", async (event, ctx) => {
|
|
1765
|
-
if (!
|
|
1792
|
+
if (!initiated(ctx.cwd)) return;
|
|
1766
1793
|
// Whatever the reason, the summary replaced the transcript — the core the first run injected is
|
|
1767
1794
|
// gone from context, so the next run pays it once more (manual compactions included: our own
|
|
1768
1795
|
// safe-point compaction is the common one).
|
|
@@ -1786,14 +1813,12 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1786
1813
|
const shellInput = isToolCallEventType("bash", event) || isToolCallEventType("powershell", event) ? (event.input as { command?: unknown; timeout?: unknown }) : undefined;
|
|
1787
1814
|
const shellCmd = shellInput ? String(shellInput.command ?? "") : "";
|
|
1788
1815
|
const explicitTimeout = typeof shellInput?.timeout === "number" ? shellInput.timeout : undefined;
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
if (why) return { block: true, reason: why };
|
|
1796
|
-
}
|
|
1816
|
+
const noDf = !initiated(ctx.cwd);
|
|
1817
|
+
// in an initiated repo the silent default stays armed either way: it is the safety net for an
|
|
1818
|
+
// `inject` project and the number the refusal quotes; an uninitiated folder is not touched at all
|
|
1819
|
+
if (shellCmd && shellInput && !noDf) shellInput.timeout = bashTimeout(shellCmd, explicitTimeout);
|
|
1820
|
+
// an uninitiated folder hears nothing from dev-flow at all — flow init is the opt-in that arms
|
|
1821
|
+
// the guards, the no-playbook bash-timeout default included
|
|
1797
1822
|
if (noDf) return undefined;
|
|
1798
1823
|
const cfg = loadProject(dfDir(ctx.cwd)).cfg;
|
|
1799
1824
|
const mustStateTimeout = shellCmd !== "" && explicitTimeout === undefined && cfg.bashTimeout === "require";
|
|
@@ -1813,7 +1838,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1813
1838
|
const why = await askOperator(ctx, `Editing ${path.relative(ctx.cwd, abs) || abs}`, pv.confirm);
|
|
1814
1839
|
if (why) return { block: true, reason: why };
|
|
1815
1840
|
}
|
|
1816
|
-
const reason = writeGuard({ abs, dfDir: dfDir(ctx.cwd), features: feats, boundSlug: bound?.slug ?? null });
|
|
1841
|
+
const reason = writeGuard({ abs, dfDir: dfDir(ctx.cwd), features: feats, boundSlug: bound?.slug ?? null, repoRoot: ctx.cwd });
|
|
1817
1842
|
if (reason) return { block: true, reason };
|
|
1818
1843
|
// Editing a worktree invalidates that feature's tier-1 checks and tier-2 confirmation until they rerun.
|
|
1819
1844
|
const owner = feats.find((f) => f.worktreeAbs && abs.startsWith(f.worktreeAbs + path.sep));
|
|
@@ -1918,7 +1943,10 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1918
1943
|
const run = ctx as unknown as Record<symbol, boolean | undefined>;
|
|
1919
1944
|
if (run[CONTEXT_EMITTED]) return undefined;
|
|
1920
1945
|
run[CONTEXT_EMITTED] = true;
|
|
1921
|
-
|
|
1946
|
+
// repaint the footer at the start of every run: the session_start push can land before a web
|
|
1947
|
+
// client attaches, and this is the earliest point the client is certainly listening
|
|
1948
|
+
refreshStatus(ctx);
|
|
1949
|
+
if (!initiated(ctx.cwd)) return undefined;
|
|
1922
1950
|
const key = sessionKey(ctx);
|
|
1923
1951
|
// The playbook core rides along on the message this run writes anyway — once per session.
|
|
1924
1952
|
const core = corePreamble(key);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.0",
|
|
4
4
|
"description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
package/skills/dev-flow/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: dev-flow
|
|
|
3
3
|
description: >
|
|
4
4
|
The repo's enforced feature workflow: plan → implement → pre-release →
|
|
5
5
|
release → done, one feature at a time, driven through the flow tool. Read before
|
|
6
|
-
starting ANY feature work in a repo
|
|
6
|
+
starting ANY feature work in a repo whose .dev-flow/project.md playbook exists — the
|
|
7
7
|
stage guards block out-of-stage edits and main-branch git ops, so working
|
|
8
8
|
outside this flow fails at the guard.
|
|
9
9
|
---
|
package/src/core.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { existsSync, readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
|
+
import os from "node:os";
|
|
9
10
|
import path from "node:path";
|
|
10
11
|
|
|
11
12
|
export type Stage = "plan" | "implement" | "pre-release" | "release" | "done";
|
|
@@ -1176,6 +1177,23 @@ export interface FeatureRef {
|
|
|
1176
1177
|
|
|
1177
1178
|
const within = (abs: string, dir: string | null) => !!dir && (abs === dir || abs.startsWith(dir + path.sep));
|
|
1178
1179
|
|
|
1180
|
+
/**
|
|
1181
|
+
* A throwaway outside the repository, which is not a repo write at all: a mechanical multi-file rewrite
|
|
1182
|
+
* needs somewhere to keep a scratch script, and refusing `/tmp/split_skill.py` only taught agents to park
|
|
1183
|
+
* junk inside the checkout. Both sides are realpath'd, so a symlink in the temp dir cannot reach back into
|
|
1184
|
+
* the guarded checkout, and `repoRoot` keeps a repository that merely lives under the temp dir (every
|
|
1185
|
+
* smoke-test repo) under the normal stage rules.
|
|
1186
|
+
*/
|
|
1187
|
+
export function inScratchDir(abs: string, repoRoot?: string | null): boolean {
|
|
1188
|
+
const real = realAbs(abs);
|
|
1189
|
+
if (repoRoot) {
|
|
1190
|
+
const root = realAbs(path.resolve(repoRoot));
|
|
1191
|
+
if (real === root || real.startsWith(root + path.sep)) return false;
|
|
1192
|
+
}
|
|
1193
|
+
const tmp = realAbs(path.resolve(os.tmpdir()));
|
|
1194
|
+
return real === tmp || real.startsWith(tmp + path.sep);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1179
1197
|
/**
|
|
1180
1198
|
* Write guard with per-path attribution: writes inside a worktree are judged by that
|
|
1181
1199
|
* worktree's own feature; main-checkout writes are judged by the session's bound feature
|
|
@@ -1184,7 +1202,7 @@ const within = (abs: string, dir: string | null) => !!dir && (abs === dir || abs
|
|
|
1184
1202
|
* touch the checkout at all — a bound feature is the only way in.
|
|
1185
1203
|
* Returns a reason or null (allowed).
|
|
1186
1204
|
*/
|
|
1187
|
-
export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef[]; boundSlug: string | null }): string | null {
|
|
1205
|
+
export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef[]; boundSlug: string | null; repoRoot?: string | null }): string | null {
|
|
1188
1206
|
if (o.abs === path.join(o.dfDir, "project.json")) return ".dev-flow/project.json is legacy — it is no longer read; fold its values into project.md and delete it";
|
|
1189
1207
|
if (o.abs === path.join(o.dfDir, "project.md")) return "project.md is the operator playbook — change it with flow init --write (setup) or inside a docs/patch flow's worktree";
|
|
1190
1208
|
if (o.abs.endsWith("state.json") && o.abs.includes(o.dfDir + path.sep)) return "state.json is dev-flow-owned — advance stages with the flow tool only";
|
|
@@ -1199,6 +1217,10 @@ export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef
|
|
|
1199
1217
|
return `project.md changes belong to a docs or patch flow — ${owner.state.slug} is a normal feature (flow start <slug> --docs --confirmed)`;
|
|
1200
1218
|
return null; // implement/pre-release/release: own worktree is the working area
|
|
1201
1219
|
}
|
|
1220
|
+
// Scratch outside the checkout is not a repo write: every stage (and an unbound session) may use it. It
|
|
1221
|
+
// sits after the dev-flow-owned refusals and after owner attribution, so no path shape — a symlink, or a
|
|
1222
|
+
// worktreeDir an operator parked in the temp dir — reaches those rules through the temp dir.
|
|
1223
|
+
if (inScratchDir(o.abs, o.repoRoot)) return null;
|
|
1202
1224
|
const bound = o.boundSlug ? o.features.find((f) => f.state.slug === o.boundSlug) : undefined;
|
|
1203
1225
|
// A plan-stage session may only write its own feature directory: otherwise one session edits another
|
|
1204
1226
|
// feature's plan and that feature's approval gate then rubber-stamps text it never wrote.
|
|
@@ -1207,7 +1229,7 @@ export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef
|
|
|
1207
1229
|
if (within(o.abs, o.dfDir)) return null;
|
|
1208
1230
|
if (bound) {
|
|
1209
1231
|
if (bound.state.stage === "implement" || bound.state.stage === "pre-release")
|
|
1210
|
-
return `bound feature ${o.boundSlug} is at ${bound.state.stage} — edit its worktree (${bound.state.worktree}), not the main checkout`;
|
|
1232
|
+
return `bound feature ${o.boundSlug} is at ${bound.state.stage} — edit its worktree (${bound.state.worktree}), not the main checkout; a throwaway script goes outside the repo (under $TMPDIR)`;
|
|
1211
1233
|
return null; // release: release chores may touch the main checkout
|
|
1212
1234
|
}
|
|
1213
1235
|
if (!o.features.length) return "no active flow — every request goes through flow: flow start <slug> for new work, flow use <slug> for an unfinished feature";
|
|
@@ -1255,15 +1277,16 @@ export function statusCompact(state: FlowState): { text: string; failed: boolean
|
|
|
1255
1277
|
return { text: `${STAGE_EMOJI[state.stage]} ${state.slug}${state.patch ? " ⚡" : state.docs ? " 📚" : ""}${state.yolo ? " 🎱" : ""}`, failed };
|
|
1256
1278
|
}
|
|
1257
1279
|
|
|
1258
|
-
/** Footer decision for any session: a bound feature renders as statusCompact, its ⚠️
|
|
1259
|
-
* checks only; an unbound session shows the count of unfinished features — never a
|
|
1260
|
-
* session is never shown (or made to feel bound to) a feature it did not take with flow
|
|
1261
|
-
|
|
1280
|
+
/** Footer decision for any session in an initiated repo: a bound feature renders as statusCompact, its ⚠️
|
|
1281
|
+
* from its own failing checks only; an unbound session shows the count of unfinished features — never a
|
|
1282
|
+
* slug, so a fresh session is never shown (or made to feel bound to) a feature it did not take with flow
|
|
1283
|
+
* use — and `⧖ no flows` when nothing is in flight: dev-flow initiated means a footer always present. */
|
|
1284
|
+
export function statusFor(bound: FlowState | null, openCount: number): { text: string } {
|
|
1262
1285
|
if (bound && bound.stage !== "done") {
|
|
1263
1286
|
const { text, failed } = statusCompact(bound);
|
|
1264
1287
|
return { text: failed ? `${text} ⚠️` : text };
|
|
1265
1288
|
}
|
|
1266
|
-
if (openCount < 1) return
|
|
1289
|
+
if (openCount < 1) return { text: "⧖ no flows" };
|
|
1267
1290
|
return { text: `⧖ ${openCount} flow${openCount === 1 ? "" : "s"} open` };
|
|
1268
1291
|
}
|
|
1269
1292
|
|