create-principles-disciple 1.146.4 → 1.146.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 (308) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/package.json +3 -3
  3. package/release-manager/package.json +3 -3
  4. package/console/dist/ui/App.d.ts +0 -1
  5. package/console/dist/ui/App.js +0 -172
  6. package/console/dist/ui/api.d.ts +0 -611
  7. package/console/dist/ui/api.js +0 -1094
  8. package/console/dist/ui/components/auth/login-form.d.ts +0 -4
  9. package/console/dist/ui/components/auth/login-form.js +0 -142
  10. package/console/dist/ui/components/auth/splash-screen.d.ts +0 -9
  11. package/console/dist/ui/components/auth/splash-screen.js +0 -22
  12. package/console/dist/ui/components/error-boundary.d.ts +0 -15
  13. package/console/dist/ui/components/error-boundary.js +0 -30
  14. package/console/dist/ui/components/focus/daily-thought-card.d.ts +0 -1
  15. package/console/dist/ui/components/focus/daily-thought-card.js +0 -41
  16. package/console/dist/ui/components/language-switcher.d.ts +0 -2
  17. package/console/dist/ui/components/language-switcher.js +0 -17
  18. package/console/dist/ui/components/layout/app-sidebar.d.ts +0 -27
  19. package/console/dist/ui/components/layout/app-sidebar.js +0 -128
  20. package/console/dist/ui/components/layout/page-loading.d.ts +0 -13
  21. package/console/dist/ui/components/layout/page-loading.js +0 -14
  22. package/console/dist/ui/components/layout/page-shell.d.ts +0 -12
  23. package/console/dist/ui/components/layout/page-shell.js +0 -11
  24. package/console/dist/ui/components/layout/section-title.d.ts +0 -10
  25. package/console/dist/ui/components/layout/section-title.js +0 -9
  26. package/console/dist/ui/components/notifications/NotificationProvider.d.ts +0 -14
  27. package/console/dist/ui/components/notifications/NotificationProvider.js +0 -136
  28. package/console/dist/ui/components/notifications/favicon-badge.d.ts +0 -3
  29. package/console/dist/ui/components/notifications/favicon-badge.js +0 -68
  30. package/console/dist/ui/components/notifications/notification-reducer.d.ts +0 -9
  31. package/console/dist/ui/components/notifications/notification-reducer.js +0 -9
  32. package/console/dist/ui/components/notifications/sound-storage.d.ts +0 -3
  33. package/console/dist/ui/components/notifications/sound-storage.js +0 -37
  34. package/console/dist/ui/components/notifications/useNotifications.d.ts +0 -1
  35. package/console/dist/ui/components/notifications/useNotifications.js +0 -9
  36. package/console/dist/ui/components/onboarding/CircuitDiagram.d.ts +0 -8
  37. package/console/dist/ui/components/onboarding/CircuitDiagram.js +0 -18
  38. package/console/dist/ui/components/onboarding/DemoResultView.d.ts +0 -22
  39. package/console/dist/ui/components/onboarding/DemoResultView.js +0 -33
  40. package/console/dist/ui/components/onboarding/SlashCommandsCard.d.ts +0 -16
  41. package/console/dist/ui/components/onboarding/SlashCommandsCard.js +0 -20
  42. package/console/dist/ui/components/onboarding/slashCommands.d.ts +0 -20
  43. package/console/dist/ui/components/onboarding/slashCommands.js +0 -22
  44. package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.d.ts +0 -6
  45. package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.js +0 -66
  46. package/console/dist/ui/components/theme-provider.d.ts +0 -14
  47. package/console/dist/ui/components/theme-provider.js +0 -40
  48. package/console/dist/ui/components/theme-toggle.d.ts +0 -2
  49. package/console/dist/ui/components/theme-toggle.js +0 -11
  50. package/console/dist/ui/components/ui/alert-dialog.d.ts +0 -20
  51. package/console/dist/ui/components/ui/alert-dialog.js +0 -26
  52. package/console/dist/ui/components/ui/badge.d.ts +0 -9
  53. package/console/dist/ui/components/ui/badge.js +0 -22
  54. package/console/dist/ui/components/ui/button.d.ts +0 -11
  55. package/console/dist/ui/components/ui/button.js +0 -34
  56. package/console/dist/ui/components/ui/card.d.ts +0 -8
  57. package/console/dist/ui/components/ui/card.js +0 -16
  58. package/console/dist/ui/components/ui/charts.d.ts +0 -51
  59. package/console/dist/ui/components/ui/charts.js +0 -72
  60. package/console/dist/ui/components/ui/dialog.d.ts +0 -19
  61. package/console/dist/ui/components/ui/dialog.js +0 -22
  62. package/console/dist/ui/components/ui/input.d.ts +0 -3
  63. package/console/dist/ui/components/ui/input.js +0 -8
  64. package/console/dist/ui/components/ui/markdown.d.ts +0 -24
  65. package/console/dist/ui/components/ui/markdown.js +0 -119
  66. package/console/dist/ui/components/ui/progress-bar.d.ts +0 -20
  67. package/console/dist/ui/components/ui/progress-bar.js +0 -38
  68. package/console/dist/ui/components/ui/select.d.ts +0 -13
  69. package/console/dist/ui/components/ui/select.js +0 -26
  70. package/console/dist/ui/components/ui/separator.d.ts +0 -3
  71. package/console/dist/ui/components/ui/separator.js +0 -6
  72. package/console/dist/ui/components/ui/sheet.d.ts +0 -25
  73. package/console/dist/ui/components/ui/sheet.js +0 -37
  74. package/console/dist/ui/components/ui/shiny-text.d.ts +0 -28
  75. package/console/dist/ui/components/ui/shiny-text.js +0 -46
  76. package/console/dist/ui/components/ui/skeleton.d.ts +0 -3
  77. package/console/dist/ui/components/ui/skeleton.js +0 -6
  78. package/console/dist/ui/components/ui/sonner.d.ts +0 -3
  79. package/console/dist/ui/components/ui/sonner.js +0 -13
  80. package/console/dist/ui/components/ui/tooltip.d.ts +0 -7
  81. package/console/dist/ui/components/ui/tooltip.js +0 -10
  82. package/console/dist/ui/data/daily-thoughts.d.ts +0 -15
  83. package/console/dist/ui/data/daily-thoughts.js +0 -164
  84. package/console/dist/ui/hooks/useNotificationSound.d.ts +0 -12
  85. package/console/dist/ui/hooks/useNotificationSound.js +0 -74
  86. package/console/dist/ui/i18n/en.json +0 -2399
  87. package/console/dist/ui/i18n/index.d.ts +0 -2
  88. package/console/dist/ui/i18n/index.js +0 -32
  89. package/console/dist/ui/i18n/zh-CN.json +0 -2399
  90. package/console/dist/ui/main.d.ts +0 -1
  91. package/console/dist/ui/main.js +0 -9
  92. package/console/dist/ui/pages/ReportProblemValidators.d.ts +0 -144
  93. package/console/dist/ui/pages/ReportProblemValidators.js +0 -418
  94. package/console/dist/ui/pages/activation/ActivationPage.d.ts +0 -1
  95. package/console/dist/ui/pages/activation/ActivationPage.js +0 -512
  96. package/console/dist/ui/pages/activation/ActivationValidators.d.ts +0 -20
  97. package/console/dist/ui/pages/activation/ActivationValidators.js +0 -160
  98. package/console/dist/ui/pages/control-center/AgentCard.d.ts +0 -31
  99. package/console/dist/ui/pages/control-center/AgentCard.js +0 -212
  100. package/console/dist/ui/pages/control-center/AgentGroup.d.ts +0 -26
  101. package/console/dist/ui/pages/control-center/AgentGroup.js +0 -38
  102. package/console/dist/ui/pages/control-center/ControlCenterPage.d.ts +0 -1
  103. package/console/dist/ui/pages/control-center/ControlCenterPage.js +0 -509
  104. package/console/dist/ui/pages/control-center/DesignGatePanel.d.ts +0 -1
  105. package/console/dist/ui/pages/control-center/DesignGatePanel.js +0 -137
  106. package/console/dist/ui/pages/control-center/RuntimeProfileManager.d.ts +0 -31
  107. package/console/dist/ui/pages/control-center/RuntimeProfileManager.js +0 -199
  108. package/console/dist/ui/pages/control-center/WorkflowDiagram.d.ts +0 -17
  109. package/console/dist/ui/pages/control-center/WorkflowDiagram.js +0 -55
  110. package/console/dist/ui/pages/debt/DebtPage.d.ts +0 -2
  111. package/console/dist/ui/pages/debt/DebtPage.js +0 -222
  112. package/console/dist/ui/pages/design-system/DesignSystemPage.d.ts +0 -2
  113. package/console/dist/ui/pages/design-system/DesignSystemPage.js +0 -30
  114. package/console/dist/ui/pages/examiner/ExaminerPage.d.ts +0 -15
  115. package/console/dist/ui/pages/examiner/ExaminerPage.js +0 -158
  116. package/console/dist/ui/pages/failed-tasks/FailedTasksPage.d.ts +0 -1
  117. package/console/dist/ui/pages/failed-tasks/FailedTasksPage.js +0 -421
  118. package/console/dist/ui/pages/focus/ApprovalSubjectReading.d.ts +0 -24
  119. package/console/dist/ui/pages/focus/ApprovalSubjectReading.js +0 -133
  120. package/console/dist/ui/pages/focus/FocusPage.d.ts +0 -123
  121. package/console/dist/ui/pages/focus/FocusPage.js +0 -567
  122. package/console/dist/ui/pages/focus/OwnerDecisionCard.d.ts +0 -9
  123. package/console/dist/ui/pages/focus/OwnerDecisionCard.js +0 -111
  124. package/console/dist/ui/pages/focus/OwnerWorkbench.d.ts +0 -19
  125. package/console/dist/ui/pages/focus/OwnerWorkbench.js +0 -75
  126. package/console/dist/ui/pages/focus/RuleCandidateBindingPanel.d.ts +0 -34
  127. package/console/dist/ui/pages/focus/RuleCandidateBindingPanel.js +0 -298
  128. package/console/dist/ui/pages/focus/focus-validation.d.ts +0 -40
  129. package/console/dist/ui/pages/focus/focus-validation.js +0 -211
  130. package/console/dist/ui/pages/intent/IntentOnboarding.d.ts +0 -67
  131. package/console/dist/ui/pages/intent/IntentOnboarding.js +0 -289
  132. package/console/dist/ui/pages/intent/IntentPage.d.ts +0 -1
  133. package/console/dist/ui/pages/intent/IntentPage.js +0 -252
  134. package/console/dist/ui/pages/pain/PainEvidenceValidators.d.ts +0 -59
  135. package/console/dist/ui/pages/pain/PainEvidenceValidators.js +0 -125
  136. package/console/dist/ui/pages/pain/PainPage.d.ts +0 -1
  137. package/console/dist/ui/pages/pain/PainPage.js +0 -420
  138. package/console/dist/ui/pages/pain/pain-card-helpers.d.ts +0 -175
  139. package/console/dist/ui/pages/pain/pain-card-helpers.js +0 -181
  140. package/console/dist/ui/pages/principles/CorePrinciplesPage.d.ts +0 -10
  141. package/console/dist/ui/pages/principles/CorePrinciplesPage.js +0 -59
  142. package/console/dist/ui/pages/principles/PrincipleDetailPage.d.ts +0 -60
  143. package/console/dist/ui/pages/principles/PrincipleDetailPage.js +0 -602
  144. package/console/dist/ui/pages/principles/PrinciplesPage.d.ts +0 -1
  145. package/console/dist/ui/pages/principles/PrinciplesPage.js +0 -327
  146. package/console/dist/ui/pages/principles/PrinciplesViewNav.d.ts +0 -8
  147. package/console/dist/ui/pages/principles/PrinciplesViewNav.js +0 -15
  148. package/console/dist/ui/pages/report-problem/ReportProblemPage.d.ts +0 -1
  149. package/console/dist/ui/pages/report-problem/ReportProblemPage.js +0 -467
  150. package/console/dist/ui/pages/settings/SettingsPage.d.ts +0 -4
  151. package/console/dist/ui/pages/settings/SettingsPage.js +0 -457
  152. package/console/dist/ui/pages/settings/UpdatePage.d.ts +0 -1
  153. package/console/dist/ui/pages/settings/UpdatePage.js +0 -215
  154. package/console/dist/ui/pages/welcome/WelcomePage.d.ts +0 -5
  155. package/console/dist/ui/pages/welcome/WelcomePage.js +0 -187
  156. package/console/dist/ui/utils/agent-metadata.d.ts +0 -71
  157. package/console/dist/ui/utils/agent-metadata.js +0 -284
  158. package/console/dist/ui/utils/approval-review.d.ts +0 -30
  159. package/console/dist/ui/utils/approval-review.js +0 -50
  160. package/console/dist/ui/utils/approval-warning-localization.d.ts +0 -34
  161. package/console/dist/ui/utils/approval-warning-localization.js +0 -148
  162. package/console/dist/ui/utils/attention-presentation.d.ts +0 -35
  163. package/console/dist/ui/utils/attention-presentation.js +0 -46
  164. package/console/dist/ui/utils/blocker-localization.d.ts +0 -23
  165. package/console/dist/ui/utils/blocker-localization.js +0 -36
  166. package/console/dist/ui/utils/control-center-helpers.d.ts +0 -79
  167. package/console/dist/ui/utils/control-center-helpers.js +0 -189
  168. package/console/dist/ui/utils/enum-labels.d.ts +0 -50
  169. package/console/dist/ui/utils/enum-labels.js +0 -171
  170. package/console/dist/ui/utils/format-date.d.ts +0 -11
  171. package/console/dist/ui/utils/format-date.js +0 -17
  172. package/console/dist/ui/utils/onboarding-state.d.ts +0 -25
  173. package/console/dist/ui/utils/onboarding-state.js +0 -77
  174. package/console/dist/ui/utils/reading-layout.d.ts +0 -20
  175. package/console/dist/ui/utils/reading-layout.js +0 -46
  176. package/console/dist/ui/utils/rule-binding-validators.d.ts +0 -13
  177. package/console/dist/ui/utils/rule-binding-validators.js +0 -188
  178. package/console/dist/ui/utils/runtime-mode.d.ts +0 -11
  179. package/console/dist/ui/utils/runtime-mode.js +0 -11
  180. package/console/dist/ui/utils/token-storage.d.ts +0 -22
  181. package/console/dist/ui/utils/token-storage.js +0 -47
  182. package/console/dist/ui/utils/validators.d.ts +0 -1178
  183. package/console/dist/ui/utils/validators.js +0 -3297
  184. package/release-manager/dist/bootstrap-entry.d.ts +0 -2
  185. package/release-manager/dist/bootstrap-entry.d.ts.map +0 -1
  186. package/release-manager/dist/bootstrap-entry.js.map +0 -1
  187. package/release-manager/dist/i18n.d.ts +0 -6
  188. package/release-manager/dist/i18n.d.ts.map +0 -1
  189. package/release-manager/dist/i18n.js.map +0 -1
  190. package/release-manager/dist/index.d.ts +0 -7
  191. package/release-manager/dist/index.d.ts.map +0 -1
  192. package/release-manager/dist/index.js +0 -656
  193. package/release-manager/dist/index.js.map +0 -1
  194. package/release-manager/dist/installer.d.ts +0 -629
  195. package/release-manager/dist/installer.d.ts.map +0 -1
  196. package/release-manager/dist/installer.js.map +0 -1
  197. package/release-manager/dist/installers/codex-host-installer.d.ts +0 -39
  198. package/release-manager/dist/installers/codex-host-installer.d.ts.map +0 -1
  199. package/release-manager/dist/installers/codex-host-installer.js.map +0 -1
  200. package/release-manager/dist/installers/index.d.ts +0 -51
  201. package/release-manager/dist/installers/index.d.ts.map +0 -1
  202. package/release-manager/dist/installers/index.js.map +0 -1
  203. package/release-manager/dist/installers/openclaw-host-installer.d.ts +0 -14
  204. package/release-manager/dist/installers/openclaw-host-installer.d.ts.map +0 -1
  205. package/release-manager/dist/installers/openclaw-host-installer.js.map +0 -1
  206. package/release-manager/dist/installers/workbuddy-host-installer.d.ts +0 -335
  207. package/release-manager/dist/installers/workbuddy-host-installer.d.ts.map +0 -1
  208. package/release-manager/dist/installers/workbuddy-host-installer.js.map +0 -1
  209. package/release-manager/dist/mvp-config.d.ts +0 -233
  210. package/release-manager/dist/mvp-config.d.ts.map +0 -1
  211. package/release-manager/dist/mvp-config.js.map +0 -1
  212. package/release-manager/dist/prompts.d.ts +0 -43
  213. package/release-manager/dist/prompts.d.ts.map +0 -1
  214. package/release-manager/dist/prompts.js +0 -268
  215. package/release-manager/dist/prompts.js.map +0 -1
  216. package/release-manager/dist/skill-language.d.ts +0 -32
  217. package/release-manager/dist/skill-language.d.ts.map +0 -1
  218. package/release-manager/dist/skill-language.js.map +0 -1
  219. package/release-manager/dist/uninstaller.d.ts +0 -68
  220. package/release-manager/dist/uninstaller.d.ts.map +0 -1
  221. package/release-manager/dist/uninstaller.js +0 -746
  222. package/release-manager/dist/uninstaller.js.map +0 -1
  223. package/release-manager/dist/update/apply-payload.d.ts +0 -143
  224. package/release-manager/dist/update/apply-payload.d.ts.map +0 -1
  225. package/release-manager/dist/update/apply-payload.js.map +0 -1
  226. package/release-manager/dist/update/atomic-file.d.ts +0 -35
  227. package/release-manager/dist/update/atomic-file.d.ts.map +0 -1
  228. package/release-manager/dist/update/atomic-file.js.map +0 -1
  229. package/release-manager/dist/update/bootstrap-executor.d.ts +0 -21
  230. package/release-manager/dist/update/bootstrap-executor.d.ts.map +0 -1
  231. package/release-manager/dist/update/bootstrap-executor.js.map +0 -1
  232. package/release-manager/dist/update/bootstrap-protocol.d.ts +0 -56
  233. package/release-manager/dist/update/bootstrap-protocol.d.ts.map +0 -1
  234. package/release-manager/dist/update/bootstrap-protocol.js.map +0 -1
  235. package/release-manager/dist/update/channel-metadata.d.ts +0 -28
  236. package/release-manager/dist/update/channel-metadata.d.ts.map +0 -1
  237. package/release-manager/dist/update/channel-metadata.js.map +0 -1
  238. package/release-manager/dist/update/channel-promotion.d.ts +0 -39
  239. package/release-manager/dist/update/channel-promotion.d.ts.map +0 -1
  240. package/release-manager/dist/update/channel-promotion.js +0 -55
  241. package/release-manager/dist/update/channel-promotion.js.map +0 -1
  242. package/release-manager/dist/update/console-surface.d.ts +0 -19
  243. package/release-manager/dist/update/console-surface.d.ts.map +0 -1
  244. package/release-manager/dist/update/console-surface.js.map +0 -1
  245. package/release-manager/dist/update/data-compatibility.d.ts +0 -35
  246. package/release-manager/dist/update/data-compatibility.d.ts.map +0 -1
  247. package/release-manager/dist/update/data-compatibility.js +0 -45
  248. package/release-manager/dist/update/data-compatibility.js.map +0 -1
  249. package/release-manager/dist/update/install-layout.d.ts +0 -105
  250. package/release-manager/dist/update/install-layout.d.ts.map +0 -1
  251. package/release-manager/dist/update/install-layout.js.map +0 -1
  252. package/release-manager/dist/update/product-identity.d.ts +0 -70
  253. package/release-manager/dist/update/product-identity.d.ts.map +0 -1
  254. package/release-manager/dist/update/product-identity.js.map +0 -1
  255. package/release-manager/dist/update/release-asset-manifest.d.ts +0 -31
  256. package/release-manager/dist/update/release-asset-manifest.d.ts.map +0 -1
  257. package/release-manager/dist/update/release-asset-manifest.js.map +0 -1
  258. package/release-manager/dist/update/release-identity.d.ts +0 -33
  259. package/release-manager/dist/update/release-identity.d.ts.map +0 -1
  260. package/release-manager/dist/update/release-identity.js.map +0 -1
  261. package/release-manager/dist/update/release-manager-authority.d.ts +0 -39
  262. package/release-manager/dist/update/release-manager-authority.d.ts.map +0 -1
  263. package/release-manager/dist/update/release-manager-authority.js.map +0 -1
  264. package/release-manager/dist/update/release-manager.d.ts +0 -156
  265. package/release-manager/dist/update/release-manager.d.ts.map +0 -1
  266. package/release-manager/dist/update/release-manager.js.map +0 -1
  267. package/release-manager/dist/update/release-metadata-publisher.d.ts +0 -199
  268. package/release-manager/dist/update/release-metadata-publisher.d.ts.map +0 -1
  269. package/release-manager/dist/update/release-metadata-publisher.js +0 -478
  270. package/release-manager/dist/update/release-metadata-publisher.js.map +0 -1
  271. package/release-manager/dist/update/release-metadata-source.d.ts +0 -85
  272. package/release-manager/dist/update/release-metadata-source.d.ts.map +0 -1
  273. package/release-manager/dist/update/release-metadata-source.js.map +0 -1
  274. package/release-manager/dist/update/release-metadata.d.ts +0 -60
  275. package/release-manager/dist/update/release-metadata.d.ts.map +0 -1
  276. package/release-manager/dist/update/release-metadata.js.map +0 -1
  277. package/release-manager/dist/update/release-policy.d.ts +0 -51
  278. package/release-manager/dist/update/release-policy.d.ts.map +0 -1
  279. package/release-manager/dist/update/release-policy.js.map +0 -1
  280. package/release-manager/dist/update/rollback-policy.d.ts +0 -56
  281. package/release-manager/dist/update/rollback-policy.d.ts.map +0 -1
  282. package/release-manager/dist/update/rollback-policy.js +0 -61
  283. package/release-manager/dist/update/rollback-policy.js.map +0 -1
  284. package/release-manager/dist/update/transaction-journal.d.ts +0 -212
  285. package/release-manager/dist/update/transaction-journal.d.ts.map +0 -1
  286. package/release-manager/dist/update/transaction-journal.js.map +0 -1
  287. package/release-manager/dist/update/trust-metadata.d.ts +0 -55
  288. package/release-manager/dist/update/trust-metadata.d.ts.map +0 -1
  289. package/release-manager/dist/update/trust-metadata.js.map +0 -1
  290. package/release-manager/dist/update/trust-root-provisioning.d.ts +0 -99
  291. package/release-manager/dist/update/trust-root-provisioning.d.ts.map +0 -1
  292. package/release-manager/dist/update/trust-root-provisioning.js.map +0 -1
  293. package/release-manager/dist/update/update-history.d.ts +0 -46
  294. package/release-manager/dist/update/update-history.d.ts.map +0 -1
  295. package/release-manager/dist/update/update-history.js +0 -123
  296. package/release-manager/dist/update/update-history.js.map +0 -1
  297. package/release-manager/dist/utils/config-file-io.d.ts +0 -34
  298. package/release-manager/dist/utils/config-file-io.d.ts.map +0 -1
  299. package/release-manager/dist/utils/config-file-io.js.map +0 -1
  300. package/release-manager/dist/utils/env.d.ts +0 -94
  301. package/release-manager/dist/utils/env.d.ts.map +0 -1
  302. package/release-manager/dist/utils/env.js.map +0 -1
  303. package/release-manager/dist/utils/logger.d.ts +0 -15
  304. package/release-manager/dist/utils/logger.d.ts.map +0 -1
  305. package/release-manager/dist/utils/logger.js.map +0 -1
  306. package/release-manager/dist/utils/workspace-divergence.d.ts +0 -36
  307. package/release-manager/dist/utils/workspace-divergence.d.ts.map +0 -1
  308. package/release-manager/dist/utils/workspace-divergence.js.map +0 -1
@@ -1,656 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import * as path from 'path';
4
- import * as url from 'url';
5
- import { createRequire } from 'module';
6
- import { realpathSync } from 'node:fs';
7
- import { banner, logger, setQuietMode } from './utils/logger.js';
8
- import { runPrompts } from './prompts.js';
9
- import { install, resolveConsoleWorkspaceDir } from './installer.js';
10
- import { uninstall, checkInstallStatus } from './uninstaller.js';
11
- import { checkEnvironment, detectWorkspace } from './utils/env.js';
12
- import { MVP_CHANNELS, buildFailureOutput, getHomeDir, isValidHttpBaseUrl, } from './mvp-config.js';
13
- import { setLanguage, t, getLanguage, isLanguage } from './i18n.js';
14
- import { isHostTarget, HOST_TARGETS } from './installers/index.js';
15
- export { isLanguage } from './i18n.js';
16
- const __filename = url.fileURLToPath(import.meta.url);
17
- const __dirname = path.dirname(__filename);
18
- const PLUGIN_DIR = path.resolve(__dirname, '..');
19
- // Fix-1 (P0-BUG-1): Read version from package.json instead of hardcoding.
20
- // EP-06 (Source of Truth): package.json is the canonical version source.
21
- // rc-2-no-as-bypass: validate the parsed JSON at runtime instead of `as` cast.
22
- const requireFromMeta = createRequire(import.meta.url);
23
- const pkgJson = requireFromMeta('../package.json');
24
- if (typeof pkgJson !== 'object' || pkgJson === null) {
25
- throw new Error('Invalid package.json: expected an object');
26
- }
27
- const pkgVersionValue = Object.hasOwn(pkgJson, 'version') ? Reflect.get(pkgJson, 'version') : undefined;
28
- if (typeof pkgVersionValue !== 'string' || pkgVersionValue.length === 0) {
29
- throw new Error('Invalid package.json: "version" must be a non-empty string');
30
- }
31
- const pkgVersion = pkgVersionValue;
32
- export function toInstallJsonOutput(result) {
33
- return {
34
- success: result.success,
35
- workspace: result.workspaceDir,
36
- components: result.components,
37
- enabledChannels: result.enabledChannels,
38
- verification: result.verification,
39
- nextAction: result.nextAction,
40
- ...(result.success ? {} : {
41
- reason: result.reason,
42
- component: result.component,
43
- dependency: result.dependency,
44
- }),
45
- };
46
- }
47
- async function runInstall(options) {
48
- const jsonMode = options.json === true;
49
- if (!isLanguage(options.lang)) {
50
- if (jsonMode) {
51
- console.log(JSON.stringify(buildFailureOutput('invalid_language', `--lang must be 'zh' or 'en', got: ${JSON.stringify(options.lang)}. Next: re-run with --lang zh or --lang en`), null, 2));
52
- }
53
- else {
54
- logger.error(`--lang must be 'zh' or 'en', got: ${JSON.stringify(options.lang)}`);
55
- logger.info(`${t('next_action')}: re-run with --lang zh or --lang en`);
56
- }
57
- process.exit(1);
58
- return;
59
- }
60
- setLanguage(options.lang);
61
- // ADR-0020 §2.3: Validate --host value. Default is 'openclaw' for backward compat.
62
- const rawHost = typeof options.host === 'string' ? options.host : 'openclaw';
63
- if (!isHostTarget(rawHost)) {
64
- if (jsonMode) {
65
- console.log(JSON.stringify(buildFailureOutput('invalid_host', `--host must be one of: ${HOST_TARGETS.join(', ')}. Got: ${JSON.stringify(rawHost)}. Next: re-run with --host openclaw (or --host codex / --host all)`), null, 2));
66
- }
67
- else {
68
- logger.error(`--host must be one of: ${HOST_TARGETS.join(', ')}. Got: ${JSON.stringify(rawHost)}`);
69
- logger.info(`Next: re-run with --host openclaw (or --host codex / --host all)`);
70
- }
71
- process.exit(1);
72
- return;
73
- }
74
- const host = rawHost;
75
- if (jsonMode) {
76
- setQuietMode(true);
77
- }
78
- if (!jsonMode) {
79
- console.log(banner);
80
- console.log();
81
- }
82
- const env = checkEnvironment();
83
- if (!env.hasNode) {
84
- if (jsonMode) {
85
- console.log(JSON.stringify(buildFailureOutput('node_not_found', 'Install Node.js >= 22 and retry'), null, 2));
86
- }
87
- else {
88
- logger.error(t('node_required'));
89
- }
90
- process.exit(1);
91
- return;
92
- }
93
- if (!env.isNodeSupported) {
94
- const nextAction = `Install Node.js >= 22 and retry. Detected: ${env.nodeVersion ?? 'unknown'}`;
95
- if (jsonMode) {
96
- console.log(JSON.stringify({
97
- ...buildFailureOutput('node_version_unsupported', nextAction),
98
- detectedVersion: env.nodeVersion,
99
- }, null, 2));
100
- }
101
- else {
102
- logger.error(t('node_version_unsupported'));
103
- logger.info(`${t('next_action')}: ${nextAction}`);
104
- }
105
- process.exit(1);
106
- return;
107
- }
108
- if (!jsonMode) {
109
- logger.success(`Node.js ${env.nodeVersion}`);
110
- }
111
- // ADR-0020: OpenClaw check is only required when host includes 'openclaw'.
112
- // For --host codex, the operator may not have OpenClaw installed at all.
113
- const needsOpenClaw = host === 'openclaw' || host === 'all';
114
- if (needsOpenClaw && !env.hasOpenClaw) {
115
- if (jsonMode) {
116
- console.log(JSON.stringify(buildFailureOutput('openclaw_not_found', `${t('openclaw_required')} ${t('openclaw_install_hint')} | ${t('next_action')}: ${t('openclaw_rerun_hint')} or use --host codex to skip OpenClaw`), null, 2));
117
- }
118
- else {
119
- logger.error(`\u274C ${t('openclaw_required')}`);
120
- logger.info(` ${t('openclaw_install_hint')}`);
121
- logger.info(` ${t('next_action')}: ${t('openclaw_rerun_hint')} or use --host codex to skip OpenClaw`);
122
- }
123
- process.exit(1);
124
- return;
125
- }
126
- if (!jsonMode && needsOpenClaw) {
127
- logger.success(`OpenClaw ${env.openclawVersion}`);
128
- }
129
- if (!jsonMode && host === 'codex') {
130
- logger.info(`Host: Codex CLI (OpenClaw not required)`);
131
- }
132
- if (jsonMode && !options.yes && !options.nonInteractive) {
133
- options.yes = true;
134
- }
135
- const workspaceInfo = detectWorkspace();
136
- const cliOptions = {
137
- language: options.lang,
138
- workspaceDir: typeof options.workspace === 'string' ? options.workspace : undefined,
139
- host,
140
- stopGateway: options.stopGateway === true,
141
- };
142
- if (options.force) {
143
- cliOptions.mode = 'force';
144
- }
145
- else if (options.smart) {
146
- cliOptions.mode = 'smart';
147
- }
148
- else {
149
- cliOptions.mode = workspaceInfo.isFirstInstall ? 'force' : 'smart';
150
- }
151
- if (!jsonMode && !options.nonInteractive && !options.yes) {
152
- if (workspaceInfo.isFirstInstall) {
153
- logger.info(t('first_install_detected'));
154
- }
155
- else {
156
- logger.info(t('existing_install_detected'));
157
- if (workspaceInfo.coreFiles.length > 0) {
158
- logger.info(` ${t('existing_core_files')} ${workspaceInfo.coreFiles.join(', ')}`);
159
- }
160
- }
161
- console.log();
162
- }
163
- const nonInteractive = options.nonInteractive || options.yes || jsonMode;
164
- // Fix-4 (P0-BUG-4): In non-interactive mode, collect runtime profile from
165
- // CLI flags (--provider/--api-key-env/--model) or env vars
166
- // (PD_PROVIDER/PD_API_KEY_ENV/PD_MODEL). rc-9: when provider is given
167
- // without apiKeyEnv, fail loud instead of silently writing an unusable
168
- // profile. rc-3: validate provider allowlist and apiKeyEnv format before
169
- // writing, reusing the same patterns as prompts.ts.
170
- if (nonInteractive) {
171
- const provider = typeof options.provider === 'string' ? options.provider : process.env.PD_PROVIDER;
172
- const apiKeyEnv = typeof options.apiKeyEnv === 'string' ? options.apiKeyEnv : process.env.PD_API_KEY_ENV;
173
- const model = typeof options.model === 'string' ? options.model : process.env.PD_MODEL;
174
- if (provider) {
175
- const allowedProviders = ['openai', 'anthropic', 'deepseek'];
176
- if (!allowedProviders.includes(provider)) {
177
- const msg = `--provider "${provider}" is not supported. Valid: openai, anthropic, deepseek.`;
178
- if (jsonMode) {
179
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_invalid', msg), null, 2));
180
- }
181
- else {
182
- logger.error(msg);
183
- }
184
- process.exit(1);
185
- return;
186
- }
187
- if (!apiKeyEnv) {
188
- const msg = `--provider "${provider}" given but --api-key-env is missing. Pass --api-key-env OPENAI_API_KEY (or set PD_API_KEY_ENV).`;
189
- if (jsonMode) {
190
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_incomplete', msg), null, 2));
191
- }
192
- else {
193
- logger.error(msg);
194
- }
195
- process.exit(1);
196
- return;
197
- }
198
- if (!/^[A-Z_][A-Z0-9_]*$/.test(apiKeyEnv)) {
199
- const msg = `--api-key-env "${apiKeyEnv}" is not a valid environment variable name (uppercase letters, digits, underscore; cannot start with a digit).`;
200
- if (jsonMode) {
201
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_invalid', msg), null, 2));
202
- }
203
- else {
204
- logger.error(msg);
205
- }
206
- process.exit(1);
207
- return;
208
- }
209
- // Round-4 S2: a blank --model / PD_MODEL is an EXPLICIT invalid value —
210
- // fail loud instead of silently treating it as omitted (the governance
211
- // write boundary enforces the same rule).
212
- if (typeof model === 'string' && model.trim().length === 0) {
213
- const msg = `--model was given but blank. Pass a non-empty model id, or omit --model to keep the existing configured model (or apply the per-provider default).`;
214
- if (jsonMode) {
215
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_invalid', msg), null, 2));
216
- }
217
- else {
218
- logger.error(msg);
219
- }
220
- process.exit(1);
221
- return;
222
- }
223
- cliOptions.runtimeProfile = { provider, apiKeyEnv, model: model || undefined };
224
- // Round-4 R3 / round-5 S3: --base-url / PD_BASE_URL — an OpenAI-compatible
225
- // custom endpoint. Present → pi-ai calls it directly and skips the
226
- // provider model catalog. rc-3: an EXPLICIT blank value fails loud (same
227
- // rule as blank --model); a value that does not parse as a real http(s)
228
- // URL fails loud (a prefix regex let `https://` through).
229
- const baseUrlRaw = typeof options.baseUrl === 'string' ? options.baseUrl : process.env.PD_BASE_URL;
230
- if (baseUrlRaw !== undefined) {
231
- const trimmed = baseUrlRaw.trim();
232
- if (trimmed.length === 0) {
233
- const msg = `--base-url was given but blank. Pass a valid http(s) endpoint URL, or omit --base-url to use the provider default.`;
234
- if (jsonMode) {
235
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_invalid', msg), null, 2));
236
- }
237
- else {
238
- logger.error(msg);
239
- }
240
- process.exit(1);
241
- return;
242
- }
243
- if (!isValidHttpBaseUrl(trimmed)) {
244
- const msg = `--base-url "${trimmed}" is not a valid http(s) URL with a hostname.`;
245
- if (jsonMode) {
246
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_invalid', msg), null, 2));
247
- }
248
- else {
249
- logger.error(msg);
250
- }
251
- process.exit(1);
252
- return;
253
- }
254
- cliOptions.runtimeProfile.baseUrl = trimmed;
255
- }
256
- }
257
- else if (apiKeyEnv) {
258
- // rc-3: fail loud — apiKeyEnv without provider is unusable.
259
- const msg = `--api-key-env given without --provider. Pass --provider openai (or set PD_PROVIDER).`;
260
- if (jsonMode) {
261
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_incomplete', msg), null, 2));
262
- }
263
- else {
264
- logger.error(msg);
265
- }
266
- process.exit(1);
267
- return;
268
- }
269
- else if (options.baseUrl !== undefined || process.env.PD_BASE_URL !== undefined) {
270
- // Round-5 S3 (rc-9/cli-6): an endpoint without a provider cannot attach
271
- // to any profile — fail loud instead of silently dropping it (explicit
272
- // blank included; blanks fail loud in the provider branch too).
273
- const msg = `--base-url given without --provider. Pass --provider openai (or set PD_PROVIDER).`;
274
- if (jsonMode) {
275
- console.log(JSON.stringify(buildFailureOutput('runtime_profile_incomplete', msg), null, 2));
276
- }
277
- else {
278
- logger.error(msg);
279
- }
280
- process.exit(1);
281
- return;
282
- }
283
- }
284
- const installOptions = nonInteractive
285
- ? {
286
- language: cliOptions.language || getLanguage(),
287
- mode: cliOptions.mode || (workspaceInfo.isFirstInstall ? 'force' : 'smart'),
288
- workspaceDir: cliOptions.workspaceDir || workspaceInfo.detectedPath,
289
- channels: [...MVP_CHANNELS],
290
- overwriteConfig: false,
291
- // ADR-0020 §2.3: propagate validated host target into install options.
292
- host,
293
- runtimeProfile: cliOptions.runtimeProfile,
294
- stopGateway: cliOptions.stopGateway === true,
295
- }
296
- : await runPrompts(cliOptions, workspaceInfo);
297
- if (!installOptions) {
298
- if (jsonMode) {
299
- console.log(JSON.stringify(buildFailureOutput('cancelled', 'Re-run the installer'), null, 2));
300
- }
301
- else {
302
- logger.info(t('cancel_install'));
303
- }
304
- process.exit(0);
305
- return;
306
- }
307
- // Test/hermetic-build override: when set, it must point at a COMPLETE
308
- // self-contained release asset directory (component trees + _release
309
- // manifest). Production never sets it. The env value is a PATH reaching
310
- // install()'s file operations, so it is validated (absolute, no parent
311
- // traversal) before use — an unvalidated env path here would be a
312
- // path-traversal trust boundary hole even for a test-only override.
313
- const pluginDirOverride = process.env.PD_INSTALL_PLUGIN_DIR;
314
- if (pluginDirOverride !== undefined
315
- && (!path.isAbsolute(pluginDirOverride) || pluginDirOverride.includes('..'))) {
316
- console.log(JSON.stringify(buildFailureOutput('invalid_environment', `PD_INSTALL_PLUGIN_DIR must be an absolute directory path without '..': ${JSON.stringify(pluginDirOverride)}`), null, 2));
317
- process.exit(1);
318
- return;
319
- }
320
- const pluginDir = pluginDirOverride ?? PLUGIN_DIR;
321
- const result = await install(installOptions, pluginDir, { quiet: jsonMode, nonInteractive: Boolean(nonInteractive) });
322
- // WorkBuddy remediation (review round-2 #2): the operator-facing hints
323
- // below must name the directory the console/canary actually manage — the
324
- // governance workspace for the workbuddy host, the project dir otherwise
325
- // (same resolution the installer's own nextActions use).
326
- const operatorWorkspaceDir = resolveConsoleWorkspaceDir(host, result.workspaceDir, getHomeDir());
327
- if (jsonMode) {
328
- const output = toInstallJsonOutput(result);
329
- console.log(JSON.stringify(output, null, 2));
330
- if (!result.success) {
331
- process.exit(1);
332
- return;
333
- }
334
- }
335
- else {
336
- if (result.success) {
337
- console.log();
338
- logger.success(t('install_complete'));
339
- console.log();
340
- console.log(t('principles_disciple_setup'));
341
- console.log();
342
- console.log(t('detecting_environment'));
343
- console.log(` OpenClaw integration target .... ${env.hasOpenClaw ? t('openclaw_target_found') : t('openclaw_target_not_found')}`);
344
- console.log(` Node.js ........................ ${t('node_found')} (${env.nodeVersion})`);
345
- console.log();
346
- console.log(t('installing_mvp_components'));
347
- console.log(` Runtime integration ............ ${result.components.plugin}`);
348
- console.log(` Operator CLI ................... ${result.components.cli}`);
349
- console.log(` Review console ................. ${result.components.console}${result.components.consoleEntrypoint ? ` (${result.components.consoleEntrypoint})` : ''}`);
350
- console.log();
351
- console.log(t('enabled_capabilities'));
352
- for (const ch of result.enabledChannels) {
353
- console.log(` ${ch}`);
354
- }
355
- console.log();
356
- console.log(t('verification'));
357
- console.log(` Configuration .................. ${result.verification.features}`);
358
- console.log(` Demo verification .............. ${result.verification.storyA}${result.verification.storyASkipReason ? ` (${result.verification.storyASkipReason})` : ''}`);
359
- // Fix-4: surface runtime profile status so the user knows whether LLM
360
- // features (diagnose, candidate intake, internalization) will work.
361
- // Round-3 remediation P1: the WorkBuddy host writes the profile into
362
- // the GOVERNANCE workspace config (and fails the install loudly if the
363
- // write fails), so this success line can truthfully name that file —
364
- // reaching it at all means the write was round-trip verified. Other
365
- // hosts keep the project-dir profile (operatorWorkspaceDir === project
366
- // workspace there); the line stays path-free for them (an existing
367
- // valid config is preserved verbatim, so a path claim could be false).
368
- if (installOptions.runtimeProfile) {
369
- const profileLocation = host === 'workbuddy'
370
- ? ` [written to ${path.join(operatorWorkspaceDir, '.pd', 'config.yaml')}]`
371
- : '';
372
- console.log(` LLM runtime profile ............ ${installOptions.runtimeProfile.provider} / ${installOptions.runtimeProfile.model ?? '(default)'} (key: $${installOptions.runtimeProfile.apiKeyEnv})${profileLocation}`);
373
- }
374
- else {
375
- console.log(` LLM runtime profile ............ NOT CONFIGURED — internal agents stay in needs_setup`);
376
- console.log(` evidence is still captured, but nothing is diagnosed and no principle is proposed`);
377
- console.log(` fix: set provider / model / apiKeyEnv on 'pd.default' in .pd/config.yaml, or`);
378
- console.log(` re-run with --provider <name> --api-key-env <ENV_VAR_NAME>, or`);
379
- console.log(` use the console: pd console open --workspace "${operatorWorkspaceDir}"`);
380
- }
381
- // PRI-1064: governance switch state is a first-class summary line —
382
- // "Install complete!" while every hook silently skips is exactly the
383
- // P1 defect this replaces. An explicit Owner opt-out stays OFF and is
384
- // stated as such; everything else is ON by default.
385
- for (const hr of result.hostResults ?? []) {
386
- if (!hr.governance)
387
- continue;
388
- const keywordPart = hr.governance.keywordPainEnabled === undefined ? '' : `, keyword Pain: ${hr.governance.keywordPainEnabled ? 'ON' : 'OFF'}`;
389
- const stateLine = hr.governance.enabled
390
- ? `ON${hr.governance.explicitOptOut ? '' : ' (default)'}`
391
- : 'OFF (your explicit opt-out was preserved)';
392
- console.log(` ${hr.hostId} governance ............. ${stateLine}${keywordPart}`);
393
- const disabledFlags = [];
394
- if (!hr.governance.enabled)
395
- disabledFlags.push('host.workbuddy');
396
- if (hr.governance.keywordPainEnabled === false)
397
- disabledFlags.push('workbuddy_live_keyword_pain');
398
- if (disabledFlags.length > 0) {
399
- // PRI-1063/1064 review: name the exact flag ids and the exact edit.
400
- // A `features.<flag>.enabled=true` placeholder left the operator to
401
- // guess both the id and whether the dotted form is nested. It is NOT
402
- // nested: the dotted id is one flat key inside the existing
403
- // `features:` block, and the flow mapping below keeps the line
404
- // copy-pasteable (no new `features:` key that would duplicate one).
405
- const target = hr.governance.configPath ?? 'the governance workspace .pd/config.yaml';
406
- const edits = disabledFlags.map((flag) => `${flag}: {enabled: true}`).join(' or ');
407
- console.log(` to enable: in ${target}, inside the existing "features:" block set ${edits}`);
408
- }
409
- }
410
- console.log();
411
- console.log(t('ready'));
412
- console.log(`${t('diagnostics')}: pd runtime canary --workspace "${operatorWorkspaceDir}" --json`);
413
- }
414
- else if (result.components.plugin === 'verified' && (result.components.cli === 'verified' || result.components.cli === 'verified_local_only')) {
415
- const cliLabel = result.components.cli === 'verified_local_only' ? 'verified (local only)' : result.components.cli;
416
- const diagCmd = result.components.cli === 'verified_local_only' && result.components.cliLocalPath
417
- ? `"${result.components.cliLocalPath}" runtime canary --workspace "${operatorWorkspaceDir}" --json`
418
- : `pd runtime canary --workspace "${operatorWorkspaceDir}" --json`;
419
- console.log();
420
- logger.warn(t('install_partial_complete'));
421
- console.log();
422
- console.log(t('principles_disciple_setup'));
423
- console.log();
424
- console.log(t('installing_mvp_components'));
425
- console.log(` Runtime integration ............ ${result.components.plugin}`);
426
- console.log(` Operator CLI ................... ${cliLabel}`);
427
- console.log(` Review console ................. ${result.components.console}`);
428
- console.log();
429
- console.log(t('enabled_capabilities'));
430
- for (const ch of result.enabledChannels) {
431
- console.log(` ${ch}`);
432
- }
433
- console.log();
434
- console.log(t('verification'));
435
- console.log(` Configuration .................. ${result.verification.features}`);
436
- console.log(` Demo verification .............. ${result.verification.storyA}${result.verification.storyASkipReason ? ` (${result.verification.storyASkipReason})` : ''}`);
437
- console.log();
438
- console.log(t('not_ready_for_release'));
439
- console.log(`${t('diagnostics')}: ${diagCmd}`);
440
- process.exit(1);
441
- return;
442
- }
443
- else {
444
- logger.error(`${t('install_failed')}: ${result.reason || result.error}`);
445
- if (result.nextAction) {
446
- logger.info(`${t('next_action')}: ${result.nextAction}`);
447
- }
448
- process.exit(1);
449
- return;
450
- }
451
- }
452
- }
453
- async function runUninstall(options) {
454
- // rc-3-fail-loud: validate --lang the same way runInstall does, instead of
455
- // silently defaulting any non-'en' value to 'zh'.
456
- if (!isLanguage(options.lang)) {
457
- logger.error(`--lang must be 'zh' or 'en', got: ${JSON.stringify(options.lang)}`);
458
- logger.info(`Next: re-run with --lang zh or --lang en`);
459
- process.exit(1);
460
- return;
461
- }
462
- setLanguage(options.lang);
463
- // ADR-0020 §2.3: validate --host (default 'all' for uninstall).
464
- const rawHost = typeof options.host === 'string' ? options.host : 'all';
465
- if (!isHostTarget(rawHost)) {
466
- logger.error(`--host must be one of: ${HOST_TARGETS.join(', ')}. Got: ${JSON.stringify(rawHost)}`);
467
- logger.info(`Next: re-run with --host openclaw (or --host codex / --host all)`);
468
- process.exit(1);
469
- return;
470
- }
471
- const host = rawHost;
472
- console.log(banner);
473
- console.log();
474
- logger.info(`Preparing to uninstall Principles Disciple (host: ${host})...\n`);
475
- const result = await uninstall({
476
- force: options.force === true,
477
- lang: options.lang,
478
- host,
479
- });
480
- if (!result.success) {
481
- logger.error(`${t('uninstall_failed')}: ${result.error}`);
482
- process.exit(1);
483
- return;
484
- }
485
- }
486
- async function showStatus(options) {
487
- // rc-3-fail-loud: validate --lang the same way runInstall does.
488
- if (!isLanguage(options.lang)) {
489
- logger.error(`--lang must be 'zh' or 'en', got: ${JSON.stringify(options.lang)}`);
490
- logger.info(`Next: re-run with --lang zh or --lang en`);
491
- process.exit(1);
492
- return;
493
- }
494
- setLanguage(options.lang);
495
- console.log(banner);
496
- console.log();
497
- const status = checkInstallStatus();
498
- console.log(`${t('install_status')}\n`);
499
- for (const p of status.paths) {
500
- const icon = p.type === 'dir' ? '[dir]' : '[file]';
501
- const statusIcon = p.exists ? t('install_status_ok') : t('install_status_missing');
502
- console.log(` ${statusIcon} ${icon} ${p.name}`);
503
- console.log(` ${p.path}`);
504
- }
505
- console.log();
506
- if (status.isInstalled) {
507
- logger.success(t('pd_installed'));
508
- console.log('\n User data (MD files, memory, state) is preserved on uninstall');
509
- }
510
- else {
511
- logger.warn(t('pd_not_installed'));
512
- console.log(`\n ${t('install_hint')}:`);
513
- console.log(' npx create-principles-disciple');
514
- }
515
- }
516
- // cli-7: exported so parser tests can inspect the REAL option registration
517
- // (catches removal/rename/default-change of flags). Not .parse()'d on import —
518
- // see the main-module guard at the bottom of this file.
519
- export const program = new Command();
520
- program
521
- .name('create-principles-disciple')
522
- .description('Principles Disciple - MVP-First Integration Wizard')
523
- .version(pkgVersion);
524
- program
525
- .command('install', { isDefault: true, hidden: true })
526
- .description('Install Principles Disciple (MVP-First)')
527
- .option('-l, --lang <lang>', 'Language (zh/en)', 'zh')
528
- .option('-f, --force', 'Force overwrite mode', false)
529
- .option('-s, --smart', 'Smart merge mode', false)
530
- .option('-w, --workspace <path>', 'Workspace directory')
531
- .option('-y, --yes', 'Non-interactive mode with defaults', false)
532
- .option('--non-interactive', 'Skip interactive prompts', false)
533
- .option('--json', 'Output result as JSON (implies non-interactive)', false)
534
- // Fix-4 (P0-BUG-4): allow non-interactive LLM runtime profile configuration.
535
- // When --provider is given, the installer pre-fills pd.default profile
536
- // instead of leaving it empty (which would cause silent LLM failures).
537
- .option('--provider <provider>', 'LLM provider for pd.default profile (openai/anthropic/deepseek). Enables non-interactive runtime profile config.')
538
- .option('--api-key-env <name>', 'Environment variable name holding the LLM API key (e.g. OPENAI_API_KEY). Requires --provider.')
539
- .option('--model <model>', 'LLM model id (optional; keeps the existing configured model, else applies the per-provider default)')
540
- .option('--base-url <url>', 'OpenAI-compatible custom endpoint for pd.default (optional; present = call it directly, skip the provider model catalog). Env: PD_BASE_URL.')
541
- // ADR-0020 §2.3: host target selector. Default 'openclaw' for backward compat.
542
- .option('--host <host>', `Host platform (${HOST_TARGETS.join('/')})`, 'openclaw')
543
- // Gateway lock prevention: auto-stop a running OpenClaw gateway before
544
- // install (avoids EPERM on the backup rename) and restart it afterwards.
545
- .option('--stop-gateway', 'Stop the OpenClaw gateway before install if running, restart after', false)
546
- .action(async (options) => {
547
- await runInstall(options);
548
- });
549
- program
550
- .command('uninstall')
551
- .alias('remove')
552
- .alias('rm')
553
- .description('Uninstall Principles Disciple (preserves user data)')
554
- .option('-f, --force', 'Force uninstall without confirmation', false)
555
- .option('-l, --lang <lang>', 'Language (zh/en)', 'zh')
556
- // ADR-0020 §2.3: host-scoped uninstall. Default 'all' cleans every host
557
- // PD ever registered with. Operators can scope to one host via --host codex.
558
- .option('--host <host>', `Host platform (${HOST_TARGETS.join('/')})`, 'all')
559
- .action(async (options) => {
560
- await runUninstall(options);
561
- });
562
- program
563
- .command('status')
564
- .description('Check install status')
565
- .option('-l, --lang <lang>', 'Language (zh/en)', 'zh')
566
- .action(async (options) => {
567
- await showStatus(options);
568
- });
569
- // PRI-850 (SPEC v0.3 §6.1, ADR-0024 §6): the official repair path for
570
- // installations whose update chain is broken or pre-bootstrap. Deploys the
571
- // bootstrap update executor and registers the release metadata source; NEVER
572
- // deploys a product release or changes the installed product version.
573
- program
574
- .command('repair-update-chain')
575
- .description('Repair the self-update capability (bootstrap executor + update source) without touching the installed product')
576
- .option('--json', 'Output result as JSON', false)
577
- .action(async (options) => {
578
- // PRI-850 review fix (cli-1): --json stdout must be EXACTLY one parseable
579
- // JSON document — the logger (and its ℹ/warn banners) is silenced first,
580
- // so delivery progress can never precede the JSON on stdout.
581
- if (options.json)
582
- setQuietMode(true);
583
- const { repairUpdateChain } = await import('./installer.js');
584
- const result = await repairUpdateChain({
585
- sourcePackageDir: path.resolve(url.fileURLToPath(import.meta.url), '../..'),
586
- });
587
- if (options.json) {
588
- console.log(JSON.stringify(result, null, 2));
589
- }
590
- else {
591
- for (const note of result.notes)
592
- console.log(`- ${note}`);
593
- if (result.success) {
594
- console.log(`Repair complete: bootstrap ${result.bootstrap?.bootstrapVersion ?? 'n/a'} deployed.`);
595
- if (result.needsFullInstall)
596
- console.log('This installation still needs one full official install to deploy a product release.');
597
- }
598
- else {
599
- console.error(`Repair failed: ${result.error ?? 'unknown error'}`);
600
- }
601
- }
602
- if (!result.success)
603
- process.exitCode = 1;
604
- });
605
- // cli-7: only wire the process handler and parse argv when this module is the
606
- // CLI entry point — NOT when imported by tests (which inspect `program` opts
607
- // directly). Without this guard, importing index.js would run the installer.
608
- //
609
- // PRI-892: Node resolves the main module through symlinks/junctions, so
610
- // `import.meta.url` is the realpath while `process.argv[1]` is the unresolved
611
- // link path that npm/npx `.bin` shims hand to node on Windows. The old raw
612
- // `pathToFileURL(argv[1])` comparison never matched through the shim, so the
613
- // CLI silently exited 0 doing nothing. Canonicalize argv[1] with realpathSync
614
- // before comparing, and keep the import-time (argv[1] is a test runner) path
615
- // returning false so cli-7 stays intact.
616
- function isMainModuleEntry() {
617
- const [, entry] = process.argv;
618
- if (!entry)
619
- return false;
620
- try {
621
- return url.pathToFileURL(realpathSync(entry)).href === import.meta.url;
622
- }
623
- catch {
624
- return false;
625
- }
626
- }
627
- // rc-9: realpath canonicalization should close the gap, but if some future
628
- // link topology still slips past it while argv[1] unambiguously names *this*
629
- // package's `dist/index.js`, fail loud and run rather than repeat the silent
630
- // no-op. Import-time callers never satisfy this (argv[1] is the test runner).
631
- // path.relative absorbs mixed / and \ separators (win32); deliberately no
632
- // link resolution here — this check exists exactly for when it diverges.
633
- function looksLikeOwnDistEntry() {
634
- const [, entry] = process.argv;
635
- if (!entry)
636
- return false;
637
- const relative = path.relative(path.dirname(PLUGIN_DIR), path.resolve(entry));
638
- return relative === path.join(path.basename(PLUGIN_DIR), 'dist', 'index.js');
639
- }
640
- const mainModuleEntry = isMainModuleEntry();
641
- if (mainModuleEntry || looksLikeOwnDistEntry()) {
642
- if (!mainModuleEntry) {
643
- process.stderr.write('warning: CLI entry started via fallback detection: reason=entry_identity_mismatch nextAction=report-this-line-with-your-invocation-command\n');
644
- }
645
- process.on('uncaughtException', (error) => {
646
- if (error instanceof Error && error.name === 'ExitPromptError') {
647
- logger.info('Goodbye!');
648
- }
649
- else {
650
- logger.error(`Uncaught error: ${error.message}`);
651
- process.exit(1);
652
- }
653
- });
654
- program.parse(process.argv);
655
- }
656
- //# sourceMappingURL=index.js.map