pi-dev-flow 0.89.0 → 0.90.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 +22 -0
- package/README.md +89 -225
- package/docs/concurrency.md +54 -48
- package/docs/development.md +48 -54
- package/docs/gates.md +187 -25
- package/docs/guardrails.md +112 -30
- package/docs/headless.md +32 -44
- package/docs/playbook.md +215 -275
- package/docs/reflections.md +73 -0
- package/extensions/dev-flow.ts +3 -2
- package/package.json +1 -1
- package/skills/dev-flow/references/implement.md +3 -1
- package/skills/dev-flow/references/reflect.md +4 -1
- package/skills/dev-flow/references/start.md +4 -1
- package/src/core.ts +85 -36
- package/src/projectmd.ts +18 -5
- package/src/runtime/gates.ts +10 -4
- package/src/runtime/grants.ts +13 -3
- package/src/runtime/reflect.ts +29 -17
- package/src/runtime/ship.ts +23 -6
package/docs/development.md
CHANGED
|
@@ -1,72 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Working on dev-flow
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This repo is built with dev-flow itself.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npm i && npm test
|
|
7
|
-
pi -e . run /flow status # try
|
|
6
|
+
npm i && npm test # unit tests + wiring smoke test (node --test)
|
|
7
|
+
pi -e . run /flow status # try the working tree against any repo
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
reconciles it after a release; loaded code swaps only when the process re-imports — `/reload` in a
|
|
12
|
-
per-session host, a host restart in a shared-process host like pi-web) — there is deliberately no
|
|
13
|
-
`.pi/extensions/` pointer here: a committed shim beside the global package loads two copies of the
|
|
14
|
-
extension in one process (pi dedupes by path, not by package — see the README's two-sources
|
|
15
|
-
warning), which is what the shim used to cause. The package's own `pi.extensions` manifest remains a
|
|
16
|
-
second source for any session opened in this checkout — deliberate dogfooding, made safe by the guard
|
|
17
|
-
election: the newest registered copy judges, older loaded copies answer nothing. To dogfood the
|
|
18
|
-
working tree instead of the installed copy, point pi at it explicitly for that run: `pi -e .`.
|
|
10
|
+
## Loaded code and duplicate copies
|
|
19
11
|
|
|
20
|
-
A
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
- **A running session keeps the code it started with.** After a release, run `/reload` in each
|
|
13
|
+
session that needs the new behavior. Shared-process hosts like pi-web keep the old code until
|
|
14
|
+
they're restarted: there, `/reload` re-binds state but doesn't swap code.
|
|
15
|
+
- **Two install sources load two copies.** For example, a project `git:` pin next to a global `npm:`
|
|
16
|
+
install. Pi dedupes extensions by path, not by package. Keep only the source you update from.
|
|
17
|
+
- **The newest copy decides.** Every loaded copy's guards check which registered version is highest,
|
|
18
|
+
and older copies stay silent. `flow version` lists every copy in the process and names the one
|
|
19
|
+
serving the call.
|
|
20
|
+
- **This checkout uses the global install.** There's deliberately no `.pi/extensions/` shim here:
|
|
21
|
+
one would load a second copy. The package's own `pi.extensions` manifest is a second source in
|
|
22
|
+
this checkout, which is safe because the newest copy decides. To run the working tree instead, use
|
|
23
|
+
`pi -e .`.
|
|
23
24
|
|
|
24
25
|
## Layout
|
|
25
26
|
|
|
26
|
-
- `extensions/dev-flow.ts
|
|
27
|
-
the event hooks (guards, injections, footer, compaction).
|
|
28
|
-
- `src/runtime
|
|
29
|
-
|
|
30
|
-
`
|
|
31
|
-
- `
|
|
32
|
-
`
|
|
27
|
+
- `extensions/dev-flow.ts`: Pi wiring only. The `/flow` command, the `flow` and `flow_stage` tools,
|
|
28
|
+
and the event hooks (guards, injections, footer, compaction).
|
|
29
|
+
- `src/runtime/`: what the wiring runs.
|
|
30
|
+
- `base`: shell, paths, state, sessions, claims.
|
|
31
|
+
- `checks`: dev deploy, health, tier-1 checks.
|
|
32
|
+
- `gates`: the runner and the non-shipping gates.
|
|
33
|
+
- `ship`: verify, release, release-done, finish.
|
|
34
|
+
- `setup`, `reflect`, `workers`.
|
|
35
|
+
- `src/core.ts`, `src/projectmd.ts`, `src/present.ts`, …: pure logic, unit-tested without Pi.
|
|
36
|
+
`present.ts` splits each gate result into your view and the agent's text.
|
|
33
37
|
|
|
34
|
-
## The skill: an injected core
|
|
38
|
+
## The skill: an injected core plus per-stage references
|
|
35
39
|
|
|
36
|
-
Pi
|
|
37
|
-
|
|
38
|
-
guesses at a gate and then fights the guard, so `skills/dev-flow/SKILL.md` is split:
|
|
40
|
+
Pi loads a skill's `SKILL.md` only when the model decides to read it. A session that never reads the
|
|
41
|
+
rules guesses at gates and fights the guards. So `skills/dev-flow/SKILL.md` is split in two:
|
|
39
42
|
|
|
40
|
-
- The
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- Everything else lives in `references/<stage>.md` — stage prose moved verbatim. The stage injection
|
|
47
|
-
names the one file the current stage needs (`…/references/plan.md` at plan), and the map under the
|
|
48
|
-
core lists them all. `references/` stays invisible to pi: only `SKILL.md` registers, and a
|
|
49
|
-
directory holding one is not scanned deeper.
|
|
43
|
+
- **The core** sits between `<!-- dev-flow:core:start -->` and `<!-- dev-flow:core:end -->`. It's
|
|
44
|
+
injected **once per session**. A reload, resume or fork doesn't inject it again, and a compaction
|
|
45
|
+
that summarizes it away brings it back once. Every session pays for it, so `package.test.ts`
|
|
46
|
+
rejects a core over **4,000 characters**.
|
|
47
|
+
- **Everything else** lives in `references/<stage>.md`. Each stage's message names the one file it
|
|
48
|
+
needs.
|
|
50
49
|
|
|
51
|
-
When a stage
|
|
52
|
-
every stage has a file
|
|
53
|
-
the state machine has no finish stage that could name it.
|
|
50
|
+
When a stage needs more guidance, add it to that stage's reference file, not the core. The tests
|
|
51
|
+
check that every stage has a file and that the map names every file.
|
|
54
52
|
|
|
55
53
|
## Publishing
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
from exactly that commit. Nothing publishes from a developer machine.
|
|
55
|
+
`.github/workflows/release.yml` publishes to npm when a `v*` tag is pushed. It checks out the tag,
|
|
56
|
+
runs `npm ci && npm test`, and runs `npm publish --provenance`. Nothing publishes from a laptop.
|
|
60
57
|
|
|
61
|
-
Auth is npm
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
- **Auth is npm trusted publishing** (OIDC, no token). The registration on npmjs.com names this repo
|
|
59
|
+
and the workflow file name, so re-register after renaming either one.
|
|
60
|
+
- **`--provenance` needs a public repo.** If the repo ever goes private, drop the flag.
|
|
61
|
+
- **If the job fails,** fix the cause and re-run the same job. The tag already points at the right
|
|
62
|
+
commit. `flow release-done` refuses to close the flow until `npm view pi-dev-flow@<version>`
|
|
63
|
+
succeeds.
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
public. If it ever goes private, drop the flag rather than the release.
|
|
69
|
-
|
|
70
|
-
If the job fails, fix the cause and **Re-run jobs** on the same failed run: the tag already points at what
|
|
71
|
-
should ship, so no re-tag. `flow release-done` then runs `npm view pi-dev-flow@<version> version` and
|
|
72
|
-
refuses to close the flow while the version is missing — which also catches a tag that never published.
|
|
65
|
+
The README is also the package page on npm and [pi.dev](https://pi.dev/packages/pi-dev-flow). Its doc
|
|
66
|
+
links use absolute GitHub URLs, because pi.dev rewrites relative links to raw files on jsDelivr.
|
package/docs/gates.md
CHANGED
|
@@ -1,31 +1,193 @@
|
|
|
1
1
|
# Gate reference
|
|
2
2
|
|
|
3
|
-
Every gate
|
|
3
|
+
Every gate: what it advances and what makes it refuse.
|
|
4
4
|
|
|
5
|
-
You normally type none of this
|
|
6
|
-
your **manual
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`
|
|
5
|
+
You normally type none of this. The agent runs the gates, and you answer in chat. `/flow <sub>` is
|
|
6
|
+
your **manual override**: use it to read state when the agent is confused, or to advance a gate
|
|
7
|
+
yourself when the agent is stuck.
|
|
8
|
+
|
|
9
|
+
**How checkpoints work.** The agent's `flow` call never opens a dialog. A checkpoint gate refuses
|
|
10
|
+
with `NEEDS-OPERATOR <Question?>`, the agent asks you in chat, and it re-runs the gate with
|
|
11
|
+
`--confirmed` once you answer. A `/flow` command you type yourself asks you in a dialog instead.
|
|
12
|
+
`--confirmed` means "the operator literally answered this question". The agent must never add it on
|
|
13
|
+
its own.
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
11
16
|
|
|
12
17
|
| Gate | Advances | Refuses unless |
|
|
13
18
|
|---|---|---|
|
|
14
|
-
| `start <slug
|
|
15
|
-
| `use <slug>` |
|
|
16
|
-
| `approve
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
`--
|
|
19
|
+
| `start <slug>` | → plan | the slug is new and the playbook has a `merge` policy |
|
|
20
|
+
| `use <slug>` | binds this session | the feature is unfinished |
|
|
21
|
+
| `approve` | plan → implement | `plan/plan.md` exists (plus embedded mockups for `--ui`) and you said yes |
|
|
22
|
+
| `verify` | implement → pre-release | the branch has commits, checks are green, the deploy is healthy, and you said yes |
|
|
23
|
+
| `release` | pre-release → release | the version and changelog are right, nothing is uncommitted, and you said yes (or it answered itself) |
|
|
24
|
+
| `release-done` | records the release | the tag is on origin, the artifact is published, and the forge release exists |
|
|
25
|
+
| `finish` | release → done | the release is recorded, main is clean and pushed, and you said yes |
|
|
26
|
+
|
|
27
|
+
Tools that never gate: `test`, `check`, `health`, `status`, `abort`, `doctor`, `reflect`, `roadmap`,
|
|
28
|
+
`help`, `version`.
|
|
29
|
+
|
|
30
|
+
## start
|
|
31
|
+
|
|
32
|
+
`flow start <slug> [--ui | --patch | --docs] [--merge=<style>] [--check-upstream]`
|
|
33
|
+
|
|
34
|
+
Creates the feature, binds this session to it, and renames the session after the slug.
|
|
35
|
+
|
|
36
|
+
- `--ui` means the plan gate requires rendered mockups. `--patch` (a small fix, no written plan) and
|
|
37
|
+
`--docs` (docs only, no build checks) are lighter modes. All three need your OK in chat, and the
|
|
38
|
+
agent then adds `--confirmed`.
|
|
39
|
+
- **The playbook needs a `merge` policy.** If it has none, start asks which style to use (squash,
|
|
40
|
+
merge, rebase or any), suggests one from your git history, and writes your answer into
|
|
41
|
+
`## release`.
|
|
42
|
+
- It prints the dev-flow version, warns if this session runs an older build than the checkout
|
|
43
|
+
(`--check-upstream` also asks npm), and lists playbook gaps.
|
|
44
|
+
- A leftover `.dev-flow/<slug>/` without `state.json` (a "ghost") is shown to you and adopted on
|
|
45
|
+
`--confirmed`, unless it still holds a `worktree/`.
|
|
46
|
+
- If the roadmap has an item picked for this slug, the plan starts from it.
|
|
47
|
+
|
|
48
|
+
## use
|
|
49
|
+
|
|
50
|
+
`flow use <slug>` binds this session to an unfinished feature, records a claim on disk, and renames
|
|
51
|
+
the session. It also takes over a feature another session holds. Nothing binds automatically.
|
|
52
|
+
|
|
53
|
+
## approve: Approve?
|
|
54
|
+
|
|
55
|
+
`flow approve [--yolo]`
|
|
56
|
+
|
|
57
|
+
- `plan/plan.md` must exist with exactly that name.
|
|
58
|
+
- For a `--ui` feature, every screenshot under `plan/` must be embedded in plan.md, every
|
|
59
|
+
`mockups/<screen>.html` needs a `<screen>-<width>.png` render, and no mockup may link into another
|
|
60
|
+
feature's worktree.
|
|
61
|
+
- On yes, it creates the worktree and the `feat/<slug>` branch, then runs `setup` there. If setup
|
|
62
|
+
fails, the next `approve` retries it.
|
|
63
|
+
|
|
64
|
+
## test, check, health
|
|
65
|
+
|
|
66
|
+
- `flow test` runs the `test` command and records the result.
|
|
67
|
+
- `flow check` runs every tier-1 check from `## implement`.
|
|
68
|
+
- `flow health` runs `seedData` and then the health probe, retrying for up to `healthWait` seconds.
|
|
69
|
+
|
|
70
|
+
Each record carries a fingerprint of the worktree. When the tree changes, the record goes stale and
|
|
71
|
+
the next gate re-runs it. A `--docs` flow runs none of these.
|
|
72
|
+
|
|
73
|
+
## verify: Verified?
|
|
74
|
+
|
|
75
|
+
`flow verify [--yolo] [--version=patch|minor|major|<v> | --no-version] [--port=<n> | --replace]`
|
|
76
|
+
|
|
77
|
+
Run without `--confirmed`, it deploys for your review:
|
|
78
|
+
|
|
79
|
+
1. Fetches, and rebases the branch if main moved ahead. Conflicts or uncommitted tracked edits
|
|
80
|
+
refuse, and the branch is left untouched.
|
|
81
|
+
2. Checks the dev port. If another live flow holds it, it asks **Dev port?**: run alongside on
|
|
82
|
+
another port, replace that deploy, or wait. See [concurrency](concurrency.md).
|
|
83
|
+
3. Runs the checks (re-running any that are stale or missing), the build, the `dev` deploy, and then
|
|
84
|
+
the health probe against what it just deployed.
|
|
85
|
+
4. Asks **Verified?**
|
|
86
|
+
|
|
87
|
+
It refuses if:
|
|
88
|
+
- the branch has no commits (except a release-only flow on a versioned project with unreleased
|
|
89
|
+
commits on main);
|
|
90
|
+
- a check, the build or the post-deploy health probe fails;
|
|
91
|
+
- `servedBuild` is set and the running app isn't serving this commit.
|
|
92
|
+
|
|
93
|
+
**The release call rides on Verified?** On a versioned project with `version = ask` (the default),
|
|
94
|
+
the question also asks: *patch, minor or major release, or merge unreleased?* Your answer is recorded
|
|
95
|
+
with `--version=…` or `--no-version`.
|
|
96
|
+
|
|
97
|
+
With `--confirmed`, it never rewrites history. If main moved since the review deploy, re-run
|
|
98
|
+
`flow verify`.
|
|
99
|
+
|
|
100
|
+
**At pre-release, `verify` is the re-verify:** after review fixes, it re-runs the build, deploy and
|
|
101
|
+
probes on the current tree and asks Verified? again. A standing yolo never answers this.
|
|
102
|
+
|
|
103
|
+
## release: Release?
|
|
104
|
+
|
|
105
|
+
`flow release [--yolo] [--version=<v> | --no-version] [--no-fold-check] [--no-marker-check]`
|
|
106
|
+
|
|
107
|
+
Proves the branch is ready to ship:
|
|
108
|
+
|
|
109
|
+
- **The version** matches your release call. Patch, minor or major is counted from the newest tag
|
|
110
|
+
at release time, so if a parallel flow shipped first, yours moves to the next number.
|
|
111
|
+
- **The version is new**: the manifest's version isn't tagged yet.
|
|
112
|
+
- **The changelog** has a heading for this version, this branch edited it, every entry that was
|
|
113
|
+
pending under `Unreleased` is kept in the new section, and `Unreleased` is now empty.
|
|
114
|
+
- **Merge unreleased** (`--no-version`): no bump, but the branch adds its own line under
|
|
115
|
+
`Unreleased`. Docs flows are exempt.
|
|
116
|
+
- The checks are green again after the prep edits, and `release.preflight` passes if set.
|
|
117
|
+
- There are no leftover conflict markers (`<<<<<<<`) and no uncommitted files in the worktree.
|
|
118
|
+
|
|
119
|
+
**Release? often answers itself** (`ask = on-change`, the default). That happens when your call is
|
|
120
|
+
on record and only release prep (bump, changelog) changed since Verified?. It still asks when:
|
|
121
|
+
- code changed after Verified?;
|
|
122
|
+
- the session runs an old build (proceeding is allowed, and it says what you'd miss);
|
|
123
|
+
- the playbook sets `yolo = until-release`;
|
|
124
|
+
- it's a major bump the playbook made rather than you.
|
|
125
|
+
|
|
126
|
+
Set `ask = always` in `## release` to be asked every time.
|
|
127
|
+
|
|
128
|
+
Escape hatches, used only on your word: `--no-fold-check` skips the line-level changelog check, and
|
|
129
|
+
`--no-marker-check` allows intentional conflict-marker lines.
|
|
130
|
+
|
|
131
|
+
## release-done
|
|
132
|
+
|
|
133
|
+
Records the release. It asks no question, because your Release? answer covered it. `finish` runs it
|
|
134
|
+
for you if the agent didn't.
|
|
135
|
+
|
|
136
|
+
- The tag exists, is reachable from main, and is **on origin**. If origin can't be reached, it
|
|
137
|
+
refuses rather than trust local tags.
|
|
138
|
+
- `release.artifact` (for example `npm view <pkg>@{version} version`) passes. On GitHub, it waits
|
|
139
|
+
for the CI runs the tag started.
|
|
140
|
+
- It creates the forge release (`gh` / `glab`), using the changelog entry as the body, then reads it
|
|
141
|
+
back to confirm it exists and matches.
|
|
142
|
+
- It checks that the merge matched the `merge` policy. If that can't be seen (self-hosted forge, no
|
|
143
|
+
CLI), it prints a note instead of refusing.
|
|
144
|
+
|
|
145
|
+
Skip flags (on your word): `--no-artifact-check`, `--no-release-create`. You can also set
|
|
146
|
+
`release.releases = false` or `forge = self` to skip creating the forge release.
|
|
147
|
+
|
|
148
|
+
## finish: Finish?
|
|
149
|
+
|
|
150
|
+
`flow finish [--yolo] [--no-reflect] [--note=<text>] [slug]`
|
|
151
|
+
|
|
152
|
+
1. Records the release if `release-done` never ran. If the `## release` checklist still has open
|
|
153
|
+
items, it stops and lists them.
|
|
154
|
+
2. Runs the **closing reflection** (see [reflections](reflections.md)) and waits for your fold/drop.
|
|
155
|
+
3. On `--confirmed`, cleans up: removes the worktree, the branch and `.dev-flow/<slug>/`. It deletes
|
|
156
|
+
the remote branch only once it's proven merged. If local main is just behind origin, it
|
|
157
|
+
fast-forwards it.
|
|
158
|
+
|
|
159
|
+
It refuses until the release is recorded, the main checkout is clean and pushed, and the worktree has
|
|
160
|
+
no uncommitted changes. Under `merge = merge`, commits missing from main are a policy violation that
|
|
161
|
+
yolo can't answer.
|
|
162
|
+
|
|
163
|
+
To drop an unreleased feature, use `flow abort` instead.
|
|
164
|
+
|
|
165
|
+
## reflect, roadmap, doctor
|
|
166
|
+
|
|
167
|
+
- `flow reflect …` manages the notes queue. See [reflections](reflections.md).
|
|
168
|
+
- `flow roadmap [add "<feature>" [--slug=] [--brief=] | pick <n> <slug> | done <n> | drop <n> | tidy]`
|
|
169
|
+
manages `.dev-flow/roadmap.md`. `pick` stamps an item for `flow start <slug>`, and `finish` checks
|
|
170
|
+
it off when the feature ships.
|
|
171
|
+
- `flow doctor ["<note>"]` is a read-only health report: playbook drift, dead commands, ghost
|
|
172
|
+
folders, orphan worktrees and branches, and a review of every open reflection. It writes nothing,
|
|
173
|
+
so it's safe at any stage and in CI.
|
|
174
|
+
|
|
175
|
+
## status, abort, help, version
|
|
176
|
+
|
|
177
|
+
- `flow status [slug]` shows where every feature stands. `--json` gives machine output.
|
|
178
|
+
- `flow abort [slug]` drops a feature.
|
|
179
|
+
- `flow help` (`--json`) prints the gate contract.
|
|
180
|
+
- `flow version [--check-upstream]` prints which dev-flow copy this session runs and whether the
|
|
181
|
+
checkout is newer.
|
|
182
|
+
|
|
183
|
+
These work in any repo, even without `.dev-flow/`.
|
|
184
|
+
|
|
185
|
+
## yolo
|
|
186
|
+
|
|
187
|
+
Answering **yolo** at any checkpoint runs that gate with `--yolo --confirmed`. That answers the
|
|
188
|
+
question and pre-confirms the rest, so the agent runs the remaining gates back to back, following
|
|
189
|
+
any wishes you added ("yolo, patch bump"). Every check and guard still applies. Yolo never answers:
|
|
190
|
+
- the re-verify at pre-release;
|
|
191
|
+
- Release? when code changed after Verified?, or when the playbook sets `yolo = until-release`;
|
|
192
|
+
- a `merge = merge` policy violation at finish;
|
|
193
|
+
- skipping the closing reflection.
|
package/docs/guardrails.md
CHANGED
|
@@ -1,30 +1,112 @@
|
|
|
1
|
-
# Guardrails
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
1
|
+
# Guardrails
|
|
2
|
+
|
|
3
|
+
What dev-flow enforces while a feature is in flight, and what it deliberately doesn't do.
|
|
4
|
+
|
|
5
|
+
All of this applies only in an initialized repo, one where `.dev-flow/project.md` exists. Without the
|
|
6
|
+
playbook, dev-flow stays silent.
|
|
7
|
+
|
|
8
|
+
## What is enforced
|
|
9
|
+
|
|
10
|
+
**Nothing lands on main until release.**
|
|
11
|
+
- `git commit`, `git merge` and pushes *to* the default branch are blocked at every stage except
|
|
12
|
+
`release`. Tag pushes and feature-branch pushes are fine from any stage.
|
|
13
|
+
- One exception: a commit whose only change is `.dev-flow/project.md`, since tracking your playbook
|
|
14
|
+
is setup, not feature work.
|
|
15
|
+
- A `pre-commit` hook covers commits made outside Pi.
|
|
16
|
+
|
|
17
|
+
**Shipping waits for `flow release`.** Before the release stage, tagging, merging the PR
|
|
18
|
+
(`gh pr merge`, `glab mr merge`) and creating a forge release are refused. Reads like `git tag -l`
|
|
19
|
+
and opening the PR are fine.
|
|
20
|
+
|
|
21
|
+
**No code before an approved plan.** During plan, the agent can only write in its own
|
|
22
|
+
`.dev-flow/<slug>/` folder.
|
|
23
|
+
|
|
24
|
+
**Work stays in the worktree.**
|
|
25
|
+
- During implement and pre-release, the agent can only write in its own feature's worktree. Each
|
|
26
|
+
write is judged by the feature that owns the path, so sessions can't write into each other's
|
|
27
|
+
worktrees.
|
|
28
|
+
- Paths are checked after resolving symlinks.
|
|
29
|
+
- Scratch files outside the repo (the OS temp dir) are always fine. A bound feature's `TMPDIR`
|
|
30
|
+
points to `.dev-flow/<slug>/tmp/`, which is cleaned up at finish.
|
|
31
|
+
- Creating a new branch inside a feature worktree is refused. An unrelated fix gets its own flow.
|
|
32
|
+
|
|
33
|
+
**No work outside a flow.**
|
|
34
|
+
- In a repo with `.dev-flow/`, an unbound session can't edit source files. Everything starts with
|
|
35
|
+
`flow start` or `flow use`.
|
|
36
|
+
- Files git ignores (like a local secrets file) stay writable.
|
|
37
|
+
- `flow start` requires the main checkout to be on the default branch.
|
|
38
|
+
|
|
39
|
+
**Gates can't be faked.**
|
|
40
|
+
- The agent can't write, move or delete `state.json`, `claim.json`, a feature folder or `.dev-flow/`
|
|
41
|
+
itself, through either edit tools or bash.
|
|
42
|
+
- The playbook is yours. The agent can only edit it inside a docs or patch flow's worktree, and every
|
|
43
|
+
sanctioned overwrite keeps a `project.md.bak`.
|
|
44
|
+
- Every check result is tied to a fingerprint of the worktree. Any change, even through `sed -i` or a
|
|
45
|
+
formatter, makes it stale, and the next gate re-runs it.
|
|
46
|
+
|
|
47
|
+
**Your own rules.** The `deny` / `confirm` / `protect` / `forbid` rules in your playbook's
|
|
48
|
+
`flow-guard` block run on every bash command and every edit, at every stage, before dev-flow's own
|
|
49
|
+
checks. A block always shows the reason you wrote. See the [playbook](playbook.md).
|
|
50
|
+
|
|
51
|
+
**Force pushes ask you.** `git push --force` / `-f` / `--force-with-lease` needs your OK. The
|
|
52
|
+
refusal prints the prefix that marks it as approved: `DEV_FLOW_ALLOW_REWRITE=1`.
|
|
53
|
+
|
|
54
|
+
**Shell calls can't hang.** The model often omits a timeout, so a `gh` waiting on a prompt could
|
|
55
|
+
freeze a session for hours. A shell call without a timeout gets a default for its kind:
|
|
56
|
+
|
|
57
|
+
| Kind | Timeout |
|
|
58
|
+
|---|---|
|
|
59
|
+
| quick inspection | 30s |
|
|
60
|
+
| local git, unknown commands | 120s |
|
|
61
|
+
| network | 180s |
|
|
62
|
+
| containers and services | 300s |
|
|
63
|
+
| builds, tests, installs | 900s |
|
|
64
|
+
| watchers (`gh run watch`) | 1,200s |
|
|
65
|
+
|
|
66
|
+
Explicit timeouts are capped at 1,800s. A command wrapped in its own `timeout N` gets N + 15s. When
|
|
67
|
+
dev-flow's default kills a command, the result says so. Set `bashTimeout = require` in `## global` to
|
|
68
|
+
refuse calls without a timeout instead.
|
|
69
|
+
|
|
70
|
+
**There is no `flow` CLI.** A bash command named `flow` is refused. Gates live inside the Pi session.
|
|
71
|
+
If your project ships its own `flow` binary, call it by path or through `npx`.
|
|
72
|
+
|
|
73
|
+
**The rules reach the agent.** Pi loads a skill only when the model decides to read it. So dev-flow
|
|
74
|
+
injects the ground rules (about a thousand tokens) into each session once, and again after a
|
|
75
|
+
compaction removes them. Each stage then names the one reference file it needs.
|
|
76
|
+
|
|
77
|
+
**Compaction is flow-aware.** dev-flow uses your effective `reserveTokens`. When Pi compacts anyway,
|
|
78
|
+
dev-flow redoes the compaction with flow-aware summary instructions. If auto-compaction is off in
|
|
79
|
+
your settings, dev-flow leaves it off.
|
|
80
|
+
|
|
81
|
+
## Status bar
|
|
82
|
+
|
|
83
|
+
In an initialized repo, the footer shows the bound feature:
|
|
84
|
+
|
|
85
|
+
| Glyph | Means |
|
|
86
|
+
|---|---|
|
|
87
|
+
| 📝 🔨 🔍 🚀 | plan · implement · pre-release · release |
|
|
88
|
+
| ⚡ 📚 🎱 | patch · docs · yolo mode |
|
|
89
|
+
| 💬 | a checkpoint is waiting for your answer |
|
|
90
|
+
| ⚠️ | a check is failing |
|
|
91
|
+
|
|
92
|
+
An unbound session shows `💬 N flow(s) open` or `💬 no flows`. In pi-web, the footer is a chip you
|
|
93
|
+
can click to see the other open flows. `flow status` spells all of it out.
|
|
94
|
+
|
|
95
|
+
## Limitations
|
|
96
|
+
|
|
97
|
+
These guards stop the common mistakes an agent makes. They are **not a security sandbox**.
|
|
98
|
+
|
|
99
|
+
- **Production deploys stay manual.** `flow finish` only closes the flow.
|
|
100
|
+
- **The git guard reads shell commands.** It splits commands into segments and understands
|
|
101
|
+
`cd … &&`, `git -C`, quotes, and wrappers like `sh -c`, `env` and `xargs`. An exotic wrapper
|
|
102
|
+
(a subshell, or a command held in a variable) can still slip past.
|
|
103
|
+
- **Quoted text is data.** `gh pr create --body "…git commit…"` isn't a commit. That means a command
|
|
104
|
+
built at runtime isn't caught either.
|
|
105
|
+
- **`protect` / `forbid` cover edit tools only, judged from the repo root.** A copy inside a
|
|
106
|
+
worktree is a different path. Use a `deny` rule to stop a bash redirect.
|
|
107
|
+
- **Read-only commands can still write.** `find -delete` and `awk … > file` can write, so a `deny`
|
|
108
|
+
on `rm` doesn't cover them. Write the rule for the effect you want to prevent.
|
|
109
|
+
- **Where gate commands run.** Before the worktree exists, gate commands run in the main checkout.
|
|
110
|
+
After that, they run in the worktree.
|
|
111
|
+
- **Keep real validation in CI.** Write rules for common mistakes, and keep checks you truly depend
|
|
112
|
+
on in scripts and CI.
|