From 52abecd8b38f3e0916807e85d95eac8cb7083ae4 Mon Sep 17 00:00:00 2001 From: Rahul Varghese Date: Thu, 15 Oct 2026 01:25:27 +0530 Subject: [PATCH] HA0: the hono-api epic doc set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The declaration (epic.yaml, key HA, three milestones), the README with the thesis and status table, the design with the Vercel→Cloudflare mapping, the implementation plan, the risks, the as-built status, and the three task contracts. Orun-Task: HA-1 Co-Authored-By: Claude Fable 5.1 --- specs/epics/hono-api/IMPLEMENTATION-STATUS.md | 32 +++++++++++ specs/epics/hono-api/README.md | 34 ++++++++++++ specs/epics/hono-api/design.md | 55 +++++++++++++++++++ specs/epics/hono-api/epic.yaml | 28 ++++++++++ specs/epics/hono-api/implementation-plan.md | 39 +++++++++++++ .../hono-api/risks-and-open-questions.md | 39 +++++++++++++ tasks/HA-1.TaskContract.yaml | 12 ++++ tasks/HA-2.TaskContract.yaml | 15 +++++ tasks/HA-3.TaskContract.yaml | 15 +++++ 9 files changed, 269 insertions(+) create mode 100644 specs/epics/hono-api/IMPLEMENTATION-STATUS.md create mode 100644 specs/epics/hono-api/README.md create mode 100644 specs/epics/hono-api/design.md create mode 100644 specs/epics/hono-api/epic.yaml create mode 100644 specs/epics/hono-api/implementation-plan.md create mode 100644 specs/epics/hono-api/risks-and-open-questions.md create mode 100644 tasks/HA-1.TaskContract.yaml create mode 100644 tasks/HA-2.TaskContract.yaml create mode 100644 tasks/HA-3.TaskContract.yaml diff --git a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md new file mode 100644 index 0000000..d46f6c5 --- /dev/null +++ b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md @@ -0,0 +1,32 @@ +# hono-api (HA) — Implementation status + +As-built ≠ intent. This file records what actually shipped, and every place +the code departed from `design.md` or from the upstream template. + +| Milestone | State | PR | +|---|---|---| +| HA0 — the spec | | | +| HA1 — the API on Workers | | | +| HA2 — ready to instantiate | | | + +## Departures from the upstream template + +### The second welcome line + +Upstream: "To learn more about Hono on Vercel, visit +https://vercel.com/docs/frameworks/hono". Here: "To learn more about Hono on +Cloudflare Workers, visit https://hono.dev/docs/getting-started/cloudflare-workers". +The first line (`Hello Hono!`) and the route are unchanged. + +### The Node tsconfig becomes the Worker tsconfig + +Upstream's `tsconfig.json` (`module: NodeNext`, `types: ["node"]`, `outDir`) +is replaced by one that extends `tooling/tsconfig/worker.json` (bundler +resolution, `WebWorker` lib, `@cloudflare/workers-types`, `noEmit`). The +`jsx: react-jsx` / `jsxImportSource: hono/jsx` pair is kept. `@types/node` +is not a dependency of the app. + +### `@cloudflare/workers-types` 5.x + +The brief's floor was `^4.20250508.0`; wrangler 4.151.0's peer range is +`^5.20261006.1`, so the port takes 5.x to install without a peer warning. diff --git a/specs/epics/hono-api/README.md b/specs/epics/hono-api/README.md new file mode 100644 index 0000000..6ffba54 --- /dev/null +++ b/specs/epics/hono-api/README.md @@ -0,0 +1,34 @@ +# Epic: hono-api (HA) + +**Vercel's Hono boilerplate is the smallest framework template in its catalog — one `Hono` app, one route, a two-line welcome text — and Hono was written for the Workers runtime before it ran anywhere else. On Cloudflare the port is the file itself: `src/index.ts` exports the app, wrangler bundles it, and the Worker's `fetch` is Hono's. Around it is the Cirrus baseline's repository shape: an Orun intent, one component per deployable, a credential-free check lane as the merge gate, and an Orun lane that turns on when the product is linked to a workspace.** + +The upstream code stays the code. The port adds the Worker's config (`wrangler.jsonc` with per-environment sections, the way the baseline's workers deploy), the monorepo wrapper (pnpm + Turborepo, shared tsconfig and eslint), a test package that drives the app in-process with `app.request()`, and the deploy contract. The one textual change is the second welcome line, which pointed at Vercel's Hono docs and now points at Hono's Cloudflare Workers guide. + +## Status + +| Field | Value | +|-------|-------| +| Status | Draft | +| Cluster | **HA** (HA0–HA2) | +| Owner(s) | `apps/api` (the Worker) · `tests/api` (the in-process request tests) | +| Builds on | `cirrus-baseline` conventions (intent, components, `checks.yml` gate, gated `ci.yml`) and the `cloudflare-worker-turbo` composition its workers deploy with — no bounded context of the fleet is needed | +| Upstream | [vercel/examples `framework-boilerplates/hono`](https://github.com/vercel/examples/tree/main/framework-boilerplates/hono) | +| Changes | Adds the Worker config, the monorepo wrapper, tests and the deploy contract; the template's app code is untouched but for the welcome line's link | +| Decisions locked | (1) A plain Worker (`cloudflare-worker-turbo`), not Pages Functions and not an adapter: Hono's default export is already a Workers module handler. (2) `wrangler.jsonc` is committed, not rendered: the Worker binds nothing, so there is nothing to wire. (3) Per-environment deploys through wrangler `env` sections (`--env stage` / `--env prod`), naming `hono-api-api-{stage,prod}`. (4) No infra root. | +| Gate | HA1 is the first user-visible rung (the API serves from a Worker). | +| Shipped as | | + +## Read order + +1. `design.md` — what maps to what, the build, what is out of scope +2. `implementation-plan.md` — the milestones and what "done" means for each +3. `risks-and-open-questions.md` — what could go wrong and what was decided +4. `IMPLEMENTATION-STATUS.md` — what actually shipped (kept distinct from intent) + +## Milestones at a glance + +| Milestone | What it lands | Done when | +|---|---|---| +| HA0 — the spec | this doc set and the task contracts | merged on `main` | +| HA1 — the API on Workers | `apps/api` bundled by wrangler, `tests/api`, green checks | `wrangler dev` answers `/` with the welcome text; Checks green | +| HA2 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | diff --git a/specs/epics/hono-api/design.md b/specs/epics/hono-api/design.md new file mode 100644 index 0000000..119decd --- /dev/null +++ b/specs/epics/hono-api/design.md @@ -0,0 +1,55 @@ +# hono-api — design + +## 1. What the template is + +A Hono application in one file. `src/index.ts` creates `new Hono()`, +registers `app.get('/')` returning two lines of text (`Hello Hono!` and a +pointer to the framework docs), and `export default app`. The upstream +`package.json` depends on `hono` and Node typings; its `tsconfig` is +`NodeNext` with `hono/jsx` as the JSX source. On Vercel the repository is +detected as a Hono app and the default export is run as a serverless +function by Vercel's Hono builder. No data source, no auth, no other route. + +## 2. The mapping (Vercel → Cloudflare) + +| Vercel primitive the template uses | Here | +|---|---| +| Framework detection + the Hono builder (a serverless function) | A Cloudflare Worker: `export default app` is a module Worker (`fetch` is `app.fetch`); wrangler bundles `src/index.ts` with esbuild. No adapter — Hono targets the Workers runtime natively | +| `vc dev` on `:3000` | `wrangler dev` (the Worker under workerd on `:8787`), `pnpm --filter @app/api dev` | +| `vc build` | `wrangler deploy --dry-run --outdir dist`: the bundle, no upload | +| `vc deploy` | Orun: `apps/api/component.yaml` (`cloudflare-worker-turbo`) runs `wrangler deploy --env prod` (and `--env stage`) on merge to `main` once the product is linked; the Worker is `hono-api-api-{stage,prod}` | +| Node typings (`@types/node`, `module: NodeNext`) | `@cloudflare/workers-types` through the shared `tooling/tsconfig/worker.json` (bundler resolution, `WebWorker` lib); `nodejs_compat` is on for the Node built-ins a later route may need | +| The welcome line's link to Vercel's Hono docs | Hono's Cloudflare Workers guide — the only change to the app code | + +Alternative rejected: Cloudflare Pages Functions through `hono/cloudflare-pages`. +It would also serve this app, but Pages is a second deploy surface with its +own `functions/` convention and no `--env` story, and the Cirrus fleet +deploys every worker with `cloudflare-worker-turbo`; the point of the port is +a shape every later API template can copy. + +## 3. The repository + +``` +apps/api the template (src/index.ts) + the Worker config + component.yaml Orun component: build with turbo, dry-run/deploy with wrangler --env + wrangler.jsonc worker name, compatibility date, nodejs_compat, observability, env.{dev,stage,prod} vars +tests/api vitest: app.request("/") in-process — no server, no workerd +tooling/* shared tsconfig / eslint / wrangler wiring renderer (unused here: nothing to wire) +intent.yaml environments dev (verify) · stage · prod; `work:` points at specs/epics and tasks +.github/workflows checks.yml (merge gate) · ci.yml (Orun lanes, gated by the ORUN_CI variable) +``` + +## 4. The build + +`pnpm --filter @app/api build` = `wrangler deploy --dry-run --outdir dist`: +esbuild bundles `src/index.ts` and `hono` into `dist/index.js` (58 KiB, +15 KiB gzipped) and exits before upload. Orun's verify profile runs the same +dry run with `--env prod`; the deploy profile drops `--dry-run`. There is no +framework build step and nothing to pre-render. + +## 5. Out of scope + +Routes beyond `/`, bindings (KV, D1, R2 — the `*-starter` ports carry the +wiring-template shape for those), a custom domain (the baseline's +`cloudflare-domain` root), and Hono's JSX/SSR (`hono/jsx` stays configured in +`tsconfig`, as upstream had it, and is unused). diff --git a/specs/epics/hono-api/epic.yaml b/specs/epics/hono-api/epic.yaml new file mode 100644 index 0000000..b967793 --- /dev/null +++ b/specs/epics/hono-api/epic.yaml @@ -0,0 +1,28 @@ +# The epic's declaration. metadata.name equals the directory name; metadata.key +# is the task-key prefix this epic reserves (HA → HA-1, HA-2, …). Owner, target +# date and health are the platform's — never written here. +apiVersion: orun.io/v1 +kind: Epic +metadata: + name: hono-api + key: HA +spec: + title: "Vercel's Hono boilerplate as a Cloudflare Worker" + summary: "The Vercel Hono framework boilerplate — one Hono app answering `/` with a welcome text — runs natively as a Cloudflare Worker (the app's default export is the Worker's module handler), inside the Cirrus baseline's repository conventions (Orun intent and components, credential-free checks, a gated Orun CI, one epic per repository). It is the Cloudflare-only API port with the shortest path: no adapter and no build beyond wrangler's bundle." + state: backlog + milestones: + - name: "HA0 — the spec" + exitCriteria: + - "the doc set and the task contracts are on main" + tasks: [HA-1] + - name: "HA1 — the API on Workers" + exitCriteria: + - "apps/api is the upstream src/index.ts, bundled and served by wrangler as a plain Worker" + - "`pnpm typecheck`, `pnpm lint`, `pnpm test` and `pnpm build` are green on main (Checks)" + - "`wrangler dev` answers / with the welcome text and an unknown path with 404" + tasks: [HA-2] + - name: "HA2 — ready to instantiate" + exitCriteria: + - "the README says how to run, test, preview and deploy it through Orun" + - "the as-built status records every departure from the upstream template" + tasks: [HA-3] diff --git a/specs/epics/hono-api/implementation-plan.md b/specs/epics/hono-api/implementation-plan.md new file mode 100644 index 0000000..4e08209 --- /dev/null +++ b/specs/epics/hono-api/implementation-plan.md @@ -0,0 +1,39 @@ +# hono-api — implementation plan + +Milestones land in order; each task is one pull request on an +`orun/HA-n-` branch with an `Orun-Task: HA-n` trailer. + +## HA0 — the spec + +This doc set, `epic.yaml` and the task contracts, merged to `main`. + +**Done when** +- the five documents and `epic.yaml` are on `main` +- `tasks/HA-1.TaskContract.yaml`, `HA-2`, `HA-3` exist + +## HA1 — the API on Workers + +`apps/api` is the upstream `src/index.ts` with the Worker config around it; +`tests/api` drives the app in-process with `app.request()`. + +**Done when** +- `pnpm install && pnpm typecheck && pnpm lint && pnpm test && pnpm build` is green locally and in `Checks` +- `apps/api/dist/index.js` exists after the build (the wrangler dry-run bundle) +- `wrangler dev` (via `pnpm --filter @app/api dev`) answers `/` with `Hello Hono!` and an unknown path with 404 +- `wrangler deploy --dry-run --env prod` (what the Orun verify lane runs) resolves `ENVIRONMENT=prod` + +## HA2 — ready to instantiate + +The README explains the port and how to run, test, preview and deploy it; +`IMPLEMENTATION-STATUS.md` records what shipped and every departure. + +**Done when** +- the README's quick start works from a fresh clone +- the status file names the PRs and the welcome-line departure + +## Sequencing note + +HA1 needs nothing but HA0's contracts. HA2 is documentation over HA1's +verified build and can land the same day. Deploying to a Cloudflare account +is not a milestone here: it is the Orun lane (`ci.yml`) that turns on when +`intent.yaml`'s workspace is set and the `ORUN_CI` variable is `true`. diff --git a/specs/epics/hono-api/risks-and-open-questions.md b/specs/epics/hono-api/risks-and-open-questions.md new file mode 100644 index 0000000..fc30fb8 --- /dev/null +++ b/specs/epics/hono-api/risks-and-open-questions.md @@ -0,0 +1,39 @@ +# hono-api — risks and open questions + +## HA-A — Hono version drift (RISK, mitigated) + +The upstream template asks for `hono ^4.8.9`. The port pins `^4.13.0` +(4.13.13 verified) so a `pnpm install` reproduces the verified bundle; a +major bump is a deliberate PR that re-runs the tests and the dev smoke. +Hono's Workers support is first-party, so the runtime itself is not a drift +surface. + +## HA-B — The welcome text names Vercel (RESOLVED) + +The second welcome line reads "To learn more about Hono on Vercel, visit +https://vercel.com/docs/frameworks/hono". It now points at +https://hono.dev/docs/getting-started/cloudflare-workers. This is the only +change to the app code; the test asserts the first line (`Hello Hono!`) and +the new link. + +## HA-C — wrangler's multi-environment warning on the local build (ACCEPTED) + +`wrangler.jsonc` carries `env.dev`, `env.stage` and `env.prod` because the +`cloudflare-worker-turbo` composition deploys with `--env`. A bare +`wrangler deploy --dry-run` (the `build` script) therefore warns that no +target environment was given and bundles the top level (`ENVIRONMENT=local`). +That is the intended local behaviour; Orun's lanes always pass `--env`. + +## HA-D — `@cloudflare/workers-types` major (RESOLVED) + +wrangler 4.151 declares `@cloudflare/workers-types ^5.2026` as its peer; the +baseline's workers still carry 4.x. The port takes the 5.x line the peer range +asks for, which clears the install warning and typechecks the same. + +## HA-E — Upstream's Node tsconfig (RESOLVED) + +Upstream compiles with `module: NodeNext` and `types: ["node"]`, for Vercel's +Node builder. On a Worker the shared `tooling/tsconfig/worker.json` replaces +it (bundler resolution, `WebWorker` lib, `@cloudflare/workers-types`); the +`hono/jsx` JSX settings are kept so a later route can render JSX as upstream +intended. `@types/node` is dropped from the app package. diff --git a/tasks/HA-1.TaskContract.yaml b/tasks/HA-1.TaskContract.yaml new file mode 100644 index 0000000..5b89f5f --- /dev/null +++ b/tasks/HA-1.TaskContract.yaml @@ -0,0 +1,12 @@ +apiVersion: orun.io/v1 +kind: TaskContract +spec: + goal: The hono-api epic — declaration, doc set and task contracts — is on main + affects: + - specs/epics/hono-api + - specs/epics/README.md + - tasks + doneWhen: + - epic.yaml, README, design, implementation plan, risks and status are merged + - the three task contracts exist + gates: [] diff --git a/tasks/HA-2.TaskContract.yaml b/tasks/HA-2.TaskContract.yaml new file mode 100644 index 0000000..4847dba --- /dev/null +++ b/tasks/HA-2.TaskContract.yaml @@ -0,0 +1,15 @@ +apiVersion: orun.io/v1 +kind: TaskContract +spec: + goal: The upstream Hono boilerplate runs as a plain Cloudflare Worker with green checks + affects: + - apps/api + - tests/api + - pnpm-lock.yaml + - package.json + - turbo.json + doneWhen: + - pnpm typecheck, lint, test and build are green in Checks + - wrangler dev answers / with the welcome text and an unknown path with 404 + gates: + - checks diff --git a/tasks/HA-3.TaskContract.yaml b/tasks/HA-3.TaskContract.yaml new file mode 100644 index 0000000..56244b6 --- /dev/null +++ b/tasks/HA-3.TaskContract.yaml @@ -0,0 +1,15 @@ +apiVersion: orun.io/v1 +kind: TaskContract +spec: + goal: A reader can run, test, preview and deploy the port from the README; the as-built status is complete + affects: + - README.md + - specs/epics/hono-api/IMPLEMENTATION-STATUS.md + - specs/epics/hono-api/README.md + - specs/epics/hono-api/epic.yaml + - specs/epics/hono-api/implementation-plan.md + - specs/epics/README.md + doneWhen: + - README quick start is verified from a fresh clone + - IMPLEMENTATION-STATUS lists every PR and departure + gates: []