create-egregore 0.21.0-runtime-mvp.26 → 0.21.0-runtime-mvp.28

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 (416) hide show
  1. package/assets/egregore-launcher.js +120 -70
  2. package/bin/cli.js +81 -67
  3. package/lib/api.js +6 -2
  4. package/lib/auth.js +1 -1
  5. package/lib/harness-add.js +159 -0
  6. package/lib/install-access.js +87 -0
  7. package/lib/setup.js +84 -10
  8. package/lib/token-install.js +65 -0
  9. package/package.json +5 -3
  10. package/runtime/claude/.claude/context/notification-consent.md +17 -2
  11. package/runtime/claude/.claude/context/retrieval-investigation.md +50 -0
  12. package/runtime/claude/.claude/context/telemetry.md +72 -3
  13. package/runtime/claude/.claude/hooks/memory-read-guard.sh +54 -13
  14. package/runtime/claude/.claude/hooks/retrieval-context.sh +4 -44
  15. package/runtime/claude/.claude/rules/voice-bedrock.md +11 -0
  16. package/runtime/claude/.claude/skills/branch/SKILL.md +22 -18
  17. package/runtime/claude/.claude/skills/commit/SKILL.md +11 -7
  18. package/runtime/claude/.claude/skills/create-skill/SKILL.md +5 -3
  19. package/runtime/claude/.claude/skills/issue/SKILL.md +94 -0
  20. package/runtime/claude/.claude/skills/pr/SKILL.md +11 -17
  21. package/runtime/claude/.claude/skills/pull/SKILL.md +10 -33
  22. package/runtime/claude/.claude/skills/push/SKILL.md +6 -2
  23. package/runtime/claude/.claude/skills/review-pr/SKILL.md +18 -0
  24. package/runtime/claude/.claude/skills/save/SKILL.md +12 -2
  25. package/runtime/claude/.claude/skills/test/SKILL.md +2 -2
  26. package/runtime/claude/.claude/skills/update/SKILL.md +1 -1
  27. package/runtime/claude/.claude/skills/view/SKILL.md +3 -2
  28. package/runtime/claude/CLAUDE.md +34 -16
  29. package/runtime/claude/bin/agent.sh +56 -4
  30. package/runtime/claude/bin/base-branch.sh +62 -0
  31. package/runtime/claude/bin/codex-render-spec.mjs +32 -64
  32. package/runtime/claude/bin/codex-session-start.sh +24 -39
  33. package/runtime/claude/bin/codex-sync-skills.sh +79 -24
  34. package/runtime/claude/bin/graph-op.sh +73 -3
  35. package/runtime/claude/bin/lib/generated-trees.sh +27 -0
  36. package/runtime/claude/bin/lib/git-sync.sh +53 -9
  37. package/runtime/claude/bin/lib/greeting.sh +41 -71
  38. package/runtime/claude/bin/lib/health-footer.sh +115 -0
  39. package/runtime/claude/bin/lib/identity.sh +1 -0
  40. package/runtime/claude/bin/lib/notices.sh +177 -0
  41. package/runtime/claude/bin/lib/repo-paths.sh +40 -0
  42. package/runtime/claude/bin/observe-context.sh +2 -2
  43. package/runtime/claude/bin/pi-render-spec.mjs +0 -1
  44. package/runtime/claude/bin/prime-render-spec.mjs +1 -2
  45. package/runtime/claude/bin/prose-check-tally.sh +102 -0
  46. package/runtime/claude/bin/prose-check.mjs +554 -0
  47. package/runtime/claude/bin/prose-rules/announcing-instead-of-doing.md +24 -0
  48. package/runtime/claude/bin/prose-rules/banned-vocabulary.md +40 -0
  49. package/runtime/claude/bin/prose-rules/coined-terms.md +20 -0
  50. package/runtime/claude/bin/prose-rules/exclamation.md +24 -0
  51. package/runtime/claude/bin/prose-rules/filler-intensifiers.md +24 -0
  52. package/runtime/claude/bin/prose-rules/hedging-stack.md +26 -0
  53. package/runtime/claude/bin/prose-rules/mannered-prose.md +24 -0
  54. package/runtime/claude/bin/prose-rules/not-x-but-y.md +23 -0
  55. package/runtime/claude/bin/prose-rules/one-name-per-thing.md +20 -0
  56. package/runtime/claude/bin/prose-rules/passive-enthusiasm.md +25 -0
  57. package/runtime/claude/bin/prose-rules/process-narration.md +30 -0
  58. package/runtime/claude/bin/prose-rules/rhetorical-opener.md +23 -0
  59. package/runtime/claude/bin/prose-rules/self-contained.md +20 -0
  60. package/runtime/claude/bin/prose-rules/self-praise.md +22 -0
  61. package/runtime/claude/bin/prose-rules/temporal-handwave.md +27 -0
  62. package/runtime/claude/bin/pull.sh +272 -0
  63. package/runtime/claude/bin/qa-inventory.sh +341 -0
  64. package/runtime/claude/bin/search.sh +104 -58
  65. package/runtime/claude/bin/session-start.sh +2 -0
  66. package/runtime/claude/bin/telemetry.sh +65 -18
  67. package/runtime/claude/bin/test-baseline.sh +296 -0
  68. package/runtime/claude/bin/test-changes.sh +196 -145
  69. package/runtime/claude/bin/view-render.sh +6 -2
  70. package/runtime/claude/bin/worktree-create.sh +11 -0
  71. package/runtime/claude/egregore_runtime/adapters/qmd.py +309 -50
  72. package/runtime/claude/egregore_runtime/adapters/qmd_cli.py +6 -3
  73. package/runtime/claude/egregore_runtime/adapters/qmd_scoped.mjs +202 -0
  74. package/runtime/claude/egregore_runtime/adapters/qmd_scoped.py +137 -0
  75. package/runtime/claude/egregore_runtime/adapters/qmd_worker.mjs +123 -0
  76. package/runtime/claude/egregore_runtime/artifacts.py +11 -1
  77. package/runtime/claude/egregore_runtime/contracts.py +25 -1
  78. package/runtime/claude/egregore_runtime/eligibility.py +137 -0
  79. package/runtime/claude/egregore_runtime/episode_binding.py +178 -0
  80. package/runtime/claude/egregore_runtime/excerpts.py +42 -0
  81. package/runtime/claude/egregore_runtime/github_issues.py +244 -0
  82. package/runtime/claude/egregore_runtime/harness_cli.py +545 -402
  83. package/runtime/claude/egregore_runtime/identity.py +52 -0
  84. package/runtime/claude/egregore_runtime/ingest_index_cli.py +4 -2
  85. package/runtime/claude/egregore_runtime/investigation.py +792 -0
  86. package/runtime/claude/egregore_runtime/investigation_contracts.py +104 -0
  87. package/runtime/claude/egregore_runtime/investigation_guidance.py +51 -0
  88. package/runtime/claude/egregore_runtime/issue_cli.py +66 -0
  89. package/runtime/claude/egregore_runtime/issue_markers.py +50 -0
  90. package/runtime/claude/egregore_runtime/issue_reporting.py +224 -0
  91. package/runtime/claude/egregore_runtime/observe.py +41 -6
  92. package/runtime/claude/egregore_runtime/operation_cli.py +76 -0
  93. package/runtime/claude/egregore_runtime/operation_observations.py +208 -0
  94. package/runtime/claude/egregore_runtime/private_result.py +147 -0
  95. package/runtime/claude/egregore_runtime/research_ingest_cli.py +3 -1
  96. package/runtime/claude/egregore_runtime/runtime.py +38 -1
  97. package/runtime/claude/egregore_runtime/scroll_cli.py +1 -1
  98. package/runtime/claude/egregore_runtime/scrolls.py +172 -28
  99. package/runtime/claude/egregore_runtime/sync.py +226 -15
  100. package/runtime/claude/egregore_runtime/sync_health.py +63 -0
  101. package/runtime/claude/egregore_runtime/telemetry.py +102 -10
  102. package/runtime/claude/egregore_runtime/threads.py +4 -1
  103. package/runtime/claude/egregore_runtime/writeback.py +28 -4
  104. package/runtime/claude/manifest.json +42 -0
  105. package/runtime/codex/.claude/context/notification-consent.md +17 -2
  106. package/runtime/codex/.claude/context/retrieval-investigation.md +50 -0
  107. package/runtime/codex/.codex/skills/activity/SKILL.md +4 -0
  108. package/runtime/codex/.codex/skills/announce/SKILL.md +7 -0
  109. package/runtime/codex/.codex/skills/archive/SKILL.md +7 -0
  110. package/runtime/codex/.codex/skills/checkup/SKILL.md +7 -0
  111. package/runtime/codex/.codex/skills/dashboard/SKILL.md +4 -0
  112. package/runtime/codex/.codex/skills/deep-reflect/SKILL.md +8 -0
  113. package/runtime/codex/.codex/skills/handoff/SKILL.md +8 -3
  114. package/runtime/codex/.codex/skills/harvest/SKILL.md +8 -0
  115. package/runtime/codex/.codex/skills/ingest/SKILL.md +4 -0
  116. package/runtime/codex/.codex/skills/ingest-user-interview/SKILL.md +7 -0
  117. package/runtime/codex/.codex/skills/invite/SKILL.md +7 -0
  118. package/runtime/codex/.codex/skills/issue/SKILL.md +102 -0
  119. package/runtime/codex/.codex/skills/meeting/SKILL.md +8 -0
  120. package/runtime/codex/.codex/skills/note/SKILL.md +7 -0
  121. package/runtime/codex/.codex/skills/onboarding/SKILL.md +7 -0
  122. package/runtime/codex/.codex/skills/quest/SKILL.md +7 -0
  123. package/runtime/codex/.codex/skills/reflect/SKILL.md +8 -0
  124. package/runtime/codex/.codex/skills/save/SKILL.md +24 -7
  125. package/runtime/codex/.codex/skills/the-spiral/SKILL.md +10 -1
  126. package/runtime/codex/.codex/skills/tutorial/SKILL.md +8 -0
  127. package/runtime/codex/.codex/skills/view/SKILL.md +8 -0
  128. package/runtime/codex/.codex/skills/wrap/SKILL.md +8 -0
  129. package/runtime/codex/.codex/spec-manifest.json +7 -7
  130. package/runtime/codex/AGENTS.md +60 -74
  131. package/runtime/codex/bin/agent.sh +56 -4
  132. package/runtime/codex/bin/base-branch.sh +62 -0
  133. package/runtime/codex/bin/codex-render-spec.mjs +32 -64
  134. package/runtime/codex/bin/codex-session-start.sh +24 -39
  135. package/runtime/codex/bin/codex-sync-skills.sh +79 -24
  136. package/runtime/codex/bin/graph-op.sh +73 -3
  137. package/runtime/codex/bin/lib/generated-trees.sh +27 -0
  138. package/runtime/codex/bin/lib/git-sync.sh +53 -9
  139. package/runtime/codex/bin/lib/greeting.sh +41 -71
  140. package/runtime/codex/bin/lib/health-footer.sh +115 -0
  141. package/runtime/codex/bin/lib/identity.sh +1 -0
  142. package/runtime/codex/bin/lib/notices.sh +177 -0
  143. package/runtime/codex/bin/lib/repo-paths.sh +40 -0
  144. package/runtime/codex/bin/observe-context.sh +2 -2
  145. package/runtime/codex/bin/pi-render-spec.mjs +0 -1
  146. package/runtime/codex/bin/prime-render-spec.mjs +1 -2
  147. package/runtime/codex/bin/prose-check-tally.sh +102 -0
  148. package/runtime/codex/bin/prose-check.mjs +554 -0
  149. package/runtime/codex/bin/prose-rules/announcing-instead-of-doing.md +24 -0
  150. package/runtime/codex/bin/prose-rules/banned-vocabulary.md +40 -0
  151. package/runtime/codex/bin/prose-rules/coined-terms.md +20 -0
  152. package/runtime/codex/bin/prose-rules/exclamation.md +24 -0
  153. package/runtime/codex/bin/prose-rules/filler-intensifiers.md +24 -0
  154. package/runtime/codex/bin/prose-rules/hedging-stack.md +26 -0
  155. package/runtime/codex/bin/prose-rules/mannered-prose.md +24 -0
  156. package/runtime/codex/bin/prose-rules/not-x-but-y.md +23 -0
  157. package/runtime/codex/bin/prose-rules/one-name-per-thing.md +20 -0
  158. package/runtime/codex/bin/prose-rules/passive-enthusiasm.md +25 -0
  159. package/runtime/codex/bin/prose-rules/process-narration.md +30 -0
  160. package/runtime/codex/bin/prose-rules/rhetorical-opener.md +23 -0
  161. package/runtime/codex/bin/prose-rules/self-contained.md +20 -0
  162. package/runtime/codex/bin/prose-rules/self-praise.md +22 -0
  163. package/runtime/codex/bin/prose-rules/temporal-handwave.md +27 -0
  164. package/runtime/codex/bin/pull.sh +272 -0
  165. package/runtime/codex/bin/qa-inventory.sh +341 -0
  166. package/runtime/codex/bin/search.sh +104 -58
  167. package/runtime/codex/bin/telemetry.sh +65 -18
  168. package/runtime/codex/bin/test-baseline.sh +296 -0
  169. package/runtime/codex/bin/test-changes.sh +196 -145
  170. package/runtime/codex/bin/view-render.sh +6 -2
  171. package/runtime/codex/bin/worktree-create.sh +11 -0
  172. package/runtime/codex/egregore_runtime/adapters/qmd.py +309 -50
  173. package/runtime/codex/egregore_runtime/adapters/qmd_cli.py +6 -3
  174. package/runtime/codex/egregore_runtime/adapters/qmd_scoped.mjs +202 -0
  175. package/runtime/codex/egregore_runtime/adapters/qmd_scoped.py +137 -0
  176. package/runtime/codex/egregore_runtime/adapters/qmd_worker.mjs +123 -0
  177. package/runtime/codex/egregore_runtime/artifacts.py +11 -1
  178. package/runtime/codex/egregore_runtime/contracts.py +25 -1
  179. package/runtime/codex/egregore_runtime/eligibility.py +137 -0
  180. package/runtime/codex/egregore_runtime/episode_binding.py +178 -0
  181. package/runtime/codex/egregore_runtime/excerpts.py +42 -0
  182. package/runtime/codex/egregore_runtime/github_issues.py +244 -0
  183. package/runtime/codex/egregore_runtime/harness_cli.py +545 -402
  184. package/runtime/codex/egregore_runtime/identity.py +52 -0
  185. package/runtime/codex/egregore_runtime/ingest_index_cli.py +4 -2
  186. package/runtime/codex/egregore_runtime/investigation.py +792 -0
  187. package/runtime/codex/egregore_runtime/investigation_contracts.py +104 -0
  188. package/runtime/codex/egregore_runtime/investigation_guidance.py +51 -0
  189. package/runtime/codex/egregore_runtime/issue_cli.py +66 -0
  190. package/runtime/codex/egregore_runtime/issue_markers.py +50 -0
  191. package/runtime/codex/egregore_runtime/issue_reporting.py +224 -0
  192. package/runtime/codex/egregore_runtime/observe.py +41 -6
  193. package/runtime/codex/egregore_runtime/operation_cli.py +76 -0
  194. package/runtime/codex/egregore_runtime/operation_observations.py +208 -0
  195. package/runtime/codex/egregore_runtime/private_result.py +147 -0
  196. package/runtime/codex/egregore_runtime/research_ingest_cli.py +3 -1
  197. package/runtime/codex/egregore_runtime/runtime.py +38 -1
  198. package/runtime/codex/egregore_runtime/scroll_cli.py +1 -1
  199. package/runtime/codex/egregore_runtime/scrolls.py +172 -28
  200. package/runtime/codex/egregore_runtime/sync.py +226 -15
  201. package/runtime/codex/egregore_runtime/sync_health.py +63 -0
  202. package/runtime/codex/egregore_runtime/telemetry.py +102 -10
  203. package/runtime/codex/egregore_runtime/threads.py +4 -1
  204. package/runtime/codex/egregore_runtime/writeback.py +28 -4
  205. package/runtime/codex/manifest.json +42 -0
  206. package/runtime/pi/.claude/context/notification-consent.md +17 -2
  207. package/runtime/pi/.claude/context/retrieval-investigation.md +50 -0
  208. package/runtime/pi/.codex/skills/activity/SKILL.md +4 -0
  209. package/runtime/pi/.codex/skills/announce/SKILL.md +7 -0
  210. package/runtime/pi/.codex/skills/archive/SKILL.md +7 -0
  211. package/runtime/pi/.codex/skills/checkup/SKILL.md +7 -0
  212. package/runtime/pi/.codex/skills/dashboard/SKILL.md +4 -0
  213. package/runtime/pi/.codex/skills/deep-reflect/SKILL.md +8 -0
  214. package/runtime/pi/.codex/skills/handoff/SKILL.md +8 -3
  215. package/runtime/pi/.codex/skills/harvest/SKILL.md +8 -0
  216. package/runtime/pi/.codex/skills/ingest/SKILL.md +4 -0
  217. package/runtime/pi/.codex/skills/ingest-user-interview/SKILL.md +7 -0
  218. package/runtime/pi/.codex/skills/invite/SKILL.md +7 -0
  219. package/runtime/pi/.codex/skills/issue/SKILL.md +102 -0
  220. package/runtime/pi/.codex/skills/meeting/SKILL.md +8 -0
  221. package/runtime/pi/.codex/skills/note/SKILL.md +7 -0
  222. package/runtime/pi/.codex/skills/onboarding/SKILL.md +7 -0
  223. package/runtime/pi/.codex/skills/quest/SKILL.md +7 -0
  224. package/runtime/pi/.codex/skills/reflect/SKILL.md +8 -0
  225. package/runtime/pi/.codex/skills/save/SKILL.md +24 -7
  226. package/runtime/pi/.codex/skills/the-spiral/SKILL.md +10 -1
  227. package/runtime/pi/.codex/skills/tutorial/SKILL.md +8 -0
  228. package/runtime/pi/.codex/skills/view/SKILL.md +8 -0
  229. package/runtime/pi/.codex/skills/wrap/SKILL.md +8 -0
  230. package/runtime/pi/.codex/spec-manifest.json +7 -7
  231. package/runtime/pi/.pi/APPEND_SYSTEM.md +35 -17
  232. package/runtime/pi/.pi/extensions/egregore.ts +8 -7
  233. package/runtime/pi/.pi/spec-manifest.json +2 -2
  234. package/runtime/pi/AGENTS.md +60 -74
  235. package/runtime/pi/bin/agent.sh +56 -4
  236. package/runtime/pi/bin/base-branch.sh +62 -0
  237. package/runtime/pi/bin/codex-render-spec.mjs +32 -64
  238. package/runtime/pi/bin/codex-session-start.sh +24 -39
  239. package/runtime/pi/bin/codex-sync-skills.sh +79 -24
  240. package/runtime/pi/bin/graph-op.sh +73 -3
  241. package/runtime/pi/bin/lib/generated-trees.sh +27 -0
  242. package/runtime/pi/bin/lib/git-sync.sh +53 -9
  243. package/runtime/pi/bin/lib/greeting.sh +41 -71
  244. package/runtime/pi/bin/lib/health-footer.sh +115 -0
  245. package/runtime/pi/bin/lib/identity.sh +1 -0
  246. package/runtime/pi/bin/lib/notices.sh +177 -0
  247. package/runtime/pi/bin/lib/repo-paths.sh +40 -0
  248. package/runtime/pi/bin/observe-context.sh +2 -2
  249. package/runtime/pi/bin/pi-observe-context.mjs +38 -2
  250. package/runtime/pi/bin/pi-render-spec.mjs +0 -1
  251. package/runtime/pi/bin/prime-render-spec.mjs +1 -2
  252. package/runtime/pi/bin/prose-check-tally.sh +102 -0
  253. package/runtime/pi/bin/prose-check.mjs +554 -0
  254. package/runtime/pi/bin/prose-rules/announcing-instead-of-doing.md +24 -0
  255. package/runtime/pi/bin/prose-rules/banned-vocabulary.md +40 -0
  256. package/runtime/pi/bin/prose-rules/coined-terms.md +20 -0
  257. package/runtime/pi/bin/prose-rules/exclamation.md +24 -0
  258. package/runtime/pi/bin/prose-rules/filler-intensifiers.md +24 -0
  259. package/runtime/pi/bin/prose-rules/hedging-stack.md +26 -0
  260. package/runtime/pi/bin/prose-rules/mannered-prose.md +24 -0
  261. package/runtime/pi/bin/prose-rules/not-x-but-y.md +23 -0
  262. package/runtime/pi/bin/prose-rules/one-name-per-thing.md +20 -0
  263. package/runtime/pi/bin/prose-rules/passive-enthusiasm.md +25 -0
  264. package/runtime/pi/bin/prose-rules/process-narration.md +30 -0
  265. package/runtime/pi/bin/prose-rules/rhetorical-opener.md +23 -0
  266. package/runtime/pi/bin/prose-rules/self-contained.md +20 -0
  267. package/runtime/pi/bin/prose-rules/self-praise.md +22 -0
  268. package/runtime/pi/bin/prose-rules/temporal-handwave.md +27 -0
  269. package/runtime/pi/bin/pull.sh +272 -0
  270. package/runtime/pi/bin/qa-inventory.sh +341 -0
  271. package/runtime/pi/bin/search.sh +104 -58
  272. package/runtime/pi/bin/telemetry.sh +65 -18
  273. package/runtime/pi/bin/test-baseline.sh +296 -0
  274. package/runtime/pi/bin/test-changes.sh +196 -145
  275. package/runtime/pi/bin/view-render.sh +6 -2
  276. package/runtime/pi/bin/worktree-create.sh +11 -0
  277. package/runtime/pi/egregore_runtime/adapters/qmd.py +309 -50
  278. package/runtime/pi/egregore_runtime/adapters/qmd_cli.py +6 -3
  279. package/runtime/pi/egregore_runtime/adapters/qmd_scoped.mjs +202 -0
  280. package/runtime/pi/egregore_runtime/adapters/qmd_scoped.py +137 -0
  281. package/runtime/pi/egregore_runtime/adapters/qmd_worker.mjs +123 -0
  282. package/runtime/pi/egregore_runtime/artifacts.py +11 -1
  283. package/runtime/pi/egregore_runtime/contracts.py +25 -1
  284. package/runtime/pi/egregore_runtime/eligibility.py +137 -0
  285. package/runtime/pi/egregore_runtime/episode_binding.py +178 -0
  286. package/runtime/pi/egregore_runtime/excerpts.py +42 -0
  287. package/runtime/pi/egregore_runtime/github_issues.py +244 -0
  288. package/runtime/pi/egregore_runtime/harness_cli.py +545 -402
  289. package/runtime/pi/egregore_runtime/identity.py +52 -0
  290. package/runtime/pi/egregore_runtime/ingest_index_cli.py +4 -2
  291. package/runtime/pi/egregore_runtime/investigation.py +792 -0
  292. package/runtime/pi/egregore_runtime/investigation_contracts.py +104 -0
  293. package/runtime/pi/egregore_runtime/investigation_guidance.py +51 -0
  294. package/runtime/pi/egregore_runtime/issue_cli.py +66 -0
  295. package/runtime/pi/egregore_runtime/issue_markers.py +50 -0
  296. package/runtime/pi/egregore_runtime/issue_reporting.py +224 -0
  297. package/runtime/pi/egregore_runtime/observe.py +41 -6
  298. package/runtime/pi/egregore_runtime/operation_cli.py +76 -0
  299. package/runtime/pi/egregore_runtime/operation_observations.py +208 -0
  300. package/runtime/pi/egregore_runtime/private_result.py +147 -0
  301. package/runtime/pi/egregore_runtime/research_ingest_cli.py +3 -1
  302. package/runtime/pi/egregore_runtime/runtime.py +38 -1
  303. package/runtime/pi/egregore_runtime/scroll_cli.py +1 -1
  304. package/runtime/pi/egregore_runtime/scrolls.py +172 -28
  305. package/runtime/pi/egregore_runtime/sync.py +226 -15
  306. package/runtime/pi/egregore_runtime/sync_health.py +63 -0
  307. package/runtime/pi/egregore_runtime/telemetry.py +102 -10
  308. package/runtime/pi/egregore_runtime/threads.py +4 -1
  309. package/runtime/pi/egregore_runtime/writeback.py +28 -4
  310. package/runtime/pi/manifest.json +42 -0
  311. package/runtime/prime/.claude/context/notification-consent.md +17 -2
  312. package/runtime/prime/.claude/context/retrieval-investigation.md +50 -0
  313. package/runtime/prime/.codex/skills/activity/SKILL.md +4 -0
  314. package/runtime/prime/.codex/skills/announce/SKILL.md +7 -0
  315. package/runtime/prime/.codex/skills/archive/SKILL.md +7 -0
  316. package/runtime/prime/.codex/skills/checkup/SKILL.md +7 -0
  317. package/runtime/prime/.codex/skills/dashboard/SKILL.md +4 -0
  318. package/runtime/prime/.codex/skills/deep-reflect/SKILL.md +8 -0
  319. package/runtime/prime/.codex/skills/handoff/SKILL.md +8 -3
  320. package/runtime/prime/.codex/skills/harvest/SKILL.md +8 -0
  321. package/runtime/prime/.codex/skills/ingest/SKILL.md +4 -0
  322. package/runtime/prime/.codex/skills/ingest-user-interview/SKILL.md +7 -0
  323. package/runtime/prime/.codex/skills/invite/SKILL.md +7 -0
  324. package/runtime/prime/.codex/skills/issue/SKILL.md +102 -0
  325. package/runtime/prime/.codex/skills/meeting/SKILL.md +8 -0
  326. package/runtime/prime/.codex/skills/note/SKILL.md +7 -0
  327. package/runtime/prime/.codex/skills/onboarding/SKILL.md +7 -0
  328. package/runtime/prime/.codex/skills/quest/SKILL.md +7 -0
  329. package/runtime/prime/.codex/skills/reflect/SKILL.md +8 -0
  330. package/runtime/prime/.codex/skills/save/SKILL.md +24 -7
  331. package/runtime/prime/.codex/skills/the-spiral/SKILL.md +10 -1
  332. package/runtime/prime/.codex/skills/tutorial/SKILL.md +8 -0
  333. package/runtime/prime/.codex/skills/view/SKILL.md +8 -0
  334. package/runtime/prime/.codex/skills/wrap/SKILL.md +8 -0
  335. package/runtime/prime/.codex/spec-manifest.json +7 -7
  336. package/runtime/prime/.prime/agent/APPEND_SYSTEM.md +36 -18
  337. package/runtime/prime/.prime/agent/extensions/egregore.ts +8 -7
  338. package/runtime/prime/.prime/agent/skills/egregore/src/egregore/__init__.py +14 -2
  339. package/runtime/prime/.prime/agent/spec-manifest.json +2 -2
  340. package/runtime/prime/AGENTS.md +60 -74
  341. package/runtime/prime/bin/agent.sh +56 -4
  342. package/runtime/prime/bin/base-branch.sh +62 -0
  343. package/runtime/prime/bin/codex-render-spec.mjs +32 -64
  344. package/runtime/prime/bin/codex-session-start.sh +24 -39
  345. package/runtime/prime/bin/codex-sync-skills.sh +79 -24
  346. package/runtime/prime/bin/graph-op.sh +73 -3
  347. package/runtime/prime/bin/lib/generated-trees.sh +27 -0
  348. package/runtime/prime/bin/lib/git-sync.sh +53 -9
  349. package/runtime/prime/bin/lib/greeting.sh +41 -71
  350. package/runtime/prime/bin/lib/health-footer.sh +115 -0
  351. package/runtime/prime/bin/lib/identity.sh +1 -0
  352. package/runtime/prime/bin/lib/notices.sh +177 -0
  353. package/runtime/prime/bin/lib/repo-paths.sh +40 -0
  354. package/runtime/prime/bin/observe-context.sh +2 -2
  355. package/runtime/prime/bin/pi-observe-context.mjs +38 -2
  356. package/runtime/prime/bin/pi-render-spec.mjs +0 -1
  357. package/runtime/prime/bin/prime-render-spec.mjs +1 -2
  358. package/runtime/prime/bin/prose-check-tally.sh +102 -0
  359. package/runtime/prime/bin/prose-check.mjs +554 -0
  360. package/runtime/prime/bin/prose-rules/announcing-instead-of-doing.md +24 -0
  361. package/runtime/prime/bin/prose-rules/banned-vocabulary.md +40 -0
  362. package/runtime/prime/bin/prose-rules/coined-terms.md +20 -0
  363. package/runtime/prime/bin/prose-rules/exclamation.md +24 -0
  364. package/runtime/prime/bin/prose-rules/filler-intensifiers.md +24 -0
  365. package/runtime/prime/bin/prose-rules/hedging-stack.md +26 -0
  366. package/runtime/prime/bin/prose-rules/mannered-prose.md +24 -0
  367. package/runtime/prime/bin/prose-rules/not-x-but-y.md +23 -0
  368. package/runtime/prime/bin/prose-rules/one-name-per-thing.md +20 -0
  369. package/runtime/prime/bin/prose-rules/passive-enthusiasm.md +25 -0
  370. package/runtime/prime/bin/prose-rules/process-narration.md +30 -0
  371. package/runtime/prime/bin/prose-rules/rhetorical-opener.md +23 -0
  372. package/runtime/prime/bin/prose-rules/self-contained.md +20 -0
  373. package/runtime/prime/bin/prose-rules/self-praise.md +22 -0
  374. package/runtime/prime/bin/prose-rules/temporal-handwave.md +27 -0
  375. package/runtime/prime/bin/pull.sh +272 -0
  376. package/runtime/prime/bin/qa-inventory.sh +341 -0
  377. package/runtime/prime/bin/search.sh +104 -58
  378. package/runtime/prime/bin/telemetry.sh +65 -18
  379. package/runtime/prime/bin/test-baseline.sh +296 -0
  380. package/runtime/prime/bin/test-changes.sh +196 -145
  381. package/runtime/prime/bin/view-render.sh +6 -2
  382. package/runtime/prime/bin/worktree-create.sh +11 -0
  383. package/runtime/prime/egregore_runtime/adapters/qmd.py +309 -50
  384. package/runtime/prime/egregore_runtime/adapters/qmd_cli.py +6 -3
  385. package/runtime/prime/egregore_runtime/adapters/qmd_scoped.mjs +202 -0
  386. package/runtime/prime/egregore_runtime/adapters/qmd_scoped.py +137 -0
  387. package/runtime/prime/egregore_runtime/adapters/qmd_worker.mjs +123 -0
  388. package/runtime/prime/egregore_runtime/artifacts.py +11 -1
  389. package/runtime/prime/egregore_runtime/contracts.py +25 -1
  390. package/runtime/prime/egregore_runtime/eligibility.py +137 -0
  391. package/runtime/prime/egregore_runtime/episode_binding.py +178 -0
  392. package/runtime/prime/egregore_runtime/excerpts.py +42 -0
  393. package/runtime/prime/egregore_runtime/github_issues.py +244 -0
  394. package/runtime/prime/egregore_runtime/harness_cli.py +545 -402
  395. package/runtime/prime/egregore_runtime/identity.py +52 -0
  396. package/runtime/prime/egregore_runtime/ingest_index_cli.py +4 -2
  397. package/runtime/prime/egregore_runtime/investigation.py +792 -0
  398. package/runtime/prime/egregore_runtime/investigation_contracts.py +104 -0
  399. package/runtime/prime/egregore_runtime/investigation_guidance.py +51 -0
  400. package/runtime/prime/egregore_runtime/issue_cli.py +66 -0
  401. package/runtime/prime/egregore_runtime/issue_markers.py +50 -0
  402. package/runtime/prime/egregore_runtime/issue_reporting.py +224 -0
  403. package/runtime/prime/egregore_runtime/observe.py +41 -6
  404. package/runtime/prime/egregore_runtime/operation_cli.py +76 -0
  405. package/runtime/prime/egregore_runtime/operation_observations.py +208 -0
  406. package/runtime/prime/egregore_runtime/private_result.py +147 -0
  407. package/runtime/prime/egregore_runtime/research_ingest_cli.py +3 -1
  408. package/runtime/prime/egregore_runtime/runtime.py +38 -1
  409. package/runtime/prime/egregore_runtime/scroll_cli.py +1 -1
  410. package/runtime/prime/egregore_runtime/scrolls.py +172 -28
  411. package/runtime/prime/egregore_runtime/sync.py +226 -15
  412. package/runtime/prime/egregore_runtime/sync_health.py +63 -0
  413. package/runtime/prime/egregore_runtime/telemetry.py +102 -10
  414. package/runtime/prime/egregore_runtime/threads.py +4 -1
  415. package/runtime/prime/egregore_runtime/writeback.py +28 -4
  416. package/runtime/prime/manifest.json +42 -0
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // egregore-launcher-version: 0.21.0-runtime-mvp.26
2
+ // egregore-launcher-version: 0.21.0-runtime-mvp.28
3
3
  //
4
4
  // egregore — launch and browse Egregore instances from your terminal.
5
5
  // Installed by create-egregore. Reads ~/.egregore/instances.json.
@@ -35,7 +35,7 @@ const crypto = require("node:crypto");
35
35
  const { spawnSync, spawn } = require("node:child_process");
36
36
  const readline = require("node:readline");
37
37
 
38
- const VERSION = "0.21.0-runtime-mvp.26";
38
+ const VERSION = "0.21.0-runtime-mvp.28";
39
39
  const REGISTRY = path.join(os.homedir(), ".egregore", "instances.json");
40
40
  const DEFAULT_FILE = path.join(os.homedir(), ".egregore", "default");
41
41
  const UPDATE_CACHE_FILE = path.join(os.homedir(), ".egregore", "update-check.json");
@@ -753,72 +753,120 @@ async function renderCodexStartupCard(egregoreDir) {
753
753
  return false;
754
754
  }
755
755
 
756
- function codexSupportMessage(egregoreDir) {
757
- return [
758
- "Codex harness support is missing from this Egregore checkout.",
759
- ` path: ${egregoreDir}`,
760
- "",
761
- "This checkout needs a newer Egregore core with:",
762
- " bin/codex-session-start.sh",
763
- " bin/codex-install-skills.sh",
764
- " .codex/config.toml",
765
- " .codex/skills/",
766
- " .codex/hooks.json",
767
- " .codex/hooks/",
768
- "",
769
- "Restore this instance using its installed runtime version, then rerun egregore.",
770
- "A global CLI refresh does not repair instance files.",
771
- "Egregore workflows appear as slash commands. In Codex, invoke them with the matching $skill token or ask in natural language.",
772
- ].join("\n");
756
+ const CORE_SUPPORT_PATHS = {
757
+ codex: [
758
+ "bin/codex-session-start.sh",
759
+ "bin/codex-install-skills.sh",
760
+ ".codex/config.toml",
761
+ ".codex/skills",
762
+ ".codex/hooks.json",
763
+ ".codex/hooks",
764
+ ],
765
+ pi: [
766
+ "bin/pi-session-start.sh",
767
+ ".pi/APPEND_SYSTEM.md",
768
+ ".pi/settings.json",
769
+ ".pi/extensions/egregore.ts",
770
+ ".codex/skills",
771
+ ],
772
+ prime: [
773
+ "bin/prime-session-start.sh",
774
+ ".prime/agent/APPEND_SYSTEM.md",
775
+ ".prime/agent/settings.json",
776
+ ".prime/agent/extensions/egregore.ts",
777
+ ".codex/skills",
778
+ ],
779
+ };
780
+
781
+ function missingCorePaths(runtime, egregoreDir) {
782
+ return (CORE_SUPPORT_PATHS[runtime] || []).filter(
783
+ (rel) => !fs.existsSync(path.join(egregoreDir, ...rel.split("/"))),
784
+ );
773
785
  }
774
786
 
775
787
  function hasCodexCoreSupport(egregoreDir) {
776
- return (
777
- fs.existsSync(path.join(egregoreDir, "bin", "codex-session-start.sh")) &&
778
- fs.existsSync(path.join(egregoreDir, "bin", "codex-install-skills.sh")) &&
779
- fs.existsSync(path.join(egregoreDir, ".codex", "config.toml")) &&
780
- fs.existsSync(path.join(egregoreDir, ".codex", "skills")) &&
781
- fs.existsSync(path.join(egregoreDir, ".codex", "hooks.json")) &&
782
- fs.existsSync(path.join(egregoreDir, ".codex", "hooks"))
783
- );
788
+ return missingCorePaths("codex", egregoreDir).length === 0;
784
789
  }
785
790
 
786
791
  function hasPiCoreSupport(egregoreDir) {
787
- return (
788
- fs.existsSync(path.join(egregoreDir, "bin", "pi-session-start.sh")) &&
789
- fs.existsSync(path.join(egregoreDir, ".pi", "APPEND_SYSTEM.md")) &&
790
- fs.existsSync(path.join(egregoreDir, ".pi", "settings.json")) &&
791
- fs.existsSync(path.join(egregoreDir, ".pi", "extensions", "egregore.ts")) &&
792
- fs.existsSync(path.join(egregoreDir, ".codex", "skills"))
793
- );
792
+ return missingCorePaths("pi", egregoreDir).length === 0;
794
793
  }
795
794
 
796
- function piSupportMessage(egregoreDir) {
797
- return [
798
- "Pi meta-harness support is missing from this Egregore checkout.",
795
+ function hasPrimeCoreSupport(egregoreDir) {
796
+ return missingCorePaths("prime", egregoreDir).length === 0;
797
+ }
798
+
799
+ // The repair command is pinned to this launcher's own release. `@latest`
800
+ // once pulled another release channel's files into an instance; the
801
+ // launcher and the files it installs must always be the same version.
802
+ function harnessAddCommand(runtime) {
803
+ return `npx -y ${PUBLIC_NPX_PACKAGE}@${VERSION} --add-harness ${runtimeShort(runtime)}`;
804
+ }
805
+
806
+ function harnessSupportMessage(runtime, egregoreDir) {
807
+ const label = runtimeLabel(runtime);
808
+ const missing = missingCorePaths(runtime, egregoreDir);
809
+ const lines = [
810
+ `${label} support is missing from this Egregore checkout.`,
799
811
  ` path: ${egregoreDir}`,
812
+ ];
813
+ if (missing.length > 0) {
814
+ lines.push("", "Missing:");
815
+ for (const rel of missing) lines.push(` ${rel}`);
816
+ }
817
+ lines.push(
800
818
  "",
801
- "Restore this instance using its installed runtime version, then rerun egregore.",
802
- ].join("\n");
819
+ `Add ${label} support to this instance (missing files only, nothing overwritten):`,
820
+ ` cd ${egregoreDir}`,
821
+ ` ${harnessAddCommand(runtime)}`,
822
+ "Then rerun egregore.",
823
+ );
824
+ if (runtime === "codex") {
825
+ lines.push("Egregore workflows appear as slash commands. In Codex, invoke them with the matching $skill token or ask in natural language.");
826
+ }
827
+ return lines.join("\n");
803
828
  }
804
829
 
805
- function hasPrimeCoreSupport(egregoreDir) {
806
- return (
807
- fs.existsSync(path.join(egregoreDir, "bin", "prime-session-start.sh")) &&
808
- fs.existsSync(path.join(egregoreDir, ".prime", "agent", "APPEND_SYSTEM.md")) &&
809
- fs.existsSync(path.join(egregoreDir, ".prime", "agent", "settings.json")) &&
810
- fs.existsSync(path.join(egregoreDir, ".prime", "agent", "extensions", "egregore.ts")) &&
811
- fs.existsSync(path.join(egregoreDir, ".codex", "skills"))
812
- );
830
+ function codexSupportMessage(egregoreDir) {
831
+ return harnessSupportMessage("codex", egregoreDir);
832
+ }
833
+
834
+ function piSupportMessage(egregoreDir) {
835
+ return harnessSupportMessage("pi", egregoreDir);
813
836
  }
814
837
 
815
838
  function primeSupportMessage(egregoreDir) {
816
- return [
817
- "Prime Agent runtime support is missing from this Egregore checkout.",
818
- ` path: ${egregoreDir}`,
839
+ return harnessSupportMessage("prime", egregoreDir);
840
+ }
841
+
842
+ // A launch that fails the support check offers to add exactly that harness
843
+ // to exactly this instance, using this launcher's own release. Without a
844
+ // terminal to ask, print the command and stop; never install unattended.
845
+ async function ensureHarnessSupport(inst, runtime) {
846
+ if (missingCorePaths(runtime, inst.path).length === 0) return;
847
+ const message = harnessSupportMessage(runtime, inst.path);
848
+ if (!canPrompt()) die(message);
849
+ const label = runtimeLabel(runtime);
850
+ const name = inst.name || inst.slug || path.basename(inst.path);
851
+ process.stdout.write([
819
852
  "",
820
- "Restore this instance using its installed runtime version, then rerun egregore.",
821
- ].join("\n");
853
+ ` ${BOLD}${label} support is missing from ${name}.${RESET}`,
854
+ ` ${DIM}Missing: ${missingCorePaths(runtime, inst.path).join(", ")}${RESET}`,
855
+ ` ${DIM}Egregore can add it now. Only missing files are written; nothing is overwritten:${RESET}`,
856
+ ` ${harnessAddCommand(runtime)}`,
857
+ "",
858
+ ].join("\n"));
859
+ const yes = await confirmLine(`Add ${label} support to ${name} now?`);
860
+ if (!yes) die(message);
861
+ const result = spawnSync(
862
+ "npx",
863
+ ["-y", `${PUBLIC_NPX_PACKAGE}@${VERSION}`, "--add-harness", runtimeShort(runtime)],
864
+ { cwd: inst.path, stdio: "inherit", env: process.env, timeout: 3 * 60 * 1000 },
865
+ );
866
+ if (result.error || result.status !== 0 || missingCorePaths(runtime, inst.path).length > 0) {
867
+ die(`${label} support could not be added automatically.\n\n${harnessSupportMessage(runtime, inst.path)}`);
868
+ }
869
+ process.stdout.write(` ${GREEN}✓${RESET} ${label} support added to ${name}\n\n`);
822
870
  }
823
871
 
824
872
  // Minimal y/N line prompt for pre-launch decisions (the TUI select machinery
@@ -873,7 +921,7 @@ function primeAuthHint() {
873
921
 
874
922
  function installCodexSkills(egregoreDir) {
875
923
  const script = path.join(egregoreDir, "bin", "codex-install-skills.sh");
876
- if (!fs.existsSync(script)) return false;
924
+ if (!fs.existsSync(script)) return { ok: false, stderr: `missing ${script}` };
877
925
  try {
878
926
  const result = spawnSync("bash", [script], {
879
927
  cwd: egregoreDir,
@@ -881,9 +929,9 @@ function installCodexSkills(egregoreDir) {
881
929
  encoding: "utf-8",
882
930
  maxBuffer: 1024 * 1024,
883
931
  });
884
- return result.status === 0;
885
- } catch {
886
- return false;
932
+ return { ok: result.status === 0, stderr: (result.stderr || "").trim() };
933
+ } catch (err) {
934
+ return { ok: false, stderr: String(err && err.message ? err.message : err) };
887
935
  }
888
936
  }
889
937
 
@@ -966,29 +1014,31 @@ async function launch(inst, runtimeOverride) {
966
1014
  }
967
1015
  }
968
1016
  if (runtime === "codex") {
969
- // Launching never changes an instance's runtime or release channel.
970
- if (!hasCodexCoreSupport(inst.path)) die(codexSupportMessage(inst.path));
971
- const skillsInstalled = installCodexSkills(inst.path);
1017
+ // Launching never changes an instance's runtime or release channel. A
1018
+ // missing harness is added only with the user's consent, one harness
1019
+ // into this one instance, at this launcher's own version.
1020
+ await ensureHarnessSupport(inst, runtime);
1021
+ const skills = installCodexSkills(inst.path);
1022
+ if (!skills.ok) {
1023
+ die(`Codex skill setup failed in ${inst.path} (bin/codex-install-skills.sh):\n${skills.stderr || " (no error output)"}`);
1024
+ }
972
1025
  const cardRendered = await renderCodexStartupCard(inst.path);
973
- if (!skillsInstalled || !cardRendered) {
974
- die(codexSupportMessage(inst.path));
1026
+ if (!cardRendered) {
1027
+ die(`Codex startup card failed in ${inst.path} (bin/codex-session-start.sh exited non-zero; its output is above).`);
975
1028
  }
976
1029
  } else if (runtime === "pi") {
977
- if (!hasPiCoreSupport(inst.path)) {
978
- die(piSupportMessage(inst.path));
979
- }
1030
+ await ensureHarnessSupport(inst, runtime);
980
1031
  }
981
1032
  let launchArgs = null;
982
1033
  if (runtime === "prime") {
1034
+ await ensureHarnessSupport(inst, runtime);
983
1035
  // Cover the gap between choosing the harness and Prime's first paint:
984
- // the loader runs through the launcher-side pre-flight (core-support
985
- // check + the trust-flag probe, which shells out to the binary), then a
986
- // single handoff line explains the remaining in-harness startup.
1036
+ // the loader runs through the launcher-side pre-flight (the trust-flag
1037
+ // probe, which shells out to the binary), then a single handoff line
1038
+ // explains the remaining in-harness startup.
987
1039
  const stopLoader = startSpinner("Starting Prime Agent");
988
- const coreOk = hasPrimeCoreSupport(inst.path);
989
- launchArgs = coreOk ? runtimeLaunchArgs(runtime, inst.path) : null;
1040
+ launchArgs = runtimeLaunchArgs(runtime, inst.path);
990
1041
  stopLoader();
991
- if (!coreOk) die(primeSupportMessage(inst.path));
992
1042
  primeAuthHint();
993
1043
  process.stdout.write(` ${CYAN}◆${RESET} ${BOLD}Prime Agent starting${RESET}${DIM} — the Egregore greeting loads inside in a few seconds${RESET}\n`);
994
1044
  }
package/bin/cli.js CHANGED
@@ -91,6 +91,32 @@ function detectCwdEgregore(cwd) {
91
91
  }
92
92
  }
93
93
 
94
+ // Resolve which instance `--add-harness` writes into. Explicit `--instance`
95
+ // wins; otherwise the current directory when it is an instance; otherwise the
96
+ // only registered instance. Several registered instances and no explicit
97
+ // choice is an error — this command must never fan out.
98
+ function resolveAddHarnessTarget(explicitPath) {
99
+ const isInstance = (dir) => dir && fs.existsSync(path.join(dir, "egregore.json"));
100
+ if (explicitPath) {
101
+ const dir = path.resolve(explicitPath);
102
+ if (isInstance(dir)) return dir;
103
+ ui.error(`Not an Egregore instance: ${dir} (no egregore.json).`);
104
+ return null;
105
+ }
106
+ let cwd = null;
107
+ try { cwd = process.cwd(); } catch {}
108
+ if (isInstance(cwd)) return cwd;
109
+ const registered = readLocalInstances().filter((inst) => isInstance(inst.path));
110
+ if (registered.length === 1) return path.resolve(registered[0].path);
111
+ if (registered.length === 0) {
112
+ ui.error("No Egregore instance found. Run this inside the instance directory, or pass --instance <path>.");
113
+ return null;
114
+ }
115
+ ui.error("Several Egregore instances are registered. Pass --instance <path> to choose one:");
116
+ for (const inst of registered) ui.info(` ${inst.path}`);
117
+ return null;
118
+ }
119
+
94
120
  function binaryOnPath(bin) {
95
121
  return commandExists(bin);
96
122
  }
@@ -211,6 +237,14 @@ function parseArgs(argv) {
211
237
  args.refreshLauncher = true;
212
238
  } else if (argv[i] === "--refresh-connect") {
213
239
  args.refreshConnect = true;
240
+ } else if (argv[i] === "--add-harness" && argv[i + 1]) {
241
+ args.addHarness = argv[++i];
242
+ } else if (argv[i].startsWith("--add-harness=")) {
243
+ args.addHarness = argv[i].split("=")[1];
244
+ } else if (argv[i] === "--instance" && argv[i + 1]) {
245
+ args.instance = argv[++i];
246
+ } else if (argv[i].startsWith("--instance=")) {
247
+ args.instance = argv[i].split("=")[1];
214
248
  } else if (argv[i] === "--codex") {
215
249
  args.runtime = "codex";
216
250
  } else if (argv[i] === "--pi") {
@@ -386,7 +420,9 @@ function showHelp() {
386
420
  ui.info(" --force Skip the in-repo detection check");
387
421
  ui.info(" --no-autolaunch Don't launch the harness at the end (for CI)");
388
422
  ui.info(" --no-screens Skip the full-screen welcome/ready bookends");
389
- ui.info(" --refresh-launcher Refresh the Egregore CLI and runtime packs, then exit");
423
+ ui.info(" --refresh-launcher Refresh only the global Egregore CLI, then exit");
424
+ ui.info(" --add-harness <h> Add codex, pi, or prime support to one existing instance (missing files only)");
425
+ ui.info(" --instance <path> Instance for --add-harness (default: cwd, or the only registered instance)");
390
426
  ui.info(" -h, --help Show this help");
391
427
  ui.info("");
392
428
  }
@@ -433,6 +469,39 @@ async function main() {
433
469
  }
434
470
  }
435
471
 
472
+ if (args.addHarness) {
473
+ // Explicit, instance-scoped harness addition. This is the only path that
474
+ // writes harness files into an existing instance from the global CLI: one
475
+ // harness, one instance, missing files only. The launcher invokes it with
476
+ // its own pinned version when a launch fails the support check.
477
+ const { addHarnessRuntime, harnessLabel, normalizeHarness } = require("../lib/harness-add");
478
+ const harness = normalizeHarness(args.addHarness);
479
+ if (!harness) {
480
+ ui.error(`Unknown harness "${args.addHarness}". Use --add-harness codex, pi, or prime.`);
481
+ process.exit(1);
482
+ }
483
+ const targetDir = resolveAddHarnessTarget(args.instance);
484
+ if (!targetDir) process.exit(1);
485
+ try {
486
+ const summary = addHarnessRuntime(targetDir, harness);
487
+ const label = harnessLabel(harness);
488
+ if (summary.installed.length === 0) {
489
+ ui.success(`${label} support already present in ${targetDir}`);
490
+ } else {
491
+ ui.success(`Added ${label} support to ${targetDir} ${ui.dim(`(${summary.installed.length} files, ${summary.present} kept)`)}`);
492
+ }
493
+ if (!summary.ready) {
494
+ ui.warn(`${label} support is still incomplete in ${targetDir}; an existing file may be a directory or symlink where a file is expected.`);
495
+ process.exit(1);
496
+ }
497
+ ui.info(`Run: egregore --runtime ${harness}`);
498
+ return;
499
+ } catch (err) {
500
+ ui.error(String(err.message || err));
501
+ process.exit(1);
502
+ }
503
+ }
504
+
436
505
  if (args.refreshConnect) {
437
506
  // Session-start maintenance mode: refresh the Connect overlay for an
438
507
  // existing instance. Local instances no-op instantly; network failure is
@@ -559,75 +628,20 @@ async function main() {
559
628
  }
560
629
 
561
630
  async function tokenFlow(api, token, ctx) {
562
- const s = ui.spinner("Claiming setup token...");
563
- let data;
564
- try {
565
- data = await api.claimToken(token);
566
- s.stop(`Claimed — setting up ${ui.bold(data.org_name)}`);
567
- } catch (err) {
568
- s.fail("Token claim failed");
569
- ui.error(err.message);
570
- ui.info("");
571
- ui.info("The token may have expired or already been used.");
572
- ui.info("Visit egregore.xyz to get a new one, or run without --token:");
573
- ui.info(" npx -y create-egregore@latest");
574
- process.exit(1);
575
- }
576
-
577
- // Joiner tokens don't include a github_token — try gh CLI first. If gh is
578
- // installed but logged out, run gh auth login instead of device flow.
579
- if (!data.github_token || data.needs_cli_auth) {
580
- const ghAuth = tryGhAuthOrLogin(ui, data.needs_cli_auth ? { mode: "join" } : {});
581
- if (ghAuth) {
582
- ui.success(`Using your ${ui.bold("gh")} CLI auth${ghAuth.user ? ` (${ghAuth.user})` : ""}`);
583
- data.github_token = ghAuth.token;
584
- } else if (ghCliExists()) {
585
- ui.error("GitHub CLI auth did not complete.");
586
- ui.info(`Run ${ui.bold("gh auth login")} and then re-run this command.`);
587
- process.exit(1);
588
- } else {
631
+ const { installFromToken } = require("../lib/token-install");
632
+ await installFromToken(api, token, ctx, {
633
+ ui, install, request: ghApi,
634
+ authenticate: async (forceLogin) => {
635
+ const auth = tryGhAuthOrLogin(ui, { mode: "join", requireRepoScope: true, forceLogin });
636
+ if (auth) return auth;
637
+ if (ghCliExists()) return null;
589
638
  if (!canUseInteractiveBrowserFlow()) {
590
639
  explainNoGhHeadless(ui);
591
- process.exit(1);
592
- }
593
- ui.info("\nSign in to your GitHub to complete setup.\n");
594
- try {
595
- data.github_token = await deviceFlow(ui, data.needs_cli_auth ? { mode: "join" } : {});
596
- ui.success("Authenticated with GitHub");
597
- } catch (err) {
598
- ui.error(`GitHub auth failed: ${err.message}`);
599
- process.exit(1);
640
+ return null;
600
641
  }
601
- }
602
- }
603
-
604
- // Token-mode setups already have their repo list baked in server-side. If
605
- // the user's current working repo happens to match a managed-repo name, skip
606
- // the clone/pull/configure step for it so we don't clobber uncommitted work.
607
- const skipRepos = new Set();
608
- if (ctx.prefilledRepo && Array.isArray(data.repos)) {
609
- for (const r of data.repos) {
610
- const n = typeof r === "string" ? r : r && r.name;
611
- if (n && n === ctx.prefilledRepo.name) skipRepos.add(n);
612
- }
613
- }
614
- try {
615
- await install(data, ui, ctx.targetDir, {
616
- skipRepos,
617
- noAutolaunch: ctx.noAutolaunch,
618
- noScreens: ctx.noScreens,
619
- flowVariant: ctx.flowVariant,
620
- runtime: ctx.runtime,
621
- });
622
- if (ctx.prefilledRepo && skipRepos.size === 0) {
623
- console.log("");
624
- ui.info(`Tip: add your current repo to managed_repos with:`);
625
- ui.info(` /add ${ctx.prefilledRepo.toplevel || `../${ctx.prefilledRepo.localName}`}`);
626
- }
627
- } catch (err) {
628
- ui.error(`Install failed: ${err.message}`);
629
- process.exit(1);
630
- }
642
+ return { token: await deviceFlow(ui, { mode: "join", scope: "repo" }) };
643
+ },
644
+ });
631
645
  }
632
646
 
633
647
  async function interactiveFlow(api, ctx) {
package/lib/api.js CHANGED
@@ -63,8 +63,12 @@ class EgregoreAPI {
63
63
  this.base = (baseUrl || DEFAULT_API).replace(/\/$/, "");
64
64
  }
65
65
 
66
- async claimToken(token) {
67
- return request("GET", `${this.base}/api/org/claim/${token}`);
66
+ async claimToken(token, githubToken) {
67
+ // Old APIs reject POST without consuming a one-time setup token. Never
68
+ // silently downgrade an authenticated retry to the legacy GET protocol.
69
+ return request(githubToken ? "POST" : "GET", `${this.base}/api/org/claim/${token}`, {
70
+ headers: githubToken ? { Authorization: `Bearer ${githubToken}` } : {},
71
+ });
68
72
  }
69
73
 
70
74
  async getOrgs(githubToken) {
package/lib/auth.js CHANGED
@@ -212,7 +212,7 @@ function runGhAuthLogin(ui, opts = {}) {
212
212
 
213
213
  function tryGhAuthOrLogin(ui, opts = {}) {
214
214
  const existing = tryGhAuth();
215
- if (existing) return existing;
215
+ if (existing && !opts.forceLogin && !(opts.requireRepoScope && existing.hasRepoScope === false)) return existing;
216
216
  if (!ghCliExists()) return null;
217
217
  return runGhAuthLogin(ui, opts);
218
218
  }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ // Add one harness (Codex, Pi, Prime Agent) to an existing instance.
4
+ //
5
+ // Setup overlays only the harness chosen at install time, so a Claude-only
6
+ // instance has no Codex files. The September 2026 launcher auto-repair fixed
7
+ // that by running the *latest* installer against *every* registered instance,
8
+ // which overwrote and deleted files in instances on another release channel.
9
+ // This module is the scoped replacement:
10
+ //
11
+ // - one harness, one instance, chosen explicitly;
12
+ // - copies only files that are missing from that harness's packaged bundle;
13
+ // - never overwrites, never deletes, never touches another harness;
14
+ // - records what it wrote in its own manifest so nothing else claims
15
+ // ownership of pre-existing files.
16
+
17
+ const fs = require("node:fs");
18
+ const path = require("node:path");
19
+
20
+ const PACKAGE = require("../package.json");
21
+
22
+ const HARNESSES = {
23
+ codex: { label: "Codex", module: "./codex-runtime", bundle: "codex" },
24
+ pi: { label: "Pi", module: "./pi-runtime", bundle: "pi" },
25
+ prime: { label: "Prime Agent", module: "./prime-runtime", bundle: "prime" },
26
+ };
27
+
28
+ function normalizeHarness(name) {
29
+ const value = String(name || "").trim().toLowerCase();
30
+ if (value === "codex") return "codex";
31
+ if (value === "pi") return "pi";
32
+ if (value === "prime" || value === "prime-agent") return "prime";
33
+ return null;
34
+ }
35
+
36
+ function harnessLabel(harness) {
37
+ return (HARNESSES[harness] && HARNESSES[harness].label) || harness;
38
+ }
39
+
40
+ function bundleDirFor(harness) {
41
+ return path.join(__dirname, "..", "runtime", HARNESSES[harness].bundle);
42
+ }
43
+
44
+ function listFiles(dir, prefix = "") {
45
+ if (!fs.existsSync(dir)) return [];
46
+ const result = [];
47
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
48
+ const rel = prefix ? path.join(prefix, entry.name) : entry.name;
49
+ const full = path.join(dir, entry.name);
50
+ if (entry.isDirectory()) {
51
+ result.push(...listFiles(full, rel));
52
+ } else if (entry.isFile()) {
53
+ result.push(rel);
54
+ }
55
+ }
56
+ return result.sort();
57
+ }
58
+
59
+ function pathExistsOrSymlink(file) {
60
+ try {
61
+ fs.lstatSync(file);
62
+ return true;
63
+ } catch {
64
+ return false;
65
+ }
66
+ }
67
+
68
+ function copyMissingFile(src, dest) {
69
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
70
+ fs.copyFileSync(src, dest);
71
+ try {
72
+ const mode = fs.statSync(src).mode & 0o777;
73
+ fs.chmodSync(dest, mode);
74
+ } catch {}
75
+ }
76
+
77
+ // Required paths come from the harness module so the CLI and the launcher's
78
+ // pre-launch check agree on what "support present" means.
79
+ function requiredPathsFor(harness) {
80
+ const mod = require(HARNESSES[harness].module);
81
+ const checker = mod.hasCodexRuntimeSupport || mod.hasPiRuntimeSupport || mod.hasPrimeRuntimeSupport;
82
+ return { hasSupport: (dir) => Boolean(checker && checker(dir)) };
83
+ }
84
+
85
+ function manifestPath(egregoreDir, harness) {
86
+ return path.join(egregoreDir, ".egregore", `${harness}-harness-add.json`);
87
+ }
88
+
89
+ // Current Codex discovers project skills via .agents/skills -> ../.codex/skills.
90
+ // Create the link only when nothing is there; never replace a real directory.
91
+ function ensureAgentsSkillsLink(egregoreDir, summary) {
92
+ const agentsDir = path.join(egregoreDir, ".agents");
93
+ const link = path.join(agentsDir, "skills");
94
+ if (pathExistsOrSymlink(link)) return;
95
+ try {
96
+ fs.mkdirSync(agentsDir, { recursive: true });
97
+ fs.symlinkSync(path.join("..", ".codex", "skills"), link);
98
+ summary.installed.push(".agents/skills");
99
+ } catch {}
100
+ }
101
+
102
+ /**
103
+ * Copy every file of `harness`'s packaged bundle that is missing from
104
+ * `egregoreDir`. Existing files are left untouched regardless of content.
105
+ *
106
+ * Returns { harness, installed: [rel...], present: n, ready: bool }.
107
+ */
108
+ function addHarnessRuntime(egregoreDir, harnessName) {
109
+ const harness = normalizeHarness(harnessName);
110
+ if (!harness) {
111
+ throw new Error(`Unknown harness "${harnessName}". Expected codex, pi, or prime.`);
112
+ }
113
+ const bundleDir = bundleDirFor(harness);
114
+ if (!fs.existsSync(bundleDir)) {
115
+ throw new Error(`This create-egregore release ships no ${harnessLabel(harness)} bundle (${bundleDir}).`);
116
+ }
117
+ if (!fs.existsSync(path.join(egregoreDir, "egregore.json"))) {
118
+ throw new Error(`Not an Egregore instance: ${egregoreDir} (no egregore.json).`);
119
+ }
120
+
121
+ const summary = { harness, installed: [], present: 0, ready: false };
122
+ for (const rel of listFiles(bundleDir)) {
123
+ if (rel === "manifest.json") continue;
124
+ const dest = path.join(egregoreDir, rel);
125
+ if (pathExistsOrSymlink(dest)) {
126
+ summary.present += 1;
127
+ continue;
128
+ }
129
+ copyMissingFile(path.join(bundleDir, rel), dest);
130
+ summary.installed.push(rel);
131
+ }
132
+ if (harness === "codex") ensureAgentsSkillsLink(egregoreDir, summary);
133
+
134
+ summary.ready = requiredPathsFor(harness).hasSupport(egregoreDir);
135
+
136
+ if (summary.installed.length > 0) {
137
+ const file = manifestPath(egregoreDir, harness);
138
+ const previous = (() => {
139
+ try { return JSON.parse(fs.readFileSync(file, "utf-8")); } catch { return { files: [] }; }
140
+ })();
141
+ const files = Array.from(new Set([...(previous.files || []), ...summary.installed])).sort();
142
+ fs.mkdirSync(path.dirname(file), { recursive: true });
143
+ fs.writeFileSync(file, JSON.stringify({
144
+ package: PACKAGE.name,
145
+ version: PACKAGE.version,
146
+ harness,
147
+ addedAt: new Date().toISOString(),
148
+ files,
149
+ }, null, 2) + "\n");
150
+ }
151
+ return summary;
152
+ }
153
+
154
+ module.exports = {
155
+ HARNESSES,
156
+ addHarnessRuntime,
157
+ harnessLabel,
158
+ normalizeHarness,
159
+ };