pi-adx-workflow 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mossaab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,503 @@
1
- # Temporary Holding Version
1
+ # pi-adx-workflow
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
4
+ [![pi-coding-agent](https://img.shields.io/badge/pi-coding-agent-%E2%89%A51.5-blueviolet.svg)](https://github.com/earendil-works/pi)
5
+
6
+ **plan → build/verify → review → summarize** workflow for
7
+ [pi-coding-agent](https://github.com/earendil-works/pi), built as a pi extension with
8
+ **in-house sub-agent propagation**: flow children (verifier / code reviewer)
9
+ run as isolated `pi -p` child processes — no pi-subagents dependency.
10
+
11
+ It implements a complete working method:
12
+
13
+ 1. **Plan mode** (read-only) — the planner explores and proposes **acceptance
14
+ criteria** (`flow_meta`, key `criteria`, status `pending`).
15
+ 2. **Build mode** — you approve, then `/adx-run` starts the workflow:
16
+ the builder implements and marks criteria `completed`.
17
+ 3. **Verify loop** — an isolated **verifier** sub-agent (fresh `pi -p` child
18
+ session) checks each criterion and sets `passed`/`failed`. Failures
19
+ send the builder back with a nudge carrying the verifier's findings.
20
+ 4. **Code review** — an isolated **code reviewer** sub-agent reviews the git
21
+ diff and raises `review_findings`.
22
+ 5. **Finalize loop** — the builder must resolve or dismiss every finding.
23
+ 6. **Summarize** — final report + a "What to test" mini-tutorial.
24
+
25
+ The whole run is a declarative state machine: steps, ordered transitions,
26
+ metadata conditions, nudge re-entry, `maxIterations` safety cap,
27
+ `$blocked` handling, and persistence/resume.
28
+
29
+ ## Contents
30
+
31
+ - [Requirements](#requirements)
32
+ - [Install](#install)
33
+ - [Usage](#usage)
34
+ - [Configuration](#configuration)
35
+ - [Never-stop (auto-continue)](#never-stop-auto-continue)
36
+ - [Tools](#tools)
37
+ - [Sub-agents](#sub-agents)
38
+ - [Workflows](#workflows)
39
+ - [Development](#development)
40
+ - [Contributing](#contributing)
41
+ - [Troubleshooting](#troubleshooting)
42
+ - [Project layout](#project-layout)
43
+ - [License](#license)
44
+
45
+ ## Requirements
46
+
47
+ - pi-coding-agent **≥ 1.5** (the `pi` CLI is resolved from
48
+ `~/.pi/agent/bin/pi`, `ADX_PI_BIN`, or `PATH`)
49
+ - Node **≥ 22.19** (pi's own engine requirement)
50
+
51
+ pi-subagents is **not** required: children are plain `pi -p` processes that
52
+ load only this extension (child mode), so there is no retained-child state
53
+ and no "Agent is already processing" jams.
54
+
55
+ No `npm install` is needed for the extension itself: its runtime imports
56
+ (`typebox`, `@earendil-works/pi-ai`, `@earendil-works/pi-coding-agent`) are
57
+ **host-provided** — pi maps them to its own copies, so the extension shares
58
+ pi's classes and registries (declared as `peerDependencies` with a `*` range,
59
+ per the pi package conventions).
60
+
61
+ ## Install
62
+
63
+ Recommended: install as a [pi package](https://github.com/earendil-works/pi) from git:
64
+
65
+ ```sh
66
+ pi install git:github.com/mossaab/pi-adx-workflow
67
+ ```
68
+
69
+ Variants:
70
+
71
+ ```sh
72
+ # project-local (written to .pi/settings.json, loads after project trust)
73
+ pi install --local git:github.com/mossaab/pi-adx-workflow
74
+
75
+ # from npm
76
+ pi install npm:pi-adx-workflow
77
+ ```
78
+
79
+ Manage the install:
80
+
81
+ ```sh
82
+ pi list # show configured packages
83
+ pi remove git:github.com/mossaab/pi-adx-workflow
84
+ pi update --extensions # reconcile git checkouts / npm specs
85
+ ```
86
+
87
+ ### Development install (symlink)
88
+
89
+ To develop the extension, clone the repo and symlink it into pi's global
90
+ extension directory (pi discovers `package.json` with a `pi.extensions`
91
+ field one level deep):
92
+
93
+ ```sh
94
+ git clone https://github.com/mossaab/pi-adx-workflow.git
95
+ ln -sfn ~/path/to/pi-adx-workflow ~/.pi/agent/extensions/adx-workflow
96
+ ```
97
+
98
+ No build step: pi loads `src/index.ts` through jiti. If you move the repo,
99
+ re-create the symlink.
100
+
101
+ ## Usage
102
+
103
+ ```
104
+ /adx-plan enter plan mode (read-only)
105
+ /adx-spec [path] enter spec mode (read-only brainstorm/research; writes a spec file, no build)
106
+ /adx-spec SPEC.md spec mode with a custom spec location (default: .pi/specs/<slug>.md)
107
+ /adx-approve approve the plan/spec: switch to build mode (turn plan/spec mode off, no launch)
108
+ /adx-run [workflow] [params] switch to build mode + launch a workflow (default: the configured build one)
109
+ /adx-run build-verify switch to build mode + launch the full build-verify workflow
110
+ /adx-run build-verify skip_review=true full workflow minus the code review step
111
+ /adx-run build-verify commit=true pipeline + commit & push at the end (auto-skips the "Commit changes?" picker)
112
+ /adx-run build-verify commit=false pipeline, changes left uncommitted (picker auto-skipped)
113
+ /adx-run build-verify commit=true message="feat: ..." commit phase with an explicit commit message
114
+ /adx-status show current workflow state
115
+ /adx-resume resume a blocked/waiting workflow
116
+ /adx-cancel cancel the current run
117
+ /adx-config show the effective config ("edit" menu / "set key=value")
118
+ Ctrl+Alt+A toggle plan/spec mode (spec mode exits; plan mode toggles)
119
+ ```
120
+
121
+ ### Auto mode (unattended pipeline)
122
+
123
+ ```
124
+ pi --adx-auto "Add a dark mode toggle: - toggle in settings, - persist to localStorage, - follow system preference"
125
+ ```
126
+
127
+ `--adx-auto` runs the whole pipeline without any approval:
128
+
129
+ 1. **Plan** — the planner refines the acceptance points you provided into
130
+ final criteria (no questions, no validation step) and adds them to the store.
131
+ 2. **Build** — plan mode exits automatically and the build-verify workflow
132
+ launches (user steps like the work-location and commit pickers are
133
+ auto-skipped — in auto mode the work is left uncommitted by default).
134
+ 3. **Verify → recap** — the verifier checks the criteria, then the summary
135
+ with "What to test" is printed. The code review step is skipped in auto
136
+ mode; use `/adx-run build-verify` for the full pipeline with review.
137
+
138
+ Manual mode (`/adx-plan` + `/adx-approve` / `/adx-run`) is unchanged.
139
+
140
+ When the planner finishes in interactive mode it calls `flow_plan_done`, which
141
+ shows a picker: **Build + verify (full pipeline)** / **Build (simple)** /
142
+ **Choose workspace** (current workspace or fresh worktree, then the pipeline) /
143
+ **Spec only — stop** (export the stored criteria as a spec document and stop —
144
+ no build is launched).
145
+
146
+ ### Spec mode (brainstorm / research, no code)
147
+
148
+ `/adx-spec` is the "specs without dev" mode: pure brainstorming, research, and
149
+ spec writing — **zero coding, zero verification, zero review**.
150
+
151
+ - **Read-only workspace** — same gating as plan mode (edit/write disabled,
152
+ read-only bash allowlist). The single exception is the `spec_write` tool,
153
+ the only write channel: it writes the spec markdown file and nothing else.
154
+ - **Iterative reasoning** — the spec agent asks you 1-3 focused questions per
155
+ turn (`ask_user`), explores the codebase read-only, and researches on the
156
+ web (`web_search`, `fetch_content`, `source_check`).
157
+ - **Output = a spec document** — a markdown file with *Context & goal*,
158
+ *Research notes*, *Decisions & assumptions*, and an *Acceptance criteria*
159
+ checklist. Written to `.pi/specs/<slug>.md` by default (auto-generated
160
+ timestamp slug); pass a path to `/adx-spec` (e.g. `/adx-spec SPEC.md`) to
161
+ choose the location. `spec_write` is called exactly once, at the end.
162
+ - **No hand-off** — after the spec is saved the session simply ends in normal
163
+ build mode; nothing is launched, verified, or reviewed. Exit spec mode early
164
+ with `/adx-approve` or Ctrl+Alt+A (no launch). Spec mode is persisted per
165
+ session and restored on resume (unfinished spec → continue, then call
166
+ `spec_write` once).
167
+
168
+ After a regular plan, the `flow_plan_done` picker's **Spec only — stop**
169
+ option does the same export: it composes the spec from the stored criteria,
170
+ saves it to `.pi/specs/<slug>.md`, exits plan mode, and launches nothing.
171
+
172
+ ### Typical session
173
+
174
+ 1. `/adx-plan`
175
+ 2. Ask for a feature: *"Add a dark mode toggle. Use flow_meta to define the
176
+ acceptance criteria."* — the planner explores (read-only) and adds
177
+ criteria. Review them in the widget (or edit with `flow_meta`).
178
+ 3. `/adx-run` (quick: `build → summarize`) or `/adx-run build-verify`
179
+ (full: `work_location → build → verify → code_review → finalize → summarize`).
180
+ The widget tracks step, iteration, and criterion status; the footer shows
181
+ a compact status line.
182
+ 4. When a criterion fails verification, the builder is nudged with the
183
+ verifier's findings and re-enters `build` until everything is `passed`.
184
+ 5. The reviewer's findings are dispositioned in `finalize`, then the summary
185
+ with "What to test" is printed.
186
+
187
+ State lives **per pi session** in `.pi/adx-flow/state/<sessionId>.json`
188
+ (criteria, findings, execution state, plan-mode and spec-mode flags) — each session has its
189
+ own plan, and resuming a session restores exactly that session's plan/run.
190
+ A new session starts fresh. On the first per-session load, an in-flight run
191
+ still in the legacy shared `.pi/adx-flow/state.json` (status ≠ done) is
192
+ adopted into the new session's file once, so pre-existing runs keep working.
193
+ Flow sub-agents (verifier / code reviewer) write to the *parent's* state file
194
+ (passed via the `ADX_FLOW_STATE` env var) so their `flow_meta` updates land
195
+ in the driving session's store. It survives pi restarts — `session_start`
196
+ restores the resumed session's running run (and its plan/spec mode if the session
197
+ stopped mid-plan or mid-spec), and `/adx-resume` continues a blocked one.
198
+
199
+ ## Configuration
200
+
201
+ The user config file is **created automatically on first run** with all
202
+ defaults, ready to edit:
203
+
204
+ - user: `~/.pi/agent/adx-workflow.json` (auto-created, all projects)
205
+ - project: `<cwd>/.pi/adx-workflow.json` (optional, overrides user per key)
206
+
207
+ All keys optional, unknown keys ignored, malformed file = defaults.
208
+
209
+ You can also manage it from inside pi:
210
+
211
+ ```
212
+ /adx-config show the effective config + file paths
213
+ /adx-config edit interactive menu: pick the file (user/project),
214
+ then pick a setting row to TOGGLE it (booleans flip,
215
+ defaultBuildWorkflow cycles) — repeat, "Done" exits
216
+ /adx-config set defaultPlanMode=true one-shot update (user file)
217
+ /adx-config set showWidget=false project # write to the project file
218
+ ```
219
+
220
+ `showWidget`, `skipReview` and `defaultBuildWorkflow` apply immediately;
221
+ `defaultPlanMode` / `autoMode` apply from the next session.
222
+
223
+ ```json
224
+ {
225
+ "defaultPlanMode": true,
226
+ "showWidget": true,
227
+ "autoMode": false,
228
+ "skipReview": false,
229
+ "defaultBuildWorkflow": "build"
230
+ }
231
+ ```
232
+
233
+ | Key | Default | Effect |
234
+ |---|---|---|
235
+ | `defaultPlanMode` | `false` | Start every pi session in plan mode (no active run to restore) |
236
+ | `showWidget` | `true` | `false` hides the bottom flow/criteria widget entirely |
237
+ | `autoMode` | `false` | Persistent `--adx-auto`: unattended plan → build → verify → recap (the CLI flag still wins when passed) |
238
+ | `skipReview` | `false` | Default `skip_review=true` for the build-verify pipeline (picker + `/adx-run build-verify`); an explicit `skip_review=` in the command args wins |
239
+ | `defaultBuildWorkflow` | `"build"` | Which workflow `/adx-run` launches: `"build"` (simple) or `"build-verify"` (full) |
240
+
241
+ ## Never-stop (auto-continue)
242
+
243
+ The workflow never parks itself on you:
244
+
245
+ - **Agent steps**: when a run ends on an active agent step without
246
+ `flow_step_done` (context pressure, stream stop, the model pausing
247
+ mid-reflection), the `agent_before_settle` hook appends a continuation
248
+ message — carrying the agent's **resume note** (written with `flow_meta`,
249
+ key `resume`), the criteria status, and the step reason — and requests one
250
+ more provider request. You never press "continue" (auto-continue /
251
+ `CONTINUE_PROMPT` behavior).
252
+ - **Context overflow**: pi's built-in auto-compaction keeps the context
253
+ usable between turns; the continuation message is what re-anchors the
254
+ agent after a compaction.
255
+ - **Sub-agents**: if an isolated verifier/reviewer child stops before
256
+ finishing (context pressure, timeout) and its run id is known, the executor
257
+ revives it once by re-spawning the persisted child session
258
+ (`pi -p --session <runId>` + "continue from where you stopped").
259
+ - **Safety**: 8 consecutive auto-continues on one step → the run blocks
260
+ (`/adx-resume`); `maxIterations` caps the whole run. Explicit user aborts
261
+ (Escape) are respected — `/adx-resume` continues from the persisted step.
262
+ - **Boot**: after a pi restart, `session_start` re-enters the current step of
263
+ any running run (boot auto-continuation).
264
+
265
+ ## Tools
266
+
267
+ | Tool | Purpose |
268
+ | --- | --- |
269
+ | `flow_meta` | Shared workflow metadata store: `criteria`, `todos`, `review_findings`, `resume` (auto-continue notes) and `progress` (live display feed). Writes are atomic (per-process write chain + cross-process file lock — parent and `pi -p` children never lose updates); multi-item writes: `add_batch` (descriptions) / `update_batch` (items) |
270
+ | `flow_step_done` | Ends the current workflow step; the executor evaluates transitions and injects the next prompt (or a nudge) |
271
+ | `flow_plan_done` | Signals that planning is complete and hands off to the build pipeline (auto-launch in `--adx-auto`, picker in interactive mode — including **Spec only — stop**, which exports the criteria as a spec file and launches nothing) |
272
+ | `ask_user` | Structured question (choice / confirm / text) that pauses the turn for a user answer — plan/spec-mode clarification |
273
+ | `spec_write` | Writes the spec markdown document (spec mode only; `defaultActive: false`, so it is inactive in plan/build modes) — the single write channel while the workspace stays read-only |
274
+
275
+ ## Sub-agents
276
+
277
+ Flow children are spawned **in-house** as isolated `pi -p` child processes
278
+ (`src/subagent.ts`), not through pi-subagents:
279
+
280
+ ```
281
+ pi -p --mode json --extension <adx-workflow> --no-extensions --no-mcp --no-skills
282
+ --tools "read,bash,flow_meta" --session-dir <cwd>/.pi/adx-flow/sessions
283
+ --session-id <runId> (fresh run) | --session <runId> (resume)
284
+ --append-system-prompt <agent role>
285
+ "<task>"
286
+ ```
287
+
288
+ | Agent | Role |
289
+ | --- | --- |
290
+ | `adx-verifier` | Independent criterion verification; sets `passed`/`failed` via `flow_meta` |
291
+ | `adx-code-reviewer` | Reviews the git diff; manages `review_findings` via `flow_meta` |
292
+
293
+ - **Fresh session per run** (session files in `.pi/adx-flow/sessions/`) → no
294
+ retained in-process agent state → the "Agent is already processing" failure
295
+ class (stuck retained child blocking all subsequent spawns) is
296
+ structurally impossible.
297
+ - **Child mode** (`ADX_CHILD=1`): the child loads the extension with only the
298
+ `flow_meta` tool registered — no executor/commands/widgets, so the child can
299
+ update the shared store but never advance the workflow itself.
300
+ - **Bounded failures**: a 15-minute timeout kills the child process group;
301
+ provider hangs are recovered by the never-stop resume (persisted session).
302
+ - **Result contract**: the child updates `flow_meta` (criteria /
303
+ review_findings) and writes a report to `.pi/adx-flow/reports/<agent>.md`.
304
+ - **Model**: children use the user's default model; set `ADX_FLOW_MODEL`
305
+ (e.g. `litellm/qwen3.8-27b`) to pin a cheaper model for flow children, or a
306
+ per-step `"model"` field on any `sub_agent` step in a workflow file
307
+ (takes precedence over `ADX_FLOW_MODEL`) — e.g. a fast model for
308
+ verify/review on small projects.
309
+ - **Env overrides**: `ADX_PI_BIN` (pi CLI path), `ADX_EXTENSION_PATH`
310
+ (extension entry for the child).
311
+
312
+ ### Performance: no redundant verification
313
+
314
+ The executor keeps verification cheap in three ways:
315
+
316
+ - **Re-run short-circuit** — after a successful verify pass the executor
317
+ records a content hash of the project files (`.pi/`, `node_modules/`,
318
+ `.git/`, build dirs excluded). On re-entry to the verify step, if the hash
319
+ is unchanged AND the step's metadata gate is now met (e.g. the store
320
+ caught up after a lost write), the expensive verifier pass is skipped and
321
+ the previous report is reused — a small project no longer pays 3-4 full
322
+ verifier passes to re-converge on the same verdict.
323
+ - **Proportional effort** — verify prompts get `{{projectFileCount}}` /
324
+ `{{projectLines}}` template variables and instruct the verifier to scale
325
+ the effort to the project size (small project: focused read + one smoke
326
+ run, not an exhaustive test suite).
327
+ - **Atomic store** — the state file is protected by a cross-process lock
328
+ (parent + children) and `flow_meta` mutations are atomic read-modify-writes;
329
+ the verifier records all criterion verdicts in a single `update_batch` call,
330
+ so "the verifier said PASS but the store disagrees" re-loops can't happen.
331
+
332
+ ## Workflows
333
+
334
+ Workflow files are plain JSON state machines: `workflows/*.workflow.json`
335
+ (bundled), overridable per project in `.pi/adx-workflows/` (highest
336
+ precedence) and per user in `~/.pi/agent/workflows/`.
337
+
338
+ Four workflows are bundled:
339
+
340
+ - `build` — **simple**: `work_location → build → commit? → summarize`. No
341
+ automated verification, no code review; the builder self-checks before
342
+ marking criteria complete. Launched by `/adx-run`.
343
+ - `build-verify` — **the full pipeline** (launched with `/adx-run build-verify`):
344
+ `work_location → build → verify → code_review → finalize → commit? →
345
+ summarize`.
346
+
347
+ Both build pipelines end with an optional **commit & push** phase (`commit?`
348
+ above), controlled by the `commit` launch parameter: `commit=true` runs the
349
+ commit & push step automatically (the "Commit changes?" picker is skipped),
350
+ `commit=false` skips it, and without the parameter an interactive
351
+ "Commit changes?" picker is shown (auto mode skips it — no commit by
352
+ default). The step stages only the session's files (never `git add -A`),
353
+ commits with a clear message, and pushes (rebase onto origin if rejected).
354
+ An optional `message` launch parameter sets the exact commit message
355
+ verbatim (without it, the agent derives one from the staged diff).
356
+ In a **fresh worktree** (the `worklocation=new` path) it commits on the
357
+ `adx/<slug>` branch and pushes that branch only — `git push -u origin
358
+ adx/<slug>` — with **no merge into the base branch**: the merge stays manual
359
+ (open a PR or `git merge adx/<slug>` later), and the worktree + branch are
360
+ kept in place for follow-up work.
361
+ - `pr-review` — PR review + fixes + squash-merge (requires `gh`), launched
362
+ with `/adx-run pr-review pr_number=123`.
363
+ - `commit` — **commit & push**: `check_status → stage → commit → push →
364
+ summarize`. Stages only the session's files (never `git add -A`), commits
365
+ with a clear message, and rebases onto origin if the push is rejected.
366
+ Launched with `/adx-run commit` (optional `message="..."` param to set
367
+ the commit message explicitly).
368
+
369
+ ### Authoring reference (short)
370
+
371
+ - **Steps**: `agent` (in-session LLM turn; must end with `flow_step_done`),
372
+ `sub_agent` (isolated child by `subAgentType`), `shell` (branch on exit
373
+ code), `user` (pause; buttons derived from `step_result` transitions + a
374
+ `Continue` for the `always` transition).
375
+ - **Transitions**: ordered, first match wins. Conditions: `step_result`,
376
+ `metadata_all_match`, `metadata_all_in` (empty list ⇒ true), `always`.
377
+ `goto` targets a step id, `$done`, or `$blocked`.
378
+ - **Templates**: `{{workdir}}`, `{{reason}}`, `{{criteriaCount}}`,
379
+ `{{pendingCount}}`, `{{criteriaList}}`, `{{modifiedFiles}}`,
380
+ `{{stepOutput.<key>}}` (incl. `content`, `stdout`, `stderr`, `exitCode`),
381
+ `{{params}}` / individual launch parameters.
382
+ - **Shell trust boundary**: `shell` step commands run via `sh -c`, and
383
+ `{{params.*}}` / `{{workdir}}` are interpolated **verbatim (unquoted)**.
384
+ Launch parameters are trusted shell input: a value like
385
+ `message="a; rm -rf ~"` is executed as shell code, and word-splitting
386
+ applies (a param `args="a b"` becomes two words). Quote values yourself when
387
+ composing commands from params. This is a deliberate trust assumption,
388
+ not a bug — workflow JSON and launch args are authored by the user running
389
+ the workflow.
390
+ - **Semantics**: `settings.maxIterations` caps the whole run (default 50);
391
+ no matching transition ⇒ `$blocked`; agent steps re-enter with
392
+ `nudgePrompt` when their transition condition is unmet; state is persisted
393
+ on every transition.
394
+
395
+ Full semantics: this extension is a self-contained declarative workflow
396
+ engine — steps, ordered transitions, metadata conditions, nudge re-entry,
397
+ `maxIterations` safety cap, `$blocked` handling, persistence and resume.
398
+
399
+ ## Development
400
+
401
+ ```sh
402
+ git clone https://github.com/mossaab/pi-adx-workflow.git
403
+ cd pi-adx-workflow
404
+ npm install # dev dependencies (typescript, @types/node, jiti, typebox,
405
+ # @earendil-works/pi-ai + pi-coding-agent for the test scripts)
406
+ npm run setup-dev # link host-provided packages (typebox, @earendil-works/*)
407
+ # from your pi install into node_modules
408
+
409
+ npm run smoke # jiti-load the extension with a fake ExtensionAPI
410
+ npm run e2e # drive the full build-verify pipeline with fake pi + fake sub-agents
411
+ npm run typecheck # tsc --noEmit (strict)
412
+ ```
413
+
414
+ `npm run setup-dev` replicates pi's runtime resolution: it symlinks the
415
+ host-provided packages (`typebox`, `@earendil-works/*`) from your pi install
416
+ into the local `node_modules/`, so the dev commands work from a fresh clone.
417
+ Re-run it if your pi install location changes (or use `ADX_FLOW_JITI` below).
418
+
419
+ The test scripts load TypeScript the same way pi does (via jiti). They find
420
+ jiti from your pi install — `~/.pi/agent/install/releases/<newest>/node_modules/jiti` —
421
+ with no hard-coded paths. Override the lookup with
422
+ `ADX_FLOW_JITI=/path/to/node_modules/jiti` if your layout is unusual.
423
+
424
+ Extension development loop: symlink the repo into
425
+ `~/.pi/agent/extensions/` (see [Install](#development-install-symlink)), edit
426
+ `src/*.ts`, and restart pi (or `/reload`) — jiti loads the TypeScript
427
+ directly, no build step.
428
+
429
+ ### CI/CD
430
+
431
+ - **CI** (`.github/workflows/ci.yml`): on every push to `main` and on pull
432
+ requests, GitHub Actions runs `npm ci` → `typecheck` → `smoke` → `e2e` →
433
+ `e2e:lock` on Node 22. The test scripts' jiti lookup is pointed at the
434
+ devDependency copy via `ADX_FLOW_JITI` (runners have no pi install).
435
+ - **Publish** (`.github/workflows/npm-publish.yml`): publishing a
436
+ [GitHub release](https://github.com/mossaab/pi-adx-workflow/releases)
437
+ (or the manual `workflow_dispatch`) runs the typecheck + smoke checks, then
438
+ `npm publish --provenance`. Configure the repo secret **`NPM_TOKEN`** with
439
+ an npm automation token (fine-grained or classic with publish access);
440
+ `--provenance` additionally requires the GitHub OIDC token, which the
441
+ workflow requests via the `id-token: write` permission.
442
+
443
+ ## Contributing
444
+
445
+ Contributions are welcome — fork, branch, and open a pull request.
446
+
447
+ - **TypeScript, strict mode, no build step** — the extension ships as
448
+ TypeScript loaded by pi's jiti; keep it that way.
449
+ - **Workflow engine changes**: extend `scripts/e2e-executor.mjs` — it drives
450
+ the whole pipeline (nudge loops, verify/review sub-agents, resume,
451
+ maxIterations blocking) against a fake pi, so it catches regressions fast.
452
+ - **New workflows**: plain JSON state machines in `workflows/` (schema in
453
+ `src/types.ts`); see the [authoring reference](#authoring-reference-short).
454
+ - **Docs**: README sections mirror the feature set — update both together.
455
+
456
+ ## Troubleshooting
457
+
458
+ - **`pi` CLI not found** — point the extension at it: `export ADX_PI_BIN=/path/to/pi`
459
+ (or install pi-coding-agent so `~/.pi/agent/bin/pi` exists).
460
+ - **Flow children using a model you don't want** — pin one:
461
+ `export ADX_FLOW_MODEL=<provider/model>`.
462
+ - **Config not taking effect** — run `/adx-config` to see the effective
463
+ config and which files were read. Note: `defaultPlanMode` / `autoMode`
464
+ apply from the *next* session; the rest apply immediately.
465
+ - **"Agent is already processing"** — structurally impossible here: flow
466
+ children are isolated `pi -p` processes with fresh sessions, so no stuck
467
+ retained child can block later spawns. A hung child is killed by the
468
+ 15-minute timeout and revived by the never-stop resume.
469
+ - **Package install fails at startup** (e.g. offline) — pi warns, skips the
470
+ package, and retries on the next start or `/reload`; `pi update --extensions`
471
+ reports the failure explicitly.
472
+ - **Dev scripts can't find jiti** — set `ADX_FLOW_JITI` to your jiti install
473
+ path (see [Development](#development)).
474
+
475
+ ## Project layout
476
+
477
+ ```
478
+ src/
479
+ ├── index.ts # entry: tools, commands, events, wiring
480
+ ├── types.ts # workflow schema types
481
+ ├── store.ts # flow_meta store + execution state (file-backed)
482
+ ├── templates.ts # template variable resolution
483
+ ├── modes.ts # plan/build tool gating, bash allowlist, prompt sections
484
+ ├── subagent.ts # in-house child-process propagation (pi -p spawn/resume)
485
+ ├── executor.ts # the workflow state machine
486
+ ├── tools.ts # flow_meta + flow_step_done tool definitions
487
+ ├── widgets.ts # TUI widget (criteria checklist, step, findings)
488
+ └── workflows.ts # workflow loading (project > user > bundled)
489
+ workflows/
490
+ ├── build.workflow.json
491
+ ├── build-verify.workflow.json
492
+ ├── commit.workflow.json
493
+ └── pr-review.workflow.json
494
+ scripts/
495
+ ├── find-jiti.mjs # locate jiti in your pi install (used by the dev scripts)
496
+ ├── setup-dev.mjs # npm run setup-dev (link host-provided packages)
497
+ ├── smoke-load.mjs # npm run smoke
498
+ └── e2e-executor.mjs # npm run e2e
499
+ ```
500
+
501
+ ## License
502
+
503
+ [MIT](./LICENSE) © mossaab
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "pi-adx-workflow",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Declarative plan → build → verify → review workflow for pi-coding-agent, with in-house isolated sub-agents and never-stop auto-continue.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "mossaab",
8
+ "homepage": "https://github.com/mossaab/pi-adx-workflow",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/mossaab/pi-adx-workflow.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/mossaab/pi-adx-workflow/issues"
15
+ },
16
+ "keywords": [
17
+ "pi",
18
+ "pi-coding-agent",
19
+ "pi-extension",
20
+ "pi-package",
21
+ "pi-adx-workflow",
22
+ "workflow",
23
+ "subagent",
24
+ "acceptance-criteria",
25
+ "planning",
26
+ "verification",
27
+ "code-review"
28
+ ],
29
+ "files": [
30
+ "src",
31
+ "workflows",
32
+ "README.md"
33
+ ],
34
+ "scripts": {
35
+ "setup-dev": "node scripts/setup-dev.mjs",
36
+ "smoke": "node scripts/smoke-load.mjs",
37
+ "e2e": "node scripts/e2e-executor.mjs",
38
+ "e2e:lock": "node scripts/e2e-lock.mjs",
39
+ "typecheck": "tsc --noEmit"
40
+ },
41
+ "pi": {
42
+ "extensions": [
43
+ "./src/index.ts"
44
+ ]
45
+ },
46
+ "peerDependencies": {
47
+ "@earendil-works/pi-ai": "*",
48
+ "@earendil-works/pi-coding-agent": "*",
49
+ "typebox": "*"
50
+ },
51
+ "devDependencies": {
52
+ "@earendil-works/pi-ai": "^1.5.2",
53
+ "@earendil-works/pi-coding-agent": "^1.5.2",
54
+ "@types/node": "^26.6.6",
55
+ "jiti": "^2.7.0",
56
+ "typebox": "^1.4.6",
57
+ "typescript": "^7.0.2"
58
+ }
59
+ }