@openrig/cli 0.5.2 → 0.5.3

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 (484) hide show
  1. package/daemon/assets/plugins/openrig-core/hooks/claude.json +36 -0
  2. package/daemon/assets/plugins/openrig-core/hooks/codex.json +27 -0
  3. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +132 -0
  4. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md +35 -3
  5. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/precompact-hook.mjs +8 -95
  6. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs +63 -20
  7. package/daemon/assets/plugins/openrig-core/skills/forming-an-openrig-mental-model/SKILL.md +6 -2
  8. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +28 -2
  9. package/daemon/assets/plugins/openrig-core/skills/mission-slice-sop/SKILL.md +42 -52
  10. package/daemon/assets/plugins/openrig-core/skills/openrig-skills/SKILL.md +23 -1
  11. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +7 -2
  12. package/daemon/assets/plugins/openrig-core/skills/orienting-to-an-inherited-seat/CHANGELOG.md +64 -0
  13. package/daemon/assets/plugins/openrig-core/skills/orienting-to-an-inherited-seat/SKILL.md +235 -0
  14. package/daemon/assets/plugins/openrig-core/skills/queue-handoff/SKILL.md +31 -1
  15. package/daemon/assets/plugins/openrig-core/skills/retiring-and-inheriting-a-seat/CHANGELOG.md +48 -0
  16. package/daemon/assets/plugins/openrig-core/skills/retiring-and-inheriting-a-seat/SKILL.md +211 -0
  17. package/daemon/assets/plugins/openrig-core/skills/seat-continuity-and-handover/SKILL.md +8 -0
  18. package/daemon/assets/plugins/openrig-core/skills/software-for-agents/SKILL.md +28 -1
  19. package/daemon/context-packs/skills/core/agent-starters/SKILL.md +132 -0
  20. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +9 -0
  21. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/SKILL.md +112 -0
  22. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +9 -0
  23. package/daemon/context-packs/skills/core/attention-queue/SKILL.md +264 -0
  24. package/daemon/context-packs/skills/core/attention-queue/manifest.yaml +9 -0
  25. package/daemon/context-packs/skills/core/cross-host-rig-commands/SKILL.md +195 -0
  26. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +9 -0
  27. package/daemon/context-packs/skills/core/human-in-the-loop/SKILL.md +104 -0
  28. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +9 -0
  29. package/daemon/context-packs/skills/core/openrig-architect/SKILL.md +378 -0
  30. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +9 -0
  31. package/daemon/context-packs/skills/core/openrig-cmux/SKILL.md +81 -0
  32. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +9 -0
  33. package/daemon/context-packs/skills/core/openrig-herdr/SKILL.md +153 -0
  34. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +9 -0
  35. package/daemon/context-packs/skills/core/openrig-upgrade/SKILL.md +460 -0
  36. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +9 -0
  37. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/SKILL.md +101 -0
  38. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +9 -0
  39. package/daemon/context-packs/skills/core/rig-lifecycle/SKILL.md +127 -0
  40. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +9 -0
  41. package/daemon/context-packs/skills/core/session-source-fork/SKILL.md +160 -0
  42. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +9 -0
  43. package/daemon/context-packs/skills/core/specification-system/SKILL.md +103 -0
  44. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +9 -0
  45. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/SKILL.md +118 -0
  46. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +9 -0
  47. package/daemon/context-packs/skills/core/watchdog/SKILL.md +126 -0
  48. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +9 -0
  49. package/daemon/context-packs/skills/pm/backlog-capture/SKILL.md +43 -0
  50. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +9 -0
  51. package/daemon/context-packs/skills/pm/context-builder/SKILL.md +87 -0
  52. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +9 -0
  53. package/daemon/context-packs/skills/pm/exec-summary/SKILL.md +84 -0
  54. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +9 -0
  55. package/daemon/context-packs/skills/pm/office-hours/SKILL.md +129 -0
  56. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +9 -0
  57. package/daemon/context-packs/skills/pm/plan-review/SKILL.md +98 -0
  58. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +9 -0
  59. package/daemon/context-packs/skills/pm/requirements-writer/SKILL.md +113 -0
  60. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +9 -0
  61. package/daemon/context-packs/skills/pm/ui-mockup/SKILL.md +76 -0
  62. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +9 -0
  63. package/daemon/context-packs/skills/pods/development-team/SKILL.md +156 -0
  64. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +9 -0
  65. package/daemon/context-packs/skills/pods/orchestration-team/SKILL.md +307 -0
  66. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +9 -0
  67. package/daemon/context-packs/skills/pods/oversight-team/SKILL.md +106 -0
  68. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +9 -0
  69. package/daemon/context-packs/skills/pods/review-team/SKILL.md +213 -0
  70. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +9 -0
  71. package/daemon/context-packs/skills/process/agent-browser/LOCAL-INSIGHTS.md +189 -0
  72. package/daemon/context-packs/skills/process/agent-browser/OPENRIG.md +40 -0
  73. package/daemon/context-packs/skills/process/agent-browser/SKILL.md +427 -0
  74. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +13 -0
  75. package/daemon/context-packs/skills/process/brainstorming/OPENRIG.md +48 -0
  76. package/daemon/context-packs/skills/process/brainstorming/SKILL.md +107 -0
  77. package/daemon/context-packs/skills/process/brainstorming/manifest.yaml +11 -0
  78. package/daemon/context-packs/skills/process/context-engineering/SKILL.md +479 -0
  79. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +9 -0
  80. package/daemon/context-packs/skills/process/dogfood/SKILL.md +225 -0
  81. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +13 -0
  82. package/daemon/context-packs/skills/process/dogfood/references/issue-taxonomy.md +109 -0
  83. package/daemon/context-packs/skills/process/dogfood/templates/dogfood-report-template.md +53 -0
  84. package/daemon/context-packs/skills/process/executing-plans/OPENRIG.md +56 -0
  85. package/daemon/context-packs/skills/process/executing-plans/SKILL.md +94 -0
  86. package/daemon/context-packs/skills/process/executing-plans/manifest.yaml +11 -0
  87. package/daemon/context-packs/skills/process/frontend-design/LICENSE.txt +177 -0
  88. package/daemon/context-packs/skills/process/frontend-design/SKILL.md +50 -0
  89. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +11 -0
  90. package/daemon/context-packs/skills/process/systematic-debugging/SKILL.md +301 -0
  91. package/daemon/context-packs/skills/process/systematic-debugging/condition-based-waiting-example.ts +158 -0
  92. package/daemon/context-packs/skills/process/systematic-debugging/condition-based-waiting.md +115 -0
  93. package/daemon/context-packs/skills/process/systematic-debugging/defense-in-depth.md +122 -0
  94. package/daemon/context-packs/skills/process/systematic-debugging/find-polluter.sh +63 -0
  95. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +19 -0
  96. package/daemon/context-packs/skills/process/systematic-debugging/root-cause-tracing.md +169 -0
  97. package/daemon/context-packs/skills/process/test-driven-development/SKILL.md +385 -0
  98. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +11 -0
  99. package/daemon/context-packs/skills/process/test-driven-development/testing-anti-patterns.md +299 -0
  100. package/daemon/context-packs/skills/process/using-superpowers/OPENRIG.md +48 -0
  101. package/daemon/context-packs/skills/process/using-superpowers/SKILL.md +106 -0
  102. package/daemon/context-packs/skills/process/using-superpowers/manifest.yaml +11 -0
  103. package/daemon/context-packs/skills/process/verification-before-completion/SKILL.md +155 -0
  104. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +9 -0
  105. package/daemon/context-packs/skills/process/writing-plans/OPENRIG.md +52 -0
  106. package/daemon/context-packs/skills/process/writing-plans/SKILL.md +126 -0
  107. package/daemon/context-packs/skills/process/writing-plans/manifest.yaml +11 -0
  108. package/daemon/context-packs/world/install/01-world-from-primitives.md +97 -0
  109. package/daemon/context-packs/world/install/02-permission-self-sleep.md +141 -0
  110. package/daemon/context-packs/world/install/03-what-this-is-for.md +86 -0
  111. package/daemon/context-packs/world/install/04-ontology.md +790 -0
  112. package/daemon/context-packs/world/install/05-harness-power-use.md +355 -0
  113. package/daemon/context-packs/world/install/06-a-competent-turn.md +225 -0
  114. package/daemon/context-packs/world/install/manifest.yaml +125 -0
  115. package/daemon/context-packs/world/install/reference-material.md +125 -0
  116. package/daemon/context-packs/world/install/what-you-can-do.md +416 -0
  117. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  118. package/daemon/dist/adapters/claude-code-adapter.js +7 -4
  119. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  120. package/daemon/dist/adapters/claude-resume.js +2 -2
  121. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  122. package/daemon/dist/adapters/tmux.d.ts +10 -2
  123. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  124. package/daemon/dist/adapters/tmux.js +27 -7
  125. package/daemon/dist/adapters/tmux.js.map +1 -1
  126. package/daemon/dist/adapters/yolo-mode.d.ts +18 -0
  127. package/daemon/dist/adapters/yolo-mode.d.ts.map +1 -1
  128. package/daemon/dist/adapters/yolo-mode.js +21 -0
  129. package/daemon/dist/adapters/yolo-mode.js.map +1 -1
  130. package/daemon/dist/build-info.js +3 -3
  131. package/daemon/dist/domain/codex-thread-id.d.ts +95 -0
  132. package/daemon/dist/domain/codex-thread-id.d.ts.map +1 -1
  133. package/daemon/dist/domain/codex-thread-id.js +171 -2
  134. package/daemon/dist/domain/codex-thread-id.js.map +1 -1
  135. package/daemon/dist/domain/context-packs/context-pack-types.d.ts +48 -0
  136. package/daemon/dist/domain/context-packs/context-pack-types.d.ts.map +1 -1
  137. package/daemon/dist/domain/context-packs/context-pack-types.js +8 -0
  138. package/daemon/dist/domain/context-packs/context-pack-types.js.map +1 -1
  139. package/daemon/dist/domain/context-packs/manifest-parser.d.ts.map +1 -1
  140. package/daemon/dist/domain/context-packs/manifest-parser.js +234 -2
  141. package/daemon/dist/domain/context-packs/manifest-parser.js.map +1 -1
  142. package/daemon/dist/domain/context-packs/probe-eval-bridge.d.ts +34 -0
  143. package/daemon/dist/domain/context-packs/probe-eval-bridge.d.ts.map +1 -0
  144. package/daemon/dist/domain/context-packs/probe-eval-bridge.js +38 -0
  145. package/daemon/dist/domain/context-packs/probe-eval-bridge.js.map +1 -0
  146. package/daemon/dist/domain/context-packs/profile-composer.d.ts +49 -0
  147. package/daemon/dist/domain/context-packs/profile-composer.d.ts.map +1 -0
  148. package/daemon/dist/domain/context-packs/profile-composer.js +125 -0
  149. package/daemon/dist/domain/context-packs/profile-composer.js.map +1 -0
  150. package/daemon/dist/domain/context-packs/profile-source-resolver.d.ts +53 -0
  151. package/daemon/dist/domain/context-packs/profile-source-resolver.d.ts.map +1 -0
  152. package/daemon/dist/domain/context-packs/profile-source-resolver.js +129 -0
  153. package/daemon/dist/domain/context-packs/profile-source-resolver.js.map +1 -0
  154. package/daemon/dist/domain/context-packs/seat-recap-store.d.ts +48 -0
  155. package/daemon/dist/domain/context-packs/seat-recap-store.d.ts.map +1 -0
  156. package/daemon/dist/domain/context-packs/seat-recap-store.js +123 -0
  157. package/daemon/dist/domain/context-packs/seat-recap-store.js.map +1 -0
  158. package/daemon/dist/domain/markdown-address.d.ts +56 -0
  159. package/daemon/dist/domain/markdown-address.d.ts.map +1 -0
  160. package/daemon/dist/domain/markdown-address.js +188 -0
  161. package/daemon/dist/domain/markdown-address.js.map +1 -0
  162. package/daemon/dist/domain/model-divergence/current-generation-record.d.ts +8 -2
  163. package/daemon/dist/domain/model-divergence/current-generation-record.d.ts.map +1 -1
  164. package/daemon/dist/domain/model-divergence/current-generation-record.js +1 -1
  165. package/daemon/dist/domain/model-divergence/current-generation-record.js.map +1 -1
  166. package/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts +33 -21
  167. package/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts.map +1 -1
  168. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js +64 -55
  169. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js.map +1 -1
  170. package/daemon/dist/domain/periodic-snapshot-scheduler.d.ts +4 -0
  171. package/daemon/dist/domain/periodic-snapshot-scheduler.d.ts.map +1 -1
  172. package/daemon/dist/domain/periodic-snapshot-scheduler.js +5 -1
  173. package/daemon/dist/domain/periodic-snapshot-scheduler.js.map +1 -1
  174. package/daemon/dist/domain/permission-drift-observer.d.ts.map +1 -1
  175. package/daemon/dist/domain/permission-drift-observer.js +6 -1
  176. package/daemon/dist/domain/permission-drift-observer.js.map +1 -1
  177. package/daemon/dist/domain/process-census.d.ts +25 -0
  178. package/daemon/dist/domain/process-census.d.ts.map +1 -0
  179. package/daemon/dist/domain/process-census.js +47 -0
  180. package/daemon/dist/domain/process-census.js.map +1 -0
  181. package/daemon/dist/domain/resume-metadata-refresher.d.ts +31 -2
  182. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  183. package/daemon/dist/domain/resume-metadata-refresher.js +64 -29
  184. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  185. package/daemon/dist/domain/review/compose.d.ts +5 -26
  186. package/daemon/dist/domain/review/compose.d.ts.map +1 -1
  187. package/daemon/dist/domain/review/compose.js +31 -57
  188. package/daemon/dist/domain/review/compose.js.map +1 -1
  189. package/daemon/dist/domain/rigspec-instantiator.d.ts +4 -0
  190. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  191. package/daemon/dist/domain/rigspec-instantiator.js +39 -0
  192. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  193. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  194. package/daemon/dist/domain/rigspec-schema.js +19 -3
  195. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  196. package/daemon/dist/domain/scope/logical-checkbox.d.ts +26 -0
  197. package/daemon/dist/domain/scope/logical-checkbox.d.ts.map +1 -0
  198. package/daemon/dist/domain/scope/logical-checkbox.js +65 -0
  199. package/daemon/dist/domain/scope/logical-checkbox.js.map +1 -0
  200. package/daemon/dist/domain/scope/plan-lock-artifacts.d.ts +1 -1
  201. package/daemon/dist/domain/scope/plan-lock-artifacts.d.ts.map +1 -1
  202. package/daemon/dist/domain/scope/plan-lock-artifacts.js +2 -2
  203. package/daemon/dist/domain/scope/plan-lock-artifacts.js.map +1 -1
  204. package/daemon/dist/domain/scope/scaffold-placeholder.d.ts +22 -0
  205. package/daemon/dist/domain/scope/scaffold-placeholder.d.ts.map +1 -1
  206. package/daemon/dist/domain/scope/scaffold-placeholder.js +24 -0
  207. package/daemon/dist/domain/scope/scaffold-placeholder.js.map +1 -1
  208. package/daemon/dist/domain/seat-activity-service.d.ts +1 -0
  209. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  210. package/daemon/dist/domain/seat-activity-service.js +39 -23
  211. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  212. package/daemon/dist/domain/seat-handover-service.d.ts +22 -0
  213. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  214. package/daemon/dist/domain/seat-handover-service.js +32 -2
  215. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  216. package/daemon/dist/domain/session-transport.d.ts +8 -0
  217. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  218. package/daemon/dist/domain/session-transport.js +116 -0
  219. package/daemon/dist/domain/session-transport.js.map +1 -1
  220. package/daemon/dist/domain/shell-classifier.d.ts +23 -0
  221. package/daemon/dist/domain/shell-classifier.d.ts.map +1 -0
  222. package/daemon/dist/domain/shell-classifier.js +36 -0
  223. package/daemon/dist/domain/shell-classifier.js.map +1 -0
  224. package/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -1
  225. package/daemon/dist/domain/slices/slice-detail-projector.js +10 -1
  226. package/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -1
  227. package/daemon/dist/domain/spec-validation-advisory.d.ts +17 -0
  228. package/daemon/dist/domain/spec-validation-advisory.d.ts.map +1 -0
  229. package/daemon/dist/domain/spec-validation-advisory.js +38 -0
  230. package/daemon/dist/domain/spec-validation-advisory.js.map +1 -0
  231. package/daemon/dist/domain/successor-session-launcher.d.ts +7 -0
  232. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  233. package/daemon/dist/domain/successor-session-launcher.js +38 -1
  234. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  235. package/daemon/dist/domain/topology-defaults-installer.d.ts +47 -0
  236. package/daemon/dist/domain/topology-defaults-installer.d.ts.map +1 -0
  237. package/daemon/dist/domain/topology-defaults-installer.js +92 -0
  238. package/daemon/dist/domain/topology-defaults-installer.js.map +1 -0
  239. package/daemon/dist/domain/transcript-rotation.d.ts +4 -0
  240. package/daemon/dist/domain/transcript-rotation.d.ts.map +1 -1
  241. package/daemon/dist/domain/transcript-rotation.js +61 -3
  242. package/daemon/dist/domain/transcript-rotation.js.map +1 -1
  243. package/daemon/dist/domain/transcript-store.d.ts.map +1 -1
  244. package/daemon/dist/domain/transcript-store.js +9 -2
  245. package/daemon/dist/domain/transcript-store.js.map +1 -1
  246. package/daemon/dist/domain/types.d.ts +3 -0
  247. package/daemon/dist/domain/types.d.ts.map +1 -1
  248. package/daemon/dist/domain/user-settings/settings-store.d.ts +10 -1
  249. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  250. package/daemon/dist/domain/user-settings/settings-store.js +39 -0
  251. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  252. package/daemon/dist/routes/context-packs.d.ts.map +1 -1
  253. package/daemon/dist/routes/context-packs.js +205 -0
  254. package/daemon/dist/routes/context-packs.js.map +1 -1
  255. package/daemon/dist/routes/seat.d.ts.map +1 -1
  256. package/daemon/dist/routes/seat.js +11 -0
  257. package/daemon/dist/routes/seat.js.map +1 -1
  258. package/daemon/dist/routes/sessions.js +55 -0
  259. package/daemon/dist/routes/sessions.js.map +1 -1
  260. package/daemon/dist/routes/transport.d.ts.map +1 -1
  261. package/daemon/dist/routes/transport.js +12 -3
  262. package/daemon/dist/routes/transport.js.map +1 -1
  263. package/daemon/dist/seat-recap-store-surface.d.ts +2 -0
  264. package/daemon/dist/seat-recap-store-surface.d.ts.map +1 -0
  265. package/daemon/dist/seat-recap-store-surface.js +6 -0
  266. package/daemon/dist/seat-recap-store-surface.js.map +1 -0
  267. package/daemon/dist/startup.d.ts.map +1 -1
  268. package/daemon/dist/startup.js +37 -6
  269. package/daemon/dist/startup.js.map +1 -1
  270. package/daemon/docs/reference/chain-file-convention.md +115 -0
  271. package/daemon/docs/reference/legacy-topology-migration.md +53 -0
  272. package/daemon/docs/reference/refocus-channel.md +80 -0
  273. package/daemon/docs/reference/sdlc-conventions.md +24 -0
  274. package/daemon/specs/agents/shared/skills/core/attention-queue/SKILL.md +1 -1
  275. package/daemon/specs/agents/shared/skills/core/human-in-the-loop/SKILL.md +1 -1
  276. package/daemon/specs/agents/shared/skills/core/session-source-fork/SKILL.md +1 -1
  277. package/daemon/specs/agents/shared/skills/core/watchdog/SKILL.md +4 -4
  278. package/daemon/specs/agents/shared/skills/pods/development-team/SKILL.md +8 -0
  279. package/daemon/specs/agents/shared/skills/pods/orchestration-team/SKILL.md +72 -31
  280. package/daemon/specs/agents/shared/skills/pods/oversight-team/SKILL.md +106 -0
  281. package/daemon/specs/agents/shared/skills/process/context-engineering/SKILL.md +479 -0
  282. package/daemon/specs/agents/shared/skills/process/test-driven-development/SKILL.md +9 -0
  283. package/daemon/specs/rigs/launch/demo/project-example/README.md +25 -0
  284. package/daemon/specs/rigs/launch/demo/project-example/missions/improve-onboarding/SPEC.md +19 -0
  285. package/daemon/specs/rigs/launch/demo/project-example/missions/improve-onboarding/slices/01-shorten-first-run/PROGRESS.md +6 -0
  286. package/daemon/specs/rigs/launch/demo/project-example/missions/improve-onboarding/slices/01-shorten-first-run/PROOF.md +7 -0
  287. package/daemon/specs/rigs/launch/demo/project-example/missions/improve-onboarding/slices/01-shorten-first-run/SPEC.md +31 -0
  288. package/daemon/specs/rigs/preview/product-team/topology/instance/CRAFT.md +24 -0
  289. package/daemon/specs/rigs/preview/product-team/topology/rig/CRAFT.md +21 -0
  290. package/daemon/specs/rigs/preview/product-team/topology/rig/ORCHESTRATION-CRAFT.md +50 -0
  291. package/daemon/specs/rigs/preview/product-team/topology/seats/dev1-qa/CRAFT.md +13 -0
  292. package/daemon/specs/rigs/preview/product-team/topology/seats/orch1-lead/CRAFT.md +17 -0
  293. package/daemon/specs/rigs/preview/product-team/topology/seats/rev1-r1/CRAFT.md +17 -0
  294. package/daemon/specs/rigs/preview/product-team/topology/seats/rev1-r2/CRAFT.md +15 -0
  295. package/dist/build-info.js +3 -3
  296. package/dist/commands/config.d.ts.map +1 -1
  297. package/dist/commands/config.js +8 -0
  298. package/dist/commands/config.js.map +1 -1
  299. package/dist/commands/context.d.ts.map +1 -1
  300. package/dist/commands/context.js +353 -48
  301. package/dist/commands/context.js.map +1 -1
  302. package/dist/commands/proof.d.ts.map +1 -1
  303. package/dist/commands/proof.js +70 -12
  304. package/dist/commands/proof.js.map +1 -1
  305. package/dist/commands/rig.d.ts.map +1 -1
  306. package/dist/commands/rig.js +5 -0
  307. package/dist/commands/rig.js.map +1 -1
  308. package/dist/commands/transcript.d.ts.map +1 -1
  309. package/dist/commands/transcript.js +25 -1
  310. package/dist/commands/transcript.js.map +1 -1
  311. package/dist/commands/walk.d.ts.map +1 -1
  312. package/dist/commands/walk.js +279 -26
  313. package/dist/commands/walk.js.map +1 -1
  314. package/dist/config-store.d.ts +15 -1
  315. package/dist/config-store.d.ts.map +1 -1
  316. package/dist/config-store.js +35 -1
  317. package/dist/config-store.js.map +1 -1
  318. package/dist/lib/scope/logical-checkbox.d.ts +26 -0
  319. package/dist/lib/scope/logical-checkbox.d.ts.map +1 -0
  320. package/dist/lib/scope/logical-checkbox.js +65 -0
  321. package/dist/lib/scope/logical-checkbox.js.map +1 -0
  322. package/dist/lib/scope/scaffold-placeholder.d.ts +22 -0
  323. package/dist/lib/scope/scaffold-placeholder.d.ts.map +1 -1
  324. package/dist/lib/scope/scaffold-placeholder.js +24 -0
  325. package/dist/lib/scope/scaffold-placeholder.js.map +1 -1
  326. package/dist/lib/topology-trace.d.ts +36 -0
  327. package/dist/lib/topology-trace.d.ts.map +1 -0
  328. package/dist/lib/topology-trace.js +91 -0
  329. package/dist/lib/topology-trace.js.map +1 -0
  330. package/node_modules/@openrig/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  331. package/node_modules/@openrig/daemon/dist/adapters/claude-code-adapter.js +7 -4
  332. package/node_modules/@openrig/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  333. package/node_modules/@openrig/daemon/dist/adapters/claude-resume.js +2 -2
  334. package/node_modules/@openrig/daemon/dist/adapters/claude-resume.js.map +1 -1
  335. package/node_modules/@openrig/daemon/dist/adapters/tmux.d.ts +10 -2
  336. package/node_modules/@openrig/daemon/dist/adapters/tmux.d.ts.map +1 -1
  337. package/node_modules/@openrig/daemon/dist/adapters/tmux.js +27 -7
  338. package/node_modules/@openrig/daemon/dist/adapters/tmux.js.map +1 -1
  339. package/node_modules/@openrig/daemon/dist/adapters/yolo-mode.d.ts +18 -0
  340. package/node_modules/@openrig/daemon/dist/adapters/yolo-mode.d.ts.map +1 -1
  341. package/node_modules/@openrig/daemon/dist/adapters/yolo-mode.js +21 -0
  342. package/node_modules/@openrig/daemon/dist/adapters/yolo-mode.js.map +1 -1
  343. package/node_modules/@openrig/daemon/dist/build-info.js +3 -3
  344. package/node_modules/@openrig/daemon/dist/domain/codex-thread-id.d.ts +95 -0
  345. package/node_modules/@openrig/daemon/dist/domain/codex-thread-id.d.ts.map +1 -1
  346. package/node_modules/@openrig/daemon/dist/domain/codex-thread-id.js +171 -2
  347. package/node_modules/@openrig/daemon/dist/domain/codex-thread-id.js.map +1 -1
  348. package/node_modules/@openrig/daemon/dist/domain/context-packs/context-pack-types.d.ts +48 -0
  349. package/node_modules/@openrig/daemon/dist/domain/context-packs/context-pack-types.d.ts.map +1 -1
  350. package/node_modules/@openrig/daemon/dist/domain/context-packs/context-pack-types.js +8 -0
  351. package/node_modules/@openrig/daemon/dist/domain/context-packs/context-pack-types.js.map +1 -1
  352. package/node_modules/@openrig/daemon/dist/domain/context-packs/manifest-parser.d.ts.map +1 -1
  353. package/node_modules/@openrig/daemon/dist/domain/context-packs/manifest-parser.js +234 -2
  354. package/node_modules/@openrig/daemon/dist/domain/context-packs/manifest-parser.js.map +1 -1
  355. package/node_modules/@openrig/daemon/dist/domain/context-packs/probe-eval-bridge.d.ts +34 -0
  356. package/node_modules/@openrig/daemon/dist/domain/context-packs/probe-eval-bridge.d.ts.map +1 -0
  357. package/node_modules/@openrig/daemon/dist/domain/context-packs/probe-eval-bridge.js +38 -0
  358. package/node_modules/@openrig/daemon/dist/domain/context-packs/probe-eval-bridge.js.map +1 -0
  359. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-composer.d.ts +49 -0
  360. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-composer.d.ts.map +1 -0
  361. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-composer.js +125 -0
  362. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-composer.js.map +1 -0
  363. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-source-resolver.d.ts +53 -0
  364. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-source-resolver.d.ts.map +1 -0
  365. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-source-resolver.js +129 -0
  366. package/node_modules/@openrig/daemon/dist/domain/context-packs/profile-source-resolver.js.map +1 -0
  367. package/node_modules/@openrig/daemon/dist/domain/context-packs/seat-recap-store.d.ts +48 -0
  368. package/node_modules/@openrig/daemon/dist/domain/context-packs/seat-recap-store.d.ts.map +1 -0
  369. package/node_modules/@openrig/daemon/dist/domain/context-packs/seat-recap-store.js +123 -0
  370. package/node_modules/@openrig/daemon/dist/domain/context-packs/seat-recap-store.js.map +1 -0
  371. package/node_modules/@openrig/daemon/dist/domain/markdown-address.d.ts +56 -0
  372. package/node_modules/@openrig/daemon/dist/domain/markdown-address.d.ts.map +1 -0
  373. package/node_modules/@openrig/daemon/dist/domain/markdown-address.js +188 -0
  374. package/node_modules/@openrig/daemon/dist/domain/markdown-address.js.map +1 -0
  375. package/node_modules/@openrig/daemon/dist/domain/model-divergence/current-generation-record.d.ts +8 -2
  376. package/node_modules/@openrig/daemon/dist/domain/model-divergence/current-generation-record.d.ts.map +1 -1
  377. package/node_modules/@openrig/daemon/dist/domain/model-divergence/current-generation-record.js +1 -1
  378. package/node_modules/@openrig/daemon/dist/domain/model-divergence/current-generation-record.js.map +1 -1
  379. package/node_modules/@openrig/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts +33 -21
  380. package/node_modules/@openrig/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts.map +1 -1
  381. package/node_modules/@openrig/daemon/dist/domain/model-divergence/model-divergence-monitor.js +64 -55
  382. package/node_modules/@openrig/daemon/dist/domain/model-divergence/model-divergence-monitor.js.map +1 -1
  383. package/node_modules/@openrig/daemon/dist/domain/periodic-snapshot-scheduler.d.ts +4 -0
  384. package/node_modules/@openrig/daemon/dist/domain/periodic-snapshot-scheduler.d.ts.map +1 -1
  385. package/node_modules/@openrig/daemon/dist/domain/periodic-snapshot-scheduler.js +5 -1
  386. package/node_modules/@openrig/daemon/dist/domain/periodic-snapshot-scheduler.js.map +1 -1
  387. package/node_modules/@openrig/daemon/dist/domain/permission-drift-observer.d.ts.map +1 -1
  388. package/node_modules/@openrig/daemon/dist/domain/permission-drift-observer.js +6 -1
  389. package/node_modules/@openrig/daemon/dist/domain/permission-drift-observer.js.map +1 -1
  390. package/node_modules/@openrig/daemon/dist/domain/process-census.d.ts +25 -0
  391. package/node_modules/@openrig/daemon/dist/domain/process-census.d.ts.map +1 -0
  392. package/node_modules/@openrig/daemon/dist/domain/process-census.js +47 -0
  393. package/node_modules/@openrig/daemon/dist/domain/process-census.js.map +1 -0
  394. package/node_modules/@openrig/daemon/dist/domain/resume-metadata-refresher.d.ts +31 -2
  395. package/node_modules/@openrig/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  396. package/node_modules/@openrig/daemon/dist/domain/resume-metadata-refresher.js +64 -29
  397. package/node_modules/@openrig/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  398. package/node_modules/@openrig/daemon/dist/domain/review/compose.d.ts +5 -26
  399. package/node_modules/@openrig/daemon/dist/domain/review/compose.d.ts.map +1 -1
  400. package/node_modules/@openrig/daemon/dist/domain/review/compose.js +31 -57
  401. package/node_modules/@openrig/daemon/dist/domain/review/compose.js.map +1 -1
  402. package/node_modules/@openrig/daemon/dist/domain/rigspec-instantiator.d.ts +4 -0
  403. package/node_modules/@openrig/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  404. package/node_modules/@openrig/daemon/dist/domain/rigspec-instantiator.js +39 -0
  405. package/node_modules/@openrig/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  406. package/node_modules/@openrig/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  407. package/node_modules/@openrig/daemon/dist/domain/rigspec-schema.js +19 -3
  408. package/node_modules/@openrig/daemon/dist/domain/rigspec-schema.js.map +1 -1
  409. package/node_modules/@openrig/daemon/dist/domain/scope/logical-checkbox.d.ts +26 -0
  410. package/node_modules/@openrig/daemon/dist/domain/scope/logical-checkbox.d.ts.map +1 -0
  411. package/node_modules/@openrig/daemon/dist/domain/scope/logical-checkbox.js +65 -0
  412. package/node_modules/@openrig/daemon/dist/domain/scope/logical-checkbox.js.map +1 -0
  413. package/node_modules/@openrig/daemon/dist/domain/scope/plan-lock-artifacts.d.ts +1 -1
  414. package/node_modules/@openrig/daemon/dist/domain/scope/plan-lock-artifacts.d.ts.map +1 -1
  415. package/node_modules/@openrig/daemon/dist/domain/scope/plan-lock-artifacts.js +2 -2
  416. package/node_modules/@openrig/daemon/dist/domain/scope/plan-lock-artifacts.js.map +1 -1
  417. package/node_modules/@openrig/daemon/dist/domain/scope/scaffold-placeholder.d.ts +22 -0
  418. package/node_modules/@openrig/daemon/dist/domain/scope/scaffold-placeholder.d.ts.map +1 -1
  419. package/node_modules/@openrig/daemon/dist/domain/scope/scaffold-placeholder.js +24 -0
  420. package/node_modules/@openrig/daemon/dist/domain/scope/scaffold-placeholder.js.map +1 -1
  421. package/node_modules/@openrig/daemon/dist/domain/seat-activity-service.d.ts +1 -0
  422. package/node_modules/@openrig/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  423. package/node_modules/@openrig/daemon/dist/domain/seat-activity-service.js +39 -23
  424. package/node_modules/@openrig/daemon/dist/domain/seat-activity-service.js.map +1 -1
  425. package/node_modules/@openrig/daemon/dist/domain/seat-handover-service.d.ts +22 -0
  426. package/node_modules/@openrig/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  427. package/node_modules/@openrig/daemon/dist/domain/seat-handover-service.js +32 -2
  428. package/node_modules/@openrig/daemon/dist/domain/seat-handover-service.js.map +1 -1
  429. package/node_modules/@openrig/daemon/dist/domain/session-transport.d.ts +8 -0
  430. package/node_modules/@openrig/daemon/dist/domain/session-transport.d.ts.map +1 -1
  431. package/node_modules/@openrig/daemon/dist/domain/session-transport.js +116 -0
  432. package/node_modules/@openrig/daemon/dist/domain/session-transport.js.map +1 -1
  433. package/node_modules/@openrig/daemon/dist/domain/shell-classifier.d.ts +23 -0
  434. package/node_modules/@openrig/daemon/dist/domain/shell-classifier.d.ts.map +1 -0
  435. package/node_modules/@openrig/daemon/dist/domain/shell-classifier.js +36 -0
  436. package/node_modules/@openrig/daemon/dist/domain/shell-classifier.js.map +1 -0
  437. package/node_modules/@openrig/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -1
  438. package/node_modules/@openrig/daemon/dist/domain/slices/slice-detail-projector.js +10 -1
  439. package/node_modules/@openrig/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -1
  440. package/node_modules/@openrig/daemon/dist/domain/spec-validation-advisory.d.ts +17 -0
  441. package/node_modules/@openrig/daemon/dist/domain/spec-validation-advisory.d.ts.map +1 -0
  442. package/node_modules/@openrig/daemon/dist/domain/spec-validation-advisory.js +38 -0
  443. package/node_modules/@openrig/daemon/dist/domain/spec-validation-advisory.js.map +1 -0
  444. package/node_modules/@openrig/daemon/dist/domain/successor-session-launcher.d.ts +7 -0
  445. package/node_modules/@openrig/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  446. package/node_modules/@openrig/daemon/dist/domain/successor-session-launcher.js +38 -1
  447. package/node_modules/@openrig/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  448. package/node_modules/@openrig/daemon/dist/domain/topology-defaults-installer.d.ts +47 -0
  449. package/node_modules/@openrig/daemon/dist/domain/topology-defaults-installer.d.ts.map +1 -0
  450. package/node_modules/@openrig/daemon/dist/domain/topology-defaults-installer.js +92 -0
  451. package/node_modules/@openrig/daemon/dist/domain/topology-defaults-installer.js.map +1 -0
  452. package/node_modules/@openrig/daemon/dist/domain/transcript-rotation.d.ts +4 -0
  453. package/node_modules/@openrig/daemon/dist/domain/transcript-rotation.d.ts.map +1 -1
  454. package/node_modules/@openrig/daemon/dist/domain/transcript-rotation.js +61 -3
  455. package/node_modules/@openrig/daemon/dist/domain/transcript-rotation.js.map +1 -1
  456. package/node_modules/@openrig/daemon/dist/domain/transcript-store.d.ts.map +1 -1
  457. package/node_modules/@openrig/daemon/dist/domain/transcript-store.js +9 -2
  458. package/node_modules/@openrig/daemon/dist/domain/transcript-store.js.map +1 -1
  459. package/node_modules/@openrig/daemon/dist/domain/types.d.ts +3 -0
  460. package/node_modules/@openrig/daemon/dist/domain/types.d.ts.map +1 -1
  461. package/node_modules/@openrig/daemon/dist/domain/user-settings/settings-store.d.ts +10 -1
  462. package/node_modules/@openrig/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  463. package/node_modules/@openrig/daemon/dist/domain/user-settings/settings-store.js +39 -0
  464. package/node_modules/@openrig/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  465. package/node_modules/@openrig/daemon/dist/routes/context-packs.d.ts.map +1 -1
  466. package/node_modules/@openrig/daemon/dist/routes/context-packs.js +205 -0
  467. package/node_modules/@openrig/daemon/dist/routes/context-packs.js.map +1 -1
  468. package/node_modules/@openrig/daemon/dist/routes/seat.d.ts.map +1 -1
  469. package/node_modules/@openrig/daemon/dist/routes/seat.js +11 -0
  470. package/node_modules/@openrig/daemon/dist/routes/seat.js.map +1 -1
  471. package/node_modules/@openrig/daemon/dist/routes/sessions.js +55 -0
  472. package/node_modules/@openrig/daemon/dist/routes/sessions.js.map +1 -1
  473. package/node_modules/@openrig/daemon/dist/routes/transport.d.ts.map +1 -1
  474. package/node_modules/@openrig/daemon/dist/routes/transport.js +12 -3
  475. package/node_modules/@openrig/daemon/dist/routes/transport.js.map +1 -1
  476. package/node_modules/@openrig/daemon/dist/seat-recap-store-surface.d.ts +2 -0
  477. package/node_modules/@openrig/daemon/dist/seat-recap-store-surface.d.ts.map +1 -0
  478. package/node_modules/@openrig/daemon/dist/seat-recap-store-surface.js +6 -0
  479. package/node_modules/@openrig/daemon/dist/seat-recap-store-surface.js.map +1 -0
  480. package/node_modules/@openrig/daemon/dist/startup.d.ts.map +1 -1
  481. package/node_modules/@openrig/daemon/dist/startup.js +37 -6
  482. package/node_modules/@openrig/daemon/dist/startup.js.map +1 -1
  483. package/node_modules/@openrig/daemon/package.json +6 -1
  484. package/package.json +1 -1
@@ -19,6 +19,15 @@
19
19
  "timeout": 5
20
20
  }
21
21
  ]
22
+ },
23
+ {
24
+ "hooks": [
25
+ {
26
+ "type": "command",
27
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/refocus.cjs\"",
28
+ "timeout": 5
29
+ }
30
+ ]
22
31
  }
23
32
  ],
24
33
  "UserPromptSubmit": [
@@ -39,6 +48,15 @@
39
48
  "timeout": 5
40
49
  }
41
50
  ]
51
+ },
52
+ {
53
+ "hooks": [
54
+ {
55
+ "type": "command",
56
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/refocus.cjs\"",
57
+ "timeout": 5
58
+ }
59
+ ]
42
60
  }
43
61
  ],
44
62
  "PreCompact": [
@@ -61,6 +79,15 @@
61
79
  "timeout": 5
62
80
  }
63
81
  ]
82
+ },
83
+ {
84
+ "hooks": [
85
+ {
86
+ "type": "command",
87
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/refocus.cjs\"",
88
+ "timeout": 5
89
+ }
90
+ ]
64
91
  }
65
92
  ],
66
93
  "Stop": [
@@ -72,6 +99,15 @@
72
99
  "timeout": 5
73
100
  }
74
101
  ]
102
+ },
103
+ {
104
+ "hooks": [
105
+ {
106
+ "type": "command",
107
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/refocus.cjs\"",
108
+ "timeout": 5
109
+ }
110
+ ]
75
111
  }
76
112
  ],
77
113
  "Notification": [
@@ -9,6 +9,15 @@
9
9
  "timeout": 5
10
10
  }
11
11
  ]
12
+ },
13
+ {
14
+ "hooks": [
15
+ {
16
+ "type": "command",
17
+ "command": "node \"${PLUGIN_ROOT}/hooks/scripts/refocus.cjs\"",
18
+ "timeout": 5
19
+ }
20
+ ]
12
21
  }
13
22
  ],
14
23
  "UserPromptSubmit": [
@@ -20,6 +29,15 @@
20
29
  "timeout": 5
21
30
  }
22
31
  ]
32
+ },
33
+ {
34
+ "hooks": [
35
+ {
36
+ "type": "command",
37
+ "command": "node \"${PLUGIN_ROOT}/hooks/scripts/refocus.cjs\"",
38
+ "timeout": 5
39
+ }
40
+ ]
23
41
  }
24
42
  ],
25
43
  "Stop": [
@@ -31,6 +49,15 @@
31
49
  "timeout": 5
32
50
  }
33
51
  ]
52
+ },
53
+ {
54
+ "hooks": [
55
+ {
56
+ "type": "command",
57
+ "command": "node \"${PLUGIN_ROOT}/hooks/scripts/refocus.cjs\"",
58
+ "timeout": 5
59
+ }
60
+ ]
34
61
  }
35
62
  ],
36
63
  "PermissionRequest": [
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // openrig-core REFOCUS hook (OPR.0.5.3.6 — promoted from the lab where it ran
4
+ // live on 6+ seats; the mechanism ships, the CONTENT is configurable).
5
+ //
6
+ // WHY: the moment an agent most needs to reorient is the moment it is least
7
+ // able to choose to. Drift does not feel like drift — it feels like work. So
8
+ // refocus FIRES rather than waits to be invoked.
9
+ //
10
+ // THIS IS ALSO HOW TOPOLOGY CHAIN FILES REACH A RUNNING SEAT. Editing a file
11
+ // under topology.root is not delivery — a running seat reads its config at
12
+ // session start and its context never re-reads disk on its own. This hook is
13
+ // the delivery channel: it injects orientation content at the seat's next
14
+ // hook boundary (SessionStart / UserPromptSubmit / Stop / PostCompact), so a
15
+ // shipped or updated chain file becomes live doctrine without a relaunch.
16
+ //
17
+ // SIGNAL = TRANSCRIPT GROWTH, not turns and not wall-clock. A "turn" is one
18
+ // prompt submission; an agent can burn 200k tokens across fifty tool calls
19
+ // inside ONE turn, so a turn counter is blind to exactly the drift that
20
+ // matters. The JSONL grows monotonically with work done (measured ~8.9 bytes
21
+ // per context token, so ~300k tokens ≈ 2.6MB — rough on purpose; it needs to
22
+ // be monotonic, not exact). Tune with OPENRIG_REFOCUS_BYTES.
23
+ //
24
+ // CONTENT IS CONFIGURABLE, NEVER PROJECT-SPECIFIC IN SOURCE. Resolution:
25
+ // 1. OPENRIG_REFOCUS_CONTENT_REF env — resolved by `rig context get`.
26
+ // 2. OPENRIG_REFOCUS_CONTENT_FILE env — an operator-authored file.
27
+ // 3. $OPENRIG_HOME/refocus/REFOCUS.md — the instance's standing content.
28
+ // 4. The generic three-question orientation below (project-neutral).
29
+ // Project- or mission-specific refocus text belongs in those FILES, on the
30
+ // instance that needs it — it must never be committed here.
31
+ //
32
+ // Fires on: SessionStart (fresh orientation), Stop (catches the long single
33
+ // turn), UserPromptSubmit, and PostCompact on Claude (post-compaction
34
+ // re-orientation; Codex exposes no compact hook — growth+Stop is the coverage
35
+ // there). Silent unless due. A configured REF failure degrades loudly inside
36
+ // the delivered payload; every failure remains non-blocking because a refocus
37
+ // hook must never break a seat's turn.
38
+
39
+ const fs = require("node:fs");
40
+ const path = require("node:path");
41
+ const { spawnSync } = require("node:child_process");
42
+ const THRESH = Number(process.env.OPENRIG_REFOCUS_BYTES || 2_600_000);
43
+
44
+ const readStdin = () => new Promise((r) => { let d = ""; process.stdin.setEncoding("utf8");
45
+ process.stdin.on("data", (c) => d += c); process.stdin.on("end", () => r(d)); process.stdin.on("error", () => r("")); });
46
+
47
+ (async () => {
48
+ let input = {}; try { input = JSON.parse((await readStdin()) || "{}") || {}; } catch {}
49
+ const ev = input.hook_event_name || "UserPromptSubmit";
50
+ const seat = process.env.OPENRIG_SESSION_NAME || "unknown-seat";
51
+ const home = process.env.OPENRIG_HOME || path.join(process.env.HOME || "/tmp", ".openrig");
52
+ const tpath = input.transcript_path || input.transcriptPath || "";
53
+
54
+ let size = 0; try { size = fs.statSync(tpath).size; } catch {}
55
+
56
+ const dir = path.join(home, "refocus");
57
+ const file = path.join(dir, `${seat.replace(/[^A-Za-z0-9@._-]/g, "_")}.json`);
58
+ let st = { lastBytes: 0 };
59
+ try { st = JSON.parse(fs.readFileSync(file, "utf8")) || st; } catch {}
60
+
61
+ const grown = size > 0 ? size - (st.lastBytes || 0) : 0;
62
+ const due = ev === "SessionStart" || ev === "PostCompact" || grown >= THRESH;
63
+ if (!due) { process.exit(0); } // silent no-op — the common path
64
+
65
+ st.lastBytes = size; st.firedAt = new Date().toISOString(); st.firedOn = ev;
66
+ try { fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(file, JSON.stringify(st)); } catch {}
67
+
68
+ // A library ref wins over file configuration and reuses the public assembler instead of
69
+ // growing a second resolver inside this hook. REF failures stay visible without blocking
70
+ // the session boundary; REF-unset follows the folded FILE/default path byte-for-byte.
71
+ const contentRef = process.env.OPENRIG_REFOCUS_CONTENT_REF || "";
72
+ let configured = null;
73
+ let refFailure = null;
74
+ if (contentRef) {
75
+ const result = spawnSync("rig", ["context", "get", contentRef], {
76
+ encoding: "utf8",
77
+ env: process.env,
78
+ timeout: 4_000,
79
+ maxBuffer: 16 * 1024 * 1024,
80
+ });
81
+ if (!result.error && result.status === 0 && result.stdout.trim()) {
82
+ configured = result.stdout;
83
+ } else {
84
+ refFailure = result.error?.message
85
+ || result.stderr?.trim()
86
+ || result.stdout?.trim()
87
+ || `rig context get exited ${result.status ?? "without a status"}`;
88
+ refFailure = String(refFailure).replace(/\s+/g, " ").trim();
89
+ }
90
+ } else {
91
+ // Configurable content: operator file beats instance file beats the generic default.
92
+ const contentFile = [
93
+ process.env.OPENRIG_REFOCUS_CONTENT_FILE,
94
+ path.join(home, "refocus", "REFOCUS.md"),
95
+ ].filter(Boolean).find((p) => { try { return fs.existsSync(p); } catch { return false; } });
96
+ if (contentFile) {
97
+ try { configured = fs.readFileSync(contentFile, "utf8").trim() || null; } catch {}
98
+ }
99
+ }
100
+
101
+ const why = ev === "SessionStart" ? "fresh session"
102
+ : ev === "PostCompact" ? "just compacted — your picture is lossy"
103
+ : `${Math.round(grown / 1e6 * 10) / 10}MB of work since your last refocus`;
104
+
105
+ const generic = [
106
+ `1. What is the person actually trying to get? Not your current task — the outcome.`,
107
+ `2. Does what you are doing RIGHT NOW move that? If you cannot say what a user gets, stop and say so.`,
108
+ `3. What have you concluded without opening the file or running the thing?`,
109
+ ``,
110
+ `Discomfort on any of these IS the signal — drift feels like work.`,
111
+ ``,
112
+ `Your topology context (instance/rig/seat craft and this seat's LEARNED) is one walk away:`,
113
+ `rig context trace --rig <rig> --seat <seat> --name CRAFT.md — read it, do not recall it.`,
114
+ `A seat's LEARNED.md is written by previous occupants in the first person: it is evidence`,
115
+ `about the SEAT, never your own memory.`,
116
+ ];
117
+
118
+ const payload = refFailure ? [
119
+ `REFOCUS CONTENT REF FAILED: ${contentRef} — ${refFailure}`,
120
+ ``,
121
+ `REFOCUS (${why}). Answer briefly, out loud, before your next move:`,
122
+ ``,
123
+ ...generic,
124
+ ] : [
125
+ `REFOCUS (${why}). Answer briefly, out loud, before your next move:`,
126
+ ``,
127
+ ...(contentRef
128
+ ? [`REFOCUS CONTENT SOURCE: OPENRIG_REFOCUS_CONTENT_REF=${contentRef}`, ``, configured]
129
+ : configured ? [configured] : generic),
130
+ ];
131
+ process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: ev, additionalContext: payload.join("\n") } }));
132
+ })();
@@ -92,6 +92,32 @@ restored from packet at <path>; resumed at step <X>
92
92
 
93
93
  Include the main files you read in full when you make that statement.
94
94
 
95
+ 9. **REFOCUS BEFORE YOU RESUME — the restore returns your TASK, not your BEARINGS.** Everything
96
+ above rebuilds *what you were doing*. None of it rebuilds *what the work is for* or *how this
97
+ rig operates* — those live in the chains, and nothing in steps 1–8 walks them. Invoke the
98
+ `refocus` skill and do its reads before your next substantive move.
99
+
100
+ **Measured 2026-08-13, and this step exists because of it:** a seat completed this protocol
101
+ faithfully — packet built, narrative read tail-first, read-depth audit reported honestly — and
102
+ resumed with a perfect picture of its atom and *zero* work-tree context. It had never opened
103
+ the mission or project nodes, and could only paraphrase the release's intent second-hand from
104
+ a peer's message. It then produced a technically-correct trace concluding *"I hold nothing"*
105
+ while holding 18 pending rows. **A restore that returns you to your task without your bearings
106
+ is how a confidently-wrong agent gets back to work.**
107
+
108
+ **On the marker and the packet's size (measured across restores, 2026-08):** two realities the restore
109
+ must handle honestly —
110
+
111
+ - **The per-seat marker (`restore-pending/<session>.json`) is frequently absent** — in five observed
112
+ restores it was never present. Treat the JSONL rebuild via `restore-from-jsonl.mjs` as the **primary**
113
+ path, not a fallback: run it regardless of whether a marker exists. (When product-infra reliably writes
114
+ the marker for tmux-launched seats, it becomes a fast-path upgrade — not a prerequisite that keeps failing.)
115
+ - **The generated transcript can be very large** (measured at ~346k tokens in one restore). Do **not**
116
+ read it front-to-back or claim to. `restore-instructions.md` declares its token cost up front; default
117
+ to the **most recent ~50k tokens of unique narrative first** (recency is what a restore needs — the
118
+ thread that produced the current frontier, not the boot handshake), and go earlier only if a specific
119
+ question requires it. A restore must leave room for the work it was restored to do.
120
+
95
121
  ## Required Read-Depth Audit
96
122
 
97
123
  After the first restore pass, audit yourself before continuing.
@@ -101,9 +127,15 @@ After the first restore pass, audit yourself before continuing.
101
127
  2. Mark each item as `FULL`, `PARTIAL`, or `NOT_READ`.
102
128
  3. You will be given a task where all of these files are required reading in
103
129
  order to understand the task.
104
- 4. Do not optimize for token conservation.
105
- 5. Read every `PARTIAL` or `NOT_READ` item in full now.
106
- 6. Report the final read-depth table before doing any substantive task work.
130
+ 4. Read `PARTIAL`/`NOT_READ` items in full — but **to a declared budget with a stopping rule**, not
131
+ unbounded. Prioritize by relevance to the active task; for a large transcript read the most recent
132
+ unique narrative first (see *If You Just Compacted*), not front-to-back.
133
+ 5. **Stop** when either every task-relevant item is `FULL`, or you reach the budget — *a restore that
134
+ cannot leave room for the work it was restored to do is not a successful restore.* "Read everything,
135
+ never conserve" has no termination condition; that open-endedness is the bug, not the goal.
136
+ 6. Report the final read-depth table **honestly** (`FULL`/`PARTIAL`/`NOT_READ`, each with a reason)
137
+ before task work. **An honest `PARTIAL` with its reason is a correct outcome, not a failure** — do
138
+ not claim a completion you did not reach.
107
139
 
108
140
  ## Guardrails
109
141
 
@@ -6,12 +6,7 @@ import { spawnSync } from "node:child_process";
6
6
 
7
7
  const skillRoot = path.resolve(new URL("..", import.meta.url).pathname);
8
8
  const restoreScript = path.join(skillRoot, "scripts", "restore-from-jsonl.mjs");
9
- // P6(C) injectable output-root: the packet base defaults to the shared
10
- // /tmp/claude-compaction-restore (production), but becomes per-run isolated when the
11
- // hermetic env-var OPENRIG_COMPACTION_OUT_ROOT is set — so concurrent writers with the
12
- // same injected clock + sessionId no longer collide on the same `${sessionId}-${stamp}`
13
- // dir. Mirrors the injectable-clock seam (OPENRIG_TEST_CLOCK_NOW). Empty/absent = /tmp.
14
- const outRoot = process.env.OPENRIG_COMPACTION_OUT_ROOT || "/tmp/claude-compaction-restore";
9
+ const outRoot = "/tmp/claude-compaction-restore";
15
10
  const defaultRestoreInstruction =
16
11
  "Read the claude-compaction-restore skill and follow its \"If You Just Compacted\" protocol.";
17
12
 
@@ -29,14 +24,6 @@ function getOpenRigHome() {
29
24
  return process.env.OPENRIG_HOME || process.env.RIGGED_HOME || path.join(os.homedir(), ".openrig");
30
25
  }
31
26
 
32
- // A3-R3 injectable clock (slice 51-01): marker.createdAt defaults to real wall-clock,
33
- // but becomes deterministic when the shared hermetic env-var OPENRIG_TEST_CLOCK_NOW is
34
- // set (an ISO instant). Empty/absent = production real-time.
35
- function nowIso() {
36
- const injected = process.env.OPENRIG_TEST_CLOCK_NOW;
37
- return typeof injected === "string" && injected.trim().length > 0 ? injected : new Date().toISOString();
38
- }
39
-
40
27
  function expandInstructionPath(filePath) {
41
28
  if (filePath.startsWith("~/")) return path.join(os.homedir(), filePath.slice(2));
42
29
  if (filePath.startsWith("${OPENRIG_HOME}/")) {
@@ -54,50 +41,6 @@ function readInstructionFile(filePath) {
54
41
  return fs.readFileSync(expanded, "utf8");
55
42
  }
56
43
 
57
- // OPR.0.4.1.09 / R5 marker-lifecycle (foreign-content-in-marker face): the hook
58
- // path must apply the SAME seat-check the daemon enforcer's resolvePostCompactExtra
59
- // applies (rev1-r2 dcd95bd9), or a FOREIGN seat's global messageFilePath leaks into
60
- // THIS seat's marker. Parse a WELL-FORMED leading `---` frontmatter for a declared
61
- // seat (target_seat / seat / session); body text is never scanned; a broken/absent
62
- // fence is GENERIC (valid for any seat). Byte-mirrors the enforcer regexes.
63
- function declaredSeatOf(content) {
64
- const fm = /^\s*---\s*\n([\s\S]*?)\n---/.exec(content);
65
- if (!fm) return null;
66
- const m = /^[ \t]*(?:target[_-]?seat|seat|session(?:[_-]?name)?)[ \t]*:[ \t]*["']?([^"'\n#]+?)["']?[ \t]*$/im.exec(fm[1]);
67
- return m ? m[1].trim() : null;
68
- }
69
-
70
- function sanitizeSeat(value) {
71
- return value.replace(/[^a-zA-Z0-9_.@-]/g, "_");
72
- }
73
-
74
- // Resolve the post-compaction extra FOR THIS SEAT (mirror of the enforcer): (1) prefer
75
- // a per-seat compaction/post-compact-extra/<seat>.md — no cross-seat contamination
76
- // possible; (2) fall back to the global ONLY when it does not declare a DIFFERENT seat
77
- // (a wrong-seat global is REFUSED). Generic/undeclared/configured-but-absent stay
78
- // allowed. Returns the path to read, or null when nothing valid for this seat.
79
- function resolveSeatSafeExtraPath(globalFilePathRaw) {
80
- const rawSeat = process.env.OPENRIG_SESSION_NAME || process.env.RIGGED_SESSION_NAME || "";
81
- const seatKey = rawSeat ? sanitizeSeat(rawSeat) : "";
82
- if (seatKey) {
83
- const perSeatPath = path.join(getOpenRigHome(), "compaction", "post-compact-extra", `${seatKey}.md`);
84
- if (fs.existsSync(perSeatPath)) {
85
- const declared = declaredSeatOf(fs.readFileSync(perSeatPath, "utf8"));
86
- if (declared && sanitizeSeat(declared) !== seatKey) return null; // wrong-seat per-seat file
87
- return perSeatPath;
88
- }
89
- }
90
- const trimmed = (globalFilePathRaw || "").trim();
91
- if (!trimmed) return null;
92
- const expanded = expandInstructionPath(trimmed);
93
- // configured-but-absent: keep the path (an absent file cannot be a wrong-seat leak;
94
- // readInstructionFile returns "" so nothing is appended).
95
- if (!fs.existsSync(expanded)) return trimmed;
96
- const declared = declaredSeatOf(fs.readFileSync(expanded, "utf8"));
97
- if (declared && sanitizeSeat(declared) !== seatKey) return null; // foreign-seat global REFUSED
98
- return trimmed;
99
- }
100
-
101
44
  function sessionKey(input) {
102
45
  const raw = [
103
46
  process.env.OPENRIG_SESSION_NAME,
@@ -115,28 +58,12 @@ function pendingMarkerPath(input) {
115
58
  return path.join(getOpenRigHome(), "compaction", "restore-pending", `${sessionKey(input)}.json`);
116
59
  }
117
60
 
118
- // R5 absent-when-needed: drop a lightweight EXPECTED sentinel FIRST (before the packet is
119
- // generated + the marker is written), carrying the SAME identity binding the marker gets.
120
- // Its presence-without-a-marker is what lets the bridge be LOUD about a missing packet
121
- // (hook died partway / write failed); policy off = no hook = no sentinel = silent.
122
- function writeExpectedSentinel(input) {
123
- const p = path.join(getOpenRigHome(), "compaction", "restore-pending", `${sessionKey(input)}.expected.json`);
124
- fs.mkdirSync(path.dirname(p), { recursive: true });
125
- fs.writeFileSync(p, `${JSON.stringify({
126
- version: 1,
127
- sessionName: process.env.OPENRIG_SESSION_NAME || process.env.RIGGED_SESSION_NAME || null,
128
- sessionId: input.session_id || input.sessionId || null,
129
- transcriptPath: input.transcript_path || null,
130
- createdAt: nowIso(),
131
- }, null, 2)}\n`, "utf8");
132
- }
133
-
134
61
  function writePendingRestoreMarker(input, parsed, restoreInstruction, customMessage) {
135
62
  const markerPath = pendingMarkerPath(input);
136
63
  fs.mkdirSync(path.dirname(markerPath), { recursive: true });
137
64
  const payload = {
138
65
  version: 1,
139
- createdAt: nowIso(),
66
+ createdAt: new Date().toISOString(),
140
67
  sessionName: process.env.OPENRIG_SESSION_NAME || process.env.RIGGED_SESSION_NAME || null,
141
68
  sessionId: input.session_id || input.sessionId || null,
142
69
  transcriptPath: input.transcript_path || null,
@@ -191,18 +118,13 @@ function readClaudeCompactionMessage() {
191
118
  parts.push(`Inline restore instruction:\n${inline}`);
192
119
  }
193
120
  if (filePath && filePath.length > 0) {
194
- // R5 seat-check: resolve to the per-seat extra or a seat-safe global; a
195
- // foreign-seat global resolves to null and is never injected into this marker.
196
- const resolved = resolveSeatSafeExtraPath(filePath);
197
- if (resolved) {
198
- try {
199
- const fileText = readInstructionFile(resolved);
200
- if (fileText) {
201
- parts.push(`Additional restore instruction file (${resolved}):\n${fileText}`);
202
- }
203
- } catch {
204
- // Keep any inline instruction; unreadable extra files degrade quietly.
121
+ try {
122
+ const fileText = readInstructionFile(filePath);
123
+ if (fileText) {
124
+ parts.push(`Additional restore instruction file (${filePath}):\n${fileText}`);
205
125
  }
126
+ } catch {
127
+ // Keep any inline instruction; unreadable extra files degrade quietly.
206
128
  }
207
129
  }
208
130
  if (parts.length > 0) return parts.join("\n\n");
@@ -218,16 +140,7 @@ function buildSystemMessage(restoreInstruction, customMessage) {
218
140
  }
219
141
 
220
142
  try {
221
- // Slice 51-01 RIDER (leak-visibility, review-r1 escalation): OPENRIG_TEST_CLOCK_NOW is
222
- // read by nowIso() to make createdAt deterministic in tests — but a LEAKED var in a
223
- // real seat would silently FREEZE production createdAt. Announce loudly on stderr when
224
- // active so any leak is visible in seat logs; absence stays silent (production path).
225
- // MUST stay byte-identical to STUB_CLOCK_ANNOUNCEMENT in stub-runner.ts.
226
- if (typeof process.env.OPENRIG_TEST_CLOCK_NOW === "string" && process.env.OPENRIG_TEST_CLOCK_NOW.trim().length > 0) {
227
- process.stderr.write("OPENRIG_TEST_CLOCK_NOW active — timestamps are injected\n");
228
- }
229
143
  const input = readHookInput();
230
- writeExpectedSentinel(input); // R5: sentinel FIRST, before the packet + marker (catches hook-died-partway)
231
144
  const args = [restoreScript, "--out", outRoot, "--json"];
232
145
  if (input.cwd) args.push("--cwd", input.cwd);
233
146
  if (input.transcript_path && input.transcript_path.endsWith(".jsonl") && fs.existsSync(input.transcript_path)) {
@@ -3,12 +3,26 @@ import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { spawnSync } from "node:child_process";
6
+ import crypto from "node:crypto";
6
7
 
7
8
  const TEXT_LIMIT = 4000;
8
- // P6(C) injectable output-root (mirrors precompact-hook.mjs): per-run isolation when
9
- // OPENRIG_COMPACTION_OUT_ROOT is set, real /tmp default in production. Guards a direct
10
- // invocation (the hook passes --out explicitly) against the same cross-writer collision.
11
- const DEFAULT_OUT = process.env.OPENRIG_COMPACTION_OUT_ROOT || "/tmp/claude-compaction-restore";
9
+ const BASE64_RUN = 800; // strip contiguous base64 runs at least this long (screenshots, data URIs)
10
+
11
+ function sha256(text) {
12
+ return crypto.createHash("sha256").update(String(text ?? "")).digest("hex").slice(0, 16);
13
+ }
14
+
15
+ // R3: replace binary / base64 payloads (data: URIs, long base64 runs) with a compact marker,
16
+ // so a single screenshot block does not blow the transcript into un-chunkable size.
17
+ function stripBinary(text) {
18
+ let s = String(text ?? "");
19
+ s = s.replace(/data:([\w.+-]+\/[\w.+-]+)?;base64,[A-Za-z0-9+/=\s]{200,}/g,
20
+ (m, mime) => `[binary omitted: ~${m.length} bytes${mime ? `, ${mime}` : ""}]`);
21
+ s = s.replace(new RegExp(`[A-Za-z0-9+/]{${BASE64_RUN},}={0,2}`, "g"),
22
+ (m) => `[base64 omitted: ~${m.length} bytes]`);
23
+ return s;
24
+ }
25
+ const DEFAULT_OUT = "/tmp/claude-compaction-restore";
12
26
 
13
27
  function parseArgs(argv) {
14
28
  const args = {
@@ -86,8 +100,9 @@ function stringifyContent(content) {
86
100
  .map((block) => {
87
101
  if (typeof block === "string") return block;
88
102
  if (block?.type === "text") return block.text ?? "";
103
+ if (block?.type === "image") return `[image omitted: ${block.source?.media_type ?? "image"}]`;
89
104
  if (block?.type === "tool_use") return `[tool_use:${block.name}] ${JSON.stringify(block.input ?? {})}`;
90
- if (block?.type === "tool_result") return `[tool_result] ${truncate(stringifyContent(block.content), TEXT_LIMIT)}`;
105
+ if (block?.type === "tool_result") return `[tool_result] ${truncate(stripBinary(stringifyContent(block.content)), TEXT_LIMIT)}`;
91
106
  return JSON.stringify(block);
92
107
  })
93
108
  .join("\n");
@@ -239,6 +254,8 @@ function analyze(jsonlPath, cwd) {
239
254
  const records = readJsonLines(jsonlPath);
240
255
  const registry = createRegistry();
241
256
  const transcript = [];
257
+ const narrative = []; // R4: message-turns only (assistant/user text), no tool bodies
258
+ const readTargets = new Map(); // R1: tool_use_id -> file_path for Read calls
242
259
  const cwdCounts = new Map();
243
260
  let sessionId = null;
244
261
 
@@ -262,20 +279,26 @@ function analyze(jsonlPath, cwd) {
262
279
 
263
280
  if (typeof content === "string") {
264
281
  transcript.push(`\n## ${role}\n\n${content}`);
282
+ narrative.push(`\n## ${role}\n\n${content}`);
265
283
  for (const file of extractPaths(content, cwd)) registry.add(file, "mentioned", `${role}:text`);
266
284
  continue;
267
285
  }
268
286
 
269
287
  if (!Array.isArray(content)) continue;
270
288
  const parts = [];
289
+ const narrativeParts = [];
271
290
  for (const block of content) {
272
291
  if (block?.type === "text") {
273
292
  parts.push(block.text ?? "");
293
+ narrativeParts.push(block.text ?? "");
274
294
  for (const file of extractPaths(block.text ?? "", cwd)) registry.add(file, "mentioned", `${role}:text`);
275
295
  } else if (block?.type === "tool_use") {
276
296
  const name = block.name ?? "unknown";
277
297
  const input = block.input ?? {};
278
298
  parts.push(`\n[tool_use:${name}]\n${JSON.stringify(input, null, 2)}`);
299
+ if (name === "Read" && block.id && (input.file_path || input.path)) {
300
+ readTargets.set(block.id, input.file_path || input.path);
301
+ }
279
302
  const kind = toolKind(name, input);
280
303
  if (input.file_path) registry.add(normalizeFile(input.file_path, cwd), kind, `tool:${name}:file_path`);
281
304
  if (input.path) registry.add(normalizeFile(input.path, cwd), kind, `tool:${name}:path`);
@@ -284,12 +307,21 @@ function analyze(jsonlPath, cwd) {
284
307
  for (const file of extractPaths(text, cwd)) registry.add(file, kind, `tool:${name}:input`);
285
308
  }
286
309
  } else if (block?.type === "tool_result") {
287
- const resultText = stringifyContent(block.content);
288
- parts.push(`\n[tool_result]\n${truncate(resultText, TEXT_LIMIT)}`);
310
+ const resultText = stripBinary(stringifyContent(block.content));
311
+ const target = block.tool_use_id && readTargets.get(block.tool_use_id);
312
+ if (target) {
313
+ // R1: a Read result reproduces a whole file — emit a pointer, not the body.
314
+ // The live file is current; this transcript copy is a snapshot that may be stale.
315
+ const lineCount = resultText.split("\n").length;
316
+ parts.push(`\n[tool_result: Read ${target} — ${lineCount} lines, sha256 ${sha256(resultText)} — READ THE LIVE FILE; this snapshot may be stale]`);
317
+ } else {
318
+ parts.push(`\n[tool_result]\n${truncate(resultText, TEXT_LIMIT)}`);
319
+ }
289
320
  for (const file of extractPaths(resultText, cwd)) registry.add(file, "mentioned", "tool_result");
290
321
  }
291
322
  }
292
323
  if (parts.length) transcript.push(`\n## ${role}\n\n${parts.join("\n")}`);
324
+ if (narrativeParts.some((p) => String(p).trim())) narrative.push(`\n## ${role}\n\n${narrativeParts.join("\n")}`);
293
325
  }
294
326
 
295
327
  const rankedFiles = registry
@@ -300,12 +332,17 @@ function analyze(jsonlPath, cwd) {
300
332
  const cwdRanked = [...cwdCounts.entries()].sort((a, b) => b[1] - a[1]);
301
333
  const effectiveCwd = cwdRanked[0]?.[0] ?? cwd;
302
334
 
335
+ const transcriptText = transcript.join("\n");
336
+ const narrativeText = narrative.join("\n");
303
337
  return {
304
338
  sessionId,
305
339
  jsonlPath,
306
340
  cwd: effectiveCwd,
307
341
  records: records.length,
308
- transcript: transcript.join("\n"),
342
+ transcript: transcriptText,
343
+ narrative: narrativeText,
344
+ transcriptTokens: Math.round(transcriptText.length / 4),
345
+ narrativeTokens: Math.round(narrativeText.length / 4),
309
346
  files: rankedFiles,
310
347
  docs: discoverDocs(effectiveCwd),
311
348
  };
@@ -346,10 +383,18 @@ function restoreInstructions(summary, outputPaths) {
346
383
  lines.push("You have just been compacted or are restoring a compacted Claude Code seat. Your mental model is compressed and unreliable.");
347
384
  lines.push("");
348
385
  lines.push(`- JSONL transcript: \`${summary.jsonlPath}\``);
349
- lines.push(`- Reconstructed transcript: \`${outputPaths.transcript}\``);
386
+ lines.push(`- Reconstructed transcript: \`${outputPaths.transcript}\` (~${summary.transcriptTokens ?? "?"} tokens — do NOT read front-to-back)`);
387
+ lines.push(`- Narrative companion (READ THIS FIRST): \`${outputPaths.narrative}\` (~${summary.narrativeTokens ?? "?"} tokens — message turns only, no tool bodies)`);
350
388
  lines.push(`- Touched-file triage: \`${outputPaths.touchedFiles}\``);
351
389
  lines.push(`- Working directory inferred: \`${summary.cwd}\``);
352
390
  lines.push("");
391
+ lines.push("## Read budget (the restore must leave room for the work)");
392
+ lines.push("");
393
+ lines.push(`- The full transcript is ~${summary.transcriptTokens ?? "?"} tokens. **Reading it front-to-back can consume the window the restore exists to rebuild.**`);
394
+ lines.push(`- Default order: read the **narrative companion first** (~${summary.narrativeTokens ?? "?"} tokens — message turns + decisions), tail-first (most recent first).`);
395
+ lines.push("- Drop to the full transcript only for a specific question the narrative can't answer. File bodies inside tool-results are pointers now — **read the live file, not the transcript snapshot.**");
396
+ lines.push("- Read to a budget with a stopping rule; report depth honestly (an honest PARTIAL beats a false completion). See the skill's *Required Read-Depth Audit*.");
397
+ lines.push("");
353
398
  lines.push("## Required Sequence");
354
399
  lines.push("");
355
400
  lines.push("1. Read this file and `touched-files.md`.");
@@ -378,31 +423,25 @@ function restoreInstructions(summary, outputPaths) {
378
423
  return lines.join("\n");
379
424
  }
380
425
 
381
- // A3-R3 injectable clock (slice 51-01): the packet output-dir timestamped path
382
- // defaults to real wall-clock, but becomes deterministic when the shared hermetic
383
- // env-var OPENRIG_TEST_CLOCK_NOW is set (an ISO instant). Empty/absent = production.
384
- function nowIso() {
385
- const injected = process.env.OPENRIG_TEST_CLOCK_NOW;
386
- return typeof injected === "string" && injected.trim().length > 0 ? injected : new Date().toISOString();
387
- }
388
-
389
426
  function writeOutputs(summary, outRoot) {
390
- const stamp = nowIso().replace(/[:.]/g, "-");
427
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
391
428
  const base = path.join(outRoot, `${summary.sessionId ?? "unknown-session"}-${stamp}`);
392
429
  fs.mkdirSync(base, { recursive: true });
393
430
 
394
431
  const outputPaths = {
395
432
  dir: base,
396
433
  transcript: path.join(base, "transcript.txt"),
434
+ narrative: path.join(base, "transcript-narrative.txt"),
397
435
  touchedFiles: path.join(base, "touched-files.md"),
398
436
  instructions: path.join(base, "restore-instructions.md"),
399
437
  summary: path.join(base, "restore-summary.json"),
400
438
  };
401
439
 
402
440
  fs.writeFileSync(outputPaths.transcript, summary.transcript || "(no message transcript reconstructed)\n");
441
+ fs.writeFileSync(outputPaths.narrative, summary.narrative || "(no narrative reconstructed)\n");
403
442
  fs.writeFileSync(outputPaths.touchedFiles, markdownFileList(summary.files));
404
443
  fs.writeFileSync(outputPaths.instructions, restoreInstructions(summary, outputPaths));
405
- fs.writeFileSync(outputPaths.summary, JSON.stringify({ ...summary, transcript: undefined, outputPaths }, null, 2));
444
+ fs.writeFileSync(outputPaths.summary, JSON.stringify({ ...summary, transcript: undefined, narrative: undefined, outputPaths }, null, 2));
406
445
 
407
446
  return outputPaths;
408
447
  }
@@ -421,6 +460,9 @@ function main() {
421
460
  jsonlPath,
422
461
  outputDir: outputPaths.dir,
423
462
  transcript: outputPaths.transcript,
463
+ narrative: outputPaths.narrative,
464
+ transcriptTokens: summary.transcriptTokens,
465
+ narrativeTokens: summary.narrativeTokens,
424
466
  touchedFiles: outputPaths.touchedFiles,
425
467
  instructions: outputPaths.instructions,
426
468
  fileCount: summary.files.length,
@@ -432,7 +474,8 @@ function main() {
432
474
  console.log(`Restore packet: ${result.outputDir}`);
433
475
  console.log(`Instructions: ${result.instructions}`);
434
476
  console.log(`Touched files: ${result.touchedFiles}`);
435
- console.log(`Transcript: ${result.transcript}`);
477
+ console.log(`Narrative (read first): ${result.narrative} (~${result.narrativeTokens} tokens)`);
478
+ console.log(`Transcript (drill-down): ${result.transcript} (~${result.transcriptTokens} tokens)`);
436
479
  }
437
480
  }
438
481
 
@@ -1,7 +1,11 @@
1
1
  ---
2
2
  name: forming-an-openrig-mental-model
3
- description: |
4
- Use when an agent is newly oriented to OpenRig and needs to form an accurate mental model of the system fast what rigs are, how skills load, what the topology shapes mean, what the product loop is. For agents booting into a new seat or returning to OpenRig work after time away. NOT for compaction recovery (use claude-compaction-restore for that) or for specific operational procedures.
3
+ description: >-
4
+ Use when the system around you does not make sense yet: you just booted into a seat and do not
5
+ know how the pieces fit; someone said rig, pod, seat, fleet, topology, or slice and you are not
6
+ certain what they mean here; you are unsure what kind of rig you are in or what it is for; you do
7
+ not know how skills reach you or where context comes from; or you are about to act on a guess
8
+ about how OpenRig works. Gives the runtime mental model fast, so you stop guessing.
5
9
  metadata:
6
10
  cli_surfaces_referenced:
7
11
  - ask