create-macostack 0.6.2 → 0.6.3

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 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
- ├── server/ # Bun + Hono + Postgres API its own git repo
42
- └── client/ # TanStack web app its own git repo
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 folder is intentionally **not** a git repository: server and client are designed to live and deploy as separate repos.
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 to add the missing part or toggle feature modules on and off — it detects the existing setup and switches to manage mode:
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
@@ -17,10 +17,11 @@ import {
17
17
  readdirSync,
18
18
  readFileSync,
19
19
  rmSync,
20
+ statSync,
20
21
  writeFileSync,
21
22
  } from "node:fs";
22
23
  import { tmpdir } from "node:os";
23
- import { basename, join, resolve } from "node:path";
24
+ import { basename, dirname, join, resolve } from "node:path";
24
25
  import { parseArgs } from "node:util";
25
26
 
26
27
  // create-macostack — start a new app from the macostack templates.
@@ -254,6 +255,75 @@ const scaffoldDocs = async (
254
255
  return true;
255
256
  };
256
257
 
258
+ // The docs-system files that a sync may replace. STRICT whitelist: process and
259
+ // templates only — never the project's own content (PRODUCT, CURRENT_PLAN,
260
+ // DECISIONS, ARCHITECTURE, real features), which lives outside these paths.
261
+ const DOCS_SYNC_PATHS = [
262
+ "AGENTS.md",
263
+ "CLAUDE.md",
264
+ "docs/CHEATSHEET.md",
265
+ "docs/features/_template",
266
+ ".claude/commands",
267
+ ".opencode/commands",
268
+ ];
269
+
270
+ // Bring an existing project's docs SYSTEM up to date with the template repo.
271
+ // Downloads the repo to a temp dir and copies only DOCS_SYNC_PATHS over the
272
+ // local files, reporting exactly what changed. Nothing is committed — the
273
+ // workspace repo shows the diff for review.
274
+ const updateDocs = async (token: string, root: string): Promise<void> => {
275
+ const docsOwner = flags.owner ?? DEFAULT_OWNER;
276
+ const docsRef = flags.ref ?? DEFAULT_REF;
277
+ const docsRepo = flags["docs-repo"] ?? DOCS_REPO;
278
+ const s = spinner();
279
+ s.start(`Docs — fetching ${docsOwner}/${docsRepo}@${docsRef}`);
280
+ const tmp = mkdtempSync(join(tmpdir(), "macostack-docs-sync-"));
281
+ try {
282
+ const err = await downloadInto(token, docsOwner, docsRepo, docsRef, tmp);
283
+ if (err) {
284
+ s.stop("Docs — download failed");
285
+ bail(err);
286
+ }
287
+ const changed: string[] = [];
288
+ const syncFile = (rel: string) => {
289
+ const src = join(tmp, rel);
290
+ const next = readFileSync(src, "utf8");
291
+ const dst = resolve(root, rel);
292
+ if (existsSync(dst) && readFileSync(dst, "utf8") === next) return;
293
+ mkdirSync(dirname(dst), { recursive: true });
294
+ writeFileSync(dst, next);
295
+ changed.push(rel);
296
+ };
297
+ const syncDir = (rel: string) => {
298
+ for (const e of readdirSync(join(tmp, rel), { withFileTypes: true })) {
299
+ const childRel = `${rel}/${e.name}`;
300
+ if (e.isDirectory()) syncDir(childRel);
301
+ else syncFile(childRel);
302
+ }
303
+ };
304
+ for (const p of DOCS_SYNC_PATHS) {
305
+ const src = join(tmp, p);
306
+ if (!existsSync(src)) continue;
307
+ if (statSync(src).isDirectory()) syncDir(p);
308
+ else syncFile(p);
309
+ }
310
+ s.stop(
311
+ changed.length === 0
312
+ ? "Docs — already up to date"
313
+ : `Docs — updated ${changed.length} file${changed.length === 1 ? "" : "s"}`,
314
+ );
315
+ if (changed.length > 0) {
316
+ note(
317
+ changed.map((f) => `• ${f}`).join("\n") +
318
+ "\n\nYour project's own docs (PRODUCT, CURRENT_PLAN, features…) were not touched.\nReview with git diff, then commit when happy.",
319
+ "Docs system updated",
320
+ );
321
+ }
322
+ } finally {
323
+ rmSync(tmp, { recursive: true, force: true });
324
+ }
325
+ };
326
+
257
327
  // Scaffold docs/features/<name>/ from the _template folder (SPEC → DESIGN →
258
328
  // TASKS). Returns an error message, or null on success.
259
329
  const scaffoldFeature = (root: string, feature: string): string | null => {
@@ -394,7 +464,10 @@ if (present.length > 0) {
394
464
 
395
465
  const actions = [
396
466
  ...(hasDocs
397
- ? [{ value: "feature", label: "Start a new feature", hint: "SPEC → DESIGN → TASKS in docs/features/" }]
467
+ ? [
468
+ { value: "feature", label: "Start a new feature", hint: "SPEC → DESIGN → TASKS in docs/features/" },
469
+ { value: "docs-update", label: "Update the docs system", hint: "sync AGENTS.md, commands and templates — your content stays" },
470
+ ]
398
471
  : [{ value: "docs", label: "Add the docs system", hint: "AGENTS.md + docs/ + /spec /design /tasks commands" }]),
399
472
  ...missing.map((p) => ({ value: `add:${p.id}`, label: `Add the ${p.label.toLowerCase()}`, hint: p.hint })),
400
473
  ...present.map((p) => ({ value: `adjust:${p.id}`, label: `Adjust ${p.label.toLowerCase()} modules`, hint: "turn things on or off" })),
@@ -412,9 +485,9 @@ if (present.length > 0) {
412
485
  const feature = answered(
413
486
  await text({
414
487
  message: "Feature name?",
415
- placeholder: "member-invites",
488
+ placeholder: "your-feature-name",
416
489
  validate: (v) =>
417
- validName(v ?? "") ? undefined : "lowercase letters, digits and dashes — e.g. member-invites",
490
+ validName(v ?? "") ? undefined : "lowercase letters, digits and dashes — e.g. dark-mode",
418
491
  }),
419
492
  );
420
493
  const err = scaffoldFeature(targetRoot, feature);
@@ -426,6 +499,20 @@ if (present.length > 0) {
426
499
  outro(`${appName} — ready to spec ✨`);
427
500
  process.exit(0);
428
501
  }
502
+ if (action === "docs-update") {
503
+ const syncToken = githubToken();
504
+ if (!syncToken) {
505
+ bail(
506
+ "I need GitHub access to fetch the docs system (the repo is private).\n" +
507
+ " Easiest: gh auth login\n" +
508
+ " Or: export GITHUB_TOKEN=github_pat_… (Contents: Read-only)",
509
+ );
510
+ throw ""; // unreachable
511
+ }
512
+ await updateDocs(syncToken, targetRoot);
513
+ outro(`${appName} is up to date ✨`);
514
+ process.exit(0);
515
+ }
429
516
  if (action === "docs") {
430
517
  const docsToken = githubToken();
431
518
  if (!docsToken) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-macostack",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
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": {