Repository navigation
Closed
Labels
area:cliTouches the cli areaarea:coreTouches the core areaarea:docsTouches the docs areaarea:serverTouches the server areaready-for-agentFully specified, ready for an AFK agent
Description
Problem
Request/response shapes live implicitly in apps/server/src/app.ts and are re-typed by hand in the CLI and its stubs; only status has --json; there is no API reference. Supersedes #35.
Do
- New
packages/api(@patchy/api), importing only@patchy/core+ Effect: oneSchema.Classper wire shape; theHttpApiwith two groups —auth(tokens, mint, me) andpatches— under.prefix("/api"). The wire renamesdraft → patchhere: paths (/api/patches/*) and field names are written withpatchnaming from the start so agents see one wire break, not two; update the CLI (drafts.jsoncache keys included),docs/API.mdandskills/patchy/SKILL.mdin the same PR. Tables and code keepdraftuntil thepatchesticket; the bearerHttpApiMiddleware.Servicedefinition withsecurity: { bearer }and the 401 body pinned as today's{ ok: false, error: "Missing or invalid API token." }(plainSchema.Struct+HttpApiSchema.status(401), no_tag); the derivedHttpApiClient. Shape to copy:packages/effect-slice/src/api.tsonprototype/effect-slice. - Error responses carry the same field names and status codes as today for every route (400/401/403/404/409/413/429); the CLI's exit-code ladder later keys off status, not body.
- Fastify decodes and encodes through these schemas as the interim adapter (
Schema.decodeUnknownSync/encodeSyncat the route boundary). No handler is rewritten;runPromiseis not needed. - CLI:
--jsonon every command (auth set,whoami,status,validate,upload;deleteif #41 has landed), printing exactly theapishape; success is one stdout document, failure{ ok: false, error }on stderr (thekindfield arrives with thecliport).status --json's contract test reads its keys from a real run. docs/API.mdrendered fromOpenApi.fromApi(PatchyApi)by a small local markdown renderer inpackages/api/scripts/, pinned by a test that fails on drift.- ADR
apiis the contract package indocs/adr/(why wire types live beside neither context). - Tests:
HttpApiTest.groupsis not yet usable without handlers — pin schemas with decode/encode round-trip tests and keep the existing route tests green through the adapter.
Done when
One schema per wire shape used by server, CLI and docs; no draft on the wire; every command has --json; the API.md test fails on drift; #35 closed as superseded.
Decisions implemented
Spec §1 (HTTP shape, 401 body), §9 (wire schemas, API.md); #35; vertical slice.
Filed from the Effect v4 port spec (#68) by the map task Write the port spec and file the build tickets.
Metadata
Metadata
Assignees
Labels
area:cliTouches the cli areaarea:coreTouches the core areaarea:docsTouches the docs areaarea:serverTouches the server areaready-for-agentFully specified, ready for an AFK agent
Activity
feat(api): one wire contract for server, CLI and docs, with --json on…