oh-my-opencode 4.19.2 → 4.19.4
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.
- package/.agents/command/get-unpublished-changes.md +2 -0
- package/.agents/command/omomomo.md +1 -1
- package/.agents/command/publish.md +102 -28
- package/.agents/skills/get-unpublished-changes/SKILL.md +2 -0
- package/.agents/skills/hyperplan/SKILL.md +3 -3
- package/.agents/skills/omomomo/SKILL.md +1 -1
- package/.agents/skills/publish/SKILL.md +27 -6
- package/.opencode/command/get-unpublished-changes.md +2 -0
- package/.opencode/command/omomomo.md +1 -1
- package/.opencode/command/publish.md +102 -28
- package/.opencode/skills/hyperplan/SKILL.md +3 -3
- package/THIRD-PARTY-NOTICES.md +7 -7
- package/dist/agents/sisyphus-junior/agent.d.ts +1 -1
- package/dist/agents/sisyphus-runtime-prompt-reconciler.d.ts +1 -1
- package/dist/cli/config-migrate.d.ts +8 -0
- package/dist/cli/doctor/checks/deprecated-reasoning-keys.d.ts +2 -0
- package/dist/cli/doctor/checks/legacy-config-leftovers.d.ts +10 -0
- package/dist/cli/doctor/checks/model-resolution-config.d.ts +1 -1
- package/dist/cli/doctor/checks/tools-lsp.d.ts +1 -1
- package/dist/cli/doctor/framework/constants.d.ts +1 -1
- package/dist/cli/index.js +95684 -92814
- package/dist/cli-node/index.js +95650 -92780
- package/dist/config/schema/agent-overrides.d.ts +800 -0
- package/dist/config/schema/categories.d.ts +132 -0
- package/dist/config/schema/fallback-models.d.ts +50 -0
- package/dist/config/schema/oh-my-opencode-config.d.ts +818 -2
- package/dist/config/validate.d.ts +2 -1
- package/dist/config-migration/deep-diff.d.ts +1 -0
- package/dist/config-migration/discovery-paths.d.ts +11 -0
- package/dist/config-migration/discovery-roots.d.ts +7 -0
- package/dist/config-migration/discovery.d.ts +4 -0
- package/dist/config-migration/index.d.ts +10 -0
- package/dist/config-migration/legacy-history.d.ts +3 -0
- package/dist/config-migration/migration-executor.d.ts +4 -0
- package/dist/config-migration/migration-plans.d.ts +15 -0
- package/dist/config-migration/reasoning-unification.d.ts +3 -0
- package/dist/config-migration/record-values.d.ts +4 -0
- package/dist/config-migration/schema-url.d.ts +1 -0
- package/dist/config-migration/transform-config-jsonc.d.ts +2 -0
- package/dist/config-migration/transform-opencode.d.ts +2 -0
- package/dist/config-migration/transform-types.d.ts +24 -0
- package/dist/config-migration/types.d.ts +39 -0
- package/dist/features/builtin-commands/templates/hyperplan.d.ts +1 -1
- package/dist/features/team-mode/tools/lifecycle-test-fixture.d.ts +2 -0
- package/dist/hooks/auto-update-checker/constants.d.ts +3 -3
- package/dist/hooks/codegraph-bootstrap/command-runner.d.ts +1 -0
- package/dist/hooks/model-fallback/next-fallback.d.ts +1 -0
- package/dist/hooks/runtime-fallback/constants.d.ts +1 -1
- package/dist/index.js +12368 -9788
- package/dist/oh-my-opencode.schema.json +1672 -8
- package/dist/plugin-config/omo-config-chain.d.ts +14 -0
- package/dist/plugin-config/unknown-key-diagnostics.d.ts +5 -0
- package/dist/plugin-config.d.ts +2 -2
- package/dist/plugin-handlers/prometheus-agent-config-builder.d.ts +1 -0
- package/dist/shared/agent-display-names.d.ts +1 -1
- package/dist/shared/agent-variant.d.ts +11 -0
- package/dist/shared/jsonc-parser.d.ts +1 -1
- package/dist/shared/migration.d.ts +5 -1
- package/dist/shared/opencode-config-dir-types.d.ts +0 -1
- package/dist/shared/plugin-identity.d.ts +6 -8
- package/dist/shared/project-discovery-dirs.d.ts +0 -1
- package/dist/shared/session-prompt-params-helpers.d.ts +6 -1
- package/dist/skills/coding-agent-sessions/SKILL.md +4 -3
- package/dist/skills/coding-agent-sessions/references/all-platforms.md +3 -1
- package/dist/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
- package/dist/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +3 -0
- package/dist/skills/data-scientist/SKILL.md +243 -0
- package/dist/skills/data-scientist/references/common-scenarios.md +176 -0
- package/dist/skills/data-scientist/references/execution-templates.md +197 -0
- package/dist/skills/data-scientist/references/integration-patterns.md +153 -0
- package/dist/skills/data-scientist/references/performance-benchmarks.md +37 -0
- package/dist/skills/data-scientist/references/uv-setup.md +78 -0
- package/dist/skills/data-scientist/scripts/quick-query.py +111 -0
- package/dist/skills/data-scientist/scripts/setup-uv.ps1 +53 -0
- package/dist/skills/data-scientist/scripts/setup-uv.sh +60 -0
- package/dist/skills/debugging/SKILL.md +1 -1
- package/dist/skills/frontend/ATTRIBUTION.md +7 -0
- package/dist/skills/frontend/SKILL.md +4 -1
- package/dist/skills/frontend/references/design/README.md +8 -0
- package/dist/skills/frontend/references/design/_INDEX.md +14 -1
- package/dist/skills/frontend/references/design/interaction-skill.md +144 -0
- package/dist/skills/programming/SKILL.md +1 -2
- package/dist/skills/ulw-plan/SKILL.md +1 -1
- package/dist/skills/ulw-research/SKILL.md +122 -11
- package/dist/startup-migration.d.ts +28 -0
- package/dist/testing/create-plugin-module.d.ts +4 -0
- package/dist/tools/delegate-task/builtin-categories.d.ts +1 -0
- package/dist/tools/delegate-task/builtin-category-definition.d.ts +1 -0
- package/dist/tools/delegate-task/constants.d.ts +1 -1
- package/dist/tui.js +6040 -5443
- package/package.json +13 -13
- package/packages/lsp-core/src/lsp/client-diagnostics-freshness.integration.test.ts +21 -5
- package/packages/lsp-core/src/lsp/fixtures/workspace-edit-server.mjs +11 -2
- package/packages/omo-codex/THIRD-PARTY-NOTICES.md +2 -2
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +21 -3
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/codegraph/AGENTS.md +11 -5
- package/packages/omo-codex/plugin/components/codegraph/NOTICE +1 -1
- package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +10373 -2570
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +7502 -574
- package/packages/omo-codex/plugin/components/codegraph/package.json +2 -2
- package/packages/omo-codex/plugin/components/codegraph/src/hook-input.ts +33 -0
- package/packages/omo-codex/plugin/components/codegraph/src/hook-types.ts +36 -10
- package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +164 -159
- package/packages/omo-codex/plugin/components/codegraph/src/post-tool-use-hook.ts +34 -0
- package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +20 -2
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-command.ts +106 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-cooldown.ts +145 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-hook-runtime.ts +21 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-lock.ts +139 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-outcome.ts +15 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-paths.ts +32 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-project.ts +109 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker-result.ts +148 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker.ts +126 -175
- package/packages/omo-codex/plugin/components/codegraph/test/hook-exclusion.test.ts +4 -4
- package/packages/omo-codex/plugin/components/codegraph/test/hook-session-start-guard.test.ts +160 -0
- package/packages/omo-codex/plugin/components/codegraph/test/hook-store-upgrade.test.ts +12 -138
- package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +34 -24
- package/packages/omo-codex/plugin/components/codegraph/test/mcp-bridge-fixtures.ts +3 -3
- package/packages/omo-codex/plugin/components/codegraph/test/package-runtime.test.ts +2 -2
- package/packages/omo-codex/plugin/components/codegraph/test/provisioned-node-guard.test.ts +5 -5
- package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge.test.ts +3 -3
- package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-facade.test.ts +1 -1
- package/packages/omo-codex/plugin/components/codegraph/test/serve-provision.test.ts +45 -0
- package/packages/omo-codex/plugin/components/codegraph/test/serve-unavailable.test.ts +2 -2
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-node-support.test.ts +70 -13
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-project.test.ts +58 -0
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-state.test.ts +104 -0
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-trust-boundary.test.ts +4 -2
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-cooldown.test.ts +116 -0
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-flow.test.ts +58 -57
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/dist/cli.js +32 -15
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +17 -0
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-start-work-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-checking-start-work-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +42 -41
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +6 -0
- package/packages/omo-codex/plugin/shared/src/config-loader.ts +165 -16
- package/packages/omo-codex/plugin/shared/src/config-migration.ts +162 -0
- package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +186 -9
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +4 -3
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/all-platforms.md +3 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +3 -0
- package/packages/omo-codex/plugin/skills/data-scientist/SKILL.md +243 -0
- package/packages/omo-codex/plugin/skills/data-scientist/agents/openai.yaml +2 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/common-scenarios.md +176 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/execution-templates.md +197 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/integration-patterns.md +153 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/performance-benchmarks.md +37 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/uv-setup.md +78 -0
- package/packages/omo-codex/plugin/skills/data-scientist/scripts/quick-query.py +111 -0
- package/packages/omo-codex/plugin/skills/data-scientist/scripts/setup-uv.ps1 +53 -0
- package/packages/omo-codex/plugin/skills/data-scientist/scripts/setup-uv.sh +60 -0
- package/packages/omo-codex/plugin/skills/debugging/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +7 -0
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +4 -1
- package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +8 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +14 -1
- package/packages/omo-codex/plugin/skills/frontend/references/design/interaction-skill.md +144 -0
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +1 -2
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +17 -0
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +121 -11
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +7 -0
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +12 -0
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +24 -5
- package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +4 -3
- package/packages/shared-skills/skills/coding-agent-sessions/references/all-platforms.md +3 -1
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +3 -0
- package/packages/shared-skills/skills/data-scientist/SKILL.md +243 -0
- package/packages/shared-skills/skills/data-scientist/references/common-scenarios.md +176 -0
- package/packages/shared-skills/skills/data-scientist/references/execution-templates.md +197 -0
- package/packages/shared-skills/skills/data-scientist/references/integration-patterns.md +153 -0
- package/packages/shared-skills/skills/data-scientist/references/performance-benchmarks.md +37 -0
- package/packages/shared-skills/skills/data-scientist/references/uv-setup.md +78 -0
- package/packages/shared-skills/skills/data-scientist/scripts/quick-query.py +111 -0
- package/packages/shared-skills/skills/data-scientist/scripts/setup-uv.ps1 +53 -0
- package/packages/shared-skills/skills/data-scientist/scripts/setup-uv.sh +60 -0
- package/packages/shared-skills/skills/debugging/SKILL.md +1 -1
- package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +7 -0
- package/packages/shared-skills/skills/frontend/SKILL.md +4 -1
- package/packages/shared-skills/skills/frontend/references/design/README.md +8 -0
- package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +14 -1
- package/packages/shared-skills/skills/frontend/references/design/interaction-skill.md +144 -0
- package/packages/shared-skills/skills/programming/SKILL.md +1 -2
- package/packages/shared-skills/skills/ulw-plan/SKILL.md +1 -1
- package/packages/shared-skills/skills/ulw-research/SKILL.md +122 -11
- package/dist/plugin-config/layered-config-loader.d.ts +0 -2
- package/dist/plugin-config/single-config-loader.d.ts +0 -4
- package/dist/shared/migrate-legacy-config-file.d.ts +0 -1
- package/dist/shared/migration/config-migration.d.ts +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { env as processEnv, stderr as processStderr } from "node:process";
|
|
2
|
+
|
|
3
|
+
import type { CodegraphCommandResolution } from "../../../../../utils/src/codegraph/resolve.ts";
|
|
4
|
+
import type { CodegraphSessionStartOutcome, WorkerAction } from "./hook-types.js";
|
|
5
|
+
import {
|
|
6
|
+
clearSessionStartCooldown,
|
|
7
|
+
recordSessionStartFailure,
|
|
8
|
+
type SessionStartFailureAction,
|
|
9
|
+
} from "./session-start-cooldown.js";
|
|
10
|
+
import type { CodegraphProjectState } from "./session-start-project.js";
|
|
11
|
+
|
|
12
|
+
export type WorkerResultContext = {
|
|
13
|
+
readonly baseCooldownMs: number;
|
|
14
|
+
readonly homeDir: string;
|
|
15
|
+
readonly logOutcome: (outcome: CodegraphSessionStartOutcome) => void;
|
|
16
|
+
readonly nowMs: () => number;
|
|
17
|
+
readonly projectRoot: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type WorkerRunResult = {
|
|
21
|
+
readonly action: WorkerAction;
|
|
22
|
+
readonly releaseLock: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function finishWorkerProjectState(
|
|
26
|
+
state: CodegraphProjectState,
|
|
27
|
+
context: WorkerResultContext,
|
|
28
|
+
): WorkerRunResult | null {
|
|
29
|
+
switch (state.kind) {
|
|
30
|
+
case "inconclusive":
|
|
31
|
+
return finishWorkerFailure("skipped-probe-error", "skipped-probe-error", {
|
|
32
|
+
error: state.reason,
|
|
33
|
+
projectRoot: context.projectRoot,
|
|
34
|
+
}, context);
|
|
35
|
+
case "initialized":
|
|
36
|
+
return finishWorkerSuccess("skipped-initialized", { projectRoot: context.projectRoot }, context);
|
|
37
|
+
case "nested-root":
|
|
38
|
+
return finishWorkerSuccess("skipped-nested-root", {
|
|
39
|
+
ancestorRoot: state.ancestorRoot,
|
|
40
|
+
projectRoot: context.projectRoot,
|
|
41
|
+
}, context);
|
|
42
|
+
case "uninitialized":
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function finishWorkerInitialization(
|
|
48
|
+
state: CodegraphProjectState,
|
|
49
|
+
detail: {
|
|
50
|
+
readonly exitCode: number;
|
|
51
|
+
readonly source: CodegraphCommandResolution["source"];
|
|
52
|
+
},
|
|
53
|
+
context: WorkerResultContext,
|
|
54
|
+
): WorkerRunResult {
|
|
55
|
+
switch (state.kind) {
|
|
56
|
+
case "inconclusive":
|
|
57
|
+
return finishWorkerFailure("skipped-probe-error", "skipped-probe-error", {
|
|
58
|
+
error: state.reason,
|
|
59
|
+
...detail,
|
|
60
|
+
projectRoot: context.projectRoot,
|
|
61
|
+
timedOut: false,
|
|
62
|
+
}, context);
|
|
63
|
+
case "initialized":
|
|
64
|
+
return finishWorkerSuccess("initialized", {
|
|
65
|
+
...detail,
|
|
66
|
+
projectRoot: context.projectRoot,
|
|
67
|
+
timedOut: false,
|
|
68
|
+
}, context);
|
|
69
|
+
case "nested-root":
|
|
70
|
+
return finishWorkerFailure("failed", "failed", {
|
|
71
|
+
...detail,
|
|
72
|
+
error: `codegraph init resolved to ancestor database at ${state.ancestorRoot}`,
|
|
73
|
+
projectRoot: context.projectRoot,
|
|
74
|
+
timedOut: false,
|
|
75
|
+
}, context);
|
|
76
|
+
case "uninitialized":
|
|
77
|
+
return finishWorkerFailure("failed", "failed", {
|
|
78
|
+
...detail,
|
|
79
|
+
error: "codegraph init completed without creating an exact project database",
|
|
80
|
+
projectRoot: context.projectRoot,
|
|
81
|
+
timedOut: false,
|
|
82
|
+
}, context);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function finishWorkerFailure(
|
|
87
|
+
action: WorkerAction,
|
|
88
|
+
failureAction: SessionStartFailureAction,
|
|
89
|
+
detail: Omit<CodegraphSessionStartOutcome, "action">,
|
|
90
|
+
context: WorkerResultContext,
|
|
91
|
+
): WorkerRunResult {
|
|
92
|
+
let releaseLock = true;
|
|
93
|
+
try {
|
|
94
|
+
recordSessionStartFailure({
|
|
95
|
+
action: failureAction,
|
|
96
|
+
baseCooldownMs: context.baseCooldownMs,
|
|
97
|
+
homeDir: context.homeDir,
|
|
98
|
+
nowMs: context.nowMs(),
|
|
99
|
+
projectRoot: context.projectRoot,
|
|
100
|
+
});
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (error instanceof Error) releaseLock = false;
|
|
103
|
+
else throw error;
|
|
104
|
+
}
|
|
105
|
+
safeLogWorkerOutcome(context.logOutcome, { ...detail, action });
|
|
106
|
+
return { action, releaseLock };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function finishWorkerSuccess(
|
|
110
|
+
action: WorkerAction,
|
|
111
|
+
detail: Omit<CodegraphSessionStartOutcome, "action">,
|
|
112
|
+
context: WorkerResultContext,
|
|
113
|
+
): WorkerRunResult {
|
|
114
|
+
try {
|
|
115
|
+
clearSessionStartCooldown({ homeDir: context.homeDir, projectRoot: context.projectRoot });
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (error instanceof Error) writeDebugLog(`failed to clear SessionStart cooldown: ${error.message}`);
|
|
118
|
+
else throw error;
|
|
119
|
+
}
|
|
120
|
+
safeLogWorkerOutcome(context.logOutcome, { ...detail, action });
|
|
121
|
+
return { action, releaseLock: true };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function finishWorkerNeutral(
|
|
125
|
+
action: WorkerAction,
|
|
126
|
+
detail: Omit<CodegraphSessionStartOutcome, "action">,
|
|
127
|
+
context: WorkerResultContext,
|
|
128
|
+
): WorkerRunResult {
|
|
129
|
+
safeLogWorkerOutcome(context.logOutcome, { ...detail, action });
|
|
130
|
+
return { action, releaseLock: true };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function safeLogWorkerOutcome(
|
|
134
|
+
logOutcome: (outcome: CodegraphSessionStartOutcome) => void,
|
|
135
|
+
outcome: CodegraphSessionStartOutcome,
|
|
136
|
+
): void {
|
|
137
|
+
try {
|
|
138
|
+
logOutcome(outcome);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (error instanceof Error) processStderr.write(`[codegraph-session-start] failed to write outcome: ${error.message}\n`);
|
|
141
|
+
else throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function writeDebugLog(message: string): void {
|
|
146
|
+
if (processEnv["OMO_CODEGRAPH_DEBUG"] !== "1") return;
|
|
147
|
+
processStderr.write(`[codegraph-session-start] ${message}\n`);
|
|
148
|
+
}
|
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
2
1
|
import { homedir } from "node:os";
|
|
3
|
-
import {
|
|
4
|
-
import { cwd as processCwd, env as processEnv, execPath as processExecPath, stderr as processStderr } from "node:process";
|
|
2
|
+
import { cwd as processCwd, env as processEnv } from "node:process";
|
|
5
3
|
|
|
6
4
|
import { getCodexOmoConfig } from "../../../shared/src/config-loader.ts";
|
|
7
|
-
import {
|
|
8
|
-
import { resolvePinnedCodegraphBin } from "../../../../../utils/src/codegraph/managed-runtime.ts";
|
|
9
|
-
import { CODEGRAPH_PINNED_VERSION } from "../../../../../utils/src/codegraph/manifest.ts";
|
|
5
|
+
import { hasCodegraphManagedInstall, resolvePinnedCodegraphBin } from "../../../../../utils/src/codegraph/managed-runtime.ts";
|
|
10
6
|
import { evaluateCodegraphNodeSupport, type CodegraphNodeSupport } from "../../../../../utils/src/codegraph/node-support.ts";
|
|
11
7
|
import { ensureCodegraphProvisioned } from "../../../../../utils/src/codegraph/provision.ts";
|
|
12
|
-
import {
|
|
13
|
-
codegraphCommandRequiresSupportedLocalNode,
|
|
14
|
-
resolveCodegraphCommand,
|
|
15
|
-
type CodegraphCommandResolution,
|
|
16
|
-
} from "../../../../../utils/src/codegraph/resolve.ts";
|
|
8
|
+
import { resolveCodegraphCommand } from "../../../../../utils/src/codegraph/resolve.ts";
|
|
17
9
|
import { ensureCodegraphGitignored, prepareCodegraphWorkspace } from "../../../../../utils/src/codegraph/workspace.ts";
|
|
18
|
-
import { runProcessWithTreeTimeout } from "../../../../../utils/src/process-tree.ts";
|
|
19
10
|
import type {
|
|
20
|
-
CodegraphCommandResult,
|
|
21
|
-
CodegraphConfig,
|
|
22
11
|
CodegraphSessionStartDeps,
|
|
23
12
|
CodegraphSessionStartOutcome,
|
|
24
13
|
SessionStartWorkerOptions,
|
|
25
14
|
WorkerAction,
|
|
26
15
|
} from "./hook-types.js";
|
|
16
|
+
import {
|
|
17
|
+
resolveSessionStartCommand,
|
|
18
|
+
runSessionStartCodegraphCommand,
|
|
19
|
+
SESSION_START_COMMAND_TIMEOUT_MS,
|
|
20
|
+
sessionStartCodegraphEnv,
|
|
21
|
+
type CodegraphBootstrapConfig,
|
|
22
|
+
} from "./session-start-command.js";
|
|
23
|
+
import { DEFAULT_SESSION_START_COOLDOWN_MS } from "./session-start-cooldown.js";
|
|
24
|
+
import { releaseSessionStartLock, sessionStartLockIsOwned, type SessionStartLock } from "./session-start-lock.js";
|
|
25
|
+
import { appendSessionStartOutcome } from "./session-start-outcome.js";
|
|
26
|
+
import { resolveSessionStartStatePaths } from "./session-start-paths.js";
|
|
27
|
+
import { probeCodegraphProject, type CodegraphProjectState } from "./session-start-project.js";
|
|
28
|
+
import {
|
|
29
|
+
finishWorkerFailure,
|
|
30
|
+
finishWorkerInitialization,
|
|
31
|
+
finishWorkerNeutral,
|
|
32
|
+
finishWorkerProjectState,
|
|
33
|
+
safeLogWorkerOutcome,
|
|
34
|
+
type WorkerResultContext,
|
|
35
|
+
type WorkerRunResult,
|
|
36
|
+
} from "./session-start-worker-result.js";
|
|
27
37
|
|
|
28
38
|
export const SESSION_START_CWD_ENV = "OMO_CODEGRAPH_SESSION_START_CWD";
|
|
39
|
+
export const SESSION_START_LOCK_TOKEN_ENV = "OMO_CODEGRAPH_SESSION_START_LOCK_TOKEN";
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
readonly trustedCodegraphInstallDir?: string;
|
|
41
|
+
type WorkerContext = WorkerResultContext & {
|
|
42
|
+
readonly config: CodegraphBootstrapConfig;
|
|
43
|
+
readonly deps: CodegraphSessionStartDeps;
|
|
44
|
+
readonly env: Record<string, string | undefined>;
|
|
45
|
+
readonly probeProject: (projectRoot: string) => CodegraphProjectState;
|
|
36
46
|
};
|
|
37
47
|
|
|
38
48
|
const defaultDeps: CodegraphSessionStartDeps = {
|
|
39
49
|
ensureGitignored: ensureCodegraphGitignored,
|
|
40
50
|
ensureProvisioned: ensureCodegraphProvisioned,
|
|
51
|
+
managedInstallExists: hasCodegraphManagedInstall,
|
|
41
52
|
prepareWorkspace: prepareCodegraphWorkspace,
|
|
42
53
|
resolveCommand: resolveCodegraphCommand,
|
|
43
|
-
|
|
54
|
+
resolveManagedBin: resolvePinnedCodegraphBin,
|
|
55
|
+
runCommand: runSessionStartCodegraphCommand,
|
|
44
56
|
};
|
|
45
57
|
|
|
46
58
|
export async function runCodegraphSessionStartWorker(options: SessionStartWorkerOptions = {}): Promise<{ readonly action: WorkerAction }> {
|
|
@@ -48,177 +60,116 @@ export async function runCodegraphSessionStartWorker(options: SessionStartWorker
|
|
|
48
60
|
const homeDir = resolveHomeDir(env);
|
|
49
61
|
const projectRoot = options.cwd ?? env[SESSION_START_CWD_ENV] ?? processCwd();
|
|
50
62
|
const config = options.config ?? getCodexOmoConfig({ cwd: projectRoot, env, homeDir });
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
const lock = resolveWorkerLock(homeDir, projectRoot, env[SESSION_START_LOCK_TOKEN_ENV]);
|
|
64
|
+
if (lock !== null && !sessionStartLockIsOwned(lock)) {
|
|
65
|
+
const outcome = { action: "skipped-locked", projectRoot } satisfies CodegraphSessionStartOutcome;
|
|
66
|
+
safeLogWorkerOutcome(options.logOutcome ?? ((value) => appendSessionStartOutcome(homeDir, value)), outcome);
|
|
67
|
+
return { action: "skipped-locked" };
|
|
55
68
|
}
|
|
56
69
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
const customResolutionDeps = options.deps?.resolveCommand === undefined
|
|
71
|
+
? {}
|
|
72
|
+
: {
|
|
73
|
+
managedInstallExists: options.deps.managedInstallExists ?? (() => false),
|
|
74
|
+
resolveManagedBin: options.deps.resolveManagedBin ?? (() => null),
|
|
75
|
+
};
|
|
76
|
+
const context: WorkerContext = {
|
|
77
|
+
baseCooldownMs: config.codegraph?.session_start_cooldown_ms ?? DEFAULT_SESSION_START_COOLDOWN_MS,
|
|
78
|
+
config: {
|
|
79
|
+
...(config.codegraph ?? {}),
|
|
80
|
+
...(config.trustedCodegraphInstallDir === undefined ? {} : { trustedCodegraphInstallDir: config.trustedCodegraphInstallDir }),
|
|
81
|
+
},
|
|
82
|
+
deps: { ...defaultDeps, ...customResolutionDeps, ...options.deps },
|
|
83
|
+
env,
|
|
84
|
+
homeDir,
|
|
85
|
+
logOutcome: options.logOutcome ?? ((outcome) => appendSessionStartOutcome(homeDir, outcome)),
|
|
86
|
+
nowMs: () => options.nowMs ?? Date.now(),
|
|
87
|
+
probeProject: options.projectProbe ?? probeCodegraphProject,
|
|
88
|
+
projectRoot,
|
|
61
89
|
};
|
|
62
|
-
|
|
90
|
+
|
|
91
|
+
let result: WorkerRunResult;
|
|
92
|
+
if (config.codegraph?.enabled === false) {
|
|
93
|
+
result = finishWorkerNeutral("skipped-disabled", { projectRoot }, context);
|
|
94
|
+
} else {
|
|
95
|
+
const nodeSupport = evaluateCodegraphNodeSupport({ env, nodeVersion: options.nodeVersion });
|
|
96
|
+
result = await runBootstrap(context, nodeSupport);
|
|
97
|
+
}
|
|
98
|
+
if (lock !== null && result.releaseLock) releaseSessionStartLock(lock);
|
|
99
|
+
return { action: result.action };
|
|
63
100
|
}
|
|
64
101
|
|
|
65
|
-
async function runBootstrap(
|
|
66
|
-
projectRoot: string,
|
|
67
|
-
config: CodegraphBootstrapConfig,
|
|
68
|
-
env: Record<string, string | undefined>,
|
|
69
|
-
homeDir: string,
|
|
70
|
-
nodeSupport: CodegraphNodeSupport,
|
|
71
|
-
deps: CodegraphSessionStartDeps,
|
|
72
|
-
logOutcome: (outcome: CodegraphSessionStartOutcome) => void,
|
|
73
|
-
): Promise<{ readonly action: WorkerAction }> {
|
|
102
|
+
async function runBootstrap(context: WorkerContext, nodeSupport: CodegraphNodeSupport): Promise<WorkerRunResult> {
|
|
74
103
|
try {
|
|
75
|
-
const
|
|
104
|
+
const projectState = context.probeProject(context.projectRoot);
|
|
105
|
+
const projectDecision = finishWorkerProjectState(projectState, context);
|
|
106
|
+
if (projectDecision !== null) return projectDecision;
|
|
107
|
+
|
|
108
|
+
const command = await resolveSessionStartCommand({
|
|
109
|
+
config: context.config,
|
|
110
|
+
deps: context.deps,
|
|
111
|
+
env: context.env,
|
|
112
|
+
homeDir: context.homeDir,
|
|
113
|
+
nodeSupport,
|
|
114
|
+
});
|
|
76
115
|
if (command.kind === "unavailable") {
|
|
77
|
-
return
|
|
116
|
+
return finishWorkerFailure("skipped-unavailable", "skipped-unavailable", {
|
|
117
|
+
error: command.error,
|
|
118
|
+
projectRoot: context.projectRoot,
|
|
119
|
+
source: command.source,
|
|
120
|
+
}, context);
|
|
78
121
|
}
|
|
79
122
|
if (command.kind === "unsupported-node") {
|
|
80
|
-
return
|
|
123
|
+
return finishWorkerFailure("skipped-unsupported-node", "skipped-unsupported-node", { projectRoot: context.projectRoot }, context);
|
|
81
124
|
}
|
|
82
125
|
|
|
83
|
-
deps.prepareWorkspace(projectRoot, { homeDir });
|
|
84
|
-
deps.ensureGitignored(projectRoot);
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (resolved.exists && canUseResolvedCommand(resolved, nodeSupport)) {
|
|
118
|
-
return { kind: "resolved", resolution: resolved };
|
|
119
|
-
}
|
|
120
|
-
if (resolved.exists && config.auto_provision === false) return { kind: "unsupported-node" };
|
|
121
|
-
if (config.auto_provision === false) return { error: "codegraph binary unavailable and auto_provision is disabled", kind: "unavailable", source: resolved.source };
|
|
122
|
-
|
|
123
|
-
const installDir = trustedInstallDir ?? join(homeDir, ".omo", "codegraph");
|
|
124
|
-
const provisioned = await deps.ensureProvisioned({ installDir, lockDir: join(installDir, ".locks"), version: CODEGRAPH_VERSION });
|
|
125
|
-
if (!provisioned.provisioned || provisioned.binPath === undefined) {
|
|
126
|
-
return { error: provisioned.error ?? "provisioning did not produce a binary", kind: "unavailable", source: resolved.source };
|
|
127
|
-
}
|
|
128
|
-
return { kind: "resolved", resolution: { argsPrefix: [], command: provisioned.binPath, exists: true, source: "provisioned" } };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function codegraphEnvForConfig(config: CodegraphBootstrapConfig, homeDir: string): Record<string, string> {
|
|
132
|
-
// The detached indexing worker must NEVER engage the upstream daemon, even
|
|
133
|
-
// when the user opted into daemon mode for interactive MCP sessions: a
|
|
134
|
-
// daemon-backed init/sync would outlive and race the worker's lifecycle.
|
|
135
|
-
const env = buildCodegraphEnv({ daemon: false, homeDir });
|
|
136
|
-
return config.trustedCodegraphInstallDir === undefined ? env : { ...env, CODEGRAPH_INSTALL_DIR: config.trustedCodegraphInstallDir };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function canUseResolvedCommand(resolved: CodegraphCommandResolution, nodeSupport: CodegraphNodeSupport): boolean {
|
|
140
|
-
return !codegraphCommandRequiresSupportedLocalNode(resolved) || nodeSupport.supported;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function decideStartupAction(status: CodegraphCommandResult): { readonly kind: "init" } | { readonly kind: "skip"; readonly reason: string } | { readonly kind: "sync" } {
|
|
144
|
-
if (status.timedOut) return { kind: "skip", reason: "status timed out" };
|
|
145
|
-
const text = `${status.stdout}\n${status.stderr ?? ""}`.toLowerCase();
|
|
146
|
-
if (text.includes("not initialized") || text.includes("uninitialized")) return { kind: "init" };
|
|
147
|
-
const initialized = jsonSaysInitialized(parseJson(status.stdout));
|
|
148
|
-
if (initialized === false) return { kind: "init" };
|
|
149
|
-
if (initialized === true) return { kind: "sync" };
|
|
150
|
-
if (status.exitCode !== 0) return { kind: "skip", reason: `status exited ${status.exitCode}` };
|
|
151
|
-
return { kind: "sync" };
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function jsonSaysInitialized(value: unknown): boolean | undefined {
|
|
155
|
-
if (!isRecord(value)) return undefined;
|
|
156
|
-
const initialized = value["initialized"] ?? value["isInitialized"] ?? value["ready"];
|
|
157
|
-
if (typeof initialized === "boolean") return initialized;
|
|
158
|
-
const status = value["status"];
|
|
159
|
-
if (typeof status !== "string") return undefined;
|
|
160
|
-
const normalized = status.toLowerCase();
|
|
161
|
-
if (normalized.includes("not initialized") || normalized.includes("uninitialized")) return false;
|
|
162
|
-
if (normalized.includes("initialized") || normalized.includes("ready")) return true;
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async function runCodegraphCommand(projectRoot: string, command: string, args: readonly string[], options: { readonly env: Record<string, string>; readonly timeoutMs: number }): Promise<CodegraphCommandResult> {
|
|
167
|
-
const invocation = resolveCodegraphCommandInvocation(command, args);
|
|
168
|
-
return runProcessWithTreeTimeout({
|
|
169
|
-
args: invocation.args,
|
|
170
|
-
command: invocation.command,
|
|
171
|
-
cwd: projectRoot,
|
|
172
|
-
env: buildCodegraphChildEnv({ ambientEnv: processEnv, codegraphEnv: options.env }),
|
|
173
|
-
maxBuffer: 1024 * 1024,
|
|
174
|
-
timeoutMs: options.timeoutMs,
|
|
175
|
-
}).then(({ exitCode, stderr, stdout, timedOut }) => ({ exitCode, stderr, stdout, timedOut }));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export function resolveCodegraphCommandInvocation(
|
|
179
|
-
command: string,
|
|
180
|
-
args: readonly string[],
|
|
181
|
-
platform: NodeJS.Platform = process.platform,
|
|
182
|
-
): { readonly args: readonly string[]; readonly command: string } {
|
|
183
|
-
if (platform !== "win32") return { args: [...args], command };
|
|
184
|
-
const extension = extname(command).toLowerCase();
|
|
185
|
-
if (WINDOWS_NODE_SCRIPT_EXTENSIONS.has(extension)) return { args: [command, ...args], command: processExecPath };
|
|
186
|
-
if (!WINDOWS_CMD_EXTENSIONS.has(extension)) return { args: [...args], command };
|
|
187
|
-
return { args: ["/d", "/s", "/c", command, ...args], command: "cmd.exe" };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function appendOutcome(homeDir: string, outcome: CodegraphSessionStartOutcome): void {
|
|
191
|
-
const logDir = join(homeDir, ".omo", "codegraph");
|
|
192
|
-
mkdirSync(logDir, { recursive: true });
|
|
193
|
-
appendFileSync(join(logDir, "session-start.jsonl"), `${JSON.stringify({ ...outcome, timestamp: new Date().toISOString() })}\n`);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function safeLogOutcome(logOutcome: (outcome: CodegraphSessionStartOutcome) => void, outcome: CodegraphSessionStartOutcome): void {
|
|
197
|
-
try {
|
|
198
|
-
logOutcome(outcome);
|
|
126
|
+
context.deps.prepareWorkspace(context.projectRoot, { homeDir: context.homeDir });
|
|
127
|
+
context.deps.ensureGitignored(context.projectRoot);
|
|
128
|
+
const preparedState = context.probeProject(context.projectRoot);
|
|
129
|
+
const preparedDecision = finishWorkerProjectState(preparedState, context);
|
|
130
|
+
if (preparedDecision !== null) return preparedDecision;
|
|
131
|
+
|
|
132
|
+
const action = await context.deps.runCommand(
|
|
133
|
+
context.projectRoot,
|
|
134
|
+
command.resolution.command,
|
|
135
|
+
[...command.resolution.argsPrefix, "init"],
|
|
136
|
+
{ env: sessionStartCodegraphEnv(context.config, context.homeDir), timeoutMs: SESSION_START_COMMAND_TIMEOUT_MS },
|
|
137
|
+
);
|
|
138
|
+
if (action.timedOut) {
|
|
139
|
+
return finishWorkerFailure("failed", "timeout", {
|
|
140
|
+
error: "codegraph init timed out",
|
|
141
|
+
exitCode: action.exitCode,
|
|
142
|
+
projectRoot: context.projectRoot,
|
|
143
|
+
source: command.resolution.source,
|
|
144
|
+
timedOut: true,
|
|
145
|
+
}, context);
|
|
146
|
+
}
|
|
147
|
+
if (action.exitCode !== 0) {
|
|
148
|
+
return finishWorkerFailure("failed", "failed", {
|
|
149
|
+
error: `codegraph init exited ${action.exitCode}`,
|
|
150
|
+
exitCode: action.exitCode,
|
|
151
|
+
projectRoot: context.projectRoot,
|
|
152
|
+
source: command.resolution.source,
|
|
153
|
+
timedOut: false,
|
|
154
|
+
}, context);
|
|
155
|
+
}
|
|
156
|
+
return finishWorkerInitialization(context.probeProject(context.projectRoot), {
|
|
157
|
+
exitCode: action.exitCode,
|
|
158
|
+
source: command.resolution.source,
|
|
159
|
+
}, context);
|
|
199
160
|
} catch (error) {
|
|
200
|
-
|
|
201
|
-
|
|
161
|
+
return finishWorkerFailure("failed", "failed", {
|
|
162
|
+
error: error instanceof Error ? error.message : String(error),
|
|
163
|
+
projectRoot: context.projectRoot,
|
|
164
|
+
}, context);
|
|
202
165
|
}
|
|
203
166
|
}
|
|
204
167
|
|
|
205
|
-
function
|
|
206
|
-
|
|
168
|
+
function resolveWorkerLock(homeDir: string, projectRoot: string, token: string | undefined): SessionStartLock | null {
|
|
169
|
+
if (token === undefined || token.length === 0) return null;
|
|
170
|
+
return { path: resolveSessionStartStatePaths(homeDir, projectRoot).lockPath, token };
|
|
207
171
|
}
|
|
208
172
|
|
|
209
173
|
function resolveHomeDir(env: Record<string, string | undefined>): string {
|
|
210
174
|
return env["HOME"] ?? env["USERPROFILE"] ?? homedir();
|
|
211
175
|
}
|
|
212
|
-
|
|
213
|
-
function parseJson(text: string): unknown {
|
|
214
|
-
try {
|
|
215
|
-
return JSON.parse(text);
|
|
216
|
-
} catch (error) {
|
|
217
|
-
if (error instanceof SyntaxError) return undefined;
|
|
218
|
-
throw error;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
223
|
-
return typeof value === "object" && value !== null;
|
|
224
|
-
}
|
|
@@ -34,8 +34,8 @@ describe("CodeGraph SessionStart exclusion policy", () => {
|
|
|
34
34
|
stdin: Readable.from(["{}"]),
|
|
35
35
|
stdout: { write: (chunk) => stdout.push(chunk) },
|
|
36
36
|
spawnWorker: (invocation) => spawned.push(invocation),
|
|
37
|
-
|
|
38
|
-
throw new Error("excluded projects must not probe CodeGraph
|
|
37
|
+
ancestorProbe: () => {
|
|
38
|
+
throw new Error("excluded projects must not probe CodeGraph ancestors");
|
|
39
39
|
},
|
|
40
40
|
sweepZombies: () => {
|
|
41
41
|
sweepCalls += 1;
|
|
@@ -68,8 +68,8 @@ describe("CodeGraph SessionStart exclusion policy", () => {
|
|
|
68
68
|
env: { HOME: "/tmp/home" },
|
|
69
69
|
stdin: Readable.from(["{}"]),
|
|
70
70
|
stdout: { write: (chunk) => stdout.push(chunk) },
|
|
71
|
+
ancestorProbe: () => ({ kind: "uninitialized" }),
|
|
71
72
|
spawnWorker: (invocation) => spawned.push(invocation),
|
|
72
|
-
statusProbe: () => Promise.resolve(false),
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
// then
|
|
@@ -97,8 +97,8 @@ describe("CodeGraph SessionStart exclusion policy", () => {
|
|
|
97
97
|
env: { HOME: "/tmp/home" },
|
|
98
98
|
stdin: Readable.from(["{}"]),
|
|
99
99
|
stdout: { write: (chunk) => stdout.push(chunk) },
|
|
100
|
+
ancestorProbe: () => ({ kind: "uninitialized" }),
|
|
100
101
|
spawnWorker: (invocation) => spawned.push(invocation),
|
|
101
|
-
statusProbe: () => Promise.resolve(false),
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
// then
|