Skip to content

AGENTS.md size budget (agents-md.maxBytes) - #66

Merged
llima merged 22 commits into
mainfrom
feat/agents-md-budget
Oct 18, 2026
Merged

llima merged 22 commits into
mainfrom
feat/agents-md-budget

Conversation

@llima

@llima llima commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Version bumped to 0.32.0, rebased onto main after Import reads a Claude rule's paths: as its scope #65 (0.31.0) merged. Merging publishes craftar@0.32.0 to npm after approval in the npm environment.
  • A size budget for the generated AGENTS.md: the param agents-md.maxBytes (a recipe default, the profile's params, or overrides.params in craftar.yaml / craftar.local.yaml), default 32768 (Codex's project_doc_max_bytes), 0 turns it off; an invalid value is a warning and the default applies.
  • Every plan over the budget warns once, naming at most 5 rule bodies by name and bytes (always-on, and scoped rules AGENTS.md embeds because no target writes them), never their content.
  • Opt-in failure: only an explicitly set budget makes sync --check, status (text and --json — keys unchanged, reason in warnings) and diff --exit-code with no [path] exit 1, with error: AGENTS.md is N bytes, over the budget of M set by agents-md.maxBytes and its fix. A writing sync still writes. doctor gains the check id agents-md-size (ok / warn over the default / error over a set budget), reporting the cause once.
  • agents-md.maxBytes is reserved from forge unify extraction and import inference, like kiro.banner.

Upgrading

  • No emitted byte changes. A workspace whose AGENTS.md is above 32768 bytes now gets a warning on every plan, and doctor --strict exits 1 for it (the new warn); set agents-md.maxBytes (or 0) to decide it.
  • sync --check's out-of-sync exit is now through process.exitCode (a piped listing is no longer cut).

Test plan

  • npm run typecheck — pass
  • npm run build — pass
  • npx vitest run --exclude test/ci.test.ts — 3006 passed, 8 skipped; oracle skipped (no fixture on the machine that ran it)
  • New tests: test/agents-md-budget.test.ts (measure, both warning forms, layers incl. recipe default and craftar.local.yaml, invalid value, top-5 with embedded scoped rules, reserved key) and test/agents-md-budget-cli.test.ts (sync --check, status, status --json, diff in every form, writing sync, doctor levels and one-cause)
  • Not covered by a test, by choice: two writers of AGENTS.md (only the agents-md emitter writes it today)
  • Rebased onto the 0.31.0 main; full suite 3047 passed, 8 skipped; confirmation review clean

llima added 22 commits October 18, 2026 09:15
Adds core and CLI tests for the agents-md.maxBytes budget feature.
All tests fail as expected — the feature is not yet implemented.
Adds Plan.agentsMd field with bytes, maxBytes, explicit flag, and per-rule sizes.
The emitter reports each always-on rule's byte size through a new callback.
…plicit AGENTS.md budget

Adds budgetRefusalBlock helper and uses it in status, sync --check, and diff.
Updates command descriptions to mention the budget.
Reports ok when within budget or budget is off, warn when over default budget,
and error when over explicit budget.
Adds documentation for the AGENTS.md size budget feature in the Targets section.
Fixes regression where 'workspace in sync' was printed even when refusals were present.
Split agentsMdRefusal into message and fix parts shared with doctor.
Exact messages for ok (within/off), warn (default exceeded), error (explicit).
Remove misleading comment about leading zeros and dead n < 0 check.
Compute agentsMdOverBudget once in diff command.
- agents-md paragraph: where to set it, byte counting, 5 rules max
- sync --check: also exits 1 for explicit budget
- status: also exits 1 for explicit budget
- diff --exit-code: also exits 1 for explicit budget
- doctor: agents-md-size check with levels
- Upgrading 'to the next release' entry
Two distinct warning formats for default vs explicit budget.
The plan check is ok when agents-md-size reports the budget.
A scoped rule no target writes is embedded whole and counts toward the size; it is now listed
as "(scoped, N bytes)" and the fix text names both ways to shrink the file.
…on --exit-code

Same shape as the unset-params refusal: diff <path> --exit-code no longer hides the block. The
budget is measured on the deduplicated plan, and the CLI tests now prove the budget alone fails.
Reserved beside kiro.banner; the key now lives with the agents-md emitter so extract.ts reads it
without importing sync.ts.
The two warning forms, embedded scoped rules counted, the invalid value, diff's block in every
form, doctor's one check, and the Upgrading lines for status --json and doctor --strict.
…rding

One builder per message (default and set), the emitter's report is required on its context, the
rule list sorts without the locale, and a file with no rule body ends the warning at the budget.
…eholder

The heading follows the placeholder /open-pr renames; status's row says the listing prints before
the budget block; diff's --help names the budget.
…unset parameter

No block on stderr under --json: the reason is the budget line in warnings. Pins the warning with
no rule body, and the test EmitBase gains the agents-md report.
Only craftar mcp's status tool and the ui's status view carry the warning; workspaces, forge
impact and next sync: describe a writing sync, which still succeeds.
…nging the row

The previous wording said it did not show it; the row lists every plan warning, only an unset
declared parameter makes it an error.
@llima
llima force-pushed the feat/agents-md-budget branch from df61993 to 82ef5a7 Compare October 18, 2026 12:32
@llima
llima merged commit 5031cd8 into main Oct 18, 2026
8 checks passed
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