@productbrain/cli 0.1.0-beta.1 → 0.1.0-beta.102

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