oh-my-opencode 4.19.1 → 4.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -2
- package/README.ko.md +2 -2
- package/README.md +2 -2
- package/README.ru.md +2 -2
- package/README.zh-cn.md +2 -2
- package/dist/agents/atlas/agent.d.ts +4 -2
- package/dist/agents/explore.d.ts +4 -2
- package/dist/agents/hephaestus/agent.d.ts +4 -2
- package/dist/agents/librarian.d.ts +4 -2
- package/dist/agents/metis.d.ts +4 -2
- package/dist/agents/momus.d.ts +3 -2
- package/dist/agents/multimodal-looker.d.ts +4 -2
- package/dist/agents/oracle.d.ts +4 -2
- package/dist/agents/sisyphus/claude-opus-5.d.ts +33 -0
- package/dist/agents/sisyphus/index.d.ts +2 -0
- package/dist/agents/sisyphus-agent-factory.d.ts +5 -2
- package/dist/agents/sisyphus-junior/agent.d.ts +4 -1
- package/dist/agents/types.d.ts +2 -2
- package/dist/cli/index.js +23454 -19200
- package/dist/cli-node/index.js +23454 -19200
- package/dist/config/schema/agent-names.d.ts +26 -26
- package/dist/config/schema/agent-overrides.d.ts +400 -400
- package/dist/config/schema/browser-automation.d.ts +2 -2
- package/dist/config/schema/categories.d.ts +36 -36
- package/dist/config/schema/commands.d.ts +2 -2
- package/dist/config/schema/dynamic-context-pruning.d.ts +1 -1
- package/dist/config/schema/experimental.d.ts +1 -1
- package/dist/config/schema/fallback-models.d.ts +25 -25
- package/dist/config/schema/hooks.d.ts +43 -43
- package/dist/config/schema/internal/permission.d.ts +9 -9
- package/dist/config/schema/keyword-detector.d.ts +6 -6
- package/dist/config/schema/oh-my-opencode-config.d.ts +402 -402
- package/dist/config/schema/tmux.d.ts +6 -6
- package/dist/create-hooks.d.ts +35 -35
- package/dist/features/background-agent/spawner/tmux-callback-invoker.d.ts +11 -0
- package/dist/features/builtin-commands/templates/start-work.d.ts +1 -1
- package/dist/features/claude-tasks/types.d.ts +4 -4
- package/dist/features/team-mode/team-runtime/shutdown-helpers.d.ts +1 -1
- package/dist/features/team-mode/team-runtime/shutdown-test-fixtures.d.ts +4 -4
- package/dist/features/team-mode/tools/lifecycle-test-fixture.d.ts +42 -42
- package/dist/features/tmux-subagent/environment-eligibility.d.ts +2 -0
- package/dist/features/tmux-subagent/index.d.ts +1 -0
- package/dist/features/tmux-subagent/tracked-session-state.d.ts +1 -0
- package/dist/features/tui-sidebar/snapshot-schema.d.ts +6 -6
- package/dist/help/schema/acp.d.ts +3 -3
- package/dist/help/schema/doctor.d.ts +4 -4
- package/dist/help/schema/status.d.ts +3 -3
- package/dist/hooks/goal/types.d.ts +5 -5
- package/dist/hooks/non-interactive-env/constants.d.ts +4 -1
- package/dist/hooks/start-work/parse-user-request.d.ts +2 -0
- package/dist/hooks/start-work/worktree-block.d.ts +5 -0
- package/dist/index.js +25231 -20301
- package/dist/mcp/types.d.ts +3 -3
- package/dist/oh-my-opencode.schema.json +1 -1
- package/dist/plugin/chat-message/loop-commands.d.ts +1 -0
- package/dist/plugin/command-execute-before.d.ts +3 -3
- package/dist/plugin/hooks/create-core-hooks.d.ts +25 -25
- package/dist/shared/tmux/tmux-utils/environment.d.ts +1 -1
- package/dist/shared/tmux/tmux-utils.d.ts +1 -1
- package/dist/shared/typescript-native-source-parser.d.ts +7 -0
- package/dist/skills/coding-agent-sessions/SKILL.md +5 -2
- package/dist/skills/coding-agent-sessions/references/all-platforms.md +3 -1
- package/dist/skills/coding-agent-sessions/references/senpi.md +15 -5
- package/dist/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
- package/dist/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +19 -10
- package/dist/skills/debugging/SKILL.md +2 -1
- package/dist/skills/debugging/references/methodology/03-flaky-triage.md +47 -0
- package/dist/skills/programming/SKILL.md +11 -1
- package/dist/skills/programming/references/logging.md +6 -1
- package/dist/skills/programming/scripts/typescript/check-no-excuse-rules.ts +51 -17
- package/dist/skills/start-work/SKILL.md +12 -2
- package/dist/skills/ulw-plan/SKILL.md +1 -1
- package/dist/skills/ulw-plan/references/full-workflow.md +12 -1
- package/dist/skills/ulw-plan/references/intent-clear.md +1 -1
- package/dist/tools/task/types.d.ts +10 -10
- package/dist/tui.js +23468 -19218
- package/package.json +14 -14
- package/packages/lsp-core/src/lsp/client-diagnostics-freshness.integration.test.ts +2 -2
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +8 -4
- 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/dist/cli.js +296 -206
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +126 -86
- package/packages/omo-codex/plugin/components/codegraph/package.json +1 -1
- package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +21 -42
- package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +3 -4
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker.ts +12 -23
- package/packages/omo-codex/plugin/components/codegraph/test/hook-exclusion.test.ts +5 -0
- package/packages/omo-codex/plugin/components/codegraph/test/hook-store-upgrade.test.ts +33 -5
- package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +6 -1
- package/packages/omo-codex/plugin/components/codegraph/test/provisioned-node-guard.test.ts +6 -0
- package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-facade.test.ts +1 -0
- package/packages/omo-codex/plugin/components/codegraph/test/serve-provision.test.ts +5 -5
- package/packages/omo-codex/plugin/components/codegraph/test/serve-unavailable.test.ts +1 -0
- package/packages/omo-codex/plugin/components/codegraph/test/serve.test.ts +24 -13
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-flow.test.ts +58 -64
- 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/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/directive.md +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/directive.md +12 -7
- 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/ultrawork/SKILL.md +12 -7
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +12 -1
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-clear.md +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/directive.md +12 -7
- 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 +2 -1
- 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 +13 -13
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +10 -9
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +5 -2
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/all-platforms.md +3 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/senpi.md +15 -5
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +19 -10
- package/packages/omo-codex/plugin/skills/debugging/SKILL.md +2 -1
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/03-flaky-triage.md +47 -0
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +11 -1
- package/packages/omo-codex/plugin/skills/programming/references/logging.md +6 -1
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/check-no-excuse-rules.ts +51 -17
- package/packages/omo-codex/plugin/skills/start-work/SKILL.md +12 -2
- package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +12 -7
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +2 -1
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +12 -1
- package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-clear.md +1 -1
- package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +22 -0
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +1 -1
- package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +5 -2
- package/packages/shared-skills/skills/coding-agent-sessions/references/all-platforms.md +3 -1
- package/packages/shared-skills/skills/coding-agent-sessions/references/senpi.md +15 -5
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +19 -10
- package/packages/shared-skills/skills/debugging/SKILL.md +2 -1
- package/packages/shared-skills/skills/debugging/references/methodology/03-flaky-triage.md +47 -0
- package/packages/shared-skills/skills/programming/SKILL.md +11 -1
- package/packages/shared-skills/skills/programming/references/logging.md +6 -1
- package/packages/shared-skills/skills/programming/scripts/typescript/check-no-excuse-rules.ts +51 -17
- package/packages/shared-skills/skills/start-work/SKILL.md +12 -2
- package/packages/shared-skills/skills/ulw-plan/SKILL.md +1 -1
- package/packages/shared-skills/skills/ulw-plan/references/full-workflow.md +12 -1
- package/packages/shared-skills/skills/ulw-plan/references/intent-clear.md +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/serve.ts
|
|
4
|
-
import { existsSync as
|
|
4
|
+
import { existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
|
|
5
5
|
import { homedir as homedir7 } from "node:os";
|
|
6
|
-
import { basename as basename3, join as
|
|
6
|
+
import { basename as basename3, join as join8, resolve as resolve4 } from "node:path";
|
|
7
7
|
import {
|
|
8
8
|
cwd as processCwd,
|
|
9
9
|
env as processEnv,
|
|
@@ -62,7 +62,7 @@ function buildCodegraphEnv(options = {}) {
|
|
|
62
62
|
const homeDir = options.homeDir ?? homedir();
|
|
63
63
|
return {
|
|
64
64
|
[CODEGRAPH_INSTALL_DIR_ENV]: join(homeDir, ".omo", "codegraph"),
|
|
65
|
-
...options.daemon ===
|
|
65
|
+
...options.daemon === false ? { [CODEGRAPH_NO_DAEMON_ENV]: "1" } : {},
|
|
66
66
|
[CODEGRAPH_NO_DOWNLOAD_ENV]: "1",
|
|
67
67
|
[CODEGRAPH_TELEMETRY_ENV]: "0",
|
|
68
68
|
[DO_NOT_TRACK_ENV]: "1"
|
|
@@ -89,6 +89,15 @@ function buildCodegraphChildEnv(options = {}) {
|
|
|
89
89
|
return env;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
// ../../../../utils/src/codegraph/managed-runtime.ts
|
|
93
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
94
|
+
import { join as join2, resolve } from "node:path";
|
|
95
|
+
|
|
96
|
+
// ../../../../utils/src/record-type-guard.ts
|
|
97
|
+
function isPlainRecord(value) {
|
|
98
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
// ../../../../utils/src/codegraph/manifest.ts
|
|
93
102
|
var CODEGRAPH_PINNED_VERSION = "1.4.1";
|
|
94
103
|
var CODEGRAPH_PROVISION_MANIFEST = {
|
|
@@ -127,6 +136,44 @@ var CODEGRAPH_PROVISION_MANIFEST = {
|
|
|
127
136
|
version: CODEGRAPH_PINNED_VERSION
|
|
128
137
|
};
|
|
129
138
|
|
|
139
|
+
// ../../../../utils/src/codegraph/managed-runtime.ts
|
|
140
|
+
function resolvePinnedCodegraphBin(installDir, options = {}) {
|
|
141
|
+
if (installDir === undefined)
|
|
142
|
+
return null;
|
|
143
|
+
const fileExists = options.fileExists ?? existsSync;
|
|
144
|
+
const readText = options.readText ?? ((filePath) => readFileSync(filePath, "utf8"));
|
|
145
|
+
const expectedBin = join2(installDir, "bin", (options.platform ?? process.platform) === "win32" ? "codegraph.cmd" : "codegraph");
|
|
146
|
+
const markerPath = join2(installDir, ".provisioned", `codegraph-${CODEGRAPH_PINNED_VERSION}.json`);
|
|
147
|
+
if (!fileExists(expectedBin) || !fileExists(markerPath))
|
|
148
|
+
return null;
|
|
149
|
+
let markerText;
|
|
150
|
+
try {
|
|
151
|
+
markerText = readText(markerPath);
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const marker = parseProvisionMarker(markerText);
|
|
156
|
+
if (marker === null || marker.version !== CODEGRAPH_PINNED_VERSION)
|
|
157
|
+
return null;
|
|
158
|
+
return resolve(marker.binPath) === resolve(expectedBin) ? expectedBin : null;
|
|
159
|
+
}
|
|
160
|
+
function parseProvisionMarker(text) {
|
|
161
|
+
try {
|
|
162
|
+
const value = JSON.parse(text);
|
|
163
|
+
if (!isPlainRecord(value))
|
|
164
|
+
return null;
|
|
165
|
+
const binPath = value["binPath"];
|
|
166
|
+
const version = value["version"];
|
|
167
|
+
if (typeof binPath !== "string" || typeof version !== "string")
|
|
168
|
+
return null;
|
|
169
|
+
return { binPath, version };
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (error instanceof SyntaxError)
|
|
172
|
+
return null;
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
130
177
|
// ../../../../utils/src/codegraph/node-support.ts
|
|
131
178
|
var CODEGRAPH_MIN_NODE_MAJOR = 20;
|
|
132
179
|
var CODEGRAPH_BLOCKED_NODE_MAJOR = 25;
|
|
@@ -160,9 +207,9 @@ function parseNodeMajor(version) {
|
|
|
160
207
|
import { createHash, randomUUID } from "node:crypto";
|
|
161
208
|
import { execFile } from "node:child_process";
|
|
162
209
|
import { chmod, mkdir, readdir, readFile, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
163
|
-
import { existsSync } from "node:fs";
|
|
210
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
164
211
|
import { homedir as homedir2, hostname } from "node:os";
|
|
165
|
-
import { basename, join as
|
|
212
|
+
import { basename, join as join3 } from "node:path";
|
|
166
213
|
import { promisify } from "node:util";
|
|
167
214
|
var DEFAULT_LOCK_WAIT_MS = 5000;
|
|
168
215
|
var DEFAULT_LOCK_STALE_MS = 120000;
|
|
@@ -172,10 +219,10 @@ function platformKey() {
|
|
|
172
219
|
return `${process.platform}-${process.arch}`;
|
|
173
220
|
}
|
|
174
221
|
function markerPath(installDir, version) {
|
|
175
|
-
return
|
|
222
|
+
return join3(installDir, ".provisioned", `codegraph-${version}.json`);
|
|
176
223
|
}
|
|
177
224
|
function defaultInstallDir() {
|
|
178
|
-
return
|
|
225
|
+
return join3(homedir2(), ".omo", "codegraph");
|
|
179
226
|
}
|
|
180
227
|
function sha256(bytes) {
|
|
181
228
|
return createHash("sha256").update(bytes).digest("hex");
|
|
@@ -195,7 +242,7 @@ async function removeEmptyDirectory(path) {
|
|
|
195
242
|
}
|
|
196
243
|
}
|
|
197
244
|
function sleep(ms) {
|
|
198
|
-
return new Promise((
|
|
245
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
199
246
|
}
|
|
200
247
|
async function defaultDownloader(asset, timeoutMs = DEFAULT_DOWNLOAD_TIMEOUT_MS) {
|
|
201
248
|
const response = await fetch(asset.url, { signal: AbortSignal.timeout(timeoutMs) });
|
|
@@ -209,7 +256,7 @@ function forcedBadChecksumOptions(options) {
|
|
|
209
256
|
const key = options.platformKey ?? platformKey();
|
|
210
257
|
return {
|
|
211
258
|
downloader: async () => new TextEncoder().encode("checksum mismatch"),
|
|
212
|
-
installDir: options.installDir ??
|
|
259
|
+
installDir: options.installDir ?? join3(options.lockDir, "codegraph-force-bad-checksum"),
|
|
213
260
|
manifest: {
|
|
214
261
|
assets: {
|
|
215
262
|
[key]: { executableName: process.platform === "win32" ? "codegraph.cmd" : "codegraph", sha256: "0000", url: "memory://bad" }
|
|
@@ -220,13 +267,13 @@ function forcedBadChecksumOptions(options) {
|
|
|
220
267
|
};
|
|
221
268
|
}
|
|
222
269
|
async function readMarker(path) {
|
|
223
|
-
if (!
|
|
270
|
+
if (!existsSync2(path))
|
|
224
271
|
return null;
|
|
225
272
|
try {
|
|
226
273
|
const raw = JSON.parse(await readFile(path, "utf8"));
|
|
227
274
|
if (typeof raw === "object" && raw !== null && "binPath" in raw) {
|
|
228
275
|
const value = raw.binPath;
|
|
229
|
-
return typeof value === "string" &&
|
|
276
|
+
return typeof value === "string" && existsSync2(value) ? value : null;
|
|
230
277
|
}
|
|
231
278
|
return null;
|
|
232
279
|
} catch (error) {
|
|
@@ -237,7 +284,7 @@ async function readMarker(path) {
|
|
|
237
284
|
}
|
|
238
285
|
async function acquireLock(lockPath, waitMs, staleMs) {
|
|
239
286
|
const startedAt = Date.now();
|
|
240
|
-
await mkdir(
|
|
287
|
+
await mkdir(join3(lockPath, ".."), { recursive: true });
|
|
241
288
|
while (Date.now() - startedAt <= waitMs) {
|
|
242
289
|
try {
|
|
243
290
|
await mkdir(lockPath);
|
|
@@ -262,24 +309,24 @@ async function installExtractedBundle(extractDir, installDir, executableName) {
|
|
|
262
309
|
const roots = await readdir(extractDir);
|
|
263
310
|
if (roots.length !== 1)
|
|
264
311
|
throw new Error(`CodeGraph archive should contain one root directory, found ${roots.length}`);
|
|
265
|
-
const bundleDir =
|
|
312
|
+
const bundleDir = join3(extractDir, roots[0] ?? "");
|
|
266
313
|
const bundleEntries = await readdir(bundleDir);
|
|
267
314
|
await mkdir(installDir, { recursive: true });
|
|
268
315
|
for (const entry of bundleEntries) {
|
|
269
|
-
await rm(
|
|
270
|
-
await rename(
|
|
316
|
+
await rm(join3(installDir, entry), { force: true, recursive: true });
|
|
317
|
+
await rename(join3(bundleDir, entry), join3(installDir, entry));
|
|
271
318
|
}
|
|
272
|
-
const destination =
|
|
273
|
-
if (!
|
|
319
|
+
const destination = join3(installDir, "bin", executableName);
|
|
320
|
+
if (!existsSync2(destination))
|
|
274
321
|
throw new Error(`CodeGraph archive did not contain bin/${executableName}`);
|
|
275
322
|
await chmod(destination, 493);
|
|
276
323
|
return destination;
|
|
277
324
|
}
|
|
278
325
|
async function installAsset(layout) {
|
|
279
326
|
const { asset, downloader, installDir, version } = layout;
|
|
280
|
-
const stagingDir =
|
|
281
|
-
const archivePath =
|
|
282
|
-
const extractDir =
|
|
327
|
+
const stagingDir = join3(installDir, ".staging", randomUUID());
|
|
328
|
+
const archivePath = join3(stagingDir, basename(asset.url));
|
|
329
|
+
const extractDir = join3(stagingDir, "extract");
|
|
283
330
|
try {
|
|
284
331
|
await mkdir(extractDir, { recursive: true });
|
|
285
332
|
const bytes = await downloader(asset);
|
|
@@ -293,13 +340,13 @@ async function installAsset(layout) {
|
|
|
293
340
|
await writeFile(archivePath, bytes);
|
|
294
341
|
await extractTarGz(archivePath, extractDir);
|
|
295
342
|
const destination = await installExtractedBundle(extractDir, installDir, asset.executableName);
|
|
296
|
-
await mkdir(
|
|
343
|
+
await mkdir(join3(installDir, ".provisioned"), { recursive: true });
|
|
297
344
|
await writeFile(markerPath(installDir, version), `${JSON.stringify({ binPath: destination, version })}
|
|
298
345
|
`);
|
|
299
346
|
return destination;
|
|
300
347
|
} finally {
|
|
301
348
|
await rm(stagingDir, { force: true, recursive: true });
|
|
302
|
-
await removeEmptyDirectory(
|
|
349
|
+
await removeEmptyDirectory(join3(installDir, ".staging"));
|
|
303
350
|
}
|
|
304
351
|
}
|
|
305
352
|
async function ensureCodegraphProvisioned(options) {
|
|
@@ -312,7 +359,7 @@ async function ensureCodegraphProvisioned(options) {
|
|
|
312
359
|
const existing = await readMarker(marker);
|
|
313
360
|
if (existing !== null)
|
|
314
361
|
return { binPath: existing, provisioned: true };
|
|
315
|
-
const lockPath =
|
|
362
|
+
const lockPath = join3(options.lockDir, `codegraph-${hostname()}.lock`);
|
|
316
363
|
const release = await acquireLock(lockPath, options.lockWaitMs ?? DEFAULT_LOCK_WAIT_MS, options.lockStaleMs ?? DEFAULT_LOCK_STALE_MS);
|
|
317
364
|
if (release === null)
|
|
318
365
|
return { error: "timed out waiting for codegraph provisioning lock", provisioned: false };
|
|
@@ -337,15 +384,15 @@ async function ensureCodegraphProvisioned(options) {
|
|
|
337
384
|
}
|
|
338
385
|
|
|
339
386
|
// ../../../../utils/src/codegraph/resolve.ts
|
|
340
|
-
import { existsSync as
|
|
387
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
341
388
|
import { homedir as homedir3 } from "node:os";
|
|
342
389
|
import { spawnSync } from "node:child_process";
|
|
343
|
-
import { basename as basename2, dirname, join as
|
|
390
|
+
import { basename as basename2, dirname, join as join5 } from "node:path";
|
|
344
391
|
import { createRequire } from "node:module";
|
|
345
392
|
|
|
346
393
|
// ../../../../utils/src/runtime/which.ts
|
|
347
394
|
import { accessSync, constants } from "node:fs";
|
|
348
|
-
import { delimiter, join as
|
|
395
|
+
import { delimiter, join as join4 } from "node:path";
|
|
349
396
|
var runtime = globalThis;
|
|
350
397
|
function isUnsafeCommandName(commandName) {
|
|
351
398
|
if (commandName.includes("/") || commandName.includes("\\"))
|
|
@@ -400,7 +447,7 @@ function bunWhich(commandName) {
|
|
|
400
447
|
return null;
|
|
401
448
|
for (const pathEntry of pathEntries) {
|
|
402
449
|
for (const candidateName of candidateNames) {
|
|
403
|
-
const candidatePath =
|
|
450
|
+
const candidatePath = join4(pathEntry, candidateName);
|
|
404
451
|
if (isExecutable(candidatePath))
|
|
405
452
|
return candidatePath;
|
|
406
453
|
}
|
|
@@ -488,18 +535,13 @@ function defaultNodeRuntime(env, fileExists, which, nodeVersion) {
|
|
|
488
535
|
return null;
|
|
489
536
|
}
|
|
490
537
|
function defaultProvisionedBin(homeDir, fileExists) {
|
|
491
|
-
|
|
492
|
-
const candidates = [
|
|
493
|
-
join4(homeDir, ".omo", "codegraph", "bin", binaryName),
|
|
494
|
-
join4(homeDir, ".omo", "codegraph", "node-servers", "node_modules", ".bin", binaryName)
|
|
495
|
-
];
|
|
496
|
-
return candidates.find((candidate) => fileExists(candidate)) ?? null;
|
|
538
|
+
return resolvePinnedCodegraphBin(join5(homeDir, ".omo", "codegraph"), { fileExists });
|
|
497
539
|
}
|
|
498
540
|
function resolveBundledShim(requireResolve, fileExists) {
|
|
499
541
|
try {
|
|
500
542
|
const packageJson = requireResolve(`${CODEGRAPH_PACKAGE}/package.json`);
|
|
501
543
|
const packageRoot = dirname(packageJson);
|
|
502
|
-
const candidates = [
|
|
544
|
+
const candidates = [join5(packageRoot, "bin", "codegraph.js"), join5(packageRoot, "npm-shim.js")];
|
|
503
545
|
return candidates.find((candidate) => fileExists(candidate)) ?? null;
|
|
504
546
|
} catch (error) {
|
|
505
547
|
if (error instanceof Error)
|
|
@@ -515,7 +557,7 @@ function resolveBundledShim(requireResolve, fileExists) {
|
|
|
515
557
|
}
|
|
516
558
|
function resolveCodegraphCommand(options = {}) {
|
|
517
559
|
const env = options.env ?? process.env;
|
|
518
|
-
const fileExists = options.fileExists ??
|
|
560
|
+
const fileExists = options.fileExists ?? existsSync3;
|
|
519
561
|
const configuredBin = env[CODEGRAPH_ENV_BIN]?.trim() || env[CODEGRAPH_LEGACY_ENV_BIN]?.trim();
|
|
520
562
|
if (configuredBin !== undefined && configuredBin.length > 0) {
|
|
521
563
|
return { argsPrefix: [], command: configuredBin, exists: fileExists(configuredBin), source: "env" };
|
|
@@ -543,13 +585,13 @@ function resolveCodegraphCommand(options = {}) {
|
|
|
543
585
|
// ../../../../utils/src/codegraph/exclusion.ts
|
|
544
586
|
import { realpathSync } from "node:fs";
|
|
545
587
|
import { homedir as homedir4, tmpdir as osTmpdir } from "node:os";
|
|
546
|
-
import { isAbsolute, join as
|
|
588
|
+
import { isAbsolute, join as join6, resolve as resolve2 } from "node:path";
|
|
547
589
|
var POSIX_DEFAULT_EXCLUDED_ROOTS = ["/tmp", "/private/tmp"];
|
|
548
590
|
function expandHome(path, homeDir) {
|
|
549
591
|
if (path === "~")
|
|
550
592
|
return homeDir;
|
|
551
593
|
if (path.startsWith("~/") || path.startsWith("~\\"))
|
|
552
|
-
return
|
|
594
|
+
return join6(homeDir, path.slice(2));
|
|
553
595
|
return path;
|
|
554
596
|
}
|
|
555
597
|
function realpathIfPossible(path) {
|
|
@@ -557,13 +599,13 @@ function realpathIfPossible(path) {
|
|
|
557
599
|
return realpathSync(path);
|
|
558
600
|
} catch (error) {
|
|
559
601
|
if (error instanceof Error)
|
|
560
|
-
return
|
|
602
|
+
return resolve2(path);
|
|
561
603
|
throw error;
|
|
562
604
|
}
|
|
563
605
|
}
|
|
564
606
|
function resolveConfiguredRoot(path, homeDir) {
|
|
565
607
|
const expanded = expandHome(path, homeDir);
|
|
566
|
-
return realpathIfPossible(isAbsolute(expanded) ? expanded :
|
|
608
|
+
return realpathIfPossible(isAbsolute(expanded) ? expanded : join6(homeDir, expanded));
|
|
567
609
|
}
|
|
568
610
|
function normalizeForComparison(path, platform) {
|
|
569
611
|
const normalized = path.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
@@ -584,12 +626,12 @@ function shouldExcludeCodegraphProject(workspace, options = {}) {
|
|
|
584
626
|
const platform = options.platform ?? process.platform;
|
|
585
627
|
const homeDir = options.homeDir ?? homedir4();
|
|
586
628
|
const tmpdir = options.tmpdir ?? osTmpdir();
|
|
587
|
-
const resolvedWorkspace = realpathIfPossible(
|
|
629
|
+
const resolvedWorkspace = realpathIfPossible(resolve2(workspace));
|
|
588
630
|
if (hasOmoPathSegment(resolvedWorkspace)) {
|
|
589
631
|
return { excluded: true, matchedRoot: ".omo", reason: "omo-state" };
|
|
590
632
|
}
|
|
591
633
|
for (const root of defaultExcludedRoots(platform, tmpdir)) {
|
|
592
|
-
const resolvedRoot = realpathIfPossible(
|
|
634
|
+
const resolvedRoot = realpathIfPossible(resolve2(root));
|
|
593
635
|
if (pathIsWithin(resolvedWorkspace, resolvedRoot, platform)) {
|
|
594
636
|
return { excluded: true, matchedRoot: root, reason: "tmp-root" };
|
|
595
637
|
}
|
|
@@ -609,11 +651,11 @@ function shouldExcludeCodegraphProject(workspace, options = {}) {
|
|
|
609
651
|
import { homedir as homedir6 } from "node:os";
|
|
610
652
|
|
|
611
653
|
// ../../../../utils/src/omo-config/loader.ts
|
|
612
|
-
import { existsSync as
|
|
654
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
613
655
|
import { homedir as homedir5 } from "node:os";
|
|
614
656
|
|
|
615
657
|
// ../../../../utils/src/omo-config/body.ts
|
|
616
|
-
import { readFileSync } from "node:fs";
|
|
658
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
617
659
|
|
|
618
660
|
// ../../../../utils/src/deep-merge.ts
|
|
619
661
|
var DANGEROUS_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -1502,6 +1544,7 @@ var SETTING_HARNESS_SUPPORT = {
|
|
|
1502
1544
|
var BUILT_IN_DEFAULTS = {
|
|
1503
1545
|
codegraph: {
|
|
1504
1546
|
auto_provision: true,
|
|
1547
|
+
daemon: true,
|
|
1505
1548
|
enabled: true,
|
|
1506
1549
|
telemetry: false
|
|
1507
1550
|
}
|
|
@@ -1661,7 +1704,7 @@ function normalizeActiveHarnessBlock(value, harness, pathPrefix, warnings) {
|
|
|
1661
1704
|
}
|
|
1662
1705
|
function loadConfigFile(path, harness) {
|
|
1663
1706
|
try {
|
|
1664
|
-
const content =
|
|
1707
|
+
const content = readFileSync2(path, "utf-8");
|
|
1665
1708
|
const parsed = parseJsoncSafe(content);
|
|
1666
1709
|
if (parsed.errors.length > 0) {
|
|
1667
1710
|
return {
|
|
@@ -1784,22 +1827,22 @@ function buildEnvOverrides(harness, env, warnings, merge) {
|
|
|
1784
1827
|
}
|
|
1785
1828
|
|
|
1786
1829
|
// ../../../../utils/src/omo-config/resolve.ts
|
|
1787
|
-
import { existsSync as
|
|
1788
|
-
import { dirname as dirname2, isAbsolute as isAbsolute2, join as
|
|
1830
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
1831
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, join as join7, relative, resolve as resolve3 } from "node:path";
|
|
1789
1832
|
function containsPath(parent, child) {
|
|
1790
1833
|
const pathToChild = relative(parent, child);
|
|
1791
1834
|
return pathToChild === "" || !pathToChild.startsWith("..") && !isAbsolute2(pathToChild);
|
|
1792
1835
|
}
|
|
1793
1836
|
function findProjectConfigPathsNearestFirst(cwd, homeDir) {
|
|
1794
|
-
const startDir =
|
|
1795
|
-
const stopBeforeDir = containsPath(
|
|
1837
|
+
const startDir = resolve3(cwd);
|
|
1838
|
+
const stopBeforeDir = containsPath(resolve3(homeDir), startDir) ? resolve3(homeDir) : null;
|
|
1796
1839
|
const paths = [];
|
|
1797
1840
|
let currentDir = startDir;
|
|
1798
1841
|
while (true) {
|
|
1799
1842
|
if (stopBeforeDir !== null && currentDir === stopBeforeDir)
|
|
1800
1843
|
break;
|
|
1801
|
-
const configPath =
|
|
1802
|
-
if (
|
|
1844
|
+
const configPath = join7(currentDir, ".omo", "config.jsonc");
|
|
1845
|
+
if (existsSync4(configPath)) {
|
|
1803
1846
|
paths.push(configPath);
|
|
1804
1847
|
}
|
|
1805
1848
|
const parentDir = dirname2(currentDir);
|
|
@@ -1810,7 +1853,7 @@ function findProjectConfigPathsNearestFirst(cwd, homeDir) {
|
|
|
1810
1853
|
return paths;
|
|
1811
1854
|
}
|
|
1812
1855
|
function resolveOmoConfigPaths(options) {
|
|
1813
|
-
const globalPath =
|
|
1856
|
+
const globalPath = join7(resolve3(options.homeDir), ".omo", "config.jsonc");
|
|
1814
1857
|
const projectPathsFarthestFirst = findProjectConfigPathsNearestFirst(options.cwd, options.homeDir).reverse();
|
|
1815
1858
|
return [
|
|
1816
1859
|
{ path: globalPath, scope: "global" },
|
|
@@ -1835,7 +1878,7 @@ function loadOmoConfig(options) {
|
|
|
1835
1878
|
const sources = [];
|
|
1836
1879
|
const warnings = [];
|
|
1837
1880
|
for (const candidate of resolveOmoConfigPaths({ cwd, homeDir })) {
|
|
1838
|
-
if (!
|
|
1881
|
+
if (!existsSync5(candidate.path)) {
|
|
1839
1882
|
if (candidate.scope === "global") {
|
|
1840
1883
|
sources.push(toMissingSource(candidate));
|
|
1841
1884
|
}
|
|
@@ -1890,7 +1933,7 @@ function resolveHomeDir(options) {
|
|
|
1890
1933
|
import { spawn } from "node:child_process";
|
|
1891
1934
|
|
|
1892
1935
|
// ../../../../mcp-stdio-core/src/record.ts
|
|
1893
|
-
function
|
|
1936
|
+
function isPlainRecord2(value) {
|
|
1894
1937
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1895
1938
|
}
|
|
1896
1939
|
// ../../../../mcp-stdio-core/src/responses.ts
|
|
@@ -1937,7 +1980,7 @@ ${body}` : `${body}
|
|
|
1937
1980
|
await writeChunk(output, payload);
|
|
1938
1981
|
}
|
|
1939
1982
|
function writeChunk(output, chunk) {
|
|
1940
|
-
return new Promise((
|
|
1983
|
+
return new Promise((resolve4, reject) => {
|
|
1941
1984
|
let settled = false;
|
|
1942
1985
|
const onError = (error) => {
|
|
1943
1986
|
if (settled)
|
|
@@ -1957,7 +2000,7 @@ function writeChunk(output, chunk) {
|
|
|
1957
2000
|
return;
|
|
1958
2001
|
}
|
|
1959
2002
|
output.removeListener("error", onError);
|
|
1960
|
-
|
|
2003
|
+
resolve4();
|
|
1961
2004
|
});
|
|
1962
2005
|
} catch (error) {
|
|
1963
2006
|
output.removeListener("error", onError);
|
|
@@ -2110,8 +2153,8 @@ async function handleParseError(message, config, log) {
|
|
|
2110
2153
|
}
|
|
2111
2154
|
async function handleRequest(message, config, log) {
|
|
2112
2155
|
const parsed = message.payload;
|
|
2113
|
-
const id =
|
|
2114
|
-
const method =
|
|
2156
|
+
const id = isPlainRecord2(parsed) ? jsonRpcId(parsed["id"]) : null;
|
|
2157
|
+
const method = isPlainRecord2(parsed) && typeof parsed["method"] === "string" ? parsed["method"] : null;
|
|
2115
2158
|
log("request", { id: id === null ? null : String(id), method });
|
|
2116
2159
|
let response;
|
|
2117
2160
|
try {
|
|
@@ -2343,22 +2386,22 @@ async function forwardCodegraphToClient(childOutput, output, pendingResponses, d
|
|
|
2343
2386
|
}
|
|
2344
2387
|
}
|
|
2345
2388
|
function responseModeKey(payload) {
|
|
2346
|
-
if (!
|
|
2389
|
+
if (!isPlainRecord2(payload) || !("id" in payload))
|
|
2347
2390
|
return null;
|
|
2348
2391
|
const id = jsonRpcId(payload["id"]);
|
|
2349
2392
|
return `${typeof id}:${String(id)}`;
|
|
2350
2393
|
}
|
|
2351
2394
|
function jsonRpcMethod(payload) {
|
|
2352
|
-
if (!
|
|
2395
|
+
if (!isPlainRecord2(payload))
|
|
2353
2396
|
return null;
|
|
2354
2397
|
const method = payload["method"];
|
|
2355
2398
|
return typeof method === "string" ? method : null;
|
|
2356
2399
|
}
|
|
2357
2400
|
function jsonRpcToolName(payload) {
|
|
2358
|
-
if (jsonRpcMethod(payload) !== "tools/call" || !
|
|
2401
|
+
if (jsonRpcMethod(payload) !== "tools/call" || !isPlainRecord2(payload))
|
|
2359
2402
|
return null;
|
|
2360
2403
|
const params = payload["params"];
|
|
2361
|
-
if (!
|
|
2404
|
+
if (!isPlainRecord2(params))
|
|
2362
2405
|
return null;
|
|
2363
2406
|
const name = params["name"];
|
|
2364
2407
|
return typeof name === "string" ? name : null;
|
|
@@ -2372,14 +2415,14 @@ function clarifyCodegraphResponse(payload, pendingResponse) {
|
|
|
2372
2415
|
return payload;
|
|
2373
2416
|
}
|
|
2374
2417
|
function clarifyCodegraphToolsList(payload) {
|
|
2375
|
-
if (!
|
|
2418
|
+
if (!isPlainRecord2(payload))
|
|
2376
2419
|
return payload;
|
|
2377
2420
|
const result = payload["result"];
|
|
2378
|
-
if (!
|
|
2421
|
+
if (!isPlainRecord2(result) || !Array.isArray(result["tools"]))
|
|
2379
2422
|
return payload;
|
|
2380
2423
|
let changed = false;
|
|
2381
2424
|
const tools = result["tools"].map((tool) => {
|
|
2382
|
-
if (!
|
|
2425
|
+
if (!isPlainRecord2(tool) || tool["name"] !== "codegraph_node")
|
|
2383
2426
|
return tool;
|
|
2384
2427
|
if (!hasCodegraphNodeContractMetadata(tool))
|
|
2385
2428
|
return tool;
|
|
@@ -2396,7 +2439,7 @@ function clarifyCodegraphNodeTool(tool) {
|
|
|
2396
2439
|
description: CODEGRAPH_NODE_DESCRIPTION
|
|
2397
2440
|
};
|
|
2398
2441
|
const inputSchema = tool["inputSchema"];
|
|
2399
|
-
if (
|
|
2442
|
+
if (isPlainRecord2(inputSchema))
|
|
2400
2443
|
clarified["inputSchema"] = clarifyCodegraphNodeInputSchema(inputSchema);
|
|
2401
2444
|
return clarified;
|
|
2402
2445
|
}
|
|
@@ -2404,17 +2447,17 @@ function hasCodegraphNodeContractMetadata(tool) {
|
|
|
2404
2447
|
if (typeof tool["description"] === "string")
|
|
2405
2448
|
return true;
|
|
2406
2449
|
const inputSchema = tool["inputSchema"];
|
|
2407
|
-
if (!
|
|
2450
|
+
if (!isPlainRecord2(inputSchema))
|
|
2408
2451
|
return false;
|
|
2409
2452
|
const properties = inputSchema["properties"];
|
|
2410
|
-
return
|
|
2453
|
+
return isPlainRecord2(properties) && isPlainRecord2(properties["includeCode"]);
|
|
2411
2454
|
}
|
|
2412
2455
|
function clarifyCodegraphNodeInputSchema(inputSchema) {
|
|
2413
2456
|
const properties = inputSchema["properties"];
|
|
2414
|
-
if (!
|
|
2457
|
+
if (!isPlainRecord2(properties))
|
|
2415
2458
|
return inputSchema;
|
|
2416
2459
|
const includeCode = properties["includeCode"];
|
|
2417
|
-
if (!
|
|
2460
|
+
if (!isPlainRecord2(includeCode))
|
|
2418
2461
|
return inputSchema;
|
|
2419
2462
|
return {
|
|
2420
2463
|
...inputSchema,
|
|
@@ -2428,14 +2471,14 @@ function clarifyCodegraphNodeInputSchema(inputSchema) {
|
|
|
2428
2471
|
};
|
|
2429
2472
|
}
|
|
2430
2473
|
function clarifyCodegraphNodeCallResult(payload) {
|
|
2431
|
-
if (!
|
|
2474
|
+
if (!isPlainRecord2(payload))
|
|
2432
2475
|
return payload;
|
|
2433
2476
|
const result = payload["result"];
|
|
2434
|
-
if (!
|
|
2477
|
+
if (!isPlainRecord2(result) || !Array.isArray(result["content"]))
|
|
2435
2478
|
return payload;
|
|
2436
2479
|
let changed = false;
|
|
2437
2480
|
const content = result["content"].map((item) => {
|
|
2438
|
-
if (!
|
|
2481
|
+
if (!isPlainRecord2(item) || item["type"] !== "text" || typeof item["text"] !== "string")
|
|
2439
2482
|
return item;
|
|
2440
2483
|
const text = clarifyContainerOutlineGuidance(item["text"]);
|
|
2441
2484
|
if (text === item["text"])
|
|
@@ -2476,7 +2519,7 @@ async function runUnavailableCodegraphMcpServer(options) {
|
|
|
2476
2519
|
});
|
|
2477
2520
|
}
|
|
2478
2521
|
async function handleUnavailableCodegraphMcpRequest(input, options) {
|
|
2479
|
-
if (!
|
|
2522
|
+
if (!isPlainRecord2(input)) {
|
|
2480
2523
|
return errorResponse(null, -32600, "Invalid Request");
|
|
2481
2524
|
}
|
|
2482
2525
|
const id = jsonRpcId(input["id"]);
|
|
@@ -2504,7 +2547,7 @@ async function handleUnavailableCodegraphMcpRequest(input, options) {
|
|
|
2504
2547
|
return errorResponse(id, -32601, `Method not found: ${String(method)}`);
|
|
2505
2548
|
}
|
|
2506
2549
|
function requestedProtocolVersion(params) {
|
|
2507
|
-
if (!
|
|
2550
|
+
if (!isPlainRecord2(params) || typeof params["protocolVersion"] !== "string")
|
|
2508
2551
|
return "2024-11-05";
|
|
2509
2552
|
return params["protocolVersion"];
|
|
2510
2553
|
}
|
|
@@ -2549,7 +2592,7 @@ async function runCodegraphServe(options = {}) {
|
|
|
2549
2592
|
};
|
|
2550
2593
|
let resolution = options.resolve?.(resolutionOptions) ?? resolveCodegraphCommand(resolutionOptions);
|
|
2551
2594
|
const nodeSupport = evaluateCodegraphNodeSupport({ env, nodeVersion: options.nodeVersion });
|
|
2552
|
-
if (!resolution.exists || shouldSkipResolvedCommand(resolution, options.commandExists ??
|
|
2595
|
+
if (!resolution.exists || shouldSkipResolvedCommand(resolution, options.commandExists ?? existsSync6)) {
|
|
2553
2596
|
if (resolution.source === "path" && !nodeSupport.supported) {
|
|
2554
2597
|
return runUnavailableMcp(buildCodegraphNodeSkipHint(nodeSupport), options);
|
|
2555
2598
|
}
|
|
@@ -2569,7 +2612,7 @@ async function runCodegraphServe(options = {}) {
|
|
|
2569
2612
|
return runUnavailableMcp(buildCodegraphNodeSkipHint(nodeSupport), options);
|
|
2570
2613
|
}
|
|
2571
2614
|
const runProcess = options.runProcess ?? runBridgedCodegraphProcess;
|
|
2572
|
-
const codegraphEnv = codegraphEnvForConfig(trustedInstallDir, homeDir, codegraphConfig.daemon
|
|
2615
|
+
const codegraphEnv = codegraphEnvForConfig(trustedInstallDir, homeDir, codegraphConfig.daemon !== false, options.buildEnv);
|
|
2573
2616
|
const mergedEnv = buildCodegraphChildEnv({ ambientEnv: env, codegraphEnv, runtimeEnv: env });
|
|
2574
2617
|
return runProcess(resolution.command, [...resolution.argsPrefix, "serve", "--mcp"], {
|
|
2575
2618
|
cwd: projectCwd,
|
|
@@ -2597,10 +2640,10 @@ async function provisionMissingCodegraph(options) {
|
|
|
2597
2640
|
return null;
|
|
2598
2641
|
if (options.config.auto_provision === false)
|
|
2599
2642
|
return null;
|
|
2600
|
-
const installDir = options.trustedInstallDir ??
|
|
2643
|
+
const installDir = options.trustedInstallDir ?? join8(options.homeDir, ".omo", "codegraph");
|
|
2601
2644
|
const result = await options.ensureProvisioned({
|
|
2602
2645
|
installDir,
|
|
2603
|
-
lockDir:
|
|
2646
|
+
lockDir: join8(installDir, ".locks"),
|
|
2604
2647
|
version: CODEGRAPH_VERSION
|
|
2605
2648
|
});
|
|
2606
2649
|
if (!result.provisioned || result.binPath === undefined)
|
|
@@ -2626,17 +2669,14 @@ function resolveProjectCwd(env, fallback) {
|
|
|
2626
2669
|
const candidate = env[key]?.trim();
|
|
2627
2670
|
if (candidate === undefined || candidate.length === 0)
|
|
2628
2671
|
continue;
|
|
2629
|
-
const resolved =
|
|
2630
|
-
if (
|
|
2672
|
+
const resolved = resolve4(candidate);
|
|
2673
|
+
if (existsSync6(resolved))
|
|
2631
2674
|
return resolved;
|
|
2632
2675
|
}
|
|
2633
|
-
return
|
|
2676
|
+
return resolve4(fallback);
|
|
2634
2677
|
}
|
|
2635
2678
|
function provisionedBinFromInstallDir(installDir) {
|
|
2636
|
-
|
|
2637
|
-
return null;
|
|
2638
|
-
const candidate = join7(installDir, "bin", process.platform === "win32" ? "codegraph.cmd" : "codegraph");
|
|
2639
|
-
return existsSync5(candidate) ? candidate : null;
|
|
2679
|
+
return resolvePinnedCodegraphBin(installDir);
|
|
2640
2680
|
}
|
|
2641
2681
|
async function runCodegraphServeCli() {
|
|
2642
2682
|
process.exitCode = await runCodegraphServe();
|
|
@@ -2655,7 +2695,7 @@ function isDirectInvocation(argvPath) {
|
|
|
2655
2695
|
const moduleName = basename3(modulePath);
|
|
2656
2696
|
if (moduleName !== "serve.js" && moduleName !== "serve.ts")
|
|
2657
2697
|
return false;
|
|
2658
|
-
return realpathSync2(
|
|
2698
|
+
return realpathSync2(resolve4(argvPath)) === realpathSync2(modulePath);
|
|
2659
2699
|
}
|
|
2660
2700
|
export {
|
|
2661
2701
|
runCodegraphServeCli,
|