PrimaChat
Stone, browse
List the files, open one, pull the latest, and never read outside the working copy.
Live Built and working today on the surface this card describes.
What it does
Three routes. The tree, one file, and a pull.
Opening a file returns its text and its headings, each with its line number and its depth. That is what makes a citation land on a section rather than on a file.
Every path is pushed through one join that rejects anything resolving outside the working copy. There is no route here that takes a path and does not.
A pull that fails does not fail the request. The repository record is updated either way and the response says pulled: false with the reason, because a stale working copy is still readable.
Inputs and outputs
GET /api/stone/repos/:id/tree | {files: [{path, size}], commit}. |
|---|---|
GET /api/stone/repos/:id/file?path= | {path, content, headings: [{heading, line, depth}]}. 400 without a path, 404 if it is not a file. |
POST /api/stone/repos/:id/sync | {repo, pulled, note}. note carries the reason when pulled is false. |
| Path outside the repository | Refused. The join throws before anything is read. |
Configuration
| Nothing to configure | These three routes take no settings. What they can see is decided when the repository is connected. |
|---|
Limits
- The tree lists only the readable extensions, so a repository of source code will look almost empty here. That is the intent: this is a wiki reader, not a file browser.
- A file's size is read at listing time and can be zero if the file was deleted between the listing and the check.
- There is no write route. Files change through engraving, or through git.
Example
open one file
GET /api/stone/repos/repo_…/file?path=handbook/holidays.md Source of truth
prima-chat/server/routes/stone.ts (tree, file, sync)prima-chat/server/wiki.ts (`safeJoin`, `listFiles`, heading extraction)