pi-dev-flow 0.64.4 → 0.64.5
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 +12 -0
- package/docs/guardrails.md +1 -1
- package/docs/playbook.md +3 -2
- package/extensions/dev-flow.ts +67 -14
- package/package.json +1 -1
- package/skills/dev-flow/references/release.md +4 -2
- package/src/core.ts +102 -11
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.64.5] - 2026-10-25
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **A heredoc body is an argument's prose, not a command.** `bashSegments` splits on newlines outside quotes, so every line of `git commit -F - <<'MSG' … MSG` was judged as its own command: a commit message whose line began with `flow status` was refused with *there is no "flow" shell command*, and one that named `.dev-flow/<slug>/state.json` tripped the state-tamper block. `stripHeredocBodies` now blanks heredoc bodies (line count kept, so segment order survives) before the split, which every guard inherits — flow invocation, state/playbook tamper, project deny rules, git parsing, merge style and force-push detection. A head that executes its argument (`sh`, `node`, `python`…) is never masked: a heredoc fed to an interpreter really runs, and prose-is-argument is a rule about data, not a licence to unsee code. Unterminated bodies are left judged — masking less is the safe direction.
|
|
12
|
+
- **`.dev-flow/` is no longer a free write area for an unbound session.** The write guard allowed anything under `.dev-flow/`, and the folder gitignores everything, so an unbound session could park arbitrary files there (`.dev-flow/COMMUNICATION-PLAN.md` was one) — a folder whose whole purpose is flow state doubled as untracked scratch space. Only the two advisory files the agent owns (`reflections.md`, `roadmap.md`) stay writable with no binding; anything else in the folder is refused, and the refusal names the writable pair. A bound session keeps the folder exactly as it had it — the flow-owned paths inside it were, and stay, refused by their own rules.
|
|
13
|
+
- **`gh pr merge --merge main` merges nothing, so every hint now spells `gh pr merge <n> --merge`.** A positional after the style flag is read by gh as the PR selector ("no pull requests found for main"), which turned the form the release reference and the release-stage hint showed into a silent no-op at the one step of the release. The skill's release reference, the merge-policy section of `docs/playbook.md` and `nextHint` all put the number first and say why the order matters.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **💬 in the footer while the operator's word is outstanding.** The legend already said 💬 means "operator, your turn" (stage lines open with it); the footer never did, so a flow parked on an unanswered checkpoint looked exactly like one with nothing pending. A gate that tells the agent to go ask now records the word it wants (`FlowState.pendingAsk`), the footer renders `🔨 slug 💬`, and `flow status` prints `💬 Approve?` — set for a chat question or an interactive dialog alike, cleared when the word arrives or the answer comes back no, and dropped when another session takes the feature over (the question belonged to whoever asked it). An unbound session shows the same pre-flow glyph: `💬 no flows`, `💬 N flow(s) open` — an unbound session is parked on the operator by definition, so `⧖` leaves the legend. Presentation only: no gate, guard or verdict reads the field.
|
|
18
|
+
|
|
7
19
|
## [0.64.4] - 2026-10-25
|
|
8
20
|
|
|
9
21
|
### Added
|
package/docs/guardrails.md
CHANGED
|
@@ -15,7 +15,7 @@ While a feature is active, the extension intercepts every tool call:
|
|
|
15
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`), `/flow-audit` (the whole repo) and `/flow-simplify` (the operative cut: deletes dead and duplicated code, one verified commit at a time) — and injects a built-in senior-discipline guidance at implement stage unless the playbook sets its own `prose.implement`.
|
|
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
|
|
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, `💬` while a checkpoint (Approve?/Verified?/Release?/Finish?) still waits on the operator's word — the legend's "operator, your turn" glyph, the same one stage lines open with — 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: the pre-flow glyph, because an unbound session is parked on the operator by definition; 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]`), the `💬 <word>` marker of a checkpoint the operator has not answered, and the `flow=<ver>` stamp of the build that started the feature.
|
|
19
19
|
|
|
20
20
|
## Limitations (deliberate, v1)
|
|
21
21
|
|
package/docs/playbook.md
CHANGED
|
@@ -132,10 +132,11 @@ needs to know which one the release contains. Three things read the key:
|
|
|
132
132
|
in chat, re-runs with `--merge=<style> --confirmed`, and the answer is inserted as a single line under
|
|
133
133
|
`## release` (validated before the write, `.bak` kept, committed as a playbook chore when the playbook is
|
|
134
134
|
the only dirty path). `any` is the explicit opt-out: no policy, no asking.
|
|
135
|
-
- **the guard enforces it where the decision is made** — `gh pr merge --squash` against `merge = merge` is
|
|
135
|
+
- **the guard enforces it where the decision is made** — `gh pr merge <n> --squash` against `merge = merge` is
|
|
136
136
|
blocked outright, and a merge that carries no style flag (so the forge default decides) needs your
|
|
137
137
|
confirmation; a local `git merge --squash` only ever confirms, because merging main into a branch is
|
|
138
|
-
ordinary work.
|
|
138
|
+
ordinary work. Spell the PR number **before** the flag: `gh pr merge --merge main` reads `main` as the
|
|
139
|
+
PR selector ("no pull requests found for main") and never merges anything.
|
|
139
140
|
- **`release-done` proves what actually landed** matched the policy (branch ancestry plus what the forge
|
|
140
141
|
reports), and `flow finish` says whether commits missing from the default branch are expected (squash,
|
|
141
142
|
rebase) or a violation (merge — where `yolo` does not answer for you). A shape dev-flow cannot see —
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -832,6 +832,20 @@ async function runFlow(args: string[], root: string, ui: Ui, sess: Session): Pro
|
|
|
832
832
|
return { text: `unknown subcommand "${sub}" — ${GATE_HELP}`, isError: true };
|
|
833
833
|
}
|
|
834
834
|
}
|
|
835
|
+
/** Records the checkpoint word a gate asked for and has not been given: the footer shows 💬 (“operator,
|
|
836
|
+
* your turn”, the legend in docs/playbook.md) while a session is parked on an answer. Presentation only —
|
|
837
|
+
* no verdict reads it — and the same gate clears it when the word arrives (or when the answer is no and the
|
|
838
|
+
* turn returns to the agent). */
|
|
839
|
+
function markPendingAsk(root: string, state: FlowState, word: string): void {
|
|
840
|
+
state.pendingAsk = word;
|
|
841
|
+
writeState(root, state);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/** The pending checkpoint is answered either way — the 💬 leaves the footer with it. */
|
|
845
|
+
function clearPendingAsk(state: FlowState): void {
|
|
846
|
+
delete state.pendingAsk;
|
|
847
|
+
}
|
|
848
|
+
|
|
835
849
|
async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
836
850
|
const { root, ui, sess, cfg, flag, slugArg, takeYoloWord } = o;
|
|
837
851
|
const { state, err } = needState(root, sess, slugArg);
|
|
@@ -898,17 +912,26 @@ async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
898
912
|
const yoloWord = takeYoloWord(state!);
|
|
899
913
|
if (yoloWord) return { text: yoloWord, isError: true };
|
|
900
914
|
const audit = flag("confirmed") ? " (confirmed by operator instruction)" : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
901
|
-
|
|
915
|
+
const askPending = !flag("confirmed") && !state!.yolo;
|
|
916
|
+
if (askPending) {
|
|
917
|
+
markPendingAsk(root, state!, "Verified?"); // pending however it is asked — a chat question or a dialog
|
|
902
918
|
// these commands already ran — say so even on the way out
|
|
903
|
-
if (!ui.hasUI)
|
|
919
|
+
if (!ui.hasUI) {
|
|
920
|
+
return { text: `${needsOperator("verification needs the operator: confirm interactively, or re-run with --confirmed once the operator answered in chat.", "Verified?")}\n${ran}`, isError: true };
|
|
921
|
+
}
|
|
904
922
|
const ok = await ui.confirm("Operator verification", `Verified? All checks green${cfg.commands.dev && !state!.docs ? `; dev deploy is up for review (${cfg.commands.dev})` : ""} \u2014 does it work?`);
|
|
905
|
-
if (!ok)
|
|
923
|
+
if (!ok) {
|
|
924
|
+
clearPendingAsk(state!);
|
|
925
|
+
writeState(root, state!);
|
|
926
|
+
return { text: "verification declined — stay in implement and fix what failed" };
|
|
927
|
+
}
|
|
906
928
|
}
|
|
907
929
|
state!.confirmations = { ...state!.confirmations, implement: { hash: checklistHash(items), at: now() } };
|
|
908
930
|
const final = verifyGate(state!, cfg, branch);
|
|
909
931
|
if (final.length) return { text: `verify gate FAILED:\n- ${final.join("\n- ")}`, isError: true };
|
|
910
932
|
state!.approvals.verify = now();
|
|
911
933
|
state!.stage = "pre-release";
|
|
934
|
+
clearPendingAsk(state!);
|
|
912
935
|
writeState(root, state!);
|
|
913
936
|
return { text: `verified${audit} — entering pre-release stage.\n${ran}\n${nextHint(state!, cfg)}` };
|
|
914
937
|
}
|
|
@@ -992,10 +1015,18 @@ async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
992
1015
|
staleNote = `released under dev-flow ${behind} (${selfBuild.label} ${selfBuild.version ?? "?"}) by operator choice — proofs newer than ${behind} did not run`;
|
|
993
1016
|
}
|
|
994
1017
|
const audit = flag("confirmed") ? " (confirmed by operator instruction)" : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
995
|
-
|
|
996
|
-
|
|
1018
|
+
const askPending = !flag("confirmed") && !state!.yolo;
|
|
1019
|
+
if (askPending) {
|
|
1020
|
+
markPendingAsk(root, state!, "Release?");
|
|
1021
|
+
if (!ui.hasUI) {
|
|
1022
|
+
return { text: needsOperator(`release confirmation needs the operator: confirm interactively, or re-run with --confirmed once the operator answered 'Release?' in chat${stale ? ` — the operator must also answer the stale-build question: ${staleAsk}` : ""}`, "Release?"), isError: true };
|
|
1023
|
+
}
|
|
997
1024
|
const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${state!.noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${state!.noVersion ? "" : ", tag"} — release-done afterwards needs no further answer.${staleAsk ? `\n\n${staleAsk}` : ""}`);
|
|
998
|
-
if (!ok)
|
|
1025
|
+
if (!ok) {
|
|
1026
|
+
clearPendingAsk(state!);
|
|
1027
|
+
writeState(root, state!);
|
|
1028
|
+
return { text: "release declined — keep preparing in pre-release" };
|
|
1029
|
+
}
|
|
999
1030
|
}
|
|
1000
1031
|
state!.confirmations = { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } };
|
|
1001
1032
|
state!.approvals["pre-release"] = now();
|
|
@@ -1012,6 +1043,7 @@ async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
1012
1043
|
// re-read a checkout that may still be behind (#52)
|
|
1013
1044
|
if (!state!.noVersion && manifestVer) state!.releaseVersion = manifestVer;
|
|
1014
1045
|
if (stale) state!.staleBuild = `${behind} (${selfBuild.label} ${selfBuild.version ?? "?"})`;
|
|
1046
|
+
clearPendingAsk(state!);
|
|
1015
1047
|
writeState(root, state!);
|
|
1016
1048
|
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)}` };
|
|
1017
1049
|
}
|
|
@@ -1229,8 +1261,10 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
1229
1261
|
: ` ${assess.unmerged.length} commit(s) in ${state!.worktree} are not on ${cfg.defaultBranch} (squash merge?)`;
|
|
1230
1262
|
// under a merge-commit policy this is a violation, not a routine cleanup note: yolo does not
|
|
1231
1263
|
// answer it, only the operator does
|
|
1232
|
-
if (policy === "merge" && measurable && !flag("confirmed"))
|
|
1264
|
+
if (policy === "merge" && measurable && !flag("confirmed")) {
|
|
1265
|
+
markPendingAsk(root, state!, "Merge policy violation?");
|
|
1233
1266
|
return { text: needsOperator(`the playbook says merge = merge, but ${assess.unmerged.length} commit(s) of ${state!.slug} are not on ${cfg.defaultBranch} — the PR landed as a squash or a rebase. Ask the operator how to proceed, then re-run with --confirmed`, "Merge policy violation?"), isError: true };
|
|
1267
|
+
}
|
|
1234
1268
|
}
|
|
1235
1269
|
}
|
|
1236
1270
|
// a forge release that failed at release-done is still the operator's call — but they must see it before the state vanishes (#63)
|
|
@@ -1239,10 +1273,18 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
1239
1273
|
// yolo works uniformly at every gate: at Finish? nothing later remains to pre-confirm, the flag just answers this one
|
|
1240
1274
|
const yoloWord = takeYoloWord(state!);
|
|
1241
1275
|
if (yoloWord) return { text: yoloWord, isError: true };
|
|
1242
|
-
|
|
1243
|
-
|
|
1276
|
+
const askPending = !flag("confirmed") && !state!.yolo;
|
|
1277
|
+
if (askPending) {
|
|
1278
|
+
markPendingAsk(root, state!, "Finish?");
|
|
1279
|
+
if (!ui.hasUI) {
|
|
1280
|
+
return { text: needsOperator(`finish needs the operator: ask them Finish? in chat, then re-run with --confirmed (or run /flow finish interactively)${forgeSkipNote}`, "Finish?"), isError: true };
|
|
1281
|
+
}
|
|
1244
1282
|
const ok = await ui.confirm("Finish feature", `Finish ${state!.slug}?${unmergedNote}${forgeSkipNote} Removes worktree, branch ${state!.branch || "-"} and .dev-flow/${state!.slug}/.`);
|
|
1245
|
-
if (!ok)
|
|
1283
|
+
if (!ok) {
|
|
1284
|
+
clearPendingAsk(state!);
|
|
1285
|
+
writeState(root, state!);
|
|
1286
|
+
return { text: "finish declined" };
|
|
1287
|
+
}
|
|
1246
1288
|
}
|
|
1247
1289
|
if (wt && existsSync(wt)) {
|
|
1248
1290
|
const rm = await sh(`git worktree remove ${sq(wt)} && git branch -D ${sq(state!.branch)}`, root);
|
|
@@ -1504,8 +1546,12 @@ async function gateApprove(o: GateCtx): Promise<RunResult> {
|
|
|
1504
1546
|
const planItems = applicableItems(cfg, state!, "plan");
|
|
1505
1547
|
if (flag("yolo")) state!.yolo = true; // operator's word at Approve? — every later gate question is pre-confirmed; checks and guardrails stay
|
|
1506
1548
|
const audit = flag("confirmed") ? " (confirmed by operator instruction)" : "";
|
|
1507
|
-
|
|
1508
|
-
|
|
1549
|
+
const askPending = !flag("confirmed");
|
|
1550
|
+
if (askPending) {
|
|
1551
|
+
markPendingAsk(root, state!, "Approve?");
|
|
1552
|
+
if (!ui.hasUI) {
|
|
1553
|
+
return { text: needsOperator("plan approval needs the operator: approve interactively, or re-run with --confirmed once the operator answered in chat", "Approve?"), isError: true };
|
|
1554
|
+
}
|
|
1509
1555
|
const ok = await ui.confirm("Approve plan", `Approve ${state!.slug}${state!.ui ? " (UI)" : ""}${state!.patch ? " (patch)" : state!.docs ? " (docs)" : ""}? Creates the worktree.${flag("yolo") ? " YOLO: all later gate questions (Verified?/Release?/Finish?) are pre-confirmed — checks and guardrails stay in place." : ""}`);
|
|
1510
1556
|
if (!ok) return { text: "approval declined — keep iterating on the plan" };
|
|
1511
1557
|
}
|
|
@@ -1536,6 +1582,7 @@ async function gateApprove(o: GateCtx): Promise<RunResult> {
|
|
|
1536
1582
|
state!.worktree = wtRel;
|
|
1537
1583
|
state!.stage = "implement";
|
|
1538
1584
|
state!.approvals.plan = now();
|
|
1585
|
+
clearPendingAsk(state!);
|
|
1539
1586
|
writeState(root, state!);
|
|
1540
1587
|
return { text: `plan approved${audit}${state!.yolo ? " — yolo: later gate questions pre-confirmed" : ""}; worktree ${wtRel} on branch ${branch}.${setupNote}\n${nextHint(state!, cfg)}` };
|
|
1541
1588
|
}
|
|
@@ -1565,7 +1612,7 @@ async function gateStatus(o: GateCtx): Promise<RunResult> {
|
|
|
1565
1612
|
const st = readState(root, s);
|
|
1566
1613
|
if (!st) return [];
|
|
1567
1614
|
return [
|
|
1568
|
-
`${s === cur ? "→" : " "} ${s}: stage=${st.stage}${st.ui ? " [ui]" : ""}${st.yolo ? " [yolo]" : ""}${st.noVersion ? " [no-version]" : ""} branch=${st.branch || "-"} worktree=${st.worktree || "-"}${st.flowVersion ? ` flow=${st.flowVersion}` : ""}`,
|
|
1615
|
+
`${s === cur ? "→" : " "} ${s}: stage=${st.stage}${st.ui ? " [ui]" : ""}${st.yolo ? " [yolo]" : ""}${st.noVersion ? " [no-version]" : ""}${st.pendingAsk ? ` 💬 ${st.pendingAsk}` : ""} branch=${st.branch || "-"} worktree=${st.worktree || "-"}${st.flowVersion ? ` flow=${st.flowVersion}` : ""}`,
|
|
1569
1616
|
` approvals: ${Object.keys(st.approvals).join(", ") || "none"} | checks: ${Object.entries(st.checks).map(([k, v]) => `${k}:${v.ok ? "ok" : "FAILED"}`).join(", ") || "none"}${st.confirmations?.implement ? " | checklist: confirmed" : ""}`,
|
|
1570
1617
|
` next: ${nextHint(st, cfg)}`,
|
|
1571
1618
|
];
|
|
@@ -1753,6 +1800,12 @@ async function gateUse(o: GateCtx): Promise<RunResult> {
|
|
|
1753
1800
|
const takeover = claimBlocks(prior, sess.key) ? ` — taken over from live session (pid ${prior!.pid})` : "";
|
|
1754
1801
|
sess.bind(slugArg);
|
|
1755
1802
|
sess.rename(slugArg);
|
|
1803
|
+
// a checkpoint that was still unanswered belongs to whoever asked; a session taking the feature over
|
|
1804
|
+
// must not inherit a 💬 for a question it never posed
|
|
1805
|
+
if (st.pendingAsk) {
|
|
1806
|
+
clearPendingAsk(st);
|
|
1807
|
+
writeState(root, st);
|
|
1808
|
+
}
|
|
1756
1809
|
return { text: `this session is now bound to ${slugArg} (stage ${st.stage})${st.worktree ? ` — work in its worktree: ${st.worktree} (branch ${st.branch})` : ""}; session renamed to ${slugArg}${takeover}` };
|
|
1757
1810
|
}
|
|
1758
1811
|
|
|
@@ -1814,7 +1867,7 @@ function tail(out: string, n = 15): string {
|
|
|
1814
1867
|
// ------------------------------------------------------------------ extension
|
|
1815
1868
|
|
|
1816
1869
|
/** Compact footer: bound flow = stage glyph, slug, mode markers, ⚠️ on its failing checks; unbound = the
|
|
1817
|
-
* unfinished-flow count, or
|
|
1870
|
+
* unfinished-flow count, or `💬 no flows` — an initiated repo always carries the footer. An uninitiated
|
|
1818
1871
|
* folder gets nothing: the status is cleared. Pure read — rendering never binds or claims anything. */
|
|
1819
1872
|
function refreshStatus(ctx: ExtensionContext): void {
|
|
1820
1873
|
if (!ctx.hasUI) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.5",
|
|
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": [
|
|
@@ -9,8 +9,10 @@ here) — this stage publishes; the preparation happened in pre-release. Run in
|
|
|
9
9
|
the worktree unless noted:
|
|
10
10
|
|
|
11
11
|
1. Commit everything, push the feature branch, open the PR, wait for the merge
|
|
12
|
-
(`gh pr merge` or ask the user) — with the **playbook's merge style spelled out**
|
|
13
|
-
(`gh pr merge --squash` under `merge = squash`)
|
|
12
|
+
(`gh pr merge <n> --merge` or ask the user) — with the **playbook's merge style spelled out**
|
|
13
|
+
(`gh pr merge <n> --squash` under `merge = squash`), and **the PR number before the flag**: a bare
|
|
14
|
+
`gh pr merge --merge main` makes gh read `main` as the PR selector ("no pull requests found for
|
|
15
|
+
main"). The guard blocks a style that contradicts the
|
|
14
16
|
playbook and asks the operator about a merge with no style flag, so let the playbook decide rather
|
|
15
17
|
than the forge default. Merge without `--delete-branch`: it fails when
|
|
16
18
|
the default branch is checked out in the main worktree, and `flow finish`
|
package/src/core.ts
CHANGED
|
@@ -46,6 +46,7 @@ export interface FlowState {
|
|
|
46
46
|
releaseVersion?: string; // the manifest version the release gate approved — release-done publishes this, not whatever a checkout says later (#52)
|
|
47
47
|
forgeReleaseSkipped?: string; // a gh/glab release create that failed: release-done says so, finish names it so the missing forge release cannot slip past (#63)
|
|
48
48
|
staleBuild?: string; // release ran under an older dev-flow than the checkout by operator choice ("<loaded> (checkout <disk>)"); release-done repeats the acknowledgement
|
|
49
|
+
pendingAsk?: string; // the checkpoint word a gate asked for and has not been given ("Approve?", "Verified?", …) — presentation only (💬 in the footer), it never gates
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
/** Tier-2 item: operator prose; uiOnly items ("(ui)" in project.md) apply only to --ui features. */
|
|
@@ -865,6 +866,9 @@ const DF_ANYWHERE = /\.dev-flow\b/;
|
|
|
865
866
|
* plan/mockups path), are not "the folder". The leading boundary takes `/` too: an absolute path names
|
|
866
867
|
* the same folder, and absolute paths are the shape the harness hands the agent. */
|
|
867
868
|
const DF_FOLDER = /(?:^|[\s'"/])\.dev-flow(?:\/(?!project\.md$|roadmap\.md$|reflections\.md$|\.gitignore$)[\w.-]+)?(?=$|[\s'"])/;
|
|
869
|
+
/** The advisory files under `.dev-flow/` the agent owns (the reflection queue and the roadmap backlog):
|
|
870
|
+
* writable with no flow bound — they are suggestions, not state — unlike everything else in the folder. */
|
|
871
|
+
export const DF_ADVISORY_FILES = new Set(["reflections.md", "roadmap.md"]);
|
|
868
872
|
// write tools that can overwrite a file. A bare `>` is deliberately absent: the redirect target is
|
|
869
873
|
// checked on its own, and testing for any `>` here refused every segment that merely mentioned an
|
|
870
874
|
// owned path while redirecting elsewhere (`gh pr create … 2>&1`).
|
|
@@ -1042,18 +1046,93 @@ function quotesBalanced(command: string): boolean {
|
|
|
1042
1046
|
return q === null;
|
|
1043
1047
|
}
|
|
1044
1048
|
|
|
1049
|
+
/** A heredoc redirector at the end of a word: `<<EOF`, `<<'EOF'`, `<<-MSG`, `<<- 'SQL'`. `2>file` and `<<<`
|
|
1050
|
+
* are not heredocs; neither is the shift in `$((1<<2))` — the lookbehind refuses a word character or `(` in
|
|
1051
|
+
* front of the second `<`, and a word character or quote in front of the first. */
|
|
1052
|
+
const HEREDOC_OP = /(?<![\w(<])<<(-)?(['"]?)([A-Za-z_][\w]*)\2\s*$/;
|
|
1053
|
+
|
|
1054
|
+
/** Blank the body of every heredoc, keeping the line count. A heredoc body is an argument's prose exactly
|
|
1055
|
+
* like a quoted string — `git commit -F - <<'MSG' … flow approve … MSG` carries no invocation — but the
|
|
1056
|
+
* body lines are unquoted, so the newline split read each of them as its own command and a commit message
|
|
1057
|
+
* that started a line with `flow …` was refused as an invocation. A head that execs its argument is not
|
|
1058
|
+
* masked: a heredoc fed to `sh`/`node`/`python` really executes, and prose-is-argument is a rule about
|
|
1059
|
+
* data, not a licence to unsee code. Unterminated bodies are left alone (fail toward judging more).
|
|
1060
|
+
* shortcut: a heredoc whose redirector sits on a continuation line takes the head of that line, so a
|
|
1061
|
+
* re-exec head written on the line above keeps its body judged — again the safe direction. */
|
|
1062
|
+
export function stripHeredocBodies(command: string): string[] {
|
|
1063
|
+
const lines = command.split("\n");
|
|
1064
|
+
const out = lines.slice();
|
|
1065
|
+
const skip = new Set<number>(); // redirector lines, so a nested opener inside a body is never parsed
|
|
1066
|
+
let i = 0;
|
|
1067
|
+
while (i < lines.length) {
|
|
1068
|
+
const line = lines[i];
|
|
1069
|
+
if (skip.has(i) || line.trim() === "") {
|
|
1070
|
+
i++;
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1073
|
+
const m = line.match(HEREDOC_OP);
|
|
1074
|
+
if (!m || REEXEC_HEADS.has(heredocHead(line))) {
|
|
1075
|
+
i++;
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
const term = m[3];
|
|
1079
|
+
const tab = !!m[1];
|
|
1080
|
+
const stops: number[] = [];
|
|
1081
|
+
let j = i + 1;
|
|
1082
|
+
let terminated = false;
|
|
1083
|
+
while (j < lines.length) {
|
|
1084
|
+
const t = tab ? lines[j].trimStart() : lines[j];
|
|
1085
|
+
if (t === term) {
|
|
1086
|
+
terminated = true;
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
const inner = skip.has(j) ? null : lines[j].match(HEREDOC_OP);
|
|
1090
|
+
if (inner && !REEXEC_HEADS.has(heredocHead(lines[j]))) {
|
|
1091
|
+
// a nested heredoc: its body is data for the data — skip past its terminator unparsed
|
|
1092
|
+
const it = inner[3];
|
|
1093
|
+
let k = j + 1;
|
|
1094
|
+
for (; k < lines.length && lines[k] !== it; k++) skip.add(k);
|
|
1095
|
+
if (k < lines.length) {
|
|
1096
|
+
skip.add(k);
|
|
1097
|
+
j = k + 1;
|
|
1098
|
+
continue;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
stops.push(j);
|
|
1102
|
+
j++;
|
|
1103
|
+
}
|
|
1104
|
+
if (!terminated) {
|
|
1105
|
+
i++;
|
|
1106
|
+
continue; // an unterminated body is left for the guard to judge — masking less is the safe direction
|
|
1107
|
+
}
|
|
1108
|
+
for (const l of stops) out[l] = "";
|
|
1109
|
+
out[i] = line.replace(HEREDOC_OP, " ");
|
|
1110
|
+
skip.add(i);
|
|
1111
|
+
i = j + 1;
|
|
1112
|
+
}
|
|
1113
|
+
return out;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/** The head a heredoc redirector belongs to: the first word of its line, env-prefixes and a `dir/` path
|
|
1117
|
+
* ignored (`/usr/bin/git commit -F - <<'MSG'`), so REEXEC_HEADS reads the verb and not the path. */
|
|
1118
|
+
function heredocHead(line: string): string {
|
|
1119
|
+
return segHead(line.replace(/^(?:\w+=\S*\s+)+/, "")).replace(/\S*\/$/, "");
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1045
1122
|
/** Split on shell separators — but only outside quotes. Text inside quotes is an argument's prose, not a
|
|
1046
1123
|
* command: a gh --body that discusses a commit is one segment, not five. Unbalanced quoting keeps the plain
|
|
1047
1124
|
* split, so a stray quote cannot be used to hide a real command. The same split the git guard uses, so
|
|
1048
|
-
* `cd … &&`, `;`, pipes and `&` each judge on their own.
|
|
1125
|
+
* `cd … &&`, `;`, pipes and `&` each judge on their own. Heredoc bodies are stripped first (see
|
|
1126
|
+
* stripHeredocBodies) — a `git commit -F - <<'MSG'` message is an argument, not five commands. */
|
|
1049
1127
|
export function bashSegments(command: string): string[] {
|
|
1050
|
-
|
|
1128
|
+
const src = stripHeredocBodies(command).join("\n");
|
|
1129
|
+
if (!quotesBalanced(src)) return src.split(/[\n;|&]+/).map((s) => s.trim()).filter(Boolean);
|
|
1051
1130
|
const out: string[] = [];
|
|
1052
1131
|
let cur = "";
|
|
1053
1132
|
let q: string | null = null;
|
|
1054
|
-
for (let i = 0; i <
|
|
1055
|
-
const c =
|
|
1056
|
-
const esc = i > 0 &&
|
|
1133
|
+
for (let i = 0; i < src.length; i++) {
|
|
1134
|
+
const c = src[i];
|
|
1135
|
+
const esc = i > 0 && src[i - 1] === "\\" && q !== "'";
|
|
1057
1136
|
if (!esc && (c === '"' || c === "'")) q = q === null ? c : q === c ? null : q;
|
|
1058
1137
|
if (q === null && /[\n;|&]/.test(c)) {
|
|
1059
1138
|
if (cur.trim()) out.push(cur.trim());
|
|
@@ -1224,7 +1303,15 @@ export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef
|
|
|
1224
1303
|
// feature's plan and that feature's approval gate then rubber-stamps text it never wrote.
|
|
1225
1304
|
if (bound?.state.stage === "plan" && !within(abs, path.join(dfDir, bound.state.slug)))
|
|
1226
1305
|
return `bound feature ${bound.state.slug} is in plan — write only inside its own .dev-flow/${bound.state.slug}/`;
|
|
1227
|
-
if (within(abs, dfDir))
|
|
1306
|
+
if (within(abs, dfDir)) {
|
|
1307
|
+
// `.dev-flow/` is not a free write area: it gitignores everything, so the blanket allow let an unbound
|
|
1308
|
+
// session drop arbitrary files there (.dev-flow/COMMUNICATION-PLAN.md was one) — a folder whose whole
|
|
1309
|
+
// point is flow state must not double as an untracked scratch dir. Only the two advisory files the
|
|
1310
|
+
// agent owns stay writable with no binding; project.md is refused above, state/claim.json too.
|
|
1311
|
+
if (DF_ADVISORY_FILES.has(path.relative(dfDir, abs))) return null;
|
|
1312
|
+
if (!bound) return `.dev-flow/ holds flow state — an unbound session may write only its advisory files there (.dev-flow/reflections.md, .dev-flow/roadmap.md); bind with flow start <slug> or flow use <slug>, and a throwaway script goes outside the repo (under $TMPDIR)`;
|
|
1313
|
+
return null;
|
|
1314
|
+
}
|
|
1228
1315
|
if (bound) {
|
|
1229
1316
|
if (bound.state.stage === "implement" || bound.state.stage === "pre-release")
|
|
1230
1317
|
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)`;
|
|
@@ -1272,20 +1359,24 @@ export const STAGE_EMOJI: Record<Stage, string> = { plan: "📝", implement: "
|
|
|
1272
1359
|
|
|
1273
1360
|
export function statusCompact(state: FlowState): { text: string; failed: boolean } {
|
|
1274
1361
|
const failed = Object.values(state.checks).some((c) => !c.ok);
|
|
1275
|
-
|
|
1362
|
+
// 💬 is the legend's "operator, your turn" (docs/playbook.md stage lines): a bound flow whose checkpoint
|
|
1363
|
+
// is unanswered is parked on the operator, and the footer is the only thing they see.
|
|
1364
|
+
return { text: `${STAGE_EMOJI[state.stage]} ${state.slug}${state.patch ? " ⚡" : state.docs ? " 📚" : ""}${state.yolo ? " 🎱" : ""}${state.pendingAsk ? " 💬" : ""}`, failed };
|
|
1276
1365
|
}
|
|
1277
1366
|
|
|
1278
1367
|
/** Footer decision for any session in an initiated repo: a bound feature renders as statusCompact, its ⚠️
|
|
1279
1368
|
* from its own failing checks only; an unbound session shows the count of unfinished features — never a
|
|
1280
1369
|
* slug, so a fresh session is never shown (or made to feel bound to) a feature it did not take with flow
|
|
1281
|
-
* use — and
|
|
1370
|
+
* use — and `💬 no flows` when nothing is in flight: dev-flow initiated means a footer always present.
|
|
1371
|
+
* 💬 is the legend's "operator, your turn": an unbound session is parked on the operator by definition (an
|
|
1372
|
+
* answer to start, or nothing to do until they say), so the pre-flow glyph is the honest one there too. */
|
|
1282
1373
|
export function statusFor(bound: FlowState | null, openCount: number): { text: string } {
|
|
1283
1374
|
if (bound && bound.stage !== "done") {
|
|
1284
1375
|
const { text, failed } = statusCompact(bound);
|
|
1285
1376
|
return { text: failed ? `${text} ⚠️` : text };
|
|
1286
1377
|
}
|
|
1287
|
-
if (openCount < 1) return { text: "
|
|
1288
|
-
return { text:
|
|
1378
|
+
if (openCount < 1) return { text: "💬 no flows" };
|
|
1379
|
+
return { text: `💬 ${openCount} flow${openCount === 1 ? "" : "s"} open` };
|
|
1289
1380
|
}
|
|
1290
1381
|
|
|
1291
1382
|
/** `- [ ]` checklist items of a markdown document (reflections.md and roadmap.md share the format). */
|
|
@@ -1670,7 +1761,7 @@ export function compactionReflectionLine(slug: string, stage: Stage, reason: str
|
|
|
1670
1761
|
/** The playbook's merge style spelled for a hint: "" when the project has no policy. */
|
|
1671
1762
|
function mergeHintFor(cfg: Config): string {
|
|
1672
1763
|
const m = cfg.release.merge;
|
|
1673
|
-
return m && m !== "any" ? ` (the playbook says merge = ${m} — gh pr merge --${m === "merge" ? "merge" : m})` : "";
|
|
1764
|
+
return m && m !== "any" ? ` (the playbook says merge = ${m} — gh pr merge <n> --${m === "merge" ? "merge" : m}, number before the flag: a trailing one reads as the PR selector)` : "";
|
|
1674
1765
|
}
|
|
1675
1766
|
|
|
1676
1767
|
export function nextHint(state: FlowState, cfg: Config): string {
|