sordo 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -0
- package/CLAUDE.md +124 -0
- package/README.md +102 -2
- package/bin/sordo.ts +5 -0
- package/package.json +73 -5
- package/src/adapters/bun.ts +59 -0
- package/src/adapters/edge.ts +38 -0
- package/src/adapters/types.ts +39 -0
- package/src/agents-md/collect.ts +113 -0
- package/src/agents-md/generate.ts +44 -0
- package/src/agents-md/index.ts +9 -0
- package/src/agents-md/render.ts +150 -0
- package/src/agents-md/subprocess-entry.ts +92 -0
- package/src/agents-md/subprocess-runner.ts +111 -0
- package/src/agents-md/write.ts +38 -0
- package/src/agents-md/zod-to-json-schema.ts +18 -0
- package/src/ai/context.ts +72 -0
- package/src/ai/define.ts +15 -0
- package/src/ai/errors.ts +51 -0
- package/src/ai/index.ts +36 -0
- package/src/ai/middleware.ts +21 -0
- package/src/ai/registry.ts +96 -0
- package/src/ai/run.ts +185 -0
- package/src/ai/scan.ts +42 -0
- package/src/ai/stream.ts +71 -0
- package/src/ai/triggers.ts +124 -0
- package/src/ai/types.ts +67 -0
- package/src/ai/validate.ts +82 -0
- package/src/build/assets.ts +48 -0
- package/src/build/client-entry.ts +43 -0
- package/src/build/css.ts +102 -0
- package/src/build/embedded.ts +66 -0
- package/src/build/hash.ts +21 -0
- package/src/build/index.ts +476 -0
- package/src/build/macros/agents-hash.macro.ts +9 -0
- package/src/build/macros/agents.macro.ts +21 -0
- package/src/build/macros/env.macro.ts +25 -0
- package/src/build/macros/inline-assets.macro.ts +28 -0
- package/src/build/macros/manifest.macro.ts +8 -0
- package/src/build/macros/routes.macro.ts +10 -0
- package/src/build/page-entry.ts +136 -0
- package/src/build/scan-islands.ts +39 -0
- package/src/build/server-entry.ts +256 -0
- package/src/cli/ansi.ts +41 -0
- package/src/cli/build.ts +184 -0
- package/src/cli/commands/add/apply.ts +31 -0
- package/src/cli/commands/add/component-diff.ts +116 -0
- package/src/cli/commands/add/diff.ts +153 -0
- package/src/cli/commands/add/internal.ts +41 -0
- package/src/cli/commands/add/load-catalog.ts +22 -0
- package/src/cli/commands/add/peer-deps.ts +115 -0
- package/src/cli/commands/add/registry-fetch.ts +122 -0
- package/src/cli/commands/add/shadcn.ts +285 -0
- package/src/cli/commands/add/source.ts +273 -0
- package/src/cli/commands/add/stamper.ts +73 -0
- package/src/cli/commands/add/tokens.ts +81 -0
- package/src/cli/commands/add/ui-paths.ts +113 -0
- package/src/cli/commands/add.ts +427 -0
- package/src/cli/commands/deploy.ts +143 -0
- package/src/cli/commands/migrate.ts +149 -0
- package/src/cli/commands/secret.ts +316 -0
- package/src/cli/commands/ui/build.ts +111 -0
- package/src/cli/commands/ui/init.ts +135 -0
- package/src/cli/commands/ui/migrate/git-guard.ts +19 -0
- package/src/cli/commands/ui/migrate/radix.ts +67 -0
- package/src/cli/commands/ui/migrate/rtl.ts +148 -0
- package/src/cli/commands/ui/shadcn.ts +82 -0
- package/src/cli/commands/ui/view.ts +63 -0
- package/src/cli/commands/ui.ts +86 -0
- package/src/cli/commands/update.ts +134 -0
- package/src/cli/commands/upgrade.ts +53 -0
- package/src/cli/commands/view.ts +34 -0
- package/src/cli/dev.ts +393 -0
- package/src/cli/doctor/config-checks.ts +63 -0
- package/src/cli/doctor/deps.ts +295 -0
- package/src/cli/doctor/hydrate.ts +65 -0
- package/src/cli/doctor/monorepo.ts +158 -0
- package/src/cli/doctor/probes.ts +16 -0
- package/src/cli/doctor/report.ts +72 -0
- package/src/cli/doctor/toolchain.ts +95 -0
- package/src/cli/doctor/types.ts +36 -0
- package/src/cli/doctor.ts +127 -0
- package/src/cli/index.ts +168 -0
- package/src/cli/log.ts +135 -0
- package/src/cli/run/affected.ts +79 -0
- package/src/cli/run/cache-key.ts +177 -0
- package/src/cli/run/cache-store.ts +0 -0
- package/src/cli/run/files.ts +96 -0
- package/src/cli/run/git.ts +13 -0
- package/src/cli/run/runner.ts +189 -0
- package/src/cli/run/workspace.ts +216 -0
- package/src/cli/run.ts +184 -0
- package/src/cli/start.ts +99 -0
- package/src/cli/update-check.ts +157 -0
- package/src/client/index.ts +65 -0
- package/src/client/link.tsx +61 -0
- package/src/client/page.ts +250 -0
- package/src/config/define.ts +5 -0
- package/src/config/env.ts +36 -0
- package/src/config/load.ts +152 -0
- package/src/config/schema.ts +128 -0
- package/src/config/secrets.ts +108 -0
- package/src/dev/client.ts +112 -0
- package/src/dev/hot.ts +24 -0
- package/src/dev/index.ts +4 -0
- package/src/dev/tree.ts +95 -0
- package/src/dev/watcher.ts +95 -0
- package/src/index.ts +54 -0
- package/src/internal/hmr-client.ts +52 -0
- package/src/internal/open-in-editor.ts +23 -0
- package/src/internal/runtime.ts +30 -0
- package/src/middleware/cookie-jar.ts +135 -0
- package/src/middleware/cookies.ts +60 -0
- package/src/middleware/index.ts +99 -0
- package/src/middleware/request-id.ts +22 -0
- package/src/middleware/response-helpers.ts +25 -0
- package/src/plugin/index.ts +109 -0
- package/src/render/bootstrap.ts +44 -0
- package/src/render/dev-error.tsx +73 -0
- package/src/render/index.tsx +261 -0
- package/src/render/island.tsx +33 -0
- package/src/render/meta.tsx +48 -0
- package/src/render/shell.tsx +41 -0
- package/src/router/conflict.ts +20 -0
- package/src/router/filesystem.ts +37 -0
- package/src/router/index.ts +247 -0
- package/src/router/match.ts +91 -0
- package/src/router/pattern.ts +88 -0
- package/src/server/index.ts +250 -0
- package/src/server/inline-assets.ts +39 -0
- package/src/types.ts +53 -0
- package/src/ui/schema.ts +68 -0
- package/src/ui/types.ts +10 -0
- package/templates/_internal/cn.ts +6 -0
- package/templates/_internal/slot.ts +50 -0
- package/templates/_internal/variants.ts +1 -0
- package/templates/themes/neutral/tokens.css +46 -0
- package/templates/themes/slate/tokens.css +46 -0
- package/templates/themes/stone/tokens.css +46 -0
- package/templates/themes/zinc/tokens.css +46 -0
- package/templates/tokens.css +46 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# sordo
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0f36821: Add an optional `css` build entry. Set `css: "app/styles/app.css"` (or `{ entry, tailwind }`) in `sordo.config.ts` and `sordo build` / the dev client compile it with `Bun.build` into a content-hashed sheet under `/_sordo/client/`, record it as `manifest.css`, and link it from every rendered page. The bun and edge servers serve the sheet from the bundle. Entries that `@import "tailwindcss"` load `bun-plugin-tailwind` (an optional peer dependency: `bun add -D bun-plugin-tailwind`). Apps without the option build exactly as before.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 62a3969: Production servers now serve the app's client code. A non-compiled `bun` build and the `edge` worker serve every `/_sordo/client/*` output (island and page chunks, the CSS sheet and its assets) from bytes inlined at build time, so islands and hydrated pages hydrate in production. Before, only `--compile` builds served them, and every other build returned 404. Adds `sordo start`, which runs the last build's server (the compiled binary when there is one) and accepts `--port` / `--out`; scaffolded apps' `bun run start` already calls it. The built bun server now honours `PORT`.
|
|
12
|
+
|
|
13
|
+
## 0.2.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- c5c1020: Remove the `patties-ui` package and its built-in 60-component catalog. `sordo add` now takes upstream shadcn/ui (`@shadcn/<name>`), local paths, URLs, and `ui.registries`; `sordo add <name>` for a non-catalog name points at `@shadcn/<name>`. The registry schema, `_internal` helpers, tokens, and theme presets now ship inside `sordo`, so `bun add -D patties-ui` is no longer needed. Scaffolded apps no longer depend on `patties-ui`.
|
|
18
|
+
- a50617f: `sordo add @shadcn/<name>` stamps upstream shadcn/ui verbatim: registry items are mapped onto the existing add pipeline (import alias rewrite, transitive registry deps, pinned peer deps, `cssVars` token merge, schema validation, HTTPS-only, never installs). `sordo ui init --shadcn` wires the `@/*` alias and `app/lib/utils.ts`. The registry `ComponentFileSchema` gains an optional `root` (`components` | `app`) for files stamped into `app/{components,hooks,lib}`; the stamper refuses any other app-dir destination.
|
|
19
|
+
- a50617f: Add opt-in whole-tree page hydration (`export const hydrate = true`, or `render: { hydrate: "pages" }`): the page's whole React tree hydrates as one root from a `__sordo_bootstrap` payload, so function props and shared context work. Pages can export `loader(req, ctx)` (plus optional `serialize`/`deserialize`); server-only exports are stripped from client bundles. Adds client-side navigation between hydrated pages (`Link`, `navigate`, `prefetch` from `sordo/client`), per-route client-bytes reporting in `sordo build`, and a `sordo doctor` check for pages mixing `<Island>` with `hydrate`. Client bundles now define `NODE_ENV`, so production builds ship React's production build. Routes without `hydrate` are unchanged.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 36541a8: `sordo dev` no longer misses a newly added or deleted route when the file watcher drops its event; the app tree is also rescanned every second, so the server restarts within about a second instead of serving a stale route table.
|
|
24
|
+
- 089cb1a: Fix the `edge` target crashing every request with `Bun is not defined` / `process is not defined` on workerd. Cookies fall back to a small built-in jar when `Bun.CookieMap` is absent, and env / cwd / semver lookups no longer assume `Bun` or `process` exist.
|
|
25
|
+
|
|
26
|
+
## 0.1.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- 748b2d7: Add `sordo run <task>`: a Bun-native task runner with a content-addressed
|
|
31
|
+
output cache and affected detection for workspace monorepos.
|
|
32
|
+
|
|
33
|
+
`sordo run` wraps each `(package, task)` unit with a cache built entirely on
|
|
34
|
+
Bun builtins (`Bun.CryptoHasher`, `Bun.Glob`, `Bun.Archive`, `bun:sqlite`,
|
|
35
|
+
`Bun.$`, `Bun.spawn`) — no Turborepo/Nx. It walks the workspace in topological
|
|
36
|
+
order, computes a conservative nine-component sha256 cache key per task, and on a
|
|
37
|
+
hit restores the task's declared outputs and replays its log instead of
|
|
38
|
+
re-running. A leaf change rebuilds exactly it and its transitive dependents;
|
|
39
|
+
everything else restores from cache.
|
|
40
|
+
|
|
41
|
+
Declare per-task `inputs` / `outputs` / `env` / `cache` in a `tasks` block in
|
|
42
|
+
`sordo.config.ts`. Flags: `--filter`, `--affected --since <ref>`, `--no-cache`,
|
|
43
|
+
`--force`, and `--dry-run` (which explains every hit/miss and why a key changed).
|
|
44
|
+
`sordo dev` / `build` are unchanged. Remote caching (`--remote`) is reserved
|
|
45
|
+
for a later release.
|
|
46
|
+
|
|
47
|
+
- b893f36: Add `sordo doctor`: a read-only project hygiene report. Runs and contextualizes `bun audit` / `bun outdated`, adds sordo-specific checks (config validity, single-React invariant in monorepos), and prints one aligned report with a concrete remedy per finding. Composed from Bun builtins (`Bun.which`, `Bun.$`, `Bun.stringWidth`/`stripANSI`/`wrapAnsi`). Exit codes: 0 pass / 1 fail / 2 cannot-run.
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- ffa0b2b: Add an "update available" banner and a `sordo upgrade` command.
|
|
52
|
+
|
|
53
|
+
The CLI now prints a cached, channel-aware banner on startup when a newer
|
|
54
|
+
`sordo` is published, and `sordo upgrade` bumps the project's dependency to
|
|
55
|
+
the newest release on its channel (`bun add sordo@<latest|next|…>`). The
|
|
56
|
+
banner reads from a local cache and refreshes in the background, so it never
|
|
57
|
+
blocks the CLI; opt out with `--no-update-check` or `NO_UPDATE_NOTIFIER`.
|
|
58
|
+
|
|
59
|
+
- ffa0b2b: Make dev-server bin + React resolution workspace-aware so Bun-workspace monorepos (hoisted root `node_modules`) load a single copy of React and don't crash SSR with "Invalid hook call". Flat-app resolution is unchanged.
|
|
60
|
+
- a99d1bf: Make `patties-ui` truly optional at the CLI: the `add` / `ui` / `view` /
|
|
61
|
+
`update` catalog commands (the only modules that import `patties-ui`) are now
|
|
62
|
+
lazy-loaded in the command dispatcher, so `sordo dev` / `build` / `deploy` /
|
|
63
|
+
`secret` no longer fail with "Cannot find module 'patties-ui/schema'" in
|
|
64
|
+
projects that don't depend on the UI catalog (e.g. backend or `--no-ui`
|
|
65
|
+
projects scaffolded by create-sordo).
|
|
66
|
+
|
|
67
|
+
## 0.0.12-next.0
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- ffa0b2b: Add an "update available" banner and a `sordo upgrade` command.
|
|
72
|
+
|
|
73
|
+
The CLI now prints a cached, channel-aware banner on startup when a newer
|
|
74
|
+
`sordo` is published, and `sordo upgrade` bumps the project's dependency to
|
|
75
|
+
the newest release on its channel (`bun add sordo@<latest|next|…>`). The
|
|
76
|
+
banner reads from a local cache and refreshes in the background, so it never
|
|
77
|
+
blocks the CLI; opt out with `--no-update-check` or `NO_UPDATE_NOTIFIER`.
|
|
78
|
+
|
|
79
|
+
- ffa0b2b: Make dev-server bin + React resolution workspace-aware so Bun-workspace monorepos (hoisted root `node_modules`) load a single copy of React and don't crash SSR with "Invalid hook call". Flat-app resolution is unchanged.
|
|
80
|
+
- a99d1bf: Make `patties-ui` truly optional at the CLI: the `add` / `ui` / `view` /
|
|
81
|
+
`update` catalog commands (the only modules that import `patties-ui`) are now
|
|
82
|
+
lazy-loaded in the command dispatcher, so `sordo dev` / `build` / `deploy` /
|
|
83
|
+
`secret` no longer fail with "Cannot find module 'patties-ui/schema'" in
|
|
84
|
+
projects that don't depend on the UI catalog (e.g. backend or `--no-ui`
|
|
85
|
+
projects scaffolded by create-sordo).
|
|
86
|
+
|
|
87
|
+
## 0.0.8
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- 67ab8ce: Internal: move framework source from the repo root into
|
|
92
|
+
`packages/sordo/` so the framework participates in changesets-managed
|
|
93
|
+
releases. The repo root is now a private workspace shell; both
|
|
94
|
+
`sordo` and `create-sordo` live under `packages/*` and are
|
|
95
|
+
discovered uniformly by changesets and `bun --filter`.
|
|
96
|
+
|
|
97
|
+
No public API changes. The published tarball still ships `src/`,
|
|
98
|
+
`bin/`, `AGENTS.md`, `README.md`, and `CHANGELOG.md` at the same
|
|
99
|
+
relative paths inside the package.
|
|
100
|
+
|
|
101
|
+
## 0.0.3
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- Ship phase 4: plugin system (`sordo/plugin` subpath). Adds `definePlugin`, `PluginServer.route`/`use`, `Bun.semver`-based compat checks, and hooks for build, dev, agents-md, and jobs.
|
|
106
|
+
|
|
107
|
+
## 0.0.1
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- Initial release.
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# `sordo` package conventions
|
|
2
|
+
|
|
3
|
+
This is the framework itself — the runtime, CLI, build pipeline, dev server,
|
|
4
|
+
renderer, router, middleware, and adapters. Most things you'd add to a
|
|
5
|
+
Bun-native full-stack framework live somewhere under `src/`.
|
|
6
|
+
|
|
7
|
+
Project-wide rules live in `../../CLAUDE.md`. Read those first. The notes
|
|
8
|
+
below are specific to working inside this package.
|
|
9
|
+
|
|
10
|
+
## Source layout
|
|
11
|
+
|
|
12
|
+
- `src/router/` — filesystem route scan + compile to Bun route patterns
|
|
13
|
+
- `src/render/` — React SSR (`renderToReadableStream`) + dev error overlay + island marker emission
|
|
14
|
+
- `src/client/` — browser hydration runtime: scans `[data-island]` markers; `page.ts` boots whole-tree hydrated pages (`export const hydrate = true`) and drives client-side navigation (`Link` / `navigate`) from the `__sordo_bootstrap` payload (framework specs 28/29)
|
|
15
|
+
- `src/build/` — route + island scan, client/server entry generation, `Bun.build` pipeline. Hydrated pages get a generated per-route entry (`page-entry.ts`) bundled in the same split build as islands; `loader`/`serialize` are stripped from client bundles via `Bun.Transpiler` export elimination. `adapter.bun.compile` (production) runs `bun build --compile` against the generated server-entry SOURCE and embeds app/public + client chunks via `with { type: "file" }` / `Bun.embeddedFiles`; `--compile` with `--target edge` is a config-time error. An optional `css` config entry is built by `css.ts` into a hashed sheet under `client/`, recorded as `manifest.css` (the renderer links it), and inlined into the bun/edge server bundle via `inline-assets.macro.ts`; Tailwind entries load `bun-plugin-tailwind` (optional peer) by dynamic import
|
|
16
|
+
- `src/middleware/` — composition, `SordoContext`. `request-id.ts` mints `ctx.requestId` (echoed as `X-Request-Id`, inbound junk ignored); the router finalizer folds in the cookie flush and dev-only `Server-Timing`
|
|
17
|
+
- `src/dev/` — `bun --hot` / `bun --watch` integration, HMR WebSocket, `setupDevClient` (bundles islands in dev and serves `/_sordo/client/*`)
|
|
18
|
+
- `src/server/` — `startServer` / `createServer` around `Bun.serve`
|
|
19
|
+
- `src/config/` — `defineConfig`, env + secrets loading, Zod schemas. `config.agentsMd.path` (string or string[]) picks where the manifest lands; default is `CLAUDE.md`
|
|
20
|
+
- `src/ai/` — optional agents / tools / jobs primitives (Anthropic SDK is an optional peer dep)
|
|
21
|
+
- `src/agents-md/` — manifest generator + `writeManifestToFile` (splices into a fenced section so rules around it survive regeneration)
|
|
22
|
+
- `src/plugin/` — plugin system
|
|
23
|
+
- `src/adapters/` — `bun` and `edge` runtime adapters
|
|
24
|
+
|
|
25
|
+
## Public entry points
|
|
26
|
+
|
|
27
|
+
Declared in `package.json#exports`:
|
|
28
|
+
|
|
29
|
+
`sordo`, `sordo/router`, `sordo/render`, `sordo/client`,
|
|
30
|
+
`sordo/build`, `sordo/dev`, `sordo/config`, `sordo/middleware`,
|
|
31
|
+
`sordo/server`, `sordo/ai`, `sordo/agents-md`, `sordo/plugin`.
|
|
32
|
+
|
|
33
|
+
CLI at `bin/sordo.ts` → `src/cli/index.ts` (`dev` / `build` / `start` / `run` / `deploy` / `secret` / `doctor` / `add` / `ui` / `view` / `update` / `upgrade` / `migrate`). `run` is the opt-in monorepo task orchestrator: `sordo run <task>` wraps each workspace `(package, task)` unit with a content-addressed output cache + affected detection (`src/cli/run.ts` + `src/cli/run/`, framework spec 27). Its cache is 100% Bun builtins (`Bun.CryptoHasher` sha256 key, `Bun.Glob`, `Bun.Archive` tarballs, `bun:sqlite` WAL index, `Bun.$` git, `Bun.spawn`); per-task `inputs`/`outputs`/`env`/`cache` come from a `tasks` block in `sordo.config.ts`. `sordo add <component>` stamps UI source (upstream shadcn/ui via `@shadcn/<name>`) into `app/components/ui/` (it also resolves local paths, https URLs, and `@ns/<name>` namespaced registries); `ui init` scaffolds tokens + helpers, `ui build` emits a fetchable registry, `view`/`update` preview-then-stamp, and `migrate` codemods radix imports / RTL logical props. See `src/cli/commands/` and `.claude/rules/ui-catalog.md`. `upgrade` bumps the project's `sordo` dependency to the newest release on its channel (stable→`latest`, prerelease→its pre tag); the CLI also prints a cached, channel-aware "update available" banner on startup (`src/cli/update-check.ts`, opt out with `--no-update-check` / `NO_UPDATE_NOTIFIER`). `doctor` aggregates read-only project-hygiene checks (toolchain probes, `bun audit` / `bun outdated`, lockfile sync, config + biome validity, and monorepo single-React / catalog invariants) into one aligned report with a remedy per finding and a CI exit code (`src/cli/doctor.ts` + `src/cli/doctor/`, cli spec 20); Phase 1 is report-only — no `--fix`. Width-aware output utilities live in `src/cli/ansi.ts` (`Bun.stringWidth` / `stripANSI` / `wrapAnsi`).
|
|
34
|
+
|
|
35
|
+
## Dev mode wiring
|
|
36
|
+
|
|
37
|
+
`sordo dev` re-execs under `bun --hot --preserve-symlinks` and resolves the
|
|
38
|
+
re-exec entry through the user-project copy of the bin
|
|
39
|
+
(`<cwd>/node_modules/sordo/bin/sordo.ts` when present). This keeps module
|
|
40
|
+
resolution rooted in the app even when `sordo` is linked from a workspace —
|
|
41
|
+
without it, two copies of React load and SSR hooks blow up.
|
|
42
|
+
|
|
43
|
+
Templates wire dev mode via `setupDevClient({ appDir })` from `sordo/dev`:
|
|
44
|
+
it bundles islands in development, mutates a `ClientManifest` the renderer
|
|
45
|
+
holds by reference, and returns a `BunRoutes` map for `/_sordo/client/*`.
|
|
46
|
+
Pages emit hydration markers only when wrapped in `<Island name=…>` — direct
|
|
47
|
+
island imports SSR fine but never hydrate.
|
|
48
|
+
|
|
49
|
+
## Tests
|
|
50
|
+
|
|
51
|
+
`bun test`. Snapshot-style assertions on the agent manifest live under
|
|
52
|
+
`tests/agents-md/`; the framework's checked-in `CLAUDE.md` manifest section
|
|
53
|
+
is regenerated by `scripts/generate-agents-md.ts` and CI fails on drift.
|
|
54
|
+
|
|
55
|
+
The manifest section below is auto-generated from
|
|
56
|
+
`tests/fixtures/ai-app/app`. Everything between the markers is regenerated
|
|
57
|
+
on every `sordo dev/build` (and by the script above); content outside the
|
|
58
|
+
markers is preserved.
|
|
59
|
+
|
|
60
|
+
<!-- sordo:manifest-start -->
|
|
61
|
+
> Generated by `sordo dev/build`. Edits inside the manifest markers are overwritten; content outside is preserved.
|
|
62
|
+
|
|
63
|
+
## Route map
|
|
64
|
+
|
|
65
|
+
| File | URL | Methods |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| tests/fixtures/ai-app/app/routes/index.tsx | / | GET |
|
|
68
|
+
|
|
69
|
+
## Islands
|
|
70
|
+
|
|
71
|
+
_No islands._
|
|
72
|
+
|
|
73
|
+
## Agents
|
|
74
|
+
|
|
75
|
+
| Name | Model | Tools | Triggers |
|
|
76
|
+
|---|---|---|---|
|
|
77
|
+
| booking | claude-sonnet-4-6 | search | POST /api/booking/chat |
|
|
78
|
+
| concierge | claude-sonnet-4-6 | | |
|
|
79
|
+
|
|
80
|
+
## Tools
|
|
81
|
+
|
|
82
|
+
### `search`
|
|
83
|
+
|
|
84
|
+
Search hotel inventory.
|
|
85
|
+
|
|
86
|
+
Input schema:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"additionalProperties": false,
|
|
91
|
+
"properties": {
|
|
92
|
+
"city": {
|
|
93
|
+
"type": "string"
|
|
94
|
+
},
|
|
95
|
+
"from": {
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
"to": {
|
|
99
|
+
"type": "string"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"required": [
|
|
103
|
+
"city",
|
|
104
|
+
"from",
|
|
105
|
+
"to"
|
|
106
|
+
],
|
|
107
|
+
"type": "object"
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Jobs
|
|
112
|
+
|
|
113
|
+
| Name | Schedule | TZ |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| refresh-inventory | */15 * * * * | Asia/Makassar |
|
|
116
|
+
|
|
117
|
+
## Middleware
|
|
118
|
+
|
|
119
|
+
Tracks request counts and attaches a marker for downstream handlers.
|
|
120
|
+
|
|
121
|
+
## Environment variables
|
|
122
|
+
|
|
123
|
+
_No declared env vars._
|
|
124
|
+
<!-- sordo:manifest-end -->
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./sordo-banner.png" alt="Bun + Sordo" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# Bun + Sordo
|
|
6
|
+
|
|
7
|
+
Sordo is a Bun-native full-stack meta-framework with React for UI and `Bun.serve` for HTTP. It is intentionally built around Bun primitives — `Bun.serve`, `Bun.Glob`, `Bun.build`, `bun --hot` — rather than as a Node-era framework with a Bun adapter. The goal is a smaller, more legible architecture that treats Bun as the foundation instead of a faster place to run old assumptions.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
bunx create-sordo@latest my-app
|
|
13
|
+
cd my-app
|
|
14
|
+
bunx sordo dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
By default the scaffold includes a `CLAUDE.md` for Claude Code (rules +
|
|
18
|
+
auto-generated manifest fenced into a marked section). Pick a different
|
|
19
|
+
agent platform with `--template`:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
bunx create-sordo@latest my-app --template codex # .codex/ + AGENTS.md
|
|
23
|
+
bunx create-sordo@latest my-app --template none # no agent file
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Manual setup
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
bun add sordo react react-dom
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { setupDevClient } from "sordo/dev"
|
|
34
|
+
import { createRenderer } from "sordo/render"
|
|
35
|
+
import { createRouter } from "sordo/router"
|
|
36
|
+
import { startServer } from "sordo/server"
|
|
37
|
+
|
|
38
|
+
const appDir = import.meta.dir + "/app"
|
|
39
|
+
const devClient = await setupDevClient({ appDir })
|
|
40
|
+
const renderer = createRenderer({ manifest: devClient.manifest, dev: true })
|
|
41
|
+
const { routes, fallback } = await createRouter({ appDir, renderer })
|
|
42
|
+
|
|
43
|
+
startServer({
|
|
44
|
+
routes: { ...devClient.routes, ...routes },
|
|
45
|
+
fallback,
|
|
46
|
+
dev: true,
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Drop files into `app/routes/` for pages and API handlers, and into
|
|
51
|
+
`app/islands/` for components you want hydrated on the client. Wrap each
|
|
52
|
+
island use site in `<Island name="MyIsland">…</Island>` (from
|
|
53
|
+
`sordo/render`) so the SSR markers are emitted and the client runtime
|
|
54
|
+
hydrates them.
|
|
55
|
+
|
|
56
|
+
## Agent manifest
|
|
57
|
+
|
|
58
|
+
`sordo dev` / `sordo build` regenerate a route + island + agent +
|
|
59
|
+
tool + job + middleware + env inventory. It's spliced between
|
|
60
|
+
`<!-- sordo:manifest-start -->` … `<!-- sordo:manifest-end -->` so
|
|
61
|
+
rules and notes above the section are preserved across regenerations.
|
|
62
|
+
Default target is `CLAUDE.md`; override with `config.agentsMd.path`
|
|
63
|
+
(string or `string[]`) in `sordo.config.ts`.
|
|
64
|
+
|
|
65
|
+
## CLI
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
sordo dev # bun --hot dev server (use --cold for bun --watch)
|
|
69
|
+
sordo build # production bundle
|
|
70
|
+
sordo build --target edge
|
|
71
|
+
sordo deploy # build then dispatch to an installed deploy plugin
|
|
72
|
+
sordo secret # manage dev-time secrets in the OS keychain
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
UI components (upstream shadcn/ui, local paths, or registries):
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
sordo ui init # scaffold tokens + _internal helpers (once)
|
|
79
|
+
sordo add @shadcn/button # stamp components into app/components/ui/
|
|
80
|
+
sordo view button # print a component's source before stamping
|
|
81
|
+
sordo update button # re-stamp from the catalog after showing the diff
|
|
82
|
+
sordo migrate # codemods: radix imports / RTL logical properties
|
|
83
|
+
sordo ui build # emit a fetchable registry.json (for registry authors)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
See `sordo --help` for all flags.
|
|
87
|
+
|
|
88
|
+
## What's in the box
|
|
89
|
+
|
|
90
|
+
- Filesystem routing compiled to Bun route patterns
|
|
91
|
+
- React server rendering via `renderToReadableStream`
|
|
92
|
+
- Client islands with on-demand hydration
|
|
93
|
+
- HMR over a small WebSocket layer
|
|
94
|
+
- Build pipeline that inlines route + island manifests for portable Bun / edge output
|
|
95
|
+
- Single-file `--compile` binaries (`adapter.bun.compile`) with app/public + client chunks embedded via `Bun.embeddedFiles` — no `dist/` sidecar to ship
|
|
96
|
+
- Per-request correlation IDs on `ctx.requestId`, echoed as `X-Request-Id`; dev responses also carry `Server-Timing: total;dur=<ms>`
|
|
97
|
+
- Middleware composition, typed context, config + secrets loading
|
|
98
|
+
- Optional AI primitives (agents, tools, jobs) and agent-manifest generation (default `CLAUDE.md`, configurable)
|
|
99
|
+
- Plugin system
|
|
100
|
+
|
|
101
|
+
## Background
|
|
102
|
+
|
|
103
|
+
Read the longer write-up: [_Bun, Patties, and Fries: A Complete Meal for the Bun-Native Web Stack_](https://medium.com/bihaviour/bun-patties-and-fries-a-complete-meal-for-the-bun-native-web-stack-01bcf977f564).
|
package/bin/sordo.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "sordo",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Bun-native full-stack meta-framework with React rendering",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/bihaviour/sordo.git",
|
|
8
|
+
"directory": "packages/sordo"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/index.ts",
|
|
14
|
+
"./middleware": "./src/middleware/index.ts",
|
|
15
|
+
"./server": "./src/server/index.ts",
|
|
16
|
+
"./router": "./src/router/index.ts",
|
|
17
|
+
"./render": "./src/render/index.tsx",
|
|
18
|
+
"./client": "./src/client/index.ts",
|
|
19
|
+
"./build": "./src/build/index.ts",
|
|
20
|
+
"./dev": "./src/dev/index.ts",
|
|
21
|
+
"./config": "./src/config/define.ts",
|
|
22
|
+
"./ai": "./src/ai/index.ts",
|
|
23
|
+
"./agents-md": "./src/agents-md/index.ts",
|
|
24
|
+
"./plugin": "./src/plugin/index.ts"
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"sordo": "bin/sordo.ts"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"bin",
|
|
31
|
+
"src",
|
|
32
|
+
"templates",
|
|
33
|
+
"CLAUDE.md",
|
|
34
|
+
"README.md",
|
|
35
|
+
"CHANGELOG.md"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test": "bun test",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint": "biome check .",
|
|
41
|
+
"generate:agents-md": "bun run scripts/generate-agents-md.ts"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "^19.0.0",
|
|
45
|
+
"react-dom": "^19.0.0",
|
|
46
|
+
"@anthropic-ai/sdk": "^0.30.0",
|
|
47
|
+
"bun-plugin-tailwind": ">=0.1.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@anthropic-ai/sdk": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"bun-plugin-tailwind": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"zod": "^4.4.3"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@happy-dom/global-registrator": "^15.0.0",
|
|
62
|
+
"@types/react": "^19.0.0",
|
|
63
|
+
"@types/react-dom": "^19.0.0",
|
|
64
|
+
"class-variance-authority": "^0.7.0",
|
|
65
|
+
"cn": "^0.5.0",
|
|
66
|
+
"lucide-react": "^1.59.0",
|
|
67
|
+
"radix-ui": "^1.8.1",
|
|
68
|
+
"react": "^19.0.0",
|
|
69
|
+
"react-dom": "^19.0.0"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"bun": ">=1.3.0"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Adapter,
|
|
3
|
+
AdapterBuildInput,
|
|
4
|
+
AdapterContext,
|
|
5
|
+
EmittedArtifacts,
|
|
6
|
+
} from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export const bunAdapter: Adapter = {
|
|
9
|
+
name: "bun",
|
|
10
|
+
buildTarget: "bun",
|
|
11
|
+
async emit(
|
|
12
|
+
input: AdapterBuildInput,
|
|
13
|
+
ctx: AdapterContext,
|
|
14
|
+
): Promise<EmittedArtifacts> {
|
|
15
|
+
if (ctx.compile && ctx.mode === "production") {
|
|
16
|
+
const exePath = `${ctx.outDir}/server-bin`;
|
|
17
|
+
// Compile the SOURCE entry, not the stage-1 bundle: `with { type: "file" }`
|
|
18
|
+
// and `with { type: "macro" }` attributes only survive into --compile when
|
|
19
|
+
// the compiler sees the source. The source transitively imports the
|
|
20
|
+
// generated embedded-manifest.ts, so all assets land in the binary.
|
|
21
|
+
const proc = Bun.spawn({
|
|
22
|
+
cmd: [
|
|
23
|
+
"bun",
|
|
24
|
+
"build",
|
|
25
|
+
"--compile",
|
|
26
|
+
"--outfile",
|
|
27
|
+
exePath,
|
|
28
|
+
input.serverEntrySrc,
|
|
29
|
+
],
|
|
30
|
+
stdout: "pipe",
|
|
31
|
+
stderr: "pipe",
|
|
32
|
+
});
|
|
33
|
+
// Drain both pipes concurrently with the exit wait. On a fresh runner
|
|
34
|
+
// `bun build --compile` downloads the runtime and streams progress; if we
|
|
35
|
+
// only read after `exited`, a full OS pipe buffer blocks the child on
|
|
36
|
+
// write while we block on exit — a deadlock that hangs CI until timeout.
|
|
37
|
+
const [, err, code] = await Promise.all([
|
|
38
|
+
new Response(proc.stdout).text(),
|
|
39
|
+
new Response(proc.stderr).text(),
|
|
40
|
+
proc.exited,
|
|
41
|
+
]);
|
|
42
|
+
if (code !== 0) {
|
|
43
|
+
throw new Error(`sordo build: --compile failed (exit ${code})\n${err}`);
|
|
44
|
+
}
|
|
45
|
+
// Single-file deploy: assets + client chunks are embedded; drop the
|
|
46
|
+
// on-disk sidecars so the binary is the whole artifact.
|
|
47
|
+
await Bun.$`rm -rf ${`${ctx.outDir}/server`}`.quiet();
|
|
48
|
+
await Bun.$`rm -rf ${`${ctx.outDir}/client`}`.quiet();
|
|
49
|
+
await Bun.$`rm -rf ${`${ctx.outDir}/assets`}`.quiet();
|
|
50
|
+
return { serverEntry: exePath, assets: [] };
|
|
51
|
+
}
|
|
52
|
+
if (!input.serverEntryOut) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"sordo build: bun target requires a bundled server entry",
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return { serverEntry: input.serverEntryOut, assets: input.assets };
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Adapter,
|
|
3
|
+
AdapterBuildInput,
|
|
4
|
+
AdapterContext,
|
|
5
|
+
EmittedArtifacts,
|
|
6
|
+
} from "./types.ts";
|
|
7
|
+
|
|
8
|
+
// Emits a portable WinterCG / workerd-style Worker module. The framework stays
|
|
9
|
+
// vendor-neutral: no wrangler.toml, vercel.json, etc. — those belong to deploy
|
|
10
|
+
// plugins. The bundled server entry already wraps itself in
|
|
11
|
+
// `export default { fetch }` via build/server-entry.ts::bootForEdge.
|
|
12
|
+
export const edgeAdapter: Adapter = {
|
|
13
|
+
name: "edge",
|
|
14
|
+
buildTarget: "browser",
|
|
15
|
+
async emit(
|
|
16
|
+
input: AdapterBuildInput,
|
|
17
|
+
ctx: AdapterContext,
|
|
18
|
+
): Promise<EmittedArtifacts> {
|
|
19
|
+
// Surface the worker module under the canonical name spec 12 promises
|
|
20
|
+
// (`dist/worker.js`). Bun.build wrote it as `<outDir>/server/server-entry.js`;
|
|
21
|
+
// we re-emit it at `<outDir>/worker.js` so deploy plugins and ad-hoc CLIs
|
|
22
|
+
// (`wrangler deploy <file>`) can find a predictable path.
|
|
23
|
+
const workerPath = `${ctx.outDir}/worker.js`;
|
|
24
|
+
if (!input.serverEntryOut) {
|
|
25
|
+
// Edge never compiles, so stage-1 Bun.build always runs and sets this.
|
|
26
|
+
throw new Error(
|
|
27
|
+
"sordo build: edge target requires a bundled server entry",
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
const bytes = await Bun.file(input.serverEntryOut).bytes();
|
|
31
|
+
await Bun.write(workerPath, bytes);
|
|
32
|
+
return {
|
|
33
|
+
serverEntry: workerPath,
|
|
34
|
+
assets: input.assets,
|
|
35
|
+
extraFiles: [workerPath],
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BuiltAsset } from "../build/assets.ts";
|
|
2
|
+
import type { SordoConfig } from "../config/schema.ts";
|
|
3
|
+
|
|
4
|
+
export interface AdapterContext {
|
|
5
|
+
appDir: string;
|
|
6
|
+
outDir: string;
|
|
7
|
+
mode: "development" | "production";
|
|
8
|
+
config?: SordoConfig;
|
|
9
|
+
compile?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AdapterBuildInput {
|
|
13
|
+
/** Absolute path to the bundled server entry produced by stage-1 Bun.build.
|
|
14
|
+
* Undefined in bun compile mode, where stage-1 is skipped and the adapter
|
|
15
|
+
* compiles `serverEntrySrc` directly so file/macro import attributes survive. */
|
|
16
|
+
serverEntryOut?: string;
|
|
17
|
+
/** Absolute path to the generated server-entry.ts SOURCE (for --compile). */
|
|
18
|
+
serverEntrySrc: string;
|
|
19
|
+
assets: BuiltAsset[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface EmittedArtifacts {
|
|
23
|
+
/**
|
|
24
|
+
* Absolute path to the consumable server entry after the adapter's
|
|
25
|
+
* post-processing (e.g. compiled binary for bun, worker.js for edge).
|
|
26
|
+
*/
|
|
27
|
+
serverEntry: string;
|
|
28
|
+
assets: BuiltAsset[];
|
|
29
|
+
extraFiles?: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface Adapter {
|
|
33
|
+
name: "edge" | "bun";
|
|
34
|
+
buildTarget: "browser" | "bun";
|
|
35
|
+
emit(
|
|
36
|
+
input: AdapterBuildInput,
|
|
37
|
+
ctx: AdapterContext,
|
|
38
|
+
): Promise<EmittedArtifacts>;
|
|
39
|
+
}
|