Repository navigation
Write an AGENTS.md at the top of a ledger (#63) - #121
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #63.
What changed
Code (
packages/ledger/ledger.ts):NAMED_EXTRASis the list of extras ledger: ignore what the format doesn't name, instead of refusing or reporting it #104 left empty, andAGENTS.mdis 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.openOrCreatewrites each named extra after the marker with an exclusive create (createOnce, factored out ofcreateMarker). One that is already there is left alone, whatever it holds.inspectcounts a folder that holds only named extras as empty, so a sync that deliversAGENTS.mdbeforeLEDGERstill lets the folder open.#scandoes not list them instatus.ignored.AGENTS.mdis read as a writer, like any folder at the top.Spec (
packages/ledger/multi-writer.md):AGENTS.mdis 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.mdsays the same.For the reviewer
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.openWriterdoes not write it. Its test says it puts nothing in the folder but its own directory, and that stays true.Tests
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 instatus.ignored; a folder holding onlyAGENTS.mdinspects asmissingand opens; a folder namedAGENTS.mdholding a segment is folded as a writer.AGENTS.md. TheopenWriterone compares against the folder as it was beforeopenWriterran, so it still checks thatopenWriteradds only its own directory.npm test(all workspaces),npm run typecheckand the app's lint pass.🤖 Generated with Claude Code