Publish public content for reading agents
The experimental /publication import and agent-native-site executable, published in version 1.1.0, generate a text index, directly readable Markdown mirrors, optional aggregate text and JSON-LD for approved public pages. Your app owns its human HTML, data permissions and cache invalidation.
Framework integrations and showcases
Install the published package with npm install @uppercut-labs/agent-native@1.2.0. The repository examples below are source-checkout workflows for the 1.1.0 branch; the package includes the publication API and executable but not the runnable example projects.
Try a source-backed example
Use Node 22+ and a checkout of the 1.1.0 source branch. From the repository root, run the following commands. The example creates a small workshop site in a new working directory with a private manifest, an empty state directory and a separate public output directory.
npm ci
npm run build
node examples/site-publication/build.mjs workshop-demo http://127.0.0.1:4173/
node bin/agent-native-site.mjs preview --manifest workshop-demo/site.json --out workshop-demo/public --state workshop-demo/state
Read the proposed changes, included routes and excluded sources. Substitute the exact digest from that preview.
node bin/agent-native-site.mjs apply --manifest workshop-demo/site.json --out workshop-demo/public --state workshop-demo/state --approve REVIEWED_DIGEST
In a clean consumer that installed the published 1.1.0 package, use npm exec -- agent-native-site in place of node bin/agent-native-site.mjs. The public site must serve the generated files verbatim with the expected media types. Configure .md as text/markdown or text/plain, .jsonld as application/ld+json or application/json, and .txt as text/plain. Unknown mirror paths should return 404 or 410. The verifier performs anonymous requests against the configured origin and checks canonical HTML, applicable JSON-LD, actual bytes, types and a missing Markdown path.
node bin/agent-native-site.mjs verify --manifest workshop-demo/site.json
Discover review candidates in existing projects
Run agent-native-site discover --framework next --project . on an App Router app. Astro, Next.js App Router, Nuxt and SvelteKit use conventional filesystem page paths. Dynamic parameters stay unresolved, and discovery reads filenames without running loaders or opening page bodies. Angular can read an existing dist/prerendered-routes.json. For React/Vite, Vue/Vite, React Router framework mode and Angular, pass --routes routes.json with an application-exported route table (paths or nested records with path, index and children). A custom route file must be inside the project. Redirects, internationalization, custom framework directories, aliases and complex mounted routers require developer review.
The output is private review material. Every discovered route has unknown visibility, a source locator and a stable candidate ID. Enumerate the finite public routes and select their public fields to construct the manifest. An automatically discovered path cannot authorize publication.
Supply public projections
A manifest has config and candidates. Generate these records from the same public fields that render the human site. The CLI consumes a developer-supplied route inventory. The workshop source drives both the page and its publication records.
{
"config": {
"enabled": true,
"siteUrl": "https://example.org/",
"title": "Workshop calendar",
"description": "Public event information.",
"full": false
},
"candidates": [
{
"id": "w17",
"revision": "r1",
"route": "/events/lantern/",
"visibility": "public",
"title": "Lantern workshop",
"markdown": "Doors open at 10:30.",
"structuredType": "WebPage"
}
],
"verify": {
"responses": [
{"path": "/events/lantern/", "status": 200, "contains": ["Doors open at 10:30."]},
{"path": "/unavailable-draft/", "status": 404}
]
}
}
Keep the manifest and journal outside every served directory. A public record requires a finite site-relative route, opaque ID and revision, title and Markdown prose. Use links with public source IDs for navigation. A protected/draft record needs only its identifier, revision, route and visibility. The engine excludes nonpublic material from generated bytes. The private preview can include opaque source IDs. Render the returned JSON-LD on the corresponding public HTML page when selecting a structured type, and set its canonical link to the reviewed URL.
planPublication(config, candidates) performs an in-memory preview. Its assets are UTF-8 content, relative output paths, media types and SHA-256 digests. An error diagnostic suppresses all assets. An adapter can pass a read-only verifier as a third argument for public protocol declarations. The CLI recognizes same-site OpenAPI 3 JSON descriptions with an info record and at least one HTTP operation with an inline documented response. A protocol declaration alone cannot advertise an endpoint.
A public record can also declare facts: up to 20 {"label", "value"} pairs that restate values from its prose, such as {"label": "Doors open", "value": "10:30"}. Each mirror lists them under Key facts after the body, so an agent can quote the bare value beside a citable URL. Render the same list on the human page. Each mirror states both its canonical URL and its own URL. The generated llms.txt opens with a coverage statement: it counts the pages in the approved projection, says that a fact outside those pages is not published by the site, and links llms-full.txt when the aggregate is enabled.
A server can also return a page's mirror at its canonical URL to a client that asks for Markdown. negotiateMarkdown({ method, pathname, accept }, markdownMirrors(plan.manifest.entries)) returns the mirror path when the Accept header names text/markdown at least as strongly as HTML. Browsers never send it, so they keep the HTML. Send Vary: Accept from those routes whichever representation you serve. markdownNegotiationHandler(mirrors, read) wraps the same decision as Node (req, res, next) middleware; read returns the mirror bytes from your generated asset directory.
Change or withdraw content
Regenerate the manifest when a source changes, preview the diff and apply the new digest. Removing a candidate, changing it to private, or disabling the aggregate withdraws owned files on the next approved apply. Publish the changed human site and assets together and invalidate the host's public caches. Check its actual URLs again, including any retired mirror paths through verify.responses.
restore-preview shows the owned files that restoration would remove. Run restore with the digest from that preview. Modified owned files produce a conflict and the command leaves their content intact. Resolve edits before retrying. The journal tracks only files created by the CLI. Empty generated directories may persist.
Operational boundaries
Use an offline build or staging output under a single writer. Review first, apply, verify, then promote the complete build with the hosting platform’s deployment mechanism. The CLI checks existing path components and file digests, rejects symlinks and human-owned collisions, uses a private lock for writes and rolls back ordinary write failures. Keep a backup of the last accepted build. After a hard process or machine interruption, inspect the private recovery record and the target before resuming. The private pending.json includes the approved transaction digest, prior ownership, per-file before/after hashes and base64 originals. A matching transaction in ownership.json means the new journal was committed. Otherwise, compare each affected file to the recorded hashes before restoring an original or removing a newly created file. Preserve any unexpected human edits. Remove the recovery record and stale lock only after confirming the writer has stopped and reconciling all files. Never deploy the state directory. This executable operates independently of the app-owned capability CLI and its authorization model.