oh-my-opencode 5.0.0-beta.33 → 5.0.0-beta.35

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 (221) hide show
  1. package/.agents/skills/codex-qa/scripts/lsp-e2e.sh +1 -3
  2. package/.agents/skills/opencode-qa/scripts/lsp-e2e.sh +1 -1
  3. package/.agents/skills/tech-debt-audit/SKILL.md +6 -76
  4. package/README.ja.md +1 -1
  5. package/README.ko.md +1 -1
  6. package/README.md +1 -1
  7. package/README.ru.md +1 -1
  8. package/README.zh-cn.md +1 -1
  9. package/THIRD-PARTY-NOTICES.md +27 -99
  10. package/dist/cli/index.js +48350 -48559
  11. package/dist/cli-node/index.js +48480 -48689
  12. package/dist/config/index.d.ts +1 -1
  13. package/dist/config/schema/hooks.d.ts +0 -1
  14. package/dist/config/schema/oh-my-opencode-config.d.ts +0 -10
  15. package/dist/config/schema.d.ts +0 -1
  16. package/dist/create-hooks.d.ts +0 -1
  17. package/dist/hooks/index.d.ts +0 -1
  18. package/dist/index.js +11675 -13742
  19. package/dist/mcp/index.d.ts +0 -4
  20. package/dist/mcp/types.d.ts +0 -1
  21. package/dist/oh-my-opencode.schema.json +1 -45
  22. package/dist/plugin/hooks/create-core-hooks.d.ts +0 -1
  23. package/dist/plugin/hooks/create-session-hooks.d.ts +1 -2
  24. package/dist/shared/omo-process-sweep.d.ts +2 -4
  25. package/dist/skills/init-deep/SKILL.md +13 -13
  26. package/dist/skills/ulw-plan/SKILL.md +0 -1
  27. package/dist/tui.js +44809 -44910
  28. package/package.json +16 -18
  29. package/packages/omo-codex/THIRD-PARTY-NOTICES.md +0 -17
  30. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -3
  31. package/packages/omo-codex/plugin/.mcp.json +0 -6
  32. package/packages/omo-codex/plugin/AGENTS.md +5 -5
  33. package/packages/omo-codex/plugin/README.md +1 -1
  34. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +1 -15
  35. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  36. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  37. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  38. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  39. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  40. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  41. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  42. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  43. package/packages/omo-codex/plugin/components/lcx/skills/lcx-doctor/SKILL.md +1 -1
  44. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
  45. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  46. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  47. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  48. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  49. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  50. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  51. package/packages/omo-codex/plugin/components/teammode/test/thread-title-hook.test.ts +1 -1
  52. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  53. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  54. package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +2 -2
  55. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  56. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  57. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +0 -1
  58. package/packages/omo-codex/plugin/components/ultrawork/src/directive-content.ts +1 -1
  59. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +2 -2
  60. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
  61. package/packages/omo-codex/plugin/components/ulw-loop/README.md +11 -1
  62. package/packages/omo-codex/plugin/components/ulw-loop/directive.md +2 -2
  63. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.d.ts +12 -0
  64. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.js +45 -0
  65. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.d.ts +1 -0
  66. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.js +5 -0
  67. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.js +10 -3
  68. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +35 -38
  69. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +278 -193
  70. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.d.ts +5 -0
  71. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.js +7 -51
  72. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-artifacts.js +39 -22
  73. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.d.ts +13 -1
  74. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.js +64 -8
  75. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-verdicts.js +5 -1
  76. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.js +37 -18
  77. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +4 -4
  78. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  79. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +2 -1
  80. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-codex-validation.ts +81 -0
  81. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-reconciliation.ts +6 -0
  82. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-template.ts +10 -3
  83. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +32 -63
  84. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-aggregate.ts +7 -53
  85. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-artifacts.ts +50 -31
  86. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-fields.ts +67 -14
  87. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-verdicts.ts +6 -1
  88. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate.ts +36 -17
  89. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-final.test.ts +26 -0
  90. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-template.test.ts +47 -2
  91. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-aggregate-basics.test.ts +258 -0
  92. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-cap-and-dedupe.test.ts +22 -0
  93. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-poisoning-cascades.test.ts +97 -0
  94. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-single-report.test.ts +241 -0
  95. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  96. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  97. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  98. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  99. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  100. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  101. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  102. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  103. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  104. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  105. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  106. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  107. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  108. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  109. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  110. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  111. package/packages/omo-codex/plugin/hooks/subagent-stop-checking-ulw-execute-continuation.json +1 -1
  112. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  113. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  114. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  115. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  116. package/packages/omo-codex/plugin/package-lock.json +12 -146
  117. package/packages/omo-codex/plugin/package.json +1 -2
  118. package/packages/omo-codex/plugin/scripts/AGENTS.md +0 -1
  119. package/packages/omo-codex/plugin/scripts/auto-update-plan.mjs +0 -1
  120. package/packages/omo-codex/plugin/scripts/auto-update.mjs +0 -9
  121. package/packages/omo-codex/plugin/scripts/canonical-ultrawork-directive.mjs +17 -0
  122. package/packages/omo-codex/plugin/scripts/hook-status-message.mjs +0 -1
  123. package/packages/omo-codex/plugin/scripts/sync-skills.mjs +2 -8
  124. package/packages/omo-codex/plugin/shared/src/config-loader.ts +2 -102
  125. package/packages/omo-codex/plugin/shared/src/config-migration.ts +0 -1
  126. package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +41 -130
  127. package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +13 -13
  128. package/packages/omo-codex/plugin/skills/lcx-doctor/SKILL.md +1 -1
  129. package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +2 -2
  130. package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +2 -1
  131. package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +0 -1
  132. package/packages/omo-codex/plugin/test/AGENTS.md +2 -2
  133. package/packages/omo-codex/plugin/test/aggregate-hooks.test.mjs +2 -21
  134. package/packages/omo-codex/plugin/test/aggregate-manifest.test.mjs +1 -2
  135. package/packages/omo-codex/plugin/test/aggregate-mcp.test.mjs +2 -7
  136. package/packages/omo-codex/plugin/test/auto-update.test.mjs +0 -25
  137. package/packages/omo-codex/plugin/test/bootstrap-setup.test.mjs +0 -31
  138. package/packages/omo-codex/plugin/test/canonical-ultrawork-directive.test.mjs +53 -0
  139. package/packages/omo-codex/plugin/test/component-bundled-cli.test.mjs +0 -50
  140. package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +0 -1
  141. package/packages/omo-codex/plugin/test/mcp-research-servers.test.mjs +1 -3
  142. package/packages/omo-codex/scripts/install-cache-copy.test.mjs +27 -1
  143. package/packages/omo-codex/scripts/install-config-git-bash.test.mjs +0 -23
  144. package/packages/omo-codex/scripts/install-dist/install-local.mjs +238 -431
  145. package/packages/omo-codex/scripts/install-git-bash-mcp-env.test.mjs +1 -25
  146. package/packages/omo-codex/scripts/install-mcp-runtime.test.mjs +0 -36
  147. package/packages/shared-skills/skills/init-deep/SKILL.md +13 -13
  148. package/packages/shared-skills/skills/ulw-plan/SKILL.md +0 -1
  149. package/dist/config/schema/codegraph.d.ts +0 -12
  150. package/dist/hooks/codegraph-bootstrap/command-runner.d.ts +0 -17
  151. package/dist/hooks/codegraph-bootstrap/hook.d.ts +0 -35
  152. package/dist/hooks/codegraph-bootstrap/index.d.ts +0 -1
  153. package/dist/hooks/codegraph-bootstrap/project-root.d.ts +0 -1
  154. package/dist/hooks/codegraph-bootstrap/status.d.ts +0 -11
  155. package/dist/mcp/codegraph.d.ts +0 -16
  156. package/packages/omo-codex/plugin/components/codegraph/AGENTS.md +0 -58
  157. package/packages/omo-codex/plugin/components/codegraph/LICENSE +0 -21
  158. package/packages/omo-codex/plugin/components/codegraph/NODE-RUNTIME-LICENSES.md +0 -2951
  159. package/packages/omo-codex/plugin/components/codegraph/NOTICE +0 -16
  160. package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +0 -12326
  161. package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +0 -9908
  162. package/packages/omo-codex/plugin/components/codegraph/package.json +0 -33
  163. package/packages/omo-codex/plugin/components/codegraph/src/cache-gc.ts +0 -29
  164. package/packages/omo-codex/plugin/components/codegraph/src/cli.ts +0 -79
  165. package/packages/omo-codex/plugin/components/codegraph/src/hook-input.ts +0 -33
  166. package/packages/omo-codex/plugin/components/codegraph/src/hook-sweep.ts +0 -25
  167. package/packages/omo-codex/plugin/components/codegraph/src/hook-types.ts +0 -131
  168. package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +0 -258
  169. package/packages/omo-codex/plugin/components/codegraph/src/mcp-bridge.ts +0 -310
  170. package/packages/omo-codex/plugin/components/codegraph/src/mcp-unavailable.ts +0 -92
  171. package/packages/omo-codex/plugin/components/codegraph/src/post-tool-use-hook.ts +0 -34
  172. package/packages/omo-codex/plugin/components/codegraph/src/serve-invocation.ts +0 -29
  173. package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +0 -263
  174. package/packages/omo-codex/plugin/components/codegraph/src/session-start-command.ts +0 -106
  175. package/packages/omo-codex/plugin/components/codegraph/src/session-start-cooldown.ts +0 -145
  176. package/packages/omo-codex/plugin/components/codegraph/src/session-start-hook-runtime.ts +0 -22
  177. package/packages/omo-codex/plugin/components/codegraph/src/session-start-lock.ts +0 -139
  178. package/packages/omo-codex/plugin/components/codegraph/src/session-start-outcome.ts +0 -15
  179. package/packages/omo-codex/plugin/components/codegraph/src/session-start-paths.ts +0 -32
  180. package/packages/omo-codex/plugin/components/codegraph/src/session-start-project.ts +0 -109
  181. package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker-result.ts +0 -148
  182. package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker.ts +0 -175
  183. package/packages/omo-codex/plugin/components/codegraph/src/sweep-cli.ts +0 -81
  184. package/packages/omo-codex/plugin/components/codegraph/test/cache-gc.test.ts +0 -34
  185. package/packages/omo-codex/plugin/components/codegraph/test/hook-exclusion.test.ts +0 -112
  186. package/packages/omo-codex/plugin/components/codegraph/test/hook-registration.test.ts +0 -26
  187. package/packages/omo-codex/plugin/components/codegraph/test/hook-session-start-guard.test.ts +0 -160
  188. package/packages/omo-codex/plugin/components/codegraph/test/hook-store-upgrade.test.ts +0 -50
  189. package/packages/omo-codex/plugin/components/codegraph/test/hook-sweep.test.ts +0 -29
  190. package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +0 -320
  191. package/packages/omo-codex/plugin/components/codegraph/test/mcp-bridge-fixtures.ts +0 -172
  192. package/packages/omo-codex/plugin/components/codegraph/test/package-runtime.test.ts +0 -91
  193. package/packages/omo-codex/plugin/components/codegraph/test/provisioned-node-guard.test.ts +0 -100
  194. package/packages/omo-codex/plugin/components/codegraph/test/serve-built-wrapper.test.ts +0 -76
  195. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge-lifecycle.test.ts +0 -133
  196. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge.test.ts +0 -245
  197. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-facade.test.ts +0 -69
  198. package/packages/omo-codex/plugin/components/codegraph/test/serve-node-support.test.ts +0 -43
  199. package/packages/omo-codex/plugin/components/codegraph/test/serve-provision.test.ts +0 -147
  200. package/packages/omo-codex/plugin/components/codegraph/test/serve-unavailable-idle.test.ts +0 -47
  201. package/packages/omo-codex/plugin/components/codegraph/test/serve-unavailable.test.ts +0 -175
  202. package/packages/omo-codex/plugin/components/codegraph/test/serve.test.ts +0 -385
  203. package/packages/omo-codex/plugin/components/codegraph/test/session-start-node-support.test.ts +0 -206
  204. package/packages/omo-codex/plugin/components/codegraph/test/session-start-project.test.ts +0 -58
  205. package/packages/omo-codex/plugin/components/codegraph/test/session-start-state.test.ts +0 -104
  206. package/packages/omo-codex/plugin/components/codegraph/test/session-start-trust-boundary.test.ts +0 -65
  207. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-availability.test.ts +0 -106
  208. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-cooldown.test.ts +0 -116
  209. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-flow.test.ts +0 -258
  210. package/packages/omo-codex/plugin/components/codegraph/test/sweep-cli.test.ts +0 -56
  211. package/packages/omo-codex/plugin/components/codegraph/tsconfig.build.json +0 -13
  212. package/packages/omo-codex/plugin/components/codegraph/tsconfig.json +0 -25
  213. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-aggregate.test.ts +0 -101
  214. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +0 -18
  215. package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +0 -17
  216. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/editor.mjs +0 -125
  217. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/jsonc.mjs +0 -43
  218. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/scaffold.mjs +0 -29
  219. package/packages/omo-codex/plugin/scripts/migrate-omo-sot.mjs +0 -121
  220. package/packages/omo-codex/plugin/test/component-codegraph-mcp-smoke.test.mjs +0 -76
  221. package/packages/omo-codex/plugin/test/migrate-omo-sot.test.mjs +0 -179
@@ -1,33 +0,0 @@
1
- {
2
- "name": "@sisyphuslabs/codex-codegraph",
3
- "version": "5.0.0-beta.33",
4
- "description": "Codex plugin MCP wrapper for CodeGraph.",
5
- "type": "module",
6
- "private": true,
7
- "bin": {
8
- "omo-codegraph": "./dist/cli.js"
9
- },
10
- "files": [
11
- "dist",
12
- "LICENSE",
13
- "NODE-RUNTIME-LICENSES.md",
14
- "NOTICE"
15
- ],
16
- "scripts": {
17
- "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && bun build src/serve.ts --target node --format esm --outfile dist/serve.js && bun build src/cli.ts --target node --format esm --outfile dist/cli.js",
18
- "test": "bun test ./test",
19
- "typecheck": "tsc --noEmit"
20
- },
21
- "devDependencies": {
22
- "@oh-my-opencode/utils": "file:../../../../utils",
23
- "@types/node": "^26.2.0",
24
- "bun-types": "^1.4.0",
25
- "typescript": "^7.0.2"
26
- },
27
- "optionalDependencies": {
28
- "@colbymchenry/codegraph": "1.5.0"
29
- },
30
- "engines": {
31
- "node": ">=20.0.0"
32
- }
33
- }
@@ -1,29 +0,0 @@
1
- import {
2
- pruneDeadCodegraphProjectStores,
3
- type PruneCodegraphStoreResult,
4
- } from "../../../../../utils/src/codegraph/workspace.ts";
5
-
6
- interface PruneCodegraphProjectStoresBestEffortOptions {
7
- readonly debugLog?: (message: string) => void;
8
- readonly prune?: (options: { readonly homeDir: string }) => PruneCodegraphStoreResult;
9
- }
10
-
11
- const NON_FATAL_GC_ERROR_CODES = new Set(["EACCES", "EBUSY", "ENOENT", "ENOTEMPTY", "ENOTDIR", "EPERM"]);
12
-
13
- export function pruneCodegraphProjectStoresBestEffort(
14
- homeDir: string,
15
- options: PruneCodegraphProjectStoresBestEffortOptions = {},
16
- ): void {
17
- try {
18
- (options.prune ?? pruneDeadCodegraphProjectStores)({ homeDir });
19
- } catch (error) {
20
- if (!isNonFatalCodegraphGcError(error)) throw error;
21
- options.debugLog?.(`CodeGraph cache GC skipped: ${error.message}`);
22
- }
23
- }
24
-
25
- export function isNonFatalCodegraphGcError(error: unknown): error is Error {
26
- if (!(error instanceof Error)) return false;
27
- const code = typeof error === "object" && error !== null && "code" in error ? (error as { readonly code?: unknown }).code : undefined;
28
- return typeof code === "string" && NON_FATAL_GC_ERROR_CODES.has(code);
29
- }
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env node
2
- import { realpathSync } from "node:fs";
3
- import { basename, resolve } from "node:path";
4
- import { stderr as processStderr } from "node:process";
5
- import { fileURLToPath } from "node:url";
6
-
7
- import {
8
- runCodegraphPostToolUseHookCli,
9
- runCodegraphSessionStartHook,
10
- runCodegraphSessionStartWorker,
11
- type PostToolUseHookOptions,
12
- type SessionStartHookOptions,
13
- type SessionStartWorkerOptions,
14
- } from "./hook.js";
15
- import { runCodegraphServeCli } from "./serve.js";
16
- import { runCodegraphSweepCli, type RunCodegraphSweepCliOptions } from "./sweep-cli.js";
17
-
18
- export interface RunCodegraphCliOptions extends SessionStartHookOptions {
19
- readonly sweepOptions?: SweepCodegraphZombiesTestOptions;
20
- readonly workerOptions?: SessionStartWorkerOptions;
21
- }
22
-
23
- type SweepCodegraphZombiesTestOptions = Omit<RunCodegraphSweepCliOptions, "argv" | "env" | "stdout">;
24
-
25
- export async function runCodegraphCli(options: RunCodegraphCliOptions = {}): Promise<number> {
26
- const argv = options.argv ?? process.argv;
27
- const command = argv[2];
28
- const subcommand = argv[3];
29
-
30
- if (command === "sweep") {
31
- return runCodegraphSweepCli({
32
- ...options.sweepOptions,
33
- argv,
34
- ...(options.env === undefined ? {} : { env: options.env }),
35
- ...(options.stdout === undefined ? {} : { stdout: options.stdout }),
36
- });
37
- }
38
-
39
- if (command === "hook" && subcommand === "session-start") {
40
- return runCodegraphSessionStartHook(options);
41
- }
42
-
43
- if (command === "hook" && subcommand === "post-tool-use") {
44
- const hookOptions: PostToolUseHookOptions = {
45
- ...(options.env === undefined ? {} : { env: options.env }),
46
- ...(options.stdin === undefined ? {} : { stdin: options.stdin }),
47
- ...(options.stdout === undefined ? {} : { stdout: options.stdout }),
48
- };
49
- return runCodegraphPostToolUseHookCli(hookOptions);
50
- }
51
-
52
- if (command === "hook" && subcommand === "session-start-worker") {
53
- const workerOptions: SessionStartWorkerOptions = {
54
- ...options.workerOptions,
55
- ...(options.workerOptions?.cwd === undefined && options.cwd !== undefined ? { cwd: options.cwd } : {}),
56
- ...(options.workerOptions?.env === undefined && options.env !== undefined ? { env: options.env } : {}),
57
- };
58
- await runCodegraphSessionStartWorker(workerOptions);
59
- return 0;
60
- }
61
-
62
- await runCodegraphServeCli();
63
- return process.exitCode === undefined ? 0 : Number(process.exitCode);
64
- }
65
-
66
- if (isDirectInvocation(process.argv[1])) {
67
- runCodegraphCli().catch((error: unknown) => {
68
- processStderr.write(`${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`);
69
- process.exitCode = 1;
70
- });
71
- }
72
-
73
- function isDirectInvocation(argvPath: string | undefined): boolean {
74
- if (argvPath === undefined) return false;
75
- const modulePath = fileURLToPath(import.meta.url);
76
- const moduleName = basename(modulePath);
77
- if (moduleName !== "cli.js" && moduleName !== "cli.ts") return false;
78
- return realpathSync(resolve(argvPath)) === realpathSync(modulePath);
79
- }
@@ -1,33 +0,0 @@
1
- import { homedir } from "node:os";
2
- import type { Readable } from "node:stream";
3
-
4
- export function resolveHomeDir(env: Record<string, string | undefined>): string {
5
- return env["HOME"] ?? env["USERPROFILE"] ?? homedir();
6
- }
7
-
8
- export function resolveHookProjectRoot(input: unknown, fallback: string): string {
9
- if (!isRecord(input)) return fallback;
10
- const cwd = input["cwd"];
11
- return typeof cwd === "string" && cwd.trim().length > 0 ? cwd : fallback;
12
- }
13
-
14
- export async function readHookInput(stdin: Readable & { readonly isTTY?: boolean }): Promise<unknown> {
15
- if (stdin.isTTY === true) return undefined;
16
- let text = "";
17
- for await (const chunk of stdin) text += typeof chunk === "string" ? chunk : String(chunk);
18
- if (text.trim().length === 0) return undefined;
19
- return parseJson(text);
20
- }
21
-
22
- export function isRecord(value: unknown): value is Record<string, unknown> {
23
- return typeof value === "object" && value !== null;
24
- }
25
-
26
- function parseJson(text: string): unknown {
27
- try {
28
- return JSON.parse(text);
29
- } catch (error) {
30
- if (error instanceof SyntaxError) return undefined;
31
- throw error;
32
- }
33
- }
@@ -1,25 +0,0 @@
1
- import { fileURLToPath } from "node:url";
2
-
3
- import {
4
- sweepCodegraphZombies,
5
- type SweepCodegraphZombiesOptions,
6
- } from "../../../../../utils/src/codegraph/process-sweep.ts";
7
-
8
- export async function sweepCodegraphZombiesBestEffort(
9
- options: Omit<SweepCodegraphZombiesOptions, "pluginRoot">,
10
- sweep: (options: SweepCodegraphZombiesOptions) => Promise<unknown> | unknown = sweepCodegraphZombies,
11
- ): Promise<void> {
12
- try {
13
- await sweep({
14
- ...options,
15
- pluginRoot: defaultPluginRoot(),
16
- ...(options.log === undefined ? {} : { log: options.log }),
17
- });
18
- } catch (error) {
19
- options.log?.(`CodeGraph zombie sweep skipped: ${error instanceof Error ? error.message : String(error)}`);
20
- }
21
- }
22
-
23
- function defaultPluginRoot(): string {
24
- return fileURLToPath(new URL("../../..", import.meta.url));
25
- }
@@ -1,131 +0,0 @@
1
- import type { Readable } from "node:stream";
2
-
3
- import type { CodexOmoConfig as SharedCodexOmoConfig } from "../../../shared/src/config-loader.ts";
4
- import type { CODEGRAPH_PINNED_VERSION } from "../../../../../utils/src/codegraph/manifest.ts";
5
- import type { SweepCodegraphZombiesOptions } from "../../../../../utils/src/codegraph/process-sweep.ts";
6
- import type { CodegraphProvisionResult as SharedCodegraphProvisionResult } from "../../../../../utils/src/codegraph/provision.ts";
7
- import type {
8
- CodegraphCommandResolution,
9
- ResolveCodegraphCommandOptions,
10
- } from "../../../../../utils/src/codegraph/resolve.ts";
11
- import type { CodegraphWorkspacePreparation as SharedCodegraphWorkspacePreparation } from "../../../../../utils/src/codegraph/workspace.ts";
12
- import type { CodegraphConfig as SharedCodegraphConfig } from "../../../../../utils/src/omo-config.ts";
13
- import type { CodegraphAncestorState, CodegraphProjectState } from "./session-start-project.js";
14
-
15
- export type SessionStartAction =
16
- | "skipped-cooldown"
17
- | "skipped-disabled"
18
- | "skipped-excluded"
19
- | "skipped-inconclusive"
20
- | "skipped-initialized"
21
- | "skipped-locked"
22
- | "skipped-nested-root"
23
- | "skipped-spawn-error"
24
- | "spawned";
25
- export type PostToolUseAction = "emitted-guidance" | "skipped";
26
- export type WorkerAction =
27
- | "failed"
28
- | "initialized"
29
- | "skipped-disabled"
30
- | "skipped-initialized"
31
- | "skipped-locked"
32
- | "skipped-nested-root"
33
- | "skipped-probe-error"
34
- | "skipped-status"
35
- | "skipped-unavailable"
36
- | "skipped-unsupported-node"
37
- | "synced";
38
- export type SessionStartOutcomeAction = SessionStartAction | WorkerAction;
39
-
40
- export interface WorkerSpawnInvocation {
41
- readonly args: readonly string[];
42
- readonly command: string;
43
- readonly env: Record<string, string | undefined>;
44
- }
45
-
46
- export interface HookStdout {
47
- readonly write: (chunk: string) => void;
48
- }
49
-
50
- export interface SessionStartHookResult {
51
- readonly action: SessionStartAction;
52
- readonly exitCode: 0;
53
- }
54
-
55
- export interface PostToolUseHookResult {
56
- readonly action: PostToolUseAction;
57
- readonly exitCode: 0;
58
- }
59
-
60
- export interface CodegraphCommandResult {
61
- readonly exitCode: number;
62
- readonly stderr?: string;
63
- readonly stdout: string;
64
- readonly timedOut: boolean;
65
- }
66
-
67
- export type CodegraphConfig = Partial<SharedCodegraphConfig>;
68
- export type CodexOmoConfig = SharedCodexOmoConfig;
69
- export type OmoConfigSource = CodexOmoConfig["sources"][number];
70
- export type CodegraphProvisionResult = SharedCodegraphProvisionResult;
71
- export type CodegraphWorkspacePreparation = SharedCodegraphWorkspacePreparation;
72
-
73
- export interface CodegraphSessionStartOutcome {
74
- readonly action: SessionStartOutcomeAction;
75
- readonly ancestorRoot?: string;
76
- readonly cooldownUntil?: number;
77
- readonly error?: string;
78
- readonly exitCode?: number;
79
- readonly failureCount?: number;
80
- readonly projectRoot?: string;
81
- readonly source?: CodegraphCommandResolution["source"];
82
- readonly timedOut?: boolean;
83
- }
84
-
85
- export interface CodegraphSessionStartDeps {
86
- readonly ensureGitignored: (projectRoot: string) => boolean;
87
- readonly ensureProvisioned: (options: { readonly installDir?: string; readonly lockDir: string; readonly version: typeof CODEGRAPH_PINNED_VERSION }) => Promise<CodegraphProvisionResult>;
88
- readonly managedInstallExists: (installDir: string) => boolean;
89
- readonly prepareWorkspace: (projectRoot: string, options: { readonly homeDir: string }) => CodegraphWorkspacePreparation;
90
- readonly resolveCommand: (options?: ResolveCodegraphCommandOptions) => CodegraphCommandResolution;
91
- readonly resolveManagedBin: (installDir: string) => string | null;
92
- readonly runCommand: (
93
- projectRoot: string,
94
- command: string,
95
- args: readonly string[],
96
- options: { readonly env: Record<string, string>; readonly timeoutMs: number },
97
- ) => Promise<CodegraphCommandResult>;
98
- }
99
-
100
- export interface SessionStartHookOptions {
101
- readonly ancestorProbe?: (projectRoot: string) => CodegraphAncestorState;
102
- readonly argv?: readonly string[];
103
- readonly config?: CodexOmoConfig;
104
- readonly cwd?: string;
105
- readonly env?: Record<string, string | undefined>;
106
- readonly lockStaleMs?: number;
107
- readonly logOutcome?: (outcome: CodegraphSessionStartOutcome) => void;
108
- readonly nowMs?: number;
109
- readonly spawnWorker?: (invocation: WorkerSpawnInvocation) => void;
110
- readonly stdin?: Readable & { readonly isTTY?: boolean };
111
- readonly stdout?: HookStdout;
112
- readonly sweepZombies?: (options: SweepCodegraphZombiesOptions) => Promise<unknown> | unknown;
113
- readonly workerCliPath?: string;
114
- }
115
-
116
- export interface PostToolUseHookOptions {
117
- readonly env?: Record<string, string | undefined>;
118
- readonly stdin?: Readable & { readonly isTTY?: boolean };
119
- readonly stdout?: HookStdout;
120
- }
121
-
122
- export interface SessionStartWorkerOptions {
123
- readonly config?: CodexOmoConfig;
124
- readonly cwd?: string;
125
- readonly deps?: Partial<CodegraphSessionStartDeps>;
126
- readonly env?: Record<string, string | undefined>;
127
- readonly logOutcome?: (outcome: CodegraphSessionStartOutcome) => void;
128
- readonly nodeVersion?: string;
129
- readonly nowMs?: number;
130
- readonly projectProbe?: (projectRoot: string) => CodegraphProjectState;
131
- }
@@ -1,258 +0,0 @@
1
- import {
2
- cwd as processCwd,
3
- env as processEnv,
4
- stderr as processStderr,
5
- stdin as processStdin,
6
- stdout as processStdout,
7
- } from "node:process";
8
- import { fileURLToPath } from "node:url";
9
-
10
- import { buildCodegraphChildEnv } from "../../../../../utils/src/codegraph/env.ts";
11
- import { shouldExcludeCodegraphProject } from "../../../../../utils/src/codegraph/workspace.ts";
12
- import { getCodexOmoConfig } from "../../../shared/src/config-loader.ts";
13
- import { pruneCodegraphProjectStoresBestEffort } from "./cache-gc.js";
14
- import { readHookInput, resolveHomeDir, resolveHookProjectRoot } from "./hook-input.js";
15
- import { sweepCodegraphZombiesBestEffort } from "./hook-sweep.js";
16
- import type {
17
- CodegraphSessionStartOutcome,
18
- SessionStartHookOptions,
19
- SessionStartHookResult,
20
- } from "./hook-types.js";
21
- import {
22
- DEFAULT_SESSION_START_COOLDOWN_MS,
23
- readSessionStartCooldown,
24
- recordSessionStartFailure,
25
- } from "./session-start-cooldown.js";
26
- import { spawnDetachedSessionStartWorker, writeSessionStartNotice } from "./session-start-hook-runtime.js";
27
- import { acquireSessionStartLock, releaseSessionStartLock, type SessionStartLock } from "./session-start-lock.js";
28
- import { appendSessionStartOutcome } from "./session-start-outcome.js";
29
- import {
30
- probeCodegraphAncestors,
31
- probeExactCodegraphProject,
32
- type CodegraphProjectState,
33
- } from "./session-start-project.js";
34
- import { SESSION_START_CWD_ENV, SESSION_START_LOCK_TOKEN_ENV } from "./session-start-worker.js";
35
-
36
- export type {
37
- CodegraphCommandResult,
38
- CodegraphConfig,
39
- CodegraphProvisionResult,
40
- CodegraphSessionStartDeps,
41
- CodegraphSessionStartOutcome,
42
- CodegraphWorkspacePreparation,
43
- CodexOmoConfig,
44
- HookStdout,
45
- OmoConfigSource,
46
- PostToolUseHookOptions,
47
- PostToolUseHookResult,
48
- SessionStartAction,
49
- SessionStartHookOptions,
50
- SessionStartHookResult,
51
- SessionStartWorkerOptions,
52
- WorkerAction,
53
- WorkerSpawnInvocation,
54
- } from "./hook-types.js";
55
- export {
56
- executeCodegraphPostToolUseHook,
57
- runCodegraphPostToolUseHook,
58
- runCodegraphPostToolUseHookCli,
59
- } from "./post-tool-use-hook.js";
60
- export { resolveCodegraphCommandInvocation } from "./session-start-command.js";
61
- export { runCodegraphSessionStartWorker } from "./session-start-worker.js";
62
-
63
- export const CODEGRAPH_SESSION_START_NOTICE = "LazyCodex CodeGraph bootstrap scheduled in background";
64
- export const DEFAULT_SESSION_START_LOCK_STALE_MS = 10 * 60 * 1_000;
65
-
66
- type HookContext = {
67
- readonly baseCooldownMs: number;
68
- readonly env: Record<string, string | undefined>;
69
- readonly homeDir: string;
70
- readonly logOutcome: (outcome: CodegraphSessionStartOutcome) => void;
71
- readonly nowMs: number;
72
- readonly options: SessionStartHookOptions;
73
- readonly projectRoot: string;
74
- };
75
-
76
- export async function runCodegraphSessionStartHook(options: SessionStartHookOptions = {}): Promise<number> {
77
- return (await executeCodegraphSessionStartHook(options)).exitCode;
78
- }
79
-
80
- export async function executeCodegraphSessionStartHook(options: SessionStartHookOptions = {}): Promise<SessionStartHookResult> {
81
- const env = options.env ?? processEnv;
82
- const input = await readHookInput(options.stdin ?? processStdin);
83
- const projectRoot = resolveHookProjectRoot(input, options.cwd ?? processCwd());
84
- const homeDir = resolveHomeDir(env);
85
- const config = options.config ?? getCodexOmoConfig({ cwd: projectRoot, env, homeDir });
86
- if (config.codegraph?.enabled === false) return { action: "skipped-disabled", exitCode: 0 };
87
-
88
- const excludedRoots = config.codegraph?.excluded_roots;
89
- const exclusion = shouldExcludeCodegraphProject(projectRoot, {
90
- homeDir,
91
- ...(excludedRoots === undefined ? {} : { excludedRoots }),
92
- });
93
- if (exclusion.excluded) return { action: "skipped-excluded", exitCode: 0 };
94
-
95
- pruneCodegraphProjectStoresBestEffort(homeDir, { debugLog: writeDebugLog });
96
- await sweepCodegraphZombiesBestEffort({
97
- env,
98
- homeDir,
99
- ...(config.trustedCodegraphInstallDir === undefined ? {} : { trustedCodegraphInstallDir: config.trustedCodegraphInstallDir }),
100
- log: writeDebugLog,
101
- }, options.sweepZombies);
102
-
103
- const nowMs = options.nowMs ?? Date.now();
104
- const context: HookContext = {
105
- baseCooldownMs: config.codegraph?.session_start_cooldown_ms ?? DEFAULT_SESSION_START_COOLDOWN_MS,
106
- env,
107
- homeDir,
108
- logOutcome: options.logOutcome ?? ((outcome) => appendSessionStartOutcome(homeDir, outcome, nowMs)),
109
- nowMs,
110
- options,
111
- projectRoot,
112
- };
113
- const projectDecision = handleProjectState(resolveHookProjectState(context), context);
114
- if (projectDecision !== null) return projectDecision;
115
-
116
- const cooldown = readSessionStartCooldown({
117
- baseCooldownMs: context.baseCooldownMs,
118
- homeDir,
119
- nowMs,
120
- projectRoot,
121
- });
122
- if (cooldown.kind === "inconclusive") return { action: "skipped-inconclusive", exitCode: 0 };
123
- if (cooldown.kind === "active") {
124
- safeLogOutcome(context.logOutcome, {
125
- action: "skipped-cooldown",
126
- cooldownUntil: cooldown.cooldownUntil,
127
- failureCount: cooldown.failureCount,
128
- projectRoot,
129
- });
130
- return { action: "skipped-cooldown", exitCode: 0 };
131
- }
132
-
133
- const lockResult = acquireSessionStartLock({
134
- homeDir,
135
- nowMs,
136
- projectRoot,
137
- staleMs: options.lockStaleMs ?? DEFAULT_SESSION_START_LOCK_STALE_MS,
138
- });
139
- if (lockResult.kind === "inconclusive") return { action: "skipped-inconclusive", exitCode: 0 };
140
- if (lockResult.kind === "locked") {
141
- safeLogOutcome(context.logOutcome, { action: "skipped-locked", projectRoot });
142
- return { action: "skipped-locked", exitCode: 0 };
143
- }
144
- if (lockResult.recoveredStale) return handleRecoveredStaleLock(lockResult.lock, context);
145
-
146
- const lockedProjectDecision = handleProjectState(resolveHookProjectState(context), context);
147
- if (lockedProjectDecision !== null) {
148
- releaseSessionStartLock(lockResult.lock);
149
- return lockedProjectDecision;
150
- }
151
-
152
- try {
153
- (options.spawnWorker ?? spawnDetachedSessionStartWorker)({
154
- args: [options.workerCliPath ?? defaultWorkerCliPath(), "hook", "session-start-worker"],
155
- command: process.execPath,
156
- env: buildCodegraphChildEnv({
157
- ambientEnv: env,
158
- codegraphEnv: {
159
- [SESSION_START_CWD_ENV]: projectRoot,
160
- [SESSION_START_LOCK_TOKEN_ENV]: lockResult.lock.token,
161
- },
162
- runtimeEnv: env,
163
- }),
164
- });
165
- } catch (error) {
166
- if (error instanceof Error) return handleSpawnFailure(error, lockResult.lock, context);
167
- throw error;
168
- }
169
-
170
- writeSessionStartNotice(options.stdout ?? processStdout, CODEGRAPH_SESSION_START_NOTICE);
171
- return { action: "spawned", exitCode: 0 };
172
- }
173
-
174
- function resolveHookProjectState(context: HookContext): CodegraphProjectState {
175
- const exact = probeExactCodegraphProject(context.projectRoot);
176
- if (exact.kind !== "uninitialized") return exact;
177
- return (context.options.ancestorProbe ?? probeCodegraphAncestors)(context.projectRoot);
178
- }
179
-
180
- function handleProjectState(state: CodegraphProjectState, context: HookContext): SessionStartHookResult | null {
181
- switch (state.kind) {
182
- case "inconclusive":
183
- return { action: "skipped-inconclusive", exitCode: 0 };
184
- case "initialized":
185
- return { action: "skipped-initialized", exitCode: 0 };
186
- case "nested-root":
187
- safeLogOutcome(context.logOutcome, { action: "skipped-nested-root", ancestorRoot: state.ancestorRoot, projectRoot: context.projectRoot });
188
- return { action: "skipped-nested-root", exitCode: 0 };
189
- case "uninitialized":
190
- return null;
191
- }
192
- }
193
-
194
- function handleRecoveredStaleLock(lock: SessionStartLock, context: HookContext): SessionStartHookResult {
195
- try {
196
- const cooldown = recordSessionStartFailure({
197
- action: "stale-lock",
198
- baseCooldownMs: context.baseCooldownMs,
199
- homeDir: context.homeDir,
200
- nowMs: context.nowMs,
201
- projectRoot: context.projectRoot,
202
- });
203
- releaseSessionStartLock(lock);
204
- safeLogOutcome(context.logOutcome, {
205
- action: "skipped-cooldown",
206
- cooldownUntil: cooldown.cooldownUntil,
207
- error: "recovered stale SessionStart worker lock",
208
- failureCount: cooldown.failureCount,
209
- projectRoot: context.projectRoot,
210
- });
211
- return { action: "skipped-cooldown", exitCode: 0 };
212
- } catch (error) {
213
- if (error instanceof Error) return { action: "skipped-inconclusive", exitCode: 0 };
214
- throw error;
215
- }
216
- }
217
-
218
- function handleSpawnFailure(error: unknown, lock: SessionStartLock, context: HookContext): SessionStartHookResult {
219
- try {
220
- const cooldown = recordSessionStartFailure({
221
- action: "spawn-failed",
222
- baseCooldownMs: context.baseCooldownMs,
223
- homeDir: context.homeDir,
224
- nowMs: context.nowMs,
225
- projectRoot: context.projectRoot,
226
- });
227
- releaseSessionStartLock(lock);
228
- safeLogOutcome(context.logOutcome, {
229
- action: "skipped-spawn-error",
230
- cooldownUntil: cooldown.cooldownUntil,
231
- error: error instanceof Error ? error.message : String(error),
232
- failureCount: cooldown.failureCount,
233
- projectRoot: context.projectRoot,
234
- });
235
- } catch (cooldownError) {
236
- if (cooldownError instanceof Error) return { action: "skipped-inconclusive", exitCode: 0 };
237
- throw cooldownError;
238
- }
239
- return { action: "skipped-spawn-error", exitCode: 0 };
240
- }
241
-
242
- function safeLogOutcome(logOutcome: (outcome: CodegraphSessionStartOutcome) => void, outcome: CodegraphSessionStartOutcome): void {
243
- try {
244
- logOutcome(outcome);
245
- } catch (error) {
246
- if (error instanceof Error) writeDebugLog(`failed to write SessionStart outcome: ${error.message}`);
247
- else throw error;
248
- }
249
- }
250
-
251
- function writeDebugLog(message: string): void {
252
- if (processEnv["OMO_CODEGRAPH_DEBUG"] !== "1") return;
253
- processStderr.write(`${message}\n`);
254
- }
255
-
256
- function defaultWorkerCliPath(): string {
257
- return fileURLToPath(import.meta.url);
258
- }