@ferris1225/pi-subagents 4.1.4 → 4.1.5

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
@@ -22,15 +22,15 @@ losing retained context.
22
22
  ```text
23
23
  You
24
24
  └─ pi main agent
25
- ├─ explorer ─── maps the codebase
26
- ├─ worker ───── implements ─┬─▶ reviewer ─▶ documenter
27
- ├─ cleaner ──── cleans up ──┘ (enabled roles only)
28
- ├─ documenter ─ synchronizes docs ─▶ reviewer
25
+ ├─ explorer ─── retrieval index only (never an automatic gate)
26
+ ├─ worker ───── implements ─┬─▶ reviewer ─┬─ docs CLEAN → deliver
27
+ ├─ cleaner ──── cleans up ──┘ └─ NEEDED/missing → documenter
28
+ ├─ documenter ─ explicit docs/comments task → deliver
29
29
  └─ reviewer ─── advisory report (no VERDICT), or managed gate
30
- ├─ REVIEW_PASS + documenterfinal documentation sync
31
- └─ REVIEW_FAIL → worker → reviewer (fix rounds) → final docs
30
+ └─ REVIEW_FAIL workerreviewer (bounded fix rounds)
32
31
 
33
- The stable parent run returns one final result when the complete workflow settles.
32
+ Worker and cleaner update existing docs/comments they directly affect. The stable
33
+ parent returns one final result when its complete managed workflow settles.
34
34
  ```
35
35
 
36
36
  Install it once and keep using pi normally. The extension teaches the main model
@@ -48,13 +48,13 @@ more of it.
48
48
  - **Parallel edits stay safe.** Parallel workers use temporary, isolated Git
49
49
  checkouts (worktrees) by default, then apply their changes back without
50
50
  touching your index.
51
- - **Documentation stops drifting.** Enabled `documenter` runs automatically
52
- once after the review gate settles after successful workers/cleaners or
53
- fix rounds, never per fix round. It can also run an explicitly requested
54
- whole-codebase maintenance pass.
51
+ - **Documentation stops drifting without a mandatory extra pass.** Workers and
52
+ cleaners synchronize directly affected existing docs. After `REVIEW_PASS`,
53
+ enabled `documenter` runs only for `DOCUMENTATION: NEEDED` (or conservatively
54
+ for a missing marker); with reviewer disabled, it remains the fallback.
55
55
  - **Review can close the loop.** A failed gate can automatically dispatch a
56
56
  worker, request another independent review, and repeat up to a hard limit;
57
- one final documentation sync follows the settled chain.
57
+ documentation is considered only after the terminal `REVIEW_PASS`.
58
58
  - **Agents remain controllable.** Every run has a stable id and retained session,
59
59
  so you can change direction or continue later without starting from zero.
60
60
  - **Failures are handled, not hidden.** Model failures can hand the same session to
@@ -68,7 +68,7 @@ more of it.
68
68
  | One generic child role | Five focused engineering roles |
69
69
  | A one-shot prompt | Retained, steerable, resumable, forkable threads |
70
70
  | Concurrent writers in one checkout | Git worktree isolation for parallel workers |
71
- | A review report you must act on manually | Automatic writer reviewer documenter delivery and bounded fix rounds |
71
+ | A review report you must act on manually | Independent worker/cleaner gate, bounded fix rounds, and conditional docs sync |
72
72
  | Manual polling or follow-up | Automatic result delivery that resumes the main agent |
73
73
  | A hard failure when the selected model is unavailable | Direct handoff to the current main model |
74
74
  | Synchronized retries during startup contention | Extended jittered backoff that reduces retry collisions |
@@ -109,58 +109,31 @@ Compare screenshots/settings.png with design.png and report every visual mismatc
109
109
  The main agent decides when delegation is useful. You can also call the tools
110
110
  explicitly when you want exact control.
111
111
 
112
- ## What changed in 4.1.4
113
-
114
- ### Documentation sync moved after the review gate
115
-
116
- `documenter` now runs once at the end of a managed chain instead of before the
117
- reviewer and once per fix round:
118
-
119
- ```text
120
- before: worker documenter reviewer (worker → documenter → reviewer) × N
121
- after: worker reviewer (worker reviewer) × N documenter
122
- ```
123
-
124
- Code fixes no longer invalidate a docs pass written moments earlier, fix rounds
125
- stop paying for documenter runs and re-reviewing their churn, and a direct
126
- passing gate gets one final documentation sync instead of a second full review.
127
- Gate reviewers record documentation drift as non-gating `## Documentation notes`
128
- that the final documenter applies; when `documenter` is disabled, drift stays a
129
- normal gate finding. The sync is skipped when a chain ends on a failing gate.
130
-
131
- ## What changed in 4.1.2
132
-
133
- ### Documentation sync as a real workflow stage
134
-
135
- The new `documenter` is a write-capable, explorer-class role with two modes:
136
-
137
- 1. **Pre-commit diff sync** — after the last code edit and before the final
138
- reviewer, it compares the actual diff with comments, README/docs, examples,
139
- commands, config, defaults, and lifecycle descriptions.
140
- 2. **Whole-codebase maintenance** — when explicitly requested, it scans an
141
- existing project for stale comments and documentation and applies every safe,
142
- verified correction in scope.
143
-
144
- It never changes runtime behavior, commits, pushes, publishes, or bumps versions.
145
- When enabled, runtime now treats it as a managed stage: successful top-level
146
- `worker`/`cleaner` runs continue through `documenter → reviewer`, a successful
147
- whole-codebase `documenter` continues through reviewer, and auto-fix rounds use
148
- `worker → documenter → reviewer`. Existing non-empty configs receive `documenter`
149
- once and inherit the configured `explorer` model and thinking level; fresh
150
- installs leave it as an explicit setup choice.
151
-
152
- ### Safer startup contention recovery
153
-
154
- Startup contention is much harder to exhaust. A child that exits or fails its RPC
155
- readiness handshake before the initial prompt is dispatched is retried through a
156
- longer backoff window. Each default delay also gets additive jitter, reducing the
157
- chance that several children retry in the same lockstep waves. The base window
158
- covers stale startup locks and leaves headroom beyond the default four-way fan-out.
159
-
160
- Only a failure known to precede prompt dispatch qualifies. Once the parent sends a
161
- prompt command, pi-subagents will not replay it—even if the ACK is lost or an idle
162
- watchdog wins the race—because Pi may already have started the model or tools.
163
- This recovery therefore cannot repeat model calls or edits.
112
+ ## Managed workflow behavior
113
+
114
+ The runtime deliberately keeps delegation conservative:
115
+
116
+ - Small work with a known target stays in the main thread on direct tools.
117
+ `explorer` is worthwhile for broad reconnaissance only; it returns a retrieval
118
+ index, never an automatic gate, and downstream roles re-read load-bearing code.
119
+ - `worker` and `cleaner` remain distinct write-capable entry roles. Each updates
120
+ existing README/docs/examples/comments directly affected by its change. After
121
+ success, one enabled independent `reviewer` gate runs, with the existing bounded
122
+ worker ↔ reviewer fix loop for `REVIEW_FAIL`.
123
+ - When `documenter` is enabled, every managed reviewer gate is asked for a
124
+ standalone `DOCUMENTATION: CLEAN` or `DOCUMENTATION: NEEDED` line. Only
125
+ `REVIEW_PASS` can authorize the final sync: NEEDED includes
126
+ `## Documentation notes` and runs it, CLEAN removes the pending docs stage,
127
+ and a missing marker on that passing gate conservatively runs it.
128
+ - A process failure, missing verdict, or terminal `REVIEW_FAIL` never starts
129
+ documentation writing. With reviewer disabled, the writer documenter
130
+ fallback remains. Documentation drift is non-gating only while documenter is
131
+ available; otherwise it is an ordinary review finding.
132
+ - A top-level `documenter` is already an explicit docs/comments writing task. It
133
+ still uses the shared writer lane and may use worktree isolation, but delivers
134
+ directly after success instead of starting another reviewer.
135
+
136
+ No workflow decision depends on diff line count, file count, or a size heuristic.
164
137
 
165
138
  ## Meet the team
166
139
 
@@ -169,7 +142,7 @@ This recovery therefore cannot repeat model calls or edits.
169
142
  | `explorer` | Read-only | Broad codebase search, unfamiliar-area mapping, symbol and dependency tracing, and multi-file reconnaissance. |
170
143
  | `worker` | Full | A self-contained implementation, bug fix, refactor, or test task carried through verification. |
171
144
  | `cleaner` | Full | Explicitly authorized cleanup, removal, simplification, and duplicate-code consolidation. Dispatch authorizes every safe in-scope cut; it must prove each one. |
172
- | `documenter` | Docs/comments | Pre-commit diff sync or explicitly requested whole-codebase documentation maintenance. Uses an explorer-class model, may make zero edits, and never changes runtime behavior. |
145
+ | `documenter` | Docs/comments | Conditional final diff sync or an explicit standalone documentation/comment task (including explicitly broad maintenance). Uses an explorer-class model, may make zero edits, and never changes runtime behavior. |
173
146
  | `reviewer` | Read-only | Audits, code-health checks, plans, PR or issue validation, documentation-drift checks, and fresh pre-commit gates. |
174
147
 
175
148
  Children have no memory of the parent conversation. A good manual brief includes
@@ -245,25 +218,30 @@ subagent({
245
218
  });
246
219
  ```
247
220
 
248
- A gate reviewer ends with `REVIEW_PASS` or `REVIEW_FAIL`. A direct pass is
249
- final for the code: runtime runs the final documentation sync once (when
250
- `documenter` is enabled) and delivers. A failure uses the bounded loop:
221
+ A gate reviewer ends with `REVIEW_PASS` or `REVIEW_FAIL` and independently
222
+ emits `DOCUMENTATION: CLEAN` or `DOCUMENTATION: NEEDED` when documenter is
223
+ enabled. Only `REVIEW_PASS` can continue to documentation: CLEAN delivers
224
+ immediately, while NEEDED (or a missing marker on that passing gate) runs one
225
+ final docs sync. A failure uses the bounded loop:
251
226
 
252
227
  ```text
253
- reviewer → worker fixes every open finding → reviewer checks again → … → final documentation sync
228
+ reviewer → worker fixes every open finding → reviewer checks again → …
229
+ REVIEW_PASS ─┬─ CLEAN → deliver
230
+ └─ NEEDED/missing → documenter
254
231
  ```
255
232
 
256
233
  Each step gets a fresh model context. The chain shares the same code state and
257
234
  passes every full reviewer and worker report forward; it does not reuse one
258
235
  context window. Internal children bypass top-level lifecycle policy, so they
259
236
  cannot recursively start another chain. Gate reviewers keep documentation drift
260
- out of the verdict while `documenter` is enabled by recording it as
261
- `## Documentation notes` for the final documenter.
237
+ out of the code verdict while `documenter` is enabled by recording it under
238
+ `## Documentation notes`; with documenter disabled, drift is a normal finding.
262
239
 
263
- `maxFixRounds` limits worker fix attempts only. The post-writer review gate and
264
- the final documentation sync still run when it is `0`. Generic audits and
265
- read-only reviews are advisory: they omit `VERDICT`, remain read-only, and
266
- never trigger edits.
240
+ `maxFixRounds` limits worker fix attempts only. The post-writer review gate still
241
+ runs when it is `0`, and only a terminal `REVIEW_PASS` can decide whether docs
242
+ sync is needed. Generic audits and read-only reviews are advisory: they omit
243
+ `VERDICT` and documentation machine markers, remain read-only, and never trigger
244
+ edits.
267
245
 
268
246
  ### Clean up without guessing
269
247
 
@@ -281,7 +259,7 @@ axes genuinely differ, avoiding a generic abstraction that is worse than the
281
259
  duplication.
282
260
 
283
261
  ```text
284
- explicit cleanup request → cleaner applies proven cuts → reviewer gates the diff documenter syncs docs
262
+ explicit cleanup request → cleaner applies cuts + syncs affected docs → reviewer gate conditional documenter
285
263
  read-only cleanup audit → reviewer reports candidates only
286
264
  ```
287
265
 
@@ -292,13 +270,16 @@ changes, and asking for cleanup does not reward speculative deletion.
292
270
 
293
271
  `documenter` has two deliberate launch paths.
294
272
 
295
- **For a pending worker or cleaner change**, enable the role. Runtime schedules
296
- one final sync automatically against the actual diff after the review gate
297
- settles; do not dispatch a duplicate manual sync. If reviewer is disabled,
298
- documenter becomes the final managed stage directly after the writer. If
299
- documenter is disabled, reviewer follows the writer directly.
273
+ **For a pending worker or cleaner change**, those writers first synchronize
274
+ existing docs/comments directly affected by their edits. When the role is
275
+ enabled, runtime schedules a final sync only after terminal `REVIEW_PASS` when
276
+ the reviewer emits `DOCUMENTATION: NEEDED` or omits the marker; do not dispatch
277
+ a duplicate. If reviewer is disabled, documenter remains the conservative final
278
+ fallback. If documenter is disabled, documentation drift is an ordinary reviewer
279
+ finding.
300
280
 
301
- **For an existing project**, explicitly authorize a broad maintenance pass:
281
+ **For standalone documentation work**, explicitly authorize the desired scope
282
+ (a whole-codebase maintenance pass must be explicit):
302
283
 
303
284
  ```ts
304
285
  subagent({
@@ -307,13 +288,10 @@ subagent({
307
288
  });
308
289
  ```
309
290
 
310
- A successful explicit whole-codebase documenter also continues automatically to
311
- reviewer when enabled. A generic or read-only documentation audit still belongs
312
- to `reviewer`. `documenter` is the last writer, never the approver:
313
-
314
- ```text
315
- worker / cleaner / documenter / auto-fix worker → enabled downstream roles → one final delivery
316
- ```
291
+ A successful top-level documenter delivers directly without another reviewer.
292
+ It still occupies the shared writer lane and can use worktree isolation. A
293
+ generic or read-only documentation audit belongs to `reviewer`; `documenter` is
294
+ a docs/comments writer, never the code approver.
317
295
 
318
296
  ## Safe parallel editing
319
297
 
@@ -332,11 +310,12 @@ filesystem isolation:
332
310
  not need a writable checkout.
333
311
 
334
312
  Worktree mode requires a Git repository with a committed `HEAD`. For an isolated
335
- writer, automatic reviewer/documenter children run inside that same worktree.
336
- Those isolated stages can still run in parallel; writer, fix, and documentation
337
- changes are integrated only after the final managed stage settles. Tracked,
338
- deleted, untracked, and binary changes are then carried back to the original
339
- checkout without staging or modifying the parent index.
313
+ worker/cleaner, its automatic reviewer and any needed documenter run inside that
314
+ same worktree. A top-level isolated documenter writes there and then delivers
315
+ directly. Isolated workflows can still run in parallel; writer, fix, and any
316
+ documentation changes are integrated only after the final managed stage
317
+ settles. Tracked, deleted, untracked, and binary changes are then carried back
318
+ to the original checkout without staging or modifying the parent index.
340
319
 
341
320
  Repository-lane discovery uses the Git top-level even in an empty repository, so
342
321
  root and nested paths share one lane before the first commit. Every shared
@@ -361,10 +340,11 @@ isolated checkpoint is available after that checkpoint has settled and integrate
361
340
 
362
341
  ## Follow, redirect, or stop a run
363
342
 
364
- Dispatch confirmations and completion messages include a stable `#id`. That
365
- parent id represents the whole managed workflow; each internal documenter,
366
- reviewer, and fix step gets a separate queryable id in the final summary. No
367
- internal completion wakes the main agent.
343
+ Dispatch confirmations and completion messages include a stable `#id`. For a
344
+ managed worker/cleaner or fix chain, that parent id represents the whole workflow;
345
+ each internal reviewer, fix, and conditionally launched documenter gets a
346
+ separate queryable id in the final summary. No internal completion wakes the
347
+ main agent.
368
348
 
369
349
  | Tool | What it does |
370
350
  | --- | --- |
@@ -402,26 +382,34 @@ isolated apply is queued behind shared work.
402
382
 
403
383
  ## Results and live status
404
384
 
405
- The active TUI widget shows queued and running work as a compact tree:
385
+ The active TUI widget shows standalone runs normally and projects each managed
386
+ workflow as a compact timeline plus its current internal child:
406
387
 
407
388
  ```text
408
- reviewer workflow · review diff of src/cache.ts · 42s
409
- worker · fix round 1 · src/cache.ts · claude-sonnet-4-5/high · 10s
410
- │ grep cacheKey
411
- ○ documenter · final documentation sync · claude-haiku-4-5/low · 3s
389
+ worker workflow · src/cache.ts · 42s
390
+ implement review docs
391
+ ● reviewer · final review · claude-sonnet-4-5/high · 10s
392
+ git diff
412
393
  ```
413
394
 
414
- A managed root keeps its original top-level role and workflow-wide elapsed
415
- time, but deliberately omits model/thinking because several model stages own
416
- that row over its lifetime. The active nested row shows the current stage's
417
- actual role, selected/fallback model, thinking level, stage elapsed time, and
418
- activity. Per-stage usage stays attached to that stage; only the final summary
419
- is labeled and calculated as an aggregate.
420
-
421
- Completed internal rows disappear from the widget; a parked parent remains
422
- queryable. Final messages contain one managed-workflow summary with aggregate
423
- token/cost totals and every internal id. Built-in roles author their own
424
- result-only handoff—outcome, relevant paths, verification, and unresolved
395
+ Success is green, the active stage uses the accent color and bold text, pending
396
+ stages are dim, `REQUEST_CHANGES` is warning-colored, and process failure is an
397
+ error. Fix paths show their budget (`fix 1/2`, `re-review 1/2`). The timeline
398
+ contains only stages that ran or are currently planned; `DOCUMENTATION: CLEAN`
399
+ removes pending docs instead of pretending that stage ran.
400
+
401
+ A managed root keeps its original top-level role and workflow-wide elapsed time,
402
+ but omits model/thinking because several model stages own it. The active nested
403
+ row shows the current role, relation, selected/fallback model, thinking, stage
404
+ elapsed, and activity. Completed internal rows can disappear while their stage
405
+ remains visible on the parent until the workflow settles. Standalone,
406
+ resume/retarget, and fork labels retain their existing semantics; narrow layouts
407
+ prioritize the current stage and elapsed tail. Adjacent workflows add no blank
408
+ separator rows.
409
+
410
+ A parked parent remains queryable. Final messages contain one managed-workflow
411
+ summary with aggregate token/cost totals and every internal id. Built-in roles
412
+ author their own result-only handoff—outcome, relevant paths, verification, and unresolved
425
413
  blockers—without a second summarization layer that could distort the result.
426
414
  They omit task/process narration and recovered transient tool failures. The
427
415
  80-line delivery cap remains a safety limit; long output is written unchanged to
@@ -529,7 +517,7 @@ Configuration is stored at `~/.pi/agent/pi-subagents.json` and follows
529
517
  | `proactiveInjection` | Teach the main model when and how to delegate. Default `true`. |
530
518
  | `agentScope` | Discover `user`, `project`, or `both` agent directories. Default `user`. |
531
519
  | `maxConcurrency` | Running process limit and maximum tasks in one parallel call, from `1` to `16`. Default `4`. |
532
- | `maxFixRounds` | Maximum worker fixes after `REVIEW_FAIL`; each fix is re-reviewed by a reviewer, and one final documentation sync runs after the chain settles. `0` disables fixes but not the post-writer review gate or final docs. Default `2`. |
520
+ | `maxFixRounds` | Maximum worker fixes after `REVIEW_FAIL`; each fix is re-reviewed. After terminal `REVIEW_PASS`, docs sync runs only for `DOCUMENTATION: NEEDED` or a missing marker. `0` disables fixes but not the post-writer gate or conditional/reviewer-disabled docs behavior. Default `2`. |
533
521
  | `idleTimeoutSec` | Seconds without RPC output before termination. `0` disables the watchdog. Default `90`. |
534
522
 
535
523
  Invalid values fall back safely. Older configs are normalized automatically. The
package/agents/cleaner.md CHANGED
@@ -38,14 +38,15 @@ Never simplify away authorization, validation at trust boundaries, security cont
38
38
  ## Apply proven cuts
39
39
  - Work within one ownership boundary at a time and keep batches reviewable.
40
40
  - Delete an obsolete contract end to end: declaration, implementation, callers, branches, exports, config, dependencies, dedicated tests, docs, examples, snapshots, and generated inventories.
41
+ - Synchronize every existing README/docs/example/API comment/docstring/explanatory comment directly affected by the cleanup. Do not defer known drift or broaden into unrelated documentation maintenance.
41
42
  - Preserve tests of surviving observable behavior. Prefer deletion, then platform features, then dependencies already present; do not add replacement glue that erases the net reduction.
42
43
  - Re-search removed names and stale documentation. Run the narrowest decisive check first, then the repository's relevant broad type/lint/test/build gates. Inspect the complete diff and run `git diff --check` when available.
43
44
  - Do not weaken a meaningful check to force a cut through. Repair or revert only the current batch when evidence fails.
44
45
 
45
46
  ## Release boundary
46
- Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns the independent review gate, the final documentation sync, and every release action—even when repository instructions normally automate release after green checks.
47
+ Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns the independent review gate, any conditional final documentation sync, and every release action—even when repository instructions normally automate release after green checks.
47
48
 
48
49
  ## Final response
49
50
  Return only the cleanup outcome: exact files/contracts removed or consolidated, measurable net reduction, behavior tradeoffs, and checks actually run. Mention a kept candidate only when the caller must make a product decision or it blocks an otherwise safe cut. If no safe cut was proved, say so and make no edits. Do not repeat the task brief or evidence-gathering chronology. Omit transient tool failures that were recovered; report only unresolved blockers and checks that remain failed. Keep the final response comfortably below the 80-line delivery cap unless the result genuinely requires more. Never equate green tests with proof, or deletion volume with value.
50
51
 
51
- The parent runtime automatically runs the enabled `reviewer` gate and final `documenter` sync after a successful top-level cleaner. Provide a complete handoff without asking the caller to dispatch duplicate downstream roles. Reviewer gates the code; documenter is the final stage before delivery.
52
+ The parent runtime automatically runs one enabled `reviewer` gate after a successful top-level cleaner and preserves the bounded worker/reviewer fix loop. A final `documenter` runs only when the terminal healthy review reports documentation drift or omits its marker (or when reviewer is disabled). Provide a complete handoff without asking the caller to dispatch duplicate downstream roles.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: documenter
3
- description: "Write-capable documentation synchronizer with two modes: final diff sync after the review gate settles, or an explicitly requested whole-codebase comment/README/docs maintenance pass. May make zero edits and never changes runtime behavior."
3
+ description: "Write-capable documentation synchronizer with two modes: final diff sync selected by a gate's documentation disposition (or as the reviewer-disabled fallback), or an explicitly requested standalone comment/README/docs maintenance task. May make zero edits and never changes runtime behavior."
4
4
  tools: read, grep, find, ls, bash, edit, write
5
5
  # At launch, this shell slot follows the parent and parent-active plugin tools
6
6
  # are appended; the listed non-shell Pi built-ins remain the permission boundary.
@@ -15,14 +15,14 @@ You are a documenter agent: a write-capable specialist for keeping comments, REA
15
15
  You may edit documentation and comments, but you must never change runtime behavior to make the documentation true. Finding no drift and making zero edits is valid.
16
16
 
17
17
  ## Choose the mode
18
- - **Pre-commit diff sync (default for a concrete change):** run after the code review gate settles following implementation, cleanup, or auto-fix rounds as the final managed stage before delivery. Inspect the complete pending diff, apply every documentation note the reviewers recorded, and synchronize every documentation surface affected by it.
19
- - **Whole-codebase maintenance:** run only when the user explicitly asks to refresh, re-document, or audit-and-update comments/README/docs across an existing project. Inspect the whole requested codebase or scope, prove each stale statement against implementation, and apply every safe in-scope correction. Do not trigger this broad mode merely because a diff is large or a PR exists.
20
- - If the brief does not explicitly authorize a whole-codebase pass, stay in diff mode. A read-only documentation audit belongs to `reviewer`, not this write-capable role.
18
+ - **Pre-commit diff sync (default for a managed concrete change):** when reviewer is enabled, run conditionally after the code review gate settles because the terminal review emitted `DOCUMENTATION: NEEDED` or omitted the marker. With reviewer disabled, run as the writer documenter fallback. Inspect the complete pending diff, apply every documentation note the reviewers recorded, and synchronize every documentation surface affected by it.
19
+ - **Standalone documentation maintenance:** run only when the user explicitly asks to write, refresh, re-document, or audit-and-update comments/README/docs for a requested scope. A whole-codebase pass requires explicit broad scope; never infer it merely because a diff is large or a PR exists. A successful top-level documenter delivers directly without an automatic reviewer.
20
+ - If the brief does not explicitly authorize a whole-codebase pass, keep standalone work to its requested scope; do not infer broad maintenance. A read-only documentation audit belongs to `reviewer`, not this write-capable role.
21
21
 
22
22
  ## Hard boundaries
23
23
  - Update documentation surfaces only: README/docs, examples, API comments, docstrings, and explanatory code comments, including comments inside tests. Do not change executable behavior, test behavior or assertions, schemas, generated output, dependencies, or configuration defaults.
24
24
  - When documentation exposes a likely code defect or an unresolved product decision, report it for `reviewer`; do not repair code under the cover of documentation sync.
25
- - Never commit, push, publish, tag, or release; never bump versions. The parent owns the automatic final reviewer gate and every release action, even when repository instructions normally automate release after green checks.
25
+ - Never commit, push, publish, tag, or release; never bump versions. The parent owns every release action, even when repository instructions normally automate release after green checks. A top-level documenter is not automatically sent to reviewer; a managed final sync follows an already settled code gate when reviewer is enabled, or serves as the reviewer-disabled fallback.
26
26
  - Preserve unrelated worktree changes. Never rewrite broad prose merely for style when it is already accurate.
27
27
 
28
28
  ## Sync workflow
@@ -43,4 +43,4 @@ Return only the documentation outcome:
43
43
 
44
44
  Do not repeat the task brief, diff walkthrough, generic root-cause explanation, or tool chronology. Omit transient tool failures that were recovered; report only checks that remain failed or blockers that remain unresolved. Mention diff mode versus whole-codebase mode only when it materially clarifies scope. Keep the final response comfortably below the 80-line delivery cap unless the result genuinely requires more.
45
45
 
46
- A successful top-level `documenter` still gets a fresh read-only `reviewer` gate when that role is enabled; report a complete handoff without requesting a duplicate dispatch. When you run as the final managed stage after a settled gate, the workflow delivers directly after you and no fresh reviewer runs. You are always the last writer, never the code approver.
46
+ Whether invoked as an explicit top-level documentation task or as the conditional final managed stage, the workflow delivers directly after you and no fresh reviewer runs. Report a complete handoff without requesting duplicate downstream work. You are always a documentation writer, never the code approver.
@@ -41,8 +41,9 @@ You are a senior, adversarial code reviewer. Find genuine defects and risks rath
41
41
  ## Reporting discipline
42
42
  - Report only defensible defects or risks with file:line evidence; omit preferences and optional nits.
43
43
  - Return only the review result. Do not repeat the task brief, summarize the implementation, narrate inspection/tool chronology, or explain a root cause when no finding depends on it. Omit transient tool failures that were recovered; report only unresolved coverage gaps.
44
- - Stay independent of `worker`, `cleaner`, and `documenter`; fix nothing yourself. When the final documenter is pending (documenter is enabled), documentation sync runs AFTER this gate: documentation drift is not a gate finding record needed updates as a short "## Documentation notes" list and carry it forward on re-review so the final documenter applies it. When documenter is disabled, documentation drift is a normal finding.
45
- - In a gate, every finding enters auto-fix, with no severity tiers. A direct REVIEW_PASS is final for code: runtime runs the final documentation sync once, then delivers; those documentation edits never reopen the gate. On re-review, rule on each open finding once, concretely adjudicate worker rejections, add only defects the fix introduced or exposed, and never re-open a verified resolution.
44
+ - Stay independent of `worker`, `cleaner`, and `documenter`; fix nothing yourself. When a final documenter is available, documentation drift is not a code-gate finding: record it in a short `## Documentation notes` section and carry it forward on re-review. When documenter is disabled, drift is a normal gate finding.
45
+ - Every gate (never an advisory review) must classify documentation on its own standalone machine line. Emit `DOCUMENTATION: NEEDED` and include `## Documentation notes` when a sync is needed; otherwise emit `DOCUMENTATION: CLEAN`. Runtime treats a missing marker conservatively as NEEDED. Do not emit this marker for advisory output.
46
+ - In a gate, every code/test finding enters auto-fix, with no severity tiers. A direct REVIEW_PASS is final for code: CLEAN delivers directly, while NEEDED/missing runs one conditional documentation sync without reopening the gate. On re-review, rule on each open finding once, concretely adjudicate worker rejections, add only defects the fix introduced or exposed, and never re-open a verified resolution.
46
47
  - Advisory findings never enter auto-fix; the caller decides whether to authorize later implementation or cleanup.
47
48
 
48
49
  ## Output
@@ -65,10 +66,14 @@ For a gate review:
65
66
  ## Findings
66
67
  - file.ts:42 — concrete issue and why it breaks
67
68
  (Write "None" when no finding remains.)
69
+ ## Documentation notes
70
+ - exact stale surface and required correction
71
+ (Omit this section when documentation is clean.)
72
+ DOCUMENTATION: NEEDED
68
73
  ## Verdict
69
74
  APPROVE or REQUEST_CHANGES, plus a concise rationale.
70
75
  VERDICT: REVIEW_PASS
71
76
  ```
72
- In a gate review, use `VERDICT: REVIEW_FAIL` when any finding remains. A `REQUEST_CHANGES` gate verdict starts the configured worker/re-review loop; `APPROVE` means the gate finding list is empty. Never wave an issue through or invent findings to hedge.
77
+ Use the independent line `DOCUMENTATION: CLEAN` instead when no documentation update is needed. Use `VERDICT: REVIEW_FAIL` when any gate finding remains. A `REQUEST_CHANGES` gate verdict starts the configured worker/re-review loop; `APPROVE` means the gate finding list is empty. Never wave an issue through or invent findings to hedge.
73
78
 
74
79
  Use exact paths and line numbers. State uncertainty plainly. Keep the final response comfortably below the 80-line delivery cap unless the finding set genuinely requires more.
package/agents/worker.md CHANGED
@@ -16,10 +16,10 @@ Work in phases. Do not skip planning or verification.
16
16
  Read the brief fully. If it references files, read them before editing. If it references images (screenshots, mockups, designs), `read` them too — the model receives them as attachments when it supports vision. If critical context is clearly missing, state what an `explorer` should retrieve rather than guessing.
17
17
 
18
18
  ### Phase 2 — Plan
19
- Inspect existing code and conventions first. Form the smallest coherent root-cause change that satisfies the brief. For a large task, write a short internal plan (files to touch, order, risks) before editing. Do not refactor unrelated code or create docs unless the brief asks.
19
+ Inspect existing code and conventions first. Form the smallest coherent root-cause change that satisfies the brief. For a large task, write a short internal plan (files to touch, order, risks) before editing. Do not refactor unrelated code or start broad/standalone documentation work unless the brief asks.
20
20
 
21
21
  ### Phase 3 — Implement
22
- Make the change. Preserve the user's work; limit edits to the request plus required validation. Follow the project's existing error handling, naming, and style.
22
+ Make the change. Preserve the user's work; limit edits to the request plus required validation. Follow the project's existing error handling, naming, and style. Synchronize any existing README/docs, examples, API comments, docstrings, and explanatory comments directly affected by your change; do not defer obvious drift to another role.
23
23
 
24
24
  ### Phase 4 — Verify
25
25
  Run the project's format/build/tests when they exist (e.g. `tsc --noEmit`, the test runner). NEVER report an unrun check as passed — report it as unavailable or as a pre-existing failure, with the exact error.
@@ -28,13 +28,13 @@ Run the project's format/build/tests when they exist (e.g. `tsc --noEmit`, the t
28
28
  Return only the concrete outcome so the caller can verify it and, if needed, hand it to a `reviewer`. Do not repeat the task brief, plan, root-cause investigation, or tool chronology. Omit transient tool failures that were recovered; report only checks that remain failed or blockers that remain unresolved.
29
29
 
30
30
  ## Release boundary
31
- Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns the independent review gate, the final documentation sync, and every release action—even when repository instructions normally automate release after green checks.
31
+ Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns the independent review gate, any conditional final documentation sync, and every release action—even when repository instructions normally automate release after green checks.
32
32
 
33
33
  ## Collaboration
34
34
  - You cannot dispatch sub-agents (children are leaf processes with no `subagent` tool). When the
35
35
  brief lacks context that needs broad code discovery, state concretely what an `explorer` should
36
36
  retrieve for the caller — do not guess.
37
- - The parent runtime automatically runs the enabled `reviewer` gate and final `documenter` sync after a successful top-level worker. Report a complete handoff, but do not ask the caller to dispatch duplicate downstream roles. Never treat your own verification as the final gate.
37
+ - The parent runtime automatically runs one enabled `reviewer` gate after a successful top-level worker and preserves the bounded worker/reviewer fix loop. A final `documenter` runs only when that terminal review reports documentation drift or omits its marker (or when reviewer is disabled). Report a complete handoff, but do not ask the caller to duplicate downstream roles. Never treat your own verification as the final gate.
38
38
 
39
39
  ## Output format
40
40
  ## Completed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferris1225/pi-subagents",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
4
4
  "description": "A managed sub-agent team for pi: specialized roles, pre-commit documentation sync, retained threads, auto-fix chains, model fallback, and Git worktree isolation.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/config.ts CHANGED
@@ -73,8 +73,9 @@ export const DEFAULT_MAX_CONCURRENCY = 4;
73
73
  export const MAX_CONCURRENCY_LIMIT = 16;
74
74
  /**
75
75
  * Maximum worker fixes after REVIEW_FAIL. Each fix is followed by a reviewer
76
- * re-review; this cap does not suppress the post-writer review gate or the
77
- * final documentation sync. 0 disables fixes. Default: 2.
76
+ * re-review; this cap does not suppress the post-writer review gate or its
77
+ * conditional/reviewer-disabled documentation fallback. 0 disables fixes.
78
+ * Default: 2.
78
79
  */
79
80
  export const DEFAULT_MAX_FIX_ROUNDS = 2;
80
81
  /** Upper bound accepted for maxFixRounds (defensive clamp). 0 disables the loop. */
@@ -116,8 +117,8 @@ export interface SubagentsConfig {
116
117
  maxConcurrency: number;
117
118
  /**
118
119
  * Maximum worker fixes after REVIEW_FAIL. Every fix receives the full review,
119
- * then a re-review runs; one final documentation sync follows the settled
120
- * chain and does not consume this budget. 0 disables fixes. Default: 2.
120
+ * then a re-review runs; any documentation sync selected after the terminal
121
+ * healthy review does not consume this budget. 0 disables fixes. Default: 2.
121
122
  */
122
123
  maxFixRounds: number;
123
124
  /**
@@ -247,7 +248,8 @@ export function normalizeConfig(raw: unknown): SubagentsConfig {
247
248
  const maxConcurrency = clampCount(raw.maxConcurrency, MAX_CONCURRENCY_LIMIT);
248
249
  if (maxConcurrency !== undefined) config.maxConcurrency = maxConcurrency;
249
250
 
250
- // 0 disables worker fixes, not the initial managed docs/review workflow.
251
+ // 0 disables worker fixes, not the independent post-writer review gate or
252
+ // conditional/reviewer-disabled documentation fallback.
251
253
  if (typeof raw.maxFixRounds === "number" && Number.isFinite(raw.maxFixRounds)) {
252
254
  config.maxFixRounds = Math.max(0, Math.min(MAX_FIX_ROUNDS_LIMIT, Math.round(raw.maxFixRounds)));
253
255
  }