create-principles-disciple 1.150.3 → 1.150.6

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 (646) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/ingestion/admission.js +2 -0
  3. package/codex-adapter/dist/ingestion/ingestion.js +25 -4
  4. package/codex-adapter/dist/ingestion/transcript-decoder.d.ts +5 -3
  5. package/codex-adapter/dist/ingestion/transcript-decoder.js +61 -5
  6. package/codex-adapter/dist/pd-hook.d.ts +7 -5
  7. package/codex-adapter/dist/pd-hook.js +18 -7
  8. package/codex-adapter/dist/tool-semantics.js +5 -1
  9. package/codex-adapter/dist/worker/workspace-worker.js +4 -2
  10. package/codex-adapter/package.json +1 -1
  11. package/console/dist/lib/utils.js +16 -1
  12. package/console/dist/server/index.js +14 -2
  13. package/console/dist/server/models/ActivationsConsoleModel.js +3 -2
  14. package/console/dist/server/models/ApprovalsConsoleModel.js +2 -1
  15. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +2 -1
  16. package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +46 -0
  17. package/console/dist/server/models/EvidenceChainConsoleModel.js +121 -2
  18. package/console/dist/server/models/GovernanceConsoleModel.js +3 -2
  19. package/console/dist/server/models/GovernanceExperienceCollector.js +2 -1
  20. package/console/dist/server/models/GovernanceProjectionCollector.js +2 -1
  21. package/console/dist/server/models/IngestionHealthModel.d.ts +34 -0
  22. package/console/dist/server/models/IngestionHealthModel.js +254 -0
  23. package/console/dist/server/models/IntentDecisionModel.js +2 -2
  24. package/console/dist/server/models/IntentPageModel.js +2 -1
  25. package/console/dist/server/models/OwnerDecisionConsoleModel.js +3 -3
  26. package/console/dist/server/models/OwnerDecisionViewModel.js +2 -2
  27. package/console/dist/server/models/PrincipleTrajectoryModel.js +2 -1
  28. package/console/dist/server/models/ReceiptsConsoleModel.js +2 -2
  29. package/console/dist/server/models/RuleCandidateBindingConsoleModel.js +3 -2
  30. package/console/dist/server/routes/diagnostician.js +2 -1
  31. package/console/dist/server/routes/evidence-chain.d.ts +4 -0
  32. package/console/dist/server/routes/evidence-chain.js +22 -0
  33. package/console/dist/server/routes/failed-tasks.js +78 -2
  34. package/console/dist/server/routes/health.d.ts +8 -0
  35. package/console/dist/server/routes/health.js +72 -0
  36. package/console/dist/server/routes/owner-identity.d.ts +6 -0
  37. package/console/dist/server/routes/owner-identity.js +7 -3
  38. package/console/dist/server/routes/principles.js +3 -3
  39. package/console/dist/web/assets/app.css +150 -46
  40. package/console/dist/web/assets/app.js +37 -32
  41. package/console/package.json +2 -0
  42. package/core/dist/runtime/activation/adaptive-selection-output.d.ts +0 -21
  43. package/core/dist/runtime/activation/adaptive-selection-output.d.ts.map +1 -1
  44. package/core/dist/runtime/activation/adaptive-selection-output.js.map +1 -1
  45. package/core/dist/runtime/activation/index.d.ts +2 -6
  46. package/core/dist/runtime/activation/index.d.ts.map +1 -1
  47. package/core/dist/runtime/activation/index.js.map +1 -1
  48. package/core/dist/runtime/activation/production-gate-deps.d.ts +2 -1
  49. package/core/dist/runtime/activation/production-gate-deps.d.ts.map +1 -1
  50. package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +2 -1
  51. package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
  52. package/core/dist/runtime/activation/writers/index.d.ts +0 -1
  53. package/core/dist/runtime/activation/writers/index.d.ts.map +1 -1
  54. package/core/dist/runtime/activation/writers/rule-host-writer.d.ts.map +1 -1
  55. package/core/dist/runtime/activation/writers/rule-host-writer.js +15 -6
  56. package/core/dist/runtime/activation/writers/rule-host-writer.js.map +1 -1
  57. package/core/dist/runtime/activation-compatibility-read-model.d.ts +3 -2
  58. package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
  59. package/core/dist/runtime/activation-compatibility-read-model.js +2 -1
  60. package/core/dist/runtime/activation-compatibility-read-model.js.map +1 -1
  61. package/core/dist/runtime/adapter/context-budget.d.ts +3 -14
  62. package/core/dist/runtime/adapter/context-budget.d.ts.map +1 -1
  63. package/core/dist/runtime/adapter/context-budget.js +2 -2
  64. package/core/dist/runtime/adapter/context-budget.js.map +1 -1
  65. package/core/dist/runtime/adapter/index.d.ts +1 -2
  66. package/core/dist/runtime/adapter/index.d.ts.map +1 -1
  67. package/core/dist/runtime/adapter/index.js +1 -1
  68. package/core/dist/runtime/adapter/index.js.map +1 -1
  69. package/core/dist/runtime/adapter/output-repair-contract.d.ts +18 -1
  70. package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
  71. package/core/dist/runtime/adapter/output-repair-contract.js +94 -0
  72. package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
  73. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +2 -3
  74. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  75. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +111 -21
  76. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  77. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +1 -1
  78. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
  79. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts +0 -1
  80. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
  81. package/core/dist/runtime/adapter/schema-prompt-adapter.js +43 -1
  82. package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
  83. package/core/dist/runtime/bridge-result-shaper.d.ts +1 -1
  84. package/core/dist/runtime/bridge-result-shaper.d.ts.map +1 -1
  85. package/core/dist/runtime/candidate-audit.d.ts.map +1 -1
  86. package/core/dist/runtime/candidate-audit.js +2 -1
  87. package/core/dist/runtime/candidate-audit.js.map +1 -1
  88. package/core/dist/runtime/candidate-intake-service.d.ts +2 -1
  89. package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
  90. package/core/dist/runtime/cli/diagnose.d.ts +4 -3
  91. package/core/dist/runtime/cli/diagnose.d.ts.map +1 -1
  92. package/core/dist/runtime/config/index.d.ts +2 -2
  93. package/core/dist/runtime/config/index.d.ts.map +1 -1
  94. package/core/dist/runtime/config/index.js +3 -3
  95. package/core/dist/runtime/config/index.js.map +1 -1
  96. package/core/dist/runtime/config/pd-config-defaults.d.ts +0 -2
  97. package/core/dist/runtime/config/pd-config-defaults.d.ts.map +1 -1
  98. package/core/dist/runtime/config/pd-config-defaults.js +2 -2
  99. package/core/dist/runtime/config/pd-config-defaults.js.map +1 -1
  100. package/core/dist/runtime/config/pd-config-effective.d.ts.map +1 -1
  101. package/core/dist/runtime/config/pd-config-effective.js +2 -0
  102. package/core/dist/runtime/config/pd-config-effective.js.map +1 -1
  103. package/core/dist/runtime/config/pd-config-types.d.ts +54 -0
  104. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  105. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  106. package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
  107. package/core/dist/runtime/config/pd-config-validate.js +143 -0
  108. package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
  109. package/core/dist/runtime/config/pd-profile-constants.d.ts +1 -7
  110. package/core/dist/runtime/config/pd-profile-constants.d.ts.map +1 -1
  111. package/core/dist/runtime/config/pd-profile-constants.js +5 -6
  112. package/core/dist/runtime/config/pd-profile-constants.js.map +1 -1
  113. package/core/dist/runtime/config/pd-validate-profile.d.ts +3 -2
  114. package/core/dist/runtime/config/pd-validate-profile.d.ts.map +1 -1
  115. package/core/dist/runtime/context-payload.d.ts +0 -7
  116. package/core/dist/runtime/context-payload.d.ts.map +1 -1
  117. package/core/dist/runtime/context-payload.js +1 -1
  118. package/core/dist/runtime/context-payload.js.map +1 -1
  119. package/core/dist/runtime/core-principles/index.d.ts +1 -1
  120. package/core/dist/runtime/core-principles/index.d.ts.map +1 -1
  121. package/core/dist/runtime/correction/correction-types.d.ts +0 -10
  122. package/core/dist/runtime/correction/correction-types.d.ts.map +1 -1
  123. package/core/dist/runtime/correction/correction-types.js.map +1 -1
  124. package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts +0 -3
  125. package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts.map +1 -1
  126. package/core/dist/runtime/diagnostician/diag-distiller-output.js +1 -1
  127. package/core/dist/runtime/diagnostician/diag-distiller-output.js.map +1 -1
  128. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +3 -11
  129. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
  130. package/core/dist/runtime/diagnostician/diag-rootcause-output.js +3 -3
  131. package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
  132. package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts +5 -4
  133. package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
  134. package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts +2 -1
  135. package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts.map +1 -1
  136. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts +2 -1
  137. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
  138. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts +22 -3
  139. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
  140. package/core/dist/runtime/diagnostician/router-prompt-builder.js +11 -1
  141. package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
  142. package/core/dist/runtime/diagnostician-association-shadow.d.ts +2 -2
  143. package/core/dist/runtime/diagnostician-association-shadow.d.ts.map +1 -1
  144. package/core/dist/runtime/diagnostician-association-validation.d.ts +3 -2
  145. package/core/dist/runtime/diagnostician-association-validation.d.ts.map +1 -1
  146. package/core/dist/runtime/diagnostician-output.d.ts +32 -5
  147. package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
  148. package/core/dist/runtime/diagnostician-output.js +47 -4
  149. package/core/dist/runtime/diagnostician-output.js.map +1 -1
  150. package/core/dist/runtime/diagnostician-prompt-builder.d.ts +2 -1
  151. package/core/dist/runtime/diagnostician-prompt-builder.d.ts.map +1 -1
  152. package/core/dist/runtime/error-categories.d.ts.map +1 -1
  153. package/core/dist/runtime/error-categories.js +10 -1
  154. package/core/dist/runtime/error-categories.js.map +1 -1
  155. package/core/dist/runtime/evidence-sanitizer.d.ts +8 -1
  156. package/core/dist/runtime/evidence-sanitizer.d.ts.map +1 -1
  157. package/core/dist/runtime/evidence-sanitizer.js +10 -3
  158. package/core/dist/runtime/evidence-sanitizer.js.map +1 -1
  159. package/core/dist/runtime/evolution/evolution-types.d.ts +0 -26
  160. package/core/dist/runtime/evolution/evolution-types.d.ts.map +1 -1
  161. package/core/dist/runtime/evolution/evolution-types.js.map +1 -1
  162. package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
  163. package/core/dist/runtime/feature-flags/feature-flag-contract.js +8 -0
  164. package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
  165. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  166. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +24 -0
  167. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  168. package/core/dist/runtime/feature-flags/index.d.ts +0 -1
  169. package/core/dist/runtime/feature-flags/index.d.ts.map +1 -1
  170. package/core/dist/runtime/feature-flags/index.js.map +1 -1
  171. package/core/dist/runtime/golden-trace.d.ts +9 -1
  172. package/core/dist/runtime/golden-trace.d.ts.map +1 -1
  173. package/core/dist/runtime/golden-trace.js +7 -0
  174. package/core/dist/runtime/golden-trace.js.map +1 -1
  175. package/core/dist/runtime/governance-projection-contract.d.ts +0 -6
  176. package/core/dist/runtime/governance-projection-contract.d.ts.map +1 -1
  177. package/core/dist/runtime/governance-projection-contract.js +3 -3
  178. package/core/dist/runtime/governance-projection-contract.js.map +1 -1
  179. package/core/dist/runtime/index.d.ts +2 -0
  180. package/core/dist/runtime/index.d.ts.map +1 -1
  181. package/core/dist/runtime/index.js +2 -0
  182. package/core/dist/runtime/index.js.map +1 -1
  183. package/core/dist/runtime/internalization/artifact-summary.d.ts +5 -4
  184. package/core/dist/runtime/internalization/artifact-summary.d.ts.map +1 -1
  185. package/core/dist/runtime/internalization/artifact-summary.js +1 -1
  186. package/core/dist/runtime/internalization/artifact-summary.js.map +1 -1
  187. package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts +1 -1
  188. package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts.map +1 -1
  189. package/core/dist/runtime/internalization/artificer-output.d.ts +0 -2
  190. package/core/dist/runtime/internalization/artificer-output.d.ts.map +1 -1
  191. package/core/dist/runtime/internalization/artificer-output.js +17 -0
  192. package/core/dist/runtime/internalization/artificer-output.js.map +1 -1
  193. package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts +14 -3
  194. package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts.map +1 -1
  195. package/core/dist/runtime/internalization/artificer-prompt-builder.js +13 -1
  196. package/core/dist/runtime/internalization/artificer-prompt-builder.js.map +1 -1
  197. package/core/dist/runtime/internalization/artificer-run-correlation.d.ts +3 -2
  198. package/core/dist/runtime/internalization/artificer-run-correlation.d.ts.map +1 -1
  199. package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts +2 -1
  200. package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts.map +1 -1
  201. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +1 -1
  202. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  203. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +1 -1
  204. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  205. package/core/dist/runtime/internalization/diag-router-runner.d.ts +11 -1
  206. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  207. package/core/dist/runtime/internalization/diag-router-runner.js +105 -1
  208. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  209. package/core/dist/runtime/internalization/dreamer-output.d.ts +0 -9
  210. package/core/dist/runtime/internalization/dreamer-output.d.ts.map +1 -1
  211. package/core/dist/runtime/internalization/dreamer-output.js +1 -1
  212. package/core/dist/runtime/internalization/dreamer-output.js.map +1 -1
  213. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts +3 -2
  214. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  215. package/core/dist/runtime/internalization/dreamer-runner.d.ts +1 -1
  216. package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
  217. package/core/dist/runtime/internalization/evaluator-output.d.ts +7 -17
  218. package/core/dist/runtime/internalization/evaluator-output.d.ts.map +1 -1
  219. package/core/dist/runtime/internalization/evaluator-output.js +2 -2
  220. package/core/dist/runtime/internalization/evaluator-output.js.map +1 -1
  221. package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts +3 -9
  222. package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  223. package/core/dist/runtime/internalization/evaluator-prompt-builder.js +1 -1
  224. package/core/dist/runtime/internalization/evaluator-prompt-builder.js.map +1 -1
  225. package/core/dist/runtime/internalization/formation-context.d.ts +4 -6
  226. package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
  227. package/core/dist/runtime/internalization/formation-context.js +3 -3
  228. package/core/dist/runtime/internalization/formation-context.js.map +1 -1
  229. package/core/dist/runtime/internalization/index.d.ts +2 -4
  230. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  231. package/core/dist/runtime/internalization/index.js +8 -1
  232. package/core/dist/runtime/internalization/index.js.map +1 -1
  233. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +2 -1
  234. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
  235. package/core/dist/runtime/internalization/intent-contract.d.ts +2 -1
  236. package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
  237. package/core/dist/runtime/internalization/internalization-job-graph.d.ts +1 -1
  238. package/core/dist/runtime/internalization/internalization-job-graph.d.ts.map +1 -1
  239. package/core/dist/runtime/internalization/internalization-route.d.ts +2 -1
  240. package/core/dist/runtime/internalization/internalization-route.d.ts.map +1 -1
  241. package/core/dist/runtime/internalization/owner-decision-review.d.ts +3 -2
  242. package/core/dist/runtime/internalization/owner-decision-review.d.ts.map +1 -1
  243. package/core/dist/runtime/internalization/owner-resolution-service.d.ts +2 -1
  244. package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
  245. package/core/dist/runtime/internalization/owner-retry.d.ts +2 -1
  246. package/core/dist/runtime/internalization/owner-retry.d.ts.map +1 -1
  247. package/core/dist/runtime/internalization/owner-review.d.ts +2 -21
  248. package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
  249. package/core/dist/runtime/internalization/owner-review.js +2 -2
  250. package/core/dist/runtime/internalization/owner-review.js.map +1 -1
  251. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -5
  252. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
  253. package/core/dist/runtime/internalization/peer-runner-contracts.js +1 -1
  254. package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
  255. package/core/dist/runtime/internalization/philosopher-output.d.ts +0 -8
  256. package/core/dist/runtime/internalization/philosopher-output.d.ts.map +1 -1
  257. package/core/dist/runtime/internalization/philosopher-output.js +1 -1
  258. package/core/dist/runtime/internalization/philosopher-output.js.map +1 -1
  259. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +3 -2
  260. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
  261. package/core/dist/runtime/internalization/pitask-metadata.d.ts +1 -1
  262. package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
  263. package/core/dist/runtime/internalization/repair-replay-resolver.d.ts +4 -3
  264. package/core/dist/runtime/internalization/repair-replay-resolver.d.ts.map +1 -1
  265. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts +2 -3
  266. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts.map +1 -1
  267. package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
  268. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts +0 -1
  269. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
  270. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js +1 -1
  271. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js.map +1 -1
  272. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts +3 -3
  273. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts.map +1 -1
  274. package/core/dist/runtime/internalization/rule-activation-contract.d.ts +3 -2
  275. package/core/dist/runtime/internalization/rule-activation-contract.d.ts.map +1 -1
  276. package/core/dist/runtime/internalization/rule-host-input-builder.d.ts +16 -0
  277. package/core/dist/runtime/internalization/rule-host-input-builder.d.ts.map +1 -1
  278. package/core/dist/runtime/internalization/rule-host-input-builder.js +18 -0
  279. package/core/dist/runtime/internalization/rule-host-input-builder.js.map +1 -1
  280. package/core/dist/runtime/internalization/rule-reliability-validation.d.ts +13 -18
  281. package/core/dist/runtime/internalization/rule-reliability-validation.d.ts.map +1 -1
  282. package/core/dist/runtime/internalization/rule-reliability-validation.js +43 -1
  283. package/core/dist/runtime/internalization/rule-reliability-validation.js.map +1 -1
  284. package/core/dist/runtime/internalization/scribe-output.d.ts +2 -15
  285. package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
  286. package/core/dist/runtime/internalization/scribe-output.js +2 -2
  287. package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
  288. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +3 -3
  289. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
  290. package/core/dist/runtime/internalization/scribe-prompt-builder.js +0 -1
  291. package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
  292. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +25 -1
  293. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  294. package/core/dist/runtime/internalization/split-diagnostician-runner.js +122 -5
  295. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  296. package/core/dist/runtime/internalization/textual-basis-anchor.d.ts +3 -6
  297. package/core/dist/runtime/internalization/textual-basis-anchor.d.ts.map +1 -1
  298. package/core/dist/runtime/internalization/textual-basis-anchor.js +2 -2
  299. package/core/dist/runtime/internalization/textual-basis-anchor.js.map +1 -1
  300. package/core/dist/runtime/internalization/tool-semantic-registry.d.ts +26 -0
  301. package/core/dist/runtime/internalization/tool-semantic-registry.d.ts.map +1 -1
  302. package/core/dist/runtime/internalization/tool-semantic-registry.js +55 -5
  303. package/core/dist/runtime/internalization/tool-semantic-registry.js.map +1 -1
  304. package/core/dist/runtime/internalization-chain-integrity-read-model.d.ts.map +1 -1
  305. package/core/dist/runtime/internalization-chain-integrity-read-model.js +2 -2
  306. package/core/dist/runtime/internalization-chain-integrity-read-model.js.map +1 -1
  307. package/core/dist/runtime/internalization-integrity-remediation.d.ts.map +1 -1
  308. package/core/dist/runtime/internalization-integrity-remediation.js +2 -2
  309. package/core/dist/runtime/internalization-integrity-remediation.js.map +1 -1
  310. package/core/dist/runtime/language-directive.d.ts +2 -1
  311. package/core/dist/runtime/language-directive.d.ts.map +1 -1
  312. package/core/dist/runtime/operator-health-read-model.d.ts.map +1 -1
  313. package/core/dist/runtime/operator-health-read-model.js +2 -2
  314. package/core/dist/runtime/operator-health-read-model.js.map +1 -1
  315. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts +3 -29
  316. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
  317. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js +4 -5
  318. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js.map +1 -1
  319. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts +0 -49
  320. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts.map +1 -1
  321. package/core/dist/runtime/owner-decision/owner-decision-view.js +5 -5
  322. package/core/dist/runtime/owner-decision/owner-decision-view.js.map +1 -1
  323. package/core/dist/runtime/owner-decision/semantic-selector.d.ts +3 -2
  324. package/core/dist/runtime/owner-decision/semantic-selector.d.ts.map +1 -1
  325. package/core/dist/runtime/owner-identity.d.ts +12 -1
  326. package/core/dist/runtime/owner-identity.d.ts.map +1 -1
  327. package/core/dist/runtime/owner-identity.js +19 -1
  328. package/core/dist/runtime/owner-identity.js.map +1 -1
  329. package/core/dist/runtime/pain-ingress-payload.d.ts +0 -39
  330. package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
  331. package/core/dist/runtime/pain-ingress-payload.js +4 -4
  332. package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
  333. package/core/dist/runtime/pain-ingress.d.ts +1 -1
  334. package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
  335. package/core/dist/runtime/pain-ingress.js.map +1 -1
  336. package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
  337. package/core/dist/runtime/pain-recall-read-model.js +4 -3
  338. package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
  339. package/core/dist/runtime/pain-signal-bridge.d.ts +0 -2
  340. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  341. package/core/dist/runtime/pain-signal-bridge.js +1 -1
  342. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  343. package/core/dist/runtime/pain-signal-runtime-factory.d.ts +3 -3
  344. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  345. package/core/dist/runtime/pain-signal-runtime-factory.js +1 -1
  346. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  347. package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts +3 -2
  348. package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts.map +1 -1
  349. package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts +0 -10
  350. package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts.map +1 -1
  351. package/core/dist/runtime/principle-reuse/reuse-retrieval.js +1 -1
  352. package/core/dist/runtime/principle-reuse/reuse-retrieval.js.map +1 -1
  353. package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts +1 -8
  354. package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts.map +1 -1
  355. package/core/dist/runtime/principle-reuse/reuse-shortlist.js +1 -1
  356. package/core/dist/runtime/principle-reuse/reuse-shortlist.js.map +1 -1
  357. package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts +3 -2
  358. package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts.map +1 -1
  359. package/core/dist/runtime/pruning-read-model.d.ts.map +1 -1
  360. package/core/dist/runtime/pruning-read-model.js +3 -2
  361. package/core/dist/runtime/pruning-read-model.js.map +1 -1
  362. package/core/dist/runtime/risk/risk-calculator-policy.d.ts +12 -2
  363. package/core/dist/runtime/risk/risk-calculator-policy.d.ts.map +1 -1
  364. package/core/dist/runtime/risk/risk-calculator-policy.js +33 -22
  365. package/core/dist/runtime/risk/risk-calculator-policy.js.map +1 -1
  366. package/core/dist/runtime/runner/base-peer-runner.d.ts +32 -0
  367. package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
  368. package/core/dist/runtime/runner/base-peer-runner.js +168 -16
  369. package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
  370. package/core/dist/runtime/runner/default-validator.d.ts +0 -1
  371. package/core/dist/runtime/runner/default-validator.d.ts.map +1 -1
  372. package/core/dist/runtime/runner/default-validator.js +11 -3
  373. package/core/dist/runtime/runner/default-validator.js.map +1 -1
  374. package/core/dist/runtime/runner/peer-runner-types.d.ts +11 -0
  375. package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
  376. package/core/dist/runtime/schema-conformance-read-model.js +2 -2
  377. package/core/dist/runtime/schema-conformance-read-model.js.map +1 -1
  378. package/core/dist/runtime/storage-paths.d.ts +15 -0
  379. package/core/dist/runtime/storage-paths.d.ts.map +1 -0
  380. package/core/dist/runtime/storage-paths.js +15 -0
  381. package/core/dist/runtime/storage-paths.js.map +1 -0
  382. package/core/dist/runtime/store/artifact/index.d.ts +1 -1
  383. package/core/dist/runtime/store/artifact/index.d.ts.map +1 -1
  384. package/core/dist/runtime/store/candidate/admission-document.d.ts +4 -3
  385. package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
  386. package/core/dist/runtime/store/commit/index.d.ts +0 -1
  387. package/core/dist/runtime/store/commit/index.d.ts.map +1 -1
  388. package/core/dist/runtime/store/commit/index.js.map +1 -1
  389. package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts +4 -3
  390. package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts.map +1 -1
  391. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +2 -1
  392. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  393. package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -2
  394. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  395. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  396. package/core/dist/runtime/store/sqlite-connection.d.ts +2 -6
  397. package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
  398. package/core/dist/runtime/store/sqlite-connection.js +4 -12
  399. package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
  400. package/core/dist/runtime/store/storage-paths.d.ts +17 -0
  401. package/core/dist/runtime/store/storage-paths.d.ts.map +1 -0
  402. package/core/dist/runtime/store/storage-paths.js +52 -0
  403. package/core/dist/runtime/store/storage-paths.js.map +1 -0
  404. package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts +2 -1
  405. package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts.map +1 -1
  406. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +2 -1
  407. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  408. package/core/dist/runtime/story-a-demo.d.ts.map +1 -1
  409. package/core/dist/runtime/story-a-demo.js +4 -1
  410. package/core/dist/runtime/story-a-demo.js.map +1 -1
  411. package/core/dist/runtime/tools/agent-tool-contract.d.ts +1 -2
  412. package/core/dist/runtime/tools/agent-tool-contract.d.ts.map +1 -1
  413. package/core/dist/runtime/tools/agent-tool-contract.js +0 -2
  414. package/core/dist/runtime/tools/agent-tool-contract.js.map +1 -1
  415. package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts +0 -2
  416. package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts.map +1 -1
  417. package/core/dist/runtime/tools/artificer-l2-tool-contract.js +0 -2
  418. package/core/dist/runtime/tools/artificer-l2-tool-contract.js.map +1 -1
  419. package/core/dist/runtime/trajectory-retention.d.ts +257 -0
  420. package/core/dist/runtime/trajectory-retention.d.ts.map +1 -0
  421. package/core/dist/runtime/trajectory-retention.js +598 -0
  422. package/core/dist/runtime/trajectory-retention.js.map +1 -0
  423. package/core/dist/runtime/types/event-payload.d.ts +0 -2
  424. package/core/dist/runtime/types/event-payload.d.ts.map +1 -1
  425. package/core/dist/runtime/types/event-payload.js.map +1 -1
  426. package/core/dist/runtime/types/evidence-chain-contract.d.ts +66 -2
  427. package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
  428. package/core/dist/runtime/types/evidence-chain-contract.js +69 -4
  429. package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
  430. package/core/dist/runtime/types/hygiene-types.d.ts +0 -6
  431. package/core/dist/runtime/types/hygiene-types.d.ts.map +1 -1
  432. package/core/dist/runtime/types/hygiene-types.js.map +1 -1
  433. package/core/dist/runtime/types/index.d.ts +1 -1
  434. package/core/dist/runtime/types/index.d.ts.map +1 -1
  435. package/core/dist/runtime/types/index.js.map +1 -1
  436. package/core/dist/runtime/types/intervention-evidence-contract.d.ts +5 -5
  437. package/core/dist/runtime/types/intervention-evidence-contract.d.ts.map +1 -1
  438. package/core/dist/runtime/types/intervention-evidence-contract.js +0 -2
  439. package/core/dist/runtime/types/intervention-evidence-contract.js.map +1 -1
  440. package/core/dist/runtime/types/principle-dependency.d.ts +0 -2
  441. package/core/dist/runtime/types/principle-dependency.d.ts.map +1 -1
  442. package/core/dist/runtime/types/principle-dependency.js.map +1 -1
  443. package/core/dist/runtime/types/principle-lifecycle-event.d.ts +0 -2
  444. package/core/dist/runtime/types/principle-lifecycle-event.d.ts.map +1 -1
  445. package/core/dist/runtime/types/principle-lifecycle-event.js.map +1 -1
  446. package/core/dist/runtime/types/principle-schema.d.ts +0 -26
  447. package/core/dist/runtime/types/principle-schema.d.ts.map +1 -1
  448. package/core/dist/runtime/types/principle-schema.js +2 -2
  449. package/core/dist/runtime/types/principle-schema.js.map +1 -1
  450. package/core/dist/runtime/types/principle-tree-store.d.ts +0 -2
  451. package/core/dist/runtime/types/principle-tree-store.d.ts.map +1 -1
  452. package/core/dist/runtime/types/principle-tree-store.js.map +1 -1
  453. package/core/dist/runtime/types/principle-value-metrics.d.ts +0 -2
  454. package/core/dist/runtime/types/principle-value-metrics.d.ts.map +1 -1
  455. package/core/dist/runtime/types/principle-value-metrics.js.map +1 -1
  456. package/core/dist/runtime/types/rule-candidate-binding.d.ts +2 -1
  457. package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
  458. package/core/dist/telemetry-event.d.ts +2 -2
  459. package/core/dist/telemetry-event.d.ts.map +1 -1
  460. package/core/dist/telemetry-event.js +11 -0
  461. package/core/dist/telemetry-event.js.map +1 -1
  462. package/core/dist/trajectory-store.d.ts +9 -9
  463. package/core/dist/trajectory-store.d.ts.map +1 -1
  464. package/core/dist/trajectory-store.js +9 -12
  465. package/core/dist/trajectory-store.js.map +1 -1
  466. package/core/package.json +5 -1
  467. package/dist/installers/codex-host-installer.d.ts +9 -0
  468. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  469. package/dist/installers/codex-host-installer.js +127 -6
  470. package/dist/installers/codex-host-installer.js.map +1 -1
  471. package/dist/installers/mcp-binding-shape-mirror.d.ts +27 -0
  472. package/dist/installers/mcp-binding-shape-mirror.d.ts.map +1 -0
  473. package/dist/installers/mcp-binding-shape-mirror.js +105 -0
  474. package/dist/installers/mcp-binding-shape-mirror.js.map +1 -0
  475. package/dist/skill-catalog.d.ts +35 -0
  476. package/dist/skill-catalog.d.ts.map +1 -0
  477. package/dist/skill-catalog.js +85 -0
  478. package/dist/skill-catalog.js.map +1 -0
  479. package/dist/skill-delivery-parity.d.ts +22 -0
  480. package/dist/skill-delivery-parity.d.ts.map +1 -0
  481. package/dist/skill-delivery-parity.js +31 -0
  482. package/dist/skill-delivery-parity.js.map +1 -0
  483. package/dist/update/product-identity.d.ts.map +1 -1
  484. package/dist/update/product-identity.js +5 -1
  485. package/dist/update/product-identity.js.map +1 -1
  486. package/host-runtime/dist/active-principle-prompt.d.ts +13 -0
  487. package/host-runtime/dist/active-principle-prompt.js +87 -10
  488. package/host-runtime/dist/adaptive-decision-protocol.d.ts +129 -0
  489. package/host-runtime/dist/adaptive-decision-protocol.js +176 -0
  490. package/host-runtime/dist/adaptive-priority-provider.d.ts +38 -13
  491. package/host-runtime/dist/adaptive-priority-provider.js +70 -66
  492. package/host-runtime/dist/adaptive-selection.d.ts +71 -64
  493. package/host-runtime/dist/adaptive-selection.js +220 -329
  494. package/host-runtime/dist/adaptive-skip-decision.d.ts +26 -14
  495. package/host-runtime/dist/adaptive-skip-decision.js +33 -29
  496. package/host-runtime/dist/codex-disclosure.d.ts +12 -7
  497. package/host-runtime/dist/codex-disclosure.js +12 -7
  498. package/host-runtime/dist/codex-rule-context-provider.js +4 -1
  499. package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +8 -0
  500. package/host-runtime/dist/conversation-ingestion/pipeline.js +6 -1
  501. package/host-runtime/dist/conversation-ingestion/text-policy.d.ts +3 -4
  502. package/host-runtime/dist/conversation-ingestion/text-policy.js +3 -4
  503. package/host-runtime/dist/governance-observation-store.d.ts +73 -1
  504. package/host-runtime/dist/governance-observation-store.js +251 -14
  505. package/host-runtime/dist/governance-signal-admission.d.ts +19 -3
  506. package/host-runtime/dist/governance-signal-admission.js +12 -4
  507. package/host-runtime/dist/host-tool-declaration.d.ts +18 -2
  508. package/host-runtime/dist/host-tool-declaration.js +67 -11
  509. package/host-runtime/dist/host-tool-semantic-resolver.d.ts +7 -0
  510. package/host-runtime/dist/host-tool-semantic-resolver.js +22 -2
  511. package/host-runtime/dist/index.d.ts +3 -0
  512. package/host-runtime/dist/index.js +17 -0
  513. package/host-runtime/dist/production-rulehost-gate.d.ts +36 -1
  514. package/host-runtime/dist/production-rulehost-gate.js +106 -4
  515. package/host-runtime/dist/trajectory-retention.d.ts +147 -0
  516. package/host-runtime/dist/trajectory-retention.js +907 -0
  517. package/host-runtime/package.json +1 -1
  518. package/install-layout/dist/index.d.ts +9 -2
  519. package/install-layout/dist/index.js +26 -9
  520. package/install-layout/dist/mcp-binding-contract.d.ts +91 -0
  521. package/install-layout/dist/mcp-binding-contract.js +230 -0
  522. package/install-layout/package.json +1 -1
  523. package/package.json +4 -4
  524. package/pd-cli/dist/commands/build-trajectory-evidence.d.ts.map +1 -1
  525. package/pd-cli/dist/commands/build-trajectory-evidence.js +17 -11
  526. package/pd-cli/dist/commands/build-trajectory-evidence.js.map +1 -1
  527. package/pd-cli/dist/commands/codex-reconcile.d.ts +7 -0
  528. package/pd-cli/dist/commands/codex-reconcile.d.ts.map +1 -1
  529. package/pd-cli/dist/commands/codex-reconcile.js +11 -2
  530. package/pd-cli/dist/commands/codex-reconcile.js.map +1 -1
  531. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  532. package/pd-cli/dist/commands/codex-worker.js +35 -0
  533. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  534. package/pd-cli/dist/commands/command-helpers.d.ts +1 -1
  535. package/pd-cli/dist/commands/command-helpers.js +1 -1
  536. package/pd-cli/dist/commands/diagnose.js +1 -1
  537. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  538. package/pd-cli/dist/commands/errors-list.d.ts +1 -1
  539. package/pd-cli/dist/commands/errors-list.js +1 -1
  540. package/pd-cli/dist/commands/health-ingestion.d.ts +96 -0
  541. package/pd-cli/dist/commands/health-ingestion.d.ts.map +1 -0
  542. package/pd-cli/dist/commands/health-ingestion.js +473 -0
  543. package/pd-cli/dist/commands/health-ingestion.js.map +1 -0
  544. package/pd-cli/dist/commands/health-mcp.d.ts +23 -1
  545. package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
  546. package/pd-cli/dist/commands/health-mcp.js +81 -22
  547. package/pd-cli/dist/commands/health-mcp.js.map +1 -1
  548. package/pd-cli/dist/commands/health.d.ts +1 -1
  549. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  550. package/pd-cli/dist/commands/health.js +22 -5
  551. package/pd-cli/dist/commands/health.js.map +1 -1
  552. package/pd-cli/dist/commands/principles-stats.d.ts +1 -1
  553. package/pd-cli/dist/commands/principles-stats.js +1 -1
  554. package/pd-cli/dist/commands/trajectory-retention.d.ts +23 -0
  555. package/pd-cli/dist/commands/trajectory-retention.d.ts.map +1 -0
  556. package/pd-cli/dist/commands/trajectory-retention.js +159 -0
  557. package/pd-cli/dist/commands/trajectory-retention.js.map +1 -0
  558. package/pd-cli/dist/commands/workbuddy-setup.d.ts +69 -0
  559. package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -0
  560. package/pd-cli/dist/commands/workbuddy-setup.js +379 -0
  561. package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -0
  562. package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
  563. package/pd-cli/dist/commands/workbuddy-worker.js +42 -6
  564. package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
  565. package/pd-cli/dist/index.d.ts +1 -7
  566. package/pd-cli/dist/index.d.ts.map +1 -1
  567. package/pd-cli/dist/index.js +15 -1201
  568. package/pd-cli/dist/index.js.map +1 -1
  569. package/pd-cli/dist/program.d.ts +17 -0
  570. package/pd-cli/dist/program.d.ts.map +1 -0
  571. package/pd-cli/dist/program.js +1263 -0
  572. package/pd-cli/dist/program.js.map +1 -0
  573. package/pd-cli/dist/services/delivery-surfaces.d.ts.map +1 -1
  574. package/pd-cli/dist/services/delivery-surfaces.js +7 -5
  575. package/pd-cli/dist/services/delivery-surfaces.js.map +1 -1
  576. package/pd-cli/dist/services/demo-story-a-runner.js +1 -1
  577. package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
  578. package/pd-cli/dist/services/version-report.d.ts.map +1 -1
  579. package/pd-cli/dist/services/version-report.js +35 -5
  580. package/pd-cli/dist/services/version-report.js.map +1 -1
  581. package/pd-cli/package.json +1 -1
  582. package/pd-mcp-server/dist/version.d.ts +1 -1
  583. package/pd-mcp-server/dist/version.js +1 -1
  584. package/pd-mcp-server/package.json +3 -1
  585. package/plugin/dist/bundle.js +529 -468
  586. package/plugin/dist/constants/tools.d.ts +8 -1
  587. package/plugin/dist/core/experiment-workspace-guard.d.ts +25 -0
  588. package/plugin/dist/core/trajectory-retention-trigger.d.ts +13 -0
  589. package/plugin/dist/core/trajectory.d.ts +14 -0
  590. package/plugin/dist/hooks/gate-block-helper.d.ts +17 -0
  591. package/plugin/dist/hooks/gate.d.ts +6 -1
  592. package/plugin/dist/host-runtime/openclaw-host-runtime.d.ts +1 -0
  593. package/plugin/dist/index.d.ts +5 -0
  594. package/plugin/dist/openclaw.plugin.json +1 -1
  595. package/plugin/dist/rulehost-evidence.js +29 -23
  596. package/plugin/dist/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
  597. package/plugin/dist/templates/langs/en/skills/pd-control/SKILL.md +7 -6
  598. package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
  599. package/plugin/dist/templates/langs/en/skills/pd-review/SKILL.md +15 -1
  600. package/plugin/dist/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
  601. package/plugin/dist/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
  602. package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
  603. package/plugin/dist/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
  604. package/plugin/openclaw.plugin.json +1 -1
  605. package/plugin/package.json +1 -1
  606. package/plugin/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
  607. package/plugin/templates/langs/en/skills/pd-control/SKILL.md +7 -6
  608. package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
  609. package/plugin/templates/langs/en/skills/pd-review/SKILL.md +15 -1
  610. package/plugin/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
  611. package/plugin/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
  612. package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
  613. package/plugin/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
  614. package/release-manager/dist/installers/codex-host-installer.js +127 -6
  615. package/release-manager/dist/installers/mcp-binding-shape-mirror.js +105 -0
  616. package/release-manager/dist/update/product-identity.js +5 -1
  617. package/release-manager/package.json +1 -1
  618. package/workbuddy-adapter/dist/codec/input-decoder.d.ts +10 -0
  619. package/workbuddy-adapter/dist/codec/input-decoder.js +62 -5
  620. package/workbuddy-adapter/dist/host-adapter.js +1 -0
  621. package/workbuddy-adapter/dist/index.d.ts +1 -0
  622. package/workbuddy-adapter/dist/index.js +1 -0
  623. package/workbuddy-adapter/dist/ingestion/catch-up.d.ts +36 -0
  624. package/workbuddy-adapter/dist/ingestion/catch-up.js +166 -0
  625. package/workbuddy-adapter/dist/ingestion/encode-cwd.d.ts +6 -0
  626. package/workbuddy-adapter/dist/ingestion/encode-cwd.js +39 -0
  627. package/workbuddy-adapter/dist/ingestion/index.d.ts +13 -0
  628. package/workbuddy-adapter/dist/ingestion/index.js +13 -0
  629. package/workbuddy-adapter/dist/ingestion/ingestion.d.ts +46 -0
  630. package/workbuddy-adapter/dist/ingestion/ingestion.js +135 -0
  631. package/workbuddy-adapter/dist/ingestion/transcript-decoder.d.ts +70 -0
  632. package/workbuddy-adapter/dist/ingestion/transcript-decoder.js +554 -0
  633. package/workbuddy-adapter/dist/ingestion/transcript-path.d.ts +39 -0
  634. package/workbuddy-adapter/dist/ingestion/transcript-path.js +117 -0
  635. package/workbuddy-adapter/dist/ingestion/transcript-source.d.ts +15 -0
  636. package/workbuddy-adapter/dist/ingestion/transcript-source.js +152 -0
  637. package/workbuddy-adapter/dist/pd-hook.d.ts +8 -0
  638. package/workbuddy-adapter/dist/pd-hook.js +59 -2
  639. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -0
  640. package/workbuddy-adapter/dist/worker/workspace-worker.js +46 -17
  641. package/workbuddy-adapter/package.json +1 -1
  642. package/workbuddy-adapter/plugin/hooks/hooks.json +11 -0
  643. package/workbuddy-adapter/plugin/skills/pd-cli-operator/SKILL.md +57 -19
  644. package/workbuddy-adapter/plugin/skills/pd-control/SKILL.md +21 -9
  645. package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +72 -61
  646. package/workbuddy-adapter/plugin/skills/pd-review/SKILL.md +27 -12
@@ -1,1208 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * pd CLI — Principles Disciple command-line interface.
3
+ * Process entry for the `pd` command.
4
4
  *
5
- * Usage:
6
- * pd pain record --reason <text> [--score N] [--source manual]
5
+ * The command tree lives in `./program.js` so that tests and other library
6
+ * consumers can import it WITHOUT executing the CLI. This file is the only
7
+ * place that parses argv, and it does so unconditionally.
8
+ *
9
+ * Why unconditional (regression introduced by #2555): every real entry reaches
10
+ * the CLI through this file — `package.json#bin`, the installer's
11
+ * `pd` / `pd.cmd` / `pd.ps1` shims, and any loader shim that wraps it
12
+ * (`import 'file://…/dist/index.js'`). An `argv[1] === import.meta.url` guard
13
+ * cannot see the loader-shim shape, because argv[1] is then the wrapper: the
14
+ * process exits 0 having done nothing. Import safety is guaranteed by the
15
+ * module boundary instead — import `./program.js` for the tree, never this
16
+ * file.
7
17
  */
8
- import { Command, Option } from 'commander';
9
- import { handlePainRecord } from './commands/pain-record.js';
10
- import { handlePainExplicit } from './commands/pain-explicit.js';
11
- import { registerPainRetryCommand } from './commands/pain-retry.js';
12
- import { handlePainRecall, parsePainRecallLimit } from './commands/pain-recall.js';
13
- import { handlePainEvidence } from './commands/pain-evidence.js';
14
- import { handlePainList } from './commands/pain-list.js';
15
- import { handleSamplesList } from './commands/samples-list.js';
16
- import { handleSamplesReview } from './commands/samples-review.js';
17
- import { handleEvolutionTasksList } from './commands/evolution-tasks-list.js';
18
- import { handleEvolutionTasksShow } from './commands/evolution-tasks-show.js';
19
- import { registerHealthCommand } from './commands/health.js';
20
- import { registerVersionCommand } from './commands/version.js';
21
- import { buildVersionReport, formatShortVersion, VersionReportError } from './services/version-report.js';
22
- import { handleTaskShow, registerTaskListCommand } from './commands/task.js';
23
- import { handleRunList, handleRunShow } from './commands/run.js';
24
- import { handleTrajectoryLocate } from './commands/trajectory.js';
25
- import { handleHistoryQuery } from './commands/history.js';
26
- import { handleContextBuild } from './commands/context.js';
27
- import { handleLegacyImportOpenClaw } from './commands/legacy-import.js';
28
- import { handleLegacyCleanup } from './commands/legacy-cleanup.js';
29
- import { handleDiagnoseStatus, handleDiagnoseRun } from './commands/diagnose.js';
30
- import { registerRuntimeProbeCommand } from './commands/runtime.js';
31
- import { handleFlowShow } from './commands/flow.js';
32
- import { handleTraceShow } from './commands/trace.js';
33
- import { handlePruningReport, handlePruningExplain, handlePruningOrphans } from './commands/runtime-pruning.js';
34
- import { handleRuntimeHealthSnapshot } from './commands/runtime-health-snapshot.js';
35
- import { handleRuntimeUat } from './commands/runtime-uat.js';
36
- import { handleRuntimeInternalizationQueue } from './commands/runtime-internalization-queue.js';
37
- import { handleRuntimeInternalizationWakeOnce } from './commands/runtime-internalization-wake-once.js';
38
- import { handleRuntimeInternalizationRunOnce } from './commands/runtime-internalization-run-once.js';
39
- import { handleRuntimeInternalizationRetry } from './commands/runtime-internalization-retry.js';
40
- import { registerRuntimeInternalizationAuditArtificerEvidenceCommand } from './commands/runtime-internalization-audit-artificer-evidence.js';
41
- import { registerRuntimeInternalizationEvidenceCommand } from './commands/runtime-internalization-evidence.js';
42
- import { registerRunRuleHostCommand } from './commands/runtime-internalization-run-rulehost.js';
43
- import { handleCandidateList, handleCandidateShow, handleCandidateIntake, handleCandidateReview, handleCandidateAudit, handleCandidateRepair, handleCandidateRoute, handleCandidateInternalize, handleCandidateInternalizationBackfill } from './commands/candidate.js';
44
- import { handleArtifactShow } from './commands/artifact.js';
45
- import { handleRuntimeCanary } from './commands/runtime-canary.js';
46
- import { handleRuntimeSyntheticBaseline } from './commands/runtime-synthetic-baseline.js';
47
- import { handleRuntimePainFlood } from './commands/runtime-pain-flood-simulation.js';
48
- import { handleRuntimeInternalizationIntegrity } from './commands/runtime-internalization-integrity.js';
49
- import { handleRuntimeInternalizationIntegrityRepair } from './commands/runtime-internalization-integrity-repair.js';
50
- import { handleRuntimeInternalizationEnqueueSuccessors } from './commands/runtime-internalization-enqueue-successors.js';
51
- import { handleRuntimeDiagnosticsExport } from './commands/runtime-diagnostics-export.js';
52
- import { handleMcpLogsExport } from './commands/mcp-logs-export.js';
53
- import { registerRuntimeCompatibilityScanCommand } from './commands/runtime-compatibility-scan.js';
54
- import { handleRuntimeRecoverySweep } from './commands/runtime-recovery.js';
55
- import { handleRuntimeRecoveryFailedTasks } from './commands/runtime-recovery-failed-tasks.js';
56
- import { registerRuntimeRecoveryFailedTaskCommand } from './commands/runtime-recovery-failed-task.js';
57
- import { handleRuntimeArtifactRepair } from './commands/runtime-artifact-repair.js';
58
- import { handleRuntimeActivationDeactivate, handleRuntimeActivationList, handleRuntimeActivationEdit, registerRuntimeActivationPromoteCommand, registerRuntimeActivationDeactivateCommand, registerRuntimeActivationListCommand, registerRuntimeActivationJournalCommand, registerRuntimeActivationLinkCommand, registerRuntimeActivationDispatchCommand, registerRuntimeActivationApproveCommand, } from './commands/runtime-activation.js';
59
- import { handleProvenChannelBaseline } from './commands/proven-channel-baseline.js';
60
- import { handleDemoStoryA } from './commands/demo-story-a.js';
61
- import { handleRuntimeFeaturesStatus } from './commands/runtime-features.js';
62
- import { handleConfigDoctor } from './commands/config-doctor.js';
63
- import { registerMvpCommands } from './commands/mvp-smoke.js';
64
- import { registerRulecodeCommand } from './commands/rulecode.js';
65
- import { registerIntentCommand } from './commands/intent.js';
66
- import { registerErrorsListCommand } from './commands/errors-list.js';
67
- import { registerPrinciplesCommand } from './commands/principles-stats.js';
68
- import { registerTelemetryCommand } from './commands/telemetry.js';
69
- import { createRequire } from 'module';
70
- const require = createRequire(import.meta.url);
71
- const pkg = require('../package.json');
72
- const program = new Command();
73
- // SPEC §12: `pd --version` prints the canonical product version when a
74
- // supported installation exists; a development checkout falls back to the
75
- // CLI package version with an explicit marker instead of impersonating an
76
- // installed release.
77
- function handleVersionFlag(args) {
78
- if (!args.includes('--version') && !args.includes('-V'))
79
- return false;
80
- try {
81
- console.log(formatShortVersion(buildVersionReport()));
82
- return true;
83
- }
84
- catch (error) {
85
- if (error instanceof VersionReportError && error.reason === 'not_installed') {
86
- console.log(`Principles Disciple ${pkg.version} (development-checkout)`);
87
- return true;
88
- }
89
- if (error instanceof VersionReportError) {
90
- console.error(error.message);
91
- console.error(`Next: ${error.nextAction}`);
92
- process.exitCode = 1;
93
- return true;
94
- }
95
- throw error;
96
- }
97
- }
98
- program
99
- .name('pd')
100
- .description('PD CLI — Pain recording, sample management, and evolution task history')
101
- .option('-V, --version', 'output the canonical PD product version')
102
- .enablePositionalOptions();
103
- registerVersionCommand(program);
104
- const painCmd = program
105
- .command('pain')
106
- .description('Pain signal management');
107
- painCmd
108
- .command('record')
109
- .description('Record a pain signal via Runtime v2 bridge')
110
- .option('-r, --reason <text>', 'Reason for the pain signal (required)')
111
- .option('-s, --score <number>', 'Pain score 0-100', parseInt)
112
- .option('-S, --source <text>', 'Source of the pain signal', 'manual')
113
- .option('-w, --workspace <path>', 'Workspace directory')
114
- .option('--session <id>', 'Session ID to bind (validated against this workspace\'s trajectory.db; without it the record is unbound: no trajectory evidence, candidates likely gated by the admission threshold)')
115
- .option('--host <kind>', 'PRI-743: explicit host attribution (openclaw | codex). openclaw = default attribution without the disclosure warning; codex requires the real Codex lineage (--rollout-id, --host-turn-id, and --session as the root session).', undefined)
116
- .option('--rollout-id <id>', 'PRI-743: Codex rollout identity — required by --host codex', undefined)
117
- .option('--host-turn-id <id>', 'PRI-743: Codex turn id — required by --host codex', undefined)
118
- .option('--logical-key <key>', 'PRI-743: Codex logical observation key override for --host codex (default: codex|<rollout-id>|<host-turn-id>|user)', undefined)
119
- .option('--owner-statement <text>', 'SPEC-CODEX-PAIN-CLOSURE-001 CR-02: the Owner verbatim statement (explicit submission, max 500 chars, rejected when longer — never truncated). It satisfies only the empty-input-evidence admission condition and is disclosed as an unverified owner_statement.', undefined)
120
- .option('--wait', 'Wait for diagnosis to complete (sync mode, overrides async flag)')
121
- .option('--json', 'Output raw JSON')
122
- .action(async (opts) => {
123
- await handlePainRecord(opts);
124
- });
125
- painCmd
126
- .command('explicit')
127
- .description('Register an explicit Owner pain statement from the live Codex turn context (agent-assisted, no prefix; same admission chain as PD记录痛苦: — takes no lineage flags)')
128
- .option('--statement <text>', 'Owner verbatim statement (1-500 chars, required; rejected when longer — never truncated)')
129
- .option('-w, --workspace <path>', 'Workspace directory')
130
- .option('--json', 'Output raw JSON')
131
- .action(async (opts) => {
132
- await handlePainExplicit(opts);
133
- });
134
- registerPainRetryCommand(painCmd);
135
- painCmd
136
- .command('list')
137
- .description('List canonical pain events with host attribution (PRI-640)')
138
- .option('-w, --workspace <path>', 'Workspace directory')
139
- .option('-l, --limit <number>', 'Max entries to show (default: 20)', parseInt)
140
- .option('--host <kind>', 'Filter by host: openclaw | codex | workbuddy | unknown')
141
- .option('--json', 'Output raw JSON')
142
- .action(async (opts) => {
143
- await handlePainList(opts);
144
- });
145
- painCmd
146
- .command('evidence')
147
- .description('Show recent TRIGGER_DECISION log entries — pain admission gate decisions only (PEAT-B2)')
148
- .option('-w, --workspace <path>', 'Workspace directory')
149
- .option('-l, --limit <number>', 'Max entries to show (default: 20)', parseInt)
150
- .option('--json', 'Output raw JSON')
151
- .action(async (opts) => {
152
- await handlePainEvidence(opts);
153
- });
154
- // SPEC-PD-PAIN-RECALL-CLI-001: on-demand, read-only recall of the historical
155
- // pains a principle verifiably derives from. Uses .option() (not
156
- // .requiredOption()) so missing-flag errors produce structured JSON via the
157
- // handler (same convention as activation edit, P2 #5).
158
- painCmd
159
- .command('recall')
160
- .description('Recall historical pains verifiably associated with a principle (read-only)')
161
- .option('--principle-id <id>', 'Canonical ledger principle id (required)')
162
- .option('--pain-id <id>', 'Filter to one pain within this principle\'s verified associations')
163
- .option('--context <text>', 'Current question — deterministic local re-ranking only, never creates associations')
164
- // Strict integer parser (SPEC §3.3): non-integers become NaN and are
165
- // rejected by the handler; never `parseInt` — Commander passes the previous
166
- // option value as the parser's second argument, which parseInt would treat
167
- // as a radix on repeated flags.
168
- .option('-l, --limit <n>', 'Max results (default 3, 1-10)', parsePainRecallLimit)
169
- .option('-w, --workspace <path>', 'Workspace directory')
170
- .option('--json', 'Output raw JSON')
171
- .action(async (opts) => {
172
- await handlePainRecall(opts);
173
- });
174
- const samplesCmd = program
175
- .command('samples', { hidden: true })
176
- .description('Correction sample management');
177
- samplesCmd
178
- .command('list')
179
- .description('List correction samples')
180
- .option('-s, --status <pending|approved|rejected>', 'Filter by review status', 'pending')
181
- .action(async (opts) => {
182
- await handleSamplesList(opts);
183
- });
184
- samplesCmd
185
- .command('review')
186
- .description('Review a correction sample')
187
- .argument('<sample-id>', 'The sample ID to review')
188
- .argument('<approve|reject>', 'Review decision')
189
- .argument('[note]', 'Optional review note')
190
- .action(async (sampleId, decision, note) => {
191
- if (decision !== 'approve' && decision !== 'reject') {
192
- console.error('Error: decision must be "approve" or "reject"');
193
- process.exit(1);
194
- }
195
- await handleSamplesReview({ sampleId, decision: decision === 'approve' ? 'approved' : 'rejected', note });
196
- });
197
- // ── Evolution task reader (hidden) ────────────────────────────────────────────
198
- // PRI-752 review: the worker is gone (flag retired to `gone`), but this
199
- // read-only surface stays for historical `evolution_tasks` rows in already-
200
- // provisioned workspaces — data-retention disposition is a separate Owner
201
- // decision (PRI-737 reality audit §7.3). Table schema + quality-scorecard
202
- // reader are retained accordingly.
203
- const evolutionCmd = program
204
- .command('evolution', { hidden: true })
205
- .description('Evolution task management (historical data reader)');
206
- const tasksCmd = evolutionCmd
207
- .command('tasks')
208
- .description('List and show evolution tasks');
209
- tasksCmd
210
- .command('list')
211
- .description('List evolution tasks')
212
- .option('-s, --status <status>', 'Filter by status (pending|in_progress|completed|all)', 'all')
213
- .option('-l, --limit <number>', 'Maximum tasks to return', parseInt, 50)
214
- .option('-f, --date-from <date>', 'Filter tasks created on or after this date')
215
- .option('-t, --date-to <date>', 'Filter tasks created on or before this date')
216
- .action(async (opts) => {
217
- await handleEvolutionTasksList(opts);
218
- });
219
- tasksCmd
220
- .command('show')
221
- .description('Show full details for an evolution task')
222
- .argument('<id>', 'Task ID (numeric or string taskId)')
223
- .action(async (id, _opts) => {
224
- await handleEvolutionTasksShow({ id });
225
- });
226
- registerHealthCommand(program);
227
- // ── Anonymous Product Telemetry v1 control plane (PRI-595~603) ────────────────
228
- registerTelemetryCommand(program);
229
- // ── Runtime v2 task/run commands ──────────────────────────────────────────────鈹€鈹€鈹€鈹€鈹€鈹€
230
- const rtTaskCmd = program
231
- .command('task')
232
- .description('Runtime v2 task inspection');
233
- registerTaskListCommand(rtTaskCmd);
234
- rtTaskCmd
235
- .command('show <taskId>')
236
- .description('Show detailed task information')
237
- .option('-w, --workspace <path>', 'Workspace directory')
238
- .option('--json', 'Output raw JSON')
239
- .action(async (taskId, opts) => {
240
- await handleTaskShow({ id: taskId, json: opts.json, workspace: opts.workspace });
241
- });
242
- const rtRunCmd = program
243
- .command('run', { hidden: true })
244
- .description('Runtime v2 run inspection');
245
- rtRunCmd
246
- .command('list <taskId>')
247
- .description('List all runs for a task')
248
- .option('-w, --workspace <path>', 'Workspace directory')
249
- .action(async (taskId, opts) => {
250
- await handleRunList({ taskId, workspace: opts.workspace });
251
- });
252
- rtRunCmd
253
- .command('show <runId>')
254
- .description('Show detailed run information')
255
- .option('-w, --workspace <path>', 'Workspace directory')
256
- .action(async (runId, opts) => {
257
- await handleRunShow({ id: runId, workspace: opts.workspace });
258
- });
259
- // ── Runtime v2 trajectory/history/context commands ────────────────────────────鈹€鈹€
260
- const trajectoryCmd = program
261
- .command('trajectory', { hidden: true })
262
- .description('Runtime v2 trajectory location');
263
- trajectoryCmd
264
- .command('locate')
265
- .description('Locate a trajectory by task ID, run ID, or time range')
266
- .option('-t, --task <taskId>', 'Locate by task ID')
267
- .option('-r, --run <runId>', 'Locate by run ID')
268
- .option('--from <date>', 'Start of time range (ISO string)')
269
- .option('--to <date>', 'End of time range (ISO string)')
270
- .option('-w, --workspace <path>', 'Workspace directory')
271
- .option('--json', 'Output raw JSON')
272
- .action(async (opts) => {
273
- await handleTrajectoryLocate(opts);
274
- });
275
- const historyCmd = program
276
- .command('history', { hidden: true })
277
- .description('Runtime v2 history query');
278
- historyCmd
279
- .command('query <taskId>')
280
- .description('Query run history for a task')
281
- .option('-l, --limit <number>', 'Limit number of entries', parseInt)
282
- .option('-c, --cursor <cursor>', 'Pagination cursor')
283
- .option('--from <date>', 'Start of time range (ISO string)')
284
- .option('--to <date>', 'End of time range (ISO string)')
285
- .option('-w, --workspace <path>', 'Workspace directory')
286
- .option('--json', 'Output raw JSON')
287
- .action(async (taskId, opts) => {
288
- await handleHistoryQuery(taskId, opts);
289
- });
290
- const contextCmd = program
291
- .command('context', { hidden: true })
292
- .description('Runtime v2 context assembly');
293
- contextCmd
294
- .command('build <taskId>')
295
- .description('Assemble diagnostician context for a task')
296
- .option('-w, --workspace <path>', 'Workspace directory')
297
- .option('--json', 'Output raw JSON')
298
- .action(async (taskId, opts) => {
299
- await handleContextBuild(taskId, opts);
300
- });
301
- // ── Legacy import command ──────────────────────────────────────────────────────鈹€鈹€鈹€鈹€鈹€鈹€鈹€
302
- const legacyCmd = program
303
- .command('legacy', { hidden: true })
304
- .description('Legacy data management (import and cleanup)');
305
- const importCmd = legacyCmd.command('import');
306
- importCmd
307
- .command('openclaw')
308
- .description('Import OpenClaw legacy data into PD Runtime v2 SQLite. ' +
309
- 'Run this once per workspace before using trajectory/history/context commands.')
310
- .option('-w, --workspace <path>', 'Workspace directory (required)')
311
- .option('--json', 'Output raw JSON')
312
- .action(async (opts) => {
313
- await handleLegacyImportOpenClaw(opts);
314
- });
315
- // ── Diagnostician run/status commands ─────────────────────────────────────────鈹€鈹€鈹€鈹€
316
- const diagnoseCmd = program
317
- .command('diagnose')
318
- .description('Diagnostician execution and status inspection');
319
- diagnoseCmd
320
- .command('status')
321
- .description('Inspect diagnostician task status')
322
- .requiredOption('-t, --task-id <taskId>', 'Task ID to inspect')
323
- .option('-w, --workspace <path>', 'Workspace directory')
324
- .option('--stalled-threshold <seconds>', 'Age threshold in seconds for classifying task as stalled')
325
- .option('--json', 'Output raw JSON')
326
- .action(async (opts) => {
327
- await handleDiagnoseStatus(opts);
328
- });
329
- diagnoseCmd
330
- .command('run')
331
- .description('Execute diagnostician runner for a task')
332
- .requiredOption('-t, --task-id <taskId>', 'Task ID to execute')
333
- .option('-w, --workspace <path>', 'Workspace directory')
334
- .option('-r, --runtime <kind>', "Runtime kind: 'pi-ai', 'test-double'. If omitted, resolved from .pd/config.yaml; refuses if no binding (no test-double default).")
335
- .option('--provider <name>', 'LLM provider (e.g., openrouter) — for pi-ai, falls back to policy')
336
- .option('--model <id>', 'Model ID (e.g., anthropic/claude-sonnet-4) — for pi-ai, falls back to policy')
337
- .option('--apiKeyEnv <name>', 'Env var name for API key — for pi-ai, falls back to policy')
338
- .option('--baseUrl <url>', 'Custom base URL — for pi-ai, falls back to policy')
339
- .option('--maxRetries <n>', 'Max retry attempts for LLM failures — for pi-ai, falls back to policy', parseInt)
340
- .option('--timeoutMs <ms>', 'Timeout in milliseconds — for pi-ai, falls back to policy', parseInt)
341
- .option('--no-intake', 'Skip candidate intake after successful diagnosis')
342
- .option('--preflight', 'Read-only check that a run would be accepted (no lease, no state write, no model call)')
343
- .option('--json', 'Output raw JSON')
344
- .action(async (opts) => {
345
- await handleDiagnoseRun(opts);
346
- });
347
- // ── Runtime probe command (HG-01 HARD GATE) ───────────────────────────────────鈹€鈹€鈹€鈹€
348
- const runtimeCmd = program
349
- .command('runtime')
350
- .description('Runtime inspection and health checks');
351
- runtimeCmd
352
- .command('canary', { hidden: true })
353
- .description('One-shot control plane health canary')
354
- .option('-w, --workspace <path>', 'Workspace directory')
355
- .option('--json', 'Output raw JSON')
356
- .action(async (opts) => {
357
- await handleRuntimeCanary({ workspace: opts.workspace, json: opts.json });
358
- });
359
- // pd runtime init — Initialize all PD SQLite databases for a workspace.
360
- // Lazy import: avoids loading `principles-disciple` at module init time, which
361
- // would crash `pd --version` in packaged installs where the plugin's transitive
362
- // deps are not resolvable from pd-cli's node_modules. The import only executes
363
- // when `pd runtime init` is actually invoked.
364
- runtimeCmd
365
- .command('init')
366
- .description('Initialize all PD SQLite databases (state.db, trajectory.db)')
367
- .option('-w, --workspace <path>', 'Workspace directory')
368
- .option('--dry-run', 'Show what would be initialized without writing (default)')
369
- .option('--confirm', 'Actually initialize the databases (required to write)')
370
- .option('--json', 'Output raw JSON')
371
- .action(async (opts) => {
372
- const { handleRuntimeInit } = await import('./commands/runtime-init.js');
373
- await handleRuntimeInit({
374
- workspace: opts.workspace,
375
- dryRun: opts.dryRun === true,
376
- confirm: opts.confirm === true,
377
- json: opts.json === true,
378
- });
379
- });
380
- registerRuntimeCompatibilityScanCommand(runtimeCmd);
381
- const synthCmd = runtimeCmd
382
- .command('synthetic', { hidden: true })
383
- .description('Synthetic workload baseline commands');
384
- synthCmd
385
- .command('baseline')
386
- .description('Run synthetic PD workload baseline (PRI-206) — deterministic, no LLM required')
387
- .option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
388
- .option('--json', 'Output raw JSON')
389
- .action(async (opts) => {
390
- await handleRuntimeSyntheticBaseline({ workspace: opts.workspace, json: opts.json });
391
- });
392
- synthCmd
393
- .command('flood')
394
- .description('Run pain flood simulation (PRI-208) — deterministic dedup/stress test, no LLM required')
395
- .option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
396
- .option('--json', 'Output raw JSON')
397
- .option('--identical-count <n>', 'Number of identical pain signals (default: 10)', parseInt)
398
- .option('--similar-count <n>', 'Number of similar pain signals (default: 10)', parseInt)
399
- .option('--stress-count <n>', 'Number of stress test pain signals (default: 50)', parseInt)
400
- .action(async (opts) => {
401
- await handleRuntimePainFlood({
402
- workspace: opts.workspace,
403
- json: opts.json,
404
- identicalCount: opts.identicalCount,
405
- similarCount: opts.similarCount,
406
- stressCount: opts.stressCount,
407
- });
408
- });
409
- synthCmd
410
- .command('proven-channel')
411
- .description('Run MVP activation continuity baseline (PRI-240) — deterministic, no LLM required')
412
- .option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
413
- .option('--json', 'Output raw JSON')
414
- .option('--channels <channels>', 'Comma-separated channel list (prompt,code_tool_hook,defer_archive)')
415
- .action(async (opts) => {
416
- await handleProvenChannelBaseline({
417
- workspace: opts.workspace,
418
- json: opts.json,
419
- channels: opts.channels,
420
- });
421
- });
422
- runtimeCmd
423
- .command('features')
424
- .description('Show feature flag status (PRI-239)')
425
- .option('-w, --workspace <path>', 'Workspace directory')
426
- .option('--json', 'Output raw JSON')
427
- .action(async (opts) => {
428
- await handleRuntimeFeaturesStatus({
429
- workspace: opts.workspace,
430
- json: opts.json,
431
- });
432
- });
433
- // ── PRI-455: Promoted owner commands (trace + activation) ────────────────────
434
- // These are promoted from runtime subcommands to top-level for discoverability.
435
- // The old paths (pd runtime trace show, pd runtime activation list) remain as
436
- // hidden aliases — they still work but are not shown in --help.
437
- const traceTopCmd = program
438
- .command('trace')
439
- .description('Trace full pain-to-ledger chain (Story A\' Step 6: Observe)');
440
- traceTopCmd
441
- .command('show')
442
- .description('Show full trace for a pain ID')
443
- .requiredOption('--pain-id <id>', 'Pain ID to trace')
444
- .option('-w, --workspace <path>', 'Workspace directory')
445
- .option('--json', 'Output raw JSON')
446
- .action(async (opts) => {
447
- await handleTraceShow({ painId: opts.painId, workspace: opts.workspace, json: opts.json });
448
- });
449
- const activationTopCmd = program
450
- .command('activation')
451
- .description('Activation management — list active activations, deactivate (Story A\' Steps 5-6)');
452
- registerRuntimeActivationListCommand(activationTopCmd);
453
- // PRI-1109: read-only journal reconciliation (no writes, no model runs).
454
- registerRuntimeActivationJournalCommand(activationTopCmd);
455
- // PRI-1114: read-only behavior evidence linkage (no writes, no model runs).
456
- registerRuntimeActivationLinkCommand(activationTopCmd);
457
- registerRuntimeActivationDeactivateCommand(activationTopCmd);
458
- // Bug-M fix: CLI closed loop — approve a pending approval and dispatch its activation.
459
- // Reuses the same ApprovalQueue + ApprovalCompletionService as the Console model.
460
- registerRuntimeActivationApproveCommand(activationTopCmd);
461
- registerRuntimeActivationPromoteCommand(activationTopCmd);
462
- const configCmd = program
463
- .command('config')
464
- .description('PD configuration discovery and diagnosis');
465
- configCmd
466
- .command('doctor')
467
- .description('Show PD + OpenClaw config locations, feature flags, and provider connectivity (PRI-299)')
468
- .option('-w, --workspace <path>', 'Workspace directory')
469
- .option('--json', 'Output raw JSON')
470
- .action(async (opts) => {
471
- await handleConfigDoctor({ workspace: opts.workspace, json: opts.json });
472
- });
473
- const demoCmd = program
474
- .command('demo', { hidden: true })
475
- .description('Demo scenarios for MVP validation');
476
- demoCmd
477
- .command('story-a')
478
- .alias('first-principle')
479
- .description('Run Story A\'s proven-channel demo (PRI-246) — full evidence→proposal→approval→activation→observation chain')
480
- .option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
481
- .option('--json', 'Output raw JSON')
482
- .option('--channels <channels>', 'Comma-separated channel list (prompt,code_tool_hook,defer_archive)')
483
- .option('--allow-demo-write-to-existing-workspace', 'Developer override: permit writing demo artifacts into a workspace that already contains PD state (demo isolation guard)')
484
- .action(async (opts) => {
485
- await handleDemoStoryA({
486
- workspace: opts.workspace,
487
- json: opts.json,
488
- channels: opts.channels,
489
- allowDemoWriteToExistingWorkspace: opts.allowDemoWriteToExistingWorkspace === true,
490
- });
491
- });
492
- registerRuntimeProbeCommand(runtimeCmd);
493
- const flowCmd = runtimeCmd
494
- .command('flow', { hidden: true })
495
- .description('Workflow funnel inspection');
496
- flowCmd
497
- .command('show')
498
- .description('Show all workflow funnel definitions from workflows.yaml')
499
- .option('-w, --workspace <path>', 'Workspace directory')
500
- .option('--json', 'Output raw JSON')
501
- .action(async (opts) => {
502
- await handleFlowShow(opts);
503
- });
504
- const traceCmd = runtimeCmd
505
- .command('trace', { hidden: true })
506
- .description('Trace full pain-to-ledger chain (hidden alias — use pd trace show)');
507
- traceCmd
508
- .command('show')
509
- .description('Show full trace for a pain ID')
510
- .requiredOption('--pain-id <id>', 'Pain ID to trace')
511
- .option('-w, --workspace <path>', 'Workspace directory')
512
- .option('--json', 'Output raw JSON')
513
- .action(async (opts) => {
514
- await handleTraceShow({ painId: opts.painId, workspace: opts.workspace, json: opts.json });
515
- });
516
- runtimeCmd
517
- .command('uat', { hidden: true })
518
- .description('Runtime V2 chain UAT baseline runner')
519
- .option('-w, --workspace <path>', 'Workspace directory')
520
- .option('--count <n>', 'Number of iterations (default: 5, max: 50)', parseInt)
521
- .option('--min-success-rate <rate>', 'Minimum success rate threshold (default: 1.0)', parseFloat)
522
- .option('--json', 'Output machine-readable JSON summary')
523
- .option('--allow-production-workspace-for-uat', 'DANGEROUS: Allow UAT to write to production workspace (NOT RECOMMENDED)')
524
- .action(async (opts) => {
525
- await handleRuntimeUat({
526
- workspace: opts.workspace,
527
- count: opts.count,
528
- minSuccessRate: opts.minSuccessRate,
529
- json: opts.json,
530
- allowProductionWorkspaceForUat: opts.allowProductionWorkspaceForUat,
531
- });
532
- });
533
- const runtimeHealthCmd = runtimeCmd
534
- .command('health', { hidden: true })
535
- .description('Runtime V2 health inspection');
536
- runtimeHealthCmd
537
- .command('snapshot')
538
- .description('Operator health snapshot combining chain, ledger, and pruning status')
539
- .option('-w, --workspace <path>', 'Workspace directory')
540
- .option('--json', 'Output raw JSON')
541
- .action(async (opts) => {
542
- await handleRuntimeHealthSnapshot({ workspace: opts.workspace, json: opts.json });
543
- });
544
- // ── pd codex reconcile — Codex governance continuation recovery ───────────────
545
- // Codex Governance Closure Slice B (PRI-623, SPEC §13/§20): runs the idempotent
546
- // cross-store reconciliation pass (admitted pain → missing Diagnostician task,
547
- // task-before-link, pending promotion tails) exposed for the CLI now and the
548
- // Slice C Companion worker later.
549
- const codexCmd = program
550
- .command('codex')
551
- .description('Codex host governance operations');
552
- // ── pd codex setup — consent UX for conversation ingestion (Slice D) ─────────
553
- // PRI-625, SPEC rev 2 §17 + G2A frozen disclosure: the ONE authority that can
554
- // enable codex_conversation_ingestion — presents the frozen disclosure and
555
- // records the explicit Owner decision BEFORE flipping the flag. Declining
556
- // leaves all existing governance unchanged and reads no transcript.
557
- codexCmd
558
- .command('setup')
559
- .description('Present the frozen ingestion disclosure and record the explicit consent decision (accept enables codex_conversation_ingestion; decline keeps everything off)')
560
- .option('-w, --workspace <path>', 'Workspace directory')
561
- .option('--accept', 'Explicitly accept after the disclosure has been presented (non-interactive)')
562
- .option('--decline', 'Explicitly decline; the ingestion flag stays off and no transcript is ever read')
563
- .option('--show-disclosure', 'Print the frozen disclosure text (zh default, --lang en) and exit without mutating anything')
564
- .option('--lang <zh|en>', 'Disclosure language for presentation', undefined)
565
- .option('--json', 'Output raw JSON (decision must be explicit: --accept or --decline)')
566
- .action(async (opts) => {
567
- const { handleCodexSetup } = await import('./commands/codex-setup.js');
568
- await handleCodexSetup({
569
- workspace: opts.workspace,
570
- json: opts.json === true,
571
- accept: opts.accept === true,
572
- decline: opts.decline === true,
573
- showDisclosure: opts.showDisclosure === true,
574
- ...(typeof opts.lang === 'string' ? { lang: opts.lang } : {}),
575
- });
576
- });
577
- codexCmd
578
- .command('reconcile')
579
- .description('Reconcile admitted Codex pains with Diagnostician tasks and promotion tails (idempotent)')
580
- .option('-w, --workspace <path>', 'Workspace directory')
581
- .option('--limit <n>', 'Maximum admitted pains to reconcile per pass (1-200, default 50)')
582
- .option('--json', 'Output raw JSON')
583
- .action(async (opts) => {
584
- const { handleCodexReconcile } = await import('./commands/codex-reconcile.js');
585
- const limit = typeof opts.limit === 'string' ? Number.parseInt(opts.limit, 10) : undefined;
586
- await handleCodexReconcile({
587
- workspace: opts.workspace,
588
- json: opts.json === true,
589
- ...(limit !== undefined && Number.isInteger(limit) ? { limit } : {}),
590
- });
591
- });
592
- // ── pd codex ingest catch-up — bounded manual transcript lag recovery ────────
593
- // Codex Governance Closure Slice C (PRI-624, SPEC §15): the manual-mode
594
- // counterpart of the Companion worker's catch-up step. Zero transcript I/O
595
- // when codex_conversation_ingestion is disabled.
596
- const codexIngestCmd = codexCmd
597
- .command('ingest')
598
- .description('Codex conversation-ingestion operations');
599
- codexIngestCmd
600
- .command('catch-up')
601
- .description('Catch up transcript lag from durable checkpoints (bounded, non-destructive, no LLM)')
602
- .option('-w, --workspace <path>', 'Workspace directory')
603
- .option('--max-rollouts <n>', 'Maximum rollouts to catch up per pass (1-32, default 8)')
604
- .option('--json', 'Output raw JSON')
605
- .action(async (opts) => {
606
- const { handleCodexIngestCatchUp } = await import('./commands/codex-ingest-catchup.js');
607
- const maxRollouts = typeof opts.maxRollouts === 'string' ? Number.parseInt(opts.maxRollouts, 10) : undefined;
608
- await handleCodexIngestCatchUp({
609
- workspace: opts.workspace,
610
- json: opts.json === true,
611
- ...(maxRollouts !== undefined && Number.isInteger(maxRollouts) ? { maxRollouts } : {}),
612
- });
613
- });
614
- // ── pd codex ingest quarantine — audited recovery for invalid records ────────
615
- // Codex Governance Closure Slice D (PRI-625, SPEC §15): dry-run by default,
616
- // --confirm required to mutate; records digest/reason/operator/timestamp/gap;
617
- // never edits the Codex transcript; promoted evidence is refused.
618
- codexIngestCmd
619
- .command('quarantine')
620
- .description('Quarantine a permanently invalid governance observation (dry-run by default; --confirm to apply; never touches the transcript)')
621
- .option('-w, --workspace <path>', 'Workspace directory')
622
- .option('--rollout <id>', 'Rollout identity that owns the record (required)')
623
- .option('--record <id>', 'Numeric governance_observations.id to quarantine (required)')
624
- .option('--reason <text>', 'Why the record is permanently invalid, 1-200 chars (required)')
625
- .option('--operator <id>', 'Operator identity recorded in the audit metadata (default: current OS user)')
626
- .option('--confirm', 'Apply the quarantine; without this flag the command is a dry run')
627
- .option('--json', 'Output raw JSON')
628
- .action(async (opts) => {
629
- const { handleCodexIngestQuarantine } = await import('./commands/codex-ingest-quarantine.js');
630
- await handleCodexIngestQuarantine({
631
- workspace: opts.workspace,
632
- rollout: opts.rollout,
633
- record: opts.record,
634
- reason: opts.reason,
635
- ...(typeof opts.operator === 'string' ? { operator: opts.operator } : {}),
636
- confirm: opts.confirm === true,
637
- json: opts.json === true,
638
- });
639
- });
640
- // ── pd codex worker — Workspace-scoped governance worker ─────────────────────
641
- // Codex Governance Closure Slice C (PRI-624, SPEC §13; ADR-0020 §11.1): the
642
- // one Owner-approved background worker (catch-up → reconciliation → one
643
- // Diagnostician execution → one bounded downstream consumer cycle). The
644
- // Companion spawns this per registered workspace; --once is the manual and
645
- // supervised-restart form.
646
- codexCmd
647
- .command('worker')
648
- .description('Run the Codex workspace governance worker (catch-up, reconciliation, diagnostician, downstream)')
649
- .option('-w, --workspace <path>', 'Workspace directory')
650
- .option('--once', 'Run exactly one bounded cycle and exit')
651
- .option('--interval <ms>', 'Cycle interval for continuous mode (default 120000, minimum 1000)')
652
- .option('--status', 'Report the SPEC §15 worker mode without executing anything')
653
- .option('--json', 'Output raw JSON')
654
- .action(async (opts) => {
655
- const { handleCodexWorker } = await import('./commands/codex-worker.js');
656
- const intervalMs = typeof opts.interval === 'string' ? Number.parseInt(opts.interval, 10) : undefined;
657
- await handleCodexWorker({
658
- workspace: opts.workspace,
659
- json: opts.json === true,
660
- once: opts.once === true,
661
- status: opts.status === true,
662
- ...(intervalMs !== undefined && Number.isInteger(intervalMs) ? { intervalMs } : {}),
663
- });
664
- });
665
- // ── pd workbuddy — WorkBuddy host governance operations ──────────────────────
666
- // SPEC workbuddy-host-adapter §5 Part 5 (ADR-0020 third host): the worker is
667
- // the only operator command the WorkBuddy MVP needs — reconciliation,
668
- // diagnostician and downstream reuse the shared authorities; there is no
669
- // ingestion consent flow because the WorkBuddy MVP reads no transcript.
670
- const workbuddyCmd = program
671
- .command('workbuddy')
672
- .description('WorkBuddy host governance operations');
673
- workbuddyCmd
674
- .command('worker')
675
- .description('Run the WorkBuddy governance worker (reconciliation, diagnostician, downstream — no transcript ingestion)')
676
- .option('-w, --workspace <path>', 'Governance workspace directory (default: the WorkBuddy governance workspace)')
677
- .option('--once', 'Run exactly one bounded cycle and exit')
678
- .option('--interval <ms>', 'Cycle interval for continuous mode (default 120000, minimum 1000)')
679
- .option('--status', 'Report the §15 worker mode without executing anything')
680
- .option('--json', 'Output raw JSON')
681
- .action(async (opts) => {
682
- const { handleWorkbuddyWorker } = await import('./commands/workbuddy-worker.js');
683
- const intervalMs = typeof opts.interval === 'string' ? Number.parseInt(opts.interval, 10) : undefined;
684
- await handleWorkbuddyWorker({
685
- workspace: opts.workspace,
686
- json: opts.json === true,
687
- once: opts.once === true,
688
- status: opts.status === true,
689
- ...(intervalMs !== undefined && Number.isInteger(intervalMs) ? { intervalMs } : {}),
690
- });
691
- });
692
- const internalizationCmd = runtimeCmd
693
- .command('internalization')
694
- .description('Internalization Engine operator visibility');
695
- internalizationCmd
696
- .command('queue')
697
- .description('Show PI task queue health snapshot')
698
- .option('-w, --workspace <path>', 'Workspace directory')
699
- .option('--json', 'Output raw JSON')
700
- .action(async (opts) => {
701
- await handleRuntimeInternalizationQueue({ workspace: opts.workspace, json: opts.json });
702
- });
703
- internalizationCmd
704
- .command('wake-once')
705
- .description('Dry-run lease evaluation for the next leasable PI task')
706
- .option('-w, --workspace <path>', 'Workspace directory')
707
- .option('--dry-run', 'Evaluate lease without acquiring (required)', false)
708
- .option('--json', 'Output raw JSON')
709
- .action(async (opts) => {
710
- await handleRuntimeInternalizationWakeOnce({ workspace: opts.workspace, dryRun: opts.dryRun, json: opts.json });
711
- });
712
- internalizationCmd
713
- .command('retry')
714
- .description('Requeue a needs_human_review task (owner attention queue out-edge)')
715
- .option('-w, --workspace <path>', 'Workspace directory')
716
- .requiredOption('--task <taskId>', 'Task id to requeue')
717
- .option('--confirm', 'Actually requeue (default is dry-run)')
718
- .option('--json', 'Output as JSON')
719
- .action(async (opts) => {
720
- await handleRuntimeInternalizationRetry({ workspace: opts.workspace, taskId: opts.task, confirm: opts.confirm, json: opts.json });
721
- });
722
- internalizationCmd
723
- .command('run-once')
724
- .description('Wake-and-run: lease the next PI task and execute it')
725
- .option('-w, --workspace <path>', 'Workspace directory')
726
- .option('--runner <kind>', 'Runner kind to execute (default: dreamer)', 'dreamer')
727
- .option('--runtime <kind>', 'Runtime adapter kind: config (from .pd/config.yaml), pi-ai, test-double (default: config)', 'config')
728
- .option('--allow-test-double', 'Acknowledge that test-double runtime will mutate real queue state')
729
- .option('--no-enqueue-next', 'Skip successor enqueue after successful runner (default: auto-enqueue)')
730
- .option('--timeout-ms <ms>', 'Runner timeout in milliseconds (default: 300000, overrides workflows.yaml)', parseInt)
731
- .option('--json', 'Output raw JSON')
732
- .action(async (opts) => {
733
- await handleRuntimeInternalizationRunOnce({ workspace: opts.workspace, json: opts.json, runtime: opts.runtime, runner: opts.runner, allowTestDouble: opts.allowTestDouble, enqueueNext: opts.enqueueNext, timeoutMs: opts.timeoutMs });
734
- });
735
- registerRunRuleHostCommand(internalizationCmd);
736
- // PRI-985 (SPEC-PD-IAER-001 FR-09): read-only history audit of
737
- // behavior_example_pack_missing failures, aggregated by task.
738
- registerRuntimeInternalizationAuditArtificerEvidenceCommand(internalizationCmd);
739
- // PRI-983 (SPEC-PD-IAER-001 FR-03/FR-06): Owner evidence attach/resume
740
- // (list / attach / resume — all default dry-run, --confirm mutates).
741
- registerRuntimeInternalizationEvidenceCommand(internalizationCmd);
742
- internalizationCmd
743
- .command('integrity')
744
- .description('Check internalization chain integrity')
745
- .option('-w, --workspace <path>', 'Workspace directory')
746
- .option('--json', 'Output raw JSON')
747
- .action(async (opts) => {
748
- await handleRuntimeInternalizationIntegrity({ workspace: opts.workspace, json: opts.json });
749
- });
750
- internalizationCmd
751
- .command('integrity-repair')
752
- .description('Repair broken internalization chain links (operator repair path)')
753
- .option('-w, --workspace <path>', 'Workspace directory')
754
- .option('--dry-run', 'Report only, no modifications')
755
- .option('--confirm', 'Actually repair broken links')
756
- .option('--json', 'Output raw JSON')
757
- .action(async (opts) => {
758
- await handleRuntimeInternalizationIntegrityRepair({ workspace: opts.workspace, confirm: opts.confirm, dryRun: opts.dryRun, json: opts.json });
759
- });
760
- internalizationCmd
761
- .command('enqueue-successors')
762
- .description('Enqueue successor tasks for succeeded internalization tasks missing successors')
763
- .option('-w, --workspace <path>', 'Workspace directory')
764
- .option('--dry-run', 'Report only, no modifications (default)')
765
- .option('--confirm', 'Actually create successor tasks')
766
- .option('--json', 'Output raw JSON')
767
- .action(async (opts) => {
768
- await handleRuntimeInternalizationEnqueueSuccessors({ workspace: opts.workspace, dryRun: opts.dryRun, confirm: opts.confirm, json: opts.json });
769
- });
770
- const activationCmd = runtimeCmd
771
- .command('activation', { hidden: true })
772
- .description('Activation dispatch operations (hidden — use pd activation for list/deactivate)');
773
- registerRuntimeActivationDispatchCommand(activationCmd);
774
- // PRI-408 Contract E: Owner-initiated rollback/deactivate of an activation.
775
- // Idempotent — calling twice on the same ID is safe and returns ok=false with reason.
776
- activationCmd
777
- .command('deactivate')
778
- .description('Deactivate (rollback) an active activation — idempotent (PRI-408 Contract E)')
779
- .option('-a, --activation-id <id>', 'Activation ID to deactivate')
780
- .option('-w, --workspace <path>', 'Workspace directory')
781
- .option('--json', 'Output raw JSON')
782
- .action(async (opts) => {
783
- await handleRuntimeActivationDeactivate({
784
- workspace: opts.workspace,
785
- activationId: opts.activationId,
786
- json: opts.json,
787
- });
788
- });
789
- // PRI-408 Contract D: Owner observability — list current activations.
790
- activationCmd
791
- .command('list')
792
- .description('List activations (default: active only) — PRI-408 Contract D observability')
793
- .option('-w, --workspace <path>', 'Workspace directory')
794
- .option('-c, --channel <channel>', 'Filter by channel (prompt|code_tool_hook)')
795
- .option('--include-deactivated', 'Include deactivated records in output')
796
- .option('--json', 'Output raw JSON')
797
- .action(async (opts) => {
798
- await handleRuntimeActivationList({
799
- workspace: opts.workspace,
800
- channel: opts.channel,
801
- includeDeactivated: opts.includeDeactivated,
802
- json: opts.json,
803
- });
804
- });
805
- // P1 #2 fix: Owner edit entry point — swap a pending approval's artifact.
806
- // Required because ApprovalQueue.edit() was dead code with no CLI/OpenClaw entry.
807
- // P2 #5: use .option() instead of .requiredOption() so missing-flag errors
808
- // produce structured JSON output via the handler, not Commander's pre-handler exit.
809
- activationCmd
810
- .command('edit')
811
- .description('Edit a pending approval to swap its artifact — P1 #2 owner edit entry point')
812
- .option('-a, --approval-id <id>', 'Approval ID to edit (must be pending)')
813
- .option('-n, --new-artifact-id <id>', 'New PIArtifact ID to swap to')
814
- .option('-r, --edit-reason <text>', 'Reason for the edit')
815
- .option('-w, --workspace <path>', 'Workspace directory')
816
- .option('--json', 'Output raw JSON')
817
- .action(async (opts) => {
818
- await handleRuntimeActivationEdit({
819
- workspace: opts.workspace,
820
- approvalId: opts.approvalId,
821
- newArtifactId: opts.newArtifactId,
822
- editReason: opts.editReason,
823
- json: opts.json,
824
- });
825
- });
826
- const diagnosticsCmd = runtimeCmd
827
- .command('diagnostics', { hidden: true })
828
- .description('Control plane diagnostic bundle operations');
829
- // PRI-674: visible (was hidden) — the only recovery re-entry point for an
830
- // Owner without Console access; hidden-ness left failed diagnostician tasks
831
- // undiscoverable.
832
- const recoveryCmd = runtimeCmd
833
- .command('recovery')
834
- .description('Runtime V2 recovery operations (expired-lease sweep, failed-task recovery)');
835
- // PRI-555 phase 1: dry-run-only artifact identity drift repair planner.
836
- runtimeCmd
837
- .command('artifact-repair')
838
- .description('Plan repairs for unreachable scribe artifacts (dry-run only; writes migration-plan.json, never modifies state.db)')
839
- .option('-w, --workspace <path>', 'Workspace directory')
840
- .option('--dry-run', 'Build migration-plan.json only (default)')
841
- .option('--confirm', 'Not implemented in this phase — refused')
842
- .option('--out <path>', 'Output path for migration-plan.json (default: ./migration-plan.json)')
843
- .option('--json', 'Output raw JSON')
844
- .action(async (opts) => {
845
- await handleRuntimeArtifactRepair({
846
- workspace: opts.workspace,
847
- dryRun: opts.dryRun,
848
- confirm: opts.confirm,
849
- out: opts.out,
850
- json: opts.json,
851
- });
852
- });
853
- recoveryCmd
854
- .command('sweep')
855
- .description('Detect and optionally recover expired leases')
856
- .option('-w, --workspace <path>', 'Workspace directory')
857
- .option('--dry-run', 'Report only, no modifications (default)')
858
- .option('--confirm', 'Actually recover expired leases')
859
- .option('--json', 'Output raw JSON')
860
- .action(async (opts) => {
861
- await handleRuntimeRecoverySweep({ workspace: opts.workspace, dryRun: opts.dryRun, confirm: opts.confirm, json: opts.json });
862
- });
863
- recoveryCmd
864
- .command('failed-tasks')
865
- .description('Recover failed internalization and diagnostician tasks')
866
- .option('-w, --workspace <path>', 'Workspace directory')
867
- .option('--dry-run', 'Report only, no modifications (default)')
868
- .option('--confirm', 'Actually recover failed tasks')
869
- .option('--force', 'Force recovery of tasks that exhausted max attempts')
870
- .option('--json', 'Output raw JSON')
871
- .action(async (opts) => {
872
- await handleRuntimeRecoveryFailedTasks({
873
- workspace: opts.workspace,
874
- dryRun: opts.dryRun,
875
- confirm: opts.confirm,
876
- force: opts.force,
877
- json: opts.json,
878
- });
879
- });
880
- // PRI-991: exact single-task counterpart of `failed-tasks`. A batch --force
881
- // resets the budget of EVERY exhausted failed task; this command recovers
882
- // exactly one Owner-selected task (CAS-guarded, audited, dry-run default).
883
- registerRuntimeRecoveryFailedTaskCommand(recoveryCmd);
884
- diagnosticsCmd
885
- .command('export')
886
- .description('Export diagnostic bundle for AI assistant analysis')
887
- .option('-w, --workspace <path>', 'Workspace directory')
888
- .option('--out <dir>', 'Output directory (must be within workspace)')
889
- .option('--json', 'Output raw JSON')
890
- .action(async (opts) => {
891
- await handleRuntimeDiagnosticsExport({ workspace: opts.workspace, out: opts.out, json: opts.json });
892
- });
893
- const pruningCmd = runtimeCmd
894
- .command('pruning', { hidden: true })
895
- .description('Non-destructive pruning metrics and health signals');
896
- pruningCmd
897
- .command('report')
898
- .description('Show pruning health report — watch/review principle signals')
899
- .option('-w, --workspace <path>', 'Workspace directory')
900
- .option('--json', 'Output raw JSON')
901
- .action((opts) => {
902
- handlePruningReport({ workspace: opts.workspace, json: opts.json });
903
- });
904
- pruningCmd
905
- .command('explain')
906
- .description('Explain why a specific principle was flagged')
907
- .requiredOption('--principle-id <id>', 'Principle ID to explain')
908
- .option('-w, --workspace <path>', 'Workspace directory')
909
- .option('--json', 'Output raw JSON')
910
- .action((opts) => {
911
- handlePruningExplain({ principleId: opts.principleId, workspace: opts.workspace, json: opts.json });
912
- });
913
- pruningCmd
914
- .command('orphans')
915
- .description('List orphan derived candidates not found in state.db')
916
- .option('-w, --workspace <path>', 'Workspace directory')
917
- .option('--dry-run', 'Report only, no modifications (default)')
918
- .option('--confirm', 'Actually remove orphan references from ledger')
919
- .option('--json', 'Output raw JSON')
920
- .action((opts) => {
921
- handlePruningOrphans({
922
- workspace: opts.workspace,
923
- dryRun: opts.dryRun,
924
- confirm: opts.confirm,
925
- json: opts.json,
926
- });
927
- });
928
- // ── Candidate inspection commands ─────────────────────────────────────────────
929
- const candidateCmd = program
930
- .command('candidate')
931
- .description('Principle candidate inspection');
932
- candidateCmd
933
- .command('list')
934
- .description('List principle candidates for a task')
935
- .requiredOption('-t, --task-id <taskId>', 'Task ID to query')
936
- .option('-w, --workspace <path>', 'Workspace directory')
937
- .option('--json', 'Output raw JSON')
938
- .action(async (opts) => {
939
- await handleCandidateList(opts);
940
- });
941
- candidateCmd
942
- .command('show [candidateId]')
943
- .description('Show detail for a single principle candidate')
944
- .requiredOption('-w, --workspace <path>', 'Workspace directory')
945
- .option('--candidate-id <id>', 'Candidate ID (alternative to positional arg)')
946
- .option('--json', 'Output raw JSON')
947
- .action(async (candidateId, opts) => {
948
- const resolvedId = opts.candidateId ?? candidateId;
949
- if (!resolvedId) {
950
- console.error('Error: candidate ID is required (positional or --candidate-id)');
951
- process.exitCode = 1;
952
- return;
953
- }
954
- if (candidateId && opts.candidateId && candidateId !== opts.candidateId) {
955
- console.error(`Error: conflicting candidate IDs: positional="${candidateId}", --candidate-id="${opts.candidateId}"`);
956
- process.exitCode = 1;
957
- return;
958
- }
959
- await handleCandidateShow({ candidateId: resolvedId, ...opts });
960
- });
961
- candidateCmd
962
- .command('intake')
963
- .description('Intake a principle candidate into the ledger')
964
- .requiredOption('--candidate-id <id>', 'Candidate ID to intake')
965
- .option('-w, --workspace <path>', 'Workspace directory')
966
- .option('--json', 'Output as JSON')
967
- .option('--dry-run', 'Show what would be written without writing')
968
- .action(async (opts) => {
969
- await handleCandidateIntake(opts);
970
- });
971
- // PRI-917 PR3A: the Owner reuse decision surface (SPEC §18 — interaction
972
- // layer only; the durable authority stays Principle.reuseEvidence[]).
973
- candidateCmd
974
- .command('review')
975
- .description('Review a candidate\'s reuse proposal and optionally record the Owner decision (reuse|create)')
976
- .requiredOption('--candidate-id <id>', 'Candidate ID to review')
977
- .option('-w, --workspace <path>', 'Workspace directory')
978
- .option('--json', 'Output as JSON')
979
- .addOption(new Option('--decide <decision>', 'Record the Owner decision (omit for read-only proposal view)').choices(['reuse', 'create']))
980
- .option('--principle-id <id>', 'Existing Principle to reuse (required with --decide reuse)')
981
- .option('--reason <text>', 'Why the Owner resolved this candidate (required with --decide)')
982
- .action(async (opts) => {
983
- await handleCandidateReview(opts);
984
- });
985
- candidateCmd
986
- .command('audit')
987
- .description('Audit candidate/ledger consistency for Runtime v2')
988
- .option('-w, --workspace <path>', 'Workspace directory')
989
- .option('--json', 'Output as JSON')
990
- .action(async (opts) => {
991
- await handleCandidateAudit(opts);
992
- });
993
- candidateCmd
994
- .command('repair')
995
- .description('Repair consumed candidate with missing ledger entry')
996
- .requiredOption('--candidate-id <id>', 'Candidate ID to repair')
997
- .option('-w, --workspace <path>', 'Workspace directory')
998
- .option('--json', 'Output as JSON')
999
- .action(async (opts) => {
1000
- await handleCandidateRepair(opts);
1001
- });
1002
- candidateCmd
1003
- .command('route')
1004
- .description('Show internalization route decision for a candidate')
1005
- .requiredOption('--candidate-id <id>', 'Candidate ID to inspect')
1006
- .option('-w, --workspace <path>', 'Workspace directory')
1007
- .option('--json', 'Output as JSON')
1008
- .action(async (opts) => {
1009
- await handleCandidateRoute(opts);
1010
- });
1011
- candidateCmd
1012
- .command('internalize')
1013
- .description('Seed internalization Dreamer task from a candidate')
1014
- .requiredOption('--candidate-id <id>', 'Candidate ID to internalize')
1015
- .option('-w, --workspace <path>', 'Workspace directory')
1016
- .option('--json', 'Output as JSON')
1017
- .option('--dry-run', 'Preview without writing to database')
1018
- .action(async (opts) => {
1019
- await handleCandidateInternalize(opts);
1020
- });
1021
- const candidateInternalizationCmd = candidateCmd
1022
- .command('internalization')
1023
- .description('Internalization pipeline operations for candidates');
1024
- candidateInternalizationCmd
1025
- .command('backfill')
1026
- .description('Backfill dreamer tasks for consumed candidates created before Internalization Engine')
1027
- .option('-w, --workspace <path>', 'Workspace directory')
1028
- .option('--dry-run', 'Report only, no modifications (default)')
1029
- .option('--confirm', 'Actually create missing dreamer tasks')
1030
- .option('--include-pending', 'Include pending candidates (intake first, then seed dreamer)')
1031
- .option('--json', 'Output as JSON')
1032
- .action(async (opts) => {
1033
- await handleCandidateInternalizationBackfill({ workspace: opts.workspace, dryRun: opts.dryRun, confirm: opts.confirm, includePending: opts.includePending, json: opts.json });
1034
- });
1035
- // ── Artifact inspection commands ──────────────────────────────────────────────
1036
- const artifactCmd = program
1037
- .command('artifact', { hidden: true })
1038
- .description('Artifact registry inspection');
1039
- artifactCmd
1040
- .command('show <artifactId>')
1041
- .description('Show artifact content and its associated candidates')
1042
- .requiredOption('-w, --workspace <path>', 'Workspace directory')
1043
- .option('--json', 'Output raw JSON')
1044
- .action(async (artifactId, opts) => {
1045
- await handleArtifactShow({ artifactId, ...opts });
1046
- });
1047
- const _legacyCleanupCmd = legacyCmd
1048
- .command('cleanup')
1049
- .description('Clean legacy empathy/diagnostician artifacts and V1 Artificer artifacts from workspace')
1050
- .requiredOption('-w, --workspace <path>', 'Workspace directory')
1051
- .option('--dry-run', 'Show what would be cleaned without applying (default)')
1052
- .option('--apply', 'Actually apply the cleanup')
1053
- .option('--json', 'Output raw JSON')
1054
- .action(async (opts) => {
1055
- // CLI gate rule 4: --dry-run and --apply are mutually exclusive
1056
- if (opts.dryRun && opts.apply) {
1057
- const msg = 'Error: --dry-run and --apply are mutually exclusive';
1058
- if (opts.json) {
1059
- console.log(JSON.stringify({ status: 'failed', reason: msg, nextAction: 'Specify either --dry-run or --apply, not both' }, null, 2));
1060
- }
1061
- else {
1062
- console.error(msg);
1063
- }
1064
- process.exitCode = 1;
1065
- return;
1066
- }
1067
- // Default to dry-run if neither flag is set (CLI gate rule 4).
1068
- // Pass undefined through — the handler's logic
1069
- // (opts.apply === true ? false : opts.dryRun !== false) correctly
1070
- // defaults to dry-run when both are undefined.
1071
- await handleLegacyCleanup({
1072
- workspacePath: opts.workspace,
1073
- dryRun: opts.dryRun,
1074
- apply: opts.apply,
1075
- json: opts.json ?? false,
1076
- });
1077
- });
1078
- // ─── MVP Smoke (PRI-397) ────────────────────────────────────────────────────
1079
- registerMvpCommands(program);
1080
- // ─── RuleCode CLI (PRI-439 Phase 5) ─────────────────────────────────────────
1081
- // Read-only commands: spec, validate, replay. No DB mutation, no artifact writes.
1082
- registerRulecodeCommand(program);
1083
- // ─── Intent Engineering (PRI-466) ───────────────────────────────────────────
1084
- // Owner-authored INTENT.md management: init (create), show (read-only summary).
1085
- registerIntentCommand(program);
1086
- // ─── Errors List (Task 14: Feedback Pipeline Observability) ────────────────
1087
- // Operator diagnostic: aggregates SQLite failed/needs_human_review tasks +
1088
- // worker-status.json errors array. Read-only.
1089
- registerErrorsListCommand(program);
1090
- // ─── Principles Stats (PRI-562 Phase 0) ─────────────────────────────────────
1091
- // Owner-facing observability: principle injection volume/cost/duplicates/
1092
- // application evidence. Read-only aggregation over event logs + receipt ledger.
1093
- registerPrinciplesCommand(program);
1094
- const consoleCmd = program
1095
- .command('console')
1096
- .description('Start the pd-console web UI for principle review (default: fallback launcher)')
1097
- .passThroughOptions()
1098
- .option('-w, --workspace <path>', 'Workspace directory')
1099
- .option('-p, --port <port>', 'Port to listen on', '3100')
1100
- .option('--no-auth', 'Disable authentication (local dev only)')
1101
- .option('--json', 'Output JSON status', false);
1102
- consoleCmd
1103
- .command('start')
1104
- .description('Legacy launcher — start the pd-console on the requested port (no reuse, no browser open)')
1105
- .option('-w, --workspace <path>', 'Workspace directory')
1106
- .option('-p, --port <port>', 'Port to listen on', '3100')
1107
- .option('--no-auth', 'Disable authentication (local dev only)')
1108
- .option('--json', 'Output JSON status', false)
1109
- .action(async (opts) => {
1110
- const { handleConsole } = await import('./commands/console.js');
1111
- await handleConsole({
1112
- workspace: opts.workspace,
1113
- port: opts.port,
1114
- noAuth: opts.auth === false,
1115
- json: opts.json,
1116
- });
1117
- });
1118
- // PRI-300: seed-friendly Console launcher with reuse + auto-port + browser open
1119
- consoleCmd
1120
- .command('open')
1121
- .description('Open the pd-console in your browser (PRI-300) — auto-port, reuses running console, loopback-only')
1122
- .option('-w, --workspace <path>', 'Workspace directory')
1123
- .option('-p, --port <port>', 'Preferred port (default 3100; auto-falls back to next free port)')
1124
- .option('--host <host>', 'Loopback host (default 127.0.0.1; non-loopback refused)')
1125
- .option('--no-auth', 'Disable authentication (local dev only)')
1126
- .option('--token <token>', 'Auth token for the Console (or set PD_CONSOLE_TOKEN env var)')
1127
- .option('--no-browser', 'Do not open the system browser on success')
1128
- .option('--json', 'Output JSON status (suppresses browser open)', false)
1129
- .action(async (opts) => {
1130
- const { handleConsoleOpen } = await import('./commands/console.js');
1131
- await handleConsoleOpen({
1132
- workspace: opts.workspace,
1133
- port: opts.port,
1134
- host: opts.host,
1135
- noAuth: opts.auth === false,
1136
- token: opts.token,
1137
- noBrowser: opts.browser === false,
1138
- json: opts.json,
1139
- });
1140
- });
1141
- // Default `pd console` → legacy launcher (backward compat)
1142
- consoleCmd.action(async (opts) => {
1143
- const { handleConsole } = await import('./commands/console.js');
1144
- await handleConsole({
1145
- workspace: opts.workspace,
1146
- port: opts.port,
1147
- noAuth: opts.auth === false,
1148
- json: opts.json,
1149
- });
1150
- });
1151
- // ─── Quality Scorecard (PRI-361) ──────────────────────────────────
1152
- const qualityCmd = program
1153
- .command('quality', { hidden: true })
1154
- .description('Quality scoring and evaluation');
1155
- qualityCmd
1156
- .command('scorecard')
1157
- .description('Generate quality scorecard report for PD pain→diagnosis→principle chain')
1158
- .option('-w, --workspace <path>', 'Workspace directory')
1159
- .option('--local-model <id>', 'LM Studio model ID', 'qwen3.6-27b-mtp')
1160
- .option('--local-url <url>', 'LM Studio base URL', 'http://localhost:12341/v1')
1161
- .option('--strong-model <id>', 'Strong model for adjudication (provider/model)')
1162
- .option('--skip-strong-model', 'Skip strong model adjudication', false)
1163
- .option('--min-score <n>', 'Minimum pain score to evaluate', '50')
1164
- .option('--limit <n>', 'Max episodes to evaluate (0=all)', '0')
1165
- .option('--format <fmt>', 'Output format: json, markdown, html', 'markdown')
1166
- .option('--output <path>', 'Output file path')
1167
- .option('--json', 'Output as JSON', false)
1168
- .action(async (opts) => {
1169
- const { handleQualityScorecard } = await import('./commands/quality-scorecard.js');
1170
- await handleQualityScorecard(opts);
1171
- });
1172
- // ─── PD MCP durable logs (observability export) ───────────────────
1173
- // One command that turns the on-disk MCP JSONL logs into a single bounded zip
1174
- // the Owner can send to an agent for offline analysis.
1175
- const mcpCmd = program
1176
- .command('mcp')
1177
- .description('PD MCP server operations');
1178
- const mcpLogsCmd = mcpCmd
1179
- .command('logs')
1180
- .description('Inspect durable PD MCP logs');
1181
- mcpLogsCmd
1182
- .command('export')
1183
- .description('Bundle the last N days of PD MCP logs into one zip (≤20 MiB, sanitized)')
1184
- .option('--days <n>', 'Days of history to include (1-365)', '7')
1185
- .option('-o, --out <path>', 'Output .zip path, or a directory to write the default file name into')
1186
- .option('--json', 'Output raw JSON')
1187
- .action(async (opts) => {
1188
- const parsedDays = Number.parseInt(opts.days, 10);
1189
- if (!Number.isInteger(parsedDays) || parsedDays < 1 || parsedDays > 365) {
1190
- console.error('--days must be an integer between 1 and 365');
1191
- process.exitCode = 1;
1192
- return;
1193
- }
1194
- try {
1195
- await handleMcpLogsExport({
1196
- days: parsedDays,
1197
- out: opts.out,
1198
- json: opts.json === true,
1199
- });
1200
- }
1201
- catch (error) {
1202
- console.error(`MCP log export failed: ${error instanceof Error ? error.message : String(error)}`);
1203
- process.exitCode = 1;
1204
- }
1205
- });
18
+ import { handleVersionFlag, program } from './program.js';
19
+ export { buildPdProgram } from './program.js';
1206
20
  if (!handleVersionFlag(process.argv.slice(2))) {
1207
21
  program.parse();
1208
22
  }