@productbrain/cli 0.1.0-beta.67 → 0.1.0-beta.6713

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 (1433) hide show
  1. package/README.md +8 -2
  2. package/dist/__tests__/adapters.test.js +60 -12
  3. package/dist/__tests__/adapters.test.js.map +1 -1
  4. package/dist/__tests__/adminConfig.test.d.ts +18 -0
  5. package/dist/__tests__/adminConfig.test.d.ts.map +1 -0
  6. package/dist/__tests__/adminConfig.test.js +221 -0
  7. package/dist/__tests__/adminConfig.test.js.map +1 -0
  8. package/dist/__tests__/audit.test.js +130 -72
  9. package/dist/__tests__/audit.test.js.map +1 -1
  10. package/dist/__tests__/batch-transformations.test.js +2 -26
  11. package/dist/__tests__/batch-transformations.test.js.map +1 -1
  12. package/dist/__tests__/canonicalRefs.vocab.test.d.ts +2 -0
  13. package/dist/__tests__/canonicalRefs.vocab.test.d.ts.map +1 -0
  14. package/dist/__tests__/canonicalRefs.vocab.test.js +251 -0
  15. package/dist/__tests__/canonicalRefs.vocab.test.js.map +1 -0
  16. package/dist/__tests__/capture-receipt-coaching.test.d.ts +2 -0
  17. package/dist/__tests__/capture-receipt-coaching.test.d.ts.map +1 -0
  18. package/dist/__tests__/capture-receipt-coaching.test.js +89 -0
  19. package/dist/__tests__/capture-receipt-coaching.test.js.map +1 -0
  20. package/dist/__tests__/capture-receipt-spine-floor.test.d.ts +2 -0
  21. package/dist/__tests__/capture-receipt-spine-floor.test.d.ts.map +1 -0
  22. package/dist/__tests__/capture-receipt-spine-floor.test.js +45 -0
  23. package/dist/__tests__/capture-receipt-spine-floor.test.js.map +1 -0
  24. package/dist/__tests__/capture.test.js +1304 -105
  25. package/dist/__tests__/capture.test.js.map +1 -1
  26. package/dist/__tests__/client-binding-guard.test.d.ts +2 -0
  27. package/dist/__tests__/client-binding-guard.test.d.ts.map +1 -0
  28. package/dist/__tests__/client-binding-guard.test.js +84 -0
  29. package/dist/__tests__/client-binding-guard.test.js.map +1 -0
  30. package/dist/__tests__/coaching-mirror-drift.test.d.ts +2 -0
  31. package/dist/__tests__/coaching-mirror-drift.test.d.ts.map +1 -0
  32. package/dist/__tests__/coaching-mirror-drift.test.js +47 -0
  33. package/dist/__tests__/coaching-mirror-drift.test.js.map +1 -0
  34. package/dist/__tests__/codex-prep-parity.test.d.ts +2 -0
  35. package/dist/__tests__/codex-prep-parity.test.d.ts.map +1 -0
  36. package/dist/__tests__/codex-prep-parity.test.js +106 -0
  37. package/dist/__tests__/codex-prep-parity.test.js.map +1 -0
  38. package/dist/__tests__/collection-registry-seed-drift.test.d.ts +2 -0
  39. package/dist/__tests__/collection-registry-seed-drift.test.d.ts.map +1 -0
  40. package/dist/__tests__/collection-registry-seed-drift.test.js +81 -0
  41. package/dist/__tests__/collection-registry-seed-drift.test.js.map +1 -0
  42. package/dist/__tests__/config-prod-fallthrough.test.d.ts +2 -0
  43. package/dist/__tests__/config-prod-fallthrough.test.d.ts.map +1 -0
  44. package/dist/__tests__/config-prod-fallthrough.test.js +93 -0
  45. package/dist/__tests__/config-prod-fallthrough.test.js.map +1 -0
  46. package/dist/__tests__/config.test.d.ts +1 -1
  47. package/dist/__tests__/config.test.js +845 -18
  48. package/dist/__tests__/config.test.js.map +1 -1
  49. package/dist/__tests__/constants.test.js +6 -1
  50. package/dist/__tests__/constants.test.js.map +1 -1
  51. package/dist/__tests__/constellation.test.js +40 -28
  52. package/dist/__tests__/constellation.test.js.map +1 -1
  53. package/dist/__tests__/context-strategy.test.js +8 -8
  54. package/dist/__tests__/context-strategy.test.js.map +1 -1
  55. package/dist/__tests__/conversation.test.d.ts +2 -0
  56. package/dist/__tests__/conversation.test.d.ts.map +1 -0
  57. package/dist/__tests__/conversation.test.js +113 -0
  58. package/dist/__tests__/conversation.test.js.map +1 -0
  59. package/dist/__tests__/entry-formatter.test.d.ts +2 -0
  60. package/dist/__tests__/entry-formatter.test.d.ts.map +1 -0
  61. package/dist/__tests__/entry-formatter.test.js +110 -0
  62. package/dist/__tests__/entry-formatter.test.js.map +1 -0
  63. package/dist/__tests__/entry-preflight.test.d.ts +2 -0
  64. package/dist/__tests__/entry-preflight.test.d.ts.map +1 -0
  65. package/dist/__tests__/entry-preflight.test.js +58 -0
  66. package/dist/__tests__/entry-preflight.test.js.map +1 -0
  67. package/dist/__tests__/entryAccept-batch.test.d.ts +2 -0
  68. package/dist/__tests__/entryAccept-batch.test.d.ts.map +1 -0
  69. package/dist/__tests__/entryAccept-batch.test.js +305 -0
  70. package/dist/__tests__/entryAccept-batch.test.js.map +1 -0
  71. package/dist/__tests__/entryAccept.test.d.ts +2 -0
  72. package/dist/__tests__/entryAccept.test.d.ts.map +1 -0
  73. package/dist/__tests__/entryAccept.test.js +433 -0
  74. package/dist/__tests__/entryAccept.test.js.map +1 -0
  75. package/dist/__tests__/entryArchive.test.d.ts +2 -0
  76. package/dist/__tests__/entryArchive.test.d.ts.map +1 -0
  77. package/dist/__tests__/entryArchive.test.js +35 -0
  78. package/dist/__tests__/entryArchive.test.js.map +1 -0
  79. package/dist/__tests__/entryOwn.test.d.ts +2 -0
  80. package/dist/__tests__/entryOwn.test.d.ts.map +1 -0
  81. package/dist/__tests__/entryOwn.test.js +50 -0
  82. package/dist/__tests__/entryOwn.test.js.map +1 -0
  83. package/dist/__tests__/envelope-contract.test.d.ts +15 -0
  84. package/dist/__tests__/envelope-contract.test.d.ts.map +1 -0
  85. package/dist/__tests__/envelope-contract.test.js +154 -0
  86. package/dist/__tests__/envelope-contract.test.js.map +1 -0
  87. package/dist/__tests__/errors.test.js +30 -0
  88. package/dist/__tests__/errors.test.js.map +1 -1
  89. package/dist/__tests__/fields.test.js +20 -20
  90. package/dist/__tests__/fields.test.js.map +1 -1
  91. package/dist/__tests__/gateway-dry-run-timeout.test.d.ts +2 -0
  92. package/dist/__tests__/gateway-dry-run-timeout.test.d.ts.map +1 -0
  93. package/dist/__tests__/gateway-dry-run-timeout.test.js +70 -0
  94. package/dist/__tests__/gateway-dry-run-timeout.test.js.map +1 -0
  95. package/dist/__tests__/gateway-timeout-body-phase.test.d.ts +2 -0
  96. package/dist/__tests__/gateway-timeout-body-phase.test.d.ts.map +1 -0
  97. package/dist/__tests__/gateway-timeout-body-phase.test.js +121 -0
  98. package/dist/__tests__/gateway-timeout-body-phase.test.js.map +1 -0
  99. package/dist/__tests__/handshake-augment.test.d.ts +2 -0
  100. package/dist/__tests__/handshake-augment.test.d.ts.map +1 -0
  101. package/dist/__tests__/handshake-augment.test.js +422 -0
  102. package/dist/__tests__/handshake-augment.test.js.map +1 -0
  103. package/dist/__tests__/handshake-dormancy.test.d.ts +2 -0
  104. package/dist/__tests__/handshake-dormancy.test.d.ts.map +1 -0
  105. package/dist/__tests__/handshake-dormancy.test.js +82 -0
  106. package/dist/__tests__/handshake-dormancy.test.js.map +1 -0
  107. package/dist/__tests__/handshake-formatter.test.d.ts +2 -0
  108. package/dist/__tests__/handshake-formatter.test.d.ts.map +1 -0
  109. package/dist/__tests__/handshake-formatter.test.js +111 -0
  110. package/dist/__tests__/handshake-formatter.test.js.map +1 -0
  111. package/dist/__tests__/handshake-preview.test.d.ts +2 -0
  112. package/dist/__tests__/handshake-preview.test.d.ts.map +1 -0
  113. package/dist/__tests__/handshake-preview.test.js +1092 -0
  114. package/dist/__tests__/handshake-preview.test.js.map +1 -0
  115. package/dist/__tests__/handshake.e2e.test.d.ts +2 -0
  116. package/dist/__tests__/handshake.e2e.test.d.ts.map +1 -0
  117. package/dist/__tests__/handshake.e2e.test.js +485 -0
  118. package/dist/__tests__/handshake.e2e.test.js.map +1 -0
  119. package/dist/__tests__/handshake.test.js +962 -4
  120. package/dist/__tests__/handshake.test.js.map +1 -1
  121. package/dist/__tests__/health-gap-kinds-drift.test.d.ts +2 -0
  122. package/dist/__tests__/health-gap-kinds-drift.test.d.ts.map +1 -0
  123. package/dist/__tests__/health-gap-kinds-drift.test.js +41 -0
  124. package/dist/__tests__/health-gap-kinds-drift.test.js.map +1 -0
  125. package/dist/__tests__/hook-intents.test.d.ts +2 -0
  126. package/dist/__tests__/hook-intents.test.d.ts.map +1 -0
  127. package/dist/__tests__/hook-intents.test.js +184 -0
  128. package/dist/__tests__/hook-intents.test.js.map +1 -0
  129. package/dist/__tests__/ingest.test.js +37 -28
  130. package/dist/__tests__/ingest.test.js.map +1 -1
  131. package/dist/__tests__/init.test.js +51 -14
  132. package/dist/__tests__/init.test.js.map +1 -1
  133. package/dist/__tests__/kernel-value-sets-drift.test.d.ts +2 -0
  134. package/dist/__tests__/kernel-value-sets-drift.test.d.ts.map +1 -0
  135. package/dist/__tests__/kernel-value-sets-drift.test.js +46 -0
  136. package/dist/__tests__/kernel-value-sets-drift.test.js.map +1 -0
  137. package/dist/__tests__/kernel-value-sets-generator.test.d.ts +2 -0
  138. package/dist/__tests__/kernel-value-sets-generator.test.d.ts.map +1 -0
  139. package/dist/__tests__/kernel-value-sets-generator.test.js +108 -0
  140. package/dist/__tests__/kernel-value-sets-generator.test.js.map +1 -0
  141. package/dist/__tests__/manifest.test.d.ts +6 -0
  142. package/dist/__tests__/manifest.test.d.ts.map +1 -0
  143. package/dist/__tests__/manifest.test.js +255 -0
  144. package/dist/__tests__/manifest.test.js.map +1 -0
  145. package/dist/__tests__/method-publish-coherency.test.d.ts +9 -0
  146. package/dist/__tests__/method-publish-coherency.test.d.ts.map +1 -0
  147. package/dist/__tests__/method-publish-coherency.test.js +71 -0
  148. package/dist/__tests__/method-publish-coherency.test.js.map +1 -0
  149. package/dist/__tests__/method-registry.integration.test.d.ts +6 -0
  150. package/dist/__tests__/method-registry.integration.test.d.ts.map +1 -0
  151. package/dist/__tests__/method-registry.integration.test.js +17 -0
  152. package/dist/__tests__/method-registry.integration.test.js.map +1 -0
  153. package/dist/__tests__/method-registry.test.d.ts +12 -0
  154. package/dist/__tests__/method-registry.test.d.ts.map +1 -0
  155. package/dist/__tests__/method-registry.test.js +86 -0
  156. package/dist/__tests__/method-registry.test.js.map +1 -0
  157. package/dist/__tests__/migrate-setup-session-refusal.test.d.ts +2 -0
  158. package/dist/__tests__/migrate-setup-session-refusal.test.d.ts.map +1 -0
  159. package/dist/__tests__/migrate-setup-session-refusal.test.js +65 -0
  160. package/dist/__tests__/migrate-setup-session-refusal.test.js.map +1 -0
  161. package/dist/__tests__/missingPin.test.d.ts +11 -0
  162. package/dist/__tests__/missingPin.test.d.ts.map +1 -0
  163. package/dist/__tests__/missingPin.test.js +233 -0
  164. package/dist/__tests__/missingPin.test.js.map +1 -0
  165. package/dist/__tests__/notice-marker.test.d.ts +2 -0
  166. package/dist/__tests__/notice-marker.test.d.ts.map +1 -0
  167. package/dist/__tests__/notice-marker.test.js +176 -0
  168. package/dist/__tests__/notice-marker.test.js.map +1 -0
  169. package/dist/__tests__/onboarding-path-b.test.js +4 -4
  170. package/dist/__tests__/onboarding-path-b.test.js.map +1 -1
  171. package/dist/__tests__/orient.test.js +491 -14
  172. package/dist/__tests__/orient.test.js.map +1 -1
  173. package/dist/__tests__/perimeter.test.d.ts +2 -0
  174. package/dist/__tests__/perimeter.test.d.ts.map +1 -0
  175. package/dist/__tests__/perimeter.test.js +165 -0
  176. package/dist/__tests__/perimeter.test.js.map +1 -0
  177. package/dist/__tests__/personal-layer.test.d.ts +11 -0
  178. package/dist/__tests__/personal-layer.test.d.ts.map +1 -0
  179. package/dist/__tests__/personal-layer.test.js +268 -0
  180. package/dist/__tests__/personal-layer.test.js.map +1 -0
  181. package/dist/__tests__/preview-key-refresh.test.d.ts +2 -0
  182. package/dist/__tests__/preview-key-refresh.test.d.ts.map +1 -0
  183. package/dist/__tests__/preview-key-refresh.test.js +126 -0
  184. package/dist/__tests__/preview-key-refresh.test.js.map +1 -0
  185. package/dist/__tests__/profiles.test.js +613 -5
  186. package/dist/__tests__/profiles.test.js.map +1 -1
  187. package/dist/__tests__/proof-run.test.d.ts +2 -0
  188. package/dist/__tests__/proof-run.test.d.ts.map +1 -0
  189. package/dist/__tests__/proof-run.test.js +255 -0
  190. package/dist/__tests__/proof-run.test.js.map +1 -0
  191. package/dist/__tests__/proposals.test.js +19 -19
  192. package/dist/__tests__/proposals.test.js.map +1 -1
  193. package/dist/__tests__/rate-limit-resilience.test.d.ts +7 -0
  194. package/dist/__tests__/rate-limit-resilience.test.d.ts.map +1 -0
  195. package/dist/__tests__/rate-limit-resilience.test.js +209 -0
  196. package/dist/__tests__/rate-limit-resilience.test.js.map +1 -0
  197. package/dist/__tests__/read-target-notice.test.d.ts +2 -0
  198. package/dist/__tests__/read-target-notice.test.d.ts.map +1 -0
  199. package/dist/__tests__/read-target-notice.test.js +129 -0
  200. package/dist/__tests__/read-target-notice.test.js.map +1 -0
  201. package/dist/__tests__/relate.test.js +260 -16
  202. package/dist/__tests__/relate.test.js.map +1 -1
  203. package/dist/__tests__/repo-detect.test.js +9 -14
  204. package/dist/__tests__/repo-detect.test.js.map +1 -1
  205. package/dist/__tests__/reportedProfile.test.d.ts +2 -0
  206. package/dist/__tests__/reportedProfile.test.d.ts.map +1 -0
  207. package/dist/__tests__/reportedProfile.test.js +328 -0
  208. package/dist/__tests__/reportedProfile.test.js.map +1 -0
  209. package/dist/__tests__/restore.test.d.ts +2 -0
  210. package/dist/__tests__/restore.test.d.ts.map +1 -0
  211. package/dist/__tests__/restore.test.js +85 -0
  212. package/dist/__tests__/restore.test.js.map +1 -0
  213. package/dist/__tests__/route-latency-budget.test.d.ts +2 -0
  214. package/dist/__tests__/route-latency-budget.test.d.ts.map +1 -0
  215. package/dist/__tests__/route-latency-budget.test.js +103 -0
  216. package/dist/__tests__/route-latency-budget.test.js.map +1 -0
  217. package/dist/__tests__/runner.test.js +59 -44
  218. package/dist/__tests__/runner.test.js.map +1 -1
  219. package/dist/__tests__/session-binding-refusal-tenant.test.d.ts +2 -0
  220. package/dist/__tests__/session-binding-refusal-tenant.test.d.ts.map +1 -0
  221. package/dist/__tests__/session-binding-refusal-tenant.test.js +112 -0
  222. package/dist/__tests__/session-binding-refusal-tenant.test.js.map +1 -0
  223. package/dist/__tests__/session-close-loop.test.d.ts +2 -0
  224. package/dist/__tests__/session-close-loop.test.d.ts.map +1 -0
  225. package/dist/__tests__/session-close-loop.test.js +215 -0
  226. package/dist/__tests__/session-close-loop.test.js.map +1 -0
  227. package/dist/__tests__/session-label.test.d.ts +2 -0
  228. package/dist/__tests__/session-label.test.d.ts.map +1 -0
  229. package/dist/__tests__/session-label.test.js +46 -0
  230. package/dist/__tests__/session-label.test.js.map +1 -0
  231. package/dist/__tests__/session-list-show.test.d.ts +2 -0
  232. package/dist/__tests__/session-list-show.test.d.ts.map +1 -0
  233. package/dist/__tests__/session-list-show.test.js +174 -0
  234. package/dist/__tests__/session-list-show.test.js.map +1 -0
  235. package/dist/__tests__/session-reset.test.d.ts +2 -0
  236. package/dist/__tests__/session-reset.test.d.ts.map +1 -0
  237. package/dist/__tests__/session-reset.test.js +138 -0
  238. package/dist/__tests__/session-reset.test.js.map +1 -0
  239. package/dist/__tests__/session-resume-backstop.test.d.ts +2 -0
  240. package/dist/__tests__/session-resume-backstop.test.d.ts.map +1 -0
  241. package/dist/__tests__/session-resume-backstop.test.js +107 -0
  242. package/dist/__tests__/session-resume-backstop.test.js.map +1 -0
  243. package/dist/__tests__/session-start-key-refresh.test.d.ts +2 -0
  244. package/dist/__tests__/session-start-key-refresh.test.d.ts.map +1 -0
  245. package/dist/__tests__/session-start-key-refresh.test.js +191 -0
  246. package/dist/__tests__/session-start-key-refresh.test.js.map +1 -0
  247. package/dist/__tests__/session-state-machine.test.d.ts +2 -0
  248. package/dist/__tests__/session-state-machine.test.d.ts.map +1 -0
  249. package/dist/__tests__/session-state-machine.test.js +379 -0
  250. package/dist/__tests__/session-state-machine.test.js.map +1 -0
  251. package/dist/__tests__/session-switch.test.d.ts +2 -0
  252. package/dist/__tests__/session-switch.test.d.ts.map +1 -0
  253. package/dist/__tests__/session-switch.test.js +267 -0
  254. package/dist/__tests__/session-switch.test.js.map +1 -0
  255. package/dist/__tests__/session-touch.test.js +16 -11
  256. package/dist/__tests__/session-touch.test.js.map +1 -1
  257. package/dist/__tests__/session.test.js +2 -2
  258. package/dist/__tests__/session.test.js.map +1 -1
  259. package/dist/__tests__/sessionBinding.test.d.ts +2 -0
  260. package/dist/__tests__/sessionBinding.test.d.ts.map +1 -0
  261. package/dist/__tests__/sessionBinding.test.js +118 -0
  262. package/dist/__tests__/sessionBinding.test.js.map +1 -0
  263. package/dist/__tests__/sessionByIdLookup.test.d.ts +2 -0
  264. package/dist/__tests__/sessionByIdLookup.test.d.ts.map +1 -0
  265. package/dist/__tests__/sessionByIdLookup.test.js +63 -0
  266. package/dist/__tests__/sessionByIdLookup.test.js.map +1 -0
  267. package/dist/__tests__/setup-ingest.test.d.ts +2 -0
  268. package/dist/__tests__/setup-ingest.test.d.ts.map +1 -0
  269. package/dist/__tests__/setup-ingest.test.js +71 -0
  270. package/dist/__tests__/setup-ingest.test.js.map +1 -0
  271. package/dist/__tests__/setup-resolver.test.d.ts +14 -0
  272. package/dist/__tests__/setup-resolver.test.d.ts.map +1 -0
  273. package/dist/__tests__/setup-resolver.test.js +228 -0
  274. package/dist/__tests__/setup-resolver.test.js.map +1 -0
  275. package/dist/__tests__/setupShFallbackWarning.test.d.ts +2 -0
  276. package/dist/__tests__/setupShFallbackWarning.test.d.ts.map +1 -0
  277. package/dist/__tests__/setupShFallbackWarning.test.js +15 -0
  278. package/dist/__tests__/setupShFallbackWarning.test.js.map +1 -0
  279. package/dist/__tests__/skill-vocabulary.test.d.ts +21 -0
  280. package/dist/__tests__/skill-vocabulary.test.d.ts.map +1 -0
  281. package/dist/__tests__/skill-vocabulary.test.js +192 -0
  282. package/dist/__tests__/skill-vocabulary.test.js.map +1 -0
  283. package/dist/__tests__/state.test.d.ts +6 -0
  284. package/dist/__tests__/state.test.d.ts.map +1 -0
  285. package/dist/__tests__/state.test.js +117 -0
  286. package/dist/__tests__/state.test.js.map +1 -0
  287. package/dist/__tests__/strip.test.js +57 -3
  288. package/dist/__tests__/strip.test.js.map +1 -1
  289. package/dist/__tests__/surfaces.test.d.ts +2 -0
  290. package/dist/__tests__/surfaces.test.d.ts.map +1 -0
  291. package/dist/__tests__/surfaces.test.js +46 -0
  292. package/dist/__tests__/surfaces.test.js.map +1 -0
  293. package/dist/__tests__/tenant-notice-write-path.test.d.ts +2 -0
  294. package/dist/__tests__/tenant-notice-write-path.test.d.ts.map +1 -0
  295. package/dist/__tests__/tenant-notice-write-path.test.js +169 -0
  296. package/dist/__tests__/tenant-notice-write-path.test.js.map +1 -0
  297. package/dist/__tests__/update-check.test.d.ts +2 -0
  298. package/dist/__tests__/update-check.test.d.ts.map +1 -0
  299. package/dist/__tests__/update-check.test.js +215 -0
  300. package/dist/__tests__/update-check.test.js.map +1 -0
  301. package/dist/__tests__/update.test.js +464 -26
  302. package/dist/__tests__/update.test.js.map +1 -1
  303. package/dist/__tests__/upgrade-runner.test.d.ts +2 -0
  304. package/dist/__tests__/upgrade-runner.test.d.ts.map +1 -0
  305. package/dist/__tests__/upgrade-runner.test.js +54 -0
  306. package/dist/__tests__/upgrade-runner.test.js.map +1 -0
  307. package/dist/__tests__/upgrade.test.d.ts +2 -0
  308. package/dist/__tests__/upgrade.test.d.ts.map +1 -0
  309. package/dist/__tests__/upgrade.test.js +56 -0
  310. package/dist/__tests__/upgrade.test.js.map +1 -0
  311. package/dist/__tests__/verify-formatter.test.d.ts +2 -0
  312. package/dist/__tests__/verify-formatter.test.d.ts.map +1 -0
  313. package/dist/__tests__/verify-formatter.test.js +85 -0
  314. package/dist/__tests__/verify-formatter.test.js.map +1 -0
  315. package/dist/__tests__/vocabulary-leak.test.d.ts +39 -0
  316. package/dist/__tests__/vocabulary-leak.test.d.ts.map +1 -0
  317. package/dist/__tests__/vocabulary-leak.test.js +539 -0
  318. package/dist/__tests__/vocabulary-leak.test.js.map +1 -0
  319. package/dist/__tests__/workspace.test.js +52 -32
  320. package/dist/__tests__/workspace.test.js.map +1 -1
  321. package/dist/__tests__/workspaceNotice.test.d.ts +2 -0
  322. package/dist/__tests__/workspaceNotice.test.d.ts.map +1 -0
  323. package/dist/__tests__/workspaceNotice.test.js +571 -0
  324. package/dist/__tests__/workspaceNotice.test.js.map +1 -0
  325. package/dist/commands/__tests__/connect-handoff.test.d.ts +11 -0
  326. package/dist/commands/__tests__/connect-handoff.test.d.ts.map +1 -0
  327. package/dist/commands/__tests__/connect-handoff.test.js +111 -0
  328. package/dist/commands/__tests__/connect-handoff.test.js.map +1 -0
  329. package/dist/commands/__tests__/quality.test.d.ts +2 -0
  330. package/dist/commands/__tests__/quality.test.d.ts.map +1 -0
  331. package/dist/commands/__tests__/quality.test.js +156 -0
  332. package/dist/commands/__tests__/quality.test.js.map +1 -0
  333. package/dist/commands/__tests__/rework.test.d.ts +2 -0
  334. package/dist/commands/__tests__/rework.test.d.ts.map +1 -0
  335. package/dist/commands/__tests__/rework.test.js +149 -0
  336. package/dist/commands/__tests__/rework.test.js.map +1 -0
  337. package/dist/commands/__tests__/setup-detect-surfaces.test.d.ts +15 -0
  338. package/dist/commands/__tests__/setup-detect-surfaces.test.d.ts.map +1 -0
  339. package/dist/commands/__tests__/setup-detect-surfaces.test.js +149 -0
  340. package/dist/commands/__tests__/setup-detect-surfaces.test.js.map +1 -0
  341. package/dist/commands/__tests__/setup-state.test.d.ts +2 -0
  342. package/dist/commands/__tests__/setup-state.test.d.ts.map +1 -0
  343. package/dist/commands/__tests__/setup-state.test.js +194 -0
  344. package/dist/commands/__tests__/setup-state.test.js.map +1 -0
  345. package/dist/commands/accept-policy.d.ts +10 -0
  346. package/dist/commands/accept-policy.d.ts.map +1 -0
  347. package/dist/commands/accept-policy.js +107 -0
  348. package/dist/commands/accept-policy.js.map +1 -0
  349. package/dist/commands/accept.d.ts.map +1 -1
  350. package/dist/commands/accept.js +5 -5
  351. package/dist/commands/accept.js.map +1 -1
  352. package/dist/commands/admin/cockpit.d.ts +6 -14
  353. package/dist/commands/admin/cockpit.d.ts.map +1 -1
  354. package/dist/commands/admin/cockpit.js +222 -13
  355. package/dist/commands/admin/cockpit.js.map +1 -1
  356. package/dist/commands/admin/index.d.ts +49 -0
  357. package/dist/commands/admin/index.d.ts.map +1 -1
  358. package/dist/commands/admin/index.js +147 -29
  359. package/dist/commands/admin/index.js.map +1 -1
  360. package/dist/commands/admin/index.test.d.ts +2 -0
  361. package/dist/commands/admin/index.test.d.ts.map +1 -0
  362. package/dist/commands/admin/index.test.js +84 -0
  363. package/dist/commands/admin/index.test.js.map +1 -0
  364. package/dist/commands/admin/inspect.d.ts +9 -0
  365. package/dist/commands/admin/inspect.d.ts.map +1 -1
  366. package/dist/commands/admin/inspect.js +20 -1
  367. package/dist/commands/admin/inspect.js.map +1 -1
  368. package/dist/commands/admin/inspect.test.js +20 -1
  369. package/dist/commands/admin/inspect.test.js.map +1 -1
  370. package/dist/commands/admin/manage.d.ts +8 -0
  371. package/dist/commands/admin/manage.d.ts.map +1 -0
  372. package/dist/commands/admin/manage.js +262 -0
  373. package/dist/commands/admin/manage.js.map +1 -0
  374. package/dist/commands/admin/manage.test.d.ts +16 -0
  375. package/dist/commands/admin/manage.test.d.ts.map +1 -0
  376. package/dist/commands/admin/manage.test.js +171 -0
  377. package/dist/commands/admin/manage.test.js.map +1 -0
  378. package/dist/commands/admin/probe.d.ts +75 -0
  379. package/dist/commands/admin/probe.d.ts.map +1 -0
  380. package/dist/commands/admin/probe.js +224 -0
  381. package/dist/commands/admin/probe.js.map +1 -0
  382. package/dist/commands/admin/probe.test.d.ts +2 -0
  383. package/dist/commands/admin/probe.test.d.ts.map +1 -0
  384. package/dist/commands/admin/probe.test.js +193 -0
  385. package/dist/commands/admin/probe.test.js.map +1 -0
  386. package/dist/commands/admin/run.d.ts +43 -0
  387. package/dist/commands/admin/run.d.ts.map +1 -0
  388. package/dist/commands/admin/run.js +78 -0
  389. package/dist/commands/admin/run.js.map +1 -0
  390. package/dist/commands/admin/run.test.d.ts +18 -0
  391. package/dist/commands/admin/run.test.d.ts.map +1 -0
  392. package/dist/commands/admin/run.test.js +168 -0
  393. package/dist/commands/admin/run.test.js.map +1 -0
  394. package/dist/commands/admin/seed.d.ts +46 -3
  395. package/dist/commands/admin/seed.d.ts.map +1 -1
  396. package/dist/commands/admin/seed.js +500 -83
  397. package/dist/commands/admin/seed.js.map +1 -1
  398. package/dist/commands/admin/seed.test.d.ts +5 -0
  399. package/dist/commands/admin/seed.test.d.ts.map +1 -1
  400. package/dist/commands/admin/seed.test.js +90 -8
  401. package/dist/commands/admin/seed.test.js.map +1 -1
  402. package/dist/commands/admin/seedRegistryEntries.generated.d.ts +14 -0
  403. package/dist/commands/admin/seedRegistryEntries.generated.d.ts.map +1 -0
  404. package/dist/commands/admin/seedRegistryEntries.generated.js +144 -0
  405. package/dist/commands/admin/seedRegistryEntries.generated.js.map +1 -0
  406. package/dist/commands/admin/seedRegistryEntries.test.d.ts +13 -0
  407. package/dist/commands/admin/seedRegistryEntries.test.d.ts.map +1 -0
  408. package/dist/commands/admin/seedRegistryEntries.test.js +92 -0
  409. package/dist/commands/admin/seedRegistryEntries.test.js.map +1 -0
  410. package/dist/commands/admin/seedRowType.d.ts +22 -0
  411. package/dist/commands/admin/seedRowType.d.ts.map +1 -0
  412. package/dist/commands/admin/seedRowType.js +2 -0
  413. package/dist/commands/admin/seedRowType.js.map +1 -0
  414. package/dist/commands/admin/seedStatusColor.d.ts +9 -0
  415. package/dist/commands/admin/seedStatusColor.d.ts.map +1 -0
  416. package/dist/commands/admin/seedStatusColor.js +18 -0
  417. package/dist/commands/admin/seedStatusColor.js.map +1 -0
  418. package/dist/commands/admin/seedStatusColor.test.d.ts +2 -0
  419. package/dist/commands/admin/seedStatusColor.test.d.ts.map +1 -0
  420. package/dist/commands/admin/seedStatusColor.test.js +25 -0
  421. package/dist/commands/admin/seedStatusColor.test.js.map +1 -0
  422. package/dist/commands/audit.d.ts.map +1 -1
  423. package/dist/commands/audit.js +53 -7
  424. package/dist/commands/audit.js.map +1 -1
  425. package/dist/commands/brief.d.ts.map +1 -1
  426. package/dist/commands/brief.js +27 -5
  427. package/dist/commands/brief.js.map +1 -1
  428. package/dist/commands/capture.d.ts +15 -8
  429. package/dist/commands/capture.d.ts.map +1 -1
  430. package/dist/commands/capture.js +259 -240
  431. package/dist/commands/capture.js.map +1 -1
  432. package/dist/commands/chain-walk.d.ts.map +1 -1
  433. package/dist/commands/chain-walk.js +2 -2
  434. package/dist/commands/chain-walk.js.map +1 -1
  435. package/dist/commands/changes.d.ts.map +1 -1
  436. package/dist/commands/changes.js +2 -2
  437. package/dist/commands/changes.js.map +1 -1
  438. package/dist/commands/codex-prep.d.ts +12 -1
  439. package/dist/commands/codex-prep.d.ts.map +1 -1
  440. package/dist/commands/codex-prep.js +19 -85
  441. package/dist/commands/codex-prep.js.map +1 -1
  442. package/dist/commands/collections.d.ts.map +1 -1
  443. package/dist/commands/collections.js +5 -5
  444. package/dist/commands/collections.js.map +1 -1
  445. package/dist/commands/conflicts.d.ts +40 -0
  446. package/dist/commands/conflicts.d.ts.map +1 -0
  447. package/dist/commands/conflicts.js +267 -0
  448. package/dist/commands/conflicts.js.map +1 -0
  449. package/dist/commands/conflicts.test.d.ts +2 -0
  450. package/dist/commands/conflicts.test.d.ts.map +1 -0
  451. package/dist/commands/conflicts.test.js +219 -0
  452. package/dist/commands/conflicts.test.js.map +1 -0
  453. package/dist/commands/connect-config.test.d.ts +2 -0
  454. package/dist/commands/connect-config.test.d.ts.map +1 -0
  455. package/dist/commands/connect-config.test.js +44 -0
  456. package/dist/commands/connect-config.test.js.map +1 -0
  457. package/dist/commands/connect-context.d.ts +57 -0
  458. package/dist/commands/connect-context.d.ts.map +1 -0
  459. package/dist/commands/connect-context.js +93 -0
  460. package/dist/commands/connect-context.js.map +1 -0
  461. package/dist/commands/connect-context.test.d.ts +2 -0
  462. package/dist/commands/connect-context.test.d.ts.map +1 -0
  463. package/dist/commands/connect-context.test.js +187 -0
  464. package/dist/commands/connect-context.test.js.map +1 -0
  465. package/dist/commands/connect-handoff.d.ts +51 -0
  466. package/dist/commands/connect-handoff.d.ts.map +1 -0
  467. package/dist/commands/connect-handoff.js +70 -0
  468. package/dist/commands/connect-handoff.js.map +1 -0
  469. package/dist/commands/connect-integration.test.js +58 -35
  470. package/dist/commands/connect-integration.test.js.map +1 -1
  471. package/dist/commands/connect-legacy-migration.test.d.ts +2 -0
  472. package/dist/commands/connect-legacy-migration.test.d.ts.map +1 -0
  473. package/dist/commands/connect-legacy-migration.test.js +109 -0
  474. package/dist/commands/connect-legacy-migration.test.js.map +1 -0
  475. package/dist/commands/connect-screens.d.ts +33 -0
  476. package/dist/commands/connect-screens.d.ts.map +1 -0
  477. package/dist/commands/connect-screens.js +143 -0
  478. package/dist/commands/connect-screens.js.map +1 -0
  479. package/dist/commands/connect.d.ts +27 -6
  480. package/dist/commands/connect.d.ts.map +1 -1
  481. package/dist/commands/connect.js +252 -115
  482. package/dist/commands/connect.js.map +1 -1
  483. package/dist/commands/connect.test.js +348 -7
  484. package/dist/commands/connect.test.js.map +1 -1
  485. package/dist/commands/constellation.d.ts.map +1 -1
  486. package/dist/commands/constellation.js +2 -2
  487. package/dist/commands/constellation.js.map +1 -1
  488. package/dist/commands/context.d.ts.map +1 -1
  489. package/dist/commands/context.js +2 -2
  490. package/dist/commands/context.js.map +1 -1
  491. package/dist/commands/cross-cut.d.ts.map +1 -1
  492. package/dist/commands/cross-cut.js +2 -2
  493. package/dist/commands/cross-cut.js.map +1 -1
  494. package/dist/commands/direction.d.ts +10 -0
  495. package/dist/commands/direction.d.ts.map +1 -0
  496. package/dist/commands/direction.js +79 -0
  497. package/dist/commands/direction.js.map +1 -0
  498. package/dist/commands/doctor.d.ts.map +1 -1
  499. package/dist/commands/doctor.js +175 -40
  500. package/dist/commands/doctor.js.map +1 -1
  501. package/dist/commands/doctor.test.js +353 -7
  502. package/dist/commands/doctor.test.js.map +1 -1
  503. package/dist/commands/entryAccept.d.ts +24 -0
  504. package/dist/commands/entryAccept.d.ts.map +1 -0
  505. package/dist/commands/entryAccept.js +282 -0
  506. package/dist/commands/entryAccept.js.map +1 -0
  507. package/dist/commands/entryArchive.d.ts +8 -0
  508. package/dist/commands/entryArchive.d.ts.map +1 -0
  509. package/dist/commands/entryArchive.js +37 -0
  510. package/dist/commands/entryArchive.js.map +1 -0
  511. package/dist/commands/entryOwn.d.ts +5 -0
  512. package/dist/commands/entryOwn.d.ts.map +1 -0
  513. package/dist/commands/entryOwn.js +17 -0
  514. package/dist/commands/entryOwn.js.map +1 -0
  515. package/dist/commands/entryPreflight.d.ts +8 -0
  516. package/dist/commands/entryPreflight.d.ts.map +1 -0
  517. package/dist/commands/entryPreflight.js +48 -0
  518. package/dist/commands/entryPreflight.js.map +1 -0
  519. package/dist/commands/feedback.d.ts +36 -0
  520. package/dist/commands/feedback.d.ts.map +1 -0
  521. package/dist/commands/feedback.js +193 -0
  522. package/dist/commands/feedback.js.map +1 -0
  523. package/dist/commands/feedback.test.d.ts +2 -0
  524. package/dist/commands/feedback.test.d.ts.map +1 -0
  525. package/dist/commands/feedback.test.js +125 -0
  526. package/dist/commands/feedback.test.js.map +1 -0
  527. package/dist/commands/fields.d.ts.map +1 -1
  528. package/dist/commands/fields.js +3 -3
  529. package/dist/commands/fields.js.map +1 -1
  530. package/dist/commands/files.d.ts +26 -0
  531. package/dist/commands/files.d.ts.map +1 -0
  532. package/dist/commands/files.js +160 -0
  533. package/dist/commands/files.js.map +1 -0
  534. package/dist/commands/files.test.d.ts +2 -0
  535. package/dist/commands/files.test.d.ts.map +1 -0
  536. package/dist/commands/files.test.js +278 -0
  537. package/dist/commands/files.test.js.map +1 -0
  538. package/dist/commands/get.js +3 -3
  539. package/dist/commands/get.js.map +1 -1
  540. package/dist/commands/handshake.d.ts +94 -7
  541. package/dist/commands/handshake.d.ts.map +1 -1
  542. package/dist/commands/handshake.js +1586 -104
  543. package/dist/commands/handshake.js.map +1 -1
  544. package/dist/commands/handshakeCursorSkillCleanup.d.ts +36 -0
  545. package/dist/commands/handshakeCursorSkillCleanup.d.ts.map +1 -0
  546. package/dist/commands/handshakeCursorSkillCleanup.js +110 -0
  547. package/dist/commands/handshakeCursorSkillCleanup.js.map +1 -0
  548. package/dist/commands/handshakeDriftClassification.d.ts +33 -0
  549. package/dist/commands/handshakeDriftClassification.d.ts.map +1 -0
  550. package/dist/commands/handshakeDriftClassification.js +62 -0
  551. package/dist/commands/handshakeDriftClassification.js.map +1 -0
  552. package/dist/commands/history.d.ts +30 -0
  553. package/dist/commands/history.d.ts.map +1 -0
  554. package/dist/commands/history.js +62 -0
  555. package/dist/commands/history.js.map +1 -0
  556. package/dist/commands/history.test.d.ts +2 -0
  557. package/dist/commands/history.test.d.ts.map +1 -0
  558. package/dist/commands/history.test.js +106 -0
  559. package/dist/commands/history.test.js.map +1 -0
  560. package/dist/commands/ingest.d.ts.map +1 -1
  561. package/dist/commands/ingest.js +15 -6
  562. package/dist/commands/ingest.js.map +1 -1
  563. package/dist/commands/init.d.ts +1 -1
  564. package/dist/commands/init.d.ts.map +1 -1
  565. package/dist/commands/init.js +20 -17
  566. package/dist/commands/init.js.map +1 -1
  567. package/dist/commands/method.d.ts +97 -0
  568. package/dist/commands/method.d.ts.map +1 -0
  569. package/dist/commands/method.js +773 -0
  570. package/dist/commands/method.js.map +1 -0
  571. package/dist/commands/migrate-setup.d.ts +18 -0
  572. package/dist/commands/migrate-setup.d.ts.map +1 -0
  573. package/dist/commands/migrate-setup.js +162 -0
  574. package/dist/commands/migrate-setup.js.map +1 -0
  575. package/dist/commands/organisation.d.ts +17 -0
  576. package/dist/commands/organisation.d.ts.map +1 -0
  577. package/dist/commands/organisation.js +201 -0
  578. package/dist/commands/organisation.js.map +1 -0
  579. package/dist/commands/organisation.test.d.ts +2 -0
  580. package/dist/commands/organisation.test.d.ts.map +1 -0
  581. package/dist/commands/organisation.test.js +204 -0
  582. package/dist/commands/organisation.test.js.map +1 -0
  583. package/dist/commands/organisationHierarchy.d.ts +8 -0
  584. package/dist/commands/organisationHierarchy.d.ts.map +1 -0
  585. package/dist/commands/organisationHierarchy.js +75 -0
  586. package/dist/commands/organisationHierarchy.js.map +1 -0
  587. package/dist/commands/organisationHierarchy.test.d.ts +2 -0
  588. package/dist/commands/organisationHierarchy.test.d.ts.map +1 -0
  589. package/dist/commands/organisationHierarchy.test.js +72 -0
  590. package/dist/commands/organisationHierarchy.test.js.map +1 -0
  591. package/dist/commands/organisationWrite.d.ts +18 -0
  592. package/dist/commands/organisationWrite.d.ts.map +1 -0
  593. package/dist/commands/organisationWrite.js +68 -0
  594. package/dist/commands/organisationWrite.js.map +1 -0
  595. package/dist/commands/orient.d.ts +113 -4
  596. package/dist/commands/orient.d.ts.map +1 -1
  597. package/dist/commands/orient.js +226 -13
  598. package/dist/commands/orient.js.map +1 -1
  599. package/dist/commands/outcome.d.ts +92 -0
  600. package/dist/commands/outcome.d.ts.map +1 -0
  601. package/dist/commands/outcome.js +203 -0
  602. package/dist/commands/outcome.js.map +1 -0
  603. package/dist/commands/outcome.test.d.ts +2 -0
  604. package/dist/commands/outcome.test.d.ts.map +1 -0
  605. package/dist/commands/outcome.test.js +308 -0
  606. package/dist/commands/outcome.test.js.map +1 -0
  607. package/dist/commands/profile.d.ts +34 -2
  608. package/dist/commands/profile.d.ts.map +1 -1
  609. package/dist/commands/profile.js +294 -41
  610. package/dist/commands/profile.js.map +1 -1
  611. package/dist/commands/proof-run.d.ts +51 -0
  612. package/dist/commands/proof-run.d.ts.map +1 -0
  613. package/dist/commands/proof-run.js +209 -0
  614. package/dist/commands/proof-run.js.map +1 -0
  615. package/dist/commands/proposals.d.ts.map +1 -1
  616. package/dist/commands/proposals.js +2 -2
  617. package/dist/commands/proposals.js.map +1 -1
  618. package/dist/commands/quality.d.ts +16 -0
  619. package/dist/commands/quality.d.ts.map +1 -0
  620. package/dist/commands/quality.js +29 -0
  621. package/dist/commands/quality.js.map +1 -0
  622. package/dist/commands/questions.d.ts +34 -0
  623. package/dist/commands/questions.d.ts.map +1 -0
  624. package/dist/commands/questions.js +318 -0
  625. package/dist/commands/questions.js.map +1 -0
  626. package/dist/commands/questions.test.d.ts +2 -0
  627. package/dist/commands/questions.test.d.ts.map +1 -0
  628. package/dist/commands/questions.test.js +186 -0
  629. package/dist/commands/questions.test.js.map +1 -0
  630. package/dist/commands/reject.d.ts.map +1 -1
  631. package/dist/commands/reject.js +5 -4
  632. package/dist/commands/reject.js.map +1 -1
  633. package/dist/commands/relate.d.ts +1 -0
  634. package/dist/commands/relate.d.ts.map +1 -1
  635. package/dist/commands/relate.js +104 -5
  636. package/dist/commands/relate.js.map +1 -1
  637. package/dist/commands/restore.d.ts +2 -0
  638. package/dist/commands/restore.d.ts.map +1 -0
  639. package/dist/commands/restore.js +83 -0
  640. package/dist/commands/restore.js.map +1 -0
  641. package/dist/commands/rework.d.ts +24 -0
  642. package/dist/commands/rework.d.ts.map +1 -0
  643. package/dist/commands/rework.js +97 -0
  644. package/dist/commands/rework.js.map +1 -0
  645. package/dist/commands/role.d.ts +48 -0
  646. package/dist/commands/role.d.ts.map +1 -0
  647. package/dist/commands/role.js +122 -0
  648. package/dist/commands/role.js.map +1 -0
  649. package/dist/commands/role.test.d.ts +2 -0
  650. package/dist/commands/role.test.d.ts.map +1 -0
  651. package/dist/commands/role.test.js +173 -0
  652. package/dist/commands/role.test.js.map +1 -0
  653. package/dist/commands/scoreboard.d.ts +28 -0
  654. package/dist/commands/scoreboard.d.ts.map +1 -0
  655. package/dist/commands/scoreboard.js +40 -0
  656. package/dist/commands/scoreboard.js.map +1 -0
  657. package/dist/commands/search.d.ts.map +1 -1
  658. package/dist/commands/search.js +2 -2
  659. package/dist/commands/search.js.map +1 -1
  660. package/dist/commands/session.d.ts +60 -7
  661. package/dist/commands/session.d.ts.map +1 -1
  662. package/dist/commands/session.js +470 -51
  663. package/dist/commands/session.js.map +1 -1
  664. package/dist/commands/setup-audit.d.ts +59 -0
  665. package/dist/commands/setup-audit.d.ts.map +1 -0
  666. package/dist/commands/setup-audit.js +250 -0
  667. package/dist/commands/setup-audit.js.map +1 -0
  668. package/dist/commands/setup-detect-surfaces.d.ts +38 -0
  669. package/dist/commands/setup-detect-surfaces.d.ts.map +1 -0
  670. package/dist/commands/setup-detect-surfaces.js +76 -0
  671. package/dist/commands/setup-detect-surfaces.js.map +1 -0
  672. package/dist/commands/setup-ingest.d.ts +17 -0
  673. package/dist/commands/setup-ingest.d.ts.map +1 -0
  674. package/dist/commands/setup-ingest.js +179 -0
  675. package/dist/commands/setup-ingest.js.map +1 -0
  676. package/dist/commands/setup-resolver.d.ts +58 -0
  677. package/dist/commands/setup-resolver.d.ts.map +1 -0
  678. package/dist/commands/setup-resolver.js +150 -0
  679. package/dist/commands/setup-resolver.js.map +1 -0
  680. package/dist/commands/setup-state.d.ts +42 -0
  681. package/dist/commands/setup-state.d.ts.map +1 -0
  682. package/dist/commands/setup-state.js +93 -0
  683. package/dist/commands/setup-state.js.map +1 -0
  684. package/dist/commands/setup.d.ts +17 -9
  685. package/dist/commands/setup.d.ts.map +1 -1
  686. package/dist/commands/setup.js +53 -152
  687. package/dist/commands/setup.js.map +1 -1
  688. package/dist/commands/shape.d.ts +16 -0
  689. package/dist/commands/shape.d.ts.map +1 -0
  690. package/dist/commands/shape.js +149 -0
  691. package/dist/commands/shape.js.map +1 -0
  692. package/dist/commands/shape.test.d.ts +2 -0
  693. package/dist/commands/shape.test.d.ts.map +1 -0
  694. package/dist/commands/shape.test.js +148 -0
  695. package/dist/commands/shape.test.js.map +1 -0
  696. package/dist/commands/status.d.ts +7 -0
  697. package/dist/commands/status.d.ts.map +1 -0
  698. package/dist/commands/status.js +102 -0
  699. package/dist/commands/status.js.map +1 -0
  700. package/dist/commands/status.test.d.ts +2 -0
  701. package/dist/commands/status.test.d.ts.map +1 -0
  702. package/dist/commands/status.test.js +75 -0
  703. package/dist/commands/status.test.js.map +1 -0
  704. package/dist/commands/update.d.ts +20 -0
  705. package/dist/commands/update.d.ts.map +1 -1
  706. package/dist/commands/update.js +138 -37
  707. package/dist/commands/update.js.map +1 -1
  708. package/dist/commands/upgrade.d.ts +5 -0
  709. package/dist/commands/upgrade.d.ts.map +1 -0
  710. package/dist/commands/upgrade.js +110 -0
  711. package/dist/commands/upgrade.js.map +1 -0
  712. package/dist/commands/usage.d.ts +40 -0
  713. package/dist/commands/usage.d.ts.map +1 -0
  714. package/dist/commands/usage.js +214 -0
  715. package/dist/commands/usage.js.map +1 -0
  716. package/dist/commands/verify.d.ts.map +1 -1
  717. package/dist/commands/verify.js +9 -3
  718. package/dist/commands/verify.js.map +1 -1
  719. package/dist/commands/welcome.d.ts +21 -0
  720. package/dist/commands/welcome.d.ts.map +1 -0
  721. package/dist/commands/welcome.js +53 -0
  722. package/dist/commands/welcome.js.map +1 -0
  723. package/dist/commands/whoami.d.ts +20 -0
  724. package/dist/commands/whoami.d.ts.map +1 -0
  725. package/dist/commands/whoami.js +126 -0
  726. package/dist/commands/whoami.js.map +1 -0
  727. package/dist/commands/whoami.test.d.ts +2 -0
  728. package/dist/commands/whoami.test.d.ts.map +1 -0
  729. package/dist/commands/whoami.test.js +130 -0
  730. package/dist/commands/whoami.test.js.map +1 -0
  731. package/dist/commands/workspace.d.ts +59 -2
  732. package/dist/commands/workspace.d.ts.map +1 -1
  733. package/dist/commands/workspace.js +27 -6
  734. package/dist/commands/workspace.js.map +1 -1
  735. package/dist/formatters/__tests__/orient-possibleConflict.test.d.ts +2 -0
  736. package/dist/formatters/__tests__/orient-possibleConflict.test.d.ts.map +1 -0
  737. package/dist/formatters/__tests__/orient-possibleConflict.test.js +68 -0
  738. package/dist/formatters/__tests__/orient-possibleConflict.test.js.map +1 -0
  739. package/dist/formatters/__tests__/orient-provenance.test.d.ts +7 -0
  740. package/dist/formatters/__tests__/orient-provenance.test.d.ts.map +1 -0
  741. package/dist/formatters/__tests__/orient-provenance.test.js +548 -0
  742. package/dist/formatters/__tests__/orient-provenance.test.js.map +1 -0
  743. package/dist/formatters/__tests__/session-list-show.test.d.ts +2 -0
  744. package/dist/formatters/__tests__/session-list-show.test.d.ts.map +1 -0
  745. package/dist/formatters/__tests__/session-list-show.test.js +159 -0
  746. package/dist/formatters/__tests__/session-list-show.test.js.map +1 -0
  747. package/dist/formatters/__tests__/session.test.d.ts +2 -0
  748. package/dist/formatters/__tests__/session.test.d.ts.map +1 -0
  749. package/dist/formatters/__tests__/session.test.js +192 -0
  750. package/dist/formatters/__tests__/session.test.js.map +1 -0
  751. package/dist/formatters/audit.d.ts +6 -0
  752. package/dist/formatters/audit.d.ts.map +1 -1
  753. package/dist/formatters/audit.js +1 -1
  754. package/dist/formatters/audit.js.map +1 -1
  755. package/dist/formatters/brief.d.ts +6 -10
  756. package/dist/formatters/brief.d.ts.map +1 -1
  757. package/dist/formatters/brief.js +14 -3
  758. package/dist/formatters/brief.js.map +1 -1
  759. package/dist/formatters/brief.test.d.ts +2 -0
  760. package/dist/formatters/brief.test.d.ts.map +1 -0
  761. package/dist/formatters/brief.test.js +21 -0
  762. package/dist/formatters/brief.test.js.map +1 -0
  763. package/dist/formatters/capture.d.ts +13 -0
  764. package/dist/formatters/capture.d.ts.map +1 -1
  765. package/dist/formatters/capture.js +20 -1
  766. package/dist/formatters/capture.js.map +1 -1
  767. package/dist/formatters/coaching.d.ts +55 -0
  768. package/dist/formatters/coaching.d.ts.map +1 -0
  769. package/dist/formatters/coaching.js +46 -0
  770. package/dist/formatters/coaching.js.map +1 -0
  771. package/dist/formatters/conflicts.d.ts +69 -0
  772. package/dist/formatters/conflicts.d.ts.map +1 -0
  773. package/dist/formatters/conflicts.js +87 -0
  774. package/dist/formatters/conflicts.js.map +1 -0
  775. package/dist/formatters/conflicts.test.d.ts +2 -0
  776. package/dist/formatters/conflicts.test.d.ts.map +1 -0
  777. package/dist/formatters/conflicts.test.js +136 -0
  778. package/dist/formatters/conflicts.test.js.map +1 -0
  779. package/dist/formatters/context.d.ts +1 -1
  780. package/dist/formatters/context.d.ts.map +1 -1
  781. package/dist/formatters/context.js.map +1 -1
  782. package/dist/formatters/direction.d.ts +48 -0
  783. package/dist/formatters/direction.d.ts.map +1 -0
  784. package/dist/formatters/direction.js +75 -0
  785. package/dist/formatters/direction.js.map +1 -0
  786. package/dist/formatters/direction.test.d.ts +2 -0
  787. package/dist/formatters/direction.test.d.ts.map +1 -0
  788. package/dist/formatters/direction.test.js +70 -0
  789. package/dist/formatters/direction.test.js.map +1 -0
  790. package/dist/formatters/entry.d.ts +54 -0
  791. package/dist/formatters/entry.d.ts.map +1 -1
  792. package/dist/formatters/entry.js +93 -9
  793. package/dist/formatters/entry.js.map +1 -1
  794. package/dist/formatters/entryAccept.d.ts +79 -0
  795. package/dist/formatters/entryAccept.d.ts.map +1 -0
  796. package/dist/formatters/entryAccept.js +80 -0
  797. package/dist/formatters/entryAccept.js.map +1 -0
  798. package/dist/formatters/feedback.d.ts +56 -0
  799. package/dist/formatters/feedback.d.ts.map +1 -0
  800. package/dist/formatters/feedback.js +89 -0
  801. package/dist/formatters/feedback.js.map +1 -0
  802. package/dist/formatters/feedback.test.d.ts +2 -0
  803. package/dist/formatters/feedback.test.d.ts.map +1 -0
  804. package/dist/formatters/feedback.test.js +112 -0
  805. package/dist/formatters/feedback.test.js.map +1 -0
  806. package/dist/formatters/handshake.d.ts +61 -0
  807. package/dist/formatters/handshake.d.ts.map +1 -1
  808. package/dist/formatters/handshake.js +160 -3
  809. package/dist/formatters/handshake.js.map +1 -1
  810. package/dist/formatters/orient.coherencyCheckTag.test.d.ts +2 -0
  811. package/dist/formatters/orient.coherencyCheckTag.test.d.ts.map +1 -0
  812. package/dist/formatters/orient.coherencyCheckTag.test.js +22 -0
  813. package/dist/formatters/orient.coherencyCheckTag.test.js.map +1 -0
  814. package/dist/formatters/orient.d.ts +221 -10
  815. package/dist/formatters/orient.d.ts.map +1 -1
  816. package/dist/formatters/orient.js +253 -37
  817. package/dist/formatters/orient.js.map +1 -1
  818. package/dist/formatters/orient.rcrtMiss.test.d.ts +2 -0
  819. package/dist/formatters/orient.rcrtMiss.test.d.ts.map +1 -0
  820. package/dist/formatters/orient.rcrtMiss.test.js +82 -0
  821. package/dist/formatters/orient.rcrtMiss.test.js.map +1 -0
  822. package/dist/formatters/orient.rituals.test.d.ts +2 -0
  823. package/dist/formatters/orient.rituals.test.d.ts.map +1 -0
  824. package/dist/formatters/orient.rituals.test.js +77 -0
  825. package/dist/formatters/orient.rituals.test.js.map +1 -0
  826. package/dist/formatters/orient.shapeAdvisorySummary.test.d.ts +2 -0
  827. package/dist/formatters/orient.shapeAdvisorySummary.test.d.ts.map +1 -0
  828. package/dist/formatters/orient.shapeAdvisorySummary.test.js +62 -0
  829. package/dist/formatters/orient.shapeAdvisorySummary.test.js.map +1 -0
  830. package/dist/formatters/orientDegradation.d.ts +38 -0
  831. package/dist/formatters/orientDegradation.d.ts.map +1 -0
  832. package/dist/formatters/orientDegradation.js +50 -0
  833. package/dist/formatters/orientDegradation.js.map +1 -0
  834. package/dist/formatters/orientDegradation.test.d.ts +2 -0
  835. package/dist/formatters/orientDegradation.test.d.ts.map +1 -0
  836. package/dist/formatters/orientDegradation.test.js +28 -0
  837. package/dist/formatters/orientDegradation.test.js.map +1 -0
  838. package/dist/formatters/orientDirection.d.ts +67 -0
  839. package/dist/formatters/orientDirection.d.ts.map +1 -0
  840. package/dist/formatters/orientDirection.js +82 -0
  841. package/dist/formatters/orientDirection.js.map +1 -0
  842. package/dist/formatters/orientDirection.test.d.ts +2 -0
  843. package/dist/formatters/orientDirection.test.d.ts.map +1 -0
  844. package/dist/formatters/orientDirection.test.js +171 -0
  845. package/dist/formatters/orientDirection.test.js.map +1 -0
  846. package/dist/formatters/orientRetrievalMiss.d.ts +22 -0
  847. package/dist/formatters/orientRetrievalMiss.d.ts.map +1 -0
  848. package/dist/formatters/orientRetrievalMiss.js +17 -0
  849. package/dist/formatters/orientRetrievalMiss.js.map +1 -0
  850. package/dist/formatters/proposals.js +2 -2
  851. package/dist/formatters/proposals.js.map +1 -1
  852. package/dist/formatters/questions.d.ts +100 -0
  853. package/dist/formatters/questions.d.ts.map +1 -0
  854. package/dist/formatters/questions.js +163 -0
  855. package/dist/formatters/questions.js.map +1 -0
  856. package/dist/formatters/questions.test.d.ts +2 -0
  857. package/dist/formatters/questions.test.d.ts.map +1 -0
  858. package/dist/formatters/questions.test.js +211 -0
  859. package/dist/formatters/questions.test.js.map +1 -0
  860. package/dist/formatters/relate.d.ts +14 -1
  861. package/dist/formatters/relate.d.ts.map +1 -1
  862. package/dist/formatters/relate.js +12 -3
  863. package/dist/formatters/relate.js.map +1 -1
  864. package/dist/formatters/relate.test.d.ts +2 -0
  865. package/dist/formatters/relate.test.d.ts.map +1 -0
  866. package/dist/formatters/relate.test.js +81 -0
  867. package/dist/formatters/relate.test.js.map +1 -0
  868. package/dist/formatters/scoreboard.d.ts +11 -0
  869. package/dist/formatters/scoreboard.d.ts.map +1 -0
  870. package/dist/formatters/scoreboard.js +164 -0
  871. package/dist/formatters/scoreboard.js.map +1 -0
  872. package/dist/formatters/scoreboard.test.d.ts +2 -0
  873. package/dist/formatters/scoreboard.test.d.ts.map +1 -0
  874. package/dist/formatters/scoreboard.test.js +303 -0
  875. package/dist/formatters/scoreboard.test.js.map +1 -0
  876. package/dist/formatters/search.d.ts.map +1 -1
  877. package/dist/formatters/search.js +17 -1
  878. package/dist/formatters/search.js.map +1 -1
  879. package/dist/formatters/search.test.d.ts +2 -0
  880. package/dist/formatters/search.test.d.ts.map +1 -0
  881. package/dist/formatters/search.test.js +46 -0
  882. package/dist/formatters/search.test.js.map +1 -0
  883. package/dist/formatters/session-feedback.test.d.ts +2 -0
  884. package/dist/formatters/session-feedback.test.d.ts.map +1 -0
  885. package/dist/formatters/session-feedback.test.js +61 -0
  886. package/dist/formatters/session-feedback.test.js.map +1 -0
  887. package/dist/formatters/session.d.ts +121 -5
  888. package/dist/formatters/session.d.ts.map +1 -1
  889. package/dist/formatters/session.js +309 -12
  890. package/dist/formatters/session.js.map +1 -1
  891. package/dist/formatters/shape.d.ts +54 -0
  892. package/dist/formatters/shape.d.ts.map +1 -0
  893. package/dist/formatters/shape.js +97 -0
  894. package/dist/formatters/shape.js.map +1 -0
  895. package/dist/formatters/shape.test.d.ts +2 -0
  896. package/dist/formatters/shape.test.d.ts.map +1 -0
  897. package/dist/formatters/shape.test.js +80 -0
  898. package/dist/formatters/shape.test.js.map +1 -0
  899. package/dist/formatters/spineCheck.d.ts +14 -0
  900. package/dist/formatters/spineCheck.d.ts.map +1 -0
  901. package/dist/formatters/spineCheck.js +113 -0
  902. package/dist/formatters/spineCheck.js.map +1 -0
  903. package/dist/formatters/spineCheck.test.d.ts +2 -0
  904. package/dist/formatters/spineCheck.test.d.ts.map +1 -0
  905. package/dist/formatters/spineCheck.test.js +76 -0
  906. package/dist/formatters/spineCheck.test.js.map +1 -0
  907. package/dist/formatters/update.d.ts +23 -0
  908. package/dist/formatters/update.d.ts.map +1 -1
  909. package/dist/formatters/update.js +46 -6
  910. package/dist/formatters/update.js.map +1 -1
  911. package/dist/formatters/update.test.d.ts +2 -0
  912. package/dist/formatters/update.test.d.ts.map +1 -0
  913. package/dist/formatters/update.test.js +103 -0
  914. package/dist/formatters/update.test.js.map +1 -0
  915. package/dist/formatters/verify.d.ts +12 -4
  916. package/dist/formatters/verify.d.ts.map +1 -1
  917. package/dist/formatters/verify.js +20 -2
  918. package/dist/formatters/verify.js.map +1 -1
  919. package/dist/generated/healthGapKinds.generated.d.ts +12 -0
  920. package/dist/generated/healthGapKinds.generated.d.ts.map +1 -0
  921. package/dist/generated/healthGapKinds.generated.js +24 -0
  922. package/dist/generated/healthGapKinds.generated.js.map +1 -0
  923. package/dist/generated/organisationalAuthorityRefusalCodes.generated.d.ts +12 -0
  924. package/dist/generated/organisationalAuthorityRefusalCodes.generated.d.ts.map +1 -0
  925. package/dist/generated/organisationalAuthorityRefusalCodes.generated.js +11 -0
  926. package/dist/generated/organisationalAuthorityRefusalCodes.generated.js.map +1 -0
  927. package/dist/generated/relationTypes.generated.d.ts +12 -0
  928. package/dist/generated/relationTypes.generated.d.ts.map +1 -0
  929. package/dist/generated/relationTypes.generated.js +11 -0
  930. package/dist/generated/relationTypes.generated.js.map +1 -0
  931. package/dist/generated/routeLatencyBudget.generated.d.ts +55 -0
  932. package/dist/generated/routeLatencyBudget.generated.d.ts.map +1 -0
  933. package/dist/generated/routeLatencyBudget.generated.js +311 -0
  934. package/dist/generated/routeLatencyBudget.generated.js.map +1 -0
  935. package/dist/generated/sourceSurfaces.generated.d.ts +12 -0
  936. package/dist/generated/sourceSurfaces.generated.d.ts.map +1 -0
  937. package/dist/generated/sourceSurfaces.generated.js +11 -0
  938. package/dist/generated/sourceSurfaces.generated.js.map +1 -0
  939. package/dist/generators/adapters.d.ts +33 -2
  940. package/dist/generators/adapters.d.ts.map +1 -1
  941. package/dist/generators/adapters.js +68 -23
  942. package/dist/generators/adapters.js.map +1 -1
  943. package/dist/generators/adapters.test.js +0 -2
  944. package/dist/generators/adapters.test.js.map +1 -1
  945. package/dist/generators/archetypes.d.ts.map +1 -1
  946. package/dist/generators/archetypes.js +46 -9
  947. package/dist/generators/archetypes.js.map +1 -1
  948. package/dist/generators/archetypes.test.js +35 -0
  949. package/dist/generators/archetypes.test.js.map +1 -1
  950. package/dist/generators/boundary-manifest.d.ts +29 -0
  951. package/dist/generators/boundary-manifest.d.ts.map +1 -0
  952. package/dist/generators/boundary-manifest.js +183 -0
  953. package/dist/generators/boundary-manifest.js.map +1 -0
  954. package/dist/generators/boundary-manifest.real-file.test.d.ts +2 -0
  955. package/dist/generators/boundary-manifest.real-file.test.d.ts.map +1 -0
  956. package/dist/generators/boundary-manifest.real-file.test.js +70 -0
  957. package/dist/generators/boundary-manifest.real-file.test.js.map +1 -0
  958. package/dist/generators/boundary-manifest.test.d.ts +2 -0
  959. package/dist/generators/boundary-manifest.test.d.ts.map +1 -0
  960. package/dist/generators/boundary-manifest.test.js +91 -0
  961. package/dist/generators/boundary-manifest.test.js.map +1 -0
  962. package/dist/generators/chain-classifier-kernel-client-drift.test.d.ts +2 -0
  963. package/dist/generators/chain-classifier-kernel-client-drift.test.d.ts.map +1 -0
  964. package/dist/generators/chain-classifier-kernel-client-drift.test.js +41 -0
  965. package/dist/generators/chain-classifier-kernel-client-drift.test.js.map +1 -0
  966. package/dist/generators/chain-classifier.d.ts +67 -14
  967. package/dist/generators/chain-classifier.d.ts.map +1 -1
  968. package/dist/generators/chain-classifier.js +46 -174
  969. package/dist/generators/chain-classifier.js.map +1 -1
  970. package/dist/generators/chain-rules.d.ts +3 -3
  971. package/dist/generators/chain-rules.d.ts.map +1 -1
  972. package/dist/generators/chain-rules.js +118 -6
  973. package/dist/generators/chain-rules.js.map +1 -1
  974. package/dist/generators/chain-rules.test.js +273 -4
  975. package/dist/generators/chain-rules.test.js.map +1 -1
  976. package/dist/generators/context-md.js +7 -7
  977. package/dist/generators/context-md.js.map +1 -1
  978. package/dist/generators/manifest.d.ts +115 -0
  979. package/dist/generators/manifest.d.ts.map +1 -0
  980. package/dist/generators/manifest.js +277 -0
  981. package/dist/generators/manifest.js.map +1 -0
  982. package/dist/generators/noProjectionAssets.d.ts +15 -0
  983. package/dist/generators/noProjectionAssets.d.ts.map +1 -0
  984. package/dist/generators/noProjectionAssets.js +6 -0
  985. package/dist/generators/noProjectionAssets.js.map +1 -0
  986. package/dist/generators/portable-knowledge.d.ts +24 -12
  987. package/dist/generators/portable-knowledge.d.ts.map +1 -1
  988. package/dist/generators/portable-knowledge.js +97 -57
  989. package/dist/generators/portable-knowledge.js.map +1 -1
  990. package/dist/generators/portable-knowledge.test.js +46 -81
  991. package/dist/generators/portable-knowledge.test.js.map +1 -1
  992. package/dist/generators/region-projections.d.ts +17 -0
  993. package/dist/generators/region-projections.d.ts.map +1 -0
  994. package/dist/generators/region-projections.js +48 -0
  995. package/dist/generators/region-projections.js.map +1 -0
  996. package/dist/generators/region-projections.test.d.ts +2 -0
  997. package/dist/generators/region-projections.test.d.ts.map +1 -0
  998. package/dist/generators/region-projections.test.js +63 -0
  999. package/dist/generators/region-projections.test.js.map +1 -0
  1000. package/dist/generators/region.d.ts +24 -0
  1001. package/dist/generators/region.d.ts.map +1 -0
  1002. package/dist/generators/region.js +87 -0
  1003. package/dist/generators/region.js.map +1 -0
  1004. package/dist/generators/region.test.d.ts +2 -0
  1005. package/dist/generators/region.test.d.ts.map +1 -0
  1006. package/dist/generators/region.test.js +126 -0
  1007. package/dist/generators/region.test.js.map +1 -0
  1008. package/dist/generators/surface-profiles.d.ts +1 -2
  1009. package/dist/generators/surface-profiles.d.ts.map +1 -1
  1010. package/dist/generators/surface-profiles.js.map +1 -1
  1011. package/dist/handleCliError.d.ts +2 -0
  1012. package/dist/handleCliError.d.ts.map +1 -0
  1013. package/dist/handleCliError.js +56 -0
  1014. package/dist/handleCliError.js.map +1 -0
  1015. package/dist/index.d.ts +0 -5
  1016. package/dist/index.d.ts.map +1 -1
  1017. package/dist/index.js +320 -240
  1018. package/dist/index.js.map +1 -1
  1019. package/dist/lib/__tests__/legalRelationTypes.test.d.ts +2 -0
  1020. package/dist/lib/__tests__/legalRelationTypes.test.d.ts.map +1 -0
  1021. package/dist/lib/__tests__/legalRelationTypes.test.js +98 -0
  1022. package/dist/lib/__tests__/legalRelationTypes.test.js.map +1 -0
  1023. package/dist/lib/__tests__/parseFields.test.d.ts +2 -0
  1024. package/dist/lib/__tests__/parseFields.test.d.ts.map +1 -0
  1025. package/dist/lib/__tests__/parseFields.test.js +40 -0
  1026. package/dist/lib/__tests__/parseFields.test.js.map +1 -0
  1027. package/dist/lib/activation.d.ts.map +1 -1
  1028. package/dist/lib/activation.js +8 -4
  1029. package/dist/lib/activation.js.map +1 -1
  1030. package/dist/lib/activation.test.js +6 -6
  1031. package/dist/lib/activation.test.js.map +1 -1
  1032. package/dist/lib/adminConfig.d.ts +48 -0
  1033. package/dist/lib/adminConfig.d.ts.map +1 -0
  1034. package/dist/lib/adminConfig.js +130 -0
  1035. package/dist/lib/adminConfig.js.map +1 -0
  1036. package/dist/lib/canonicalRefs.d.ts +160 -0
  1037. package/dist/lib/canonicalRefs.d.ts.map +1 -0
  1038. package/dist/lib/canonicalRefs.js +169 -0
  1039. package/dist/lib/canonicalRefs.js.map +1 -0
  1040. package/dist/lib/captureGrounding.d.ts +43 -0
  1041. package/dist/lib/captureGrounding.d.ts.map +1 -0
  1042. package/dist/lib/captureGrounding.js +99 -0
  1043. package/dist/lib/captureGrounding.js.map +1 -0
  1044. package/dist/lib/captureGrounding.test.d.ts +2 -0
  1045. package/dist/lib/captureGrounding.test.d.ts.map +1 -0
  1046. package/dist/lib/captureGrounding.test.js +116 -0
  1047. package/dist/lib/captureGrounding.test.js.map +1 -0
  1048. package/dist/lib/captureLink.d.ts +26 -0
  1049. package/dist/lib/captureLink.d.ts.map +1 -0
  1050. package/dist/lib/captureLink.js +96 -0
  1051. package/dist/lib/captureLink.js.map +1 -0
  1052. package/dist/lib/captureVersion.d.ts +38 -0
  1053. package/dist/lib/captureVersion.d.ts.map +1 -0
  1054. package/dist/lib/captureVersion.js +73 -0
  1055. package/dist/lib/captureVersion.js.map +1 -0
  1056. package/dist/lib/client.d.ts +48 -21
  1057. package/dist/lib/client.d.ts.map +1 -1
  1058. package/dist/lib/client.js +237 -78
  1059. package/dist/lib/client.js.map +1 -1
  1060. package/dist/lib/collectionRegistry.d.ts +80 -0
  1061. package/dist/lib/collectionRegistry.d.ts.map +1 -0
  1062. package/dist/lib/collectionRegistry.js +170 -0
  1063. package/dist/lib/collectionRegistry.js.map +1 -0
  1064. package/dist/lib/commanderOptions.d.ts +8 -0
  1065. package/dist/lib/commanderOptions.d.ts.map +1 -0
  1066. package/dist/lib/commanderOptions.js +10 -0
  1067. package/dist/lib/commanderOptions.js.map +1 -0
  1068. package/dist/lib/compose-wrapup-view.d.ts +48 -0
  1069. package/dist/lib/compose-wrapup-view.d.ts.map +1 -0
  1070. package/dist/lib/compose-wrapup-view.js +37 -0
  1071. package/dist/lib/compose-wrapup-view.js.map +1 -0
  1072. package/dist/lib/config.d.ts +102 -54
  1073. package/dist/lib/config.d.ts.map +1 -1
  1074. package/dist/lib/config.js +252 -156
  1075. package/dist/lib/config.js.map +1 -1
  1076. package/dist/lib/configResult.d.ts +103 -0
  1077. package/dist/lib/configResult.d.ts.map +1 -0
  1078. package/dist/lib/configResult.js +180 -0
  1079. package/dist/lib/configResult.js.map +1 -0
  1080. package/dist/lib/connectKeyLabel.d.ts +9 -0
  1081. package/dist/lib/connectKeyLabel.d.ts.map +1 -0
  1082. package/dist/lib/connectKeyLabel.js +12 -0
  1083. package/dist/lib/connectKeyLabel.js.map +1 -0
  1084. package/dist/lib/constants.d.ts +5 -1
  1085. package/dist/lib/constants.d.ts.map +1 -1
  1086. package/dist/lib/constants.js +8 -1
  1087. package/dist/lib/constants.js.map +1 -1
  1088. package/dist/lib/conversation.d.ts +36 -0
  1089. package/dist/lib/conversation.d.ts.map +1 -0
  1090. package/dist/lib/conversation.js +66 -0
  1091. package/dist/lib/conversation.js.map +1 -0
  1092. package/dist/lib/createEntryResult.d.ts +34 -0
  1093. package/dist/lib/createEntryResult.d.ts.map +1 -0
  1094. package/dist/lib/createEntryResult.js +12 -0
  1095. package/dist/lib/createEntryResult.js.map +1 -0
  1096. package/dist/lib/deployment.test.js +19 -0
  1097. package/dist/lib/deployment.test.js.map +1 -1
  1098. package/dist/lib/envKeySnapshot.d.ts +10 -0
  1099. package/dist/lib/envKeySnapshot.d.ts.map +1 -0
  1100. package/dist/lib/envKeySnapshot.js +30 -0
  1101. package/dist/lib/envKeySnapshot.js.map +1 -0
  1102. package/dist/lib/errors.d.ts +70 -0
  1103. package/dist/lib/errors.d.ts.map +1 -1
  1104. package/dist/lib/errors.js +70 -0
  1105. package/dist/lib/errors.js.map +1 -1
  1106. package/dist/lib/frontmatter.d.ts +55 -0
  1107. package/dist/lib/frontmatter.d.ts.map +1 -0
  1108. package/dist/lib/frontmatter.js +92 -0
  1109. package/dist/lib/frontmatter.js.map +1 -0
  1110. package/dist/lib/frontmatter.test.d.ts +15 -0
  1111. package/dist/lib/frontmatter.test.d.ts.map +1 -0
  1112. package/dist/lib/frontmatter.test.js +98 -0
  1113. package/dist/lib/frontmatter.test.js.map +1 -0
  1114. package/dist/lib/gatewayTimeout.d.ts +88 -0
  1115. package/dist/lib/gatewayTimeout.d.ts.map +1 -0
  1116. package/dist/lib/gatewayTimeout.js +118 -0
  1117. package/dist/lib/gatewayTimeout.js.map +1 -0
  1118. package/dist/lib/gitEnvLeakKeysParity.test.d.ts +2 -0
  1119. package/dist/lib/gitEnvLeakKeysParity.test.d.ts.map +1 -0
  1120. package/dist/lib/gitEnvLeakKeysParity.test.js +73 -0
  1121. package/dist/lib/gitEnvLeakKeysParity.test.js.map +1 -0
  1122. package/dist/lib/glossary.js +1 -1
  1123. package/dist/lib/glossary.js.map +1 -1
  1124. package/dist/lib/hook-intents.d.ts +51 -0
  1125. package/dist/lib/hook-intents.d.ts.map +1 -0
  1126. package/dist/lib/hook-intents.js +84 -0
  1127. package/dist/lib/hook-intents.js.map +1 -0
  1128. package/dist/lib/inferSourceDate.d.ts +12 -0
  1129. package/dist/lib/inferSourceDate.d.ts.map +1 -0
  1130. package/dist/lib/inferSourceDate.js +44 -0
  1131. package/dist/lib/inferSourceDate.js.map +1 -0
  1132. package/dist/lib/kernelEnvelope.d.ts +31 -0
  1133. package/dist/lib/kernelEnvelope.d.ts.map +1 -0
  1134. package/dist/lib/kernelEnvelope.js +52 -0
  1135. package/dist/lib/kernelEnvelope.js.map +1 -0
  1136. package/dist/lib/legalRelationTypes.d.ts +25 -0
  1137. package/dist/lib/legalRelationTypes.d.ts.map +1 -0
  1138. package/dist/lib/legalRelationTypes.js +94 -0
  1139. package/dist/lib/legalRelationTypes.js.map +1 -0
  1140. package/dist/lib/localBinding.d.ts +86 -0
  1141. package/dist/lib/localBinding.d.ts.map +1 -0
  1142. package/dist/lib/localBinding.js +173 -0
  1143. package/dist/lib/localBinding.js.map +1 -0
  1144. package/dist/lib/method-registry.d.ts +37 -0
  1145. package/dist/lib/method-registry.d.ts.map +1 -0
  1146. package/dist/lib/method-registry.js +41 -0
  1147. package/dist/lib/method-registry.js.map +1 -0
  1148. package/dist/lib/normalizeMaterializedFilename.d.ts +28 -0
  1149. package/dist/lib/normalizeMaterializedFilename.d.ts.map +1 -0
  1150. package/dist/lib/normalizeMaterializedFilename.js +56 -0
  1151. package/dist/lib/normalizeMaterializedFilename.js.map +1 -0
  1152. package/dist/lib/normalizeMaterializedFilename.test.d.ts +16 -0
  1153. package/dist/lib/normalizeMaterializedFilename.test.d.ts.map +1 -0
  1154. package/dist/lib/normalizeMaterializedFilename.test.js +90 -0
  1155. package/dist/lib/normalizeMaterializedFilename.test.js.map +1 -0
  1156. package/dist/lib/notice-marker.d.ts +3 -0
  1157. package/dist/lib/notice-marker.d.ts.map +1 -0
  1158. package/dist/lib/notice-marker.js +223 -0
  1159. package/dist/lib/notice-marker.js.map +1 -0
  1160. package/dist/lib/onboarding-path-b.d.ts.map +1 -1
  1161. package/dist/lib/onboarding-path-b.js +42 -13
  1162. package/dist/lib/onboarding-path-b.js.map +1 -1
  1163. package/dist/lib/onboarding-shared.d.ts +4 -4
  1164. package/dist/lib/onboarding-shared.d.ts.map +1 -1
  1165. package/dist/lib/onboarding-shared.js +7 -22
  1166. package/dist/lib/onboarding-shared.js.map +1 -1
  1167. package/dist/lib/onboarding.d.ts.map +1 -1
  1168. package/dist/lib/onboarding.js +12 -4
  1169. package/dist/lib/onboarding.js.map +1 -1
  1170. package/dist/lib/ownerLine.d.ts +62 -0
  1171. package/dist/lib/ownerLine.d.ts.map +1 -0
  1172. package/dist/lib/ownerLine.js +42 -0
  1173. package/dist/lib/ownerLine.js.map +1 -0
  1174. package/dist/lib/parseFields.d.ts +19 -0
  1175. package/dist/lib/parseFields.d.ts.map +1 -0
  1176. package/dist/lib/parseFields.js +49 -0
  1177. package/dist/lib/parseFields.js.map +1 -0
  1178. package/dist/lib/previewBanner.d.ts +9 -0
  1179. package/dist/lib/previewBanner.d.ts.map +1 -0
  1180. package/dist/lib/previewBanner.js +37 -0
  1181. package/dist/lib/previewBanner.js.map +1 -0
  1182. package/dist/lib/productbrain-files.d.ts +94 -0
  1183. package/dist/lib/productbrain-files.d.ts.map +1 -0
  1184. package/dist/lib/productbrain-files.js +214 -0
  1185. package/dist/lib/productbrain-files.js.map +1 -0
  1186. package/dist/lib/productbrain-files.test.d.ts +2 -0
  1187. package/dist/lib/productbrain-files.test.d.ts.map +1 -0
  1188. package/dist/lib/productbrain-files.test.js +293 -0
  1189. package/dist/lib/productbrain-files.test.js.map +1 -0
  1190. package/dist/lib/profiles.d.ts +53 -5
  1191. package/dist/lib/profiles.d.ts.map +1 -1
  1192. package/dist/lib/profiles.js +77 -23
  1193. package/dist/lib/profiles.js.map +1 -1
  1194. package/dist/lib/projectConfig.d.ts +81 -0
  1195. package/dist/lib/projectConfig.d.ts.map +1 -0
  1196. package/dist/lib/projectConfig.js +157 -0
  1197. package/dist/lib/projectConfig.js.map +1 -0
  1198. package/dist/lib/rate-limit.d.ts +38 -0
  1199. package/dist/lib/rate-limit.d.ts.map +1 -0
  1200. package/dist/lib/rate-limit.js +83 -0
  1201. package/dist/lib/rate-limit.js.map +1 -0
  1202. package/dist/lib/readinessNotices.d.ts +15 -0
  1203. package/dist/lib/readinessNotices.d.ts.map +1 -0
  1204. package/dist/lib/readinessNotices.js +15 -0
  1205. package/dist/lib/readinessNotices.js.map +1 -0
  1206. package/dist/lib/repo-detect.d.ts +5 -1
  1207. package/dist/lib/repo-detect.d.ts.map +1 -1
  1208. package/dist/lib/repo-detect.js +10 -3
  1209. package/dist/lib/repo-detect.js.map +1 -1
  1210. package/dist/lib/reportedProfile.d.ts +18 -0
  1211. package/dist/lib/reportedProfile.d.ts.map +1 -0
  1212. package/dist/lib/reportedProfile.js +144 -0
  1213. package/dist/lib/reportedProfile.js.map +1 -0
  1214. package/dist/lib/runner.d.ts +9 -1
  1215. package/dist/lib/runner.d.ts.map +1 -1
  1216. package/dist/lib/runner.js +30 -4
  1217. package/dist/lib/runner.js.map +1 -1
  1218. package/dist/lib/session.d.ts +113 -4
  1219. package/dist/lib/session.d.ts.map +1 -1
  1220. package/dist/lib/session.js +323 -13
  1221. package/dist/lib/session.js.map +1 -1
  1222. package/dist/lib/sessionBinding.d.ts +61 -0
  1223. package/dist/lib/sessionBinding.d.ts.map +1 -0
  1224. package/dist/lib/sessionBinding.js +125 -0
  1225. package/dist/lib/sessionBinding.js.map +1 -0
  1226. package/dist/lib/sessionNotices.d.ts +57 -0
  1227. package/dist/lib/sessionNotices.d.ts.map +1 -0
  1228. package/dist/lib/sessionNotices.js +128 -0
  1229. package/dist/lib/sessionNotices.js.map +1 -0
  1230. package/dist/lib/sessionNotices.test.d.ts +2 -0
  1231. package/dist/lib/sessionNotices.test.d.ts.map +1 -0
  1232. package/dist/lib/sessionNotices.test.js +48 -0
  1233. package/dist/lib/sessionNotices.test.js.map +1 -0
  1234. package/dist/lib/spineVerdictRead.d.ts +70 -0
  1235. package/dist/lib/spineVerdictRead.d.ts.map +1 -0
  1236. package/dist/lib/spineVerdictRead.js +73 -0
  1237. package/dist/lib/spineVerdictRead.js.map +1 -0
  1238. package/dist/lib/spinner.js +2 -2
  1239. package/dist/lib/spinner.js.map +1 -1
  1240. package/dist/lib/startup-resolution-signals.d.ts +34 -0
  1241. package/dist/lib/startup-resolution-signals.d.ts.map +1 -0
  1242. package/dist/lib/startup-resolution-signals.js +116 -0
  1243. package/dist/lib/startup-resolution-signals.js.map +1 -0
  1244. package/dist/lib/startup-resolution-signals.test.d.ts +2 -0
  1245. package/dist/lib/startup-resolution-signals.test.d.ts.map +1 -0
  1246. package/dist/lib/startup-resolution-signals.test.js +113 -0
  1247. package/dist/lib/startup-resolution-signals.test.js.map +1 -0
  1248. package/dist/lib/startup-signals.d.ts +12 -0
  1249. package/dist/lib/startup-signals.d.ts.map +1 -0
  1250. package/dist/lib/startup-signals.js +179 -0
  1251. package/dist/lib/startup-signals.js.map +1 -0
  1252. package/dist/lib/startup-signals.test.d.ts +2 -0
  1253. package/dist/lib/startup-signals.test.d.ts.map +1 -0
  1254. package/dist/lib/startup-signals.test.js +165 -0
  1255. package/dist/lib/startup-signals.test.js.map +1 -0
  1256. package/dist/lib/state.d.ts +60 -0
  1257. package/dist/lib/state.d.ts.map +1 -0
  1258. package/dist/lib/state.js +97 -0
  1259. package/dist/lib/state.js.map +1 -0
  1260. package/dist/lib/strip.d.ts +17 -0
  1261. package/dist/lib/strip.d.ts.map +1 -1
  1262. package/dist/lib/strip.js +48 -1
  1263. package/dist/lib/strip.js.map +1 -1
  1264. package/dist/lib/style.d.ts +10 -2
  1265. package/dist/lib/style.d.ts.map +1 -1
  1266. package/dist/lib/style.js +26 -17
  1267. package/dist/lib/style.js.map +1 -1
  1268. package/dist/lib/tokenConstants.d.ts +2 -0
  1269. package/dist/lib/tokenConstants.d.ts.map +1 -1
  1270. package/dist/lib/tokenConstants.js +2 -0
  1271. package/dist/lib/tokenConstants.js.map +1 -1
  1272. package/dist/lib/update-check.d.ts +56 -0
  1273. package/dist/lib/update-check.d.ts.map +1 -0
  1274. package/dist/lib/update-check.js +296 -0
  1275. package/dist/lib/update-check.js.map +1 -0
  1276. package/dist/lib/upgrade-runner.d.ts +22 -0
  1277. package/dist/lib/upgrade-runner.d.ts.map +1 -0
  1278. package/dist/lib/upgrade-runner.js +110 -0
  1279. package/dist/lib/upgrade-runner.js.map +1 -0
  1280. package/dist/lib/versionWrite.d.ts +65 -0
  1281. package/dist/lib/versionWrite.d.ts.map +1 -0
  1282. package/dist/lib/versionWrite.js +32 -0
  1283. package/dist/lib/versionWrite.js.map +1 -0
  1284. package/dist/lib/workspace-probe.d.ts +3 -0
  1285. package/dist/lib/workspace-probe.d.ts.map +1 -1
  1286. package/dist/lib/workspace-probe.js +8 -14
  1287. package/dist/lib/workspace-probe.js.map +1 -1
  1288. package/dist/lib/workspaceNotice.d.ts +202 -0
  1289. package/dist/lib/workspaceNotice.d.ts.map +1 -0
  1290. package/dist/lib/workspaceNotice.js +345 -0
  1291. package/dist/lib/workspaceNotice.js.map +1 -0
  1292. package/dist/lib/workspaceVocabCache.d.ts +60 -0
  1293. package/dist/lib/workspaceVocabCache.d.ts.map +1 -0
  1294. package/dist/lib/workspaceVocabCache.js +98 -0
  1295. package/dist/lib/workspaceVocabCache.js.map +1 -0
  1296. package/dist/registerEntryCommands.d.ts +17 -0
  1297. package/dist/registerEntryCommands.d.ts.map +1 -0
  1298. package/dist/registerEntryCommands.js +106 -0
  1299. package/dist/registerEntryCommands.js.map +1 -0
  1300. package/dist/registerHistoryCommand.d.ts +8 -0
  1301. package/dist/registerHistoryCommand.d.ts.map +1 -0
  1302. package/dist/registerHistoryCommand.js +14 -0
  1303. package/dist/registerHistoryCommand.js.map +1 -0
  1304. package/dist/registerOutcomeCommands.d.ts +27 -0
  1305. package/dist/registerOutcomeCommands.d.ts.map +1 -0
  1306. package/dist/registerOutcomeCommands.js +27 -0
  1307. package/dist/registerOutcomeCommands.js.map +1 -0
  1308. package/dist/registerProposalCommands.d.ts +13 -0
  1309. package/dist/registerProposalCommands.d.ts.map +1 -0
  1310. package/dist/registerProposalCommands.js +76 -0
  1311. package/dist/registerProposalCommands.js.map +1 -0
  1312. package/dist/registerRoleCommands.d.ts +10 -0
  1313. package/dist/registerRoleCommands.d.ts.map +1 -0
  1314. package/dist/registerRoleCommands.js +14 -0
  1315. package/dist/registerRoleCommands.js.map +1 -0
  1316. package/dist/scoreboard/diagnose.d.ts +226 -0
  1317. package/dist/scoreboard/diagnose.d.ts.map +1 -0
  1318. package/dist/scoreboard/diagnose.js +344 -0
  1319. package/dist/scoreboard/diagnose.js.map +1 -0
  1320. package/dist/scoreboard/diagnose.test.d.ts +15 -0
  1321. package/dist/scoreboard/diagnose.test.d.ts.map +1 -0
  1322. package/dist/scoreboard/diagnose.test.js +355 -0
  1323. package/dist/scoreboard/diagnose.test.js.map +1 -0
  1324. package/dist/scoreboard/floors.d.ts +47 -0
  1325. package/dist/scoreboard/floors.d.ts.map +1 -0
  1326. package/dist/scoreboard/floors.js +33 -0
  1327. package/dist/scoreboard/floors.js.map +1 -0
  1328. package/dist/scoreboard/localDrift.d.ts +23 -0
  1329. package/dist/scoreboard/localDrift.d.ts.map +1 -0
  1330. package/dist/scoreboard/localDrift.js +111 -0
  1331. package/dist/scoreboard/localDrift.js.map +1 -0
  1332. package/dist/scoreboard/localDrift.test.d.ts +9 -0
  1333. package/dist/scoreboard/localDrift.test.d.ts.map +1 -0
  1334. package/dist/scoreboard/localDrift.test.js +82 -0
  1335. package/dist/scoreboard/localDrift.test.js.map +1 -0
  1336. package/dist/setup/__tests__/coach-traces.test.d.ts +2 -0
  1337. package/dist/setup/__tests__/coach-traces.test.d.ts.map +1 -0
  1338. package/dist/setup/__tests__/coach-traces.test.js +189 -0
  1339. package/dist/setup/__tests__/coach-traces.test.js.map +1 -0
  1340. package/dist/setup/__tests__/setup-commands.test.d.ts +2 -0
  1341. package/dist/setup/__tests__/setup-commands.test.d.ts.map +1 -0
  1342. package/dist/setup/__tests__/setup-commands.test.js +177 -0
  1343. package/dist/setup/__tests__/setup-commands.test.js.map +1 -0
  1344. package/dist/setup/__tests__/state-machine.test.d.ts +2 -0
  1345. package/dist/setup/__tests__/state-machine.test.d.ts.map +1 -0
  1346. package/dist/setup/__tests__/state-machine.test.js +341 -0
  1347. package/dist/setup/__tests__/state-machine.test.js.map +1 -0
  1348. package/dist/setup/detect-surfaces.d.ts +21 -0
  1349. package/dist/setup/detect-surfaces.d.ts.map +1 -0
  1350. package/dist/setup/detect-surfaces.js +39 -0
  1351. package/dist/setup/detect-surfaces.js.map +1 -0
  1352. package/dist/setup/manifest-writer.d.ts +17 -0
  1353. package/dist/setup/manifest-writer.d.ts.map +1 -0
  1354. package/dist/setup/manifest-writer.js +153 -0
  1355. package/dist/setup/manifest-writer.js.map +1 -0
  1356. package/dist/setup/perimeter.d.ts +72 -0
  1357. package/dist/setup/perimeter.d.ts.map +1 -0
  1358. package/dist/setup/perimeter.js +128 -0
  1359. package/dist/setup/perimeter.js.map +1 -0
  1360. package/dist/setup/state-machine.d.ts +67 -0
  1361. package/dist/setup/state-machine.d.ts.map +1 -0
  1362. package/dist/setup/state-machine.js +124 -0
  1363. package/dist/setup/state-machine.js.map +1 -0
  1364. package/dist/surfaces/__tests__/adapter.test.d.ts +2 -0
  1365. package/dist/surfaces/__tests__/adapter.test.d.ts.map +1 -0
  1366. package/dist/surfaces/__tests__/adapter.test.js +86 -0
  1367. package/dist/surfaces/__tests__/adapter.test.js.map +1 -0
  1368. package/dist/surfaces/__tests__/pb-setup-passthrough.test.d.ts +2 -0
  1369. package/dist/surfaces/__tests__/pb-setup-passthrough.test.d.ts.map +1 -0
  1370. package/dist/surfaces/__tests__/pb-setup-passthrough.test.js +131 -0
  1371. package/dist/surfaces/__tests__/pb-setup-passthrough.test.js.map +1 -0
  1372. package/dist/surfaces/__tests__/telemetry.test.d.ts +2 -0
  1373. package/dist/surfaces/__tests__/telemetry.test.d.ts.map +1 -0
  1374. package/dist/surfaces/__tests__/telemetry.test.js +55 -0
  1375. package/dist/surfaces/__tests__/telemetry.test.js.map +1 -0
  1376. package/dist/surfaces/adapter.d.ts +70 -0
  1377. package/dist/surfaces/adapter.d.ts.map +1 -0
  1378. package/dist/surfaces/adapter.js +2 -0
  1379. package/dist/surfaces/adapter.js.map +1 -0
  1380. package/dist/surfaces/adapters/claude.d.ts +3 -0
  1381. package/dist/surfaces/adapters/claude.d.ts.map +1 -0
  1382. package/dist/surfaces/adapters/claude.js +72 -0
  1383. package/dist/surfaces/adapters/claude.js.map +1 -0
  1384. package/dist/surfaces/adapters/codex.d.ts +3 -0
  1385. package/dist/surfaces/adapters/codex.d.ts.map +1 -0
  1386. package/dist/surfaces/adapters/codex.js +61 -0
  1387. package/dist/surfaces/adapters/codex.js.map +1 -0
  1388. package/dist/surfaces/adapters/copilot.d.ts +3 -0
  1389. package/dist/surfaces/adapters/copilot.d.ts.map +1 -0
  1390. package/dist/surfaces/adapters/copilot.js +59 -0
  1391. package/dist/surfaces/adapters/copilot.js.map +1 -0
  1392. package/dist/surfaces/adapters/cursor.d.ts +3 -0
  1393. package/dist/surfaces/adapters/cursor.d.ts.map +1 -0
  1394. package/dist/surfaces/adapters/cursor.js +78 -0
  1395. package/dist/surfaces/adapters/cursor.js.map +1 -0
  1396. package/dist/surfaces/registry.d.ts +76 -0
  1397. package/dist/surfaces/registry.d.ts.map +1 -0
  1398. package/dist/surfaces/registry.js +117 -0
  1399. package/dist/surfaces/registry.js.map +1 -0
  1400. package/dist/surfaces/telemetry.d.ts +17 -0
  1401. package/dist/surfaces/telemetry.d.ts.map +1 -0
  1402. package/dist/surfaces/telemetry.js +31 -0
  1403. package/dist/surfaces/telemetry.js.map +1 -0
  1404. package/package.json +9 -5
  1405. package/templates/method-registry.json +16 -0
  1406. package/dist/__tests__/promote.test.d.ts +0 -2
  1407. package/dist/__tests__/promote.test.d.ts.map +0 -1
  1408. package/dist/__tests__/promote.test.js +0 -161
  1409. package/dist/__tests__/promote.test.js.map +0 -1
  1410. package/dist/__tests__/setup.test.d.ts +0 -2
  1411. package/dist/__tests__/setup.test.d.ts.map +0 -1
  1412. package/dist/__tests__/setup.test.js +0 -141
  1413. package/dist/__tests__/setup.test.js.map +0 -1
  1414. package/dist/commands/promote.d.ts +0 -12
  1415. package/dist/commands/promote.d.ts.map +0 -1
  1416. package/dist/commands/promote.js +0 -90
  1417. package/dist/commands/promote.js.map +0 -1
  1418. package/dist/formatters/promote.d.ts +0 -30
  1419. package/dist/formatters/promote.d.ts.map +0 -1
  1420. package/dist/formatters/promote.js +0 -39
  1421. package/dist/formatters/promote.js.map +0 -1
  1422. package/dist/generators/__tests__/surface-profiles.test.d.ts +0 -2
  1423. package/dist/generators/__tests__/surface-profiles.test.d.ts.map +0 -1
  1424. package/dist/generators/__tests__/surface-profiles.test.js +0 -89
  1425. package/dist/generators/__tests__/surface-profiles.test.js.map +0 -1
  1426. package/dist/generators/chain-classifier.test.d.ts +0 -2
  1427. package/dist/generators/chain-classifier.test.d.ts.map +0 -1
  1428. package/dist/generators/chain-classifier.test.js +0 -257
  1429. package/dist/generators/chain-classifier.test.js.map +0 -1
  1430. package/dist/lib/onboarding-phases.d.ts +0 -9
  1431. package/dist/lib/onboarding-phases.d.ts.map +0 -1
  1432. package/dist/lib/onboarding-phases.js +0 -120
  1433. package/dist/lib/onboarding-phases.js.map +0 -1
@@ -1,24 +1,96 @@
1
1
  /**
2
2
  * pb handshake — generate context files for AI developer tools.
3
- * The fourth delivery surface: context export (GLO-63, DEC-161).
3
+ * Context export wiring (read-only filesystem bridge; GLO-63, DEC-161) — not a product surface.
4
4
  */
5
- import { mkdirSync, writeFileSync, existsSync, readFileSync, readdirSync, copyFileSync } from 'fs';
6
- import { join, dirname, resolve } from 'path';
5
+ import { mkdirSync, writeFileSync, existsSync, readFileSync, readdirSync, copyFileSync, realpathSync } from 'fs';
6
+ import { join, dirname, resolve, basename, relative, sep, isAbsolute } from 'path';
7
7
  import { homedir } from 'os';
8
8
  import { fileURLToPath } from 'url';
9
+ import { createHash } from 'crypto';
10
+ import { execSync } from 'child_process';
9
11
  import { getConfigOrGuide } from '../lib/config.js';
10
- import { select as promptSelect } from '../lib/prompts.js';
11
- import { mcpCall } from '../lib/client.js';
12
+ import { select as promptSelect, confirm as promptConfirm } from '../lib/prompts.js';
13
+ import { composeHooksFromIntents, getHookStatusForSurface } from '../lib/hook-intents.js';
14
+ import { kernelCall, kernelCallWithSession } from '../lib/client.js';
15
+ import { readSession } from '../lib/session.js';
12
16
  import { detectRepo, extractWorkspaceProfile } from '../lib/repo-detect.js';
13
17
  import { generateContextMd } from '../generators/context-md.js';
14
18
  import { generateBriefingMd } from '../generators/briefing-md.js';
15
- import { MARKER, generateAgentsMd, generateClaudeMd, generateCursorMdc, generateCopilotMd } from '../generators/adapters.js';
16
- import { readCanonicalSkills, readCanonicalRules, generateCursorSkill, generateCursorRule, generateCodexSkill, generateCodexSkillIndex, generateClaudeRule, generateClaudeSkillRouter, shouldEmitToTarget, filterByLevel, validateCodexSkills, evaluateConditions, STAGE_TO_MAX_LEVEL, LEVEL_ORDER, } from '../generators/portable-knowledge.js';
19
+ import { MARKER, generateAgentsMd, generateClaudeMd, generateCursorMdc, generateCopilotMd, generateCopilotInstructionFiles } from '../generators/adapters.js';
20
+ import { readCanonicalSkills, readCanonicalRules, readPersonalLayer, readPersonalSkillsLayer, generateCursorSkill, generateCursorRule, generateCodexSkill, generateCodexSkillIndex, shouldEmitToTarget, filterByLevel, validateCodexSkills, evaluateConditions, STAGE_TO_MAX_LEVEL, LEVEL_ORDER, } from '../generators/portable-knowledge.js';
17
21
  import { generateChainRules } from '../generators/chain-rules.js';
22
+ import { findNoProjectionAssets } from '../generators/noProjectionAssets.js'; // WP-660 S2 combine
18
23
  import { saveHandshakeState, loadPreviousState, diffHandshakeState, formatDiff, buildCurrentState, } from '../generators/handshake-diff.js';
19
24
  import { resolveSurfaceProfile } from '../generators/surface-profiles.js';
20
25
  import { formatHandshakeReport } from '../formatters/handshake.js';
26
+ import { classifyAdapterFile, detectEol, spliceAppend, spliceReplace } from '../generators/region.js';
27
+ import { REGION_PROJECTIONS } from '../generators/region-projections.js';
28
+ import { readManifest, readManifestStatus, filterByAdoptionState } from '../generators/manifest.js';
29
+ import { generateBoundaryManifest, getBoundaryEnforcementMode } from '../generators/boundary-manifest.js';
30
+ import { loadMethodRegistry } from '../lib/method-registry.js';
21
31
  import { CLIError, ErrorCode } from '../lib/errors.js';
32
+ import { trackEvent } from '../lib/telemetry.js';
33
+ import { isJsonMode } from '../lib/runner.js';
34
+ import { stripConvexInternals } from '../lib/strip.js';
35
+ import { replaceVocabTokens } from '../lib/canonicalRefs.js';
36
+ // WP-436 S3: vocab projector — resolves {{vocab:...}} tokens before writing to disk.
37
+ import { getOrFetchVocabCtx } from '../lib/workspaceVocabCache.js';
38
+ import { normalizeMaterializedFilename } from '../lib/normalizeMaterializedFilename.js';
39
+ import { findLeftoverCursorSkills, LEFTOVER_FILES_MAX } from './handshakeCursorSkillCleanup.js';
40
+ import { classifyDriftBucket } from './handshakeDriftClassification.js';
41
+ import { parseSetupFrontmatter } from '../lib/frontmatter.js';
42
+ import { sanitizeStartupResolutionSignals } from '../lib/startup-resolution-signals.js';
43
+ import { assertSetupWritePath } from '../setup/perimeter.js';
44
+ // WP-421 S3: SurfaceAdapter reverse-map for tampered prompts (DEC-952, doneWhen #34).
45
+ import { canonicalPathForAnySurface, SURFACE_GOVERN_NO_SURFACES, SURFACE_REGISTRY, validateSurfacesForMode, } from '../surfaces/registry.js';
46
+ import { getReverseMapFallbackMessage, reportReverseMapMissing } from '../surfaces/telemetry.js';
47
+ const MAX_HANDSHAKE_WAIT_MS = 10_000; // 10 seconds
48
+ const POLL_INTERVAL_MS = 500; // 500 ms per poll
49
+ const MAX_POLLS = MAX_HANDSHAKE_WAIT_MS / POLL_INTERVAL_MS; // 20
50
+ /** Single-shot health probe (no internal polling — caller's job, connect-context.ts). Returns
51
+ * `seeds-ready`/`seeds-pending` (query ok) or `probe-failed` (query threw). */
52
+ export async function probeStarterSetupSeeded() {
53
+ try {
54
+ const health = await kernelCall('workspace.health', {});
55
+ if (health.starterSetupSeeded) {
56
+ return { status: 'seeds-ready' };
57
+ }
58
+ const starterGaps = (health.gaps ?? []).filter((g) => g.kind === 'starter-setup-missing' || g.kind === 'platform-domains-missing');
59
+ return {
60
+ status: 'seeds-pending',
61
+ gaps: starterGaps.length > 0 ? starterGaps : [
62
+ {
63
+ kind: 'starter-setup-missing',
64
+ severity: 'warn',
65
+ message: 'Starter setup seeds are still running.',
66
+ },
67
+ ],
68
+ };
69
+ }
70
+ catch (err) {
71
+ return {
72
+ status: 'probe-failed',
73
+ error: err instanceof Error ? err.message : String(err),
74
+ };
75
+ }
76
+ }
77
+ /** Poll `probeStarterSetupSeeded` up to MAX_POLLS times (10s @ 500ms); returns the final probe
78
+ * result (caller renders it). Exported for connect-context.ts's reuse. */
79
+ export async function pollUntilSeedsReady() {
80
+ for (let poll = 0; poll < MAX_POLLS; poll++) {
81
+ const result = await probeStarterSetupSeeded();
82
+ if (result.status === 'seeds-ready')
83
+ return result;
84
+ if (result.status === 'probe-failed')
85
+ return result; // don't retry on auth/network errors
86
+ // seeds-pending — wait before next poll
87
+ if (poll < MAX_POLLS - 1) {
88
+ await new Promise((res) => setTimeout(res, POLL_INTERVAL_MS));
89
+ }
90
+ }
91
+ // Final probe after exhausting waits — return whatever state we have
92
+ return probeStarterSetupSeeded();
93
+ }
22
94
  const LEVELS = {
23
95
  guide: {
24
96
  label: 'Guide me',
@@ -47,12 +119,8 @@ const LEVELS = {
47
119
  };
48
120
  // Explicit ordering — determines menu numbering in promptLevel(). Do not reorder.
49
121
  const LEVEL_KEYS = ['guide', 'work', 'silent', 'full-trust'];
50
- // Hook failure contract (TEN-712): all hook commands MUST end with '2>/dev/null || true'
51
- // so Claude Code always starts even if pb is unavailable. Never remove this suffix.
122
+ // Hook failure contract (TEN-712): every hook command MUST end with '|| true' so Claude Code always starts even if pb is unavailable.
52
123
  const INIT_PERMISSION = 'Bash(pb:*)';
53
- const INIT_SESSION_START_CMD = 'pb session start 2>/dev/null || true';
54
- const INIT_SESSION_CLOSE_CMD = 'pb session close 2>/dev/null || true';
55
- const INIT_PRECOMPACT_CMD = 'pb session id > /dev/null 2>&1 && echo \'{"systemMessage": "pb session active — capture decisions/tensions before compacting: pb capture \\"DEC: ...\\""}\' || true';
56
124
  function readSettings(filePath) {
57
125
  if (!existsSync(filePath))
58
126
  return {};
@@ -64,9 +132,6 @@ function readSettings(filePath) {
64
132
  return {};
65
133
  }
66
134
  }
67
- function hasCommand(groups, cmd) {
68
- return (groups ?? []).some((g) => g.hooks?.some((h) => h.command === cmd));
69
- }
70
135
  // Team write: hooks + Bash(pb:*) → .claude/settings.json (safe to commit)
71
136
  function writeTeamSettings(cwd, dryRun) {
72
137
  const claudeDir = join(cwd, '.claude');
@@ -82,26 +147,10 @@ function writeTeamSettings(cwd, dryRun) {
82
147
  }
83
148
  settings.permissions = permissions;
84
149
  const hooks = (settings.hooks ?? {});
85
- if (!hasCommand(hooks.SessionStart, INIT_SESSION_START_CMD)) {
86
- hooks.SessionStart = [
87
- ...(hooks.SessionStart ?? []),
88
- { hooks: [{ type: 'command', command: INIT_SESSION_START_CMD, statusMessage: 'Opening pb session...' }] },
89
- ];
90
- added.push('SessionStart → pb session start');
91
- }
92
- if (!hasCommand(hooks.Stop, INIT_SESSION_CLOSE_CMD)) {
93
- hooks.Stop = [
94
- ...(hooks.Stop ?? []),
95
- { hooks: [{ type: 'command', command: INIT_SESSION_CLOSE_CMD, statusMessage: 'Closing pb session...' }] },
96
- ];
97
- added.push('Stop → pb session close');
98
- }
99
- if (!hasCommand(hooks.PreCompact, INIT_PRECOMPACT_CMD)) {
100
- hooks.PreCompact = [
101
- ...(hooks.PreCompact ?? []),
102
- { hooks: [{ type: 'command', command: INIT_PRECOMPACT_CMD }] },
103
- ];
104
- added.push('PreCompact → decision capture reminder');
150
+ const hookAdditions = composeHooksFromIntents(['session-start', 'session-close', 'pre-compact'], hooks);
151
+ for (const addition of hookAdditions) {
152
+ hooks[addition.event] = [...(hooks[addition.event] ?? []), addition.entry];
153
+ added.push(addition.label);
105
154
  }
106
155
  settings.hooks = hooks;
107
156
  if (!dryRun) {
@@ -171,8 +220,7 @@ export async function runHandshakeInit(options = {}) {
171
220
  for (const item of teamAdded)
172
221
  console.log(` + ${item}`);
173
222
  }
174
- // Step 2: Personal config — wizard or --level flag
175
- // Cast is safe: LEVEL_KEYS.includes() validated above; invalid level already threw CLIError.
223
+ // Step 2: Personal config — wizard or --level flag. Cast is safe: LEVEL_KEYS.includes() validated above.
176
224
  const levelKey = options.level ? options.level : await promptLevel();
177
225
  const level = LEVELS[levelKey];
178
226
  const personalAdded = writePersonalSettings(levelKey, dryRun);
@@ -194,6 +242,27 @@ export async function runHandshakeInit(options = {}) {
194
242
  if (!dryRun)
195
243
  console.log('Reload /hooks in Claude Code (or restart) to activate.');
196
244
  console.log('Run `pb handshake --init --level <guide|work|silent|full-trust>` to change level.');
245
+ // Step 2b: Report multi-surface hook opt-in status (WP-310 E3b) — manifest.hooks.{cursor,copilot}, silence = no manifest/flags (DEC-536).
246
+ const pbDirForManifest = join(cwd, '.productbrain');
247
+ const initManifest = readManifest(pbDirForManifest);
248
+ const multiSurfaceOptIns = [];
249
+ if (initManifest?.hooks?.cursor)
250
+ multiSurfaceOptIns.push('cursor');
251
+ if (initManifest?.hooks?.copilot)
252
+ multiSurfaceOptIns.push('copilot');
253
+ if (multiSurfaceOptIns.length > 0) {
254
+ console.log('');
255
+ for (const surface of multiSurfaceOptIns) {
256
+ const status = getHookStatusForSurface(surface);
257
+ if (status.writable) {
258
+ // Future-proofing path: surface has hook events, would write files.
259
+ console.log(`ℹ ${surface} hooks: opted in — hooks will be written`);
260
+ }
261
+ else {
262
+ console.log(`ℹ ${surface} hooks: opted in — no auto-hooks (${surface} has no session events; run \`pb session start\` manually)`);
263
+ }
264
+ }
265
+ }
197
266
  // Step 3: Scaffold starter templates if .productbrain/rules/ is empty
198
267
  const rulesDir = join(cwd, '.productbrain', 'rules');
199
268
  const hasExistingRules = existsSync(rulesDir) && readdirSync(rulesDir).filter((f) => f.endsWith('.md')).length > 0;
@@ -242,24 +311,385 @@ export async function runHandshakeInit(options = {}) {
242
311
  }
243
312
  }
244
313
  }
245
- /**
246
- * Normalize volatile handshake-only timestamps before comparing generated files.
247
- * This keeps the visible timestamps in generated artifacts while avoiding
248
- * meaningless rewrites when semantic content is unchanged.
249
- */
314
+ const LOCAL_REF_REGEX = /\b(?:WP|TEN|DEC|BET|FEAT|INS|STD|PRI|ARCH)[-\s#]*\d+\b|\bPR\s*#?\s*\d+\b/gi;
315
+ const STARTUP_RESOLUTION_RESOLVER_VERSION = 'startup-resolution-v1';
316
+ // Global cap on collected refs (spec "Contract: StartupResolutionSignals" — arrays are capped).
317
+ const LOCAL_REF_GLOBAL_CAP = 25;
318
+ // Per-source cap so a broad source (context.md) can't starve briefing.md's task-specific refs (Codex@677).
319
+ const LOCAL_REF_PER_SOURCE_CAP = 18;
320
+ // Time-boxed so an unauthed/slow `gh` can't stall session-start (F4).
321
+ const PR_DIFF_TIMEOUT_MS = 4_000;
322
+ // Bounds worst-case `gh` subprocess invocations per handshake.
323
+ const PR_DIFF_MAX_REFS = 5;
324
+ function runGitText(cwd, command) {
325
+ try {
326
+ const value = execSync(command, {
327
+ cwd,
328
+ encoding: 'utf8',
329
+ stdio: ['ignore', 'pipe', 'ignore'],
330
+ }).trim();
331
+ return value.length > 0 ? value : undefined;
332
+ }
333
+ catch {
334
+ return undefined;
335
+ }
336
+ }
337
+ /** Dereference a "PR #N" ref to its changed paths via `gh pr diff <N> --name-only` (F4: server
338
+ * resolver has no git/gh access). Guarded/time-boxed; `run` is injectable for tests. */
339
+ export function dereferencePrRefToPaths(cwd, prNumber, run = runGitTextTimeboxed) {
340
+ if (!Number.isInteger(prNumber) || prNumber <= 0)
341
+ return [];
342
+ const raw = run(cwd, `gh pr diff ${prNumber} --name-only`, PR_DIFF_TIMEOUT_MS);
343
+ if (!raw)
344
+ return [];
345
+ return raw.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
346
+ }
347
+ /** Time-boxed variant of runGitText for the PR-diff dereference (F4). */
348
+ function runGitTextTimeboxed(cwd, command, timeoutMs) {
349
+ try {
350
+ const value = execSync(command, {
351
+ cwd,
352
+ encoding: 'utf8',
353
+ stdio: ['ignore', 'pipe', 'ignore'],
354
+ timeout: timeoutMs,
355
+ }).trim();
356
+ return value.length > 0 ? value : undefined;
357
+ }
358
+ catch {
359
+ return undefined;
360
+ }
361
+ }
362
+ function readOptionalLocalText(cwd, path) {
363
+ const fullPath = join(cwd, path);
364
+ if (!existsSync(fullPath))
365
+ return undefined;
366
+ try {
367
+ return readFileSync(fullPath, 'utf8');
368
+ }
369
+ catch {
370
+ return undefined;
371
+ }
372
+ }
373
+ function normalizeLocalRef(ref) {
374
+ const trimmed = ref.trim().replace(/\s+/g, ' ');
375
+ const pr = trimmed.match(/^PR\s*#?\s*(\d+)$/i);
376
+ if (pr)
377
+ return `PR #${pr[1]}`;
378
+ const entry = trimmed.match(/^([A-Z]+)[-\s#]*(\d+)$/i);
379
+ if (entry)
380
+ return `${entry[1].toUpperCase()}-${entry[2]}`;
381
+ return trimmed;
382
+ }
383
+ /** Collect normalized local refs across several text sources, deduped. Codex@677: a per-source
384
+ * cap alongside the global one, so a broad source (context.md) can't starve a later,
385
+ * task-specific source (briefing.md); already-collected refs dedupe without spending later quota. */
386
+ function collectLocalRefs(texts) {
387
+ const refs = [];
388
+ const seen = new Set();
389
+ for (const text of texts) {
390
+ if (!text)
391
+ continue;
392
+ let fromThisSource = 0;
393
+ for (const match of text.matchAll(LOCAL_REF_REGEX)) {
394
+ const ref = normalizeLocalRef(match[0]);
395
+ const key = ref.toLowerCase();
396
+ if (seen.has(key))
397
+ continue;
398
+ if (fromThisSource >= LOCAL_REF_PER_SOURCE_CAP)
399
+ break;
400
+ seen.add(key);
401
+ refs.push(ref);
402
+ fromThisSource++;
403
+ if (refs.length >= LOCAL_REF_GLOBAL_CAP)
404
+ return refs;
405
+ }
406
+ }
407
+ return refs;
408
+ }
409
+ function deriveHandshakeStartupTask(refs, changedPaths, callerTask) {
410
+ if (callerTask && callerTask.trim())
411
+ return callerTask.trim();
412
+ const parts = [];
413
+ if (refs.length > 0)
414
+ parts.push(refs.join(' '));
415
+ if (changedPaths.length > 0)
416
+ parts.push(`changed paths ${changedPaths.slice(0, 5).join(' ')}`);
417
+ return parts.length > 0 ? parts.join(' ') : undefined;
418
+ }
419
+ const DEFAULT_HANDSHAKE_SIGNAL_DEPS = {
420
+ runGit: runGitText,
421
+ prDiff: (cwd, prNumber) => dereferencePrRefToPaths(cwd, prNumber),
422
+ };
423
+ /** Extract the PR number from a normalized "PR #N" ref, else null. */
424
+ function prNumberFromRef(ref) {
425
+ const m = ref.match(/^PR\s*#?\s*(\d+)$/i);
426
+ if (!m)
427
+ return null;
428
+ const n = Number(m[1]);
429
+ return Number.isInteger(n) && n > 0 ? n : null;
430
+ }
431
+ export function deriveHandshakeStartupSignals(cwd, callerSignals = {}, deps = DEFAULT_HANDSHAKE_SIGNAL_DEPS) {
432
+ const { runGit, prDiff } = deps;
433
+ const branchName = runGit(cwd, 'git branch --show-current');
434
+ const commitSha = runGit(cwd, 'git rev-parse --short HEAD');
435
+ // Changed paths, unioned + deduped: (1) dirty worktree; (2) committed branch delta vs origin/main's
436
+ // merge-base (Codex@665, invisible once the tree is clean); (3) PR-ref dereference (F4), appended later.
437
+ const dirtyChangedPaths = runGit(cwd, 'git diff --name-only HEAD')?.split(/\r?\n/).filter(Boolean) ?? [];
438
+ const mergeBase = runGit(cwd, 'git merge-base HEAD origin/main');
439
+ const branchChangedPaths = mergeBase
440
+ ? (runGit(cwd, `git diff --name-only ${mergeBase} HEAD`)?.split(/\r?\n/).filter(Boolean) ?? [])
441
+ : [];
442
+ const worktreeName = basename(cwd);
443
+ const contextText = readOptionalLocalText(cwd, '.productbrain/context.md');
444
+ const briefingText = readOptionalLocalText(cwd, '.productbrain/briefing.md');
445
+ const callerRefs = Array.isArray(callerSignals.reviewedArtifactRefs) ? callerSignals.reviewedArtifactRefs.join('\n') : undefined;
446
+ // Codex@677: briefing.md (task-specific) reads BEFORE context.md (broad) so its refs collect first — with the per-source cap, context.md can't starve briefing.
447
+ const refs = collectLocalRefs([
448
+ callerSignals.taskText ?? undefined,
449
+ callerSignals.explicitScope ?? undefined,
450
+ callerRefs,
451
+ branchName,
452
+ worktreeName,
453
+ briefingText,
454
+ contextText,
455
+ ]);
456
+ // F4: dereference "PR #N" refs to diff paths, folded into changedPaths — the only place this can happen (server records dereferenced:false, no git access). Time-boxed; absent/unauthed gh no-ops.
457
+ const prDiffPaths = [];
458
+ if (callerSignals.changedPaths === undefined) {
459
+ let derefed = 0;
460
+ for (const ref of refs) {
461
+ const prNumber = prNumberFromRef(ref);
462
+ if (prNumber === null)
463
+ continue;
464
+ if (derefed >= PR_DIFF_MAX_REFS)
465
+ break;
466
+ derefed++;
467
+ try {
468
+ for (const p of prDiff(cwd, prNumber))
469
+ prDiffPaths.push(p);
470
+ }
471
+ catch {
472
+ // gh absent / unauthed / PR missing — skip gracefully, leave existing behavior.
473
+ }
474
+ }
475
+ }
476
+ // Caller-supplied changedPaths win (backward compat); otherwise union the
477
+ // three local sources, deduped, order-stable.
478
+ const unionedChangedPaths = callerSignals.changedPaths ??
479
+ Array.from(new Set([...dirtyChangedPaths, ...branchChangedPaths, ...prDiffPaths]));
480
+ const baseSignals = sanitizeStartupResolutionSignals({
481
+ ...callerSignals,
482
+ sourceSurface: callerSignals.sourceSurface ?? 'cli',
483
+ resolverVersion: callerSignals.resolverVersion ?? STARTUP_RESOLUTION_RESOLVER_VERSION,
484
+ branchName: callerSignals.branchName ?? branchName,
485
+ worktreeName: callerSignals.worktreeName ?? worktreeName,
486
+ changedPaths: unionedChangedPaths,
487
+ reviewedArtifactRefs: callerSignals.reviewedArtifactRefs ?? refs,
488
+ commitSha: callerSignals.commitSha ?? commitSha,
489
+ });
490
+ const taskText = deriveHandshakeStartupTask(baseSignals.reviewedArtifactRefs ?? [], baseSignals.changedPaths ?? [], baseSignals.taskText);
491
+ const sanitized = sanitizeStartupResolutionSignals({
492
+ ...baseSignals,
493
+ taskText,
494
+ });
495
+ const hasMeaningfulEvidence = Boolean(sanitized.taskText) ||
496
+ (sanitized.changedPaths?.length ?? 0) > 0 ||
497
+ (sanitized.reviewedArtifactRefs?.length ?? 0) > 0 ||
498
+ Boolean(sanitized.explicitScope);
499
+ if (hasMeaningfulEvidence)
500
+ return sanitized;
501
+ // Codex@704: even with no evidence, emit a minimal envelope carrying attribution — {} would
502
+ // drop the whole startup block, losing the loud domain-unresolved signal (spec "Loud Unresolved State", AC #4).
503
+ return sanitizeStartupResolutionSignals({
504
+ sourceSurface: sanitized.sourceSurface ?? 'cli',
505
+ resolverVersion: sanitized.resolverVersion ?? STARTUP_RESOLUTION_RESOLVER_VERSION,
506
+ branchName: sanitized.branchName,
507
+ worktreeName: sanitized.worktreeName,
508
+ commitSha: sanitized.commitSha,
509
+ changeId: sanitized.changeId,
510
+ });
511
+ }
512
+ /** Normalize volatile handshake-only timestamps before comparing generated files — keeps visible
513
+ * timestamps in artifacts while avoiding meaningless rewrites when content is unchanged. */
250
514
  export function normalizeHandshakeContentForComparison(content) {
251
515
  return content
252
516
  .replace(/<!-- auto-generated by pb handshake — [0-9]{4}-[0-9]{2}-[0-9]{2}T[^>]+ -->/g, '<!-- auto-generated by pb handshake — <TIMESTAMP> -->')
253
517
  .replace(/^_Generated: [0-9]{4}-[0-9]{2}-[0-9]{2}T.*_$/gm, '_Generated: <TIMESTAMP>_');
254
518
  }
255
519
  function shouldWriteAdapter(filePath, force) {
256
- if (force)
257
- return true;
520
+ // An absent file at an adapter path is a projection target → materialize it.
258
521
  if (!existsSync(filePath))
259
522
  return true;
260
523
  const content = readFileSync(filePath, 'utf8');
524
+ // No MARKER → user-owned/committed-static (CLAUDE.md, AGENTS.md, Copilot instructions) — never overwritten, not even under --force.
525
+ void force;
261
526
  return content.includes(MARKER);
262
527
  }
528
+ function normalizeSurfaceName(surface) {
529
+ const stripped = surface.startsWith('.') ? surface.slice(1) : surface;
530
+ const normalized = stripped === 'github' ? 'copilot' : stripped;
531
+ return normalized in SURFACE_REGISTRY ? normalized : null;
532
+ }
533
+ function surfacePerimeterRoots(surface) {
534
+ if (surface === 'codex')
535
+ return ['.codex', SURFACE_REGISTRY.codex.hookFilePath];
536
+ if (surface === 'copilot')
537
+ return ['.github', SURFACE_REGISTRY.copilot.hookFilePath];
538
+ if (surface === 'claude')
539
+ return ['.claude', 'CLAUDE.md'];
540
+ return [`.${surface}`];
541
+ }
542
+ function modeRank(mode) {
543
+ return { off: 0, observe: 1, project: 2, govern: 3 }[mode];
544
+ }
545
+ function normalizeSetupAuthoringBody(body) {
546
+ return body.replace(/\r\n/g, '\n').replace(/\r/g, '\n').trimEnd();
547
+ }
548
+ function setupAuthoringAssetHash(asset) {
549
+ const canonical = {
550
+ entryId: asset.entryId,
551
+ name: asset.name,
552
+ description: asset.description ?? '',
553
+ assetKind: asset.assetKind,
554
+ triggers: asset.triggers ?? [],
555
+ semanticRefs: asset.semanticRefs ?? [],
556
+ body: normalizeSetupAuthoringBody(asset.body),
557
+ };
558
+ return `sha256:${createHash('sha256').update(JSON.stringify(canonical), 'utf8').digest('hex')}`;
559
+ }
560
+ function parseSetupAuthoringFrontmatter(raw) {
561
+ // Shared parser (lib/frontmatter.ts): array-item quotes strip exactly as before, now canonical
562
+ // for migrate-setup/setup-ingest too. `assetKind` ignored (handshake derives kind from dir).
563
+ const parsed = parseSetupFrontmatter(raw);
564
+ return {
565
+ frontmatterId: parsed.frontmatterId,
566
+ name: parsed.name,
567
+ description: parsed.description,
568
+ body: parsed.body,
569
+ triggers: parsed.triggers,
570
+ semanticRefs: parsed.semanticRefs,
571
+ };
572
+ }
573
+ function deriveSetupAuthoringEntryId(filename, kind) {
574
+ const base = basename(filename, '.md');
575
+ const snakeCase = base.toUpperCase().replace(/[^A-Z0-9]+/g, '_');
576
+ return `SETUP-${kind.toUpperCase()}-${snakeCase}`;
577
+ }
578
+ function scanSetupAuthoringFiles(productbrainDir) {
579
+ const dirs = [
580
+ { dir: 'skills', kind: 'skill' },
581
+ { dir: 'rules', kind: 'rule' },
582
+ { dir: 'hooks', kind: 'hook' },
583
+ ];
584
+ const items = [];
585
+ for (const { dir, kind } of dirs) {
586
+ const absDir = join(productbrainDir, dir);
587
+ if (!existsSync(absDir))
588
+ continue;
589
+ for (const file of readdirSync(absDir).filter((f) => f.endsWith('.md'))) {
590
+ const filePath = join(absDir, file);
591
+ const parsed = parseSetupAuthoringFrontmatter(readFileSync(filePath, 'utf8'));
592
+ const fallbackName = basename(file, '.md');
593
+ items.push({
594
+ filePath,
595
+ derivedEntryId: deriveSetupAuthoringEntryId(file, kind),
596
+ frontmatterId: parsed.frontmatterId,
597
+ name: parsed.name || fallbackName,
598
+ description: parsed.description,
599
+ body: parsed.body,
600
+ assetKind: kind,
601
+ triggers: parsed.triggers,
602
+ semanticRefs: parsed.semanticRefs,
603
+ });
604
+ }
605
+ }
606
+ return items.sort((a, b) => a.filePath.localeCompare(b.filePath));
607
+ }
608
+ function setupAuthoringDirForKind(kind) {
609
+ if (kind === 'skill')
610
+ return 'skills';
611
+ if (kind === 'rule')
612
+ return 'rules';
613
+ if (kind === 'hook')
614
+ return 'hooks';
615
+ return null;
616
+ }
617
+ function setupAuthoringFilename(name, entryId) {
618
+ const base = (name || entryId)
619
+ .replace(/[\/\\:*?"<>|]/g, '-')
620
+ .replace(/\s+/g, ' ')
621
+ .trim();
622
+ return `${base || entryId}.md`;
623
+ }
624
+ function setupAuthoringPath(cwd, asset) {
625
+ const dir = setupAuthoringDirForKind(asset.assetKind);
626
+ if (!dir)
627
+ return null;
628
+ // WP-426 E3: recorded authoring source path wins so reprojection lands where the
629
+ // user authored — no duplicate (TEN-1920). Stored relative to .productbrain/.
630
+ if (asset.authoringPath && asset.authoringPath.trim()) {
631
+ // Codex P1/P2: authoringPath is untrusted DB data, probed before any assertSetupWritePath guard runs —
632
+ // constrain to a kind-appropriate markdown file, else fall back to the safe name-derived path.
633
+ const pbDir = join(cwd, '.productbrain');
634
+ const candidate = resolve(pbDir, asset.authoringPath);
635
+ const within = relative(pbDir, candidate);
636
+ const withinPosix = within.split(sep).join('/');
637
+ if (!within.startsWith('..') &&
638
+ !isAbsolute(within) &&
639
+ withinPosix.startsWith(`${dir}/`) &&
640
+ withinPosix.toLowerCase().endsWith('.md')) {
641
+ return candidate;
642
+ }
643
+ }
644
+ return join(cwd, '.productbrain', dir, setupAuthoringFilename(asset.name, asset.entryId));
645
+ }
646
+ function renderSetupAuthoringFile(asset) {
647
+ const lines = [
648
+ '---',
649
+ `id: ${asset.entryId}`,
650
+ `name: ${JSON.stringify(asset.name)}`,
651
+ `description: ${JSON.stringify(asset.description ?? '')}`,
652
+ `assetKind: ${asset.assetKind}`,
653
+ ];
654
+ const pushArray = (key, values) => {
655
+ if (!values || values.length === 0)
656
+ return;
657
+ lines.push(`${key}:`);
658
+ for (const value of values)
659
+ lines.push(` - ${JSON.stringify(value)}`);
660
+ };
661
+ pushArray('triggers', asset.triggers);
662
+ pushArray('semanticRefs', asset.semanticRefs);
663
+ lines.push('---', normalizeSetupAuthoringBody(asset.body), '');
664
+ return lines.join('\n');
665
+ }
666
+ function loadAuthoringSyncState(productbrainDir) {
667
+ const statePath = join(productbrainDir, '.authoring-sync.json');
668
+ if (!existsSync(statePath))
669
+ return { version: 1, assets: {} };
670
+ try {
671
+ const parsed = JSON.parse(readFileSync(statePath, 'utf8'));
672
+ if (parsed.version !== 1 || !parsed.assets || typeof parsed.assets !== 'object') {
673
+ return { version: 1, assets: {} };
674
+ }
675
+ return {
676
+ version: 1,
677
+ assets: parsed.assets,
678
+ };
679
+ }
680
+ catch {
681
+ return { version: 1, assets: {} };
682
+ }
683
+ }
684
+ function saveAuthoringSyncState(productbrainDir, state) {
685
+ const statePath = join(productbrainDir, '.authoring-sync.json');
686
+ assertSetupWritePath(statePath, { surfaces: [] });
687
+ mkdirSync(productbrainDir, { recursive: true });
688
+ writeFileSync(statePath, JSON.stringify(state, null, 2) + '\n');
689
+ }
690
+ // ── WP-421 S3: Three-bucket drift classification (doneWhen #17) — now its own module (STD-2/DEC-1504
691
+ // shrink-only offset). Re-exported so existing imports `from '../commands/handshake.js'` keep working.
692
+ export { classifyDriftBucket };
263
693
  function deduplicateEntries(entries) {
264
694
  const seen = new Set();
265
695
  const result = [];
@@ -272,19 +702,128 @@ function deduplicateEntries(entries) {
272
702
  }
273
703
  return result;
274
704
  }
705
+ /**
706
+ * findLeftoverProjections — WP-379 S5b
707
+ *
708
+ * Lists marker-bearing files under .cursor/rules/, .claude/rules/, .claude/skills/, .codex/skills/
709
+ * (plus the nested .cursor/skills/<name>/SKILL.md layout) that look stale: orphan (no canonical
710
+ * asset), stale case/punctuation variant, or a leftover `.dormant` copy. User-owned (no MARKER)
711
+ * files and unselected `allowedTargets` are never reported.
712
+ *
713
+ * Round 12: stops once `LEFTOVER_FILES_MAX + 1` matches are found across the flat + merged
714
+ * nested-Cursor scan combined — bounds read/enumerate I/O, not just the reported list.
715
+ * `truncated` says more exist beyond the capped, returned `files`.
716
+ *
717
+ * @param cursorSkillNames Cursor-specific, SKILL-kind-only canon (falls back to `assetNames`).
718
+ * @param exactRelativePaths Round 11: exact write-plan paths (forward-slash), exempted from both
719
+ * checks — covers asset-less generated files and a canonical raw name not already normalized.
720
+ */
721
+ export function findLeftoverProjections(cwd, assetNames, allowedTargets, cursorSkillNames, exactRelativePaths) {
722
+ const TARGET_DIRS_BY_EXT = [
723
+ { dir: join(cwd, '.cursor', 'rules'), ext: '.mdc', surface: 'cursor' },
724
+ { dir: join(cwd, '.claude', 'rules'), ext: '.md', surface: 'claude' },
725
+ { dir: join(cwd, '.claude', 'skills'), ext: '.md', surface: 'claude' },
726
+ { dir: join(cwd, '.codex', 'skills'), ext: '.md', surface: 'codex' },
727
+ ];
728
+ const canonicalNormalizedStems = new Set(assetNames.map((n) => normalizeMaterializedFilename(n)));
729
+ const exactPaths = exactRelativePaths ?? new Set();
730
+ const leftovers = [];
731
+ let truncated = false;
732
+ scanLoop: for (const { dir, ext, surface } of TARGET_DIRS_BY_EXT) {
733
+ if (!allowedTargets.has(surface))
734
+ continue;
735
+ if (!existsSync(dir))
736
+ continue;
737
+ let files;
738
+ try {
739
+ files = readdirSync(dir);
740
+ }
741
+ catch {
742
+ continue; // unreadable dir — skip
743
+ }
744
+ for (const filename of files) {
745
+ if (!filename.endsWith(ext) && !filename.endsWith(`${ext}.dormant`))
746
+ continue;
747
+ const fullPath = join(dir, filename);
748
+ let content;
749
+ try {
750
+ content = readFileSync(fullPath, 'utf8');
751
+ }
752
+ catch {
753
+ continue; // unreadable file — skip
754
+ }
755
+ if (!content.includes(MARKER))
756
+ continue; // user-owned — never reported
757
+ const isDormant = filename.endsWith('.dormant');
758
+ // A live file the write plan targets by this exact path is canonical by construction.
759
+ if (!isDormant) {
760
+ const relativePath = relative(cwd, fullPath).split(sep).join('/');
761
+ if (exactPaths.has(relativePath))
762
+ continue;
763
+ }
764
+ const stem = basename(isDormant ? filename.slice(0, -'.dormant'.length) : filename, ext);
765
+ const normalizedStem = normalizeMaterializedFilename(stem);
766
+ let entry = null;
767
+ if (!canonicalNormalizedStems.has(normalizedStem)) {
768
+ entry = { path: fullPath, reason: 'orphan — no canonical asset matches this name' };
769
+ }
770
+ else if (isDormant) {
771
+ entry = { path: fullPath, reason: 'leftover .dormant file from an older binary version' };
772
+ }
773
+ else if (stem !== normalizedStem) {
774
+ entry = { path: fullPath, reason: `stale case/punctuation variant — canonical form is "${normalizedStem}${ext}"` };
775
+ }
776
+ if (!entry)
777
+ continue;
778
+ leftovers.push(entry);
779
+ if (leftovers.length > LEFTOVER_FILES_MAX) {
780
+ truncated = true;
781
+ leftovers.pop();
782
+ break scanLoop;
783
+ }
784
+ }
785
+ }
786
+ // Nested Cursor skills — extracted to its own module (STD-2/DEC-1504 shrink-only offset).
787
+ // Skipped once the flat scan already hit the cap; the remaining budget keeps the combined
788
+ // total across both scans stopping at LEFTOVER_FILES_MAX + 1.
789
+ if (!truncated && allowedTargets.has('cursor')) {
790
+ const nested = findLeftoverCursorSkills(cwd, cursorSkillNames ?? assetNames, LEFTOVER_FILES_MAX - leftovers.length);
791
+ leftovers.push(...nested.files);
792
+ truncated = nested.truncated;
793
+ }
794
+ return { files: leftovers, truncated };
795
+ }
796
+ /** Round 13 (Codex P1, security): strips a `user:token@` userinfo segment from an https remote
797
+ * so a credential never reaches JSON output. SSH remotes (`git@host:...`) are untouched — that
798
+ * `git@` is a fixed public username, not a secret. */
799
+ function redactGitRemote(remote) {
800
+ return remote ? remote.replace(/^(https?:\/\/)[^@/]+@/i, '$1') : remote;
801
+ }
802
+ /** Round 13 (Codex P1, security): `pb --json handshake` serialized the report directly — leaking
803
+ * an HTTPS git-remote credential and raw Convex `_id`/`_creationTime` on `matchedEntries` (never
804
+ * went through the shared runner's `stripConvexInternals`). One public shape, both JSON paths. */
805
+ function toPublicJsonReport(report) {
806
+ return stripConvexInternals({ ...report, repo: { ...report.repo, gitRemote: redactGitRemote(report.repo.gitRemote) } });
807
+ }
275
808
  export async function runHandshake(options = {}) {
276
- const config = await getConfigOrGuide(() => runHandshake(options));
809
+ const config = await getConfigOrGuide(async () => { await runHandshake(options); });
277
810
  if (!config)
278
- return;
811
+ return undefined;
279
812
  const cwd = process.cwd();
280
813
  const force = options.force ?? false;
281
814
  const dryRun = options.dryRun ?? false;
815
+ // Preview mode: default when neither --apply nor --dry-run is passed (--dry-run is a backward-compat alias).
816
+ const preview = !options.apply && !dryRun;
817
+ const applyMode = options.apply === true && !dryRun;
282
818
  const level = options.level;
819
+ // `quiet` gates the final report write (`--json` alone still prints). `suppressProgress`
820
+ // also silences stdout log() prose in JSON mode. logErr() stays on `quiet` alone (stderr).
283
821
  const quiet = options.quiet ?? false;
822
+ const suppressProgress = quiet || isJsonMode();
284
823
  const generate = options.generate ?? false;
285
824
  const timestamp = new Date().toISOString();
286
- // Helper: emit progress line only when not quiet (used when handshake is a sub-step)
287
- const log = (msg) => { if (!quiet)
825
+ // Helper: emit progress line only when not suppressed. logErr is gated on `quiet` alone.
826
+ const log = (msg) => { if (!suppressProgress)
288
827
  process.stdout.write(msg + '\n'); };
289
828
  const logErr = (msg) => { if (!quiet)
290
829
  process.stderr.write(msg + '\n'); };
@@ -303,14 +842,23 @@ export async function runHandshake(options = {}) {
303
842
  if (repo.detectedStack.length > 0) {
304
843
  log(`Stack: ${repo.detectedStack.join(', ')}`);
305
844
  }
845
+ const startupSignals = deriveHandshakeStartupSignals(cwd, options.startupSignals ?? {});
846
+ const orientArgs = { tier: 'standard' };
847
+ if (options.invocationPath)
848
+ orientArgs.invocationPath = options.invocationPath;
849
+ if (Object.keys(startupSignals).length > 0) {
850
+ orientArgs.startupSignals = startupSignals;
851
+ if (startupSignals.taskText)
852
+ orientArgs.task = startupSignals.taskText;
853
+ }
306
854
  // 2. Fetch orient view + workspace readiness in parallel (budget max +200ms added latency)
307
855
  log('Fetching workspace context...');
308
856
  let orientView = null;
309
857
  let workspaceProfile = null;
310
858
  try {
311
- const workspaceReadinessPromise = mcpCall('chain.workspaceReadiness', {}).catch(() => null);
859
+ const workspaceReadinessPromise = kernelCall('chain.workspaceReadiness', {}).catch(() => null);
312
860
  const [orientResult, readinessRaw] = await Promise.all([
313
- mcpCall('chain.getOrientView', {}).catch((err) => {
861
+ kernelCall('chain.getOrientView', orientArgs).catch((err) => {
314
862
  logErr(`Warning: could not fetch workspace context — ${err instanceof Error ? err.message : err}`);
315
863
  logErr('Continuing with limited context (Chain search + portable knowledge only).');
316
864
  return null;
@@ -325,7 +873,7 @@ export async function runHandshake(options = {}) {
325
873
  logErr('Continuing with limited context (Chain search + portable knowledge only).');
326
874
  }
327
875
  if (workspaceProfile) {
328
- log(`Workspace profile: stage=${workspaceProfile.stage}, entries=${workspaceProfile.totalEntries}, governance=${workspaceProfile.governanceMode}`);
876
+ log(`Workspace profile: stage=${workspaceProfile.stage}, entries=${workspaceProfile.totalEntries}`);
329
877
  }
330
878
  // 3. Build search queries from repo context
331
879
  const searchQueries = [];
@@ -344,20 +892,329 @@ export async function runHandshake(options = {}) {
344
892
  let matchedEntries = [];
345
893
  if (uniqueQueries.length > 0) {
346
894
  log(`Searching Chain for: ${uniqueQueries.join(', ')}...`);
347
- const searchResults = await Promise.all(uniqueQueries.map((q) => mcpCall('chain.searchEntries', { query: q }).catch(() => [])));
895
+ const searchResults = await Promise.all(uniqueQueries.map((q) => kernelCall('chain.searchEntries', { query: q }).catch(() => [])));
348
896
  matchedEntries = deduplicateEntries(searchResults.flat());
349
897
  }
350
- // 5. Read canonical skills & rules from .productbrain/
898
+ // 5. Read canonical skills & rules — DB-first (WP-345 S0c, TEN-1459): query setup.listAssetsForUser, FS fallback.
351
899
  const pbDir = join(cwd, '.productbrain');
352
- const allSkills = readCanonicalSkills(pbDir);
353
- const manualRules = readCanonicalRules(pbDir);
900
+ const manifestStatus = readManifestStatus(pbDir);
901
+ const manifest = manifestStatus.manifest;
902
+ const surfaceValidation = validateSurfacesForMode(manifestStatus.mode, manifestStatus.surfaces);
903
+ if (applyMode && surfaceValidation.error === SURFACE_GOVERN_NO_SURFACES) {
904
+ throw new CLIError('materialize: govern requires at least one registered manifest surface.', {
905
+ code: ErrorCode.VALIDATION_FAILED,
906
+ category: 'validation',
907
+ guidance: 'Add surfaces such as `.cursor` or `.claude` to .productbrain/manifest.yaml.',
908
+ });
909
+ }
910
+ for (const surface of surfaceValidation.unregisteredSurfaces) {
911
+ logErr(`Warning: manifest surface "${surface}" is not registered; skipping it.`);
912
+ }
913
+ const manifestTargets = new Set(surfaceValidation.registeredSurfaces);
914
+ const cliTargets = new Set();
915
+ const ignoredCliSurfaces = [];
916
+ for (const surface of options.surfaces ?? []) {
917
+ const normalized = normalizeSurfaceName(surface);
918
+ if (normalized && manifestTargets.has(normalized)) {
919
+ cliTargets.add(normalized);
920
+ }
921
+ else {
922
+ ignoredCliSurfaces.push(surface);
923
+ }
924
+ }
925
+ if (ignoredCliSurfaces.length > 0) {
926
+ logErr(`Warning: --surfaces ignored outside manifest.surfaces: ${ignoredCliSurfaces.join(', ')}`);
927
+ }
928
+ const allowedTargets = options.surfaces && options.surfaces.length > 0
929
+ ? cliTargets
930
+ : manifestTargets;
931
+ const perimeterManifest = {
932
+ surfaces: [...manifestTargets].flatMap(surfacePerimeterRoots),
933
+ };
934
+ const authorityCanWrite = manifestStatus.mode === 'project' || manifestStatus.mode === 'govern';
935
+ const authorityPreviewOnly = applyMode && !authorityCanWrite;
936
+ const writeMode = applyMode && authorityCanWrite;
937
+ let dbSkills = [];
938
+ let dbRules = [];
939
+ let usedDbSource = false;
940
+ // Codex P2 (PR #912 round 3): distinct from usedDbSource — true whenever the query succeeded
941
+ // (even empty), gating cleanup regardless of a later body-fetch throw; usedDbSource stays the
942
+ // CONTENT-source flag, only true after full success (a throw falls back to the filesystem).
943
+ let dbQuerySucceeded = false;
944
+ let dbAssetRows = [];
945
+ // WP-428 S2 (Finding #5): entryIds whose body fetch failed — hoisted so both the
946
+ // skills/rules AND authoring-file projection loops can skip them.
947
+ const bodyFetchFailedEntryIds = new Set();
948
+ const dbProjectionHashes = new Map();
949
+ const syncDriftTensToFire = [];
950
+ const deferredAuthoringBaselineEntryIds = new Set();
951
+ if (writeMode) {
952
+ const authoringItems = scanSetupAuthoringFiles(pbDir);
953
+ if (authoringItems.length > 0) {
954
+ // WP-428 S2 (Critical #1): ingestSetupAssetWithBody runs per-asset (batch can't call ctx.storage.store()), losing intra-batch collision detection — checked client-side below (replaces server-side DEC-954).
955
+ const idToPaths = new Map();
956
+ for (const item of authoringItems) {
957
+ const canonicalId = item.frontmatterId?.trim() || item.derivedEntryId;
958
+ const paths = idToPaths.get(canonicalId) ?? [];
959
+ paths.push(item.filePath);
960
+ idToPaths.set(canonicalId, paths);
961
+ }
962
+ const conflictingPaths = new Set();
963
+ for (const [, paths] of idToPaths) {
964
+ if (paths.length > 1) {
965
+ for (const p of paths)
966
+ conflictingPaths.add(p);
967
+ }
968
+ }
969
+ if (conflictingPaths.size > 0) {
970
+ logErr(`Setup authoring import partial: ${conflictingPaths.size} file(s) refused for duplicate setup id. ` +
971
+ [...conflictingPaths].join(', '));
972
+ }
973
+ const itemsToIngest = authoringItems.filter((item) => !conflictingPaths.has(item.filePath));
974
+ if (itemsToIngest.length > 0) {
975
+ try {
976
+ // Parallel uploads — concurrency limit 10 to avoid overwhelming the gateway.
977
+ const CONCURRENCY = 10;
978
+ const ingestResults = [];
979
+ for (let i = 0; i < itemsToIngest.length; i += CONCURRENCY) {
980
+ const batch = itemsToIngest.slice(i, i + CONCURRENCY);
981
+ const settled = await Promise.allSettled(batch.map(async (item) => {
982
+ const result = await kernelCall('setup.ingestSetupAssetWithBody', {
983
+ entryId: item.derivedEntryId,
984
+ frontmatterId: item.frontmatterId,
985
+ name: item.name,
986
+ description: item.description,
987
+ body: item.body,
988
+ assetKind: item.assetKind,
989
+ triggers: item.triggers,
990
+ semanticRefs: item.semanticRefs,
991
+ authoringPath: relative(pbDir, item.filePath).split(sep).join('/'),
992
+ });
993
+ return { filePath: item.filePath, ...result };
994
+ }));
995
+ for (const r of settled) {
996
+ if (r.status === 'fulfilled') {
997
+ ingestResults.push(r.value);
998
+ if (r.value.conflict === 'repo-wins') {
999
+ syncDriftTensToFire.push(`Repo authoring file won setup sync conflict for ${r.value.entryId} at ${r.value.filePath}.`);
1000
+ logErr(`Warning: repo authoring file won sync conflict for ${r.value.entryId}; DB edit was overwritten.`);
1001
+ }
1002
+ }
1003
+ else {
1004
+ trackEvent('setup.authoring_import.item_failed', { error: r.reason instanceof Error ? r.reason.message : String(r.reason) });
1005
+ logErr(`Warning: setup authoring import failed for one asset — ${r.reason instanceof Error ? r.reason.message : String(r.reason)}`);
1006
+ }
1007
+ }
1008
+ }
1009
+ if (ingestResults.length > 0) {
1010
+ log(`Setup authoring import: ${ingestResults.length} file(s) checked (with bodyStorageId).`);
1011
+ }
1012
+ }
1013
+ catch (err) {
1014
+ trackEvent('setup.authoring_import.failed', { error: err instanceof Error ? err.message : String(err) });
1015
+ logErr(`Warning: setup authoring import failed — ${err instanceof Error ? err.message : String(err)}`);
1016
+ }
1017
+ }
1018
+ }
1019
+ }
1020
+ try {
1021
+ // WP-379 S4: only activeAssets projects (DEC-1690); falls back to [] for the old flat-array server shape.
1022
+ const rawResponse = await kernelCall('setup.listAssetsForUser', {}).catch(() => null);
1023
+ let dbAssets = [];
1024
+ if (rawResponse !== null) {
1025
+ if (Array.isArray(rawResponse)) {
1026
+ // Pre-S4 server — treat entire response as active assets with no dormant list.
1027
+ dbAssets = rawResponse;
1028
+ }
1029
+ else {
1030
+ dbAssets = rawResponse.activeAssets ?? [];
1031
+ }
1032
+ // Successful (even empty) is authoritative, distinct from "unavailable" (catch below) — an
1033
+ // empty active set must still gate cleanup on, or a workspace whose last asset was deleted
1034
+ // keeps stale projections forever.
1035
+ dbQuerySucceeded = true;
1036
+ dbAssetRows = dbAssets;
1037
+ }
1038
+ if (dbAssets.length > 0) {
1039
+ // WP-428 S2: body is no longer inline — fetch from storage per non-disabled skill/rule/hook (bounded, parallel).
1040
+ const projectableAssets = dbAssets.filter((a) => !a.disabledByOwner && (a.assetKind === 'skill' || a.assetKind === 'rule' || a.assetKind === 'hook'));
1041
+ const assetsNeedingBodyFetch = projectableAssets.filter((a) => a.bodyStorageId);
1042
+ const bodyFetchMap = new Map(); // entryId → body
1043
+ // WP-428 S2 (Finding #5/#12): fetch-failed entryIds excluded from dbSkills/dbRules below (outer-scope bodyFetchFailedEntryIds).
1044
+ if (assetsNeedingBodyFetch.length > 0) {
1045
+ log(`Fetching ${assetsNeedingBodyFetch.length} asset body(s) from storage...`);
1046
+ const bodyFetchResults = await Promise.allSettled(assetsNeedingBodyFetch.map(async (asset) => {
1047
+ const result = await kernelCall('setup.fetchAssetBody', { bodyStorageId: asset.bodyStorageId });
1048
+ return { entryId: asset.entryId, name: asset.name, body: result.body };
1049
+ }));
1050
+ for (let i = 0; i < bodyFetchResults.length; i++) {
1051
+ const result = bodyFetchResults[i];
1052
+ if (result.status === 'fulfilled') {
1053
+ bodyFetchMap.set(result.value.entryId, result.value.body);
1054
+ }
1055
+ else {
1056
+ // WP-428 S2 (Finding #12): include entryId and name in the warning (Finding #5: skip projection).
1057
+ const asset = assetsNeedingBodyFetch[i];
1058
+ logErr(`Warning: failed to fetch body for ${asset.entryId} (${asset.name}) — ${result.reason instanceof Error ? result.reason.message : String(result.reason)}`);
1059
+ bodyFetchFailedEntryIds.add(asset.entryId);
1060
+ }
1061
+ }
1062
+ if (bodyFetchFailedEntryIds.size > 0) {
1063
+ // WP-439 S4: strict-by-default — a body-fetch failure is hard unless --lenient.
1064
+ const failedList = [...bodyFetchFailedEntryIds].join(', ');
1065
+ if (options.lenient) {
1066
+ logErr(`Warning: ${bodyFetchFailedEntryIds.size} asset(s) skipped due to body fetch failure (--lenient): ${failedList}`);
1067
+ }
1068
+ else {
1069
+ throw new CLIError(`${bodyFetchFailedEntryIds.size} asset(s) failed body fetch: ${failedList}. ` +
1070
+ `Run \`pb setup-audit\` to diagnose, then \`pb setup-audit --repair\` to reseed. ` +
1071
+ `Pass --lenient to suppress this and continue with affected entries skipped (legacy behaviour).`, { code: ErrorCode.INTERNAL, category: 'internal' });
1072
+ }
1073
+ }
1074
+ }
1075
+ // Map DB assets to CanonicalSkill/CanonicalRule shapes
1076
+ for (const asset of dbAssets) {
1077
+ if (asset.disabledByOwner)
1078
+ continue;
1079
+ // WP-428 S2 (Finding #5): skip fetch-failed assets — no empty body written, no lastProjectedHash update.
1080
+ if (bodyFetchFailedEntryIds.has(asset.entryId))
1081
+ continue;
1082
+ // WP-428 S2: prefer storage-fetched body, fall back to inline body (pre-S2 servers, deletable once all servers are S2+).
1083
+ const resolvedBody = bodyFetchMap.get(asset.entryId) ?? asset.body ?? '';
1084
+ if (asset.assetKind === 'skill') {
1085
+ dbSkills.push({
1086
+ name: asset.name,
1087
+ description: asset.description,
1088
+ triggers: asset.triggers ?? [],
1089
+ body: resolvedBody,
1090
+ sourcePath: `db:${asset.entryId}`,
1091
+ });
1092
+ }
1093
+ else if (asset.assetKind === 'rule' || asset.assetKind === 'hook') {
1094
+ dbRules.push({
1095
+ name: asset.name,
1096
+ description: asset.description,
1097
+ autoApply: false,
1098
+ body: resolvedBody,
1099
+ sourcePath: `db:${asset.entryId}`,
1100
+ });
1101
+ }
1102
+ }
1103
+ log(`Setup assets: ${dbSkills.length} skills, ${dbRules.length} rules/hooks from DB (WP-345 DB-first path)`);
1104
+ // Reaching here (no throw above) means it's safe to use as the CONTENT source (Codex P2, PR #912 round 3).
1105
+ usedDbSource = true;
1106
+ }
1107
+ else if (dbQuerySucceeded && writeMode) {
1108
+ // Empty DB in WRITE mode is authoritative (ingest already ran); preview never ingests, so FS still forecasts apply.
1109
+ // Round 14: findLeftoverProjections only lists stale files, never removes them — say so.
1110
+ // Round 15: it also skips surfaces outside allowedTargets — scope the claim to those.
1111
+ log('Setup assets: DB query succeeded with zero active assets — any existing projections on the selected surfaces will be listed as leftovers, not removed.');
1112
+ usedDbSource = true;
1113
+ }
1114
+ }
1115
+ catch {
1116
+ // DB unavailable, or post-query processing failed hard — usedDbSource stays false either way.
1117
+ }
1118
+ const allSkills = usedDbSource ? dbSkills : readCanonicalSkills(pbDir);
1119
+ const manualRules = usedDbSource ? dbRules : readCanonicalRules(pbDir);
1120
+ if (!usedDbSource) {
1121
+ log('Setup assets: reading from filesystem (DB source unavailable, or unauthoritative for this mode)');
1122
+ }
1123
+ // 5a-pre. E4: resolve semantic refs (WP-345, DEC-A/C/K) — replace {{ref:key}} via the Convex
1124
+ // resolver, apply mode only. NG11: PostHog events fire from CLI side only.
1125
+ if (usedDbSource && writeMode) {
1126
+ const projectableDbAssets = dbAssetRows.filter((a) => !a.disabledByOwner && (a.assetKind === 'skill' || a.assetKind === 'rule' || a.assetKind === 'hook'));
1127
+ const assetsWithRefs = projectableDbAssets.filter((a) => a.semanticRefs && a.semanticRefs.length > 0);
1128
+ if (assetsWithRefs.length > 0) {
1129
+ log(`Resolving semantic refs for ${assetsWithRefs.length} asset(s)...`);
1130
+ // Collect unique ref keys across all assets
1131
+ const allRefKeys = [...new Set(assetsWithRefs.flatMap((a) => a.semanticRefs))];
1132
+ // Resolve all refs in a single batch call (DEC-767 / WP-354 Build-Order #6 — kind + status discriminator).
1133
+ let resolvedRefs = [];
1134
+ try {
1135
+ resolvedRefs = await kernelCall('setup.resolveSemanticRefs', { semanticRefs: allRefKeys });
1136
+ }
1137
+ catch (err) {
1138
+ trackEvent('setup.refs.resolve_failed', { error: err instanceof Error ? err.message : String(err) });
1139
+ logErr(`Warning: could not resolve semantic refs — ${err instanceof Error ? err.message : String(err)}`);
1140
+ }
1141
+ // Build resolved map: canonicalKey → display name. Only required refs count as unresolved warnings.
1142
+ const resolvedMap = new Map();
1143
+ let unresolvedCount = 0;
1144
+ for (const result of resolvedRefs) {
1145
+ if (result.status === 'resolved' && result.localEntryId) {
1146
+ resolvedMap.set(result.ref, result.localEntryId);
1147
+ trackEvent('skill.ref.resolved', { ref: result.ref, kind: result.kind });
1148
+ }
1149
+ else if (result.status === 'unsupported-future') {
1150
+ // seed: refs are explicitly future scope per WP-354 Build-Order #6 — not a warning.
1151
+ trackEvent('skill.ref.future', { ref: result.ref, kind: result.kind });
1152
+ }
1153
+ else if (result.required) {
1154
+ unresolvedCount++;
1155
+ trackEvent('skill.ref.unresolved', { ref: result.ref, kind: result.kind, status: result.status });
1156
+ }
1157
+ }
1158
+ if (unresolvedCount > 0) {
1159
+ logErr(`Warning: ${unresolvedCount} required semantic ref(s) could not be resolved.`);
1160
+ }
1161
+ // Projection preserves ref tokens as portable refs — resolvedMap is validation/telemetry only.
1162
+ }
1163
+ // Compute projection hash per projected DB asset (DEC-K): sha256 of the normalized resolved body.
1164
+ const HASH_TRAILER_REGEX = /^<!--\s*pb-hash:.*-->\s*$/gm;
1165
+ const TIMESTAMP_REGEX = /^<!--\s*pb-generated-at:.*-->\s*$/gm;
1166
+ for (const rawAsset of projectableDbAssets) {
1167
+ const resolvedAsset = [...dbSkills, ...dbRules].find((a) => a.sourcePath === `db:${rawAsset.entryId}`);
1168
+ if (!resolvedAsset)
1169
+ continue;
1170
+ try {
1171
+ // Build the projected body (what will be written to disk)
1172
+ const projectedBody = resolvedAsset.body;
1173
+ // Normalize: strip existing hash/timestamp trailers, convert to LF
1174
+ const normalized = projectedBody
1175
+ .replace(HASH_TRAILER_REGEX, '')
1176
+ .replace(TIMESTAMP_REGEX, '')
1177
+ .replace(/\r\n/g, '\n')
1178
+ .replace(/\r/g, '\n')
1179
+ .trimEnd();
1180
+ // Compute sha256 hash
1181
+ const hash = createHash('sha256').update(normalized, 'utf8').digest('hex');
1182
+ const hashTrailer = `<!-- pb-hash: sha256:${hash} -->`;
1183
+ // Append hash trailer to the projected body
1184
+ resolvedAsset.body = `${normalized}\n${hashTrailer}`;
1185
+ dbProjectionHashes.set(rawAsset.entryId, {
1186
+ hash: `sha256:${hash}`,
1187
+ assetKind: rawAsset.assetKind,
1188
+ });
1189
+ // Drift detection: compare against last known hash
1190
+ if (rawAsset.lastProjectedHash && rawAsset.lastProjectedHash !== `sha256:${hash}`) {
1191
+ trackEvent('skill.drift.detected', {
1192
+ entryId: rawAsset.entryId,
1193
+ assetKind: rawAsset.assetKind,
1194
+ });
1195
+ log(`Drift detected for asset ${rawAsset.entryId} — projecting updated version.`);
1196
+ }
1197
+ trackEvent('skill.projection.succeeded', {
1198
+ entryId: rawAsset.entryId,
1199
+ assetKind: rawAsset.assetKind,
1200
+ });
1201
+ }
1202
+ catch (err) {
1203
+ trackEvent('skill.projection.failed', {
1204
+ entryId: rawAsset.entryId,
1205
+ assetKind: rawAsset.assetKind,
1206
+ });
1207
+ logErr(`Warning: projection failed for ${rawAsset.entryId} — ${err instanceof Error ? err.message : String(err)}`);
1208
+ }
1209
+ }
1210
+ }
354
1211
  // 5a. Optionally fetch and merge Chain-derived rules (--generate flag)
355
1212
  let chainRulesStats = null;
356
1213
  let chainGaps = [];
357
1214
  let allRules = manualRules;
358
1215
  if (generate) {
359
1216
  log('Generating Chain-derived rules...');
360
- const chainResult = await generateChainRules(mcpCall, manualRules);
1217
+ const chainResult = await generateChainRules(kernelCall, manualRules);
361
1218
  if (chainResult.sentinel) {
362
1219
  // MCP unavailable — inject sentinel rule and warn
363
1220
  allRules = [...manualRules, chainResult.sentinel];
@@ -382,12 +1239,48 @@ export async function runHandshake(options = {}) {
382
1239
  log(diffText);
383
1240
  }
384
1241
  }
385
- // Apply level filtering with stage-gating (after read, before target filtering in write loop)
386
- // Stage caps the effective level: blank→beginner, seed→intermediate, grounded+→expert.
387
- // If stage caps below the requested level, log it so the user knows why items were dropped.
1242
+ // 5b. Read personal layer (WP-310 E2) — machine-local rules/skills from .productbrain/.local/, [] if absent, all persist: 'local'.
1243
+ const personalRules = readPersonalLayer(pbDir);
1244
+ if (personalRules.length > 0) {
1245
+ // Name collision detection — warn when a personal rule overrides a team rule
1246
+ const teamRuleNames = new Set(allRules.map((r) => r.name));
1247
+ for (const pr of personalRules) {
1248
+ if (teamRuleNames.has(pr.name)) {
1249
+ logErr(`Personal rule "${pr.name}" overrides team rule (local takes precedence).`);
1250
+ }
1251
+ }
1252
+ // Merge: team rules first, personal rules appended (personal takes precedence via name collision above)
1253
+ allRules = [...allRules, ...personalRules];
1254
+ }
1255
+ const personalSkills = readPersonalSkillsLayer(pbDir);
1256
+ if (personalSkills.length > 0) {
1257
+ const teamSkillNames = new Set(allSkills.map((s) => s.name));
1258
+ for (const ps of personalSkills) {
1259
+ if (teamSkillNames.has(ps.name)) {
1260
+ logErr(`Personal skill "${ps.name}" overrides team skill (local takes precedence).`);
1261
+ }
1262
+ }
1263
+ allSkills.push(...personalSkills);
1264
+ }
1265
+ // 5d. Load method registry (WP-310 E4) — only when manifest is present.
1266
+ let registrySource;
1267
+ let registryStale;
1268
+ if (manifest) {
1269
+ const registryResult = await loadMethodRegistry().catch(() => null);
1270
+ if (registryResult) {
1271
+ registrySource = registryResult.source;
1272
+ registryStale = registryResult.stale;
1273
+ }
1274
+ }
1275
+ const adoptionFilteredSkills = filterByAdoptionState(allSkills, manifest);
1276
+ const adoptionFilteredRules = filterByAdoptionState(allRules, manifest);
1277
+ // Compute adoption counts for report (only meaningful when manifest is present)
1278
+ const adoptedRulesCount = manifest ? adoptionFilteredRules.length : undefined;
1279
+ const rejectedRulesCount = manifest ? allRules.length - adoptionFilteredRules.length : undefined;
1280
+ // Level filtering with stage-gating: stage caps the effective level (blank→beginner, seed→intermediate, grounded+→expert).
388
1281
  const profileStage = workspaceProfile?.stage;
389
- const levelFilteredSkills = filterByLevel(allSkills, level, profileStage);
390
- const levelFilteredRules = filterByLevel(allRules, level, profileStage);
1282
+ const levelFilteredSkills = filterByLevel(adoptionFilteredSkills, level, profileStage);
1283
+ const levelFilteredRules = filterByLevel(adoptionFilteredRules, level, profileStage);
391
1284
  // Log when stage gating changes the effective level
392
1285
  if (profileStage) {
393
1286
  const stageCap = STAGE_TO_MAX_LEVEL[profileStage];
@@ -420,6 +1313,7 @@ export async function runHandshake(options = {}) {
420
1313
  if (dryRun && canonicalRules.length > 0) {
421
1314
  log(` INCLUDED rules: ${canonicalRules.map((r) => r.name).join(', ')}`);
422
1315
  }
1316
+ const noProjectionAssets = findNoProjectionAssets(canonicalSkills, canonicalRules);
423
1317
  if (canonicalSkills.length > 0 || canonicalRules.length > 0) {
424
1318
  const levelSuffix = level ? ` (level: ${level})` : '';
425
1319
  const stageSuffix = profileStage ? `, stage: ${profileStage}` : '';
@@ -429,16 +1323,15 @@ export async function runHandshake(options = {}) {
429
1323
  log(`Portable knowledge: ${canonicalSkills.length}/${totalSkills} skills, ${canonicalRules.length}/${totalRules} rules${levelSuffix}${stageSuffix}${stackSuffix}`);
430
1324
  }
431
1325
  // 6. Generate file contents
432
- // Build workspace context for AGENTS.md enrichment (stage, focus, governance, entry count)
1326
+ // Build workspace context for AGENTS.md enrichment (stage, focus, entry count)
433
1327
  const agentsWorkspaceContext = workspaceProfile
434
1328
  ? {
435
1329
  stage: workspaceProfile.stage,
436
- focus: orientView?.strategicContext?.currentBet ?? undefined,
437
- governanceMode: workspaceProfile.governanceMode,
1330
+ focus: orientView?.strategicContext?.currentWorkPackage ?? undefined,
438
1331
  totalEntries: workspaceProfile.totalEntries,
439
1332
  }
440
1333
  : undefined;
441
- // Collect codex-targeted skills for AGENTS.md skill directory
1334
+ // Collect codex-targeted skills for AGENTS.md skill directory — persist: 'local' entries included (all projections are local-only now).
442
1335
  const agentsCodexSkills = canonicalSkills
443
1336
  .filter((s) => shouldEmitToTarget(s, 'codex'))
444
1337
  .map((s) => ({
@@ -477,26 +1370,160 @@ export async function runHandshake(options = {}) {
477
1370
  const claudeContent = generateClaudeMd(timestamp);
478
1371
  const cursorContent = generateCursorMdc(timestamp);
479
1372
  const copilotContent = generateCopilotMd(timestamp, copilotOptions);
1373
+ // DEC-1343: one committed .github/instructions/<slug>.instructions.md per copilot rule with applyTo; repo-wide rules stay above.
1374
+ const copilotInstructionFiles = generateCopilotInstructionFiles(canonicalRules
1375
+ .filter((r) => shouldEmitToTarget(r, 'copilot'))
1376
+ // `.github/instructions/` is COMMITTED — never project a machine-local (persist: 'local') rule into it.
1377
+ .filter((r) => r.persist !== 'local')
1378
+ .map((r) => ({ name: r.name, body: r.body, applyTo: r.applyTo, sourcePath: r.sourcePath })), timestamp);
1379
+ const boundaryEnforcementMode = getBoundaryEnforcementMode(manifest);
1380
+ const boundaryManifestContent = boundaryEnforcementMode === 'advisory'
1381
+ ? null
1382
+ : generateBoundaryManifest(pbDir);
480
1383
  // 7. Write files
481
1384
  const filesWritten = [];
482
1385
  const filesSkipped = [];
483
- // Surface filtering: skip adapter writes for targets not in the allowed set
484
- const allowedTargets = options.surfaces && options.surfaces.length > 0
485
- ? new Set(options.surfaces)
486
- : null; // null = write all
1386
+ const previewPlan = [];
1387
+ if (writeMode && usedDbSource) {
1388
+ const authoringSyncState = loadAuthoringSyncState(pbDir);
1389
+ let authoringSyncStateChanged = false;
1390
+ const personalAssets = dbAssetRows.filter((asset) => asset.scope === 'personal' &&
1391
+ !asset.disabledByOwner &&
1392
+ (asset.assetKind === 'skill' || asset.assetKind === 'rule' || asset.assetKind === 'hook'));
1393
+ for (const asset of personalAssets) {
1394
+ // WP-428 S2 (Finding #5): skip fetch-failed assets — no empty-body authoring file, no lastProjectedHash update.
1395
+ if (bodyFetchFailedEntryIds.has(asset.entryId))
1396
+ continue;
1397
+ const authoringPath = setupAuthoringPath(cwd, asset);
1398
+ if (!authoringPath)
1399
+ continue;
1400
+ // relative() for correct cross-platform path computation (string-replace mis-fires on non-'/' cwd separators).
1401
+ const relativeAuthoringPath = relative(cwd, authoringPath);
1402
+ const bodyHash = setupAuthoringAssetHash(asset);
1403
+ const authoringExists = existsSync(authoringPath);
1404
+ const tracked = authoringSyncState.assets[asset.entryId];
1405
+ const trackedHere = tracked?.path === relativeAuthoringPath;
1406
+ const trackedMatchesServer = Boolean(trackedHere && asset.lastProjectedHash && tracked?.hash === asset.lastProjectedHash);
1407
+ if (!authoringExists && asset.lastProjectedHash && trackedHere && trackedMatchesServer) {
1408
+ try {
1409
+ const dormantResult = await kernelCall('setup.markPersonalSetupAssetDormantFromSync', { entryId: asset.entryId, expectedLastProjectedHash: tracked.hash });
1410
+ if (dormantResult.action === 'conflict') {
1411
+ syncDriftTensToFire.push(`Repo authoring deletion skipped for ${asset.entryId}; server baseline changed during sync, so writeback was deferred until the next DB read.`);
1412
+ logErr(`Warning: authoring deletion for ${asset.entryId} was not applied because the DB baseline changed during sync.`);
1413
+ deferredAuthoringBaselineEntryIds.add(asset.entryId);
1414
+ continue;
1415
+ }
1416
+ else {
1417
+ syncDriftTensToFire.push(`Repo authoring file was deleted for ${asset.entryId}; caller-owned personal setup asset marked dormant.`);
1418
+ log(`Setup authoring deletion: ${asset.entryId} marked dormant.`);
1419
+ delete authoringSyncState.assets[asset.entryId];
1420
+ authoringSyncStateChanged = true;
1421
+ continue;
1422
+ }
1423
+ }
1424
+ catch (err) {
1425
+ logErr(`Warning: could not mark ${asset.entryId} dormant after authoring deletion — ${err instanceof Error ? err.message : String(err)}`);
1426
+ continue;
1427
+ }
1428
+ }
1429
+ else if (!authoringExists && asset.lastProjectedHash && trackedHere) {
1430
+ syncDriftTensToFire.push(`Repo authoring deletion skipped for ${asset.entryId}; local sync baseline is stale, so DB writeback wins.`);
1431
+ logErr(`Warning: authoring deletion for ${asset.entryId} was not applied because the DB baseline changed.`);
1432
+ }
1433
+ const nextAuthoringContent = renderSetupAuthoringFile(asset);
1434
+ if (authoringExists) {
1435
+ const parsed = parseSetupAuthoringFrontmatter(readFileSync(authoringPath, 'utf8'));
1436
+ const fileHash = setupAuthoringAssetHash({
1437
+ entryId: parsed.frontmatterId?.trim() || asset.entryId,
1438
+ name: parsed.name || asset.name,
1439
+ description: parsed.description,
1440
+ body: parsed.body,
1441
+ assetKind: asset.assetKind,
1442
+ triggers: parsed.triggers,
1443
+ semanticRefs: parsed.semanticRefs,
1444
+ });
1445
+ if (fileHash === bodyHash) {
1446
+ if (asset.lastProjectedHash !== bodyHash) {
1447
+ await kernelCall('setup.updateLastProjectedHash', {
1448
+ entryId: asset.entryId,
1449
+ hash: bodyHash,
1450
+ }).catch(() => null);
1451
+ }
1452
+ authoringSyncState.assets[asset.entryId] = { path: relativeAuthoringPath, hash: bodyHash };
1453
+ authoringSyncStateChanged = true;
1454
+ continue;
1455
+ }
1456
+ if (!asset.lastProjectedHash) {
1457
+ syncDriftTensToFire.push(`Repo authoring file differs from DB for ${asset.entryId} at ${authoringPath} with no shared baseline; DB writeback skipped.`);
1458
+ logErr(`Warning: setup authoring drift for ${asset.entryId}; DB writeback skipped because no shared baseline exists.`);
1459
+ continue;
1460
+ }
1461
+ if (fileHash !== asset.lastProjectedHash &&
1462
+ bodyHash !== asset.lastProjectedHash) {
1463
+ syncDriftTensToFire.push(`Repo authoring file won setup sync conflict for ${asset.entryId} at ${authoringPath}.`);
1464
+ logErr(`Warning: repo authoring file won sync conflict for ${asset.entryId}; DB writeback skipped.`);
1465
+ continue;
1466
+ }
1467
+ if (fileHash !== asset.lastProjectedHash) {
1468
+ syncDriftTensToFire.push(`Repo authoring file differs from DB baseline for ${asset.entryId} at ${authoringPath}; DB writeback skipped.`);
1469
+ logErr(`Warning: setup authoring drift for ${asset.entryId}; DB writeback skipped.`);
1470
+ continue;
1471
+ }
1472
+ }
1473
+ try {
1474
+ assertSetupWritePath(authoringPath, perimeterManifest);
1475
+ mkdirSync(dirname(authoringPath), { recursive: true });
1476
+ writeFileSync(authoringPath, nextAuthoringContent);
1477
+ filesWritten.push(relativeAuthoringPath);
1478
+ await kernelCall('setup.updateLastProjectedHash', {
1479
+ entryId: asset.entryId,
1480
+ hash: bodyHash,
1481
+ }).catch(() => null);
1482
+ authoringSyncState.assets[asset.entryId] = { path: relativeAuthoringPath, hash: bodyHash };
1483
+ authoringSyncStateChanged = true;
1484
+ }
1485
+ catch (err) {
1486
+ logErr(`Warning: could not write setup authoring file for ${asset.entryId} — ${err instanceof Error ? err.message : String(err)}`);
1487
+ }
1488
+ }
1489
+ if (authoringSyncStateChanged) {
1490
+ try {
1491
+ saveAuthoringSyncState(pbDir, authoringSyncState);
1492
+ }
1493
+ catch (err) {
1494
+ logErr(`Warning: could not persist setup authoring sync state — ${err instanceof Error ? err.message : String(err)}`);
1495
+ }
1496
+ }
1497
+ }
487
1498
  const writes = [
488
1499
  ...(contextContent ? [{ path: join(cwd, '.productbrain', 'context.md'), relative: '.productbrain/context.md', content: contextContent, dirs: join(cwd, '.productbrain'), isAdapter: false }] : []),
489
1500
  { path: join(cwd, '.productbrain', 'briefing.md'), relative: '.productbrain/briefing.md', content: briefingContent, isAdapter: false },
490
- { path: join(cwd, 'AGENTS.md'), relative: 'AGENTS.md', content: agentsContent, isAdapter: true, target: 'codex' },
491
- { path: join(cwd, 'CLAUDE.md'), relative: 'CLAUDE.md', content: claudeContent, isAdapter: true, target: 'claude' },
1501
+ { path: join(cwd, 'AGENTS.md'), relative: 'AGENTS.md', content: agentsContent, isAdapter: true, target: 'codex', augmentTarget: true },
1502
+ { path: join(cwd, 'CLAUDE.md'), relative: 'CLAUDE.md', content: claudeContent, isAdapter: true, target: 'claude', augmentTarget: true },
492
1503
  { path: join(cwd, '.cursor', 'rules', 'chain.mdc'), relative: '.cursor/rules/chain.mdc', content: cursorContent, dirs: join(cwd, '.cursor', 'rules'), isAdapter: true, target: 'cursor' },
493
1504
  { path: join(cwd, '.github', 'copilot-instructions.md'), relative: '.github/copilot-instructions.md', content: copilotContent, dirs: join(cwd, '.github'), isAdapter: true, target: 'copilot' },
1505
+ ...copilotInstructionFiles.map((f) => ({
1506
+ path: join(cwd, f.relativePath),
1507
+ relative: f.relativePath,
1508
+ content: f.content,
1509
+ dirs: join(cwd, '.github', 'instructions'),
1510
+ isAdapter: true,
1511
+ target: 'copilot',
1512
+ })),
1513
+ ...(boundaryManifestContent ? [{
1514
+ path: join(cwd, '.productbrain', 'generated', 'boundaries.json'),
1515
+ relative: '.productbrain/generated/boundaries.json',
1516
+ content: boundaryManifestContent,
1517
+ dirs: join(cwd, '.productbrain', 'generated'),
1518
+ isAdapter: false,
1519
+ }] : []),
494
1520
  ];
495
1521
  // Add Cursor skill copies (filtered by target)
496
1522
  const cursorProfile = resolveSurfaceProfile('cursor');
497
1523
  for (const skill of canonicalSkills) {
498
1524
  if (!shouldEmitToTarget(skill, 'cursor'))
499
1525
  continue;
1526
+ const dbAssetEntryId = skill.sourcePath.startsWith('db:') ? skill.sourcePath.slice(3) : undefined;
500
1527
  const skillDir = join(cwd, '.cursor', 'skills', skill.name);
501
1528
  writes.push({
502
1529
  path: join(skillDir, 'SKILL.md'),
@@ -505,12 +1532,14 @@ export async function runHandshake(options = {}) {
505
1532
  dirs: skillDir,
506
1533
  isAdapter: true,
507
1534
  target: 'cursor',
1535
+ dbAssetEntryId,
508
1536
  });
509
1537
  }
510
1538
  // Add Codex skill copies (projected markdown + index)
511
1539
  const codexProfile = resolveSurfaceProfile('codex');
512
1540
  const codexSkills = canonicalSkills.filter((s) => shouldEmitToTarget(s, 'codex'));
513
1541
  for (const skill of codexSkills) {
1542
+ const dbAssetEntryId = skill.sourcePath.startsWith('db:') ? skill.sourcePath.slice(3) : undefined;
514
1543
  writes.push({
515
1544
  path: join(cwd, '.codex', 'skills', `${skill.name}.md`),
516
1545
  relative: `.codex/skills/${skill.name}.md`,
@@ -518,6 +1547,7 @@ export async function runHandshake(options = {}) {
518
1547
  dirs: join(cwd, '.codex', 'skills'),
519
1548
  isAdapter: true,
520
1549
  target: 'codex',
1550
+ dbAssetEntryId,
521
1551
  });
522
1552
  }
523
1553
  writes.push({
@@ -534,6 +1564,7 @@ export async function runHandshake(options = {}) {
534
1564
  for (const rule of canonicalRules) {
535
1565
  if (!shouldEmitToTarget(rule, 'cursor'))
536
1566
  continue;
1567
+ const dbAssetEntryId = rule.sourcePath.startsWith('db:') ? rule.sourcePath.slice(3) : undefined;
537
1568
  writes.push({
538
1569
  path: join(cwd, '.cursor', 'rules', `${rule.name}.mdc`),
539
1570
  relative: `.cursor/rules/${rule.name}.mdc`,
@@ -541,64 +1572,492 @@ export async function runHandshake(options = {}) {
541
1572
  dirs: join(cwd, '.cursor', 'rules'),
542
1573
  isAdapter: true,
543
1574
  target: 'cursor',
1575
+ dbAssetEntryId,
544
1576
  });
545
1577
  }
546
- // Add Claude Code rule copies (filtered by target)
547
- const claudeProfile = resolveSurfaceProfile('claude');
548
- for (const rule of canonicalRules) {
549
- if (!shouldEmitToTarget(rule, 'claude'))
550
- continue;
551
- writes.push({
552
- path: join(cwd, '.claude', 'rules', `${rule.name}.md`),
553
- relative: `.claude/rules/${rule.name}.md`,
554
- content: generateClaudeRule(rule, claudeProfile),
555
- dirs: join(cwd, '.claude', 'rules'),
556
- isAdapter: true,
557
- target: 'claude',
558
- });
1578
+ // 7a. WP-379 S5b: find leftover projections (apply mode) — REPORT-ONLY (coordinator ruling, PR
1579
+ // #912 round 10), see findLeftoverProjections's own header. Gated on dbQuerySucceeded, not
1580
+ // usedDbSource — the report only needs dbAssetRows' names, not the write-content source.
1581
+ let leftoverFiles = [];
1582
+ let leftoverFilesTruncated = false;
1583
+ if (writeMode && dbQuerySucceeded) {
1584
+ // Personal-layer names: merged into allSkills/allRules below but absent from dbAssetRows —
1585
+ // without this an already-projected personal asset reads as a false-positive leftover.
1586
+ const activeAssetNames = [
1587
+ ...dbAssetRows.filter((a) => !a.disabledByOwner).map((a) => a.name),
1588
+ ...personalSkills.map((s) => s.name),
1589
+ ...personalRules.map((r) => r.name),
1590
+ ];
1591
+ // Nested .cursor/skills scan gets its OWN canon: canonicalSkills is SKILL-kind only and
1592
+ // shouldEmitToTarget(_, 'cursor') respects per-skill target routing.
1593
+ const cursorSkillNames = canonicalSkills.filter((s) => shouldEmitToTarget(s, 'cursor')).map((s) => s.name);
1594
+ // Round 11: exempt exact write-plan paths from the leftover scan (see findLeftoverProjections's own doc).
1595
+ const exactRelativePaths = new Set(writes.map((w) => w.relative));
1596
+ const scanResult = findLeftoverProjections(cwd, activeAssetNames, allowedTargets, cursorSkillNames, exactRelativePaths);
1597
+ leftoverFiles = scanResult.files;
1598
+ leftoverFilesTruncated = scanResult.truncated;
559
1599
  }
560
- // Add Claude Code skill router (filtered by target)
561
- const claudeSkills = canonicalSkills.filter((s) => shouldEmitToTarget(s, 'claude'));
562
- const skillRouterContent = generateClaudeSkillRouter(claudeSkills, claudeProfile);
563
- if (skillRouterContent) {
564
- writes.push({
565
- path: join(cwd, '.claude', 'rules', 'skill-router.md'),
566
- relative: '.claude/rules/skill-router.md',
567
- content: skillRouterContent,
568
- dirs: join(cwd, '.claude', 'rules'),
569
- isAdapter: true,
570
- target: 'claude',
571
- });
1600
+ // ── WP-436 S3: Vocab projector — fetch workspace vocab context once per handshake. Source-side
1601
+ // stays tokenized; resolves {{vocab:...}} before writing. Fail-open: a failed fetch writes the raw token.
1602
+ const handshakeVocabCtx = await getOrFetchVocabCtx(config.apiKey, async () => {
1603
+ try {
1604
+ const vocab = await kernelCall('chain.getVocabulary', {});
1605
+ if (vocab?.collectionLabels || vocab?.collectionDefaults) {
1606
+ return {
1607
+ ...(vocab.collectionLabels ? { collectionLabels: vocab.collectionLabels } : {}),
1608
+ ...(vocab.collectionDefaults ? { collectionDefaults: vocab.collectionDefaults } : {}),
1609
+ };
1610
+ }
1611
+ return null;
1612
+ }
1613
+ catch {
1614
+ return null; // fail-open
1615
+ }
1616
+ });
1617
+ const userOwnedSkipped = [];
1618
+ const projectedHashUpdates = new Map();
1619
+ const cleanBucketPaths = [];
1620
+ const tamperedBucket = [];
1621
+ const recordProjectedHash = (entryId) => {
1622
+ if (!applyMode || !entryId)
1623
+ return;
1624
+ if (deferredAuthoringBaselineEntryIds.has(entryId))
1625
+ return;
1626
+ const projection = dbProjectionHashes.get(entryId);
1627
+ if (projection)
1628
+ projectedHashUpdates.set(entryId, projection.hash);
1629
+ };
1630
+ // TEN-2155: region augmentation context + symlink dedupe — codexActive gates the AGENTS.md skills-index pointer.
1631
+ const regionCtx = { codexActive: allowedTargets.has('codex') };
1632
+ const malformedRegionPaths = [];
1633
+ // Same inode for two augment targets (e.g. CLAUDE.md symlinked to AGENTS.md): augment only first-seen.
1634
+ const seenAugmentRealpaths = new Set();
1635
+ const augmentTargetSkip = new Set();
1636
+ for (const w of writes) {
1637
+ if (!w.augmentTarget || !w.target || !allowedTargets.has(w.target) || !existsSync(w.path))
1638
+ continue;
1639
+ let real;
1640
+ try {
1641
+ real = realpathSync(w.path);
1642
+ }
1643
+ catch {
1644
+ real = w.path;
1645
+ }
1646
+ if (seenAugmentRealpaths.has(real))
1647
+ augmentTargetSkip.add(w.path);
1648
+ else
1649
+ seenAugmentRealpaths.add(real);
572
1650
  }
573
1651
  for (const w of writes) {
574
1652
  // Surface filtering: skip adapter writes for targets not in the allowed set
575
- if (allowedTargets && w.target && !allowedTargets.has(w.target)) {
1653
+ if (w.target && !allowedTargets.has(w.target)) {
576
1654
  filesSkipped.push({ path: w.relative, reason: `filtered (surface: ${w.target})` });
1655
+ if (preview)
1656
+ previewPlan.push({ path: w.relative, status: 'filtered' });
577
1657
  continue;
578
1658
  }
1659
+ // ── TEN-2155: augment user-owned CLAUDE.md / AGENTS.md with a marked PB region — runs ahead
1660
+ // of the legacy MARKER gates; absent/legacy-pb-managed fall through to the legacy path.
1661
+ if (w.augmentTarget) {
1662
+ const projection = REGION_PROJECTIONS[w.target];
1663
+ if (projection && existsSync(w.path)) {
1664
+ if (augmentTargetSkip.has(w.path)) {
1665
+ filesSkipped.push({ path: w.relative, reason: 'symlinked to another augment target — augmented once' });
1666
+ continue;
1667
+ }
1668
+ const disk = readFileSync(w.path, 'utf8');
1669
+ const cls = classifyAdapterFile(disk);
1670
+ if (cls === 'augmentable' || cls === 'region-present') {
1671
+ const eol = detectEol(disk);
1672
+ const region = replaceVocabTokens(projection.build(regionCtx, eol), handshakeVocabCtx);
1673
+ // Defense-in-depth: the composed region (post vocab-token resolution) must itself be a
1674
+ // single well-formed region. v1 content has no vocab tokens so this is a no-op, but it
1675
+ // guards the documented future override/vocab seam from injecting a stray sentinel/MARKER.
1676
+ if (classifyAdapterFile(region) !== 'region-present') {
1677
+ filesSkipped.push({ path: w.relative, reason: 'internal: composed PB region malformed — skipped to protect your file' });
1678
+ if (preview)
1679
+ previewPlan.push({ path: w.relative, status: 'needs-attention' });
1680
+ continue;
1681
+ }
1682
+ const candidate = cls === 'augmentable' ? spliceAppend(disk, region, eol) : spliceReplace(disk, region);
1683
+ if (candidate === disk) {
1684
+ filesSkipped.push({ path: w.relative, reason: 'unchanged' });
1685
+ if (preview)
1686
+ previewPlan.push({ path: w.relative, status: 'unchanged' });
1687
+ continue;
1688
+ }
1689
+ if (preview || dryRun) {
1690
+ filesWritten.push(w.relative + (dryRun ? ' (dry run)' : ''));
1691
+ if (preview)
1692
+ previewPlan.push({ path: w.relative, status: 'would-augment' });
1693
+ continue;
1694
+ }
1695
+ if (authorityPreviewOnly) {
1696
+ // apply + materialize observe/off: honor authority — do NOT write; mirror the legacy
1697
+ // preview-only skip so the report does not falsely list it as written.
1698
+ filesSkipped.push({ path: w.relative, reason: `preview-only (materialize: ${manifestStatus.mode})` });
1699
+ continue;
1700
+ }
1701
+ assertSetupWritePath(w.path, perimeterManifest);
1702
+ writeFileSync(w.path, candidate);
1703
+ filesWritten.push(w.relative);
1704
+ continue;
1705
+ }
1706
+ if (cls === 'malformed') {
1707
+ filesSkipped.push({ path: w.relative, reason: 'malformed PB region — left untouched; fix the pb:region sentinels' });
1708
+ if (preview)
1709
+ previewPlan.push({ path: w.relative, status: 'needs-attention' });
1710
+ malformedRegionPaths.push(w.relative);
1711
+ continue;
1712
+ }
1713
+ // cls 'pb-managed' falls through to legacy re-projection; 'opt-out' (pb:no-augment) falls through to the user-owned skip.
1714
+ }
1715
+ // absent file → fall through to legacy whole-file CREATE.
1716
+ }
579
1717
  if (w.isAdapter && !shouldWriteAdapter(w.path, force)) {
580
- filesSkipped.push({ path: w.relative, reason: 'exists without auto-generated marker (use --force to overwrite)' });
1718
+ // User-owned: a file at an adapter path without our auto-gen MARKER is the
1719
+ // user's own file. Leave it untouched — never overwrite, never treat as drift
1720
+ // or log a TEN (TEN-2150). Relayed to the connect screen via userOwnedSkipped.
1721
+ filesSkipped.push({ path: w.relative, reason: 'user-owned — left untouched (pb won\'t overwrite your file)' });
1722
+ if (preview) {
1723
+ previewPlan.push({ path: w.relative, status: 'user-owned' });
1724
+ }
1725
+ else {
1726
+ userOwnedSkipped.push(w.relative);
1727
+ }
581
1728
  continue;
582
1729
  }
583
- if (dryRun) {
584
- filesWritten.push(w.relative + ' (dry run)');
1730
+ if (authorityPreviewOnly) {
1731
+ filesSkipped.push({
1732
+ path: w.relative,
1733
+ reason: `preview-only (materialize: ${manifestStatus.mode})`,
1734
+ });
585
1735
  continue;
586
1736
  }
1737
+ if (preview || dryRun) {
1738
+ // In preview/dry-run mode: check content to distinguish new/update/unchanged
1739
+ if (existsSync(w.path)) {
1740
+ const current = readFileSync(w.path, 'utf8');
1741
+ const nextNormalized = normalizeHandshakeContentForComparison(w.content);
1742
+ const currentNormalized = normalizeHandshakeContentForComparison(current);
1743
+ if (nextNormalized === currentNormalized) {
1744
+ filesSkipped.push({ path: w.relative, reason: 'unchanged' });
1745
+ if (preview)
1746
+ previewPlan.push({ path: w.relative, status: 'unchanged' });
1747
+ }
1748
+ else {
1749
+ filesWritten.push(w.relative + (dryRun ? ' (dry run)' : ''));
1750
+ if (preview)
1751
+ previewPlan.push({ path: w.relative, status: 'would-update' });
1752
+ }
1753
+ }
1754
+ else {
1755
+ filesWritten.push(w.relative + (dryRun ? ' (dry run)' : ''));
1756
+ if (preview)
1757
+ previewPlan.push({ path: w.relative, status: 'would-write' });
1758
+ }
1759
+ continue;
1760
+ }
1761
+ // ── WP-421 S3: defer tampered adapter writes (doneWhen #17) — classify pb-managed-clean vs
1762
+ // pb-managed-tampered, deferred not overwritten; post-loop resolves. --force bypasses the defer.
1763
+ if (w.isAdapter && !force) {
1764
+ const drift = classifyDriftBucket(w.path);
1765
+ if (drift && drift.bucket === 'pb-managed-tampered') {
1766
+ tamperedBucket.push({
1767
+ path: w.path,
1768
+ relative: w.relative,
1769
+ content: w.content,
1770
+ expectedHash: drift.expectedHash,
1771
+ actualHash: drift.actualHash,
1772
+ dirs: w.dirs,
1773
+ dbAssetEntryId: w.dbAssetEntryId,
1774
+ });
1775
+ // Do NOT write — defer until prompt/refusal resolves the file.
1776
+ continue;
1777
+ }
1778
+ if (drift && drift.bucket === 'pb-managed-clean') {
1779
+ cleanBucketPaths.push(w.relative);
1780
+ }
1781
+ }
1782
+ assertSetupWritePath(w.path, perimeterManifest);
587
1783
  if (w.dirs)
588
1784
  mkdirSync(w.dirs, { recursive: true });
1785
+ // WP-436 S3: resolve {{vocab:...}} tokens before writing projected adapter files only
1786
+ // (source-side stays tokenized). Fail-open: undefined vocabCtx falls back to canonicalKey literals.
1787
+ const resolvedContent = w.isAdapter
1788
+ ? replaceVocabTokens(w.content, handshakeVocabCtx)
1789
+ : w.content;
589
1790
  if (existsSync(w.path)) {
590
1791
  const current = readFileSync(w.path, 'utf8');
591
- const nextNormalized = normalizeHandshakeContentForComparison(w.content);
1792
+ const nextNormalized = normalizeHandshakeContentForComparison(resolvedContent);
592
1793
  const currentNormalized = normalizeHandshakeContentForComparison(current);
593
1794
  if (nextNormalized === currentNormalized) {
594
1795
  filesSkipped.push({ path: w.relative, reason: 'unchanged' });
1796
+ recordProjectedHash(w.dbAssetEntryId);
595
1797
  continue;
596
1798
  }
597
1799
  }
598
- writeFileSync(w.path, w.content);
1800
+ writeFileSync(w.path, resolvedContent);
599
1801
  filesWritten.push(w.relative);
1802
+ recordProjectedHash(w.dbAssetEntryId);
1803
+ }
1804
+ if (projectedHashUpdates.size > 0) {
1805
+ const updates = [...projectedHashUpdates];
1806
+ const results = await Promise.allSettled(updates.map(([entryId, hash]) => kernelCall('setup.updateLastProjectedHash', { entryId, hash })));
1807
+ results.forEach((result, index) => {
1808
+ if (result.status === 'rejected') {
1809
+ const [entryId] = updates[index];
1810
+ trackEvent('skill.projection.failed', {
1811
+ entryId,
1812
+ reason: result.reason instanceof Error ? result.reason.message : String(result.reason),
1813
+ });
1814
+ }
1815
+ });
1816
+ }
1817
+ // Runs AFTER the hash flush (malformed files were never written, nothing to record). TEN-2155:
1818
+ // non-interactive apply refuses on a malformed region — gated on applyMode per STD-263 vi.
1819
+ if (applyMode && malformedRegionPaths.length > 0 && (options.noPrompt || !process.stdout.isTTY)) {
1820
+ throw new CLIError(`Malformed PB region in: ${malformedRegionPaths.join(', ')}`, {
1821
+ code: ErrorCode.VALIDATION_FAILED,
1822
+ category: 'validation',
1823
+ guidance: 'Fix the `<!-- pb:region:start -->` / `<!-- pb:region:end -->` sentinels (one balanced pair), then re-run `pb handshake`.',
1824
+ });
1825
+ }
1826
+ // ── WP-421 S3: tampered-bucket resolution (doneWhen #17), apply mode only — headless (--no-prompt
1827
+ // / non-TTY) refuses (setup_receipt kind='transition', DEC-962, exit non-zero); interactive adopts
1828
+ // (personal draft from tampered content) or reverts (re-project canonical content).
1829
+ const adoptedTamperedPaths = [];
1830
+ const revertedTamperedPaths = [];
1831
+ if (writeMode && tamperedBucket.length > 0) {
1832
+ const headless = options.noPrompt === true || !process.stdout.isTTY;
1833
+ if (headless) {
1834
+ // ── Headless refusal path (doneWhen #17) ────────────────────────────────
1835
+ logErr('');
1836
+ logErr(`pb handshake: ${tamperedBucket.length} PB-managed projection file(s) were edited downstream of the auto-gen marker.`);
1837
+ logErr('Headless mode (--no-prompt or no TTY) cannot resolve adopt-or-revert — refusing.');
1838
+ logErr('');
1839
+ const refusedTamperedFiles = tamperedBucket.map((t) => ({
1840
+ path: t.relative,
1841
+ expectedHash: t.expectedHash,
1842
+ actualHash: t.actualHash,
1843
+ }));
1844
+ for (const refused of refusedTamperedFiles) {
1845
+ // Per #17: stderr enumerates each tampered file as
1846
+ // {path, expectedHash, actualHash, bucket}.
1847
+ logErr(` ${JSON.stringify({ ...refused, bucket: 'pb-managed-tampered' })}`);
1848
+ }
1849
+ logErr('');
1850
+ logErr('Re-run interactively to resolve, or use --force to overwrite (data loss).');
1851
+ // Write the kind='transition' setup_receipt row. Fail-open on the
1852
+ // network/auth side: if the row cannot be written, we still exit non-zero
1853
+ // (the audit trail is best-effort; refusal is mandatory).
1854
+ try {
1855
+ const manifestStatus = readManifestStatus(pbDir);
1856
+ await kernelCall('setup.recordTamperRefusal', {
1857
+ mode: manifestStatus.mode,
1858
+ refusedTamperedFiles,
1859
+ });
1860
+ trackEvent('setup.transition.refused', {
1861
+ fileCount: refusedTamperedFiles.length,
1862
+ mode: manifestStatus.mode,
1863
+ });
1864
+ }
1865
+ catch (err) {
1866
+ trackEvent('setup.transition.refused.write_failed', {
1867
+ error: err instanceof Error ? err.message : String(err),
1868
+ });
1869
+ logErr(`Warning: could not record transition receipt — ${err instanceof Error ? err.message : String(err)}`);
1870
+ }
1871
+ // Surface the report counts before exit (visibility for CI logs).
1872
+ if (!quiet) {
1873
+ const refusalReport = {
1874
+ filesWritten,
1875
+ filesSkipped,
1876
+ matchedEntries,
1877
+ searchQueries: uniqueQueries,
1878
+ repo,
1879
+ codexWarnings: codexWarnings.length > 0 ? codexWarnings : undefined,
1880
+ chainRulesStats: chainRulesStats ?? undefined,
1881
+ chainGaps: chainGaps.length > 0 ? chainGaps : undefined,
1882
+ adoptedCount: adoptedRulesCount,
1883
+ rejectedCount: rejectedRulesCount,
1884
+ personalRuleCount: personalRules.length > 0 ? personalRules.length : undefined,
1885
+ personalSkillCount: personalSkills.length > 0 ? personalSkills.length : undefined,
1886
+ registrySource,
1887
+ registryStale,
1888
+ userOwnedSkipped: userOwnedSkipped.length > 0 ? userOwnedSkipped : undefined,
1889
+ managedCleanCount: cleanBucketPaths.length || undefined,
1890
+ tamperedFiles: refusedTamperedFiles,
1891
+ leftoverFiles: leftoverFiles.length > 0 ? leftoverFiles : undefined,
1892
+ leftoverFilesTruncated: leftoverFilesTruncated || undefined, noProjectionAssets: noProjectionAssets.length > 0 ? noProjectionAssets : undefined, // same-line combine, shrink-only budget
1893
+ };
1894
+ process.stdout.write('\n');
1895
+ process.stdout.write(isJsonMode() ? JSON.stringify(toPublicJsonReport(refusalReport)) + '\n' : formatHandshakeReport(refusalReport) + '\n');
1896
+ }
1897
+ // Exit non-zero per #17.
1898
+ process.exit(1);
1899
+ }
1900
+ // ── Interactive path: prompt adopt-or-revert per file ──────────────────────
1901
+ log('');
1902
+ log(`pb handshake: ${tamperedBucket.length} PB-managed projection file(s) were edited downstream of the auto-gen marker.`);
1903
+ log('You can ADOPT (capture your edits as a personal-scoped draft) or REVERT (overwrite with canonical content).');
1904
+ // Batch yes-to-all / no-to-all when the user has many tampered files.
1905
+ // Threshold: 5 (arbitrary; mirrors the typical handshake projection set).
1906
+ let batchChoice = null;
1907
+ if (tamperedBucket.length >= 5) {
1908
+ const useBatch = await promptConfirm({
1909
+ message: `Apply the same choice to all ${tamperedBucket.length} tampered files?`,
1910
+ initialValue: false,
1911
+ });
1912
+ if (useBatch) {
1913
+ const choice = await promptSelect({
1914
+ message: 'Apply to all:',
1915
+ options: [
1916
+ { value: 'adopt', label: 'Adopt all — capture each as a personal-scoped draft' },
1917
+ { value: 'revert', label: 'Revert all — overwrite with canonical content' },
1918
+ ],
1919
+ });
1920
+ batchChoice = choice === 'adopt' ? 'adopt-all' : 'revert-all';
1921
+ }
1922
+ }
1923
+ for (const tamper of tamperedBucket) {
1924
+ // Reverse-map the projection path back to the canonical authoring path.
1925
+ const reverse = canonicalPathForAnySurface(tamper.relative);
1926
+ const canonicalHint = reverse
1927
+ ? `Canonical authoring path: ${reverse.canonicalPath}`
1928
+ : (() => {
1929
+ // Telemetry + fallback message per surfaces/telemetry.ts.
1930
+ reportReverseMapMissing({ surface: 'unknown', projectionPath: tamper.relative }, logErr);
1931
+ return `Canonical authoring path: ${getReverseMapFallbackMessage()}`;
1932
+ })();
1933
+ log('');
1934
+ log(`Tampered: ${tamper.relative}`);
1935
+ log(` expected: ${tamper.expectedHash}`);
1936
+ log(` actual: ${tamper.actualHash}`);
1937
+ log(` ${canonicalHint}`);
1938
+ let action;
1939
+ if (batchChoice === 'adopt-all')
1940
+ action = 'adopt';
1941
+ else if (batchChoice === 'revert-all')
1942
+ action = 'revert';
1943
+ else {
1944
+ action = await promptSelect({
1945
+ message: 'Adopt or revert?',
1946
+ options: [
1947
+ { value: 'adopt', label: 'Adopt — capture this as a personal-scoped setup_asset draft' },
1948
+ { value: 'revert', label: 'Revert — overwrite with canonical content' },
1949
+ ],
1950
+ });
1951
+ }
1952
+ if (action === 'revert') {
1953
+ // Re-project canonical content over the tampered file.
1954
+ // WP-436 S3: resolve vocab tokens before writing (all tampered files are adapters).
1955
+ if (tamper.dirs)
1956
+ mkdirSync(tamper.dirs, { recursive: true });
1957
+ assertSetupWritePath(tamper.path, perimeterManifest);
1958
+ writeFileSync(tamper.path, replaceVocabTokens(tamper.content, handshakeVocabCtx));
1959
+ revertedTamperedPaths.push(tamper.relative);
1960
+ recordProjectedHash(tamper.dbAssetEntryId);
1961
+ trackEvent('setup.tampered.reverted', { path: tamper.relative });
1962
+ }
1963
+ else {
1964
+ // Adopt: capture the tampered content as a personal-scoped draft (DEC-953: personal
1965
+ // scope = push, no fork required). Best-effort — on failure the file stays untouched and
1966
+ // a warning is logged. Does NOT revert; preserves the edits AND records them as a draft.
1967
+ const draftName = basename(tamper.relative).replace(/\.(md|mdc)$/, '') + ' (adopted)';
1968
+ try {
1969
+ const tamperedContent = readFileSync(tamper.path, 'utf8');
1970
+ const session = readSession();
1971
+ const caller = session ? kernelCallWithSession : kernelCall;
1972
+ await caller('setup.ingestSetupAsset', {
1973
+ entryId: `SETUP-ADOPTED-${Date.now()}-${draftName.replace(/\s+/g, '-')}`,
1974
+ name: draftName,
1975
+ // WP-421 S3
1976
+ description: `Adopted from tampered projection at ${tamper.relative}.`,
1977
+ body: tamperedContent,
1978
+ assetKind: tamper.relative.includes('/skills/') ? 'skill' : 'rule',
1979
+ triggers: [],
1980
+ semanticRefs: [],
1981
+ });
1982
+ adoptedTamperedPaths.push(tamper.relative);
1983
+ trackEvent('setup.tampered.adopted', { path: tamper.relative });
1984
+ }
1985
+ catch (err) {
1986
+ logErr(`Warning: could not adopt ${tamper.relative} as draft — ${err instanceof Error ? err.message : String(err)}`);
1987
+ trackEvent('setup.tampered.adopt_failed', {
1988
+ path: tamper.relative,
1989
+ error: err instanceof Error ? err.message : String(err),
1990
+ });
1991
+ }
1992
+ }
1993
+ }
1994
+ }
1995
+ // DEC-1690: a dormant (gate-failed) asset is simply not projected — dbAssets already comes
1996
+ // from the server's activeAssets list. The WP-379 S4 / WP-426 E4 on-disk marker/rename/restore
1997
+ // machinery (and its .authoring-sync.json registries) is retired: nothing to reconcile.
1998
+ // 8. User-owned files left untouched are NOT drift (TEN-2150) — a marker-less adapter-path
1999
+ // file is the user's own; handshake never wrote it, so no "sync", no draft TEN, just a benign
2000
+ // "Skipped:" surfaced via report.userOwnedSkipped (the tampered/authoring-sync drift below is unaffected).
2001
+ if (syncDriftTensToFire.length > 0) {
2002
+ const session = readSession();
2003
+ if (session) {
2004
+ for (const driftDescription of syncDriftTensToFire) {
2005
+ kernelCallWithSession('chain.createEntry', {
2006
+ collectionSlug: 'tensions',
2007
+ name: 'TEN: setup authoring sync drift — repo wins',
2008
+ status: 'draft',
2009
+ data: { kind: 'drift', description: driftDescription },
2010
+ sessionId: session.sessionId,
2011
+ createdBy: `agent:${session.sessionId}`,
2012
+ }, { retryOnRateLimit: false }).catch((err) => {
2013
+ // WP-513 round 3 (P2): still fail-open, but surfaced — an unowned rung-2 refusal must not silently drop the drift evidence.
2014
+ logErr(`Warning: could not persist drift TEN (${driftDescription.slice(0, 60)}…) — ${err instanceof Error ? err.message : String(err)}`);
2015
+ });
2016
+ }
2017
+ }
2018
+ }
2019
+ // 8. Case-collision and dormant-drift TENs are gone (coordinator ruling, PR #912 round 10) —
2020
+ // they existed only to audit automated deletions that no longer happen; `report.leftoverFiles`
2021
+ // below is the single reporting surface now.
2022
+ // 8b. Setup receipt — record which assets were materialized (apply mode only)
2023
+ // Fail-open: receipt write is advisory, never blocks the handshake.
2024
+ if (applyMode) {
2025
+ const session = readSession();
2026
+ const caller = session ? kernelCallWithSession : kernelCall;
2027
+ try {
2028
+ const currentState = await caller('setup.getCurrentSetupState', {});
2029
+ const fromMode = currentState?.effectiveMode ?? 'observe';
2030
+ if (fromMode !== manifestStatus.mode) {
2031
+ await caller('setup.recordTransition', {
2032
+ fromMode, toMode: manifestStatus.mode, parseStatus: manifestStatus.parseStatus,
2033
+ surfaces: manifestStatus.surfaces,
2034
+ lock: manifestStatus.lock,
2035
+ });
2036
+ if (modeRank(manifestStatus.mode) < modeRank(fromMode)) {
2037
+ trackEvent('setup.transition.lowered', { fromMode, toMode: manifestStatus.mode });
2038
+ }
2039
+ }
2040
+ }
2041
+ catch (err) {
2042
+ trackEvent('setup.transition.write_failed', { error: err instanceof Error ? err.message : String(err) });
2043
+ logErr(`Warning: could not record setup transition — ${err instanceof Error ? err.message : String(err)}`);
2044
+ }
2045
+ }
2046
+ if (writeMode) {
2047
+ const session = readSession();
2048
+ const caller = session ? kernelCallWithSession : kernelCall;
2049
+ try {
2050
+ const receiptResult = await caller('setup.materializeSetup', {});
2051
+ if (receiptResult?.assetCount > 0) {
2052
+ log(`Setup receipt: ${receiptResult.assetCount} asset(s) recorded.`);
2053
+ }
2054
+ }
2055
+ catch (err) {
2056
+ trackEvent('setup.receipt.write_failed', { error: err instanceof Error ? err.message : String(err) });
2057
+ logErr(`Warning: could not write setup receipt — ${err instanceof Error ? err.message : String(err)}`);
2058
+ }
600
2059
  }
601
- // 8. Report
2060
+ // 9. Report
602
2061
  const report = {
603
2062
  filesWritten,
604
2063
  filesSkipped,
@@ -608,10 +2067,33 @@ export async function runHandshake(options = {}) {
608
2067
  codexWarnings: codexWarnings.length > 0 ? codexWarnings : undefined,
609
2068
  chainRulesStats: chainRulesStats ?? undefined,
610
2069
  chainGaps: chainGaps.length > 0 ? chainGaps : undefined,
2070
+ adoptedCount: adoptedRulesCount,
2071
+ rejectedCount: rejectedRulesCount,
2072
+ personalRuleCount: personalRules.length > 0 ? personalRules.length : undefined,
2073
+ personalSkillCount: personalSkills.length > 0 ? personalSkills.length : undefined,
2074
+ registrySource,
2075
+ registryStale,
2076
+ preview: preview ? true : undefined,
2077
+ previewPlan: preview && previewPlan.length > 0 ? previewPlan : undefined,
2078
+ userOwnedSkipped: userOwnedSkipped.length > 0 ? userOwnedSkipped : undefined,
2079
+ // WP-421 S3: three-bucket drift report (doneWhen #17). PB-managed-clean is
2080
+ // the count of files whose marker + hash matched. Tampered files were
2081
+ // resolved (adopted/reverted) above and are reported separately.
2082
+ managedCleanCount: cleanBucketPaths.length > 0 ? cleanBucketPaths.length : undefined,
2083
+ adoptedTamperedPaths: adoptedTamperedPaths.length > 0 ? adoptedTamperedPaths : undefined,
2084
+ revertedTamperedPaths: revertedTamperedPaths.length > 0 ? revertedTamperedPaths : undefined,
2085
+ // REPORT-ONLY leftover-file listing (coordinator ruling, PR #912 round 10) — the human removes these.
2086
+ leftoverFiles: leftoverFiles.length > 0 ? leftoverFiles : undefined,
2087
+ leftoverFilesTruncated: leftoverFilesTruncated || undefined, noProjectionAssets: noProjectionAssets.length > 0 ? noProjectionAssets : undefined, // WP-660 S2 combine
611
2088
  };
612
2089
  if (!quiet) {
613
2090
  process.stdout.write('\n');
614
- process.stdout.write(formatHandshakeReport(report) + '\n');
2091
+ process.stdout.write(isJsonMode() ? JSON.stringify(toPublicJsonReport(report)) + '\n' : formatHandshakeReport(report) + '\n');
615
2092
  }
2093
+ // Return the report so non-UI callers (e.g. prepareConnectContext) can surface
2094
+ // skipped/user-owned files without re-deriving the skip logic (TEN-2107).
2095
+ return report;
616
2096
  }
2097
+ // WP-426 E3/E4: exported test-only surface (not part of the public CLI API).
2098
+ export const __test = { setupAuthoringPath, loadAuthoringSyncState, MARKER };
617
2099
  //# sourceMappingURL=handshake.js.map