@productbrain/cli 0.1.0-beta.7 → 0.1.0-beta.71

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