codebyplan 1.5.1 → 1.9.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.
Files changed (211) hide show
  1. package/dist/cli.js +4462 -748
  2. package/package.json +5 -1
  3. package/templates/.gitkeep +0 -0
  4. package/templates/README.md +20 -0
  5. package/templates/agents/cbp-cc-executor.md +213 -0
  6. package/templates/agents/cbp-database-agent.md +229 -0
  7. package/templates/agents/cbp-improve-claude.md +245 -0
  8. package/templates/agents/cbp-improve-round.md +284 -0
  9. package/templates/agents/cbp-mechanical-edits.md +111 -0
  10. package/templates/agents/cbp-research.md +282 -0
  11. package/templates/agents/cbp-round-executor.md +604 -0
  12. package/templates/agents/cbp-security-agent.md +134 -0
  13. package/templates/agents/cbp-task-check.md +213 -0
  14. package/templates/agents/cbp-task-planner.md +582 -0
  15. package/templates/agents/cbp-test-e2e-agent.md +363 -0
  16. package/templates/agents/cbp-testing-qa-agent.md +400 -0
  17. package/templates/context/mcp-docs.md +139 -0
  18. package/templates/hooks/README.md +236 -0
  19. package/templates/hooks/cbp-auto-test-hooks.sh +44 -0
  20. package/templates/hooks/cbp-lint-format-on-edit.sh +159 -0
  21. package/templates/hooks/cbp-maestro-yaml-validate.sh +100 -0
  22. package/templates/hooks/cbp-mcp-migration-guard.sh +32 -0
  23. package/templates/hooks/cbp-mcp-round-sync.sh +79 -0
  24. package/templates/hooks/cbp-mcp-worktree-inject.sh +76 -0
  25. package/templates/hooks/cbp-notify.sh +68 -0
  26. package/templates/hooks/cbp-plugin-dispatch.sh +29 -0
  27. package/templates/hooks/cbp-pre-commit-quality-gate.sh +204 -0
  28. package/templates/hooks/cbp-statusline.sh +347 -0
  29. package/templates/hooks/cbp-subagent-statusline.sh +182 -0
  30. package/templates/hooks/cbp-test-coverage-gate.sh +144 -0
  31. package/templates/hooks/cbp-test-hooks.sh +320 -0
  32. package/templates/hooks/hooks.json +85 -0
  33. package/templates/hooks/validate-context-usage.sh +59 -0
  34. package/templates/hooks/validate-git-commit.sh +78 -0
  35. package/templates/hooks/validate-git-stash-deny.sh +32 -0
  36. package/templates/hooks/validate-structure-lengths.sh +57 -0
  37. package/templates/hooks/validate-structure-lib.sh +104 -0
  38. package/templates/hooks/validate-structure-patterns.sh +54 -0
  39. package/templates/hooks/validate-structure-scope.sh +33 -0
  40. package/templates/hooks/validate-structure-smoke.sh +95 -0
  41. package/templates/hooks/validate-structure-templates.sh +34 -0
  42. package/templates/hooks/validate-structure.sh +69 -0
  43. package/templates/rules/.gitkeep +0 -0
  44. package/templates/rules/README.md +47 -0
  45. package/templates/rules/context-file-loading.md +52 -0
  46. package/templates/rules/scope-vocabulary.md +64 -0
  47. package/templates/rules/todo-backend.md +109 -0
  48. package/templates/settings.project.base.json +55 -0
  49. package/templates/settings.user.base.json +25 -0
  50. package/templates/skills/cbp-build-cc-agent/SKILL.md +139 -0
  51. package/templates/skills/cbp-build-cc-agent/examples/read-only-reviewer.md +32 -0
  52. package/templates/skills/cbp-build-cc-agent/examples/with-hooks.md +41 -0
  53. package/templates/skills/cbp-build-cc-agent/examples/with-skills-preload.md +25 -0
  54. package/templates/skills/cbp-build-cc-agent/reference/cbp-quality.md +153 -0
  55. package/templates/skills/cbp-build-cc-agent/reference/frontmatter-fields.md +37 -0
  56. package/templates/skills/cbp-build-cc-agent/reference/permission-modes.md +18 -0
  57. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +67 -0
  58. package/templates/skills/cbp-build-cc-agent/templates/agent.md +66 -0
  59. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +178 -0
  60. package/templates/skills/cbp-build-cc-claude-file/examples/minimal-project.md +33 -0
  61. package/templates/skills/cbp-build-cc-claude-file/examples/monorepo-with-imports.md +39 -0
  62. package/templates/skills/cbp-build-cc-claude-file/reference/imports.md +72 -0
  63. package/templates/skills/cbp-build-cc-claude-file/reference/what-belongs.md +39 -0
  64. package/templates/skills/cbp-build-cc-claude-file/templates/project-claude-md.md +48 -0
  65. package/templates/skills/cbp-build-cc-claude-file/templates/user-claude-md.md +22 -0
  66. package/templates/skills/cbp-build-cc-memory/SKILL.md +201 -0
  67. package/templates/skills/cbp-build-cc-memory/examples/feedback-memory.md +11 -0
  68. package/templates/skills/cbp-build-cc-memory/examples/project-memory.md +11 -0
  69. package/templates/skills/cbp-build-cc-memory/examples/reference-memory.md +13 -0
  70. package/templates/skills/cbp-build-cc-memory/examples/user-memory.md +14 -0
  71. package/templates/skills/cbp-build-cc-memory/reference/memory-types.md +59 -0
  72. package/templates/skills/cbp-build-cc-memory/reference/when-to-save.md +62 -0
  73. package/templates/skills/cbp-build-cc-memory/templates/MEMORY-index.md +4 -0
  74. package/templates/skills/cbp-build-cc-memory/templates/memory-entry.md +15 -0
  75. package/templates/skills/cbp-build-cc-mode/SKILL.md +99 -0
  76. package/templates/skills/cbp-build-cc-rule/SKILL.md +176 -0
  77. package/templates/skills/cbp-build-cc-rule/examples/global-rule.md +19 -0
  78. package/templates/skills/cbp-build-cc-rule/examples/scoped-rule.md +41 -0
  79. package/templates/skills/cbp-build-cc-rule/reference/paths-patterns.md +48 -0
  80. package/templates/skills/cbp-build-cc-rule/templates/rule.md +32 -0
  81. package/templates/skills/cbp-build-cc-settings/SKILL.md +220 -0
  82. package/templates/skills/cbp-build-cc-settings/examples/hooks-config.json +64 -0
  83. package/templates/skills/cbp-build-cc-settings/examples/permissions-config.json +34 -0
  84. package/templates/skills/cbp-build-cc-settings/examples/sandbox-config.json +42 -0
  85. package/templates/skills/cbp-build-cc-settings/reference/cbp-conventions.md +104 -0
  86. package/templates/skills/cbp-build-cc-settings/reference/permission-rules.md +61 -0
  87. package/templates/skills/cbp-build-cc-settings/reference/scope-precedence.md +73 -0
  88. package/templates/skills/cbp-build-cc-settings/reference/settings-fields.md +166 -0
  89. package/templates/skills/cbp-build-cc-settings/templates/settings.json +23 -0
  90. package/templates/skills/cbp-build-cc-settings/templates/settings.local.json +10 -0
  91. package/templates/skills/cbp-build-cc-skill/SKILL.md +154 -0
  92. package/templates/skills/cbp-build-cc-skill/examples/dynamic-context.md +31 -0
  93. package/templates/skills/cbp-build-cc-skill/examples/fork-skill.md +22 -0
  94. package/templates/skills/cbp-build-cc-skill/examples/knowledge-skill.md +25 -0
  95. package/templates/skills/cbp-build-cc-skill/examples/task-skill.md +29 -0
  96. package/templates/skills/cbp-build-cc-skill/reference/cbp-quality.md +157 -0
  97. package/templates/skills/cbp-build-cc-skill/reference/frontmatter-fields.md +35 -0
  98. package/templates/skills/cbp-build-cc-skill/reference/string-substitutions.md +60 -0
  99. package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +90 -0
  100. package/templates/skills/cbp-build-cc-skill/templates/skill.md +51 -0
  101. package/templates/skills/cbp-checkpoint-check/SKILL.md +156 -0
  102. package/templates/skills/cbp-checkpoint-complete/SKILL.md +109 -0
  103. package/templates/skills/cbp-checkpoint-create/SKILL.md +116 -0
  104. package/templates/skills/cbp-checkpoint-end/SKILL.md +241 -0
  105. package/templates/skills/cbp-checkpoint-plan/SKILL.md +137 -0
  106. package/templates/skills/cbp-checkpoint-plan/reference/alternative-comparison-template.md +54 -0
  107. package/templates/skills/cbp-checkpoint-plan/reference/dep-decision-rubric.md +50 -0
  108. package/templates/skills/cbp-checkpoint-plan/reference/e2e-discovery-probe.md +57 -0
  109. package/templates/skills/cbp-checkpoint-plan/reference/gap-analysis-playbook.md +47 -0
  110. package/templates/skills/cbp-checkpoint-start/SKILL.md +84 -0
  111. package/templates/skills/cbp-checkpoint-update/SKILL.md +115 -0
  112. package/templates/skills/cbp-frontend-a11y/SKILL.md +109 -0
  113. package/templates/skills/cbp-frontend-a11y/reference/aria-roles-states.md +130 -0
  114. package/templates/skills/cbp-frontend-a11y/reference/contrast-visual.md +122 -0
  115. package/templates/skills/cbp-frontend-a11y/reference/keyboard-patterns.md +154 -0
  116. package/templates/skills/cbp-frontend-a11y/reference/semantic-html.md +111 -0
  117. package/templates/skills/cbp-frontend-design/SKILL.md +145 -0
  118. package/templates/skills/cbp-frontend-design/reference/nextjs-scss.md +118 -0
  119. package/templates/skills/cbp-frontend-design/reference/rn-expo.md +101 -0
  120. package/templates/skills/cbp-frontend-design/reference/tauri-react.md +82 -0
  121. package/templates/skills/cbp-frontend-ui/SKILL.md +262 -0
  122. package/templates/skills/cbp-frontend-ui/reference/ui-label-maps.md +42 -0
  123. package/templates/skills/cbp-frontend-ui/reference/ui-layout-patterns.md +105 -0
  124. package/templates/skills/cbp-frontend-ui/reference/variant-defaults.md +149 -0
  125. package/templates/skills/cbp-frontend-ux/SKILL.md +181 -0
  126. package/templates/skills/cbp-git-branch-feat-create/SKILL.md +115 -0
  127. package/templates/skills/cbp-git-commit/SKILL.md +278 -0
  128. package/templates/skills/cbp-git-worktree-create/SKILL.md +226 -0
  129. package/templates/skills/cbp-git-worktree-remove/SKILL.md +145 -0
  130. package/templates/skills/cbp-merge-main/SKILL.md +228 -0
  131. package/templates/skills/cbp-round-check/SKILL.md +104 -0
  132. package/templates/skills/cbp-round-end/SKILL.md +183 -0
  133. package/templates/skills/cbp-round-end/reference/findings-presentation.md +44 -0
  134. package/templates/skills/cbp-round-end/reference/inline-fallback.md +35 -0
  135. package/templates/skills/cbp-round-execute/SKILL.md +211 -0
  136. package/templates/skills/cbp-round-execute/reference/inline-fallback.md +59 -0
  137. package/templates/skills/cbp-round-input/SKILL.md +165 -0
  138. package/templates/skills/cbp-round-start/SKILL.md +222 -0
  139. package/templates/skills/cbp-round-update/SKILL.md +163 -0
  140. package/templates/skills/cbp-session-end/SKILL.md +187 -0
  141. package/templates/skills/cbp-session-start/SKILL.md +155 -0
  142. package/templates/skills/cbp-ship/SKILL.md +332 -0
  143. package/templates/skills/cbp-ship/reference/changesets-overview.md +120 -0
  144. package/templates/skills/cbp-ship/reference/eas-cli-overview.md +60 -0
  145. package/templates/skills/cbp-ship/reference/gh-cli-overview.md +135 -0
  146. package/templates/skills/cbp-ship/reference/gh-cli-shipment-commands.md +283 -0
  147. package/templates/skills/cbp-ship/reference/npm-publish-monorepo.md +252 -0
  148. package/templates/skills/cbp-ship/reference/npm-publish-oidc-trusted.md +157 -0
  149. package/templates/skills/cbp-ship/reference/npm-publish-overview.md +171 -0
  150. package/templates/skills/cbp-ship/reference/preflight-checklist.md +88 -0
  151. package/templates/skills/cbp-ship/reference/railway-nestjs-deployment.md +169 -0
  152. package/templates/skills/cbp-ship/reference/railway-overview.md +120 -0
  153. package/templates/skills/cbp-ship/reference/railway-troubleshooting.md +168 -0
  154. package/templates/skills/cbp-ship/reference/release-please-overview.md +99 -0
  155. package/templates/skills/cbp-ship/reference/surface-expo-eas.md +155 -0
  156. package/templates/skills/cbp-ship/reference/surface-npm.md +180 -0
  157. package/templates/skills/cbp-ship/reference/surface-railway.md +152 -0
  158. package/templates/skills/cbp-ship/reference/surface-supabase.md +178 -0
  159. package/templates/skills/cbp-ship/reference/surface-tauri.md +138 -0
  160. package/templates/skills/cbp-ship/reference/surface-vercel.md +124 -0
  161. package/templates/skills/cbp-ship/reference/surface-vscode-ext.md +144 -0
  162. package/templates/skills/cbp-ship/reference/surfaces.md +60 -0
  163. package/templates/skills/cbp-ship/reference/testflight-automation.md +215 -0
  164. package/templates/skills/cbp-ship/reference/testflight-internal-vs-external.md +69 -0
  165. package/templates/skills/cbp-ship/reference/testflight-overview.md +98 -0
  166. package/templates/skills/cbp-ship/reference/versioning.md +116 -0
  167. package/templates/skills/cbp-ship/scripts/detect-surfaces.sh +217 -0
  168. package/templates/skills/cbp-ship/scripts/verify-expo-eas.sh +35 -0
  169. package/templates/skills/cbp-ship/scripts/verify-npm.sh +21 -0
  170. package/templates/skills/cbp-ship/scripts/verify-railway.sh +41 -0
  171. package/templates/skills/cbp-ship/scripts/verify-supabase.sh +19 -0
  172. package/templates/skills/cbp-ship/scripts/verify-tauri.sh +24 -0
  173. package/templates/skills/cbp-ship/scripts/verify-vercel.sh +32 -0
  174. package/templates/skills/cbp-ship/scripts/verify-vscode-ext.sh +25 -0
  175. package/templates/skills/cbp-ship/templates/eas.json +66 -0
  176. package/templates/skills/cbp-ship/templates/railway.toml +15 -0
  177. package/templates/skills/cbp-ship/templates/release-please-config.json +17 -0
  178. package/templates/skills/cbp-ship/templates/vercel.json +19 -0
  179. package/templates/skills/cbp-ship/templates/vscodeignore +21 -0
  180. package/templates/skills/cbp-ship/templates/workflow-changesets.yml +41 -0
  181. package/templates/skills/cbp-ship/templates/workflow-eas-submit.yml +53 -0
  182. package/templates/skills/cbp-ship/templates/workflow-npm-publish.yml +36 -0
  183. package/templates/skills/cbp-ship/templates/workflow-release-please.yml +21 -0
  184. package/templates/skills/cbp-ship/templates/workflow-tauri-release.yml +69 -0
  185. package/templates/skills/cbp-ship/templates/workflow-vsce-publish.yml +31 -0
  186. package/templates/skills/cbp-ship-configure/SKILL.md +296 -0
  187. package/templates/skills/cbp-ship-configure/reference/expo-mobile.md +204 -0
  188. package/templates/skills/cbp-ship-configure/reference/npm-package.md +165 -0
  189. package/templates/skills/cbp-ship-configure/reference/railway-backend.md +199 -0
  190. package/templates/skills/cbp-ship-configure/reference/supabase.md +200 -0
  191. package/templates/skills/cbp-ship-configure/reference/tauri-desktop.md +181 -0
  192. package/templates/skills/cbp-ship-configure/reference/vercel.md +117 -0
  193. package/templates/skills/cbp-ship-configure/reference/vscode-ext.md +155 -0
  194. package/templates/skills/cbp-ship-main/SKILL.md +65 -0
  195. package/templates/skills/cbp-supabase-branch-check/SKILL.md +337 -0
  196. package/templates/skills/cbp-supabase-branch-check/reference/dag-steps.md +29 -0
  197. package/templates/skills/cbp-supabase-migrate/SKILL.md +314 -0
  198. package/templates/skills/cbp-supabase-migrate/reference/advisor-triage.md +70 -0
  199. package/templates/skills/cbp-supabase-migrate/reference/cli-fallback.md +87 -0
  200. package/templates/skills/cbp-supabase-migrate/reference/preflight-dry-run.md +58 -0
  201. package/templates/skills/cbp-supabase-setup/SKILL.md +239 -0
  202. package/templates/skills/cbp-supabase-setup/reference/branching-setup.md +121 -0
  203. package/templates/skills/cbp-supabase-setup/reference/cli-fallback.md +109 -0
  204. package/templates/skills/cbp-task-check/SKILL.md +166 -0
  205. package/templates/skills/cbp-task-complete/SKILL.md +206 -0
  206. package/templates/skills/cbp-task-complete/reference/checkpoint-done-branching.md +48 -0
  207. package/templates/skills/cbp-task-complete/reference/next-step-heuristic.md +56 -0
  208. package/templates/skills/cbp-task-create/SKILL.md +167 -0
  209. package/templates/skills/cbp-task-start/SKILL.md +239 -0
  210. package/templates/skills/cbp-task-testing/SKILL.md +277 -0
  211. package/templates/skills/cbp-todo/SKILL.md +111 -0
@@ -0,0 +1,171 @@
1
+ # npm Publish — Overview
2
+
3
+ Reference for the `/cbp-ship` orchestrator's `npm-package` surface. Covers what `npm publish` does, registry types, 2FA tiers, package metadata that affects publish output, and `latest` dist-tag semantics.
4
+
5
+ ## What `npm publish` Does
6
+
7
+ `npm publish` packs the current package into a tarball and uploads it to a registry, registering the version under the package name. Once a version is published it is **immutable** — you cannot republish the same `name@version` (you can only `npm unpublish` within 72 hours, and only if no other public package depends on it).
8
+
9
+ Pack rules:
10
+
11
+ 1. CLI computes the file list from (in order): `files` field in `package.json`, `.npmignore`, `.gitignore`. Always-included: `package.json`, `README*`, `LICENSE*`, the file at `main`/`bin`/`exports`. Always-excluded: `node_modules`, `.git`, `.npmrc`, `package-lock.json`.
12
+ 2. CLI runs lifecycle scripts: `prepublishOnly` → `prepack` → tarball write → `postpack` → `publish` → `postpublish`.
13
+ 3. Tarball uploaded to registry with auth (token or OIDC); registry assigns the `latest` dist-tag unless `--tag <name>` overrides.
14
+
15
+ `npm publish --dry-run` runs all the above except the upload — use it to preview the file list and lifecycle execution.
16
+
17
+ ## Registry Types
18
+
19
+ | Registry | Purpose | URL |
20
+ |----------|---------|-----|
21
+ | Public registry | Default; what `npm install <pkg>` hits | `https://registry.npmjs.org` |
22
+ | GitHub Packages | npm packages scoped to a GitHub org | `https://npm.pkg.github.com` |
23
+ | Private registry | Verdaccio, Nexus, JFrog Artifactory, Bytesafe, Cloudsmith | self-hosted or vendor URL |
24
+
25
+ Registry selection comes from (highest precedence first):
26
+
27
+ 1. `publishConfig.registry` in `package.json`
28
+ 2. `--registry <url>` on the CLI
29
+ 3. `npm_config_registry` env var
30
+ 4. `registry=` line in `.npmrc` (project, then user, then global)
31
+ 5. Default — `https://registry.npmjs.org`
32
+
33
+ Scoped packages (`@scope/name`) can route by scope: `@cbp-registry=https://npm.pkg.github.com` in `.npmrc` sends only that scope to GH Packages.
34
+
35
+ ## 2FA Tiers
36
+
37
+ npm offers two 2FA modes (set with `npm profile enable-2fa <mode>`):
38
+
39
+ | Mode | Covers | Use case |
40
+ |------|--------|----------|
41
+ | `auth-only` | Login, profile changes | Convenience — publishes work with token alone |
42
+ | `auth-and-writes` | Login + every publish, `dist-tag`, `unpublish`, `access` change | Hardened — publish requires fresh OTP |
43
+
44
+ Publishing requires **one** of:
45
+
46
+ - 2FA enabled on the account (any mode), OR
47
+ - A **granular access token** with "bypass 2FA" enabled (legacy automation tokens are deprecated; granular is the modern equivalent).
48
+
49
+ For CI flows the modern recommendation is **OIDC trusted publishing** (no token at all) — see [npm-publish-oidc-trusted.md](./npm-publish-oidc-trusted.md). Granular tokens with bypass-2FA remain valid for non-CI release machines.
50
+
51
+ ## Package Metadata That Matters at Publish Time
52
+
53
+ ### `exports`
54
+
55
+ Modern entry-point map. Replaces `main` for resolvers that honour it (Node ≥12.20, all modern bundlers). Conditional exports let you ship CJS + ESM + types from one package:
56
+
57
+ ```json
58
+ {
59
+ "exports": {
60
+ ".": {
61
+ "types": "./dist/index.d.ts",
62
+ "import": "./dist/index.mjs",
63
+ "require": "./dist/index.cjs"
64
+ },
65
+ "./package.json": "./package.json"
66
+ }
67
+ }
68
+ ```
69
+
70
+ Always export `./package.json` — toolchains (`publint`, `attw`) and some bundlers expect it. If `exports` is set, `main` becomes a fallback only for legacy resolvers.
71
+
72
+ ### `files`
73
+
74
+ Allowlist of paths to include in the tarball. Prefer `files` over `.npmignore` — allowlists fail closed (forgetting to ignore a build artefact never leaks a secret):
75
+
76
+ ```json
77
+ {
78
+ "files": ["dist", "README.md", "LICENSE"]
79
+ }
80
+ ```
81
+
82
+ `package.json`, `README*`, `LICENSE*` are always included regardless. `test/`, `__tests__/`, `*.test.*` are excluded automatically.
83
+
84
+ ### `publishConfig`
85
+
86
+ Per-package override of registry config, applied only at publish time. Common keys:
87
+
88
+ ```json
89
+ {
90
+ "publishConfig": {
91
+ "access": "public",
92
+ "registry": "https://registry.npmjs.org",
93
+ "tag": "next",
94
+ "provenance": true
95
+ }
96
+ }
97
+ ```
98
+
99
+ - `access: "public"` is required when first publishing a scoped package (`@scope/name`); otherwise registry assumes private and rejects free-tier accounts.
100
+ - `tag: "next"` (or any non-`latest`) keeps the version off the default install pointer — useful for prereleases.
101
+ - `provenance: true` is the package.json equivalent of `--provenance` (see [npm-publish-oidc-trusted.md](./npm-publish-oidc-trusted.md)).
102
+
103
+ ### `engines`
104
+
105
+ Declares Node/npm version compatibility:
106
+
107
+ ```json
108
+ {
109
+ "engines": { "node": ">=20.0.0", "pnpm": ">=10.0.0" }
110
+ }
111
+ ```
112
+
113
+ By default `engines` is advisory (warns, does not fail). `engine-strict=true` in `.npmrc` makes it a hard error on install.
114
+
115
+ ### `bin`
116
+
117
+ Maps CLI command names to file paths. The published tarball will mark these executable; the install will create symlinks in `node_modules/.bin`:
118
+
119
+ ```json
120
+ {
121
+ "bin": { "codebyplan": "./dist/cli.js" }
122
+ }
123
+ ```
124
+
125
+ The target file must have a shebang (`#!/usr/bin/env node`).
126
+
127
+ ## `latest` Dist-Tag Semantics
128
+
129
+ When a user runs `npm install <pkg>` without a version specifier, npm resolves to whatever the `latest` dist-tag points at. Implications:
130
+
131
+ - The first publish of a package always becomes `latest`.
132
+ - Subsequent publishes become `latest` **unless** `--tag <name>` is passed (or `publishConfig.tag` is set to something other than `latest`).
133
+ - Publishing a hotfix to an older major (e.g. `1.5.3` after `2.0.0` is already `latest`) will overwrite `latest` to point back at `1.5.3` — almost always a mistake. Use `npm publish --tag legacy` for hotfixes on old majors, then `npm dist-tag add <pkg>@1.5.3 v1-legacy` to give consumers an explicit pointer.
134
+
135
+ Common dist-tag conventions:
136
+
137
+ | Tag | Convention |
138
+ |-----|-----------|
139
+ | `latest` | Default install target — stable releases only |
140
+ | `next` | Upcoming version (often release candidates) |
141
+ | `beta` / `alpha` | Prereleases — opt-in via `npm install pkg@beta` |
142
+ | `canary` / `nightly` | Auto-published from main branch |
143
+
144
+ Manage tags after publish:
145
+
146
+ ```bash
147
+ npm dist-tag ls <pkg> # list all tags
148
+ npm dist-tag add <pkg>@<ver> next # promote a version to a tag
149
+ npm dist-tag rm <pkg> beta # remove a tag (does not unpublish)
150
+ ```
151
+
152
+ Tags must not parse as valid semver ranges — `v1.4` is rejected, `v1-legacy` is fine.
153
+
154
+ ## Pre-Publish Checklist
155
+
156
+ For a clean publish via `/cbp-ship`:
157
+
158
+ 1. `npm whoami` (or OIDC trust verified) — confirm auth context.
159
+ 2. `npm publish --dry-run` — review the file list; nothing surprising.
160
+ 3. `npx publint` — lint package.json shape.
161
+ 4. `npx @arethetypeswrong/cli --pack` — verify type resolution across CJS/ESM.
162
+ 5. Version bump committed and tagged in git (release-please or changesets handles this).
163
+ 6. CI green on the commit being published.
164
+
165
+ ## Sources
166
+
167
+ - [npm Docs — package.json](https://docs.npmjs.com/cli/v10/configuring-npm/package-json)
168
+ - [npm Docs — npm publish](https://docs.npmjs.com/cli/v10/commands/npm-publish)
169
+ - [npm Docs — npm dist-tag](https://docs.npmjs.com/cli/v10/commands/npm-dist-tag)
170
+ - [npm Docs — Configuring 2FA](https://docs.npmjs.com/configuring-two-factor-authentication)
171
+ - [npm CLI source](https://github.com/npm/cli)
@@ -0,0 +1,88 @@
1
+ # Pre-flight Checklist
2
+
3
+ Run before invoking `/cbp-ship`. The orchestrator's Step 1 detection runs this implicitly; this file documents what it checks and what to do when a check fails.
4
+
5
+ ## Universal pre-flight (every shipment)
6
+
7
+ | # | Check | Why | If fails |
8
+ |---|---|---|---|
9
+ | 1 | `gh auth status` succeeds | gh CLI is needed for tag push, release verification | `gh auth login` |
10
+ | 2 | Working tree is clean (no uncommitted changes) | Shipping uncommitted code = ghosts | Commit or stash; do NOT proceed |
11
+ | 3 | Current branch matches expected post-promotion branch | Caller (`/cbp-checkpoint-end`) just merged into PRODUCTION | If wrong, `git checkout` correct branch |
12
+ | 4 | `.codebyplan/` files are parseable | All config reads from per-concern files | Fix JSON; or run `npx codebyplan config` |
13
+ | 5 | Active checkpoint exists in DB | Shipment is per-checkpoint | Run `/cbp-todo` to find/create checkpoint |
14
+ | 6 | `checkpoint.context.check_results` exists | Checkpoint check must pass before shipment | Run `/cbp-checkpoint-check` first |
15
+
16
+ ## Per-surface pre-flight
17
+
18
+ The detection script (`scripts/detect-surfaces.sh`) emits `configured: false` with a `reason` when a surface fails its pre-flight. Rather than duplicating those reasons here, see each surface's `## Configured indicators` section in its reference file.
19
+
20
+ Quick reference:
21
+
22
+ | Surface | Critical pre-flight check |
23
+ |---|---|
24
+ | `vercel-web` | `vercel whoami` succeeds AND `.vercel/project.json` exists |
25
+ | `expo-mobile` | `eas whoami` succeeds AND `eas.json` parseable AND credentials valid (`eas credentials` audit) |
26
+ | `tauri-desktop` | All 9 GH secrets present in repo (`gh secret list`) |
27
+ | `npm-package` | `npm whoami` succeeds AND 2FA enabled AND local version > registry version |
28
+ | `vscode-ext` | `vsce verify-pat <publisher>` succeeds |
29
+ | `railway-backend` | `railway whoami` succeeds AND service is linked AND env vars set |
30
+ | `supabase` | `supabase projects list` succeeds AND project ref matches |
31
+
32
+ ## Recommended pre-flight when adding a new surface
33
+
34
+ If you're configuring a surface for the first time (via `/cbp-ship-configure`), run these once:
35
+
36
+ 1. **For Vercel**:
37
+ - Verify build works locally: `pnpm build`
38
+ - Verify env vars are documented: `cat .env.example`
39
+ - Verify domain DNS is healthy if using custom domain
40
+
41
+ 2. **For Expo / mobile**:
42
+ - Verify Apple Developer account is enrolled (paid)
43
+ - Verify ASC API key is generated and `.p8` file is readable
44
+ - Verify EAS project is created: `eas project:info`
45
+ - Run a development build first: `eas build --profile development --platform ios`
46
+
47
+ 3. **For Tauri desktop**:
48
+ - Generate signing key: `npx tauri signer generate -w ~/.tauri/{app}.key`
49
+ - Export Apple Developer ID cert as `.p12`
50
+ - Upload all 9 GH secrets per architecture doc
51
+ - Test the workflow on a non-production tag first (e.g., `v0.0.0-test`)
52
+
53
+ 4. **For npm package**:
54
+ - Verify `package.json` has `name`, `version`, `description`, `keywords`, `repository`, `license`, `author`
55
+ - Run `npm pack --dry-run` and verify the tarball contains the right files
56
+ - Run `pnpm publint` to catch metadata issues
57
+ - Run `pnpm attw --pack` to verify TS types resolve correctly
58
+
59
+ 5. **For VS Code extension**:
60
+ - Create a publisher account at https://aka.ms/vscode-create-publisher
61
+ - Generate PAT with "Marketplace → Manage" scope
62
+ - Run `vsce verify-pat <publisher>` — succeeds = good
63
+ - Verify `package.json` has `displayName`, `description`, `categories`, `icon` (≥128×128 PNG)
64
+
65
+ 6. **For Railway**:
66
+ - Create project: `railway init`
67
+ - Link service: `railway link`
68
+ - Add env vars: `railway variables set KEY=VALUE`
69
+ - Configure health endpoint in service code (`/health` returning 200)
70
+ - Test deploy: `railway up`
71
+
72
+ 7. **For Supabase**:
73
+ - Verify migrations directory is initialized: `ls supabase/migrations/`
74
+ - Link project: `supabase link --project-ref <ref>`
75
+ - Generate baseline migration if existing schema: `supabase db dump > supabase/migrations/0000_baseline.sql`
76
+ - Verify types path: `supabase gen types typescript --project-id <ref> > types.ts`
77
+
78
+ ## When pre-flight fails mid-shipment
79
+
80
+ If `/cbp-ship` is mid-shipment and a per-surface pre-flight fails:
81
+
82
+ 1. Mark that surface failed
83
+ 2. Continue with remaining surfaces (don't halt the whole shipment unless `supabase` failed)
84
+ 3. Surface the failure in the final report
85
+ 4. Suggest the user run `/cbp-ship-configure --surface=<id>` to fix
86
+ 5. After fix, re-run `/cbp-ship` — it picks up where it left off (verified surfaces are skipped)
87
+
88
+ The shipment record (`checkpoint.context.shipment`) tracks per-surface status, so partial re-runs are safe.
@@ -0,0 +1,169 @@
1
+ # Railway — NestJS Deployment
2
+
3
+ Concrete walkthrough for the canonical CodeByPlan backend shape: a NestJS app in `apps/backend` of a pnpm/Turborepo monorepo, talking to Supabase, deployed to Railway via GitHub auto-deploys. Read [railway-overview.md](./railway-overview.md) first for concept-level context.
4
+
5
+ ## Build Strategy: Dockerfile vs Nixpacks/Railpack
6
+
7
+ Railway picks a builder in this order: **Dockerfile** at repo root (or `RAILWAY_DOCKERFILE_PATH`) → **Railpack** (Elixir, Ruby, Rust) → **Nixpacks** (auto-detect Node/Python/Go).
8
+
9
+ For CBP NestJS backends, **always use a Dockerfile**:
10
+
11
+ | Concern | Dockerfile | Nixpacks |
12
+ |---------|-----------|----------|
13
+ | Reproducible builds (pinned base) | Yes | Drifts on Nixpacks updates |
14
+ | pnpm workspace / monorepo | Explicit, scoped | Heuristics often misfire |
15
+ | Build caching | Predictable layers | Opaque |
16
+ | Multi-stage slim runtime | Easy | Not supported |
17
+ | Native deps (sharp, prisma) | Apt/apk control | Black-box failures |
18
+
19
+ The only case for Nixpacks is a single-package repo with no native deps — and CBP doesn't have any of those.
20
+
21
+ ## Canonical NestJS Dockerfile (pnpm + Turborepo)
22
+
23
+ Place at `apps/backend/Dockerfile`, set `RAILWAY_DOCKERFILE_PATH=apps/backend/Dockerfile` on the service. Build context is the repo root.
24
+
25
+ ```dockerfile
26
+ # syntax=docker/dockerfile:1.7
27
+
28
+ # ---- builder ----
29
+ FROM node:22-alpine AS builder
30
+ WORKDIR /repo
31
+ RUN corepack enable && corepack prepare pnpm@10.12.4 --activate
32
+
33
+ COPY pnpm-lock.yaml pnpm-workspace.yaml package.json turbo.json ./
34
+ COPY apps/backend/package.json ./apps/backend/
35
+ COPY packages/auth/package.json ./packages/auth/
36
+ COPY packages/design-tokens/package.json ./packages/design-tokens/
37
+
38
+ RUN --mount=type=cache,id=s/pnpm-store,target=/root/.local/share/pnpm/store \
39
+ pnpm install --frozen-lockfile
40
+
41
+ COPY . .
42
+ RUN pnpm turbo run build --filter=@codebyplan/backend...
43
+ RUN pnpm --filter=@codebyplan/backend deploy --prod /out
44
+
45
+ # ---- runtime ----
46
+ FROM node:22-alpine AS runtime
47
+ WORKDIR /app
48
+ ENV NODE_ENV=production
49
+ RUN apk add --no-cache tini
50
+
51
+ COPY --from=builder /out/node_modules ./node_modules
52
+ COPY --from=builder /out/dist ./dist
53
+ COPY --from=builder /out/package.json ./package.json
54
+
55
+ EXPOSE 3000
56
+ ENTRYPOINT ["/sbin/tini", "--"]
57
+ CMD ["node", "dist/main.js"]
58
+ ```
59
+
60
+ Notes: `--mount=type=cache,id=s/...` uses Railway's persistent build cache. `pnpm deploy --prod` produces a self-contained dir with hoisted prod deps (slim image). `tini` as PID 1 forwards SIGTERM cleanly so NestJS shuts down on rolling deploys. `EXPOSE 3000` is documentation only — Railway routes to whatever `$PORT` your process binds.
61
+
62
+ ## $PORT Binding
63
+
64
+ Railway assigns `PORT` per deployment. NestJS bootstrap MUST honour it:
65
+
66
+ ```ts
67
+ // apps/backend/src/main.ts
68
+ import { NestFactory } from '@nestjs/core';
69
+ import { AppModule } from './app.module';
70
+
71
+ async function bootstrap() {
72
+ const app = await NestFactory.create(AppModule);
73
+ app.enableShutdownHooks(); // pairs with tini in the Dockerfile
74
+ const port = parseInt(process.env.PORT ?? '3000', 10);
75
+ await app.listen(port, '0.0.0.0'); // 0.0.0.0, NOT localhost
76
+ }
77
+ bootstrap();
78
+ ```
79
+
80
+ Two extremely common failures: (1) listening on `localhost`/`127.0.0.1` — Railway's proxy can't reach you and the healthcheck times out; (2) hardcoding `3000` — works locally but Railway thinks the service never came up.
81
+
82
+ ## Health Endpoint
83
+
84
+ Configure per service: `Settings → Deploy → Healthcheck Path` (e.g. `/health`) and timeout (default 100s, max 300s). On failure the new deployment never replaces the old — old keeps serving, new is marked CRASHED.
85
+
86
+ Use `@nestjs/terminus`:
87
+
88
+ ```ts
89
+ // apps/backend/src/health/health.module.ts
90
+ import { Module } from '@nestjs/common';
91
+ import { TerminusModule } from '@nestjs/terminus';
92
+ import { HealthController } from './health.controller';
93
+
94
+ @Module({ imports: [TerminusModule], controllers: [HealthController] })
95
+ export class HealthModule {}
96
+ ```
97
+
98
+ ```ts
99
+ // apps/backend/src/health/health.controller.ts
100
+ import { Controller, Get } from '@nestjs/common';
101
+ import { HealthCheck, HealthCheckService, HttpHealthIndicator } from '@nestjs/terminus';
102
+
103
+ @Controller('health')
104
+ export class HealthController {
105
+ constructor(private health: HealthCheckService, private http: HttpHealthIndicator) {}
106
+
107
+ @Get()
108
+ @HealthCheck()
109
+ check() {
110
+ return this.health.check([
111
+ () => this.http.pingCheck('self', `http://localhost:${process.env.PORT ?? '3000'}/`),
112
+ ]);
113
+ }
114
+ }
115
+ ```
116
+
117
+ Keep healthchecks **cheap and dependency-free**. Don't ping Supabase here — a transient Supabase blip would mark every Railway deploy as failed and you'd be unable to ship. For "is my DB reachable" use a separate `/ready` endpoint that uptime monitors poll.
118
+
119
+ ## Env Var Management
120
+
121
+ Three layers: **service vars** (`Settings → Variables`, default home for secrets) → **shared vars** (project-level, referenced as `${{ shared.NAME }}`) → **reference vars** (pull from another service: `${{ Postgres.DATABASE_URL }}`).
122
+
123
+ CBP convention for a NestJS-on-Supabase backend:
124
+
125
+ ```
126
+ # Shared (project-level)
127
+ SUPABASE_URL=https://<project>.supabase.co
128
+ SUPABASE_ANON_KEY=...
129
+
130
+ # Service-only (api service)
131
+ SUPABASE_SERVICE_ROLE_KEY=... # never share — staging/prod must differ
132
+ SENTRY_DSN=...
133
+ NODE_ENV=production
134
+ ```
135
+
136
+ Rules: `NODE_ENV=production` always — even in staging (differentiate via `RAILWAY_ENVIRONMENT_NAME`). Never put service-role secrets in shared. Use the dashboard "raw editor" for bulk paste; the UI input strips trailing newlines and occasionally mangles `=` in values.
137
+
138
+ ## Multi-Service Projects
139
+
140
+ A typical CBP backend project:
141
+
142
+ | Service | Source | Purpose |
143
+ |---------|--------|---------|
144
+ | `api` | GitHub: `apps/backend` | NestJS HTTP API |
145
+ | `worker` | GitHub: `apps/backend` (different start cmd) | Queue/cron worker if needed |
146
+ | `postgres` | Railway template | Optional fallback DB (Supabase is primary) |
147
+
148
+ To run two services off one repo: create two services on the same GitHub repo, override `Settings → Deploy → Start Command` per service (`node dist/main.js` for api, `node dist/worker.js` for worker), set `RAILWAY_DOCKERFILE_PATH` the same on both.
149
+
150
+ Internal traffic uses `<service-name>.railway.internal:<port>` (IPv6) — no public hop, no egress cost.
151
+
152
+ ## Custom Domains
153
+
154
+ `Settings → Networking → Custom Domain → Add`. Railway provisions Let's Encrypt automatically. DNS: subdomain via `CNAME api → <generated>.up.railway.app`; apex via Railway's CNAME flattening / ALIAS, or buy the domain via Railway and it auto-wires.
155
+
156
+ CBP convention: production `api.codebyplan.com` → Railway production env's api service. Staging stays on the generated `up.railway.app` domain unless there's a reason for a real subdomain.
157
+
158
+ ## Build Caching
159
+
160
+ Two caches matter: (1) **layer cache** — Railway preserves Docker layers per service; order Dockerfile so manifest copy + install precedes source copy (canonical Dockerfile above does this); (2) **cache mounts** — `--mount=type=cache,id=s/<service id>-<path>,target=<path>` for pnpm store, npm cache. The `s/<service id>` prefix is Railway-specific and scopes the cache per service.
161
+
162
+ Clean rebuild (no cache): ~3-5 min for a typical CBP backend. Cached: ~30-60 sec — almost entirely the source COPY + turbo build steps.
163
+
164
+ ## Sources
165
+
166
+ - https://docs.railway.com/guides/dockerfiles
167
+ - https://docs.railway.com/guides/healthchecks
168
+ - https://docs.railway.com/guides/variables
169
+ - https://docs.railway.com/reference/private-networking
@@ -0,0 +1,120 @@
1
+ # Railway Overview
2
+
3
+ Railway (railway.com, formerly railway.app) is the standard backend deployment target for the CodeByPlan family of repos. The `/cbp-ship` orchestrator's `railway-backend` surface targets it for NestJS API services, scheduled workers, and any long-running process that doesn't belong on Vercel's edge/serverless surface.
4
+
5
+ ## What Railway Is
6
+
7
+ A platform-as-a-service that runs containers (or Nixpacks/Railpack-built images) from a GitHub repo or a CLI push. It handles:
8
+
9
+ - Build (Dockerfile, Nixpacks, or Railpack — auto-detected)
10
+ - Deploy (rolling, with healthcheck gating)
11
+ - Networking (public HTTPS endpoint + private `*.railway.internal` mesh)
12
+ - Env var management (per-service, per-environment, with shared groups)
13
+ - Logs / metrics / smart diagnosis
14
+
15
+ It is positioned as "Heroku, but you pay for what you use, with Docker as a first-class citizen."
16
+
17
+ ## When to Pick Railway (vs Alternatives)
18
+
19
+ | Need | Pick |
20
+ |------|------|
21
+ | Long-running NestJS API, scheduled job, queue worker | **Railway** |
22
+ | WebSocket server, gRPC, raw TCP | **Railway** |
23
+ | Edge-rendered Next.js, ISR-heavy site | **Vercel** |
24
+ | Static site / Jamstack with form handlers | **Vercel** or Netlify |
25
+ | Self-host on a single $5 box, no CI/CD | Render or Fly.io |
26
+ | Multi-region with Anycast and global edge state | **Fly.io** |
27
+ | Already on Supabase + need adjacent worker | **Railway** (best Supabase neighbour — same VPC-style flow) |
28
+
29
+ CodeByPlan's rule of thumb: **NestJS = Railway, Next.js web = Vercel**. The desktop and VS Code apps don't deploy to Railway at all.
30
+
31
+ ## Pricing Model (as of Apr 2026)
32
+
33
+ | Plan | Base | Includes | Usage |
34
+ |------|------|----------|-------|
35
+ | Hobby | $5/mo | $5 of usage credit | $0.000231/GB-hour RAM, $0.000463/vCPU-hour |
36
+ | Pro | $20/mo per seat | $20 of usage credit per seat | Same per-resource rates, no cap |
37
+ | Enterprise | Custom | SOC2, dedicated support | Custom |
38
+
39
+ The `$5/mo` Hobby fee **is** the $5 of usage — it's a credit, not a base + usage. A typical CBP NestJS backend (256 MB RAM, ~5% CPU avg) runs ~$3-4/mo, fitting inside Hobby.
40
+
41
+ Pro is required for: team seats, priority support, multi-region, committed spend discounts, Metal regions for production workloads.
42
+
43
+ See https://railway.com/pricing for the live rate card.
44
+
45
+ ## Key Concepts
46
+
47
+ ```
48
+ Project
49
+ └── Environment (e.g. production, staging, pr-42)
50
+ └── Service (e.g. api, worker, postgres)
51
+ └── Deployment (a build+release of one commit)
52
+ ```
53
+
54
+ - **Project** — top-level container; usually one per repo or one per app family. CBP convention: one project per backend repo.
55
+ - **Environment** — a parallel copy of all services in a project. `production` is created by default. PR environments are auto-spawned via the GitHub integration if enabled.
56
+ - **Service** — one running thing (an API, a worker, a managed Postgres). Each service has its own image, env vars, domain, replicas.
57
+ - **Deployment** — one build of one service. Railway keeps deployment history; you can roll back via the dashboard or `railway redeploy`.
58
+
59
+ ## CLI Auth Model
60
+
61
+ ```bash
62
+ npm i -g @railway/cli # or pnpm add -g @railway/cli
63
+ railway login # opens browser, OAuths against your Railway account
64
+ railway link # binds CWD to a project + environment + service
65
+ railway up # tar-up CWD and push as a one-off deployment
66
+ railway run -- <cmd> # run <cmd> with the linked service's env vars
67
+ railway logs # tail logs for the linked service
68
+ ```
69
+
70
+ `railway login --browserless` produces a pairing code for headless/CI environments. CI typically uses `RAILWAY_TOKEN` (project token, scoped to one project) instead — set it as an env var and skip `login` entirely.
71
+
72
+ The `.railway/` directory in CWD stores the link (project ID, environment, service). It is gitignored by default — do not commit it.
73
+
74
+ ## GitHub Auto-Deploys
75
+
76
+ Railway's GitHub integration is the production deploy path for every CBP backend. Mechanics:
77
+
78
+ 1. Connect the repo to the service via the dashboard (one-time).
79
+ 2. Pick a branch (CBP convention: `main` for production, `development` for staging if a staging environment exists).
80
+ 3. Every push to that branch triggers a build → healthcheck → swap.
81
+ 4. PRs against the configured branch can auto-spawn ephemeral environments (opt-in per project).
82
+
83
+ **Important:** the GitHub integration uses a webhook. If Railway shows "no deployment triggered" after a push, check the webhook delivery log on the GitHub side first — see [railway-troubleshooting.md](./railway-troubleshooting.md).
84
+
85
+ ## How `/cbp-ship` Uses Railway
86
+
87
+ The `railway-backend` surface in `/cbp-ship`:
88
+
89
+ 1. Confirms `apps/backend` (or whatever the NestJS app is) builds clean locally
90
+ 2. Runs the test suite tied to the backend
91
+ 3. Pushes the deploy branch (usually `main`) — Railway picks it up via webhook
92
+ 4. Polls `railway logs` (or the GraphQL API via `RAILWAY_TOKEN`) for the new deployment
93
+ 5. Verifies healthcheck passes and surfaces the deployment URL
94
+ 6. Records the deploy outcome (deployment ID + commit SHA) on the round/task record
95
+
96
+ The orchestrator does NOT call `railway up` directly for production — that bypasses the GitHub history and breaks rollback. CLI push is reserved for one-off debugging.
97
+
98
+ ## Recent Platform Changes Worth Knowing
99
+
100
+ (From https://railway.com/changelog — keep this short, prune when stale.)
101
+
102
+ - **Railway Metal** — dedicated-hardware regions, including EU (Amsterdam) and SE Asia, available on Pro+. Use for latency-sensitive prod.
103
+ - **Multi-region deployments** — single service can run replicas in multiple regions. Pro+.
104
+ - **One-click HA Postgres** — replicated managed Postgres without manual setup. Useful when CBP repos outgrow Supabase's free tier and want a Railway-native DB.
105
+ - **Buckets** — Railway-native object storage with CLI support. Alternative to S3/R2 when staying in-platform matters.
106
+ - **Railpack** — successor build system to Nixpacks for some languages (Elixir, Ruby, Rust). Auto-detected; no migration needed.
107
+ - **IPv6** — full IPv6 support across public + private networking.
108
+ - **Smart Diagnosis** — automated build/deploy failure analysis surfaced in the dashboard. Read its output before opening a support ticket.
109
+
110
+ ## Sources
111
+
112
+ - https://docs.railway.com — primary reference
113
+ - https://railway.com/changelog — platform updates
114
+ - https://railway.com/pricing — current rate card
115
+
116
+ ## See also
117
+
118
+ - [railway-nestjs-deployment.md](./railway-nestjs-deployment.md) — concrete CBP-shape walkthrough
119
+ - [railway-troubleshooting.md](./railway-troubleshooting.md) — failure-mode reference
120
+ - [surface-railway.md](./surface-railway.md) — `/cbp-ship` deploy steps for this surface