codebyplan 1.13.65 → 1.13.67

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 (300) hide show
  1. package/README.md +118 -75
  2. package/dist/__tests__/helpers.d.ts +22 -0
  3. package/dist/__tests__/helpers.d.ts.map +1 -0
  4. package/dist/ci-public.d.ts +20 -0
  5. package/dist/ci-public.d.ts.map +1 -0
  6. package/dist/ci.js +11 -2
  7. package/dist/cli/arch-map.d.ts +33 -0
  8. package/dist/cli/arch-map.d.ts.map +1 -0
  9. package/dist/cli/branch.d.ts +10 -0
  10. package/dist/cli/branch.d.ts.map +1 -0
  11. package/dist/cli/bump.d.ts +12 -0
  12. package/dist/cli/bump.d.ts.map +1 -0
  13. package/dist/cli/cd.d.ts +20 -0
  14. package/dist/cli/cd.d.ts.map +1 -0
  15. package/dist/cli/check.d.ts +30 -0
  16. package/dist/cli/check.d.ts.map +1 -0
  17. package/dist/cli/checkpoint.d.ts +17 -0
  18. package/dist/cli/checkpoint.d.ts.map +1 -0
  19. package/dist/cli/ci.d.ts +31 -0
  20. package/dist/cli/ci.d.ts.map +1 -0
  21. package/dist/cli/claude/__test-helpers__/expect-manifest.d.ts +7 -0
  22. package/dist/cli/claude/__test-helpers__/expect-manifest.d.ts.map +1 -0
  23. package/dist/cli/claude/__test-helpers__/tmp-fixture.d.ts +64 -0
  24. package/dist/cli/claude/__test-helpers__/tmp-fixture.d.ts.map +1 -0
  25. package/dist/cli/claude/audit-mode.d.ts +16 -0
  26. package/dist/cli/claude/audit-mode.d.ts.map +1 -0
  27. package/dist/cli/claude/generate.d.ts +23 -0
  28. package/dist/cli/claude/generate.d.ts.map +1 -0
  29. package/dist/cli/claude/install.d.ts +55 -0
  30. package/dist/cli/claude/install.d.ts.map +1 -0
  31. package/dist/cli/claude/migrate-memory.d.ts +117 -0
  32. package/dist/cli/claude/migrate-memory.d.ts.map +1 -0
  33. package/dist/cli/claude/readme.d.ts +28 -0
  34. package/dist/cli/claude/readme.d.ts.map +1 -0
  35. package/dist/cli/claude/status.d.ts +41 -0
  36. package/dist/cli/claude/status.d.ts.map +1 -0
  37. package/dist/cli/claude/uninstall.d.ts +21 -0
  38. package/dist/cli/claude/uninstall.d.ts.map +1 -0
  39. package/dist/cli/claude/update.d.ts +25 -0
  40. package/dist/cli/claude/update.d.ts.map +1 -0
  41. package/dist/cli/claude/verify-parity.d.ts +25 -0
  42. package/dist/cli/claude/verify-parity.d.ts.map +1 -0
  43. package/dist/cli/cleanup-plan-folders.d.ts +21 -0
  44. package/dist/cli/cleanup-plan-folders.d.ts.map +1 -0
  45. package/dist/cli/commit.d.ts +25 -0
  46. package/dist/cli/commit.d.ts.map +1 -0
  47. package/dist/cli/config.d.ts +50 -0
  48. package/dist/cli/config.d.ts.map +1 -0
  49. package/dist/cli/confirm.d.ts +9 -0
  50. package/dist/cli/confirm.d.ts.map +1 -0
  51. package/dist/cli/create-org.d.ts +9 -0
  52. package/dist/cli/create-org.d.ts.map +1 -0
  53. package/dist/cli/create-project.d.ts +10 -0
  54. package/dist/cli/create-project.d.ts.map +1 -0
  55. package/dist/cli/create-repo.d.ts +14 -0
  56. package/dist/cli/create-repo.d.ts.map +1 -0
  57. package/dist/cli/docs.d.ts +41 -0
  58. package/dist/cli/docs.d.ts.map +1 -0
  59. package/dist/cli/doctor.d.ts +17 -0
  60. package/dist/cli/doctor.d.ts.map +1 -0
  61. package/dist/cli/e2e/verify-round.d.ts +46 -0
  62. package/dist/cli/e2e/verify-round.d.ts.map +1 -0
  63. package/dist/cli/e2e.d.ts +11 -0
  64. package/dist/cli/e2e.d.ts.map +1 -0
  65. package/dist/cli/eslint.d.ts +20 -0
  66. package/dist/cli/eslint.d.ts.map +1 -0
  67. package/dist/cli/export-writer.d.ts +99 -0
  68. package/dist/cli/export-writer.d.ts.map +1 -0
  69. package/dist/cli/handoff.d.ts +13 -0
  70. package/dist/cli/handoff.d.ts.map +1 -0
  71. package/dist/cli/login.d.ts +10 -0
  72. package/dist/cli/login.d.ts.map +1 -0
  73. package/dist/cli/logout.d.ts +2 -0
  74. package/dist/cli/logout.d.ts.map +1 -0
  75. package/dist/cli/lsp.d.ts +16 -0
  76. package/dist/cli/lsp.d.ts.map +1 -0
  77. package/dist/cli/migration-collisions.d.ts +10 -0
  78. package/dist/cli/migration-collisions.d.ts.map +1 -0
  79. package/dist/cli/ports.d.ts +29 -0
  80. package/dist/cli/ports.d.ts.map +1 -0
  81. package/dist/cli/process-exit-signal.d.ts +24 -0
  82. package/dist/cli/process-exit-signal.d.ts.map +1 -0
  83. package/dist/cli/round.d.ts +79 -0
  84. package/dist/cli/round.d.ts.map +1 -0
  85. package/dist/cli/scaffold-publish-workflow.d.ts +16 -0
  86. package/dist/cli/scaffold-publish-workflow.d.ts.map +1 -0
  87. package/dist/cli/session/freshness-gate.d.ts +21 -0
  88. package/dist/cli/session/freshness-gate.d.ts.map +1 -0
  89. package/dist/cli/session/home-ff.d.ts +16 -0
  90. package/dist/cli/session/home-ff.d.ts.map +1 -0
  91. package/dist/cli/session/infra-files.d.ts +21 -0
  92. package/dist/cli/session/infra-files.d.ts.map +1 -0
  93. package/dist/cli/session/start.d.ts +70 -0
  94. package/dist/cli/session/start.d.ts.map +1 -0
  95. package/dist/cli/session.d.ts +17 -0
  96. package/dist/cli/session.d.ts.map +1 -0
  97. package/dist/cli/setup.d.ts +2 -0
  98. package/dist/cli/setup.d.ts.map +1 -0
  99. package/dist/cli/ship.d.ts +16 -0
  100. package/dist/cli/ship.d.ts.map +1 -0
  101. package/dist/cli/slug.d.ts +10 -0
  102. package/dist/cli/slug.d.ts.map +1 -0
  103. package/dist/cli/standalone-task.d.ts +31 -0
  104. package/dist/cli/standalone-task.d.ts.map +1 -0
  105. package/dist/cli/statusline.d.ts +10 -0
  106. package/dist/cli/statusline.d.ts.map +1 -0
  107. package/dist/cli/supabase/new-migration.d.ts +24 -0
  108. package/dist/cli/supabase/new-migration.d.ts.map +1 -0
  109. package/dist/cli/supabase/preview-check.d.ts +30 -0
  110. package/dist/cli/supabase/preview-check.d.ts.map +1 -0
  111. package/dist/cli/supabase/resolve-preview.d.ts +19 -0
  112. package/dist/cli/supabase/resolve-preview.d.ts.map +1 -0
  113. package/dist/cli/supabase/teardown-preview.d.ts +22 -0
  114. package/dist/cli/supabase/teardown-preview.d.ts.map +1 -0
  115. package/dist/cli/sync.d.ts +13 -0
  116. package/dist/cli/sync.d.ts.map +1 -0
  117. package/dist/cli/task.d.ts +17 -0
  118. package/dist/cli/task.d.ts.map +1 -0
  119. package/dist/cli/tech-stack.d.ts +11 -0
  120. package/dist/cli/tech-stack.d.ts.map +1 -0
  121. package/dist/cli/upgrade-auth.d.ts +2 -0
  122. package/dist/cli/upgrade-auth.d.ts.map +1 -0
  123. package/dist/cli/upload-e2e-images.d.ts +18 -0
  124. package/dist/cli/upload-e2e-images.d.ts.map +1 -0
  125. package/dist/cli/validate-waves.d.ts +22 -0
  126. package/dist/cli/validate-waves.d.ts.map +1 -0
  127. package/dist/cli/version-status.d.ts +42 -0
  128. package/dist/cli/version-status.d.ts.map +1 -0
  129. package/dist/cli/watch.d.ts +18 -0
  130. package/dist/cli/watch.d.ts.map +1 -0
  131. package/dist/cli/whoami.d.ts +5 -0
  132. package/dist/cli/whoami.d.ts.map +1 -0
  133. package/dist/cli/worktree/add.d.ts +81 -0
  134. package/dist/cli/worktree/add.d.ts.map +1 -0
  135. package/dist/cli/worktree/create.d.ts +46 -0
  136. package/dist/cli/worktree/create.d.ts.map +1 -0
  137. package/dist/cli/worktree/path.d.ts +19 -0
  138. package/dist/cli/worktree/path.d.ts.map +1 -0
  139. package/dist/cli/worktree/remove.d.ts +92 -0
  140. package/dist/cli/worktree/remove.d.ts.map +1 -0
  141. package/dist/cli/worktree.d.ts +15 -0
  142. package/dist/cli/worktree.d.ts.map +1 -0
  143. package/dist/cli.js +5697 -5322
  144. package/dist/dispatch.d.ts +64 -0
  145. package/dist/dispatch.d.ts.map +1 -0
  146. package/dist/index.d.ts +2 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/lib/agents-generator.d.ts +42 -0
  149. package/dist/lib/agents-generator.d.ts.map +1 -0
  150. package/dist/lib/api.d.ts +54 -0
  151. package/dist/lib/api.d.ts.map +1 -0
  152. package/dist/lib/atomic-write.d.ts +27 -0
  153. package/dist/lib/atomic-write.d.ts.map +1 -0
  154. package/dist/lib/branch-checkout.d.ts +47 -0
  155. package/dist/lib/branch-checkout.d.ts.map +1 -0
  156. package/dist/lib/branch-port-resolver.d.ts +58 -0
  157. package/dist/lib/branch-port-resolver.d.ts.map +1 -0
  158. package/dist/lib/bump.d.ts +97 -0
  159. package/dist/lib/bump.d.ts.map +1 -0
  160. package/dist/lib/cd-init.d.ts +86 -0
  161. package/dist/lib/cd-init.d.ts.map +1 -0
  162. package/dist/lib/check-baseline.d.ts +91 -0
  163. package/dist/lib/check-baseline.d.ts.map +1 -0
  164. package/dist/lib/check.d.ts +178 -0
  165. package/dist/lib/check.d.ts.map +1 -0
  166. package/dist/lib/ci-init.d.ts +106 -0
  167. package/dist/lib/ci-init.d.ts.map +1 -0
  168. package/dist/lib/ci-resolve.d.ts +60 -0
  169. package/dist/lib/ci-resolve.d.ts.map +1 -0
  170. package/dist/lib/claude-mode-audit.d.ts +41 -0
  171. package/dist/lib/claude-mode-audit.d.ts.map +1 -0
  172. package/dist/lib/claude-plan.d.ts +34 -0
  173. package/dist/lib/claude-plan.d.ts.map +1 -0
  174. package/dist/lib/commit-scope.d.ts +21 -0
  175. package/dist/lib/commit-scope.d.ts.map +1 -0
  176. package/dist/lib/e2e.d.ts +157 -0
  177. package/dist/lib/e2e.d.ts.map +1 -0
  178. package/dist/lib/eslint-generator.d.ts +86 -0
  179. package/dist/lib/eslint-generator.d.ts.map +1 -0
  180. package/dist/lib/file-lock.d.ts +44 -0
  181. package/dist/lib/file-lock.d.ts.map +1 -0
  182. package/dist/lib/flags.d.ts +115 -0
  183. package/dist/lib/flags.d.ts.map +1 -0
  184. package/dist/lib/gh-required-checks.d.ts +76 -0
  185. package/dist/lib/gh-required-checks.d.ts.map +1 -0
  186. package/dist/lib/git-utils.d.ts +46 -0
  187. package/dist/lib/git-utils.d.ts.map +1 -0
  188. package/dist/lib/gitignore-block.d.ts +32 -0
  189. package/dist/lib/gitignore-block.d.ts.map +1 -0
  190. package/dist/lib/gitignore-detect.d.ts +117 -0
  191. package/dist/lib/gitignore-detect.d.ts.map +1 -0
  192. package/dist/lib/handoff-file.d.ts +63 -0
  193. package/dist/lib/handoff-file.d.ts.map +1 -0
  194. package/dist/lib/hash.d.ts +9 -0
  195. package/dist/lib/hash.d.ts.map +1 -0
  196. package/dist/lib/lsp-detect.d.ts +42 -0
  197. package/dist/lib/lsp-detect.d.ts.map +1 -0
  198. package/dist/lib/manifest.d.ts +88 -0
  199. package/dist/lib/manifest.d.ts.map +1 -0
  200. package/dist/lib/mcp-client.d.ts +39 -0
  201. package/dist/lib/mcp-client.d.ts.map +1 -0
  202. package/dist/lib/migrate-branch-model.d.ts +34 -0
  203. package/dist/lib/migrate-branch-model.d.ts.map +1 -0
  204. package/dist/lib/migrate-local-config.d.ts +39 -0
  205. package/dist/lib/migrate-local-config.d.ts.map +1 -0
  206. package/dist/lib/migration-collisions.d.ts +61 -0
  207. package/dist/lib/migration-collisions.d.ts.map +1 -0
  208. package/dist/lib/port-verify.d.ts +73 -0
  209. package/dist/lib/port-verify.d.ts.map +1 -0
  210. package/dist/lib/prompt.d.ts +41 -0
  211. package/dist/lib/prompt.d.ts.map +1 -0
  212. package/dist/lib/readme-generator.d.ts +108 -0
  213. package/dist/lib/readme-generator.d.ts.map +1 -0
  214. package/dist/lib/repo-reader.d.ts +59 -0
  215. package/dist/lib/repo-reader.d.ts.map +1 -0
  216. package/dist/lib/scaffold-cd-workflow.d.ts +48 -0
  217. package/dist/lib/scaffold-cd-workflow.d.ts.map +1 -0
  218. package/dist/lib/scaffold-ci-workflow.d.ts +83 -0
  219. package/dist/lib/scaffold-ci-workflow.d.ts.map +1 -0
  220. package/dist/lib/scaffold-publish-workflow.d.ts +48 -0
  221. package/dist/lib/scaffold-publish-workflow.d.ts.map +1 -0
  222. package/dist/lib/server-detect.d.ts +20 -0
  223. package/dist/lib/server-detect.d.ts.map +1 -0
  224. package/dist/lib/session.d.ts +371 -0
  225. package/dist/lib/session.d.ts.map +1 -0
  226. package/dist/lib/settings-merge.d.ts +268 -0
  227. package/dist/lib/settings-merge.d.ts.map +1 -0
  228. package/dist/lib/ship.d.ts +84 -0
  229. package/dist/lib/ship.d.ts.map +1 -0
  230. package/dist/lib/slug.d.ts +26 -0
  231. package/dist/lib/slug.d.ts.map +1 -0
  232. package/dist/lib/spawn.d.ts +12 -0
  233. package/dist/lib/spawn.d.ts.map +1 -0
  234. package/dist/lib/state-client.d.ts +54 -0
  235. package/dist/lib/state-client.d.ts.map +1 -0
  236. package/dist/lib/state-store.d.ts +153 -0
  237. package/dist/lib/state-store.d.ts.map +1 -0
  238. package/dist/lib/state-sync.d.ts +101 -0
  239. package/dist/lib/state-sync.d.ts.map +1 -0
  240. package/dist/lib/statusline-config.d.ts +55 -0
  241. package/dist/lib/statusline-config.d.ts.map +1 -0
  242. package/dist/lib/structure-generator.d.ts +63 -0
  243. package/dist/lib/structure-generator.d.ts.map +1 -0
  244. package/dist/lib/supabase.d.ts +87 -0
  245. package/dist/lib/supabase.d.ts.map +1 -0
  246. package/dist/lib/sync-approvals.d.ts +108 -0
  247. package/dist/lib/sync-approvals.d.ts.map +1 -0
  248. package/dist/lib/tech-detect.d.ts +77 -0
  249. package/dist/lib/tech-detect.d.ts.map +1 -0
  250. package/dist/lib/template-walker.d.ts +26 -0
  251. package/dist/lib/template-walker.d.ts.map +1 -0
  252. package/dist/lib/templates-dir.d.ts +25 -0
  253. package/dist/lib/templates-dir.d.ts.map +1 -0
  254. package/dist/lib/types.d.ts +843 -0
  255. package/dist/lib/types.d.ts.map +1 -0
  256. package/dist/lib/validate-waves.d.ts +38 -0
  257. package/dist/lib/validate-waves.d.ts.map +1 -0
  258. package/dist/lib/verify-parity.d.ts +154 -0
  259. package/dist/lib/verify-parity.d.ts.map +1 -0
  260. package/dist/lib/version.d.ts +3 -0
  261. package/dist/lib/version.d.ts.map +1 -0
  262. package/dist/lib/watch-daemon.d.ts +114 -0
  263. package/dist/lib/watch-daemon.d.ts.map +1 -0
  264. package/dist/lib/worktree.d.ts +56 -0
  265. package/dist/lib/worktree.d.ts.map +1 -0
  266. package/dist/oauth/browser.d.ts +8 -0
  267. package/dist/oauth/browser.d.ts.map +1 -0
  268. package/dist/oauth/client-registration.d.ts +16 -0
  269. package/dist/oauth/client-registration.d.ts.map +1 -0
  270. package/dist/oauth/device-flow.d.ts +40 -0
  271. package/dist/oauth/device-flow.d.ts.map +1 -0
  272. package/dist/oauth/jwt-decode.d.ts +10 -0
  273. package/dist/oauth/jwt-decode.d.ts.map +1 -0
  274. package/dist/oauth/keychain.d.ts +17 -0
  275. package/dist/oauth/keychain.d.ts.map +1 -0
  276. package/dist/oauth/token-refresh.d.ts +7 -0
  277. package/dist/oauth/token-refresh.d.ts.map +1 -0
  278. package/dist/oauth/types.d.ts +28 -0
  279. package/dist/oauth/types.d.ts.map +1 -0
  280. package/dist/oauth/urls.d.ts +16 -0
  281. package/dist/oauth/urls.d.ts.map +1 -0
  282. package/package.json +5 -6
  283. package/templates/agents/cbp-security-agent.md +0 -1
  284. package/templates/agents/cbp-stripe-agent.md +0 -1
  285. package/templates/agents/cbp-testing-qa-agent.md +0 -1
  286. package/templates/hooks/cbp-skill-context-guard.sh +0 -1
  287. package/templates/hooks/cbp-test-hooks.sh +0 -81
  288. package/templates/hooks/validate-structure-lib.sh +36 -9
  289. package/templates/rules/cbp-operating-gotchas.md +8 -10
  290. package/templates/rules/todo-backend.md +4 -2
  291. package/templates/skills/cbp-build-cc-settings/reference/cbp-permission-policy.md +3 -3
  292. package/templates/skills/cbp-checkpoint-check/SKILL.md +0 -1
  293. package/templates/skills/cbp-checkpoint-end/SKILL.md +11 -5
  294. package/templates/skills/cbp-clear-continue/SKILL.md +0 -1
  295. package/templates/skills/cbp-clear-prep/SKILL.md +0 -1
  296. package/templates/skills/cbp-finalize/SKILL.md +2 -2
  297. package/templates/skills/cbp-setup-cd/SKILL.md +0 -1
  298. package/templates/skills/cbp-setup-ci/SKILL.md +0 -1
  299. package/templates/skills/cbp-standalone-task-complete/SKILL.md +40 -0
  300. package/templates/skills/cbp-stripe/SKILL.md +0 -1
@@ -0,0 +1,64 @@
1
+ /**
2
+ * CLI command dispatch.
3
+ *
4
+ * A single `COMMANDS` table maps each top-level command to a lazy handler, and
5
+ * one `runCli` wrapper owns the cross-cutting concerns that the previous
6
+ * 44-branch if/else router got subtly wrong per-branch:
7
+ * - exit codes ALWAYS honor `process.exitCode` (a handler that fails by
8
+ * setting `process.exitCode = 1` and returning is never masked as exit 0),
9
+ * - a top-level try/catch turns an unexpected throw into a friendly one-line
10
+ * error (full stack only with --verbose / DEBUG=1) instead of a raw trace,
11
+ * - `--help` / `-h` is intercepted uniformly so a command never runs its
12
+ * (possibly destructive) side effects when the user only asked for help.
13
+ *
14
+ * Handlers keep the lazy dynamic-import pattern so the CLI startup cost stays
15
+ * proportional to the one command being run.
16
+ *
17
+ * `runCli` takes its command table and process bindings (exit/log/error/env) as
18
+ * parameters so the routing + exit-code + help behavior is unit-testable
19
+ * without spawning a process — see dispatch.test.ts.
20
+ */
21
+ type CommandResult = number | void;
22
+ export type CommandHandler = (rest: string[]) => Promise<CommandResult> | CommandResult;
23
+ export interface Command {
24
+ run: CommandHandler;
25
+ /**
26
+ * The command renders its own `--help` (e.g. a sub-command router with a rich
27
+ * usage block). When true, `runCli` does NOT intercept `--help`; the handler
28
+ * is responsible for it. Only `claude` and `supabase` set this.
29
+ */
30
+ ownsHelp?: boolean;
31
+ }
32
+ export declare const COMMANDS: Record<string, Command>;
33
+ export interface RunCliDeps {
34
+ /** Terminate the process. Defaults to `process.exit`. */
35
+ exit?: (code: number) => never;
36
+ log?: (msg: string) => void;
37
+ error?: (msg: string) => void;
38
+ env?: NodeJS.ProcessEnv;
39
+ /** Read the ambient deferred exit code. Defaults to `() => process.exitCode`. */
40
+ getExitCode?: () => number | undefined;
41
+ }
42
+ /**
43
+ * Resolve a command from `argv` and run it under uniform exit-code, error, and
44
+ * `--help` handling.
45
+ */
46
+ export declare function runCli(argv: string[], commands?: Record<string, Command>, deps?: RunCliDeps): Promise<void>;
47
+ interface ClaudeParsedFlags {
48
+ opts: {
49
+ yes: boolean;
50
+ dryRun: boolean;
51
+ verbose: boolean;
52
+ scope: "user" | "project";
53
+ renderer?: "bash" | "node" | "python";
54
+ };
55
+ projectDir: string | null;
56
+ }
57
+ /**
58
+ * Parse flags from the `claude` sub-command argv tail (everything from the
59
+ * sub-command name onward). Order-insensitive; unknown flags are ignored for
60
+ * forward compatibility. Returns `null` (and writes to stderr) on a conflict.
61
+ */
62
+ export declare function parseClaudeFlags(rest: string[]): ClaudeParsedFlags | null;
63
+ export {};
64
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,KAAK,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC;AAEnC,MAAM,MAAM,cAAc,GAAG,CAC3B,IAAI,EAAE,MAAM,EAAE,KACX,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC;AAE5C,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,cAAc,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAMD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAqS5C,CAAC;AAMF,MAAM,WAAW,UAAU;IACzB,yDAAyD;IACzD,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;IAC/B,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAY,EAC5C,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,IAAI,CAAC,CAwDf;AAMD,UAAU,iBAAiB;IACzB,IAAI,EAAE;QACJ,GAAG,EAAE,OAAO,CAAC;QACb,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;KACvC,CAAC;IACF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,iBAAiB,GAAG,IAAI,CA2DzE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Pure, side-effect-free library for generating AGENTS.md — the cross-tool
3
+ * bridge that inlines repo structure context for non-Claude coding agents
4
+ * (Cursor, Copilot, etc.).
5
+ *
6
+ * Source of truth: .claude/CLAUDE.md (the canonical Claude Code context).
7
+ * This file is generated for cross-tool compatibility only — hand-edits
8
+ * will be overwritten on the next `codebyplan claude generate`.
9
+ *
10
+ * Uses the same managed-marker + drift-hash machinery as readme-generator.ts:
11
+ * <!-- codebyplan:managed:start:agents-context -->
12
+ * ...content...
13
+ * <!-- codebyplan:managed:end:agents-context -->
14
+ * <!-- codebyplan:hash:sha256:... -->
15
+ *
16
+ * DETERMINISTIC: no I/O, no Date.now/random.
17
+ * Two calls with identical structureContent produce byte-identical output.
18
+ */
19
+ /** The managed section name used for the agents context block. */
20
+ export declare const AGENTS_SECTION_NAME = "agents-context";
21
+ /**
22
+ * Generate the full AGENTS.md file content from structure.md output.
23
+ *
24
+ * Accepts the raw string produced by `generateStructureMd` (including its
25
+ * `<!-- @codebyplan-generated: structure start/end -->` sentinels). The
26
+ * sentinels are stripped before embedding; the clean markdown is inlined into
27
+ * a hardcoded curated-guidance template.
28
+ *
29
+ * The returned string is the COMPLETE file content — write it directly to
30
+ * `{rootDir}/AGENTS.md` with no further transformation.
31
+ *
32
+ * DETERMINISTIC — no I/O, no Date.now/random.
33
+ */
34
+ export declare function generateAgentsMd(structureContent: string): string;
35
+ /**
36
+ * Extract the current drift hash from AGENTS.md content, or null if absent.
37
+ *
38
+ * Thin alias of `extractManagedHash` kept for API stability.
39
+ * Delegates to the canonical implementation in readme-generator.ts.
40
+ */
41
+ export declare function extractAgentsHash(content: string): string | null;
42
+ //# sourceMappingURL=agents-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents-generator.d.ts","sourceRoot":"","sources":["../../src/lib/agents-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAeH,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAyGpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAsBjE;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEhE"}
@@ -0,0 +1,54 @@
1
+ export declare class ApiError extends Error {
2
+ status: number;
3
+ code?: string;
4
+ constructor(message: string, status: number, code?: string);
5
+ }
6
+ /**
7
+ * Validate that a legacy CODEBYPLAN_API_KEY is present in the environment.
8
+ * Synchronous; does NOT check OAuth tokens.
9
+ *
10
+ * @deprecated Prefer {@link validateAuth} for new callers — it accepts OAuth
11
+ * bearer tokens as well as the legacy API key, so it works for all
12
+ * authenticated users. validateApiKey() is kept for callers that explicitly
13
+ * require a legacy env-key check. No internal callers remain as of CHK-160
14
+ * (every CLI command now uses validateAuth); retained as a public export for
15
+ * external consumers pinned to the legacy flow — removal candidate in a future
16
+ * major version.
17
+ */
18
+ export declare function validateApiKey(): void;
19
+ /**
20
+ * OAuth-aware auth pre-check. Resolves when EITHER an OAuth bearer token
21
+ * (getAccessToken) OR a legacy CODEBYPLAN_API_KEY is available; throws
22
+ * noAuthHint() when neither is present. Prefer this over validateApiKey()
23
+ * for commands that should work for OAuth-authenticated users.
24
+ *
25
+ * Implementation note: this delegates to getAuthHeaders() purely as a
26
+ * fail-fast pre-check and discards the headers. The subsequent apiGet/apiPost
27
+ * calls invoke getAuthHeaders() again, so getAccessToken() runs twice per
28
+ * command — this is intentional and cheap: token-refresh caches the resolved
29
+ * access token, so the second call is a cache hit (no double network refresh).
30
+ * Do NOT "optimise" this away by removing the pre-check; the early throw is
31
+ * what gives commands a clean "Not authenticated" message before any work.
32
+ * Note it does NOT swallow non-NoTokenError failures — getAuthHeaders rethrows
33
+ * those (e.g. a network error during refresh), so validateAuth surfaces them.
34
+ */
35
+ export declare function validateAuth(): Promise<void>;
36
+ interface AuthHeaders {
37
+ headers: Record<string, string>;
38
+ via: "bearer" | "api_key";
39
+ }
40
+ export declare function getAuthHeaders(): Promise<AuthHeaders>;
41
+ export declare function validateConnectivity(): Promise<void>;
42
+ export declare function apiGet<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
43
+ export declare function apiPost<T>(path: string, body: unknown): Promise<T>;
44
+ export declare function apiPut<T>(path: string, body: unknown): Promise<T>;
45
+ export declare function apiPatch<T>(path: string, body: unknown): Promise<T>;
46
+ export declare function apiDelete(path: string, params?: Record<string, string | undefined>): Promise<void>;
47
+ /**
48
+ * Call an MCP tool via JSON-RPC 2.0 over HTTP. Best-effort — callers should
49
+ * wrap in try/catch and treat failures as non-blocking (used for fire-and-
50
+ * forget enqueue_todo_job and bind_worktree_user from CLI sync paths).
51
+ */
52
+ export declare function callMcpTool(toolName: string, params: Record<string, unknown>): Promise<unknown>;
53
+ export {};
54
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAQA,qBAAa,QAAS,SAAQ,KAAK;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAM3D;AAqBD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAIrC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD;AAED,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,GAAG,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC3B;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAgB3D;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiC1D;AAuGD,wBAAsB,MAAM,CAAC,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC1C,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,wBAAsB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAExE;AAED,wBAAsB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAEvE;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAEzE;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAsClB"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Shared atomic JSON-write utility.
3
+ *
4
+ * Used by ci-init.ts, gh-required-checks.ts, and the OAuth credential store to
5
+ * write JSON files to disk atomically via a tmp-file rename, ensuring no partial
6
+ * or corrupt writes are left behind if the process is interrupted or the write
7
+ * fails.
8
+ */
9
+ export interface WriteJsonAtomicOptions {
10
+ /**
11
+ * POSIX file mode to apply to the file (e.g. `0o600` for credentials). Applied
12
+ * at tmp-file creation (and re-asserted before the rename), so the bytes never
13
+ * sit world-readable and the final file is never briefly world-readable.
14
+ * Ignored on win32. When omitted, the file inherits the default umask-derived mode.
15
+ */
16
+ mode?: number;
17
+ }
18
+ /**
19
+ * Write `value` as pretty JSON to `filePath` atomically (tmp + rename),
20
+ * removing the tmp file if the write fails so no stale `.tmp` artefact is left.
21
+ *
22
+ * Pass `opts.mode` to set the final file's permissions atomically (chmod the
23
+ * tmp file before the rename) — used by the credential store to keep
24
+ * `credentials.json` at `0600` even across a torn write.
25
+ */
26
+ export declare function writeJsonAtomic(filePath: string, value: unknown, opts?: WriteJsonAtomicOptions): void;
27
+ //# sourceMappingURL=atomic-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomic-write.d.ts","sourceRoot":"","sources":["../../src/lib/atomic-write.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,sBAA2B,GAChC,IAAI,CA2BN"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Deterministic branch checkout helper.
3
+ *
4
+ * Replicates cbp-task-start Step 3.3 (branch auto-handling) so the behaviour
5
+ * is testable, versionable, and available in every consumer repo via the
6
+ * codebyplan npm package.
7
+ *
8
+ * All git operations accept an injectable RunFn so tests never touch the
9
+ * real filesystem or git. No top-level side effects.
10
+ */
11
+ /** Synchronous command runner — returns stdout on success, throws on non-zero exit. */
12
+ export type RunFn = (cmd: string, args: string[]) => string;
13
+ export type CheckoutAction = "checked_out_local" | "checked_out_tracking" | "created_from_production" | "error";
14
+ export interface CheckoutBranchOpts {
15
+ /** Branch to switch to (required). */
16
+ target: string;
17
+ /** Production branch to create from when target doesn't exist. Defaults to readGitConfig().production. */
18
+ production?: string;
19
+ /** Skip `git fetch origin <production>` before creating from production. Useful in tests / offline. */
20
+ skipFetch?: boolean;
21
+ /** Working directory for git commands. Defaults to process.cwd(). */
22
+ cwd?: string;
23
+ /** Injectable git runner. */
24
+ run?: RunFn;
25
+ }
26
+ export interface CheckoutBranchResult {
27
+ action: CheckoutAction;
28
+ branch: string;
29
+ /** Branch that was active before the switch (undefined when action is 'error'). */
30
+ previous?: string;
31
+ /** Raw git stderr when action is 'error'. */
32
+ error?: string;
33
+ }
34
+ /**
35
+ * Switch to `target` branch using the same three-case logic as cbp-task-start Step 3.3:
36
+ *
37
+ * (a) target exists locally → git checkout target
38
+ * (b) target exists on origin → git checkout -t origin/target
39
+ * (c) otherwise → git fetch origin <production> (best-effort), then
40
+ * git checkout -b target origin/<production>
41
+ * fallback: git checkout -b target <production>
42
+ *
43
+ * Captures `previous` branch before switching.
44
+ * Non-zero checkout exit (e.g. "would clobber") → action 'error' with raw stderr verbatim.
45
+ */
46
+ export declare function checkoutBranch(opts: CheckoutBranchOpts): CheckoutBranchResult;
47
+ //# sourceMappingURL=branch-checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-checkout.d.ts","sourceRoot":"","sources":["../../src/lib/branch-checkout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,uFAAuF;AACvF,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;AAE5D,MAAM,MAAM,cAAc,GACtB,mBAAmB,GACnB,sBAAsB,GACtB,yBAAyB,GACzB,OAAO,CAAC;AAEZ,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,0GAA0G;IAC1G,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uGAAuG;IACvG,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,oBAAoB,CAoG7E"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Branch-based port-allocation resolver.
3
+ *
4
+ * Replaces the deleted worktree-port-resolver.ts (CHK-225 TASK-3).
5
+ * Instead of resolving a worktree_id via device+path+branch tuple, this helper
6
+ * derives the current git branch and filters port_allocations by their `branch`
7
+ * column (a new column added in CHK-225). The server does not yet support
8
+ * server-side branch filtering, so we fetch all allocations for the repo and
9
+ * filter client-side. NULL branch rows are treated as no-match.
10
+ *
11
+ * ALLOWED_FIELDS is the canonical projection allowlist for the
12
+ * port-allocation rows written to .codebyplan/server.local.json.
13
+ * Previously it lived in worktree-port-resolver.ts; types.ts ServerLocalConfig
14
+ * JSDoc now points here.
15
+ *
16
+ * Used by:
17
+ * src/cli/ports.ts — codebyplan ports --write-local
18
+ * src/cli/config.ts — codebyplan config (server.json port overlay)
19
+ */
20
+ import type { PortAllocation } from "./types.js";
21
+ /**
22
+ * Page-size hint when fetching all allocations for a repo.
23
+ * Kept large enough that paginated truncation is unlikely in practice.
24
+ */
25
+ export declare const PORT_ALLOCATIONS_FETCH_LIMIT = "500";
26
+ /**
27
+ * Canonical field allowlist for port-allocation rows written to local config.
28
+ * Single source of truth — ServerLocalConfig.port_allocations is typed as
29
+ * Partial<PortAllocation>[] to reflect that only these fields are present.
30
+ */
31
+ export declare const ALLOWED_FIELDS: readonly ["id", "repo_id", "port", "label", "server_type", "auto_start", "command", "working_dir", "env_vars", "external_refs", "worktree_id", "created_at", "updated_at"];
32
+ export interface BranchPortResolution {
33
+ /** The current git branch (empty string when unavailable). */
34
+ currentBranch: string;
35
+ /** Allowlist-projected allocations whose branch matches the current branch. */
36
+ portAllocations: Partial<PortAllocation>[];
37
+ /** First matching allocation, or undefined when none matched. */
38
+ matchingAlloc: Partial<PortAllocation> | undefined;
39
+ }
40
+ /**
41
+ * Resolve port allocations for the current git branch.
42
+ *
43
+ * Semantics:
44
+ * 1. Read the current git branch (fall back to "" on detached HEAD / non-repo).
45
+ * 2. Fetch GET /port-allocations?repo_id={repoId}&limit=500.
46
+ * 3. Filter client-side: keep rows whose `branch` field === currentBranch.
47
+ * Rows with NULL branch are treated as no-match.
48
+ * 4. Apply ALLOWED_FIELDS projection.
49
+ * 5. matchingAlloc = portAllocations[0].
50
+ *
51
+ * API failure (step 2) is warn-and-continue: returns empty portAllocations,
52
+ * undefined matchingAlloc. Never throws.
53
+ *
54
+ * @param repoId Repo UUID (from .codebyplan/repo.json or env)
55
+ * @param projectPath Absolute path to the project root
56
+ */
57
+ export declare function resolveBranchPortAllocations(repoId: string, projectPath: string): Promise<BranchPortResolution>;
58
+ //# sourceMappingURL=branch-port-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-port-resolver.d.ts","sourceRoot":"","sources":["../../src/lib/branch-port-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAQ,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,cAAc,4KAcjB,CAAC;AAMX,MAAM,WAAW,oBAAoB;IACnC,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,eAAe,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;IAC3C,iEAAiE;IACjE,aAAa,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;CACpD;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,oBAAoB,CAAC,CA6C/B"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Changed-package detection + patch-bump engine.
3
+ *
4
+ * Repo-agnostic: works in any pnpm-workspace consuming repo, not just this
5
+ * monorepo. Reads pnpm-workspace.yaml globs, maps git-changed files to their
6
+ * owning packages, patch-bumps version files, and prepends CHANGELOG entries.
7
+ *
8
+ * Does NOT commit or push — pure version-file + changelog edits.
9
+ * Idempotent: skips packages whose working-tree version already exceeds base.
10
+ */
11
+ export type BumpOptions = {
12
+ /** Override cwd for testing. Default: process.cwd(). */
13
+ cwd?: string;
14
+ /** If true, compute bumps but do NOT write any files. */
15
+ dryRun?: boolean;
16
+ /** Injectable date string for CHANGELOG entries (YYYY-MM-DD). Default: today. */
17
+ now?: string;
18
+ /**
19
+ * When set, cut or iterate a prerelease with this identifier (e.g. "beta", "rc").
20
+ * X.Y.Z → X.(Y+1).0-{id}.1; X.(Y+1).0-{id}.N → X.(Y+1).0-{id}.N+1.
21
+ * Bypasses the compareSemver idempotency guard so that a working-tree prerelease
22
+ * version that already exceeds the stable base is still incremented.
23
+ */
24
+ prereleaseId?: string;
25
+ };
26
+ export type BumpEntry = {
27
+ /** Workspace package name (from package.json `name` field, or the dir path). */
28
+ name: string;
29
+ /** Absolute path to the package directory. */
30
+ packageDir: string;
31
+ /** Current (working-tree) version, before bump. */
32
+ currentVersion: string;
33
+ /** Next (patch-bumped) version. */
34
+ nextVersion: string;
35
+ /** Relative paths of the version files that were updated. */
36
+ versionFiles: string[];
37
+ /** Relative paths of version-file candidates that had no version field and were skipped. */
38
+ skippedVersionFiles?: string[];
39
+ /** Whether the CHANGELOG was updated. */
40
+ changelogUpdated: boolean;
41
+ /** Whether this entry was a no-op (already bumped / idempotent). */
42
+ skipped: boolean;
43
+ /** Human-readable reason for skipping (present when skipped=true). */
44
+ skipReason?: string;
45
+ };
46
+ export type BumpResult = {
47
+ /** Configured base branch NAME from .codebyplan/git.json (e.g. "main"). */
48
+ baseBranch: string;
49
+ /** The git ref actually compared against (e.g. "origin/main" when it exists). */
50
+ baseRef: string;
51
+ entries: BumpEntry[];
52
+ /** true when dryRun=true (files NOT written). */
53
+ dryRun: boolean;
54
+ };
55
+ /**
56
+ * Patch-bump a semver string: increment the LAST numeric segment.
57
+ * Examples:
58
+ * 1.2.3 → 1.2.4
59
+ * 1.2.3-beta.4 → 1.2.4 (pre-release: bump the patch segment, drop pre-release tag)
60
+ * 0.0.1 → 0.0.2
61
+ */
62
+ export declare function patchBump(version: string): string;
63
+ /**
64
+ * Prerelease-bump a semver string.
65
+ *
66
+ * Rules (id = the caller-supplied identifier, e.g. "beta", "rc"):
67
+ * - version carries `-{id}.{N}` with matching id → increment N.
68
+ * e.g. "1.14.0-beta.1", "beta" → "1.14.0-beta.2"
69
+ * - version carries bare `-{id}` with no number → append ".1".
70
+ * e.g. "1.14.0-beta", "beta" → "1.14.0-beta.1"
71
+ * - version is stable OR carries a DIFFERENT id → minor-bump the numeric
72
+ * core (major.(minor+1).0) and append -{id}.1.
73
+ * e.g. "1.13.40", "beta" → "1.14.0-beta.1"
74
+ * "1.14.0-beta.3", "rc" → "1.15.0-rc.1"
75
+ * Preserves a leading "v" prefix (same contract as patchBump).
76
+ * Non-semver / unrecognisable input → returned unchanged.
77
+ */
78
+ export declare function prereleaseBump(version: string, id: string): string;
79
+ /**
80
+ * Compare two semver strings. Returns positive if a > b, 0 if equal, negative if a < b.
81
+ * Handles:
82
+ * - Leading "v" prefix (stripped before comparison)
83
+ * - Pre-release suffixes (e.g. "1.2.3-beta.1"): a pre-release ranks BELOW its release
84
+ * when numeric cores are equal (semver spec: 1.2.3-beta.1 < 1.2.3)
85
+ * - Non-semver strings: parseCore returns [-1,-1,-1] sentinel (distinct from real 0.0.0)
86
+ */
87
+ export declare function compareSemver(a: string, b: string): number;
88
+ /**
89
+ * Run the bump engine.
90
+ *
91
+ * 1. Resolve base branch from .codebyplan/git.json.
92
+ * 2. Compute git diff --name-only <base>...HEAD (three-dot / merge-base).
93
+ * 3. Map changed files to owning workspace packages.
94
+ * 4. For each changed package: check idempotency, patch-bump, update CHANGELOG.
95
+ */
96
+ export declare function runBump(opts?: BumpOptions): Promise<BumpResult>;
97
+ //# sourceMappingURL=bump.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bump.d.ts","sourceRoot":"","sources":["../../src/lib/bump.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,MAAM,MAAM,WAAW,GAAG;IACxB,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,4FAA4F;IAC5F,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,yCAAyC;IACzC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,iDAAiD;IACjD,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAiIF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAejD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CA2ClE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAsB1D;AAsGD;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAmNrE"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Library for `codebyplan cd init`.
3
+ *
4
+ * Reads `.codebyplan/shipment.json` to discover which CD surfaces are
5
+ * configured for this repo, builds a default CdConfig from the discovered
6
+ * surface keys, and writes it to `.codebyplan/cd.json`. Idempotent — deep-
7
+ * merges newly discovered surfaces into an existing config, never overwriting
8
+ * existing surface keys unless --force is set.
9
+ *
10
+ * Surface detection is policy-explicit (driven by shipment.json surface keys),
11
+ * NOT filesystem-inferred. This is the key difference from ci-init.ts which
12
+ * probes files/directories to detect platforms.
13
+ *
14
+ * Credential values are NEVER written — only env var NAMES are recorded.
15
+ */
16
+ import type { CdConfig, CdSurface } from "./types.js";
17
+ /**
18
+ * Default CD surface configuration per well-known surface slug.
19
+ *
20
+ * Credentials carry only the env-var NAMES that are conventionally expected
21
+ * for each surface — never actual secret values. Unknown surface slugs fall
22
+ * back to the `_default` entry.
23
+ */
24
+ export declare const SURFACE_DEFAULTS: Record<string, CdSurface>;
25
+ /**
26
+ * Read `.codebyplan/shipment.json` and return the set of surface keys defined
27
+ * under `shipment.surfaces`. Returns an empty array when the file is absent,
28
+ * malformed, or has no surfaces block.
29
+ *
30
+ * Surface keys from shipment.json may contain platform prefixes (e.g.
31
+ * "railway-todo-worker"). The function normalises them to well-known
32
+ * CdSurfaceId slugs when possible, otherwise keeps the raw key.
33
+ */
34
+ export declare function detectSurfaces(projectDir: string): string[];
35
+ /**
36
+ * Map a raw shipment.json surface key to a canonical CdSurfaceId (or keep the
37
+ * raw key when it does not match any well-known prefix).
38
+ *
39
+ * Matching rules (first match wins):
40
+ * - Exact match against a known CdSurfaceId → use it as-is.
41
+ * - Key starts with a known platform prefix (e.g. "railway-" → "railway",
42
+ * "vercel_" → "vercel") → return the prefix.
43
+ * - No match → return the raw key (custom surface).
44
+ */
45
+ export declare function normaliseSurfaceKey(key: string): string;
46
+ /**
47
+ * Build a default CdConfig from a list of raw shipment.json surface keys.
48
+ *
49
+ * Each key is normalised to a canonical CdSurfaceId before looking up the
50
+ * defaults. Unknown slugs fall back to DEFAULT_SURFACE.
51
+ */
52
+ export declare function buildDefaultCdConfig(rawSurfaceKeys: string[]): CdConfig;
53
+ export interface CdInitOptions {
54
+ /** If true, compute the operation but do NOT write any files. */
55
+ dryRun?: boolean;
56
+ /**
57
+ * If true, overwrite existing surface keys rather than deep-merging.
58
+ * Without --force, only NEW surfaces (not already in the config) are added.
59
+ */
60
+ force?: boolean;
61
+ /**
62
+ * Override the project root directory (default: process.cwd()).
63
+ */
64
+ projectDir?: string;
65
+ }
66
+ export interface CdInitResult {
67
+ /** `written` — file was created or updated. `skipped` — all surfaces already present.
68
+ * `dry_run` — computed what would change but wrote nothing. */
69
+ status: "written" | "skipped" | "dry_run";
70
+ /** Absolute path to `.codebyplan/cd.json`. */
71
+ path: string;
72
+ /**
73
+ * For `written`/`dry_run` — the detected (normalised) surface slugs.
74
+ * For `skipped` — the already-present surface slugs (no-op).
75
+ */
76
+ surfaces: string[];
77
+ }
78
+ /**
79
+ * Detect CD surfaces from `.codebyplan/shipment.json` and write (or update)
80
+ * `.codebyplan/cd.json`.
81
+ *
82
+ * Idempotent deep-merge: newly detected surfaces are added to the existing
83
+ * config; existing surface keys are left unchanged unless `force` is set.
84
+ */
85
+ export declare function runCdInit(opts?: CdInitOptions): Promise<CdInitResult>;
86
+ //# sourceMappingURL=cd-init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cd-init.d.ts","sourceRoot":"","sources":["../../src/lib/cd-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAOnE;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAmEtD,CAAC;AAeF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAuB3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAwBvD;AAMD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,QAAQ,CAqBvE;AAMD,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B;oEACgE;IAChE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC1C,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAMD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAyE3E"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Baseline file management for `codebyplan check`.
3
+ *
4
+ * The baseline records the set of known-failing packages per check (lint,
5
+ * typecheck, tests) and known GHSA advisory IDs for audit. A check only
6
+ * hard-fails when a NEW package fails (not in the baseline) or a NEW GHSA
7
+ * advisory appears (not in the allowlist).
8
+ *
9
+ * This module is deliberately PURE for diff/parse functions — no process
10
+ * spawning and disk I/O isolated to loadBaseline/saveBaseline so the logic
11
+ * can be unit-tested without disk.
12
+ */
13
+ export interface BaselineCheckEntry {
14
+ /** Package names (e.g. "@codebyplan/web") that are known to fail. */
15
+ known_failing: string[];
16
+ }
17
+ export interface BaselineFile {
18
+ lint: BaselineCheckEntry;
19
+ typecheck: BaselineCheckEntry;
20
+ tests: BaselineCheckEntry;
21
+ audit: {
22
+ /** GHSA advisory IDs that are known/allowlisted (e.g. "GHSA-49rj-9fvp-4h2h"). */
23
+ ghsa_ids: string[];
24
+ };
25
+ }
26
+ export type BaselineCheckName = "lint" | "typecheck" | "tests";
27
+ /**
28
+ * Load the baseline file from the project root.
29
+ * Returns an empty-shaped default if the file is missing or malformed.
30
+ */
31
+ export declare function loadBaseline(projectRoot: string): BaselineFile;
32
+ /**
33
+ * Write the baseline file to the project root (overwrites any existing file).
34
+ */
35
+ export declare function saveBaseline(projectRoot: string, baseline: BaselineFile): void;
36
+ /**
37
+ * Return the NEW failing packages for a given check.
38
+ * "New" means the package is in currentFailingPackages but NOT in the
39
+ * baseline's known_failing list for that check.
40
+ *
41
+ * @param check - Which check (lint | typecheck | tests)
42
+ * @param currentFailingPackages - Package names that failed this run
43
+ * @param baseline - The loaded baseline file
44
+ * @returns Array of package names that are NEW failures (not baselined)
45
+ */
46
+ export declare function diffBaseline(check: BaselineCheckName, currentFailingPackages: string[], baseline: BaselineFile): string[];
47
+ /**
48
+ * Sentinel returned by parseAuditJson when stdout is NON-EMPTY but the JSON
49
+ * cannot be parsed or the shape is unrecognised. Exported so callers can
50
+ * distinguish "parse failed" from "parsed OK, no advisories" (the latter still
51
+ * returns []).
52
+ *
53
+ * Keep as a const so tests can reference the exported symbol rather than a
54
+ * string literal.
55
+ */
56
+ export declare const AUDIT_PARSE_FAILED = "__audit_parse_failed__";
57
+ /**
58
+ * Parse GHSA advisory IDs from `pnpm audit --json` stdout.
59
+ *
60
+ * `pnpm audit --json` emits a single JSON object with an `advisories` map
61
+ * keyed by numeric advisory ID. Each entry has a `github_advisory_id` field
62
+ * containing the GHSA-* identifier (may be null for non-GitHub advisories).
63
+ *
64
+ * Example structure:
65
+ * {
66
+ * "advisories": {
67
+ * "1120063": {
68
+ * "github_advisory_id": "GHSA-49rj-9fvp-4h2h",
69
+ * ...
70
+ * }
71
+ * }
72
+ * }
73
+ *
74
+ * Returns deduplicated GHSA IDs in sorted order for determinism.
75
+ *
76
+ * FAIL-CLOSED: when stdout is non-empty but cannot be parsed or the recognised
77
+ * shape is absent, returns [AUDIT_PARSE_FAILED] so the caller can surface a
78
+ * failure rather than silently treating it as "no advisories".
79
+ * Empty / whitespace-only stdout fast-paths to [] (genuine "no advisories").
80
+ */
81
+ export declare function parseAuditJson(stdout: string): string[];
82
+ /**
83
+ * Return GHSA IDs in currentGhsaIds that are NOT in the allowlist.
84
+ * "New advisory" = a GHSA id present in the current run but absent from the baseline.
85
+ *
86
+ * @param currentGhsaIds - GHSA IDs found in this audit run
87
+ * @param allowlist - GHSA IDs from the baseline (known/allowed advisories)
88
+ * @returns Array of new (unallowlisted) GHSA IDs
89
+ */
90
+ export declare function diffAudit(currentGhsaIds: string[], allowlist: string[]): string[];
91
+ //# sourceMappingURL=check-baseline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-baseline.d.ts","sourceRoot":"","sources":["../../src/lib/check-baseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,EAAE;QACL,iFAAiF;QACjF,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;AAqB/D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CA4B9D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,YAAY,GACrB,IAAI,CAGN;AAMD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,sBAAsB,EAAE,MAAM,EAAE,EAChC,QAAQ,EAAE,YAAY,GACrB,MAAM,EAAE,CAGV;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CA0CvD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,cAAc,EAAE,MAAM,EAAE,EACxB,SAAS,EAAE,MAAM,EAAE,GAClB,MAAM,EAAE,CAGV"}