create-sordo 0.5.0 → 1.0.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 +5 -125
- package/README.md +3 -49
- package/bin/create-sordo.ts +1 -10
- package/package.json +7 -13
- package/src/index.ts +0 -697
- package/src/probes.ts +0 -28
- package/src/prompts.ts +0 -141
- package/src/readme.ts +0 -74
- package/src/ui.ts +0 -152
- package/src/versions.ts +0 -3
- package/templates/_backend/app/routes/api/todos.ts +0 -27
- package/templates/_claude/.claude/commands/sordo-init.md +0 -64
- package/templates/_claude/.claude/hooks/biome-check.sh +0 -17
- package/templates/_claude/.claude/rules/build-time-discovery.md +0 -17
- package/templates/_claude/.claude/rules/bun-native.md +0 -28
- package/templates/_claude/.claude/rules/filesystem-routing.md +0 -31
- package/templates/_claude/.claude/rules/islands.md +0 -46
- package/templates/_claude/.claude/rules/optional-ai.md +0 -16
- package/templates/_claude/.claude/rules/web-standards-boundary.md +0 -25
- package/templates/_claude/.claude/settings.json +0 -22
- package/templates/_claude/.claude/skills/sordo/SKILL.md +0 -120
- package/templates/_claude/.claude/skills/sordo-cli/SKILL.md +0 -112
- package/templates/_claude/CLAUDE.md +0 -28
- package/templates/_codex/.codex/README.md +0 -10
- package/templates/_codex/.codex/rules/build-time-discovery.md +0 -17
- package/templates/_codex/.codex/rules/bun-native.md +0 -28
- package/templates/_codex/.codex/rules/filesystem-routing.md +0 -31
- package/templates/_codex/.codex/rules/islands.md +0 -46
- package/templates/_codex/.codex/rules/optional-ai.md +0 -15
- package/templates/_codex/.codex/rules/sordo-cli.md +0 -108
- package/templates/_codex/.codex/rules/sordo-patterns.md +0 -121
- package/templates/_codex/.codex/rules/web-standards-boundary.md +0 -25
- package/templates/_codex/AGENTS.md +0 -27
- package/templates/_container/.dockerignore +0 -7
- package/templates/_container/Dockerfile +0 -27
- package/templates/_monorepo/packages/README.md +0 -18
- package/templates/_shared/sordo-patterns.md +0 -121
- package/templates/default/README-template.md +0 -174
- package/templates/default/app/islands/TodoApp.tsx +0 -83
- package/templates/default/app/routes/api/health.ts +0 -8
- package/templates/default/app/routes/index.tsx +0 -29
- package/templates/default/app/server.ts +0 -28
- package/templates/default/gitignore +0 -8
- package/templates/default/sordo.config.ts +0 -5
- package/templates/default/tsconfig.json +0 -14
- package/templates/ui-shadcn/components/button.tsx +0 -63
- package/templates/ui-shadcn/components/dialog.tsx +0 -158
- package/templates/ui-shadcn/demo/index.tsx +0 -58
- package/templates/ui-starter/_internal/cn.ts +0 -6
- package/templates/ui-starter/_internal/slot.ts +0 -50
- package/templates/ui-starter/_internal/variants.ts +0 -1
- package/templates/ui-starter/button.tsx +0 -60
- package/templates/ui-starter/card.tsx +0 -92
- package/templates/ui-starter/demo/TodoApp.tsx +0 -86
- package/templates/ui-starter/demo/index.tsx +0 -41
- package/templates/ui-starter/input.tsx +0 -20
- package/templates/ui-starter/label.tsx +0 -18
- package/templates/ui-starter/themes/neutral/tokens.css +0 -46
- package/templates/ui-starter/themes/slate/tokens.css +0 -46
- package/templates/ui-starter/themes/stone/tokens.css +0 -46
- package/templates/ui-starter/themes/zinc/tokens.css +0 -46
- package/templates/ui-starter/tokens.css +0 -46
package/src/probes.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Tool probes for the scaffolder. See spec cli/10-scaffold-probes.
|
|
2
|
-
//
|
|
3
|
-
// `bun` is required to run the resulting project — if it is missing from PATH
|
|
4
|
-
// at scaffold time, fail before any FS writes so the user does not end up with
|
|
5
|
-
// half a project on disk.
|
|
6
|
-
// `git` is optional — if it is missing, skip the `git init` step and warn at
|
|
7
|
-
// the end of the scaffold rather than letting git fail mid-pipeline.
|
|
8
|
-
|
|
9
|
-
export interface ProbeIO {
|
|
10
|
-
stderr?: (msg: string) => void;
|
|
11
|
-
exit?: (code: number) => never;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function probeTools(io: ProbeIO = {}): void {
|
|
15
|
-
const stderr = io.stderr ?? ((m: string) => process.stderr.write(`${m}\n`));
|
|
16
|
-
const exit = io.exit ?? ((c: number) => process.exit(c) as never);
|
|
17
|
-
|
|
18
|
-
if (!Bun.which("bun")) {
|
|
19
|
-
stderr(
|
|
20
|
-
"create-sordo: `bun` not found in PATH. Install Bun from https://bun.sh and re-run.",
|
|
21
|
-
);
|
|
22
|
-
exit(1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function hasGit(): boolean {
|
|
27
|
-
return Bun.which("git") !== null;
|
|
28
|
-
}
|
package/src/prompts.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// Interactive prompts for create-sordo. See cli specs 09 + 18.
|
|
2
|
-
// Uses Bun's built-in prompt() — no new dependency.
|
|
3
|
-
//
|
|
4
|
-
// Non-TTY callers must supply the equivalent flags; the run loop only invokes
|
|
5
|
-
// these helpers when stdin is a TTY and --yes was not passed. The prompt order
|
|
6
|
-
// (spec 18) is gated by project type: UI is asked only for frontend/fullstack,
|
|
7
|
-
// monorepo only for fullstack, and the deploy target option set depends on type.
|
|
8
|
-
|
|
9
|
-
export type AgentTemplate = "claude" | "codex" | "none";
|
|
10
|
-
export type ProjectType = "frontend" | "backend" | "fullstack";
|
|
11
|
-
export type Target = "bun" | "edge" | "container";
|
|
12
|
-
export type Theme = "neutral" | "slate" | "stone" | "zinc";
|
|
13
|
-
export type Deploy =
|
|
14
|
-
| "cloudflare"
|
|
15
|
-
| "vercel"
|
|
16
|
-
| "deno"
|
|
17
|
-
| "netlify"
|
|
18
|
-
| "bun"
|
|
19
|
-
| "none";
|
|
20
|
-
|
|
21
|
-
export interface PromptIO {
|
|
22
|
-
prompt?: (q: string) => string | null;
|
|
23
|
-
stdout?: (msg: string) => void;
|
|
24
|
-
isTTY?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const DEFAULT_NAME = "my-sordo-app";
|
|
28
|
-
|
|
29
|
-
export function isInteractive(io: PromptIO = {}): boolean {
|
|
30
|
-
if (io.isTTY !== undefined) return io.isTTY;
|
|
31
|
-
return Boolean(process.stdin.isTTY);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function promptName(
|
|
35
|
-
current: string | undefined,
|
|
36
|
-
isValid: (name: string) => boolean,
|
|
37
|
-
io: PromptIO = {},
|
|
38
|
-
): string | undefined {
|
|
39
|
-
if (current) return current;
|
|
40
|
-
const ask = io.prompt ?? prompt;
|
|
41
|
-
const out = io.stdout ?? ((m: string) => process.stdout.write(m));
|
|
42
|
-
|
|
43
|
-
for (let attempt = 0; attempt < 5; attempt++) {
|
|
44
|
-
const answer = (ask(`Project name: (${DEFAULT_NAME}) `) ?? "").trim();
|
|
45
|
-
const candidate = answer === "" ? DEFAULT_NAME : answer;
|
|
46
|
-
if (isValid(candidate)) return candidate;
|
|
47
|
-
out(
|
|
48
|
-
`✗ invalid project name: "${candidate}" — use lowercase letters, digits, _ or -\n`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// "old school" is the TTY label for the no-agent choice; the flag value stays
|
|
55
|
-
// `none` (spec 18). `--template` remains an alias for `--agent`.
|
|
56
|
-
export function promptAgent(io: PromptIO = {}): AgentTemplate {
|
|
57
|
-
const ask = io.prompt ?? prompt;
|
|
58
|
-
const answer = (
|
|
59
|
-
ask(
|
|
60
|
-
"Which coding agent are you using? [Claude/Codex/old school] (Claude) ",
|
|
61
|
-
) ?? ""
|
|
62
|
-
)
|
|
63
|
-
.trim()
|
|
64
|
-
.toLowerCase();
|
|
65
|
-
if (answer === "codex") return "codex";
|
|
66
|
-
if (answer === "none" || answer === "old school" || answer === "old-school") {
|
|
67
|
-
return "none";
|
|
68
|
-
}
|
|
69
|
-
return "claude";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function promptType(io: PromptIO = {}): ProjectType {
|
|
73
|
-
const ask = io.prompt ?? prompt;
|
|
74
|
-
const answer = (
|
|
75
|
-
ask(
|
|
76
|
-
"What kind of project are you building? [frontend/backend/fullstack] (fullstack) ",
|
|
77
|
-
) ?? ""
|
|
78
|
-
)
|
|
79
|
-
.trim()
|
|
80
|
-
.toLowerCase();
|
|
81
|
-
if (answer === "frontend") return "frontend";
|
|
82
|
-
if (answer === "backend") return "backend";
|
|
83
|
-
return "fullstack";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Asked only for frontend/fullstack — backend has no UI surface.
|
|
87
|
-
export function promptUi(io: PromptIO = {}): boolean {
|
|
88
|
-
const ask = io.prompt ?? prompt;
|
|
89
|
-
const answer = (ask("Do you want a styled UI template? [Y/n] (Y) ") ?? "")
|
|
90
|
-
.trim()
|
|
91
|
-
.toLowerCase();
|
|
92
|
-
return !(answer === "n" || answer === "no");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Asked only for fullstack.
|
|
96
|
-
export function promptMonorepo(io: PromptIO = {}): boolean {
|
|
97
|
-
const ask = io.prompt ?? prompt;
|
|
98
|
-
const answer = (ask("Do you want a monorepo structure? [y/N] (N) ") ?? "")
|
|
99
|
-
.trim()
|
|
100
|
-
.toLowerCase();
|
|
101
|
-
return answer === "y" || answer === "yes";
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// The option set depends on project type: container is fullstack-only.
|
|
105
|
-
export function promptTarget(type: ProjectType, io: PromptIO = {}): Target {
|
|
106
|
-
const ask = io.prompt ?? prompt;
|
|
107
|
-
const options = type === "fullstack" ? "bun/edge/container" : "bun/edge";
|
|
108
|
-
const answer = (ask(`Where will you deploy? [${options}] (bun) `) ?? "")
|
|
109
|
-
.trim()
|
|
110
|
-
.toLowerCase();
|
|
111
|
-
if (answer === "edge" || answer === "worker" || answer === "worker/edge") {
|
|
112
|
-
return "edge";
|
|
113
|
-
}
|
|
114
|
-
if (
|
|
115
|
-
type === "fullstack" &&
|
|
116
|
-
(answer === "container" ||
|
|
117
|
-
answer === "docker" ||
|
|
118
|
-
answer === "container/docker")
|
|
119
|
-
) {
|
|
120
|
-
return "container";
|
|
121
|
-
}
|
|
122
|
-
return "bun";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function promptDeploy(io: PromptIO = {}): Deploy {
|
|
126
|
-
const ask = io.prompt ?? prompt;
|
|
127
|
-
const answer = (
|
|
128
|
-
ask("Deploy plugin? [cloudflare/vercel/deno/netlify/none] (none) ") ?? ""
|
|
129
|
-
)
|
|
130
|
-
.trim()
|
|
131
|
-
.toLowerCase();
|
|
132
|
-
const valid: Deploy[] = [
|
|
133
|
-
"cloudflare",
|
|
134
|
-
"vercel",
|
|
135
|
-
"deno",
|
|
136
|
-
"netlify",
|
|
137
|
-
"bun",
|
|
138
|
-
"none",
|
|
139
|
-
];
|
|
140
|
-
return (valid as string[]).includes(answer) ? (answer as Deploy) : "none";
|
|
141
|
-
}
|
package/src/readme.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// README + template-file rendering. See spec cli/09-create-sordo-dx item 2.
|
|
2
|
-
//
|
|
3
|
-
// `applyTemplate` does two passes:
|
|
4
|
-
// 1. Strip/keep conditional blocks delimited by:
|
|
5
|
-
// <!-- if:KEY=VALUE -->...<!-- /if -->
|
|
6
|
-
// The block is kept iff `vars[KEY] === VALUE`.
|
|
7
|
-
// 2. Replace `{{name}}`, `{{agent}}`, `{{type}}`, `{{ui}}`, `{{monorepo}}`,
|
|
8
|
-
// `{{app_name}}`, `{{target}}`, `{{deploy}}` placeholders with the
|
|
9
|
-
// corresponding `vars` entry.
|
|
10
|
-
//
|
|
11
|
-
// `renderTemplatesInTree` walks a scaffolded project and applies the template
|
|
12
|
-
// to every text file we care about (README.md, *.md, *.json, *.ts, *.tsx).
|
|
13
|
-
// Anything else is left untouched so we don't corrupt binary assets.
|
|
14
|
-
|
|
15
|
-
export interface TemplateVars {
|
|
16
|
-
name: string;
|
|
17
|
-
agent: "claude" | "codex" | "none";
|
|
18
|
-
type: "frontend" | "backend" | "fullstack";
|
|
19
|
-
ui: "yes" | "no";
|
|
20
|
-
monorepo: "yes" | "no";
|
|
21
|
-
target: "bun" | "edge" | "container";
|
|
22
|
-
deploy: "cloudflare" | "vercel" | "deno" | "netlify" | "bun" | "none";
|
|
23
|
-
app_name: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const CONDITIONAL_RE =
|
|
27
|
-
/<!--\s*if:([a-zA-Z_]+)=([a-zA-Z0-9_-]+)\s*-->([\s\S]*?)<!--\s*\/if\s*-->\n?/g;
|
|
28
|
-
|
|
29
|
-
const TEXT_EXT_RE =
|
|
30
|
-
/\.(md|mdx|json|jsonc|ts|tsx|js|jsx|sh|toml|yml|yaml|gitignore)$/;
|
|
31
|
-
|
|
32
|
-
export function applyTemplate(source: string, vars: TemplateVars): string {
|
|
33
|
-
const stripped = source.replace(
|
|
34
|
-
CONDITIONAL_RE,
|
|
35
|
-
(_match, key: string, value: string, body: string) => {
|
|
36
|
-
const v = (vars as unknown as Record<string, string>)[key];
|
|
37
|
-
return v === value ? body : "";
|
|
38
|
-
},
|
|
39
|
-
);
|
|
40
|
-
return (
|
|
41
|
-
stripped
|
|
42
|
-
.replaceAll("{{name}}", vars.name)
|
|
43
|
-
.replaceAll("{{agent}}", vars.agent)
|
|
44
|
-
.replaceAll("{{type}}", vars.type)
|
|
45
|
-
.replaceAll("{{ui}}", vars.ui)
|
|
46
|
-
.replaceAll("{{monorepo}}", vars.monorepo)
|
|
47
|
-
.replaceAll("{{app_name}}", vars.app_name)
|
|
48
|
-
.replaceAll("{{target}}", vars.target)
|
|
49
|
-
.replaceAll("{{deploy}}", vars.deploy)
|
|
50
|
-
// Legacy placeholders from earlier overlay revisions — kept so existing
|
|
51
|
-
// CLAUDE.md / AGENTS.md template text keeps interpolating.
|
|
52
|
-
.replaceAll("{{PROJECT_NAME}}", vars.name)
|
|
53
|
-
.replaceAll("{{DEPLOY_TARGET}}", vars.deploy)
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function renderTemplatesInTree(
|
|
58
|
-
dir: string,
|
|
59
|
-
vars: TemplateVars,
|
|
60
|
-
): Promise<void> {
|
|
61
|
-
const glob = new Bun.Glob("**/*");
|
|
62
|
-
for await (const rel of glob.scan({ cwd: dir, onlyFiles: true, dot: true })) {
|
|
63
|
-
if (!TEXT_EXT_RE.test(rel) && !rel.endsWith("README.md")) continue;
|
|
64
|
-
const path = `${dir}/${rel}`;
|
|
65
|
-
const file = Bun.file(path);
|
|
66
|
-
const text = await file.text();
|
|
67
|
-
if (!hasTemplateMarkers(text)) continue;
|
|
68
|
-
await Bun.write(path, applyTemplate(text, vars));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function hasTemplateMarkers(text: string): boolean {
|
|
73
|
-
return text.includes("{{") || text.includes("<!-- if:");
|
|
74
|
-
}
|
package/src/ui.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
// UI starter integration (spec 18 §UI starter).
|
|
2
|
-
//
|
|
3
|
-
// create-sordo stays zero-dependency and offline, so instead of shelling out
|
|
4
|
-
// to `sordo ui init` + `sordo add` (which need the project's installed
|
|
5
|
-
// binary) we vendor the starter set under templates/ui-starter/ and copy it
|
|
6
|
-
// directly. The vendored copies are byte-for-byte identical to
|
|
7
|
-
// packages/sordo/templates/ (helpers, tokens, themes) — a drift test enforces
|
|
8
|
-
// that — so this is
|
|
9
|
-
// equivalent to what `sordo add button card input label` would stamp.
|
|
10
|
-
|
|
11
|
-
import { existsSync } from "node:fs";
|
|
12
|
-
import { resolve } from "node:path";
|
|
13
|
-
import type { Theme } from "./prompts.ts";
|
|
14
|
-
|
|
15
|
-
// Runtime peer deps the starter components + _internal helpers import.
|
|
16
|
-
// Peer deps of the starter set:
|
|
17
|
-
// button → cn + cva, card → cn, input → cn, label → cn + @radix-ui/react-label
|
|
18
|
-
export const UI_DEPS: Record<string, string> = {
|
|
19
|
-
"@radix-ui/react-label": "^2.1.0",
|
|
20
|
-
"class-variance-authority": "^0.7.0",
|
|
21
|
-
clsx: "^2.1.0",
|
|
22
|
-
"tailwind-merge": "^2.5.0",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Dev-only: the Bun plugin sordo's `css` build entry loads to compile the
|
|
26
|
-
// Tailwind v4 stylesheet (`css: "app/styles/app.css"` in sordo.config.ts).
|
|
27
|
-
export const UI_DEV_DEPS: Record<string, string> = {
|
|
28
|
-
"bun-plugin-tailwind": "^0.1.2",
|
|
29
|
-
tailwindcss: "^4.0.0",
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const STARTER_COMPONENTS = ["button", "card", "input", "label"] as const;
|
|
33
|
-
|
|
34
|
-
// Stamp the vendored starter set into an app directory and rewrite the demo to
|
|
35
|
-
// import the stamped components. `uiStarterDir` is templates/ui-starter.
|
|
36
|
-
export async function applyUiStarter(
|
|
37
|
-
appRoot: string,
|
|
38
|
-
theme: Theme,
|
|
39
|
-
uiStarterDir: string,
|
|
40
|
-
): Promise<void> {
|
|
41
|
-
const uiDir = `${appRoot}/app/components/ui`;
|
|
42
|
-
const internalDir = `${uiDir}/_internal`;
|
|
43
|
-
await Bun.$`mkdir -p ${internalDir}`.quiet();
|
|
44
|
-
|
|
45
|
-
for (const name of STARTER_COMPONENTS) {
|
|
46
|
-
await Bun.$`cp ${uiStarterDir}/${name}.tsx ${uiDir}/${name}.tsx`.quiet();
|
|
47
|
-
}
|
|
48
|
-
await Bun.$`cp -R ${uiStarterDir}/_internal/. ${internalDir}`.quiet();
|
|
49
|
-
await writeStyling(appRoot, theme, uiStarterDir);
|
|
50
|
-
|
|
51
|
-
// Demo page + island that import the stamped components. Only applies to
|
|
52
|
-
// frontend / fullstack, which always have app/routes + app/islands.
|
|
53
|
-
await Bun.$`cp ${uiStarterDir}/demo/index.tsx ${appRoot}/app/routes/index.tsx`.quiet();
|
|
54
|
-
await Bun.$`cp ${uiStarterDir}/demo/TodoApp.tsx ${appRoot}/app/islands/TodoApp.tsx`.quiet();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Upstream shadcn/ui deps for the vendored button + dialog. `cn` is shadcn's
|
|
58
|
-
// own clsx + tailwind-merge package, imported directly by upstream source.
|
|
59
|
-
export const UI_SHADCN_DEPS: Record<string, string> = {
|
|
60
|
-
"class-variance-authority": "^0.7.1",
|
|
61
|
-
cn: "^0.5.0",
|
|
62
|
-
"lucide-react": "^1.59.0",
|
|
63
|
-
"radix-ui": "^1.8.1",
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// `--ui shadcn`: upstream shadcn/ui on a whole-tree hydrated demo page. The
|
|
67
|
-
// vendored components under templates/ui-shadcn/components are byte-for-byte
|
|
68
|
-
// what `sordo add @shadcn/<name>` stamps (drift-tested), so later adds slot
|
|
69
|
-
// in beside them.
|
|
70
|
-
export async function applyShadcnStarter(
|
|
71
|
-
appRoot: string,
|
|
72
|
-
theme: Theme,
|
|
73
|
-
uiStarterDir: string,
|
|
74
|
-
uiShadcnDir: string,
|
|
75
|
-
): Promise<void> {
|
|
76
|
-
const uiDir = `${appRoot}/app/components/ui`;
|
|
77
|
-
const libDir = `${appRoot}/app/lib`;
|
|
78
|
-
await Bun.$`mkdir -p ${uiDir} ${libDir}`.quiet();
|
|
79
|
-
await Bun.$`cp -R ${uiShadcnDir}/components/. ${uiDir}`.quiet();
|
|
80
|
-
// Upstream `registry:lib/utils` — keeps `@/lib/utils` imports working.
|
|
81
|
-
await Bun.write(`${libDir}/utils.ts`, 'export { cn } from "cn";\n');
|
|
82
|
-
await writeStyling(appRoot, theme, uiStarterDir);
|
|
83
|
-
await addAppAlias(appRoot);
|
|
84
|
-
|
|
85
|
-
await Bun.$`cp ${uiShadcnDir}/demo/index.tsx ${appRoot}/app/routes/index.tsx`.quiet();
|
|
86
|
-
// The hydrated page replaces the island demo.
|
|
87
|
-
await Bun.$`rm -rf ${appRoot}/app/islands`.quiet();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// `@/*` → `./app/*`, the alias upstream shadcn source imports through.
|
|
91
|
-
async function addAppAlias(appRoot: string): Promise<void> {
|
|
92
|
-
const path = `${appRoot}/tsconfig.json`;
|
|
93
|
-
const config = (await Bun.file(path).json()) as {
|
|
94
|
-
compilerOptions?: Record<string, unknown>;
|
|
95
|
-
};
|
|
96
|
-
config.compilerOptions = {
|
|
97
|
-
...(config.compilerOptions ?? {}),
|
|
98
|
-
paths: { "@/*": ["./app/*"] },
|
|
99
|
-
};
|
|
100
|
-
await Bun.write(path, `${JSON.stringify(config, null, "\t")}\n`);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Tokens and the Tailwind entry both starters share; sordo.config.ts points its
|
|
104
|
-
// `css` option at app.css.
|
|
105
|
-
async function writeStyling(
|
|
106
|
-
appRoot: string,
|
|
107
|
-
theme: Theme,
|
|
108
|
-
uiStarterDir: string,
|
|
109
|
-
): Promise<void> {
|
|
110
|
-
const stylesDir = `${appRoot}/app/styles`;
|
|
111
|
-
await Bun.$`mkdir -p ${stylesDir}`.quiet();
|
|
112
|
-
|
|
113
|
-
const themeTokens = resolve(uiStarterDir, "themes", theme, "tokens.css");
|
|
114
|
-
const tokens = existsSync(themeTokens)
|
|
115
|
-
? themeTokens
|
|
116
|
-
: resolve(uiStarterDir, "tokens.css");
|
|
117
|
-
await Bun.$`cp ${tokens} ${stylesDir}/tokens.css`.quiet();
|
|
118
|
-
// app.css is written (not vendored) because a committed `@theme` stylesheet
|
|
119
|
-
// would trip this repo's Biome CSS parser, which has Tailwind directives off.
|
|
120
|
-
await Bun.write(`${stylesDir}/app.css`, APP_CSS);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Pre-wired Tailwind v4 + tokens stylesheet (the wiring `sordo ui init`
|
|
124
|
-
// prints). `sordo build` / `sordo dev` compile it via the `css` config option.
|
|
125
|
-
const APP_CSS = `@import "tailwindcss";
|
|
126
|
-
@import "./tokens.css";
|
|
127
|
-
|
|
128
|
-
@theme inline {
|
|
129
|
-
--color-background: var(--background);
|
|
130
|
-
--color-foreground: var(--foreground);
|
|
131
|
-
--color-card: var(--card);
|
|
132
|
-
--color-card-foreground: var(--card-foreground);
|
|
133
|
-
--color-popover: var(--popover);
|
|
134
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
135
|
-
--color-primary: var(--primary);
|
|
136
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
137
|
-
--color-secondary: var(--secondary);
|
|
138
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
139
|
-
--color-muted: var(--muted);
|
|
140
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
141
|
-
--color-accent: var(--accent);
|
|
142
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
143
|
-
--color-destructive: var(--destructive);
|
|
144
|
-
--color-destructive-foreground: var(--destructive-foreground);
|
|
145
|
-
--color-border: var(--border);
|
|
146
|
-
--color-input: var(--input);
|
|
147
|
-
--color-ring: var(--ring);
|
|
148
|
-
--radius-lg: var(--radius);
|
|
149
|
-
--radius-md: calc(var(--radius) - 2px);
|
|
150
|
-
--radius-sm: calc(var(--radius) - 4px);
|
|
151
|
-
}
|
|
152
|
-
`;
|
package/src/versions.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { SordoContext } from "sordo/middleware";
|
|
2
|
-
|
|
3
|
-
// A small in-memory sample resource so a backend project boots with a working
|
|
4
|
-
// endpoint. Swap the array for a real data source when you're ready.
|
|
5
|
-
interface Todo {
|
|
6
|
-
id: number;
|
|
7
|
-
text: string;
|
|
8
|
-
done: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const todos: Todo[] = [
|
|
12
|
-
{ id: 1, text: "wire up a database", done: false },
|
|
13
|
-
{ id: 2, text: "add authentication", done: false },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export function GET(_req: Request, ctx: SordoContext): Response {
|
|
17
|
-
return ctx.json({ todos });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function POST(req: Request, ctx: SordoContext): Promise<Response> {
|
|
21
|
-
const body = (await req.json()) as { text?: unknown };
|
|
22
|
-
const text = typeof body.text === "string" ? body.text.trim() : "";
|
|
23
|
-
if (!text) return ctx.json({ error: "text is required" }, { status: 400 });
|
|
24
|
-
const todo: Todo = { id: todos.length + 1, text, done: false };
|
|
25
|
-
todos.push(todo);
|
|
26
|
-
return ctx.json({ todo }, { status: 201 });
|
|
27
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Guided, plan-mode first scaffold for a Sordo project — pick feature patterns, see a plan, then scaffold after approval.
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# /sordo-init
|
|
6
|
-
|
|
7
|
-
Guide the user through their first feature scaffold. This command is a thin
|
|
8
|
-
driver — all the recipe detail lives in the `sordo` skill. Do **not**
|
|
9
|
-
duplicate the pattern catalog here; defer to `/sordo`.
|
|
10
|
-
|
|
11
|
-
You are (or should be) in **plan mode**: explore and propose, but write nothing
|
|
12
|
-
until the user approves the plan.
|
|
13
|
-
|
|
14
|
-
Run these four steps:
|
|
15
|
-
|
|
16
|
-
1. **Discover** — read the project to fit the plan to what was scaffolded:
|
|
17
|
-
- project type (frontend / backend / fullstack) and deploy target, from
|
|
18
|
-
`sordo.config.ts` and `package.json`,
|
|
19
|
-
- whether the UI starter is initialized (does `app/components/ui/_internal/`
|
|
20
|
-
exist?),
|
|
21
|
-
- flat vs. monorepo layout (is there an `apps/` workspace?).
|
|
22
|
-
2. **Ask** — which feature pattern(s) from the `sordo` skill catalog the user
|
|
23
|
-
wants (auth-rbac, crm, task, pivot, dashboard), plus the domain specifics the
|
|
24
|
-
recipes adapt to: entity names, fields, and roles.
|
|
25
|
-
3. **Plan** — present the file list, the `sordo add @shadcn/<name>` components to stamp, and
|
|
26
|
-
the mock-data shape, honoring the skill's **UI + mock data** depth contract
|
|
27
|
-
(no `bun:sqlite`, migrations, or real backend). Write nothing yet.
|
|
28
|
-
4. **Scaffold** — once the user approves and exits plan mode:
|
|
29
|
-
- **Remove the starter demo first.** The scaffolder ships a placeholder
|
|
30
|
-
`app/routes/index.tsx` + `app/islands/TodoApp.tsx` to prove hydration. This
|
|
31
|
-
is pre-`/sordo-init` filler — delete both before generating the real
|
|
32
|
-
feature so the first page isn't a throwaway todo list. (Replace `index.tsx`
|
|
33
|
-
with the chosen pattern's landing page, or a minimal welcome if the pattern
|
|
34
|
-
has its own routes.)
|
|
35
|
-
- Generate the files per the `sordo` skill recipes. If UI setup isn't
|
|
36
|
-
initialized, run `sordo ui init --shadcn` first.
|
|
37
|
-
|
|
38
|
-
## Framework constraints (don't re-derive these)
|
|
39
|
-
|
|
40
|
-
These are stable facts — bake them into the plan instead of tracing the source:
|
|
41
|
-
|
|
42
|
-
- **Page routes (`.tsx`) receive only `ctx.params`** as props. They cannot read
|
|
43
|
-
cookies, set headers, or redirect. Anything needing those goes in an API route
|
|
44
|
-
or middleware (below). Pages contribute to `<head>` via an exported
|
|
45
|
-
`head()` function.
|
|
46
|
-
- **`.ts` route files must live under `app/routes/api/`** (URL `/api/...`). A
|
|
47
|
-
`.ts` route anywhere else is a build error — e.g. logout is
|
|
48
|
-
`app/routes/api/logout.ts` → `/api/logout`, not `app/routes/logout.ts`.
|
|
49
|
-
- **`app/middleware.ts` is the only way to gate a page route.** It default-exports
|
|
50
|
-
one global `Middleware (req, ctx, next)` that runs on every request with full
|
|
51
|
-
`ctx` (cookies, `ctx.redirect`). Protect `/admin`-style pages here; never try
|
|
52
|
-
to gate inside the page component.
|
|
53
|
-
- **Form POSTs target API routes.** Since pages can't read the request body or
|
|
54
|
-
set cookies, login/mutation forms use a native `<form method="post"
|
|
55
|
-
action="/api/…">` posting to a `.ts` handler that sets the cookie and redirects.
|
|
56
|
-
- **`chart` and `form` are client islands** (they pull `recharts` /
|
|
57
|
-
`react-hook-form`). Wrap them in `<Island name="…">`; a server-rendered native
|
|
58
|
-
form avoids `form` entirely.
|
|
59
|
-
- **Styling is opt-in per page.** If `app/components/_head.tsx` exists (UI
|
|
60
|
-
projects have it), every new page route must re-export it —
|
|
61
|
-
`export { head } from "../components/_head.tsx";` — or it renders unstyled.
|
|
62
|
-
|
|
63
|
-
For ongoing work after this first scaffold (adding one component or one more
|
|
64
|
-
pattern later), the user invokes the `/sordo` skill directly.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# PostToolUse hook: run Biome on the file Claude just touched.
|
|
3
|
-
# No-ops cleanly when Biome is not installed so it's safe to ship by default.
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
file="${CLAUDE_FILE_PATH:-${1:-}}"
|
|
7
|
-
if [[ -z "${file}" ]]; then exit 0; fi
|
|
8
|
-
case "${file}" in
|
|
9
|
-
*.ts|*.tsx|*.js|*.jsx|*.json|*.jsonc) ;;
|
|
10
|
-
*) exit 0 ;;
|
|
11
|
-
esac
|
|
12
|
-
|
|
13
|
-
if command -v biome >/dev/null 2>&1; then
|
|
14
|
-
biome check --write --no-errors-on-unmatched "${file}" || exit 2
|
|
15
|
-
elif command -v bunx >/dev/null 2>&1; then
|
|
16
|
-
bunx --bun @biomejs/biome check --write --no-errors-on-unmatched "${file}" 2>/dev/null || exit 0
|
|
17
|
-
fi
|
|
@@ -1,17 +0,0 @@
|
|
|
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`.
|
|
@@ -1,28 +0,0 @@
|
|
|
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.
|
|
@@ -1,31 +0,0 @@
|
|
|
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).
|
|
@@ -1,46 +0,0 @@
|
|
|
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.
|
|
@@ -1,16 +0,0 @@
|
|
|
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.
|