Repository navigation
Releases
v0.0.4-dev.2
What's Changed
- ci(release): publish to npm with trusted publishing instead of a token by @willgosnold in #380
Full Changelog: v0.0.4-dev.1...v0.0.4-dev.2
v0.0.4-dev.1
A failed track can be retried, and a missing change copy gets a message
When patchbook track failed after its sync, such as when .patchbook/config.toml couldn't be written, it left the new upstream's pin in upstream.lock and its vendored copy behind. Running it again with another URL was then refused, because the vendored copy it left behind was in the way. Now a failed track puts the lock, the vendored copy and the config back as they were, and the same name can be tracked again.
patchbook sync used to stop with a stack trace when a change's base/<file>.pb or ours/<file>.pb was missing. Now it fails with a patchbook: message that names each change, file and missing copy, both copies when both are gone, and changes nothing. Restore the copies, or remove the edit from the change, and sync again (#10).
An edited copy keeps following upstream
Copy an upstream file, commit so record writes copy skills/a -> skills/b, then edit skills/b/SKILL.md and commit. record and the commit hook used to write replace skills/b/SKILL.md, a frozen copy, so skills/b missed every later upstream change to skills/a, and status said nothing. Now they write file skills/b/SKILL.md, a file edit on the copy's own path whose base is upstream's skills/a/SKILL.md. sync merges upstream's changes to skills/a into it. An upstream change that overlaps your edit is a conflict, which sync reports and status, build and the commit hook refuse, as for any file edit. skills/a still builds from upstream, without your edit. The file edit applies where the replace did in the series, so a later hand-written copy or move of skills/b still builds your edit, and record writes it only into the change with the copy or a later one. An edited rename of a file that a copy still builds from is now move plus a file edit on the new path, where it was delete plus add. Once a copy has its own file edit, an edit to its source is a file edit as well, where it was a replace. Deleting the edited copy takes its file edit out of the change and records a delete, unless a later copy or move reads it, when the edit stays. An edited copy that isn't text, or whose source upstream makes binary, keeps your bytes and builds, as the replace did, since sync merges only text. sync then moves its base to upstream's file, lists it in replacedUpstreamChanged and says on stderr that it kept yours. To take upstream's file instead, write it over the copy and run patchbook record. A copy's file edit now needs its base copy, and status and build refuse and name the change and the missing copy when it is gone, where the replace built the frozen copy without one. A copy recorded as a replace before this release stays one (#317).
A partial commit can't move the upstream pin without its vendored copy
git commit -- note.txt .patchbook/upstream.lock after a patchbook sync used to commit the new pin and leave the vendored copy at the old one, and a clone's status then failed with vendor/extra (tree ...) differs from the pin. The hook now refuses that commit before it records or builds anything, and names the upstream, the lock and the vendor folder. Add the lock and the folder to the paths you name, or run git add on the lock, and on the file it points to when it is a link, and make a full commit, where the hook stages the pinned copy. When the lock is a link to a file in the repo, name that file too. When git doesn't know a path yet, such as the folder of a first vendoring, the message says to git add it first, since git commit -- <path> fails on a path git doesn't know. A refused commit leaves HEAD, your index and your working files as they were. A partial commit that doesn't move the pin, such as one that only names note.txt, is not refused by this check, including when HEAD's lock is a link that leads out of the repo. A copy that differs from the pin still gets the message that it differs from the pin. The message for an unstaged upstream.lock gives the same advice. It names the lock, the file a linked lock points to, the copies, and any other unstaged build input, where it said that naming the lock alone was enough (#227).
Resolve change conflicts before committing
After a conflicted patchbook sync, the commit hook now refuses the commit and names the change's ours/<file>.pb to resolve. Previously it warned and committed the conflict markers. The check covers every change, including a copy hidden by a later edit, and patched paragraph entries. Resolve the markers in the named file, stage it, and commit again. A refused commit leaves HEAD, the index and the working files unchanged. If recording staged output would introduce markers, the hook restores that recording, refuses the commit and names the staged file to fix (#276).
Markers that upstream itself holds don't stop a commit. For a copy that the last sync reported as conflicted in .patchbook/last-sync.json, the hook refuses while the copy holds a conflict block, from a <<<<<<< line through the next >>>>>>> line, that its base copy holds fewer times. So it catches the conflict even when upstream's file holds marker text of its own. That holds only until the sync is committed, meaning HEAD's upstream.lock pins the report's to commit for that upstream. Once you have resolved the copy and committed, a later edit inside upstream's literal block commits as before. For any other copy, or for every copy when last-sync.json is missing or can't be read, it refuses only when the copy holds more marker lines than its base copy. A HEAD with no commit, no upstream.lock, an upstream.lock that is a link or doesn't parse, or no entry for that upstream pins nothing, so a listed copy gets the block rule. It refuses a paragraph entry whose patched text holds more marker lines than its upstream text.
status reports unrecorded output and stray entries in changes/
status said "no problems" while build refused output files that were edited, added or deleted by hand since the last build, including a paragraph edit that record skipped. Now status lists each one as unrecorded <path> and exits 1, and status --json carries the same problems. Run patchbook record to keep the edits, or edit the block entries when record skips the paragraph. An output that is only behind the patchbook stays a note and exits 0 (#255).
status also reports every entry in .patchbook/changes/ that the series doesn't list and that holds no CHANGE.md: an ours-only or empty folder, a plain file, a dotfile or a bad name. Its wording matches record's. Only status changes. record, build, skill install and the commit hook treat these entries as before, so an ignored .DS_Store in changes/ doesn't block a record or a commit (#106).
A failed model call no longer leaves new paragraph entries without an intent
When the model failed, record and the commit hook wrote a new paragraph entry with an empty intent. status reported the entry as a problem, and build refused until you ran patchbook intent. Now patchbook writes the entry's intent from the paragraph edit and labels it intent (by patchbook): in the entries file, as it does for a change, so the build goes ahead:
$ PATCHBOOK_PROVIDER=none patchbook record
entry dup.md [79aeaf7ba450] added
entry dup.md [230d8358dc8e] added
intent by patchbook for dup.md [79aeaf7ba450], dup.md [230d8358dc8e] (intent.provider is none). To replace them, run `patchbook intent` or edit their lines to `intent: <yours>`
$ patchbook status
note dup.md [79aeaf7ba450]: patchbook wrote its intent from the paragraph edit. To replace it, run `patchbook intent` or edit its line to `intent: <yours>`
note dup.md [230d8358dc8e]: patchbook wrote its intent from the paragraph edit. To replace it, run `patchbook intent` or edit its line to `intent: <yours>`
4 edits apply at up 123ec94; no problems
The intent names the start of upstream's paragraph and says whether the edit rewrote or deleted it, as in Rewrites the paragraph that starts "body" in dup.md., so descriptions can coincide, as when paragraphs of one file start alike, and the hash in each entry's label tells the paragraphs apart. patchbook intent replaces it through the model, or you can rewrite the line as intent: .... A later record that edits the same paragraph with no model writes it again, unless you give an intent with --intent or PATCHBOOK_INTENT, which replaces it as it fills an empty one. An entry whose intent someone wrote keeps its intent. An entry that already has an empty intent still keeps it empty after a failed model call (#349) (#331).
Hook manager lines paste into your existing config
patchbook hook install prints the lines to add to a lefthook or pre-commit config. Pasted as printed, they broke some configs: a four-space lefthook YAML, pre-commit's own sample-config layout with items at column 0, and lefthook JSON where another hook holds the commands all failed to validate. It now reads the config, writes the lines in its indent, and says where they go: at the end of the file, directly below a line, or as the first member of a JSON object with its comma. Patchbook also runs first in lefthook when another command has priority 1 or the hook uses jobs. The post-merge, post-checkout and post-rewrite lines for lefthook and pre-commit are now a command or a hook in the config, not shell to paste into a script. Patchbook recognizes its own hook, whatever the entry is named, when it is the lines it printed or a bare patchbook hook run that nothing skips or limits to some files. In lefthook the bare call may end in || exit 1 or || true. In pre-commit the hook must run at the commit stage, set on the hook or inherited from default_stages, and have no args, which pre-commit adds to the entry and patchbook rejects. Text that only mentions the ...
v0.0.3
A new change gets its intent instead of going to pending
When a record started a new change, the model had to put the intent under the name it had just chosen for the change. It often put it under the changed paths instead, as on a rename or a commit that touched many files. record then couldn't use the reply, put the edits in a change called pending with an empty intent, and build refused until you ran patchbook intent. Now the reply has its own field for the new change's intent, so the model has no key to guess. Replaying real prompts, a one-file rename went from 10 of 10 replies unusable to 0 of 10 (#319).
The model sees a rename or a copy as one
The intent for a recorded move was written from a diff that showed the new path as an added file, listed twice, and never named the old path. A copy showed as a whole new file. So the intent described a new skill instead of the rename or where the files came from. Now the model sees the edit line, such as move skills/a -> skills/a2 or copy extra/skills/x -> skills/x, and only what you changed in the file, diffed against the moved file (#320).
Status and build count every edit
status and build printed <n> edits apply, and status --json reported applied, but the count left out add, replace, delete, move and copy edits. A change that vendored a skill with a copy edit reported 0. Now the count includes every edit that applies, once, however many outputs it reaches, and a later edit that deletes, replaces or moves its file doesn't undo it: a block entry in a file that a copy also writes elsewhere is one edit. A copy or move of a folder is one edit, as CHANGE.md lists it (#321).
Record names the change and writes its intent when the model can't
When the model failed, as with a reply patchbook can't use, a timeout, no claude or codex CLI, or intent.provider = none, record and the commit hook put the edits in a change called pending with an empty intent. status reported it as a problem, and build and the hook's build refused until you ran patchbook intent. Now patchbook names the change from its edits and writes an intent that says what they do, so the build goes ahead:
$ PATCHBOOK_PROVIDER=none git commit -qm "rename a"
rename-skills-a-to-skills-a2: Renames skills/a to skills/a2. Edits skills/a/SKILL.md.
move skills/a -> skills/a2
file a2/SKILL.md
intent by patchbook for rename-skills-a-to-skills-a2 (intent.provider is none). To replace it, run `patchbook intent rename-skills-a-to-skills-a2` or edit its line to `intent: <yours>`
CHANGE.md labels that line intent (by patchbook):, and status lists the change as a note, not a problem. To replace the intent, run patchbook intent <name>, or rewrite the line as intent: .... While the model fails, the edits always go to a new change or the one you name, never to an existing change the model would have picked. A new block entry still gets an empty intent, and build refuses until patchbook intent fills it. A pending change that 0.0.1 recorded keeps its name, and its intent stays empty until you fill it or a later record adds to that change.
What's Changed
- fix(record): the model writes the new intent in its own reply field by @willgosnold in #325
- fix(record): the model reads a recorded move or copy as one by @willgosnold in #326
- fix(status): count add, replace, delete, move and copy edits as applied by @willgosnold in #322
- fix(verify-patchbook): clean a sandbox when TMPDIR ends in a slash by @willgosnold in #323
- test(qa): script dogfooding journeys, with a fake or the real model by @willgosnold in #324
- ci: stop running the qa journeys by @willgosnold in #332
- feat(record): write the intent from the edits when no model can by @willgosnold in #330
- docs(changelog): move this week's entries to 0.0.3 and add #319 and #320 by @willgosnold in #333
Full Changelog: v0.0.2...v0.0.3
v0.0.2
Record writes a copy for a file copied from upstream
When you copied a file from an upstream into the output, such as a skill from a second upstream tracked at extra/, record and the commit hook wrote an add edit with a frozen copy of the file. The file then never changed with upstream, and status reported no problems. Now a new file that builds exactly as an upstream file builds is recorded as a copy edit, so sync and build bring in upstream's changes to it. If you copy a whole folder into a new folder, the edit copies the folder, and a file upstream adds to it later ships too (#307).
$ git commit -m "ship x"
ship-extra-s-x: Ship extra's x skill.
copy extra/skills/x -> skills/x
A copy you edit before it is recorded, as when you copy a file and edit it in the same commit, is still recorded as an add.
Changes recorded with 0.0.1 keep their add lines, so those files still don't follow upstream. To redo one, move the file out of the output and run patchbook record, which removes the add line and its copy. Then move the file back and run patchbook record <change>, which writes a copy edit into that change.
Record writes a move for a renamed file
When you renamed an output file or folder with git mv, record and the commit hook wrote a delete of the old path and an add of the new one, with a frozen copy. The renamed file then never changed with upstream, and status reported no problems. Now a rename is recorded as a move edit, so sync and build bring in upstream's changes to the renamed file. If you also edited the file, as when you change the name: line of a renamed skill, the edit is recorded after the move as a file edit or as block entries, and sync merges upstream's changes into it (#308).
$ git mv skills/a skills/a2
$ sed -i 's/^name: a$/name: a2/' skills/a2/SKILL.md
$ git commit -am "rename a"
ship-a-as-a2: Ship a as a2.
move skills/a -> skills/a2
file a2/SKILL.md
A rename is still recorded as a delete and an add when the old and new versions keep, in order, less than half of the non-blank lines of the longer one, or when its edit can't be recorded on the moved file, as in a file whose copy uses placeholders. Renames recorded with 0.0.1 keep their delete and add lines.
Intents cover every file in a large record
The model was given the diff cut at 40,000 characters, with no list of paths, so on a large record it never saw the later files and the intent named only the first ones. Now the prompt lists every changed path first, and each file's diff gets its own share of the budget. A long record loses detail in its diffs, never whole files (#309).
An edit that joins an existing change rewrites its intent
When an edit went to a file an existing change or block entry already owned, the change kept its old intent, which then no longer described it. Now record rewrites that intent from the change's whole diff, in the same single model call it already makes. If you gave the intent yourself (--intent or PATCHBOOK_INTENT), or no model answers, the old intent stays and record prints a line naming it:
intent may be stale: <change> (<why>)
(#310)
record also no longer writes two blank lines after an entry with an empty patched side (#311).
What's Changed
- fix(record): rewrite joined intents in one call, and show the model every path by @willgosnold in #315
- fix(record): record a new output that matches an upstream file as a copy by @willgosnold in #313
- fix(record): record a renamed output as a move by @willgosnold in #314
- docs(changelog): add #309, #310 and #311 to 0.0.2 by @willgosnold in #318
Full Changelog: v0.0.1...v0.0.2
v0.0.1
The first release.
Install it with npm install -g @patchbook/cli. The command it installs is patchbook. The package is scoped because npm refused the plain name patchbook as too close to an existing package.
Patchbook checks your config when it loads it
Some configs would build once and then break status, build or the next commit, so patchbook refuses them when it loads the config. The message names the folder and says what to change. If init, clone or track fails, it writes nothing.
- A
vendorfolder that is its upstream's output folder, holds that output, or sits inside it. The same applies to avendorfolder that holds another upstream's output, or holds or sits inside another upstream'svendorfolder. - A
mountat or inside.patchbookor.git, amountgiven as an absolute path, or one whose..climbs out of the repo. Mounts are normalised, so./libandx/../libboth meanlib. - An
[output] tothat is any of these: the repo root; outside the repo; inside.patchbook; holding or inside a vendored copy; a link; under a link inside the repo; under a file; or containing a.gitsegment in any case.
If you see one of these messages, change the named vendor, mount or [output] to in .patchbook/config.toml as it says, then run patchbook build.
Sync reports a conflict instead of guessing where a paragraph goes
git merge-file can misplace a file edit once upstream moves paragraphs around. This happens when a file holds the same paragraph more than once, and when the fork deleted a paragraph that upstream then moved. In these cases sync reports a conflict rather than a clean merge, and status and build refuse until you resolve it:
- an edit to one copy of a paragraph that the merge would put on another copy or leave out;
- a copy the fork deleted that the merge would bring back;
- a copy the fork inserted that the merge would drop because upstream moved another copy to the same spot;
- a paragraph the fork deleted from any file that the merge would bring back because upstream moved it.
Sync names the file on stderr, and .patchbook/changes/<change>/ours/<file>.pb holds both texts between conflict markers. Edit it so the file reads as you mean it, then run patchbook build. Sometimes the merge sync refuses would have been right. Sync refuses rather than guess (#286, #294).
What's Changed
- test: remove tests another test already covers by @willgosnold in #299
- docs(verify-patchbook): drop gotchas for fixed #4 and #5 by @willgosnold in #73
- docs: write the 0.0.1 notes as a first release by @willgosnold in #304
- docs: make the README a short introduction, and move its detail into DESIGN.md by @willgosnold in #305
- docs: add a contributing guide, security policy, issue forms and PR template by @willgosnold in #244
Full Changelog: v0.0.1-rc.2...v0.0.1
v0.0.1-rc.2
What's Changed
- build(npm): publish the main package as @patchbook/cli by @willgosnold in #297
- fix: refuse a sync journal whose old/ leads outside the repo by @willgosnold in #298
- fix(sync): refuse a merge that brings back a paragraph ours deletes once upstream moves it by @willgosnold in #300
Full Changelog: v0.0.1-rc.1...v0.0.1-rc.2
v0.0.1-rc.1
What's Changed
- test: read the command under test from PATCHBOOK_CMD by @willgosnold in #35
- feat: port patchbook to TypeScript on Bun by @willgosnold in #36
- ci: build releases and publish patchbook to npm by @willgosnold in #37
- build: publish the platform packages under the @PatchBook scope by @willgosnold in #38
- chore: add the verify-patchbook skill and pstack's model config by @willgosnold in #39
- chore: add the release promo clip and logo by @willgosnold in #46
- fix(store): keep a ref to each commit fetched into the store by @willgosnold in #40
- fix: ignore upstream's own .patchbook when forking a patchbook repo by @willgosnold in #42
- fix: validate the output folder so to = "." can't delete .patchbook by @willgosnold in #43
- fix: keep a given intent when record has no change name by @willgosnold in #41
- fix(store): fetch into a ref of its own instead of reading FETCH_HEAD by @willgosnold in #63
- fix: pass output and vendor paths to git as literal pathspecs by @willgosnold in #62
- fix(store): fetch a fork's pin from its upstream URL in any clone by @willgosnold in #74
- fix(book): refuse names git reads as .git and root links behind a linked repo path by @willgosnold in #82
- fix: read a folder in the output as its files when the index still calls it a link by @willgosnold in #85
- fix: report a structural edit into .patchbook or .git as invalid by @willgosnold in #88
- fix: validate edit paths and change names, document the trust model by @willgosnold in #89
- docs(readme): warn against merging upstream with git in a fork by @willgosnold in #59
- fix(cli): make init and track safe to stop between steps by @willgosnold in #69
- test: restore the environment Case leaks and add unit tests by @willgosnold in #60
- fix(cli): name the file for invalid TOML and quote every TOML value written by @willgosnold in #75
- test: cover the codex provider, partial syncs, check before a pin, hooks beside another tool's and paragraph planning by @willgosnold in #91
- fix(config): replace the line-based setToml with @decimalturn/toml-patch by @willgosnold in #84
- fix: name the file when writing upstream.lock fails by @willgosnold in #118
- feat(skill): add
patchbook skill installto refresh the update skill by @willgosnold in #68 - fix: refuse to install the skill over uncommitted changes in init and clone by @willgosnold in #111
- fix(skill): keep a skill path only when HEAD holds what is on disk by @willgosnold in #114
- feat(skill): merge patchbook-update only on a clean sync or a passing test command by @willgosnold in #65
- fix(skill): delete a test's untracked leftovers before the gate by @willgosnold in #110
- fix(skill): stop on a sync that pins nothing, and read only this run's reports by @willgosnold in #112
- fix(hook): record and commit only what is staged by @willgosnold in #71
- fix(hook): put the patchbook and the output back when a hook run fails by @willgosnold in #100
- fix(githook): run patchbook from the hook git runs under a hook manager by @willgosnold in #102
- fix(sync): keep each upstream's report in last-sync.json by @willgosnold in #64
- fix(hook): install the hook only from commands that change things, and add hook status by @willgosnold in #123
- fix(sync): leave the vendored copy, changes and lock as they were when sync fails by @willgosnold in #83
- fix(hook): refuse to commit or build after upstream was merged in directly by @willgosnold in #125
- fix(hook): name the link when a commit turns an output folder into one by @willgosnold in #131
- fix(record): record a regular file over a recorded symlink, and refuse an upstream link turned into a file by @willgosnold in #136
- fix(hook): refuse to print lefthook advice when more than one config file exists by @willgosnold in #137
- fix(hook): skip a checkout with no .patchbook in the hook script by @willgosnold in #139
- feat(json): version and document status --json, check and last-sync.json by @willgosnold in #66
- fix(sync): rewrite a vendored copy that no longer matches an unmoved pin by @willgosnold in #67
- fix: say why a vendored copy can't be hashed, put the pinned copy into the index in the hook, and refuse init --vendor in the fork layout by @willgosnold in #80
- ci: test macOS on main pushes only, not on every pull request by @willgosnold in #232
- fix(book): refuse a vendor folder a sync would wrongly delete, and never delete a .git inside it by @willgosnold in #117
- fix(sync): ignore last-sync.json so a sync leaves nothing untracked by @willgosnold in #142
- fix(check): ignore a change to upstream's own .patchbook by @willgosnold in #145
- docs: say what init refuses for a vendor folder inside the output by @willgosnold in #147
- fix: refuse an upstream path git reads as .git when a build would write it by @willgosnold in #150
- fix: upstream --export refuses a .git path and a folder that isn't empty (#153) by @willgosnold in #240
- fix: track, init and sync refuse a vendor folder that holds files that aren't upstream's (#55) by @willgosnold in #241
- fix: refuse an upstream tree path with a .., . or empty part before anything is written (#219) by @willgosnold in #243
- refactor(record): classify each edited path once into an explicit kind by @willgosnold in #81
- test: expect the export destination as the CLI resolves it by @willgosnold in #246
- fix(record): don't overwrite a change folder that is missing from series by @willgosnold in #101
- fix(record): remove a deleted file's block entries and type intents as strings by @willgosnold in #107
- fix(record): record a delete for the output of a replace and keep an emptied change by @willgosnold in #113
- fix(record): skip an owned file edit whose ours copy uses a placeholder by @willgosnold in #119
- fix(record): record a mode change and keep it through the build by @willgosnold in #122
- ci: split the end-to-end tests across three parallel jobs by @willgosnold in #267
- fix(record): refuse a bad change name before looking for hand edits by @willgosnold in #138
- fix(record): say when a given intent is not used by @willgosnold in #141
- feat(record): record with an empty intent when the model fails by @willgosnold in #144
- fix(intent): run the model as a plain completion and parse its reply strictly by @willgosnold in #148
- fix(record): put the patchbook back when a record fails by @willgosnold in #176
- fix(record): record an exec bit by one rule for commit, record and hook install (#143) by @willgosnold in #235
- fix(cli): make init complete or change nothing by @willgosnold in #180
- fix(cli): refuse init when .patchbook holds a series or retired.md by @willgosnold in #190
- fix(cli): refuse a URL whose credentials patchbook would drop by @willgosnold in #198
- fix: sync recovery trusts a committed journal only where it stays inside the repo by @willgosnold in ht...