create-principles-disciple 1.76.0 → 1.78.0

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 (217) hide show
  1. package/console/dist/server/config/feature-flags.d.ts +25 -0
  2. package/console/dist/server/config/feature-flags.js +101 -0
  3. package/console/dist/server/index.js +16 -0
  4. package/console/dist/server/models/FeedbackReportConsoleModel.d.ts +49 -0
  5. package/console/dist/server/models/FeedbackReportConsoleModel.js +242 -0
  6. package/console/dist/server/routes/feedback-reports.d.ts +18 -0
  7. package/console/dist/server/routes/feedback-reports.js +165 -0
  8. package/console/dist/ui/App.js +2 -1
  9. package/console/dist/ui/api.d.ts +26 -2
  10. package/console/dist/ui/api.js +18 -1
  11. package/console/dist/ui/components/app-sidebar.js +2 -1
  12. package/console/dist/ui/components/error-boundary.js +9 -2
  13. package/console/dist/ui/i18n/en.json +67 -1
  14. package/console/dist/ui/i18n/zh-CN.json +67 -1
  15. package/console/dist/ui/pages/ReportProblemPage.d.ts +1 -0
  16. package/console/dist/ui/pages/ReportProblemPage.js +186 -0
  17. package/console/dist/ui/pages/ReportProblemValidators.d.ts +51 -0
  18. package/console/dist/ui/pages/ReportProblemValidators.js +114 -0
  19. package/console/dist/web/assets/app.css +18 -0
  20. package/console/dist/web/assets/app.js +1047 -125
  21. package/console/package.json +1 -0
  22. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +24 -1
  23. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  24. package/core/dist/runtime-v2/__tests__/feedback/create-report.test.d.ts +2 -0
  25. package/core/dist/runtime-v2/__tests__/feedback/create-report.test.d.ts.map +1 -0
  26. package/core/dist/runtime-v2/__tests__/feedback/create-report.test.js +402 -0
  27. package/core/dist/runtime-v2/__tests__/feedback/create-report.test.js.map +1 -0
  28. package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.d.ts +2 -0
  29. package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.d.ts.map +1 -0
  30. package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.js +128 -0
  31. package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.js.map +1 -0
  32. package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.d.ts +2 -0
  33. package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.d.ts.map +1 -0
  34. package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.js +231 -0
  35. package/core/dist/runtime-v2/__tests__/feedback/redact-sensitive.test.js.map +1 -0
  36. package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.d.ts +2 -0
  37. package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.d.ts.map +1 -0
  38. package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.js +102 -0
  39. package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.js.map +1 -0
  40. package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.d.ts +2 -0
  41. package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.d.ts.map +1 -0
  42. package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.js +130 -0
  43. package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.js.map +1 -0
  44. package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.d.ts +2 -0
  45. package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.d.ts.map +1 -0
  46. package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.js +328 -0
  47. package/core/dist/runtime-v2/__tests__/workspace-guidance-migration.test.js.map +1 -0
  48. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.d.ts +2 -0
  49. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.d.ts.map +1 -0
  50. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +343 -0
  51. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -0
  52. package/core/dist/runtime-v2/activation/index.d.ts +2 -0
  53. package/core/dist/runtime-v2/activation/index.d.ts.map +1 -1
  54. package/core/dist/runtime-v2/activation/index.js +1 -0
  55. package/core/dist/runtime-v2/activation/index.js.map +1 -1
  56. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts +34 -0
  57. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts.map +1 -0
  58. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +109 -0
  59. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -0
  60. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +13 -0
  61. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  62. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.d.ts +2 -0
  63. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.d.ts.map +1 -0
  64. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js +141 -0
  65. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js.map +1 -0
  66. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  67. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +4 -1
  68. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  69. package/core/dist/runtime-v2/feature-flags/index.d.ts +2 -0
  70. package/core/dist/runtime-v2/feature-flags/index.d.ts.map +1 -1
  71. package/core/dist/runtime-v2/feature-flags/index.js +1 -0
  72. package/core/dist/runtime-v2/feature-flags/index.js.map +1 -1
  73. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts +25 -0
  74. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts.map +1 -0
  75. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js +233 -0
  76. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js.map +1 -0
  77. package/core/dist/runtime-v2/feedback/create-report.d.ts +14 -0
  78. package/core/dist/runtime-v2/feedback/create-report.d.ts.map +1 -0
  79. package/core/dist/runtime-v2/feedback/create-report.js +257 -0
  80. package/core/dist/runtime-v2/feedback/create-report.js.map +1 -0
  81. package/core/dist/runtime-v2/feedback/feedback-types.d.ts +120 -0
  82. package/core/dist/runtime-v2/feedback/feedback-types.d.ts.map +1 -0
  83. package/core/dist/runtime-v2/feedback/feedback-types.js +243 -0
  84. package/core/dist/runtime-v2/feedback/feedback-types.js.map +1 -0
  85. package/core/dist/runtime-v2/feedback/index.d.ts +9 -0
  86. package/core/dist/runtime-v2/feedback/index.d.ts.map +1 -0
  87. package/core/dist/runtime-v2/feedback/index.js +11 -0
  88. package/core/dist/runtime-v2/feedback/index.js.map +1 -0
  89. package/core/dist/runtime-v2/feedback/internal-guards.d.ts +2 -0
  90. package/core/dist/runtime-v2/feedback/internal-guards.d.ts.map +1 -0
  91. package/core/dist/runtime-v2/feedback/internal-guards.js +6 -0
  92. package/core/dist/runtime-v2/feedback/internal-guards.js.map +1 -0
  93. package/core/dist/runtime-v2/feedback/privacy-preview.d.ts +14 -0
  94. package/core/dist/runtime-v2/feedback/privacy-preview.d.ts.map +1 -0
  95. package/core/dist/runtime-v2/feedback/privacy-preview.js +128 -0
  96. package/core/dist/runtime-v2/feedback/privacy-preview.js.map +1 -0
  97. package/core/dist/runtime-v2/feedback/redact-sensitive.d.ts +37 -0
  98. package/core/dist/runtime-v2/feedback/redact-sensitive.d.ts.map +1 -0
  99. package/core/dist/runtime-v2/feedback/redact-sensitive.js +272 -0
  100. package/core/dist/runtime-v2/feedback/redact-sensitive.js.map +1 -0
  101. package/core/dist/runtime-v2/feedback/render-github-url.d.ts +21 -0
  102. package/core/dist/runtime-v2/feedback/render-github-url.d.ts.map +1 -0
  103. package/core/dist/runtime-v2/feedback/render-github-url.js +57 -0
  104. package/core/dist/runtime-v2/feedback/render-github-url.js.map +1 -0
  105. package/core/dist/runtime-v2/feedback/render-markdown.d.ts +12 -0
  106. package/core/dist/runtime-v2/feedback/render-markdown.d.ts.map +1 -0
  107. package/core/dist/runtime-v2/feedback/render-markdown.js +166 -0
  108. package/core/dist/runtime-v2/feedback/render-markdown.js.map +1 -0
  109. package/core/dist/runtime-v2/feedback/safe-stringify.d.ts +6 -0
  110. package/core/dist/runtime-v2/feedback/safe-stringify.d.ts.map +1 -0
  111. package/core/dist/runtime-v2/feedback/safe-stringify.js +115 -0
  112. package/core/dist/runtime-v2/feedback/safe-stringify.js.map +1 -0
  113. package/core/dist/runtime-v2/index.d.ts +8 -1
  114. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  115. package/core/dist/runtime-v2/index.js +12 -1
  116. package/core/dist/runtime-v2/index.js.map +1 -1
  117. package/core/dist/runtime-v2/workspace-guidance-migration.d.ts +12 -0
  118. package/core/dist/runtime-v2/workspace-guidance-migration.d.ts.map +1 -0
  119. package/core/dist/runtime-v2/workspace-guidance-migration.js +193 -0
  120. package/core/dist/runtime-v2/workspace-guidance-migration.js.map +1 -0
  121. package/core/package.json +4 -0
  122. package/package.json +1 -1
  123. package/plugin/dist/commands/context.js +5 -5
  124. package/plugin/dist/commands/strategy.d.ts +0 -1
  125. package/plugin/dist/commands/strategy.js +0 -14
  126. package/plugin/dist/core/runtime-v2-prompt-activation-reader.d.ts +4 -13
  127. package/plugin/dist/core/runtime-v2-prompt-activation-reader.js +36 -74
  128. package/plugin/dist/core/surface-guard.d.ts +27 -0
  129. package/plugin/dist/core/surface-guard.js +82 -0
  130. package/plugin/dist/core/workspace-guidance-migrator.d.ts +12 -0
  131. package/plugin/dist/core/workspace-guidance-migrator.js +141 -0
  132. package/plugin/dist/hooks/prompt.js +20 -143
  133. package/plugin/dist/i18n/commands.js +2 -14
  134. package/plugin/dist/index.d.ts +27 -0
  135. package/plugin/dist/index.js +180 -65
  136. package/plugin/dist/service/correction-observer-service.d.ts +11 -0
  137. package/plugin/dist/service/correction-observer-service.js +172 -0
  138. package/plugin/dist/service/evolution-worker.js +1 -110
  139. package/plugin/dist/types.d.ts +2 -2
  140. package/plugin/dist/types.js +3 -3
  141. package/plugin/templates/langs/en/core/BOOTSTRAP.md +5 -19
  142. package/plugin/templates/langs/en/principles/THINKING_OS.md +1 -1
  143. package/plugin/templates/langs/en/skills/admin/SKILL.md +2 -2
  144. package/plugin/templates/langs/en/skills/bootstrap-tools/SKILL.md +1 -1
  145. package/plugin/templates/langs/en/skills/init-strategy/SKILL.md +1 -1
  146. package/plugin/templates/langs/en/skills/pd-mentor/SKILL.md +8 -23
  147. package/plugin/templates/langs/en/skills/reflection/SKILL.md +2 -2
  148. package/plugin/templates/langs/en/skills/report/SKILL.md +1 -1
  149. package/plugin/templates/langs/zh/core/BOOTSTRAP.md +3 -16
  150. package/plugin/templates/langs/zh/principles/THINKING_OS.md +1 -1
  151. package/plugin/templates/langs/zh/skills/admin/SKILL.md +2 -2
  152. package/plugin/templates/langs/zh/skills/bootstrap-tools/SKILL.md +1 -1
  153. package/plugin/templates/langs/zh/skills/init-strategy/SKILL.md +1 -1
  154. package/plugin/templates/langs/zh/skills/pd-mentor/SKILL.md +7 -22
  155. package/plugin/templates/langs/zh/skills/reflection/SKILL.md +2 -2
  156. package/plugin/templates/langs/zh/skills/report/SKILL.md +1 -1
  157. package/plugin/templates/workspace/.principles/THINKING_OS.md +1 -1
  158. package/templates/langs/en/core/BOOTSTRAP.md +1 -1
  159. package/templates/langs/en/principles/THINKING_OS.md +1 -1
  160. package/templates/langs/en/skills/admin/SKILL.md +2 -2
  161. package/templates/langs/en/skills/pd-grooming/SKILL.md +1 -1
  162. package/templates/langs/en/skills/reflection/SKILL.md +2 -2
  163. package/templates/langs/en/skills/report/SKILL.md +1 -1
  164. package/templates/langs/zh/core/BOOTSTRAP.md +1 -1
  165. package/templates/langs/zh/principles/THINKING_OS.md +1 -1
  166. package/templates/langs/zh/skills/admin/SKILL.md +2 -2
  167. package/templates/langs/zh/skills/pd-grooming/SKILL.md +1 -1
  168. package/templates/langs/zh/skills/reflection/SKILL.md +2 -2
  169. package/templates/langs/zh/skills/report/SKILL.md +1 -1
  170. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/EXAMPLES.md +0 -63
  171. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/REFERENCE.md +0 -136
  172. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/SKILL.md +0 -67
  173. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/agent-registry.json +0 -143
  174. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/bugfix-complex-template.json +0 -107
  175. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/feature-complex-template.json +0 -107
  176. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal-verify.json +0 -95
  177. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal.json +0 -98
  178. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/workflow-v1-acceptance-checklist.md +0 -58
  179. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/references/workflow-v1.4-work-unit-handoff.md +0 -190
  180. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/archive.mjs +0 -310
  181. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/contract-enforcement.mjs +0 -683
  182. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/decision.mjs +0 -604
  183. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/state-store.mjs +0 -32
  184. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/lib/task-specs.mjs +0 -707
  185. package/plugin/templates/langs/en/skills/ai-sprint-orchestration/scripts/run.mjs +0 -3455
  186. package/plugin/templates/langs/en/skills/evolve-system/SKILL.md +0 -46
  187. package/plugin/templates/langs/en/skills/manage-okr/SKILL.md +0 -96
  188. package/plugin/templates/langs/en/skills/pd-daily/SKILL.md +0 -199
  189. package/plugin/templates/langs/en/skills/pd-grooming/SKILL.md +0 -46
  190. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/EXAMPLES.md +0 -63
  191. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/REFERENCE.md +0 -136
  192. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/SKILL.md +0 -67
  193. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/agent-registry.json +0 -143
  194. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/bugfix-complex-template.json +0 -107
  195. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/feature-complex-template.json +0 -107
  196. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/nocturnal-trinity-quality-enhancement.json +0 -111
  197. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal-verify.json +0 -95
  198. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/specs/workflow-validation-minimal.json +0 -98
  199. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/workflow-v1-acceptance-checklist.md +0 -58
  200. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/references/workflow-v1.4-work-unit-handoff.md +0 -190
  201. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/runtime/.gitignore +0 -2
  202. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/archive.mjs +0 -310
  203. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/contract-enforcement.mjs +0 -683
  204. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/decision.mjs +0 -604
  205. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/state-store.mjs +0 -32
  206. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/lib/task-specs.mjs +0 -707
  207. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/scripts/run.mjs +0 -3455
  208. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/archive.test.mjs +0 -230
  209. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/contract-enforcement.test.mjs +0 -672
  210. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/decision.test.mjs +0 -1321
  211. package/plugin/templates/langs/zh/skills/ai-sprint-orchestration/test/run.test.mjs +0 -1435
  212. package/plugin/templates/langs/zh/skills/evolve-system/SKILL.md +0 -46
  213. package/plugin/templates/langs/zh/skills/manage-okr/SKILL.md +0 -109
  214. package/plugin/templates/langs/zh/skills/pd-daily/SKILL.md +0 -283
  215. package/plugin/templates/langs/zh/skills/pd-grooming/SKILL.md +0 -46
  216. package/plugin/templates/workspace/PLAN.md +0 -2
  217. package/templates/workspace/PLAN.md +0 -2
@@ -0,0 +1,193 @@
1
+ const MIGRATION_RULES = [
2
+ {
3
+ pattern: /Physical interception|physical blocking|物理拦截/i,
4
+ description: 'Remove Physical interception / physical blocking / 物理拦截 references (AGENTS.md)',
5
+ filenameSuffixes: ['AGENTS.md'],
6
+ actionType: 'remove-line',
7
+ },
8
+ {
9
+ pattern: /Single source of truth.*PLAN/i,
10
+ description: 'Remove Single source of truth PLAN references (AGENTS.md)',
11
+ filenameSuffixes: ['AGENTS.md'],
12
+ actionType: 'remove-line',
13
+ },
14
+ {
15
+ pattern: /PLAN\.md` \(status: READY\)|PLAN\.md`(状态:READY)/,
16
+ description: 'Remove PLAN.md status: READY references (AGENTS.md, THINKING_OS.md)',
17
+ filenameSuffixes: ['AGENTS.md', 'THINKING_OS.md'],
18
+ actionType: 'remove-line',
19
+ },
20
+ {
21
+ pattern: /project physical plan|项目物理计划/i,
22
+ description: 'Remove project physical plan / 项目物理计划 references (AGENTS.md)',
23
+ filenameSuffixes: ['AGENTS.md'],
24
+ actionType: 'remove-line',
25
+ },
26
+ {
27
+ pattern: /L2 delegation.*(PLAN|gate|blocking)|L2 委派.*(PLAN|gate|拦截)/i,
28
+ description: 'Remove L2 delegation / L2 委派 tied to PLAN.md gate enforcement (AGENTS.md)',
29
+ filenameSuffixes: ['AGENTS.md'],
30
+ actionType: 'remove-line',
31
+ },
32
+ {
33
+ pattern: / or `PLAN\.md`/,
34
+ description: 'Replace "or PLAN.md" in T-02 PHYSICAL_MEMORY_PERSISTENCE (en)',
35
+ filenameSuffixes: ['THINKING_OS.md'],
36
+ actionType: 'replace',
37
+ replacement: '',
38
+ },
39
+ {
40
+ pattern: /或 `PLAN\.md`/,
41
+ description: 'Replace "或 PLAN.md" in T-02 PHYSICAL_MEMORY_PERSISTENCE (zh)',
42
+ filenameSuffixes: ['THINKING_OS.md'],
43
+ actionType: 'replace',
44
+ replacement: '',
45
+ },
46
+ {
47
+ pattern: /PLAN\.md mechanism protects|PLAN\.md 机制保护/,
48
+ description: 'Remove PLAN.md mechanism protects / PLAN.md 机制保护 lines (MEMORY.md)',
49
+ filenameSuffixes: ['MEMORY.md'],
50
+ actionType: 'remove-line',
51
+ },
52
+ {
53
+ pattern: /STATUS: READY|STATUS:READY/,
54
+ description: 'Remove STATUS: READY references (MEMORY.md)',
55
+ filenameSuffixes: ['MEMORY.md'],
56
+ actionType: 'remove-line',
57
+ },
58
+ {
59
+ pattern: /Ensure `PLAN\.md` contains `## Target Files` heading|确保 `PLAN\.md` 包含 `## Target Files` 标题/,
60
+ description: 'Remove PLAN.md Target Files heading checks (admin/SKILL.md)',
61
+ filenameSuffixes: ['admin/SKILL.md'],
62
+ actionType: 'remove-line',
63
+ },
64
+ {
65
+ pattern: /,\s*`PLAN\.md`\s*/,
66
+ description: 'Remove PLAN.md from list as trailing item (admin/SKILL.md, pd-grooming/SKILL.md)',
67
+ filenameSuffixes: ['admin/SKILL.md', 'pd-grooming/SKILL.md'],
68
+ actionType: 'replace',
69
+ replacement: '',
70
+ },
71
+ {
72
+ pattern: /`PLAN\.md`\s*,\s*/,
73
+ description: 'Remove PLAN.md from list as leading item (admin/SKILL.md, pd-grooming/SKILL.md)',
74
+ filenameSuffixes: ['admin/SKILL.md', 'pd-grooming/SKILL.md'],
75
+ actionType: 'replace',
76
+ replacement: '',
77
+ },
78
+ {
79
+ pattern: /Check `PLAN\.md` or early conversation/,
80
+ description: 'Replace Check PLAN.md or early conversation (en, reflection/SKILL.md)',
81
+ filenameSuffixes: ['reflection/SKILL.md'],
82
+ actionType: 'replace',
83
+ replacement: 'Check early conversation context',
84
+ },
85
+ {
86
+ pattern: /Update `PLAN\.md`/,
87
+ description: 'Replace Update PLAN.md with Update memory/.scratchpad.md (en, reflection/SKILL.md)',
88
+ filenameSuffixes: ['reflection/SKILL.md'],
89
+ actionType: 'replace',
90
+ replacement: 'Update `memory/.scratchpad.md`',
91
+ },
92
+ {
93
+ pattern: /检查 `PLAN\.md` 或早期对话/,
94
+ description: 'Replace Check PLAN.md or early conversation (zh, reflection/SKILL.md)',
95
+ filenameSuffixes: ['reflection/SKILL.md'],
96
+ actionType: 'replace',
97
+ replacement: '检查早期对话上下文',
98
+ },
99
+ {
100
+ pattern: /更新 `PLAN\.md`/,
101
+ description: 'Replace Update PLAN.md (zh, reflection/SKILL.md)',
102
+ filenameSuffixes: ['reflection/SKILL.md'],
103
+ actionType: 'replace',
104
+ replacement: '更新 `memory/.scratchpad.md`',
105
+ },
106
+ {
107
+ pattern: /, `PLAN\.md`, and /,
108
+ description: 'Remove PLAN.md from task descriptions (en, report/SKILL.md)',
109
+ filenameSuffixes: ['report/SKILL.md'],
110
+ actionType: 'replace',
111
+ replacement: ' and ',
112
+ },
113
+ {
114
+ pattern: /、`PLAN\.md` 和/,
115
+ description: 'Remove PLAN.md from task descriptions (zh, report/SKILL.md)',
116
+ filenameSuffixes: ['report/SKILL.md'],
117
+ actionType: 'replace',
118
+ replacement: '和',
119
+ },
120
+ ];
121
+ export const STALE_PLAN_MD_PATTERNS = MIGRATION_RULES.map((rule) => ({ pattern: rule.pattern, description: rule.description }));
122
+ function filenameMatches(filename, suffix) {
123
+ const normalized = filename.replace(/\\/g, '/');
124
+ return normalized === suffix || normalized.endsWith('/' + suffix);
125
+ }
126
+ export function migrateWorkspaceGuidance(content, filename) {
127
+ if (content.length === 0) {
128
+ return { migrated: content, changed: false };
129
+ }
130
+ const applicableRules = MIGRATION_RULES.filter((rule) => rule.filenameSuffixes.some((suffix) => filenameMatches(filename, suffix)));
131
+ if (applicableRules.length === 0) {
132
+ return { migrated: content, changed: false };
133
+ }
134
+ const removeLineRules = applicableRules.filter((r) => r.actionType === 'remove-line');
135
+ const replaceRules = applicableRules.filter((r) => r.actionType === 'replace');
136
+ const triggeredDescriptions = [];
137
+ let memoryMdContentRemoved = false;
138
+ const lines = content.split('\n');
139
+ const keptLines = [];
140
+ for (const line of lines) {
141
+ let shouldRemove = false;
142
+ for (const rule of removeLineRules) {
143
+ if (rule.pattern.test(line)) {
144
+ shouldRemove = true;
145
+ if (!triggeredDescriptions.includes(rule.description)) {
146
+ triggeredDescriptions.push(rule.description);
147
+ }
148
+ if (filenameMatches(filename, 'MEMORY.md')) {
149
+ memoryMdContentRemoved = true;
150
+ }
151
+ break;
152
+ }
153
+ }
154
+ if (!shouldRemove) {
155
+ keptLines.push(line);
156
+ }
157
+ }
158
+ let migrated = keptLines.join('\n');
159
+ for (const rule of replaceRules) {
160
+ const replacement = rule.replacement ?? '';
161
+ const before = migrated;
162
+ const flags = rule.pattern.flags.includes('g')
163
+ ? rule.pattern.flags
164
+ : rule.pattern.flags + 'g';
165
+ const globalPattern = new RegExp(rule.pattern.source, flags);
166
+ migrated = migrated.replace(globalPattern, replacement);
167
+ if (migrated !== before && !triggeredDescriptions.includes(rule.description)) {
168
+ triggeredDescriptions.push(rule.description);
169
+ }
170
+ }
171
+ if (memoryMdContentRemoved) {
172
+ const historicalNote = '[Historical: confirm-first gate was removed in PRI-286. This section is preserved for reference only.]';
173
+ if (!migrated.endsWith('\n')) {
174
+ migrated = migrated + '\n';
175
+ }
176
+ migrated = migrated + historicalNote;
177
+ }
178
+ const changed = migrated !== content;
179
+ const reason = changed
180
+ ? `Migrated stale PLAN.md guidance: ${triggeredDescriptions.join('; ')}`
181
+ : undefined;
182
+ return { migrated, changed, reason };
183
+ }
184
+ export function containsStalePlanMdGuidance(content, filename) {
185
+ const applicableRules = MIGRATION_RULES.filter((rule) => rule.filenameSuffixes.some((suffix) => filenameMatches(filename, suffix)));
186
+ for (const rule of applicableRules) {
187
+ if (rule.pattern.test(content)) {
188
+ return true;
189
+ }
190
+ }
191
+ return false;
192
+ }
193
+ //# sourceMappingURL=workspace-guidance-migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-guidance-migration.js","sourceRoot":"","sources":["../../src/runtime-v2/workspace-guidance-migration.ts"],"names":[],"mappings":"AAgBA,MAAM,eAAe,GAAoB;IACvC;QACE,OAAO,EAAE,+CAA+C;QACxD,WAAW,EAAE,gFAAgF;QAC7F,gBAAgB,EAAE,CAAC,WAAW,CAAC;QAC/B,UAAU,EAAE,aAAa;KAC1B;IACD;QACE,OAAO,EAAE,+BAA+B;QACxC,WAAW,EAAE,2DAA2D;QACxE,gBAAgB,EAAE,CAAC,WAAW,CAAC;QAC/B,UAAU,EAAE,aAAa;KAC1B;IACD;QACE,OAAO,EAAE,iDAAiD;QAC1D,WAAW,EAAE,qEAAqE;QAClF,gBAAgB,EAAE,CAAC,WAAW,EAAE,gBAAgB,CAAC;QACjD,UAAU,EAAE,aAAa;KAC1B;IACD;QACE,OAAO,EAAE,+BAA+B;QACxC,WAAW,EAAE,8DAA8D;QAC3E,gBAAgB,EAAE,CAAC,WAAW,CAAC;QAC/B,UAAU,EAAE,aAAa;KAC1B;IACD;QACE,OAAO,EAAE,4DAA4D;QACrE,WAAW,EAAE,2EAA2E;QACxF,gBAAgB,EAAE,CAAC,WAAW,CAAC;QAC/B,UAAU,EAAE,aAAa;KAC1B;IACD;QACE,OAAO,EAAE,gBAAgB;QACzB,WAAW,EAAE,+DAA+D;QAC5E,gBAAgB,EAAE,CAAC,gBAAgB,CAAC;QACpC,UAAU,EAAE,SAAS;QACrB,WAAW,EAAE,EAAE;KAChB;IACD;QACE,OAAO,EAAE,cAAc;QACvB,WAAW,EAAE,8DAA8D;QAC3E,gBAA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AI,CAAC,IAAI,CAAC,EAAE;QACxE,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,OAAe,EACf,QAAgB;IAEhB,MAAM,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CACtD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAC1E,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
package/core/package.json CHANGED
@@ -65,6 +65,10 @@
65
65
  "./runtime-v2": {
66
66
  "types": "./dist/runtime-v2/index.d.ts",
67
67
  "default": "./dist/runtime-v2/index.js"
68
+ },
69
+ "./runtime-v2/feedback": {
70
+ "types": "./dist/runtime-v2/feedback/index.d.ts",
71
+ "default": "./dist/runtime-v2/feedback/index.js"
68
72
  }
69
73
  },
70
74
  "files": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.76.0",
3
+ "version": "1.78.0",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -185,7 +185,7 @@ function applyPreset(workspaceDir, preset, isZh) {
185
185
  break;
186
186
  case 'standard':
187
187
  config = {
188
- thinkingOs: true,
188
+ thinkingOs: false,
189
189
  projectFocus: 'off',
190
190
  evolutionContext: { ...defaultContextConfig.evolutionContext }
191
191
  };
@@ -230,8 +230,8 @@ function showHelp(isZh) {
230
230
 
231
231
  **预设模式**:
232
232
  \`/pd-context minimal\` - 最小模式(仅核心原则)
233
- \`/pd-context standard\` - 标准模式(原则+思维模型)
234
- \`/pd-context full\` - 完整模式(全部开启)
233
+ \`/pd-context standard\` - 标准模式(原则,不含思维模型)
234
+ \`/pd-context full\` - 完整模式(原则+思维模型+项目上下文)
235
235
 
236
236
  **注意**: 核心原则始终注入,不可关闭。
237
237
  `.trim();
@@ -250,8 +250,8 @@ function showHelp(isZh) {
250
250
 
251
251
  **Presets**:
252
252
  \`/pd-context minimal\` - Minimal mode (core principles only)
253
- \`/pd-context standard\` - Standard mode (principles + thinking)
254
- \`/pd-context full\` - Full mode (all enabled)
253
+ \`/pd-context standard\` - Standard mode (principles, no Thinking OS)
254
+ \`/pd-context full\` - Full mode (principles + Thinking OS + project context)
255
255
 
256
256
  **Note**: Core Principles are always injected and cannot be disabled.
257
257
  `.trim();
@@ -1,3 +1,2 @@
1
1
  import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
2
  export declare function handleInitStrategy(ctx: PluginCommandContext): PluginCommandResult;
3
- export declare function handleManageOkr(ctx: PluginCommandContext): PluginCommandResult;
@@ -14,17 +14,3 @@ export function handleInitStrategy(ctx) {
14
14
  `Then update \`${userContextPath}\` with key user preferences discovered.`,
15
15
  };
16
16
  }
17
- export function handleManageOkr(ctx) {
18
- const workspaceDir = resolvePluginCommandWorkspaceDir(ctx, 'strategy:manageOkr');
19
- const wctx = WorkspaceContext.fromHookContext({ workspaceDir, ...ctx.config });
20
- const focusPath = wctx.resolve('CURRENT_FOCUS').replace(workspaceDir, '').replace(/^\/+/, '');
21
- const weekStatePath = wctx.resolve('WEEK_STATE').replace(workspaceDir, '').replace(/^\/+/, '');
22
- return {
23
- text: `📊 **OKR Management**\n\n` +
24
- `The Agent will analyze recent work and align sub-agent objectives.\n\n` +
25
- `**Instructions for Agent:** Read \`${focusPath}\` and \`${weekStatePath}\`. ` +
26
- `Compare them against recent session history. ` +
27
- `Update OKRs as needed and output a brief alignment report. ` +
28
- `If OKRs are stale (>7 days), prompt the user for a re-alignment conversation.`,
29
- };
30
- }
@@ -1,15 +1,6 @@
1
- export declare const RUNTIME_V2_PRINCIPLE_BUDGET = 2000;
2
- export interface ActivatedPrinciple {
3
- principleId: string;
4
- text: string;
5
- artifactId: string;
6
- activationId: string;
7
- }
8
- export interface PromptActivationReaderResult {
9
- principles: ActivatedPrinciple[];
10
- warnings: string[];
11
- source: 'runtime_v2';
12
- }
1
+ import type { ActivatedPrinciple, PromptActivationReaderResult } from '@principles/core/runtime-v2';
2
+ export { RUNTIME_V2_PRINCIPLE_BUDGET } from '@principles/core/runtime-v2';
3
+ export type { ActivatedPrinciple, PromptActivationReaderResult };
13
4
  export interface PromptActivationReaderDeps {
14
5
  logger?: {
15
6
  warn?: (msg: string) => void;
@@ -22,6 +13,6 @@ export declare class PromptActivationReader {
22
13
  private readonly deps;
23
14
  constructor(workspaceDir: string, deps?: PromptActivationReaderDeps);
24
15
  readActivatedPrinciples(): Promise<PromptActivationReaderResult>;
16
+ private queryArtifactRow;
25
17
  private loadFeatureFlags;
26
- private resolvePrincipleFromActivation;
27
18
  }
@@ -1,8 +1,8 @@
1
1
  import * as path from 'path';
2
2
  import * as fs from 'fs';
3
3
  import * as yaml from 'js-yaml';
4
- import { SqliteConnection, SqliteActivationStateStore, computeEffectiveFlags, DEFAULT_FEATURE_FLAGS } from '@principles/core/runtime-v2';
5
- export const RUNTIME_V2_PRINCIPLE_BUDGET = 2000;
4
+ import { SqliteConnection, SqliteActivationStateStore, computeEffectiveFlags, DEFAULT_FEATURE_FLAGS, filterPromptActivations, resolvePrincipleFromArtifact } from '@principles/core/runtime-v2';
5
+ export { RUNTIME_V2_PRINCIPLE_BUDGET } from '@principles/core/runtime-v2';
6
6
  const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
7
7
  function isRecord(value) {
8
8
  return value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -27,12 +27,27 @@ export class PromptActivationReader {
27
27
  try {
28
28
  sqliteConn = new SqliteConnection(this.workspaceDir);
29
29
  const store = new SqliteActivationStateStore(sqliteConn);
30
- const activations = await store.listPromptActivations();
31
- for (const activation of activations) {
32
- if (activation.channel !== 'prompt' || activation.action !== 'prompt_activate') {
30
+ const allActivations = await store.listPromptActivations();
31
+ const promptActivations = filterPromptActivations(allActivations);
32
+ for (const activation of promptActivations) {
33
+ let artifactRow;
34
+ try {
35
+ artifactRow = this.queryArtifactRow(sqliteConn, activation.artifactId);
36
+ }
37
+ catch (e) {
38
+ const msg = e instanceof Error ? e.message : String(e);
39
+ const warning = `artifact_query_failed: artifactId=${activation.artifactId} reason=${msg}; nextAction=check_pi_artifacts_table`;
40
+ warnings.push(warning);
41
+ this.deps.logger?.warn?.(`[PD:RuntimeV2] ${warning}`);
42
+ continue;
43
+ }
44
+ if (artifactRow === null) {
45
+ const warning = `artifact_not_found: artifactId=${activation.artifactId}; nextAction=check_pi_artifacts_table`;
46
+ warnings.push(warning);
47
+ this.deps.logger?.warn?.(`[PD:RuntimeV2] ${warning}`);
33
48
  continue;
34
49
  }
35
- const result = this.resolvePrincipleFromActivation(sqliteConn, activation);
50
+ const result = resolvePrincipleFromArtifact(artifactRow, activation);
36
51
  if (result.ok) {
37
52
  principles.push(result.principle);
38
53
  }
@@ -58,6 +73,21 @@ export class PromptActivationReader {
58
73
  }
59
74
  return { principles, warnings, source: 'runtime_v2' };
60
75
  }
76
+ queryArtifactRow(sqliteConn, artifactId) {
77
+ try {
78
+ const db = sqliteConn.getDb();
79
+ const row = db.prepare(`
80
+ SELECT artifact_id, artifact_kind, content_json, validation_status
81
+ FROM pi_artifacts
82
+ WHERE artifact_id = ?
83
+ `).get(artifactId);
84
+ return row ?? null;
85
+ }
86
+ catch (e) {
87
+ const msg = e instanceof Error ? e.message : String(e);
88
+ throw new Error(`artifact_query_failed: artifactId=${artifactId} reason=${msg}; nextAction=check_pi_artifacts_table`);
89
+ }
90
+ }
61
91
  loadFeatureFlags() {
62
92
  const configPath = path.join(this.workspaceDir, '.pd', 'feature-flags.yaml');
63
93
  if (!fs.existsSync(configPath)) {
@@ -110,72 +140,4 @@ export class PromptActivationReader {
110
140
  }
111
141
  return result;
112
142
  }
113
- resolvePrincipleFromActivation(sqliteConn, activation) {
114
- const db = sqliteConn.getDb();
115
- let contentJson;
116
- try {
117
- const row = db.prepare(`
118
- SELECT artifact_id, artifact_kind, content_json, validation_status
119
- FROM pi_artifacts
120
- WHERE artifact_id = ?
121
- `).get(activation.artifactId);
122
- if (!isRecord(row)) {
123
- return { ok: false, warning: `artifact_query_unexpected: artifactId=${activation.artifactId}; nextAction=check_pi_artifacts_table` };
124
- }
125
- const artifact_id = Object.hasOwn(row, 'artifact_id') && typeof row.artifact_id === 'string' && row.artifact_id.length > 0 ? row.artifact_id : null;
126
- const artifact_kind = Object.hasOwn(row, 'artifact_kind') && typeof row.artifact_kind === 'string' ? row.artifact_kind : null;
127
- const raw_content_json = Object.hasOwn(row, 'content_json') && typeof row.content_json === 'string' ? row.content_json : null;
128
- const validation_status = Object.hasOwn(row, 'validation_status') && typeof row.validation_status === 'string' ? row.validation_status : null;
129
- if (!artifact_id) {
130
- return { ok: false, warning: `artifact_not_found: artifactId=${activation.artifactId} activationId=${activation.activationId}; nextAction=verify_artifact_exists_or_remove_stale_activation` };
131
- }
132
- if (artifact_kind !== 'principle') {
133
- return { ok: false, warning: `artifact_not_principle: artifactId=${artifact_id} kind=${artifact_kind ?? 'missing'}; nextAction=skip_non_principle_activations` };
134
- }
135
- if (validation_status !== 'validated') {
136
- return { ok: false, warning: `artifact_not_validated: artifactId=${artifact_id} status=${validation_status ?? 'missing'}; nextAction=skip_unvalidated_artifacts` };
137
- }
138
- if (raw_content_json === null) {
139
- return { ok: false, warning: `artifact_missing_content_json: artifactId=${artifact_id}; nextAction=ensure_artifact_has_content_json` };
140
- }
141
- contentJson = raw_content_json;
142
- }
143
- catch (e) {
144
- const msg = e instanceof Error ? e.message : String(e);
145
- return { ok: false, warning: `artifact_query_failed: artifactId=${activation.artifactId} reason=${msg}; nextAction=check_pi_artifacts_table` };
146
- }
147
- let parsed;
148
- try {
149
- parsed = JSON.parse(contentJson);
150
- }
151
- catch (e) {
152
- const msg = e instanceof Error ? e.message : String(e);
153
- return { ok: false, warning: `artifact_content_json_parse_error: artifactId=${activation.artifactId} reason=${msg}; nextAction=fix_artifact_content_json` };
154
- }
155
- if (!isRecord(parsed)) {
156
- return { ok: false, warning: `artifact_content_malformed: artifactId=${activation.artifactId} reason=parsed_to_non_object; nextAction=fix_artifact_content_json` };
157
- }
158
- const principleId = Object.hasOwn(parsed, 'principleId') && typeof parsed.principleId === 'string' ? parsed.principleId : undefined;
159
- const text = Object.hasOwn(parsed, 'text') && typeof parsed.text === 'string' ? parsed.text : undefined;
160
- const draftObj = Object.hasOwn(parsed, 'principleDraft') && isRecord(parsed.principleDraft) ? parsed.principleDraft : null;
161
- const draftTitle = draftObj && Object.hasOwn(draftObj, 'title') && typeof draftObj.title === 'string' ? draftObj.title : undefined;
162
- const draftStatement = draftObj && Object.hasOwn(draftObj, 'statement') && typeof draftObj.statement === 'string' ? draftObj.statement : undefined;
163
- const resolvedPrincipleId = principleId && principleId.length > 0 ? principleId : draftTitle;
164
- const resolvedText = text && text.length > 0 ? text : draftStatement;
165
- if (!resolvedPrincipleId || resolvedPrincipleId.length === 0) {
166
- return { ok: false, warning: `artifact_missing_principle_id: artifactId=${activation.artifactId}; nextAction=ensure_artifact_has_principleId_or_principleDraft_title` };
167
- }
168
- if (!resolvedText || resolvedText.length === 0) {
169
- return { ok: false, warning: `artifact_missing_text: artifactId=${activation.artifactId} principleId=${resolvedPrincipleId}; nextAction=ensure_artifact_has_text_or_principleDraft_statement` };
170
- }
171
- return {
172
- ok: true,
173
- principle: {
174
- principleId: resolvedPrincipleId,
175
- text: resolvedText,
176
- artifactId: activation.artifactId,
177
- activationId: activation.activationId,
178
- },
179
- };
180
- }
181
143
  }
@@ -0,0 +1,27 @@
1
+ import { PLUGIN_SURFACE_REGISTRY, validateSurfaceRegistry, getSurfacesByCategory, type PluginSurfaceEntry, type MvpCategory } from '@principles/core/runtime-v2';
2
+ import type { OpenClawPluginService } from '../openclaw-sdk.js';
3
+ export interface SurfaceGuardResult {
4
+ passed: boolean;
5
+ enabledCoreSurfaces: string[];
6
+ disabledNonCoreSurfaces: string[];
7
+ violations: string[];
8
+ warnings: string[];
9
+ }
10
+ export declare function checkSurfaceGuard(): SurfaceGuardResult;
11
+ export declare function getSurfaceIdForHook(hookEvent: string, label?: string): string;
12
+ export declare function getSurfaceIdForService(serviceName: string): string;
13
+ export declare function isSurfaceEnabled(surfaceId: string, overrides?: Record<string, boolean>): {
14
+ enabled: boolean;
15
+ reason?: string;
16
+ };
17
+ export type HookHandler<E, C, R> = (event: E, ctx: C) => R | Promise<R>;
18
+ export declare function guardHook<E, C, R>(surfaceId: string, logger: {
19
+ info?: (msg: string) => void;
20
+ debug?: (msg: string) => void;
21
+ } | undefined, handler: HookHandler<E, C, R>): HookHandler<E, C, R>;
22
+ export declare function guardService<T extends OpenClawPluginService>(surfaceId: string, service: T, logger?: {
23
+ info?: (msg: string) => void;
24
+ debug?: (msg: string) => void;
25
+ }): T | null;
26
+ export { PLUGIN_SURFACE_REGISTRY, validateSurfaceRegistry, getSurfacesByCategory };
27
+ export type { PluginSurfaceEntry, MvpCategory };
@@ -0,0 +1,82 @@
1
+ import { PLUGIN_SURFACE_REGISTRY, validateSurfaceRegistry, getSurfacesByCategory, } from '@principles/core/runtime-v2';
2
+ export function checkSurfaceGuard() {
3
+ const validation = validateSurfaceRegistry(PLUGIN_SURFACE_REGISTRY);
4
+ const violations = [];
5
+ const warnings = [...validation.warnings];
6
+ const coreSurfaces = getSurfacesByCategory(PLUGIN_SURFACE_REGISTRY, 'core');
7
+ const enabledCore = coreSurfaces.filter(s => s.enabledByDefault);
8
+ const nonCoreEnabled = PLUGIN_SURFACE_REGISTRY.filter(s => s.category !== 'core' && s.enabledByDefault);
9
+ if (nonCoreEnabled.length > 0) {
10
+ for (const surface of nonCoreEnabled) {
11
+ violations.push(`non-core surface '${surface.id}' (${surface.category}) is enabledByDefault=true — must be false per ADR-0014`);
12
+ }
13
+ }
14
+ if (!validation.valid) {
15
+ violations.push(...validation.errors);
16
+ }
17
+ return {
18
+ passed: violations.length === 0,
19
+ enabledCoreSurfaces: enabledCore.map(s => s.id),
20
+ disabledNonCoreSurfaces: PLUGIN_SURFACE_REGISTRY
21
+ .filter(s => s.category !== 'core' && !s.enabledByDefault)
22
+ .map(s => s.id),
23
+ violations,
24
+ warnings,
25
+ };
26
+ }
27
+ export function getSurfaceIdForHook(hookEvent, label) {
28
+ if (label) {
29
+ return `hook:${hookEvent}.${label}`;
30
+ }
31
+ return `hook:${hookEvent}`;
32
+ }
33
+ export function getSurfaceIdForService(serviceName) {
34
+ return `service:${serviceName}`;
35
+ }
36
+ export function isSurfaceEnabled(surfaceId, overrides = {}) {
37
+ const entry = PLUGIN_SURFACE_REGISTRY.find(s => s.id === surfaceId);
38
+ if (!entry) {
39
+ return {
40
+ enabled: false,
41
+ reason: `surface '${surfaceId}' not found in registry — classify before enabling (PRI-289)`,
42
+ };
43
+ }
44
+ if (Object.hasOwn(overrides, surfaceId)) {
45
+ const override = overrides[surfaceId];
46
+ if (typeof override !== 'boolean') {
47
+ return { enabled: entry.enabledByDefault, reason: `override for '${surfaceId}' is not boolean, using default` };
48
+ }
49
+ if (entry.category === 'gone') {
50
+ return { enabled: false, reason: `surface '${surfaceId}' is gone and cannot be re-enabled` };
51
+ }
52
+ if (entry.category === 'core' && !override) {
53
+ return { enabled: true, reason: `surface '${surfaceId}' is core and cannot be disabled` };
54
+ }
55
+ return { enabled: override };
56
+ }
57
+ if (!entry.enabledByDefault && entry.disabledReason) {
58
+ return { enabled: false, reason: entry.disabledReason };
59
+ }
60
+ return { enabled: entry.enabledByDefault };
61
+ }
62
+ export function guardHook(surfaceId, logger, handler) {
63
+ const check = isSurfaceEnabled(surfaceId);
64
+ if (check.enabled) {
65
+ return handler;
66
+ }
67
+ const reason = check.reason ?? 'surface not enabled';
68
+ return (_event, _ctx) => {
69
+ logger?.info?.(`[PD:surface-guard] SKIP ${surfaceId}: ${reason}`);
70
+ return undefined;
71
+ };
72
+ }
73
+ export function guardService(surfaceId, service, logger) {
74
+ const check = isSurfaceEnabled(surfaceId);
75
+ if (check.enabled) {
76
+ return service;
77
+ }
78
+ const reason = check.reason ?? 'surface not enabled';
79
+ logger?.info?.(`[PD:surface-guard] SKIP service ${surfaceId}: ${reason}`);
80
+ return null;
81
+ }
82
+ export { PLUGIN_SURFACE_REGISTRY, validateSurfaceRegistry, getSurfacesByCategory };
@@ -0,0 +1,12 @@
1
+ import type { OpenClawPluginApi } from '../openclaw-sdk.js';
2
+ interface MigrationError {
3
+ file: string;
4
+ error: string;
5
+ }
6
+ export interface MigrationResult {
7
+ migratedFiles: string[];
8
+ skippedFiles: string[];
9
+ errors: MigrationError[];
10
+ }
11
+ export declare function migrateStaleWorkspaceGuidance(api: OpenClawPluginApi, workspaceDir: string): MigrationResult;
12
+ export {};