pi-dev-flow 0.80.0 → 0.81.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 +14 -0
- package/docs/gates.md +2 -2
- package/extensions/dev-flow.ts +36 -13
- package/package.json +1 -1
- package/skills/dev-flow/references/implement.md +3 -1
- package/skills/dev-flow/references/plan.md +6 -1
- package/skills/dev-flow/references/start.md +3 -1
- package/src/core.ts +63 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.81.0] - 2026-11-04
|
|
8
|
+
|
|
9
|
+
**Temp-dir fixtures stay outside the repo for git; a UI flag can be added at plan; compaction keeps the real stage.**
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- **Tests that make temp dirs no longer find the enclosing repo under dev-flow.** Since 0.79.0 a bound feature's commands run with `TMPDIR` in `.dev-flow/<slug>/tmp/`, inside the checkout, so git walked up out of a test's `mkdtemp` fixture and answered with the project's repo; a suite asserting "no repository here" failed only under the gates. That dir is now also the commands' `GIT_CEILING_DIRECTORIES` (an inherited list is kept).
|
|
13
|
+
- **The "this session runs an older dev-flow" warning named the versions backwards** in projects that install dev-flow: after an in-place update it said the session ran the new build and the install shipped the old one. The loaded version is now the one read at load, and the shipped one is read fresh.
|
|
14
|
+
- **A flow-aware compaction can no longer carry a stale stage forward.** Its summary ends with a block written from `state.json` (stage, approvals, checks, next) that says it outranks the prose above it; one pre-release summary had still said "implement, next: flow verify".
|
|
15
|
+
- **An implement worker sharing a dirty worktree is told the uncommitted paths are the driver's**: commit only its own paths by name, never `git add -A` / `commit -a`.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- `flow start <slug> --ui --confirmed` on the plan-stage feature this session drives switches the mockup gate on instead of refusing with "already exists". Past plan it refuses, and a plain re-start names `flow use`.
|
|
19
|
+
- The approve gate refuses a mockup that links another feature's worktree (href, src or `@import`); at plan, link the main checkout's stylesheet.
|
|
20
|
+
|
|
7
21
|
## [0.80.0] - 2026-11-03
|
|
8
22
|
|
|
9
23
|
**A reflection that runs out of time still hands back its findings; release-only flows pass verify.**
|
package/docs/gates.md
CHANGED
|
@@ -9,9 +9,9 @@ so it needs no `--confirmed`.
|
|
|
9
9
|
|
|
10
10
|
| Gate | Advances | Refuses unless |
|
|
11
11
|
|---|---|---|
|
|
12
|
-
| `start <slug> [--ui|--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); `--ui` and the relaxed modes are operator-granted in chat, anchored by `--confirmed` (`--ui` = the plan gate demands rendered mockups); `--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 |
|
|
12
|
+
| `start <slug> [--ui|--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); `--ui` and the relaxed modes are operator-granted in chat, anchored by `--confirmed` (`--ui` = the plan gate demands rendered mockups; on an existing feature still at plan, `start <slug> --ui --confirmed` from its bound session switches the flag on instead of refusing); `--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
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
|
-
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/plan.md` exists **by name** (a separate pre-plan/direction file does not open the gate — a preliminary direction belongs inside plan.md); if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md, and the gate opens plan.md to prove it: every image file under `plan/` must appear in an embed (``, case-insensitive) and every `mockups/<screen>.html` must carry an embedded `<screen>-<width>.` shot
|
|
14
|
+
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/plan.md` exists **by name** (a separate pre-plan/direction file does not open the gate — a preliminary direction belongs inside plan.md); if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md, and the gate opens plan.md to prove it: every image file under `plan/` must appear in an embed (``, case-insensitive) and every `mockups/<screen>.html` must carry an embedded `<screen>-<width>.` shot, and no mockup may link (href/src/@import) into another feature's `.dev-flow/<other>/worktree/`; **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) |
|
|
17
17
|
| `health` | records a check | — (runs `seedData` + the health command, retrying up to `healthWait` seconds; app must be up locally with real data) |
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -123,6 +123,9 @@ import {
|
|
|
123
123
|
subst,
|
|
124
124
|
sq,
|
|
125
125
|
featureTmpDir,
|
|
126
|
+
featureTmpEnv,
|
|
127
|
+
compactionStateBlock,
|
|
128
|
+
foreignWorktreeLinks,
|
|
126
129
|
withTmpDir,
|
|
127
130
|
tagNotesCommand,
|
|
128
131
|
validSlug,
|
|
@@ -155,17 +158,20 @@ import { detectProject, type Detection } from "../src/detect.ts";
|
|
|
155
158
|
|
|
156
159
|
const execAsync = promisify(exec);
|
|
157
160
|
|
|
158
|
-
/**
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
/** This build's own identity, read once at load: it is what this session's code IS — an update that
|
|
162
|
+
* rewrites the package on disk later does not change the code already running. */
|
|
163
|
+
const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
164
|
+
|
|
165
|
+
/** The dev-flow build this session actually loaded — see sessionRunsOlderBuild. The load-time
|
|
166
|
+
* manifest, never a fresh read: re-reading the package after an in-place update reported the NEW
|
|
167
|
+
* version as loaded and the stale one as shipped (lettuce rail-ui-fixes, 0.79.0 → 0.80.0).
|
|
168
|
+
* DEV_FLOW_LOADED_VERSION (read at call time) can stand in for it (the smoke suite runs gates
|
|
169
|
+
* in-process and needs to pretend it is an old session): the override can only ever make a gate more
|
|
170
|
+
* cautious — it never lifts a proof, it turns a release into a warn-and-ask. */
|
|
162
171
|
function loadedVersion(): string | null {
|
|
163
|
-
return process.env.DEV_FLOW_LOADED_VERSION?.trim() ||
|
|
172
|
+
return process.env.DEV_FLOW_LOADED_VERSION?.trim() || SELF_BUILD.version;
|
|
164
173
|
}
|
|
165
174
|
|
|
166
|
-
/** This build's own identity, read once (the guard hot path must not re-walk the fs per call). */
|
|
167
|
-
const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
168
|
-
|
|
169
175
|
/** The dev-flow build this session *should* be running, as the disk describes it, and how to call it.
|
|
170
176
|
* In the dev-flow repo that is the checkout's own manifest: main moves ahead of the installed copy at
|
|
171
177
|
* every release, while `loadedVersion()` and the plugin's own package.json are the same file — so a
|
|
@@ -174,7 +180,7 @@ const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
|
174
180
|
function checkoutBuild(root: string): { version: string | null; dir: string; repo: string; label: string } {
|
|
175
181
|
return isSelfRepo(root)
|
|
176
182
|
? { ...pluginVersion(root), label: "this checkout" }
|
|
177
|
-
: { ...
|
|
183
|
+
: { ...pluginVersion(import.meta.dirname), label: "the dev-flow install" }; // fresh: what the disk ships NOW
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
/** The build this session runs vs the one the disk ships: `behind` is the loaded version when they differ
|
|
@@ -618,7 +624,7 @@ function gateCwd(root: string, state: FlowState): string {
|
|
|
618
624
|
function featureEnv(root: string, state: FlowState): Record<string, string> {
|
|
619
625
|
const dir = featureTmpDir(dfDir(root), state.slug);
|
|
620
626
|
mkdirSync(dir, { recursive: true });
|
|
621
|
-
return
|
|
627
|
+
return featureTmpEnv(dir);
|
|
622
628
|
}
|
|
623
629
|
|
|
624
630
|
/** Tier-1 checks the gate still has to see green. Entering a stage — and every edit of the worktree —
|
|
@@ -1772,7 +1778,20 @@ async function gateInit(o: GateCtx): Promise<RunResult> {
|
|
|
1772
1778
|
async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
1773
1779
|
const { root, sess, cfg, rest, flag, slugArg } = o;
|
|
1774
1780
|
if (!slugArg || !validSlug(slugArg)) return { text: "usage: flow start <slug> [--ui] [--patch|--docs] [--merge=squash|merge|rebase|any] (slug: lowercase, dashes); --ui/--patch/--docs are operator-granted — ask the operator in chat, then add --confirmed", isError: true };
|
|
1775
|
-
if (existsSync(featDir(root, slugArg)))
|
|
1781
|
+
if (existsSync(featDir(root, slugArg))) {
|
|
1782
|
+
// --ui on the plan-stage feature this session drives: the operator asked for mockups after the start,
|
|
1783
|
+
// so turn the mockup gate on instead of refusing — a UI feature left at ui=false skips the mockup
|
|
1784
|
+
// proof at approve and every (ui) checklist item (lettuce rail-ui-fixes shipped 20 ungated mockups)
|
|
1785
|
+
const existing = readState(root, slugArg);
|
|
1786
|
+
if (flag("ui") && existing && sess.slug === slugArg) {
|
|
1787
|
+
if (!flag("confirmed")) return { text: "--ui is operator-granted — it adds a rendered-mockup requirement to the plan gate; ask the operator, then re-run with --confirmed", isError: true };
|
|
1788
|
+
if (existing.ui) return { text: `feature ${slugArg} already has the ui flag` };
|
|
1789
|
+
if (existing.stage !== "plan") return { text: `feature ${slugArg} is at ${existing.stage} — the ui flag can be set only at plan (the mockup gate is approve's); render the screens anyway and say so in the verify report`, isError: true };
|
|
1790
|
+
writeState(root, { ...existing, ui: true });
|
|
1791
|
+
return { text: `ui flag set on existing feature ${slugArg} (plan stage): the approve gate now requires rendered mockups under plan/mockups/ (${cfg.mockupGlobs.join(", ")}), each embedded in plan.md, and the (ui) checklist items apply` };
|
|
1792
|
+
}
|
|
1793
|
+
return { text: `feature ${slugArg} already exists — flow use ${slugArg} to resume it${existing?.stage === "plan" ? `; to add the mockup gate at plan, run flow start ${slugArg} --ui --confirmed from the session bound to it` : ""}`, isError: true };
|
|
1794
|
+
}
|
|
1776
1795
|
// relaxed modes are operator-granted: --confirmed anchors a literal chat grant, same convention as the gate verbs
|
|
1777
1796
|
if (flag("patch") && flag("docs")) return { text: "--patch and --docs are exclusive — ask the operator which mode they grant", isError: true };
|
|
1778
1797
|
const mode = flag("patch") ? "patch" : flag("docs") ? "docs" : null;
|
|
@@ -1836,7 +1855,9 @@ async function gateApprove(o: GateCtx): Promise<RunResult> {
|
|
|
1836
1855
|
// the embed proofs read the plan document itself: a render that exists on disk but is not
|
|
1837
1856
|
// embedded in plan.md is one the operator would never be shown
|
|
1838
1857
|
const planMd = path.join(planDir, "plan.md");
|
|
1839
|
-
const
|
|
1858
|
+
const planFiles = listFiles(planDir);
|
|
1859
|
+
const mockupHtml = planFiles.filter((f) => /^mockups\/.+\.html?$/i.test(f)).map((f) => ({ file: f, html: readFileSync(path.join(planDir, f), "utf8") }));
|
|
1860
|
+
const errs = approveGate(state!, cfg, planFiles, existsSync(planMd) ? readFileSync(planMd, "utf8") : undefined, foreignWorktreeLinks(dfDir(root), state!.slug, mockupHtml));
|
|
1840
1861
|
if (errs.length) return { text: `plan gate FAILED:\n- ${errs.join("\n- ")}`, isError: true };
|
|
1841
1862
|
const planItems = applicableItems(cfg, state!, "plan");
|
|
1842
1863
|
const audit = flag("confirmed") ? " (confirmed by operator instruction)" : "";
|
|
@@ -2784,7 +2805,9 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2784
2805
|
const headers = auth.headers ? (Object.fromEntries(Object.entries(auth.headers).filter(([, v]) => v !== null)) as Record<string, string>) : undefined;
|
|
2785
2806
|
// same function pi itself calls — same split-turn merge, file lists and prompts, just flow-aware instructions
|
|
2786
2807
|
const result = await compactionTakeover.run(event.preparation, model, auth.apiKey, headers, flowCompactInstructions(st!), event.signal, undefined, undefined, auth.env);
|
|
2787
|
-
|
|
2808
|
+
// re-read: the summarize call took a while, and the block must state the disk as it is now
|
|
2809
|
+
const now = readState(root, st!.slug) ?? st!;
|
|
2810
|
+
return { compaction: { ...result, summary: result.summary + compactionStateBlock(now, loadProject(dfDir(root)).cfg) } };
|
|
2788
2811
|
} catch {
|
|
2789
2812
|
return undefined; // pi's default compaction proceeds untouched
|
|
2790
2813
|
} finally {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.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": [
|
|
@@ -26,7 +26,9 @@ feature).
|
|
|
26
26
|
blocks).
|
|
27
27
|
Throwaway scripts and scratch output go in `$TMPDIR` (or `mktemp`), not a
|
|
28
28
|
hard-coded `/tmp/...`: in a bound session, and in every command a gate runs,
|
|
29
|
-
it is `.dev-flow/<slug>/tmp/`, and finish removes it with the feature.
|
|
29
|
+
it is `.dev-flow/<slug>/tmp/`, and finish removes it with the feature. The
|
|
30
|
+
same commands get that dir as `GIT_CEILING_DIRECTORIES`, so a test fixture
|
|
31
|
+
made under it is not inside the checkout (git does not climb out of it).
|
|
30
32
|
3. `flow check` runs every tier-1 check (test, health, named `flow-check`
|
|
31
33
|
blocks) and records each against a fingerprint of the worktree; any later
|
|
32
34
|
worktree change makes them stale — verify reruns stale checks itself.
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
commits fall out of the worktree's base (push them or re-plan).
|
|
23
23
|
4. **UI flag set?** Mockups live in `plan/mockups/`, one HTML per screen/state
|
|
24
24
|
(`<screen>.html`), linking the project's real stylesheet and class names
|
|
25
|
-
where they exist (relative links work from `.dev-flow/`).
|
|
25
|
+
where they exist (relative links work from `.dev-flow/`). At plan the
|
|
26
|
+
feature has **no worktree yet** — link the main checkout's stylesheet
|
|
27
|
+
(`../../../../<path>` from `plan/mockups/`), never another feature's
|
|
28
|
+
worktree (the approve gate refuses it: that branch drifts and is removed at
|
|
29
|
+
its finish); after approve, re-render against this feature's worktree any
|
|
30
|
+
mockup you keep using. Every mockup
|
|
26
31
|
must be **rendered** — an unrendered mockup is not a mockup:
|
|
27
32
|
- Headless chromium: PATH `chromium`/`chromium-browser`/`google-chrome`,
|
|
28
33
|
else playwright's
|
|
@@ -27,7 +27,9 @@ writing.
|
|
|
27
27
|
|
|
28
28
|
`flow start <slug> [--ui --confirmed]` — `--ui` adds a rendered-mockup gate to plan, so it is
|
|
29
29
|
operator-granted like `--patch`/`--docs`: propose it when screens change, start with it only on their word;
|
|
30
|
-
slug lowercase words-dashed; check `flow status` for an active feature first.
|
|
30
|
+
slug lowercase words-dashed; check `flow status` for an active feature first. Screens turned out to
|
|
31
|
+
change after a plain start (the operator asks for mockups)? While the feature is still at plan,
|
|
32
|
+
`flow start <slug> --ui --confirmed` from its session switches the mockup gate on; past plan it refuses.
|
|
31
33
|
|
|
32
34
|
`flow start` **preflights** before it creates anything: it warns when this session runs an older dev-flow
|
|
33
35
|
build than the checkout (`/reload` before trusting gate output), prints the playbook gaps `flow doctor`
|
package/src/core.ts
CHANGED
|
@@ -242,7 +242,32 @@ const IMG_EXT = /\.(?:png|jpe?g|webp|gif)$/i;
|
|
|
242
242
|
* planDoc is the text of plan/plan.md (undefined = absent) — the embed proofs read the plan
|
|
243
243
|
* document itself. Before it, the gate checked only that *a* *.md and *a* *.png existed, which
|
|
244
244
|
* let a pre-plan/direction file with unembedded screenshots walk through Approve. */
|
|
245
|
-
|
|
245
|
+
/** Links in a feature's mockup HTML that resolve into ANOTHER feature's worktree, as `file: href`.
|
|
246
|
+
* At plan this feature has no worktree yet, and a sibling's is a tempting stand-in for "the branch's
|
|
247
|
+
* stylesheet" — but it is a different branch that drifts or vanishes when that feature finishes, so
|
|
248
|
+
* every later re-render silently describes someone else's styles (lettuce rail-ui-fixes linked
|
|
249
|
+
* status-and-loading's). `mockups` are paths relative to plan/ with their HTML; dfDir is absolute. */
|
|
250
|
+
export function foreignWorktreeLinks(dfDir: string, slug: string, mockups: { file: string; html: string }[]): string[] {
|
|
251
|
+
const out: string[] = [];
|
|
252
|
+
const base = path.join(dfDir, slug, "plan");
|
|
253
|
+
for (const m of mockups) {
|
|
254
|
+
const refs = [
|
|
255
|
+
...m.html.matchAll(/\b(?:href|src)\s*=\s*["']([^"']+)["']/gi),
|
|
256
|
+
...m.html.matchAll(/@import\s+(?:url\(\s*)?["']?([^"')\s;]+)/gi),
|
|
257
|
+
].map((x) => x[1]);
|
|
258
|
+
for (const ref of refs) {
|
|
259
|
+
if (/^(?:https?:|data:|#|mailto:)/i.test(ref)) continue;
|
|
260
|
+
const p = ref.replace(/^file:\/\//i, "").split(/[?#]/)[0];
|
|
261
|
+
const abs = path.isAbsolute(p) ? path.normalize(p) : path.resolve(path.dirname(path.join(base, m.file)), p);
|
|
262
|
+
const rel = path.relative(dfDir, abs);
|
|
263
|
+
const owner = /^([^/\\]+)[/\\]worktree(?:[/\\]|$)/.exec(rel)?.[1];
|
|
264
|
+
if (owner && owner !== slug && !rel.startsWith("..")) out.push(`${m.file}: ${ref}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return out;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function approveGate(state: FlowState, cfg: Config, planFiles: string[], planDoc?: string, foreignLinks: string[] = []): string[] {
|
|
246
271
|
const errs: string[] = [];
|
|
247
272
|
if (state.stage !== "plan") errs.push(`stage is "${state.stage}", approval only applies to "plan"`);
|
|
248
273
|
if (!state.patch && !state.docs && !planFiles.includes("plan.md"))
|
|
@@ -264,6 +289,8 @@ export function approveGate(state: FlowState, cfg: Config, planFiles: string[],
|
|
|
264
289
|
});
|
|
265
290
|
if (unrendered.length) errs.push(`mockups without an embedded render — ${unrendered.join(", ")} (render each screen and name the shot after it: <screen>-<width>.png)`);
|
|
266
291
|
}
|
|
292
|
+
if (foreignLinks.length)
|
|
293
|
+
errs.push(`mockups link another feature's worktree — ${foreignLinks.join(", ")}: that branch drifts and is removed at its finish; at plan link the main checkout's stylesheet (this feature's worktree does not exist until approve) and re-render`);
|
|
267
294
|
return errs;
|
|
268
295
|
}
|
|
269
296
|
|
|
@@ -1377,10 +1404,20 @@ export function featureTmpDir(dfDir: string, slug: string): string {
|
|
|
1377
1404
|
return path.join(dfDir, slug, "tmp");
|
|
1378
1405
|
}
|
|
1379
1406
|
|
|
1380
|
-
/** The
|
|
1407
|
+
/** The env every process of a bound feature gets: TMPDIR in the feature's scratch dir, and that dir as a
|
|
1408
|
+
* git ceiling. The scratch dir sits inside the repo, so without the ceiling git walks up out of a
|
|
1409
|
+
* test's mkdtemp fixture and answers with the enclosing checkout — a suite asserting "no repo here"
|
|
1410
|
+
* goes red only under dev-flow (lettuce rail-ui-fixes: a build-info test failed every gate run).
|
|
1411
|
+
* Commands run from the worktree or the main checkout never climb through the scratch dir, so they
|
|
1412
|
+
* are untouched. An inherited ceiling list is kept. */
|
|
1413
|
+
export function featureTmpEnv(dir: string, inherited = process.env.GIT_CEILING_DIRECTORIES): Record<string, string> {
|
|
1414
|
+
return { TMPDIR: dir, GIT_CEILING_DIRECTORIES: inherited ? `${dir}${path.delimiter}${inherited}` : dir };
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/** The agent's shell command with the feature env (featureTmpEnv) exported (newline-prefixed, the
|
|
1381
1418
|
* shape pi's own commandPrefix uses — the command itself stays byte-for-byte what the guards judged). */
|
|
1382
1419
|
export function withTmpDir(command: string, dir: string): string {
|
|
1383
|
-
return `export TMPDIR=${sq(dir)}\n${command}`;
|
|
1420
|
+
return `export TMPDIR=${sq(dir)} GIT_CEILING_DIRECTORIES=${sq(dir)}\${GIT_CEILING_DIRECTORIES:+:\$GIT_CEILING_DIRECTORIES}\n${command}`;
|
|
1384
1421
|
}
|
|
1385
1422
|
|
|
1386
1423
|
export function inScratchDir(abs: string, repoRoot?: string | null): boolean {
|
|
@@ -2014,6 +2051,24 @@ function mergeHintFor(cfg: Config): string {
|
|
|
2014
2051
|
}
|
|
2015
2052
|
|
|
2016
2053
|
/** What the agent/user should do next, per stage. */
|
|
2054
|
+
/** The block a flow-aware compaction appends to its summary: the flow's state as the disk holds it.
|
|
2055
|
+
* A summarizer merging an older summary can carry a stale stage forward (lettuce rail-ui-fixes: a
|
|
2056
|
+
* pre-release compaction still said "implement, next: flow verify"); this block is written from
|
|
2057
|
+
* state.json, never by the model, and says it outranks the prose above it. */
|
|
2058
|
+
export function compactionStateBlock(state: FlowState, cfg: Config): string {
|
|
2059
|
+
const approvals = Object.keys(state.approvals ?? {});
|
|
2060
|
+
const checks = Object.entries(state.checks ?? {}).map(([k, v]) => `${k}:${v?.ok ? "ok" : "FAILED"}`);
|
|
2061
|
+
return [
|
|
2062
|
+
"",
|
|
2063
|
+
"---",
|
|
2064
|
+
"[dev-flow state on disk — authoritative; where the summary above disagrees, this wins]",
|
|
2065
|
+
`- feature ${state.slug}${state.patch ? " (patch)" : state.docs ? " (docs)" : ""}${state.ui ? " (UI)" : ""} — stage: ${state.stage}${state.branch ? `, branch ${state.branch}` : ""}`,
|
|
2066
|
+
`- approvals recorded: ${approvals.length ? approvals.join(", ") : "none"}`,
|
|
2067
|
+
`- checks: ${checks.length ? checks.join(", ") : "none recorded"}`,
|
|
2068
|
+
`- next: ${nextHint(state, cfg)}`,
|
|
2069
|
+
].join("\n");
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2017
2072
|
export function nextHint(state: FlowState, cfg: Config): string {
|
|
2018
2073
|
switch (state.stage) {
|
|
2019
2074
|
case "plan":
|
|
@@ -2183,6 +2238,11 @@ export function buildWorkerBrief(o: WorkerBriefInput): string {
|
|
|
2183
2238
|
? [
|
|
2184
2239
|
"## Contract",
|
|
2185
2240
|
"- Use the edit/write tools for source changes. Commit as you go on the feature branch (small, meaningful commits).",
|
|
2241
|
+
...(o.status.trim()
|
|
2242
|
+
? [
|
|
2243
|
+
"- The uncommitted paths above are the driving session's work in progress, not yours: never stage or commit them. Commit only your own paths by name (`git add <paths>` then `git commit -m … -- <paths>`); never `git add -A`, `git add .` or `git commit -a`. Check `git diff --cached --name-only` before every commit.",
|
|
2244
|
+
]
|
|
2245
|
+
: []),
|
|
2186
2246
|
"- Do not stop to narrate — keep working until the slice is done or you are blocked.",
|
|
2187
2247
|
"- Finish with a final message whose last section starts with a line `REPORT` followed by: done, commits, open items, risks.",
|
|
2188
2248
|
]
|