Skip to content

feat(update,fix,doctor): auto-populate markers, validate YAML/model ids, add agentrig fix + --auto-fix - #15

Merged
doidor merged 1 commit into
mainfrom
doidor/update-workflow-improvements
Jun 10, 2026
Merged

feat(update,fix,doctor): auto-populate markers, validate YAML/model ids, add agentrig fix + --auto-fix#15
doidor merged 1 commit into
mainfrom
doidor/update-workflow-improvements

Conversation

@doidor

@doidor doidor commented Jun 10, 2026

Copy link
Copy Markdown
Owner

What this PR does

Implements all 9 improvements reported from the @doidor/markbook agentrig update experience, so the next update on any target repo no longer needs the surgical hand-patching that motivated the report.

# Item Implementation
1 Marker populator — the <!-- AGENTRIG:skills-inventory:start --> block in AGENTS.md is auto-rewritten by both compile and update; enumerates .agents/skills/ on disk so user-added skills (e.g. the 6 markbook-* skills in this very repo) appear alongside AgentRig-bundled ones src/core/markers.ts (new), src/core/install.ts (filesystem walker)
2 YAML validation gates update — uses parseAllDocuments so multi-doc scenario files are tolerated; broken state-machine.yml now blocks the update src/core/validate.ts (new)
3 Model-ID validation against the SDK registry — live listModels() when available, curated allowlist as offline fallback, "did you mean…" suggestions src/core/validate.ts, surfaced in doctor and update
4 agentrig fix + agentrig update --auto-fix — deterministic repair engine; restores broken YAML from canonical and replaces unknown model ids (e.g. the retired gpt-5) with the safe auto fallback; writes .bak backups; no agent / network needed src/core/fix.ts (new), src/commands/fix.ts (new)
5 --diff drift classification — preserved files tagged 🔴 broken / 🟡 stale / 🟢 enhancement / ⚪ mixed with a per-severity summary at the top src/commands/update.ts:diffPreserved
6 --skip-agent enumerates preserved files inline — no more "11 files preserved" without naming them src/commands/update.ts:logFileList
7 New files grouped by parent dir in the post-install summary same
8 doctor detects npm-link installs + checks npm latestlinked-checkout vs registry provenance, surfaces validation findings (YAML / model-id) as exit-blocking failures src/commands/doctor.ts:detectInstallProvenance
9 Reconciliation historystate.json.reconciled[] records per-file decisions + the canonical hash at decision time; the next update skips re-prompting on files the user consciously diverged on, unless canonical has drifted past the recorded hash src/core/state.ts:ReconciledRecord, src/commands/update.ts:alreadyDivergedOn

Audit upgrade

  • New marker-populated check type in both src/core/audit.ts and knowledge/templates/eval/static-audit.mjs so CLI + in-repo audit stay in lock-step.
  • agents-skills-inventory upgraded from a loose file-contains substring match to marker-populated — the audit now fails (correctly) if the block is empty, has unfilled placeholders, or omits any skill under .agents/skills/. This is what surfaced the disk-enumeration bug fixed in Automate releases via Changesets #1.

Bonus find logged as a gotcha

The new strict check immediately caught a latent bug: the original skillsInventory() only iterated manifest.artifacts, so user-added skills under .agents/skills/ were silently dropped from the populated block. Fixed and logged in .agents/wiki/skills-inventory-populator-enumerates-disk.md per critical-rule #2.

Docs

  • README.md — new fix row + --auto-fix flag in Commands table; new "Self-healing the install" subsection.
  • docs/commands.md — extended update, compile, doctor; new fix section.
  • docs/getting-started.md — iterate block now includes --auto-fix + fix.
  • knowledge/templates/AGENTS.md — notes that the skills-inventory marker is auto-populated.

Verification

  • npm run build clean under TypeScript strict.
  • CLI audit + in-repo static-audit.mjs both 100% / 100%.
  • Round-trip:
    1. Broke .agentrig/harness/state-machine.yml (appended invalid YAML).
    2. Injected model: gpt-5 (retired ID) into .agentrig/agents/developer.yml.
    3. eval --static → P1 + P2 FAIL.
    4. doctor → surfaced both validation findings + "did you mean…" suggestions + linked-checkout detection.
    5. agentrig fix → restored state-machine.yml from canonical, replaced gpt-5 with auto.
    6. eval --static → back to 100%.
  • Knowledge bundle bumped 0.5.0 → 0.6.0; Changeset at .changeset/update-workflow-improvements.md (minor bump).

Out of scope

  • New principles or rules.
  • Dynamic eval pipeline.
  • Provider abstraction beyond the existing validateModel hook.

…ds, add agentrig fix + --auto-fix

Closes the entire feedback loop from the markbook update-experience report — fewer
surgical edits after `agentrig update` on any target repo.

What changed
============

1. Marker populator (src/core/markers.ts). The <!-- AGENTRIG:skills-inventory:start -->
   ... :end --> block in AGENTS.md is now rewritten deterministically by both `compile`
   AND `update`. `skillsInventory()` walks .agents/skills/ on disk (with manifest
   fallback) so user-added skills appear alongside AgentRig-bundled ones — surfaced by
   running on this repo's own 6 markbook-* skills.

2. YAML validation (src/core/validate.ts). `validateYaml()` parses every
   .agentrig/**/*.yml using `parseAllDocuments` so multi-doc scenario files are
   tolerated. `update` runs it post-install and exits non-zero on syntax errors.

3. Model-ID validation. `validateModelIds()` matches every .agentrig/agents/*.yml's
   `model:` against the Copilot SDK registry (live, when reachable) or a curated allowlist
   (offline fallback), with "did you mean…" suggestions.

4. `agentrig fix` + `agentrig update --auto-fix`. New deterministic repair engine
   (src/core/fix.ts): restores broken YAML from canonical, replaces unknown model ids
   with the safe `auto` fallback. Writes .bak backups; no agent / network needed.

5. `--diff` drift classification. Preserved files tagged 🔴 broken / 🟡 stale /
   🟢 enhancement / ⚪ mixed with a per-severity summary at the top.

6. `update` enumerates added + preserved files inline (no more "11 files preserved"
   without naming them).

7. New files grouped + summarized by parent dir.

8. `doctor` install provenance + model-ID validation. Detects when the global
   `agentrig` binary resolves to a linked checkout vs the registry, and surfaces
   YAML / model-id validation findings; exits non-zero on any blocker.

9. Reconciliation history (state.json.reconciled[]). Records every preserved-file
   decision with a canonical hash so a future `update` skips re-prompting on files the
   user has consciously diverged on — unless canonical has drifted past the recorded
   hash.

Audit changes
=============

- New `marker-populated` check type in BOTH src/core/audit.ts and
  knowledge/templates/eval/static-audit.mjs (the in-repo audit) so they stay in lock-step.
- `agents-skills-inventory` upgraded from a loose `file-contains` substring match to
  `marker-populated` — the audit now fails (correctly) if the block is empty, has
  unfilled placeholders, or omits any skill under .agents/skills/.
- Knowledge bundle bumped 0.5.0 → 0.6.0; Changeset at
  .changeset/update-workflow-improvements.md.

Docs
====

- README: new `fix` row + `--auto-fix` flag in Commands table; new "Self-healing the
  install" subsection.
- docs/commands.md: extended `update`, `compile`, `doctor`; new `fix` section.
- docs/getting-started.md: iterate block includes `--auto-fix` + `fix`.
- knowledge/templates/AGENTS.md: notes that the skills-inventory marker is auto-populated.
- .agents/wiki/skills-inventory-populator-enumerates-disk.md (new): gotcha log for the
  disk-enumeration fix (per critical rule #2).

Verification
============

- `npm run build` clean under TypeScript strict.
- CLI audit + in-repo `static-audit.mjs` both 100% / 100%.
- Round-trip: broke state-machine.yml + injected `model: gpt-5` → both audits caught it
  → `agentrig fix` restored both → 100% recovered.
- Doctor on this dev checkout correctly reports `linked checkout` + `npm latest: 0.10.0`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@doidor
doidor merged commit 3d04ba8 into main Jun 10, 2026
4 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant