create-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 +120 -0
- package/README.md +52 -2
- package/bin/create-sordo.ts +11 -0
- package/package.json +36 -5
- package/src/index.ts +675 -0
- package/src/probes.ts +28 -0
- package/src/prompts.ts +141 -0
- package/src/readme.ts +74 -0
- package/src/ui.ts +207 -0
- package/src/versions.ts +3 -0
- package/templates/_backend/app/routes/api/todos.ts +27 -0
- package/templates/_claude/.claude/commands/sordo-init.md +64 -0
- package/templates/_claude/.claude/hooks/biome-check.sh +17 -0
- package/templates/_claude/.claude/rules/build-time-discovery.md +17 -0
- package/templates/_claude/.claude/rules/bun-native.md +28 -0
- package/templates/_claude/.claude/rules/filesystem-routing.md +31 -0
- package/templates/_claude/.claude/rules/islands.md +46 -0
- package/templates/_claude/.claude/rules/optional-ai.md +16 -0
- package/templates/_claude/.claude/rules/web-standards-boundary.md +25 -0
- package/templates/_claude/.claude/settings.json +22 -0
- package/templates/_claude/.claude/skills/sordo/SKILL.md +121 -0
- package/templates/_claude/.claude/skills/sordo-cli/SKILL.md +112 -0
- package/templates/_claude/CLAUDE.md +28 -0
- package/templates/_codex/.codex/README.md +10 -0
- package/templates/_codex/.codex/rules/build-time-discovery.md +17 -0
- package/templates/_codex/.codex/rules/bun-native.md +28 -0
- package/templates/_codex/.codex/rules/filesystem-routing.md +31 -0
- package/templates/_codex/.codex/rules/islands.md +46 -0
- package/templates/_codex/.codex/rules/optional-ai.md +15 -0
- package/templates/_codex/.codex/rules/sordo-cli.md +108 -0
- package/templates/_codex/.codex/rules/sordo-patterns.md +122 -0
- package/templates/_codex/.codex/rules/web-standards-boundary.md +25 -0
- package/templates/_codex/AGENTS.md +27 -0
- package/templates/_container/.dockerignore +7 -0
- package/templates/_container/Dockerfile +27 -0
- package/templates/_monorepo/packages/README.md +18 -0
- package/templates/_shared/sordo-patterns.md +122 -0
- package/templates/default/README-template.md +181 -0
- package/templates/default/app/islands/TodoApp.tsx +83 -0
- package/templates/default/app/routes/api/health.ts +8 -0
- package/templates/default/app/routes/index.tsx +29 -0
- package/templates/default/app/server.ts +28 -0
- package/templates/default/gitignore +9 -0
- package/templates/default/sordo.config.ts +5 -0
- package/templates/default/tsconfig.json +14 -0
- package/templates/ui-shadcn/components/button.tsx +63 -0
- package/templates/ui-shadcn/components/dialog.tsx +158 -0
- package/templates/ui-shadcn/demo/index.tsx +62 -0
- package/templates/ui-starter/_internal/cn.ts +6 -0
- package/templates/ui-starter/_internal/slot.ts +50 -0
- package/templates/ui-starter/_internal/variants.ts +1 -0
- package/templates/ui-starter/button.tsx +60 -0
- package/templates/ui-starter/card.tsx +92 -0
- package/templates/ui-starter/demo/TodoApp.tsx +86 -0
- package/templates/ui-starter/demo/index.tsx +45 -0
- package/templates/ui-starter/input.tsx +20 -0
- package/templates/ui-starter/label.tsx +18 -0
- package/templates/ui-starter/themes/neutral/tokens.css +46 -0
- package/templates/ui-starter/themes/slate/tokens.css +46 -0
- package/templates/ui-starter/themes/stone/tokens.css +46 -0
- package/templates/ui-starter/themes/zinc/tokens.css +46 -0
- package/templates/ui-starter/tokens.css +46 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Optional AI dependency rule
|
|
2
|
+
|
|
3
|
+
The Anthropic SDK is an **optional** peer dependency. Apps that do
|
|
4
|
+
not use the `app/agents/`, `app/tools/`, or `app/jobs/` directories
|
|
5
|
+
must still install and run without `@anthropic-ai/sdk` present.
|
|
6
|
+
|
|
7
|
+
- Never `import "@anthropic-ai/sdk"` at the top level of a route or
|
|
8
|
+
middleware file. Wrap it in a dynamic `import()` inside the function
|
|
9
|
+
that needs it, or accept an `AnthropicLike` instance from
|
|
10
|
+
`SordoContext`.
|
|
11
|
+
- Do not move `@anthropic-ai/sdk` into `dependencies` unless your app
|
|
12
|
+
genuinely requires it at boot. Even then, prefer keeping it as a
|
|
13
|
+
peer + `bun add @anthropic-ai/sdk` step.
|
|
14
|
+
- The auto-generated manifest (default `CLAUDE.md`; configurable via
|
|
15
|
+
`config.agentsMd.path`) references AI types, but does not require a
|
|
16
|
+
live SDK at import time.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Web-standards boundary rule
|
|
2
|
+
|
|
3
|
+
The framework stays close to web standards at handler boundaries. Do
|
|
4
|
+
not paper over them with a custom request abstraction.
|
|
5
|
+
|
|
6
|
+
- **Handler signature:** `(req: Request, ctx: SordoContext) => Response | Promise<Response>`.
|
|
7
|
+
`req` is a standard web `Request`; the handler returns a standard web
|
|
8
|
+
`Response`. Streaming responses use `ReadableStream`.
|
|
9
|
+
- **`SordoContext` is the only framework-added affordance.** It
|
|
10
|
+
exposes `params`, `cookies`, `env`, `vars`, `url`, and the
|
|
11
|
+
short-circuit helpers `ctx.json(data, init?)`, `ctx.html(body, init?)`,
|
|
12
|
+
`ctx.redirect(to, status?)`. Keep it thin — don't expect a
|
|
13
|
+
Next-style `request.cookies.set(...)` API.
|
|
14
|
+
- **No Hono / Express / Fastify types.** If you find yourself reaching
|
|
15
|
+
for `MiddlewareHandler` from Hono, write the standard
|
|
16
|
+
`Middleware = (req, ctx, next) => Promise<Response>` instead.
|
|
17
|
+
- **React SSR uses `renderToReadableStream`** (the streaming web API).
|
|
18
|
+
Do not use `renderToString` or `renderToPipeableStream`.
|
|
19
|
+
- **Client hydration uses `hydrateRoot`** (React 19). Do not use
|
|
20
|
+
`ReactDOM.render`.
|
|
21
|
+
|
|
22
|
+
If a deployment target needs platform-specific wiring (Vercel edge
|
|
23
|
+
context, Cloudflare bindings, etc.), the framework's adapters under
|
|
24
|
+
`sordo/adapters` translate to/from these web-standard handlers — that
|
|
25
|
+
belongs in the adapter, not in your routes.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(bun:*)",
|
|
5
|
+
"Bash(bunx:*)",
|
|
6
|
+
"Bash(sordo:*)",
|
|
7
|
+
"Bash(git status)",
|
|
8
|
+
"Bash(git diff:*)",
|
|
9
|
+
"Bash(git log:*)"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"hooks": {
|
|
13
|
+
"PostToolUse": [
|
|
14
|
+
{
|
|
15
|
+
"matcher": "Edit|Write|MultiEdit",
|
|
16
|
+
"hooks": [
|
|
17
|
+
{ "type": "command", "command": ".claude/hooks/biome-check.sh" }
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sordo
|
|
3
|
+
description: Use when adding a UI component or scaffolding a feature pattern (auth + RBAC, CRM, task board, pivot table, dashboard). Trigger phrases include "add a component", "scaffold a CRM / dashboard / auth", "sordo pattern", "/sordo".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /sordo — components & feature patterns
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
|
|
10
|
+
Use this when the user wants to **add a UI component** or **scaffold a
|
|
11
|
+
feature pattern** (auth + RBAC, a CRM, a task board, a pivot table, a
|
|
12
|
+
dashboard). It covers scaffolding only — for running, building, deploying, or
|
|
13
|
+
managing secrets, use the `sordo-cli` skill instead.
|
|
14
|
+
|
|
15
|
+
Two capabilities:
|
|
16
|
+
|
|
17
|
+
1. **Add a UI component** — a thin wrapper over the deterministic catalog.
|
|
18
|
+
2. **Scaffold a feature pattern** — instruction-driven: you generate the files,
|
|
19
|
+
adapting names/fields/copy to the user's domain.
|
|
20
|
+
|
|
21
|
+
## Add a component
|
|
22
|
+
|
|
23
|
+
Components are upstream shadcn/ui, stamped verbatim — never hand-author
|
|
24
|
+
component source; the shadcn registry is the source of truth.
|
|
25
|
+
|
|
26
|
+
1. If `app/components/ui/_internal/` does not exist, the UI setup isn't
|
|
27
|
+
initialized — run `sordo ui init --shadcn` first (it wires the `@/*` alias
|
|
28
|
+
and `app/lib/utils.ts`).
|
|
29
|
+
2. Run `sordo add @shadcn/<name>` (preview first with
|
|
30
|
+
`sordo add --view @shadcn/<name>` if the user wants to see the source).
|
|
31
|
+
3. Import the stamped component from `app/components/ui/<name>.tsx` and use it.
|
|
32
|
+
Pages that render shadcn components must `export const hydrate = true`
|
|
33
|
+
(whole-tree hydration).
|
|
34
|
+
|
|
35
|
+
`sordo add` edits `package.json` (it never runs an install) and stamps source
|
|
36
|
+
into `app/components/ui/`. After adding, remind the user to run `bun install` if
|
|
37
|
+
new peer deps were added.
|
|
38
|
+
|
|
39
|
+
## Scaffold a pattern
|
|
40
|
+
|
|
41
|
+
Pick a pattern below, `sordo add @shadcn/<name>` its components first, then
|
|
42
|
+
generate the listed files — adapting entity names, fields, columns, and copy to
|
|
43
|
+
the user's stated domain (e.g. "a CRM for veterinary clinics").
|
|
44
|
+
|
|
45
|
+
| Pattern | Goal | `@shadcn/<name>` components | Generated files (under `app/`) |
|
|
46
|
+
|---|---|---|---|
|
|
47
|
+
| **auth-rbac** | Login / logout + role-gated route | `input`, `label`, `button`, `card` | `routes/login.tsx` (native POST form), `routes/api/login.ts`, `routes/api/logout.ts`, `routes/admin.tsx` (gated by middleware), `app/middleware.ts` (gates `/admin`), `lib/auth.ts` (cookie session over mock users), `lib/rbac.ts` (role guard), `lib/mock-users.ts` |
|
|
48
|
+
| **crm** | Contacts list + detail / edit | `table`, `dialog`, `form`, `input`, `button`, `badge` | `routes/contacts/index.tsx` (table), `routes/contacts/[id].tsx` (detail), `islands/ContactForm.tsx`, `lib/mock-contacts.ts` |
|
|
49
|
+
| **task** | Task board / list | `card`, `checkbox`, `badge`, `dialog`, `button` | `routes/tasks.tsx`, `islands/TaskBoard.tsx` (columns + toggle), `lib/mock-tasks.ts` |
|
|
50
|
+
| **pivot** | Group-by / pivot over rows | `table`, `select`, `card` | `routes/pivot.tsx`, `islands/PivotTable.tsx` (pick row/col/measure), `lib/mock-rows.ts` |
|
|
51
|
+
| **dashboard** | Metrics overview | `card`, `chart`, `separator`, `sidebar` | `routes/dashboard.tsx` (cards + chart + sidebar shell), `lib/mock-metrics.ts` |
|
|
52
|
+
|
|
53
|
+
Per-pattern recipes:
|
|
54
|
+
|
|
55
|
+
- **auth-rbac** — sessions are a signed cookie over the mock user list. Because
|
|
56
|
+
pages can't read cookies or redirect (see Conventions), the gate lives in
|
|
57
|
+
`app/middleware.ts`: it checks the session + role and redirects unauthenticated
|
|
58
|
+
`/admin` hits to `/login`. The login page is a native `<form method="post"
|
|
59
|
+
action="/api/login">` (no `form` component) posting to `routes/api/login.ts`,
|
|
60
|
+
which sets the cookie and redirects; `routes/api/logout.ts` clears it. Make the
|
|
61
|
+
mock-only nature loud: a banner on the login page and a TODO at the top of the
|
|
62
|
+
auth module. Real auth needs persistence (a future DB spec).
|
|
63
|
+
- **crm** — the list uses `table` over `mock-contacts`; create / edit
|
|
64
|
+
happens in a `dialog` driven by a `form` island. The detail route reads the
|
|
65
|
+
same mock store by id.
|
|
66
|
+
- **task** — the board is an island holding `useState` columns; toggling a
|
|
67
|
+
`checkbox` moves a task between done / not-done. No persistence — state resets
|
|
68
|
+
on reload (call this out).
|
|
69
|
+
- **pivot** — an island lets the user pick a row dimension, a column dimension,
|
|
70
|
+
and a numeric measure from `select`s, then renders the aggregated `table`.
|
|
71
|
+
Aggregation runs client-side over the mock rows.
|
|
72
|
+
- **dashboard** — a static SSR shell (`sidebar` is `subtree`, `chart` hydrates)
|
|
73
|
+
with metric `card`s fed by `mock-metrics`; the chart is the one interactive
|
|
74
|
+
island.
|
|
75
|
+
|
|
76
|
+
Always `sordo add @shadcn/<name>` the listed components (running
|
|
77
|
+
`sordo ui init --shadcn` first if needed) before generating files that import
|
|
78
|
+
them. Only reference components that exist in the upstream shadcn registry.
|
|
79
|
+
|
|
80
|
+
## Depth contract: UI + mock data
|
|
81
|
+
|
|
82
|
+
Every pattern is scaffolded at **"UI + mock data"** depth:
|
|
83
|
+
|
|
84
|
+
- **In scope:** SSR routes / pages, islands where interactivity is needed,
|
|
85
|
+
stamped UI components, and a typed in-memory seed in
|
|
86
|
+
`app/lib/mock-<entity>.ts` that the pages read from.
|
|
87
|
+
- **Out of scope:** `bun:sqlite`, migrations, a real persistence or auth
|
|
88
|
+
backend, network calls. The pattern *shows the shape*; the developer swaps the
|
|
89
|
+
mock data for a real source later.
|
|
90
|
+
- Every generated `mock-*` module starts with `// TODO: replace mock data with a
|
|
91
|
+
real source`, and the route / page carries a short note marking the mock
|
|
92
|
+
boundary.
|
|
93
|
+
|
|
94
|
+
Do not generate a database layer, migrations, or a real auth/network backend
|
|
95
|
+
from this skill — that is deferred to a future spec.
|
|
96
|
+
|
|
97
|
+
## Conventions
|
|
98
|
+
|
|
99
|
+
- Pages live under `app/routes/*.tsx` (default-export a React component); API
|
|
100
|
+
handlers under `app/routes/api/*.ts` (named `GET`/`POST`/… returning a
|
|
101
|
+
`Response`, e.g. via `ctx.json()`). Dynamic segments use `[id]`. A `.ts` route
|
|
102
|
+
**must** be under `app/routes/api/` — anywhere else is a build error.
|
|
103
|
+
- **Pages get only `ctx.params`** — they can't read cookies, set headers, or
|
|
104
|
+
redirect. Push that work to an API route or to `app/middleware.ts` (the single
|
|
105
|
+
global `Middleware (req, ctx, next)`, the only place to gate a page). Mutation
|
|
106
|
+
forms use a native `<form method="post" action="/api/…">` posting to a `.ts`
|
|
107
|
+
handler.
|
|
108
|
+
- Islands (interactive client components) live under `app/islands/` and are
|
|
109
|
+
wrapped at the use site in `<Island name="…">…</Island>` from `sordo/render`.
|
|
110
|
+
`chart` and `form` are islands (they pull `recharts` / `react-hook-form`).
|
|
111
|
+
- **Styling is opt-in per page.** If `app/components/_head.tsx` exists, every new
|
|
112
|
+
page route must re-export it (`export { head } from "../components/_head.tsx";`)
|
|
113
|
+
or it renders unstyled. Run `bun run css` (or `bun run css:watch`) after adding
|
|
114
|
+
classNames; `dev`/`build` compile it for you.
|
|
115
|
+
- Mock data lives in `app/lib/mock-<entity>.ts`, typed, with the TODO marker.
|
|
116
|
+
- Never re-author component source — stamp from the catalog and import.
|
|
117
|
+
|
|
118
|
+
## See also
|
|
119
|
+
|
|
120
|
+
- The `sordo-cli` skill — running, building, deploying the app.
|
|
121
|
+
- cli specs 11–15 (UI: `ui init`, `add`, `view`, `update`, registries).
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sordo-cli
|
|
3
|
+
description: Use when running, building, deploying, or managing secrets for a Sordo app. Covers `sordo dev`, `sordo build`, `sordo start`, `sordo deploy`, and `sordo secret`. Trigger phrases include "start the dev server", "build the app", "deploy", "set a secret", "run sordo".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# sordo CLI
|
|
7
|
+
|
|
8
|
+
`sordo` is the project's CLI. It's installed via the `sordo` dependency
|
|
9
|
+
and exposed through `package.json#scripts` (`bun dev`, `bun run build`,
|
|
10
|
+
`bun start`). Reach for these commands directly instead of inventing
|
|
11
|
+
ad-hoc Bun invocations.
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
### `sordo dev` — start the dev server
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
bunx sordo dev # the canonical invocation (bun dev runs the same thing via the package.json script)
|
|
19
|
+
sordo dev --port 4000
|
|
20
|
+
sordo dev --host 0.0.0.0
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Starts the dev server with HMR over WebSocket. Reads `sordo.config.ts`
|
|
24
|
+
for `target`, `port`, env, and secrets. Islands are bundled and hydrated
|
|
25
|
+
in dev — the same code path users see in production, minus minification.
|
|
26
|
+
|
|
27
|
+
### `sordo build` — produce a production bundle
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
bun run build # equivalent to `sordo build`
|
|
31
|
+
sordo build --target bun
|
|
32
|
+
sordo build --target edge --out-dir dist
|
|
33
|
+
sordo build --compile # bun target only; single-binary
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Outputs to `.sordo/` by default. The server entry is at
|
|
37
|
+
`.sordo/server/server-entry.js`. Build also regenerates the agent
|
|
38
|
+
manifest section (default `CLAUDE.md`; configurable via
|
|
39
|
+
`config.agentsMd.path`).
|
|
40
|
+
|
|
41
|
+
### `sordo start` — run the production bundle
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
bun start # equivalent to `sordo start`
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Runs the last `sordo build` output. If no build exists, prints an
|
|
48
|
+
error directing you to `sordo build` first.
|
|
49
|
+
|
|
50
|
+
### `sordo deploy` — build then dispatch to a deploy plugin
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
sordo deploy # build + dispatch
|
|
54
|
+
sordo deploy --skip-build # reuse the existing `.sordo/`
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Requires a deploy plugin declared in `sordo.config.ts#plugins`. If no
|
|
58
|
+
plugin is installed, prints the command to run the server bundle
|
|
59
|
+
manually.
|
|
60
|
+
|
|
61
|
+
### `sordo secret` — manage dev-time secrets
|
|
62
|
+
|
|
63
|
+
Dev-only. In production, secrets come from the host's secrets surface
|
|
64
|
+
(env vars, Cloudflare bindings, Vercel env, etc.) — not from this CLI.
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
sordo secret set DATABASE_URL # prompts for value
|
|
68
|
+
sordo secret set DATABASE_URL "postgres://..."
|
|
69
|
+
sordo secret get DATABASE_URL
|
|
70
|
+
sordo secret list
|
|
71
|
+
sordo secret rm DATABASE_URL
|
|
72
|
+
sordo secret doctor # checks OS keychain access
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Values live in the OS keychain (macOS Keychain, GNOME Keyring, Windows
|
|
76
|
+
Credential Manager). They are loaded into `Bun.env` automatically when
|
|
77
|
+
the dev server reads `config.secrets`.
|
|
78
|
+
|
|
79
|
+
## Global flags
|
|
80
|
+
|
|
81
|
+
- `--cwd <path>` — project root (default `process.cwd()`)
|
|
82
|
+
- `--config <path>` — explicit config file (default: discovery in cwd)
|
|
83
|
+
- `--verbose` — verbose diagnostics, includes stack traces
|
|
84
|
+
- `--version` / `-v` — print version
|
|
85
|
+
- `--help` / `-h` — show help
|
|
86
|
+
|
|
87
|
+
## Common workflows
|
|
88
|
+
|
|
89
|
+
**First-run sanity check after scaffolding:**
|
|
90
|
+
```sh
|
|
91
|
+
bun install
|
|
92
|
+
bunx sordo dev # opens http://localhost:3000 — SSR + island hydration
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Verify the production bundle:**
|
|
96
|
+
```sh
|
|
97
|
+
bun run build
|
|
98
|
+
bun start
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Iterate on a deploy config:**
|
|
102
|
+
```sh
|
|
103
|
+
sordo build --target edge
|
|
104
|
+
sordo deploy --skip-build
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## What this skill does NOT cover
|
|
108
|
+
|
|
109
|
+
- Authoring framework primitives (routes, islands, agents, tools, jobs).
|
|
110
|
+
See the project's `CLAUDE.md` and `.claude/rules/*.md` for those.
|
|
111
|
+
- Bun-the-runtime invocations (`bun add`, `bun upgrade`, `bun pm`).
|
|
112
|
+
Those are upstream Bun commands; check `bun --help` directly.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
Built with Sordo — a Bun-native full-stack meta-framework.
|
|
4
|
+
|
|
5
|
+
Project conventions live in `.claude/rules/` as small focused files.
|
|
6
|
+
Read each one when it's relevant to the task at hand:
|
|
7
|
+
|
|
8
|
+
- @.claude/rules/bun-native.md — reach for Bun primitives, not Node-era replacements
|
|
9
|
+
- @.claude/rules/web-standards-boundary.md — handlers use standard Request / Response; SordoContext stays thin
|
|
10
|
+
- @.claude/rules/filesystem-routing.md — how `app/routes/` becomes URLs
|
|
11
|
+
- @.claude/rules/islands.md — when and how to use `app/islands/*.tsx`
|
|
12
|
+
- @.claude/rules/build-time-discovery.md — discovery happens at build, not at request time
|
|
13
|
+
- @.claude/rules/optional-ai.md — keep `@anthropic-ai/sdk` import-disjoint from non-AI code paths
|
|
14
|
+
|
|
15
|
+
The CLI surface (`sordo dev/build/start/deploy/secret`) lives in the
|
|
16
|
+
`sordo-cli` skill at `.claude/skills/sordo-cli/SKILL.md` — it loads
|
|
17
|
+
automatically when CLI work is in scope.
|
|
18
|
+
|
|
19
|
+
The live inventory of routes, islands, agents, tools, and jobs is spliced
|
|
20
|
+
into this file between `<!-- sordo:manifest-start -->` and
|
|
21
|
+
`<!-- sordo:manifest-end -->` — regenerated on every `sordo dev/build`
|
|
22
|
+
while everything else here is preserved. Trust that section for inventory
|
|
23
|
+
questions; trust the rules files for conventions. Change the target file
|
|
24
|
+
with `config.agentsMd.path` in `sordo.config.ts` if you'd rather the
|
|
25
|
+
manifest live elsewhere.
|
|
26
|
+
|
|
27
|
+
<!-- sordo:manifest-start -->
|
|
28
|
+
<!-- sordo:manifest-end -->
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Codex workspace config
|
|
2
|
+
|
|
3
|
+
Codex CLI reads conventions from `AGENTS.md` at the project root — that
|
|
4
|
+
file is the single source of truth for rules, the CLI surface, and the
|
|
5
|
+
auto-regenerated inventory of routes / islands / agents / tools.
|
|
6
|
+
|
|
7
|
+
This directory is reserved for future Codex-specific config (the
|
|
8
|
+
conventions are still evolving — see https://github.com/openai/codex).
|
|
9
|
+
Leave it in place; the scaffolder relies on it as a marker that the
|
|
10
|
+
project opted into the Codex agent overlay.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Build-time discovery rule
|
|
2
|
+
|
|
3
|
+
Routes, islands, agents, and tools are discovered from the filesystem
|
|
4
|
+
at **build time**, not at request time.
|
|
5
|
+
|
|
6
|
+
- `sordo build` scans `app/routes/`, `app/islands/`, `app/agents/`,
|
|
7
|
+
`app/tools/`, and `app/jobs/` and inlines the discovered tables into
|
|
8
|
+
the server bundle. The production server never calls `Bun.Glob` /
|
|
9
|
+
`scanRoutes` / `scanIslands`.
|
|
10
|
+
- This is what makes Sordo cold-start fast and adapter-portable
|
|
11
|
+
(edge runtimes that disallow filesystem access still work).
|
|
12
|
+
- **Dev mode is the exception.** The dev server re-scans on file
|
|
13
|
+
change to drive HMR.
|
|
14
|
+
- **Don't break the rule:** never write code that calls `Bun.Glob` or
|
|
15
|
+
reads `app/**` at request time. If you find yourself wanting to,
|
|
16
|
+
the answer is probably a build-time macro or a config option in
|
|
17
|
+
`sordo.config.ts`.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Bun-native rule
|
|
2
|
+
|
|
3
|
+
This project runs on Bun. Reach for Bun primitives first; do not
|
|
4
|
+
reintroduce Node-era replacements just because a familiar library
|
|
5
|
+
provides them.
|
|
6
|
+
|
|
7
|
+
- **HTTP server:** `Bun.serve`. The framework already wires it — do
|
|
8
|
+
not add Express / Fastify / Hono / `node:http`.
|
|
9
|
+
- **Filesystem discovery:** `Bun.Glob`. Do not pull in `fast-glob`,
|
|
10
|
+
`globby`, or `chokidar`.
|
|
11
|
+
- **Bundling:** `Bun.build`. The framework runs it for you at
|
|
12
|
+
`sordo build`; you should not add Webpack / Rollup / esbuild /
|
|
13
|
+
Vite / tsup.
|
|
14
|
+
- **File I/O:** `Bun.file(path).text()` / `.json()` / `.bytes()` and
|
|
15
|
+
`Bun.write(path, data)` before reaching for `node:fs`.
|
|
16
|
+
- **Hashing / crypto:** `Bun.CryptoHasher`, `Bun.password`. Avoid
|
|
17
|
+
`crypto` / `bcrypt` unless you have a real reason.
|
|
18
|
+
- **Databases:** `bun:sqlite`, `Bun.sql` (Postgres), `Bun.RedisClient`,
|
|
19
|
+
`Bun.S3Client` before reaching for npm wrappers.
|
|
20
|
+
- **Environment:** `Bun.env`. The framework injects the public subset
|
|
21
|
+
declared in `sordo.config.ts#env.public`; secrets live in the OS
|
|
22
|
+
keychain (see `sordo-cli` skill).
|
|
23
|
+
- **Tests:** `bun test`. Do not add Jest or Vitest.
|
|
24
|
+
- **Package manager:** `bun` / `bunx`. Do not run `npm` / `npx` /
|
|
25
|
+
`yarn` / `pnpm` in this project.
|
|
26
|
+
|
|
27
|
+
If you genuinely need a Node-only library, that's fine — Bun's Node
|
|
28
|
+
compatibility is strong. But default to Bun primitives.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Filesystem routing rule
|
|
2
|
+
|
|
3
|
+
Routes are discovered from the filesystem under `app/routes/`. Path
|
|
4
|
+
conventions:
|
|
5
|
+
|
|
6
|
+
| File | URL |
|
|
7
|
+
|---|---|
|
|
8
|
+
| `app/routes/index.tsx` | `/` |
|
|
9
|
+
| `app/routes/about.tsx` | `/about` |
|
|
10
|
+
| `app/routes/hotels/index.tsx` | `/hotels` |
|
|
11
|
+
| `app/routes/hotels/[city].tsx` | `/hotels/:city` |
|
|
12
|
+
| `app/routes/api/revenue.ts` | `/api/revenue` |
|
|
13
|
+
| `app/routes/_internal.tsx` | (private — never routed) |
|
|
14
|
+
|
|
15
|
+
- **Page routes** are `.tsx` files that default-export a React
|
|
16
|
+
component. The component receives no props by default; read params
|
|
17
|
+
/ cookies / env from `SordoContext` via the page's optional
|
|
18
|
+
`loader` (export `loader` if you need server-side data).
|
|
19
|
+
- **API routes** are `.ts` files that export named HTTP-method handlers:
|
|
20
|
+
`GET`, `POST`, `PUT`, `DELETE`, `PATCH`. They return a standard
|
|
21
|
+
`Response`. Default exports in `.ts` files are reserved and will
|
|
22
|
+
error.
|
|
23
|
+
- **Dynamic segments** use `[param]` in the filename. The values land
|
|
24
|
+
in `ctx.params`.
|
|
25
|
+
- **Files starting with `_`** are private — co-located helpers,
|
|
26
|
+
components, or test files. They are never routed.
|
|
27
|
+
- **Reserved URL prefixes:** `/__sordo_*` and `/_sordo/*` are
|
|
28
|
+
framework-owned. Don't put your own routes under them.
|
|
29
|
+
- **Discovery happens at build time.** The production server bundle
|
|
30
|
+
has the route table inlined; it does not call `Bun.Glob` at runtime.
|
|
31
|
+
Dev mode re-scans on file change (that's where HMR comes from).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Islands rule
|
|
2
|
+
|
|
3
|
+
The default rendering mode is server-side. Use **islands** for the
|
|
4
|
+
parts of a page that need browser-side interactivity (`useState`,
|
|
5
|
+
`useEffect`, event handlers).
|
|
6
|
+
|
|
7
|
+
- **Where they live:** `app/islands/*.tsx`. Files outside this
|
|
8
|
+
directory are server-only and never ship to the browser.
|
|
9
|
+
- **How to mark one:** start the file with `"use client";` and
|
|
10
|
+
default-export a React component. The framework auto-registers it,
|
|
11
|
+
bundles its client code, and serves the chunk under
|
|
12
|
+
`/_sordo/client/*` (in dev via `setupDevClient`; in production via
|
|
13
|
+
`sordo build`).
|
|
14
|
+
- **How to use one:** import the component from a route file and
|
|
15
|
+
wrap each use-site in `<Island name="…">…</Island>` from
|
|
16
|
+
`sordo/render`. The wrapper emits the `data-island` marker + props
|
|
17
|
+
sibling that the client runtime scans for — without it the markup
|
|
18
|
+
SSRs fine but never hydrates.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { Island } from "sordo/render";
|
|
22
|
+
import TodoApp from "../islands/TodoApp.tsx";
|
|
23
|
+
|
|
24
|
+
export default function Index() {
|
|
25
|
+
return (
|
|
26
|
+
<main>
|
|
27
|
+
<Island name="TodoApp">
|
|
28
|
+
<TodoApp />
|
|
29
|
+
</Island>
|
|
30
|
+
</main>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
- **Naming:** the island's auto-registered name is the file path
|
|
35
|
+
relative to `app/islands/` with slashes replaced by dashes and the
|
|
36
|
+
extension stripped (e.g. `app/islands/forms/Signup.tsx` →
|
|
37
|
+
`forms-Signup`). Pass the same string as `<Island name="…">`. Default
|
|
38
|
+
exports are the only export consulted.
|
|
39
|
+
- **Dev mode hydrates.** `sordo dev` builds islands in
|
|
40
|
+
`--mode development` (no minify), serves them, and the client runtime
|
|
41
|
+
hydrates each `[data-island]` marker. HMR reloads the page on island
|
|
42
|
+
changes.
|
|
43
|
+
- **Don't put non-island helpers in `app/islands/`.** Every `.tsx`
|
|
44
|
+
in there is treated as a hydratable component. Put shared
|
|
45
|
+
presentational components in `app/components/` or co-locate them
|
|
46
|
+
under a `_` prefix.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Optional AI dependency rule
|
|
2
|
+
|
|
3
|
+
The Anthropic SDK is an **optional** peer dependency. Apps that do
|
|
4
|
+
not use the `app/agents/`, `app/tools/`, or `app/jobs/` directories
|
|
5
|
+
must still install and run without `@anthropic-ai/sdk` present.
|
|
6
|
+
|
|
7
|
+
- Never `import "@anthropic-ai/sdk"` at the top level of a route or
|
|
8
|
+
middleware file. Wrap it in a dynamic `import()` inside the function
|
|
9
|
+
that needs it, or accept an `AnthropicLike` instance from
|
|
10
|
+
`SordoContext`.
|
|
11
|
+
- Do not move `@anthropic-ai/sdk` into `dependencies` unless your app
|
|
12
|
+
genuinely requires it at boot. Even then, prefer keeping it as a
|
|
13
|
+
peer + `bun add @anthropic-ai/sdk` step.
|
|
14
|
+
- The auto-generated `AGENTS.md` references AI types, but does not
|
|
15
|
+
require a live SDK at import time.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# sordo CLI
|
|
2
|
+
|
|
3
|
+
`sordo` is the project's CLI. It's installed via the `sordo` dependency
|
|
4
|
+
and exposed through `package.json#scripts` (`bun dev`, `bun run build`,
|
|
5
|
+
`bun start`). Reach for these commands directly instead of inventing
|
|
6
|
+
ad-hoc Bun invocations.
|
|
7
|
+
|
|
8
|
+
## Commands
|
|
9
|
+
|
|
10
|
+
### `sordo dev` — start the dev server
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
bunx sordo dev # the canonical invocation (bun dev runs the same thing via the package.json script)
|
|
14
|
+
sordo dev --port 4000
|
|
15
|
+
sordo dev --host 0.0.0.0
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Starts the dev server with HMR over WebSocket. Reads `sordo.config.ts`
|
|
19
|
+
for `target`, `port`, env, and secrets. Islands are bundled and hydrated
|
|
20
|
+
in dev — the same code path users see in production, minus minification.
|
|
21
|
+
|
|
22
|
+
### `sordo build` — produce a production bundle
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
bun run build # equivalent to `sordo build`
|
|
26
|
+
sordo build --target bun
|
|
27
|
+
sordo build --target edge --out-dir dist
|
|
28
|
+
sordo build --compile # bun target only; single-binary
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Outputs to `.sordo/` by default. The server entry is at
|
|
32
|
+
`.sordo/server/server-entry.js`. Build also regenerates the agent
|
|
33
|
+
manifest section. For Codex projects, set `config.agentsMd.path =
|
|
34
|
+
"AGENTS.md"` in `sordo.config.ts` so the manifest lands in the file
|
|
35
|
+
Codex reads from.
|
|
36
|
+
|
|
37
|
+
### `sordo start` — run the production bundle
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
bun start # equivalent to `sordo start`
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Runs the last `sordo build` output. If no build exists, prints an
|
|
44
|
+
error directing you to `sordo build` first.
|
|
45
|
+
|
|
46
|
+
### `sordo deploy` — build then dispatch to a deploy plugin
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
sordo deploy # build + dispatch
|
|
50
|
+
sordo deploy --skip-build # reuse the existing `.sordo/`
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Requires a deploy plugin declared in `sordo.config.ts#plugins`. If no
|
|
54
|
+
plugin is installed, prints the command to run the server bundle
|
|
55
|
+
manually.
|
|
56
|
+
|
|
57
|
+
### `sordo secret` — manage dev-time secrets
|
|
58
|
+
|
|
59
|
+
Dev-only. In production, secrets come from the host's secrets surface
|
|
60
|
+
(env vars, Cloudflare bindings, Vercel env, etc.) — not from this CLI.
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
sordo secret set DATABASE_URL # prompts for value
|
|
64
|
+
sordo secret set DATABASE_URL "postgres://..."
|
|
65
|
+
sordo secret get DATABASE_URL
|
|
66
|
+
sordo secret list
|
|
67
|
+
sordo secret rm DATABASE_URL
|
|
68
|
+
sordo secret doctor # checks OS keychain access
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Values live in the OS keychain (macOS Keychain, GNOME Keyring, Windows
|
|
72
|
+
Credential Manager). They are loaded into `Bun.env` automatically when
|
|
73
|
+
the dev server reads `config.secrets`.
|
|
74
|
+
|
|
75
|
+
## Global flags
|
|
76
|
+
|
|
77
|
+
- `--cwd <path>` — project root (default `process.cwd()`)
|
|
78
|
+
- `--config <path>` — explicit config file (default: discovery in cwd)
|
|
79
|
+
- `--verbose` — verbose diagnostics, includes stack traces
|
|
80
|
+
- `--version` / `-v` — print version
|
|
81
|
+
- `--help` / `-h` — show help
|
|
82
|
+
|
|
83
|
+
## Common workflows
|
|
84
|
+
|
|
85
|
+
**First-run sanity check after scaffolding:**
|
|
86
|
+
```sh
|
|
87
|
+
bun install
|
|
88
|
+
bunx sordo dev # opens http://localhost:3000 — SSR + island hydration
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Verify the production bundle:**
|
|
92
|
+
```sh
|
|
93
|
+
bun run build
|
|
94
|
+
bun start
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Iterate on a deploy config:**
|
|
98
|
+
```sh
|
|
99
|
+
sordo build --target edge
|
|
100
|
+
sordo deploy --skip-build
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## What this skill does NOT cover
|
|
104
|
+
|
|
105
|
+
- Authoring framework primitives (routes, islands, agents, tools, jobs).
|
|
106
|
+
See the project's `CLAUDE.md` and `.claude/rules/*.md` for those.
|
|
107
|
+
- Bun-the-runtime invocations (`bun add`, `bun upgrade`, `bun pm`).
|
|
108
|
+
Those are upstream Bun commands; check `bun --help` directly.
|