mandrel 2.89.0 → 2.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/README.md +47 -7
- package/.agents/agents/story-worker.md +20 -0
- package/.agents/audit-checklists/lean.md +26 -0
- package/.agents/docs/agentrc-reference.json +5 -6
- package/.agents/docs/configuration.md +38 -30
- package/.agents/docs/workflows.md +7 -1
- package/.agents/instructions.md +3 -1
- package/.agents/runtime-deps.json +0 -2
- package/.agents/schemas/agentrc.schema.json +46 -45
- package/.agents/schemas/audit-rules.json +19 -0
- package/.agents/scripts/acceptance-eval.js +2 -6
- package/.agents/scripts/audit-exceptions.js +2 -4
- package/.agents/scripts/board-backfill.js +253 -0
- package/.agents/scripts/check-arch-cycles.js +1 -5
- package/.agents/scripts/check-context-budget.js +1 -5
- package/.agents/scripts/check-cyclomatic.js +1 -5
- package/.agents/scripts/check-dead-exports.js +23 -14
- package/.agents/scripts/check-doc-links.js +4 -4
- package/.agents/scripts/check-test-temp-hygiene.js +29 -33
- package/.agents/scripts/coverage-capture.js +14 -6
- package/.agents/scripts/diagnose-friction.js +8 -10
- package/.agents/scripts/generate-workflows-doc.js +5 -0
- package/.agents/scripts/lib/audit-exceptions/adapters/index.js +2 -0
- package/.agents/scripts/lib/audit-exceptions/adapters/inline-suppressions.js +36 -27
- package/.agents/scripts/lib/audit-exceptions/adapters/shortcut-markers.js +70 -0
- package/.agents/scripts/lib/audit-exceptions/adapters/source-scan.js +26 -0
- package/.agents/scripts/lib/audit-to-stories/audit-lenses.js +1 -0
- package/.agents/scripts/lib/baseline-schema-registry.js +3 -5
- package/.agents/scripts/lib/baselines/bundle-size-scorer.js +11 -28
- package/.agents/scripts/lib/baselines/components.js +5 -5
- package/.agents/scripts/lib/baselines/crap-preview-scan.js +4 -1
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +6 -4
- package/.agents/scripts/lib/baselines/duplication-scanner.js +4 -10
- package/.agents/scripts/lib/baselines/kinds/crap.js +4 -2
- package/.agents/scripts/lib/baselines/kinds/duplication.js +4 -2
- package/.agents/scripts/lib/baselines/kinds/kind-factory.js +13 -6
- package/.agents/scripts/lib/baselines/refresh-service.js +10 -13
- package/.agents/scripts/lib/baselines/writer.js +4 -4
- package/.agents/scripts/lib/bdd-scenario-scanner.js +26 -31
- package/.agents/scripts/lib/bootstrap/gh-list.js +4 -5
- package/.agents/scripts/lib/bootstrap/gh-preflight.js +13 -8
- package/.agents/scripts/lib/child-exec.js +4 -4
- package/.agents/scripts/lib/claude/agents-projection.js +170 -0
- package/.agents/scripts/lib/claude/commands-projection.js +184 -0
- package/.agents/scripts/lib/close-validation/commands.js +28 -117
- package/.agents/scripts/lib/close-validation/gates.js +54 -48
- package/.agents/scripts/lib/close-validation/process.js +5 -1
- package/.agents/scripts/lib/close-validation/projections/crap.js +2 -1
- package/.agents/scripts/lib/close-validation/projections/maintainability.js +50 -15
- package/.agents/scripts/lib/config/agentrc-overlay.js +4 -7
- package/.agents/scripts/lib/config/commands.js +82 -7
- package/.agents/scripts/lib/config/explain.js +2 -1
- package/.agents/scripts/lib/config/gates/coverage.schema.js +39 -3
- package/.agents/scripts/lib/config/gates/crap-incremental-coverage.schema.js +1 -1
- package/.agents/scripts/lib/config/gates/crap.schema.js +5 -3
- package/.agents/scripts/lib/config/gates/duplication.schema.js +6 -11
- package/.agents/scripts/lib/config/gates/shared.js +2 -2
- package/.agents/scripts/lib/config/git-roots.js +120 -0
- package/.agents/scripts/lib/config/quality.js +46 -50
- package/.agents/scripts/lib/config/review-chain-default.js +4 -3
- package/.agents/scripts/lib/config/review-provider-clis.js +11 -0
- package/.agents/scripts/lib/config/temp-paths.js +3 -37
- package/.agents/scripts/lib/config-resolver.js +5 -9
- package/.agents/scripts/lib/config-settings-schema-delivery.js +2 -2
- package/.agents/scripts/lib/config-settings-schema-quality.js +3 -2
- package/.agents/scripts/lib/config-settings-schema.js +6 -7
- package/.agents/scripts/lib/coverage-baseline.js +2 -1
- package/.agents/scripts/lib/coverage-capture-affected.js +4 -3
- package/.agents/scripts/lib/coverage-capture-fullscope.js +3 -1
- package/.agents/scripts/lib/coverage-capture-passes.js +119 -34
- package/.agents/scripts/lib/coverage-capture-usage.js +1 -1
- package/.agents/scripts/lib/coverage-capture.js +80 -43
- package/.agents/scripts/lib/coverage-utils.js +34 -16
- package/.agents/scripts/lib/cpu-pool.js +2 -4
- package/.agents/scripts/lib/crap-engine.js +19 -1
- package/.agents/scripts/lib/crap-utils.js +2 -1
- package/.agents/scripts/lib/dead-exports-knip.js +29 -11
- package/.agents/scripts/lib/detect-package-manager.js +13 -0
- package/.agents/scripts/lib/feedback-loop/graduator-gh.js +4 -2
- package/.agents/scripts/lib/full-suite-lock.js +25 -9
- package/.agents/scripts/lib/gates/baseline-store.js +2 -10
- package/.agents/scripts/lib/generated/agentrc-validator.js +4 -1
- package/.agents/scripts/lib/gh-env.js +72 -0
- package/.agents/scripts/lib/gh-exec.js +26 -1
- package/.agents/scripts/lib/maintainability-utils.js +8 -8
- package/.agents/scripts/lib/npm-scripts.js +1 -1
- package/.agents/scripts/lib/observability/signal-validator.js +2 -6
- package/.agents/scripts/lib/observability/source-classifier.js +1 -0
- package/.agents/scripts/lib/observability/terse-result.js +2 -6
- package/.agents/scripts/lib/orchestration/board-access-latch.js +112 -0
- package/.agents/scripts/lib/orchestration/ci-rerun-guard.js +10 -13
- package/.agents/scripts/lib/orchestration/column-sync.js +107 -52
- package/.agents/scripts/lib/orchestration/deliver-recover.js +2 -1
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes.js +3 -3
- package/.agents/scripts/lib/orchestration/lifecycle/emit-ledger-event.js +2 -6
- package/.agents/scripts/lib/orchestration/light-suitability.js +5 -7
- package/.agents/scripts/lib/orchestration/pr-watch.js +7 -7
- package/.agents/scripts/lib/orchestration/project-meta-cache.js +2 -11
- package/.agents/scripts/lib/orchestration/project-meta-resolver.js +44 -17
- package/.agents/scripts/lib/orchestration/review-deposit.js +2 -9
- package/.agents/scripts/lib/orchestration/review-providers/callers-context.js +219 -0
- package/.agents/scripts/lib/orchestration/review-providers/code-review.js +53 -5
- package/.agents/scripts/lib/orchestration/review-providers/codex-cli.js +2 -2
- package/.agents/scripts/lib/orchestration/review-providers/llm-review.js +96 -0
- package/.agents/scripts/lib/orchestration/review-providers/mi-exemptions.js +2 -2
- package/.agents/scripts/lib/orchestration/review-providers/native.js +13 -19
- package/.agents/scripts/lib/orchestration/review-providers/review-depth.js +3 -2
- package/.agents/scripts/lib/orchestration/review-providers/review-provider-factory.js +2 -0
- package/.agents/scripts/lib/orchestration/review-providers/security-review.js +11 -3
- package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +2 -3
- package/.agents/scripts/lib/orchestration/story-close/format-autofix.js +41 -15
- package/.agents/scripts/lib/orchestration/story-deliver-terminal-schema.js +2 -4
- package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +2 -13
- package/.agents/scripts/lib/orchestration/story-handoff.js +27 -6
- package/.agents/scripts/lib/orchestration/story-progress.js +3 -11
- package/.agents/scripts/lib/orchestration/ticketing/bulk.js +3 -5
- package/.agents/scripts/lib/orchestration/verify-credit.js +52 -28
- package/.agents/scripts/lib/single-story-sweep/protection-ctx.js +11 -11
- package/.agents/scripts/lib/single-story-sweep/protection.js +1 -9
- package/.agents/scripts/lib/single-story-sweep/sweep-lock.js +1 -5
- package/.agents/scripts/lib/source-extensions.js +30 -15
- package/.agents/scripts/lib/test-run-credit.js +1 -9
- package/.agents/scripts/lib/test-temp.js +22 -21
- package/.agents/scripts/lib/util/ajv.js +111 -0
- package/.agents/scripts/lib/util/atomic-write.js +30 -0
- package/.agents/scripts/lib/util/paths.js +51 -0
- package/.agents/scripts/lib/util/sleep.js +6 -0
- package/.agents/scripts/lib/util/slug.js +12 -0
- package/.agents/scripts/lib/validation-evidence.js +19 -40
- package/.agents/scripts/lib/worktree/lifecycle/force-drain.js +2 -1
- package/.agents/scripts/lib/worktree/lifecycle/pending-cleanup.js +10 -28
- package/.agents/scripts/lib/worktree/lifecycle/reap.js +2 -2
- package/.agents/scripts/lib/worktree/node-modules-strategy.js +21 -14
- package/.agents/scripts/lint-issue-body.js +2 -2
- package/.agents/scripts/plan-context.js +2 -7
- package/.agents/scripts/providers/github/auth.js +3 -3
- package/.agents/scripts/providers/github/board-add.js +18 -9
- package/.agents/scripts/providers/github/errors.js +3 -1
- package/.agents/scripts/providers/github/gh-token-diagnostics.js +10 -7
- package/.agents/scripts/providers/github/issues.js +6 -2
- package/.agents/scripts/providers/github/mappers.js +1 -5
- package/.agents/scripts/providers/github/projects-v2-graphql.js +26 -6
- package/.agents/scripts/providers/github/search-budget.js +3 -1
- package/.agents/scripts/resolve-doc-tiers.js +7 -20
- package/.agents/scripts/sync-agentrc.js +5 -14
- package/.agents/scripts/sync-claude-agents.js +38 -150
- package/.agents/scripts/sync-claude-commands.js +35 -218
- package/.agents/scripts/update-coverage-baseline.js +1 -1
- package/.agents/scripts/update-crap-baseline.js +1 -1
- package/.agents/scripts/update-duplication-baseline.js +2 -16
- package/.agents/scripts/validate-skills.js +6 -10
- package/.agents/skills/core/code-review-and-quality/SKILL.md +3 -18
- package/.agents/skills/core/documentation-and-adrs/SKILL.md +4 -14
- package/.agents/workflows/audit-exceptions.md +9 -0
- package/.agents/workflows/audit-lean.md +129 -0
- package/.agents/workflows/helpers/audit-lens-core.md +7 -0
- package/.agents/workflows/helpers/code-quality-guardrails.md +21 -0
- package/.agents/workflows/helpers/code-review.md +15 -1
- package/.agents/workflows/helpers/deliver-digest.md +1 -1
- package/.agents/workflows/helpers/deliver-reference.md +2 -2
- package/.agents/workflows/mandrel-plan.md +2 -2
- package/docs/CHANGELOG.md +48 -0
- package/lib/cli/doctor-checks/codex.js +6 -5
- package/lib/cli/doctor-checks/llm-review.js +102 -0
- package/lib/cli/doctor-checks/project-access.js +124 -0
- package/lib/cli/doctor-checks/sync-parity.js +65 -140
- package/lib/cli/doctor-checks/test-credit-path.js +69 -28
- package/lib/cli/doctor-checks/toolchain.js +5 -3
- package/lib/cli/registry.js +11 -0
- package/lib/migrations/helpers/retire-agentrc-key.js +3 -3
- package/lib/migrations/index.js +6 -0
- package/lib/migrations/steps/2.91.0-move-shared-crap-capture-script.js +84 -0
- package/lib/migrations/steps/2.91.0-retire-duplication-formats.js +23 -0
- package/lib/migrations/steps/2.91.0-unset-null-lint-command.js +54 -0
- package/package.json +1 -3
|
@@ -401,8 +401,8 @@ Digest § 5 states the rule and both invocations; this is what surrounds them.
|
|
|
401
401
|
`test` deposit buys nothing there: close logs `no credited capture stamp
|
|
402
402
|
covers this change set` and pays the whole suite on the serialized tail. The
|
|
403
403
|
worker's capture writes the content-digest stamp in the worktree, and
|
|
404
|
-
close's capture then exits on its freshness probe without spawning
|
|
405
|
-
`
|
|
404
|
+
close's capture then exits on its freshness probe without spawning the
|
|
405
|
+
coverage gate's `captureScript`. The stamp (beside its artifact) holds two digests — the scorable sources and
|
|
406
406
|
every suite input (all tracked and dirty paths but `baselines/` and the
|
|
407
407
|
coverage directory) — so any later commit or base-sync outside baseline
|
|
408
408
|
JSON spends it, and close re-captures.
|
|
@@ -121,8 +121,8 @@ than one Story** (a split always earns operator eyes, `--force-review` or
|
|
|
121
121
|
not), or when the operator asked to review (`--force-review`).
|
|
122
122
|
Under `--yes`, auto-proceed.
|
|
123
123
|
|
|
124
|
-
**One-for-one (tickets mode, one source → one Story)** — ask
|
|
125
|
-
|
|
124
|
+
**One-for-one (tickets mode, one source → one Story)** — ask the operator
|
|
125
|
+
(the host's question idiom, § 1.A): **Rewrite #N in place (Recommended)** or **File a new Story
|
|
126
126
|
and close #N** (`--no-rewrite-source`). Under `--yes`, rewrite
|
|
127
127
|
([ref](helpers/plan-reference.md)).
|
|
128
128
|
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,54 @@ All notable changes to this project will be documented in this file.
|
|
|
15
15
|
-->
|
|
16
16
|
<!-- markdownlint-disable-file MD004 MD012 MD037 -->
|
|
17
17
|
|
|
18
|
+
## [2.91.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.90.0...mandrel-v2.91.0) (2026-10-18)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
* **audit:** add the /audit-lean lens for grep-grounded reuse findings (refs [#5763](https://github.com/dsj1984/mandrel/issues/5763)) ([#5769](https://github.com/dsj1984/mandrel/issues/5769)) ([c770356](https://github.com/dsj1984/mandrel/commit/c77035646a1a697dc329d71bbf7b9513192a1b10))
|
|
24
|
+
* codex host parity: a first-available LLM review in the default chain, a doctor check that names it, and a host-mapping rule covering HITL questions and loop cadence ([#5741](https://github.com/dsj1984/mandrel/issues/5741)) ([#5752](https://github.com/dsj1984/mandrel/issues/5752)) ([4da251b](https://github.com/dsj1984/mandrel/commit/4da251b65395a4a84e3394ff7d9a5f172a3b8cf8))
|
|
25
|
+
* gate verdicts measure the change: CRAP joins module-scope arrows, duplication regresses on absolute lines, an untranspilable TS file is reported unscorable ([#5755](https://github.com/dsj1984/mandrel/issues/5755)) ([#5759](https://github.com/dsj1984/mandrel/issues/5759)) ([68197b2](https://github.com/dsj1984/mandrel/commit/68197b28b6467e387823b5ca4f18177143f90203))
|
|
26
|
+
* give the story-worker a smallest-complete-change ladder: reuse, stdlib, installed dep, one line, then the minimum, with the shortcut: comment form ([#5762](https://github.com/dsj1984/mandrel/issues/5762)) ([#5770](https://github.com/dsj1984/mandrel/issues/5770)) ([01c7020](https://github.com/dsj1984/mandrel/commit/01c70200295ba9d3eae08c7ccaf1ac84299d8e17))
|
|
27
|
+
* join each Story's landed diff size into the agent cost report so lines-per-Story and tokens-per-changed-line can be read before and after a worker rule changes ([#5766](https://github.com/dsj1984/mandrel/issues/5766)) ([#5772](https://github.com/dsj1984/mandrel/issues/5772)) ([9463d76](https://github.com/dsj1984/mandrel/commit/9463d763c4a530473598a90f370a8ca1522e14e6))
|
|
28
|
+
* make the close reviewer caller-aware at depth deep and record what it did not check: a callers block built from git grep, and a degradation whenever the diff or that block is truncated ([#5764](https://github.com/dsj1984/mandrel/issues/5764)) ([#5773](https://github.com/dsj1984/mandrel/issues/5773)) ([33b0cc6](https://github.com/dsj1984/mandrel/commit/33b0cc62fa91d6afcef8464ff3e633f648f98e14))
|
|
29
|
+
* one project.commands contract: a single resolver and defaults table, the coverage gate owns its capture script, capture spawns via the detected package manager ([#5737](https://github.com/dsj1984/mandrel/issues/5737)) ([#5750](https://github.com/dsj1984/mandrel/issues/5750)) ([0b1b171](https://github.com/dsj1984/mandrel/commit/0b1b171d23460ca595276a4e000a8a2435375427))
|
|
30
|
+
* one scorable-extension list drives the refresh predicates, the MI projection, native review and the duplication scanner; retire duplication.formats ([#5738](https://github.com/dsj1984/mandrel/issues/5738)) ([#5753](https://github.com/dsj1984/mandrel/issues/5753)) ([839b6cf](https://github.com/dsj1984/mandrel/commit/839b6cf715f4e8c352d25bf77d7ac5b2bb6e0a28))
|
|
31
|
+
* read `shortcut: <ceiling>, <trigger>` comments everywhere the framework judges code: an audit-exceptions adapter whose verdicts are the ledger, the shared lens rule, the guardrails convention, and one sentence for the close reviewer ([#5765](https://github.com/dsj1984/mandrel/issues/5765)) ([#5774](https://github.com/dsj1984/mandrel/issues/5774)) ([0c74524](https://github.com/dsj1984/mandrel/commit/0c745249ebac8a27c61865dbd44f8e71865990cc))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
* anchor .agentrc resolution on the working tree's git toplevel and apply GH_CONFIG_DIR at the gh boundary, not as a side effect of resolveConfig ([#5740](https://github.com/dsj1984/mandrel/issues/5740)) ([#5749](https://github.com/dsj1984/mandrel/issues/5749)) ([436844b](https://github.com/dsj1984/mandrel/commit/436844bc221dabe48946d86edf0ec0e7dddaff89))
|
|
37
|
+
* close out the Epic [#5744](https://github.com/dsj1984/mandrel/issues/5744) residue: runGh through child-exec, one provider-to-CLI source, and two test-timing band-aids replaced by root fixes ([#5756](https://github.com/dsj1984/mandrel/issues/5756)) ([#5757](https://github.com/dsj1984/mandrel/issues/5757)) ([3ffdcfc](https://github.com/dsj1984/mandrel/commit/3ffdcfc9b6773cb851ae8cb4be7f184271b12567))
|
|
38
|
+
* dead-exports gate exits non-zero when knip fails or overflows, instead of passing with zero rows ([#5736](https://github.com/dsj1984/mandrel/issues/5736)) ([#5745](https://github.com/dsj1984/mandrel/issues/5745)) ([d021612](https://github.com/dsj1984/mandrel/commit/d021612bcbbc456aa291f952278fed9513308b20))
|
|
39
|
+
* fix callers-context bogus symbols from prose: the deep review's declara… ([#5781](https://github.com/dsj1984/mandrel/issues/5781)) ([#5782](https://github.com/dsj1984/mandrel/issues/5782)) ([4e3c8fe](https://github.com/dsj1984/mandrel/commit/4e3c8fe0a0f227c5b8e20f9dfb62755d6f18de65))
|
|
40
|
+
* projects v2 scope detection recognises gh-exec classified errors, not just the fetch-path message ([#5735](https://github.com/dsj1984/mandrel/issues/5735)) ([#5746](https://github.com/dsj1984/mandrel/issues/5746)) ([95fe821](https://github.com/dsj1984/mandrel/commit/95fe821bca8b8bc1e33463dbe752d4f4a9cdc43f))
|
|
41
|
+
* ratchet child-process call sites on maxBuffer, not imports, and migrate the raw capture sites that can exceed 1 MiB ([#5739](https://github.com/dsj1984/mandrel/issues/5739)) ([#5751](https://github.com/dsj1984/mandrel/issues/5751)) ([ab7360d](https://github.com/dsj1984/mandrel/commit/ab7360dcd146f08386046c0f02592e950b7882a4))
|
|
42
|
+
* replace eight hand-rolled tmp-write-then-rename copies with one shared writeFileAtomic, and seven recursive directory walkers with one pruning walkFiles ([#5776](https://github.com/dsj1984/mandrel/issues/5776)) ([#5780](https://github.com/dsj1984/mandrel/issues/5780)) ([e927ad2](https://github.com/dsj1984/mandrel/commit/e927ad26d1c86b722701f4a54715e498fb6f4bed))
|
|
43
|
+
* **skills:** repair dead reference.md anchors in two skill capsules (refs [#4667](https://github.com/dsj1984/mandrel/issues/4667)) ([#5761](https://github.com/dsj1984/mandrel/issues/5761)) ([4c1752d](https://github.com/dsj1984/mandrel/commit/4c1752d5374fa23ad2f0297728589b5c7c689526))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
* bring the Claude command and agent projectors to the Codex projector shape: injectable modules behind thin CLIs, no env-var test seams ([#5742](https://github.com/dsj1984/mandrel/issues/5742)) ([#5748](https://github.com/dsj1984/mandrel/issues/5748)) ([5d13fbc](https://github.com/dsj1984/mandrel/commit/5d13fbcf0a7a27e0534b782d3fb77074bd71b212))
|
|
49
|
+
* drop the minimatch and ajv-formats runtime dependencies: standardise globs on picomatch and register the two JSON-schema formats Mandrel uses through one shared Ajv factory ([#5775](https://github.com/dsj1984/mandrel/issues/5775)) ([#5778](https://github.com/dsj1984/mandrel/issues/5778)) ([a00800a](https://github.com/dsj1984/mandrel/commit/a00800a848033858dbfb70fe5eaaf057e1b4c27e))
|
|
50
|
+
* retire seven small lean findings: parseArgs for four hand-rolled argv loops, ten main() forwarders, three slug copies, two isPlainObject copies, inline sleeps, two storyIdFromBranch forwarders and the issueToEpic alias ([#5777](https://github.com/dsj1984/mandrel/issues/5777)) ([#5779](https://github.com/dsj1984/mandrel/issues/5779)) ([7f9d7f2](https://github.com/dsj1984/mandrel/commit/7f9d7f2fea54d8541c6bb3c8f017b94046b8dc84))
|
|
51
|
+
* revert the callback-free scorable-extension regex once the CRAP statement-span join is on main ([#5758](https://github.com/dsj1984/mandrel/issues/5758)) ([#5760](https://github.com/dsj1984/mandrel/issues/5760)) ([8655f3f](https://github.com/dsj1984/mandrel/commit/8655f3f1a603cb745acc7a41f6fdd90e7f9779a4))
|
|
52
|
+
|
|
53
|
+
## [2.90.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.89.0...mandrel-v2.90.0) (2026-10-16)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
* surface Projects v2 scope failures instead of swallowing them, and backfill the board ([#5727](https://github.com/dsj1984/mandrel/issues/5727)) ([#5733](https://github.com/dsj1984/mandrel/issues/5733)) ([41bf87a](https://github.com/dsj1984/mandrel/commit/41bf87a94e2930d04ce4a8f374fb204bfca94e77))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
* coverage-capture: route the tree/content digest git calls through child-exec so large repos get a freshable stamp ([#5728](https://github.com/dsj1984/mandrel/issues/5728)) ([#5730](https://github.com/dsj1984/mandrel/issues/5730)) ([8919d41](https://github.com/dsj1984/mandrel/commit/8919d414e715afa9dd352a8c18cd41a72fbb2118))
|
|
64
|
+
* handoff and close gate children resolve .agentrc.json from the Story worktree, not the main checkout ([#5729](https://github.com/dsj1984/mandrel/issues/5729)) ([#5731](https://github.com/dsj1984/mandrel/issues/5731)) ([af4f4cf](https://github.com/dsj1984/mandrel/commit/af4f4cf05e7f7b05e75ab0418a366733206b84ad))
|
|
65
|
+
|
|
18
66
|
## [2.89.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.88.0...mandrel-v2.89.0) (2026-10-16)
|
|
19
67
|
|
|
20
68
|
|
|
@@ -18,10 +18,11 @@ import {
|
|
|
18
18
|
listGeneratedCodexSkills,
|
|
19
19
|
} from '../../../.agents/scripts/lib/codex/skills-projection.js';
|
|
20
20
|
|
|
21
|
-
// check: codex-skills-in-sync / codex-agents-in-sync
|
|
21
|
+
// check: codex-skills-in-sync / codex-agents-in-sync (and the Claude twins)
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Compare a generated tree against what its projector would write now
|
|
24
|
+
* Compare a generated tree against what its projector would write now,
|
|
25
|
+
* byte-for-byte. Shared by both hosts' parity checks.
|
|
25
26
|
* `readEntry(name)` returns the on-disk text or null.
|
|
26
27
|
*
|
|
27
28
|
* @param {{
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
* }} spec
|
|
35
36
|
* @returns {{ ok: boolean, detail: string, remedy?: string }}
|
|
36
37
|
*/
|
|
37
|
-
function projectionParity({
|
|
38
|
+
export function projectionParity({
|
|
38
39
|
expected,
|
|
39
40
|
onDisk,
|
|
40
41
|
readEntry,
|
|
@@ -69,7 +70,7 @@ function projectionParity({
|
|
|
69
70
|
* @param {string} file
|
|
70
71
|
* @returns {string | null}
|
|
71
72
|
*/
|
|
72
|
-
function readTextOrNull(file) {
|
|
73
|
+
export function readTextOrNull(file) {
|
|
73
74
|
try {
|
|
74
75
|
return fs.readFileSync(file, 'utf8');
|
|
75
76
|
} catch {
|
|
@@ -79,7 +80,7 @@ function readTextOrNull(file) {
|
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
82
|
* Parity of `.agents/skills/workflows/` against the workflow set — the Codex
|
|
82
|
-
* twin of `commands-in-sync
|
|
83
|
+
* twin of `commands-in-sync`.
|
|
83
84
|
*
|
|
84
85
|
* @param {{ projectRoot?: string, cwd?: () => string }} [opts]
|
|
85
86
|
* @returns {{ ok: boolean, detail: string, remedy?: string }}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// lib/cli/doctor-checks/llm-review.js — Doctor check: llm-review-provider.
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { applyLocalOverlay } from '../../../.agents/scripts/lib/config/agentrc-overlay.js';
|
|
6
|
+
import { DEFAULT_REVIEW_PROVIDERS } from '../../../.agents/scripts/lib/config/review-chain-default.js';
|
|
7
|
+
import { REVIEW_PROVIDER_CLIS } from '../../../.agents/scripts/lib/config/review-provider-clis.js';
|
|
8
|
+
import { readJsonSafe } from './read-json.js';
|
|
9
|
+
import { spawn } from './spawn.js';
|
|
10
|
+
|
|
11
|
+
const NATIVE_ONLY_ADVISORY =
|
|
12
|
+
'close runs native only — install claude or codex, or pin codeReview.providers';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* `delivery.codeReview.providers` from `.agentrc.json` with
|
|
16
|
+
* `.agentrc.local.json` merged over it; unset or empty is the default chain.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} projectRoot
|
|
19
|
+
* @param {{ readFileSync: Function }} fsImpl
|
|
20
|
+
* @returns {{ entries: ReadonlyArray<object>, pinned: boolean }}
|
|
21
|
+
*/
|
|
22
|
+
function readReviewChain(projectRoot, fsImpl) {
|
|
23
|
+
const committed =
|
|
24
|
+
readJsonSafe(path.join(projectRoot, '.agentrc.json'), fsImpl) ?? {};
|
|
25
|
+
let effective = committed;
|
|
26
|
+
try {
|
|
27
|
+
effective = applyLocalOverlay({ fsImpl, projectRoot, committed }).effective;
|
|
28
|
+
} catch {
|
|
29
|
+
// An unparseable overlay is the config check's to report.
|
|
30
|
+
}
|
|
31
|
+
const providers = effective?.delivery?.codeReview?.providers;
|
|
32
|
+
return Array.isArray(providers) && providers.length > 0
|
|
33
|
+
? { entries: providers, pinned: true }
|
|
34
|
+
: { entries: DEFAULT_REVIEW_PROVIDERS, pinned: false };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Which CLI will serve each LLM provider in the effective review chain.
|
|
39
|
+
* Fails only for a pinned non-optional provider whose CLI is missing — the
|
|
40
|
+
* same hard failure close would hit at construction.
|
|
41
|
+
*
|
|
42
|
+
* @param {{
|
|
43
|
+
* projectRoot?: string,
|
|
44
|
+
* cwd?: () => string,
|
|
45
|
+
* runner?: (cmd: string, args: string[], opts?: object) => { status: number|null },
|
|
46
|
+
* fsImpl?: { readFileSync: Function, existsSync: Function },
|
|
47
|
+
* platform?: string,
|
|
48
|
+
* }} [opts]
|
|
49
|
+
* @returns {{ ok: boolean, detail: string, remedy?: string }}
|
|
50
|
+
*/
|
|
51
|
+
export function runLlmReviewProvider({
|
|
52
|
+
projectRoot,
|
|
53
|
+
cwd,
|
|
54
|
+
runner = spawn,
|
|
55
|
+
fsImpl = fs,
|
|
56
|
+
platform = process.platform,
|
|
57
|
+
} = {}) {
|
|
58
|
+
const root = projectRoot ?? (cwd ?? (() => process.cwd()))();
|
|
59
|
+
const { entries, pinned } = readReviewChain(root, fsImpl);
|
|
60
|
+
const seen = new Map();
|
|
61
|
+
const onPath = (cli) => {
|
|
62
|
+
if (!seen.has(cli)) {
|
|
63
|
+
const r = runner(cli, ['--version'], {
|
|
64
|
+
shell: platform === 'win32',
|
|
65
|
+
timeout: 5000,
|
|
66
|
+
});
|
|
67
|
+
seen.set(cli, r?.status === 0);
|
|
68
|
+
}
|
|
69
|
+
return seen.get(cli);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const served = [];
|
|
73
|
+
const missing = [];
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
const clis = entry?.manualPrompt ? null : REVIEW_PROVIDER_CLIS[entry?.name];
|
|
76
|
+
if (!clis) continue;
|
|
77
|
+
const cli = clis.find(onPath);
|
|
78
|
+
if (cli) served.push(`${entry.name} via ${cli}`);
|
|
79
|
+
else if (entry.optional !== true) missing.push(entry.name);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (missing.length > 0) {
|
|
83
|
+
return {
|
|
84
|
+
ok: false,
|
|
85
|
+
detail: `codeReview.providers pins ${missing.join(', ')} without optional: true, but its CLI is not on PATH — close would fail at review`,
|
|
86
|
+
remedy:
|
|
87
|
+
'Install the missing CLI (`claude` or `codex`), mark the entry `optional: true`, or remove it from codeReview.providers.',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (served.length === 0) {
|
|
91
|
+
return {
|
|
92
|
+
ok: true,
|
|
93
|
+
detail: pinned
|
|
94
|
+
? 'the pinned codeReview.providers chain runs no LLM review on this host'
|
|
95
|
+
: NATIVE_ONLY_ADVISORY,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
ok: true,
|
|
100
|
+
detail: `${pinned ? 'pinned' : 'default'} chain reviews with ${served.join(', ')}`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// lib/cli/doctor-checks/project-access.js — Doctor check: github-project-access.
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { applyLocalOverlay } from '../../../.agents/scripts/lib/config/agentrc-overlay.js';
|
|
7
|
+
import { runGh } from '../../../.agents/scripts/lib/gh-exec.js';
|
|
8
|
+
import { isInsufficientScopes } from '../../../.agents/scripts/providers/github/projects-v2-graphql.js';
|
|
9
|
+
import { readJsonSafe } from './read-json.js';
|
|
10
|
+
import { spawn } from './spawn.js';
|
|
11
|
+
|
|
12
|
+
const REMEDY = 'Run `gh auth refresh -h github.com -s project`, then re-run.';
|
|
13
|
+
|
|
14
|
+
// A gh that cannot authenticate at all is gh-auth's failure, not this one's.
|
|
15
|
+
const GH_AUTH_RE = /gh auth login|not logged in|Bad credentials|HTTP 401/i;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `github.projectNumber` / `github.owner` from `.agentrc.json`, with
|
|
19
|
+
* `.agentrc.local.json` deep-merged over it (the resolver's one overlay).
|
|
20
|
+
*
|
|
21
|
+
* @param {string} projectRoot
|
|
22
|
+
* @param {{ readFileSync: Function }} fsImpl
|
|
23
|
+
* @returns {{ projectNumber: number|null, owner: string|null }}
|
|
24
|
+
*/
|
|
25
|
+
function readBoardConfig(projectRoot, fsImpl) {
|
|
26
|
+
const committed =
|
|
27
|
+
readJsonSafe(path.join(projectRoot, '.agentrc.json'), fsImpl) ?? {};
|
|
28
|
+
const github = effectiveConfig(fsImpl, projectRoot, committed).github ?? {};
|
|
29
|
+
const n = Number(github.projectNumber);
|
|
30
|
+
return {
|
|
31
|
+
projectNumber: Number.isInteger(n) && n > 0 ? n : null,
|
|
32
|
+
owner:
|
|
33
|
+
typeof github.owner === 'string' && github.owner ? github.owner : null,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The overlay merged over `committed`; an unparseable overlay is ignored here (the config check reports it). */
|
|
38
|
+
function effectiveConfig(fsImpl, projectRoot, committed) {
|
|
39
|
+
try {
|
|
40
|
+
return applyLocalOverlay({ fsImpl, projectRoot, committed }).effective;
|
|
41
|
+
} catch {
|
|
42
|
+
return committed;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** One rung's query: `organization` / `user` by login, else `viewer`. */
|
|
47
|
+
function rungArgs(root, owner, projectNumber) {
|
|
48
|
+
const query = owner
|
|
49
|
+
? `query($owner:String!,$number:Int!){${root}(login:$owner){projectV2(number:$number){id}}}`
|
|
50
|
+
: `query($number:Int!){viewer{projectV2(number:$number){id}}}`;
|
|
51
|
+
const args = ['api', 'graphql', '-f', `query=${query}`];
|
|
52
|
+
if (owner) args.push('-f', `owner=${owner}`);
|
|
53
|
+
args.push('-F', `number=${projectNumber}`);
|
|
54
|
+
return args;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Probe one rung.
|
|
59
|
+
*
|
|
60
|
+
* @returns {'found'|'miss'|'scope'|'defer'}
|
|
61
|
+
*/
|
|
62
|
+
function probeRung(runner, root, owner, projectNumber) {
|
|
63
|
+
const r = runGh(
|
|
64
|
+
rungArgs(root, owner, projectNumber),
|
|
65
|
+
{ timeout: 20_000 },
|
|
66
|
+
runner,
|
|
67
|
+
);
|
|
68
|
+
if (r.error) return 'defer';
|
|
69
|
+
const output = `${r.stdout ?? ''}\n${r.stderr ?? ''}`;
|
|
70
|
+
if (isInsufficientScopes({ message: output })) return 'scope';
|
|
71
|
+
if (r.status !== 0 && GH_AUTH_RE.test(output)) return 'defer';
|
|
72
|
+
try {
|
|
73
|
+
const json = JSON.parse(r.stdout || '{}');
|
|
74
|
+
if (json?.data?.[root]?.projectV2?.id) return 'found';
|
|
75
|
+
} catch {
|
|
76
|
+
// Non-JSON output is a miss for this rung.
|
|
77
|
+
}
|
|
78
|
+
return 'miss';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// check: github-project-access
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Can the active token read the configured Projects v2 board? No board →
|
|
85
|
+
* skipped; a gh that cannot run defers to `gh-auth`.
|
|
86
|
+
*
|
|
87
|
+
* @param {{ cwd?: () => string, fsImpl?: typeof fs, runner?: typeof spawn }} [opts]
|
|
88
|
+
* @returns {{ ok: boolean, detail: string, remedy?: string }}
|
|
89
|
+
*/
|
|
90
|
+
export function runProjectAccess({ cwd, fsImpl = fs, runner = spawn } = {}) {
|
|
91
|
+
const projectRoot = (cwd ?? (() => process.cwd()))();
|
|
92
|
+
const { projectNumber, owner } = readBoardConfig(projectRoot, fsImpl);
|
|
93
|
+
if (!projectNumber) {
|
|
94
|
+
return {
|
|
95
|
+
ok: true,
|
|
96
|
+
detail: 'skipped — no github.projectNumber configured',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const roots = owner ? ['organization', 'user'] : ['viewer'];
|
|
100
|
+
const target = `project #${projectNumber}${owner ? ` for ${owner}` : ''}`;
|
|
101
|
+
for (const root of roots) {
|
|
102
|
+
const outcome = probeRung(runner, root, owner, projectNumber);
|
|
103
|
+
if (outcome === 'found') return { ok: true, detail: `${target} readable` };
|
|
104
|
+
if (outcome === 'defer') {
|
|
105
|
+
return {
|
|
106
|
+
ok: true,
|
|
107
|
+
detail: 'skipped — gh cannot run or authenticate (see gh-auth)',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (outcome === 'scope') {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
detail: `token lacks the "project" scope — cannot read ${target}; board adds and Status flips are being skipped`,
|
|
114
|
+
remedy: REMEDY,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
ok: false,
|
|
120
|
+
detail: `${target} not found`,
|
|
121
|
+
remedy:
|
|
122
|
+
'Check github.projectNumber and github.owner in .agentrc.json (or `gh auth refresh -h github.com -s project` if the board is private).',
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -2,90 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
CLAUDE_AGENTS_DIR,
|
|
7
|
+
expectedClaudeAgents,
|
|
8
|
+
listGeneratedClaudeAgents,
|
|
9
|
+
} from '../../../.agents/scripts/lib/claude/agents-projection.js';
|
|
10
|
+
import {
|
|
11
|
+
CLAUDE_COMMANDS_DIR,
|
|
12
|
+
expectedClaudeCommands,
|
|
13
|
+
listGeneratedClaudeCommands,
|
|
14
|
+
} from '../../../.agents/scripts/lib/claude/commands-projection.js';
|
|
6
15
|
import { getDeliveryRouting } from '../../../.agents/scripts/lib/config/delivery-routing.js';
|
|
16
|
+
import { projectionParity, readTextOrNull } from './codex.js';
|
|
7
17
|
import { readJsonSafe } from './read-json.js';
|
|
8
18
|
|
|
19
|
+
const COMMANDS_REMEDY =
|
|
20
|
+
'Run `npm run sync:commands` to regenerate the `.claude/commands/` tree.';
|
|
21
|
+
const AGENTS_REMEDY =
|
|
22
|
+
'Run `mandrel sync-agents` to regenerate the `.claude/agents/` tree.';
|
|
23
|
+
|
|
9
24
|
// check: commands-in-sync
|
|
10
25
|
|
|
11
26
|
/**
|
|
12
|
-
* Parity of `.claude/commands
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* payload-wins shadowing; an unreadable source counts as projected.
|
|
27
|
+
* Parity of `.claude/commands/` against what the command projection would
|
|
28
|
+
* write now — byte-for-byte, so a same-name file with stale content fails as
|
|
29
|
+
* well as a missing or extra one.
|
|
16
30
|
*
|
|
17
31
|
* The root defaults to `process.cwd()`, never `resolveProjectRoot()` — that
|
|
18
32
|
* lands on `node_modules/mandrel/` in an installed consumer, where the
|
|
19
33
|
* command tree never exists, producing a permanent false "not synced".
|
|
20
34
|
*
|
|
21
|
-
* @param {{ projectRoot?: string, cwd?: () => string
|
|
35
|
+
* @param {{ projectRoot?: string, cwd?: () => string }} [opts]
|
|
22
36
|
* @returns {{ ok: boolean, detail: string, remedy?: string }}
|
|
23
37
|
*/
|
|
24
|
-
export function runCommandsInSync({
|
|
25
|
-
projectRoot
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
return fs.readdirSync(dir).filter((f) => f.endsWith('.md'));
|
|
37
|
-
} catch {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const readSource =
|
|
42
|
-
readFile ??
|
|
43
|
-
((file) => {
|
|
44
|
-
try {
|
|
45
|
-
return fs.readFileSync(file, 'utf8');
|
|
46
|
-
} catch {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const srcDirs = [
|
|
52
|
-
path.join(root, '.agents', 'workflows'),
|
|
53
|
-
path.join(root, '.agents', 'local', 'workflows'),
|
|
54
|
-
];
|
|
55
|
-
const destDir = path.join(root, '.claude', 'commands');
|
|
56
|
-
|
|
57
|
-
// Top-level .md only (helpers/ are included modules, not commands).
|
|
58
|
-
const expected = new Set();
|
|
59
|
-
for (const srcDir of srcDirs) {
|
|
60
|
-
for (const f of listDir(srcDir)) {
|
|
61
|
-
if (f.startsWith('.')) continue;
|
|
62
|
-
const content = readSource(path.join(srcDir, f));
|
|
63
|
-
if (content != null && isCommandExcluded(content)) continue;
|
|
64
|
-
expected.add(f);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const sources = [...expected].sort();
|
|
68
|
-
const dests = listDir(destDir)
|
|
69
|
-
.filter((f) => !f.startsWith('.'))
|
|
70
|
-
.sort();
|
|
71
|
-
|
|
72
|
-
const dstSet = new Set(dests);
|
|
73
|
-
const missing = sources.filter((f) => !dstSet.has(f));
|
|
74
|
-
const extra = dests.filter((f) => !expected.has(f));
|
|
75
|
-
|
|
76
|
-
if (missing.length === 0 && extra.length === 0) {
|
|
77
|
-
return { ok: true, detail: `${sources.length} commands up to date` };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const parts = [];
|
|
81
|
-
if (missing.length > 0) parts.push(`${missing.length} not synced`);
|
|
82
|
-
if (extra.length > 0) parts.push(`${extra.length} stale`);
|
|
83
|
-
return {
|
|
84
|
-
ok: false,
|
|
85
|
-
detail: parts.join(', '),
|
|
86
|
-
remedy:
|
|
87
|
-
'Run `npm run sync:commands` to regenerate the `.claude/commands/` tree.',
|
|
88
|
-
};
|
|
38
|
+
export function runCommandsInSync({ projectRoot, cwd } = {}) {
|
|
39
|
+
const root = projectRoot ?? (cwd ?? (() => process.cwd()))();
|
|
40
|
+
const destDir = path.join(root, ...CLAUDE_COMMANDS_DIR.split('/'));
|
|
41
|
+
return projectionParity({
|
|
42
|
+
expected: () => expectedClaudeCommands({ projectRoot: root }),
|
|
43
|
+
onDisk: listGeneratedClaudeCommands(destDir),
|
|
44
|
+
readEntry: (rel) => readTextOrNull(path.join(destDir, rel)),
|
|
45
|
+
noun: 'commands',
|
|
46
|
+
where: `${CLAUDE_COMMANDS_DIR}/`,
|
|
47
|
+
remedy: COMMANDS_REMEDY,
|
|
48
|
+
});
|
|
89
49
|
}
|
|
90
50
|
|
|
91
51
|
// check: agents-in-sync
|
|
@@ -97,15 +57,11 @@ export function runCommandsInSync({
|
|
|
97
57
|
* `.agentrc.local.json` (local wins).
|
|
98
58
|
*
|
|
99
59
|
* @param {string} projectRoot
|
|
100
|
-
* @param {typeof fs} fsImpl
|
|
101
60
|
* @returns {boolean}
|
|
102
61
|
*/
|
|
103
|
-
function resolveRoleScopedAgentsFlag(projectRoot
|
|
104
|
-
const base = readJsonSafe(path.join(projectRoot, '.agentrc.json'),
|
|
105
|
-
const local = readJsonSafe(
|
|
106
|
-
path.join(projectRoot, '.agentrc.local.json'),
|
|
107
|
-
fsImpl,
|
|
108
|
-
);
|
|
62
|
+
function resolveRoleScopedAgentsFlag(projectRoot) {
|
|
63
|
+
const base = readJsonSafe(path.join(projectRoot, '.agentrc.json'), fs);
|
|
64
|
+
const local = readJsonSafe(path.join(projectRoot, '.agentrc.local.json'), fs);
|
|
109
65
|
const merged = {
|
|
110
66
|
delivery: {
|
|
111
67
|
routing: {
|
|
@@ -118,88 +74,57 @@ function resolveRoleScopedAgentsFlag(projectRoot, fsImpl) {
|
|
|
118
74
|
}
|
|
119
75
|
|
|
120
76
|
/**
|
|
121
|
-
* Parity of `.claude/agents
|
|
122
|
-
* at `process.cwd()` as in `commands-in-sync`)
|
|
123
|
-
* fatal while `roleScopedAgents`
|
|
124
|
-
*
|
|
125
|
-
* is off. Drift in a
|
|
77
|
+
* Parity of `.claude/agents/` against what the agent projection would write
|
|
78
|
+
* now (root anchored at `process.cwd()` as in `commands-in-sync`),
|
|
79
|
+
* byte-for-byte. A never-materialized tree is fatal while `roleScopedAgents`
|
|
80
|
+
* is on — the acceptance critic would silently fail to spawn and fall back to
|
|
81
|
+
* a weaker inline critic — and advisory when it is off. Drift in a
|
|
82
|
+
* materialized tree always fails.
|
|
126
83
|
*
|
|
127
84
|
* @param {{
|
|
128
85
|
* projectRoot?: string,
|
|
129
86
|
* cwd?: () => string,
|
|
130
|
-
* readDir?: (dir: string) => string[],
|
|
131
|
-
* fsImpl?: typeof fs,
|
|
132
87
|
* roleScopedAgents?: boolean,
|
|
133
88
|
* }} [opts]
|
|
134
89
|
* @returns {{ ok: boolean, detail: string, remedy?: string }}
|
|
135
90
|
*/
|
|
136
|
-
export function runAgentsInSync({
|
|
137
|
-
projectRoot
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
return fsImpl.readdirSync(dir).filter((f) => f.endsWith('.md'));
|
|
150
|
-
} catch {
|
|
151
|
-
return [];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const srcDir = path.join(root, '.agents', 'agents');
|
|
156
|
-
const destDir = path.join(root, '.claude', 'agents');
|
|
157
|
-
|
|
158
|
-
const sources = listDir(srcDir)
|
|
159
|
-
.filter((f) => !f.startsWith('.'))
|
|
160
|
-
.sort();
|
|
161
|
-
const dests = listDir(destDir)
|
|
162
|
-
.filter((f) => !f.startsWith('.'))
|
|
163
|
-
.sort();
|
|
164
|
-
|
|
165
|
-
if (dests.length === 0) {
|
|
166
|
-
if (sources.length === 0) {
|
|
167
|
-
return { ok: true, detail: '0 agents up to date' };
|
|
91
|
+
export function runAgentsInSync({ projectRoot, cwd, roleScopedAgents } = {}) {
|
|
92
|
+
const root = projectRoot ?? (cwd ?? (() => process.cwd()))();
|
|
93
|
+
const destDir = path.join(root, ...CLAUDE_AGENTS_DIR.split('/'));
|
|
94
|
+
const onDisk = listGeneratedClaudeAgents(destDir);
|
|
95
|
+
const expected = () => expectedClaudeAgents({ projectRoot: root });
|
|
96
|
+
|
|
97
|
+
if (onDisk.length === 0) {
|
|
98
|
+
let size;
|
|
99
|
+
try {
|
|
100
|
+
size = expected().size;
|
|
101
|
+
} catch (err) {
|
|
102
|
+
return { ok: false, detail: err.message, remedy: AGENTS_REMEDY };
|
|
168
103
|
}
|
|
104
|
+
if (size === 0) return { ok: true, detail: '0 agents up to date' };
|
|
169
105
|
const resolvedFlag =
|
|
170
106
|
typeof roleScopedAgents === 'boolean'
|
|
171
107
|
? roleScopedAgents
|
|
172
|
-
: resolveRoleScopedAgentsFlag(root
|
|
108
|
+
: resolveRoleScopedAgentsFlag(root);
|
|
173
109
|
if (!resolvedFlag) {
|
|
174
110
|
return {
|
|
175
111
|
ok: true,
|
|
176
|
-
detail: `${
|
|
112
|
+
detail: `${size} agent def(s) not materialized (roleScopedAgents is disabled)`,
|
|
177
113
|
};
|
|
178
114
|
}
|
|
179
115
|
return {
|
|
180
116
|
ok: false,
|
|
181
|
-
detail: `${
|
|
182
|
-
remedy:
|
|
183
|
-
'Run `mandrel sync-agents` to regenerate the `.claude/agents/` tree.',
|
|
117
|
+
detail: `${size} agent def(s) not yet materialized in .claude/agents/`,
|
|
118
|
+
remedy: AGENTS_REMEDY,
|
|
184
119
|
};
|
|
185
120
|
}
|
|
186
121
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const parts = [];
|
|
197
|
-
if (missing.length > 0) parts.push(`${missing.length} not synced`);
|
|
198
|
-
if (extra.length > 0) parts.push(`${extra.length} stale`);
|
|
199
|
-
return {
|
|
200
|
-
ok: false,
|
|
201
|
-
detail: parts.join(', '),
|
|
202
|
-
remedy:
|
|
203
|
-
'Run `mandrel sync-agents` to regenerate the `.claude/agents/` tree.',
|
|
204
|
-
};
|
|
122
|
+
return projectionParity({
|
|
123
|
+
expected,
|
|
124
|
+
onDisk,
|
|
125
|
+
readEntry: (name) => readTextOrNull(path.join(destDir, name)),
|
|
126
|
+
noun: 'agents',
|
|
127
|
+
where: `${CLAUDE_AGENTS_DIR}/`,
|
|
128
|
+
remedy: AGENTS_REMEDY,
|
|
129
|
+
});
|
|
205
130
|
}
|