oh-my-opencode 4.8.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (512) hide show
  1. package/dist/agents/prometheus/system-prompt.d.ts +1 -1
  2. package/dist/agents/sisyphus/claude-fable-5.d.ts +19 -0
  3. package/dist/agents/sisyphus/claude-opus-4-7.d.ts +3 -1
  4. package/dist/agents/sisyphus/claude-opus-4-8.d.ts +19 -0
  5. package/dist/agents/sisyphus/index.d.ts +4 -0
  6. package/dist/agents/types.d.ts +2 -2
  7. package/dist/cli/doctor/checks/codex.d.ts +1 -0
  8. package/dist/cli/doctor/checks/tools-gh.d.ts +8 -1
  9. package/dist/cli/doctor/index.d.ts +1 -0
  10. package/dist/cli/doctor/types.d.ts +2 -0
  11. package/dist/cli/index.js +1922 -785
  12. package/dist/cli/install-codex/codex-config-permissions.d.ts +1 -1
  13. package/dist/cli/install-codex/codex-config-plugins.d.ts +1 -0
  14. package/dist/cli/install-codex/codex-config-toml.d.ts +1 -0
  15. package/dist/cli/install-codex/codex-installer-bin-dir.d.ts +8 -0
  16. package/dist/cli/install-codex/codex-multi-agent-v2-config.d.ts +11 -0
  17. package/dist/cli/install-codex/install-codex.d.ts +1 -8
  18. package/dist/cli/install-codex/lsp-daemon-reaper.d.ts +5 -0
  19. package/dist/cli/run/runnable-agent-resolver.d.ts +11 -0
  20. package/dist/cli/sparkshell-condense.d.ts +10 -0
  21. package/dist/cli/sparkshell-parse.d.ts +3 -0
  22. package/dist/cli/sparkshell-session-context.d.ts +20 -0
  23. package/dist/cli/sparkshell-spark.d.ts +23 -0
  24. package/dist/cli/sparkshell.d.ts +8 -1
  25. package/dist/cli-node/index.js +92552 -0
  26. package/dist/config/schema/agent-names.d.ts +2 -0
  27. package/dist/config/schema/hooks.d.ts +0 -2
  28. package/dist/config/schema/keyword-detector.d.ts +0 -6
  29. package/dist/config/schema/oh-my-opencode-config.d.ts +2 -4
  30. package/dist/create-hooks.d.ts +0 -2
  31. package/dist/features/background-agent/parent-wake-dedupe.d.ts +2 -0
  32. package/dist/features/background-agent/parent-wake-flush-runner.d.ts +2 -0
  33. package/dist/features/background-agent/parent-wake-prompt-dispatch.d.ts +1 -0
  34. package/dist/features/background-agent/parent-wake-session-history.d.ts +4 -0
  35. package/dist/features/background-agent/parent-wake-session-inspector.d.ts +1 -0
  36. package/dist/features/builtin-commands/templates/handoff.d.ts +1 -1
  37. package/dist/features/builtin-skills/index.d.ts +1 -1
  38. package/dist/features/builtin-skills/skills.d.ts +4 -0
  39. package/dist/features/opencode-runtime-skills/source-server.d.ts +16 -1
  40. package/dist/features/opencode-skill-loader/skill-definition-record.d.ts +2 -0
  41. package/dist/features/team-mode/tools/lifecycle-test-fixture.d.ts +2 -0
  42. package/dist/features/team-mode/types.d.ts +1 -0
  43. package/dist/features/tmux-subagent/failed-readiness-cache.d.ts +28 -0
  44. package/dist/features/tmux-subagent/manager.d.ts +1 -9
  45. package/dist/features/tmux-subagent/resolve-server-url.d.ts +3 -0
  46. package/dist/hooks/anthropic-context-window-limit-recovery/executor.d.ts +1 -1
  47. package/dist/hooks/index.d.ts +0 -1
  48. package/dist/hooks/keyword-detector/constants.d.ts +0 -4
  49. package/dist/hooks/keyword-detector/ultrawork/source-detector.d.ts +1 -1
  50. package/dist/index.js +9001 -1795
  51. package/dist/oh-my-opencode.schema.json +2 -4
  52. package/dist/plugin/chat-params.d.ts +1 -8
  53. package/dist/plugin/hooks/create-core-hooks.d.ts +0 -2
  54. package/dist/plugin/hooks/create-session-hooks.d.ts +0 -2
  55. package/dist/plugin/hooks/create-transform-hooks.d.ts +1 -2
  56. package/dist/plugin/messages-transform.d.ts +0 -1
  57. package/dist/shared/model-availability.d.ts +10 -2
  58. package/package.json +25 -18
  59. package/packages/ast-grep-mcp/dist/cli.js +2 -10
  60. package/packages/git-bash-mcp/dist/cli.js +11 -4
  61. package/packages/lsp-daemon/dist/cli.d.ts +2 -0
  62. package/packages/lsp-daemon/dist/cli.js +3711 -0
  63. package/packages/lsp-daemon/dist/daemon-client.d.ts +19 -0
  64. package/packages/lsp-daemon/dist/daemon-client.js +114 -0
  65. package/packages/lsp-daemon/dist/daemon-server.d.ts +12 -0
  66. package/packages/lsp-daemon/dist/daemon-server.js +106 -0
  67. package/packages/lsp-daemon/dist/ensure-daemon.d.ts +21 -0
  68. package/packages/lsp-daemon/dist/ensure-daemon.js +97 -0
  69. package/packages/lsp-daemon/dist/index.d.ts +5 -0
  70. package/packages/lsp-daemon/dist/index.js +3573 -0
  71. package/packages/lsp-daemon/dist/lock.d.ts +7 -0
  72. package/packages/lsp-daemon/dist/lock.js +61 -0
  73. package/packages/lsp-daemon/dist/package.json +6 -0
  74. package/packages/lsp-daemon/dist/paths.d.ts +11 -0
  75. package/packages/lsp-daemon/dist/paths.js +49 -0
  76. package/packages/lsp-daemon/dist/proxy.d.ts +10 -0
  77. package/packages/lsp-daemon/dist/proxy.js +61 -0
  78. package/packages/lsp-daemon/dist/request-routing.d.ts +9 -0
  79. package/packages/lsp-daemon/dist/request-routing.js +44 -0
  80. package/packages/lsp-daemon/dist/run-daemon.d.ts +1 -0
  81. package/packages/lsp-daemon/dist/run-daemon.js +11 -0
  82. package/packages/lsp-daemon/dist/socket-jsonrpc.d.ts +5 -0
  83. package/packages/lsp-daemon/dist/socket-jsonrpc.js +25 -0
  84. package/packages/lsp-daemon/package.json +38 -0
  85. package/packages/lsp-tools-mcp/dist/cli.js +0 -0
  86. package/packages/lsp-tools-mcp/dist/lsp/client-wrapper.js +40 -17
  87. package/packages/lsp-tools-mcp/dist/lsp/client.js +11 -9
  88. package/packages/lsp-tools-mcp/dist/lsp/config-loader.js +5 -5
  89. package/packages/lsp-tools-mcp/dist/lsp/directory-diagnostics.js +5 -3
  90. package/packages/lsp-tools-mcp/dist/lsp/effective-extension.d.ts +1 -0
  91. package/packages/lsp-tools-mcp/dist/lsp/effective-extension.js +8 -0
  92. package/packages/lsp-tools-mcp/dist/lsp/infer-extension.js +3 -2
  93. package/packages/lsp-tools-mcp/dist/lsp/language-mappings.js +1 -0
  94. package/packages/lsp-tools-mcp/dist/lsp/server-definitions.js +12 -0
  95. package/packages/lsp-tools-mcp/dist/lsp/server-install-state.d.ts +12 -0
  96. package/packages/lsp-tools-mcp/dist/lsp/server-install-state.js +51 -0
  97. package/packages/lsp-tools-mcp/dist/lsp/workspace-edit.js +2 -1
  98. package/packages/lsp-tools-mcp/dist/request-context.d.ts +7 -0
  99. package/packages/lsp-tools-mcp/dist/request-context.js +14 -0
  100. package/packages/lsp-tools-mcp/dist/tools.js +44 -1
  101. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +46 -33
  102. package/packages/omo-codex/plugin/.mcp.json +1 -1
  103. package/packages/omo-codex/plugin/components/comment-checker/dist/apply-patch.d.ts +7 -0
  104. package/packages/omo-codex/plugin/components/comment-checker/dist/apply-patch.js +173 -0
  105. package/packages/omo-codex/plugin/components/comment-checker/dist/cli.d.ts +2 -0
  106. package/packages/omo-codex/plugin/components/comment-checker/dist/cli.js +10 -0
  107. package/packages/omo-codex/plugin/components/comment-checker/dist/codex-hook.d.ts +22 -0
  108. package/packages/omo-codex/plugin/components/comment-checker/dist/codex-hook.js +165 -0
  109. package/packages/omo-codex/plugin/components/comment-checker/dist/core-values.d.ts +1 -0
  110. package/packages/omo-codex/plugin/components/comment-checker/dist/core-values.js +1 -0
  111. package/packages/omo-codex/plugin/components/comment-checker/dist/core.d.ts +5 -0
  112. package/packages/omo-codex/plugin/components/comment-checker/dist/core.js +4 -0
  113. package/packages/omo-codex/plugin/components/comment-checker/dist/hook-input.d.ts +6 -0
  114. package/packages/omo-codex/plugin/components/comment-checker/dist/hook-input.js +10 -0
  115. package/packages/omo-codex/plugin/components/comment-checker/dist/record.d.ts +2 -0
  116. package/packages/omo-codex/plugin/components/comment-checker/dist/record.js +11 -0
  117. package/packages/omo-codex/plugin/components/comment-checker/dist/request-extractor.d.ts +3 -0
  118. package/packages/omo-codex/plugin/components/comment-checker/dist/request-extractor.js +104 -0
  119. package/packages/omo-codex/plugin/components/comment-checker/dist/runner.d.ts +26 -0
  120. package/packages/omo-codex/plugin/components/comment-checker/dist/runner.js +144 -0
  121. package/packages/omo-codex/plugin/components/comment-checker/dist/types.d.ts +43 -0
  122. package/packages/omo-codex/plugin/components/comment-checker/dist/types.js +1 -0
  123. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  124. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  125. package/packages/omo-codex/plugin/components/git-bash/dist/cli.d.ts +2 -0
  126. package/packages/omo-codex/plugin/components/git-bash/dist/cli.js +29 -0
  127. package/packages/omo-codex/plugin/components/git-bash/dist/codex-hook.d.ts +28 -0
  128. package/packages/omo-codex/plugin/components/git-bash/dist/codex-hook.js +137 -0
  129. package/packages/omo-codex/plugin/components/git-bash/dist/index.d.ts +1 -0
  130. package/packages/omo-codex/plugin/components/git-bash/dist/index.js +1 -0
  131. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  132. package/packages/omo-codex/plugin/components/git-bash/package.json +5 -2
  133. package/packages/omo-codex/plugin/components/lsp/.mcp.json +1 -1
  134. package/packages/omo-codex/plugin/components/lsp/dist/cli.d.ts +2 -0
  135. package/packages/omo-codex/plugin/components/lsp/dist/cli.js +42 -0
  136. package/packages/omo-codex/plugin/components/lsp/dist/codex-hook-cli.d.ts +2 -0
  137. package/packages/omo-codex/plugin/components/lsp/dist/codex-hook-cli.js +40 -0
  138. package/packages/omo-codex/plugin/components/lsp/dist/codex-hook.d.ts +16 -0
  139. package/packages/omo-codex/plugin/components/lsp/dist/codex-hook.js +180 -0
  140. package/packages/omo-codex/plugin/components/lsp/dist/lsp-session-state.d.ts +12 -0
  141. package/packages/omo-codex/plugin/components/lsp/dist/lsp-session-state.js +95 -0
  142. package/packages/omo-codex/plugin/components/lsp/dist/mutated-file-paths.d.ts +6 -0
  143. package/packages/omo-codex/plugin/components/lsp/dist/mutated-file-paths.js +79 -0
  144. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  145. package/packages/omo-codex/plugin/components/lsp/package.json +7 -7
  146. package/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-daemon.mjs +68 -0
  147. package/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.mjs +45 -22
  148. package/packages/omo-codex/plugin/components/lsp/src/cli.ts +1 -1
  149. package/packages/omo-codex/plugin/components/lsp/src/codex-hook-cli.ts +1 -1
  150. package/packages/omo-codex/plugin/components/lsp/src/codex-hook.ts +6 -2
  151. package/packages/omo-codex/plugin/components/lsp/src/lsp-session-state.ts +4 -0
  152. package/packages/omo-codex/plugin/components/lsp/test/codex-hook-unavailable.test.ts +68 -0
  153. package/packages/omo-codex/plugin/components/lsp/test/package-smoke.test.ts +8 -20
  154. package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus.md +69 -96
  155. package/packages/omo-codex/plugin/components/rules/dist/cli.d.ts +2 -0
  156. package/packages/omo-codex/plugin/components/rules/dist/cli.js +118 -0
  157. package/packages/omo-codex/plugin/components/rules/dist/codex-hook-options.d.ts +5 -0
  158. package/packages/omo-codex/plugin/components/rules/dist/codex-hook-options.js +1 -0
  159. package/packages/omo-codex/plugin/components/rules/dist/codex-hook.d.ts +47 -0
  160. package/packages/omo-codex/plugin/components/rules/dist/codex-hook.js +127 -0
  161. package/packages/omo-codex/plugin/components/rules/dist/config.d.ts +2 -0
  162. package/packages/omo-codex/plugin/components/rules/dist/config.js +100 -0
  163. package/packages/omo-codex/plugin/components/rules/dist/context-pressure.d.ts +2 -0
  164. package/packages/omo-codex/plugin/components/rules/dist/context-pressure.js +26 -0
  165. package/packages/omo-codex/plugin/components/rules/dist/debug-log.d.ts +8 -0
  166. package/packages/omo-codex/plugin/components/rules/dist/debug-log.js +36 -0
  167. package/packages/omo-codex/plugin/components/rules/dist/dynamic-target-fingerprints.d.ts +7 -0
  168. package/packages/omo-codex/plugin/components/rules/dist/dynamic-target-fingerprints.js +65 -0
  169. package/packages/omo-codex/plugin/components/rules/dist/event-budget.d.ts +3 -0
  170. package/packages/omo-codex/plugin/components/rules/dist/event-budget.js +14 -0
  171. package/packages/omo-codex/plugin/components/rules/dist/hook-output.d.ts +2 -0
  172. package/packages/omo-codex/plugin/components/rules/dist/hook-output.js +24 -0
  173. package/packages/omo-codex/plugin/components/rules/dist/path-utils.d.ts +4 -0
  174. package/packages/omo-codex/plugin/components/rules/dist/path-utils.js +24 -0
  175. package/packages/omo-codex/plugin/components/rules/dist/persistent-cache.d.ts +13 -0
  176. package/packages/omo-codex/plugin/components/rules/dist/persistent-cache.js +172 -0
  177. package/packages/omo-codex/plugin/components/rules/dist/post-compact-budget.d.ts +6 -0
  178. package/packages/omo-codex/plugin/components/rules/dist/post-compact-budget.js +74 -0
  179. package/packages/omo-codex/plugin/components/rules/dist/post-compact-claim.d.ts +4 -0
  180. package/packages/omo-codex/plugin/components/rules/dist/post-compact-claim.js +6 -0
  181. package/packages/omo-codex/plugin/components/rules/dist/post-compact-directive.d.ts +1 -0
  182. package/packages/omo-codex/plugin/components/rules/dist/post-compact-directive.js +32 -0
  183. package/packages/omo-codex/plugin/components/rules/dist/post-compact-state.d.ts +13 -0
  184. package/packages/omo-codex/plugin/components/rules/dist/post-compact-state.js +29 -0
  185. package/packages/omo-codex/plugin/components/rules/dist/rules/cache.d.ts +9 -0
  186. package/packages/omo-codex/plugin/components/rules/dist/rules/cache.js +51 -0
  187. package/packages/omo-codex/plugin/components/rules/dist/rules/constants.d.ts +70 -0
  188. package/packages/omo-codex/plugin/components/rules/dist/rules/constants.js +101 -0
  189. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-cache.d.ts +5 -0
  190. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-cache.js +60 -0
  191. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-loader.d.ts +6 -0
  192. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-loader.js +61 -0
  193. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-loader.d.ts +7 -0
  194. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-loader.js +60 -0
  195. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-paths.d.ts +11 -0
  196. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-paths.js +75 -0
  197. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-static-loader.d.ts +6 -0
  198. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-static-loader.js +29 -0
  199. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-types.d.ts +44 -0
  200. package/packages/omo-codex/plugin/components/rules/dist/rules/engine-types.js +1 -0
  201. package/packages/omo-codex/plugin/components/rules/dist/rules/engine.d.ts +5 -0
  202. package/packages/omo-codex/plugin/components/rules/dist/rules/engine.js +85 -0
  203. package/packages/omo-codex/plugin/components/rules/dist/rules/errors.d.ts +6 -0
  204. package/packages/omo-codex/plugin/components/rules/dist/rules/errors.js +12 -0
  205. package/packages/omo-codex/plugin/components/rules/dist/rules/finder-cache.d.ts +14 -0
  206. package/packages/omo-codex/plugin/components/rules/dist/rules/finder-cache.js +51 -0
  207. package/packages/omo-codex/plugin/components/rules/dist/rules/finder-paths.d.ts +6 -0
  208. package/packages/omo-codex/plugin/components/rules/dist/rules/finder-paths.js +33 -0
  209. package/packages/omo-codex/plugin/components/rules/dist/rules/finder-sources.d.ts +5 -0
  210. package/packages/omo-codex/plugin/components/rules/dist/rules/finder-sources.js +40 -0
  211. package/packages/omo-codex/plugin/components/rules/dist/rules/finder.d.ts +28 -0
  212. package/packages/omo-codex/plugin/components/rules/dist/rules/finder.js +146 -0
  213. package/packages/omo-codex/plugin/components/rules/dist/rules/formatter.d.ts +7 -0
  214. package/packages/omo-codex/plugin/components/rules/dist/rules/formatter.js +112 -0
  215. package/packages/omo-codex/plugin/components/rules/dist/rules/matcher.d.ts +18 -0
  216. package/packages/omo-codex/plugin/components/rules/dist/rules/matcher.js +93 -0
  217. package/packages/omo-codex/plugin/components/rules/dist/rules/ordering.d.ts +3 -0
  218. package/packages/omo-codex/plugin/components/rules/dist/rules/ordering.js +27 -0
  219. package/packages/omo-codex/plugin/components/rules/dist/rules/parser-frontmatter.d.ts +7 -0
  220. package/packages/omo-codex/plugin/components/rules/dist/rules/parser-frontmatter.js +30 -0
  221. package/packages/omo-codex/plugin/components/rules/dist/rules/parser-yaml.d.ts +2 -0
  222. package/packages/omo-codex/plugin/components/rules/dist/rules/parser-yaml.js +237 -0
  223. package/packages/omo-codex/plugin/components/rules/dist/rules/parser.d.ts +3 -0
  224. package/packages/omo-codex/plugin/components/rules/dist/rules/parser.js +31 -0
  225. package/packages/omo-codex/plugin/components/rules/dist/rules/plugin-root.d.ts +1 -0
  226. package/packages/omo-codex/plugin/components/rules/dist/rules/plugin-root.js +48 -0
  227. package/packages/omo-codex/plugin/components/rules/dist/rules/project-root.d.ts +1 -0
  228. package/packages/omo-codex/plugin/components/rules/dist/rules/project-root.js +23 -0
  229. package/packages/omo-codex/plugin/components/rules/dist/rules/scanner.d.ts +14 -0
  230. package/packages/omo-codex/plugin/components/rules/dist/rules/scanner.js +111 -0
  231. package/packages/omo-codex/plugin/components/rules/dist/rules/sources.d.ts +3 -0
  232. package/packages/omo-codex/plugin/components/rules/dist/rules/sources.js +9 -0
  233. package/packages/omo-codex/plugin/components/rules/dist/rules/truncator.d.ts +18 -0
  234. package/packages/omo-codex/plugin/components/rules/dist/rules/truncator.js +59 -0
  235. package/packages/omo-codex/plugin/components/rules/dist/rules/types.d.ts +126 -0
  236. package/packages/omo-codex/plugin/components/rules/dist/rules/types.js +8 -0
  237. package/packages/omo-codex/plugin/components/rules/dist/rules-engine-factory.d.ts +6 -0
  238. package/packages/omo-codex/plugin/components/rules/dist/rules-engine-factory.js +20 -0
  239. package/packages/omo-codex/plugin/components/rules/dist/session-state-lock.d.ts +3 -0
  240. package/packages/omo-codex/plugin/components/rules/dist/session-state-lock.js +41 -0
  241. package/packages/omo-codex/plugin/components/rules/dist/sparkshell-awareness.d.ts +10 -0
  242. package/packages/omo-codex/plugin/components/rules/dist/sparkshell-awareness.js +90 -0
  243. package/packages/omo-codex/plugin/components/rules/dist/static-injection.d.ts +3 -0
  244. package/packages/omo-codex/plugin/components/rules/dist/static-injection.js +128 -0
  245. package/packages/omo-codex/plugin/components/rules/dist/tool-paths.d.ts +6 -0
  246. package/packages/omo-codex/plugin/components/rules/dist/tool-paths.js +168 -0
  247. package/packages/omo-codex/plugin/components/rules/dist/transcript-rule-filter.d.ts +4 -0
  248. package/packages/omo-codex/plugin/components/rules/dist/transcript-rule-filter.js +49 -0
  249. package/packages/omo-codex/plugin/components/rules/dist/transcript-search.d.ts +4 -0
  250. package/packages/omo-codex/plugin/components/rules/dist/transcript-search.js +91 -0
  251. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  252. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  253. package/packages/omo-codex/plugin/components/rules/src/codex-hook.ts +4 -2
  254. package/packages/omo-codex/plugin/components/rules/src/config.ts +13 -0
  255. package/packages/omo-codex/plugin/components/rules/src/event-budget.ts +17 -0
  256. package/packages/omo-codex/plugin/components/rules/src/persistent-cache.ts +4 -1
  257. package/packages/omo-codex/plugin/components/rules/src/post-compact-directive.ts +39 -0
  258. package/packages/omo-codex/plugin/components/rules/src/rules/constants.ts +16 -0
  259. package/packages/omo-codex/plugin/components/rules/src/rules/engine.ts +8 -0
  260. package/packages/omo-codex/plugin/components/rules/src/rules/formatter.ts +7 -8
  261. package/packages/omo-codex/plugin/components/rules/src/rules/truncator.ts +17 -0
  262. package/packages/omo-codex/plugin/components/rules/src/rules/types.ts +4 -0
  263. package/packages/omo-codex/plugin/components/rules/src/sparkshell-awareness.ts +53 -4
  264. package/packages/omo-codex/plugin/components/rules/src/static-injection.ts +127 -7
  265. package/packages/omo-codex/plugin/components/rules/src/transcript-rule-filter.ts +9 -1
  266. package/packages/omo-codex/plugin/components/rules/test/bundled-rules.test.ts +4 -2
  267. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-budget.test.ts +7 -2
  268. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-context.test.ts +9 -9
  269. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-dedup.test.ts +10 -4
  270. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-directive.test.ts +241 -0
  271. package/packages/omo-codex/plugin/components/rules/test/event-budget.test.ts +168 -0
  272. package/packages/omo-codex/plugin/components/rules/test/formatter.test.ts +20 -0
  273. package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +4 -0
  274. package/packages/omo-codex/plugin/components/rules/test/sparkshell-awareness.test.ts +86 -3
  275. package/packages/omo-codex/plugin/components/start-work-continuation/directive.md +15 -15
  276. package/packages/omo-codex/plugin/components/start-work-continuation/dist/boulder-reader.d.ts +16 -0
  277. package/packages/omo-codex/plugin/components/start-work-continuation/dist/boulder-reader.js +146 -0
  278. package/packages/omo-codex/plugin/components/start-work-continuation/dist/cli.d.ts +2 -0
  279. package/packages/omo-codex/plugin/components/start-work-continuation/dist/cli.js +49 -0
  280. package/packages/omo-codex/plugin/components/start-work-continuation/dist/codex-hook.d.ts +2 -0
  281. package/packages/omo-codex/plugin/components/start-work-continuation/dist/codex-hook.js +80 -0
  282. package/packages/omo-codex/plugin/components/start-work-continuation/dist/directive.d.ts +1 -0
  283. package/packages/omo-codex/plugin/components/start-work-continuation/dist/directive.js +2 -0
  284. package/packages/omo-codex/plugin/components/start-work-continuation/dist/index.d.ts +5 -0
  285. package/packages/omo-codex/plugin/components/start-work-continuation/dist/index.js +3 -0
  286. package/packages/omo-codex/plugin/components/start-work-continuation/dist/types.d.ts +20 -0
  287. package/packages/omo-codex/plugin/components/start-work-continuation/dist/types.js +1 -0
  288. package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +2 -2
  289. package/packages/omo-codex/plugin/components/start-work-continuation/package.json +1 -1
  290. package/packages/omo-codex/plugin/components/start-work-continuation/test/codex-hook.test.ts +24 -2
  291. package/packages/omo-codex/plugin/components/telemetry/dist/atomic-write.d.ts +1 -0
  292. package/packages/omo-codex/plugin/components/telemetry/dist/atomic-write.js +18 -0
  293. package/packages/omo-codex/plugin/components/telemetry/dist/cli.d.ts +2 -0
  294. package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +62 -0
  295. package/packages/omo-codex/plugin/components/telemetry/dist/codex-hook.d.ts +15 -0
  296. package/packages/omo-codex/plugin/components/telemetry/dist/codex-hook.js +42 -0
  297. package/packages/omo-codex/plugin/components/telemetry/dist/data-path.d.ts +10 -0
  298. package/packages/omo-codex/plugin/components/telemetry/dist/data-path.js +35 -0
  299. package/packages/omo-codex/plugin/components/telemetry/dist/diagnostics.d.ts +12 -0
  300. package/packages/omo-codex/plugin/components/telemetry/dist/diagnostics.js +108 -0
  301. package/packages/omo-codex/plugin/components/telemetry/dist/env-flags.d.ts +4 -0
  302. package/packages/omo-codex/plugin/components/telemetry/dist/env-flags.js +31 -0
  303. package/packages/omo-codex/plugin/components/telemetry/dist/posthog-activity-state.d.ts +8 -0
  304. package/packages/omo-codex/plugin/components/telemetry/dist/posthog-activity-state.js +68 -0
  305. package/packages/omo-codex/plugin/components/telemetry/dist/posthog.d.ts +21 -0
  306. package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +133 -0
  307. package/packages/omo-codex/plugin/components/telemetry/dist/product-identity.d.ts +8 -0
  308. package/packages/omo-codex/plugin/components/telemetry/dist/product-identity.js +29 -0
  309. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  310. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  311. package/packages/omo-codex/plugin/components/ultrawork/agents/explorer.toml +5 -13
  312. package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +61 -185
  313. package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +1 -1
  314. package/packages/omo-codex/plugin/components/ultrawork/directive.md +122 -117
  315. package/packages/omo-codex/plugin/components/ultrawork/dist/cli.d.ts +2 -0
  316. package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +48 -0
  317. package/packages/omo-codex/plugin/components/ultrawork/dist/codex-hook.d.ts +7 -0
  318. package/packages/omo-codex/plugin/components/ultrawork/dist/codex-hook.js +122 -0
  319. package/packages/omo-codex/plugin/components/ultrawork/dist/directive.d.ts +1 -0
  320. package/packages/omo-codex/plugin/components/ultrawork/dist/directive.js +2 -0
  321. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  322. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  323. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +20 -11
  324. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +17 -11
  325. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +2 -5
  326. package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +0 -71
  327. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.d.ts +16 -0
  328. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +200 -0
  329. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-arg-parser.d.ts +17 -0
  330. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-arg-parser.js +97 -0
  331. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.d.ts +4 -0
  332. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +183 -0
  333. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.d.ts +6 -0
  334. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.js +55 -0
  335. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-steering.d.ts +12 -0
  336. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-steering.js +145 -0
  337. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.d.ts +2 -0
  338. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +39 -0
  339. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.d.ts +13 -0
  340. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +100 -0
  341. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.d.ts +26 -0
  342. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.js +97 -0
  343. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-hook.d.ts +28 -0
  344. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-hook.js +145 -0
  345. package/packages/omo-codex/plugin/components/ulw-loop/dist/command-types.d.ts +34 -0
  346. package/packages/omo-codex/plugin/components/ulw-loop/dist/command-types.js +1 -0
  347. package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.d.ts +16 -0
  348. package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.js +41 -0
  349. package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.d.ts +95 -0
  350. package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.js +1 -0
  351. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.d.ts +31 -0
  352. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.js +119 -0
  353. package/packages/omo-codex/plugin/components/ulw-loop/dist/goal-status.d.ts +12 -0
  354. package/packages/omo-codex/plugin/components/ulw-loop/dist/goal-status.js +69 -0
  355. package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.d.ts +16 -0
  356. package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.js +59 -0
  357. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.d.ts +48 -0
  358. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.js +119 -0
  359. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.d.ts +8 -0
  360. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.js +89 -0
  361. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.d.ts +6 -0
  362. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.js +123 -0
  363. package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.d.ts +16 -0
  364. package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.js +70 -0
  365. package/packages/omo-codex/plugin/components/ulw-loop/dist/runtime.d.ts +10 -0
  366. package/packages/omo-codex/plugin/components/ulw-loop/dist/runtime.js +13 -0
  367. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.d.ts +63 -0
  368. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.js +1 -0
  369. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.d.ts +6 -0
  370. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.js +292 -0
  371. package/packages/omo-codex/plugin/components/ulw-loop/dist/types.d.ts +5 -0
  372. package/packages/omo-codex/plugin/components/ulw-loop/dist/types.js +5 -0
  373. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +2 -2
  374. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  375. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +14 -14
  376. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +24 -25
  377. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +17 -3
  378. package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +2 -1
  379. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +1 -1
  380. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-entrypoint.test.ts +95 -0
  381. package/packages/omo-codex/plugin/components/ulw-loop/test/package-smoke.test.ts +0 -96
  382. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate.test.ts +23 -0
  383. package/packages/omo-codex/plugin/components/ulw-loop/test/skill-contract.test.ts +46 -0
  384. package/packages/omo-codex/plugin/hooks/hooks.json +16 -16
  385. package/packages/omo-codex/plugin/package-lock.json +10 -9
  386. package/packages/omo-codex/plugin/package.json +27 -26
  387. package/packages/omo-codex/plugin/scripts/auto-update.mjs +64 -15
  388. package/packages/omo-codex/plugin/scripts/build-bundled-mcp-runtimes.mjs +16 -0
  389. package/packages/omo-codex/plugin/scripts/migrate-codex-config/multi-agent-v2-guard.mjs +104 -0
  390. package/packages/omo-codex/plugin/scripts/migrate-codex-config.mjs +23 -6
  391. package/packages/omo-codex/plugin/scripts/sync-skills.mjs +23 -11
  392. package/packages/omo-codex/plugin/scripts/sync-version.mjs +94 -0
  393. package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +9 -9
  394. package/packages/omo-codex/plugin/skills/lcx-contribute-bug-fix/SKILL.md +16 -1
  395. package/packages/omo-codex/plugin/skills/lcx-doctor/SKILL.md +93 -0
  396. package/packages/omo-codex/plugin/skills/lcx-doctor/agents/openai.yaml +11 -0
  397. package/packages/omo-codex/plugin/skills/lcx-report-bug/SKILL.md +17 -13
  398. package/packages/omo-codex/plugin/skills/lsp-setup/SKILL.md +139 -0
  399. package/packages/omo-codex/plugin/skills/lsp-setup/references/bash/README.md +60 -0
  400. package/packages/omo-codex/plugin/skills/lsp-setup/references/c-cpp/README.md +61 -0
  401. package/packages/omo-codex/plugin/skills/lsp-setup/references/csharp/README.md +71 -0
  402. package/packages/omo-codex/plugin/skills/lsp-setup/references/dart/README.md +48 -0
  403. package/packages/omo-codex/plugin/skills/lsp-setup/references/elixir/README.md +51 -0
  404. package/packages/omo-codex/plugin/skills/lsp-setup/references/go/README.md +57 -0
  405. package/packages/omo-codex/plugin/skills/lsp-setup/references/haskell/README.md +57 -0
  406. package/packages/omo-codex/plugin/skills/lsp-setup/references/java/README.md +57 -0
  407. package/packages/omo-codex/plugin/skills/lsp-setup/references/julia/README.md +60 -0
  408. package/packages/omo-codex/plugin/skills/lsp-setup/references/kotlin/README.md +59 -0
  409. package/packages/omo-codex/plugin/skills/lsp-setup/references/lua/README.md +66 -0
  410. package/packages/omo-codex/plugin/skills/lsp-setup/references/php/README.md +62 -0
  411. package/packages/omo-codex/plugin/skills/lsp-setup/references/python/README.md +71 -0
  412. package/packages/omo-codex/plugin/skills/lsp-setup/references/ruby/README.md +53 -0
  413. package/packages/omo-codex/plugin/skills/lsp-setup/references/rust/README.md +59 -0
  414. package/packages/omo-codex/plugin/skills/lsp-setup/references/swift/README.md +51 -0
  415. package/packages/omo-codex/plugin/skills/lsp-setup/references/terraform/README.md +62 -0
  416. package/packages/omo-codex/plugin/skills/lsp-setup/references/typescript/README.md +77 -0
  417. package/packages/omo-codex/plugin/skills/lsp-setup/references/yaml/README.md +70 -0
  418. package/packages/omo-codex/plugin/skills/lsp-setup/references/zig/README.md +49 -0
  419. package/packages/omo-codex/plugin/skills/lsp-setup/scripts/detect-lsp.ts +210 -0
  420. package/packages/omo-codex/plugin/skills/lsp-setup/scripts/lsp-server-table.ts +177 -0
  421. package/packages/omo-codex/plugin/skills/lsp-setup/scripts/tsconfig.json +17 -0
  422. package/packages/omo-codex/plugin/skills/lsp-setup/scripts/verify-lsp.ts +147 -0
  423. package/packages/omo-codex/plugin/skills/refactor/SKILL.md +9 -9
  424. package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +10 -10
  425. package/packages/omo-codex/plugin/skills/review-work/SKILL.md +20 -22
  426. package/packages/omo-codex/plugin/skills/start-work/SKILL.md +38 -61
  427. package/packages/omo-codex/plugin/skills/ultraresearch/SKILL.md +135 -677
  428. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +14 -14
  429. package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +24 -25
  430. package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +20 -11
  431. package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +17 -11
  432. package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +9 -9
  433. package/packages/omo-codex/plugin/test/aggregate-build.test.mjs +2 -1
  434. package/packages/omo-codex/plugin/test/aggregate-mcp.test.mjs +1 -1
  435. package/packages/omo-codex/plugin/test/aggregate-plugin-fixture.mjs +5 -5
  436. package/packages/omo-codex/plugin/test/aggregate-skills.test.mjs +6 -6
  437. package/packages/omo-codex/plugin/test/auto-update-restart-notice.test.mjs +194 -0
  438. package/packages/omo-codex/plugin/test/auto-update.test.mjs +17 -0
  439. package/packages/omo-codex/plugin/test/lcx-bug-skills.test.mjs +15 -44
  440. package/packages/omo-codex/plugin/test/lsp-prebuild-layouts.test.mjs +140 -0
  441. package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +261 -0
  442. package/packages/omo-codex/plugin/test/start-work-skill.test.mjs +9 -31
  443. package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +68 -4
  444. package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +119 -0
  445. package/packages/omo-codex/plugin/test/sync-skills.test.mjs +11 -112
  446. package/packages/omo-codex/plugin/test/sync-version.test.mjs +68 -0
  447. package/packages/omo-codex/plugin/test/ultraresearch-skill-contract.test.mjs +126 -0
  448. package/packages/omo-codex/plugin/test/ulw-plan-skill.test.mjs +2 -2
  449. package/packages/omo-codex/scripts/install/bin-dir.mjs +20 -0
  450. package/packages/omo-codex/scripts/install/bin-links.mjs +43 -6
  451. package/packages/omo-codex/scripts/install/cache.mjs +4 -0
  452. package/packages/omo-codex/scripts/install/config.mjs +5 -3
  453. package/packages/omo-codex/scripts/install/delegated-command.mjs +5 -1
  454. package/packages/omo-codex/scripts/install/git-bash-mcp-env.mjs +28 -0
  455. package/packages/omo-codex/scripts/install/git-bash.mjs +12 -4
  456. package/packages/omo-codex/scripts/install/git-bash.test.mjs +39 -4
  457. package/packages/omo-codex/scripts/install/hook-targets.mjs +46 -0
  458. package/packages/omo-codex/scripts/install/multi-agent-v2-config.mjs +22 -10
  459. package/packages/omo-codex/scripts/install/process.mjs +1 -0
  460. package/packages/omo-codex/scripts/install-bin-links.test.mjs +131 -3
  461. package/packages/omo-codex/scripts/install-config-git-bash.test.mjs +91 -0
  462. package/packages/omo-codex/scripts/install-config.test.mjs +50 -44
  463. package/packages/omo-codex/scripts/install-delegated-command.test.mjs +78 -0
  464. package/packages/omo-codex/scripts/install-git-bash-mcp-env.test.mjs +93 -0
  465. package/packages/omo-codex/scripts/install-hook-targets.test.mjs +100 -0
  466. package/packages/omo-codex/scripts/install-lazycodex-version-stamp.test.mjs +3 -1
  467. package/packages/omo-codex/scripts/install-local.mjs +7 -18
  468. package/packages/omo-codex/scripts/install-local.test.mjs +34 -1
  469. package/packages/shared-skills/skills/lcx-contribute-bug-fix/SKILL.md +16 -1
  470. package/packages/shared-skills/skills/lcx-doctor/SKILL.md +93 -0
  471. package/packages/shared-skills/skills/lcx-doctor/agents/openai.yaml +11 -0
  472. package/packages/shared-skills/skills/lcx-report-bug/SKILL.md +17 -13
  473. package/packages/shared-skills/skills/lsp-setup/SKILL.md +139 -0
  474. package/packages/shared-skills/skills/lsp-setup/references/bash/README.md +60 -0
  475. package/packages/shared-skills/skills/lsp-setup/references/c-cpp/README.md +61 -0
  476. package/packages/shared-skills/skills/lsp-setup/references/csharp/README.md +71 -0
  477. package/packages/shared-skills/skills/lsp-setup/references/dart/README.md +48 -0
  478. package/packages/shared-skills/skills/lsp-setup/references/elixir/README.md +51 -0
  479. package/packages/shared-skills/skills/lsp-setup/references/go/README.md +57 -0
  480. package/packages/shared-skills/skills/lsp-setup/references/haskell/README.md +57 -0
  481. package/packages/shared-skills/skills/lsp-setup/references/java/README.md +57 -0
  482. package/packages/shared-skills/skills/lsp-setup/references/julia/README.md +60 -0
  483. package/packages/shared-skills/skills/lsp-setup/references/kotlin/README.md +59 -0
  484. package/packages/shared-skills/skills/lsp-setup/references/lua/README.md +66 -0
  485. package/packages/shared-skills/skills/lsp-setup/references/php/README.md +62 -0
  486. package/packages/shared-skills/skills/lsp-setup/references/python/README.md +71 -0
  487. package/packages/shared-skills/skills/lsp-setup/references/ruby/README.md +53 -0
  488. package/packages/shared-skills/skills/lsp-setup/references/rust/README.md +59 -0
  489. package/packages/shared-skills/skills/lsp-setup/references/swift/README.md +51 -0
  490. package/packages/shared-skills/skills/lsp-setup/references/terraform/README.md +62 -0
  491. package/packages/shared-skills/skills/lsp-setup/references/typescript/README.md +77 -0
  492. package/packages/shared-skills/skills/lsp-setup/references/yaml/README.md +70 -0
  493. package/packages/shared-skills/skills/lsp-setup/references/zig/README.md +49 -0
  494. package/packages/shared-skills/skills/lsp-setup/scripts/detect-lsp.ts +210 -0
  495. package/packages/shared-skills/skills/lsp-setup/scripts/lsp-server-table.ts +177 -0
  496. package/packages/shared-skills/skills/lsp-setup/scripts/tsconfig.json +17 -0
  497. package/packages/shared-skills/skills/lsp-setup/scripts/verify-lsp.ts +147 -0
  498. package/packages/shared-skills/skills/remove-ai-slops/SKILL.md +1 -1
  499. package/packages/shared-skills/skills/review-work/SKILL.md +10 -14
  500. package/packages/shared-skills/skills/start-work/SKILL.md +30 -59
  501. package/packages/shared-skills/skills/ultraresearch/SKILL.md +126 -667
  502. package/dist/hooks/anthropic-effort/hook.d.ts +0 -26
  503. package/dist/hooks/anthropic-effort/index.d.ts +0 -1
  504. package/dist/hooks/keyword-detector/analyze/default.d.ts +0 -12
  505. package/dist/hooks/keyword-detector/analyze/index.d.ts +0 -1
  506. package/dist/hooks/keyword-detector/search/default.d.ts +0 -12
  507. package/dist/hooks/keyword-detector/search/index.d.ts +0 -1
  508. package/dist/hooks/thinking-block-validator/hook.d.ts +0 -12
  509. package/dist/hooks/thinking-block-validator/index.d.ts +0 -1
  510. package/packages/omo-codex/plugin/components/ultrawork/test/directive-contract.test.ts +0 -18
  511. package/packages/omo-codex/plugin/test/global-review-debug-gate.test.mjs +0 -29
  512. package/packages/omo-codex/plugin/test/subagent-guidance.test.mjs +0 -151
@@ -0,0 +1,80 @@
1
+ import { readContinuationState } from "./boulder-reader.js";
2
+ import { START_WORK_CONTINUATION_DIRECTIVE } from "./directive.js";
3
+ export function runStopHook(input, fs) {
4
+ if (!isStopInput(input))
5
+ return "";
6
+ if (input.stop_hook_active)
7
+ return "";
8
+ if (transcriptHasContextPressureMarker(input.transcript_path, fs))
9
+ return "";
10
+ const state = readContinuationState(input.cwd, input.session_id, fs);
11
+ if (state === null)
12
+ return "";
13
+ return JSON.stringify({
14
+ decision: "block",
15
+ reason: renderDirective(state, input.session_id),
16
+ });
17
+ }
18
+ function renderDirective(state, sessionId) {
19
+ const lineBreak = String.fromCharCode(10);
20
+ const worktreeBlock = state.worktreePath === null
21
+ ? ""
22
+ : `${lineBreak}- Worktree: \`${state.worktreePath}\` (all edits, tests, and commands run inside this directory)`;
23
+ const replacements = {
24
+ PLAN_NAME: state.planName,
25
+ PLAN_PATH: state.planPath,
26
+ BOULDER_PATH: state.boulderPath,
27
+ REMAINING_COUNT: String(state.checklist.remaining),
28
+ TOTAL_COUNT: String(state.checklist.total),
29
+ NEXT_TASK_LABEL: state.checklist.nextTaskLabel ?? "",
30
+ WORKTREE_BLOCK: worktreeBlock,
31
+ LEDGER_PATH: state.ledgerPath,
32
+ SESSION_ID: sessionId,
33
+ };
34
+ let rendered = START_WORK_CONTINUATION_DIRECTIVE;
35
+ for (const [placeholder, value] of Object.entries(replacements)) {
36
+ rendered = rendered.replaceAll(`{{${placeholder}}}`, value);
37
+ }
38
+ return rendered;
39
+ }
40
+ const CONTEXT_PRESSURE_MARKERS = [
41
+ "context compacted",
42
+ "context_length_exceeded",
43
+ "skill descriptions were shortened",
44
+ "context_too_large",
45
+ "codex ran out of room in the model's context window",
46
+ "your input exceeds the context window",
47
+ "long threads and multiple compactions",
48
+ ];
49
+ function transcriptHasContextPressureMarker(transcriptPath, fs) {
50
+ try {
51
+ const transcript = fs.readFileSync(transcriptPath, "utf8").toLowerCase();
52
+ return CONTEXT_PRESSURE_MARKERS.some((marker) => transcript.includes(marker));
53
+ }
54
+ catch (error) {
55
+ if (error instanceof Error)
56
+ return false;
57
+ throw error;
58
+ }
59
+ }
60
+ function isStopInput(value) {
61
+ return (isRecord(value) &&
62
+ isStopHookEventName(value["hook_event_name"]) &&
63
+ typeof value["session_id"] === "string" &&
64
+ typeof value["turn_id"] === "string" &&
65
+ typeof value["transcript_path"] === "string" &&
66
+ typeof value["cwd"] === "string" &&
67
+ typeof value["model"] === "string" &&
68
+ typeof value["permission_mode"] === "string" &&
69
+ typeof value["stop_hook_active"] === "boolean" &&
70
+ optionalString(value["last_assistant_message"]));
71
+ }
72
+ function isStopHookEventName(value) {
73
+ return value === "Stop" || value === "SubagentStop";
74
+ }
75
+ function optionalString(value) {
76
+ return value === undefined || typeof value === "string";
77
+ }
78
+ function isRecord(value) {
79
+ return typeof value === "object" && value !== null && !Array.isArray(value);
80
+ }
@@ -0,0 +1 @@
1
+ export declare const START_WORK_CONTINUATION_DIRECTIVE: string;
@@ -0,0 +1,2 @@
1
+ import { readFileSync } from "node:fs";
2
+ export const START_WORK_CONTINUATION_DIRECTIVE = readFileSync(new URL("../directive.md", import.meta.url), "utf8");
@@ -0,0 +1,5 @@
1
+ export type { ContinuationState, PlanChecklist } from "./boulder-reader.js";
2
+ export { parsePlanChecklist, readContinuationState } from "./boulder-reader.js";
3
+ export { runStopHook } from "./codex-hook.js";
4
+ export { START_WORK_CONTINUATION_DIRECTIVE } from "./directive.js";
5
+ export type { ReadonlyFileSystem, StopHookEventName, StopHookOutput, StopInput } from "./types.js";
@@ -0,0 +1,3 @@
1
+ export { parsePlanChecklist, readContinuationState } from "./boulder-reader.js";
2
+ export { runStopHook } from "./codex-hook.js";
3
+ export { START_WORK_CONTINUATION_DIRECTIVE } from "./directive.js";
@@ -0,0 +1,20 @@
1
+ export declare const STOP_HOOK_EVENTS: readonly ["Stop", "SubagentStop"];
2
+ export type StopHookEventName = (typeof STOP_HOOK_EVENTS)[number];
3
+ export type StopInput = {
4
+ readonly hook_event_name: StopHookEventName;
5
+ readonly session_id: string;
6
+ readonly turn_id: string;
7
+ readonly transcript_path: string;
8
+ readonly cwd: string;
9
+ readonly model: string;
10
+ readonly permission_mode: string;
11
+ readonly stop_hook_active: boolean;
12
+ readonly last_assistant_message?: string;
13
+ };
14
+ export type StopHookOutput = {
15
+ readonly decision: "block";
16
+ readonly reason: string;
17
+ };
18
+ export type ReadonlyFileSystem = {
19
+ readFileSync(path: string, encoding: "utf8"): string;
20
+ };
@@ -0,0 +1 @@
1
+ export const STOP_HOOK_EVENTS = ["Stop", "SubagentStop"];
@@ -7,7 +7,7 @@
7
7
  "type": "command",
8
8
  "command": "node \"${PLUGIN_ROOT}/components/start-work-continuation/dist/cli.js\" hook stop",
9
9
  "timeout": 10,
10
- "statusMessage": "LazyCodex(0.1.0): Checking Start-Work Continuation"
10
+ "statusMessage": "LazyCodex(4.9.0): Checking Start-Work Continuation"
11
11
  }
12
12
  ]
13
13
  }
@@ -19,7 +19,7 @@
19
19
  "type": "command",
20
20
  "command": "node \"${PLUGIN_ROOT}/components/start-work-continuation/dist/cli.js\" hook subagent-stop",
21
21
  "timeout": 10,
22
- "statusMessage": "LazyCodex(0.1.0): Checking Start-Work Continuation"
22
+ "statusMessage": "LazyCodex(4.9.0): Checking Start-Work Continuation"
23
23
  }
24
24
  ]
25
25
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/codex-start-work-continuation",
3
- "version": "0.1.0",
3
+ "version": "4.9.0",
4
4
  "description": "Codex Stop hook continuation injector for omo-codex start-work plans.",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.12.1",
@@ -112,12 +112,34 @@ describe("start-work Stop hook", () => {
112
112
  // then
113
113
  const parsed = parseBlockOutput(output);
114
114
  expect(parsed.reason).toMatch(/TASK:/);
115
- expect(parsed.reason).toMatch(/fork_turns:\s*"none"/);
115
+ expect(parsed.reason).toMatch(/fork_context:\s*false/);
116
116
  expect(parsed.reason).toMatch(/wait_agent.*mailbox signals/);
117
117
  expect(parsed.reason).toMatch(/TASK STILL ACTIVE/);
118
118
  expect(parsed.reason).toMatch(/respawn.*smaller/);
119
119
  expect(parsed.reason).toMatch(/WORKING:/);
120
- expect(parsed.reason).toMatch(/single `list_agents`/);
120
+ });
121
+
122
+ it("#given active codex work #when continuation directive is emitted #then QA weight is tier-scoped without echo bloat", () => {
123
+ // given
124
+ const fs = createMemoryFs({
125
+ [BOULDER_PATH]: createBoulderJson({
126
+ sessionIds: ["codex:sess_abc"],
127
+ status: "active",
128
+ }),
129
+ [PLAN_PATH]: ["# Plan", "", "## TODOs", "- [ ] First"].join("\n"),
130
+ });
131
+
132
+ // when
133
+ const output = runStopHook(createStopInput(), fs);
134
+
135
+ // then
136
+ const parsed = parseBlockOutput(output);
137
+ expect(parsed.reason).toMatch(/LIGHT/);
138
+ expect(parsed.reason).toMatch(/HEAVY/);
139
+ expect(parsed.reason).toMatch(/When unsure[^.]{0,30}HEAVY/);
140
+ expect(parsed.reason).toMatch(/mirrors its implementation/);
141
+ expect((parsed.reason.match(/malformed input, prompt injection/g) ?? []).length).toBe(1);
142
+ expect(parsed.reason.split(/\s+/).filter(Boolean).length).toBeLessThanOrEqual(1100);
121
143
  });
122
144
 
123
145
  it("#given active work belongs to another harness #when hook runs #then returns empty output", () => {
@@ -0,0 +1 @@
1
+ export declare function writeFileAtomically(filePath: string, content: string): void;
@@ -0,0 +1,18 @@
1
+ import { renameSync, unlinkSync, writeFileSync } from "node:fs";
2
+ export function writeFileAtomically(filePath, content) {
3
+ const tempPath = `${filePath}.tmp`;
4
+ writeFileSync(tempPath, content, "utf-8");
5
+ try {
6
+ renameSync(tempPath, filePath);
7
+ }
8
+ catch (error) {
9
+ const isPermissionError = error instanceof Error &&
10
+ (error.message.includes("EPERM") || error.message.includes("EACCES"));
11
+ if (process.platform === "win32" && isPermissionError) {
12
+ unlinkSync(filePath);
13
+ renameSync(tempPath, filePath);
14
+ return;
15
+ }
16
+ throw error;
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ import { stdin as processStdin, stdout as processStdout } from "node:process";
3
+ import { runSessionStartHook } from "./codex-hook.js";
4
+ const command = process.argv[2];
5
+ const subcommand = process.argv[3];
6
+ if (command === "hook" && subcommand === "session-start") {
7
+ await runHookCli();
8
+ }
9
+ else {
10
+ process.stderr.write("Usage: omo-telemetry hook session-start\n");
11
+ process.exitCode = 1;
12
+ }
13
+ async function runHookCli() {
14
+ const raw = await readStdin();
15
+ if (raw.trim().length === 0)
16
+ return;
17
+ const parsed = parseHookInput(raw);
18
+ if (!isCodexSessionStartInput(parsed))
19
+ return;
20
+ const output = await runSessionStartHook(parsed);
21
+ if (output.length > 0) {
22
+ processStdout.write(output);
23
+ }
24
+ }
25
+ function parseHookInput(raw) {
26
+ try {
27
+ const parsed = JSON.parse(raw);
28
+ return parsed;
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ }
34
+ function isCodexSessionStartInput(value) {
35
+ return (isRecord(value) &&
36
+ value["hook_event_name"] === "SessionStart" &&
37
+ typeof value["session_id"] === "string" &&
38
+ isStringOrNull(value["transcript_path"]) &&
39
+ typeof value["cwd"] === "string" &&
40
+ typeof value["model"] === "string" &&
41
+ typeof value["permission_mode"] === "string" &&
42
+ typeof value["source"] === "string");
43
+ }
44
+ function isStringOrNull(value) {
45
+ return typeof value === "string" || value === null;
46
+ }
47
+ function isRecord(value) {
48
+ return typeof value === "object" && value !== null && !Array.isArray(value);
49
+ }
50
+ function readStdin() {
51
+ return new Promise((resolve, reject) => {
52
+ let data = "";
53
+ processStdin.setEncoding("utf8");
54
+ processStdin.on("data", (chunk) => {
55
+ data += chunk;
56
+ });
57
+ processStdin.once("error", reject);
58
+ processStdin.once("end", () => {
59
+ resolve(data);
60
+ });
61
+ });
62
+ }
@@ -0,0 +1,15 @@
1
+ import { type PostHogClient } from "./posthog.js";
2
+ export type CodexSessionStartInput = {
3
+ session_id: string;
4
+ transcript_path: string | null;
5
+ cwd: string;
6
+ hook_event_name: "SessionStart";
7
+ model: string;
8
+ permission_mode: string;
9
+ source: "startup" | "resume" | "clear";
10
+ };
11
+ export type CodexTelemetryHookOptions = {
12
+ createClient?: () => PostHogClient | Promise<PostHogClient>;
13
+ getDistinctId?: () => string;
14
+ };
15
+ export declare function runSessionStartHook(_input: CodexSessionStartInput, options?: CodexTelemetryHookOptions): Promise<string>;
@@ -0,0 +1,42 @@
1
+ import { writeTelemetryDiagnostic, } from "./diagnostics.js";
2
+ import { createPluginPostHog, getPostHogDistinctId, } from "./posthog.js";
3
+ const SESSION_START_REASON = "session_start";
4
+ function writeHookDiagnostic(event, error, errorKind) {
5
+ writeTelemetryDiagnostic({
6
+ event,
7
+ source: "plugin",
8
+ error,
9
+ errorKind,
10
+ });
11
+ }
12
+ export async function runSessionStartHook(_input, options = {}) {
13
+ const createClient = options.createClient ?? createPluginPostHog;
14
+ const getDistinctId = options.getDistinctId ?? getPostHogDistinctId;
15
+ let client;
16
+ try {
17
+ client = await createClient();
18
+ }
19
+ catch (error) {
20
+ writeHookDiagnostic("telemetry_posthog_init_failed", error, error instanceof Error ? "error" : "non_error");
21
+ return "";
22
+ }
23
+ try {
24
+ client.trackActive(getDistinctId(), SESSION_START_REASON);
25
+ }
26
+ catch (error) {
27
+ writeHookDiagnostic("telemetry_capture_failed", error, error instanceof Error ? "error" : "non_error");
28
+ await safeShutdown(client);
29
+ return "";
30
+ }
31
+ await safeShutdown(client);
32
+ return "";
33
+ }
34
+ async function safeShutdown(client) {
35
+ try {
36
+ await client.shutdown();
37
+ }
38
+ catch (error) {
39
+ writeHookDiagnostic("telemetry_shutdown_failed", error, error instanceof Error ? "error" : "non_error");
40
+ return;
41
+ }
42
+ }
@@ -0,0 +1,10 @@
1
+ import os from "node:os";
2
+ type OsProvider = Pick<typeof os, "homedir" | "tmpdir">;
3
+ export declare function getOsProvider(): OsProvider;
4
+ /** @internal test-only */
5
+ export declare function __setOsProviderForTesting(provider: OsProvider): void;
6
+ /** @internal test-only */
7
+ export declare function __resetOsProviderForTesting(): void;
8
+ export declare function getDataDir(): string;
9
+ export declare function getActivityStateDir(): string;
10
+ export {};
@@ -0,0 +1,35 @@
1
+ import { accessSync, constants, mkdirSync } from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { CACHE_DIR_NAME } from "./product-identity.js";
5
+ let osProviderOverride = null;
6
+ export function getOsProvider() {
7
+ return osProviderOverride ?? os;
8
+ }
9
+ /** @internal test-only */
10
+ export function __setOsProviderForTesting(provider) {
11
+ osProviderOverride = provider;
12
+ }
13
+ /** @internal test-only */
14
+ export function __resetOsProviderForTesting() {
15
+ osProviderOverride = null;
16
+ }
17
+ function resolveWritableDirectory(preferredDir, fallbackSuffix) {
18
+ try {
19
+ mkdirSync(preferredDir, { recursive: true });
20
+ accessSync(preferredDir, constants.W_OK);
21
+ return preferredDir;
22
+ }
23
+ catch {
24
+ const fallbackDir = path.join(getOsProvider().tmpdir(), fallbackSuffix);
25
+ mkdirSync(fallbackDir, { recursive: true });
26
+ return fallbackDir;
27
+ }
28
+ }
29
+ export function getDataDir() {
30
+ const preferredDataDir = process.env["XDG_DATA_HOME"] ?? path.join(getOsProvider().homedir(), ".local", "share");
31
+ return resolveWritableDirectory(preferredDataDir, "omo-codex-data");
32
+ }
33
+ export function getActivityStateDir() {
34
+ return path.join(getDataDir(), CACHE_DIR_NAME);
35
+ }
@@ -0,0 +1,12 @@
1
+ export type TelemetryDiagnosticEvent = "telemetry_activity_state_read_failed" | "telemetry_activity_state_write_failed" | "telemetry_capture_failed" | "telemetry_cpu_info_unavailable" | "telemetry_posthog_import_failed" | "telemetry_posthog_init_failed" | "telemetry_shutdown_failed";
2
+ export type TelemetryDiagnosticSource = "cli" | "install" | "plugin" | "shared";
3
+ export type TelemetryDiagnosticErrorKind = "error" | "non_error";
4
+ export type TelemetryDiagnosticInput = {
5
+ readonly event: TelemetryDiagnosticEvent;
6
+ readonly source: TelemetryDiagnosticSource;
7
+ readonly error?: unknown;
8
+ readonly errorKind?: TelemetryDiagnosticErrorKind;
9
+ };
10
+ export declare function getTelemetryDiagnosticsFilePath(): string;
11
+ export declare function writeTelemetryDiagnostic(input: TelemetryDiagnosticInput, now?: Date): void;
12
+ export declare function cleanupTelemetryDiagnostics(now?: Date): void;
@@ -0,0 +1,108 @@
1
+ import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { writeFileAtomically } from "./atomic-write.js";
4
+ import { getActivityStateDir } from "./data-path.js";
5
+ const DIAGNOSTICS_FILE_NAME = "telemetry-diagnostics.jsonl";
6
+ const DIAGNOSTICS_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
7
+ const DIAGNOSTICS_MAX_BYTES = 256 * 1024;
8
+ export function getTelemetryDiagnosticsFilePath() {
9
+ return join(getActivityStateDir(), DIAGNOSTICS_FILE_NAME);
10
+ }
11
+ export function writeTelemetryDiagnostic(input, now = new Date()) {
12
+ try {
13
+ cleanupTelemetryDiagnostics(now);
14
+ mkdirSync(getActivityStateDir(), { recursive: true });
15
+ appendFileSync(getTelemetryDiagnosticsFilePath(), `${JSON.stringify(toDiagnosticRecord(input, now))}\n`, "utf-8");
16
+ }
17
+ catch {
18
+ return;
19
+ }
20
+ }
21
+ export function cleanupTelemetryDiagnostics(now = new Date()) {
22
+ const diagnosticsFilePath = getTelemetryDiagnosticsFilePath();
23
+ if (!existsSync(diagnosticsFilePath)) {
24
+ return;
25
+ }
26
+ try {
27
+ const cutoffMs = now.getTime() - DIAGNOSTICS_RETENTION_MS;
28
+ const retainedLines = trimToMaxBytes(readFileSync(diagnosticsFilePath, "utf-8")
29
+ .split("\n")
30
+ .filter((line) => shouldRetainLine(line, cutoffMs)));
31
+ writeFileAtomically(diagnosticsFilePath, retainedLines.length === 0 ? "" : `${retainedLines.join("\n")}\n`);
32
+ }
33
+ catch {
34
+ return;
35
+ }
36
+ }
37
+ function toDiagnosticRecord(input, now) {
38
+ return {
39
+ timestamp: now.toISOString(),
40
+ event: input.event,
41
+ source: input.source,
42
+ ...serializeError(input.error, input.errorKind),
43
+ };
44
+ }
45
+ function serializeError(error, errorKind) {
46
+ if (error instanceof Error) {
47
+ return {
48
+ error_kind: errorKind ?? "error",
49
+ error_name: error.name,
50
+ error_message: error.message,
51
+ };
52
+ }
53
+ if (error === undefined) {
54
+ return {};
55
+ }
56
+ return {
57
+ error_kind: errorKind ?? "non_error",
58
+ error_name: typeof error,
59
+ error_message: String(error),
60
+ };
61
+ }
62
+ function shouldRetainLine(line, cutoffMs) {
63
+ if (line.length === 0) {
64
+ return false;
65
+ }
66
+ const parsed = parseDiagnosticLine(line);
67
+ if (parsed === null) {
68
+ return false;
69
+ }
70
+ const timestamp = parsed["timestamp"];
71
+ if (typeof timestamp !== "string") {
72
+ return false;
73
+ }
74
+ const timestampMs = Date.parse(timestamp);
75
+ return Number.isFinite(timestampMs) && timestampMs >= cutoffMs;
76
+ }
77
+ function parseDiagnosticLine(line) {
78
+ try {
79
+ const parsed = JSON.parse(line);
80
+ if (!isRecord(parsed)) {
81
+ return null;
82
+ }
83
+ return parsed;
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ }
89
+ function isRecord(value) {
90
+ return value !== null && typeof value === "object" && !Array.isArray(value);
91
+ }
92
+ function trimToMaxBytes(lines) {
93
+ const retained = [];
94
+ let totalBytes = 0;
95
+ for (let index = lines.length - 1; index >= 0; index -= 1) {
96
+ const line = lines[index];
97
+ if (line === undefined) {
98
+ continue;
99
+ }
100
+ const lineBytes = Buffer.byteLength(`${line}\n`, "utf-8");
101
+ if (totalBytes + lineBytes > DIAGNOSTICS_MAX_BYTES) {
102
+ break;
103
+ }
104
+ retained.unshift(line);
105
+ totalBytes += lineBytes;
106
+ }
107
+ return retained;
108
+ }
@@ -0,0 +1,4 @@
1
+ export declare function shouldDisablePostHog(): boolean;
2
+ export declare function getPostHogApiKey(): string;
3
+ export declare function hasPostHogApiKey(): boolean;
4
+ export declare function getPostHogHost(): string;
@@ -0,0 +1,31 @@
1
+ import { DEFAULT_POSTHOG_API_KEY, DEFAULT_POSTHOG_HOST, } from "./product-identity.js";
2
+ function normalizeEnvValue(value) {
3
+ return value?.trim().toLowerCase();
4
+ }
5
+ function isDisableFlag(value) {
6
+ const normalized = normalizeEnvValue(value);
7
+ return normalized === "1" || normalized === "true";
8
+ }
9
+ function isTelemetryOptOutFlag(value) {
10
+ const normalized = normalizeEnvValue(value);
11
+ return normalized === "0" || normalized === "false" || normalized === "no";
12
+ }
13
+ export function shouldDisablePostHog() {
14
+ return (isDisableFlag(process.env["OMO_DISABLE_POSTHOG"]) ||
15
+ isTelemetryOptOutFlag(process.env["OMO_SEND_ANONYMOUS_TELEMETRY"]) ||
16
+ isDisableFlag(process.env["OMO_CODEX_DISABLE_POSTHOG"]) ||
17
+ isTelemetryOptOutFlag(process.env["OMO_CODEX_SEND_ANONYMOUS_TELEMETRY"]));
18
+ }
19
+ export function getPostHogApiKey() {
20
+ const explicit = process.env["POSTHOG_API_KEY"];
21
+ if (explicit === undefined) {
22
+ return DEFAULT_POSTHOG_API_KEY;
23
+ }
24
+ return explicit.trim();
25
+ }
26
+ export function hasPostHogApiKey() {
27
+ return getPostHogApiKey().length > 0;
28
+ }
29
+ export function getPostHogHost() {
30
+ return process.env["POSTHOG_HOST"]?.trim() || DEFAULT_POSTHOG_HOST;
31
+ }
@@ -0,0 +1,8 @@
1
+ export type PostHogActivityState = {
2
+ readonly lastActiveDayUTC?: string;
3
+ };
4
+ export type PostHogActivityCaptureState = {
5
+ readonly dayUTC: string;
6
+ readonly captureDaily: boolean;
7
+ };
8
+ export declare function getPostHogActivityCaptureState(now?: Date): PostHogActivityCaptureState;
@@ -0,0 +1,68 @@
1
+ import { existsSync, mkdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { writeFileAtomically } from "./atomic-write.js";
4
+ import { getActivityStateDir } from "./data-path.js";
5
+ import { writeTelemetryDiagnostic } from "./diagnostics.js";
6
+ const POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
7
+ function getPostHogActivityStateFilePath() {
8
+ return join(getActivityStateDir(), POSTHOG_ACTIVITY_STATE_FILE);
9
+ }
10
+ function getUtcDayString(date) {
11
+ return date.toISOString().slice(0, 10);
12
+ }
13
+ function isPostHogActivityState(value) {
14
+ return value !== null && typeof value === "object" && !Array.isArray(value);
15
+ }
16
+ function writeActivityStateDiagnostic(event, error, errorKind) {
17
+ writeTelemetryDiagnostic({
18
+ event,
19
+ source: "shared",
20
+ error,
21
+ errorKind,
22
+ });
23
+ }
24
+ function readPostHogActivityState() {
25
+ const stateFilePath = getPostHogActivityStateFilePath();
26
+ if (!existsSync(stateFilePath)) {
27
+ return {};
28
+ }
29
+ try {
30
+ const stateContent = readFileSync(stateFilePath, "utf-8");
31
+ const stateJson = JSON.parse(stateContent);
32
+ if (!isPostHogActivityState(stateJson)) {
33
+ return {};
34
+ }
35
+ return stateJson;
36
+ }
37
+ catch (error) {
38
+ writeActivityStateDiagnostic("telemetry_activity_state_read_failed", error, error instanceof Error ? "error" : "non_error");
39
+ return {};
40
+ }
41
+ }
42
+ function writePostHogActivityState(nextState) {
43
+ const stateDir = getActivityStateDir();
44
+ const stateFilePath = getPostHogActivityStateFilePath();
45
+ try {
46
+ mkdirSync(stateDir, { recursive: true });
47
+ writeFileAtomically(stateFilePath, `${JSON.stringify(nextState, null, 2)}\n`);
48
+ }
49
+ catch (error) {
50
+ writeActivityStateDiagnostic("telemetry_activity_state_write_failed", error, error instanceof Error ? "error" : "non_error");
51
+ return;
52
+ }
53
+ }
54
+ export function getPostHogActivityCaptureState(now = new Date()) {
55
+ const state = readPostHogActivityState();
56
+ const dayUTC = getUtcDayString(now);
57
+ const captureDaily = state.lastActiveDayUTC !== dayUTC;
58
+ if (captureDaily) {
59
+ writePostHogActivityState({
60
+ ...state,
61
+ lastActiveDayUTC: dayUTC,
62
+ });
63
+ }
64
+ return {
65
+ dayUTC,
66
+ captureDaily,
67
+ };
68
+ }
@@ -0,0 +1,21 @@
1
+ import os from "node:os";
2
+ import { getPostHogActivityCaptureState } from "./posthog-activity-state.js";
3
+ import { DEFAULT_POSTHOG_API_KEY, DEFAULT_POSTHOG_HOST } from "./product-identity.js";
4
+ export { DEFAULT_POSTHOG_API_KEY, DEFAULT_POSTHOG_HOST };
5
+ export type PostHogActivityReason = "session_start";
6
+ export type PostHogClient = {
7
+ trackActive: (distinctId: string, reason: PostHogActivityReason) => void;
8
+ shutdown: () => Promise<void>;
9
+ };
10
+ type OsProvider = Pick<typeof os, "arch" | "cpus" | "hostname" | "platform" | "release" | "totalmem" | "type">;
11
+ type ActivityStateProvider = typeof getPostHogActivityCaptureState;
12
+ export declare function createPluginPostHog(): Promise<PostHogClient>;
13
+ export declare function getPostHogDistinctId(): string;
14
+ /** @internal test-only */
15
+ export declare function __setOsProviderForTesting(provider: OsProvider): void;
16
+ /** @internal test-only */
17
+ export declare function __resetOsProviderForTesting(): void;
18
+ /** @internal test-only */
19
+ export declare function __setActivityStateProviderForTesting(provider: ActivityStateProvider): void;
20
+ /** @internal test-only */
21
+ export declare function __resetActivityStateProviderForTesting(): void;