{"_id":"@awfixerai/hashline","name":"@awfixerai/hashline","dist-tags":{"latest":"0.0.1-rc.1"},"versions":{"0.0.1-rc.1":{"type":"module","name":"@awfixerai/hashline","version":"0.0.1-rc.1","description":"Hashline: a compact, line-anchored patch language and applier. Pluggable FS/IO so it works over disk, in-memory, or any custom backend.","homepage":"https://agent.awfixer.codes","license":"MIT","repository":{"type":"git","url":"git+https://github.com/awfixers-stuff/awfixer-agent.git","directory":"packages/hashline"},"bugs":{"url":"https://github.com/awfixers-stuff/awfixer-agent/issues"},"keywords":["patch","diff","edit","hashline","agent","llm"],"main":"./src/index.ts","types":"./src/index.ts","scripts":{"check":"biome check . && bun run check:types","check:types":"tsgo -p tsconfig.json --noEmit","lint":"biome lint .","test":"bun test --parallel","fix":"biome check --write --unsafe .","fmt":"biome format --write ."},"dependencies":{"diff":"^9.0.0","lru-cache":"11.5.1"},"devDependencies":{"@types/bun":"^1.3.14"},"engines":{"bun":">=1.3.14"},"exports":{".":{"types":"./src/index.ts","import":"./src/index.ts"},"./grammar.lark":"./src/grammar.lark","./prompt.md":"./src/prompt.md","./*":{"types":"./src/*.ts","import":"./src/*.ts"},"./*.js":"./src/*.ts"},"_id":"@awfixerai/hashline@0.0.1-rc.1","_integrity":"sha512-1FR22fLoNedh2qrAJwIVjnzO5n6aypM9mmdDKh+8PThwJLVwfh1jH+fQKgSVG26d8AUDD+gkIV1WvS7EsK4klQ==","_nodeVersion":"24.3.0","_npmVersion":"10.8.3","shasum":"02137afd8e67547e31fa44a656303f02020b8bf5","dist":{"integrity":"sha512-1FR22fLoNedh2qrAJwIVjnzO5n6aypM9mmdDKh+8PThwJLVwfh1jH+fQKgSVG26d8AUDD+gkIV1WvS7EsK4klQ==","shasum":"02137afd8e67547e31fa44a656303f02020b8bf5","tarball":"https://registry.npmjs.org/@awfixerai/hashline/-/hashline-0.0.1-rc.1.tgz","fileCount":23,"unpackedSize":236655,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC2KHDk40qpRMvVxHL1ApB94QSHZ3wyL3Lh4/ge5ocssQIhAJig+30Bi6ra3qEpySywSdXXxJ3bwX1bPRT08VXz6g1P"}]},"_npmUser":{"name":"awfixer","email":"wise.jet2897@fastmail.com"},"directories":{},"maintainers":[{"name":"awfixer","email":"wise.jet2897@fastmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hashline_0.0.1-rc.1_1783014969283_0.9129269542033125"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-02T17:56:09.088Z","0.0.1-rc.1":"2026-07-02T17:56:09.420Z","modified":"2026-07-02T17:56:09.756Z"},"maintainers":[{"name":"awfixer","email":"wise.jet2897@fastmail.com"}],"description":"Hashline: a compact, line-anchored patch language and applier. Pluggable FS/IO so it works over disk, in-memory, or any custom backend.","homepage":"https://agent.awfixer.codes","keywords":["patch","diff","edit","hashline","agent","llm"],"repository":{"type":"git","url":"git+https://github.com/awfixers-stuff/awfixer-agent.git","directory":"packages/hashline"},"bugs":{"url":"https://github.com/awfixers-stuff/awfixer-agent/issues"},"license":"MIT","readme":"# @awfixerai/hashline\n\nA compact, line-anchored patch language and applier.\n\nHashline is a diff format designed for LLM-driven file edits. It binds every\nhunk to a file-content hash so stale anchors are rejected before they corrupt\ncode, and it abstracts over the filesystem so the same patcher works on disk,\nin memory, over the network, or against any custom backend.\n\n## Quick start\n\n```ts\nimport {\n\tFilesystem,\n\tInMemoryFilesystem,\n\tInMemorySnapshotStore,\n\tPatcher,\n\tPatch,\n} from \"@awfixerai/hashline\";\n\nconst fs = new InMemoryFilesystem();\nconst snapshots = new InMemorySnapshotStore();\nconst before = `const greeting = \"hi\";\\nexport { greeting };\\n`;\nawait fs.writeText(\"hello.ts\", before);\n\nconst tag = snapshots.record(\"hello.ts\", before);\nconst patcher = new Patcher({ fs, snapshots });\nconst patch = Patch.parse(String.raw`[hello.ts#${tag}]\nSWAP 1.=1:\n+const greeting = \"hello\";`);\nconst result = await patcher.apply(patch);\n\nconsole.log(result.sections[0].op); // \"update\"\nconsole.log(await fs.readText(\"hello.ts\"));\n```\n\n## Format\n\nSee [`src/prompt.md`](./src/prompt.md) for the user-facing description and\n[`src/grammar.lark`](./src/grammar.lark) for the formal grammar.\n\nEach file section starts with `[PATH#TAG]`. The tag is a 4-hex\ncontent hash of the full normalized file text recorded by the\n`SnapshotStore`, and it is not meaningful outside that store. The patcher\nprotects against stale anchors by resolving the tag, verifying the live file\nstill matches the recorded content hash, and refusing or attempting\nsession-aware recovery on mismatch.\n\nInside a section:\n- `SWAP A.=B:` — replace lines A.=B with following `+TEXT` body rows.\n- `SWAP.BLK A:` — replace the syntactic block beginning on line A.\n- `DEL A.=B` / `DEL.BLK A` — delete concrete lines or a resolved block.\n- `INS.PRE A:` / `INS.POST A:` / `INS.HEAD:` / `INS.TAIL:` — insert following body rows.\n- `INS.BLK.POST A:` — insert following body rows after the resolved block's last line.\n- `REM` — delete the whole file named by the section header.\n- `MV DEST` — move/rename the section file to `DEST` (optionally after line edits).\n- `+TEXT` — literal body row (use `+` alone for a blank line).\n\n## Abstractions\n\n### `Filesystem`\n\nRead and write text by path. The default implementations:\n\n- `InMemoryFilesystem` — backed by a `Map`. Tests, sandboxes.\n- `NodeFilesystem` — disk-backed via `Bun.file`/`Bun.write`. Default for CLIs.\n\nSubclass `Filesystem` to wire hashline into any storage: VFS, S3, an LSP\ntext-document protocol, a Git tree, anything.\n\n### `SnapshotStore`\n\nRequired. Hashline tags are full-file content hashes recorded per path, so\n`Patcher` must receive the store that observed them. Recovery replays edits\nagainst the cached pre-edit snapshot and 3-way-merges onto current content\nwhen the live file diverged.\n\n### `Patcher`\n\nThe orchestration class. Reads, normalizes line endings + BOM, applies edits,\nrestores line endings, and writes via the configured `Filesystem`. Multi-section\npatches are preflighted up front so a partial batch never lands.\n","readmeFilename":"README.md","_rev":"1-e92b4b2299dece0e92b3ddb7c36817f4"}