Public: anyone can read this; the crew can change it.

The forge is a developer's file system: every app's database and the API spec, first-party (web, terminal app, MCP) #16743

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

This pull adds one thing: the MCP data tool can now return the API spec as a list of operations. The issue is not finished by it. Most of what #7578 asks for was already on main.

Notes

opened this

This pull adds one thing: the MCP data tool can now return the API spec as a list of operations. The issue is not finished by it.

Most of what #7578 asks for was already on main. The terminal tree runs repos → apps → environments → .db files → tables → rows. The web has /data and each app's Data tab. The API reference page and the MCP data tool also exist. The gap I filled is that MCP could not read the API spec at all.

What changed

  • data with spec: true lists the operations the forge's contract exposes to your role, as {area, method, path, summary} rows. It returns at most 300 and total says how many matched.
  • q narrows the list by words.
  • With repo, it returns the document that app serves at /openapi.json. That follows the same access rule as the app's API tab, so a stranger asking about a private app gets a 404. An app that serves no spec gets a clear "serves no /openapi.json right now".
  • The logic is in src/data/spec_scope.ts. It reuses reference/narrow (src/contract/reference.ts), openapiText/roleOf, and knownSpec/refreshSpec from the existing /api pages. It adds no new tool, no new dependency and no new egress.
  • test/data-spec-scope.test.ts covers the forge's spec by role, narrowing, a private app's door, and an app with no spec.
  • docs/features/data-browser.md has a new section describing the spec read.
  • bun x tsc --noEmit is clean, and bun scripts/gate.ts is clean. The new test, test/mcp-size.test.ts, test/mcp-refusal-hints.test.ts, test/guide.test.ts and test/feature-orphans.test.ts pass.
  • I did not run the whole suite, since the forge runs it on push.
  • The MCP size ceilings are untouched.

Left out

  • The spec is not a node under an app's environment in the terminal tree.
  • No single web page joins the database tree and the spec.
  • The pull carries a No door: line. That is because the terminal's API screen already lists the forge's operations from the same reading, but not an app's.
  • Writes stay out of scope, as the issue says.

Try it: call MCP data with {"spec": true, "q": "openapi"}, or with {"repo": "owner/name", "spec": true}.

Closes #7578

commented

The spec is now a file named openapi.json in the data tree on all three doors: web, terminal and MCP. The data, tree, terminal-data and door tests plus tsc, gate.ts --fix and design-lint pass. I ran no broader suite, because scripts/fast.ts returned 3,679 of 4,483 test files, over its time budget.

What changed

  • Web: /data?spec=1 lists the forge's operations as the viewer's role may call them. /:owner/:name/data?spec=1 lists an app's own operations. Both pages show an openapi.json row and link to the canonical /api pages.
  • Gate: An app's spec is asked through appSpec, which still checks canEnterApp, so a reader gets the same 404 as for the databases and a guest is sent to sign in.
  • Terminal: The Data screen has an openapi.json node last at the top level, and one after each app's environments. l or Enter opens it and y yanks METHOD /path. The forge's node only appears for someone who sees any file. A viewer with no files, such as a reader or a guest, sees no spec.
  • Placement: The new nodes sit last so the existing cursor paths and tests are unchanged. The tree only shows them to a door that asks, in src/data/tree.ts, and the palette entry is unchanged.
  • One way to list: docs/features/data-browser.md now says /api, /:owner/:name/api and the terminal API screen stay canonical. Everything else reads through reference and adds no second listing. The "Not done" sentence is gone.
  • Cleanups: The spec_scope.ts comment about none is reworded, and the doc says appSpec reads the production environment only. I did not add preview-environment reading.

Tests (test/data-spec-door.test.ts, plus two cases in test/tui-data.test.ts)

  • Web: a writer sees the operations, a reader gets a 404, a guest does not get a 200, a private app's spec stays private, and an app with no spec says so.
  • Terminal: the forge's and an app's operations show for a writer; a reader and a guest see no app and no spec.
  • MCP tool: I called data with spec: true through the tool. It returns the forge's and an app's operations, not_found for a stranger on a private app, and the "serves no /openapi.json" message. A non-boolean spec and a non-string q return invalid.
  • One disagreement: the schema layer rejects those two inputs before data.ts does, so the message is the generic "expected boolean" text, not the tool's own. The tests assert invalid.

Left out

  • Reading a preview environment's spec.
  • A spec search box on the /data pages (the MCP q still narrows).

Try it

  • Web: open /data?spec=1 or /<owner>/<name>/data?spec=1.
  • Terminal: open Data, then open an openapi.json node.
  • MCP: call data with {spec: true, q: "openapi"}.
[
  {"go": "/<owner>/<name>/data", "look": "an openapi.json row above the environments, opening to a table of operations", "expect": "area, method, path and summary rows, and a link to the app's API page", "ask": "signed in as a writer"},
  {"go": "/<owner>/<name>/data?spec=1", "look": "the page as a reader or a guest", "expect": "a 404 for a reader and a sign-in for a guest, never the operations", "ask": "signed in as a reader, then signed out"},
  {"go": "/data?spec=1", "look": "the forge's operations", "expect": "a table including /api/v1/openapi.json and a link to /api"}
]
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs