Skip to content

The one and only agent harness for complex codebases. Project memory, planning, execution, and verified completion inside Codex.

chore: sync Codex marketplace v4.12.1

github-actions[bot]b37c8f860859
diff --git a/plugins/omo/.codex-plugin/plugin.json b/plugins/omo/.codex-plugin/plugin.json
index 8085f0b0..7c9cc3bd 100644
--- a/plugins/omo/.codex-plugin/plugin.json
+++ b/plugins/omo/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "omo",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "One Codex plugin namespace for Yeongyu's local Codex components.",
"author": {
"name": "Yeongyu Kim",
@@ -32,7 +32,9 @@
"./hooks/pre-tool-use-enforcing-unlimited-goal-budget.json",
"./hooks/post-tool-use-checking-comments.json",
"./hooks/post-tool-use-checking-lsp-diagnostics.json",
+ "./hooks/post-tool-use-checking-codegraph-init-guidance.json",
"./hooks/post-tool-use-matching-project-rules.json",
+ "./hooks/post-tool-use-checking-thread-title-hygiene.json",
"./hooks/post-compact-resetting-git-bash-mcp-reminder.json",
"./hooks/post-compact-resetting-project-rule-cache.json",
"./hooks/post-compact-resetting-lsp-diagnostics-cache.json",
diff --git a/plugins/omo/components/bootstrap/package.json b/plugins/omo/components/bootstrap/package.json
index 5ee0626e..e4f80ec1 100644
--- a/plugins/omo/components/bootstrap/package.json
+++ b/plugins/omo/components/bootstrap/package.json
@@ -1,6 +1,6 @@
{
"name": "@sisyphuslabs/codex-bootstrap",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex SessionStart bootstrap component that provisions LazyCodex runtime dependencies from a detached worker.",
"type": "module",
"private": true,
diff --git a/plugins/omo/components/codegraph/dist/cli.js b/plugins/omo/components/codegraph/dist/cli.js
index 2d6acda7..0adb1854 100755
--- a/plugins/omo/components/codegraph/dist/cli.js
+++ b/plugins/omo/components/codegraph/dist/cli.js
@@ -8,13 +8,205 @@ import { fileURLToPath as fileURLToPath3 } from "node:url";
// components/codegraph/src/hook.ts
import { spawn } from "node:child_process";
-import { homedir as homedir7 } from "node:os";
+import { homedir as homedir8 } from "node:os";
import { cwd as processCwd2, env as processEnv2, stdin as processStdin, stdout as processStdout } from "node:process";
import { fileURLToPath } from "node:url";
-// ../../utils/src/omo-config/loader.ts
-import { existsSync as existsSync2, readFileSync } from "node:fs";
+// ../../utils/src/codegraph/guidance.ts
+import { homedir as homedir2 } from "node:os";
+
+// ../../utils/src/codegraph/workspace.ts
+import { createHash } from "node:crypto";
+import {
+ appendFileSync,
+ existsSync,
+ lstatSync,
+ mkdirSync,
+ readFileSync,
+ readdirSync,
+ realpathSync,
+ rmSync,
+ statSync,
+ symlinkSync
+} from "node:fs";
import { homedir } from "node:os";
+import { basename, join, resolve } from "node:path";
+function sanitizeBase(value) {
+ const sanitized = value.replace(/[^A-Za-z0-9._-]/g, "-").replace(/-+/g, "-");
+ return sanitized.length > 0 ? sanitized : "workspace";
+}
+function codegraphDataRoot(homeDir) {
+ return join(homeDir, ".omo", "codegraph");
+}
+function workspaceStorageName(workspace) {
+ const resolved = resolve(workspace);
+ const hash = createHash("sha256").update(resolved).digest("hex").slice(0, 16);
+ return `${sanitizeBase(basename(resolved))}-${hash}`;
+}
+function resolveCodegraphWorkspacePaths(workspace, options = {}) {
+ const resolvedWorkspace = resolve(workspace);
+ const dataRoot = codegraphDataRoot(options.homeDir ?? homedir());
+ return {
+ dataDir: join(dataRoot, "projects", workspaceStorageName(resolvedWorkspace)),
+ dataRoot,
+ projectLink: join(resolvedWorkspace, ".codegraph")
+ };
+}
+function fallbackResult(dataRoot, projectLink, reason) {
+ return { dataDir: projectLink, dataRoot, linked: false, mode: "in-place-fallback", projectLink, reason };
+}
+function isSameFilesystem(workspace, dataRoot, override) {
+ if (override !== undefined)
+ return override;
+ return statSync(workspace).dev === statSync(dataRoot).dev;
+}
+function ensureInPlaceFallback(projectLink) {
+ if (!existsSync(projectLink))
+ mkdirSync(projectLink, { recursive: true });
+}
+function prepareCodegraphWorkspace(workspace, options = {}) {
+ const resolvedWorkspace = resolve(workspace);
+ const { dataDir, dataRoot, projectLink } = resolveCodegraphWorkspacePaths(resolvedWorkspace, options);
+ try {
+ mkdirSync(dataDir, { recursive: true });
+ if (existsSync(projectLink)) {
+ const linkStat = lstatSync(projectLink);
+ if (!linkStat.isSymbolicLink()) {
+ return { dataDir: projectLink, dataRoot, linked: false, mode: "in-project", projectLink };
+ }
+ if (realpathSync(projectLink) === realpathSync(dataDir)) {
+ return { dataDir, dataRoot, linked: true, mode: "global-linked", projectLink };
+ }
+ return fallbackResult(dataRoot, projectLink, "existing .codegraph symlink points outside OMO store");
+ }
+ if (!isSameFilesystem(resolvedWorkspace, dataRoot, options.sameFilesystem)) {
+ ensureInPlaceFallback(projectLink);
+ return fallbackResult(dataRoot, projectLink, "workspace and OMO store are on different filesystems");
+ }
+ const symlink = options.symlink ?? symlinkSync;
+ symlink(dataDir, projectLink, (options.platform ?? process.platform) === "win32" ? "junction" : "dir");
+ return { dataDir, dataRoot, linked: true, mode: "global-linked", projectLink };
+ } catch (error) {
+ const reason = error instanceof Error ? error.message : String(error);
+ try {
+ ensureInPlaceFallback(projectLink);
+ } catch (fallbackError) {
+ return fallbackResult(dataRoot, projectLink, `${reason}; fallback failed: ${String(fallbackError)}`);
+ }
+ return fallbackResult(dataRoot, projectLink, reason);
+ }
+}
+function ensureCodegraphGitignored(workspace) {
+ const gitDir = join(workspace, ".git");
+ if (!existsSync(gitDir))
+ return false;
+ const excludePath = join(gitDir, "info", "exclude");
+ try {
+ mkdirSync(join(gitDir, "info"), { recursive: true });
+ const existing = existsSync(excludePath) ? readFileSync(excludePath, "utf8") : "";
+ if (existing.split(/\r?\n/).includes(".codegraph"))
+ return true;
+ appendFileSync(excludePath, `${existing.endsWith(`
+`) || existing.length === 0 ? "" : `
+`}.codegraph
+`);
+ return true;
+ } catch (error) {
+ if (error instanceof Error)
+ return false;
+ throw error;
+ }
+}
+
+// ../../utils/src/codegraph/guidance.ts
+var CODEGRAPH_UNINITIALIZED_PATTERN = /CodeGraph not initialized in ([\s\S]*?)\.\s*Run ['`]codegraph init['`] in that project first\./i;
+var ANSI_ESCAPE_PATTERN = /\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;
+var CODEGRAPH_STATUS_PROJECT_PATTERN = /^.*?\bProject:\s*(.+?)\s*$/im;
+var CODEGRAPH_STATUS_UNINITIALIZED_PATTERN = /^.*?\bNot initialized\s*$/im;
+var CODEGRAPH_INIT_HINT_PATTERN = /Run\s+["'`]codegraph init["'`]\s+(?:in that project first|to initialize)\.?/i;
+function getCodegraphUninitializedProject(input) {
+ const output = textFromUnknown(input.toolOutput);
+ if (!isCodegraphTool(input.toolName))
+ return null;
+ const projectPath = extractProjectPath(output);
+ if (projectPath !== null)
+ return projectPath;
+ if (!looksLikeCodegraphUninitializedOutput(output))
+ return null;
+ return typeof input.cwd === "string" && input.cwd.trim().length > 0 ? input.cwd.trim() : null;
+}
+function buildCodegraphInitGuidance(projectPath, options = {}) {
+ const { dataDir, dataRoot, projectLink } = resolveCodegraphWorkspacePaths(projectPath, {
+ homeDir: options.homeDir ?? homedir2()
+ });
+ const displayProjectPath = formatDisplayPath(projectPath);
+ const displayProjectLink = formatDisplayPath(projectLink);
+ const displayDataDir = formatDisplayPath(dataDir);
+ const displayDataRoot = formatDisplayPath(dataRoot);
+ return [
+ "OMO CodeGraph initialization guidance:",
+ "",
+ `CodeGraph is not initialized for ${displayProjectPath}. Initialize it through OMO's global local store instead of leaving a standalone project-local index.`,
+ "",
+ `- Link or create ${displayProjectLink} so it points at ${displayDataDir} under the OMO store ${displayDataRoot}.`,
+ `- Then run \`codegraph init\` from ${displayProjectPath} and retry the CodeGraph tool.`,
+ "- OMO's CodeGraph bootstrap does this automatically on session start; if bootstrap just ran, wait for it to finish and retry."
+ ].join(`
+`);
+}
+function buildCodegraphInitGuidanceForToolResult(input, options = {}) {
+ const projectPath = getCodegraphUninitializedProject(input);
+ return projectPath === null ? null : buildCodegraphInitGuidance(projectPath, options);
+}
+function extractProjectPath(output) {
+ const normalizedOutput = normalizeCodegraphOutput(output);
+ const uninitializedMatch = normalizedOutput.match(CODEGRAPH_UNINITIALIZED_PATTERN);
+ const uninitializedProject = uninitializedMatch?.[1]?.trim();
+ if (uninitializedProject && uninitializedProject.length > 0)
+ return uninitializedProject;
+ if (!looksLikeCodegraphUninitializedOutput(normalizedOutput))
+ return null;
+ const statusMatch = normalizedOutput.match(CODEGRAPH_STATUS_PROJECT_PATTERN);
+ const statusProject = statusMatch?.[1]?.trim();
+ return statusProject && statusProject.length > 0 ? statusProject : null;
+}
+function looksLikeCodegraphUninitializedOutput(output) {
+ const normalizedOutput = normalizeCodegraphOutput(output);
+ if (normalizedOutput.match(CODEGRAPH_UNINITIALIZED_PATTERN) !== null)
+ return true;
+ return CODEGRAPH_STATUS_UNINITIALIZED_PATTERN.test(normalizedOutput) && CODEGRAPH_INIT_HINT_PATTERN.test(normalizedOutput);
+}
+function normalizeCodegraphOutput(output) {
+ return output.replace(ANSI_ESCAPE_PATTERN, "");
+}
+function isCodegraphTool(toolName) {
+ if (typeof toolName !== "string")
+ return false;
+ return toolName.startsWith("codegraph.") || toolName.startsWith("codegraph_") || toolName.startsWith("mcp__codegraph__");
+}
+function formatDisplayPath(value) {
+ return JSON.stringify(value);
+}
+function textFromUnknown(value) {
+ if (typeof value === "string")
+ return value;
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint")
+ return String(value);
+ if (Array.isArray(value))
+ return value.map(textFromUnknown).filter(Boolean).join(`
+`);
+ if (!isRecord(value))
+ return "";
+ return Object.entries(value).map(([key, nested]) => `${key}: ${textFromUnknown(nested)}`).filter((line) => line.trim().length > 0).join(`
+`);
+}
+function isRecord(value) {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+
+// ../../utils/src/omo-config/loader.ts
+import { existsSync as existsSync3, readFileSync as readFileSync2 } from "node:fs";
+import { homedir as homedir3 } from "node:os";
// ../../utils/src/deep-merge.ts
var DANGEROUS_KEYS = new Set(["__proto__", "constructor", "prototype"]);
@@ -970,22 +1162,22 @@ function buildEnvOverrides(harness, env, warnings, merge) {
}
// ../../utils/src/omo-config/resolve.ts
-import { existsSync } from "node:fs";
-import { dirname, isAbsolute, join, relative, resolve } from "node:path";
+import { existsSync as existsSync2 } from "node:fs";
+import { dirname, isAbsolute, join as join2, relative, resolve as resolve2 } from "node:path";
function containsPath(parent, child) {
const pathToChild = relative(parent, child);
return pathToChild === "" || !pathToChild.startsWith("..") && !isAbsolute(pathToChild);
}
function findProjectConfigPathsNearestFirst(cwd, homeDir) {
- const startDir = resolve(cwd);
- const stopBeforeDir = containsPath(resolve(homeDir), startDir) ? resolve(homeDir) : null;
+ const startDir = resolve2(cwd);
+ const stopBeforeDir = containsPath(resolve2(homeDir), startDir) ? resolve2(homeDir) : null;
const paths = [];
let currentDir = startDir;
while (true) {
if (stopBeforeDir !== null && currentDir === stopBeforeDir)
break;
- const configPath = join(currentDir, ".omo", "config.jsonc");
- if (existsSync(configPath)) {
+ const configPath = join2(currentDir, ".omo", "config.jsonc");
+ if (existsSync2(configPath)) {
paths.push(configPath);
}
const parentDir = dirname(currentDir);
@@ -996,7 +1188,7 @@ function findProjectConfigPathsNearestFirst(cwd, homeDir) {
return paths;
}
function resolveOmoConfigPaths(options) {
- const globalPath = join(resolve(options.homeDir), ".omo", "config.jsonc");
+ const globalPath = join2(resolve2(options.homeDir), ".omo", "config.jsonc");
const projectPathsFarthestFirst = findProjectConfigPathsNearestFirst(options.cwd, options.homeDir).reverse();
return [
{ path: globalPath, scope: "global" },
@@ -1028,7 +1220,7 @@ var CODEGRAPH_SETTING_KEYS = [
"telemetry",
"watch_debounce_ms"
];
-function isRecord(value) {
+function isRecord2(value) {
return isPlainObject(value);
}
function hasOwn(record, key) {
@@ -1056,7 +1248,7 @@ function mergeValues(base, override) {
}
function mergeCodegraphConfig(base, override) {
const merged = mergeValues(base, override);
- if (!isRecord(merged))
+ if (!isRecord2(merged))
return;
const codegraph = {};
for (const key of CODEGRAPH_SETTING_KEYS) {
@@ -1111,7 +1303,7 @@ function setCodegraphSetting2(config, key, value) {
}
}
function normalizeCodegraphSection(section, pathPrefix, warnings) {
- if (!isRecord(section)) {
+ if (!isRecord2(section)) {
warnings.push(`${pathPrefix} must be an object`);
return {};
}
@@ -1131,7 +1323,7 @@ function normalizeCodegraphSection(section, pathPrefix, warnings) {
return codegraph;
}
function normalizeConfigBody(value, pathPrefix, warnings) {
- if (!isRecord(value)) {
+ if (!isRecord2(value)) {
warnings.push(`${pathPrefix} must be an object`);
return {};
}
@@ -1152,7 +1344,7 @@ function normalizeConfigBody(value, pathPrefix, warnings) {
return config;
}
function normalizeActiveHarnessBlock(value, harness, pathPrefix, warnings) {
- if (!isRecord(value))
+ if (!isRecord2(value))
return {};
const blockKey = `[${harness}]`;
if (!hasOwn(value, blockKey))
@@ -1161,7 +1353,7 @@ function normalizeActiveHarnessBlock(value, harness, pathPrefix, warnings) {
}
function loadConfigFile(path, harness) {
try {
- const content = readFileSync(path, "utf-8");
+ const content = readFileSync2(path, "utf-8");
const parsed = parseJsoncSafe(content);
if (parsed.errors.length > 0) {
return {
@@ -1207,13 +1399,13 @@ function validateHarnessApplicability(config, harness) {
}
function loadOmoConfig(options) {
const cwd = options.cwd ?? process.cwd();
- const homeDir = options.homeDir ?? process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir();
+ const homeDir = options.homeDir ?? process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir3();
const env = options.env ?? process.env;
let config = BUILT_IN_DEFAULTS;
const sources = [];
const warnings = [];
for (const candidate of resolveOmoConfigPaths({ cwd, homeDir })) {
- if (!existsSync2(candidate.path)) {
+ if (!existsSync3(candidate.path)) {
if (candidate.scope === "global") {
sources.push(toMissingSource(candidate));
}
@@ -1253,21 +1445,21 @@ function getCodexOmoConfig(options = {}) {
// components/codegraph/src/session-start-worker.ts
import { execFile as execFile2 } from "node:child_process";
import { appendFileSync as appendFileSync2, existsSync as existsSync6, mkdirSync as mkdirSync2 } from "node:fs";
-import { homedir as homedir6 } from "node:os";
+import { homedir as homedir7 } from "node:os";
import { extname, join as join7 } from "node:path";
import { cwd as processCwd, env as processEnv, stderr as processStderr } from "node:process";
// ../../utils/src/codegraph/env.ts
-import { homedir as homedir2 } from "node:os";
-import { join as join2 } from "node:path";
+import { homedir as homedir4 } from "node:os";
+import { join as join3 } from "node:path";
var CODEGRAPH_INSTALL_DIR_ENV = "CODEGRAPH_INSTALL_DIR";
var CODEGRAPH_NO_DOWNLOAD_ENV = "CODEGRAPH_NO_DOWNLOAD";
var CODEGRAPH_TELEMETRY_ENV = "CODEGRAPH_TELEMETRY";
var DO_NOT_TRACK_ENV = "DO_NOT_TRACK";
function buildCodegraphEnv(options = {}) {
- const homeDir = options.homeDir ?? homedir2();
+ const homeDir = options.homeDir ?? homedir4();
return {
- [CODEGRAPH_INSTALL_DIR_ENV]: join2(homeDir, ".omo", "codegraph"),
+ [CODEGRAPH_INSTALL_DIR_ENV]: join3(homeDir, ".omo", "codegraph"),
[CODEGRAPH_NO_DOWNLOAD_ENV]: "1",
[CODEGRAPH_TELEMETRY_ENV]: "0",
[DO_NOT_TRACK_ENV]: "1"
@@ -1304,12 +1496,12 @@ function parseNodeMajor(version) {
}
// ../../utils/src/codegraph/provision.ts
-import { createHash, randomUUID } from "node:crypto";
+import { createHash as createHash2, randomUUID } from "node:crypto";
import { execFile } from "node:child_process";
import { chmod, mkdir, readdir, readFile, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
-import { existsSync as existsSync3 } from "node:fs";
-import { homedir as homedir3, hostname } from "node:os";
-import { basename, join as join3 } from "node:path";
+import { existsSync as existsSync4 } from "node:fs";
+import { homedir as homedir5, hostname } from "node:os";
+import { basename as basename2, join as join4 } from "node:path";
import { promisify } from "node:util";
// ../../utils/src/codegraph/manifest.ts
@@ -1358,13 +1550,13 @@ function platformKey() {
return `${process.platform}-${process.arch}`;
}
function markerPath(installDir, version) {
- return join3(installDir, ".provisioned", `codegraph-${version}.json`);
+ return join4(installDir, ".provisioned", `codegraph-${version}.json`);
}
function defaultInstallDir() {
- return join3(homedir3(), ".omo", "codegraph");
+ return join4(homedir5(), ".omo", "codegraph");
}
function sha256(bytes) {
- return createHash("sha256").update(bytes).digest("hex");
+ return createHash2("sha256").update(bytes).digest("hex");
}
function isErrnoException(error) {
return error instanceof Error && "code" in error;
@@ -1381,7 +1573,7 @@ async function removeEmptyDirectory(path) {
}
}
function sleep(ms) {
- return new Promise((resolve2) => setTimeout(resolve2, ms));
+ return new Promise((resolve3) => setTimeout(resolve3, ms));
}
async function defaultDownloader(asset, timeoutMs = DEFAULT_DOWNLOAD_TIMEOUT_MS) {
const response = await fetch(asset.url, { signal: AbortSignal.timeout(timeoutMs) });
@@ -1395,7 +1587,7 @@ function forcedBadChecksumOptions(options) {
const key = options.platformKey ?? platformKey();
return {
downloader: async () => new TextEncoder().encode("checksum mismatch"),
- installDir: options.installDir ?? join3(options.lockDir, "codegraph-force-bad-checksum"),
+ installDir: options.installDir ?? join4(options.lockDir, "codegraph-force-bad-checksum"),
manifest: {
assets: {
[key]: { executableName: process.platform === "win32" ? "codegraph.cmd" : "codegraph", sha256: "0000", url: "memory://bad" }
@@ -1406,13 +1598,13 @@ function forcedBadChecksumOptions(options) {
};
}
async function readMarker(path) {
- if (!existsSync3(path))
+ if (!existsSync4(path))
return null;
try {
const raw = JSON.parse(await readFile(path, "utf8"));
if (typeof raw === "object" && raw !== null && "binPath" in raw) {
const value = raw.binPath;
- return typeof value === "string" && existsSync3(value) ? value : null;
+ return typeof value === "string" && existsSync4(value) ? value : null;
}
return null;
} catch (error) {
@@ -1423,7 +1615,7 @@ async function readMarker(path) {
}
async function acquireLock(lockPath, waitMs, staleMs) {
const startedAt = Date.now();
- await mkdir(join3(lockPath, ".."), { recursive: true });
+ await mkdir(join4(lockPath, ".."), { recursive: true });
while (Date.now() - startedAt <= waitMs) {
try {
await mkdir(lockPath);
@@ -1448,44 +1640,44 @@ async function installExtractedBundle(extractDir, installDir, executableName) {
const roots = await readdir(extractDir);
if (roots.length !== 1)
throw new Error(`CodeGraph archive should contain one root directory, found ${roots.length}`);
- const bundleDir = join3(extractDir, roots[0] ?? "");
+ const bundleDir = join4(extractDir, roots[0] ?? "");
const bundleEntries = await readdir(bundleDir);
await mkdir(installDir, { recursive: true });
for (const entry of bundleEntries) {
- await rm(join3(installDir, entry), { force: true, recursive: true });
- await rename(join3(bundleDir, entry), join3(installDir, entry));
+ await rm(join4(installDir, entry), { force: true, recursive: true });
+ await rename(join4(bundleDir, entry), join4(installDir, entry));
}
- const destination = join3(installDir, "bin", executableName);
- if (!existsSync3(destination))
+ const destination = join4(installDir, "bin", executableName);
+ if (!existsSync4(destination))
throw new Error(`CodeGraph archive did not contain bin/${executableName}`);
await chmod(destination, 493);
return destination;
}
async function installAsset(layout) {
const { asset, downloader, installDir, version } = layout;
- const stagingDir = join3(installDir, ".staging", randomUUID());
- const archivePath = join3(stagingDir, basename(asset.url));
- const extractDir = join3(stagingDir, "extract");
+ const stagingDir = join4(installDir, ".staging", randomUUID());
+ const archivePath = join4(stagingDir, basename2(asset.url));
+ const extractDir = join4(stagingDir, "extract");
try {
await mkdir(extractDir, { recursive: true });
const bytes = await downloader(asset);
const actualChecksum = sha256(bytes);
if (actualChecksum !== asset.sha256) {
- throw new Error(`checksum mismatch for ${basename(asset.url)}: expected ${asset.sha256}, got ${actualChecksum}`);
+ throw new Error(`checksum mismatch for ${basename2(asset.url)}: expected ${asset.sha256}, got ${actualChecksum}`);
}
if (!asset.url.endsWith(".tar.gz") && !asset.url.endsWith(".tgz")) {
- throw new Error(`unsupported CodeGraph archive type for ${basename(asset.url)}`);
+ throw new Error(`unsupported CodeGraph archive type for ${basename2(asset.url)}`);
}
await writeFile(archivePath, bytes);
await extractTarGz(archivePath, extractDir);
const destination = await installExtractedBundle(extractDir, installDir, asset.executableName);
- await mkdir(join3(installDir, ".provisioned"), { recursive: true });
+ await mkdir(join4(installDir, ".provisioned"), { recursive: true });
await writeFile(markerPath(installDir, version), `${JSON.stringify({ binPath: destination, version })}
`);
return destination;
} finally {
await rm(stagingDir, { force: true, recursive: true });
- await removeEmptyDirectory(join3(installDir, ".staging"));
+ await removeEmptyDirectory(join4(installDir, ".staging"));
}
}
async function ensureCodegraphProvisioned(options) {
@@ -1498,7 +1690,7 @@ async function ensureCodegraphProvisioned(options) {
const existing = await readMarker(marker);
if (existing !== null)
return { binPath: existing, provisioned: true };
- const lockPath = join3(options.lockDir, `codegraph-${hostname()}.lock`);
+ const lockPath = join4(options.lockDir, `codegraph-${hostname()}.lock`);
const release = await acquireLock(lockPath, options.lockWaitMs ?? DEFAULT_LOCK_WAIT_MS, options.lockStaleMs ?? DEFAULT_LOCK_STALE_MS);
if (release === null)
return { error: "timed out waiting for codegraph provisioning lock", provisioned: false };
@@ -1523,15 +1715,15 @@ async function ensureCodegraphProvisioned(options) {
}
// ../../utils/src/codegraph/resolve.ts
-import { existsSync as existsSync4 } from "node:fs";
-import { homedir as homedir4 } from "node:os";
+import { existsSync as existsSync5 } from "node:fs";
+import { homedir as homedir6 } from "node:os";
import { spawnSync } from "node:child_process";
-import { basename as basename2, dirname as dirname2, join as join5 } from "node:path";
+import { basename as basename3, dirname as dirname2, join as join6 } from "node:path";
import { createRequire } from "node:module";
// ../../utils/src/runtime/which.ts
import { accessSync, constants } from "node:fs";
-import { delimiter, join as join4 } from "node:path";
+import { delimiter, join as join5 } from "node:path";
var runtime = globalThis;
function isUnsafeCommandName(commandName) {
if (commandName.includes("/") || commandName.includes("\\"))
@@ -1586,7 +1778,7 @@ function bunWhich(commandName) {
return null;
for (const pathEntry of pathEntries) {
for (const candidateName of candidateNames) {
- const candidatePath = join4(pathEntry, candidateName);
+ const candidatePath = join5(pathEntry, candidateName);
if (isExecutable(candidatePath))
return candidatePath;
}
@@ -1627,7 +1819,7 @@ ${result.stderr}`.trim().split(/\s+/)[0];
}
}
function isNodeExecutableName(filePath) {
- const executable = basename2(filePath).toLowerCase();
+ const executable = basename3(filePath).toLowerCase();
return executable === "node" || executable === "node.exe" || /^node\d+(\.exe)?$/.test(executable);
}
function looksLikePath(command) {
@@ -1667,8 +1859,8 @@ function defaultNodeRuntime(env, fileExists, which, nodeVersion) {
function defaultProvisionedBin(homeDir, fileExists) {
const binaryName = process.platform === "win32" ? "codegraph.cmd" : "codegraph";
const candidates = [
- join5(homeDir, ".omo", "codegraph", "bin", binaryName),
- join5(homeDir, ".omo", "codegraph", "node-servers", "node_modules", ".bin", binaryName)
+ join6(homeDir, ".omo", "codegraph", "bin", binaryName),
+ join6(homeDir, ".omo", "codegraph", "node-servers", "node_modules", ".bin", binaryName)
];
return candidates.find((candidate) => fileExists(candidate)) ?? null;
}
@@ -1676,7 +1868,7 @@ function resolveBundledShim(requireResolve, fileExists) {
try {
const packageJson = requireResolve(`${CODEGRAPH_PACKAGE}/package.json`);
const packageRoot = dirname2(packageJson);
- const candidates = [join5(packageRoot, "bin", "codegraph.js"), join5(packageRoot, "npm-shim.js")];
+ const candidates = [join6(packageRoot, "bin", "codegraph.js"), join6(packageRoot, "npm-shim.js")];
return candidates.find((candidate) => fileExists(candidate)) ?? null;
} catch (error) {
if (error instanceof Error)
@@ -1692,7 +1884,7 @@ function resolveBundledShim(requireResolve, fileExists) {
}
function resolveCodegraphCommand(options = {}) {
const env = options.env ?? process.env;
- const fileExists = options.fileExists ?? existsSync4;
+ const fileExists = options.fileExists ?? existsSync5;
const configuredBin = env[CODEGRAPH_ENV_BIN]?.trim() || env[CODEGRAPH_LEGACY_ENV_BIN]?.trim();
if (configuredBin !== undefined && configuredBin.length > 0) {
return { argsPrefix: [], command: configuredBin, exists: fileExists(configuredBin), source: "env" };
@@ -1704,7 +1896,7 @@ function resolveCodegraphCommand(options = {}) {
if (bundled !== null && runtime2 !== null) {
return { argsPrefix: [bundled], command: runtime2, exists: true, source: "bundled" };
}
- const provisioned = options.provisioned?.() ?? defaultProvisionedBin(options.homeDir ?? homedir4(), fileExists);
+ const provisioned = options.provisioned?.() ?? defaultProvisionedBin(options.homeDir ?? homedir6(), fileExists);
if (provisioned !== null && fileExists(provisioned)) {
return { argsPrefix: [], command: provisioned, exists: true, source: "provisioned" };
}
@@ -1717,102 +1909,6 @@ function resolveCodegraphCommand(options = {}) {
};
}
-// ../../utils/src/codegraph/workspace.ts
-import { createHash as createHash2 } from "node:crypto";
-import {
- appendFileSync,
- existsSync as existsSync5,
- lstatSync,
- mkdirSync,
- readFileSync as readFileSync2,
- readdirSync,
- realpathSync,
- rmSync,
- statSync,
- symlinkSync
-} from "node:fs";
-import { homedir as homedir5 } from "node:os";
-import { basename as basename3, join as join6, resolve as resolve2 } from "node:path";
-function sanitizeBase(value) {
- const sanitized = value.replace(/[^A-Za-z0-9._-]/g, "-").replace(/-+/g, "-");
- return sanitized.length > 0 ? sanitized : "workspace";
-}
-function codegraphDataRoot(homeDir) {
- return join6(homeDir, ".omo", "codegraph");
-}
-function workspaceStorageName(workspace) {
- const resolved = resolve2(workspace);
- const hash = createHash2("sha256").update(resolved).digest("hex").slice(0, 16);
- return `${sanitizeBase(basename3(resolved))}-${hash}`;
-}
-function fallbackResult(dataRoot, projectLink, reason) {
- return { dataDir: projectLink, dataRoot, linked: false, mode: "in-place-fallback", projectLink, reason };
-}
-function isSameFilesystem(workspace, dataRoot, override) {
- if (override !== undefined)
- return override;
- return statSync(workspace).dev === statSync(dataRoot).dev;
-}
-function ensureInPlaceFallback(projectLink) {
- if (!existsSync5(projectLink))
- mkdirSync(projectLink, { recursive: true });
-}
-function prepareCodegraphWorkspace(workspace, options = {}) {
- const resolvedWorkspace = resolve2(workspace);
- const dataRoot = codegraphDataRoot(options.homeDir ?? homedir5());
- const dataDir = join6(dataRoot, "projects", workspaceStorageName(resolvedWorkspace));
- const projectLink = join6(resolvedWorkspace, ".codegraph");
- try {
- mkdirSync(dataDir, { recursive: true });
- if (existsSync5(projectLink)) {
- const linkStat = lstatSync(projectLink);
- if (!linkStat.isSymbolicLink()) {
- return { dataDir: projectLink, dataRoot, linked: false, mode: "in-project", projectLink };
- }
- if (realpathSync(projectLink) === realpathSync(dataDir)) {
- return { dataDir, dataRoot, linked: true, mode: "global-linked", projectLink };
- }
- return fallbackResult(dataRoot, projectLink, "existing .codegraph symlink points outside OMO store");
- }
- if (!isSameFilesystem(resolvedWorkspace, dataRoot, options.sameFilesystem)) {
- ensureInPlaceFallback(projectLink);
- return fallbackResult(dataRoot, projectLink, "workspace and OMO store are on different filesystems");
- }
- const symlink = options.symlink ?? symlinkSync;
- symlink(dataDir, projectLink, (options.platform ?? process.platform) === "win32" ? "junction" : "dir");
- return { dataDir, dataRoot, linked: true, mode: "global-linked", projectLink };
- } catch (error) {
- const reason = error instanceof Error ? error.message : String(error);
- try {
- ensureInPlaceFallback(projectLink);
- } catch (fallbackError) {
- return fallbackResult(dataRoot, projectLink, `${reason}; fallback failed: ${String(fallbackError)}`);
- }
- return fallbackResult(dataRoot, projectLink, reason);
- }
-}
-function ensureCodegraphGitignored(workspace) {
- const gitDir = join6(workspace, ".git");
- if (!existsSync5(gitDir))
- return false;
- const excludePath = join6(gitDir, "info", "exclude");
- try {
- mkdirSync(join6(gitDir, "info"), { recursive: true });
- const existing = existsSync5(excludePath) ? readFileSync2(excludePath, "utf8") : "";
- if (existing.split(/\r?\n/).includes(".codegraph"))
- return true;
- appendFileSync(excludePath, `${existing.endsWith(`
-`) || existing.length === 0 ? "" : `
-`}.codegraph
-`);
- return true;
- } catch (error) {
- if (error instanceof Error)
- return false;
- throw error;
- }
-}
-
// components/codegraph/src/session-start-worker.ts
var SESSION_START_CWD_ENV = "OMO_CODEGRAPH_SESSION_START_CWD";
var CODEGRAPH_VERSION = "1.0.1";
@@ -1866,13 +1962,10 @@ function finish(action, detail, logOutcome) {
}
async function resolveOrProvisionCommand(deps, config, env, homeDir, nodeSupport) {
const resolved = deps.resolveCommand({ env, homeDir, provisioned: () => provisionedBinFromInstallDir(config.install_dir) });
- if (resolved.exists) {
- if (codegraphCommandRequiresSupportedLocalNode(resolved) && !nodeSupport.supported) {
- return { kind: "unsupported-node" };
- }
+ if (resolved.exists && canUseResolvedCommand(resolved, nodeSupport)) {
return { kind: "resolved", resolution: resolved };
}
- if (!nodeSupport.supported)
+ if (resolved.exists && config.auto_provision === false)
return { kind: "unsupported-node" };
if (config.auto_provision === false)
return { error: "codegraph binary unavailable and auto_provision is disabled", kind: "unavailable", source: resolved.source };
@@ -1883,6 +1976,9 @@ async function resolveOrProvisionCommand(deps, config, env, homeDir, nodeSupport
}
return { kind: "resolved", resolution: { argsPrefix: [], command: provisioned.binPath, exists: true, source: "provisioned" } };
}
+function canUseResolvedCommand(resolved, nodeSupport) {
+ return !codegraphCommandRequiresSupportedLocalNode(resolved) || nodeSupport.supported;
+}
function decideStartupAction(status) {
if (status.timedOut)
return { kind: "skip", reason: "status timed out" };
@@ -1900,7 +1996,7 @@ ${status.stderr ?? ""}`.toLowerCase();
return { kind: "sync" };
}
function jsonSaysInitialized(value) {
- if (!isRecord2(value))
+ if (!isRecord3(value))
return;
const initialized = value["initialized"] ?? value["isInitialized"] ?? value["ready"];
if (typeof initialized === "boolean")
@@ -1966,7 +2062,7 @@ function toOutputText(value) {
return Buffer.isBuffer(value) ? value.toString("utf8") : value;
}
function resolveHomeDir(env) {
- return env["HOME"] ?? env["USERPROFILE"] ?? homedir6();
+ return env["HOME"] ?? env["USERPROFILE"] ?? homedir7();
}
function parseJson(text) {
try {
@@ -1977,7 +2073,7 @@ function parseJson(text) {
throw error;
}
}
-function isRecord2(value) {
+function isRecord3(value) {
return typeof value === "object" && value !== null;
}
@@ -1986,6 +2082,9 @@ var CODEGRAPH_SESSION_START_NOTICE = "LazyCodex CodeGraph bootstrap scheduled in
async function runCodegraphSessionStartHook(options = {}) {
return (await executeCodegraphSessionStartHook(options)).exitCode;
}
+async function runCodegraphPostToolUseHookCli(options = {}) {
+ return (await executeCodegraphPostToolUseHook(options)).exitCode;
+}
async function executeCodegraphSessionStartHook(options = {}) {
const env = options.env ?? processEnv2;
const input = await readHookInput(options.stdin ?? processStdin);
@@ -2003,6 +2102,30 @@ async function executeCodegraphSessionStartHook(options = {}) {
writeHookJson(options.stdout ?? processStdout);
return { action: "spawned", exitCode: 0 };
}
+async function executeCodegraphPostToolUseHook(options = {}) {
+ const env = options.env ?? processEnv2;
+ const input = await readHookInput(options.stdin ?? processStdin);
+ const output = runCodegraphPostToolUseHook(input, { homeDir: resolveHomeDir2(env) });
+ if (output.length === 0)
+ return { action: "skipped", exitCode: 0 };
+ (options.stdout ?? processStdout).write(output);
+ return { action: "emitted-guidance", exitCode: 0 };
+}
+function runCodegraphPostToolUseHook(input, options = {}) {
+ const toolName = isRecord4(input) ? input["tool_name"] : undefined;
+ const cwd = isRecord4(input) ? input["cwd"] : undefined;
+ const toolOutput = isRecord4(input) ? input["tool_response"] ?? input["tool_output"] ?? input["response"] : input;
+ const guidance = buildCodegraphInitGuidanceForToolResult({ cwd, toolName, toolOutput }, options);
+ if (guidance === null)
+ return "";
+ return `${JSON.stringify({
+ hookSpecificOutput: {
+ hookEventName: "PostToolUse",
+ additionalContext: guidance
+ }
+ })}
+`;
+}
function writeHookJson(stdout) {
const output = {
hookSpecificOutput: {
@@ -2018,10 +2141,10 @@ function spawnDetachedWorker(invocation) {
child.unref();
}
function resolveHomeDir2(env) {
- return env["HOME"] ?? env["USERPROFILE"] ?? homedir7();
+ return env["HOME"] ?? env["USERPROFILE"] ?? homedir8();
}
function resolveProjectRoot(input, fallback) {
- if (!isRecord3(input))
+ if (!isRecord4(input))
return fallback;
const cwd = input["cwd"];
return typeof cwd === "string" && cwd.trim().length > 0 ? cwd : fallback;
@@ -2045,7 +2168,7 @@ function parseJson2(text) {
throw error;
}
}
-function isRecord3(value) {
+function isRecord4(value) {
return typeof value === "object" && value !== null;
}
function defaultWorkerCliPath() {
@@ -2055,7 +2178,7 @@ function defaultWorkerCliPath() {
// components/codegraph/src/serve.ts
import { spawn as spawn2 } from "node:child_process";
import { existsSync as existsSync7, realpathSync as realpathSync2 } from "node:fs";
-import { homedir as homedir8 } from "node:os";
+import { homedir as homedir9 } from "node:os";
import { basename as basename4, extname as extname2, join as join8, resolve as resolve3 } from "node:path";
import {
cwd as processCwd3,
@@ -2068,11 +2191,12 @@ var CODEGRAPH_SKIP_HINT = `CodeGraph MCP skipped: codegraph binary not found. In
`;
var CODEGRAPH_DISABLED_HINT = `CodeGraph MCP skipped: disabled by OMO SOT config. Set [codex].codegraph.enabled=true to enable it.
`;
+var CODEGRAPH_VERSION2 = "1.0.1";
var WINDOWS_CMD_EXTENSIONS2 = new Set([".bat", ".cmd"]);
var WINDOWS_NODE_SCRIPT_EXTENSIONS = new Set([".cjs", ".js", ".mjs"]);
async function runCodegraphServe(options = {}) {
const env = options.env ?? processEnv3;
- const homeDir = options.homeDir ?? homedir8();
+ const homeDir = options.homeDir ?? homedir9();
const config = options.config ?? getCodexOmoConfig({ cwd: options.cwd ?? processCwd3(), env, homeDir });
const codegraphConfig = config.codegraph ?? {};
if (codegraphConfig.enabled === false) {
@@ -2084,15 +2208,24 @@ async function runCodegraphServe(options = {}) {
homeDir,
provisioned: () => provisionedBinFromInstallDir2(codegraphConfig.install_dir)
};
- const resolution = options.resolve?.(resolutionOptions) ?? resolveCodegraphCommand(resolutionOptions);
+ let resolution = options.resolve?.(resolutionOptions) ?? resolveCodegraphCommand(resolutionOptions);
const nodeSupport = evaluateCodegraphNodeSupport({ env, nodeVersion: options.nodeVersion });
if (!resolution.exists || shouldSkipResolvedCommand(resolution, options.commandExists ?? existsSync7)) {
if (resolution.source === "path" && !nodeSupport.supported) {
(options.stderr ?? processStderr2).write(buildCodegraphNodeSkipHint(nodeSupport));
return 1;
}
- (options.stderr ?? processStderr2).write(CODEGRAPH_SKIP_HINT);
- return 1;
+ const provisioned = await provisionMissingCodegraph({
+ config: codegraphConfig,
+ ensureProvisioned: options.ensureProvisioned ?? ensureCodegraphProvisioned,
+ homeDir,
+ resolution
+ });
+ if (provisioned === null) {
+ (options.stderr ?? processStderr2).write(CODEGRAPH_SKIP_HINT);
+ return 1;
+ }
+ resolution = provisioned;
}
if (codegraphCommandRequiresSupportedLocalNode(resolution) && !nodeSupport.supported) {
(options.stderr ?? processStderr2).write(buildCodegraphNodeSkipHint(nodeSupport));
@@ -2109,6 +2242,21 @@ async function runCodegraphServe(options = {}) {
stdio: "inherit"
});
}
+async function provisionMissingCodegraph(options) {
+ if (options.resolution.source === "env")
+ return null;
+ if (options.config.auto_provision === false)
+ return null;
+ const installDir = options.config.install_dir ?? join8(options.homeDir, ".omo", "codegraph");
+ const result = await options.ensureProvisioned({
+ installDir,
+ lockDir: join8(installDir, ".locks"),
+ version: CODEGRAPH_VERSION2
+ });
+ if (!result.provisioned || result.binPath === undefined)
+ return null;
+ return { argsPrefix: [], command: result.binPath, exists: true, source: "provisioned" };
+}
function shouldSkipResolvedCommand(resolution, commandExists) {
if (resolution.source !== "env")
return false;
@@ -2183,6 +2331,14 @@ async function runCodegraphCli(options = {}) {
if (command === "hook" && subcommand === "session-start") {
return runCodegraphSessionStartHook(options);
}
+ if (command === "hook" && subcommand === "post-tool-use") {
+ const hookOptions = {
+ ...options.env === undefined ? {} : { env: options.env },
+ ...options.stdin === undefined ? {} : { stdin: options.stdin },
+ ...options.stdout === undefined ? {} : { stdout: options.stdout }
+ };
+ return runCodegraphPostToolUseHookCli(hookOptions);
+ }
if (command === "hook" && subcommand === "session-start-worker") {
const workerOptions = {
...options.workerOptions,
diff --git a/plugins/omo/components/codegraph/dist/serve.js b/plugins/omo/components/codegraph/dist/serve.js
index 3d88ab43..7154bfa5 100644
--- a/plugins/omo/components/codegraph/dist/serve.js
+++ b/plugins/omo/components/codegraph/dist/serve.js
@@ -2,9 +2,9 @@
// src/serve.ts
import { spawn } from "node:child_process";
-import { existsSync as existsSync4, realpathSync } from "node:fs";
-import { homedir as homedir4 } from "node:os";
-import { basename as basename2, extname, join as join5, resolve as resolve2 } from "node:path";
+import { existsSync as existsSync5, realpathSync } from "node:fs";
+import { homedir as homedir5 } from "node:os";
+import { basename as basename3, extname, join as join6, resolve as resolve2 } from "node:path";
import {
cwd as processCwd,
env as processEnv,
@@ -59,16 +59,235 @@ function parseNodeMajor(version) {
return Number.isNaN(major) ? 0 : major;
}
-// ../../../../utils/src/codegraph/resolve.ts
+// ../../../../utils/src/codegraph/provision.ts
+import { createHash, randomUUID } from "node:crypto";
+import { execFile } from "node:child_process";
+import { chmod, mkdir, readdir, readFile, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
import { existsSync } from "node:fs";
-import { homedir as homedir2 } from "node:os";
+import { homedir as homedir2, hostname } from "node:os";
+import { basename, join as join2 } from "node:path";
+import { promisify } from "node:util";
+
+// ../../../../utils/src/codegraph/manifest.ts
+var CODEGRAPH_PROVISION_MANIFEST = {
+ assets: {
+ "darwin-arm64": {
+ executableName: "codegraph",
+ sha256: "95bb27bf6382b69659e158e0c04d71cc394778951e1317d582be7807e7866908",
+ url: "https://github.com/colbymchenry/codegraph/releases/download/v1.0.1/codegraph-darwin-arm64.tar.gz"
+ },
+ "darwin-x64": {
+ executableName: "codegraph",
+ sha256: "3311cc1d1f0f0ad742709b6a43d8a9187b1ef0af0dd30e0b58008dc673e29478",
+ url: "https://github.com/colbymchenry/codegraph/releases/download/v1.0.1/codegraph-darwin-x64.tar.gz"
+ },
+ "linux-arm64": {
+ executableName: "codegraph",
+ sha256: "e16f612bc96c2ebccd04574cbed500c9939147c80666ad6bb024398dff7992ae",
+ url: "https://github.com/colbymchenry/codegraph/releases/download/v1.0.1/codegraph-linux-arm64.tar.gz"
+ },
+ "linux-x64": {
+ executableName: "codegraph",
+ sha256: "d45a068f44596a85c7ba7d0ef924eaf7103fbbf3cafbeb668127daff60a52228",
+ url: "https://github.com/colbymchenry/codegraph/releases/download/v1.0.1/codegraph-linux-x64.tar.gz"
+ },
+ "win32-arm64": {
+ executableName: "codegraph.cmd",
+ sha256: "8d57ced73b24d35f758f2ede2318e80e1d7241987f37a999e3d80edb6fddf961",
+ url: "https://registry.npmjs.org/@colbymchenry/codegraph-win32-arm64/-/codegraph-win32-arm64-1.0.1.tgz"
+ },
+ "win32-x64": {
+ executableName: "codegraph.cmd",
+ sha256: "52607fe73b05e741fd1087da2ceca9d3c8f565e36bf1a7070600bdbdf3931e32",
+ url: "https://registry.npmjs.org/@colbymchenry/codegraph-win32-x64/-/codegraph-win32-x64-1.0.1.tgz"
+ }
+ },
+ version: "1.0.1"
+};
+
+// ../../../../utils/src/codegraph/provision.ts
+var DEFAULT_LOCK_WAIT_MS = 5000;
+var DEFAULT_LOCK_STALE_MS = 120000;
+var DEFAULT_DOWNLOAD_TIMEOUT_MS = 60000;
+var execFileAsync = promisify(execFile);
+function platformKey() {
+ return `${process.platform}-${process.arch}`;
+}
+function markerPath(installDir, version) {
+ return join2(installDir, ".provisioned", `codegraph-${version}.json`);
+}
+function defaultInstallDir() {
+ return join2(homedir2(), ".omo", "codegraph");
+}
+function sha256(bytes) {
+ return createHash("sha256").update(bytes).digest("hex");
+}
+function isErrnoException(error) {
+ return error instanceof Error && "code" in error;
+}
+async function removeEmptyDirectory(path) {
+ try {
+ await rmdir(path);
+ } catch (error) {
+ if (isErrnoException(error) && error.code === "ENOENT")
+ return;
+ if (isErrnoException(error) && error.code === "ENOTEMPTY")
+ return;
+ throw error;
+ }
+}
+function sleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}
+async function defaultDownloader(asset, timeoutMs = DEFAULT_DOWNLOAD_TIMEOUT_MS) {
+ const response = await fetch(asset.url, { signal: AbortSignal.timeout(timeoutMs) });
+ if (!response.ok)
+ throw new Error(`download failed with HTTP ${response.status}`);
+ return new Uint8Array(await response.arrayBuffer());
+}
+function forcedBadChecksumOptions(options) {
+ if (options.forceBadChecksum !== true)
+ return null;
+ const key = options.platformKey ?? platformKey();
+ return {
+ downloader: async () => new TextEncoder().encode("checksum mismatch"),
+ installDir: options.installDir ?? join2(options.lockDir, "codegraph-force-bad-checksum"),
+ manifest: {
+ assets: {
+ [key]: { executableName: process.platform === "win32" ? "codegraph.cmd" : "codegraph", sha256: "0000", url: "memory://bad" }
+ },
+ version: options.version
+ },
+ platformKey: key
+ };
+}
+async function readMarker(path) {
+ if (!existsSync(path))
+ return null;
+ try {
+ const raw = JSON.parse(await readFile(path, "utf8"));
+ if (typeof raw === "object" && raw !== null && "binPath" in raw) {
+ const value = raw.binPath;
+ return typeof value === "string" && existsSync(value) ? value : null;
+ }
+ return null;
+ } catch (error) {
+ if (error instanceof Error)
+ return null;
+ throw error;
+ }
+}
+async function acquireLock(lockPath, waitMs, staleMs) {
+ const startedAt = Date.now();
+ await mkdir(join2(lockPath, ".."), { recursive: true });
+ while (Date.now() - startedAt <= waitMs) {
+ try {
+ await mkdir(lockPath);
+ return () => rm(lockPath, { force: true, recursive: true });
+ } catch (error) {
+ if (!isErrnoException(error) || error.code !== "EEXIST")
+ throw error;
+ const lockStat = await stat(lockPath).catch(() => null);
+ if (lockStat !== null && Date.now() - lockStat.mtimeMs > staleMs) {
+ await rm(lockPath, { force: true, recursive: true });
+ continue;
+ }
+ await sleep(25);
+ }
+ }
+ return null;
+}
+async function extractTarGz(archivePath, destinationDir) {
+ await execFileAsync("tar", ["-xzf", archivePath, "-C", destinationDir]);
+}
+async function installExtractedBundle(extractDir, installDir, executableName) {
+ const roots = await readdir(extractDir);
+ if (roots.length !== 1)
+ throw new Error(`CodeGraph archive should contain one root directory, found ${roots.length}`);
+ const bundleDir = join2(extractDir, roots[0] ?? "");
+ const bundleEntries = await readdir(bundleDir);
+ await mkdir(installDir, { recursive: true });
+ for (const entry of bundleEntries) {
+ await rm(join2(installDir, entry), { force: true, recursive: true });
+ await rename(join2(bundleDir, entry), join2(installDir, entry));
+ }
+ const destination = join2(installDir, "bin", executableName);
+ if (!existsSync(destination))
+ throw new Error(`CodeGraph archive did not contain bin/${executableName}`);
+ await chmod(destination, 493);
+ return destination;
+}
+async function installAsset(layout) {
+ const { asset, downloader, installDir, version } = layout;
+ const stagingDir = join2(installDir, ".staging", randomUUID());
+ const archivePath = join2(stagingDir, basename(asset.url));
+ const extractDir = join2(stagingDir, "extract");
+ try {
+ await mkdir(extractDir, { recursive: true });
+ const bytes = await downloader(asset);
+ const actualChecksum = sha256(bytes);
+ if (actualChecksum !== asset.sha256) {
+ throw new Error(`checksum mismatch for ${basename(asset.url)}: expected ${asset.sha256}, got ${actualChecksum}`);
+ }
+ if (!asset.url.endsWith(".tar.gz") && !asset.url.endsWith(".tgz")) {
+ throw new Error(`unsupported CodeGraph archive type for ${basename(asset.url)}`);
+ }
+ await writeFile(archivePath, bytes);
+ await extractTarGz(archivePath, extractDir);
+ const destination = await installExtractedBundle(extractDir, installDir, asset.executableName);
+ await mkdir(join2(installDir, ".provisioned"), { recursive: true });
+ await writeFile(markerPath(installDir, version), `${JSON.stringify({ binPath: destination, version })}
+`);
+ return destination;
+ } finally {
+ await rm(stagingDir, { force: true, recursive: true });
+ await removeEmptyDirectory(join2(installDir, ".staging"));
+ }
+}
+async function ensureCodegraphProvisioned(options) {
+ const forced = forcedBadChecksumOptions(options);
+ const installDir = forced?.installDir ?? options.installDir ?? defaultInstallDir();
+ const manifest = forced?.manifest ?? options.manifest ?? CODEGRAPH_PROVISION_MANIFEST;
+ const activePlatformKey = forced?.platformKey ?? options.platformKey ?? platformKey();
+ const downloader = forced?.downloader ?? options.downloader ?? ((asset) => defaultDownloader(asset, options.downloadTimeoutMs));
+ const marker = markerPath(installDir, options.version);
+ const existing = await readMarker(marker);
+ if (existing !== null)
+ return { binPath: existing, provisioned: true };
+ const lockPath = join2(options.lockDir, `codegraph-${hostname()}.lock`);
+ const release = await acquireLock(lockPath, options.lockWaitMs ?? DEFAULT_LOCK_WAIT_MS, options.lockStaleMs ?? DEFAULT_LOCK_STALE_MS);
+ if (release === null)
+ return { error: "timed out waiting for codegraph provisioning lock", provisioned: false };
+ try {
+ const lockedExisting = await readMarker(marker);
+ if (lockedExisting !== null)
+ return { binPath: lockedExisting, provisioned: true };
+ if (manifest.version !== options.version) {
+ return { error: `manifest version ${manifest.version} does not match requested ${options.version}`, provisioned: false };
+ }
+ const asset = manifest.assets[activePlatformKey];
+ if (asset === undefined) {
+ return { error: `no CodeGraph ${options.version} asset for ${activePlatformKey}`, provisioned: false };
+ }
+ const binPath = await installAsset({ asset, downloader, installDir, version: options.version });
+ return { binPath, provisioned: true };
+ } catch (error) {
+ return { error: error instanceof Error ? error.message : String(error), provisioned: false };
+ } finally {
+ await release();
+ }
+}
+
+// ../../../../utils/src/codegraph/resolve.ts
+import { existsSync as existsSync2 } from "node:fs";
+import { homedir as homedir3 } from "node:os";
import { spawnSync } from "node:child_process";
-import { basename, dirname, join as join3 } from "node:path";
+import { basename as basename2, dirname, join as join4 } from "node:path";
import { createRequire } from "node:module";
// ../../../../utils/src/runtime/which.ts
import { accessSync, constants } from "node:fs";
-import { delimiter, join as join2 } from "node:path";
+import { delimiter, join as join3 } from "node:path";
var runtime = globalThis;
function isUnsafeCommandName(commandName) {
if (commandName.includes("/") || commandName.includes("\\"))
@@ -123,7 +342,7 @@ function bunWhich(commandName) {
return null;
for (const pathEntry of pathEntries) {
for (const candidateName of candidateNames) {
- const candidatePath = join2(pathEntry, candidateName);
+ const candidatePath = join3(pathEntry, candidateName);
if (isExecutable(candidatePath))
return candidatePath;
}
@@ -164,7 +383,7 @@ ${result.stderr}`.trim().split(/\s+/)[0];
}
}
function isNodeExecutableName(filePath) {
- const executable = basename(filePath).toLowerCase();
+ const executable = basename2(filePath).toLowerCase();
return executable === "node" || executable === "node.exe" || /^node\d+(\.exe)?$/.test(executable);
}
function looksLikePath(command) {
@@ -204,8 +423,8 @@ function defaultNodeRuntime(env, fileExists, which, nodeVersion) {
function defaultProvisionedBin(homeDir, fileExists) {
const binaryName = process.platform === "win32" ? "codegraph.cmd" : "codegraph";
const candidates = [
- join3(homeDir, ".omo", "codegraph", "bin", binaryName),
- join3(homeDir, ".omo", "codegraph", "node-servers", "node_modules", ".bin", binaryName)
+ join4(homeDir, ".omo", "codegraph", "bin", binaryName),
+ join4(homeDir, ".omo", "codegraph", "node-servers", "node_modules", ".bin", binaryName)
];
return candidates.find((candidate) => fileExists(candidate)) ?? null;
}
@@ -213,7 +432,7 @@ function resolveBundledShim(requireResolve, fileExists) {
try {
const packageJson = requireResolve(`${CODEGRAPH_PACKAGE}/package.json`);
const packageRoot = dirname(packageJson);
- const candidates = [join3(packageRoot, "bin", "codegraph.js"), join3(packageRoot, "npm-shim.js")];
+ const candidates = [join4(packageRoot, "bin", "codegraph.js"), join4(packageRoot, "npm-shim.js")];
return candidates.find((candidate) => fileExists(candidate)) ?? null;
} catch (error) {
if (error instanceof Error)
@@ -229,7 +448,7 @@ function resolveBundledShim(requireResolve, fileExists) {
}
function resolveCodegraphCommand(options = {}) {
const env = options.env ?? process.env;
- const fileExists = options.fileExists ?? existsSync;
+ const fileExists = options.fileExists ?? existsSync2;
const configuredBin = env[CODEGRAPH_ENV_BIN]?.trim() || env[CODEGRAPH_LEGACY_ENV_BIN]?.trim();
if (configuredBin !== undefined && configuredBin.length > 0) {
return { argsPrefix: [], command: configuredBin, exists: fileExists(configuredBin), source: "env" };
@@ -241,7 +460,7 @@ function resolveCodegraphCommand(options = {}) {
if (bundled !== null && runtime2 !== null) {
return { argsPrefix: [bundled], command: runtime2, exists: true, source: "bundled" };
}
- const provisioned = options.provisioned?.() ?? defaultProvisionedBin(options.homeDir ?? homedir2(), fileExists);
+ const provisioned = options.provisioned?.() ?? defaultProvisionedBin(options.homeDir ?? homedir3(), fileExists);
if (provisioned !== null && fileExists(provisioned)) {
return { argsPrefix: [], command: provisioned, exists: true, source: "provisioned" };
}
@@ -255,8 +474,8 @@ function resolveCodegraphCommand(options = {}) {
}
// ../../../../utils/src/omo-config/loader.ts
-import { existsSync as existsSync3, readFileSync } from "node:fs";
-import { homedir as homedir3 } from "node:os";
+import { existsSync as existsSync4, readFileSync } from "node:fs";
+import { homedir as homedir4 } from "node:os";
// ../../../../utils/src/deep-merge.ts
var DANGEROUS_KEYS = new Set(["__proto__", "constructor", "prototype"]);
@@ -1212,8 +1431,8 @@ function buildEnvOverrides(harness, env, warnings, merge) {
}
// ../../../../utils/src/omo-config/resolve.ts
-import { existsSync as existsSync2 } from "node:fs";
-import { dirname as dirname2, isAbsolute, join as join4, relative, resolve } from "node:path";
+import { existsSync as existsSync3 } from "node:fs";
+import { dirname as dirname2, isAbsolute, join as join5, relative, resolve } from "node:path";
function containsPath(parent, child) {
const pathToChild = relative(parent, child);
return pathToChild === "" || !pathToChild.startsWith("..") && !isAbsolute(pathToChild);
@@ -1226,8 +1445,8 @@ function findProjectConfigPathsNearestFirst(cwd, homeDir) {
while (true) {
if (stopBeforeDir !== null && currentDir === stopBeforeDir)
break;
- const configPath = join4(currentDir, ".omo", "config.jsonc");
- if (existsSync2(configPath)) {
+ const configPath = join5(currentDir, ".omo", "config.jsonc");
+ if (existsSync3(configPath)) {
paths.push(configPath);
}
const parentDir = dirname2(currentDir);
@@ -1238,7 +1457,7 @@ function findProjectConfigPathsNearestFirst(cwd, homeDir) {
return paths;
}
function resolveOmoConfigPaths(options) {
- const globalPath = join4(resolve(options.homeDir), ".omo", "config.jsonc");
+ const globalPath = join5(resolve(options.homeDir), ".omo", "config.jsonc");
const projectPathsFarthestFirst = findProjectConfigPathsNearestFirst(options.cwd, options.homeDir).reverse();
return [
{ path: globalPath, scope: "global" },
@@ -1449,13 +1668,13 @@ function validateHarnessApplicability(config, harness) {
}
function loadOmoConfig(options) {
const cwd = options.cwd ?? process.cwd();
- const homeDir = options.homeDir ?? process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir3();
+ const homeDir = options.homeDir ?? process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir4();
const env = options.env ?? process.env;
let config = BUILT_IN_DEFAULTS;
const sources = [];
const warnings = [];
for (const candidate of resolveOmoConfigPaths({ cwd, homeDir })) {
- if (!existsSync3(candidate.path)) {
+ if (!existsSync4(candidate.path)) {
if (candidate.scope === "global") {
sources.push(toMissingSource(candidate));
}
@@ -1497,11 +1716,12 @@ var CODEGRAPH_SKIP_HINT = `CodeGraph MCP skipped: codegraph binary not found. In
`;
var CODEGRAPH_DISABLED_HINT = `CodeGraph MCP skipped: disabled by OMO SOT config. Set [codex].codegraph.enabled=true to enable it.
`;
+var CODEGRAPH_VERSION = "1.0.1";
var WINDOWS_CMD_EXTENSIONS = new Set([".bat", ".cmd"]);
var WINDOWS_NODE_SCRIPT_EXTENSIONS = new Set([".cjs", ".js", ".mjs"]);
async function runCodegraphServe(options = {}) {
const env = options.env ?? processEnv;
- const homeDir = options.homeDir ?? homedir4();
+ const homeDir = options.homeDir ?? homedir5();
const config = options.config ?? getCodexOmoConfig({ cwd: options.cwd ?? processCwd(), env, homeDir });
const codegraphConfig = config.codegraph ?? {};
if (codegraphConfig.enabled === false) {
@@ -1513,15 +1733,24 @@ async function runCodegraphServe(options = {}) {
homeDir,
provisioned: () => provisionedBinFromInstallDir(codegraphConfig.install_dir)
};
- const resolution = options.resolve?.(resolutionOptions) ?? resolveCodegraphCommand(resolutionOptions);
+ let resolution = options.resolve?.(resolutionOptions) ?? resolveCodegraphCommand(resolutionOptions);
const nodeSupport = evaluateCodegraphNodeSupport({ env, nodeVersion: options.nodeVersion });
- if (!resolution.exists || shouldSkipResolvedCommand(resolution, options.commandExists ?? existsSync4)) {
+ if (!resolution.exists || shouldSkipResolvedCommand(resolution, options.commandExists ?? existsSync5)) {
if (resolution.source === "path" && !nodeSupport.supported) {
(options.stderr ?? processStderr).write(buildCodegraphNodeSkipHint(nodeSupport));
return 1;
}
- (options.stderr ?? processStderr).write(CODEGRAPH_SKIP_HINT);
- return 1;
+ const provisioned = await provisionMissingCodegraph({
+ config: codegraphConfig,
+ ensureProvisioned: options.ensureProvisioned ?? ensureCodegraphProvisioned,
+ homeDir,
+ resolution
+ });
+ if (provisioned === null) {
+ (options.stderr ?? processStderr).write(CODEGRAPH_SKIP_HINT);
+ return 1;
+ }
+ resolution = provisioned;
}
if (codegraphCommandRequiresSupportedLocalNode(resolution) && !nodeSupport.supported) {
(options.stderr ?? processStderr).write(buildCodegraphNodeSkipHint(nodeSupport));
@@ -1538,6 +1767,21 @@ async function runCodegraphServe(options = {}) {
stdio: "inherit"
});
}
+async function provisionMissingCodegraph(options) {
+ if (options.resolution.source === "env")
+ return null;
+ if (options.config.auto_provision === false)
+ return null;
+ const installDir = options.config.install_dir ?? join6(options.homeDir, ".omo", "codegraph");
+ const result = await options.ensureProvisioned({
+ installDir,
+ lockDir: join6(installDir, ".locks"),
+ version: CODEGRAPH_VERSION
+ });
+ if (!result.provisioned || result.binPath === undefined)
+ return null;
+ return { argsPrefix: [], command: result.binPath, exists: true, source: "provisioned" };
+}
function shouldSkipResolvedCommand(resolution, commandExists) {
if (resolution.source !== "env")
return false;
@@ -1555,8 +1799,8 @@ function codegraphEnvForConfig(config, homeDir, buildEnv) {
function provisionedBinFromInstallDir(installDir) {
if (installDir === undefined)
return null;
- const candidate = join5(installDir, "bin", process.platform === "win32" ? "codegraph.cmd" : "codegraph");
- return existsSync4(candidate) ? candidate : null;
+ const candidate = join6(installDir, "bin", process.platform === "win32" ? "codegraph.cmd" : "codegraph");
+ return existsSync5(candidate) ? candidate : null;
}
async function runCodegraphServeCli() {
process.exitCode = await runCodegraphServe();
@@ -1598,7 +1842,7 @@ function isDirectInvocation(argvPath) {
if (argvPath === undefined)
return false;
const modulePath = fileURLToPath(import.meta.url);
- const moduleName = basename2(modulePath);
+ const moduleName = basename3(modulePath);
if (moduleName !== "serve.js" && moduleName !== "serve.ts")
return false;
return realpathSync(resolve2(argvPath)) === realpathSync(modulePath);
diff --git a/plugins/omo/components/codegraph/package.json b/plugins/omo/components/codegraph/package.json
index 21b267c1..e52b99e6 100644
--- a/plugins/omo/components/codegraph/package.json
+++ b/plugins/omo/components/codegraph/package.json
@@ -1,6 +1,6 @@
{
"name": "@sisyphuslabs/codex-codegraph",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex plugin MCP wrapper for CodeGraph.",
"type": "module",
"private": true,
diff --git a/plugins/omo/components/codegraph/src/cli.ts b/plugins/omo/components/codegraph/src/cli.ts
index 4022e140..9bd67641 100644
--- a/plugins/omo/components/codegraph/src/cli.ts
+++ b/plugins/omo/components/codegraph/src/cli.ts
@@ -5,8 +5,10 @@ import { stderr as processStderr } from "node:process";
import { fileURLToPath } from "node:url";
import {
+ runCodegraphPostToolUseHookCli,
runCodegraphSessionStartHook,
runCodegraphSessionStartWorker,
+ type PostToolUseHookOptions,
type SessionStartHookOptions,
type SessionStartWorkerOptions,
} from "./hook.js";
@@ -25,6 +27,15 @@ export async function runCodegraphCli(options: RunCodegraphCliOptions = {}): Pro
return runCodegraphSessionStartHook(options);
}
+ if (command === "hook" && subcommand === "post-tool-use") {
+ const hookOptions: PostToolUseHookOptions = {
+ ...(options.env === undefined ? {} : { env: options.env }),
+ ...(options.stdin === undefined ? {} : { stdin: options.stdin }),
+ ...(options.stdout === undefined ? {} : { stdout: options.stdout }),
+ };
+ return runCodegraphPostToolUseHookCli(hookOptions);
+ }
+
if (command === "hook" && subcommand === "session-start-worker") {
const workerOptions: SessionStartWorkerOptions = {
...options.workerOptions,
diff --git a/plugins/omo/components/codegraph/src/hook-types.ts b/plugins/omo/components/codegraph/src/hook-types.ts
index 742b8bda..dc76c290 100644
--- a/plugins/omo/components/codegraph/src/hook-types.ts
+++ b/plugins/omo/components/codegraph/src/hook-types.ts
@@ -10,6 +10,7 @@ import type { CodegraphWorkspacePreparation as SharedCodegraphWorkspacePreparati
import type { CodegraphConfig as SharedCodegraphConfig } from "../../../../../utils/src/omo-config.ts";
export type SessionStartAction = "skipped-disabled" | "spawned";
+export type PostToolUseAction = "emitted-guidance" | "skipped";
export type WorkerAction = "failed" | "initialized" | "skipped-disabled" | "skipped-status" | "skipped-unavailable" | "skipped-unsupported-node" | "synced";
export interface WorkerSpawnInvocation {
@@ -27,6 +28,11 @@ export interface SessionStartHookResult {
readonly exitCode: 0;
}
+export interface PostToolUseHookResult {
+ readonly action: PostToolUseAction;
+ readonly exitCode: 0;
+}
+
export interface CodegraphCommandResult {
readonly exitCode: number;
readonly stderr?: string;
@@ -73,6 +79,12 @@ export interface SessionStartHookOptions {
readonly workerCliPath?: string;
}
+export interface PostToolUseHookOptions {
+ readonly env?: Record<string, string | undefined>;
+ readonly stdin?: Readable & { readonly isTTY?: boolean };
+ readonly stdout?: HookStdout;
+}
+
export interface SessionStartWorkerOptions {
readonly config?: CodexOmoConfig;
readonly cwd?: string;
diff --git a/plugins/omo/components/codegraph/src/hook.ts b/plugins/omo/components/codegraph/src/hook.ts
index 9ff77f86..89e40eda 100644
--- a/plugins/omo/components/codegraph/src/hook.ts
+++ b/plugins/omo/components/codegraph/src/hook.ts
@@ -4,10 +4,13 @@ import { cwd as processCwd, env as processEnv, stdin as processStdin, stdout as
import type { Readable } from "node:stream";
import { fileURLToPath } from "node:url";
+import { buildCodegraphInitGuidanceForToolResult } from "../../../../../utils/src/codegraph/guidance.ts";
import { getCodexOmoConfig } from "../../../shared/src/config-loader.ts";
import { SESSION_START_CWD_ENV } from "./session-start-worker.js";
import type {
HookStdout,
+ PostToolUseHookOptions,
+ PostToolUseHookResult,
SessionStartHookOptions,
SessionStartHookResult,
WorkerSpawnInvocation,
@@ -23,6 +26,8 @@ export type {
CodexOmoConfig,
HookStdout,
OmoConfigSource,
+ PostToolUseHookOptions,
+ PostToolUseHookResult,
SessionStartAction,
SessionStartHookOptions,
SessionStartHookResult,
@@ -38,6 +43,10 @@ export async function runCodegraphSessionStartHook(options: SessionStartHookOpti
return (await executeCodegraphSessionStartHook(options)).exitCode;
}
+export async function runCodegraphPostToolUseHookCli(options: PostToolUseHookOptions = {}): Promise<number> {
+ return (await executeCodegraphPostToolUseHook(options)).exitCode;
+}
+
export async function executeCodegraphSessionStartHook(options: SessionStartHookOptions = {}): Promise<SessionStartHookResult> {
const env = options.env ?? processEnv;
const input = await readHookInput(options.stdin ?? processStdin);
@@ -58,6 +67,31 @@ export async function executeCodegraphSessionStartHook(options: SessionStartHook
return { action: "spawned", exitCode: 0 };
}
+export async function executeCodegraphPostToolUseHook(options: PostToolUseHookOptions = {}): Promise<PostToolUseHookResult> {
+ const env = options.env ?? processEnv;
+ const input = await readHookInput(options.stdin ?? processStdin);
+ const output = runCodegraphPostToolUseHook(input, { homeDir: resolveHomeDir(env) });
+ if (output.length === 0) return { action: "skipped", exitCode: 0 };
+
+ (options.stdout ?? processStdout).write(output);
+ return { action: "emitted-guidance", exitCode: 0 };
+}
+
+export function runCodegraphPostToolUseHook(input: unknown, options: { readonly homeDir?: string } = {}): string {
+ const toolName = isRecord(input) ? input["tool_name"] : undefined;
+ const cwd = isRecord(input) ? input["cwd"] : undefined;
+ const toolOutput = isRecord(input) ? (input["tool_response"] ?? input["tool_output"] ?? input["response"]) : input;
+ const guidance = buildCodegraphInitGuidanceForToolResult({ cwd, toolName, toolOutput }, options);
+ if (guidance === null) return "";
+
+ return `${JSON.stringify({
+ hookSpecificOutput: {
+ hookEventName: "PostToolUse",
+ additionalContext: guidance,
+ },
+ })}\n`;
+}
+
function writeHookJson(stdout: HookStdout): void {
const output = {
hookSpecificOutput: {
diff --git a/plugins/omo/components/codegraph/src/serve.ts b/plugins/omo/components/codegraph/src/serve.ts
index b9ccaa12..d9e55313 100644
--- a/plugins/omo/components/codegraph/src/serve.ts
+++ b/plugins/omo/components/codegraph/src/serve.ts
@@ -16,6 +16,10 @@ import {
buildCodegraphNodeSkipHint,
evaluateCodegraphNodeSupport,
} from "../../../../../utils/src/codegraph/node-support.ts";
+import {
+ ensureCodegraphProvisioned,
+ type EnsureCodegraphProvisionedOptions,
+} from "../../../../../utils/src/codegraph/provision.ts";
import {
codegraphCommandRequiresSupportedLocalNode,
resolveCodegraphCommand,
@@ -37,6 +41,9 @@ export type CodegraphServeProcessRunner = (
args: readonly string[],
options: CodegraphServeProcessOptions,
) => Promise<number>;
+export type CodegraphProvisioner = (
+ options: EnsureCodegraphProvisionedOptions,
+) => ReturnType<typeof ensureCodegraphProvisioned>;
export interface ServeProcessInvocation {
readonly args: readonly string[];
@@ -58,12 +65,14 @@ export interface RunCodegraphServeOptions {
readonly resolve?: (options: ResolveCodegraphCommandOptions) => ReturnType<typeof resolveCodegraphCommand>;
readonly runProcess?: CodegraphServeProcessRunner;
readonly stderr?: CodegraphServeStderr;
+ readonly ensureProvisioned?: CodegraphProvisioner;
}
const CODEGRAPH_SKIP_HINT =
"CodeGraph MCP skipped: codegraph binary not found. Install CodeGraph or set OMO_CODEGRAPH_BIN.\n";
const CODEGRAPH_DISABLED_HINT =
"CodeGraph MCP skipped: disabled by OMO SOT config. Set [codex].codegraph.enabled=true to enable it.\n";
+const CODEGRAPH_VERSION = "1.0.1";
const WINDOWS_CMD_EXTENSIONS = new Set([".bat", ".cmd"]);
const WINDOWS_NODE_SCRIPT_EXTENSIONS = new Set([".cjs", ".js", ".mjs"]);
@@ -82,15 +91,24 @@ export async function runCodegraphServe(options: RunCodegraphServeOptions = {}):
homeDir,
provisioned: () => provisionedBinFromInstallDir(codegraphConfig.install_dir),
} satisfies ResolveCodegraphCommandOptions;
- const resolution = options.resolve?.(resolutionOptions) ?? resolveCodegraphCommand(resolutionOptions);
+ let resolution = options.resolve?.(resolutionOptions) ?? resolveCodegraphCommand(resolutionOptions);
const nodeSupport = evaluateCodegraphNodeSupport({ env, nodeVersion: options.nodeVersion });
if (!resolution.exists || shouldSkipResolvedCommand(resolution, options.commandExists ?? existsSync)) {
if (resolution.source === "path" && !nodeSupport.supported) {
(options.stderr ?? processStderr).write(buildCodegraphNodeSkipHint(nodeSupport));
return 1;
}
- (options.stderr ?? processStderr).write(CODEGRAPH_SKIP_HINT);
- return 1;
+ const provisioned = await provisionMissingCodegraph({
+ config: codegraphConfig,
+ ensureProvisioned: options.ensureProvisioned ?? ensureCodegraphProvisioned,
+ homeDir,
+ resolution,
+ });
+ if (provisioned === null) {
+ (options.stderr ?? processStderr).write(CODEGRAPH_SKIP_HINT);
+ return 1;
+ }
+ resolution = provisioned;
}
if (codegraphCommandRequiresSupportedLocalNode(resolution) && !nodeSupport.supported) {
@@ -110,6 +128,25 @@ export async function runCodegraphServe(options: RunCodegraphServeOptions = {}):
});
}
+async function provisionMissingCodegraph(options: {
+ readonly config: CodegraphConfig;
+ readonly ensureProvisioned: CodegraphProvisioner;
+ readonly homeDir: string;
+ readonly resolution: CodegraphCommandResolution;
+}): Promise<CodegraphCommandResolution | null> {
+ if (options.resolution.source === "env") return null;
+ if (options.config.auto_provision === false) return null;
+
+ const installDir = options.config.install_dir ?? join(options.homeDir, ".omo", "codegraph");
+ const result = await options.ensureProvisioned({
+ installDir,
+ lockDir: join(installDir, ".locks"),
+ version: CODEGRAPH_VERSION,
+ });
+ if (!result.provisioned || result.binPath === undefined) return null;
+ return { argsPrefix: [], command: result.binPath, exists: true, source: "provisioned" };
+}
+
function shouldSkipResolvedCommand(
resolution: CodegraphCommandResolution,
commandExists: (filePath: string) => boolean,
diff --git a/plugins/omo/components/codegraph/src/session-start-worker.ts b/plugins/omo/components/codegraph/src/session-start-worker.ts
index 072be46b..e4ea90d1 100644
--- a/plugins/omo/components/codegraph/src/session-start-worker.ts
+++ b/plugins/omo/components/codegraph/src/session-start-worker.ts
@@ -103,13 +103,10 @@ async function resolveOrProvisionCommand(
nodeSupport: CodegraphNodeSupport,
): Promise<ResolutionResult> {
const resolved = deps.resolveCommand({ env, homeDir, provisioned: () => provisionedBinFromInstallDir(config.install_dir) });
- if (resolved.exists) {
- if (codegraphCommandRequiresSupportedLocalNode(resolved) && !nodeSupport.supported) {
- return { kind: "unsupported-node" };
- }
+ if (resolved.exists && canUseResolvedCommand(resolved, nodeSupport)) {
return { kind: "resolved", resolution: resolved };
}
- if (!nodeSupport.supported) return { kind: "unsupported-node" };
+ if (resolved.exists && config.auto_provision === false) return { kind: "unsupported-node" };
if (config.auto_provision === false) return { error: "codegraph binary unavailable and auto_provision is disabled", kind: "unavailable", source: resolved.source };
const installDir = config.install_dir ?? join(homeDir, ".omo", "codegraph");
@@ -120,6 +117,10 @@ async function resolveOrProvisionCommand(
return { kind: "resolved", resolution: { argsPrefix: [], command: provisioned.binPath, exists: true, source: "provisioned" } };
}
+function canUseResolvedCommand(resolved: CodegraphCommandResolution, nodeSupport: CodegraphNodeSupport): boolean {
+ return !codegraphCommandRequiresSupportedLocalNode(resolved) || nodeSupport.supported;
+}
+
function decideStartupAction(status: CodegraphCommandResult): { readonly kind: "init" } | { readonly kind: "skip"; readonly reason: string } | { readonly kind: "sync" } {
if (status.timedOut) return { kind: "skip", reason: "status timed out" };
const text = `${status.stdout}\n${status.stderr ?? ""}`.toLowerCase();
diff --git a/plugins/omo/components/codegraph/test/hook.test.ts b/plugins/omo/components/codegraph/test/hook.test.ts
index 79e208e4..625a73dd 100644
--- a/plugins/omo/components/codegraph/test/hook.test.ts
+++ b/plugins/omo/components/codegraph/test/hook.test.ts
@@ -9,6 +9,7 @@ import { runCodegraphCli } from "../src/cli.ts";
import {
executeCodegraphSessionStartHook,
resolveCodegraphCommandInvocation,
+ runCodegraphPostToolUseHook,
runCodegraphSessionStartWorker,
type WorkerSpawnInvocation,
} from "../src/hook.ts";
@@ -48,6 +49,54 @@ describe("CodeGraph SessionStart hook", () => {
}
});
+ it("#given CodeGraph MCP reports an uninitialized project #when PostToolUse fires #then it emits OMO global-store init guidance", async () => {
+ // given
+ const output = runCodegraphPostToolUseHook(
+ {
+ cwd: "/Users/me/project",
+ tool_name: "codegraph.codegraph_status",
+ tool_response: {
+ error: [
+ "Tool execution failed: CodeGraph not initialized in /Users/me/project.",
+ "Run 'codegraph init' in that project first.",
+ ].join(" "),
+ },
+ },
+ { homeDir: "/Users/me" },
+ );
+
+ // when
+ const parsed = JSON.parse(output);
+
+ // then
+ expect(parsed).toEqual({
+ hookSpecificOutput: {
+ hookEventName: "PostToolUse",
+ additionalContext: expect.stringContaining('"/Users/me/.omo/codegraph/projects/project-'),
+ },
+ });
+ expect(parsed.hookSpecificOutput.additionalContext).toContain('run `codegraph init` from "/Users/me/project"');
+ });
+
+ it("#given real CodeGraph status output has no MCP path phrase #when PostToolUse fires #then it emits OMO global-store init guidance", async () => {
+ // given
+ const output = runCodegraphPostToolUseHook(
+ {
+ cwd: "/Users/me/project",
+ tool_name: "mcp__codegraph__codegraph_status",
+ tool_response: ['Project: /Users/me/project', "Not initialized", 'Run "codegraph init" to initialize'].join("\n"),
+ },
+ { homeDir: "/Users/me" },
+ );
+
+ // when
+ const parsed = JSON.parse(output);
+
+ // then
+ expect(parsed.hookSpecificOutput.additionalContext).toContain('CodeGraph is not initialized for "/Users/me/project"');
+ expect(parsed.hookSpecificOutput.additionalContext).toContain('"/Users/me/.omo/codegraph/projects/project-');
+ });
+
it("#given CodeGraph is disabled by Codex SOT config #when SessionStart fires #then it skips without spawning", async () => {
// given
const stdout: string[] = [];
@@ -198,93 +247,6 @@ describe("CodeGraph SessionStart hook", () => {
}
});
- it("#given an unsupported local Node and a PATH CodeGraph command #when worker runs #then it skips without touching the workspace", async () => {
- // given
- const workspace = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node-"));
- const homeDir = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node-home-"));
- const outcomes: unknown[] = [];
-
- try {
- // when
- const result = await runCodegraphSessionStartWorker({
- cwd: workspace,
- env: { HOME: homeDir },
- nodeVersion: "26.3.0",
- logOutcome: (outcome) => outcomes.push(outcome),
- deps: {
- resolveCommand: () => {
- return { argsPrefix: [], command: "/usr/local/bin/codegraph", exists: true, source: "path" };
- },
- ensureProvisioned: () => {
- throw new Error("ensureProvisioned should not run on unsupported Node");
- },
- prepareWorkspace: () => {
- throw new Error("prepareWorkspace should not run on unsupported Node");
- },
- runCommand: () => {
- throw new Error("runCommand should not run on unsupported Node");
- },
- },
- });
-
- // then
- expect(result).toEqual({ action: "skipped-unsupported-node" });
- expect(existsSync(join(workspace, ".codegraph"))).toBe(false);
- expect(outcomes).toEqual([{ action: "skipped-unsupported-node", projectRoot: workspace }]);
- } finally {
- rmSync(workspace, { recursive: true, force: true });
- rmSync(homeDir, { recursive: true, force: true });
- }
- });
-
- it("#given an unsupported local Node but bundled CodeGraph resolves through CODEGRAPH_NODE_BIN #when worker runs #then it bootstraps with the compatible runtime", async () => {
- // given
- const workspace = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-compatible-node-"));
- const homeDir = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-compatible-node-home-"));
- const nodeBin = "/opt/node22/bin/node";
- const calls: Array<{ readonly args: readonly string[]; readonly command: string }> = [];
- const outcomes: unknown[] = [];
-
- try {
- // when
- const result = await runCodegraphSessionStartWorker({
- cwd: workspace,
- env: { CODEGRAPH_NODE_BIN: nodeBin, HOME: homeDir },
- nodeVersion: "26.3.0",
- logOutcome: (outcome) => outcomes.push(outcome),
- deps: {
- ensureGitignored: () => true,
- ensureProvisioned: () => {
- throw new Error("provisioning should not run when bundled CodeGraph resolved");
- },
- prepareWorkspace: () => ({
- dataDir: join(homeDir, ".omo/codegraph/projects/test"),
- dataRoot: join(homeDir, ".omo/codegraph"),
- linked: true,
- mode: "global-linked",
- projectLink: join(workspace, ".codegraph"),
- }),
- resolveCommand: () => ({ argsPrefix: ["codegraph.js"], command: nodeBin, exists: true, source: "bundled" }),
- runCommand: (_projectRoot, command, args) => {
- calls.push({ args, command });
- return Promise.resolve({ exitCode: 0, stdout: calls.length === 1 ? '{"initialized":false}' : "", timedOut: false });
- },
- },
- });
-
- // then
- expect(result).toEqual({ action: "initialized" });
- expect(calls).toEqual([
- { args: ["codegraph.js", "status", "--json"], command: nodeBin },
- { args: ["codegraph.js", "init"], command: nodeBin },
- ]);
- expect(outcomes).toEqual([{ action: "initialized", exitCode: 0, projectRoot: workspace, source: "bundled", timedOut: false }]);
- } finally {
- rmSync(workspace, { recursive: true, force: true });
- rmSync(homeDir, { recursive: true, force: true });
- }
- });
-
it("#given CodeGraph cannot be resolved or provisioned #when worker runs #then it logs a graceful skip", async () => {
// given
const workspace = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-"));
diff --git a/plugins/omo/components/codegraph/test/provisioned-node-guard.test.ts b/plugins/omo/components/codegraph/test/provisioned-node-guard.test.ts
index bdbf779f..7d74a764 100644
--- a/plugins/omo/components/codegraph/test/provisioned-node-guard.test.ts
+++ b/plugins/omo/components/codegraph/test/provisioned-node-guard.test.ts
@@ -35,7 +35,7 @@ describe("CodeGraph provisioned launcher Node guard", () => {
const workspace = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node25-"));
const homeDir = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node25-home-"));
const installDir = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node25-install-"));
- const binPath = join(installDir, "bin", "codegraph");
+ const binPath = join(installDir, "bin", process.platform === "win32" ? "codegraph.cmd" : "codegraph");
const calls: Array<{ readonly args: readonly string[]; readonly command: string }> = [];
const outcomes: unknown[] = [];
diff --git a/plugins/omo/components/codegraph/test/serve-provision.test.ts b/plugins/omo/components/codegraph/test/serve-provision.test.ts
new file mode 100644
index 00000000..77a91b7a
--- /dev/null
+++ b/plugins/omo/components/codegraph/test/serve-provision.test.ts
@@ -0,0 +1,48 @@
+import { describe, expect, it } from "bun:test";
+import { join } from "node:path";
+
+import { runCodegraphServe } from "../src/serve.ts";
+
+describe("runCodegraphServe provisioning", () => {
+ it("#given CodeGraph is unresolved #when serving MCP #then provisions CodeGraph before spawning", async () => {
+ // given
+ const binPath = join("/tmp/home/.omo/codegraph", "bin", "codegraph");
+ const calls: Array<{
+ readonly args: readonly string[];
+ readonly command: string;
+ readonly env: Record<string, string | undefined>;
+ }> = [];
+ const stderr: string[] = [];
+
+ // when
+ const exitCode = await runCodegraphServe({
+ config: { codegraph: { enabled: true }, sources: [], warnings: [] },
+ env: { PATH: "/bin" },
+ homeDir: "/tmp/home",
+ nodeVersion: "22.14.0",
+ buildEnv: () => ({}),
+ resolve: () => ({ argsPrefix: [], command: "codegraph", exists: false, source: "path" }),
+ ensureProvisioned: (options) =>
+ Promise.resolve({
+ binPath: join(options.installDir ?? "/tmp/home/.omo/codegraph", "bin", "codegraph"),
+ provisioned: true,
+ }),
+ runProcess: (command, args, options) => {
+ calls.push({ args, command, env: options.env });
+ return Promise.resolve(0);
+ },
+ stderr: { write: (chunk: string) => stderr.push(chunk) },
+ });
+
+ // then
+ expect(exitCode).toBe(0);
+ expect(stderr).toEqual([]);
+ expect(calls).toEqual([
+ {
+ args: ["serve", "--mcp"],
+ command: binPath,
+ env: { PATH: "/bin" },
+ },
+ ]);
+ });
+});
diff --git a/plugins/omo/components/codegraph/test/serve.test.ts b/plugins/omo/components/codegraph/test/serve.test.ts
index c937f7a8..7cbd8dce 100644
--- a/plugins/omo/components/codegraph/test/serve.test.ts
+++ b/plugins/omo/components/codegraph/test/serve.test.ts
@@ -17,6 +17,7 @@ describe("runCodegraphServe", () => {
// when
const exitCode = await runCodegraphServe({
+ config: { codegraph: { auto_provision: false, enabled: true }, sources: [], warnings: [] },
env: { PATH: "/bin" },
buildEnv: () => ({}),
resolve: () => ({ argsPrefix: [], command: "codegraph", exists: false, source: "path" }),
diff --git a/plugins/omo/components/codegraph/test/session-start-node-support.test.ts b/plugins/omo/components/codegraph/test/session-start-node-support.test.ts
new file mode 100644
index 00000000..5a3ca233
--- /dev/null
+++ b/plugins/omo/components/codegraph/test/session-start-node-support.test.ts
@@ -0,0 +1,142 @@
+import { describe, expect, it } from "bun:test";
+import { existsSync, mkdtempSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+
+import { runCodegraphSessionStartWorker } from "../src/hook.ts";
+
+describe("CodeGraph SessionStart worker Node support", () => {
+ it("#given an unsupported local Node and a PATH CodeGraph command with auto provisioning disabled #when worker runs #then it skips without touching the workspace", async () => {
+ // given
+ const workspace = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node-"));
+ const homeDir = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node-home-"));
+ const outcomes: unknown[] = [];
+
+ try {
+ // when
+ const result = await runCodegraphSessionStartWorker({
+ config: { codegraph: { auto_provision: false, enabled: true }, sources: [], warnings: [] },
+ cwd: workspace,
+ env: { HOME: homeDir },
+ nodeVersion: "26.3.0",
+ logOutcome: (outcome) => outcomes.push(outcome),
+ deps: {
+ resolveCommand: () => {
+ return { argsPrefix: [], command: "/usr/local/bin/codegraph", exists: true, source: "path" };
+ },
+ ensureProvisioned: () => {
+ throw new Error("ensureProvisioned should not run on unsupported Node");
+ },
+ prepareWorkspace: () => {
+ throw new Error("prepareWorkspace should not run on unsupported Node");
+ },
+ runCommand: () => {
+ throw new Error("runCommand should not run on unsupported Node");
+ },
+ },
+ });
+
+ // then
+ expect(result).toEqual({ action: "skipped-unsupported-node" });
+ expect(existsSync(join(workspace, ".codegraph"))).toBe(false);
+ expect(outcomes).toEqual([{ action: "skipped-unsupported-node", projectRoot: workspace }]);
+ } finally {
+ rmSync(workspace, { recursive: true, force: true });
+ rmSync(homeDir, { recursive: true, force: true });
+ }
+ });
+
+ it("#given an unsupported local Node and a PATH CodeGraph command #when auto provisioning succeeds #then it bootstraps with the provisioned binary", async () => {
+ // given
+ const workspace = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node-provision-"));
+ const homeDir = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-node-provision-home-"));
+ const binPath = join(homeDir, ".omo", "codegraph", "bin", "codegraph");
+ const calls: Array<{ readonly args: readonly string[]; readonly command: string }> = [];
+ const outcomes: unknown[] = [];
+
+ try {
+ // when
+ const result = await runCodegraphSessionStartWorker({
+ cwd: workspace,
+ env: { HOME: homeDir },
+ nodeVersion: "26.3.0",
+ logOutcome: (outcome) => outcomes.push(outcome),
+ deps: {
+ ensureGitignored: () => true,
+ ensureProvisioned: () => Promise.resolve({ binPath, provisioned: true }),
+ prepareWorkspace: () => ({
+ dataDir: join(homeDir, ".omo/codegraph/projects/test"),
+ dataRoot: join(homeDir, ".omo/codegraph"),
+ linked: true,
+ mode: "global-linked",
+ projectLink: join(workspace, ".codegraph"),
+ }),
+ resolveCommand: () => ({ argsPrefix: [], command: "/usr/local/bin/codegraph", exists: true, source: "path" }),
+ runCommand: (_projectRoot, command, args) => {
+ calls.push({ args, command });
+ return Promise.resolve({ exitCode: 0, stdout: calls.length === 1 ? '{"initialized":false}' : "", timedOut: false });
+ },
+ },
+ });
+
+ // then
+ expect(result).toEqual({ action: "initialized" });
+ expect(calls).toEqual([
+ { args: ["status", "--json"], command: binPath },
+ { args: ["init"], command: binPath },
+ ]);
+ expect(outcomes).toEqual([{ action: "initialized", exitCode: 0, projectRoot: workspace, source: "provisioned", timedOut: false }]);
+ } finally {
+ rmSync(workspace, { recursive: true, force: true });
+ rmSync(homeDir, { recursive: true, force: true });
+ }
+ });
+
+ it("#given an unsupported local Node but bundled CodeGraph resolves through CODEGRAPH_NODE_BIN #when worker runs #then it bootstraps with the compatible runtime", async () => {
+ // given
+ const workspace = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-compatible-node-"));
+ const homeDir = mkdtempSync(join(tmpdir(), "omo-codegraph-worker-compatible-node-home-"));
+ const nodeBin = "/opt/node22/bin/node";
+ const calls: Array<{ readonly args: readonly string[]; readonly command: string }> = [];
+ const outcomes: unknown[] = [];
+
+ try {
+ // when
+ const result = await runCodegraphSessionStartWorker({
+ cwd: workspace,
+ env: { CODEGRAPH_NODE_BIN: nodeBin, HOME: homeDir },
+ nodeVersion: "26.3.0",
+ logOutcome: (outcome) => outcomes.push(outcome),
+ deps: {
+ ensureGitignored: () => true,
+ ensureProvisioned: () => {
+ throw new Error("provisioning should not run when bundled CodeGraph resolved");
+ },
+ prepareWorkspace: () => ({
+ dataDir: join(homeDir, ".omo/codegraph/projects/test"),
+ dataRoot: join(homeDir, ".omo/codegraph"),
+ linked: true,
+ mode: "global-linked",
+ projectLink: join(workspace, ".codegraph"),
+ }),
+ resolveCommand: () => ({ argsPrefix: ["codegraph.js"], command: nodeBin, exists: true, source: "bundled" }),
+ runCommand: (_projectRoot, command, args) => {
+ calls.push({ args, command });
+ return Promise.resolve({ exitCode: 0, stdout: calls.length === 1 ? '{"initialized":false}' : "", timedOut: false });
+ },
+ },
+ });
+
+ // then
+ expect(result).toEqual({ action: "initialized" });
+ expect(calls).toEqual([
+ { args: ["codegraph.js", "status", "--json"], command: nodeBin },
+ { args: ["codegraph.js", "init"], command: nodeBin },
+ ]);
+ expect(outcomes).toEqual([{ action: "initialized", exitCode: 0, projectRoot: workspace, source: "bundled", timedOut: false }]);
+ } finally {
+ rmSync(workspace, { recursive: true, force: true });
+ rmSync(homeDir, { recursive: true, force: true });
+ }
+ });
+});
diff --git a/plugins/omo/components/comment-checker/package.json b/plugins/omo/components/comment-checker/package.json
index a9def14a..9cf81b45 100644
--- a/plugins/omo/components/comment-checker/package.json
+++ b/plugins/omo/components/comment-checker/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-comment-checker",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex plugin that runs comment-checker after edit-like PostToolUse hooks.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/components/git-bash/package.json b/plugins/omo/components/git-bash/package.json
index 87f2cae0..27e95485 100644
--- a/plugins/omo/components/git-bash/package.json
+++ b/plugins/omo/components/git-bash/package.json
@@ -1,6 +1,6 @@
{
"name": "@sisyphuslabs/codex-git-bash-hook",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex hook component that reminds Windows sessions to prefer the OMO git_bash MCP.",
"type": "module",
"private": true,
diff --git a/plugins/omo/components/lazycodex-executor-verify/package.json b/plugins/omo/components/lazycodex-executor-verify/package.json
index 029ef904..74970949 100644
--- a/plugins/omo/components/lazycodex-executor-verify/package.json
+++ b/plugins/omo/components/lazycodex-executor-verify/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-lazycodex-executor-verify",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex SubagentStop evidence verifier for LazyCodex executor completions.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/components/lsp/package.json b/plugins/omo/components/lsp/package.json
index 94b9a4e6..0d3738a4 100644
--- a/plugins/omo/components/lsp/package.json
+++ b/plugins/omo/components/lsp/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-lsp",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex plugin that exposes Language Server Protocol tools and post-edit diagnostics.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/components/rules/package.json b/plugins/omo/components/rules/package.json
index 11f026f0..ad4cd003 100644
--- a/plugins/omo/components/rules/package.json
+++ b/plugins/omo/components/rules/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-rules",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex plugin that injects project rule files into model context through lifecycle hooks.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/components/start-work-continuation/package.json b/plugins/omo/components/start-work-continuation/package.json
index 222caa93..43009757 100644
--- a/plugins/omo/components/start-work-continuation/package.json
+++ b/plugins/omo/components/start-work-continuation/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-start-work-continuation",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex Stop hook continuation injector for omo-codex start-work plans.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/components/teammode/dist/cli.js b/plugins/omo/components/teammode/dist/cli.js
new file mode 100755
index 00000000..20a4dca2
--- /dev/null
+++ b/plugins/omo/components/teammode/dist/cli.js
@@ -0,0 +1,94 @@
+#!/usr/bin/env node
+
+// components/teammode/src/codex-hook.ts
+var CREATE_THREAD_TOOL_NAMES = new Set(["create_thread", "codex_app.create_thread"]);
+function parsePostToolUsePayload(raw) {
+ if (raw.trim().length === 0)
+ return null;
+ try {
+ const parsed = JSON.parse(raw);
+ return isPostToolUsePayload(parsed) ? parsed : null;
+ } catch (error) {
+ if (error instanceof SyntaxError)
+ return null;
+ return null;
+ }
+}
+function runPostToolUseHook(payload) {
+ if (payload.hook_event_name !== "PostToolUse")
+ return "";
+ if (!CREATE_THREAD_TOOL_NAMES.has(payload.tool_name))
+ return "";
+ const threadReference = extractThreadCreationReference(payload.tool_response);
+ if (threadReference === null)
+ return "";
+ const output = {
+ hookSpecificOutput: {
+ hookEventName: "PostToolUse",
+ additionalContext: threadTitleReminder(threadReference)
+ }
+ };
+ return `${JSON.stringify(output)}
+`;
+}
+async function runTeammodeHookCli(stdin, stdout) {
+ const payload = parsePostToolUsePayload(await readAll(stdin));
+ if (payload === null)
+ return;
+ const output = runPostToolUseHook(payload);
+ if (output.length > 0)
+ stdout.write(output);
+}
+function threadTitleReminder(threadReference) {
+ const id = formatIdentifier(threadReference.id);
+ return threadReference.kind === "thread" ? `THREAD ID ${id}: CALL codex_app.set_thread_title NOW. USE THE REAL TASK/ROLE.` : `PENDING WORKTREE ID ${id}: CALL codex_app.set_thread_title AS SOON AS THREAD ID EXISTS. USE THE REAL TASK/ROLE.`;
+}
+function formatIdentifier(value) {
+ const normalized = value.replace(/\s+/g, " ").trim();
+ return normalized.length <= 200 ? normalized : `${normalized.slice(0, 197)}...`;
+}
+function extractThreadCreationReference(toolResponse) {
+ if (!isRecord(toolResponse))
+ return null;
+ const threadId = toolResponse["threadId"];
+ if (typeof threadId === "string" && threadId.trim().length > 0) {
+ return { kind: "thread", id: threadId };
+ }
+ const pendingWorktreeId = toolResponse["pendingWorktreeId"];
+ if (typeof pendingWorktreeId === "string" && pendingWorktreeId.trim().length > 0) {
+ return { kind: "pendingWorktree", id: pendingWorktreeId };
+ }
+ return null;
+}
+function isPostToolUsePayload(value) {
+ if (!isRecord(value))
+ return false;
+ return value["hook_event_name"] === "PostToolUse" && typeof value["session_id"] === "string" && typeof value["tool_name"] === "string" && Object.hasOwn(value, "tool_input") && Object.hasOwn(value, "tool_response") && optionalString(value["turn_id"]) && optionalString(value["cwd"]) && optionalString(value["model"]) && optionalString(value["permission_mode"]) && optionalString(value["tool_use_id"]) && (value["transcript_path"] === undefined || value["transcript_path"] === null || typeof value["transcript_path"] === "string");
+}
+function optionalString(value) {
+ return value === undefined || typeof value === "string";
+}
+function isRecord(value) {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+function readAll(stdin) {
+ return new Promise((resolve, reject) => {
+ let data = "";
+ stdin.setEncoding("utf8");
+ stdin.on("data", (chunk) => {
+ data += chunk instanceof Buffer ? chunk.toString() : String(chunk);
+ });
+ stdin.once("error", reject);
+ stdin.once("end", () => resolve(data));
+ });
+}
+
+// components/teammode/src/cli.ts
+var [command, subcommand] = process.argv.slice(2);
+if (command === "hook" && subcommand === "post-tool-use") {
+ await runTeammodeHookCli(process.stdin, process.stdout);
+} else {
+ process.stderr.write(`Usage: omo-teammode hook post-tool-use
+`);
+ process.exitCode = 2;
+}
diff --git a/plugins/omo/components/teammode/hooks/hooks.json b/plugins/omo/components/teammode/hooks/hooks.json
new file mode 100644
index 00000000..df3f1e02
--- /dev/null
+++ b/plugins/omo/components/teammode/hooks/hooks.json
@@ -0,0 +1,17 @@
+{
+ "hooks": {
+ "PostToolUse": [
+ {
+ "matcher": "^(create_thread|codex_app\\.create_thread)$",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook post-tool-use",
+ "timeout": 10,
+ "statusMessage": "(OmO) Checking Thread Title Hygiene"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/plugins/omo/components/teammode/package.json b/plugins/omo/components/teammode/package.json
new file mode 100644
index 00000000..5349847b
--- /dev/null
+++ b/plugins/omo/components/teammode/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "@sisyphuslabs/codex-teammode",
+ "version": "4.12.1",
+ "description": "Codex team-mode hook component that keeps background thread titles descriptive after create_thread.",
+ "type": "module",
+ "private": true,
+ "files": [
+ "dist",
+ "hooks",
+ "skills"
+ ],
+ "scripts": {
+ "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && bun build src/cli.ts --target node --format esm --outfile dist/cli.js",
+ "test": "bun test test/*.test.ts",
+ "typecheck": "tsc --noEmit"
+ },
+ "devDependencies": {
+ "@types/node": "^25.9.3",
+ "bun-types": "^1.3.1",
+ "typescript": "^6.0.3",
+ "vitest": "^4.1.8"
+ },
+ "engines": {
+ "node": ">=20.0.0"
+ }
+}
diff --git a/plugins/omo/components/teammode/src/cli.ts b/plugins/omo/components/teammode/src/cli.ts
new file mode 100644
index 00000000..8dfd33f0
--- /dev/null
+++ b/plugins/omo/components/teammode/src/cli.ts
@@ -0,0 +1,12 @@
+#!/usr/bin/env node
+
+import { runTeammodeHookCli } from "./codex-hook.js";
+
+const [command, subcommand] = process.argv.slice(2);
+
+if (command === "hook" && subcommand === "post-tool-use") {
+ await runTeammodeHookCli(process.stdin, process.stdout);
+} else {
+ process.stderr.write("Usage: omo-teammode hook post-tool-use\n");
+ process.exitCode = 2;
+}
diff --git a/plugins/omo/components/teammode/src/codex-hook.ts b/plugins/omo/components/teammode/src/codex-hook.ts
new file mode 100644
index 00000000..8f8e1539
--- /dev/null
+++ b/plugins/omo/components/teammode/src/codex-hook.ts
@@ -0,0 +1,125 @@
+export interface PostToolUsePayload {
+ readonly hook_event_name: "PostToolUse";
+ readonly session_id: string;
+ readonly turn_id?: string;
+ readonly transcript_path?: string | null;
+ readonly cwd?: string;
+ readonly model?: string;
+ readonly permission_mode?: string;
+ readonly tool_name: string;
+ readonly tool_use_id?: string;
+ readonly tool_input: unknown;
+ readonly tool_response: unknown;
+}
+
+interface PostToolUseHookOutput {
+ readonly hookSpecificOutput: {
+ readonly hookEventName: "PostToolUse";
+ readonly additionalContext: string;
+ };
+}
+
+type ThreadCreationReference =
+ | { readonly kind: "thread"; readonly id: string }
+ | { readonly kind: "pendingWorktree"; readonly id: string };
+
+const CREATE_THREAD_TOOL_NAMES = new Set(["create_thread", "codex_app.create_thread"]);
+
+export function parsePostToolUsePayload(raw: string): PostToolUsePayload | null {
+ if (raw.trim().length === 0) return null;
+ try {
+ const parsed: unknown = JSON.parse(raw);
+ return isPostToolUsePayload(parsed) ? parsed : null;
+ } catch (error) {
+ if (error instanceof SyntaxError) return null;
+ return null;
+ }
+}
+
+export function runPostToolUseHook(payload: PostToolUsePayload): string {
+ if (payload.hook_event_name !== "PostToolUse") return "";
+ if (!CREATE_THREAD_TOOL_NAMES.has(payload.tool_name)) return "";
+ const threadReference = extractThreadCreationReference(payload.tool_response);
+ if (threadReference === null) return "";
+ const output: PostToolUseHookOutput = {
+ hookSpecificOutput: {
+ hookEventName: "PostToolUse",
+ additionalContext: threadTitleReminder(threadReference),
+ },
+ };
+ return `${JSON.stringify(output)}\n`;
+}
+
+export async function runTeammodeHookCli(
+ stdin: NodeJS.ReadableStream,
+ stdout: NodeJS.WritableStream,
+): Promise<void> {
+ const payload = parsePostToolUsePayload(await readAll(stdin));
+ if (payload === null) return;
+ const output = runPostToolUseHook(payload);
+ if (output.length > 0) stdout.write(output);
+}
+
+function threadTitleReminder(threadReference: ThreadCreationReference): string {
+ const id = formatIdentifier(threadReference.id);
+ return threadReference.kind === "thread"
+ ? `THREAD ID ${id}: CALL codex_app.set_thread_title NOW. USE THE REAL TASK/ROLE.`
+ : `PENDING WORKTREE ID ${id}: CALL codex_app.set_thread_title AS SOON AS THREAD ID EXISTS. USE THE REAL TASK/ROLE.`;
+}
+
+function formatIdentifier(value: string): string {
+ const normalized = value.replace(/\s+/g, " ").trim();
+ return normalized.length <= 200 ? normalized : `${normalized.slice(0, 197)}...`;
+}
+
+function extractThreadCreationReference(toolResponse: unknown): ThreadCreationReference | null {
+ if (!isRecord(toolResponse)) return null;
+ const threadId = toolResponse["threadId"];
+ if (typeof threadId === "string" && threadId.trim().length > 0) {
+ return { kind: "thread", id: threadId };
+ }
+ const pendingWorktreeId = toolResponse["pendingWorktreeId"];
+ if (typeof pendingWorktreeId === "string" && pendingWorktreeId.trim().length > 0) {
+ return { kind: "pendingWorktree", id: pendingWorktreeId };
+ }
+ return null;
+}
+
+function isPostToolUsePayload(value: unknown): value is PostToolUsePayload {
+ if (!isRecord(value)) return false;
+ return (
+ value["hook_event_name"] === "PostToolUse" &&
+ typeof value["session_id"] === "string" &&
+ typeof value["tool_name"] === "string" &&
+ Object.hasOwn(value, "tool_input") &&
+ Object.hasOwn(value, "tool_response") &&
+ optionalString(value["turn_id"]) &&
+ optionalString(value["cwd"]) &&
+ optionalString(value["model"]) &&
+ optionalString(value["permission_mode"]) &&
+ optionalString(value["tool_use_id"]) &&
+ (value["transcript_path"] === undefined ||
+ value["transcript_path"] === null ||
+ typeof value["transcript_path"] === "string")
+ );
+}
+
+function optionalString(value: unknown): boolean {
+ return value === undefined || typeof value === "string";
+}
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+
+function readAll(stdin: NodeJS.ReadableStream): Promise<string> {
+ return new Promise((resolve, reject) => {
+ let data = "";
+ stdin.setEncoding("utf8");
+ stdin.on("data", (chunk: unknown) => {
+ data += chunk instanceof Buffer ? chunk.toString() : String(chunk);
+ });
+ stdin.once("error", reject);
+ stdin.once("end", () => resolve(data));
+ });
+}
diff --git a/plugins/omo/components/teammode/test/thread-title-hook.test.ts b/plugins/omo/components/teammode/test/thread-title-hook.test.ts
new file mode 100644
index 00000000..9f33e49c
--- /dev/null
+++ b/plugins/omo/components/teammode/test/thread-title-hook.test.ts
@@ -0,0 +1,116 @@
+import { describe, expect, it } from "vitest";
+
+import { runPostToolUseHook } from "../src/codex-hook.js";
+
+describe("thread title PostToolUse guidance", () => {
+ it("#given codex_app.create_thread completed #when the hook runs #then it asks Codex to immediately set a descriptive title", () => {
+ // given
+ const output = runPostToolUseHook({
+ hook_event_name: "PostToolUse",
+ session_id: "s-team",
+ turn_id: "t-team",
+ transcript_path: null,
+ cwd: "/repo",
+ model: "gpt-5.5",
+ permission_mode: "default",
+ tool_name: "create_thread",
+ tool_use_id: "tool-create-thread",
+ tool_input: {
+ prompt: "Investigate package install failures",
+ target: { type: "project", projectId: "/repo", environment: { type: "local" } },
+ },
+ tool_response: { threadId: "thread-123" },
+ });
+
+ // when
+ const parsed: unknown = JSON.parse(output);
+
+ // then
+ expect(isHookOutput(parsed)).toBe(true);
+ if (!isHookOutput(parsed)) return;
+ expect(parsed.hookSpecificOutput.hookEventName).toBe("PostToolUse");
+ expect(parsed.hookSpecificOutput.additionalContext).toBe(
+ "THREAD ID thread-123: CALL codex_app.set_thread_title NOW. USE THE REAL TASK/ROLE.",
+ );
+ });
+
+ it("#given an unrelated tool completed #when the hook runs #then it stays silent", () => {
+ // given
+ const output = runPostToolUseHook({
+ hook_event_name: "PostToolUse",
+ session_id: "s-team",
+ turn_id: "t-team",
+ transcript_path: null,
+ cwd: "/repo",
+ model: "gpt-5.5",
+ permission_mode: "default",
+ tool_name: "read_thread",
+ tool_use_id: "tool-read-thread",
+ tool_input: { threadId: "thread-123" },
+ tool_response: { status: "ok" },
+ });
+
+ // when
+ const actual = output;
+
+ // then
+ expect(actual).toBe("");
+ });
+
+ it("#given worktree-backed thread creation is pending #when the hook runs #then it tells Codex to title the thread once the thread id exists", () => {
+ // given
+ const output = runPostToolUseHook({
+ hook_event_name: "PostToolUse",
+ session_id: "s-team",
+ turn_id: "t-team",
+ transcript_path: null,
+ cwd: "/repo",
+ model: "gpt-5.5",
+ permission_mode: "default",
+ tool_name: "codex_app.create_thread",
+ tool_use_id: "tool-create-thread",
+ tool_input: {
+ prompt: "Fix CodeGraph provisioned launcher skip on Node 25",
+ target: {
+ type: "project",
+ projectId: "/repo",
+ environment: { type: "worktree", startingState: { type: "working-tree" } },
+ },
+ },
+ tool_response: {
+ pendingWorktreeId: "remote-control:env:test-worktree",
+ },
+ });
+
+ // when
+ const parsed: unknown = JSON.parse(output);
+
+ // then
+ expect(isHookOutput(parsed)).toBe(true);
+ if (!isHookOutput(parsed)) return;
+ expect(parsed.hookSpecificOutput.additionalContext).toBe(
+ "PENDING WORKTREE ID remote-control:env:test-worktree: CALL codex_app.set_thread_title AS SOON AS THREAD ID EXISTS. USE THE REAL TASK/ROLE.",
+ );
+ });
+});
+
+interface HookOutput {
+ readonly hookSpecificOutput: {
+ readonly hookEventName: "PostToolUse";
+ readonly additionalContext: string;
+ };
+}
+
+function isHookOutput(value: unknown): value is HookOutput {
+ if (!isRecord(value)) return false;
+ const hookSpecificOutput = value["hookSpecificOutput"];
+ return (
+ isRecord(hookSpecificOutput) &&
+ hookSpecificOutput["hookEventName"] === "PostToolUse" &&
+ typeof hookSpecificOutput["additionalContext"] === "string"
+ );
+}
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
diff --git a/plugins/omo/components/teammode/tsconfig.json b/plugins/omo/components/teammode/tsconfig.json
new file mode 100644
index 00000000..3c017b67
--- /dev/null
+++ b/plugins/omo/components/teammode/tsconfig.json
@@ -0,0 +1,25 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "module": "Node16",
+ "moduleResolution": "Node16",
+ "lib": ["ES2022"],
+ "strict": true,
+ "exactOptionalPropertyTypes": true,
+ "noUncheckedIndexedAccess": true,
+ "noPropertyAccessFromIndexSignature": true,
+ "verbatimModuleSyntax": true,
+ "noImplicitOverride": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "esModuleInterop": true,
+ "allowImportingTsExtensions": true,
+ "skipLibCheck": true,
+ "forceConsistentCasingInFileNames": true,
+ "types": ["node", "bun-types"],
+ "noEmit": true
+ },
+ "include": ["src/**/*", "test/**/*"]
+}
diff --git a/plugins/omo/components/telemetry/package.json b/plugins/omo/components/telemetry/package.json
index 9fae2dad..d8e420b9 100644
--- a/plugins/omo/components/telemetry/package.json
+++ b/plugins/omo/components/telemetry/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-telemetry",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex plugin component that emits omo-codex anonymous daily-active telemetry on SessionStart.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/components/ultrawork/package.json b/plugins/omo/components/ultrawork/package.json
index 4e78b27f..2dfa4918 100644
--- a/plugins/omo/components/ultrawork/package.json
+++ b/plugins/omo/components/ultrawork/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-ultrawork",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex plugin that injects the ultrawork orchestration directive and ships LazyCodex planning, review, QA, and gate agent roles.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/components/ulw-loop/package.json b/plugins/omo/components/ulw-loop/package.json
index 617019f1..312dcd61 100644
--- a/plugins/omo/components/ulw-loop/package.json
+++ b/plugins/omo/components/ulw-loop/package.json
@@ -1,6 +1,6 @@
{
"name": "@code-yeongyu/codex-ulw-loop",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Codex plugin: durable repo-native multi-goal orchestration with embedded success criteria and observable evidence audit.",
"type": "module",
"packageManager": "[email protected]",
diff --git a/plugins/omo/hooks/post-tool-use-checking-codegraph-init-guidance.json b/plugins/omo/hooks/post-tool-use-checking-codegraph-init-guidance.json
new file mode 100644
index 00000000..39e992eb
--- /dev/null
+++ b/plugins/omo/hooks/post-tool-use-checking-codegraph-init-guidance.json
@@ -0,0 +1,17 @@
+{
+ "hooks": {
+ "PostToolUse": [
+ {
+ "hooks": [
+ {
+ "type": "command",
+ "command": "node \"${PLUGIN_ROOT}/components/codegraph/dist/cli.js\" hook post-tool-use",
+ "timeout": 5,
+ "statusMessage": "(OmO) Checking CodeGraph Init Guidance"
+ }
+ ],
+ "matcher": "^(codegraph[._].*|mcp__codegraph__.*)$"
+ }
+ ]
+ }
+}
diff --git a/plugins/omo/hooks/post-tool-use-checking-thread-title-hygiene.json b/plugins/omo/hooks/post-tool-use-checking-thread-title-hygiene.json
new file mode 100644
index 00000000..5905b1c4
--- /dev/null
+++ b/plugins/omo/hooks/post-tool-use-checking-thread-title-hygiene.json
@@ -0,0 +1,17 @@
+{
+ "hooks": {
+ "PostToolUse": [
+ {
+ "matcher": "^(create_thread|codex_app\\.create_thread)$",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "node \"${PLUGIN_ROOT}/components/teammode/dist/cli.js\" hook post-tool-use",
+ "timeout": 10,
+ "statusMessage": "(OmO) Checking Thread Title Hygiene"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/plugins/omo/hooks/session-start-checking-codegraph-bootstrap.json b/plugins/omo/hooks/session-start-checking-codegraph-bootstrap.json
index 3dcf9131..0f820555 100644
--- a/plugins/omo/hooks/session-start-checking-codegraph-bootstrap.json
+++ b/plugins/omo/hooks/session-start-checking-codegraph-bootstrap.json
@@ -7,7 +7,7 @@
"type": "command",
"command": "node \"${PLUGIN_ROOT}/components/codegraph/dist/cli.js\" hook session-start",
"timeout": 5,
- "statusMessage": "(OmO) Checking Codegraph Bootstrap"
+ "statusMessage": "(OmO) Checking CodeGraph Bootstrap"
}
]
}
diff --git a/plugins/omo/package-lock.json b/plugins/omo/package-lock.json
index 97fce04f..a73e04d5 100644
--- a/plugins/omo/package-lock.json
+++ b/plugins/omo/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@sisyphuslabs/omo-codex-plugin",
- "version": "4.11.1",
+ "version": "4.12.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@sisyphuslabs/omo-codex-plugin",
- "version": "4.11.1",
+ "version": "4.12.0",
"workspaces": [
"components/codegraph",
"components/comment-checker",
@@ -15,6 +15,7 @@
"components/rules",
"components/lsp",
"components/telemetry",
+ "components/teammode",
"components/start-work-continuation",
"components/ulw-loop",
"components/ultrawork"
@@ -92,7 +93,7 @@
},
"components/codegraph": {
"name": "@sisyphuslabs/codex-codegraph",
- "version": "4.11.1",
+ "version": "4.12.0",
"bin": {
"omo-codegraph": "dist/cli.js"
},
@@ -108,7 +109,7 @@
},
"components/comment-checker": {
"name": "@code-yeongyu/codex-comment-checker",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"bin": {
"omo-comment-checker": "dist/cli.js"
@@ -129,7 +130,7 @@
},
"components/git-bash": {
"name": "@sisyphuslabs/codex-git-bash-hook",
- "version": "4.11.1",
+ "version": "4.12.0",
"bin": {
"omo-git-bash-hook": "dist/cli.js"
},
@@ -144,7 +145,7 @@
},
"components/lazycodex-executor-verify": {
"name": "@code-yeongyu/codex-lazycodex-executor-verify",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"bin": {
"lazycodex-executor-verify": "dist/cli.js"
@@ -161,7 +162,7 @@
},
"components/lsp": {
"name": "@code-yeongyu/codex-lsp",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"dependencies": {
"@code-yeongyu/lsp-daemon": "file:../../../../lsp-daemon"
@@ -181,7 +182,7 @@
},
"components/rules": {
"name": "@code-yeongyu/codex-rules",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"dependencies": {
"picomatch": "^4.0.3"
@@ -203,7 +204,7 @@
},
"components/start-work-continuation": {
"name": "@code-yeongyu/codex-start-work-continuation",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"bin": {
"omo-start-work-continuation": "dist/cli.js"
@@ -218,9 +219,22 @@
"node": ">=20.0.0"
}
},
+ "components/teammode": {
+ "name": "@sisyphuslabs/codex-teammode",
+ "version": "4.12.0",
+ "devDependencies": {
+ "@types/node": "^25.9.3",
+ "bun-types": "^1.3.1",
+ "typescript": "^6.0.3",
+ "vitest": "^4.1.8"
+ },
+ "engines": {
+ "node": ">=20.0.0"
+ }
+ },
"components/telemetry": {
"name": "@code-yeongyu/codex-telemetry",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"bin": {
"omo-telemetry": "dist/cli.js"
@@ -238,7 +252,7 @@
},
"components/ultrawork": {
"name": "@code-yeongyu/codex-ultrawork",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"bin": {
"omo-ultrawork": "dist/cli.js"
@@ -256,7 +270,7 @@
},
"components/ulw-loop": {
"name": "@code-yeongyu/codex-ulw-loop",
- "version": "4.11.1",
+ "version": "4.12.0",
"license": "MIT",
"bin": {
"omo-ulw-loop": "dist/cli.js"
@@ -880,6 +894,10 @@
"resolved": "components/git-bash",
"link": true
},
+ "node_modules/@sisyphuslabs/codex-teammode": {
+ "resolved": "components/teammode",
+ "link": true
+ },
"node_modules/@standard-schema/spec": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
diff --git a/plugins/omo/package.json b/plugins/omo/package.json
index 58d28cba..c5ae0e7c 100644
--- a/plugins/omo/package.json
+++ b/plugins/omo/package.json
@@ -1,6 +1,6 @@
{
"name": "@sisyphuslabs/omo-codex-plugin",
- "version": "4.12.0",
+ "version": "4.12.1",
"description": "Aggregate Codex plugin root for OMO components.",
"type": "module",
"packageManager": "[email protected]",
@@ -13,6 +13,7 @@
"components/rules",
"components/lsp",
"components/telemetry",
+ "components/teammode",
"components/start-work-continuation",
"components/ulw-loop",
"components/ultrawork"
diff --git a/plugins/omo/scripts/hook-status-message.mjs b/plugins/omo/scripts/hook-status-message.mjs
index a62edfcd..ae3b40a1 100644
--- a/plugins/omo/scripts/hook-status-message.mjs
+++ b/plugins/omo/scripts/hook-status-message.mjs
@@ -1,6 +1,7 @@
const PRODUCT_PREFIX = "(OmO)";
const WORD_OVERRIDES = new Map([
+ ["codegraph", "CodeGraph"],
["lazycodex", "LazyCodex"],
["lsp", "LSP"],
["mcp", "MCP"],
diff --git a/plugins/omo/skills/ultraresearch/SKILL.md b/plugins/omo/skills/ultraresearch/SKILL.md
index 4da98f4b..0e4711a3 100644
--- a/plugins/omo/skills/ultraresearch/SKILL.md
+++ b/plugins/omo/skills/ultraresearch/SKILL.md
@@ -49,6 +49,14 @@ The research is done when all of these hold:
- Every claim in the deliverable cites a source or a verification artifact.
- The session journal reconstructs what was searched, found, and expanded, wave by wave.
+## Run the swarm as a cooperating team
+
+Saturation research is the textbook case for a cooperating team, not isolated fire-and-forget workers: a lead one worker surfaces almost always reshapes what another should search next. So when your harness gives you real cooperating members — Codex: the `teammode` skill (`codex_app` threads); OpenCode: `team_mode` — run this swarm as a team. Fall back to the background-worker swarm below only when team mode is unavailable, or the axes are genuinely independent with no cross-pollination expected.
+
+- **One member per axis — by part, ownership, or perspective, never a job title.** Each Phase 0 axis is one member owning one concrete slice: a codebase part, a source territory, or a question lens. No two members share an angle. "Backend researcher" or "the web person" gives no real boundary and invites overlap — name what the member owns.
+- **The raise law — broadcast every lead the instant it surfaces.** Members over-communicate relentlessly: every new lead, finding, contradiction, and dead end is raised to you the moment it surfaces, never hoarded for a final dump. Through long passes they send `WORKING: <axis> - <phase>`, and `BLOCKED: <reason>` the moment progress stops, so you always know a member is alive. Too many small updates is correct here; going quiet is the only failure.
+- **You lead; expand on each raised lead.** Members raise via message text, never write session files. Journal each lead and spawn its expansion the instant it lands (Phase 2), not only when a member's final reply arrives.
+
## Worker ground rules
Research workers (explore, librarian, browsing) differ by harness, but assume:
@@ -104,7 +112,7 @@ Append each digest the moment its worker returns, not in a batch at the end —
## Phase 1 — Saturation wave
-Launch every first-wave worker in a single turn, all in background. Sequential launches and "start with one and see" defeat the mode.
+Launch the entire first wave in one turn — every axis at once, as team members if you formed a team, else as background workers. Sequential launches and "start with one and see" defeat the mode.
Scaling floor — more angles always justify more workers:
@@ -135,7 +143,7 @@ End your reply with the ## EXPAND tail: '- LEAD: <discovery> — WHY: <why> —
## Phase 2 — Expand until convergence
-This loop is what makes the mode research rather than search. Collect workers as they finish — never wait for the full wave:
+This loop is what makes the mode research rather than search. Collect returns as they land — and in team mode, act on each lead the moment a member raises it, never waiting for the full wave or a member's final reply:
1. Journal the return: digest plus verbatim EXPAND markers into `wave-<N>-<kind>-<axis>.md`.
2. Deduplicate new markers against `expansion-log.md` — every lead ever seen, not just confirmed ones, or rejected leads resurface each wave.
@@ -219,6 +227,7 @@ High-yield combinations: official docs (`site:<docs domain>`), GitHub implementa
| Failure | Correction |
|---|---|
| Sequential spawning, or trimming the first wave | All first-wave workers in one turn, background, scaling floor respected |
+| A team member hoards leads for one final dump | Raise law — every lead, finding, and dead end broadcast the moment it surfaces |
| Worker reply without the EXPAND tail | One follow-up demanding it; the lane stays open until it lands |
| Stopping after wave 1 because "enough was found" | Convergence rules only: 2+ expansion waves, leads run dry |
| Obeying a surrounding "stop exploring" rule mid-research | Authority section — those rules do not bind this mode |
diff --git a/plugins/omo/test/aggregate-hooks.test.mjs b/plugins/omo/test/aggregate-hooks.test.mjs
index f2cef862..c8c7276c 100644
--- a/plugins/omo/test/aggregate-hooks.test.mjs
+++ b/plugins/omo/test/aggregate-hooks.test.mjs
@@ -30,9 +30,11 @@ test("#given isolated components #when hooks are inspected #then commands stay i
const componentMarkers = [
"components/comment-checker/dist/cli.js",
"components/lsp/dist/cli.js",
+ "components/codegraph/dist/cli.js",
"components/rules/dist/cli.js",
"components/start-work-continuation/dist/cli.js",
"components/telemetry/dist/cli.js",
+ "components/teammode/dist/cli.js",
"components/ulw-loop/dist/cli.js",
"components/ultrawork/dist/cli.js",
"scripts/auto-update.mjs",
@@ -179,6 +181,40 @@ test("#given aggregate SessionStart hooks #when inspected #then LazyCodex auto-u
assert(sessionStartCommands.some((command) => command.includes("scripts/auto-update.mjs")));
});
+test("#given aggregate PostToolUse hooks #when inspected #then CodeGraph init guidance is registered for CodeGraph tools", async () => {
+ // given
+ const commandHooks = await readAggregateCommandHooks();
+
+ // when
+ const codegraphPostToolUseHooks = commandHooks.filter(
+ (hook) =>
+ hook.eventName === "PostToolUse" &&
+ hook.handler.command === 'node "${PLUGIN_ROOT}/components/codegraph/dist/cli.js" hook post-tool-use',
+ );
+
+ // then
+ assert.equal(codegraphPostToolUseHooks.length, 1);
+ assert.equal(codegraphPostToolUseHooks[0]?.matcher, "^(codegraph[._].*|mcp__codegraph__.*)$");
+ assert.equal(codegraphPostToolUseHooks[0]?.handler.statusMessage, "(OmO) Checking CodeGraph Init Guidance");
+});
+
+test("#given aggregate PostToolUse hooks #when inspected #then thread title hygiene is registered for created Codex threads", async () => {
+ // given
+ const commandHooks = await readAggregateCommandHooks();
+
+ // when
+ const threadTitleHooks = commandHooks.filter(
+ (hook) =>
+ hook.eventName === "PostToolUse" &&
+ hook.handler.command === 'node "${PLUGIN_ROOT}/components/teammode/dist/cli.js" hook post-tool-use',
+ );
+
+ // then
+ assert.equal(threadTitleHooks.length, 1);
+ assert.equal(threadTitleHooks[0]?.matcher, "^(create_thread|codex_app\\.create_thread)$");
+ assert.equal(threadTitleHooks[0]?.handler.statusMessage, "(OmO) Checking Thread Title Hygiene");
+});
+
test("#given aggregate plugin packaging #when inspected #then hooks and compatibility sentinels stay Python-free", async () => {
// given
const hooksText = (await Promise.all((await readAggregateHookManifests()).map(({ source }) => readFile(join(root, source), "utf8")))).join("\n");
diff --git a/plugins/omo/test/aggregate-manifest.test.mjs b/plugins/omo/test/aggregate-manifest.test.mjs
index c4d1851a..c827bdc2 100644
--- a/plugins/omo/test/aggregate-manifest.test.mjs
+++ b/plugins/omo/test/aggregate-manifest.test.mjs
@@ -17,7 +17,7 @@ test("#given aggregate plugin manifest #when inspected #then it owns the omo nam
// then
assert.equal(manifest.name, "omo");
assert(Array.isArray(hookPaths));
- assert.equal(hookPaths.length, 19);
+ assert.equal(hookPaths.length, 21);
assert(hookPaths.every((hookPath) => typeof hookPath === "string" && hookPath.startsWith("./hooks/")));
assert(!hookPaths.includes("./hooks/hooks.json"));
assert.equal(skillsPath, "./skills/");
@@ -60,6 +60,7 @@ test("#given component directories #when scanned #then only intentional resource
"lsp",
"rules",
"start-work-continuation",
+ "teammode",
"telemetry",
"ultrawork",
"ulw-loop",
diff --git a/plugins/omo/test/aggregate-plugin-fixture.mjs b/plugins/omo/test/aggregate-plugin-fixture.mjs
index cee1cb65..3be956c2 100644
--- a/plugins/omo/test/aggregate-plugin-fixture.mjs
+++ b/plugins/omo/test/aggregate-plugin-fixture.mjs
@@ -68,7 +68,7 @@ export function collectCommandHooks(hooks, source) {
}
group.hooks.forEach((handler, handlerIndex) => {
if (typeof handler !== "object" || handler === null || handler.type !== "command") return;
- commandHooks.push({ source, eventName, groupIndex, handlerIndex, handler });
+ commandHooks.push({ source, eventName, groupIndex, handlerIndex, matcher: group.matcher, handler });
});
});
}
diff --git a/plugins/omo/test/component-bundled-cli.test.mjs b/plugins/omo/test/component-bundled-cli.test.mjs
index f90d3f41..d48e7705 100644
--- a/plugins/omo/test/component-bundled-cli.test.mjs
+++ b/plugins/omo/test/component-bundled-cli.test.mjs
@@ -17,6 +17,7 @@ const HOOK_EVENTS_BY_COMPONENT = {
rules: "session-start",
"start-work-continuation": "stop",
telemetry: "session-start",
+ teammode: "post-tool-use",
ultrawork: "user-prompt-submit",
"ulw-loop": "pre-tool-use",
};
diff --git a/plugins/omo/test/component-hook-contract-cases.mjs b/plugins/omo/test/component-hook-contract-cases.mjs
index 5317297a..812d57fe 100644
--- a/plugins/omo/test/component-hook-contract-cases.mjs
+++ b/plugins/omo/test/component-hook-contract-cases.mjs
@@ -138,6 +138,30 @@ export function componentHookContractCases(tempRoot) {
assert.equal(stdout, "");
},
},
+ {
+ name: "teammode post-tool-use create-thread title reminder",
+ component: "teammode",
+ event: "post-tool-use",
+ payload: {
+ hook_event_name: "PostToolUse",
+ session_id: "s-task12",
+ turn_id: "t-task12",
+ transcript_path: null,
+ cwd: tempRoot,
+ model: "gpt-5.5",
+ permission_mode: "default",
+ tool_name: "create_thread",
+ tool_use_id: "tool-task12",
+ tool_input: { prompt: "Investigate flaky release packaging" },
+ tool_response: { threadId: "thread-task12" },
+ },
+ assertOutput(stdout) {
+ const output = JSON.parse(stdout);
+ assert.equal(output.hookSpecificOutput.hookEventName, "PostToolUse");
+ assert.match(output.hookSpecificOutput.additionalContext, /codex_app\.set_thread_title/);
+ assert.match(output.hookSpecificOutput.additionalContext, /thread-task12/);
+ },
+ },
{
name: "lsp post-compact reset",
component: "lsp",
diff --git a/plugins/omo/test/hook-status-message.test.mjs b/plugins/omo/test/hook-status-message.test.mjs
index fec626f8..26029cb2 100644
--- a/plugins/omo/test/hook-status-message.test.mjs
+++ b/plugins/omo/test/hook-status-message.test.mjs
@@ -25,6 +25,7 @@ const AGGREGATE_EXPECTED_LABELS = new Map([
["hooks/hooks.json:PreToolUse:1:0", "Enforcing Unlimited Goal Budget"],
["hooks/hooks.json:PostToolUse:0:0", "Checking Comments"],
["hooks/hooks.json:PostToolUse:0:1", "Checking LSP Diagnostics"],
+ ["hooks/hooks.json:PostToolUse:0:2", "Checking CodeGraph Init Guidance"],
["hooks/hooks.json:PostToolUse:1:0", "Matching Project Rules"],
["hooks/hooks.json:PostCompact:0:0", "Resetting Git Bash MCP Reminder"],
["hooks/hooks.json:PostCompact:1:0", "Resetting Project Rule Cache"],
diff --git a/plugins/omo/test/ultraresearch-skill-contract.test.mjs b/plugins/omo/test/ultraresearch-skill-contract.test.mjs
index 6ab13b40..5fae2e70 100644
--- a/plugins/omo/test/ultraresearch-skill-contract.test.mjs
+++ b/plugins/omo/test/ultraresearch-skill-contract.test.mjs
@@ -124,3 +124,51 @@ test("#given ultraresearch worker sizing #when spawn guidance is inspected #then
);
}
});
+
+test("#given ultraresearch execution substrate #when team usage is inspected #then it prefers a cooperating team with harness-native team tools", async () => {
+ for (const copy of await readUltraresearchCopies()) {
+ assert.match(
+ copy.content,
+ /cooperating team/i,
+ `${copy.label}: body must encourage running the swarm as a cooperating team`,
+ );
+ assert.match(copy.content, /\bteammode\b/i, `${copy.label}: body must name the Codex teammode skill`);
+ assert.match(copy.content, /team_mode/i, `${copy.label}: body must name the OpenCode team_mode path`);
+ }
+});
+
+test("#given ultraresearch team composition #when member slicing is inspected #then members map to part/ownership/perspective, never job titles", async () => {
+ for (const copy of await readUltraresearchCopies()) {
+ assert.match(
+ copy.content,
+ /by part, ownership, or perspective/i,
+ `${copy.label}: body must compose members by part, ownership, or perspective`,
+ );
+ assert.match(
+ copy.content,
+ /never a job title|not (?:a |by )?job title/i,
+ `${copy.label}: body must forbid vague job-title members`,
+ );
+ }
+});
+
+test("#given ultraresearch team communication #when the raise law is inspected #then members broadcast every lead immediately rather than hoarding", async () => {
+ for (const copy of await readUltraresearchCopies()) {
+ assert.match(
+ copy.content,
+ /raise law|broadcast every lead/i,
+ `${copy.label}: body must state the raise/broadcast law`,
+ );
+ assert.match(copy.content, /over-communicate/i, `${copy.label}: body must demand over-communication`);
+ assert.match(
+ copy.content,
+ /the (?:moment|instant) it (?:surfaces|appears|lands)/i,
+ `${copy.label}: body must require raising leads the moment they surface`,
+ );
+ assert.match(
+ copy.content,
+ /hoard/i,
+ `${copy.label}: body must reject hoarding leads for a final dump`,
+ );
+ }
+});