pi-dev-flow 0.55.0 → 0.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +3 -1
- package/docs/gates.md +2 -2
- package/extensions/dev-flow.ts +65 -5
- package/package.json +1 -1
- package/src/core.ts +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.55.1] - 2026-10-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **The guard no longer mistakes an unattributed command for a stage violation.** pi can register dev-flow twice in one process (the documented two-sources hazard — a project pointer beside the installed package), and *every* copy evaluates every guard hook: the copy that never served the flow call judges with an empty in-memory binding, and whenever a second unfinished feature exists — which kills the single-feature auto-bind that used to mask it — `git merge`/`push` to the default branch was refused with *'requires stage release'* while the bound feature sat at release the whole time (it blocked the v0.55.0 release's own chore git, live). The on-disk claim is now a binding: an unfinished feature whose `claim.json` carries this session's key attributes the call regardless of how many features are unfinished, so a second copy judges from disk instead of guessing. When attribution truly fails, the refusal says so — *not attributed to a bound feature (session key, which dev-flow, what to do)* — instead of lying about the stage. `flow version`, `status` and `start` also name every dev-flow copy registered in the process, and the README's two-sources warning says which copy to remove.
|
|
12
|
+
- **`flow finish` fast-forwards a main checkout that trails origin.** Close-out used to probe only `origin/<default>` (tag there, HEAD an ancestor), so a local main left behind by the release — exactly what a guard misattribution produces — passed silently and rotted. Now, once the checkout is clean and proven pushed, `finish` fast-forwards local `<default>` to `origin/<default>` with its own git (never a merge: a diverged or not-checked-out main prints the operator's exact `git pull --ff-only` command instead of touching it).
|
|
13
|
+
|
|
7
14
|
## [0.55.0] - 2026-10-22
|
|
8
15
|
|
|
9
16
|
### Changed
|
package/README.md
CHANGED
|
@@ -52,7 +52,9 @@ pi install ./pi-dev-flow # or a local checkout
|
|
|
52
52
|
Later releases arrive with `pi update --extensions` (an npm install reconciles to the newest version);
|
|
53
53
|
then `/reload` — a running session keeps the code it loaded at startup. Two sources at once (a project
|
|
54
54
|
`git:` pin beside the global `npm:` package) load two copies — pi dedupes extensions by path, not by
|
|
55
|
-
package — so keep the one you actually update from
|
|
55
|
+
package — so keep the one you actually update from: `flow version` lists every dev-flow copy
|
|
56
|
+
registered in the process, and the on-disk session claim keeps the guard of a copy that never served
|
|
57
|
+
a flow call attributing your commands correctly.
|
|
56
58
|
|
|
57
59
|
Then, once per project repo, `/flow init`. It reads the repo (default branch and forge from git,
|
|
58
60
|
package manager, test/build/run conventions, version manifest) and writes **`.dev-flow/project.md`
|
package/docs/gates.md
CHANGED
|
@@ -10,7 +10,7 @@ so it needs no `--confirmed`.
|
|
|
10
10
|
| Gate | Advances | Refuses unless |
|
|
11
11
|
|---|---|---|
|
|
12
12
|
| `start <slug> [--ui] [--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); relaxed modes are operator-granted in chat, anchored by `--confirmed`: `--patch` = chore release, no plan document, every gate unchanged; `--docs` = docs-only, no plan document and no tier-1 checks (worktree and release intact). Start prints the dev-flow build and stamps it into the feature state (`flow status` shows `flow=<ver>`), warns when **this session runs an older build than the checkout** (`--check-upstream` also asks npm for the published one), prints the playbook gaps `flow doctor` would report — and **refuses while the playbook has no `merge` policy**: it names the question (squash / merge / rebase / any), the style its own history suggests, and the re-run `--merge=<style> --confirmed`, which writes the answer into `## release` (single-line insert, validated, `.bak` kept, committed as a playbook chore only when the playbook is the only dirty path) and never asks again |
|
|
13
|
-
| `use <slug>` | — (binds this session to a feature) | slug unfinished |
|
|
13
|
+
| `use <slug>` | — (binds this session to a feature) | slug unfinished — the binding is persisted to disk as a claim (`flow version` lists every dev-flow copy registered in the process, and a copy whose in-memory bindings never saw the bind attributes commands from the claim, so a two-sources setup does not misjudge your git) |
|
|
14
14
|
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/*.md` exists; if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md; **one question** — or `--confirmed` after you answered in chat; **yolo** (your chat answer at **any** checkpoint question) → run that gate with `--yolo --confirmed` (`approve`/`verify`/`release`/`finish`): that question is answered and every later one (Verified?/Release?/Finish?) is pre-confirmed — the agent then runs the remaining gates back to back, honoring guidance attached to the yolo word (e.g. "yolo, create a patch version release") — checks and guardrails stay fully enforced. `commands.setup` runs in the worktree and is retried until it succeeds once (a worktree left behind by a failed setup is set up on the next `approve`, never silently reused); a `--docs` feature runs no project command at all and says `setup skipped (docs mode)` |
|
|
15
15
|
| `test` | records a check | — (runs the `test` command/check, records pass/fail) |
|
|
16
16
|
| `check` | records all tier-1 checks | — (runs every `flow-check`/test/health from project.md `## implement`); a `--docs` feature runs none of them and says `docs mode: project commands skipped` — a docs flow builds nothing, so a fresh checkout must not read as a failed deploy (#96) |
|
|
@@ -18,7 +18,7 @@ so it needs no `--confirmed`.
|
|
|
18
18
|
| `verify [--yolo]` | implement → pre-release | all tier-1 checks green — a check with no passing record is **run by the gate itself** (`checks ran at the gate (test)`) rather than refused and pointed at `flow check`, since entering the stage or editing the worktree is what cleared it, and a failure there prints the run output, **the feature branch holds at least one commit** (verify refuses a branch with nothing committed — the checks describe the working tree, so an uncommitted state has never been recorded — and prints `commits: N ahead of <default>, M uncommitted path(s)` with what it ran; uncommitted paths are reported, never gated), build (if configured) green, `dev` deploy (if configured) runs first so you can review the running app **and the health probe (if configured) re-runs against what it just deployed, retrying every 2s up to `healthWait` seconds** (a failing probe refuses the gate and reports how many attempts it took: the `flow check` PASS predates the deploy, and a service that needs seconds after its container starts is not a broken deploy; with no probe the output says `health: none configured`), tier-2 checklist (ui-only items excluded for non-UI features) confirmed as a set; a `--docs` feature runs none of it (`docs mode: project commands skipped`) and only asks you; **one question** — or `--confirmed`; `--yolo --confirmed` = you answered 'yolo' at Verified? — answers it and pre-confirms the rest |
|
|
19
19
|
| `release [--yolo|--no-version|--no-fold-check]` | pre-release → release | checks re-greened after the prep edits; with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog` the gate **proves the entry mechanically** (#97): a **heading names the version** (prose that mentions it, or a `1.2.0-beta` section when releasing `1.2.0`, is not an entry), **this branch touched the file** (an inherited changelog is not release prep), **every entry that was pending before the release survives inside the new section** — compared on normalized lines, so re-indenting a fold is free while rewording or deleting one is refused by naming the line — and **nothing is left under `Unreleased`**. The pending baseline is the newest tag's changelog (what actually shipped), else the branch's merge base; when neither resolves, the two git-dependent proofs are skipped **with a printed advisory** rather than refusing a legal release for a topology reason, and the content proofs (the heading, its body) always run; tier-2 `## pre-release` checklist confirmed; the manifest version it validates is **stamped as the release's version of record** (`release-done` publishes that, whatever the checkouts say later); **one question** (Release?) — or `--confirmed`; `--no-version` (your call at Release?) ships this flow as **merge + changelog** — the bump/tag requirements and the tag checks at `release-done` are skipped for it, but the branch must still add its **own line under `Unreleased`** (editing an older section releases nothing) and it rides there until the next versioned release folds it (default: versioned); `--no-fold-check` is the operator-granted escape from the line-level fold proofs — one flow, stamped in the gate output, the heading and touched proofs stay; **stale session build** (loaded build behind the checkout): the gate prints both builds, lists what shipped between them (those proofs will not run this release) and folds *update (/reload, then re-run) or proceed with the old release?* into the Release? question — the operator's word, recorded in the release output, **never a block**: publishing under an older gate is a legitimate choice (hotfix, offline reload) |
|
|
20
20
|
| `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only) · creates the forge release from the tag, its body **the `release.changelog` entry for that version** — the changelog is the source of truth, and the tag's annotation stands in only when the changelog has no entry for the version, else nothing (and it says why — a body that is really a shell error is dropped, never shipped) — `gh` for GitHub, `glab` for GitLab) and then **proves the release exists**: it asks the forge (`gh release view <tag>` / `glab release view <tag>`) and refuses when nothing is there, because #51, #60 and #63 were three ways of ending `release recorded as complete` with nothing published — and when the changelog was the body it **reads the stored body back** and refuses a mismatch, so the release page and the changelog cannot drift (#97; normalized before comparing, skipped with a printed note on another forge). Skipping is deliberate and loud — `--no-release-create`, `release.releases = false` or `forge = self` each print that no forge release was created, and the view check is skipped for them; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release); when the release went out on a stale build the operator acknowledged at the release gate, it prints that acknowledgement in place of the after-the-fact version-skew warning |
|
|
21
|
-
| `finish [--yolo] [slug]` | release → done (removes worktree + branch, deletes `.dev-flow/<slug>/`, and deletes `origin/<branch>` **only** when its merged state is verified — ancestor of the default branch or a merged PR/MR via `gh`/`glab`; unverifiable branches stay with a note) | a release is recorded (`release-done` ran), the main checkout is clean **and** pushed to `origin/<default>`, and the worktree has no uncommitted changes; **one question** (Finish? — mentions unmerged-looking commits with the playbook's `merge` policy in mind, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; under `merge = merge`, commits that never reached the default branch are a **policy violation**: `yolo` does not answer it, only your explicit answer does; to abandon an unreleased feature use `abort` |
|
|
21
|
+
| `finish [--yolo] [slug]` | release → done (removes worktree + branch, deletes `.dev-flow/<slug>/`, and deletes `origin/<branch>` **only** when its merged state is verified — ancestor of the default branch or a merged PR/MR via `gh`/`glab`; unverifiable branches stay with a note) | a release is recorded (`release-done` ran), the main checkout is clean **and** pushed to `origin/<default>`, and the worktree has no uncommitted changes; when the clean checkout trails `origin/<default>` the gate **fast-forwards local main** as it closes out (never a merge — anything that cannot fast-forward prints the operator's exact `git pull --ff-only` command); **one question** (Finish? — mentions unmerged-looking commits with the playbook's `merge` policy in mind, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; under `merge = merge`, commits that never reached the default branch are a **policy violation**: `yolo` does not answer it, only your explicit answer does; to abandon an unreleased feature use `abort` |
|
|
22
22
|
| `reflect ["<note>"]` | — | `reflect "<note>"` queues a suggestion in `reflections.md` (never gates; gate flags such as `--confirmed` are ignored, they never become part of the note). Bare `reflect` prints the full **session-reflection protocol** for the agent (from the `/flow reflect` bar it additionally wakes the model, so the protocol executes immediately): review the whole session log, re-check every open item against the current playbook and **newer dev-flow versions** (`npm view pi-dev-flow version` vs the running version — dev-flow ships from npm; recommend `pi install npm:pi-dev-flow` + `/reload`, the operator performs updates), dedupe new findings against the open ones, then report playbook vs plugin items to the operator and ask whether to fix now — plugin items: search upstream issues first (`gh issue list --repo <upstream> --state all --search …`; an author-addressed match is reported back, no match → `gh issue create` with a detailed description and a suggested fix), playbook items: `flow doctor` routes each to the docs flow that implements it |
|
|
23
23
|
| `roadmap [add "<feature>" \| pick <n> <slug> \| done <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one, `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
|
|
24
24
|
| `doctor ["<issue note>"]` | — | read-only findings: playbook drift, dead commands/scripts, untracked playbook, ghost feature dirs, orphan worktrees/branches — **plus a review of every open reflection, each routed to the flow that should fix it** (playbook item → docs flow; plugin item → upstream issue, or a patch/normal flow inside the dev-flow repo). It writes nothing and asks nothing, safe for agents and CI at any stage; the agent investigates, you confirm, the routed flow implements. `doctor "<note>"` prints an investigation brief and a fix route for a fresh observation |
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -122,6 +122,40 @@ function loadedVersion(): string | null {
|
|
|
122
122
|
return process.env.DEV_FLOW_LOADED_VERSION?.trim() || pluginVersion(import.meta.dirname).version;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/** This build's own identity, read once (the guard hot path must not re-walk the fs per call). */
|
|
126
|
+
const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
127
|
+
|
|
128
|
+
/** Cross-copy registry: one process can register dev-flow more than once (the documented
|
|
129
|
+
* two-sources-at-once hazard: a project dogfood pointer plus an installed copy), and EVERY copy
|
|
130
|
+
* evaluates every guard hook. The flow-tool binding belongs to whichever copy served the call,
|
|
131
|
+
* so the other copy judges from a missing binding — claims on disk (see boundFeature) keep its
|
|
132
|
+
* verdict honest, and these entries let `flow version`, `status` and `start` name the duplicate
|
|
133
|
+
* instead of leaving a misattribution a mystery. Same-process only: it is a globalThis list. */
|
|
134
|
+
interface CopyEntry {
|
|
135
|
+
dir: string;
|
|
136
|
+
version: string | null;
|
|
137
|
+
pid: number;
|
|
138
|
+
at: string;
|
|
139
|
+
}
|
|
140
|
+
const COPIES: CopyEntry[] = ((globalThis as { __piDevFlowCopies?: CopyEntry[] }).__piDevFlowCopies ??= []);
|
|
141
|
+
function registerCopy(): void {
|
|
142
|
+
const mine = COPIES.find((r) => r.dir === SELF_BUILD.dir && r.pid === process.pid);
|
|
143
|
+
if (mine) Object.assign(mine, { version: loadedVersion(), at: new Date().toISOString() });
|
|
144
|
+
else COPIES.push({ dir: SELF_BUILD.dir, version: loadedVersion(), pid: process.pid, at: new Date().toISOString() });
|
|
145
|
+
}
|
|
146
|
+
function otherCopies(): CopyEntry[] {
|
|
147
|
+
return COPIES.filter((r) => r.pid === process.pid && r.dir !== SELF_BUILD.dir);
|
|
148
|
+
}
|
|
149
|
+
function copyWarning(): string | null {
|
|
150
|
+
const dup = otherCopies();
|
|
151
|
+
return dup.length
|
|
152
|
+
? `warning: ${dup.length} other dev-flow cop${dup.length === 1 ? "y" : "ies"} registered in this process: ${dup.map((d) => `${d.dir} (${d.version ?? "?"})`).join(", ")} — every copy evaluates the guard hooks, so keep only one source you intend (README: two sources at once)`
|
|
153
|
+
: null;
|
|
154
|
+
}
|
|
155
|
+
/** Test seam: the smoke suite cannot load a second copy of this module, so it plants registry
|
|
156
|
+
* entries and asserts the warnings the real duplicate would print. */
|
|
157
|
+
export const testSeams = { copies: COPIES };
|
|
158
|
+
|
|
125
159
|
interface Ui {
|
|
126
160
|
hasUI: boolean;
|
|
127
161
|
confirm: (title: string, message: string) => Promise<boolean>;
|
|
@@ -247,7 +281,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
247
281
|
}
|
|
248
282
|
|
|
249
283
|
const GATE_HELP =
|
|
250
|
-
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>] | 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 loaded build (--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); 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";
|
|
284
|
+
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>] | 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 loaded build 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); 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";
|
|
251
285
|
const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
252
286
|
const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
253
287
|
const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -321,6 +355,12 @@ function boundFeature(root: string, key: string): FlowState | null {
|
|
|
321
355
|
if (s && s.stage !== "done") return s;
|
|
322
356
|
}
|
|
323
357
|
const un = unfinishedStates(root);
|
|
358
|
+
// the claim is the persisted binding: bind() already stamps the session key into claim.json, so
|
|
359
|
+
// trust the disk after the in-memory map — a second registered dev-flow copy (both copies
|
|
360
|
+
// evaluate the guard hooks) or a re-instantiated module then attributes the session's own
|
|
361
|
+
// feature from disk instead of misjudging with stage null
|
|
362
|
+
const mine = un.find((s) => readClaim(root, s.slug)?.key === key);
|
|
363
|
+
if (mine) return mine;
|
|
324
364
|
if (un.length !== 1) return null;
|
|
325
365
|
const claim = readClaim(root, un[0].slug);
|
|
326
366
|
// shortcut: liveness is pid-only — pid reuse can read "live" and force an explicit flow use; friction only, never a wrong commit.
|
|
@@ -723,6 +763,8 @@ ${mdDigest(draftRefresh)}`))
|
|
|
723
763
|
const self = pluginVersion(import.meta.dirname);
|
|
724
764
|
const behind = sessionRunsOlderBuild(loadedVersion(), self.version);
|
|
725
765
|
if (behind) notes.push(`warning: this session runs dev-flow ${behind}, the checkout has ${self.version} — /reload before trusting what a gate prints`);
|
|
766
|
+
const dupStart = copyWarning();
|
|
767
|
+
if (dupStart) notes.push(dupStart);
|
|
726
768
|
if (flag("check-upstream")) {
|
|
727
769
|
const pub = await sh("npm view pi-dev-flow version", root);
|
|
728
770
|
const newest = pub.ok ? pub.out.trim().split("\n").pop() : "";
|
|
@@ -771,7 +813,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
771
813
|
const { md } = loadProject(df);
|
|
772
814
|
// cheap fs probes only (no git subprocesses) — status is a glance, `flow doctor` is the full list
|
|
773
815
|
const findings = md ? doctorFindings(root, cfg, md) : [];
|
|
774
|
-
const warn = findings.length ? [`⚠ doctor: ${findings.length} finding(s) — run flow doctor`] : [];
|
|
816
|
+
const warn = [...(findings.length ? [`⚠ doctor: ${findings.length} finding(s) — run flow doctor`] : []), ...(copyWarning() ? [copyWarning()!] : [])];
|
|
775
817
|
// the backlog nudge belongs to the no-features answer too — that is when a pick is most useful
|
|
776
818
|
const rmap = roadmapOpenCount(readRoadmap(root));
|
|
777
819
|
const rmapLine = rmap ? [`◇ ${rmap} roadmap item(s) open — flow roadmap`] : [];
|
|
@@ -877,13 +919,14 @@ ${mdDigest(draftRefresh)}`))
|
|
|
877
919
|
const self = pluginVersion(import.meta.dirname);
|
|
878
920
|
const behind = sessionRunsOlderBuild(loadedVersion(), self.version);
|
|
879
921
|
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}`;
|
|
922
|
+
const dupNote = copyWarning();
|
|
880
923
|
// --check-upstream is the one that asks the registry; plain flow version stays offline and instant
|
|
881
924
|
if (flag("check-upstream")) {
|
|
882
925
|
const pub = await sh("npm view pi-dev-flow version", root);
|
|
883
926
|
const newest = pub.ok ? pub.out.trim().split("\n").pop() : "";
|
|
884
927
|
return { text: newest ? `${head} — published: ${newest}${self.version && newest !== self.version ? " (update available)" : ""}` : `${head} — could not read the published version (offline?)` };
|
|
885
928
|
}
|
|
886
|
-
return { text: behind ? `${head} — but this session runs ${behind}; /reload to run ${self.version}` : head };
|
|
929
|
+
return { text: `${behind ? `${head} — but this session runs ${behind}; /reload to run ${self.version}` : head}${dupNote ? `\n${dupNote}` : ""}` };
|
|
887
930
|
}
|
|
888
931
|
|
|
889
932
|
case "approve": {
|
|
@@ -1324,6 +1367,22 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1324
1367
|
const pushed = await sh(`git merge-base --is-ancestor HEAD ${sq(`origin/${cfg.defaultBranch}`)}`, root);
|
|
1325
1368
|
if (!pushed.ok) return { text: `HEAD is not on origin/${cfg.defaultBranch} — push the release (git push origin ${cfg.defaultBranch}) before finish`, isError: true };
|
|
1326
1369
|
}
|
|
1370
|
+
// close-out also syncs the main checkout: a released flow must never leave local
|
|
1371
|
+
// <default> trailing origin — the push check above proved nothing local-only remains, so a
|
|
1372
|
+
// differing sha means local trails and the fast-forward is safe. never a merge: a diverged
|
|
1373
|
+
// or not-checked-out main prints the operator's exact command instead of touching anything
|
|
1374
|
+
let syncNote = "";
|
|
1375
|
+
if (hasOriginF) {
|
|
1376
|
+
const headSha = await sh("git rev-parse HEAD", root);
|
|
1377
|
+
const originSha = await sh(`git rev-parse ${sq(`origin/${cfg.defaultBranch}`)}`, root);
|
|
1378
|
+
if (headSha.ok && originSha.ok && headSha.out.trim() !== originSha.out.trim()) {
|
|
1379
|
+
const onDefault = (await currentBranch(root)) === cfg.defaultBranch;
|
|
1380
|
+
const ff = onDefault ? await sh(`git merge --ff-only ${sq(`origin/${cfg.defaultBranch}`)}`, root) : { ok: false, out: "" };
|
|
1381
|
+
syncNote = ff.ok
|
|
1382
|
+
? ` local ${cfg.defaultBranch} fast-forwarded to origin/${cfg.defaultBranch}.`
|
|
1383
|
+
: ` local ${cfg.defaultBranch} trails origin/${cfg.defaultBranch} and did not fast-forward cleanly — sync by hand: git -C ${sq(root)} pull --ff-only`;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1327
1386
|
// the cleanup part of closing out: drop the worktree and branch the release consumed
|
|
1328
1387
|
const wt = worktreeAbs(root, state!);
|
|
1329
1388
|
let closeNote: string;
|
|
@@ -1413,7 +1472,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1413
1472
|
roadmapNote = ` roadmap: ${r.count} item(s) marked done.`;
|
|
1414
1473
|
}
|
|
1415
1474
|
}
|
|
1416
|
-
return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${roadmapNote}${forgeSkipNote}` };
|
|
1475
|
+
return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${roadmapNote}${forgeSkipNote}${syncNote}` };
|
|
1417
1476
|
}
|
|
1418
1477
|
|
|
1419
1478
|
case "use": {
|
|
@@ -1502,6 +1561,7 @@ async function askOperator(ctx: ExtensionContext, what: string, why: string): Pr
|
|
|
1502
1561
|
}
|
|
1503
1562
|
|
|
1504
1563
|
export default function devFlow(pi: ExtensionAPI) {
|
|
1564
|
+
registerCopy(); // which copy of dev-flow this is — see COPIES
|
|
1505
1565
|
/** Parse "flow <sub> [slug] [--flags]" args shared by command and tool. */
|
|
1506
1566
|
const parse = (input: unknown): string[] => {
|
|
1507
1567
|
if (Array.isArray(input)) return input.map(String);
|
|
@@ -1751,7 +1811,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1751
1811
|
const dirty = await sh(`git -C ${sq(gitDir)} status --porcelain`, ctx.cwd);
|
|
1752
1812
|
playbookChore = dirty.ok && playbookOnlyChange(dirty.out);
|
|
1753
1813
|
}
|
|
1754
|
-
const reason = bashFlowGuard({ command: g.seg, branch, stage: bound?.stage ?? null, defaultBranch: cfg.defaultBranch, pushRefs, playbookChore, dir: gitDir });
|
|
1814
|
+
const reason = bashFlowGuard({ command: g.seg, branch, stage: bound?.stage ?? null, defaultBranch: cfg.defaultBranch, pushRefs, playbookChore, dir: gitDir, attribution: bound ? undefined : `not attributed to a bound feature (session ${key}; dev-flow ${loadedVersion() ?? "?"} at ${SELF_BUILD.dir}) — run flow use <slug> here if a binding is missing` });
|
|
1755
1815
|
if (reason) return { block: true, reason };
|
|
1756
1816
|
// Branch discipline: feature branches live in their worktree — never checked out or created (-b) in the main checkout
|
|
1757
1817
|
const target = checkoutTarget(g.seg);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.1",
|
|
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/src/core.ts
CHANGED
|
@@ -691,6 +691,7 @@ export interface GuardCtx {
|
|
|
691
691
|
pushRefs?: PushRef[]; // caller-resolved push targets (bare names disambiguated tag vs branch); omit = guard parses raw command
|
|
692
692
|
playbookChore?: boolean; // the only change in this checkout is the playbook — tracking it is setup, not feature work (#53)
|
|
693
693
|
dir?: string; // absolute directory this segment runs in; named in the refusal so a wrong verdict is diagnosable
|
|
694
|
+
attribution?: string; // why the call could not be attributed to a bound feature; appended to the stage refusals when stage is null, so a misattribution names itself instead of lying about the stage
|
|
694
695
|
}
|
|
695
696
|
|
|
696
697
|
const unquote = (s: string): string => s.replace(/^(['"])(.*)\1$/, "$2");
|
|
@@ -929,15 +930,19 @@ export function bashFlowGuard(o: GuardCtx): string | null {
|
|
|
929
930
|
// a cd earlier in the command picks the directory this verdict is about — name it, or a misjudged segment
|
|
930
931
|
// reads as "the rule is broken" instead of "the guard looked in the wrong place".
|
|
931
932
|
const judgedIn = o.dir ? ` — judged in ${o.dir}; a cd or git -C earlier in the command picks the directory` : "";
|
|
932
|
-
|
|
933
|
+
// an unattributed refusal must admit it is guessing: "requires stage release" reads as a verdict on
|
|
934
|
+
// the feature when the real finding is "I never found your feature" (a second registered dev-flow
|
|
935
|
+
// copy judging with no bindings of its own — see boundFeature's claim path)
|
|
936
|
+
const attr = o.stage === null && o.attribution ? ` — ${o.attribution}` : "";
|
|
937
|
+
if (git("commit") && onMain && o.stage !== "release" && !playbookCommit) return `direct commits to ${o.defaultBranch} are forbidden — work in the feature worktree (tracking the playbook is legal: git add -f .dev-flow/project.md && DEV_FLOW_ALLOW_MAIN=1 git commit)${judgedIn}${attr}`;
|
|
933
938
|
if (git("push")) {
|
|
934
939
|
// ref-aware: only pushes that WRITE the default branch need stage release — tags and other branches pass.
|
|
935
940
|
// unresolved bare names arrive pre-resolved by the caller (tag vs branch); no parse info → conservative onMain.
|
|
936
941
|
const refs = o.pushRefs ?? parsePushRefs(gitInvocation(c).pushes);
|
|
937
942
|
const writesDefault = refs.some((r) => (r.kind === "branch" && (r.name === o.defaultBranch || r.name === "*")) || (r.kind === "current" && onMain));
|
|
938
|
-
if (writesDefault && o.stage !== "release") return `pushing to ${o.defaultBranch} requires stage "release" (verified feature)`;
|
|
943
|
+
if (writesDefault && o.stage !== "release") return `pushing to ${o.defaultBranch} requires stage "release" (verified feature)${attr}`;
|
|
939
944
|
}
|
|
940
|
-
if (git("merge") && onMain && o.stage !== "release") return `merging into ${o.defaultBranch} requires stage "release"`;
|
|
945
|
+
if (git("merge") && onMain && o.stage !== "release") return `merging into ${o.defaultBranch} requires stage "release"${attr}`;
|
|
941
946
|
return null;
|
|
942
947
|
}
|
|
943
948
|
|