@productbrain/cli 0.1.0-beta.9 → 0.1.0-beta.91

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 (643) hide show
  1. package/README.md +77 -92
  2. package/dist/__tests__/adapters.test.d.ts +2 -0
  3. package/dist/__tests__/adapters.test.d.ts.map +1 -0
  4. package/dist/__tests__/adapters.test.js +417 -0
  5. package/dist/__tests__/adapters.test.js.map +1 -0
  6. package/dist/__tests__/audit.test.d.ts +2 -0
  7. package/dist/__tests__/audit.test.d.ts.map +1 -0
  8. package/dist/__tests__/audit.test.js +394 -0
  9. package/dist/__tests__/audit.test.js.map +1 -0
  10. package/dist/__tests__/batch-transformations.test.d.ts +2 -0
  11. package/dist/__tests__/batch-transformations.test.d.ts.map +1 -0
  12. package/dist/__tests__/batch-transformations.test.js +263 -0
  13. package/dist/__tests__/batch-transformations.test.js.map +1 -0
  14. package/dist/__tests__/capture.test.js +309 -18
  15. package/dist/__tests__/capture.test.js.map +1 -1
  16. package/dist/__tests__/config.test.d.ts +8 -0
  17. package/dist/__tests__/config.test.d.ts.map +1 -0
  18. package/dist/__tests__/config.test.js +166 -0
  19. package/dist/__tests__/config.test.js.map +1 -0
  20. package/dist/__tests__/constants.test.d.ts +2 -0
  21. package/dist/__tests__/constants.test.d.ts.map +1 -0
  22. package/dist/__tests__/constants.test.js +141 -0
  23. package/dist/__tests__/constants.test.js.map +1 -0
  24. package/dist/__tests__/constellation.test.js +20 -26
  25. package/dist/__tests__/constellation.test.js.map +1 -1
  26. package/dist/__tests__/context-strategy.test.d.ts +2 -0
  27. package/dist/__tests__/context-strategy.test.d.ts.map +1 -0
  28. package/dist/__tests__/context-strategy.test.js +79 -0
  29. package/dist/__tests__/context-strategy.test.js.map +1 -0
  30. package/dist/__tests__/errors.test.d.ts +2 -0
  31. package/dist/__tests__/errors.test.d.ts.map +1 -0
  32. package/dist/__tests__/errors.test.js +117 -0
  33. package/dist/__tests__/errors.test.js.map +1 -0
  34. package/dist/__tests__/experiment.test.d.ts +6 -0
  35. package/dist/__tests__/experiment.test.d.ts.map +1 -0
  36. package/dist/__tests__/experiment.test.js +69 -0
  37. package/dist/__tests__/experiment.test.js.map +1 -0
  38. package/dist/__tests__/fields.test.js +68 -68
  39. package/dist/__tests__/fields.test.js.map +1 -1
  40. package/dist/__tests__/glossary.test.d.ts +2 -0
  41. package/dist/__tests__/glossary.test.d.ts.map +1 -0
  42. package/dist/__tests__/glossary.test.js +32 -0
  43. package/dist/__tests__/glossary.test.js.map +1 -0
  44. package/dist/__tests__/handshake-preview.test.d.ts +2 -0
  45. package/dist/__tests__/handshake-preview.test.d.ts.map +1 -0
  46. package/dist/__tests__/handshake-preview.test.js +156 -0
  47. package/dist/__tests__/handshake-preview.test.js.map +1 -0
  48. package/dist/__tests__/handshake.test.js +27 -18
  49. package/dist/__tests__/handshake.test.js.map +1 -1
  50. package/dist/__tests__/hook-intents.test.d.ts +2 -0
  51. package/dist/__tests__/hook-intents.test.d.ts.map +1 -0
  52. package/dist/__tests__/hook-intents.test.js +184 -0
  53. package/dist/__tests__/hook-intents.test.js.map +1 -0
  54. package/dist/__tests__/ingest.test.js +110 -12
  55. package/dist/__tests__/ingest.test.js.map +1 -1
  56. package/dist/__tests__/init.test.d.ts +7 -0
  57. package/dist/__tests__/init.test.d.ts.map +1 -0
  58. package/dist/__tests__/init.test.js +146 -0
  59. package/dist/__tests__/init.test.js.map +1 -0
  60. package/dist/__tests__/login.test.d.ts +2 -0
  61. package/dist/__tests__/login.test.d.ts.map +1 -0
  62. package/dist/__tests__/login.test.js +167 -0
  63. package/dist/__tests__/login.test.js.map +1 -0
  64. package/dist/__tests__/manifest.test.d.ts +6 -0
  65. package/dist/__tests__/manifest.test.d.ts.map +1 -0
  66. package/dist/__tests__/manifest.test.js +138 -0
  67. package/dist/__tests__/manifest.test.js.map +1 -0
  68. package/dist/__tests__/method-registry.integration.test.d.ts +6 -0
  69. package/dist/__tests__/method-registry.integration.test.d.ts.map +1 -0
  70. package/dist/__tests__/method-registry.integration.test.js +18 -0
  71. package/dist/__tests__/method-registry.integration.test.js.map +1 -0
  72. package/dist/__tests__/method-registry.test.d.ts +14 -0
  73. package/dist/__tests__/method-registry.test.d.ts.map +1 -0
  74. package/dist/__tests__/method-registry.test.js +134 -0
  75. package/dist/__tests__/method-registry.test.js.map +1 -0
  76. package/dist/__tests__/onboarding-path-b.test.d.ts +2 -0
  77. package/dist/__tests__/onboarding-path-b.test.d.ts.map +1 -0
  78. package/dist/__tests__/onboarding-path-b.test.js +46 -0
  79. package/dist/__tests__/onboarding-path-b.test.js.map +1 -0
  80. package/dist/__tests__/onboarding.test.d.ts +6 -0
  81. package/dist/__tests__/onboarding.test.d.ts.map +1 -0
  82. package/dist/__tests__/onboarding.test.js +347 -0
  83. package/dist/__tests__/onboarding.test.js.map +1 -0
  84. package/dist/__tests__/orient.test.d.ts +2 -0
  85. package/dist/__tests__/orient.test.d.ts.map +1 -0
  86. package/dist/__tests__/orient.test.js +143 -0
  87. package/dist/__tests__/orient.test.js.map +1 -0
  88. package/dist/__tests__/personal-layer.test.d.ts +12 -0
  89. package/dist/__tests__/personal-layer.test.d.ts.map +1 -0
  90. package/dist/__tests__/personal-layer.test.js +304 -0
  91. package/dist/__tests__/personal-layer.test.js.map +1 -0
  92. package/dist/__tests__/profiles.test.d.ts +2 -0
  93. package/dist/__tests__/profiles.test.d.ts.map +1 -0
  94. package/dist/__tests__/profiles.test.js +168 -0
  95. package/dist/__tests__/profiles.test.js.map +1 -0
  96. package/dist/__tests__/promote.test.d.ts +2 -0
  97. package/dist/__tests__/promote.test.d.ts.map +1 -0
  98. package/dist/__tests__/promote.test.js +161 -0
  99. package/dist/__tests__/promote.test.js.map +1 -0
  100. package/dist/__tests__/prompts.test.d.ts +6 -0
  101. package/dist/__tests__/prompts.test.d.ts.map +1 -0
  102. package/dist/__tests__/prompts.test.js +146 -0
  103. package/dist/__tests__/prompts.test.js.map +1 -0
  104. package/dist/__tests__/proposals.test.d.ts +2 -0
  105. package/dist/__tests__/proposals.test.d.ts.map +1 -0
  106. package/dist/__tests__/proposals.test.js +167 -0
  107. package/dist/__tests__/proposals.test.js.map +1 -0
  108. package/dist/__tests__/relate.test.js +57 -33
  109. package/dist/__tests__/relate.test.js.map +1 -1
  110. package/dist/__tests__/repo-detect.test.js +97 -1
  111. package/dist/__tests__/repo-detect.test.js.map +1 -1
  112. package/dist/__tests__/runner.test.js +19 -15
  113. package/dist/__tests__/runner.test.js.map +1 -1
  114. package/dist/__tests__/session-state-machine.test.d.ts +2 -0
  115. package/dist/__tests__/session-state-machine.test.d.ts.map +1 -0
  116. package/dist/__tests__/session-state-machine.test.js +154 -0
  117. package/dist/__tests__/session-state-machine.test.js.map +1 -0
  118. package/dist/__tests__/session-touch.test.js +11 -11
  119. package/dist/__tests__/session-touch.test.js.map +1 -1
  120. package/dist/__tests__/session.test.js +4 -10
  121. package/dist/__tests__/session.test.js.map +1 -1
  122. package/dist/__tests__/setup.test.d.ts +2 -0
  123. package/dist/__tests__/setup.test.d.ts.map +1 -0
  124. package/dist/__tests__/setup.test.js +141 -0
  125. package/dist/__tests__/setup.test.js.map +1 -0
  126. package/dist/__tests__/spinner-labels.test.d.ts +2 -0
  127. package/dist/__tests__/spinner-labels.test.d.ts.map +1 -0
  128. package/dist/__tests__/spinner-labels.test.js +23 -0
  129. package/dist/__tests__/spinner-labels.test.js.map +1 -0
  130. package/dist/__tests__/state.test.d.ts +6 -0
  131. package/dist/__tests__/state.test.d.ts.map +1 -0
  132. package/dist/__tests__/state.test.js +97 -0
  133. package/dist/__tests__/state.test.js.map +1 -0
  134. package/dist/__tests__/strip.test.js +2 -2
  135. package/dist/__tests__/strip.test.js.map +1 -1
  136. package/dist/__tests__/surface-profiles.test.d.ts +2 -0
  137. package/dist/__tests__/surface-profiles.test.d.ts.map +1 -0
  138. package/dist/__tests__/surface-profiles.test.js +233 -0
  139. package/dist/__tests__/surface-profiles.test.js.map +1 -0
  140. package/dist/__tests__/surfaces.test.d.ts +2 -0
  141. package/dist/__tests__/surfaces.test.d.ts.map +1 -0
  142. package/dist/__tests__/surfaces.test.js +46 -0
  143. package/dist/__tests__/surfaces.test.js.map +1 -0
  144. package/dist/__tests__/update.test.js +123 -43
  145. package/dist/__tests__/update.test.js.map +1 -1
  146. package/dist/__tests__/workspace.test.d.ts +2 -0
  147. package/dist/__tests__/workspace.test.d.ts.map +1 -0
  148. package/dist/__tests__/workspace.test.js +308 -0
  149. package/dist/__tests__/workspace.test.js.map +1 -0
  150. package/dist/commands/accept.d.ts +18 -0
  151. package/dist/commands/accept.d.ts.map +1 -0
  152. package/dist/commands/accept.js +76 -0
  153. package/dist/commands/accept.js.map +1 -0
  154. package/dist/commands/admin/cockpit.d.ts +90 -0
  155. package/dist/commands/admin/cockpit.d.ts.map +1 -0
  156. package/dist/commands/admin/cockpit.js +618 -0
  157. package/dist/commands/admin/cockpit.js.map +1 -0
  158. package/dist/commands/admin/index.d.ts +21 -0
  159. package/dist/commands/admin/index.d.ts.map +1 -0
  160. package/dist/commands/admin/index.js +256 -0
  161. package/dist/commands/admin/index.js.map +1 -0
  162. package/dist/commands/admin/inspect.d.ts +30 -0
  163. package/dist/commands/admin/inspect.d.ts.map +1 -0
  164. package/dist/commands/admin/inspect.js +555 -0
  165. package/dist/commands/admin/inspect.js.map +1 -0
  166. package/dist/commands/admin/inspect.test.d.ts +7 -0
  167. package/dist/commands/admin/inspect.test.d.ts.map +1 -0
  168. package/dist/commands/admin/inspect.test.js +90 -0
  169. package/dist/commands/admin/inspect.test.js.map +1 -0
  170. package/dist/commands/admin/manage.d.ts +8 -0
  171. package/dist/commands/admin/manage.d.ts.map +1 -0
  172. package/dist/commands/admin/manage.js +76 -0
  173. package/dist/commands/admin/manage.js.map +1 -0
  174. package/dist/commands/admin/seed.d.ts +32 -0
  175. package/dist/commands/admin/seed.d.ts.map +1 -0
  176. package/dist/commands/admin/seed.js +533 -0
  177. package/dist/commands/admin/seed.js.map +1 -0
  178. package/dist/commands/admin/seed.test.d.ts +6 -0
  179. package/dist/commands/admin/seed.test.d.ts.map +1 -0
  180. package/dist/commands/admin/seed.test.js +65 -0
  181. package/dist/commands/admin/seed.test.js.map +1 -0
  182. package/dist/commands/audit.d.ts +25 -0
  183. package/dist/commands/audit.d.ts.map +1 -0
  184. package/dist/commands/audit.js +188 -0
  185. package/dist/commands/audit.js.map +1 -0
  186. package/dist/commands/brand-pack.d.ts +2 -0
  187. package/dist/commands/brand-pack.d.ts.map +1 -0
  188. package/dist/commands/brand-pack.js +25 -0
  189. package/dist/commands/brand-pack.js.map +1 -0
  190. package/dist/commands/brief.d.ts +28 -0
  191. package/dist/commands/brief.d.ts.map +1 -0
  192. package/dist/commands/brief.js +75 -0
  193. package/dist/commands/brief.js.map +1 -0
  194. package/dist/commands/capture.d.ts +9 -0
  195. package/dist/commands/capture.d.ts.map +1 -1
  196. package/dist/commands/capture.js +256 -17
  197. package/dist/commands/capture.js.map +1 -1
  198. package/dist/commands/chain-walk.d.ts +14 -0
  199. package/dist/commands/chain-walk.d.ts.map +1 -0
  200. package/dist/commands/chain-walk.js +38 -0
  201. package/dist/commands/chain-walk.js.map +1 -0
  202. package/dist/commands/changes.d.ts +11 -0
  203. package/dist/commands/changes.d.ts.map +1 -0
  204. package/dist/commands/changes.js +46 -0
  205. package/dist/commands/changes.js.map +1 -0
  206. package/dist/commands/codex-prep.d.ts +12 -0
  207. package/dist/commands/codex-prep.d.ts.map +1 -0
  208. package/dist/commands/codex-prep.js +122 -0
  209. package/dist/commands/codex-prep.js.map +1 -0
  210. package/dist/commands/collections.d.ts +22 -0
  211. package/dist/commands/collections.d.ts.map +1 -0
  212. package/dist/commands/collections.js +77 -0
  213. package/dist/commands/collections.js.map +1 -0
  214. package/dist/commands/connect-integration.test.d.ts +7 -0
  215. package/dist/commands/connect-integration.test.d.ts.map +1 -0
  216. package/dist/commands/connect-integration.test.js +195 -0
  217. package/dist/commands/connect-integration.test.js.map +1 -0
  218. package/dist/commands/connect-screens.d.ts +21 -0
  219. package/dist/commands/connect-screens.d.ts.map +1 -0
  220. package/dist/commands/connect-screens.js +79 -0
  221. package/dist/commands/connect-screens.js.map +1 -0
  222. package/dist/commands/connect.d.ts +21 -0
  223. package/dist/commands/connect.d.ts.map +1 -0
  224. package/dist/commands/connect.js +237 -0
  225. package/dist/commands/connect.js.map +1 -0
  226. package/dist/commands/connect.test.d.ts +6 -0
  227. package/dist/commands/connect.test.d.ts.map +1 -0
  228. package/dist/commands/connect.test.js +234 -0
  229. package/dist/commands/connect.test.js.map +1 -0
  230. package/dist/commands/constellation.d.ts.map +1 -1
  231. package/dist/commands/constellation.js +8 -3
  232. package/dist/commands/constellation.js.map +1 -1
  233. package/dist/commands/context.d.ts.map +1 -1
  234. package/dist/commands/context.js +8 -3
  235. package/dist/commands/context.js.map +1 -1
  236. package/dist/commands/cross-cut.d.ts +11 -0
  237. package/dist/commands/cross-cut.d.ts.map +1 -0
  238. package/dist/commands/cross-cut.js +23 -0
  239. package/dist/commands/cross-cut.js.map +1 -0
  240. package/dist/commands/doctor.d.ts +18 -0
  241. package/dist/commands/doctor.d.ts.map +1 -0
  242. package/dist/commands/doctor.js +232 -0
  243. package/dist/commands/doctor.js.map +1 -0
  244. package/dist/commands/doctor.test.d.ts +8 -0
  245. package/dist/commands/doctor.test.d.ts.map +1 -0
  246. package/dist/commands/doctor.test.js +311 -0
  247. package/dist/commands/doctor.test.js.map +1 -0
  248. package/dist/commands/fields.d.ts.map +1 -1
  249. package/dist/commands/fields.js +8 -4
  250. package/dist/commands/fields.js.map +1 -1
  251. package/dist/commands/get.d.ts.map +1 -1
  252. package/dist/commands/get.js +14 -6
  253. package/dist/commands/get.js.map +1 -1
  254. package/dist/commands/handshake.d.ts +12 -0
  255. package/dist/commands/handshake.d.ts.map +1 -1
  256. package/dist/commands/handshake.js +422 -74
  257. package/dist/commands/handshake.js.map +1 -1
  258. package/dist/commands/ingest.d.ts +7 -2
  259. package/dist/commands/ingest.d.ts.map +1 -1
  260. package/dist/commands/ingest.js +137 -31
  261. package/dist/commands/ingest.js.map +1 -1
  262. package/dist/commands/init.d.ts +14 -0
  263. package/dist/commands/init.d.ts.map +1 -0
  264. package/dist/commands/init.js +109 -0
  265. package/dist/commands/init.js.map +1 -0
  266. package/dist/commands/login.d.ts +4 -0
  267. package/dist/commands/login.d.ts.map +1 -1
  268. package/dist/commands/login.js +101 -38
  269. package/dist/commands/login.js.map +1 -1
  270. package/dist/commands/method.d.ts +99 -0
  271. package/dist/commands/method.d.ts.map +1 -0
  272. package/dist/commands/method.js +781 -0
  273. package/dist/commands/method.js.map +1 -0
  274. package/dist/commands/orient.d.ts +106 -1
  275. package/dist/commands/orient.d.ts.map +1 -1
  276. package/dist/commands/orient.js +13 -2
  277. package/dist/commands/orient.js.map +1 -1
  278. package/dist/commands/profile.d.ts +24 -0
  279. package/dist/commands/profile.d.ts.map +1 -0
  280. package/dist/commands/profile.js +82 -0
  281. package/dist/commands/profile.js.map +1 -0
  282. package/dist/commands/promote.d.ts +12 -0
  283. package/dist/commands/promote.d.ts.map +1 -0
  284. package/dist/commands/promote.js +90 -0
  285. package/dist/commands/promote.js.map +1 -0
  286. package/dist/commands/proposals.d.ts +9 -0
  287. package/dist/commands/proposals.d.ts.map +1 -0
  288. package/dist/commands/proposals.js +24 -0
  289. package/dist/commands/proposals.js.map +1 -0
  290. package/dist/commands/reject.d.ts +14 -0
  291. package/dist/commands/reject.d.ts.map +1 -0
  292. package/dist/commands/reject.js +43 -0
  293. package/dist/commands/reject.js.map +1 -0
  294. package/dist/commands/relate.d.ts +1 -0
  295. package/dist/commands/relate.d.ts.map +1 -1
  296. package/dist/commands/relate.js +41 -15
  297. package/dist/commands/relate.js.map +1 -1
  298. package/dist/commands/search.js +2 -2
  299. package/dist/commands/search.js.map +1 -1
  300. package/dist/commands/session.d.ts.map +1 -1
  301. package/dist/commands/session.js +85 -16
  302. package/dist/commands/session.js.map +1 -1
  303. package/dist/commands/setup.d.ts +15 -0
  304. package/dist/commands/setup.d.ts.map +1 -0
  305. package/dist/commands/setup.js +148 -0
  306. package/dist/commands/setup.js.map +1 -0
  307. package/dist/commands/update.d.ts +1 -0
  308. package/dist/commands/update.d.ts.map +1 -1
  309. package/dist/commands/update.js +102 -13
  310. package/dist/commands/update.js.map +1 -1
  311. package/dist/commands/usage.d.ts +40 -0
  312. package/dist/commands/usage.d.ts.map +1 -0
  313. package/dist/commands/usage.js +232 -0
  314. package/dist/commands/usage.js.map +1 -0
  315. package/dist/commands/verify.d.ts +13 -0
  316. package/dist/commands/verify.d.ts.map +1 -0
  317. package/dist/commands/verify.js +49 -0
  318. package/dist/commands/verify.js.map +1 -0
  319. package/dist/commands/welcome.d.ts +21 -0
  320. package/dist/commands/welcome.d.ts.map +1 -0
  321. package/dist/commands/welcome.js +50 -0
  322. package/dist/commands/welcome.js.map +1 -0
  323. package/dist/commands/workspace.d.ts +41 -0
  324. package/dist/commands/workspace.d.ts.map +1 -0
  325. package/dist/commands/workspace.js +239 -0
  326. package/dist/commands/workspace.js.map +1 -0
  327. package/dist/formatters/audit.d.ts +46 -0
  328. package/dist/formatters/audit.d.ts.map +1 -0
  329. package/dist/formatters/audit.js +81 -0
  330. package/dist/formatters/audit.js.map +1 -0
  331. package/dist/formatters/brief.d.ts +112 -0
  332. package/dist/formatters/brief.d.ts.map +1 -0
  333. package/dist/formatters/brief.js +179 -0
  334. package/dist/formatters/brief.js.map +1 -0
  335. package/dist/formatters/capture.d.ts +21 -3
  336. package/dist/formatters/capture.d.ts.map +1 -1
  337. package/dist/formatters/capture.js +20 -1
  338. package/dist/formatters/capture.js.map +1 -1
  339. package/dist/formatters/chain-walk.d.ts +33 -0
  340. package/dist/formatters/chain-walk.d.ts.map +1 -0
  341. package/dist/formatters/chain-walk.js +54 -0
  342. package/dist/formatters/chain-walk.js.map +1 -0
  343. package/dist/formatters/changes.d.ts +25 -0
  344. package/dist/formatters/changes.d.ts.map +1 -0
  345. package/dist/formatters/changes.js +60 -0
  346. package/dist/formatters/changes.js.map +1 -0
  347. package/dist/formatters/collections.d.ts +40 -0
  348. package/dist/formatters/collections.d.ts.map +1 -0
  349. package/dist/formatters/collections.js +93 -0
  350. package/dist/formatters/collections.js.map +1 -0
  351. package/dist/formatters/cross-cut.d.ts +21 -0
  352. package/dist/formatters/cross-cut.d.ts.map +1 -0
  353. package/dist/formatters/cross-cut.js +32 -0
  354. package/dist/formatters/cross-cut.js.map +1 -0
  355. package/dist/formatters/entry.d.ts +11 -4
  356. package/dist/formatters/entry.d.ts.map +1 -1
  357. package/dist/formatters/entry.js +24 -8
  358. package/dist/formatters/entry.js.map +1 -1
  359. package/dist/formatters/handshake.d.ts +29 -0
  360. package/dist/formatters/handshake.d.ts.map +1 -1
  361. package/dist/formatters/handshake.js +115 -3
  362. package/dist/formatters/handshake.js.map +1 -1
  363. package/dist/formatters/orient.d.ts +104 -1
  364. package/dist/formatters/orient.d.ts.map +1 -1
  365. package/dist/formatters/orient.js +140 -17
  366. package/dist/formatters/orient.js.map +1 -1
  367. package/dist/formatters/promote.d.ts +30 -0
  368. package/dist/formatters/promote.d.ts.map +1 -0
  369. package/dist/formatters/promote.js +39 -0
  370. package/dist/formatters/promote.js.map +1 -0
  371. package/dist/formatters/proposals.d.ts +45 -0
  372. package/dist/formatters/proposals.d.ts.map +1 -0
  373. package/dist/formatters/proposals.js +62 -0
  374. package/dist/formatters/proposals.js.map +1 -0
  375. package/dist/formatters/relate.d.ts +3 -0
  376. package/dist/formatters/relate.d.ts.map +1 -1
  377. package/dist/formatters/relate.js +6 -0
  378. package/dist/formatters/relate.js.map +1 -1
  379. package/dist/formatters/search.d.ts +0 -4
  380. package/dist/formatters/search.d.ts.map +1 -1
  381. package/dist/formatters/search.js +4 -1
  382. package/dist/formatters/search.js.map +1 -1
  383. package/dist/formatters/session.d.ts +1 -1
  384. package/dist/formatters/session.d.ts.map +1 -1
  385. package/dist/formatters/session.js +3 -1
  386. package/dist/formatters/session.js.map +1 -1
  387. package/dist/formatters/update.d.ts.map +1 -1
  388. package/dist/formatters/update.js +2 -0
  389. package/dist/formatters/update.js.map +1 -1
  390. package/dist/formatters/verify.d.ts +11 -0
  391. package/dist/formatters/verify.d.ts.map +1 -0
  392. package/dist/formatters/verify.js +11 -0
  393. package/dist/formatters/verify.js.map +1 -0
  394. package/dist/generators/__tests__/surface-profiles.test.d.ts +2 -0
  395. package/dist/generators/__tests__/surface-profiles.test.d.ts.map +1 -0
  396. package/dist/generators/__tests__/surface-profiles.test.js +89 -0
  397. package/dist/generators/__tests__/surface-profiles.test.js.map +1 -0
  398. package/dist/generators/adapters.d.ts +37 -3
  399. package/dist/generators/adapters.d.ts.map +1 -1
  400. package/dist/generators/adapters.js +193 -5
  401. package/dist/generators/adapters.js.map +1 -1
  402. package/dist/generators/adapters.test.d.ts +2 -0
  403. package/dist/generators/adapters.test.d.ts.map +1 -0
  404. package/dist/generators/adapters.test.js +27 -0
  405. package/dist/generators/adapters.test.js.map +1 -0
  406. package/dist/generators/archetypes.d.ts +52 -0
  407. package/dist/generators/archetypes.d.ts.map +1 -0
  408. package/dist/generators/archetypes.js +153 -0
  409. package/dist/generators/archetypes.js.map +1 -0
  410. package/dist/generators/archetypes.test.d.ts +2 -0
  411. package/dist/generators/archetypes.test.d.ts.map +1 -0
  412. package/dist/generators/archetypes.test.js +237 -0
  413. package/dist/generators/archetypes.test.js.map +1 -0
  414. package/dist/generators/chain-classifier.d.ts +49 -0
  415. package/dist/generators/chain-classifier.d.ts.map +1 -0
  416. package/dist/generators/chain-classifier.js +180 -0
  417. package/dist/generators/chain-classifier.js.map +1 -0
  418. package/dist/generators/chain-classifier.test.d.ts +2 -0
  419. package/dist/generators/chain-classifier.test.d.ts.map +1 -0
  420. package/dist/generators/chain-classifier.test.js +257 -0
  421. package/dist/generators/chain-classifier.test.js.map +1 -0
  422. package/dist/generators/chain-rules.d.ts +42 -0
  423. package/dist/generators/chain-rules.d.ts.map +1 -0
  424. package/dist/generators/chain-rules.js +144 -0
  425. package/dist/generators/chain-rules.js.map +1 -0
  426. package/dist/generators/chain-rules.test.d.ts +2 -0
  427. package/dist/generators/chain-rules.test.d.ts.map +1 -0
  428. package/dist/generators/chain-rules.test.js +179 -0
  429. package/dist/generators/chain-rules.test.js.map +1 -0
  430. package/dist/generators/context-md.d.ts +1 -1
  431. package/dist/generators/context-md.d.ts.map +1 -1
  432. package/dist/generators/context-md.js +12 -1
  433. package/dist/generators/context-md.js.map +1 -1
  434. package/dist/generators/handshake-diff.d.ts +67 -0
  435. package/dist/generators/handshake-diff.d.ts.map +1 -0
  436. package/dist/generators/handshake-diff.js +183 -0
  437. package/dist/generators/handshake-diff.js.map +1 -0
  438. package/dist/generators/handshake-diff.test.d.ts +2 -0
  439. package/dist/generators/handshake-diff.test.d.ts.map +1 -0
  440. package/dist/generators/handshake-diff.test.js +264 -0
  441. package/dist/generators/handshake-diff.test.js.map +1 -0
  442. package/dist/generators/manifest.d.ts +37 -0
  443. package/dist/generators/manifest.d.ts.map +1 -0
  444. package/dist/generators/manifest.js +166 -0
  445. package/dist/generators/manifest.js.map +1 -0
  446. package/dist/generators/portable-knowledge.d.ts +102 -9
  447. package/dist/generators/portable-knowledge.d.ts.map +1 -1
  448. package/dist/generators/portable-knowledge.js +384 -17
  449. package/dist/generators/portable-knowledge.js.map +1 -1
  450. package/dist/generators/portable-knowledge.test.js +529 -1
  451. package/dist/generators/portable-knowledge.test.js.map +1 -1
  452. package/dist/generators/surface-profiles.d.ts +49 -0
  453. package/dist/generators/surface-profiles.d.ts.map +1 -0
  454. package/dist/generators/surface-profiles.js +98 -0
  455. package/dist/generators/surface-profiles.js.map +1 -0
  456. package/dist/index.js +618 -138
  457. package/dist/index.js.map +1 -1
  458. package/dist/lib/activation.d.ts +28 -0
  459. package/dist/lib/activation.d.ts.map +1 -0
  460. package/dist/lib/activation.js +57 -0
  461. package/dist/lib/activation.js.map +1 -0
  462. package/dist/lib/activation.test.d.ts +6 -0
  463. package/dist/lib/activation.test.d.ts.map +1 -0
  464. package/dist/lib/activation.test.js +121 -0
  465. package/dist/lib/activation.test.js.map +1 -0
  466. package/dist/lib/client.d.ts +45 -3
  467. package/dist/lib/client.d.ts.map +1 -1
  468. package/dist/lib/client.js +188 -36
  469. package/dist/lib/client.js.map +1 -1
  470. package/dist/lib/collectionRegistry.d.ts +38 -0
  471. package/dist/lib/collectionRegistry.d.ts.map +1 -0
  472. package/dist/lib/collectionRegistry.js +112 -0
  473. package/dist/lib/collectionRegistry.js.map +1 -0
  474. package/dist/lib/config.d.ts +84 -4
  475. package/dist/lib/config.d.ts.map +1 -1
  476. package/dist/lib/config.js +322 -42
  477. package/dist/lib/config.js.map +1 -1
  478. package/dist/lib/constants.d.ts +42 -0
  479. package/dist/lib/constants.d.ts.map +1 -0
  480. package/dist/lib/constants.js +76 -0
  481. package/dist/lib/constants.js.map +1 -0
  482. package/dist/lib/conversation-engine.d.ts +45 -0
  483. package/dist/lib/conversation-engine.d.ts.map +1 -0
  484. package/dist/lib/conversation-engine.js +112 -0
  485. package/dist/lib/conversation-engine.js.map +1 -0
  486. package/dist/lib/conversation-phases.d.ts +59 -0
  487. package/dist/lib/conversation-phases.d.ts.map +1 -0
  488. package/dist/lib/conversation-phases.js +11 -0
  489. package/dist/lib/conversation-phases.js.map +1 -0
  490. package/dist/lib/conversation-signals.d.ts +30 -0
  491. package/dist/lib/conversation-signals.d.ts.map +1 -0
  492. package/dist/lib/conversation-signals.js +64 -0
  493. package/dist/lib/conversation-signals.js.map +1 -0
  494. package/dist/lib/deployment.d.ts +23 -0
  495. package/dist/lib/deployment.d.ts.map +1 -0
  496. package/dist/lib/deployment.js +78 -0
  497. package/dist/lib/deployment.js.map +1 -0
  498. package/dist/lib/deployment.test.d.ts +5 -0
  499. package/dist/lib/deployment.test.d.ts.map +1 -0
  500. package/dist/lib/deployment.test.js +54 -0
  501. package/dist/lib/deployment.test.js.map +1 -0
  502. package/dist/lib/errors.d.ts +58 -0
  503. package/dist/lib/errors.d.ts.map +1 -0
  504. package/dist/lib/errors.js +67 -0
  505. package/dist/lib/errors.js.map +1 -0
  506. package/dist/lib/experiment.d.ts +18 -0
  507. package/dist/lib/experiment.d.ts.map +1 -0
  508. package/dist/lib/experiment.js +28 -0
  509. package/dist/lib/experiment.js.map +1 -0
  510. package/dist/lib/format.d.ts +10 -0
  511. package/dist/lib/format.d.ts.map +1 -0
  512. package/dist/lib/format.js +27 -0
  513. package/dist/lib/format.js.map +1 -0
  514. package/dist/lib/glossary.d.ts +19 -0
  515. package/dist/lib/glossary.d.ts.map +1 -0
  516. package/dist/lib/glossary.js +53 -0
  517. package/dist/lib/glossary.js.map +1 -0
  518. package/dist/lib/hook-intents.d.ts +51 -0
  519. package/dist/lib/hook-intents.d.ts.map +1 -0
  520. package/dist/lib/hook-intents.js +85 -0
  521. package/dist/lib/hook-intents.js.map +1 -0
  522. package/dist/lib/inferSourceDate.d.ts +12 -0
  523. package/dist/lib/inferSourceDate.d.ts.map +1 -0
  524. package/dist/lib/inferSourceDate.js +44 -0
  525. package/dist/lib/inferSourceDate.js.map +1 -0
  526. package/dist/lib/method-registry.d.ts +32 -0
  527. package/dist/lib/method-registry.d.ts.map +1 -0
  528. package/dist/lib/method-registry.js +53 -0
  529. package/dist/lib/method-registry.js.map +1 -0
  530. package/dist/lib/onboarding-path-b.d.ts +10 -0
  531. package/dist/lib/onboarding-path-b.d.ts.map +1 -0
  532. package/dist/lib/onboarding-path-b.js +214 -0
  533. package/dist/lib/onboarding-path-b.js.map +1 -0
  534. package/dist/lib/onboarding-phases.d.ts +9 -0
  535. package/dist/lib/onboarding-phases.d.ts.map +1 -0
  536. package/dist/lib/onboarding-phases.js +120 -0
  537. package/dist/lib/onboarding-phases.js.map +1 -0
  538. package/dist/lib/onboarding-shared.d.ts +81 -0
  539. package/dist/lib/onboarding-shared.d.ts.map +1 -0
  540. package/dist/lib/onboarding-shared.js +190 -0
  541. package/dist/lib/onboarding-shared.js.map +1 -0
  542. package/dist/lib/onboarding-topics.d.ts +27 -0
  543. package/dist/lib/onboarding-topics.d.ts.map +1 -0
  544. package/dist/lib/onboarding-topics.js +57 -0
  545. package/dist/lib/onboarding-topics.js.map +1 -0
  546. package/dist/lib/onboarding.d.ts +17 -0
  547. package/dist/lib/onboarding.d.ts.map +1 -0
  548. package/dist/lib/onboarding.js +350 -0
  549. package/dist/lib/onboarding.js.map +1 -0
  550. package/dist/lib/profiles.d.ts +39 -0
  551. package/dist/lib/profiles.d.ts.map +1 -0
  552. package/dist/lib/profiles.js +185 -0
  553. package/dist/lib/profiles.js.map +1 -0
  554. package/dist/lib/prompts.d.ts +65 -0
  555. package/dist/lib/prompts.d.ts.map +1 -0
  556. package/dist/lib/prompts.js +132 -0
  557. package/dist/lib/prompts.js.map +1 -0
  558. package/dist/lib/repo-detect.d.ts +19 -0
  559. package/dist/lib/repo-detect.d.ts.map +1 -1
  560. package/dist/lib/repo-detect.js +25 -0
  561. package/dist/lib/repo-detect.js.map +1 -1
  562. package/dist/lib/runner.d.ts +2 -0
  563. package/dist/lib/runner.d.ts.map +1 -1
  564. package/dist/lib/runner.js +21 -7
  565. package/dist/lib/runner.js.map +1 -1
  566. package/dist/lib/session.d.ts +25 -0
  567. package/dist/lib/session.d.ts.map +1 -1
  568. package/dist/lib/session.js +70 -4
  569. package/dist/lib/session.js.map +1 -1
  570. package/dist/lib/spinner.d.ts +27 -0
  571. package/dist/lib/spinner.d.ts.map +1 -0
  572. package/dist/lib/spinner.js +76 -0
  573. package/dist/lib/spinner.js.map +1 -0
  574. package/dist/lib/spinner.test.d.ts +2 -0
  575. package/dist/lib/spinner.test.d.ts.map +1 -0
  576. package/dist/lib/spinner.test.js +39 -0
  577. package/dist/lib/spinner.test.js.map +1 -0
  578. package/dist/lib/state.d.ts +51 -0
  579. package/dist/lib/state.d.ts.map +1 -0
  580. package/dist/lib/state.js +90 -0
  581. package/dist/lib/state.js.map +1 -0
  582. package/dist/lib/strip.d.ts +1 -0
  583. package/dist/lib/strip.d.ts.map +1 -1
  584. package/dist/lib/strip.js +15 -0
  585. package/dist/lib/strip.js.map +1 -1
  586. package/dist/lib/style.d.ts +96 -0
  587. package/dist/lib/style.d.ts.map +1 -0
  588. package/dist/lib/style.js +169 -0
  589. package/dist/lib/style.js.map +1 -0
  590. package/dist/lib/style.test.d.ts +7 -0
  591. package/dist/lib/style.test.d.ts.map +1 -0
  592. package/dist/lib/style.test.js +263 -0
  593. package/dist/lib/style.test.js.map +1 -0
  594. package/dist/lib/telemetry.d.ts +15 -0
  595. package/dist/lib/telemetry.d.ts.map +1 -0
  596. package/dist/lib/telemetry.js +47 -0
  597. package/dist/lib/telemetry.js.map +1 -0
  598. package/dist/lib/tokenConstants.d.ts +17 -0
  599. package/dist/lib/tokenConstants.d.ts.map +1 -0
  600. package/dist/lib/tokenConstants.js +17 -0
  601. package/dist/lib/tokenConstants.js.map +1 -0
  602. package/dist/lib/update-check.d.ts +21 -0
  603. package/dist/lib/update-check.d.ts.map +1 -0
  604. package/dist/lib/update-check.js +145 -0
  605. package/dist/lib/update-check.js.map +1 -0
  606. package/dist/lib/wizard-surfaces.d.ts +47 -0
  607. package/dist/lib/wizard-surfaces.d.ts.map +1 -0
  608. package/dist/lib/wizard-surfaces.js +176 -0
  609. package/dist/lib/wizard-surfaces.js.map +1 -0
  610. package/dist/lib/wizard-surfaces.test.d.ts +2 -0
  611. package/dist/lib/wizard-surfaces.test.d.ts.map +1 -0
  612. package/dist/lib/wizard-surfaces.test.js +127 -0
  613. package/dist/lib/wizard-surfaces.test.js.map +1 -0
  614. package/dist/lib/wizard-trust.d.ts +31 -0
  615. package/dist/lib/wizard-trust.d.ts.map +1 -0
  616. package/dist/lib/wizard-trust.js +66 -0
  617. package/dist/lib/wizard-trust.js.map +1 -0
  618. package/dist/lib/wizard-trust.test.d.ts +2 -0
  619. package/dist/lib/wizard-trust.test.d.ts.map +1 -0
  620. package/dist/lib/wizard-trust.test.js +32 -0
  621. package/dist/lib/wizard-trust.test.js.map +1 -0
  622. package/dist/lib/workspace-probe.d.ts +19 -0
  623. package/dist/lib/workspace-probe.d.ts.map +1 -0
  624. package/dist/lib/workspace-probe.js +27 -0
  625. package/dist/lib/workspace-probe.js.map +1 -0
  626. package/dist/surfaces/registry.d.ts +20 -0
  627. package/dist/surfaces/registry.d.ts.map +1 -0
  628. package/dist/surfaces/registry.js +42 -0
  629. package/dist/surfaces/registry.js.map +1 -0
  630. package/package.json +9 -3
  631. package/templates/archetypes/boundary.md +23 -0
  632. package/templates/archetypes/constraint.md +23 -0
  633. package/templates/archetypes/convention.md +23 -0
  634. package/templates/archetypes/policy.md +23 -0
  635. package/templates/archetypes/quality-gate.md +23 -0
  636. package/templates/archetypes/workflow.md +23 -0
  637. package/templates/general/code-integrity.md +11 -0
  638. package/templates/general/getting-started.md +12 -0
  639. package/templates/method-registry.json +16 -0
  640. package/templates/node-ts/code-integrity.md +13 -0
  641. package/templates/node-ts/testing.md +12 -0
  642. package/templates/python/code-integrity.md +13 -0
  643. package/templates/python/testing.md +12 -0
package/dist/index.js CHANGED
@@ -4,11 +4,19 @@
4
4
  * Read: BET-108. Write: pb session + pb capture (TEN-27, INS-80).
5
5
  * BET-181 Slice 0: global --json / --pretty flags for agent-native output (DEC-299).
6
6
  */
7
- import { Command } from 'commander';
8
- import { setOutputMode } from './lib/runner.js';
7
+ import { readFileSync } from 'node:fs';
8
+ import { dirname, join } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ import { Command, CommanderError } from 'commander';
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const cliPackageVersion = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
13
+ import { setOutputMode, setQuietMode, isJsonMode } from './lib/runner.js';
14
+ import { CLIError, ErrorCode } from './lib/errors.js';
9
15
  import { runContext } from './commands/context.js';
10
16
  import { runGet, runGetMany } from './commands/get.js';
17
+ import { runConnect } from './commands/connect.js';
11
18
  import { runLogin } from './commands/login.js';
19
+ import { runSetup } from './commands/setup.js';
12
20
  import { runOrient } from './commands/orient.js';
13
21
  import { runSearch } from './commands/search.js';
14
22
  import { runHandshake, runHandshakeInit } from './commands/handshake.js';
@@ -19,14 +27,89 @@ import { runRelate, runUnrelate } from './commands/relate.js';
19
27
  import { runIngest } from './commands/ingest.js';
20
28
  import { runFields } from './commands/fields.js';
21
29
  import { runConstellation } from './commands/constellation.js';
30
+ import { runPromote } from './commands/promote.js';
31
+ import { runBrandPack } from './commands/brand-pack.js';
32
+ import { runAudit } from './commands/audit.js';
33
+ import { runProposals } from './commands/proposals.js';
34
+ import { runAccept } from './commands/accept.js';
35
+ import { runReject } from './commands/reject.js';
36
+ import { runChanges } from './commands/changes.js';
37
+ import { runChainWalk } from './commands/chain-walk.js';
38
+ import { runCrossCut } from './commands/cross-cut.js';
39
+ import { runBrief, runCompoundBrief, isCompoundType } from './commands/brief.js';
40
+ import { runVerify } from './commands/verify.js';
41
+ import { runCodexPrep } from './commands/codex-prep.js';
42
+ import { runCollectionsList, runCollectionsGet, runCollectionsAudit, runCollectionsExport } from './commands/collections.js';
43
+ import { runWorkspaceVerify, runWorkspaceRepair, runDefinitionsDiff } from './commands/workspace.js';
44
+ import { runDoctor } from './commands/doctor.js';
45
+ import { runProfileList, runProfileCreate, runProfileUse, runProfileDelete } from './commands/profile.js';
46
+ import { runInit } from './commands/init.js';
47
+ import { runMethodList, runMethodShow, runMethodDiff, runMethodPublish } from './commands/method.js';
48
+ import { createAdminCommand } from './commands/admin/index.js';
49
+ import { runUsage } from './commands/usage.js';
50
+ import { GLOSSARY, formatGlossary } from './lib/glossary.js';
51
+ import { API_KEY_PREFIX } from './lib/tokenConstants.js';
52
+ import { hint, heading, bold, dim, green, icons } from './lib/style.js';
53
+ import { checkForUpdate } from './lib/update-check.js';
54
+ import { resolveSetupState, detectRenderTier } from './lib/state.js';
22
55
  const program = new Command();
56
+ /**
57
+ * Global error handler — single exit point for all CLI errors.
58
+ * CLIError: format with code + category + guidance.
59
+ * CommanderError: re-throw for --help / --version (exitCode 0), format others.
60
+ * Regular Error: wrap as INTERNAL.
61
+ */
62
+ function handleError(err) {
63
+ // Commander help/version exits with code 0 — let them through
64
+ if (err instanceof CommanderError && err.exitCode === 0) {
65
+ process.exit(0);
66
+ }
67
+ const json = isJsonMode();
68
+ if (err instanceof CLIError) {
69
+ if (json) {
70
+ process.stderr.write(JSON.stringify(err.toJSON()) + '\n');
71
+ }
72
+ else {
73
+ process.stderr.write(err.message + '\n');
74
+ if (err.guidance) {
75
+ process.stderr.write(err.guidance + '\n');
76
+ }
77
+ }
78
+ process.exit(1);
79
+ }
80
+ // CommanderError (bad usage, missing args, etc.)
81
+ if (err instanceof CommanderError) {
82
+ const cliErr = new CLIError(err.message, {
83
+ code: ErrorCode.VALIDATION_FAILED,
84
+ category: 'validation',
85
+ });
86
+ if (json) {
87
+ process.stderr.write(JSON.stringify(cliErr.toJSON()) + '\n');
88
+ }
89
+ else {
90
+ process.stderr.write(err.message + '\n');
91
+ }
92
+ process.exit(err.exitCode);
93
+ }
94
+ // Unknown / unstructured errors
95
+ const message = err instanceof Error ? err.message : String(err);
96
+ if (json) {
97
+ process.stderr.write(JSON.stringify({ error: message, code: 'INTERNAL', category: 'internal' }) + '\n');
98
+ }
99
+ else {
100
+ process.stderr.write(message + '\n');
101
+ }
102
+ process.exit(1);
103
+ }
23
104
  program
24
105
  .name('pb')
25
106
  .description('Product Brain — Chain knowledge + write-back CLI')
26
- .version('0.2.0')
107
+ .version(cliPackageVersion.version)
27
108
  // Global output mode flags (DEC-299, BET-181)
28
109
  .option('--json', 'Output machine-readable JSON (overrides TTY auto-detection)')
29
- .option('--pretty', 'Force human-readable output even when piped');
110
+ .option('--pretty', 'Force human-readable output even when piped')
111
+ .option('-q, --quiet', 'Suppress non-essential output (banners, hints, progress)')
112
+ .exitOverride(); // Throw CommanderError instead of calling process.exit directly
30
113
  // Apply global output mode BEFORE subcommand actions run
31
114
  program.hook('preAction', (thisCommand) => {
32
115
  const globalOpts = program.opts();
@@ -37,8 +120,127 @@ program.hook('preAction', (thisCommand) => {
37
120
  setOutputMode('pretty');
38
121
  }
39
122
  // else: 'auto' (default) — TTY detection handles it
123
+ if (globalOpts.quiet) {
124
+ setQuietMode(true);
125
+ }
126
+ // Ambient update notification — non-blocking, suppressed in JSON mode (WP-322 S1)
127
+ checkForUpdate(cliPackageVersion.version);
40
128
  void thisCommand;
41
129
  });
130
+ // Default action — status dashboard when `pb` is invoked with no command.
131
+ // `pb --help` still works because Commander intercepts --help before the action runs.
132
+ program.action(async () => {
133
+ // Alias handling — forward common shorthands before showing the welcome screen
134
+ if (program.args.length > 0) {
135
+ const args = program.args;
136
+ // `pb start` / `pb start session` → `pb session start`
137
+ if (args[0] === 'start') {
138
+ await runSessionStart();
139
+ return;
140
+ }
141
+ // `pb close` / `pb close session` → `pb session close`
142
+ if (args[0] === 'close') {
143
+ await runSessionClose({});
144
+ return;
145
+ }
146
+ // Unknown command — show a helpful error instead of the welcome screen
147
+ const unknown = args[0];
148
+ process.stderr.write(`error: unknown command '${unknown}'\n`);
149
+ process.stderr.write(`Run 'pb --help' to see available commands.\n`);
150
+ process.exit(1);
151
+ }
152
+ const tier = detectRenderTier();
153
+ // JSON tier — structured status output
154
+ if (tier === 'json') {
155
+ // Check for API key first (sync, no network)
156
+ let hasKey = false;
157
+ try {
158
+ const { getConfig: gc } = await import('./lib/config.js');
159
+ gc();
160
+ hasKey = true;
161
+ }
162
+ catch {
163
+ // No valid key
164
+ }
165
+ if (!hasKey) {
166
+ process.stdout.write(JSON.stringify({
167
+ configured: false,
168
+ hint: 'Run pb login to configure your API key.',
169
+ }) + '\n');
170
+ return;
171
+ }
172
+ const { readSession } = await import('./lib/session.js');
173
+ const { probeWorkspace } = await import('./lib/workspace-probe.js');
174
+ const session = readSession();
175
+ const wsInfo = await probeWorkspace();
176
+ process.stdout.write(JSON.stringify({
177
+ configured: true,
178
+ workspace: wsInfo?.name ?? null,
179
+ session: session ? { id: session.sessionId, startedAt: session.startedAt } : null,
180
+ entryCount: wsInfo?.entryCount ?? null,
181
+ hint: 'Run pb --help for available commands.',
182
+ }) + '\n');
183
+ return;
184
+ }
185
+ // Ink tier: suppress withSpinner output before Ink mounts — spinner writes pollute the TUI canvas
186
+ if (tier === 'ink')
187
+ setQuietMode(true);
188
+ // Resolve state (plain and ink both need it)
189
+ const state = await resolveSetupState();
190
+ // Plain tier — console output driven by state
191
+ if (tier === 'plain') {
192
+ process.stdout.write('\n');
193
+ if (state.stage === 'unconfigured') {
194
+ process.stdout.write(`${bold('Product Brain')} ${dim('— not connected')}\n\n`);
195
+ process.stdout.write(`${heading('Get started')}\n\n`);
196
+ hint('1. pb login Save your API key');
197
+ hint('2. pb connect Connect a workspace');
198
+ hint('3. pb orient -b See what\'s happening');
199
+ process.stdout.write('\n');
200
+ hint('pb --help Show all commands');
201
+ process.stdout.write('\n');
202
+ }
203
+ else if (state.stage === 'authenticated') {
204
+ process.stdout.write(`${bold('Product Brain')} ${dim('— server unreachable')}\n\n`);
205
+ process.stdout.write(` ${green(icons.pass)} Key: configured\n`);
206
+ process.stdout.write(` ! Server: unreachable — run pb doctor to diagnose\n\n`);
207
+ hint('pb session start Start a write session');
208
+ hint('pb doctor Diagnose connection issues');
209
+ hint('pb --help Show all commands');
210
+ process.stdout.write('\n');
211
+ }
212
+ else {
213
+ // workspace-bound or active
214
+ const workspaceName = state.workspaceName ?? 'unknown';
215
+ const entryCount = state.entryCount ?? 0;
216
+ const title = `${bold('Product Brain')} ${dim('—')} ${bold(workspaceName)}`;
217
+ process.stdout.write(`${title}\n\n`);
218
+ process.stdout.write(` ${green(icons.pass)} Key: configured\n`);
219
+ process.stdout.write(` ${green(icons.pass)} Workspace: ${workspaceName} (${entryCount} entries)\n`);
220
+ if (state.sessionActive) {
221
+ process.stdout.write(` ${green(icons.pass)} Session: active\n`);
222
+ }
223
+ else {
224
+ process.stdout.write(` ${dim('- Session: none')}\n`);
225
+ }
226
+ process.stdout.write('\n');
227
+ if (!state.sessionActive) {
228
+ hint('pb session start Start a write session');
229
+ }
230
+ hint('pb orient -b Workspace overview');
231
+ hint('pb --help Show all commands');
232
+ process.stdout.write('\n');
233
+ }
234
+ return;
235
+ }
236
+ // Ink tier — interactive TUI
237
+ const version = cliPackageVersion.version;
238
+ const { render } = await import('ink');
239
+ const { WelcomeCockpit } = await import('./commands/welcome.js');
240
+ const React = await import('react');
241
+ const { waitUntilExit, unmount } = render(React.default.createElement(WelcomeCockpit, { state, version, onExit: () => unmount() }));
242
+ await waitUntilExit();
243
+ });
42
244
  program
43
245
  .command('get <entry-id>')
44
246
  .description('Display full entry by ID (data, relations, last 10 history events)')
@@ -47,25 +249,13 @@ program
47
249
  program.commands.find((c) => c.name() === 'get')?.help();
48
250
  return;
49
251
  }
50
- try {
51
- await runGet({ entryId: entryId.trim() });
52
- }
53
- catch (err) {
54
- console.error(err instanceof Error ? err.message : String(err));
55
- process.exit(1);
56
- }
252
+ await runGet({ entryId: entryId.trim() });
57
253
  });
58
254
  program
59
255
  .command('get-many <entry-ids...>')
60
256
  .description('Fetch multiple entries in parallel (space-separated IDs)')
61
257
  .action(async (entryIds) => {
62
- try {
63
- await runGetMany({ entryIds: entryIds.map((id) => id.trim()).filter(Boolean) });
64
- }
65
- catch (err) {
66
- console.error(err instanceof Error ? err.message : String(err));
67
- process.exit(1);
68
- }
258
+ await runGetMany({ entryIds: entryIds.map((id) => id.trim()).filter(Boolean) });
69
259
  });
70
260
  program
71
261
  .command('context <entry-id>')
@@ -75,13 +265,68 @@ program
75
265
  program.commands.find((c) => c.name() === 'context')?.help();
76
266
  return;
77
267
  }
78
- try {
79
- await runContext({ entryId: entryId.trim() });
268
+ await runContext({ entryId: entryId.trim() });
269
+ });
270
+ program
271
+ .command('changes')
272
+ .description('Detect entries modified and relations created since a given time (BET-239)')
273
+ .requiredOption('--since <duration>', 'Time window: 1h, 6h, 1d, 7d, 30d')
274
+ .action(async (opts) => {
275
+ await runChanges({ since: opts.since });
276
+ });
277
+ program
278
+ .command('walk <entry-id>')
279
+ .description('Directed deep traversal along one relation type to depth 4 (BET-239)')
280
+ .option('-d, --depth <n>', 'Traversal depth 1-4 (default 2)', '2')
281
+ .option('--direction <dir>', 'Traversal direction: outgoing or incoming (default outgoing)', 'outgoing')
282
+ .option('-t, --type <relation-type>', 'Filter by relation type (e.g. depends_on, informs, governs)')
283
+ .action(async (entryId, opts) => {
284
+ const depth = parseInt(opts.depth, 10);
285
+ if (isNaN(depth) || depth < 1 || depth > 4) {
286
+ throw new CLIError('--depth must be between 1 and 4.', {
287
+ code: ErrorCode.VALIDATION_FAILED,
288
+ category: 'validation',
289
+ });
80
290
  }
81
- catch (err) {
82
- console.error(err instanceof Error ? err.message : String(err));
83
- process.exit(1);
291
+ await runChainWalk({
292
+ entryId: entryId.trim(),
293
+ depth,
294
+ direction: opts.direction,
295
+ type: opts.type,
296
+ });
297
+ });
298
+ program
299
+ .command('cross-cut')
300
+ .description('Structural aggregation — all relations of a given type grouped by source collection (BET-239)')
301
+ .requiredOption('--type <relation-type>', 'Relation type to scan (e.g. part_of, informs, governs)')
302
+ .action(async (opts) => {
303
+ await runCrossCut({ type: opts.type });
304
+ });
305
+ program
306
+ .command('brief [type]')
307
+ .description('Brief intelligence queries (BET-239).\n' +
308
+ ' pb brief --skill <name> Incremental delta for a skill (E4)\n' +
309
+ ' pb brief steering Compound: changes + structure + delta + readiness (E6)\n' +
310
+ ' pb brief confidence Compound: changes + active bets + tensions (E6)\n' +
311
+ ' pb brief delta [--since] Compound: changes + relations since timestamp (E6)')
312
+ .option('--skill <name>', 'Skill name for incremental brief (e.g. preflight, shaping, review)')
313
+ .option('--since-last', 'Compare against last brief run (incremental mode)')
314
+ .option('--since <timestamp>', 'ISO 8601 timestamp for delta type (e.g. 2026-03-24T00:00:00Z)')
315
+ .action(async (type, opts) => {
316
+ // If positional arg is a compound type, route to compound brief
317
+ if (type && isCompoundType(type)) {
318
+ await runCompoundBrief({ type, since: opts.since });
319
+ return;
320
+ }
321
+ // Otherwise, require --skill for incremental brief
322
+ if (!opts.skill) {
323
+ throw new CLIError('Usage:\n' +
324
+ ' pb brief --skill <name> Incremental delta\n' +
325
+ ' pb brief steering Compound steering brief\n' +
326
+ ' pb brief confidence Compound confidence pass\n' +
327
+ ' pb brief delta Compound delta sync', { code: ErrorCode.VALIDATION_FAILED, category: 'validation' });
84
328
  }
329
+ await runBrief({ skill: opts.skill, sinceLast: opts.sinceLast });
85
330
  });
86
331
  program
87
332
  .command('search [query...]')
@@ -92,58 +337,83 @@ program
92
337
  program.commands.find((c) => c.name() === 'search')?.help();
93
338
  return;
94
339
  }
95
- try {
96
- await runSearch({ query });
97
- }
98
- catch (err) {
99
- console.error(err instanceof Error ? err.message : String(err));
100
- process.exit(1);
101
- }
340
+ await runSearch({ query });
102
341
  });
103
342
  program
104
343
  .command('orient')
105
344
  .description('Print workspace stage and all orient sections (strategic context, bets, governance, tensions, etc.)')
106
345
  .option('-b, --brief', 'Compact view: stage, counts, top bets, tensions, planned work')
346
+ .option('-t, --task <task>', 'Task description for task-shaped governance and context')
347
+ // SYNC: domain list must match TaskDomain in convex/agentKnowledge/startupResolver.ts
348
+ .option('-s, --scope <domain>', 'Domain scope for governance filtering. Valid values: auth, governance, architecture, product, data-foundation, chainwork, capture-pipeline, ingestion, intelligence-and-operations, review-and-learning, general')
107
349
  .action(async (opts) => {
108
- try {
109
- await runOrient({ brief: opts.brief });
110
- }
111
- catch (err) {
112
- console.error(err instanceof Error ? err.message : String(err));
113
- process.exit(1);
114
- }
350
+ await runOrient({ brief: opts.brief, task: opts.task?.trim() || undefined, scope: opts.scope?.trim() || undefined });
115
351
  });
116
352
  program
117
353
  .command('handshake')
118
- .description('Generate context files for AI developer tools (CLAUDE.md, .cursor/rules/, .github/copilot-instructions.md)')
354
+ .description('Generate context files for AI developer tools (AGENTS.md, .codex/skills/, CLAUDE.md, .cursor/rules/, .github/copilot-instructions.md)')
119
355
  .option('--force', 'Overwrite adapter files even if they exist without auto-generated marker')
120
- .option('--dry-run', 'Show what would be generated without writing files')
356
+ .option('--apply', 'Write files (default: preview only)')
357
+ .option('--dry-run', 'Show what would be generated without writing files (alias for preview)')
121
358
  .option('--init', 'Set up Claude Code integration: team hooks + personal trust level')
122
359
  .option('--level <level>', 'With --init: trust level (guide|work|silent|full-trust). Without --init: content tier (beginner|intermediate|expert)')
360
+ .option('--generate', 'Fetch governance entries from the Chain and merge generated rules (BET-286)')
361
+ .option('--surfaces <list>', 'Comma-separated surfaces to write (cursor,claude,copilot,codex)')
123
362
  .action(async (opts) => {
124
- try {
125
- if (opts.init) {
126
- await runHandshakeInit({ level: opts.level, dryRun: opts.dryRun });
127
- return;
128
- }
129
- await runHandshake({ force: opts.force, dryRun: opts.dryRun, level: opts.level });
363
+ if (opts.init) {
364
+ await runHandshakeInit({ level: opts.level, dryRun: opts.dryRun });
365
+ return;
130
366
  }
131
- catch (err) {
132
- console.error(err instanceof Error ? err.message : String(err));
133
- process.exit(1);
367
+ await runHandshake({ force: opts.force, apply: opts.apply, dryRun: opts.dryRun, level: opts.level, generate: opts.generate, surfaces: opts.surfaces?.split(',') });
368
+ });
369
+ program
370
+ .command('codex-prep <task...>')
371
+ .description('Generate task-specific governance context for Codex (.codex/task-context.md)')
372
+ .option('--dry-run', 'Print to stdout instead of writing file')
373
+ .action(async (taskParts, opts) => {
374
+ const task = taskParts.join(' ').trim();
375
+ if (!task) {
376
+ program.commands.find((c) => c.name() === 'codex-prep')?.help();
377
+ return;
134
378
  }
379
+ await runCodexPrep({ task, dryRun: opts.dryRun });
380
+ });
381
+ program
382
+ .command('init')
383
+ .description('Detect setup state and guide you through configuration (WP-303)')
384
+ .action(async () => {
385
+ await runInit();
386
+ });
387
+ program
388
+ .command('connect <token>')
389
+ .description('Redeem an onboarding token and save your API key locally (FEAT-958). Uses CONVEX_SITE_URL if set, otherwise the production gateway. Override with --gateway or PB_CONNECT_GATEWAY_URL.')
390
+ .option('--gateway <url>', 'Override redeem gateway (default: CONVEX_SITE_URL or production). Use when token came from a different Convex deployment.')
391
+ .action(async (token, opts) => {
392
+ if (!token?.trim()) {
393
+ program.commands.find((c) => c.name() === 'connect')?.help();
394
+ return;
395
+ }
396
+ await runConnect(token.trim(), { gateway: opts.gateway });
135
397
  });
136
398
  program
137
399
  .command('login')
138
400
  .description('Save your API key to ~/.config/productbrain/.env (works from any directory)')
139
401
  .action(async () => {
140
- try {
141
- await runLogin();
142
- }
143
- catch (err) {
144
- console.error(err instanceof Error ? err.message : String(err));
145
- process.exit(1);
146
- }
402
+ await runLogin();
403
+ });
404
+ program
405
+ .command('doctor')
406
+ .description('Check CLI configuration and connectivity')
407
+ .option('--fix', 'Auto-repair common configuration issues')
408
+ .option('--dry-run', 'Preview what --fix would do without changing anything')
409
+ .action(async (opts) => {
410
+ await runDoctor({ fix: opts.fix, dryRun: opts.dryRun });
411
+ });
412
+ program
413
+ .command('setup')
414
+ .description('Guided first-time setup: account, login, workspace, first capture')
415
+ .action(async () => {
416
+ await runSetup();
147
417
  });
148
418
  // --- Write commands (require active session) ---
149
419
  const sessionCmd = program
@@ -154,38 +424,20 @@ sessionCmd
154
424
  .description('Start a tracked write session (opens session, refreshes context)')
155
425
  .option('--json', 'Output machine-readable JSON (deprecated: use global --json flag)')
156
426
  .action(async (opts) => {
157
- try {
158
- await runSessionStart({ json: opts.json });
159
- }
160
- catch (err) {
161
- console.error(err instanceof Error ? err.message : String(err));
162
- process.exit(1);
163
- }
427
+ await runSessionStart({ json: opts.json });
164
428
  });
165
429
  sessionCmd
166
430
  .command('id')
167
431
  .description('Print current session ID to stdout (machine-readable, TEN-707)')
168
432
  .action(() => {
169
- try {
170
- runSessionId();
171
- }
172
- catch (err) {
173
- console.error(err instanceof Error ? err.message : String(err));
174
- process.exit(1);
175
- }
433
+ runSessionId();
176
434
  });
177
435
  sessionCmd
178
436
  .command('close')
179
437
  .description('Close the active session (wrapup, refresh context)')
180
438
  .option('--force', 'Clear local session state even if server close fails')
181
439
  .action(async (opts) => {
182
- try {
183
- await runSessionClose({ force: opts.force });
184
- }
185
- catch (err) {
186
- console.error(err instanceof Error ? err.message : String(err));
187
- process.exit(1);
188
- }
440
+ await runSessionClose({ force: opts.force });
189
441
  });
190
442
  program
191
443
  .command('capture [text...]')
@@ -195,28 +447,30 @@ program
195
447
  .option('-c, --collection <slug>', 'Explicit collection (skip auto-classification)')
196
448
  .option('-l, --link <entry-id>', 'Link new entry to an existing entry (TEN-705)')
197
449
  .option('-t, --type <relation-type>', 'Relation type for --link (default: surfaces_tension_in)')
450
+ .option('--source-ref <ref>', 'Source reference URI (BET-240 E2: e.g. "meeting-2026-03-28.md")')
451
+ .option('--source-excerpt <text>', 'Verbatim source excerpt (BET-240 E2)')
198
452
  .option('--json', 'Output machine-readable JSON (deprecated: use global --json flag)')
453
+ .option('--suggest-only', 'Show grounding preview (possible duplicates, related entries) without creating entry (WP-319)')
454
+ .option('--strict', 'Prompt y/N before capturing when a possible duplicate is detected (WP-319)')
199
455
  .action(async (textParts = [], opts) => {
200
456
  const text = textParts.join(' ').trim();
201
457
  if (!text && !opts.name) {
202
458
  program.commands.find((c) => c.name() === 'capture')?.help();
203
459
  return;
204
460
  }
205
- try {
206
- await runCapture({
207
- text: text || opts.name || '',
208
- name: opts.name,
209
- description: opts.description,
210
- collection: opts.collection,
211
- link: opts.link,
212
- type: opts.type,
213
- json: opts.json,
214
- });
215
- }
216
- catch (err) {
217
- console.error(err instanceof Error ? err.message : String(err));
218
- process.exit(1);
219
- }
461
+ await runCapture({
462
+ text: text || opts.name || '',
463
+ name: opts.name,
464
+ description: opts.description,
465
+ collection: opts.collection,
466
+ link: opts.link,
467
+ type: opts.type,
468
+ sourceRef: opts.sourceRef,
469
+ sourceExcerpt: opts.sourceExcerpt,
470
+ json: opts.json,
471
+ suggestOnly: opts.suggestOnly,
472
+ strict: opts.strict,
473
+ });
220
474
  });
221
475
  // --- Update command (TEN-703) ---
222
476
  program
@@ -225,59 +479,71 @@ program
225
479
  .option('-f, --field <key=value>', 'Set a data field (repeatable)', (val, prev) => [...prev, val], [])
226
480
  .option('--name <name>', 'Update entry name')
227
481
  .option('--status <status>', 'Update entry status (draft | active | deprecated | archived)')
482
+ .option('--workflow-status <status>', 'Set workflow status (server-validated)')
228
483
  .option('--note <text>', 'Change note for history')
229
484
  .action(async (entryId, opts) => {
230
- try {
231
- await runUpdate({
232
- entryId,
233
- field: opts.field,
234
- name: opts.name,
235
- status: opts.status,
236
- note: opts.note,
237
- });
238
- }
239
- catch (err) {
240
- console.error(err instanceof Error ? err.message : String(err));
241
- process.exit(1);
485
+ await runUpdate({
486
+ entryId,
487
+ field: opts.field,
488
+ name: opts.name,
489
+ status: opts.status,
490
+ workflowStatus: opts.workflowStatus,
491
+ note: opts.note,
492
+ });
493
+ });
494
+ // --- Promote command (Wave 2 CLI Polish) ---
495
+ program
496
+ .command('verify <entry-id>')
497
+ .description('Mark an entry as verified (BET-240: source fidelity trust signal)')
498
+ .action(async (entryId) => {
499
+ if (!entryId?.trim()) {
500
+ program.commands.find((c) => c.name() === 'verify')?.help();
501
+ return;
242
502
  }
503
+ await runVerify({ entryId: entryId.trim() });
504
+ });
505
+ program
506
+ .command('promote <entry-id>')
507
+ .description('Promote entry from draft to active (commit to SSOT)')
508
+ .option('-m, --message <text>', 'Commit message')
509
+ .action(async (entryId, opts) => {
510
+ await runPromote({ entryId, message: opts.message });
243
511
  });
244
512
  // --- Relate / Unrelate commands (TEN-704) ---
245
513
  program
246
514
  .command('relate <from-id> <type> <to-id>')
247
515
  .description('Add a typed relation between two entries (requires active session)')
248
- .action(async (fromId, type, toId) => {
249
- try {
250
- await runRelate({ fromId, type, toId });
251
- }
252
- catch (err) {
253
- console.error(err instanceof Error ? err.message : String(err));
254
- process.exit(1);
255
- }
516
+ .option('--if-missing', 'Only create relation if it does not already exist')
517
+ .action(async (fromId, type, toId, opts) => {
518
+ await runRelate({ fromId, type, toId, ifMissing: opts.ifMissing });
256
519
  });
257
520
  program
258
521
  .command('unrelate <from-id> <type> <to-id>')
259
522
  .description('Remove a typed relation between two entries (requires active session)')
260
523
  .action(async (fromId, type, toId) => {
261
- try {
262
- await runUnrelate({ fromId, type, toId });
263
- }
264
- catch (err) {
265
- console.error(err instanceof Error ? err.message : String(err));
266
- process.exit(1);
267
- }
524
+ await runUnrelate({ fromId, type, toId });
268
525
  });
269
526
  // --- Ingest command (BET-81) ---
270
527
  program
271
528
  .command('ingest <pattern>')
272
529
  .description('Bulk ingest documents to Chain as drafts')
273
- .action(async (pattern) => {
274
- try {
275
- await runIngest({ pattern });
276
- }
277
- catch (err) {
278
- console.error(err instanceof Error ? err.message : String(err));
279
- process.exit(1);
530
+ .option('--dry-run', 'Stage entries without auto-committing. Shows summary only.')
531
+ .option('--resume', 'Skip files whose sourceRef is already committed in staging.')
532
+ .option('--concurrency <n>', 'Process up to N files in parallel (default 1, max 5).', '1')
533
+ .action(async (pattern, opts) => {
534
+ const concurrency = parseInt(opts.concurrency ?? '1', 10);
535
+ if (Number.isNaN(concurrency) || concurrency < 1) {
536
+ throw new CLIError('--concurrency must be a positive integer.', {
537
+ code: ErrorCode.VALIDATION_FAILED,
538
+ category: 'validation',
539
+ });
280
540
  }
541
+ await runIngest({
542
+ pattern,
543
+ dryRun: opts.dryRun,
544
+ resume: opts.resume,
545
+ concurrency,
546
+ });
281
547
  });
282
548
  // --- Fields command (BET-181 Slice 2) ---
283
549
  program
@@ -288,13 +554,7 @@ program
288
554
  program.commands.find((c) => c.name() === 'fields')?.help();
289
555
  return;
290
556
  }
291
- try {
292
- await runFields({ collectionSlug: collection.trim() });
293
- }
294
- catch (err) {
295
- console.error(err instanceof Error ? err.message : String(err));
296
- process.exit(1);
297
- }
557
+ await runFields({ collectionSlug: collection.trim() });
298
558
  });
299
559
  // --- Constellation command (BET-181 Slice 3) ---
300
560
  program
@@ -305,13 +565,233 @@ program
305
565
  program.commands.find((c) => c.name() === 'constellation')?.help();
306
566
  return;
307
567
  }
308
- try {
309
- await runConstellation({ entryId: entryId.trim() });
568
+ await runConstellation({ entryId: entryId.trim() });
569
+ });
570
+ // --- Audit command (BET-182 Slice 2) ---
571
+ program
572
+ .command('audit <entry-ids...>')
573
+ .description('Run STD-113 hygiene audit on bet(s) — 13 gates, exit code reflects verdict')
574
+ .option('--phase <phase>', 'Override phase detection (shaping | handoff)')
575
+ .option('--gate <name>', 'Run only specified gate(s) (repeatable)', (val, prev) => [...prev, val], [])
576
+ .option('--fix', 'Auto-execute exact fixes via pb update, rerun once')
577
+ .option('--verbose', 'Show all gates including PASS detail')
578
+ .action(async (entryIds, opts) => {
579
+ await runAudit({
580
+ entryIds: entryIds.map((id) => id.trim()).filter(Boolean),
581
+ phase: opts.phase,
582
+ gate: opts.gate,
583
+ fix: opts.fix,
584
+ verbose: opts.verbose,
585
+ });
586
+ });
587
+ program
588
+ .command('brand-pack')
589
+ .description('Internal marketing: structured community copy via OpenRouter (requires OPENROUTER_API_KEY). Forwards args to scripts/brand-pack.mjs')
590
+ .allowUnknownOption(true)
591
+ .allowExcessArguments(true)
592
+ .action(() => {
593
+ runBrandPack(process.argv);
594
+ });
595
+ // --- Governance proposal commands (BET-221 Slice 3) ---
596
+ program
597
+ .command('proposals')
598
+ .description('List open consent proposals with expiry countdown (BET-221)')
599
+ .action(async () => {
600
+ await runProposals();
601
+ });
602
+ program
603
+ .command('accept [proposal-id]')
604
+ .description('Approve a consent proposal by ID, or --auto to batch-approve all')
605
+ .option('-a, --auto', 'Auto-approve all open proposals (skip contradictions)')
606
+ .action(async (proposalId, opts) => {
607
+ if (!proposalId && !opts.auto) {
608
+ throw new CLIError('Usage: pb accept <proposal-id> or pb accept --auto', {
609
+ code: ErrorCode.VALIDATION_FAILED,
610
+ category: 'validation',
611
+ });
310
612
  }
311
- catch (err) {
312
- console.error(err instanceof Error ? err.message : String(err));
313
- process.exit(1);
613
+ await runAccept({ proposalId, auto: opts.auto });
614
+ });
615
+ program
616
+ .command('reject <proposal-id>')
617
+ .description('Reject a consent proposal with a required reason (BR-7)')
618
+ .requiredOption('-r, --reason <text>', 'Reason for rejection (required)')
619
+ .action(async (proposalId, opts) => {
620
+ await runReject({ proposalId, reason: opts.reason });
621
+ });
622
+ // --- Collections command (BET-280 Slice 1) ---
623
+ const collectionsCmd = program
624
+ .command('collections')
625
+ .description('Inspect and audit workspace collection registry (BET-280)');
626
+ collectionsCmd
627
+ .command('list')
628
+ .description('List all collections — slug, name, field count, icon')
629
+ .action(async () => {
630
+ await runCollectionsList();
631
+ });
632
+ collectionsCmd
633
+ .command('get <slug>')
634
+ .description('Show full detail for a collection by slug')
635
+ .action(async (slug) => {
636
+ if (!slug?.trim()) {
637
+ program.commands.find((c) => c.name() === 'collections')?.help();
638
+ return;
639
+ }
640
+ await runCollectionsGet({ slug: slug.trim() });
641
+ });
642
+ collectionsCmd
643
+ .command('audit')
644
+ .description('Collection health report — classification, icon, displayHint coverage, schema gaps')
645
+ .action(async () => {
646
+ await runCollectionsAudit();
647
+ });
648
+ collectionsCmd
649
+ .command('export')
650
+ .description('Export all system_collection_definitions with full classification metadata (admin only)')
651
+ .action(async () => {
652
+ await runCollectionsExport();
653
+ });
654
+ // --- Workspace operator commands (WP-305 Slice 4) ---
655
+ const workspaceCmd = program
656
+ .command('workspace')
657
+ .description('Operator commands for workspace health and repair (WP-305)');
658
+ workspaceCmd
659
+ .command('verify')
660
+ .description('Check workspace health — seeds, collections, glossary (admin only)')
661
+ .action(async () => {
662
+ await runWorkspaceVerify();
663
+ });
664
+ workspaceCmd
665
+ .command('repair')
666
+ .description('Backfill missing seeds for the active workspace (admin only)')
667
+ .action(async () => {
668
+ await runWorkspaceRepair();
669
+ });
670
+ // --- Definitions diff command (WP-305 Slice 4) ---
671
+ const definitionsCmd = program
672
+ .command('definitions')
673
+ .description('Inspect and compare workspace definitions (WP-305)');
674
+ definitionsCmd
675
+ .command('diff [file]')
676
+ .description('Compare local dev-system-collections.json against server definitions (admin only)')
677
+ .action(async (file) => {
678
+ await runDefinitionsDiff({ file });
679
+ });
680
+ // --- Method commands (WP-329 S1: method visibility) ---
681
+ const methodCmd = program
682
+ .command('method')
683
+ .description('Inspect published methods (skills + rules) and their per-surface adapter status (WP-329)');
684
+ methodCmd
685
+ .command('ls')
686
+ .description('List all methods with version, published status, and adapter presence')
687
+ .action(async () => {
688
+ await runMethodList();
689
+ });
690
+ methodCmd
691
+ .command('show <name>')
692
+ .description('Show details for one method: frontmatter, Chain entry, and per-adapter fork status')
693
+ .action(async (name) => {
694
+ if (!name?.trim()) {
695
+ program.commands.find((c) => c.name() === 'method')?.help();
696
+ return;
697
+ }
698
+ await runMethodShow({ name: name.trim() });
699
+ });
700
+ methodCmd
701
+ .command('diff <name>')
702
+ .description('Show diff between local .productbrain/ source and last-published Chain version (WP-329 S2)')
703
+ .action(async (name) => {
704
+ if (!name?.trim()) {
705
+ program.commands.find((c) => c.name() === 'method')?.help();
706
+ return;
707
+ }
708
+ await runMethodDiff({ name: name.trim() });
709
+ });
710
+ methodCmd
711
+ .command('publish <name>')
712
+ .description('Publish a local .productbrain/ method (skill or rule) to the Chain methods collection (WP-329 S3)')
713
+ .option('--force', 'Publish even when local body matches the last-published version (override D4 no-op guard)')
714
+ .action(async (name, opts) => {
715
+ if (!name?.trim()) {
716
+ program.commands.find((c) => c.name() === 'method')?.help();
717
+ return;
718
+ }
719
+ await runMethodPublish({ name: name.trim(), force: opts.force });
720
+ });
721
+ // --- Profile commands (WP-302 Slice 2) ---
722
+ const profileCmd = program
723
+ .command('profile')
724
+ .description('Manage workspace profiles (WP-302: multi-workspace support)');
725
+ profileCmd
726
+ .command('list')
727
+ .description('List all profiles, mark active one')
728
+ .action(async () => {
729
+ await runProfileList();
730
+ });
731
+ profileCmd
732
+ .command('create <name>')
733
+ .description('Create a new profile with an API key')
734
+ .requiredOption('--api-key <key>', `API key (${API_KEY_PREFIX}...)`)
735
+ .option('--url <url>', 'Convex site URL (defaults to production)')
736
+ .action(async (name, opts) => {
737
+ await runProfileCreate({ name, apiKey: opts.apiKey, url: opts.url });
738
+ });
739
+ profileCmd
740
+ .command('use <name>')
741
+ .description('Switch active profile (closes any active session)')
742
+ .action(async (name) => {
743
+ await runProfileUse({ name });
744
+ });
745
+ profileCmd
746
+ .command('delete <name>')
747
+ .description('Delete a profile (cannot delete active or last profile)')
748
+ .action(async (name) => {
749
+ await runProfileDelete({ name });
750
+ });
751
+ // --- Glossary command (WP-302 Slice 4) ---
752
+ program
753
+ .command('glossary')
754
+ .description('Show key Product Brain CLI terms and definitions')
755
+ .action(() => {
756
+ if (isJsonMode()) {
757
+ process.stdout.write(JSON.stringify(GLOSSARY) + '\n');
758
+ return;
759
+ }
760
+ const lines = [
761
+ '',
762
+ heading('Glossary'),
763
+ '',
764
+ formatGlossary(),
765
+ '',
766
+ ];
767
+ process.stdout.write(lines.join('\n') + '\n');
768
+ });
769
+ // --- Usage command (WP-322 S4, FEAT-1011) ---
770
+ program
771
+ .command('usage')
772
+ .description('Session and activity dashboard — 4-tab Ink TUI (WP-322)')
773
+ .option('--json', 'Output machine-readable JSON (sessions, entries30d, activity array)')
774
+ .action(async (opts) => {
775
+ await runUsage({ json: opts.json });
776
+ });
777
+ // --- Admin command group (WP-312 S2, FEAT-969) ---
778
+ program.addCommand(createAdminCommand());
779
+ // --- Upgrade command (WP-322 S1: ambient update notification) ---
780
+ program
781
+ .command('upgrade')
782
+ .description('Upgrade pb CLI to the latest version (npm install -g @productbrain/cli@latest)')
783
+ .action(() => {
784
+ if (isJsonMode()) {
785
+ process.stdout.write(JSON.stringify({
786
+ command: 'npm install -g @productbrain/cli@latest',
787
+ hint: 'Run the command above to upgrade pb CLI.',
788
+ }) + '\n');
789
+ return;
314
790
  }
791
+ process.stdout.write('\n');
792
+ process.stdout.write(`${bold('Upgrade pb CLI')} ${dim('—')} run the command below:\n\n`);
793
+ process.stdout.write(` npm install -g @productbrain/cli@latest\n\n`);
315
794
  });
316
- program.parse();
795
+ // Parse with global error handler — all uncaught errors route through handleError
796
+ program.parseAsync(process.argv).catch(handleError);
317
797
  //# sourceMappingURL=index.js.map