create-egregore 0.20.2 → 0.21.0-runtime-mvp.2

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 (706) hide show
  1. package/assets/egregore-launcher.js +1013 -16
  2. package/bin/cli.js +11 -0
  3. package/lib/claude-runtime.js +192 -0
  4. package/lib/local.js +38 -31
  5. package/lib/pi-runtime.js +1 -0
  6. package/lib/prime-runtime.js +1 -0
  7. package/lib/runtime-identity.js +146 -0
  8. package/lib/setup.js +116 -17
  9. package/package.json +10 -6
  10. package/runtime/claude/.claude/context/commit-format.md +110 -0
  11. package/runtime/claude/.claude/context/git-language.md +46 -0
  12. package/runtime/claude/.claude/context/notification-consent.md +66 -0
  13. package/runtime/claude/.claude/context/pr-format.md +67 -0
  14. package/runtime/claude/.claude/context/telemetry.md +133 -0
  15. package/runtime/claude/.claude/hooks/boundary-check.sh +333 -0
  16. package/runtime/claude/.claude/hooks/branch-guard.sh +231 -0
  17. package/runtime/claude/.claude/hooks/card-context.sh +38 -0
  18. package/runtime/claude/.claude/hooks/emissary-detect.sh +53 -0
  19. package/runtime/claude/.claude/hooks/memory-refresh.sh +67 -0
  20. package/runtime/claude/.claude/hooks/onboarding-guard.sh +86 -0
  21. package/runtime/claude/.claude/hooks/retrieval-context.sh +43 -0
  22. package/runtime/claude/.claude/rules/voice-bedrock.md +73 -0
  23. package/runtime/claude/.claude/settings.json +131 -0
  24. package/runtime/claude/.claude/skills/activity/SKILL.md +68 -0
  25. package/runtime/claude/.claude/skills/announce/SKILL.md +54 -0
  26. package/runtime/claude/.claude/skills/archive/SKILL.md +71 -0
  27. package/runtime/claude/.claude/skills/branch/SKILL.md +147 -0
  28. package/runtime/claude/.claude/skills/checkup/SKILL.md +159 -0
  29. package/runtime/claude/.claude/skills/commit/SKILL.md +103 -0
  30. package/runtime/claude/.claude/skills/contribute/SKILL.md +343 -0
  31. package/runtime/claude/.claude/skills/create-skill/SKILL.md +135 -0
  32. package/runtime/claude/.claude/skills/dark-mode/SKILL.md +410 -0
  33. package/runtime/claude/.claude/skills/dashboard/SKILL.md +43 -0
  34. package/runtime/claude/.claude/skills/deep-reflect/REPORT.md +140 -0
  35. package/runtime/claude/.claude/skills/deep-reflect/RESEARCH.md +132 -0
  36. package/runtime/claude/.claude/skills/deep-reflect/ROLES.md +104 -0
  37. package/runtime/claude/.claude/skills/deep-reflect/SKILL.md +170 -0
  38. package/runtime/claude/.claude/skills/delete-user/SKILL.md +150 -0
  39. package/runtime/claude/.claude/skills/emissary/SKILL.md +220 -0
  40. package/runtime/claude/.claude/skills/handoff/SKILL.md +124 -0
  41. package/runtime/claude/.claude/skills/harvest/AUDIT.md +546 -0
  42. package/runtime/claude/.claude/skills/harvest/FORMAT.md +436 -0
  43. package/runtime/claude/.claude/skills/harvest/PROCESS.md +395 -0
  44. package/runtime/claude/.claude/skills/harvest/QUESTION_PALETTE.md +76 -0
  45. package/runtime/claude/.claude/skills/harvest/SKILL.md +100 -0
  46. package/runtime/claude/.claude/skills/ingest/SKILL.md +112 -0
  47. package/runtime/claude/.claude/skills/ingest-corpus/SKILL.md +187 -0
  48. package/runtime/claude/.claude/skills/ingest-notion/SKILL.md +214 -0
  49. package/runtime/claude/.claude/skills/ingest-user-interview/SKILL.md +65 -0
  50. package/runtime/claude/.claude/skills/ingest-user-interview/references/analysis-contract.md +125 -0
  51. package/runtime/claude/.claude/skills/invite/SKILL.md +111 -0
  52. package/runtime/claude/.claude/skills/issue/SKILL.md +104 -0
  53. package/runtime/claude/.claude/skills/me/SKILL.md +81 -0
  54. package/runtime/claude/.claude/skills/meeting/SKILL.md +76 -0
  55. package/runtime/claude/.claude/skills/meeting/references/analysis-contract.md +102 -0
  56. package/runtime/claude/.claude/skills/note/SKILL.md +71 -0
  57. package/runtime/claude/.claude/skills/notion-connect/SKILL.md +124 -0
  58. package/runtime/claude/.claude/skills/onboarding/SKILL.md +159 -0
  59. package/runtime/claude/.claude/skills/pr/SKILL.md +85 -0
  60. package/runtime/claude/.claude/skills/pull/SKILL.md +79 -0
  61. package/runtime/claude/.claude/skills/push/SKILL.md +47 -0
  62. package/runtime/claude/.claude/skills/quest/SKILL.md +121 -0
  63. package/runtime/claude/.claude/skills/reflect/SKILL.md +69 -0
  64. package/runtime/claude/.claude/skills/review-pr/SKILL.md +276 -0
  65. package/runtime/claude/.claude/skills/save/SKILL.md +92 -0
  66. package/runtime/claude/.claude/skills/slack-connect/SKILL.md +148 -0
  67. package/runtime/claude/.claude/skills/summon/SKILL.md +240 -0
  68. package/runtime/claude/.claude/skills/sync-repos/SKILL.md +82 -0
  69. package/runtime/claude/.claude/skills/teams-connect/SKILL.md +216 -0
  70. package/runtime/claude/.claude/skills/telegram-connect/SKILL.md +110 -0
  71. package/runtime/claude/.claude/skills/telemetry/SKILL.md +117 -0
  72. package/runtime/claude/.claude/skills/test/SKILL.md +87 -0
  73. package/runtime/claude/.claude/skills/the-spiral/SKILL.md +492 -0
  74. package/runtime/claude/.claude/skills/tui-design/SKILL.md +188 -0
  75. package/runtime/claude/.claude/skills/tutorial/SKILL.md +100 -0
  76. package/runtime/claude/.claude/skills/update/SKILL.md +265 -0
  77. package/runtime/claude/.claude/skills/view/SKILL.md +393 -0
  78. package/runtime/claude/.claude/skills/view/compose-scaffold.html +221 -0
  79. package/runtime/claude/.claude/skills/visual-explain/SKILL.md +132 -0
  80. package/runtime/claude/.claude/skills/wrap/SKILL.md +98 -0
  81. package/runtime/claude/CLAUDE.md +447 -0
  82. package/runtime/claude/bin/activity-action.sh +92 -0
  83. package/runtime/claude/bin/activity-data.sh +17 -0
  84. package/runtime/claude/bin/agent.sh +783 -0
  85. package/runtime/claude/bin/artifact-register.sh +164 -0
  86. package/runtime/claude/bin/artifact-writeback.sh +53 -0
  87. package/runtime/claude/bin/artifacts.sh +288 -0
  88. package/runtime/claude/bin/attendant.sh +707 -0
  89. package/runtime/claude/bin/autosave.sh +112 -0
  90. package/runtime/claude/bin/boundary.sh +253 -0
  91. package/runtime/claude/bin/build-sealed-dataroom.mjs +722 -0
  92. package/runtime/claude/bin/capture-reconcile.sh +69 -0
  93. package/runtime/claude/bin/capture-run.sh +357 -0
  94. package/runtime/claude/bin/codex-install-skills.sh +78 -0
  95. package/runtime/claude/bin/codex-render-spec.mjs +462 -0
  96. package/runtime/claude/bin/codex-session-start.sh +275 -0
  97. package/runtime/claude/bin/codex-skill-render.mjs +349 -0
  98. package/runtime/claude/bin/codex-sync-skills.sh +237 -0
  99. package/runtime/claude/bin/connect-refresh.sh +33 -0
  100. package/runtime/claude/bin/contribute-guard.sh +79 -0
  101. package/runtime/claude/bin/corpus_map.py +806 -0
  102. package/runtime/claude/bin/corpus_survey.py +304 -0
  103. package/runtime/claude/bin/dashboard-data.sh +18 -0
  104. package/runtime/claude/bin/github-auth.sh +121 -0
  105. package/runtime/claude/bin/graph-batch.sh +86 -0
  106. package/runtime/claude/bin/graph-op.sh +1106 -0
  107. package/runtime/claude/bin/graph-projection.sh +54 -0
  108. package/runtime/claude/bin/graph-wal.sh +242 -0
  109. package/runtime/claude/bin/graph.sh +267 -0
  110. package/runtime/claude/bin/handoff-lifecycle-job.sh +146 -0
  111. package/runtime/claude/bin/handoff-lifecycle.sh +280 -0
  112. package/runtime/claude/bin/handoff-pr-backfill.sh +86 -0
  113. package/runtime/claude/bin/handoff-preview.sh +169 -0
  114. package/runtime/claude/bin/handoff-run.sh +692 -0
  115. package/runtime/claude/bin/handoff-save-egregore.sh +224 -0
  116. package/runtime/claude/bin/index-handoff.sh +322 -0
  117. package/runtime/claude/bin/ingest-graph.sh +86 -0
  118. package/runtime/claude/bin/ingest-item.sh +10 -0
  119. package/runtime/claude/bin/ingest-surface.html +495 -0
  120. package/runtime/claude/bin/ingest.py +1011 -0
  121. package/runtime/claude/bin/ingest.sh +308 -0
  122. package/runtime/claude/bin/ingest_graph.py +856 -0
  123. package/runtime/claude/bin/ingest_surface.py +544 -0
  124. package/runtime/claude/bin/invite.sh +6 -0
  125. package/runtime/claude/bin/issue.sh +10 -0
  126. package/runtime/claude/bin/knowledge.sh +10 -0
  127. package/runtime/claude/bin/lib/artifact-id.sh +46 -0
  128. package/runtime/claude/bin/lib/config.sh +136 -0
  129. package/runtime/claude/bin/lib/context.sh +642 -0
  130. package/runtime/claude/bin/lib/dashboard-artifact.sh +242 -0
  131. package/runtime/claude/bin/lib/ensure-develop.sh +183 -0
  132. package/runtime/claude/bin/lib/git-message.sh +37 -0
  133. package/runtime/claude/bin/lib/git-sync.sh +494 -0
  134. package/runtime/claude/bin/lib/greeting.sh +548 -0
  135. package/runtime/claude/bin/lib/handoff-meta.sh +97 -0
  136. package/runtime/claude/bin/lib/hash.sh +13 -0
  137. package/runtime/claude/bin/lib/identity.sh +213 -0
  138. package/runtime/claude/bin/lib/metrics.sh +374 -0
  139. package/runtime/claude/bin/lib/noncode.sh +31 -0
  140. package/runtime/claude/bin/lib/permissions.sh +106 -0
  141. package/runtime/claude/bin/lib/time.sh +56 -0
  142. package/runtime/claude/bin/lib/worktree-links.sh +85 -0
  143. package/runtime/claude/bin/node-run.sh +42 -0
  144. package/runtime/claude/bin/notification.sh +6 -0
  145. package/runtime/claude/bin/notify.sh +636 -0
  146. package/runtime/claude/bin/observe-context.sh +14 -0
  147. package/runtime/claude/bin/onboarding.sh +6 -0
  148. package/runtime/claude/bin/person.py +634 -0
  149. package/runtime/claude/bin/person.sh +481 -0
  150. package/runtime/claude/bin/pi-render-spec.mjs +140 -0
  151. package/runtime/claude/bin/post-update.sh +37 -0
  152. package/runtime/claude/bin/prime-render-spec.mjs +147 -0
  153. package/runtime/claude/bin/publish-artifact.sh +324 -0
  154. package/runtime/claude/bin/publish-references.sh +144 -0
  155. package/runtime/claude/bin/quest.sh +9 -0
  156. package/runtime/claude/bin/question.sh +8 -0
  157. package/runtime/claude/bin/repo-state.sh +96 -0
  158. package/runtime/claude/bin/research-ingest.sh +7 -0
  159. package/runtime/claude/bin/restore-owned-skills.sh +67 -0
  160. package/runtime/claude/bin/retrieval_eval.py +385 -0
  161. package/runtime/claude/bin/runtime-identity.sh +70 -0
  162. package/runtime/claude/bin/runtime-upgrade.sh +43 -0
  163. package/runtime/claude/bin/scroll.sh +9 -0
  164. package/runtime/claude/bin/search.sh +318 -0
  165. package/runtime/claude/bin/session-autosave.sh +220 -0
  166. package/runtime/claude/bin/session-log.sh +199 -0
  167. package/runtime/claude/bin/session-start.sh +696 -0
  168. package/runtime/claude/bin/settings.sh +532 -0
  169. package/runtime/claude/bin/startup-check.sh +136 -0
  170. package/runtime/claude/bin/statusline.sh +41 -0
  171. package/runtime/claude/bin/telemetry.sh +666 -0
  172. package/runtime/claude/bin/test-changes.sh +344 -0
  173. package/runtime/claude/bin/thread.sh +9 -0
  174. package/runtime/claude/bin/todo.sh +9 -0
  175. package/runtime/claude/bin/view-render.sh +126 -0
  176. package/runtime/claude/bin/worktree-create.sh +145 -0
  177. package/runtime/claude/bin/worktree-remove.sh +50 -0
  178. package/runtime/claude/bin/worktree.sh +198 -0
  179. package/runtime/claude/egregore_runtime/__init__.py +228 -0
  180. package/runtime/claude/egregore_runtime/adapters/__init__.py +5 -0
  181. package/runtime/claude/egregore_runtime/adapters/invitation.py +237 -0
  182. package/runtime/claude/egregore_runtime/adapters/notification.py +59 -0
  183. package/runtime/claude/egregore_runtime/adapters/qmd.py +1701 -0
  184. package/runtime/claude/egregore_runtime/adapters/qmd_cli.py +210 -0
  185. package/runtime/claude/egregore_runtime/adapters/qmd_embed_worker.py +59 -0
  186. package/runtime/claude/egregore_runtime/admin_gate.py +102 -0
  187. package/runtime/claude/egregore_runtime/artifacts.py +523 -0
  188. package/runtime/claude/egregore_runtime/contracts.py +499 -0
  189. package/runtime/claude/egregore_runtime/entitlements.py +85 -0
  190. package/runtime/claude/egregore_runtime/errors.py +10 -0
  191. package/runtime/claude/egregore_runtime/graph.py +356 -0
  192. package/runtime/claude/egregore_runtime/handoff_lookup.py +196 -0
  193. package/runtime/claude/egregore_runtime/harness_cli.py +1221 -0
  194. package/runtime/claude/egregore_runtime/identity.py +734 -0
  195. package/runtime/claude/egregore_runtime/identity_cli.py +91 -0
  196. package/runtime/claude/egregore_runtime/ingest.py +575 -0
  197. package/runtime/claude/egregore_runtime/ingest_cli.py +254 -0
  198. package/runtime/claude/egregore_runtime/ingest_index_cli.py +147 -0
  199. package/runtime/claude/egregore_runtime/invitation_cli.py +51 -0
  200. package/runtime/claude/egregore_runtime/invitations.py +116 -0
  201. package/runtime/claude/egregore_runtime/issue_cli.py +305 -0
  202. package/runtime/claude/egregore_runtime/issues.py +359 -0
  203. package/runtime/claude/egregore_runtime/knowledge.py +376 -0
  204. package/runtime/claude/egregore_runtime/knowledge_cli.py +173 -0
  205. package/runtime/claude/egregore_runtime/lifecycle.py +888 -0
  206. package/runtime/claude/egregore_runtime/lifecycle_cli.py +269 -0
  207. package/runtime/claude/egregore_runtime/notification_cli.py +125 -0
  208. package/runtime/claude/egregore_runtime/notifications.py +230 -0
  209. package/runtime/claude/egregore_runtime/observe.py +342 -0
  210. package/runtime/claude/egregore_runtime/onboarding.py +290 -0
  211. package/runtime/claude/egregore_runtime/onboarding_cli.py +110 -0
  212. package/runtime/claude/egregore_runtime/policy.py +144 -0
  213. package/runtime/claude/egregore_runtime/profile.py +193 -0
  214. package/runtime/claude/egregore_runtime/quest_cli.py +216 -0
  215. package/runtime/claude/egregore_runtime/question_cli.py +180 -0
  216. package/runtime/claude/egregore_runtime/questions.py +304 -0
  217. package/runtime/claude/egregore_runtime/quests.py +419 -0
  218. package/runtime/claude/egregore_runtime/readiness.py +379 -0
  219. package/runtime/claude/egregore_runtime/research_ingest.py +256 -0
  220. package/runtime/claude/egregore_runtime/research_ingest_cli.py +44 -0
  221. package/runtime/claude/egregore_runtime/runtime.py +464 -0
  222. package/runtime/claude/egregore_runtime/scroll_cli.py +185 -0
  223. package/runtime/claude/egregore_runtime/scrolls.py +726 -0
  224. package/runtime/claude/egregore_runtime/status.py +412 -0
  225. package/runtime/claude/egregore_runtime/status_cli.py +174 -0
  226. package/runtime/claude/egregore_runtime/sync.py +218 -0
  227. package/runtime/claude/egregore_runtime/teamsync.py +139 -0
  228. package/runtime/claude/egregore_runtime/telemetry.py +640 -0
  229. package/runtime/claude/egregore_runtime/thread_cli.py +173 -0
  230. package/runtime/claude/egregore_runtime/threads.py +517 -0
  231. package/runtime/claude/egregore_runtime/todo_cli.py +142 -0
  232. package/runtime/claude/egregore_runtime/todos.py +244 -0
  233. package/runtime/claude/egregore_runtime/upgrade.py +770 -0
  234. package/runtime/claude/egregore_runtime/upgrade_worker.py +53 -0
  235. package/runtime/claude/egregore_runtime/writeback.py +391 -0
  236. package/runtime/claude/egregore_runtime/writeback_cli.py +114 -0
  237. package/runtime/claude/manifest.json +284 -0
  238. package/runtime/codex/.codex/hooks/search-hint.js +21 -52
  239. package/runtime/codex/.codex/hooks.json +3 -3
  240. package/runtime/codex/.codex/skills/activity/SKILL.md +23 -66
  241. package/runtime/codex/.codex/skills/announce/SKILL.md +27 -50
  242. package/runtime/codex/.codex/skills/archive/SKILL.md +21 -36
  243. package/runtime/codex/.codex/skills/checkup/SKILL.md +77 -36
  244. package/runtime/codex/.codex/skills/dark-mode/SKILL.md +1 -1
  245. package/runtime/codex/.codex/skills/dashboard/SKILL.md +17 -47
  246. package/runtime/codex/.codex/skills/handoff/SKILL.md +84 -133
  247. package/runtime/codex/.codex/skills/harvest/SKILL.md +32 -117
  248. package/runtime/codex/.codex/skills/ingest/SKILL.md +47 -25
  249. package/runtime/codex/.codex/skills/ingest-user-interview/SKILL.md +18 -36
  250. package/runtime/codex/.codex/skills/ingest-user-interview/references/analysis-contract.md +42 -0
  251. package/runtime/codex/.codex/skills/invite/SKILL.md +21 -35
  252. package/runtime/codex/.codex/skills/issue/SKILL.md +60 -41
  253. package/runtime/codex/.codex/skills/me/SKILL.md +1 -1
  254. package/runtime/codex/.codex/skills/meeting/SKILL.md +16 -36
  255. package/runtime/codex/.codex/skills/meeting/references/analysis-contract.md +48 -0
  256. package/runtime/codex/.codex/skills/note/SKILL.md +30 -25
  257. package/runtime/codex/.codex/skills/onboarding/SKILL.md +36 -41
  258. package/runtime/codex/.codex/skills/pull/SKILL.md +1 -1
  259. package/runtime/codex/.codex/skills/quest/SKILL.md +27 -66
  260. package/runtime/codex/.codex/skills/reflect/SKILL.md +22 -36
  261. package/runtime/codex/.codex/skills/save/SKILL.md +2 -2
  262. package/runtime/codex/.codex/skills/telemetry/SKILL.md +1 -1
  263. package/runtime/codex/.codex/skills/test/SKILL.md +1 -1
  264. package/runtime/codex/.codex/skills/tutorial/SKILL.md +40 -41
  265. package/runtime/codex/.codex/skills/view/SKILL.md +115 -111
  266. package/runtime/codex/.codex/skills/wrap/SKILL.md +45 -41
  267. package/runtime/codex/.codex/spec-manifest.json +9 -9
  268. package/runtime/codex/AGENTS.md +62 -58
  269. package/runtime/codex/bin/activity-action.sh +92 -0
  270. package/runtime/codex/bin/activity-data.sh +12 -233
  271. package/runtime/codex/bin/agent.sh +84 -100
  272. package/runtime/codex/bin/artifact-register.sh +164 -0
  273. package/runtime/codex/bin/artifact-writeback.sh +53 -0
  274. package/runtime/codex/bin/artifacts.sh +288 -0
  275. package/runtime/codex/bin/build-sealed-dataroom.mjs +722 -0
  276. package/runtime/codex/bin/capture-run.sh +18 -2
  277. package/runtime/codex/bin/codex-render-spec.mjs +41 -16
  278. package/runtime/codex/bin/codex-session-start.sh +14 -4
  279. package/runtime/codex/bin/codex-skill-render.mjs +9 -7
  280. package/runtime/codex/bin/corpus_map.py +806 -0
  281. package/runtime/codex/bin/corpus_survey.py +304 -0
  282. package/runtime/codex/bin/dashboard-data.sh +11 -171
  283. package/runtime/codex/bin/github-auth.sh +121 -0
  284. package/runtime/codex/bin/graph-batch.sh +7 -0
  285. package/runtime/codex/bin/graph-op.sh +4 -0
  286. package/runtime/codex/bin/graph-projection.sh +54 -0
  287. package/runtime/codex/bin/graph-wal.sh +13 -0
  288. package/runtime/codex/bin/graph.sh +44 -0
  289. package/runtime/codex/bin/handoff-lifecycle-job.sh +146 -0
  290. package/runtime/codex/bin/handoff-lifecycle.sh +280 -0
  291. package/runtime/codex/bin/handoff-preview.sh +169 -0
  292. package/runtime/codex/bin/handoff-run.sh +42 -26
  293. package/runtime/codex/bin/ingest-graph.sh +6 -0
  294. package/runtime/codex/bin/ingest-item.sh +10 -0
  295. package/runtime/codex/bin/ingest.sh +59 -30
  296. package/runtime/codex/bin/invite.sh +6 -0
  297. package/runtime/codex/bin/issue.sh +10 -0
  298. package/runtime/codex/bin/knowledge.sh +10 -0
  299. package/runtime/codex/bin/lib/config.sh +20 -0
  300. package/runtime/codex/bin/lib/context.sh +46 -25
  301. package/runtime/codex/bin/lib/git-sync.sh +70 -6
  302. package/runtime/codex/bin/lib/greeting.sh +34 -5
  303. package/runtime/codex/bin/lib/handoff-meta.sh +97 -0
  304. package/runtime/codex/bin/lib/worktree-links.sh +6 -0
  305. package/runtime/codex/bin/node-run.sh +42 -0
  306. package/runtime/codex/bin/notification.sh +6 -0
  307. package/runtime/codex/bin/observe-context.sh +14 -0
  308. package/runtime/codex/bin/onboarding.sh +6 -0
  309. package/runtime/codex/bin/person.py +4 -0
  310. package/runtime/codex/bin/person.sh +43 -10
  311. package/runtime/codex/bin/pi-render-spec.mjs +140 -0
  312. package/runtime/codex/bin/post-update.sh +37 -0
  313. package/runtime/codex/bin/prime-render-spec.mjs +147 -0
  314. package/runtime/codex/bin/publish-artifact.sh +55 -2
  315. package/runtime/codex/bin/quest.sh +9 -0
  316. package/runtime/codex/bin/question.sh +8 -0
  317. package/runtime/codex/bin/research-ingest.sh +7 -0
  318. package/runtime/codex/bin/restore-owned-skills.sh +67 -0
  319. package/runtime/codex/bin/retrieval_eval.py +385 -0
  320. package/runtime/codex/bin/runtime-identity.sh +70 -0
  321. package/runtime/codex/bin/runtime-upgrade.sh +43 -0
  322. package/runtime/codex/bin/scroll.sh +9 -0
  323. package/runtime/codex/bin/search.sh +231 -195
  324. package/runtime/codex/bin/settings.sh +174 -5
  325. package/runtime/codex/bin/startup-check.sh +136 -0
  326. package/runtime/codex/bin/telemetry.sh +522 -247
  327. package/runtime/codex/bin/test-changes.sh +344 -0
  328. package/runtime/codex/bin/thread.sh +9 -0
  329. package/runtime/codex/bin/todo.sh +9 -0
  330. package/runtime/codex/bin/view-render.sh +126 -0
  331. package/runtime/codex/bin/worktree-create.sh +19 -5
  332. package/runtime/codex/egregore_runtime/__init__.py +228 -0
  333. package/runtime/codex/egregore_runtime/adapters/__init__.py +5 -0
  334. package/runtime/codex/egregore_runtime/adapters/invitation.py +237 -0
  335. package/runtime/codex/egregore_runtime/adapters/notification.py +59 -0
  336. package/runtime/codex/egregore_runtime/adapters/qmd.py +1701 -0
  337. package/runtime/codex/egregore_runtime/adapters/qmd_cli.py +210 -0
  338. package/runtime/codex/egregore_runtime/adapters/qmd_embed_worker.py +59 -0
  339. package/runtime/codex/egregore_runtime/admin_gate.py +102 -0
  340. package/runtime/codex/egregore_runtime/artifacts.py +523 -0
  341. package/runtime/codex/egregore_runtime/contracts.py +499 -0
  342. package/runtime/codex/egregore_runtime/entitlements.py +85 -0
  343. package/runtime/codex/egregore_runtime/errors.py +10 -0
  344. package/runtime/codex/egregore_runtime/graph.py +356 -0
  345. package/runtime/codex/egregore_runtime/handoff_lookup.py +196 -0
  346. package/runtime/codex/egregore_runtime/harness_cli.py +1221 -0
  347. package/runtime/codex/egregore_runtime/identity.py +734 -0
  348. package/runtime/codex/egregore_runtime/identity_cli.py +91 -0
  349. package/runtime/codex/egregore_runtime/ingest.py +575 -0
  350. package/runtime/codex/egregore_runtime/ingest_cli.py +254 -0
  351. package/runtime/codex/egregore_runtime/ingest_index_cli.py +147 -0
  352. package/runtime/codex/egregore_runtime/invitation_cli.py +51 -0
  353. package/runtime/codex/egregore_runtime/invitations.py +116 -0
  354. package/runtime/codex/egregore_runtime/issue_cli.py +305 -0
  355. package/runtime/codex/egregore_runtime/issues.py +359 -0
  356. package/runtime/codex/egregore_runtime/knowledge.py +376 -0
  357. package/runtime/codex/egregore_runtime/knowledge_cli.py +173 -0
  358. package/runtime/codex/egregore_runtime/lifecycle.py +888 -0
  359. package/runtime/codex/egregore_runtime/lifecycle_cli.py +269 -0
  360. package/runtime/codex/egregore_runtime/notification_cli.py +125 -0
  361. package/runtime/codex/egregore_runtime/notifications.py +230 -0
  362. package/runtime/codex/egregore_runtime/observe.py +342 -0
  363. package/runtime/codex/egregore_runtime/onboarding.py +290 -0
  364. package/runtime/codex/egregore_runtime/onboarding_cli.py +110 -0
  365. package/runtime/codex/egregore_runtime/policy.py +144 -0
  366. package/runtime/codex/egregore_runtime/profile.py +193 -0
  367. package/runtime/codex/egregore_runtime/quest_cli.py +216 -0
  368. package/runtime/codex/egregore_runtime/question_cli.py +180 -0
  369. package/runtime/codex/egregore_runtime/questions.py +304 -0
  370. package/runtime/codex/egregore_runtime/quests.py +419 -0
  371. package/runtime/codex/egregore_runtime/readiness.py +379 -0
  372. package/runtime/codex/egregore_runtime/research_ingest.py +256 -0
  373. package/runtime/codex/egregore_runtime/research_ingest_cli.py +44 -0
  374. package/runtime/codex/egregore_runtime/runtime.py +464 -0
  375. package/runtime/codex/egregore_runtime/scroll_cli.py +185 -0
  376. package/runtime/codex/egregore_runtime/scrolls.py +726 -0
  377. package/runtime/codex/egregore_runtime/status.py +412 -0
  378. package/runtime/codex/egregore_runtime/status_cli.py +174 -0
  379. package/runtime/codex/egregore_runtime/sync.py +218 -0
  380. package/runtime/codex/egregore_runtime/teamsync.py +139 -0
  381. package/runtime/codex/egregore_runtime/telemetry.py +640 -0
  382. package/runtime/codex/egregore_runtime/thread_cli.py +173 -0
  383. package/runtime/codex/egregore_runtime/threads.py +517 -0
  384. package/runtime/codex/egregore_runtime/todo_cli.py +142 -0
  385. package/runtime/codex/egregore_runtime/todos.py +244 -0
  386. package/runtime/codex/egregore_runtime/upgrade.py +770 -0
  387. package/runtime/codex/egregore_runtime/upgrade_worker.py +53 -0
  388. package/runtime/codex/egregore_runtime/writeback.py +391 -0
  389. package/runtime/codex/egregore_runtime/writeback_cli.py +114 -0
  390. package/runtime/codex/manifest.json +98 -1
  391. package/runtime/pi/.codex/hooks/search-hint.js +21 -52
  392. package/runtime/pi/.codex/hooks.json +3 -3
  393. package/runtime/pi/.codex/skills/activity/SKILL.md +23 -66
  394. package/runtime/pi/.codex/skills/announce/SKILL.md +27 -50
  395. package/runtime/pi/.codex/skills/archive/SKILL.md +21 -36
  396. package/runtime/pi/.codex/skills/checkup/SKILL.md +77 -36
  397. package/runtime/pi/.codex/skills/dark-mode/SKILL.md +1 -1
  398. package/runtime/pi/.codex/skills/dashboard/SKILL.md +17 -47
  399. package/runtime/pi/.codex/skills/handoff/SKILL.md +84 -133
  400. package/runtime/pi/.codex/skills/harvest/SKILL.md +32 -117
  401. package/runtime/pi/.codex/skills/ingest/SKILL.md +47 -25
  402. package/runtime/pi/.codex/skills/ingest-user-interview/SKILL.md +18 -36
  403. package/runtime/pi/.codex/skills/ingest-user-interview/references/analysis-contract.md +42 -0
  404. package/runtime/pi/.codex/skills/invite/SKILL.md +21 -35
  405. package/runtime/pi/.codex/skills/issue/SKILL.md +60 -41
  406. package/runtime/pi/.codex/skills/me/SKILL.md +1 -1
  407. package/runtime/pi/.codex/skills/meeting/SKILL.md +16 -36
  408. package/runtime/pi/.codex/skills/meeting/references/analysis-contract.md +48 -0
  409. package/runtime/pi/.codex/skills/note/SKILL.md +30 -25
  410. package/runtime/pi/.codex/skills/onboarding/SKILL.md +36 -41
  411. package/runtime/pi/.codex/skills/pull/SKILL.md +1 -1
  412. package/runtime/pi/.codex/skills/quest/SKILL.md +27 -66
  413. package/runtime/pi/.codex/skills/reflect/SKILL.md +22 -36
  414. package/runtime/pi/.codex/skills/save/SKILL.md +2 -2
  415. package/runtime/pi/.codex/skills/telemetry/SKILL.md +1 -1
  416. package/runtime/pi/.codex/skills/test/SKILL.md +1 -1
  417. package/runtime/pi/.codex/skills/tutorial/SKILL.md +40 -41
  418. package/runtime/pi/.codex/skills/view/SKILL.md +115 -111
  419. package/runtime/pi/.codex/skills/wrap/SKILL.md +45 -41
  420. package/runtime/pi/.codex/spec-manifest.json +9 -9
  421. package/runtime/pi/.pi/APPEND_SYSTEM.md +57 -48
  422. package/runtime/pi/.pi/extensions/egregore.ts +7 -0
  423. package/runtime/pi/.pi/spec-manifest.json +2 -2
  424. package/runtime/pi/AGENTS.md +62 -58
  425. package/runtime/pi/bin/activity-action.sh +92 -0
  426. package/runtime/pi/bin/activity-data.sh +12 -233
  427. package/runtime/pi/bin/agent.sh +84 -100
  428. package/runtime/pi/bin/artifact-register.sh +164 -0
  429. package/runtime/pi/bin/artifact-writeback.sh +53 -0
  430. package/runtime/pi/bin/artifacts.sh +288 -0
  431. package/runtime/pi/bin/build-sealed-dataroom.mjs +722 -0
  432. package/runtime/pi/bin/capture-run.sh +18 -2
  433. package/runtime/pi/bin/codex-render-spec.mjs +41 -16
  434. package/runtime/pi/bin/codex-session-start.sh +14 -4
  435. package/runtime/pi/bin/codex-skill-render.mjs +9 -7
  436. package/runtime/pi/bin/corpus_map.py +806 -0
  437. package/runtime/pi/bin/corpus_survey.py +304 -0
  438. package/runtime/pi/bin/dashboard-data.sh +11 -171
  439. package/runtime/pi/bin/github-auth.sh +121 -0
  440. package/runtime/pi/bin/graph-batch.sh +7 -0
  441. package/runtime/pi/bin/graph-op.sh +4 -0
  442. package/runtime/pi/bin/graph-projection.sh +54 -0
  443. package/runtime/pi/bin/graph-wal.sh +13 -0
  444. package/runtime/pi/bin/graph.sh +44 -0
  445. package/runtime/pi/bin/handoff-lifecycle-job.sh +146 -0
  446. package/runtime/pi/bin/handoff-lifecycle.sh +280 -0
  447. package/runtime/pi/bin/handoff-preview.sh +169 -0
  448. package/runtime/pi/bin/handoff-run.sh +42 -26
  449. package/runtime/pi/bin/ingest-graph.sh +6 -0
  450. package/runtime/pi/bin/ingest-item.sh +10 -0
  451. package/runtime/pi/bin/ingest.sh +59 -30
  452. package/runtime/pi/bin/invite.sh +6 -0
  453. package/runtime/pi/bin/issue.sh +10 -0
  454. package/runtime/pi/bin/knowledge.sh +10 -0
  455. package/runtime/pi/bin/lib/config.sh +20 -0
  456. package/runtime/pi/bin/lib/context.sh +46 -25
  457. package/runtime/pi/bin/lib/git-sync.sh +70 -6
  458. package/runtime/pi/bin/lib/greeting.sh +34 -5
  459. package/runtime/pi/bin/lib/handoff-meta.sh +97 -0
  460. package/runtime/pi/bin/lib/worktree-links.sh +6 -0
  461. package/runtime/pi/bin/node-run.sh +42 -0
  462. package/runtime/pi/bin/notification.sh +6 -0
  463. package/runtime/pi/bin/observe-context.sh +14 -0
  464. package/runtime/pi/bin/onboarding.sh +6 -0
  465. package/runtime/pi/bin/person.py +4 -0
  466. package/runtime/pi/bin/person.sh +43 -10
  467. package/runtime/pi/bin/pi-observe-context.mjs +93 -0
  468. package/runtime/pi/bin/pi-product-workflows.mjs +1 -1
  469. package/runtime/pi/bin/pi-render-spec.mjs +1 -1
  470. package/runtime/pi/bin/post-update.sh +37 -0
  471. package/runtime/pi/bin/prime-render-spec.mjs +147 -0
  472. package/runtime/pi/bin/publish-artifact.sh +55 -2
  473. package/runtime/pi/bin/quest.sh +9 -0
  474. package/runtime/pi/bin/question.sh +8 -0
  475. package/runtime/pi/bin/research-ingest.sh +7 -0
  476. package/runtime/pi/bin/restore-owned-skills.sh +67 -0
  477. package/runtime/pi/bin/retrieval_eval.py +385 -0
  478. package/runtime/pi/bin/runtime-identity.sh +70 -0
  479. package/runtime/pi/bin/runtime-upgrade.sh +43 -0
  480. package/runtime/pi/bin/scroll.sh +9 -0
  481. package/runtime/pi/bin/search.sh +231 -195
  482. package/runtime/pi/bin/settings.sh +174 -5
  483. package/runtime/pi/bin/startup-check.sh +136 -0
  484. package/runtime/pi/bin/telemetry.sh +522 -247
  485. package/runtime/pi/bin/test-changes.sh +344 -0
  486. package/runtime/pi/bin/thread.sh +9 -0
  487. package/runtime/pi/bin/todo.sh +9 -0
  488. package/runtime/pi/bin/view-render.sh +126 -0
  489. package/runtime/pi/bin/worktree-create.sh +19 -5
  490. package/runtime/pi/egregore_runtime/__init__.py +228 -0
  491. package/runtime/pi/egregore_runtime/adapters/__init__.py +5 -0
  492. package/runtime/pi/egregore_runtime/adapters/invitation.py +237 -0
  493. package/runtime/pi/egregore_runtime/adapters/notification.py +59 -0
  494. package/runtime/pi/egregore_runtime/adapters/qmd.py +1701 -0
  495. package/runtime/pi/egregore_runtime/adapters/qmd_cli.py +210 -0
  496. package/runtime/pi/egregore_runtime/adapters/qmd_embed_worker.py +59 -0
  497. package/runtime/pi/egregore_runtime/admin_gate.py +102 -0
  498. package/runtime/pi/egregore_runtime/artifacts.py +523 -0
  499. package/runtime/pi/egregore_runtime/contracts.py +499 -0
  500. package/runtime/pi/egregore_runtime/entitlements.py +85 -0
  501. package/runtime/pi/egregore_runtime/errors.py +10 -0
  502. package/runtime/pi/egregore_runtime/graph.py +356 -0
  503. package/runtime/pi/egregore_runtime/handoff_lookup.py +196 -0
  504. package/runtime/pi/egregore_runtime/harness_cli.py +1221 -0
  505. package/runtime/pi/egregore_runtime/identity.py +734 -0
  506. package/runtime/pi/egregore_runtime/identity_cli.py +91 -0
  507. package/runtime/pi/egregore_runtime/ingest.py +575 -0
  508. package/runtime/pi/egregore_runtime/ingest_cli.py +254 -0
  509. package/runtime/pi/egregore_runtime/ingest_index_cli.py +147 -0
  510. package/runtime/pi/egregore_runtime/invitation_cli.py +51 -0
  511. package/runtime/pi/egregore_runtime/invitations.py +116 -0
  512. package/runtime/pi/egregore_runtime/issue_cli.py +305 -0
  513. package/runtime/pi/egregore_runtime/issues.py +359 -0
  514. package/runtime/pi/egregore_runtime/knowledge.py +376 -0
  515. package/runtime/pi/egregore_runtime/knowledge_cli.py +173 -0
  516. package/runtime/pi/egregore_runtime/lifecycle.py +888 -0
  517. package/runtime/pi/egregore_runtime/lifecycle_cli.py +269 -0
  518. package/runtime/pi/egregore_runtime/notification_cli.py +125 -0
  519. package/runtime/pi/egregore_runtime/notifications.py +230 -0
  520. package/runtime/pi/egregore_runtime/observe.py +342 -0
  521. package/runtime/pi/egregore_runtime/onboarding.py +290 -0
  522. package/runtime/pi/egregore_runtime/onboarding_cli.py +110 -0
  523. package/runtime/pi/egregore_runtime/policy.py +144 -0
  524. package/runtime/pi/egregore_runtime/profile.py +193 -0
  525. package/runtime/pi/egregore_runtime/quest_cli.py +216 -0
  526. package/runtime/pi/egregore_runtime/question_cli.py +180 -0
  527. package/runtime/pi/egregore_runtime/questions.py +304 -0
  528. package/runtime/pi/egregore_runtime/quests.py +419 -0
  529. package/runtime/pi/egregore_runtime/readiness.py +379 -0
  530. package/runtime/pi/egregore_runtime/research_ingest.py +256 -0
  531. package/runtime/pi/egregore_runtime/research_ingest_cli.py +44 -0
  532. package/runtime/pi/egregore_runtime/runtime.py +464 -0
  533. package/runtime/pi/egregore_runtime/scroll_cli.py +185 -0
  534. package/runtime/pi/egregore_runtime/scrolls.py +726 -0
  535. package/runtime/pi/egregore_runtime/status.py +412 -0
  536. package/runtime/pi/egregore_runtime/status_cli.py +174 -0
  537. package/runtime/pi/egregore_runtime/sync.py +218 -0
  538. package/runtime/pi/egregore_runtime/teamsync.py +139 -0
  539. package/runtime/pi/egregore_runtime/telemetry.py +640 -0
  540. package/runtime/pi/egregore_runtime/thread_cli.py +173 -0
  541. package/runtime/pi/egregore_runtime/threads.py +517 -0
  542. package/runtime/pi/egregore_runtime/todo_cli.py +142 -0
  543. package/runtime/pi/egregore_runtime/todos.py +244 -0
  544. package/runtime/pi/egregore_runtime/upgrade.py +770 -0
  545. package/runtime/pi/egregore_runtime/upgrade_worker.py +53 -0
  546. package/runtime/pi/egregore_runtime/writeback.py +391 -0
  547. package/runtime/pi/egregore_runtime/writeback_cli.py +114 -0
  548. package/runtime/pi/manifest.json +98 -1
  549. package/runtime/prime/.codex/hooks/search-hint.js +21 -52
  550. package/runtime/prime/.codex/hooks.json +3 -3
  551. package/runtime/prime/.codex/skills/activity/SKILL.md +23 -66
  552. package/runtime/prime/.codex/skills/announce/SKILL.md +27 -50
  553. package/runtime/prime/.codex/skills/archive/SKILL.md +21 -36
  554. package/runtime/prime/.codex/skills/checkup/SKILL.md +77 -36
  555. package/runtime/prime/.codex/skills/dark-mode/SKILL.md +1 -1
  556. package/runtime/prime/.codex/skills/dashboard/SKILL.md +17 -47
  557. package/runtime/prime/.codex/skills/handoff/SKILL.md +84 -133
  558. package/runtime/prime/.codex/skills/harvest/SKILL.md +32 -117
  559. package/runtime/prime/.codex/skills/ingest/SKILL.md +47 -25
  560. package/runtime/prime/.codex/skills/ingest-user-interview/SKILL.md +18 -36
  561. package/runtime/prime/.codex/skills/ingest-user-interview/references/analysis-contract.md +42 -0
  562. package/runtime/prime/.codex/skills/invite/SKILL.md +21 -35
  563. package/runtime/prime/.codex/skills/issue/SKILL.md +60 -41
  564. package/runtime/prime/.codex/skills/me/SKILL.md +1 -1
  565. package/runtime/prime/.codex/skills/meeting/SKILL.md +16 -36
  566. package/runtime/prime/.codex/skills/meeting/references/analysis-contract.md +48 -0
  567. package/runtime/prime/.codex/skills/note/SKILL.md +30 -25
  568. package/runtime/prime/.codex/skills/onboarding/SKILL.md +36 -41
  569. package/runtime/prime/.codex/skills/pull/SKILL.md +1 -1
  570. package/runtime/prime/.codex/skills/quest/SKILL.md +27 -66
  571. package/runtime/prime/.codex/skills/reflect/SKILL.md +22 -36
  572. package/runtime/prime/.codex/skills/save/SKILL.md +2 -2
  573. package/runtime/prime/.codex/skills/telemetry/SKILL.md +1 -1
  574. package/runtime/prime/.codex/skills/test/SKILL.md +1 -1
  575. package/runtime/prime/.codex/skills/tutorial/SKILL.md +40 -41
  576. package/runtime/prime/.codex/skills/view/SKILL.md +115 -111
  577. package/runtime/prime/.codex/skills/wrap/SKILL.md +45 -41
  578. package/runtime/prime/.codex/spec-manifest.json +9 -9
  579. package/runtime/prime/.prime/agent/APPEND_SYSTEM.md +57 -48
  580. package/runtime/prime/.prime/agent/extensions/egregore.ts +7 -0
  581. package/runtime/prime/.prime/agent/spec-manifest.json +2 -2
  582. package/runtime/prime/AGENTS.md +62 -58
  583. package/runtime/prime/bin/activity-action.sh +92 -0
  584. package/runtime/prime/bin/activity-data.sh +12 -233
  585. package/runtime/prime/bin/agent.sh +84 -100
  586. package/runtime/prime/bin/artifact-register.sh +164 -0
  587. package/runtime/prime/bin/artifact-writeback.sh +53 -0
  588. package/runtime/prime/bin/artifacts.sh +288 -0
  589. package/runtime/prime/bin/build-sealed-dataroom.mjs +722 -0
  590. package/runtime/prime/bin/capture-run.sh +18 -2
  591. package/runtime/prime/bin/codex-render-spec.mjs +41 -16
  592. package/runtime/prime/bin/codex-session-start.sh +14 -4
  593. package/runtime/prime/bin/codex-skill-render.mjs +9 -7
  594. package/runtime/prime/bin/corpus_map.py +806 -0
  595. package/runtime/prime/bin/corpus_survey.py +304 -0
  596. package/runtime/prime/bin/dashboard-data.sh +11 -171
  597. package/runtime/prime/bin/github-auth.sh +121 -0
  598. package/runtime/prime/bin/graph-batch.sh +7 -0
  599. package/runtime/prime/bin/graph-op.sh +4 -0
  600. package/runtime/prime/bin/graph-projection.sh +54 -0
  601. package/runtime/prime/bin/graph-wal.sh +13 -0
  602. package/runtime/prime/bin/graph.sh +44 -0
  603. package/runtime/prime/bin/handoff-lifecycle-job.sh +146 -0
  604. package/runtime/prime/bin/handoff-lifecycle.sh +280 -0
  605. package/runtime/prime/bin/handoff-preview.sh +169 -0
  606. package/runtime/prime/bin/handoff-run.sh +42 -26
  607. package/runtime/prime/bin/ingest-graph.sh +6 -0
  608. package/runtime/prime/bin/ingest-item.sh +10 -0
  609. package/runtime/prime/bin/ingest.sh +59 -30
  610. package/runtime/prime/bin/invite.sh +6 -0
  611. package/runtime/prime/bin/issue.sh +10 -0
  612. package/runtime/prime/bin/knowledge.sh +10 -0
  613. package/runtime/prime/bin/lib/config.sh +20 -0
  614. package/runtime/prime/bin/lib/context.sh +46 -25
  615. package/runtime/prime/bin/lib/git-sync.sh +70 -6
  616. package/runtime/prime/bin/lib/greeting.sh +34 -5
  617. package/runtime/prime/bin/lib/handoff-meta.sh +97 -0
  618. package/runtime/prime/bin/lib/worktree-links.sh +6 -0
  619. package/runtime/prime/bin/node-run.sh +42 -0
  620. package/runtime/prime/bin/notification.sh +6 -0
  621. package/runtime/prime/bin/observe-context.sh +14 -0
  622. package/runtime/prime/bin/onboarding.sh +6 -0
  623. package/runtime/prime/bin/person.py +4 -0
  624. package/runtime/prime/bin/person.sh +43 -10
  625. package/runtime/prime/bin/pi-observe-context.mjs +93 -0
  626. package/runtime/prime/bin/pi-product-workflows.mjs +1 -1
  627. package/runtime/prime/bin/pi-render-spec.mjs +140 -0
  628. package/runtime/prime/bin/post-update.sh +37 -0
  629. package/runtime/prime/bin/prime-render-spec.mjs +1 -1
  630. package/runtime/prime/bin/publish-artifact.sh +55 -2
  631. package/runtime/prime/bin/quest.sh +9 -0
  632. package/runtime/prime/bin/question.sh +8 -0
  633. package/runtime/prime/bin/research-ingest.sh +7 -0
  634. package/runtime/prime/bin/restore-owned-skills.sh +67 -0
  635. package/runtime/prime/bin/retrieval_eval.py +385 -0
  636. package/runtime/prime/bin/runtime-identity.sh +70 -0
  637. package/runtime/prime/bin/runtime-upgrade.sh +43 -0
  638. package/runtime/prime/bin/scroll.sh +9 -0
  639. package/runtime/prime/bin/search.sh +231 -195
  640. package/runtime/prime/bin/settings.sh +174 -5
  641. package/runtime/prime/bin/startup-check.sh +136 -0
  642. package/runtime/prime/bin/telemetry.sh +522 -247
  643. package/runtime/prime/bin/test-changes.sh +344 -0
  644. package/runtime/prime/bin/thread.sh +9 -0
  645. package/runtime/prime/bin/todo.sh +9 -0
  646. package/runtime/prime/bin/view-render.sh +126 -0
  647. package/runtime/prime/bin/worktree-create.sh +19 -5
  648. package/runtime/prime/egregore_runtime/__init__.py +228 -0
  649. package/runtime/prime/egregore_runtime/adapters/__init__.py +5 -0
  650. package/runtime/prime/egregore_runtime/adapters/invitation.py +237 -0
  651. package/runtime/prime/egregore_runtime/adapters/notification.py +59 -0
  652. package/runtime/prime/egregore_runtime/adapters/qmd.py +1701 -0
  653. package/runtime/prime/egregore_runtime/adapters/qmd_cli.py +210 -0
  654. package/runtime/prime/egregore_runtime/adapters/qmd_embed_worker.py +59 -0
  655. package/runtime/prime/egregore_runtime/admin_gate.py +102 -0
  656. package/runtime/prime/egregore_runtime/artifacts.py +523 -0
  657. package/runtime/prime/egregore_runtime/contracts.py +499 -0
  658. package/runtime/prime/egregore_runtime/entitlements.py +85 -0
  659. package/runtime/prime/egregore_runtime/errors.py +10 -0
  660. package/runtime/prime/egregore_runtime/graph.py +356 -0
  661. package/runtime/prime/egregore_runtime/handoff_lookup.py +196 -0
  662. package/runtime/prime/egregore_runtime/harness_cli.py +1221 -0
  663. package/runtime/prime/egregore_runtime/identity.py +734 -0
  664. package/runtime/prime/egregore_runtime/identity_cli.py +91 -0
  665. package/runtime/prime/egregore_runtime/ingest.py +575 -0
  666. package/runtime/prime/egregore_runtime/ingest_cli.py +254 -0
  667. package/runtime/prime/egregore_runtime/ingest_index_cli.py +147 -0
  668. package/runtime/prime/egregore_runtime/invitation_cli.py +51 -0
  669. package/runtime/prime/egregore_runtime/invitations.py +116 -0
  670. package/runtime/prime/egregore_runtime/issue_cli.py +305 -0
  671. package/runtime/prime/egregore_runtime/issues.py +359 -0
  672. package/runtime/prime/egregore_runtime/knowledge.py +376 -0
  673. package/runtime/prime/egregore_runtime/knowledge_cli.py +173 -0
  674. package/runtime/prime/egregore_runtime/lifecycle.py +888 -0
  675. package/runtime/prime/egregore_runtime/lifecycle_cli.py +269 -0
  676. package/runtime/prime/egregore_runtime/notification_cli.py +125 -0
  677. package/runtime/prime/egregore_runtime/notifications.py +230 -0
  678. package/runtime/prime/egregore_runtime/observe.py +342 -0
  679. package/runtime/prime/egregore_runtime/onboarding.py +290 -0
  680. package/runtime/prime/egregore_runtime/onboarding_cli.py +110 -0
  681. package/runtime/prime/egregore_runtime/policy.py +144 -0
  682. package/runtime/prime/egregore_runtime/profile.py +193 -0
  683. package/runtime/prime/egregore_runtime/quest_cli.py +216 -0
  684. package/runtime/prime/egregore_runtime/question_cli.py +180 -0
  685. package/runtime/prime/egregore_runtime/questions.py +304 -0
  686. package/runtime/prime/egregore_runtime/quests.py +419 -0
  687. package/runtime/prime/egregore_runtime/readiness.py +379 -0
  688. package/runtime/prime/egregore_runtime/research_ingest.py +256 -0
  689. package/runtime/prime/egregore_runtime/research_ingest_cli.py +44 -0
  690. package/runtime/prime/egregore_runtime/runtime.py +464 -0
  691. package/runtime/prime/egregore_runtime/scroll_cli.py +185 -0
  692. package/runtime/prime/egregore_runtime/scrolls.py +726 -0
  693. package/runtime/prime/egregore_runtime/status.py +412 -0
  694. package/runtime/prime/egregore_runtime/status_cli.py +174 -0
  695. package/runtime/prime/egregore_runtime/sync.py +218 -0
  696. package/runtime/prime/egregore_runtime/teamsync.py +139 -0
  697. package/runtime/prime/egregore_runtime/telemetry.py +640 -0
  698. package/runtime/prime/egregore_runtime/thread_cli.py +173 -0
  699. package/runtime/prime/egregore_runtime/threads.py +517 -0
  700. package/runtime/prime/egregore_runtime/todo_cli.py +142 -0
  701. package/runtime/prime/egregore_runtime/todos.py +244 -0
  702. package/runtime/prime/egregore_runtime/upgrade.py +770 -0
  703. package/runtime/prime/egregore_runtime/upgrade_worker.py +53 -0
  704. package/runtime/prime/egregore_runtime/writeback.py +391 -0
  705. package/runtime/prime/egregore_runtime/writeback_cli.py +114 -0
  706. package/runtime/prime/manifest.json +98 -1
@@ -0,0 +1,642 @@
1
+ # shellcheck shell=bash
2
+ # context.sh — Context gathering for session-start.sh
3
+ #
4
+ # Runs 11 parallel background subshells to gather session context:
5
+ # 1. Recent handoffs
6
+ # 2. Active quests
7
+ # 3. User's last git activity
8
+ # 3b. Personal todos from graph
9
+ # 4. Team presence (graph + git branches)
10
+ # 5. Soul self-summary
11
+ # 6. Handoffs addressed to user
12
+ # 7. Graph health check
13
+ # 8. Telegram health check
14
+ # 9. Lifecycle events (merged PRs, implemented handoffs)
15
+ # 10. Last Pulse brief
16
+ # 11. Momentum metrics
17
+ #
18
+ # All subshells write to $CTX_DIR (a temp directory).
19
+ # Ends with `wait` + reading health results back.
20
+ #
21
+ # Inputs: SCRIPT_DIR, AUTHOR, LOCAL_MODE, STATE_FILE, CONFIG, ENV_FILE,
22
+ # HEALTH_GRAPH, HEALTH_TELEGRAM
23
+ # Outputs: CTX_DIR (populated), TIME_OF_DAY, HEALTH_GRAPH, HEALTH_TELEGRAM
24
+
25
+ CTX_DIR=$(mktemp -d)
26
+
27
+ source "$SCRIPT_DIR/bin/lib/handoff-meta.sh" >/dev/null 2>/dev/null || true
28
+
29
+ # Time of day
30
+ HOUR=$(date +%H)
31
+ if [ "$HOUR" -lt 12 ]; then TIME_OF_DAY="morning"
32
+ elif [ "$HOUR" -lt 17 ]; then TIME_OF_DAY="afternoon"
33
+ else TIME_OF_DAY="evening"
34
+ fi
35
+
36
+ # --- Attendant-baked seed ---------------------------------------------------
37
+ # bin/attendant.sh pre-bakes a context snapshot tar every warm cycle
38
+ # (_prebake_context). When the bake is fresh and its provenance matches, reuse
39
+ # its purely graph-bound results — todos, lifecycle, pulse, service health —
40
+ # and run every collector with local git/file inputs live below (handoffs,
41
+ # quests, activity, soul, addressed, questions, team presence, metrics), so
42
+ # everything file/git-derived reflects this instant. Purely graph-derived
43
+ # fields are then at most one warm cycle stale, and the boot path pays
44
+ # near-zero blocking graph round-trips (live collectors ride the warm cache).
45
+ #
46
+ # The seed is trusted only when ALL of these hold — otherwise fall back to a
47
+ # full live gather:
48
+ # - the tar extracts cleanly (atomic rename on the writer side means we see
49
+ # a whole bake or none, never a half-written directory)
50
+ # - .baked-author matches this session's author (shared machines)
51
+ # - .baked-local-mode matches this session's mode (a connected bake must
52
+ # not leak graph data into a session that switched to local)
53
+ # - .baked-config matches this checkout's egregore.json (org/API repoint,
54
+ # or a worktree branch carrying a different config)
55
+ # - .baked-scope matches the EFFECTIVE endpoint/credential fingerprint
56
+ # (EGREGORE_API_URL/KEY overrides can point at a different tenant than
57
+ # the committed config names)
58
+ # - .baked-schema matches this checkout's context.sh revision (a bake from
59
+ # another collector schema may be missing or misformatting files)
60
+ # - .baked-ts is numeric, not in the future, and younger than 15min
61
+ # - every seeded collector's file actually landed in CTX_DIR (a partial
62
+ # copy must not suppress live collectors)
63
+ CTX_SEED_USED="false"
64
+ if [ -n "${CTX_SEED_TAR:-}" ] && [ -f "${CTX_SEED_TAR:-}" ]; then
65
+ _SEED_TMP=$(mktemp -d)
66
+ if tar -xf "$CTX_SEED_TAR" -C "$_SEED_TMP" 2>/dev/null; then
67
+ _SEED_TS=$(cat "$_SEED_TMP/.baked-ts" 2>/dev/null || echo 0)
68
+ case "$_SEED_TS" in ''|*[!0-9]*) _SEED_TS=0 ;; esac
69
+ _SEED_AUTHOR=$(cat "$_SEED_TMP/.baked-author" 2>/dev/null || echo "")
70
+ _SEED_MODE=$(cat "$_SEED_TMP/.baked-local-mode" 2>/dev/null || echo "")
71
+ _SEED_CONFIG=$(cat "$_SEED_TMP/.baked-config" 2>/dev/null || echo "")
72
+ _SEED_SCOPE=$(cat "$_SEED_TMP/.baked-scope" 2>/dev/null || echo "")
73
+ _SEED_SCHEMA=$(cat "$_SEED_TMP/.baked-schema" 2>/dev/null || echo "")
74
+ _NOW_CONFIG=$(cksum "${CONFIG:-$SCRIPT_DIR/egregore.json}" 2>/dev/null | cut -d' ' -f1)
75
+ _NOW_SCHEMA=$(cksum "$SCRIPT_DIR/bin/lib/context.sh" 2>/dev/null | cut -d' ' -f1)
76
+ # Effective endpoint/credential, mirroring bin/graph.sh's resolution order
77
+ # (process env → .env → committed api_url).
78
+ _NOW_URL="${EGREGORE_API_URL:-$(grep '^EGREGORE_API_URL=' "${ENV_FILE:-$SCRIPT_DIR/.env}" 2>/dev/null | cut -d'=' -f2- || true)}"
79
+ _NOW_KEY="${EGREGORE_API_KEY:-$(grep '^EGREGORE_API_KEY=' "${ENV_FILE:-$SCRIPT_DIR/.env}" 2>/dev/null | cut -d'=' -f2- || true)}"
80
+ [ -n "$_NOW_URL" ] || _NOW_URL=$(jq -r '.api_url // empty' "${CONFIG:-$SCRIPT_DIR/egregore.json}" 2>/dev/null)
81
+ _NOW_SCOPE=$(echo -n "${_NOW_URL}|${_NOW_KEY}" | cksum | cut -d' ' -f1)
82
+ _SEED_AGE=$(( $(date +%s) - _SEED_TS ))
83
+ if [ -n "$_SEED_AUTHOR" ] && [ "$_SEED_AUTHOR" = "$AUTHOR" ] \
84
+ && [ "$_SEED_MODE" = "${LOCAL_MODE:-false}" ] \
85
+ && [ -n "$_SEED_CONFIG" ] && [ "$_SEED_CONFIG" = "$_NOW_CONFIG" ] \
86
+ && [ -n "$_SEED_SCOPE" ] && [ "$_SEED_SCOPE" = "$_NOW_SCOPE" ] \
87
+ && [ -n "$_SEED_SCHEMA" ] && [ "$_SEED_SCHEMA" = "$_NOW_SCHEMA" ] \
88
+ && [ "$_SEED_AGE" -ge 0 ] && [ "$_SEED_AGE" -lt 900 ]; then
89
+ if cp "$_SEED_TMP"/* "$CTX_DIR/" 2>/dev/null; then
90
+ # Completeness: every collector this seed replaces must be present.
91
+ CTX_SEED_USED="true"
92
+ for _SEED_REQ in todos lifecycle pulse_brief graph_health telegram_health; do
93
+ [ -f "$CTX_DIR/$_SEED_REQ" ] || { CTX_SEED_USED="false"; break; }
94
+ done
95
+ fi
96
+ fi
97
+ fi
98
+ # Record why a fresh bake was not used — seed misses silently cost a full
99
+ # live gather, so the reason must be observable in startup traces.
100
+ if [ "$CTX_SEED_USED" != "true" ]; then
101
+ _SEED_REASON="tar-extract"
102
+ if [ "$_SEED_TS" != "0" ] || [ -n "$_SEED_AUTHOR" ]; then
103
+ if [ "$_SEED_AUTHOR" != "$AUTHOR" ]; then _SEED_REASON="author"
104
+ elif [ "$_SEED_MODE" != "${LOCAL_MODE:-false}" ]; then _SEED_REASON="mode"
105
+ elif [ "$_SEED_CONFIG" != "$_NOW_CONFIG" ]; then _SEED_REASON="config"
106
+ elif [ "$_SEED_SCOPE" != "$_NOW_SCOPE" ]; then _SEED_REASON="scope"
107
+ elif [ "$_SEED_SCHEMA" != "$_NOW_SCHEMA" ]; then _SEED_REASON="schema"
108
+ elif [ "$_SEED_AGE" -lt 0 ] || [ "$_SEED_AGE" -ge 900 ]; then _SEED_REASON="age:${_SEED_AGE}s"
109
+ else _SEED_REASON="completeness"
110
+ fi
111
+ fi
112
+ type egregore_trace_mark >/dev/null 2>&1 && egregore_trace_mark "context:seed-rejected:${_SEED_REASON}"
113
+ else
114
+ type egregore_trace_mark >/dev/null 2>&1 && egregore_trace_mark "context:seed-accepted"
115
+ fi
116
+ rm -rf "$_SEED_TMP"
117
+ fi
118
+
119
+ # 1. Recent handoffs (background)
120
+ (
121
+ JSON="[]"
122
+ if [ -d "$SCRIPT_DIR/memory/handoffs" ]; then
123
+ FILES=$(find -L "$SCRIPT_DIR/memory/handoffs" -name '*.md' -not -name 'index*' -type f 2>/dev/null | xargs ls -t 2>/dev/null | head -3)
124
+ JSON="["
125
+ FIRST=true
126
+ for F in $FILES; do
127
+ [ -z "$F" ] && continue
128
+ NAME=$(basename "$F" .md)
129
+ PREVIEW=$(head -c 120 "$F" 2>/dev/null | tr '\n' ' ' | sed 's/"/\\"/g')
130
+ $FIRST || JSON="$JSON,"
131
+ JSON="$JSON{\"name\":\"$NAME\",\"preview\":\"$PREVIEW\"}"
132
+ FIRST=false
133
+ done
134
+ JSON="$JSON]"
135
+ fi
136
+ echo "$JSON" > "$CTX_DIR/handoffs"
137
+ ) &
138
+
139
+ # 2. Quests (background)
140
+ (
141
+ JSON="[]"
142
+ if [ -d "$SCRIPT_DIR/memory/quests" ]; then
143
+ JSON="["
144
+ FIRST=true
145
+ for F in "$SCRIPT_DIR/memory/quests/"*.md; do
146
+ [ -e "$F" ] || continue
147
+ case "$F" in *draft*) continue ;; esac
148
+ NAME=$(basename "$F" .md)
149
+ $FIRST || JSON="$JSON,"
150
+ JSON="$JSON\"$NAME\""
151
+ FIRST=false
152
+ done
153
+ JSON="$JSON]"
154
+ fi
155
+ echo "$JSON" > "$CTX_DIR/quests"
156
+ ) &
157
+
158
+ # 3. User's last activity (background)
159
+ (
160
+ git log --author="$AUTHOR" --format="%ar|%s" -1 2>/dev/null > "$CTX_DIR/activity" || echo "" > "$CTX_DIR/activity"
161
+ ) &
162
+
163
+ # 3b. Personal todos from graph (background; seeded)
164
+ [ "$CTX_SEED_USED" != "true" ] && (
165
+ _API_URL=$(jq -r '.api_url // empty' "$SCRIPT_DIR/egregore.json" 2>/dev/null)
166
+ _API_KEY=$(grep '^EGREGORE_API_KEY=' "${ENV_FILE:-$SCRIPT_DIR/.env}" 2>/dev/null | cut -d'=' -f2-)
167
+ if [ -n "$_API_URL" ] && [ -n "$_API_KEY" ]; then
168
+ TODO_RAW=$(bash "$SCRIPT_DIR/bin/graph.sh" query \
169
+ "MATCH (t:Todo)-[:BY]->(p:Person {github: \$me}) WHERE t.status IN ['open', 'blocked'] OPTIONAL MATCH (t)-[:PART_OF]->(q:Quest) RETURN t.text AS text, t.priority AS priority, t.status AS status, t.created AS created, q.id AS quest ORDER BY t.priority DESC, t.created DESC LIMIT 5" \
170
+ "$(jq -n --arg me "$AUTHOR" '{me: $me}')" 2>/dev/null || echo "")
171
+ if [ -n "$TODO_RAW" ]; then
172
+ echo "$TODO_RAW" | jq '[.values[] | {text: .[0], priority: (.[1] // 0), status: .[2], created: .[3], quest: (.[4] // "")}]' 2>/dev/null || echo "[]"
173
+ else
174
+ echo "[]"
175
+ fi
176
+ else
177
+ echo "[]"
178
+ fi
179
+ ) > "$CTX_DIR/todos" 2>/dev/null &
180
+
181
+ # 4. Team presence — last seen + active branches (background)
182
+ # Always live, even when seeded: its branch/file inputs are local and cheap
183
+ # (single awk/jq passes), and stale "last seen 2m ago" lines are the most
184
+ # user-visible form of drift. The one graph query inside rides the warm cache.
185
+ (
186
+ # --- Read config inside subshell ---
187
+ _API_URL=$(jq -r '.api_url // empty' "$SCRIPT_DIR/egregore.json" 2>/dev/null)
188
+ _API_KEY=$(grep '^EGREGORE_API_KEY=' "${ENV_FILE:-$SCRIPT_DIR/.env}" 2>/dev/null | cut -d'=' -f2-)
189
+
190
+ # --- Graph: last-seen per person (excluding self) ---
191
+ GRAPH_DATA="[]"
192
+ if [ -n "$_API_URL" ] && [ -n "$_API_KEY" ]; then
193
+ # String-compare the temporals: `datetime(s.date)` is an invalid cast when
194
+ # s.date is a Date (Neo.ClientError.Statement.TypeError), which made this
195
+ # query fail silently on every boot — GRAPH_DATA stayed empty, the greeting
196
+ # fell back to git/file presence, and the FILE_PRESENCE scan below ran in
197
+ # connected mode too. ISO-8601 strings order lexicographically, so max()
198
+ # over toString() is correct across DateTime, Date, and legacy string rows.
199
+ CYPHER="MATCH (s:Session)-[:BY]->(p:Person) WHERE p.github <> \$me RETURN p.name AS name, max(coalesce(toString(s.startedAt), toString(s.date))) AS lastSeen ORDER BY lastSeen DESC"
200
+ GRAPH_RAW=$(bash "$SCRIPT_DIR/bin/graph.sh" query "$CYPHER" "$(jq -n --arg me "$AUTHOR" '{me: $me}')" 2>/dev/null || echo "")
201
+ if [ -n "$GRAPH_RAW" ]; then
202
+ GRAPH_DATA=$(echo "$GRAPH_RAW" | jq '[.values[] | {name: .[0], lastSeen: .[1]}]' 2>/dev/null || echo "[]")
203
+ fi
204
+ fi
205
+
206
+ # --- Git: branch tip commit dates per person (primary recency signal) ---
207
+ # git for-each-ref is fast and gives the actual last commit date per branch.
208
+ # Single awk pass — the previous per-branch cut+tr loop spawned 3 processes
209
+ # per ref, and busy orgs carry hundreds of origin/dev/* refs. Refs arrive
210
+ # sorted by -committerdate, so the first epoch per author is their newest.
211
+ GIT_COMMIT_DATA="{}"
212
+ GIT_REF_DATA=$(git -C "$SCRIPT_DIR" for-each-ref --sort=-committerdate \
213
+ --format='%(refname:short)|%(committerdate:unix)' refs/remotes/origin/dev/ 2>/dev/null || echo "")
214
+ if [ -n "$GIT_REF_DATA" ]; then
215
+ GIT_COMMIT_DATA=$(printf '%s\n' "$GIT_REF_DATA" | awk -F'|' '
216
+ {
217
+ p = $1; sub(/^origin\/dev\//, "", p)
218
+ split(p, seg, "/"); a = tolower(seg[1])
219
+ if (a != "" && !(a in best)) best[a] = $2
220
+ }
221
+ END { for (a in best) printf "%s|%s\n", a, best[a] }
222
+ ' 2>/dev/null | jq -Rn '
223
+ [inputs | split("|") | {(.[0]): .[1]}]
224
+ | add // {}
225
+ ' 2>/dev/null || echo "{}")
226
+ [ -z "$GIT_COMMIT_DATA" ] && GIT_COMMIT_DATA="{}"
227
+ fi
228
+
229
+ # --- Git: active dev/* branches (excluding self) ---
230
+ SELF_LC=$(echo "$AUTHOR" | tr '[:upper:]' '[:lower:]')
231
+ SELF_DISPLAY_LC=""
232
+ if [ -f "$SCRIPT_DIR/.egregore-state.json" ]; then
233
+ SELF_DISPLAY_LC=$(jq -r '.display_name // empty' "$SCRIPT_DIR/.egregore-state.json" 2>/dev/null | tr '[:upper:]' '[:lower:]')
234
+ fi
235
+ BRANCH_DATA=$(git -C "$SCRIPT_DIR" branch -r --format='%(refname:short)' 2>/dev/null | grep "^origin/dev/" | sed 's|^origin/dev/||' || echo "")
236
+
237
+ BRANCH_MAP="{}"
238
+ if [ -n "$BRANCH_DATA" ]; then
239
+ # Single awk pass — the previous per-branch echo+tr loop spawned 2-4
240
+ # processes per branch over hundreds of refs.
241
+ BRANCH_MAP=$(printf '%s\n' "$BRANCH_DATA" | awk -v self="$SELF_LC" -v selfd="$SELF_DISPLAY_LC" '
242
+ {
243
+ if (split($0, seg, "/") < 2) next
244
+ a = tolower(seg[1])
245
+ if (a == "" || a == self || (selfd != "" && a == selfd)) next
246
+ h = $0; sub(/^[^\/]*\//, "", h); gsub(/-/, " ", h)
247
+ printf "%s|%s\n", a, h
248
+ }
249
+ ' 2>/dev/null | jq -Rn '
250
+ [inputs | split("|") | {author: .[0], branch: (.[1:] | join("|"))}]
251
+ | group_by(.author)
252
+ | map({(.[0].author): [.[] | .branch]})
253
+ | add // {}
254
+ ' 2>/dev/null || echo "{}")
255
+ [ -z "$BRANCH_MAP" ] && BRANCH_MAP="{}"
256
+ fi
257
+
258
+ # --- Local-mode presence: scan session + wrap files for lastSeen ---
259
+ # When graph has no data, these files provide temporal presence information.
260
+ # Single awk pass over all candidate files — the previous per-file
261
+ # grep+sed loop spawned 2-3 processes per file (~60 files) on every boot.
262
+ FILE_PRESENCE="{}"
263
+ if [ "$GRAPH_DATA" = "[]" ]; then
264
+ FP_FILES=$(for DIR in "$SCRIPT_DIR/memory/sessions" "$SCRIPT_DIR/memory/wraps" "$SCRIPT_DIR/memory/handoffs"; do
265
+ [ -d "$DIR" ] || continue
266
+ find -L "$DIR" -name '*.md' -type f 2>/dev/null | xargs ls -t 2>/dev/null | head -20
267
+ done)
268
+ if [ -n "$FP_FILES" ]; then
269
+ FILE_PRESENCE=$(printf '%s\n' "$FP_FILES" | tr '\n' '\0' | xargs -0 awk '
270
+ function flush() { if (a != "") printf "%s|%s\n", a, d }
271
+ FNR == 1 { if (NR != 1) flush(); a=""; d="" }
272
+ a == "" && /^\*\*Author\*\*:/ { s = $0; sub(/^\*\*Author\*\*:[ \t]*/, "", s); a = s }
273
+ d == "" && /^\*\*Date\*\*:/ { s = $0; sub(/^\*\*Date\*\*:[ \t]*/, "", s); d = s }
274
+ END { flush() }
275
+ ' 2>/dev/null \
276
+ | sort -t'|' -k1,1 -k2,2r | sort -t'|' -k1,1 -u \
277
+ | awk -F'|' '{ print tolower($1) "|" $2 }' \
278
+ | jq -Rn '
279
+ [inputs | split("|") | {(.[0]): .[1]}]
280
+ | add // {}
281
+ ' 2>/dev/null || echo "{}")
282
+ [ -z "$FILE_PRESENCE" ] && FILE_PRESENCE="{}"
283
+ fi
284
+ fi
285
+
286
+ # --- "Working on": latest session/handoff/wrap topic per person (file-based) ---
287
+ # Gives every team surface (greeting "around", dashboard) something legible in
288
+ # local mode, where git branches are usually empty for teammates.
289
+ # Single awk pass — the previous per-file grep+sed loop spawned ~6 processes
290
+ # per file over ~90 files on every boot.
291
+ _WM_TAB=$(printf '\t')
292
+ WM_FILES=$(for DIR in "$SCRIPT_DIR/memory/sessions" "$SCRIPT_DIR/memory/handoffs" "$SCRIPT_DIR/memory/wraps"; do
293
+ [ -d "$DIR" ] || continue
294
+ find -L "$DIR" -name '*.md' -not -name 'index*' -type f 2>/dev/null | xargs ls -t 2>/dev/null | head -30
295
+ done)
296
+ WORK_MAP="{}"
297
+ if [ -n "$WM_FILES" ]; then
298
+ WORK_MAP=$(printf '%s\n' "$WM_FILES" | tr '\n' '\0' | xargs -0 awk '
299
+ function flush() { if (a != "" && t != "") printf "%s\t%s\t%s\n", a, d, t }
300
+ FNR == 1 { if (NR != 1) flush(); a=""; d=""; t="" }
301
+ a == "" && /^\*\*Author\*\*:/ { s = $0; sub(/^\*\*Author\*\*:[ \t]*/, "", s); a = s }
302
+ d == "" && /^\*\*Date\*\*:/ { s = $0; sub(/^\*\*Date\*\*:[ \t]*/, "", s); d = s }
303
+ t == "" && /^# / {
304
+ s = $0; sub(/^#[ \t]*/, "", s)
305
+ sub(/^Session:[ \t]*/, "", s); sub(/^Handoff:[ \t]*/, "", s); sub(/^Wrap:[ \t]*/, "", s)
306
+ t = s
307
+ }
308
+ END { flush() }
309
+ ' 2>/dev/null \
310
+ | sort -t"$_WM_TAB" -k1,1 -k2,2r | sort -t"$_WM_TAB" -k1,1 -u \
311
+ | awk -F"$_WM_TAB" '{ print tolower($1) "\t" $3 }' \
312
+ | jq -Rn '[inputs | split("\t") | select(length >= 2) | {(.[0]): (.[1] // "")}] | add // {}' 2>/dev/null || echo "{}")
313
+ [ -z "$WORK_MAP" ] && WORK_MAP="{}"
314
+ fi
315
+
316
+ # --- Merge git commits + graph + file presence + branches into presence array ---
317
+ # One jq pass. The previous version looped over the name union in bash,
318
+ # spawning ~8 jq/date processes per teammate — at 16+ teammates that was the
319
+ # single largest block of session-start's boot time (~5s). All epoch parsing,
320
+ # relative-time formatting, merging, and sorting now happens inside jq.
321
+ # Git commit date is authoritative (actual work shipped); graph/file presence
322
+ # are fallbacks only (session opens ≠ real activity).
323
+ NOW_EPOCH=$(date +%s)
324
+ PRESENCE=$(jq -nc \
325
+ --argjson graph "$GRAPH_DATA" \
326
+ --argjson git "$GIT_COMMIT_DATA" \
327
+ --argjson branches "$BRANCH_MAP" \
328
+ --argjson files "$FILE_PRESENCE" \
329
+ --argjson work "$WORK_MAP" \
330
+ --arg now "$NOW_EPOCH" --arg self "$SELF_LC" --arg selfdisp "$SELF_DISPLAY_LC" '
331
+ def iso2e:
332
+ if . == null or . == "" then 0
333
+ else (sub("Z$"; "") | sub("\\+00:00$"; "") | sub("\\.[0-9]+"; "")
334
+ | (if test("T") then . else . + "T00:00:00" end)
335
+ | (try (strptime("%Y-%m-%dT%H:%M:%S") | mktime) catch 0))
336
+ end;
337
+ def day: (try strflocaltime("%Y-%m-%d") catch (gmtime | strftime("%Y-%m-%d")));
338
+ def rel($nowe): . as $e |
339
+ if $e <= 0 then "--"
340
+ else ($nowe - $e) as $d |
341
+ if $d < 60 then "just now"
342
+ elif $d < 3600 then "\($d / 60 | floor)m ago"
343
+ elif $d < 86400 then "\($d / 3600 | floor)h ago"
344
+ elif ($e | day) == ($nowe | day) then "today"
345
+ else
346
+ ((try (($nowe | day | strptime("%Y-%m-%d") | mktime)
347
+ - ($e | day | strptime("%Y-%m-%d") | mktime)) catch $d) / 86400
348
+ | floor | if . < 1 then 1 else . end) as $days |
349
+ if $days == 1 then "yesterday" else "\($days)d ago" end
350
+ end
351
+ end;
352
+ ($now | tonumber) as $nowe |
353
+ ($graph
354
+ | map({key: ((.name // "") | ascii_downcase), value: (.lastSeen // "")})
355
+ | group_by(.key)
356
+ | map({key: .[0].key, value: (map(.value) | max)})
357
+ | from_entries) as $g |
358
+ ([($g, $files, $branches, $git) | keys[]] | map(ascii_downcase) | unique
359
+ | map(select(. != "" and . != $self and . != $selfdisp))) as $names |
360
+ [ $names[] | . as $n |
361
+ (($git[$n] // "0") | (try tonumber catch 0)) as $ge |
362
+ (if $ge > 0 then $ge
363
+ else ((($g[$n] // "") | iso2e) as $gge |
364
+ if $gge > 0 then $gge else (($files[$n] // "") | iso2e) end)
365
+ end) as $epoch |
366
+ ($branches[$n] // []) as $b |
367
+ { name: $n,
368
+ last_seen: ($epoch | rel($nowe)),
369
+ last_seen_sort: $epoch,
370
+ branches: (if ($b | length) > 2 then ($b[0:2] + ["+\(($b | length) - 2) more"]) else $b end),
371
+ working_on: ($work[$n] // "") }
372
+ ] | sort_by(-.last_seen_sort)
373
+ ' 2>/dev/null || echo "[]")
374
+ echo "${PRESENCE:-[]}" > "$CTX_DIR/team"
375
+ ) &
376
+
377
+ # 5. Soul self-summary (background)
378
+ (
379
+ SUMMARY=""
380
+ if [ -f "$SCRIPT_DIR/egregore.md" ]; then
381
+ SUMMARY=$(sed -n '/^## Self-Summary/,/^##/p' "$SCRIPT_DIR/egregore.md" | sed '1d;/^##/d' | sed 's/^[[:space:]]*//' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
382
+ fi
383
+ echo "$SUMMARY" > "$CTX_DIR/soul_summary"
384
+ ) &
385
+
386
+ # 6. Handoffs addressed to user (background, enriched with author/topic)
387
+ (
388
+ JSON="[]"
389
+ RICH="[]"
390
+ if [ -d "$SCRIPT_DIR/memory/handoffs" ]; then
391
+ # One definition everywhere: Egregore Runtime folds canonical lifecycle
392
+ # state for both Local and Connected instances. Graph is an optional
393
+ # projection and must never become the startup/default retrieval path.
394
+ ADDRESSED=""
395
+ _RUNTIME_STATUS=$(bash "$SCRIPT_DIR/bin/activity-data.sh" 2>/dev/null || true)
396
+ if echo "$_RUNTIME_STATUS" | jq -e '.handoffs_to_me | type == "array"' >/dev/null 2>&1; then
397
+ ADDRESSED=$(echo "$_RUNTIME_STATUS" | jq -r '.handoffs_to_me[0:5][]?.filePath // empty' 2>/dev/null | while IFS= read -r _REL; do
398
+ _F=""
399
+ if [[ "$_REL" == memory/* ]]; then
400
+ _F="$SCRIPT_DIR/$_REL"
401
+ elif [[ "$_REL" == handoffs/* ]]; then
402
+ _F="$SCRIPT_DIR/memory/$_REL"
403
+ fi
404
+ [ -n "$_F" ] && [ -f "$_F" ] && printf '%s\n' "$_F"
405
+ done)
406
+ fi
407
+ # Match github username, display name, github_name first word, and people-file name
408
+ # Handoff files may use "to: name", "**To**: name", or "To: name"
409
+ _DISPLAY=$(jq -r '.display_name // empty' "$STATE_FILE" 2>/dev/null)
410
+ _GH_NAME=$(jq -r '.github_name // empty' "$STATE_FILE" 2>/dev/null)
411
+ _FIRST_NAME=$(echo "$_GH_NAME" | awk '{print $1}')
412
+ # Also check people file: memory/people/{author}.md has "# Name" on first line
413
+ _PEOPLE_NAME=""
414
+ _PEOPLE_FILE="$SCRIPT_DIR/memory/people/$(echo "$AUTHOR" | tr '[:upper:]' '[:lower:]').md"
415
+ [ -f "$_PEOPLE_FILE" ] && _PEOPLE_NAME=$(sed -n 's/^# *//p' "$_PEOPLE_FILE" 2>/dev/null | head -1)
416
+ _GREP_PAT="[Tt]o[*]*: *$AUTHOR\|[Tt]o[*]*:$AUTHOR"
417
+ for _VARIANT in "$_DISPLAY" "$_FIRST_NAME" "$_PEOPLE_NAME"; do
418
+ [ -z "$_VARIANT" ] && continue
419
+ [ "$_VARIANT" = "$AUTHOR" ] && continue
420
+ # Skip if already in pattern (avoid duplicates)
421
+ echo "$_GREP_PAT" | grep -qF "$_VARIANT" && continue
422
+ _GREP_PAT="$_GREP_PAT\|[Tt]o[*]*: *$_VARIANT\|[Tt]o[*]*:$_VARIANT"
423
+ done
424
+ # Compatibility fallback for an unavailable Runtime. It reads canonical
425
+ # Markdown directly and never calls graph or a control-plane retrieval API.
426
+ if [ -z "$ADDRESSED" ]; then
427
+ ADDRESSED=$(grep -rli "$_GREP_PAT" "$SCRIPT_DIR/memory/handoffs/" 2>/dev/null | sort -r | head -5 || true)
428
+ fi
429
+ JSON="["
430
+ RICH="["
431
+ FIRST=true
432
+ for AF in $ADDRESSED; do
433
+ [ -z "$AF" ] && continue
434
+ AF_NAME=$(basename "$AF" .md)
435
+ AF_AUTHOR=$(eg_handoff_author "$AF")
436
+ AF_TOPIC=$(eg_handoff_topic "$AF")
437
+ AF_DATE=$(eg_handoff_date "$AF")
438
+ # Extract repo state table if present
439
+ AF_REPO_STATE="[]"
440
+ AF_REPO_TABLE=$(awk '/^## Repo State/{found=1; next} found && /^#/{exit} found && /^\|[^-]/ && !/^\| Repo/{print}' "$AF" 2>/dev/null || true)
441
+ if [ -n "$AF_REPO_TABLE" ]; then
442
+ AF_REPO_STATE=$(echo "$AF_REPO_TABLE" | while IFS='|' read -r _ R_REPO R_BRANCH R_PR R_BASE _; do
443
+ R_REPO=$(echo "$R_REPO" | xargs 2>/dev/null || true)
444
+ R_BRANCH=$(echo "$R_BRANCH" | xargs 2>/dev/null || true)
445
+ R_PR=$(echo "$R_PR" | xargs 2>/dev/null | sed 's/^#//' | sed 's/—//' || true)
446
+ R_BASE=$(echo "$R_BASE" | xargs 2>/dev/null || true)
447
+ [ -z "$R_REPO" ] && continue
448
+ if [ -n "$R_PR" ] && [ "$R_PR" -eq "$R_PR" ] 2>/dev/null; then
449
+ printf '{"repo":"%s","branch":"%s","pr":%s,"base":"%s"}\n' "$R_REPO" "$R_BRANCH" "$R_PR" "$R_BASE"
450
+ else
451
+ printf '{"repo":"%s","branch":"%s","pr":null,"base":"%s"}\n' "$R_REPO" "$R_BRANCH" "$R_BASE"
452
+ fi
453
+ done | jq -sc '.' 2>/dev/null || echo "[]")
454
+ fi
455
+ $FIRST || JSON="$JSON,"
456
+ $FIRST || RICH="$RICH,"
457
+ JSON="$JSON\"$AF_NAME\""
458
+ AF_ENTRY=$(jq -cn \
459
+ --arg name "$AF_NAME" \
460
+ --arg author "$AF_AUTHOR" \
461
+ --arg topic "$AF_TOPIC" \
462
+ --arg date "$AF_DATE" \
463
+ --argjson repoState "$AF_REPO_STATE" \
464
+ '{name:$name, author:$author, topic:$topic, date:$date, repoState:$repoState}' 2>/dev/null || echo "{}")
465
+ RICH="$RICH$AF_ENTRY"
466
+ FIRST=false
467
+ done
468
+ JSON="$JSON]"
469
+ RICH="$RICH]"
470
+ fi
471
+ echo "$JSON" > "$CTX_DIR/addressed"
472
+ echo "$RICH" > "$CTX_DIR/addressed_rich"
473
+ ) &
474
+
475
+ # 6.5. Pending questions addressed to user (background)
476
+ (
477
+ PENDING_JSON="[]"
478
+ QDIR="$SCRIPT_DIR/memory/knowledge/questions"
479
+ if [ -d "$QDIR" ]; then
480
+ # Match against the same identity variants used for handoffs (display name,
481
+ # github first-name, people-file name) so "to: oz" matches author "oguzhan".
482
+ _DISPLAY_Q=$(jq -r '.display_name // empty' "$STATE_FILE" 2>/dev/null)
483
+ _GH_NAME_Q=$(jq -r '.github_name // empty' "$STATE_FILE" 2>/dev/null)
484
+ _FIRST_NAME_Q=$(echo "$_GH_NAME_Q" | awk '{print tolower($1)}')
485
+ _PEOPLE_FILE_Q="$SCRIPT_DIR/memory/people/$(echo "$AUTHOR" | tr '[:upper:]' '[:lower:]').md"
486
+ _PEOPLE_NAME_Q=""
487
+ [ -f "$_PEOPLE_FILE_Q" ] && _PEOPLE_NAME_Q=$(sed -n 's/^# *//p' "$_PEOPLE_FILE_Q" 2>/dev/null | head -1 | awk '{print tolower($1)}')
488
+
489
+ LINES=""
490
+ for QF in "$QDIR"/*.md; do
491
+ [ -f "$QF" ] || continue
492
+ Q_TO=$(sed -n 's/^to:[[:space:]]*//p' "$QF" 2>/dev/null | head -1 | tr -d '"' | tr '[:upper:]' '[:lower:]' | awk '{print $1}')
493
+ [ -z "$Q_TO" ] && continue
494
+ _MATCH="false"
495
+ for _V in "$AUTHOR" "$_DISPLAY_Q" "$_FIRST_NAME_Q" "$_PEOPLE_NAME_Q"; do
496
+ [ -z "$_V" ] && continue
497
+ _V_LC=$(echo "$_V" | tr '[:upper:]' '[:lower:]')
498
+ [ "$Q_TO" = "$_V_LC" ] && _MATCH="true" && break
499
+ done
500
+ [ "$_MATCH" = "true" ] || continue
501
+ Q_STATUS=$(sed -n 's/^status:[[:space:]]*//p' "$QF" 2>/dev/null | head -1 | tr -d '"')
502
+ [ "$Q_STATUS" = "pending" ] || continue
503
+ Q_FROM=$(sed -n 's/^from:[[:space:]]*//p' "$QF" 2>/dev/null | head -1 | tr -d '"')
504
+ Q_TOPIC=$(sed -n 's/^topic:[[:space:]]*//p' "$QF" 2>/dev/null | head -1 | tr -d '"')
505
+ Q_HID=$(sed -n 's/^harvest_id:[[:space:]]*//p' "$QF" 2>/dev/null | head -1 | tr -d '"')
506
+ Q_REL="${QF#$SCRIPT_DIR/}"
507
+ LINE=$(jq -nc \
508
+ --arg from "$Q_FROM" \
509
+ --arg topic "$Q_TOPIC" \
510
+ --arg hid "$Q_HID" \
511
+ --arg file "$Q_REL" \
512
+ '{from:$from, topic:$topic, harvest_id:$hid, file:$file}' 2>/dev/null)
513
+ [ -n "$LINE" ] && LINES="$LINES$LINE
514
+ "
515
+ done
516
+ if [ -n "$LINES" ]; then
517
+ PENDING_JSON=$(echo "$LINES" | jq -sc '.' 2>/dev/null || echo "[]")
518
+ fi
519
+ fi
520
+ echo "$PENDING_JSON" > "$CTX_DIR/pending_questions"
521
+ ) &
522
+
523
+ # 7. Graph health (background — zero added latency, runs in parallel; seeded)
524
+ [ "$CTX_SEED_USED" != "true" ] && (
525
+ if [ "$LOCAL_MODE" = "true" ] || ! _graph_projection_enabled; then
526
+ echo "skip"
527
+ else
528
+ _GRAPH_TEST=$(bash "$SCRIPT_DIR/bin/graph.sh" test 2>/dev/null)
529
+ if printf '%s' "$_GRAPH_TEST" | grep -q "runtime_qmd_active"; then
530
+ # Not a failure: the activated Runtime/QMD does not use graph
531
+ # retrieval — the greeting already carries that receipt, so /checkup
532
+ # nagging here would be false alarm.
533
+ echo "skip"
534
+ elif printf '%s' "$_GRAPH_TEST" | grep -q "Connected"; then
535
+ echo "ok"
536
+ else
537
+ echo "fail"
538
+ fi
539
+ fi
540
+ ) > "$CTX_DIR/graph_health" 2>/dev/null &
541
+
542
+ # 8. Telegram health (background)
543
+ # notify.sh test emits JSON, not prose: {"status":"ok"} connected,
544
+ # {"status":"configured"} local, {"status":"offline"} otherwise. Match the
545
+ # status field — an earlier grep for the word "connected" read a human sentence
546
+ # that the consent rewrite removed, so the footer showed telegram ✗ while the
547
+ # bot was answering.
548
+ [ "$CTX_SEED_USED" != "true" ] && (
549
+ if [ "$LOCAL_MODE" = "true" ]; then
550
+ echo "skip"
551
+ elif bash "$SCRIPT_DIR/bin/notify.sh" test 2>/dev/null \
552
+ | jq -e '.status == "ok" or .status == "configured"' >/dev/null 2>&1; then
553
+ echo "ok"
554
+ else
555
+ echo "fail"
556
+ fi
557
+ ) > "$CTX_DIR/telegram_health" 2>/dev/null &
558
+
559
+ # 9. Lifecycle events: merged PRs + implemented handoffs (background; seeded)
560
+ [ "$CTX_SEED_USED" != "true" ] && (
561
+ GH_USER_LC=""
562
+ if [ -f "$STATE_FILE" ]; then
563
+ GH_USER_LC=$(jq -r '.github_username // empty' "$STATE_FILE" 2>/dev/null)
564
+ fi
565
+ DISPLAY_NAME_LC=""
566
+ if [ -f "$STATE_FILE" ]; then
567
+ DISPLAY_NAME_LC=$(jq -r '.display_name // empty' "$STATE_FILE" 2>/dev/null)
568
+ fi
569
+ # Get last session end date (use 7 days ago as fallback)
570
+ LAST_END=$(bash "$SCRIPT_DIR/bin/graph.sh" query "
571
+ MATCH (s:Session)-[:BY]->(p:Person {github: \$gh})
572
+ WHERE s.wrappedAt IS NOT NULL
573
+ RETURN toString(s.wrappedAt) AS t
574
+ ORDER BY s.wrappedAt DESC SKIP 1 LIMIT 1
575
+ " "$(jq -n --arg gh "$GH_USER_LC" '{gh: $gh}')" 2>/dev/null | jq -r '.values[0][0] // empty' 2>/dev/null)
576
+ if [ -z "$LAST_END" ]; then
577
+ LAST_END="$(date -v-7d +%Y-%m-%d 2>/dev/null || date -d '7 days ago' +%Y-%m-%d 2>/dev/null || echo '2026-03-03')T00:00:00Z"
578
+ fi
579
+
580
+ MERGED_JSON="[]"
581
+ if [ -n "$GH_USER_LC" ]; then
582
+ MERGED_JSON=$(bash "$SCRIPT_DIR/bin/graph-op.sh" my-merged-prs "$GH_USER_LC" "$(echo "$LAST_END" | cut -dT -f1)" 2>/dev/null || echo "[]")
583
+ fi
584
+
585
+ IMPL_JSON="[]"
586
+ IMPL_NAME="${DISPLAY_NAME_LC:-$GH_USER_LC}"
587
+ if [ -n "$IMPL_NAME" ]; then
588
+ IMPL_JSON=$(bash "$SCRIPT_DIR/bin/graph-op.sh" my-implemented-handoffs "$IMPL_NAME" "$(echo "$LAST_END" | cut -dT -f1)" 2>/dev/null || echo "[]")
589
+ fi
590
+
591
+ jq -n --argjson merged "$MERGED_JSON" --argjson impl "$IMPL_JSON" \
592
+ '{merged_prs: $merged, implemented_handoffs: $impl}' 2>/dev/null || echo '{"merged_prs":[],"implemented_handoffs":[]}'
593
+ ) > "$CTX_DIR/lifecycle" 2>/dev/null &
594
+
595
+ # 10. Last Pulse brief (background) — gated on feature flag + API key; seeded
596
+ [ "$CTX_SEED_USED" != "true" ] && (
597
+ PULSE_ENABLED=$(jq -r '.features.pulse // "false"' "$CONFIG" 2>/dev/null || echo "false")
598
+ HAS_API_KEY=false
599
+ _env_file="${ENV_FILE:-$SCRIPT_DIR/.env}"
600
+ if [ -f "$_env_file" ]; then
601
+ _key=$(grep '^EGREGORE_API_KEY=' "$_env_file" 2>/dev/null | cut -d'=' -f2- || true)
602
+ [ -n "$_key" ] && HAS_API_KEY=true
603
+ fi
604
+
605
+ if [ "$PULSE_ENABLED" = "true" ] && [ "$HAS_API_KEY" = "true" ] && [ -n "$GH_USER_LC" ]; then
606
+ BRIEF_RESULT=$(bash "$SCRIPT_DIR/bin/graph.sh" query "
607
+ MATCH (p:Person {github: \$gh})
608
+ WHERE p.lastBrief IS NOT NULL
609
+ AND p.lastBriefDate >= date() - duration('P7D')
610
+ RETURN p.lastBrief, toString(p.lastBriefDate), p.lastRecommendations
611
+ " "$(jq -n --arg gh "$GH_USER_LC" '{gh: $gh}')" 2>/dev/null || echo '{"values":[]}')
612
+ BRIEF=$(echo "$BRIEF_RESULT" | jq -r '.values[0][0] // empty' 2>/dev/null || true)
613
+ BRIEF_DATE=$(echo "$BRIEF_RESULT" | jq -r '.values[0][1] // empty' 2>/dev/null || true)
614
+ RECS=$(echo "$BRIEF_RESULT" | jq -c '.values[0][2] // []' 2>/dev/null || echo '[]')
615
+ if [ -n "$BRIEF" ]; then
616
+ jq -n --arg brief "$BRIEF" --arg date "$BRIEF_DATE" --argjson recs "$RECS" \
617
+ '{brief: $brief, date: $date, recommendations: $recs}'
618
+ else
619
+ echo '{}'
620
+ fi
621
+ else
622
+ echo '{}'
623
+ fi
624
+ ) > "$CTX_DIR/pulse_brief" 2>/dev/null &
625
+
626
+ # 11. Momentum metrics (background)
627
+ # Always live, even when seeded: _metrics_gather mixes graph reads (which ride
628
+ # the warm cache) with local git/file scans — sessions, commits, handoffs,
629
+ # knowledge — whose freshness the greeting should reflect this instant.
630
+ (
631
+ source "$SCRIPT_DIR/bin/lib/metrics.sh"
632
+ _metrics_gather
633
+ ) > "$CTX_DIR/metrics" 2>/dev/null &
634
+
635
+ # Wait for all context gathering + health checks to finish
636
+ wait
637
+
638
+ # --- Read service health results ---
639
+ GRAPH_RESULT=$(cat "$CTX_DIR/graph_health" 2>/dev/null || echo "")
640
+ if [ -n "$GRAPH_RESULT" ]; then HEALTH_GRAPH="$GRAPH_RESULT"; fi
641
+ TELEGRAM_RESULT=$(cat "$CTX_DIR/telegram_health" 2>/dev/null || echo "")
642
+ if [ -n "$TELEGRAM_RESULT" ]; then HEALTH_TELEGRAM="$TELEGRAM_RESULT"; fi