dsh-compound-engineering 0.0.0-stage → 0.1.1

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 (461) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -2
  3. package/README.zh.md +161 -0
  4. package/cordis.patch.yml +6 -0
  5. package/lib/frontmatter.js +167 -0
  6. package/lib/index.js +46 -0
  7. package/lib/provider.js +201 -0
  8. package/package.json +62 -4
  9. package/skills/CODING_STANDARDS.md +68 -0
  10. package/skills/ce-babysit-pr/SKILL.md +59 -0
  11. package/skills/ce-babysit-pr/references/branch-currency.md +22 -0
  12. package/skills/ce-babysit-pr/references/envelope.md +44 -0
  13. package/skills/ce-babysit-pr/references/pipeline.md +15 -0
  14. package/skills/ce-babysit-pr/references/report.md +20 -0
  15. package/skills/ce-babysit-pr/references/settle.md +37 -0
  16. package/skills/ce-babysit-pr/references/setup.md +33 -0
  17. package/skills/ce-babysit-pr/references/stack-commands.md +39 -0
  18. package/skills/ce-babysit-pr/references/stack.md +43 -0
  19. package/skills/ce-babysit-pr/references/tick.md +102 -0
  20. package/skills/ce-babysit-pr/references/watch-loop.md +222 -0
  21. package/skills/ce-babysit-pr/scripts/pr-snapshot +3656 -0
  22. package/skills/ce-bakeoff/SKILL.md +48 -0
  23. package/skills/ce-bakeoff/references/candidates.md +37 -0
  24. package/skills/ce-bakeoff/references/judging.md +19 -0
  25. package/skills/ce-bakeoff/references/output.md +11 -0
  26. package/skills/ce-bakeoff/references/verification.md +15 -0
  27. package/skills/ce-brainstorm/SKILL.md +69 -0
  28. package/skills/ce-brainstorm/references/agents/slack-researcher.md +127 -0
  29. package/skills/ce-brainstorm/references/approaches.md +57 -0
  30. package/skills/ce-brainstorm/references/bakeoff.md +9 -0
  31. package/skills/ce-brainstorm/references/blindspot-pass.md +70 -0
  32. package/skills/ce-brainstorm/references/brainstorm-sections.md +458 -0
  33. package/skills/ce-brainstorm/references/dialogue.md +89 -0
  34. package/skills/ce-brainstorm/references/handoff.md +187 -0
  35. package/skills/ce-brainstorm/references/html-rendering.md +638 -0
  36. package/skills/ce-brainstorm/references/interaction-rules.md +33 -0
  37. package/skills/ce-brainstorm/references/markdown-rendering.md +242 -0
  38. package/skills/ce-brainstorm/references/model-tiers.md +13 -0
  39. package/skills/ce-brainstorm/references/output-mode.md +26 -0
  40. package/skills/ce-brainstorm/references/phase-0.md +104 -0
  41. package/skills/ce-brainstorm/references/plan-write.md +32 -0
  42. package/skills/ce-brainstorm/references/product-pressure-test.md +42 -0
  43. package/skills/ce-brainstorm/references/reasoning-elevation.md +124 -0
  44. package/skills/ce-brainstorm/references/settled-decisions.md +45 -0
  45. package/skills/ce-brainstorm/references/synthesis-summary.md +149 -0
  46. package/skills/ce-brainstorm/references/universal-brainstorming.md +72 -0
  47. package/skills/ce-brainstorm/references/verdict-routing.md +26 -0
  48. package/skills/ce-brainstorm/references/visual-probes.md +164 -0
  49. package/skills/ce-brainstorm/scripts/elevation-dispatch.sh +288 -0
  50. package/skills/ce-brainstorm/scripts/light-webserver.js +1275 -0
  51. package/skills/ce-brainstorm/scripts/packs-resolve.py +737 -0
  52. package/skills/ce-brainstorm/scripts/peer-job-runner.py +2594 -0
  53. package/skills/ce-code-review/SKILL.md +40 -0
  54. package/skills/ce-code-review/references/action-class-rubric.md +67 -0
  55. package/skills/ce-code-review/references/cross-model-recovery.md +38 -0
  56. package/skills/ce-code-review/references/cross-model-review.md +191 -0
  57. package/skills/ce-code-review/references/depth-paths.md +32 -0
  58. package/skills/ce-code-review/references/diff-scope.md +59 -0
  59. package/skills/ce-code-review/references/dispatch-reviewers.md +135 -0
  60. package/skills/ce-code-review/references/findings-schema.json +125 -0
  61. package/skills/ce-code-review/references/finish-input.md +118 -0
  62. package/skills/ce-code-review/references/finish-review.md +202 -0
  63. package/skills/ce-code-review/references/intent-and-plan.md +73 -0
  64. package/skills/ce-code-review/references/modes-and-output.md +156 -0
  65. package/skills/ce-code-review/references/persona-catalog.md +66 -0
  66. package/skills/ce-code-review/references/personas/adversarial-reviewer.md +111 -0
  67. package/skills/ce-code-review/references/personas/agent-native-reviewer.md +173 -0
  68. package/skills/ce-code-review/references/personas/api-contract-reviewer.md +44 -0
  69. package/skills/ce-code-review/references/personas/correctness-reviewer.md +48 -0
  70. package/skills/ce-code-review/references/personas/data-migration-reviewer.md +111 -0
  71. package/skills/ce-code-review/references/personas/deployment-verification-agent.md +157 -0
  72. package/skills/ce-code-review/references/personas/julik-frontend-races-reviewer.md +45 -0
  73. package/skills/ce-code-review/references/personas/learnings-researcher.md +260 -0
  74. package/skills/ce-code-review/references/personas/maintainability-reviewer.md +85 -0
  75. package/skills/ce-code-review/references/personas/performance-reviewer.md +45 -0
  76. package/skills/ce-code-review/references/personas/previous-comments-reviewer.md +59 -0
  77. package/skills/ce-code-review/references/personas/project-standards-reviewer.md +77 -0
  78. package/skills/ce-code-review/references/personas/reliability-reviewer.md +49 -0
  79. package/skills/ce-code-review/references/personas/security-reviewer.md +50 -0
  80. package/skills/ce-code-review/references/personas/swift-ios-reviewer.md +99 -0
  81. package/skills/ce-code-review/references/personas/testing-reviewer.md +51 -0
  82. package/skills/ce-code-review/references/review-output-template.md +172 -0
  83. package/skills/ce-code-review/references/scope.md +176 -0
  84. package/skills/ce-code-review/references/select-and-route.md +93 -0
  85. package/skills/ce-code-review/references/subagent-template.md +206 -0
  86. package/skills/ce-code-review/references/validator-batch-template.md +67 -0
  87. package/skills/ce-code-review/scripts/cross-model-adversarial-review.sh +1275 -0
  88. package/skills/ce-code-review/scripts/findings-mechanics.py +274 -0
  89. package/skills/ce-code-review/scripts/packs-resolve.py +737 -0
  90. package/skills/ce-code-review/scripts/peer-job-runner.py +2594 -0
  91. package/skills/ce-code-review/scripts/review-scope.py +419 -0
  92. package/skills/ce-code-review/scripts/run-log.py +280 -0
  93. package/skills/ce-commit/SKILL.md +60 -0
  94. package/skills/ce-commit-push-pr/SKILL.md +69 -0
  95. package/skills/ce-commit-push-pr/references/apply-and-handoff.md +79 -0
  96. package/skills/ce-commit-push-pr/references/branch-creation.md +47 -0
  97. package/skills/ce-commit-push-pr/references/commit-and-push.md +26 -0
  98. package/skills/ce-commit-push-pr/references/compose.md +29 -0
  99. package/skills/ce-commit-push-pr/references/context.md +42 -0
  100. package/skills/ce-commit-push-pr/references/gh-stack-cli.md +83 -0
  101. package/skills/ce-commit-push-pr/references/pr-description-writing.md +208 -0
  102. package/skills/ce-commit-push-pr/references/stack-submit.md +81 -0
  103. package/skills/ce-compound/SKILL.md +79 -0
  104. package/skills/ce-compound/assets/resolution-template.md +96 -0
  105. package/skills/ce-compound/references/agents/best-practices-researcher.md +115 -0
  106. package/skills/ce-compound/references/agents/data-integrity-guardian.md +68 -0
  107. package/skills/ce-compound/references/agents/framework-docs-researcher.md +93 -0
  108. package/skills/ce-compound/references/agents/pattern-recognition-specialist.md +55 -0
  109. package/skills/ce-compound/references/agents/performance-oracle.md +108 -0
  110. package/skills/ce-compound/references/agents/security-sentinel.md +91 -0
  111. package/skills/ce-compound/references/agents/session-historian.md +82 -0
  112. package/skills/ce-compound/references/assembly.md +127 -0
  113. package/skills/ce-compound/references/concepts-vocabulary.md +98 -0
  114. package/skills/ce-compound/references/enhancement.md +42 -0
  115. package/skills/ce-compound/references/grounding-validation.md +89 -0
  116. package/skills/ce-compound/references/lightweight.md +56 -0
  117. package/skills/ce-compound/references/modes.md +13 -0
  118. package/skills/ce-compound/references/refresh-and-discoverability.md +96 -0
  119. package/skills/ce-compound/references/report.md +115 -0
  120. package/skills/ce-compound/references/research.md +144 -0
  121. package/skills/ce-compound/references/schema.yaml +236 -0
  122. package/skills/ce-compound/references/session-history.md +73 -0
  123. package/skills/ce-compound/references/yaml-schema.md +130 -0
  124. package/skills/ce-compound/scripts/packs-resolve.py +737 -0
  125. package/skills/ce-compound/scripts/session-history/__pycache__/dsh_session.cpython-314.pyc +0 -0
  126. package/skills/ce-compound/scripts/session-history/discover-sessions.sh +290 -0
  127. package/skills/ce-compound/scripts/session-history/discover_dsh.py +123 -0
  128. package/skills/ce-compound/scripts/session-history/dsh_session.py +225 -0
  129. package/skills/ce-compound/scripts/session-history/extract-errors.py +178 -0
  130. package/skills/ce-compound/scripts/session-history/extract-metadata.py +301 -0
  131. package/skills/ce-compound/scripts/session-history/extract-skeleton.py +346 -0
  132. package/skills/ce-compound/scripts/validate-doc-claims.py +497 -0
  133. package/skills/ce-compound/scripts/validate-frontmatter.py +137 -0
  134. package/skills/ce-compound-refresh/SKILL.md +88 -0
  135. package/skills/ce-compound-refresh/assets/resolution-template.md +96 -0
  136. package/skills/ce-compound-refresh/references/classify.md +42 -0
  137. package/skills/ce-compound-refresh/references/commit.md +7 -0
  138. package/skills/ce-compound-refresh/references/concepts-vocabulary.md +116 -0
  139. package/skills/ce-compound-refresh/references/discoverability.md +15 -0
  140. package/skills/ce-compound-refresh/references/investigate.md +23 -0
  141. package/skills/ce-compound-refresh/references/modes.md +27 -0
  142. package/skills/ce-compound-refresh/references/per-action-flows.md +142 -0
  143. package/skills/ce-compound-refresh/references/report.md +23 -0
  144. package/skills/ce-compound-refresh/references/schema.yaml +236 -0
  145. package/skills/ce-compound-refresh/references/scope.md +18 -0
  146. package/skills/ce-compound-refresh/references/worth-audit.md +35 -0
  147. package/skills/ce-compound-refresh/references/yaml-schema.md +130 -0
  148. package/skills/ce-compound-refresh/scripts/validate-doc-claims.py +497 -0
  149. package/skills/ce-compound-refresh/scripts/validate-frontmatter.py +137 -0
  150. package/skills/ce-debug/SKILL.md +122 -0
  151. package/skills/ce-debug/references/anti-patterns.md +91 -0
  152. package/skills/ce-debug/references/defense-in-depth.md +39 -0
  153. package/skills/ce-debug/references/fix.md +21 -0
  154. package/skills/ce-debug/references/investigate.md +114 -0
  155. package/skills/ce-debug/references/investigation-techniques.md +384 -0
  156. package/skills/ce-debug/references/pipeline-mode.md +78 -0
  157. package/skills/ce-debug/references/post-fix-handoff.md +60 -0
  158. package/skills/ce-debug/references/return-to-caller.md +57 -0
  159. package/skills/ce-doc-review/SKILL.md +75 -0
  160. package/skills/ce-doc-review/references/bulk-preview.md +146 -0
  161. package/skills/ce-doc-review/references/cross-model-review.md +207 -0
  162. package/skills/ce-doc-review/references/decision-primer.md +47 -0
  163. package/skills/ce-doc-review/references/dispatch.md +56 -0
  164. package/skills/ce-doc-review/references/document-intake.md +44 -0
  165. package/skills/ce-doc-review/references/findings-schema.json +85 -0
  166. package/skills/ce-doc-review/references/modes.md +20 -0
  167. package/skills/ce-doc-review/references/open-questions-defer.md +158 -0
  168. package/skills/ce-doc-review/references/persona-selection.md +41 -0
  169. package/skills/ce-doc-review/references/personas/adversarial-document-reviewer.md +109 -0
  170. package/skills/ce-doc-review/references/personas/coherence-reviewer.md +69 -0
  171. package/skills/ce-doc-review/references/personas/design-lens-reviewer.md +48 -0
  172. package/skills/ce-doc-review/references/personas/feasibility-reviewer.md +50 -0
  173. package/skills/ce-doc-review/references/personas/product-lens-reviewer.md +85 -0
  174. package/skills/ce-doc-review/references/personas/scope-guardian-reviewer.md +83 -0
  175. package/skills/ce-doc-review/references/personas/security-lens-reviewer.md +41 -0
  176. package/skills/ce-doc-review/references/personas/whole-doc-reviewer.md +25 -0
  177. package/skills/ce-doc-review/references/rendering-floor.md +175 -0
  178. package/skills/ce-doc-review/references/review-output-template.md +123 -0
  179. package/skills/ce-doc-review/references/subagent-template.md +188 -0
  180. package/skills/ce-doc-review/references/synthesis-and-presentation.md +350 -0
  181. package/skills/ce-doc-review/references/walkthrough.md +347 -0
  182. package/skills/ce-doc-review/scripts/cross-model-doc-review.sh +1270 -0
  183. package/skills/ce-doc-review/scripts/packs-resolve.py +737 -0
  184. package/skills/ce-doc-review/scripts/peer-job-runner.py +2594 -0
  185. package/skills/ce-dogfood/SKILL.md +66 -0
  186. package/skills/ce-dogfood/agents/openai.yaml +2 -0
  187. package/skills/ce-dogfood/references/dogfood-report-template.md +97 -0
  188. package/skills/ce-dogfood/references/phases.md +167 -0
  189. package/skills/ce-dogfood/references/test-matrix-taxonomy.md +62 -0
  190. package/skills/ce-dogfood/scripts/packs-resolve.py +737 -0
  191. package/skills/ce-explain/SKILL.md +81 -0
  192. package/skills/ce-explain/references/agents/behavior-trace-scout.md +19 -0
  193. package/skills/ce-explain/references/agents/work-recap-scout.md +23 -0
  194. package/skills/ce-explain/references/check-in.md +18 -0
  195. package/skills/ce-explain/references/destinations.md +35 -0
  196. package/skills/ce-explain/references/explainer-html.md +29 -0
  197. package/skills/ce-explain/references/explainer-markdown.md +24 -0
  198. package/skills/ce-explain/references/intake.md +50 -0
  199. package/skills/ce-explain/references/orchestration.md +46 -0
  200. package/skills/ce-handoff/SKILL.md +54 -0
  201. package/skills/ce-handoff/references/create.md +88 -0
  202. package/skills/ce-handoff/references/resume.md +46 -0
  203. package/skills/ce-ideate/SKILL.md +75 -0
  204. package/skills/ce-ideate/references/agents/issue-intelligence-analyst.md +166 -0
  205. package/skills/ce-ideate/references/agents/learnings-researcher.md +247 -0
  206. package/skills/ce-ideate/references/agents/slack-researcher.md +127 -0
  207. package/skills/ce-ideate/references/agents/web-researcher.md +121 -0
  208. package/skills/ce-ideate/references/decomposition.md +39 -0
  209. package/skills/ce-ideate/references/divergent-ideation.md +112 -0
  210. package/skills/ce-ideate/references/grounding.md +138 -0
  211. package/skills/ce-ideate/references/html-rendering.md +638 -0
  212. package/skills/ce-ideate/references/ideation-sections.md +191 -0
  213. package/skills/ce-ideate/references/issue-intelligence.md +44 -0
  214. package/skills/ce-ideate/references/markdown-rendering.md +242 -0
  215. package/skills/ce-ideate/references/output-mode.md +34 -0
  216. package/skills/ce-ideate/references/post-ideation-workflow.md +169 -0
  217. package/skills/ce-ideate/references/scope-gates.md +148 -0
  218. package/skills/ce-ideate/references/universal-ideation.md +119 -0
  219. package/skills/ce-ideate/references/user-research-artifacts.md +28 -0
  220. package/skills/ce-ideate/references/web-research-cache.md +56 -0
  221. package/skills/ce-noslop/SKILL.md +45 -0
  222. package/skills/ce-noslop/references/patterns.md +61 -0
  223. package/skills/ce-noslop/references/terminology.md +3 -0
  224. package/skills/ce-optimize/SKILL.md +64 -0
  225. package/skills/ce-optimize/references/agents/learnings-researcher.md +247 -0
  226. package/skills/ce-optimize/references/agents/repo-research-analyst.md +258 -0
  227. package/skills/ce-optimize/references/example-expensive-benchmark-spec.yaml +88 -0
  228. package/skills/ce-optimize/references/example-hard-spec.yaml +64 -0
  229. package/skills/ce-optimize/references/example-judge-spec.yaml +83 -0
  230. package/skills/ce-optimize/references/example-text-target-spec.yaml +80 -0
  231. package/skills/ce-optimize/references/experiment-log-schema.yaml +563 -0
  232. package/skills/ce-optimize/references/experiment-prompt-template.md +143 -0
  233. package/skills/ce-optimize/references/judge-prompt-template.md +117 -0
  234. package/skills/ce-optimize/references/loop.md +286 -0
  235. package/skills/ce-optimize/references/measurement.md +168 -0
  236. package/skills/ce-optimize/references/optimize-spec-schema.yaml +570 -0
  237. package/skills/ce-optimize/references/persistence.md +93 -0
  238. package/skills/ce-optimize/references/spec.md +107 -0
  239. package/skills/ce-optimize/references/text-targets.md +51 -0
  240. package/skills/ce-optimize/references/usage-guide.md +147 -0
  241. package/skills/ce-optimize/references/wrap-up.md +54 -0
  242. package/skills/ce-optimize/scripts/decide.mjs +676 -0
  243. package/skills/ce-optimize/scripts/experiment-worktree.sh +330 -0
  244. package/skills/ce-optimize/scripts/measure.sh +140 -0
  245. package/skills/ce-optimize/scripts/parallel-probe.sh +134 -0
  246. package/skills/ce-plan/SKILL.md +60 -0
  247. package/skills/ce-plan/references/agents/agent-native-planning-strategist.md +66 -0
  248. package/skills/ce-plan/references/agents/architecture-strategist.md +46 -0
  249. package/skills/ce-plan/references/agents/best-practices-researcher.md +118 -0
  250. package/skills/ce-plan/references/agents/data-integrity-guardian.md +68 -0
  251. package/skills/ce-plan/references/agents/framework-docs-researcher.md +97 -0
  252. package/skills/ce-plan/references/agents/git-history-analyzer.md +40 -0
  253. package/skills/ce-plan/references/agents/learnings-researcher.md +268 -0
  254. package/skills/ce-plan/references/agents/pattern-recognition-specialist.md +55 -0
  255. package/skills/ce-plan/references/agents/performance-oracle.md +108 -0
  256. package/skills/ce-plan/references/agents/repo-research-analyst.md +262 -0
  257. package/skills/ce-plan/references/agents/security-sentinel.md +91 -0
  258. package/skills/ce-plan/references/agents/slack-researcher.md +131 -0
  259. package/skills/ce-plan/references/agents/spec-flow-analyzer.md +84 -0
  260. package/skills/ce-plan/references/agents/web-researcher.md +125 -0
  261. package/skills/ce-plan/references/approach-altitude.md +55 -0
  262. package/skills/ce-plan/references/bakeoff.md +9 -0
  263. package/skills/ce-plan/references/deepening-workflow.md +263 -0
  264. package/skills/ce-plan/references/final-review.md +134 -0
  265. package/skills/ce-plan/references/html-rendering.md +638 -0
  266. package/skills/ce-plan/references/intake.md +158 -0
  267. package/skills/ce-plan/references/markdown-rendering.md +242 -0
  268. package/skills/ce-plan/references/output-contracts.md +29 -0
  269. package/skills/ce-plan/references/output-mode.md +45 -0
  270. package/skills/ce-plan/references/plan-handoff.md +116 -0
  271. package/skills/ce-plan/references/plan-sections.md +489 -0
  272. package/skills/ce-plan/references/reasoning-elevation.md +124 -0
  273. package/skills/ce-plan/references/research.md +211 -0
  274. package/skills/ce-plan/references/resume.md +61 -0
  275. package/skills/ce-plan/references/settled-decisions.md +45 -0
  276. package/skills/ce-plan/references/structure.md +207 -0
  277. package/skills/ce-plan/references/synthesis-summary.md +260 -0
  278. package/skills/ce-plan/references/universal-planning.md +170 -0
  279. package/skills/ce-plan/scripts/elevation-dispatch.sh +288 -0
  280. package/skills/ce-plan/scripts/packs-resolve.py +737 -0
  281. package/skills/ce-plan/scripts/peer-job-runner.py +2594 -0
  282. package/skills/ce-polish/SKILL.md +22 -0
  283. package/skills/ce-polish/agents/openai.yaml +2 -0
  284. package/skills/ce-polish/references/dev-server-astro.md +58 -0
  285. package/skills/ce-polish/references/dev-server-detection.md +40 -0
  286. package/skills/ce-polish/references/dev-server-next.md +61 -0
  287. package/skills/ce-polish/references/dev-server-nuxt.md +58 -0
  288. package/skills/ce-polish/references/dev-server-procfile.md +59 -0
  289. package/skills/ce-polish/references/dev-server-rails.md +50 -0
  290. package/skills/ce-polish/references/dev-server-remix.md +58 -0
  291. package/skills/ce-polish/references/dev-server-sveltekit.md +58 -0
  292. package/skills/ce-polish/references/dev-server-vite.md +48 -0
  293. package/skills/ce-polish/references/install-riffrec.md +35 -0
  294. package/skills/ce-polish/references/launch-json-schema.md +177 -0
  295. package/skills/ce-polish/references/live-loop.md +98 -0
  296. package/skills/ce-polish/references/live-remote.md +35 -0
  297. package/skills/ce-polish/references/live-start.md +93 -0
  298. package/skills/ce-polish/references/live-stream-contract.md +253 -0
  299. package/skills/ce-polish/references/run.md +67 -0
  300. package/skills/ce-polish/scripts/detect-project-type.sh +277 -0
  301. package/skills/ce-polish/scripts/detect-riffrec.sh +225 -0
  302. package/skills/ce-polish/scripts/live-endpoint.js +2841 -0
  303. package/skills/ce-polish/scripts/read-launch-json.sh +117 -0
  304. package/skills/ce-polish/scripts/resolve-package-manager.sh +95 -0
  305. package/skills/ce-polish/scripts/resolve-port.sh +307 -0
  306. package/skills/ce-pov/SKILL.md +64 -0
  307. package/skills/ce-pov/references/agents/external-evidence-researcher.md +26 -0
  308. package/skills/ce-pov/references/agents/pov-peer.md +43 -0
  309. package/skills/ce-pov/references/agents/precedent-activity-scout.md +21 -0
  310. package/skills/ce-pov/references/agents/project-grounding-scout.md +32 -0
  311. package/skills/ce-pov/references/boundaries.md +36 -0
  312. package/skills/ce-pov/references/cross-model-panel.md +596 -0
  313. package/skills/ce-pov/references/followup.md +9 -0
  314. package/skills/ce-pov/references/grounding.md +47 -0
  315. package/skills/ce-pov/references/intake.md +61 -0
  316. package/skills/ce-pov/references/invocation.md +47 -0
  317. package/skills/ce-pov/references/method.md +68 -0
  318. package/skills/ce-pov/references/pov-schema.json +56 -0
  319. package/skills/ce-pov/references/report.md +7 -0
  320. package/skills/ce-pov/scripts/cross-model-pov.sh +1110 -0
  321. package/skills/ce-pov/scripts/peer-job-runner.py +2594 -0
  322. package/skills/ce-product-pulse/SKILL.md +81 -0
  323. package/skills/ce-product-pulse/agents/openai.yaml +2 -0
  324. package/skills/ce-product-pulse/references/config.md +20 -0
  325. package/skills/ce-product-pulse/references/interview.md +260 -0
  326. package/skills/ce-product-pulse/references/report-template.md +89 -0
  327. package/skills/ce-product-pulse/references/run.md +46 -0
  328. package/skills/ce-product-pulse/references/setup.md +43 -0
  329. package/skills/ce-promote/SKILL.md +90 -0
  330. package/skills/ce-promote/agents/openai.yaml +2 -0
  331. package/skills/ce-promote/references/spiral-cli.md +149 -0
  332. package/skills/ce-proof/SKILL.md +65 -0
  333. package/skills/ce-proof/references/api.md +176 -0
  334. package/skills/ce-proof/references/workflows.md +124 -0
  335. package/skills/ce-prototype/SKILL.md +59 -0
  336. package/skills/ce-prototype/assets/annotate.css +206 -0
  337. package/skills/ce-prototype/assets/annotate.js +837 -0
  338. package/skills/ce-prototype/references/annotation-loop.md +32 -0
  339. package/skills/ce-prototype/references/build.md +39 -0
  340. package/skills/ce-prototype/references/craft-floor.md +43 -0
  341. package/skills/ce-prototype/references/preview.md +118 -0
  342. package/skills/ce-prototype/references/scoping.md +38 -0
  343. package/skills/ce-prototype/references/write-back.md +37 -0
  344. package/skills/ce-prototype/scripts/light-webserver.js +1275 -0
  345. package/skills/ce-resolve-pr-feedback/SKILL.md +60 -0
  346. package/skills/ce-resolve-pr-feedback/references/agents/pr-comment-resolver.md +59 -0
  347. package/skills/ce-resolve-pr-feedback/references/evaluation-rubric.md +141 -0
  348. package/skills/ce-resolve-pr-feedback/references/full-mode.md +336 -0
  349. package/skills/ce-resolve-pr-feedback/references/pipeline-mode.md +23 -0
  350. package/skills/ce-resolve-pr-feedback/references/resume.md +60 -0
  351. package/skills/ce-resolve-pr-feedback/references/return-to-caller.md +111 -0
  352. package/skills/ce-resolve-pr-feedback/references/targeted-mode.md +48 -0
  353. package/skills/ce-resolve-pr-feedback/scripts/get-pr-comments +176 -0
  354. package/skills/ce-resolve-pr-feedback/scripts/get-thread-for-comment +84 -0
  355. package/skills/ce-resolve-pr-feedback/scripts/pending-feedback.py +287 -0
  356. package/skills/ce-resolve-pr-feedback/scripts/reply-to-pr-thread +57 -0
  357. package/skills/ce-resolve-pr-feedback/scripts/resolve-pr-thread +23 -0
  358. package/skills/ce-retune/SKILL.md +42 -0
  359. package/skills/ce-retune/agents/openai.yaml +2 -0
  360. package/skills/ce-retune/references/baseline-mining.md +122 -0
  361. package/skills/ce-retune/references/corpus-audit.md +128 -0
  362. package/skills/ce-retune/references/cut-passes.md +129 -0
  363. package/skills/ce-retune/references/halt-taxonomy.md +123 -0
  364. package/skills/ce-retune/references/noise-floor.md +131 -0
  365. package/skills/ce-retune/references/workflow-shapes.md +73 -0
  366. package/skills/ce-riffrec-feedback-analysis/SKILL.md +33 -0
  367. package/skills/ce-riffrec-feedback-analysis/references/analyzer.md +18 -0
  368. package/skills/ce-riffrec-feedback-analysis/references/compound-engineering-feedback-format.md +116 -0
  369. package/skills/ce-riffrec-feedback-analysis/references/extensive-analysis.md +98 -0
  370. package/skills/ce-riffrec-feedback-analysis/references/install-riffrec.md +27 -0
  371. package/skills/ce-riffrec-feedback-analysis/references/quick-bug-report.md +38 -0
  372. package/skills/ce-riffrec-feedback-analysis/scripts/analyze_riffrec_zip.py +1306 -0
  373. package/skills/ce-setup/SKILL.md +103 -0
  374. package/skills/ce-setup/agents/openai.yaml +2 -0
  375. package/skills/ce-setup/assets/compounding-directive.md +11 -0
  376. package/skills/ce-setup/assets/noslop-directive.md +7 -0
  377. package/skills/ce-setup/assets/pack-rule-template.md +11 -0
  378. package/skills/ce-setup/references/acpx-cache-warm.md +14 -0
  379. package/skills/ce-setup/references/config-template.yaml +210 -0
  380. package/skills/ce-setup/references/legacy-codex-tool-map.md +15 -0
  381. package/skills/ce-setup/references/pack-scaffold.md +45 -0
  382. package/skills/ce-setup/references/repo-fixes.md +121 -0
  383. package/skills/ce-setup/scripts/check-health +929 -0
  384. package/skills/ce-setup/scripts/packs-resolve.py +737 -0
  385. package/skills/ce-simplify-code/SKILL.md +76 -0
  386. package/skills/ce-simplify-code/references/personas/code-quality-reviewer.md +17 -0
  387. package/skills/ce-simplify-code/references/personas/code-reuse-reviewer.md +7 -0
  388. package/skills/ce-simplify-code/references/personas/comment-reviewer.md +24 -0
  389. package/skills/ce-simplify-code/references/personas/efficiency-reviewer.md +11 -0
  390. package/skills/ce-simplify-code/references/personas/test-value-reviewer.md +23 -0
  391. package/skills/ce-simplify-code/references/reviewer-dispatch.md +11 -0
  392. package/skills/ce-simplify-code/references/standalone-report.md +25 -0
  393. package/skills/ce-strategy/SKILL.md +61 -0
  394. package/skills/ce-strategy/references/grounding.md +22 -0
  395. package/skills/ce-strategy/references/interview.md +179 -0
  396. package/skills/ce-strategy/references/strategy-template.md +94 -0
  397. package/skills/ce-strategy/references/update-run.md +33 -0
  398. package/skills/ce-sweep/SKILL.md +93 -0
  399. package/skills/ce-sweep/agents/openai.yaml +2 -0
  400. package/skills/ce-sweep/references/agents/media-analyzer.md +54 -0
  401. package/skills/ce-sweep/references/interview.md +208 -0
  402. package/skills/ce-sweep/references/model-tiers.md +13 -0
  403. package/skills/ce-sweep/references/plan-template.md +62 -0
  404. package/skills/ce-sweep/references/run.md +126 -0
  405. package/skills/ce-sweep/references/sources/email.md +57 -0
  406. package/skills/ce-sweep/references/sources/github-issues.md +59 -0
  407. package/skills/ce-sweep/references/sources/slack.md +61 -0
  408. package/skills/ce-sweep/references/state-schema.md +157 -0
  409. package/skills/ce-sweep/references/subagent-template.md +60 -0
  410. package/skills/ce-sweep/scripts/analyze_riffrec_zip.py +1306 -0
  411. package/skills/ce-sweep/scripts/sweep-state.py +793 -0
  412. package/skills/ce-test-browser/SKILL.md +50 -0
  413. package/skills/ce-test-browser/references/agent-browser-driver.md +47 -0
  414. package/skills/ce-test-browser/references/pipeline-orchestration.md +45 -0
  415. package/skills/ce-test-browser/references/route-and-report.md +129 -0
  416. package/skills/ce-test-browser/scripts/resolve-port.sh +41 -0
  417. package/skills/ce-test-xcode/SKILL.md +26 -0
  418. package/skills/ce-test-xcode/agents/openai.yaml +2 -0
  419. package/skills/ce-test-xcode/references/setup-and-build.md +32 -0
  420. package/skills/ce-test-xcode/references/test-and-report.md +64 -0
  421. package/skills/ce-work/SKILL.md +62 -0
  422. package/skills/ce-work/references/agents/figma-design-sync.md +27 -0
  423. package/skills/ce-work/references/agents/implementation-worker.md +17 -0
  424. package/skills/ce-work/references/cross-model-execution.md +191 -0
  425. package/skills/ce-work/references/execution-engines.md +64 -0
  426. package/skills/ce-work/references/execution-strategy.md +73 -0
  427. package/skills/ce-work/references/implementation-loop.md +107 -0
  428. package/skills/ce-work/references/implementation-result-schema.json +52 -0
  429. package/skills/ce-work/references/input-triage.md +50 -0
  430. package/skills/ce-work/references/non-code-execution.md +23 -0
  431. package/skills/ce-work/references/return-to-caller.md +33 -0
  432. package/skills/ce-work/references/review-findings-followup.md +82 -0
  433. package/skills/ce-work/references/shipping-workflow.md +89 -0
  434. package/skills/ce-work/references/tracker-defer.md +150 -0
  435. package/skills/ce-work/references/work-intake.md +51 -0
  436. package/skills/ce-work/references/workspace-setup.md +27 -0
  437. package/skills/ce-work/scripts/__pycache__/unit_workspace_jobs.cpython-314.pyc +0 -0
  438. package/skills/ce-work/scripts/__pycache__/unit_workspace_state.cpython-314.pyc +0 -0
  439. package/skills/ce-work/scripts/cross-model-work.sh +1385 -0
  440. package/skills/ce-work/scripts/peer-job-runner.py +2594 -0
  441. package/skills/ce-work/scripts/unit-workspace.py +215 -0
  442. package/skills/ce-work/scripts/unit_workspace_ignored.py +93 -0
  443. package/skills/ce-work/scripts/unit_workspace_integration.py +677 -0
  444. package/skills/ce-work/scripts/unit_workspace_jobs.py +1216 -0
  445. package/skills/ce-work/scripts/unit_workspace_lifecycle.py +981 -0
  446. package/skills/ce-work/scripts/unit_workspace_state.py +1379 -0
  447. package/skills/ce-work/scripts/unit_workspace_transaction.py +612 -0
  448. package/skills/ce-worktree/SKILL.md +54 -0
  449. package/skills/lfg/SKILL.md +59 -0
  450. package/skills/lfg/references/debug-return.md +25 -0
  451. package/skills/lfg/references/intake.md +30 -0
  452. package/skills/lfg/references/next-work-handoff.md +96 -0
  453. package/skills/lfg/references/plan-brief.md +36 -0
  454. package/skills/lfg/references/review-followup.md +78 -0
  455. package/skills/lfg/references/shipping.md +65 -0
  456. package/skills/lfg/references/stage-routing.md +49 -0
  457. package/skills/lfg/references/task-visibility.md +11 -0
  458. package/skills/lfg/references/tracker-defer.md +150 -0
  459. package/skills/lfg/references/work-return.md +27 -0
  460. package/skills/wtf/SKILL.md +33 -0
  461. package/skills/wtf/agents/openai.yaml +2 -0
@@ -0,0 +1,164 @@
1
+ # Visual Probes
2
+
3
+ Use visual probes when a brainstorm decision is faster to judge by seeing a rough artifact than by reading prose. A visual probe is a disposable decision sketch, not a prototype, implementation plan, UI spec, or design deliverable.
4
+
5
+ ## Trigger
6
+
7
+ Use this reference only when the next question has a specific visual decision:
8
+
9
+ - behavior shape: "Which annotation or drawing behavior feels right?"
10
+ - layout shape: "Which navigation structure matches the workflow?"
11
+ - flow shape: "Where should this decision point sit?"
12
+ - state shape: "Which empty/loading/error state communicates the right thing?"
13
+ - diagram shape: "Which relationship or system boundary is clearer?"
14
+
15
+ Do not use a visual probe for product goals, scope boundaries, success criteria, evidence probes, tradeoff prose, or technical decisions that are easier to discuss in chat. A decision that meets Interaction Rule 7 in `references/interaction-rules.md` — which states that test — belongs to `ce-prototype`, not to a visual probe.
16
+
17
+ **Classifying a wide decision.** Per-avenue classification applies only once the avenues have been named. An undecomposed decision is classified once, on its dominant dimension. When any named avenue meets Rule 7, the whole decision goes to `ce-prototype` — the sketchable avenues ride along there as thin variants rather than splitting one decision across two tiers.
18
+
19
+ ## The gate (when the offer must fire)
20
+
21
+ When Phase 0.3 flagged an inherently-visual topic, the offer must be made before the **first** decision about shape, behavior, state, layout, flow, or a diagram is raised in *any* form — plain chat or a blocking question. A decision that meets Interaction Rule 7 routes to `ce-prototype` instead; this rule does not apply to it.
22
+
23
+ **Timing is state-based, not memory-based.** Anchor the check to the decision you are about to raise, not to a "pending offer" remembered since Phase 0.3: offer unless this specific decision has already been through the offer (the user already chose text or visual for it). This rule takes precedence over the default blocking-question path — do not raise the shape decision as a blocking-question menu, or as a plain-chat shape question, until the user has declined visual (or visual feedback has returned to chat).
24
+
25
+ **Having been through the offer closes only this offer, never Rule 7.** Two paths reopen the prototype route for a decision already offered here: the user chose text and the decision then turns on finish or motion, or a rough sketch was built and did not settle it. Route those to `ce-prototype` rather than treating the decision as closed.
26
+
27
+ **An ASCII preview or text mockup embedded inside the question's choices does NOT satisfy the offer** — that shortcut is exactly what this rule exists to stop. The offer is its own prior question with two options (sketch vs describe); only after the user chooses does the shape decision proceed.
28
+
29
+ ## Offer
30
+
31
+ Ask once at the decision point. Do not enable a session-wide mode.
32
+
33
+ Use the host's blocking question tool already in the current tool list (match by capability, not by a host-specific name). Presence in the current tool list is proof the tool exists; never call a user-facing question tool to discover whether it exists. If a matching tool is listed but unloaded, use the host's tool-discovery primitive to load that capability — do not search for another host's tool name. Use a plain chat question only when no such tool is in the list or a real question call errors. The opt-in should have two clear options:
34
+
35
+ - Visual sketch — create rough options in a local browser
36
+ - Text description — keep the decision in chat
37
+
38
+ Use this wording:
39
+
40
+ > This decision may be easier to judge visually. I can either sketch rough options in a local browser so you can react to the shape, or keep it in chat and describe the options textually, which is faster but lower-fidelity. Which do you prefer?
41
+
42
+ The text path must be credible. If you cannot explain the decision clearly in text, you do not understand it well enough to sketch it.
43
+
44
+ If the user chooses text, continue in chat and do not re-offer for the same decision. If they choose visual, proceed below.
45
+
46
+ ## Visual Path
47
+
48
+ Create the cheapest artifact that answers the current question. Optimize for fast feedback, not polish.
49
+
50
+ Allowed:
51
+
52
+ - rough behavior sketches
53
+ - low-fidelity wireframes
54
+ - state comparisons
55
+ - flow diagrams
56
+ - simple A/B/C visual contrasts
57
+ - a disposable one-decision interaction demo only when a single behavior shape is the decision — not a wide diverge, layered slices, or an in-app overlay
58
+
59
+ Avoid:
60
+
61
+ - polished branding
62
+ - final colors or typography
63
+ - component-library precision
64
+ - pixel-perfect layout
65
+ - production-like implementation
66
+ - unnecessary animation
67
+ - details that imply exact UI commitments
68
+
69
+ Label the artifact as directional. State what the user should judge and what they should ignore.
70
+
71
+ ## Display Helper
72
+
73
+ Use the bundled display-only helper when the current platform can run a bundled skill script. Invoke it via the `SKILL_DIR` anchor: set `SKILL_DIR` to the absolute path of the directory containing the `ce-brainstorm` `SKILL.md` you loaded (the Bash tool's cwd is the user's project, not the skill dir), and re-set it in the same command on each call since shell vars don't persist between Bash invocations. Do not resolve the helper from the user's project CWD.
74
+
75
+ Start (detached):
76
+
77
+ ```bash
78
+ SKILL_DIR="<absolute path of the ce-brainstorm skill directory>";
79
+ SCRATCH_ROOT="/tmp/compound-engineering-$(id -u)";
80
+ [ ! -L "$SCRATCH_ROOT" ] && (umask 077; mkdir -p "$SCRATCH_ROOT") 2>/dev/null && [ ! -L "$SCRATCH_ROOT" ] && [ -O "$SCRATCH_ROOT" ] && [ -w "$SCRATCH_ROOT" ] || SCRATCH_ROOT="${TMPDIR:-/tmp}/compound-engineering-$(id -u)";
81
+ if [ -L "$SCRATCH_ROOT" ]; then echo "unsafe scratch root symlink: $SCRATCH_ROOT" >&2; exit 1; fi;
82
+ (umask 077; mkdir -p "$SCRATCH_ROOT") || exit 1;
83
+ if [ -L "$SCRATCH_ROOT" ] || [ ! -O "$SCRATCH_ROOT" ]; then echo "scratch root is not owned by the current user: $SCRATCH_ROOT" >&2; exit 1; fi;
84
+ chmod 700 "$SCRATCH_ROOT" || exit 1;
85
+ PROBE_DIR="$SCRATCH_ROOT/ce-brainstorm-visual/<run-id>"; (umask 077; mkdir -p "$PROBE_DIR") || exit 1; chmod 700 "$PROBE_DIR" || exit 1;
86
+ node "$SKILL_DIR/scripts/light-webserver.js" start --root "$PROBE_DIR"
87
+ ```
88
+
89
+ Append `--foreground` to that `start` command for foreground mode. Status and stop take the same anchor — and because `SKILL_DIR` does not persist between Bash invocations, each must re-set it in its own call rather than reuse the `start` block's value:
90
+
91
+ ```bash
92
+ SKILL_DIR="<absolute path of the ce-brainstorm skill directory>";
93
+ SCRATCH_ROOT="/tmp/compound-engineering-$(id -u)";
94
+ [ ! -L "$SCRATCH_ROOT" ] && (umask 077; mkdir -p "$SCRATCH_ROOT") 2>/dev/null && [ ! -L "$SCRATCH_ROOT" ] && [ -O "$SCRATCH_ROOT" ] && [ -w "$SCRATCH_ROOT" ] || SCRATCH_ROOT="${TMPDIR:-/tmp}/compound-engineering-$(id -u)";
95
+ if [ -L "$SCRATCH_ROOT" ]; then echo "unsafe scratch root symlink: $SCRATCH_ROOT" >&2; exit 1; fi;
96
+ (umask 077; mkdir -p "$SCRATCH_ROOT") || exit 1;
97
+ if [ -L "$SCRATCH_ROOT" ] || [ ! -O "$SCRATCH_ROOT" ]; then echo "scratch root is not owned by the current user: $SCRATCH_ROOT" >&2; exit 1; fi;
98
+ chmod 700 "$SCRATCH_ROOT" || exit 1;
99
+ PROBE_DIR="$SCRATCH_ROOT/ce-brainstorm-visual/<run-id>"; (umask 077; mkdir -p "$PROBE_DIR") || exit 1; chmod 700 "$PROBE_DIR" || exit 1;
100
+ node "$SKILL_DIR/scripts/light-webserver.js" status --root "$PROBE_DIR"
101
+ # stop: the same command with `stop` in place of `status` (re-set SKILL_DIR again)
102
+ ```
103
+
104
+ If `SKILL_DIR` cannot be resolved to a concrete skill directory, do not guess from the project CWD — use the text path.
105
+
106
+ The helper creates `screens/` and `state/`, serves the newest `.html` file in `screens/`, writes `state/display-info.json`, and exposes `/version` so the browser can poll for screen changes. The browser reloads only when the newest screen changes; it must not continually reload on a timer. `/version` polling does not count as activity, so an abandoned browser tab cannot keep the server alive forever. Detached servers monitor the owning harness process when it can be resolved, and all servers exit after an idle timeout. The helper has no click tracking or browser-to-agent event path.
107
+
108
+ If the helper path is unavailable or the platform cannot display a local URL cleanly, say so briefly and use the text path. Do not build a custom event system or long-lived server to compensate during the brainstorm.
109
+
110
+ ## Launch Mode by Platform
111
+
112
+ The server is the same everywhere; only the launch mode changes.
113
+
114
+ - **Claude Code / Claude desktop app:** detached `start` is the default path. If the app opens localhost URLs, show the returned URL and continue. If the browser surface is unavailable, use the text path.
115
+ - **Codex CLI / Codex app:** if detached processes are reaped or the URL dies after the tool call, use `start --foreground` through the platform's long-running/background terminal mechanism. If there is no stable browser surface, use the text path.
116
+ - **Plain terminal UI:** print the returned URL for the user to open manually. If opening a browser would interrupt the flow, keep the decision in chat.
117
+ - **Remote or containerized sessions:** if `localhost` is not reachable from the user's browser, start with `--host 0.0.0.0` and tell the user which host/port to open. That serves the run directory to anything that can reach the port, with no auth — do it only on a network the user trusts, and say so when you hand over the URL. If that cannot be made clear, use the text path.
118
+
119
+ Never force the visual path because a local server exists. The user chose visual to understand the decision faster; if the platform plumbing gets in the way, switch back to text.
120
+
121
+ ## Post-Artifact Feedback
122
+
123
+ After showing the visual artifact, use the host's blocking question tool already in the current tool list for bounded artifact feedback. This is still chat-based feedback, not browser event capture.
124
+
125
+ Use a bounded interactive question when the expected response is a small choice set:
126
+
127
+ - A/B/C/D option selection
128
+ - visual direction vs mix
129
+ - choose one layout/state/behavior
130
+ - accept one option with requested tweaks
131
+
132
+ Include a free-text fallback option when the tool supports it. Use plain chat only when feedback is genuinely open critique, no interactive question tool exists, or the tool errors.
133
+
134
+ Good post-artifact prompt:
135
+
136
+ > Which direction best matches what you want? Pick A, B, C, D, or mix, and use the free-text fallback for anything that feels off. Judge the behavior shape, not the exact styling.
137
+
138
+ Do not ask the user to click inside the browser artifact. The question tool is for the chat/session response after the artifact is visible.
139
+
140
+ ## Interaction Contract
141
+
142
+ The browser/artifact is display-only. Feedback happens in chat.
143
+
144
+ Do not add click tracking, selected states, event ingestion, forms, analytics, or "submit" affordances in v1. Do not ask the user to click an option. Ask them to look at the artifact and reply in chat with the choice, mix, or correction.
145
+
146
+ If no interactive question tool is available, use this plain-chat fallback after showing the artifact:
147
+
148
+ > I’m showing three rough options. Reply here with A, B, C, or "mix", plus anything that feels off. Judge the behavior shape, not the exact styling.
149
+
150
+ The user's chat response is authoritative. The visual artifact is supporting context only.
151
+
152
+ ## File Placement
153
+
154
+ Use OS temp by default because visual probes are disposable scratch:
155
+
156
+ ```text
157
+ <scratch-root>/ce-brainstorm-visual/<run-id>/
158
+ screens/
159
+ 001-<decision>.html
160
+ state/
161
+ display-info.json
162
+ ```
163
+
164
+ Use `.context/compound-engineering/ce-brainstorm-visual/<run-id>/` only when the user explicitly wants to inspect, preserve, or curate the sketches after the session. The probe is disposable scratch; the durable artifact is the Phase 3 requirements-only unified plan under `<root>/plans/`.
@@ -0,0 +1,288 @@
1
+ #!/usr/bin/env bash
2
+ # elevation-dispatch.sh — off-host model-elevation worker for ce-plan / ce-brainstorm.
3
+ #
4
+ # Runs one reasoning-heavy step on a user-chosen model via the Claude CLI, as a
5
+ # detached job supervised by peer-job-runner.py. Streams NDJSON so the idle
6
+ # window observes genuine progress, not just liveness — a buffered format would
7
+ # make a healthy long run byte-identical to a wedged one. See
8
+ # docs/solutions/skill-design/cli-output-buffering-for-progress-detection.md.
9
+ #
10
+ # Read-only posture (R7): the CLI is allowlisted to Read/Glob/Grep plus
11
+ # WebSearch/WebFetch, so writes, shell, skills, and MCP are unavailable; the
12
+ # model reads the repo and web to verify its brief and returns prose.
13
+ #
14
+ # Usage:
15
+ # elevation-dispatch.sh <model> <prompt-file> <result-path>
16
+ # elevation-dispatch.sh --emit-adapter <model> # print argv, no model call (test hook)
17
+ #
18
+ # NOTE ON THE FUNCTION NAMED run_codex_cmd: it is NOT codex-specific here. It is
19
+ # the $PEERLOG byte-growth idle loop that implements R11's primary supervision
20
+ # signal (run_timeout_cmd, hard-cap-only, would leave a stalled run undetected).
21
+ # It keeps that name because the shared heartbeat-parity regex in
22
+ # tests/peer-job-runner-parity.test.ts uses `run_codex_cmd()` as the terminator
23
+ # that forces BOTH heartbeat functions into the byte-compared kernel; renaming it
24
+ # would weaken that cross-skill guard.
25
+
26
+ set -uo pipefail
27
+ trap '' HUP
28
+
29
+ ACTIVE_PEER_PID=""
30
+ RUN_SUCCEEDED=false
31
+
32
+ log() { printf '[elevation] %s\n' "$*" >&2; }
33
+
34
+ EFFORT="high" # settled: elevation runs at high effort
35
+
36
+ # Read-only tool posture (R7): the available built-in set, not a denylist. The
37
+ # elevated step reads the repo (Read/Glob/Grep) and may check current facts on
38
+ # the web (WebSearch/WebFetch) while authoring; it never needs Write/Bash/Task or
39
+ # any mutating tool. Its output is returned prose, not a file write.
40
+ ALLOWED=(Read Glob Grep WebSearch WebFetch)
41
+
42
+ build_cmd() { # <model> <handoff-dir> -> sets CMD array (claude CLI, streaming, read-only)
43
+ # --safe-mode suppresses the user environment's hooks, plugins, and MCP
44
+ # servers; --disable-slash-commands blocks skills. --tools RESTRICTS the
45
+ # available built-in set to this list — Write/Edit/Bash are not present at all.
46
+ # This is the real read-only boundary: --allowedTools ALONE only pre-approves
47
+ # (verified — it leaves every other tool available), so --allowedTools here
48
+ # just lets --permission-mode dontAsk run these five without a prompt instead
49
+ # of denying them.
50
+ local csv; csv="$(IFS=,; printf '%s' "${ALLOWED[*]}")"
51
+ # Grant read access to ONLY the single per-run handoff dir ($2, where the
52
+ # orchestrator co-located the prompt and evidence), which sits outside the
53
+ # launch dir. Claude's file access defaults to the launch dir and is extended
54
+ # via --add-dir. Adding the whole OS temp root ($TMPDIR / /tmp) instead would
55
+ # expose every other same-user scratch file and credential to the elevated
56
+ # model; the scoped dir does not. Read-only (only Read/Glob/Grep available).
57
+ local add_dirs=()
58
+ [ -n "${2:-}" ] && add_dirs=(--add-dir "$2")
59
+ # --no-session-persistence: this is a one-shot background model call, so the
60
+ # prompt and scratch-file references must not be saved as a resumable session
61
+ # on disk (matches the other scripted Claude peer routes in this repo).
62
+ CMD=(claude -p --model "$1" --effort "$EFFORT"
63
+ --output-format stream-json --verbose
64
+ --safe-mode --no-session-persistence --disable-slash-commands --strict-mcp-config
65
+ --permission-mode dontAsk
66
+ "${add_dirs[@]}"
67
+ --tools "$csv" --allowedTools "${ALLOWED[@]}"
68
+ --max-turns "${ELEVATION_MAX_TURNS:-30}")
69
+ }
70
+
71
+ # Test hook: print the argv the worker would exec, without calling a model.
72
+ # Accepts an optional handoff dir ($3) so the emitted argv shows the scoped
73
+ # --add-dir; without it the flag is omitted (no dir to grant).
74
+ if [ "${1:-}" = "--emit-adapter" ]; then
75
+ [ -n "${2:-}" ] || { log "--emit-adapter requires <model>"; exit 2; }
76
+ build_cmd "$2" "${3:-}"
77
+ printf '%s\0' "${CMD[@]}"
78
+ exit 0
79
+ fi
80
+
81
+ MODEL="${1:?model required}"
82
+ PROMPT_FILE="${2:?prompt-file required}"
83
+ RESULT_PATH="${3:?result-path required}"
84
+ [ -f "$PROMPT_FILE" ] || { log "prompt file not found: $PROMPT_FILE"; exit 2; }
85
+
86
+ # The orchestrator co-locates the prompt and every evidence file in one private
87
+ # per-run dir; grant the elevated model read access to just that dir (resolved
88
+ # to an absolute path), never the whole OS temp root. Pure-bash dirname (no
89
+ # external `dirname`): strip the last /component, defaulting to cwd if none.
90
+ HANDOFF_DIR="${PROMPT_FILE%/*}"
91
+ [ "$HANDOFF_DIR" = "$PROMPT_FILE" ] && HANDOFF_DIR="."
92
+ HANDOFF_DIR="$(cd "$HANDOFF_DIR" 2>/dev/null && pwd || printf '%s' "$HANDOFF_DIR")"
93
+
94
+ # jq builds every result envelope; it is only an optional capability (ce-setup),
95
+ # so preflight it here rather than spending the CLI call and failing to parse.
96
+ # Exit 0 with a failure envelope, NOT nonzero: the runner classifies a nonzero
97
+ # exit as `failed`, and its `result` command then refuses to emit the artifact,
98
+ # so the recovery flow could never read this envelope. Exit 0 makes the job
99
+ # `done`, the envelope's status:failed is read, and it degrades to inline.
100
+ if ! command -v jq >/dev/null 2>&1; then
101
+ log "jq not found on PATH; cannot parse the elevated result — degrading to inline"
102
+ printf '{"status":"failed","requested_model":"%s","evidence":"jq unavailable on PATH"}' "$MODEL" > "$RESULT_PATH" 2>/dev/null || true
103
+ exit 0
104
+ fi
105
+
106
+ PEERLOG="$(mktemp "${TMPDIR:-/tmp}/elevation-peer-XXXXXX")"
107
+
108
+ # Idle window is the primary stall signal; the hard cap is a raised backstop (R11).
109
+ # Keep this inner cap >= the runner's CE_PEER_HARD_SECS so it never reaps a
110
+ # healthy run before the outer supervisor's own raised backstop.
111
+ IDLE_SECS="${CE_ELEVATION_IDLE_SECS:-180}"
112
+ HARD_SECS="${CE_ELEVATION_HARD_SECS:-5400}"
113
+ POLL_SECS="${CE_ELEVATION_POLL_SECS:-5}" # $PEERLOG growth poll interval
114
+
115
+ reap() {
116
+ local pid="$1" grp
117
+ if kill -TERM -- -"$pid" 2>/dev/null; then grp=1; else kill -TERM "$pid" 2>/dev/null; grp=0; fi
118
+ for _ in 1 2 3 4 5; do
119
+ if [ "$grp" = 1 ]; then kill -0 -- -"$pid" 2>/dev/null || return 0
120
+ else kill -0 "$pid" 2>/dev/null || return 0; fi
121
+ sleep 1
122
+ done
123
+ if [ "$grp" = 1 ]; then kill -KILL -- -"$pid" 2>/dev/null; else kill -KILL "$pid" 2>/dev/null; fi
124
+ }
125
+
126
+ on_term() {
127
+ if [ -n "${_HEARTBEAT_PID:-}" ]; then
128
+ stop_heartbeat
129
+ fi
130
+ if [ -n "${ACTIVE_PEER_PID:-}" ]; then
131
+ log "received TERM/INT; reaping peer process group $ACTIVE_PEER_PID"
132
+ reap "$ACTIVE_PEER_PID" 2>/dev/null || true
133
+ ACTIVE_PEER_PID=""
134
+ fi
135
+ exit 0
136
+ }
137
+ trap 'on_term' TERM INT
138
+
139
+ write_result() { # <json-string> -> atomic publish to RESULT_PATH
140
+ local tmp="${RESULT_PATH}.tmp.$$"
141
+ printf '%s' "$1" > "$tmp" && mv -f "$tmp" "$RESULT_PATH"
142
+ }
143
+
144
+ # Bounded stderr/stdout tail for a failed run. tail -c avoids the macOS bash
145
+ # negative-slice bug that erased sub-300-char evidence in the review worker.
146
+ bounded_failure_evidence() { tail -c 800 "$PEERLOG" 2>/dev/null || true; }
147
+
148
+ # Expected served-id prefix for a requested model alias, or empty if unknown.
149
+ model_prefix() { # <requested> -> prefix | ""
150
+ case "$1" in
151
+ fable) printf 'claude-fable-' ;;
152
+ opus) printf 'claude-opus-' ;;
153
+ sonnet) printf 'claude-sonnet-' ;;
154
+ haiku) printf 'claude-haiku-' ;;
155
+ claude-*) printf '%s' "$1" ;;
156
+ esac
157
+ }
158
+
159
+ # Requested family vs served id (R6/R16). matched | mismatch | unverified.
160
+ classify_receipt() { # <requested> <served>
161
+ local served="$2" prefix
162
+ { [ -z "$served" ] || [ "$served" = "unverified" ]; } && { printf 'unverified'; return; }
163
+ prefix="$(model_prefix "$1")"
164
+ [ -z "$prefix" ] && { printf 'unverified'; return; }
165
+ case "$served" in
166
+ "$prefix"*) printf 'matched' ;;
167
+ *) printf 'mismatch' ;;
168
+ esac
169
+ }
170
+
171
+ # --- liveness heartbeat -----------------------------------------------------
172
+ # Emits one stderr line every CROSS_MODEL_HEARTBEAT_SECS so the OUTER
173
+ # peer-job-runner idle window (out.log byte-growth) sees the supervising script
174
+ # as alive during a long model call. It writes to stderr, NOT $PEERLOG, so it
175
+ # never masks this worker's OWN $PEERLOG idle detection (run_codex_cmd below) —
176
+ # a stalled model still stops growing $PEERLOG and is reaped. This block is
177
+ # byte-identical across all peer workers (kernel parity, tests/peer-job-runner-parity.test.ts).
178
+ _HEARTBEAT_PID=""
179
+ start_heartbeat() {
180
+ local every="${CROSS_MODEL_HEARTBEAT_SECS:-60}" parent_pid="$$"
181
+ # Floor to 1s: a non-numeric or 0 value would make `sleep` return instantly and
182
+ # spin the loop, flooding out.log into the runner's byte cap.
183
+ case "$every" in ''|*[!0-9]*) every=60 ;; esac; [ "$every" -lt 1 ] && every=1
184
+ _HEARTBEAT_READY=0
185
+ trap '_HEARTBEAT_READY=1' USR1
186
+ # Callers restore set +m after launching the peer, so without this the
187
+ # heartbeat inherits the worker pgid and kill -- -PID cannot reach the sleep.
188
+ local prev_m; case "$-" in *m*) prev_m=1;; *) prev_m=0;; esac
189
+ set -m
190
+ ( local t0 n sleeper=""
191
+ trap 'kill "${sleeper:-}" 2>/dev/null || true; exit 0' TERM INT
192
+ kill -USR1 "$parent_pid"
193
+ t0="$(date +%s)"
194
+ while kill -0 "$parent_pid" 2>/dev/null; do
195
+ sleep "$every" & sleeper=$!
196
+ wait "$sleeper" 2>/dev/null || exit 0
197
+ sleeper=""
198
+ kill -0 "$parent_pid" 2>/dev/null || break
199
+ n="$(date +%s)"; log "peer alive ($(( n - t0 ))s elapsed)"
200
+ done ) &
201
+ _HEARTBEAT_PID=$!
202
+ [ "$prev_m" = 0 ] && set +m
203
+ while [ "$_HEARTBEAT_READY" != 1 ] && kill -0 "$_HEARTBEAT_PID" 2>/dev/null; do sleep 0.01 || true; done
204
+ trap - USR1
205
+ }
206
+ stop_heartbeat() {
207
+ if [ -n "$_HEARTBEAT_PID" ]; then
208
+ # Leader-only TERM is deferred until the inner `wait $sleeper` returns, so
209
+ # the default 60s interval would block this wait. Signal the process group.
210
+ kill -- -"$_HEARTBEAT_PID" 2>/dev/null || kill "$_HEARTBEAT_PID" 2>/dev/null || true
211
+ wait "$_HEARTBEAT_PID" 2>/dev/null || true
212
+ fi
213
+ _HEARTBEAT_PID=""
214
+ }
215
+
216
+ run_codex_cmd() {
217
+ RUN_SUCCEEDED=false
218
+ local prev; case "$-" in *m*) prev=1;; *) prev=0;; esac
219
+ set -m
220
+ command "${CMD[@]}" < "$PROMPT_FILE" > "$PEERLOG" 2>&1 &
221
+ local pid=$!
222
+ ACTIVE_PEER_PID="$pid"
223
+ [ "$prev" = 0 ] && set +m
224
+ start_heartbeat
225
+ local start last=-1 lastchg now size
226
+ start="$(date +%s)"; lastchg="$start"
227
+ while kill -0 "$pid" 2>/dev/null; do
228
+ sleep "$POLL_SECS"; now="$(date +%s)"; size="$(wc -c <"$PEERLOG" 2>/dev/null || echo 0)"
229
+ [ "$size" != "$last" ] && { last="$size"; lastchg="$now"; }
230
+ if [ $(( now - lastchg )) -ge "$IDLE_SECS" ]; then
231
+ log "elevated call idle ${IDLE_SECS}s; reaping"; reap "$pid"; break
232
+ fi
233
+ if [ $(( now - start )) -ge "$HARD_SECS" ]; then
234
+ log "elevated call exceeded hard cap ${HARD_SECS}s; reaping"; reap "$pid"; break
235
+ fi
236
+ done
237
+ if wait "$pid" 2>/dev/null; then RUN_SUCCEEDED=true
238
+ else log "elevated call exited non-zero or was reaped"; fi
239
+ reap "$pid" 2>/dev/null || true
240
+ stop_heartbeat
241
+ ACTIVE_PEER_PID=""
242
+ }
243
+
244
+ # --- main -------------------------------------------------------------------
245
+ build_cmd "$MODEL" "$HANDOFF_DIR"
246
+ run_codex_cmd
247
+
248
+ # The stream-json terminal event is the LAST line whose type is "result". Match
249
+ # on it rather than `tail -1`, so a diagnostic written to stderr after the result
250
+ # (an update notice, wrapper output) does not become the "result" we parse.
251
+ EVENT="$(grep -a '"type":"result"' "$PEERLOG" 2>/dev/null | tail -1 || true)"
252
+ PREFIX="$(model_prefix "$MODEL")"
253
+ # jq `keys` is sorted, so keys[0] is not necessarily the served model when
254
+ # modelUsage carries an auxiliary model too; prefer the requested family's key.
255
+ SERVED="$(printf '%s' "$EVENT" | jq -r --arg p "$PREFIX" \
256
+ '(.modelUsage // {} | keys) as $k
257
+ | (if $p != "" then first($k[] | select(startswith($p))) else empty end) // $k[0] // "unverified"' \
258
+ 2>/dev/null || printf 'unverified')"
259
+ # Ship "ok" only on a clean success — a terminal event carries .result even when
260
+ # truncated/errored (subtype error_*, is_error true). HAS_OUTPUT is a tiny jq
261
+ # flag, so the plan text is never loaded into a shell variable or an argv.
262
+ SUBTYPE="$(printf '%s' "$EVENT" | jq -r '.subtype // empty' 2>/dev/null || true)"
263
+ IS_ERROR="$(printf '%s' "$EVENT" | jq -r '.is_error // false' 2>/dev/null || printf 'true')"
264
+ HAS_OUTPUT="$(printf '%s' "$EVENT" | jq -r 'if (.result // "") == "" then "no" else "yes" end' 2>/dev/null || printf 'no')"
265
+
266
+ if [ "$RUN_SUCCEEDED" = true ] && [ "$HAS_OUTPUT" = "yes" ] \
267
+ && [ "$SUBTYPE" = "success" ] && [ "$IS_ERROR" != "true" ]; then
268
+ RECEIPT="$(classify_receipt "$MODEL" "$SERVED")"
269
+ # Build the envelope by piping the event THROUGH jq, which reads .result
270
+ # internally — never pass the plan text as an argv --arg, which would exceed
271
+ # ARG_MAX for a large Deep plan.
272
+ tmp="${RESULT_PATH}.tmp.$$"
273
+ if printf '%s' "$EVENT" | jq --arg m "$MODEL" --arg s "$SERVED" --arg r "$RECEIPT" \
274
+ '{status:"ok", requested_model:$m, served_model:$s, receipt:$r, output:.result}' \
275
+ > "$tmp" 2>/dev/null; then
276
+ mv -f "$tmp" "$RESULT_PATH"
277
+ log "elevated step complete: requested=$MODEL served=$SERVED receipt=$RECEIPT"
278
+ else
279
+ rm -f "$tmp"
280
+ write_result "$(jq -n --arg m "$MODEL" '{status:"failed", requested_model:$m, evidence:"result envelope build failed"}')"
281
+ log "elevated step: result envelope build failed"
282
+ fi
283
+ else
284
+ write_result "$(jq -n --arg m "$MODEL" --arg e "$(bounded_failure_evidence)" \
285
+ '{status:"failed", requested_model:$m, evidence:$e}')"
286
+ log "elevated step failed; wrote failure envelope"
287
+ fi
288
+ rm -f "$PEERLOG"