Skip to content

Write an AGENTS.md at the top of a ledger (#63) - #121

Merged
shovon merged 1 commit into
mainfrom
agents-md-63
Oct 28, 2026
Merged

shovon merged 1 commit into
mainfrom
agents-md-63

Conversation

@shovon

@shovon shovon commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Closes #63.

What changed

Code (packages/ledger/ledger.ts):

  • NAMED_EXTRAS is the list of extras ledger: ignore what the format doesn't name, instead of refusing or reporting it #104 left empty, and AGENTS.md is its first entry, with the exact bytes every build of format 1 writes. The text says the folder is a ledger written by Pb Notes, points to https://github.com/shovon/pbnotes for the format, and says not to modify, rename or delete anything by hand.
  • openOrCreate writes each named extra after the marker with an exclusive create (createOnce, factored out of createMarker). One that is already there is left alone, whatever it holds.
  • inspect counts a folder that holds only named extras as empty, so a sync that delivers AGENTS.md before LEDGER still lets the folder open. #scan does not list them in status.ignored.
  • Only a file counts. A folder named AGENTS.md is read as a writer, like any folder at the top.

Spec (packages/ledger/multi-writer.md): AGENTS.md is listed under "Named extras" and in the layout, the opening table and the "counts as empty" rule mention named extras, and the tests section covers the new test. app/CLAUDE.md says the same.

For the reviewer

  • Backfill, for now. The file is written on every open, not only on creation, so ledgers made before this get one too. The cost is that a user who deletes it gets it back on the next open. ledger: stop backfilling AGENTS.md into existing ledgers #106 limits it to creation.
  • Best effort. The writes go through Promise.allSettled, so a folder that cannot take the file (read-only, full) still opens. The ledger is whole without it. The cost is that a failed write is silent.
  • The text is now fixed. Under ledger: ignore what the format doesn't name, instead of refusing or reporting it #104's rule for files that several writers may create, every build of one format version writes the same bytes. Changing the wording means a new format version.
  • openWriter does not write it. Its test says it puts nothing in the folder but its own directory, and that stays true.

Tests

  • New test in ledger.test.ts: a new ledger gets the exact bytes; an existing ledger without one gets one; one already there is not overwritten and is not in status.ignored; a folder holding only AGENTS.md inspects as missing and opens; a folder named AGENTS.md holding a segment is folded as a writer.
  • Three tests that listed the top of a folder now expect AGENTS.md. The openWriter one compares against the folder as it was before openWriter ran, so it still checks that openWriter adds only its own directory.
  • npm test (all workspaces), npm run typecheck and the app's lint pass.

🤖 Generated with Claude Code

An agent dropped into a project folder saw a LEDGER file and folders of
segments, and nothing telling it what they were. It might tidy them, edit a
segment, or guess at the format.

openOrCreate now writes an AGENTS.md after the marker: it says the folder is
a ledger written by Pb Notes, points to the repo for the format, and says not
to change anything by hand. It is the first named extra under #104: an
exclusive create, never rewritten, fixed bytes per format version. One that
is already there is left alone. The write is best effort, so a read-only or
full folder still opens. openWriter does not write it.

It is written on every open, so ledgers made before this get one too. #106
limits that to creation.

inspect counts a folder holding only named extras as empty, so a sync that
delivers AGENTS.md before LEDGER still lets the folder open, and #scan does
not list them in status.ignored. A folder named AGENTS.md is still read as a
writer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shovon
shovon merged commit 2cb83e4 into main Oct 28, 2026
1 check 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.

ledger: write an AGENTS.md at the root of a new ledger

1 participant