@gonrocca/zero-pi 0.1.60 → 0.1.62

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/README.md CHANGED
@@ -37,7 +37,17 @@ pi install npm:@gonrocca/zero-pi
37
37
  pi install npm:pi-subagents # required — the pipeline delegates to sub-agents
38
38
  ```
39
39
 
40
- Needs Node ≥ 20.6. Restart pi after an upgrade.
40
+ Needs Node ≥ 20.6. Restart pi after an install or upgrade so pi regenerates
41
+ the `zero-*` phase agents.
42
+
43
+ ### Quick start
44
+
45
+ 1. Run `/zero-doctor` to catch missing `pi-subagents`, stale generated agents,
46
+ invalid model config, or GitHub CLI auth before spending tokens.
47
+ 2. Run `/zero-models` (or set direct assignments) when you want a different
48
+ model/thinking profile per phase; otherwise the package defaults are used.
49
+ 3. Run `/forge <feature>` and let the automatic gates drive the flow.
50
+ 4. Run `/zero-cost [slug]` after the run to see cost/tokens by phase.
41
51
 
42
52
  ## 🛠 `/forge` — the SDD pipeline
43
53
 
@@ -55,6 +65,10 @@ to its own sub-agent:
55
65
  | **build** | Implement the plan. |
56
66
  | **veredicto** | Review it adversarially and record a verdict. |
57
67
 
68
+ Each run keeps its paper trail under `.sdd/<slug>/`: `clarifications.md`,
69
+ `findings.md`, `proposal.md`, `spec.md`, `design.md`, `tasks.md`,
70
+ `checklist.md`, and (when Strict TDD engages) `tdd-evidence.md`.
71
+
58
72
  The **clarify** and **analyze** gates are automatic inside `/forge` — no extra
59
73
  slash command in the normal flow. `clarify` writes `.sdd/<slug>/clarifications.md`
60
74
  and asks only when proceeding would risk the wrong product; `analyze` writes
@@ -96,7 +110,7 @@ into `/forge` for you.
96
110
  | **Git / PR / Issues** | `/zero-branch`, `/zero-git-validate`, `/zero-pr`, and `/zero-issue` keep branches and GitHub links audit-ready. |
97
111
  | **Run memory** | Every run recalls and saves traces to Cortex, so runs learn from each other. |
98
112
  | **Provider guard** | Warns when the `anthropic` provider runs on a metered API key instead of your subscription. |
99
- | **Startup banner** | The violet ANSI-Shadow `ZERO` wordmark, drawn once at pi startup — `ZERO_HEADER=off` to disable. |
113
+ | **Startup banner** | The sunset ANSI-Shadow `ZERO` wordmark, drawn once at pi startup — `ZERO_HEADER=off` to disable. |
100
114
  | **Working-phrase ticker** | Swaps pi's `Working...` for a context-aware Spanish phrase + spinner. |
101
115
  | **Conversation resume** | Writes `.pi/zero-resume.md` on exit — the restore command + a conversation tail. |
102
116
  | **Windows tree-kill** | Aborting a turn kills the whole process tree — no orphaned `claude`. |
@@ -207,8 +221,11 @@ strong analyze):
207
221
  ```
208
222
 
209
223
  The `thinking` map sets each phase's pi effort level — one of `off`, `minimal`,
210
- `low`, `medium`, `high`, `xhigh`. A phase with no entry gets no `thinking:` line
211
- in its generated sub-agent (no aggressive default). `autotuneBudget` is optional:
224
+ `low`, `medium`, `high`, `xhigh`. An explicit entry always wins; a phase with no
225
+ entry (or an invalid level) falls back to the package default `clarify:
226
+ medium`, `explore: high`, `plan: high`, `analyze: high`, `build: high`,
227
+ `veredicto: xhigh` — so no phase inherits your session-wide
228
+ `defaultThinkingLevel`. `autotuneBudget` is optional:
212
229
  when `maxPhaseCostUsd` is set, autotune will not step a blamed phase up to a more
213
230
  expensive tier if that phase/model is already at or above the average USD
214
231
  ceiling with enough cost samples (`minSamples`, default 3). Set thinking from
@@ -233,11 +250,24 @@ audits the TDD evidence) and accepts `"off"` to disable the discipline.
233
250
  `tdd.testCommand` overrides the auto-detected test runner the TDD cycle invokes;
234
251
  leave it empty to let the build/veredicto phases detect it from the project.
235
252
 
236
- ## Continuous integration
253
+ ### Token efficiency
254
+
255
+ The phase sub-agents run **without** your global project context
256
+ (`inheritProjectContext: false`): a global `AGENTS.md` is heavy and may carry
257
+ personal data or credentials no phase needs — project conventions still reach
258
+ the phases, because explore/build skim the repo's own `AGENTS.md`/`CLAUDE.md`.
259
+ Every phase runs at an explicit `thinking:` level (your `zero.json` entry wins;
260
+ gaps take the package defaults above), and explore works under a numeric
261
+ tool-call budget with a mid-budget stop check. The heavy lifting happens inside
262
+ the sub-agents on their own models — leave the session that runs `/forge` on
263
+ your cheap default model.
264
+
265
+ ## Release checks
237
266
 
238
- The `.github/workflows/zero-pi-ci.yml` workflow runs on every push to `main` and
239
- on every pull request that touches `packages/zero-pi/**`. It enforces `npm test`
240
- and `npm run pack-check` for the package.
267
+ Before publishing, run `npm test` and `npm run pack-check` from
268
+ `packages/zero-pi`. `prepublishOnly` also runs the test suite, but `pack-check`
269
+ confirms the npm tarball still contains the prompts, skills, themes, assets, and
270
+ extension support modules pi needs.
241
271
 
242
272
  ## 🔗 Relationship to `zero`
243
273
 
@@ -17,7 +17,7 @@ import { homedir } from "node:os";
17
17
  import { dirname, join } from "node:path";
18
18
  import { fileURLToPath } from "node:url";
19
19
 
20
- import { isThinkingLevel } from "./zero-models.ts";
20
+ import { DEFAULT_THINKING, isThinkingLevel } from "./zero-models.ts";
21
21
  import type { ThinkingLevel } from "./zero-models.ts";
22
22
 
23
23
  /** The six SDD phases, in pipeline order, each backed by a
@@ -115,9 +115,13 @@ export function buildAgentFile(
115
115
  if (thinking && isThinkingLevel(thinking)) front.push(`thinking: ${thinking}`);
116
116
  front.push(`tools: ${PHASE_TOOLS[phase].join(", ")}`);
117
117
  if (!PHASE_COMPLETION_GUARD[phase]) front.push("completionGuard: false");
118
+ // `inheritProjectContext: false` keeps the user's global AGENTS.md out of
119
+ // every phase sub-agent: it is heavy (re-sent to each phase) and may carry
120
+ // personal data or credentials no phase needs. Project conventions still
121
+ // reach the phases — explore/build skim the repo's own AGENTS.md/CLAUDE.md.
118
122
  front.push(
119
123
  "systemPromptMode: replace",
120
- "inheritProjectContext: true",
124
+ "inheritProjectContext: false",
121
125
  "inheritSkills: false",
122
126
  "---",
123
127
  );
@@ -176,6 +180,17 @@ export function phaseThinking(data: unknown, phase: Phase): ThinkingLevel | unde
176
180
  return undefined;
177
181
  }
178
182
 
183
+ /**
184
+ * Resolve the effective `thinking:` level for a phase: the user's valid
185
+ * `zero.json` entry (or recoverable legacy suffix) wins; a missing or invalid
186
+ * entry falls back to the package default, so no generated agent ever inherits
187
+ * the session-wide `defaultThinkingLevel` from the user's settings. Exported
188
+ * for tests.
189
+ */
190
+ export function resolvePhaseThinking(data: unknown, phase: Phase): ThinkingLevel {
191
+ return phaseThinking(data, phase) ?? DEFAULT_THINKING[phase];
192
+ }
193
+
179
194
  /** Read the per-phase model from `~/.pi/zero.json`; `undefined` when absent. */
180
195
  function readPhaseModel(phase: Phase): string | undefined {
181
196
  try {
@@ -224,7 +239,7 @@ export default function register(_pi?: unknown): void {
224
239
  body,
225
240
  description,
226
241
  readPhaseModel(phase),
227
- readPhaseThinking(phase),
242
+ readPhaseThinking(phase) ?? DEFAULT_THINKING[phase],
228
243
  );
229
244
  writeFileSync(join(agentsDir, `zero-${phase}.md`), file, "utf8");
230
245
  } catch {
@@ -88,6 +88,21 @@ const DEFAULT_MODELS: PhaseModels = {
88
88
  veredicto: "claude-opus-4-8",
89
89
  };
90
90
 
91
+ /** Package default thinking level per phase, used to fill any gap in the
92
+ * user's `zero.json` when the agent files are generated — so no phase ever
93
+ * inherits the session-wide `defaultThinkingLevel` from the user's settings.
94
+ * An explicit valid `zero.json` entry always wins. The gates get a level
95
+ * proportional to their job (clarify records assumptions, analyze reviews
96
+ * artifacts); veredicto keeps `xhigh` as the pipeline's adversarial guard. */
97
+ export const DEFAULT_THINKING: Record<Phase, ThinkingLevel> = {
98
+ clarify: "medium",
99
+ explore: "high",
100
+ plan: "high",
101
+ analyze: "high",
102
+ build: "high",
103
+ veredicto: "xhigh",
104
+ };
105
+
91
106
  /** Model list used only when pi's model registry is unavailable. */
92
107
  const FALLBACK_MODELS = [
93
108
  "claude-opus-4-8",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonrocca/zero-pi",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "zero-pi — an installable layer for pi (pi.dev): the zero spec-driven development workflow (clarify → explore → plan → analyze → build → veredicto) with automatic clarify/analyze gates, per-phase model autotune, and token-efficient batched builds. Adds capability to pi without modifying pi.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -260,11 +260,14 @@ and lists only the original four phases stays valid, and `clarify`/`analyze`
260
260
  fall back to their defaults (`clarify` cheap/fast, `analyze` strong). Configure
261
261
  all six through `/zero-models`.
262
262
 
263
- The `thinking` map is optional and partial: a phase with no entry simply gets no
264
- `thinking:` line in its generated `zero-<phase>.md` frontmatter no aggressive
265
- default is written. When a phase has a valid level, the generated agent file
266
- carries a `thinking: <level>` line in its frontmatter (placed after `model:` and
267
- before `systemPromptMode:`), so the sub-agent runs at that effort level.
263
+ The `thinking` map is optional and partial: an explicit valid entry always
264
+ wins, and a phase with no entry (or an invalid level) falls back to the package
265
+ default `clarify: medium`, `explore: high`, `plan: high`, `analyze: high`,
266
+ `build: high`, `veredicto: xhigh` so no phase silently inherits the
267
+ session-wide `defaultThinkingLevel` from the user's settings. Every generated
268
+ `zero-<phase>.md` therefore carries a `thinking: <level>` line in its
269
+ frontmatter (placed after `model:` and before `systemPromptMode:`), so the
270
+ sub-agent runs at that effort level.
268
271
 
269
272
  ## Language Boundary
270
273
 
@@ -22,6 +22,8 @@ re-read a file you already read this run unless you have changed it since —
22
22
  re-reading the same large file repeatedly is the main avoidable token cost. If
23
23
  the code roots are missing or wrong, run a single targeted search to fix them,
24
24
  then proceed — never fall back to scanning the whole tree.
25
+ If the project root carries an `AGENTS.md` or `CLAUDE.md`, skim it once for
26
+ project conventions — you receive no global user context.
25
27
 
26
28
  Implement the planned tasks in dependency order, test-first where practical. `tasks.md` is a dependency-aware graph: every task has a `depends:` line. Before starting a task, verify each listed dependency is already `[x]`; if a dependency is unchecked, complete that dependency first (when it is in your assigned batch) or stop and report the blocked task (when it is outside the assigned batch). Never skip ahead just because a later task looks easier. Keep every change within the plan's scope — do not expand it on your own initiative.
27
29
 
@@ -13,6 +13,8 @@ is normal; do not treat the missing directory as an error.
13
13
  Investigate the codebase and the feature request read-only. Do not modify any
14
14
  files. Map the relevant modules, the existing patterns and conventions, the
15
15
  integration points, and the constraints. Identify the risks and the unknowns.
16
+ If the project root carries an `AGENTS.md` or `CLAUDE.md`, skim it once for
17
+ project conventions — you receive no global user context.
16
18
 
17
19
  **Size exploration to the request.** Match breadth to what the change actually
18
20
  needs. A localized change — copy/text, one component, a config value, a single
@@ -21,8 +23,15 @@ wiring; do not map the full permission/billing model or unrelated subsystems
21
23
  unless the request touches them. A cross-cutting or architectural change earns
22
24
  full breadth. Stop once you can name the exact files to change and their
23
25
  constraints — reading past that point burns tokens without improving the plan.
24
- As a rough gauge, a localized change rarely needs more than ~20 tool calls; if
25
- you blow past that on a small request, you are over-exploring.
26
+
27
+ **Exploration budget.** Classify the request from `request.md` before the first
28
+ tool call: a localized change gets a budget of **20 tool calls**; a
29
+ cross-cutting or architectural change gets **40**. At half budget, checkpoint:
30
+ if you can already name the exact files to change and their constraints, STOP
31
+ and write the findings. Exceeding the budget requires a
32
+ `Budget exceeded: <concrete reason>` line inside `findings.md`, and whatever you
33
+ did not get to goes into a `## Unknowns` section of the findings instead of more
34
+ reading.
26
35
 
27
36
  **Scope every search to the project, never the filesystem root.** Search inside
28
37
  the repo/code directory you are working in. A `find`, `grep -r`, or `rg` rooted