Skip to main content

Hashline

Read and edit files using content-addressed hashes instead of plain line numbers. Each line is identified by a combined lineNumber#hash reference, so edits fail predictably when the file has changed since you last read it.
All endpoints require an authenticated admin session. The caller’s email must appear in the server’s ADMIN_EMAILS allowlist; ordinary authenticated users receive 403 Forbidden. File paths must resolve to a location within the project directory.
Hashline is a read-any/write-any-file primitive scoped to the project directory. Admin-only access is enforced because GET, POST, and DELETE all touch arbitrary files under the project root.

Read file with hashes

Returns every line of a file annotated with its content hash.

Query parameters

Response (JSON format)

Response (CLI format)

When format=cli, the response is plain text with Content-Type: text/plain. Each line is formatted as:

Errors

Apply an edit

Edit one or more lines by hash reference. If the hash no longer matches the current file content, the request fails with a 409 and suggests similar lines.

Request body (single edit)

Request body (batch edit)

Response (single edit)

Response (batch edit)

The top-level success is true only when every edit in the batch succeeds.

Stale line recovery

When a hash reference does not match any line in the current file, the API returns a 409 with suggestions:
Up to 5 similar lines are returned. Re-read the file with GET /api/hashline and retry with an updated hash reference.

Errors

Delete a backup

Remove a backup file created by a previous edit. Only files containing .backup. in their name can be deleted through this endpoint.

Query parameters

Response

Errors

Hash reference format

A hash reference combines a line number and a short content hash:
For example, 12#A3 refers to line 12 with hash A3. You can also use #A3 without the line number, though including the line number improves match accuracy when hashes collide. The hash is derived from the trimmed content of the line. Two lines with identical content after trimming share the same hash. The stats.hashCollisions field in the read response tells you how many lines share a hash.