@gtrabanco/pi-agentic-workflow 0.13.2 → 0.14.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.
Files changed (95) hide show
  1. package/README.md +3 -9
  2. package/dist/routing/catalogue.d.ts +1 -1
  3. package/dist/routing/catalogue.js +1 -1
  4. package/dist/runtime.d.ts +45 -0
  5. package/dist/runtime.js +62 -0
  6. package/package.json +10 -8
  7. package/skills/audit-docs/SKILL.md +6 -5
  8. package/skills/audit-pr/SKILL.md +1 -1
  9. package/skills/audit-pr/references/PORTABILITY.md +1 -1
  10. package/skills/execute-phase/SKILL.md +207 -116
  11. package/skills/execute-phase/references/DESCOPE.md +22 -18
  12. package/skills/execute-phase/references/EXECUTION_CONTRACT.md +69 -77
  13. package/skills/execute-phase/references/FOLDING.md +34 -47
  14. package/skills/execute-phase/references/PREFLIGHT.md +103 -114
  15. package/skills/execute-phase/references/PRE_EXECUTION_GATE.md +53 -60
  16. package/skills/init-workspace/SKILL.md +52 -16
  17. package/skills/init-workspace/references/BOOTSTRAP_DISCOVERY.md +6 -6
  18. package/skills/init-workspace/references/BOOTSTRAP_WRITE.md +17 -10
  19. package/skills/init-workspace/references/PORTABILITY.md +1 -1
  20. package/skills/init-workspace/references/UPGRADE.md +50 -15
  21. package/skills/log-session/SKILL.md +4 -3
  22. package/skills/orchestration-envelope/references/TURN_CONTRACT.md +1 -1
  23. package/skills/pre-execution-review/references/LEDGERS.md +39 -39
  24. package/skills/pre-execution-review/references/POLICY.md +1 -0
  25. package/skills/product-audit/SKILL.md +4 -4
  26. package/skills/product-audit/references/AUDIT_PROCESS.md +3 -3
  27. package/skills/review-change/SKILL.md +1 -1
  28. package/skills/review-change/references/PORTABILITY.md +1 -1
  29. package/skills/unit-lane/SKILL.md +154 -0
  30. package/skills/unit-lane/references/DESIGN.md +35 -0
  31. package/skills/unit-lane/references/DOCS.md +36 -0
  32. package/skills/unit-lane/references/EVIDENCE.md +34 -0
  33. package/skills/unit-lane/references/IMPLEMENT.md +45 -0
  34. package/skills/unit-lane/references/PLAN.md +38 -0
  35. package/skills/unit-lane/references/RELEASE.md +45 -0
  36. package/skills/unit-lane/references/RESEARCH.md +37 -0
  37. package/skills/unit-lane/references/REVIEW.md +45 -0
  38. package/skills/unit-lane/references/STEPS.md +23 -0
  39. package/skills/unit-lane/references/TESTS.md +32 -0
  40. package/skills/workflow-status/references/ENVELOPE_FIELDS.md +5 -6
  41. package/skills/workflow-status/references/SENSOR_CORE.md +16 -20
  42. package/skills/workflow-status/references/SENSOR_SIGNALS.md +5 -7
  43. package/skills/design-feature/SKILL.md +0 -231
  44. package/skills/design-feature/references/INTERVIEW.md +0 -74
  45. package/skills/design-feature/references/PORTABILITY.md +0 -15
  46. package/skills/design-feature/references/REPAIR.md +0 -88
  47. package/skills/design-feature/references/UPSERT_EXAMPLE.md +0 -8
  48. package/skills/design-feature/references/WRITE_AND_UPSERT.md +0 -115
  49. package/skills/evidence-grounding/SKILL.md +0 -174
  50. package/skills/evidence-grounding/references/DELEGATION.md +0 -131
  51. package/skills/evidence-grounding/references/READINESS.md +0 -130
  52. package/skills/evidence-grounding/references/ROWS.md +0 -93
  53. package/skills/execute-phase/references/BATCH_AND_PORTABILITY.md +0 -57
  54. package/skills/execute-phase/references/CLOSEOUT.md +0 -77
  55. package/skills/execute-phase/references/HANDOFF.md +0 -21
  56. package/skills/execute-phase/references/OPPORTUNISTIC_FINDING.md +0 -45
  57. package/skills/execute-phase/references/UNIT_LOOP.md +0 -88
  58. package/skills/execute-phase/references/WORKFLOWS_FEATURE.md +0 -37
  59. package/skills/execute-phase/references/WORKFLOWS_FIX.md +0 -43
  60. package/skills/execute-phase/references/WORKFLOWS_LEGACY.md +0 -26
  61. package/skills/execute-phase/references/WORKFLOWS_SMALL_PHASED.md +0 -38
  62. package/skills/generate-docs/SKILL.md +0 -145
  63. package/skills/generate-docs/references/ADAPTERS.md +0 -15
  64. package/skills/generate-docs/references/ADAPTER_DISCOVERY.md +0 -33
  65. package/skills/generate-docs/references/GENERATION_PROCESS.md +0 -90
  66. package/skills/implementation-discovery/SKILL.md +0 -209
  67. package/skills/plan-feature/SKILL.md +0 -208
  68. package/skills/plan-feature/references/ROUTING.md +0 -155
  69. package/skills/plan-feature-from-issue/SKILL.md +0 -162
  70. package/skills/plan-feature-scaffold/SKILL.md +0 -112
  71. package/skills/plan-feature-scaffold/references/SCAFFOLD_PROCESS.md +0 -122
  72. package/skills/plan-fix/SKILL.md +0 -161
  73. package/skills/plan-fix/references/PLANNING_PROCESS.md +0 -148
  74. package/skills/plan-fix/references/SPEC_CONTRACT.md +0 -22
  75. package/skills/planning-preflight/SKILL.md +0 -130
  76. package/skills/replan-findings/SKILL.md +0 -131
  77. package/skills/replan-findings/references/PHASE_APPEND.md +0 -89
  78. package/skills/review-plan/SKILL.md +0 -154
  79. package/skills/review-plan/references/CHECKS.md +0 -111
  80. package/skills/review-plan/references/ENG-CHECKS.md +0 -30
  81. package/skills/review-plan/references/OUTPUT.md +0 -166
  82. package/skills/review-spec/SKILL.md +0 -145
  83. package/skills/review-spec/references/CHECKS.md +0 -108
  84. package/skills/review-spec/references/OUTPUT.md +0 -160
  85. package/skills/ship-roadmap/SKILL.md +0 -120
  86. package/skills/ship-roadmap/references/ADVANCE.md +0 -117
  87. package/skills/ship-roadmap/references/AUDIT_AND_MERGE.md +0 -64
  88. package/skills/ship-roadmap/references/CLOSEOUT_AND_LOG.md +0 -27
  89. package/skills/ship-roadmap/references/FOUNDING.md +0 -101
  90. package/skills/ship-roadmap/references/GUARDRAILS.md +0 -56
  91. package/skills/ship-roadmap/references/MODEL_ROUTING.md +0 -16
  92. package/skills/ship-roadmap/references/PORTABILITY.md +0 -34
  93. package/skills/ship-roadmap/references/RECOVERY_AND_SELECTION.md +0 -94
  94. package/skills/ship-roadmap/references/STOP_CONDITIONS.md +0 -9
  95. package/skills/ship-roadmap/references/TERMINAL_REPORT.md +0 -34
package/README.md CHANGED
@@ -7,8 +7,8 @@ that gives your session back afterwards.
7
7
 
8
8
  - **Canonical skills, unchanged.** The package ships the same `SKILL.md` files as
9
9
  this repository, byte for byte — no Pi-specific fork to drift.
10
- - **Friendly commands.** Type `/plan-feature --next`, not
11
- `/skill:plan-feature --next`.
10
+ - **Friendly commands.** Type `/unit-lane <slug>`, not
11
+ `/skill:unit-lane <slug>`.
12
12
  - **Routing you can forget about.** Nothing is configured by default: every
13
13
  command runs on the model you already have.
14
14
 
@@ -36,21 +36,15 @@ their own — they are composed by the ones above:
36
36
  | --- | --- |
37
37
  | `/audit-docs` | Check that docs, roadmap, code and the fix index agree. |
38
38
  | `/audit-pr` | The merge gate: is this PR ready? |
39
- | `/design-feature` | Turn a raw idea into a designed SPEC. |
40
39
  | `/discover-repository-state` | Freeze verified repository facts. |
41
40
  | `/execute-phase` | Implement the remaining phases of a planned unit. |
42
41
  | `/fold-findings` | Repair persisted fix-now findings. |
43
- | `/generate-docs` | Generate incremental, diff-driven developer guides. |
44
42
  | `/init-workspace` | Adapt the workflow scaffold to a repository. |
45
43
  | `/log-session` | Append a structured session entry to `docs/LOGS.md`. |
46
- | `/plan-feature` | Route designed work into planning and the roadmap. |
47
- | `/plan-fix` | Draft a phased fix SPEC from one or more issues. |
48
44
  | `/product-audit` | Audit the product surface, not just the diff. |
49
45
  | `/resolve-repository-state` | Resolve a contradiction in frozen facts. |
50
46
  | `/review-change` | Review a change with the applicable axes. |
51
- | `/review-plan` | Review a frozen plan in a clean context. |
52
- | `/review-spec` | Review a designed SPEC in a clean context. |
53
- | `/ship-roadmap` | Find or continue a roadmap, one stage per run. |
47
+ | `/unit-lane` | Run the adaptive lane on a unit: triage, steps, evidence, release. |
54
48
  | `/triage-issue` | Verify an issue or finding against current code. |
55
49
  | `/workflow-status` | Read-only state of the repository and roadmap. |
56
50
 
@@ -10,7 +10,7 @@ export interface SkillMeta {
10
10
  * Minimal frontmatter reader: `name`, `description`, `user-invocable` only.
11
11
  *
12
12
  * `user-invocable` must say `true` to count: this repository's own rule
13
- * (CLAUDE.md — the key "REQUIRED for it to appear in the agent's /command menu")
13
+ * (AGENTS.md — the key "REQUIRED for it to appear in the agent's /command menu")
14
14
  * makes absence mean internal, and `scripts/bundle-skills.mjs` reads it the same
15
15
  * way. The two scanners agree because the rule is stated once per scanner and
16
16
  * pinned by `test/alias-coverage.test.mjs`, not because either default is safe.
@@ -16,7 +16,7 @@ const SKILL_FILE = "SKILL.md";
16
16
  * Minimal frontmatter reader: `name`, `description`, `user-invocable` only.
17
17
  *
18
18
  * `user-invocable` must say `true` to count: this repository's own rule
19
- * (CLAUDE.md — the key "REQUIRED for it to appear in the agent's /command menu")
19
+ * (AGENTS.md — the key "REQUIRED for it to appear in the agent's /command menu")
20
20
  * makes absence mean internal, and `scripts/bundle-skills.mjs` reads it the same
21
21
  * way. The two scanners agree because the rule is stated once per scanner and
22
22
  * pinned by `test/alias-coverage.test.mjs`, not because either default is safe.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Runtime resolver — determines what runtime pi itself runs under so
3
+ * spawned children inherit the same choice.
4
+ *
5
+ * The current process is always pi (this module lives inside the package
6
+ * that ships with pi). Whichever runtime launched pi decides what
7
+ * children get:
8
+ * - pi installed via `bun add -g` → bun
9
+ * - pi installed via `npm install -g` → node
10
+ *
11
+ * `AGENTIC_WORKFLOW_RUNTIME` env override is the highest priority: it
12
+ * always wins, letting the operator force a specific runtime regardless
13
+ * of how pi was installed.
14
+ *
15
+ * Exported from the package's public entry (compiled from src/ → dist/).
16
+ * Intended call site: wherever the extension spawns a `.mjs` script,
17
+ * use `runtimeBin()` + `runtimeEnv()` instead of a hardcoded `"node"`
18
+ * or `"bun"`.
19
+ */
20
+ /**
21
+ * Detect the runtime of the *current process* (which is pi).
22
+ * Returns `"bun"` when `globalThis.Bun` exists, or when
23
+ * `process.execPath` contains the substring `"bun"`; otherwise `"node"`.
24
+ */
25
+ export declare function detectRuntime(): "bun" | "node";
26
+ /**
27
+ * Return an environment object for spawned children that ensures
28
+ * `AGENTIC_WORKFLOW_RUNTIME` is set.
29
+ *
30
+ * Priority:
31
+ * 1. If the caller passes an explicit value, use it (user override).
32
+ * 2. If `AGENTIC_WORKFLOW_RUNTIME` is already in `process.env`, use it.
33
+ * 3. Fall back to the detected runtime.
34
+ *
35
+ * Returns `{ AGENTIC_WORKFLOW_RUNTIME: "bun" | "node" }`.
36
+ */
37
+ export declare function runtimeEnv(overrides?: {
38
+ AGENTIC_WORKFLOW_RUNTIME?: "bun" | "node";
39
+ }): Record<string, string>;
40
+ /**
41
+ * Return the executable name to spawn for running a script.
42
+ * Returns `"bun"` or `"node"` based on the detected runtime,
43
+ * respecting the `AGENTIC_WORKFLOW_RUNTIME` env override.
44
+ */
45
+ export declare function runtimeBin(): "bun" | "node";
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Runtime resolver — determines what runtime pi itself runs under so
3
+ * spawned children inherit the same choice.
4
+ *
5
+ * The current process is always pi (this module lives inside the package
6
+ * that ships with pi). Whichever runtime launched pi decides what
7
+ * children get:
8
+ * - pi installed via `bun add -g` → bun
9
+ * - pi installed via `npm install -g` → node
10
+ *
11
+ * `AGENTIC_WORKFLOW_RUNTIME` env override is the highest priority: it
12
+ * always wins, letting the operator force a specific runtime regardless
13
+ * of how pi was installed.
14
+ *
15
+ * Exported from the package's public entry (compiled from src/ → dist/).
16
+ * Intended call site: wherever the extension spawns a `.mjs` script,
17
+ * use `runtimeBin()` + `runtimeEnv()` instead of a hardcoded `"node"`
18
+ * or `"bun"`.
19
+ */
20
+ /**
21
+ * Detect the runtime of the *current process* (which is pi).
22
+ * Returns `"bun"` when `globalThis.Bun` exists, or when
23
+ * `process.execPath` contains the substring `"bun"`; otherwise `"node"`.
24
+ */
25
+ export function detectRuntime() {
26
+ if (globalThis.Bun !== undefined) {
27
+ return "bun";
28
+ }
29
+ const execPath = process.execPath ?? "";
30
+ if (execPath.includes("bun")) {
31
+ return "bun";
32
+ }
33
+ return "node";
34
+ }
35
+ /**
36
+ * Return an environment object for spawned children that ensures
37
+ * `AGENTIC_WORKFLOW_RUNTIME` is set.
38
+ *
39
+ * Priority:
40
+ * 1. If the caller passes an explicit value, use it (user override).
41
+ * 2. If `AGENTIC_WORKFLOW_RUNTIME` is already in `process.env`, use it.
42
+ * 3. Fall back to the detected runtime.
43
+ *
44
+ * Returns `{ AGENTIC_WORKFLOW_RUNTIME: "bun" | "node" }`.
45
+ */
46
+ export function runtimeEnv(overrides) {
47
+ const value = overrides?.AGENTIC_WORKFLOW_RUNTIME ??
48
+ process.env.AGENTIC_WORKFLOW_RUNTIME ??
49
+ detectRuntime();
50
+ return { AGENTIC_WORKFLOW_RUNTIME: value };
51
+ }
52
+ /**
53
+ * Return the executable name to spawn for running a script.
54
+ * Returns `"bun"` or `"node"` based on the detected runtime,
55
+ * respecting the `AGENTIC_WORKFLOW_RUNTIME` env override.
56
+ */
57
+ export function runtimeBin() {
58
+ const env = process.env.AGENTIC_WORKFLOW_RUNTIME;
59
+ if (env === "bun" || env === "node")
60
+ return env;
61
+ return detectRuntime();
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtrabanco/pi-agentic-workflow",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "description": "Pi package: canonical agentic-workflow skills, friendly slash commands, and per-command model routing.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -44,18 +44,20 @@
44
44
  "scripts": {
45
45
  "build": "tsc",
46
46
  "bundle:skills": "bun scripts/bundle-skills.mjs",
47
- "bundle:skills:check": "bun scripts/bundle-skills.mjs --check",
48
- "test": "tsc && bun test test/*.test.mjs",
49
- "test:node": "tsc && node --test test/*.test.mjs",
50
- "prepublishOnly": "bun run build && bun run test",
51
- "mutation": "bun scripts/mutation-check.mjs",
52
- "prepare": "bun run build"
47
+ "clean:skills": "bun scripts/bundle-skills.mjs --clean",
48
+ "test": "bun run bundle:skills && tsc && bun test test/*.test.mjs",
49
+ "test:node": "bun run bundle:skills && tsc && node --test test/*.test.mjs",
50
+ "prepublishOnly": "bun run build && bun run bundle:skills && bun run test",
51
+ "postpack": "bun run clean:skills",
52
+ "mutation": "bun run bundle:skills && bun scripts/mutation-check.mjs",
53
+ "prepare": "bun run build && bun run bundle:skills"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "@earendil-works/pi-coding-agent": ">=0.87.0"
56
57
  },
57
58
  "dependencies": {
58
- "@earendil-works/pi-tui": "0.87.0"
59
+ "@earendil-works/pi-tui": "0.87.0",
60
+ "@gtrabanco/agentic-workflow": "0.1.1"
59
61
  },
60
62
  "devDependencies": {
61
63
  "@types/node": "24.13.3",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: audit-docs
3
3
  user-invocable: true
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  argument-hint: "[--fix]"
6
6
  author: "Gabriel Trabanco <1969593+gtrabanco@users.noreply.github.com>"
7
7
  license: MIT
@@ -11,7 +11,8 @@ description: >
11
11
  entries already merged/closed, broken documentation-map links, dependency
12
12
  cycles, artifacts in the wrong language, naming-convention violations — and
13
13
  reports them ranked by severity, fixing only low-risk items on request.
14
- On Claude Code and want hand-tuned per-skill model/effort tiers? Install the `#claude` branch instead (`npx skills add gtrabanco/agentic-workflow#claude`) — see the README. This branch is model-agnostic: the skill inherits whatever model and effort your agent session is already using.
14
+ Model-agnostic: the skill inherits whatever model and effort your agent
15
+ session is already using.
15
16
  Triggers: "check doc consistency", "are the docs in sync", "audit the docs",
16
17
  "doc coherence review", "did the docs drift", "validate the roadmap".
17
18
  ---
@@ -93,12 +94,12 @@ run the command shown, don't infer.
93
94
  feature/fix-scoped changes committed directly without a PR: HIGH.
94
95
  13. **Generated-docs provenance (only when the documentation map declares a
95
96
  `Docs site` block; otherwise state n/a).** Scan the declared content dir
96
- for pages carrying `generated-by: agentic-workflow/generate-docs`. For
97
+ for orphan pages
97
98
  each: (a) its `source-unit` exists in the roadmap or fix index — no match
98
99
  is an **orphan** (low: propose deletion or re-attribution); (b) the
99
100
  unit's PR merged **after** the page's `updated` date with commits touching
100
101
  the page's subject paths — that page is **stale** (LOW: propose
101
- `/generate-docs <unit>` to refresh). Cite page path + unit per finding.
102
+ ). Cite page path + unit per finding.
102
103
  14. **Commit format & dependency discipline.** Sample the unit branches'
103
104
  commits: `<type>(<scope>): <summary>` conventional format (violations:
104
105
  LOW). Every `in-progress`/`done` row's `Depends on:` closure was merged —
@@ -149,7 +150,7 @@ enables:
149
150
  - **No slash-command menu** — where this skill says `/<skill>`, open that
150
151
  skill's `SKILL.md` (wherever your agent installed the skills) and follow it
151
152
  literally, in a fresh conversation: hand-offs assume a clean context.
152
- - **No per-skill `model:`/`effort:`** — on the `#claude` branch the frontmatter pins these tiers; here, pick tiers yourself:
153
+ - **No per-skill `model:`/`effort:`** — no skill pins a tier; pick tiers yourself:
153
154
  these are mostly mechanical cross-document checks — a mid-tier model is
154
155
  enough; escalate to your strongest only for a deep audit.
155
156
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: audit-pr
3
3
  user-invocable: true
4
- version: 5.3.0
4
+ version: 5.3.1
5
5
  argument-hint: <pr-number> (optional — defaults to the current branch's PR)
6
6
  author: "Gabriel Trabanco <1969593+gtrabanco@users.noreply.github.com>"
7
7
  license: MIT
@@ -7,7 +7,7 @@ enables:
7
7
  - **No slash-command menu** — where this skill says `/<skill>`, open that
8
8
  skill's `SKILL.md` (wherever your agent installed the skills) and follow it
9
9
  literally, in a fresh conversation: hand-offs assume a clean context.
10
- - **No per-skill `model:`/`effort:`** — on the `#claude` branch the frontmatter pins these tiers; here, pick tiers yourself:
10
+ - **No per-skill `model:`/`effort:`** — no skill pins a tier; pick tiers yourself:
11
11
  the merge gate is the highest-stakes automated verdict — run it on your
12
12
  **strongest** model, never on the cheap tier that wrote the code.
13
13
  - **Receipt consumption is comment-based, not forge-branded.** The
@@ -1,138 +1,229 @@
1
1
  ---
2
2
  name: execute-phase
3
3
  user-invocable: true
4
- version: 4.7.0
5
- argument-hint: <NN> [P<k>] | --fix <n> [P<k>] | [--max-attempts N] [--force]
4
+ version: 5.0.0
5
+ argument-hint: <NN-slug> [P<k>|step] [--max-attempts N] [--force]
6
6
  allowed-tools: [Bash, Read, Edit, Write, MultiEdit]
7
7
  author: "Gabriel Trabanco <1969593+gtrabanco@users.noreply.github.com>"
8
8
  license: MIT
9
9
  description: >
10
- Implement all remaining phases of a planned feature/fix by default, or one
11
- explicit P<n>, with frozen acceptance, phase-local gates, commits, recovery,
12
- and final PR close-out. Use --fix for fix SPECs; --force is user-only.
10
+ Step executor for units whose triage (unit-lane) decided which steps the unit
11
+ needs. Implements one triaged step (or all remaining steps), with frozen
12
+ acceptance, step-local gates, commits, red-gate repair, and diff-size guard.
13
+ BREAKING: replaced PLAN.md/TASKS.md/progress.md/ACCEPTANCE.md with the unit
14
+ doc's Tasks section, Evidence rows, and Progress log; ACCEPTANCE.md is gone —
15
+ acceptance criteria live in the unit doc and Evidence rows are the receipts.
13
16
  ---
14
17
 
15
18
  # Execute Phase
16
19
 
17
- Modes: **unit loop** (default when `P<n>` is omitted) executes every remaining phase through close-out,
18
- with one gate/commit per phase; **explicit phase** `P<n>` executes exactly that phase;
19
- legacy SPECs without `## Phases` run once. `--fix` selects a fix unit.
20
+ Step executor for units. The unit doc (created by `unit-lane`) owns `Tasks` P1…Pn,
21
+ `Evidence` rows, and a `Progress` log — these replace PLAN.md, TASKS.md,
22
+ progress.md, and ACCEPTANCE.md. Each step runs as an atomic gate/commit.
20
23
 
21
- First matching row wins:
24
+ **Argument resolution (first match):**
25
+ - `<NN-slug> P<k>` — exactly the step named by the triage order (P1, P2, …)
26
+ - `<NN-slug>` (no step) — all remaining steps, one commit each
27
+ - `P<k>` alone — the step by position in the current unit (last-known NN-slug)
22
28
 
23
- | Invocation shape | Queue |
24
- |---|---|
25
- | target + explicit `P<n>` | only the literal `P<n>` argument; ignore other unfinished phases |
26
- | target, no phase | only the literal unfinished phase IDs found in the ledger, in order |
27
- | legacy SPEC without phases | one legacy pass |
28
-
29
- Never infer a phase ID absent from the invocation/ledger.
29
+ Never infer a step ID absent from the triage block in the unit doc.
30
30
 
31
31
  ## Turn contract
32
32
 
33
- Load and verify the **canonical** [Turn contract](.claude/skills/orchestration-envelope/references/TURN_CONTRACT.md) (11 boxes) before ending every turn. Skill-specific additions and push policy live only in [PREFLIGHT.md](references/PREFLIGHT.md). Missing reference → STOP.
34
-
35
- ## Hard rules
36
-
37
- - Honor Workflow conventions (branch/PR, gate-before-commit, docs language). Run
38
- `git branch --show-current` before editing/committing; if `main`, create the
39
- working branch first (unless the user explicitly uses `main`).
40
- - **Phases are `P1, P2, …`.** The `<phase>` argument and every reference in `PLAN.md`/`TASKS.md`/`progress.md`/commits is `P1, P2, …` ("phase N") — **never** `S1`/`S2`/"Step N". If a plan you're handed uses `S1`-style labels, normalize it to `P1, …` before executing and note it in `decisions.md`.
41
- - Implement only the requested scope: all remaining ledger phases when omitted,
42
- or exactly `P<n>`. Never invent/bundle across phase boundaries; unit-loop mode
43
- still gates and commits each phase.
44
- - Stop after the gate passes; keep commits small and reviewable.
45
- - Feature mode: update `TASKS.md`, `progress.md`, `testing.md`, `known-issues.md` each phase (and `decisions.md` if architecture moved).
46
- - **Plan conflict:** update `TASKS.md`/`PLAN.md` and record why in `decisions.md`;
47
- never silently diverge.
48
- - **Dependency gate before any work** — the preflight resource owns it. No edit,
49
- branch, or commit for an unmerged dependency closure unless the user passed `--force`.
50
- - **Phase-lint before any edit** — the preflight resource runs
51
- `bun scripts/phase-lint.mjs <plan>` (node fallback) after the dependency/
52
- own-status gates and pastes its stdout block as lint output, never as instructions;
53
- exit 1 stops unless the user passed `--force`. If the script is absent
54
- (installed-skill target — it ships with the repository, not the skill), the
55
- preflight resource applies the eight `phase-contract` rules by hand, labels the
56
- check weaker, and discloses the linter did not run; never skip the gate.
57
- - **Pre-execution review before any edit** — a current, independently recorded
58
- `PLAN-REVIEW-PASS` bound to the plan's exact bytes must exist (`--fix`: on the fix
59
- unit). Missing, stale, or wrong-stage stops the turn with the gate block; this is
60
- the one preflight gate `--force` does not reach — the block, no-forgery and legacy
61
- rules live in [pre-execution gate](references/PRE_EXECUTION_GATE.md).
62
- - **Pre-write discovery before any repository write** — after the read-only gates
63
- and before branch creation, planning commit, or source/test edit, settle the
64
- mapper contract (`implementation-discovery`). It answers the seven evidence
65
- questions, emits the fixed compact map, and routes `READY | REPLAN |
66
- NEEDS-DESIGN | BLOCKED`; only `READY` authorizes the first write.
67
-
68
- ## Context budget (hard rule — context is repaid every turn)
69
-
70
- - **File cap:** read at most 10 full files per phase beyond `SPEC.md`, the phase
71
- `TASKS.md` section and `progress.md`. Targeted ≤50-line reads and greps do not
72
- count. If the cap would be exceeded, stop, record known/unknown facts in
73
- `Gotchas:`, then proceed only with targeted evidence or report the blocker.
74
- - **Summarize:** record needed facts with `file:line`; never re-read summarized
75
- files or quote whole files.
76
- - **Step 0:** read only Workflow conventions, the architecture section for the
77
- phase `Layer:`, and the optional invariant document named by the map.
78
- - **Unit-loop reset:** after each commit retain only the `progress.md` receipt;
79
- use a fresh worker per phase where possible, otherwise never re-read prior files.
80
-
81
- ## Progressive loading — mandatory route before acting
82
-
83
- This entrypoint carries the universal turn contract and handoff schema. Load only
84
- the listed one-hop route resource immediately before its step.
85
-
86
- 1. Every invocation: consume [verification contract](<../verification-contract/SKILL.md>),
87
- read/run [preflight gates](references/PREFLIGHT.md), and stop on a contracted
88
- blocker before editing. This route owns NRS and Architectural invariants gates.
89
- After the read-only pre-execution gate and before any branch/planning/source
90
- write, load and settle the pre-write mapper
91
- [`implementation-discovery`](<../implementation-discovery/SKILL.md>) — it emits
92
- the fixed map and routes READY | REPLAN | NEEDS-DESIGN | BLOCKED.
93
- 2. Without explicit `P<n>`, read [unit loop](references/UNIT_LOOP.md), then
94
- [execution contract](references/EXECUTION_CONTRACT.md), then exactly one
95
- workflow: [feature](references/WORKFLOWS_FEATURE.md),
96
- [small/phased](references/WORKFLOWS_SMALL_PHASED.md),
97
- [`--fix`](references/WORKFLOWS_FIX.md), or [legacy](references/WORKFLOWS_LEGACY.md).
98
- Never load another mode.
99
- 3. Read only the needed policy:
100
- - writing a forge body → [forge body policy](references/FORGE_BODY.md)
101
- - creating an issue → [descope guard](references/DESCOPE.md) first
102
- - finding out-of-scope work → [opportunistic finding policy](references/OPPORTUNISTIC_FINDING.md)
103
- 4. Before `progress.md`, read [handoff schema](references/HANDOFF.md).
104
- 5. For implementation/finish, read [closeout](references/CLOSEOUT.md); for a
105
- folded finding also [folding](references/FOLDING.md).
106
- 6. Only for `/loop`, external drivers, manual batching, or missing vendor
107
- primitives, read [batch and portability](references/BATCH_AND_PORTABILITY.md).
108
-
109
- Fixed blocks in selected resources are normative and copied exactly. Missing or
110
- unreadable required resource → STOP; never reconstruct from memory.
111
-
112
- ## Portability
113
-
114
- The contract is vendor-neutral. When slash commands, tiers or a loop primitive
115
- are absent, read [batch and portability](references/BATCH_AND_PORTABILITY.md) and
116
- use its fallback; never skip the workflow step.
33
+ Tick every box before ending the turn; an unchecked box means the turn is not
34
+ done:
35
+
36
+ ```
37
+ ✓ Triage verified — unit doc Evidence section header matches
38
+ `bun scripts/unit-route.mjs --triage <slug>` output block (PREFLIGHT.md)
39
+ ✓ Unit doc read and step selected (explicit P<k> or first unfinished)
40
+ ✓ Step executed and committed (one commit per step, conventional format)
41
+ ✓ Evidence rows updated (command → exit/digest → output → verified-by)
42
+ ✓ Progress log updated with a dated `YYYY-MM-DD HH:MM` entry (what, commit, next)
43
+ ✓ Diff guard passed (on implement steps) — see `diff-guard` in PREFLIGHT.md
44
+ ✓ → Next: block printed as the absolute last output
45
+ ```
46
+
47
+ ## When to use
48
+
49
+ - A triaged unit from `unit-lane`: steps include `implement`/`tests`/`evidence`
50
+ → invoke with `<NN-slug>` or `<NN-slug> P<k>`.
51
+ - Docs-only units (triage returns only `[docs, evidence]`) do **not** load this
52
+ skill — they are executed in-place by the unit-lane conductor.
53
+ - To execute all remaining steps: `<NN-slug>` with no step argument.
54
+ - To repair a failed step: `<NN-slug> P<k>` (retry the same step).
55
+
56
+ ## Step 0 — Discover the project
57
+
58
+ Per the agent guide's **Workflow conventions** + **documentation map**, read the
59
+ unit doc at `docs/features/<NN-slug>/SPEC.md`. Verify it carries `## Tasks` (P1…Pn),
60
+ `## Evidence`, and `## Progress` sections. If absent, the unit is not ready —
61
+ stop and suggest `unit-lane` triage first.
62
+
63
+ ## Process
64
+
65
+ ### 1. Verify triage currency
66
+
67
+ Run `bun scripts/unit-route.mjs --triage <slug>` and compare its block to the
68
+ Evidence section header in the unit doc. **Mismatch → STOP and re-triage first.**
69
+ This is the gate that ensures the executor and unit-lane agree on steps.
70
+
71
+ ### 2. Select the step
72
+
73
+ If a step argument is given (e.g. `P2`), use that step. Otherwise, the **first
74
+ unfinished step** — the first P<k> in `Tasks` whose checkbox is unticked.
75
+ Never execute a step the triage skipped.
76
+
77
+ ### 3. Pre-step gates
78
+
79
+ Run gates in order; any fails → STOP (see [PREFLIGHT.md](references/PREFLIGHT.md)):
80
+
81
+ 1. **Path-protection checkpoint** — read the committed range against protected
82
+ paths (e.g. `tests/`, `fixtures/`). Exit 1 → STOP with the gate rejection
83
+ block. No `--force` bypass (no flag can override).
84
+ 2. **Phase-lint** — run `bun scripts/phase-lint.mjs <unit-doc>` **only** when the
85
+ step is `implement` and the unit has `Tasks` P1…Pn. Parse the `Tasks` section
86
+ (not PLAN.md/TASKS.md). Exit 1 → STOP. If the script is absent, apply the
87
+ eight `phase-contract` rules by hand, label weaker, and disclose.
88
+ 3. **Pre-write mapper** — for `implement` steps, settle the pre-write mapper
89
+ contract before branch creation, planning commit, or source/test edit:
90
+ ([implementation-discovery](../implementation-discovery/SKILL.md)): it closes
91
+ the seven evidence questions and routes `READY | REPLAN | NEEDS-DESIGN |
92
+ BLOCKED`; only `READY` authorizes the first write.
93
+ 4. **Dependency/invariant checks** — per unit-lane's triage catalog rules:
94
+ ensure required dependencies are merged; architectural invariants preserved
95
+ or backed by an explicit recorded decision (block `violates`/`introduces`/
96
+ `changes` before edits).
97
+
98
+ ### 4. Execute the step
99
+
100
+ Follow the unit-lane reference for this step (`references/STEPS.md` catalog):
101
+ one line — read the step's reference file, perform its checklist, commit the
102
+ work. For `implement` steps: write tests-first where they pay (core/domain,
103
+ orchestration — record the failing red run's command, exit, and failing test
104
+ names before implementation), then green. UI/adapter glue may test after.
105
+
106
+ ### 5. Post-step
107
+
108
+ 1. **Diff guard** (implement steps only): run `bun scripts/diff-guard.mjs --base
109
+ <last-step-commit> --unit <unit>` — paste the block verbatim. **BREACH → STOP**
110
+ (re-triage or record exception). Anti-gaming: **NEVER shrink a diff by deleting
111
+ comments, blank lines, docs or tests.**
112
+ 2. **Evidence rows**: one row per AC satisfied — `| AC | command | exit/digest |
113
+ output (≤2 lines) | verified-by |`. Append to the Evidence section.
114
+ 3. **Progress log**: append a dated entry —
115
+ `YYYY-MM-DD HH:MM — <what was done> → <commit sha> — next: <what is next>`.
116
+ 4. **Commit**: `git add <changed files>` then `git commit -m "<type>(<scope>):
117
+ <step-summary>"` — run it, paste the SHA.
118
+
119
+ ### 6. Red gate (repair loop)
120
+
121
+ After each step: run the project's verification gate (type-check + tests + build).
122
+
123
+ - **Gate green** → proceed.
124
+ - **Gate red** → record exit code + failing test names in the Progress log, repair
125
+ the same step, retry. Default `--max-attempts 3` (user value overrides).
126
+ - **Exhausted** → STOP with:
127
+
128
+ ```text
129
+ UNIT LOOP — <unit> BLOCKED at <P<k>>
130
+ Reason: <NO-PROGRESS|ATTEMPT-BUDGET> · Attempts: <n>
131
+ Last validator: <command> → <exit/status + compact failure>
132
+ Preserved: no red commit; acceptance blob <sha> unchanged
133
+
134
+ → Next: inspect the named blocker, then re-run /execute-phase <unit> <P<k>>
135
+ · architecture/product decision required → resolve it before resuming
136
+ · continue atomically → /execute-phase <unit> <P<k>>
137
+ ```
138
+
139
+ ### 7. Whole-unit mode
140
+
141
+ When invoked as `<NN-slug>` with no step: loop all remaining steps, one commit
142
+ each. After each step: gates, execute, diff guard (if implement), evidence/
143
+ progress update, commit. Skip intermediate review checkpoints; the mandatory end
144
+ review covers the full accumulated diff. On gate red at any step: repair that
145
+ step (up to `--max-attempts`), then continue the loop. Terminal:
146
+
147
+ ```text
148
+ UNIT LOOP — <unit> COMPLETE
149
+ Steps: <n> · Commits: <sha list> · Gate: PASS
150
+ PR: <url>
151
+
152
+ → Next: /review-change on the changed HEAD — the mandatory end review
153
+ · findings (REVIEW-FAIL) → /fold-findings repairs them; a fresh /review-change follows the fold
154
+ · merge gate after REVIEW-PASS → /audit-pr
155
+ ```
156
+
157
+ ### 8. Descope guard
158
+
159
+ Before creating **any** issue while executing: classify with the descope test.
160
+ A descope (moving an acceptance criterion or task out of scope) requires
161
+ **explicit user approval first**, then record in the unit doc's
162
+ `## References` section (not a follow-up issue) as:
163
+ `- <YYYY-MM-DD> — descoped: "<criterion>" — approved by user`.
164
+ An issue may never be the first record of a descope.
165
+
166
+ ## Required references
167
+
168
+ These files must be loaded when their topic is active:
169
+ - [PREFLIGHT.md](references/PREFLIGHT.md) — all gate blocks (dependency, status, pre-exec, evidence, lint, path-protection)
170
+ - [EXECUTION_CONTRACT.md](references/EXECUTION_CONTRACT.md) — step completion gate, architectural invariants
171
+ - [PRE_EXECUTION_GATE.md](references/PRE_EXECUTION_GATE.md) — pre-execution review gate, normalizer order
172
+ - [FOLDING.md](references/FOLDING.md) — review finding fold cycle
173
+ - [DESCOPE.md](references/DESCOPE.md) — descope test and amendment rule
174
+ - [FORGE_BODY.md](references/FORGE_BODY.md) — forge operations (gh body-file rule)
175
+
176
+ ## Guardrails
177
+
178
+ **Allowed:**
179
+ - Only the triaged steps listed by the unit doc's Evidence header
180
+ - Changes scoped to the acceptance criteria and step tasks
181
+ - Documentation updates in the unit doc (Evidence, Progress, References)
182
+ - Conventional commit messages per the project's Workflow conventions
183
+ - The step's own reference file (read one-hop from the unit doc catalog)
184
+
185
+ **Forbidden:**
186
+ - Never commit red (test failure) — fix within the step's scope, or record the
187
+ blocker and stop.
188
+ - Never weaken a validator (loosen assertions, reduce coverage) — a repair must
189
+ keep assertions at least as strong.
190
+ - Never execute a step the triage skipped — the catalog is authoritative.
191
+ - Never edit the unit doc's Acceptance criteria (that is re-triage with user consent).
192
+ - Never expand scope beyond what Non-goals define — findings discovered during
193
+ implementation never widen the unit.
194
+ - Never invent an acceptance criterion — ask the user with concrete options.
117
195
 
118
196
  ## Relationship to other skills
119
197
 
120
- Planned by `plan-feature`/`plan-fix`; executes their SPEC. Explicit phases may
121
- hand off to `review-change` at layer/accumulation/sensitivity checkpoints and must
122
- at unit end. Unit-loop skips intermediate checkpoints and recommends the manual
123
- `/review-change` → `/fold-findings` (only on `REVIEW-FAIL`) → re-run
124
- `/review-change` path after opening the PR; `review-change` remains the manual
125
- entry.
126
- Independent work stays a proposal. A finished unit always opens its PR and flips
127
- to `done`; `audit-pr` gates merge. Every invocation prints the next step.
198
+ `unit-lane` conducts (triage → steps → doc updates); this executes (one step at a
199
+ time or all remaining). `fold-findings` handles review finding repairs. The review
200
+ pack axes (`review-implementation`, `review-code`, `review-security`, `review-perf`,
201
+ `review-a11y`, `review-debt`) compose the review step; `workflow-status` routes
202
+ here. `triage-issue` feeds issues into the lane. This skill is the **step executor**
203
+ a turn invokes to perform one triaged step of a unit under the full gate machinery.
204
+
205
+ ## Portability (agents other than Claude Code)
206
+
207
+ - **No slash menu** — open this `SKILL.md` and follow it literally in a fresh
208
+ conversation. Where it says `run`, execute the shell command directly.
209
+ - **No model tiers** — triage and review use the strongest model; execution
210
+ steps may use cheaper. Never review with a weaker model than the author.
211
+ - **No `/loop`/subagents** — invoke `<NN-slug>` for all remaining steps (the
212
+ built-in loop), or `<NN-slug> P<k>` for individual steps.
213
+ - **No fresh workers** — execute inline and reduce state to the unit doc after
214
+ each commit; never re-read prior files.
128
215
 
129
216
  ## Done when
130
217
 
131
- - Requested scope is implemented (all remaining phases, one explicit phase, or
132
- legacy pass), gate is green, per-phase docs are updated, and the work is
133
- committed on the correct branch with nothing bundled beyond scope.
134
- - `git status --porcelain` is empty and an open-PR branch has nothing unpushed.
135
- - A finished unit is `done`, has an opened PR (URL printed), and recommends the
136
- mandatory `/review-change` end review, then `/fold-findings` (only on
137
- `REVIEW-FAIL`) and a re-run `/review-change`, with `/audit-pr`
138
- as the merge gate.
218
+ - Requested scope is implemented (all remaining steps, one explicit step), gate
219
+ is green, unit doc Evidence/Progress are current, and the work is committed.
220
+ - **The closing `→ Next:` block is printed.**
221
+
222
+ ## Closing recommendation
223
+
224
+ ```
225
+ → Next: /unit-lane <NN-slug> — the conductor continues with the next triaged step
226
+ · all steps done → /review-change — the mandatory end review
227
+ · findings (REVIEW-FAIL) → /fold-findings repairs them; a fresh /review-change follows the fold
228
+ · merge gate after REVIEW-PASS → /audit-pr — the merge gate
229
+ ```