create-macostack 0.6.2 → 0.6.4
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/README.md +14 -4
- package/bin/create-macostack.ts +121 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ An interactive wizard walks you through the rest:
|
|
|
14
14
|
|
|
15
15
|
The CLI then downloads each template without its git history, installs dependencies, runs each template's own setup (app name, fresh secrets, module wiring), and leaves every part as its own independent git repository, ready to push.
|
|
16
16
|
|
|
17
|
+
Finally it scaffolds the **docs system**: `AGENTS.md` (the agent orchestrator), a `docs/` folder (product, architecture, API contract, testing strategy, current plan, ADRs, and per-feature SPEC → DESIGN → TASKS templates), and matching slash commands (`/spec`, `/design`, `/tasks`, `/implement`, `/review`) for **both Claude Code and OpenCode**. The workspace root becomes its own git repo that versions the docs — `client/` and `server/` stay independent.
|
|
18
|
+
|
|
17
19
|
## Requirements
|
|
18
20
|
|
|
19
21
|
- [Bun](https://bun.sh) 1.x
|
|
@@ -38,21 +40,26 @@ Result:
|
|
|
38
40
|
|
|
39
41
|
```txt
|
|
40
42
|
my-app/
|
|
41
|
-
├──
|
|
42
|
-
|
|
43
|
+
├── AGENTS.md # how AI agents work here (Claude Code & OpenCode)
|
|
44
|
+
├── CLAUDE.md # Claude Code adapter → AGENTS.md
|
|
45
|
+
├── docs/ # product, architecture, contracts, features (SPEC/DESIGN/TASKS)
|
|
46
|
+
├── server/ # Bun + Hono + Postgres API — its own git repo
|
|
47
|
+
└── client/ # TanStack web app — its own git repo
|
|
43
48
|
```
|
|
44
49
|
|
|
45
|
-
The root
|
|
50
|
+
The root is the **workspace repo**: it versions `docs/` and the orchestration files, while `server/` and `client/` are ignored — each lives and deploys as its own separate repo.
|
|
46
51
|
|
|
47
52
|
### Managing an existing app
|
|
48
53
|
|
|
49
|
-
Run the CLI again inside an app it created
|
|
54
|
+
Run the CLI again inside an app it created — it detects the existing setup and switches to manage mode:
|
|
50
55
|
|
|
51
56
|
```bash
|
|
52
57
|
cd my-app
|
|
53
58
|
bun create macostack .
|
|
54
59
|
```
|
|
55
60
|
|
|
61
|
+
From there you can **start a new feature** (scaffolds `docs/features/<name>/` with SPEC, DESIGN and TASKS — then run `/spec <name>` in your agent), **update the docs system** (syncs AGENTS.md, slash commands, cheat sheet and feature templates from the template repo — your project's own docs are never touched), **add the docs system** to an app created before it existed, add a missing part, or toggle feature modules on and off.
|
|
62
|
+
|
|
56
63
|
### Flags
|
|
57
64
|
|
|
58
65
|
| Flag | Description |
|
|
@@ -63,8 +70,10 @@ bun create macostack .
|
|
|
63
70
|
| `--ref <ref>` | Branch or tag to download (default: `main`) |
|
|
64
71
|
| `--server-repo <name>` | Server template repo (default: `macostack-server`) |
|
|
65
72
|
| `--client-repo <name>` | Client template repo (default: `macostack-client`) |
|
|
73
|
+
| `--docs-repo <name>` | Docs system repo (default: `macostack-docs`) |
|
|
66
74
|
| `--skip-install` | Skip `bun install` |
|
|
67
75
|
| `--skip-setup` | Skip each template's setup wizard |
|
|
76
|
+
| `--skip-docs` | Skip the docs system (AGENTS.md + docs/) |
|
|
68
77
|
| `--help` | Print usage |
|
|
69
78
|
|
|
70
79
|
### Environment variables
|
|
@@ -75,6 +84,7 @@ bun create macostack .
|
|
|
75
84
|
| `MACOSTACK_GITHUB_OWNER` | Default template owner |
|
|
76
85
|
| `MACOSTACK_SERVER_REPO` | Default server template repo |
|
|
77
86
|
| `MACOSTACK_CLIENT_REPO` | Default client template repo |
|
|
87
|
+
| `MACOSTACK_DOCS_REPO` | Default docs system repo |
|
|
78
88
|
| `MACOSTACK_REF` | Default branch or tag |
|
|
79
89
|
|
|
80
90
|
## Bring your own templates
|
package/bin/create-macostack.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
multiselect,
|
|
7
7
|
note,
|
|
8
8
|
outro,
|
|
9
|
+
password,
|
|
9
10
|
select,
|
|
10
11
|
spinner,
|
|
11
12
|
text,
|
|
@@ -17,10 +18,11 @@ import {
|
|
|
17
18
|
readdirSync,
|
|
18
19
|
readFileSync,
|
|
19
20
|
rmSync,
|
|
21
|
+
statSync,
|
|
20
22
|
writeFileSync,
|
|
21
23
|
} from "node:fs";
|
|
22
24
|
import { tmpdir } from "node:os";
|
|
23
|
-
import { basename, join, resolve } from "node:path";
|
|
25
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
24
26
|
import { parseArgs } from "node:util";
|
|
25
27
|
|
|
26
28
|
// create-macostack — start a new app from the macostack templates.
|
|
@@ -133,6 +135,7 @@ Flags:
|
|
|
133
135
|
Auth (templates are private):
|
|
134
136
|
export GITHUB_TOKEN=github_pat_… or gh auth login
|
|
135
137
|
(fine-grained token, Contents: Read-only is enough)
|
|
138
|
+
No token configured? I'll ask for one when it's needed.
|
|
136
139
|
`);
|
|
137
140
|
process.exit(0);
|
|
138
141
|
}
|
|
@@ -157,9 +160,40 @@ const answered = <T>(value: T | symbol): T => {
|
|
|
157
160
|
const githubToken = (): string | null => {
|
|
158
161
|
const fromEnv = Bun.env.GITHUB_TOKEN ?? Bun.env.GH_TOKEN;
|
|
159
162
|
if (fromEnv) return fromEnv;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
try {
|
|
164
|
+
const gh = Bun.spawnSync(["gh", "auth", "token"], { stdout: "pipe", stderr: "pipe" });
|
|
165
|
+
const token = gh.exitCode === 0 ? gh.stdout.toString().trim() : "";
|
|
166
|
+
return token || null;
|
|
167
|
+
} catch {
|
|
168
|
+
return null; // gh isn't installed
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// Resolve a GitHub token, or ask for one when nothing is configured. In --yes
|
|
173
|
+
// mode there's nobody to ask, so it bails with instructions instead.
|
|
174
|
+
const requireGithubToken = async (purpose: string): Promise<string> => {
|
|
175
|
+
const found = githubToken();
|
|
176
|
+
if (found) return found;
|
|
177
|
+
if (flags.yes) {
|
|
178
|
+
bail(
|
|
179
|
+
`I need GitHub access to ${purpose} (the repos are private).\n` +
|
|
180
|
+
" Easiest: gh auth login\n" +
|
|
181
|
+
" Or: export GITHUB_TOKEN=github_pat_… (Contents: Read-only)",
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
note(
|
|
185
|
+
`I need GitHub access to ${purpose} (the repos are private).\n` +
|
|
186
|
+
"A fine-grained token with Contents: Read-only is enough.\n" +
|
|
187
|
+
"Tip: gh auth login (or export GITHUB_TOKEN=…) skips this question next time.",
|
|
188
|
+
"GitHub access",
|
|
189
|
+
);
|
|
190
|
+
const typed = answered(
|
|
191
|
+
await password({
|
|
192
|
+
message: "Paste your GitHub token (input is hidden)",
|
|
193
|
+
validate: (v) => (v?.trim() ? undefined : "I need a token to continue"),
|
|
194
|
+
}),
|
|
195
|
+
);
|
|
196
|
+
return typed.trim();
|
|
163
197
|
};
|
|
164
198
|
|
|
165
199
|
const isEmptyDir = (dir: string) =>
|
|
@@ -254,6 +288,75 @@ const scaffoldDocs = async (
|
|
|
254
288
|
return true;
|
|
255
289
|
};
|
|
256
290
|
|
|
291
|
+
// The docs-system files that a sync may replace. STRICT whitelist: process and
|
|
292
|
+
// templates only — never the project's own content (PRODUCT, CURRENT_PLAN,
|
|
293
|
+
// DECISIONS, ARCHITECTURE, real features), which lives outside these paths.
|
|
294
|
+
const DOCS_SYNC_PATHS = [
|
|
295
|
+
"AGENTS.md",
|
|
296
|
+
"CLAUDE.md",
|
|
297
|
+
"docs/CHEATSHEET.md",
|
|
298
|
+
"docs/features/_template",
|
|
299
|
+
".claude/commands",
|
|
300
|
+
".opencode/commands",
|
|
301
|
+
];
|
|
302
|
+
|
|
303
|
+
// Bring an existing project's docs SYSTEM up to date with the template repo.
|
|
304
|
+
// Downloads the repo to a temp dir and copies only DOCS_SYNC_PATHS over the
|
|
305
|
+
// local files, reporting exactly what changed. Nothing is committed — the
|
|
306
|
+
// workspace repo shows the diff for review.
|
|
307
|
+
const updateDocs = async (token: string, root: string): Promise<void> => {
|
|
308
|
+
const docsOwner = flags.owner ?? DEFAULT_OWNER;
|
|
309
|
+
const docsRef = flags.ref ?? DEFAULT_REF;
|
|
310
|
+
const docsRepo = flags["docs-repo"] ?? DOCS_REPO;
|
|
311
|
+
const s = spinner();
|
|
312
|
+
s.start(`Docs — fetching ${docsOwner}/${docsRepo}@${docsRef}`);
|
|
313
|
+
const tmp = mkdtempSync(join(tmpdir(), "macostack-docs-sync-"));
|
|
314
|
+
try {
|
|
315
|
+
const err = await downloadInto(token, docsOwner, docsRepo, docsRef, tmp);
|
|
316
|
+
if (err) {
|
|
317
|
+
s.stop("Docs — download failed");
|
|
318
|
+
bail(err);
|
|
319
|
+
}
|
|
320
|
+
const changed: string[] = [];
|
|
321
|
+
const syncFile = (rel: string) => {
|
|
322
|
+
const src = join(tmp, rel);
|
|
323
|
+
const next = readFileSync(src, "utf8");
|
|
324
|
+
const dst = resolve(root, rel);
|
|
325
|
+
if (existsSync(dst) && readFileSync(dst, "utf8") === next) return;
|
|
326
|
+
mkdirSync(dirname(dst), { recursive: true });
|
|
327
|
+
writeFileSync(dst, next);
|
|
328
|
+
changed.push(rel);
|
|
329
|
+
};
|
|
330
|
+
const syncDir = (rel: string) => {
|
|
331
|
+
for (const e of readdirSync(join(tmp, rel), { withFileTypes: true })) {
|
|
332
|
+
const childRel = `${rel}/${e.name}`;
|
|
333
|
+
if (e.isDirectory()) syncDir(childRel);
|
|
334
|
+
else syncFile(childRel);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
for (const p of DOCS_SYNC_PATHS) {
|
|
338
|
+
const src = join(tmp, p);
|
|
339
|
+
if (!existsSync(src)) continue;
|
|
340
|
+
if (statSync(src).isDirectory()) syncDir(p);
|
|
341
|
+
else syncFile(p);
|
|
342
|
+
}
|
|
343
|
+
s.stop(
|
|
344
|
+
changed.length === 0
|
|
345
|
+
? "Docs — already up to date"
|
|
346
|
+
: `Docs — updated ${changed.length} file${changed.length === 1 ? "" : "s"}`,
|
|
347
|
+
);
|
|
348
|
+
if (changed.length > 0) {
|
|
349
|
+
note(
|
|
350
|
+
changed.map((f) => `• ${f}`).join("\n") +
|
|
351
|
+
"\n\nYour project's own docs (PRODUCT, CURRENT_PLAN, features…) were not touched.\nReview with git diff, then commit when happy.",
|
|
352
|
+
"Docs system updated",
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
} finally {
|
|
356
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
|
|
257
360
|
// Scaffold docs/features/<name>/ from the _template folder (SPEC → DESIGN →
|
|
258
361
|
// TASKS). Returns an error message, or null on success.
|
|
259
362
|
const scaffoldFeature = (root: string, feature: string): string | null => {
|
|
@@ -394,7 +497,10 @@ if (present.length > 0) {
|
|
|
394
497
|
|
|
395
498
|
const actions = [
|
|
396
499
|
...(hasDocs
|
|
397
|
-
? [
|
|
500
|
+
? [
|
|
501
|
+
{ value: "feature", label: "Start a new feature", hint: "SPEC → DESIGN → TASKS in docs/features/" },
|
|
502
|
+
{ value: "docs-update", label: "Update the docs system", hint: "sync AGENTS.md, commands and templates — your content stays" },
|
|
503
|
+
]
|
|
398
504
|
: [{ value: "docs", label: "Add the docs system", hint: "AGENTS.md + docs/ + /spec /design /tasks commands" }]),
|
|
399
505
|
...missing.map((p) => ({ value: `add:${p.id}`, label: `Add the ${p.label.toLowerCase()}`, hint: p.hint })),
|
|
400
506
|
...present.map((p) => ({ value: `adjust:${p.id}`, label: `Adjust ${p.label.toLowerCase()} modules`, hint: "turn things on or off" })),
|
|
@@ -412,9 +518,9 @@ if (present.length > 0) {
|
|
|
412
518
|
const feature = answered(
|
|
413
519
|
await text({
|
|
414
520
|
message: "Feature name?",
|
|
415
|
-
placeholder: "
|
|
521
|
+
placeholder: "your-feature-name",
|
|
416
522
|
validate: (v) =>
|
|
417
|
-
validName(v ?? "") ? undefined : "lowercase letters, digits and dashes — e.g.
|
|
523
|
+
validName(v ?? "") ? undefined : "lowercase letters, digits and dashes — e.g. dark-mode",
|
|
418
524
|
}),
|
|
419
525
|
);
|
|
420
526
|
const err = scaffoldFeature(targetRoot, feature);
|
|
@@ -426,16 +532,14 @@ if (present.length > 0) {
|
|
|
426
532
|
outro(`${appName} — ready to spec ✨`);
|
|
427
533
|
process.exit(0);
|
|
428
534
|
}
|
|
535
|
+
if (action === "docs-update") {
|
|
536
|
+
const syncToken = await requireGithubToken("fetch the docs system");
|
|
537
|
+
await updateDocs(syncToken, targetRoot);
|
|
538
|
+
outro(`${appName} is up to date ✨`);
|
|
539
|
+
process.exit(0);
|
|
540
|
+
}
|
|
429
541
|
if (action === "docs") {
|
|
430
|
-
const docsToken =
|
|
431
|
-
if (!docsToken) {
|
|
432
|
-
bail(
|
|
433
|
-
"I need GitHub access to download the docs system (the repo is private).\n" +
|
|
434
|
-
" Easiest: gh auth login\n" +
|
|
435
|
-
" Or: export GITHUB_TOKEN=github_pat_… (Contents: Read-only)",
|
|
436
|
-
);
|
|
437
|
-
throw ""; // unreachable
|
|
438
|
-
}
|
|
542
|
+
const docsToken = await requireGithubToken("download the docs system");
|
|
439
543
|
const ok = await scaffoldDocs(docsToken, targetRoot, appName, null);
|
|
440
544
|
if (ok) {
|
|
441
545
|
note(
|
|
@@ -484,15 +588,7 @@ if (!selected) {
|
|
|
484
588
|
// 3. GitHub access — checked before anything is created.
|
|
485
589
|
const owner = flags.owner ?? DEFAULT_OWNER;
|
|
486
590
|
const ref = flags.ref ?? DEFAULT_REF;
|
|
487
|
-
const token =
|
|
488
|
-
if (!token) {
|
|
489
|
-
bail(
|
|
490
|
-
"I need GitHub access to download the templates (they're private).\n" +
|
|
491
|
-
" Easiest: gh auth login\n" +
|
|
492
|
-
" Or: export GITHUB_TOKEN=github_pat_… (Contents: Read-only)",
|
|
493
|
-
);
|
|
494
|
-
throw ""; // unreachable
|
|
495
|
-
}
|
|
591
|
+
const token = await requireGithubToken("download the templates");
|
|
496
592
|
for (const p of selected) {
|
|
497
593
|
p.repo = (p.id === "server" ? flags["server-repo"] : flags["client-repo"]) ?? p.repo;
|
|
498
594
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-macostack",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Scaffold a production-ready full-stack app from the macostack templates: Bun + Hono + Postgres backend and TanStack web app, each as its own git repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|