aiongg b7b2aaaab6 Serve the React frontend over the JSON API; operator, maintainer and viewer roles
- web/: an HTTP client for the Api interface (CSRF from the X-CSRF-Token
  response header, errors carry the server's text, 401 goes to sign-in);
  the mock API and its view-as menu only in VITE_MOCK=1 builds; the clock
  is real time outside the mock; nav links to the server-rendered pages.
- Server: serves web/dist (CRAFT_AUTO_WEB_DIST) behind sign-in, hashed
  assets cached a year, index.html uncached for every client route, a 503
  page when the build is missing; a strict CSP for the app with the hash
  of the Radix scroll-lock style.
- The v1 Decisions, Item and Progress pages are gone; Contributors,
  Classifiers, Run and cost, Repos and Access stay at their paths.
- Access roles operator, maintainer and viewer; rows with role admin
  become operator on connect.
- v1 form POSTs and sign-out refuse a foreign Origin or Sec-Fetch-Site.
2026-11-02 18:11:09 +00:00

craft-automation

Local mirror of every storytold issue and PR, the triage pipeline's state, and the backlog dashboard.

  • craft-auto sync fills a SQLite mirror (~/.local/share/craft-automation/mirror.db, or $CRAFT_AUTO_DB) from GitHub GraphQL. Agents and scripts query the mirror instead of calling gh.
  • craft-auto whitelist shows and edits which contributors' PRs may merge on green CI without a decision.
  • craft-auto dash serve serves the dashboard.

Schema: src/schema.sql. Mirror tables are overwritten by sync; work tables (classifications, stages, whitelist overrides, token use) are ours.

TypeScript on Node 24, run directly (type stripping, no build step): node src/cli.ts <command>. SQLite through the built-in node:sqlite. pnpm check type-checks; pnpm test runs the tests.

Dashboard server

craft-auto dash serve serves the dashboard over plain HTTP; a proxy in front provides HTTPS. Every page needs GitHub sign-in, and only logins on the access list get a session. Roles are operator (answers decisions, manages the whitelist, repos and access), maintainer and viewer (both read and give opinions). Add the first operator from a shell: craft-auto access add <login> --operator. Then manage the list on the Access page or with craft-auto access list|add|remove|role.

The frontend is the React app in web/. Build it before serving: pnpm -C web install && pnpm -C web build (writes web/dist). Without a build the server answers app pages with a 503 that says so. VITE_MOCK=1 pnpm -C web build builds a mockup on fake data that runs without the server.

Variable Meaning
CRAFT_AUTO_BASE_URL Public origin of the dashboard, such as https://dashboard.example.org (no path). The OAuth App's callback URL must be exactly <CRAFT_AUTO_BASE_URL>/auth/callback. Required unless dev auth is on.
CRAFT_AUTO_LISTEN host:port to listen on. Default 127.0.0.1:8993.
CRAFT_AUTO_DB SQLite database path (the mirror database).
CRAFT_AUTO_WEB_DIST Directory of the built frontend. Default web/dist in the repo.
CRAFT_AUTO_SECRETS_FILE JSON file with github_client_id, github_client_secret and session_key (at least 32 characters, random). Must be mode 0600; the server refuses to start if it is missing, incomplete, or readable by group or others.
CRAFT_AUTO_TRUST_PROXY 1 to take the client address for rate limits from the last X-Forwarded-For entry. Set it only behind a proxy that sets that header.

The GitHub OAuth App needs no scopes, and expiring user tokens are supported: the server refreshes them as needed and ends the session when a refresh fails. Tokens are stored encrypted with a key derived from session_key; changing session_key ends every session.

Development sign-in

With CRAFT_AUTO_DEV_AUTH=1 the server uses a fake GitHub: /auth/signin shows a form that signs in as any login typed into it (the login must still be on the access list). It needs no secrets file and starts only on a loopback listen address. Repo permissions come from the JSON file named by CRAFT_AUTO_DEV_PERMS, read on every check: {"<login>": {"<repo>": "write"}} (values admin, maintain, write, triage, read). CRAFT_AUTO_DEV_TOKEN_TTL sets the fake access tokens' lifetime in seconds (default 8 hours). Open the dashboard as http://localhost:<port> so the browser accepts its Secure cookies.

JSON API

The frontend in web/ talks to /api/; the wire types are web/src/api/types.ts. Every endpoint needs a session (401 JSON without one) and returns errors as {"error": "..."} with a status code. Every /api/ response carries the session's CSRF token in X-CSRF-Token; every POST must send it back in the same header, with a JSON body (at most 64 KB). A POST whose Origin or Sec-Fetch-Site names another site is refused.

Method and path Who
GET /api/me, /api/repos, /api/progress, /api/search?q=, /api/items/<repo>/<n> anyone signed in
GET /api/decisions?status=open|opinions|answered&repo=&kind=&minAge=&mine=1&limit=&offset=, /api/decisions/<id>, /api/decisions/<id>/thread anyone signed in; answer notes only for operators
POST /api/decisions/<id>/answer {answer, note?, exceptions?}, /undo, /adopt {opinionId} operator with write, maintain or admin on every repo the decision covers
POST /api/decisions/<id>/opinion {option, note?}, /retract, /comments {body} anyone signed in; audited; non-operators get 60 an hour per login
POST /api/decisions/<id>/claim anyone signed in: marks the decision as being looked at for 10 minutes
POST /api/signout anyone signed in

Opinions and comments are display-only. The pipeline reads answers with craft-auto decisions list --actionable (one JSON object per line: option keys of unapplied answers by a current operator), which never includes them.

S
Description
No description provided
Readme
28 MiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 95.9%
JavaScript 2.7%
PLpgSQL 0.9%
Shell 0.4%