oh-my-opencode 4.15.0 → 4.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +644 -530
- package/dist/cli-node/index.js +644 -530
- package/dist/index.js +13 -13
- package/dist/skills/frontend/ATTRIBUTION.md +3 -2
- package/dist/skills/frontend/references/designpowers/EVIDENCE.md +10 -2
- package/dist/skills/frontend/references/designpowers/UPSTREAM.md +1 -1
- package/package.json +13 -13
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +194 -102
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/codegraph/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +1 -1
- package/packages/omo-codex/plugin/package-lock.json +13 -13
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/auto-update-plan.mjs +147 -2
- package/packages/omo-codex/plugin/scripts/auto-update-release-notes.mjs +33 -0
- package/packages/omo-codex/plugin/scripts/auto-update.mjs +48 -10
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +18 -0
- package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +3 -2
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/EVIDENCE.md +10 -2
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/UPSTREAM.md +1 -1
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +3 -3
- package/packages/omo-codex/plugin/test/auto-update-release-notes.test.mjs +32 -0
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +153 -3
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +18 -1
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +39 -10
- package/packages/omo-codex/plugin/test/ulw-research-skill-contract.test.mjs +19 -1
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +444 -330
- package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +3 -2
- package/packages/shared-skills/skills/frontend/references/designpowers/EVIDENCE.md +10 -2
- package/packages/shared-skills/skills/frontend/references/designpowers/UPSTREAM.md +1 -1
- package/packages/omo-codex/plugin/skills/ultraresearch/SKILL.md +0 -10
- package/packages/omo-codex/plugin/skills/ultraresearch/agents/openai.yaml +0 -2
- /package/dist/skills/frontend/references/designpowers/vendor/skills/accessible-content/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/adaptive-interfaces/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/cognitive-accessibility/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/design-debate/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/design-debt-tracker/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/design-handoff/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/design-md/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/design-retrospective/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/design-review/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/design-system-alignment/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/designpowers-critique/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/heuristic-evaluation/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/inclusive-personas/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/inspiration-scouting/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/interaction-design/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/motion-choreography/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/research-planning/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/responsive-patterns/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/synthetic-user-testing/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/taste-feedback/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/taste-report/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/token-architecture/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/ui-composition/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/usability-testing/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/verification-before-shipping/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/voice-and-tone/{SKILL.md → reference.md} +0 -0
- /package/dist/skills/frontend/references/designpowers/vendor/skills/writing-design-plans/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/accessible-content/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/adaptive-interfaces/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/cognitive-accessibility/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/design-debate/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/design-debt-tracker/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/design-handoff/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/design-md/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/design-retrospective/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/design-review/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/design-system-alignment/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/designpowers-critique/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/heuristic-evaluation/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/inclusive-personas/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/inspiration-scouting/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/interaction-design/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/motion-choreography/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/research-planning/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/responsive-patterns/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/synthetic-user-testing/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/taste-feedback/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/taste-report/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/token-architecture/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/ui-composition/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/usability-testing/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/verification-before-shipping/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/voice-and-tone/{SKILL.md → reference.md} +0 -0
- /package/packages/omo-codex/plugin/skills/frontend/references/designpowers/vendor/skills/writing-design-plans/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/accessible-content/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/adaptive-interfaces/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/cognitive-accessibility/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/design-debate/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/design-debt-tracker/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/design-handoff/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/design-md/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/design-retrospective/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/design-review/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/design-system-alignment/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/designpowers-critique/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/heuristic-evaluation/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/inclusive-personas/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/inspiration-scouting/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/interaction-design/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/motion-choreography/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/research-planning/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/responsive-patterns/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/synthetic-user-testing/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/taste-feedback/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/taste-report/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/token-architecture/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/ui-composition/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/usability-testing/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/verification-before-shipping/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/voice-and-tone/{SKILL.md → reference.md} +0 -0
- /package/packages/shared-skills/skills/frontend/references/designpowers/vendor/skills/writing-design-plans/{SKILL.md → reference.md} +0 -0
|
@@ -96,20 +96,20 @@ var init_atomic_write = __esm(() => {
|
|
|
96
96
|
|
|
97
97
|
// packages/telemetry-core/src/activity-state.ts
|
|
98
98
|
import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync } from "node:fs";
|
|
99
|
-
import { basename as basename6, join as
|
|
99
|
+
import { basename as basename6, join as join30 } from "node:path";
|
|
100
100
|
function resolveTelemetryStateDir(product, options = {}) {
|
|
101
101
|
const dataDir = resolveXdgDataDir(product.cacheDirName, {
|
|
102
102
|
env: options.env,
|
|
103
103
|
osProvider: options.osProvider
|
|
104
104
|
});
|
|
105
|
-
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined :
|
|
105
|
+
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join30(options.env.XDG_DATA_HOME, product.cacheDirName);
|
|
106
106
|
if (dataDir === xdgStateDir || xdgStateDir === undefined && basename6(dataDir) === product.cacheDirName) {
|
|
107
107
|
return dataDir;
|
|
108
108
|
}
|
|
109
|
-
return
|
|
109
|
+
return join30(dataDir, product.cacheDirName);
|
|
110
110
|
}
|
|
111
111
|
function getTelemetryActivityStateFilePath(stateDir) {
|
|
112
|
-
return
|
|
112
|
+
return join30(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
|
|
113
113
|
}
|
|
114
114
|
function getDailyActiveCaptureState(input) {
|
|
115
115
|
const state = readPostHogActivityState(input.stateDir, input.diagnostics);
|
|
@@ -180,9 +180,9 @@ var DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com", DEFAULT_POSTHOG_API_KEY =
|
|
|
180
180
|
|
|
181
181
|
// packages/telemetry-core/src/diagnostics.ts
|
|
182
182
|
import { appendFileSync, existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
183
|
-
import { join as
|
|
183
|
+
import { join as join31 } from "node:path";
|
|
184
184
|
function getTelemetryDiagnosticsFilePath(diagnosticsDir) {
|
|
185
|
-
return
|
|
185
|
+
return join31(diagnosticsDir, DIAGNOSTICS_FILE_NAME);
|
|
186
186
|
}
|
|
187
187
|
function writeTelemetryDiagnostic(input, options) {
|
|
188
188
|
const now = options.now ?? new Date;
|
|
@@ -348,7 +348,7 @@ function getTelemetryDistinctId(machineIdPrefix, osProvider = getDefaultTelemetr
|
|
|
348
348
|
var init_machine_id = () => {};
|
|
349
349
|
|
|
350
350
|
// node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
351
|
-
import { dirname as
|
|
351
|
+
import { dirname as dirname9, posix, sep as sep7 } from "node:path";
|
|
352
352
|
function createModulerModifier() {
|
|
353
353
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
354
354
|
return async (frames) => {
|
|
@@ -357,7 +357,7 @@ function createModulerModifier() {
|
|
|
357
357
|
return frames;
|
|
358
358
|
};
|
|
359
359
|
}
|
|
360
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
360
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname9(process.argv[1]) : process.cwd(), isWindows = sep7 === "\\") {
|
|
361
361
|
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
362
362
|
return (filename) => {
|
|
363
363
|
if (!filename)
|
|
@@ -3197,14 +3197,14 @@ async function addSourceContext(frames) {
|
|
|
3197
3197
|
return frames;
|
|
3198
3198
|
}
|
|
3199
3199
|
function getContextLinesFromFile(path2, ranges, output) {
|
|
3200
|
-
return new Promise((
|
|
3200
|
+
return new Promise((resolve11) => {
|
|
3201
3201
|
const stream = createReadStream(path2);
|
|
3202
3202
|
const lineReaded = createInterface({
|
|
3203
3203
|
input: stream
|
|
3204
3204
|
});
|
|
3205
3205
|
function destroyStreamAndResolve() {
|
|
3206
3206
|
stream.destroy();
|
|
3207
|
-
|
|
3207
|
+
resolve11();
|
|
3208
3208
|
}
|
|
3209
3209
|
let lineNumber = 0;
|
|
3210
3210
|
let currentRangeIndex = 0;
|
|
@@ -3378,7 +3378,7 @@ var init_context_lines_node = __esm(() => {
|
|
|
3378
3378
|
});
|
|
3379
3379
|
|
|
3380
3380
|
// node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
|
|
3381
|
-
import { isAbsolute as
|
|
3381
|
+
import { isAbsolute as isAbsolute6, relative as relative4, sep as sep8 } from "node:path";
|
|
3382
3382
|
function createRelativePathModifier(basePath = process.cwd()) {
|
|
3383
3383
|
const isWindows = sep8 === "\\";
|
|
3384
3384
|
const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
|
|
@@ -3386,7 +3386,7 @@ function createRelativePathModifier(basePath = process.cwd()) {
|
|
|
3386
3386
|
return async (frames) => {
|
|
3387
3387
|
for (const frame of frames)
|
|
3388
3388
|
if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
|
|
3389
|
-
if (
|
|
3389
|
+
if (isAbsolute6(frame.filename))
|
|
3390
3390
|
frame.filename = toUnix(relative4(normalizedBase, toUnix(frame.filename)));
|
|
3391
3391
|
}
|
|
3392
3392
|
return frames;
|
|
@@ -4676,9 +4676,9 @@ var init_client = __esm(() => {
|
|
|
4676
4676
|
if (this.disabled || this.optedOut)
|
|
4677
4677
|
return;
|
|
4678
4678
|
if (!this._waitUntilCycle) {
|
|
4679
|
-
let
|
|
4679
|
+
let resolve11;
|
|
4680
4680
|
const promise = new Promise((r) => {
|
|
4681
|
-
|
|
4681
|
+
resolve11 = r;
|
|
4682
4682
|
});
|
|
4683
4683
|
try {
|
|
4684
4684
|
waitUntil(promise);
|
|
@@ -4686,7 +4686,7 @@ var init_client = __esm(() => {
|
|
|
4686
4686
|
return;
|
|
4687
4687
|
}
|
|
4688
4688
|
this._waitUntilCycle = {
|
|
4689
|
-
resolve:
|
|
4689
|
+
resolve: resolve11,
|
|
4690
4690
|
startedAt: Date.now(),
|
|
4691
4691
|
timer: undefined
|
|
4692
4692
|
};
|
|
@@ -4712,11 +4712,11 @@ var init_client = __esm(() => {
|
|
|
4712
4712
|
return cycle?.resolve;
|
|
4713
4713
|
}
|
|
4714
4714
|
async resolveWaitUntilFlush() {
|
|
4715
|
-
const
|
|
4715
|
+
const resolve11 = this._consumeWaitUntilCycle();
|
|
4716
4716
|
try {
|
|
4717
4717
|
await super.flush();
|
|
4718
4718
|
} catch {} finally {
|
|
4719
|
-
|
|
4719
|
+
resolve11?.();
|
|
4720
4720
|
}
|
|
4721
4721
|
}
|
|
4722
4722
|
getPersistedProperty(key) {
|
|
@@ -4816,15 +4816,15 @@ var init_client = __esm(() => {
|
|
|
4816
4816
|
return true;
|
|
4817
4817
|
if (this.featureFlagsPoller === undefined)
|
|
4818
4818
|
return false;
|
|
4819
|
-
return new Promise((
|
|
4819
|
+
return new Promise((resolve11) => {
|
|
4820
4820
|
const timeout = setTimeout(() => {
|
|
4821
4821
|
cleanup();
|
|
4822
|
-
|
|
4822
|
+
resolve11(false);
|
|
4823
4823
|
}, timeoutMs);
|
|
4824
4824
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
|
|
4825
4825
|
clearTimeout(timeout);
|
|
4826
4826
|
cleanup();
|
|
4827
|
-
|
|
4827
|
+
resolve11(count > 0);
|
|
4828
4828
|
});
|
|
4829
4829
|
});
|
|
4830
4830
|
}
|
|
@@ -5330,13 +5330,13 @@ var init_client = __esm(() => {
|
|
|
5330
5330
|
this.context?.enter(data, options);
|
|
5331
5331
|
}
|
|
5332
5332
|
async _shutdown(shutdownTimeoutMs) {
|
|
5333
|
-
const
|
|
5333
|
+
const resolve11 = this._consumeWaitUntilCycle();
|
|
5334
5334
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
5335
5335
|
this.errorTracking.shutdown();
|
|
5336
5336
|
try {
|
|
5337
5337
|
return await super._shutdown(shutdownTimeoutMs);
|
|
5338
5338
|
} finally {
|
|
5339
|
-
|
|
5339
|
+
resolve11?.();
|
|
5340
5340
|
}
|
|
5341
5341
|
}
|
|
5342
5342
|
async _requestRemoteConfigPayload(flagKey) {
|
|
@@ -5907,7 +5907,7 @@ var package_default;
|
|
|
5907
5907
|
var init_package = __esm(() => {
|
|
5908
5908
|
package_default = {
|
|
5909
5909
|
name: "@oh-my-opencode/omo-codex",
|
|
5910
|
-
version: "4.15.
|
|
5910
|
+
version: "4.15.1",
|
|
5911
5911
|
type: "module",
|
|
5912
5912
|
private: true,
|
|
5913
5913
|
description: "Codex harness adapter for oh-my-openagent. Vendored Codex plugin namespace (omo) + TypeScript installer + telemetry.",
|
|
@@ -6126,8 +6126,8 @@ var init_telemetry = __esm(() => {
|
|
|
6126
6126
|
});
|
|
6127
6127
|
|
|
6128
6128
|
// packages/omo-codex/src/install/install-local-cli.ts
|
|
6129
|
-
import { readFile as
|
|
6130
|
-
import { dirname as
|
|
6129
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
6130
|
+
import { dirname as dirname11, join as join36, resolve as resolve12 } from "node:path";
|
|
6131
6131
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
6132
6132
|
|
|
6133
6133
|
// packages/utils/src/runtime/spawn.ts
|
|
@@ -6458,13 +6458,13 @@ var defaultRunCommand = async (command, args, options) => {
|
|
|
6458
6458
|
};
|
|
6459
6459
|
|
|
6460
6460
|
// packages/omo-codex/src/install/install-codex.ts
|
|
6461
|
-
import { join as
|
|
6461
|
+
import { join as join32, resolve as resolve11 } from "node:path";
|
|
6462
6462
|
import { existsSync as existsSync7 } from "node:fs";
|
|
6463
6463
|
import { homedir as homedir2 } from "node:os";
|
|
6464
6464
|
|
|
6465
6465
|
// packages/omo-codex/src/install/codex-cache-bins.ts
|
|
6466
|
-
import { chmod, lstat as
|
|
6467
|
-
import { basename, isAbsolute, join as
|
|
6466
|
+
import { chmod, lstat as lstat4, mkdir, readFile as readFile3, readdir as readdir2, readlink as readlink3, rm as rm3, stat as stat2, symlink, writeFile } from "node:fs/promises";
|
|
6467
|
+
import { basename, isAbsolute as isAbsolute2, join as join5, relative, resolve as resolve2, sep } from "node:path";
|
|
6468
6468
|
|
|
6469
6469
|
// packages/omo-codex/src/install/codex-cache-command-shim.ts
|
|
6470
6470
|
var COMMAND_SHIM_MARKER = ":: generated by oh-my-openagent Codex installer";
|
|
@@ -6507,6 +6507,10 @@ function windowsCommandShim(targetPath) {
|
|
|
6507
6507
|
`);
|
|
6508
6508
|
}
|
|
6509
6509
|
|
|
6510
|
+
// packages/omo-codex/src/install/codex-cache-dangling-bins.ts
|
|
6511
|
+
import { lstat as lstat2, readFile, readdir, readlink, rm, stat } from "node:fs/promises";
|
|
6512
|
+
import { dirname, isAbsolute, join as join2, resolve } from "node:path";
|
|
6513
|
+
|
|
6510
6514
|
// packages/omo-codex/src/install/codex-cache-fs.ts
|
|
6511
6515
|
import { lstat } from "node:fs/promises";
|
|
6512
6516
|
async function fileExistsStrict(path) {
|
|
@@ -6526,9 +6530,96 @@ function isNodeErrorWithCode(error) {
|
|
|
6526
6530
|
return typeof error === "object" && error !== null && "code" in error;
|
|
6527
6531
|
}
|
|
6528
6532
|
|
|
6533
|
+
// packages/omo-codex/src/install/codex-cache-dangling-bins.ts
|
|
6534
|
+
async function removeDanglingManagedComponentBins(binDir, platform, managedBinNames) {
|
|
6535
|
+
const entries = await readdir(binDir, { withFileTypes: true });
|
|
6536
|
+
for (const entry of entries) {
|
|
6537
|
+
const binName = managedBinNameForEntry(entry.name, platform);
|
|
6538
|
+
if (binName === null || !managedBinNames.has(binName))
|
|
6539
|
+
continue;
|
|
6540
|
+
const linkPath = join2(binDir, entry.name);
|
|
6541
|
+
if (platform === "win32") {
|
|
6542
|
+
await removeDanglingGeneratedCommandShim(linkPath);
|
|
6543
|
+
continue;
|
|
6544
|
+
}
|
|
6545
|
+
await removeDanglingManagedSymlink(linkPath);
|
|
6546
|
+
}
|
|
6547
|
+
}
|
|
6548
|
+
function managedBinNameForEntry(name, platform) {
|
|
6549
|
+
if (platform === "win32")
|
|
6550
|
+
return name.endsWith(".cmd") ? name.slice(0, -4) : null;
|
|
6551
|
+
return name;
|
|
6552
|
+
}
|
|
6553
|
+
async function removeDanglingManagedSymlink(linkPath) {
|
|
6554
|
+
try {
|
|
6555
|
+
const linkStat = await lstat2(linkPath);
|
|
6556
|
+
if (!linkStat.isSymbolicLink())
|
|
6557
|
+
return;
|
|
6558
|
+
const linkTarget = await readlink(linkPath);
|
|
6559
|
+
const target = isAbsolute(linkTarget) ? linkTarget : resolve(dirname(linkPath), linkTarget);
|
|
6560
|
+
if (!await isFileSystemEntry(target) && isManagedComponentBinTarget(target))
|
|
6561
|
+
await rm(linkPath, { force: true });
|
|
6562
|
+
} catch (error) {
|
|
6563
|
+
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
6564
|
+
return;
|
|
6565
|
+
throw error;
|
|
6566
|
+
}
|
|
6567
|
+
}
|
|
6568
|
+
async function removeDanglingGeneratedCommandShim(linkPath) {
|
|
6569
|
+
try {
|
|
6570
|
+
const linkStat = await lstat2(linkPath);
|
|
6571
|
+
if (!linkStat.isFile())
|
|
6572
|
+
return;
|
|
6573
|
+
const content = await readFile(linkPath, "utf8");
|
|
6574
|
+
if (!content.includes(COMMAND_SHIM_MARKER))
|
|
6575
|
+
return;
|
|
6576
|
+
const target = extractCommandShimTarget(content);
|
|
6577
|
+
if (target !== null && !await isFileSystemEntry(target) && isManagedComponentBinTarget(target))
|
|
6578
|
+
await rm(linkPath, { force: true });
|
|
6579
|
+
} catch (error) {
|
|
6580
|
+
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
6581
|
+
return;
|
|
6582
|
+
throw error;
|
|
6583
|
+
}
|
|
6584
|
+
}
|
|
6585
|
+
async function isFileSystemEntry(path) {
|
|
6586
|
+
try {
|
|
6587
|
+
await stat(path);
|
|
6588
|
+
return true;
|
|
6589
|
+
} catch (error) {
|
|
6590
|
+
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
6591
|
+
return false;
|
|
6592
|
+
throw error;
|
|
6593
|
+
}
|
|
6594
|
+
}
|
|
6595
|
+
function extractCommandShimTarget(content) {
|
|
6596
|
+
const match = /"([^"\r\n]+components[\\/][^"\r\n]+[\\/]dist[\\/]cli\.js)" %\*/.exec(content);
|
|
6597
|
+
return match?.[1] ?? null;
|
|
6598
|
+
}
|
|
6599
|
+
function isManagedComponentBinTarget(target) {
|
|
6600
|
+
const parts = target.split(/[\\/]+/);
|
|
6601
|
+
const suffix = parts.slice(-4);
|
|
6602
|
+
return suffix[0] === "components" && suffix[2] === "dist" && suffix[3] === "cli.js" && (hasOmoPluginCachePrefix(parts, parts.length - 4) || hasOmoCodexPluginPrefix(parts, parts.length - 4));
|
|
6603
|
+
}
|
|
6604
|
+
function hasOmoPluginCachePrefix(parts, endExclusive) {
|
|
6605
|
+
for (let index = 0;index < endExclusive - 4; index += 1) {
|
|
6606
|
+
if (parts[index] === "plugins" && parts[index + 1] === "cache" && parts[index + 2] === "sisyphuslabs" && parts[index + 3] === "omo") {
|
|
6607
|
+
return index + 4 < endExclusive;
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
return false;
|
|
6611
|
+
}
|
|
6612
|
+
function hasOmoCodexPluginPrefix(parts, endExclusive) {
|
|
6613
|
+
for (let index = 0;index <= endExclusive - 3; index += 1) {
|
|
6614
|
+
if (parts[index] === "packages" && parts[index + 1] === "omo-codex" && parts[index + 2] === "plugin")
|
|
6615
|
+
return true;
|
|
6616
|
+
}
|
|
6617
|
+
return false;
|
|
6618
|
+
}
|
|
6619
|
+
|
|
6529
6620
|
// packages/omo-codex/src/install/codex-cache-legacy-bins.ts
|
|
6530
|
-
import { lstat as
|
|
6531
|
-
import { join as
|
|
6621
|
+
import { lstat as lstat3, readFile as readFile2, readlink as readlink2, rm as rm2 } from "node:fs/promises";
|
|
6622
|
+
import { join as join3 } from "node:path";
|
|
6532
6623
|
var LEGACY_CODEX_COMPONENT_BINS = [
|
|
6533
6624
|
{ name: "omo", component: "ulw-loop" },
|
|
6534
6625
|
{ name: "codex-comment-checker", component: "comment-checker" },
|
|
@@ -6540,26 +6631,26 @@ var LEGACY_CODEX_COMPONENT_BINS = [
|
|
|
6540
6631
|
];
|
|
6541
6632
|
async function removeLegacyCodexComponentBins(binDir, platform) {
|
|
6542
6633
|
for (const entry of LEGACY_CODEX_COMPONENT_BINS) {
|
|
6543
|
-
const linkPath =
|
|
6634
|
+
const linkPath = join3(binDir, platform === "win32" ? `${entry.name}.cmd` : entry.name);
|
|
6544
6635
|
await removeLegacyCodexComponentBin(linkPath, entry.component, platform);
|
|
6545
6636
|
}
|
|
6546
6637
|
}
|
|
6547
6638
|
async function removeLegacyCodexComponentBin(linkPath, component, platform) {
|
|
6548
6639
|
try {
|
|
6549
|
-
const
|
|
6640
|
+
const stat2 = await lstat3(linkPath);
|
|
6550
6641
|
if (platform !== "win32") {
|
|
6551
|
-
if (!
|
|
6642
|
+
if (!stat2.isSymbolicLink())
|
|
6552
6643
|
return;
|
|
6553
|
-
const target = await
|
|
6644
|
+
const target = await readlink2(linkPath);
|
|
6554
6645
|
if (isManagedLegacyComponentTarget(target, component))
|
|
6555
|
-
await
|
|
6646
|
+
await rm2(linkPath, { force: true });
|
|
6556
6647
|
return;
|
|
6557
6648
|
}
|
|
6558
|
-
if (!
|
|
6649
|
+
if (!stat2.isFile())
|
|
6559
6650
|
return;
|
|
6560
|
-
const content = await
|
|
6651
|
+
const content = await readFile2(linkPath, "utf8");
|
|
6561
6652
|
if (content.includes(COMMAND_SHIM_MARKER))
|
|
6562
|
-
await
|
|
6653
|
+
await rm2(linkPath, { force: true });
|
|
6563
6654
|
} catch (error) {
|
|
6564
6655
|
if (isNodeErrorWithCode2(error) && error.code === "ENOENT")
|
|
6565
6656
|
return;
|
|
@@ -6570,7 +6661,7 @@ function isManagedLegacyComponentTarget(target, component) {
|
|
|
6570
6661
|
const parts = target.split(/[\\/]+/);
|
|
6571
6662
|
const suffixStart = parts.length - 4;
|
|
6572
6663
|
const suffix = parts.slice(-4);
|
|
6573
|
-
return suffix[0] === "components" && suffix[1] === component && suffix[2] === "dist" && suffix[3] === "cli.js" && (hasPluginCachePrefix(parts, suffixStart) ||
|
|
6664
|
+
return suffix[0] === "components" && suffix[1] === component && suffix[2] === "dist" && suffix[3] === "cli.js" && (hasPluginCachePrefix(parts, suffixStart) || hasOmoCodexPluginPrefix2(parts, suffixStart));
|
|
6574
6665
|
}
|
|
6575
6666
|
function hasPluginCachePrefix(parts, endExclusive) {
|
|
6576
6667
|
for (let index = 0;index < endExclusive - 1; index += 1) {
|
|
@@ -6579,7 +6670,7 @@ function hasPluginCachePrefix(parts, endExclusive) {
|
|
|
6579
6670
|
}
|
|
6580
6671
|
return false;
|
|
6581
6672
|
}
|
|
6582
|
-
function
|
|
6673
|
+
function hasOmoCodexPluginPrefix2(parts, endExclusive) {
|
|
6583
6674
|
for (let index = 0;index <= endExclusive - 3; index += 1) {
|
|
6584
6675
|
if (parts[index] === "packages" && parts[index + 1] === "omo-codex" && parts[index + 2] === "plugin")
|
|
6585
6676
|
return true;
|
|
@@ -6591,10 +6682,10 @@ function isNodeErrorWithCode2(error) {
|
|
|
6591
6682
|
}
|
|
6592
6683
|
|
|
6593
6684
|
// packages/omo-codex/src/install/codex-cache-runtime-wrapper.ts
|
|
6594
|
-
import { join as
|
|
6685
|
+
import { join as join4 } from "node:path";
|
|
6595
6686
|
var RUNTIME_WRAPPER_MARKER = "OMO_GENERATED_RUNTIME_WRAPPER";
|
|
6596
6687
|
function posixRuntimeWrapper(cliPath, codexHome, binDir, nodeCliPath) {
|
|
6597
|
-
const ulwLoopBin = toPosixPath(
|
|
6688
|
+
const ulwLoopBin = toPosixPath(join4(binDir, "omo-ulw-loop"));
|
|
6598
6689
|
const nodeCli = escapePosixDoubleQuoted(toPosixPath(nodeCliPath));
|
|
6599
6690
|
const escapedCliPath = escapePosixDoubleQuoted(toPosixPath(cliPath));
|
|
6600
6691
|
const escapedCodexHome = escapePosixDoubleQuoted(toPosixPath(codexHome));
|
|
@@ -6639,7 +6730,7 @@ function posixRuntimeWrapper(cliPath, codexHome, binDir, nodeCliPath) {
|
|
|
6639
6730
|
`);
|
|
6640
6731
|
}
|
|
6641
6732
|
function windowsRuntimeWrapper(cliPath, codexHome, binDir, nodeCliPath) {
|
|
6642
|
-
const ulwLoopBin =
|
|
6733
|
+
const ulwLoopBin = join4(binDir, "omo-ulw-loop.cmd");
|
|
6643
6734
|
return [
|
|
6644
6735
|
"@echo off",
|
|
6645
6736
|
`rem ${RUNTIME_WRAPPER_MARKER}`,
|
|
@@ -6687,6 +6778,7 @@ async function linkCachedPluginBins(input) {
|
|
|
6687
6778
|
const platform = input.platform ?? process.platform;
|
|
6688
6779
|
await mkdir(input.binDir, { recursive: true });
|
|
6689
6780
|
await removeLegacyCodexComponentBins(input.binDir, platform);
|
|
6781
|
+
await removeDanglingManagedComponentBins(input.binDir, platform, new Set(binLinks.map((link) => link.name)));
|
|
6690
6782
|
const linked = [];
|
|
6691
6783
|
for (const link of binLinks) {
|
|
6692
6784
|
const linkPath = await linkCachedPluginBin(input.binDir, link, platform);
|
|
@@ -6698,55 +6790,55 @@ async function removeCachedManagedNpmBinShims(pluginRoot) {
|
|
|
6698
6790
|
const binLinks = await discoverPackageBins(pluginRoot);
|
|
6699
6791
|
if (binLinks.length === 0)
|
|
6700
6792
|
return;
|
|
6701
|
-
const npmBinDir =
|
|
6702
|
-
if (!await
|
|
6793
|
+
const npmBinDir = join5(pluginRoot, "node_modules", ".bin");
|
|
6794
|
+
if (!await isFileSystemEntry2(npmBinDir))
|
|
6703
6795
|
return;
|
|
6704
6796
|
const managedBinNames = new Set(binLinks.map((link) => link.name));
|
|
6705
6797
|
for (const name of managedBinNames) {
|
|
6706
6798
|
for (const suffix of ["", ".cmd", ".ps1"]) {
|
|
6707
|
-
await
|
|
6799
|
+
await rm3(join5(npmBinDir, `${name}${suffix}`), { force: true });
|
|
6708
6800
|
}
|
|
6709
6801
|
}
|
|
6710
6802
|
}
|
|
6711
6803
|
async function linkRootRuntimeBin(input) {
|
|
6712
|
-
const cliPath =
|
|
6804
|
+
const cliPath = join5(input.repoRoot, "dist", "cli", "index.js");
|
|
6713
6805
|
if (!await isFile(cliPath))
|
|
6714
6806
|
return null;
|
|
6715
|
-
const nodeCliPath =
|
|
6807
|
+
const nodeCliPath = join5(input.repoRoot, "dist", "cli-node", "index.js");
|
|
6716
6808
|
const platform = input.platform ?? process.platform;
|
|
6717
6809
|
await mkdir(input.binDir, { recursive: true });
|
|
6718
6810
|
if (platform === "win32") {
|
|
6719
|
-
const linkPath2 =
|
|
6811
|
+
const linkPath2 = join5(input.binDir, "omo.cmd");
|
|
6720
6812
|
await replaceRuntimeWrapper(linkPath2, windowsRuntimeWrapper(cliPath, input.codexHome, input.binDir, nodeCliPath));
|
|
6721
6813
|
return { name: "omo", path: linkPath2, target: cliPath };
|
|
6722
6814
|
}
|
|
6723
|
-
const linkPath =
|
|
6815
|
+
const linkPath = join5(input.binDir, "omo");
|
|
6724
6816
|
await replaceRuntimeWrapper(linkPath, posixRuntimeWrapper(cliPath, input.codexHome, input.binDir, nodeCliPath));
|
|
6725
6817
|
await chmod(linkPath, 493);
|
|
6726
6818
|
return { name: "omo", path: linkPath, target: cliPath };
|
|
6727
6819
|
}
|
|
6728
6820
|
async function linkCachedPluginBin(binDir, link, platform) {
|
|
6729
6821
|
if (platform === "win32") {
|
|
6730
|
-
const linkPath2 =
|
|
6822
|
+
const linkPath2 = join5(binDir, `${link.name}.cmd`);
|
|
6731
6823
|
await replaceCommandShim(linkPath2, link.target);
|
|
6732
6824
|
return linkPath2;
|
|
6733
6825
|
}
|
|
6734
|
-
const linkPath =
|
|
6826
|
+
const linkPath = join5(binDir, link.name);
|
|
6735
6827
|
await replaceSymlink(linkPath, link.target);
|
|
6736
6828
|
return linkPath;
|
|
6737
6829
|
}
|
|
6738
6830
|
async function isFile(path) {
|
|
6739
6831
|
try {
|
|
6740
|
-
return (await
|
|
6832
|
+
return (await stat2(path)).isFile();
|
|
6741
6833
|
} catch (error) {
|
|
6742
6834
|
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
6743
6835
|
return false;
|
|
6744
6836
|
throw error;
|
|
6745
6837
|
}
|
|
6746
6838
|
}
|
|
6747
|
-
async function
|
|
6839
|
+
async function isFileSystemEntry2(path) {
|
|
6748
6840
|
try {
|
|
6749
|
-
await
|
|
6841
|
+
await stat2(path);
|
|
6750
6842
|
return true;
|
|
6751
6843
|
} catch (error) {
|
|
6752
6844
|
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
@@ -6760,23 +6852,23 @@ async function discoverPackageBins(root) {
|
|
|
6760
6852
|
return links;
|
|
6761
6853
|
}
|
|
6762
6854
|
async function collectPackageBins(directory, root, links) {
|
|
6763
|
-
const entries = await
|
|
6855
|
+
const entries = await readdir2(directory, { withFileTypes: true });
|
|
6764
6856
|
if (entries.some((entry) => entry.isFile() && entry.name === "package.json")) {
|
|
6765
|
-
await appendPackageBinLinks(
|
|
6857
|
+
await appendPackageBinLinks(join5(directory, "package.json"), directory, root, links);
|
|
6766
6858
|
}
|
|
6767
6859
|
for (const entry of entries) {
|
|
6768
6860
|
if (!entry.isDirectory())
|
|
6769
6861
|
continue;
|
|
6770
6862
|
if (entry.name === "node_modules" || entry.name === ".git" || entry.name === "dist")
|
|
6771
6863
|
continue;
|
|
6772
|
-
const childPath =
|
|
6864
|
+
const childPath = join5(directory, entry.name);
|
|
6773
6865
|
if (!childPath.startsWith(root))
|
|
6774
6866
|
continue;
|
|
6775
6867
|
await collectPackageBins(childPath, root, links);
|
|
6776
6868
|
}
|
|
6777
6869
|
}
|
|
6778
6870
|
async function appendPackageBinLinks(packageJsonPath, packageRoot, root, links) {
|
|
6779
|
-
const packageJson = JSON.parse(await
|
|
6871
|
+
const packageJson = JSON.parse(await readFile3(packageJsonPath, "utf8"));
|
|
6780
6872
|
if (!isPlainRecord(packageJson))
|
|
6781
6873
|
return;
|
|
6782
6874
|
const packageName = packageJson.name;
|
|
@@ -6811,10 +6903,10 @@ function isReservedNestedBinName(name, packageRoot, root) {
|
|
|
6811
6903
|
function resolvePackageBinTarget(packageRoot, target) {
|
|
6812
6904
|
if (target.includes("\x00"))
|
|
6813
6905
|
throw new Error("Package bin target must stay inside package root");
|
|
6814
|
-
const root =
|
|
6815
|
-
const resolvedTarget =
|
|
6906
|
+
const root = resolve2(packageRoot);
|
|
6907
|
+
const resolvedTarget = resolve2(root, target);
|
|
6816
6908
|
const relativeTarget = relative(root, resolvedTarget);
|
|
6817
|
-
if (relativeTarget === "" || relativeTarget !== ".." && !relativeTarget.startsWith(`..${sep}`) && !
|
|
6909
|
+
if (relativeTarget === "" || relativeTarget !== ".." && !relativeTarget.startsWith(`..${sep}`) && !isAbsolute2(relativeTarget)) {
|
|
6818
6910
|
return resolvedTarget;
|
|
6819
6911
|
}
|
|
6820
6912
|
throw new Error("Package bin target must stay inside package root");
|
|
@@ -6822,7 +6914,7 @@ function resolvePackageBinTarget(packageRoot, target) {
|
|
|
6822
6914
|
async function replaceSymlink(linkPath, targetPath) {
|
|
6823
6915
|
if (await existingNonSymlink(linkPath))
|
|
6824
6916
|
throw new Error(`${linkPath} already exists and is not a symlink`);
|
|
6825
|
-
await
|
|
6917
|
+
await rm3(linkPath, { force: true });
|
|
6826
6918
|
await symlink(targetPath, linkPath);
|
|
6827
6919
|
}
|
|
6828
6920
|
async function replaceCommandShim(linkPath, targetPath) {
|
|
@@ -6833,17 +6925,17 @@ async function replaceCommandShim(linkPath, targetPath) {
|
|
|
6833
6925
|
async function replaceRuntimeWrapper(linkPath, content) {
|
|
6834
6926
|
if (await existingNonRuntimeWrapper(linkPath))
|
|
6835
6927
|
throw new Error(`${linkPath} already exists and is not a generated OMO runtime wrapper`);
|
|
6836
|
-
await
|
|
6928
|
+
await rm3(linkPath, { force: true });
|
|
6837
6929
|
await writeFile(linkPath, content);
|
|
6838
6930
|
}
|
|
6839
6931
|
async function existingNonRuntimeWrapper(path) {
|
|
6840
6932
|
try {
|
|
6841
|
-
const
|
|
6842
|
-
if (
|
|
6933
|
+
const stat3 = await lstat4(path);
|
|
6934
|
+
if (stat3.isSymbolicLink())
|
|
6843
6935
|
return false;
|
|
6844
|
-
if (!
|
|
6936
|
+
if (!stat3.isFile())
|
|
6845
6937
|
return true;
|
|
6846
|
-
const content = await
|
|
6938
|
+
const content = await readFile3(path, "utf8");
|
|
6847
6939
|
return !content.includes(RUNTIME_WRAPPER_MARKER);
|
|
6848
6940
|
} catch (error) {
|
|
6849
6941
|
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
@@ -6853,10 +6945,10 @@ async function existingNonRuntimeWrapper(path) {
|
|
|
6853
6945
|
}
|
|
6854
6946
|
async function existingNonShim(path) {
|
|
6855
6947
|
try {
|
|
6856
|
-
const
|
|
6857
|
-
if (!
|
|
6948
|
+
const stat3 = await lstat4(path);
|
|
6949
|
+
if (!stat3.isFile())
|
|
6858
6950
|
return true;
|
|
6859
|
-
const content = await
|
|
6951
|
+
const content = await readFile3(path, "utf8");
|
|
6860
6952
|
if (content.includes(COMMAND_SHIM_MARKER))
|
|
6861
6953
|
return false;
|
|
6862
6954
|
throw new Error(`${path} already exists and is not a generated command shim`);
|
|
@@ -6868,10 +6960,10 @@ async function existingNonShim(path) {
|
|
|
6868
6960
|
}
|
|
6869
6961
|
async function existingNonSymlink(path) {
|
|
6870
6962
|
try {
|
|
6871
|
-
const
|
|
6872
|
-
if (!
|
|
6963
|
+
const stat3 = await lstat4(path);
|
|
6964
|
+
if (!stat3.isSymbolicLink())
|
|
6873
6965
|
return true;
|
|
6874
|
-
await
|
|
6966
|
+
await readlink3(path);
|
|
6875
6967
|
return false;
|
|
6876
6968
|
} catch (error) {
|
|
6877
6969
|
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
@@ -6880,12 +6972,12 @@ async function existingNonSymlink(path) {
|
|
|
6880
6972
|
}
|
|
6881
6973
|
}
|
|
6882
6974
|
// packages/omo-codex/src/install/codex-cache-install.ts
|
|
6883
|
-
import { cp as cp2, mkdir as mkdir3, readFile as
|
|
6884
|
-
import { basename as basename3, dirname as
|
|
6975
|
+
import { cp as cp2, mkdir as mkdir3, readFile as readFile8, readdir as readdir4, rename, rm as rm4 } from "node:fs/promises";
|
|
6976
|
+
import { basename as basename3, dirname as dirname5, join as join12, sep as sep5 } from "node:path";
|
|
6885
6977
|
|
|
6886
6978
|
// packages/omo-codex/src/install/codex-cache-bundled-mcps.ts
|
|
6887
|
-
import { cp, mkdir as mkdir2, readFile as
|
|
6888
|
-
import { dirname, join as
|
|
6979
|
+
import { cp, mkdir as mkdir2, readFile as readFile4, stat as stat3 } from "node:fs/promises";
|
|
6980
|
+
import { dirname as dirname2, join as join6, resolve as resolve3 } from "node:path";
|
|
6889
6981
|
var BUNDLED_MCP_RUNTIMES = [
|
|
6890
6982
|
{
|
|
6891
6983
|
label: "Git Bash MCP",
|
|
@@ -6903,7 +6995,7 @@ var BUNDLED_MCP_RUNTIMES = [
|
|
|
6903
6995
|
}
|
|
6904
6996
|
];
|
|
6905
6997
|
async function copyBundledMcpRuntimeDists(input) {
|
|
6906
|
-
const sourceArgs = await readSourceMcpArgs(
|
|
6998
|
+
const sourceArgs = await readSourceMcpArgs(join6(input.sourceRoot, ".mcp.json"));
|
|
6907
6999
|
for (const runtime3 of BUNDLED_MCP_RUNTIMES) {
|
|
6908
7000
|
if (!sourceArgs.has(runtime3.sourceArg))
|
|
6909
7001
|
continue;
|
|
@@ -6912,21 +7004,21 @@ async function copyBundledMcpRuntimeDists(input) {
|
|
|
6912
7004
|
}
|
|
6913
7005
|
function resolveBundledMcpRuntimeArg(pluginRoot, arg) {
|
|
6914
7006
|
const runtime3 = BUNDLED_MCP_RUNTIMES.find((candidate) => candidate.sourceArg === arg);
|
|
6915
|
-
return runtime3 ?
|
|
7007
|
+
return runtime3 ? join6(pluginRoot, runtime3.destinationArg) : null;
|
|
6916
7008
|
}
|
|
6917
7009
|
async function copyBundledMcpRuntimeDist(pluginRoot, sourceRoot, runtime3) {
|
|
6918
|
-
const sourcePath =
|
|
7010
|
+
const sourcePath = resolve3(sourceRoot, runtime3.sourceDistFromPlugin);
|
|
6919
7011
|
if (!await isDirectory(sourcePath)) {
|
|
6920
7012
|
throw new Error(`missing built ${runtime3.label} dist at ${sourcePath}`);
|
|
6921
7013
|
}
|
|
6922
|
-
const destinationPath =
|
|
6923
|
-
await mkdir2(
|
|
7014
|
+
const destinationPath = join6(pluginRoot, runtime3.destinationDistFromPlugin);
|
|
7015
|
+
await mkdir2(dirname2(destinationPath), { recursive: true });
|
|
6924
7016
|
await cp(sourcePath, destinationPath, { recursive: true });
|
|
6925
7017
|
}
|
|
6926
7018
|
async function readSourceMcpArgs(path) {
|
|
6927
7019
|
let parsed;
|
|
6928
7020
|
try {
|
|
6929
|
-
parsed = JSON.parse(await
|
|
7021
|
+
parsed = JSON.parse(await readFile4(path, "utf8"));
|
|
6930
7022
|
} catch (error) {
|
|
6931
7023
|
if (error instanceof Error)
|
|
6932
7024
|
return new Set;
|
|
@@ -6947,7 +7039,7 @@ async function readSourceMcpArgs(path) {
|
|
|
6947
7039
|
}
|
|
6948
7040
|
async function isDirectory(path) {
|
|
6949
7041
|
try {
|
|
6950
|
-
return (await
|
|
7042
|
+
return (await stat3(path)).isDirectory();
|
|
6951
7043
|
} catch (error) {
|
|
6952
7044
|
if (error instanceof Error)
|
|
6953
7045
|
return false;
|
|
@@ -6957,20 +7049,20 @@ async function isDirectory(path) {
|
|
|
6957
7049
|
|
|
6958
7050
|
// packages/omo-codex/src/install/codex-cache-local-dependencies.ts
|
|
6959
7051
|
import { realpathSync } from "node:fs";
|
|
6960
|
-
import { readFile as
|
|
6961
|
-
import { dirname as
|
|
7052
|
+
import { readFile as readFile5, readdir as readdir3, writeFile as writeFile2 } from "node:fs/promises";
|
|
7053
|
+
import { dirname as dirname3, isAbsolute as isAbsolute4, join as join8, relative as relative3, resolve as resolve5, sep as sep2 } from "node:path";
|
|
6962
7054
|
|
|
6963
7055
|
// packages/omo-codex/src/install/codex-cache-paths.ts
|
|
6964
|
-
import { isAbsolute as
|
|
7056
|
+
import { isAbsolute as isAbsolute3, join as join7, relative as relative2, resolve as resolve4 } from "node:path";
|
|
6965
7057
|
function resolveCachedRuntimePath(pluginRoot, sourceRoot, runtimePath) {
|
|
6966
|
-
const targetPath =
|
|
7058
|
+
const targetPath = resolve4(pluginRoot, runtimePath);
|
|
6967
7059
|
if (isPathInside(targetPath, pluginRoot))
|
|
6968
7060
|
return targetPath;
|
|
6969
|
-
return
|
|
7061
|
+
return resolve4(sourceRoot, runtimePath);
|
|
6970
7062
|
}
|
|
6971
7063
|
function isPathInside(candidatePath, rootPath) {
|
|
6972
7064
|
const pathFromRoot = relative2(rootPath, candidatePath);
|
|
6973
|
-
return pathFromRoot === "" || !pathFromRoot.startsWith("..") && !
|
|
7065
|
+
return pathFromRoot === "" || !pathFromRoot.startsWith("..") && !isAbsolute3(pathFromRoot);
|
|
6974
7066
|
}
|
|
6975
7067
|
|
|
6976
7068
|
// packages/omo-codex/src/install/codex-cache-local-dependencies.ts
|
|
@@ -6979,12 +7071,12 @@ async function rewriteCachedPackageLocalFileDependencies(pluginRoot, sourceRoot)
|
|
|
6979
7071
|
await collectPackageJsonPaths(pluginRoot, pluginRoot, packageJsonPaths);
|
|
6980
7072
|
const packageLock = await readPackageLock(pluginRoot);
|
|
6981
7073
|
for (const packageJsonPath of packageJsonPaths) {
|
|
6982
|
-
const raw = await
|
|
7074
|
+
const raw = await readFile5(packageJsonPath, "utf8");
|
|
6983
7075
|
const parsed = JSON.parse(raw);
|
|
6984
7076
|
if (!isPlainRecord(parsed))
|
|
6985
7077
|
continue;
|
|
6986
|
-
const packageDir =
|
|
6987
|
-
const sourcePackageDir =
|
|
7078
|
+
const packageDir = dirname3(packageJsonPath);
|
|
7079
|
+
const sourcePackageDir = join8(sourceRoot, relative3(pluginRoot, packageDir));
|
|
6988
7080
|
let changed = false;
|
|
6989
7081
|
for (const field of ["dependencies", "optionalDependencies", "peerDependencies"]) {
|
|
6990
7082
|
const dependencies = parsed[field];
|
|
@@ -6994,12 +7086,12 @@ async function rewriteCachedPackageLocalFileDependencies(pluginRoot, sourceRoot)
|
|
|
6994
7086
|
if (typeof specifier !== "string" || !specifier.startsWith("file:"))
|
|
6995
7087
|
continue;
|
|
6996
7088
|
const filePath = specifier.slice("file:".length);
|
|
6997
|
-
if (filePath.length === 0 ||
|
|
7089
|
+
if (filePath.length === 0 || isAbsolute4(filePath))
|
|
6998
7090
|
continue;
|
|
6999
|
-
const targetPath =
|
|
7091
|
+
const targetPath = resolve5(packageDir, filePath);
|
|
7000
7092
|
if (isPathInside(targetPath, pluginRoot))
|
|
7001
7093
|
continue;
|
|
7002
|
-
const sourceTargetPath =
|
|
7094
|
+
const sourceTargetPath = resolve5(sourcePackageDir, filePath);
|
|
7003
7095
|
dependencies[name] = `file:${sourceTargetPath}`;
|
|
7004
7096
|
rewritePackageLockFileDependency({
|
|
7005
7097
|
dependencyName: name,
|
|
@@ -7022,9 +7114,9 @@ async function rewriteCachedPackageLocalFileDependencies(pluginRoot, sourceRoot)
|
|
|
7022
7114
|
`);
|
|
7023
7115
|
}
|
|
7024
7116
|
async function readPackageLock(pluginRoot) {
|
|
7025
|
-
const path =
|
|
7117
|
+
const path = join8(pluginRoot, "package-lock.json");
|
|
7026
7118
|
try {
|
|
7027
|
-
const parsed = JSON.parse(await
|
|
7119
|
+
const parsed = JSON.parse(await readFile5(path, "utf8"));
|
|
7028
7120
|
return { path, value: isPlainRecord(parsed) ? parsed : null, changed: false };
|
|
7029
7121
|
} catch (error) {
|
|
7030
7122
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -7081,16 +7173,16 @@ function canonicalizeExistingPath(path) {
|
|
|
7081
7173
|
}
|
|
7082
7174
|
}
|
|
7083
7175
|
async function collectPackageJsonPaths(directory, root, paths) {
|
|
7084
|
-
const entries = await
|
|
7176
|
+
const entries = await readdir3(directory, { withFileTypes: true });
|
|
7085
7177
|
if (entries.some((entry) => entry.isFile() && entry.name === "package.json")) {
|
|
7086
|
-
paths.push(
|
|
7178
|
+
paths.push(join8(directory, "package.json"));
|
|
7087
7179
|
}
|
|
7088
7180
|
for (const entry of entries) {
|
|
7089
7181
|
if (!entry.isDirectory())
|
|
7090
7182
|
continue;
|
|
7091
7183
|
if (entry.name === "node_modules" || entry.name === ".git" || entry.name === "dist")
|
|
7092
7184
|
continue;
|
|
7093
|
-
const childPath =
|
|
7185
|
+
const childPath = join8(directory, entry.name);
|
|
7094
7186
|
if (!isPathInside(childPath, root))
|
|
7095
7187
|
continue;
|
|
7096
7188
|
await collectPackageJsonPaths(childPath, root, paths);
|
|
@@ -7098,13 +7190,13 @@ async function collectPackageJsonPaths(directory, root, paths) {
|
|
|
7098
7190
|
}
|
|
7099
7191
|
|
|
7100
7192
|
// packages/omo-codex/src/install/codex-cache-mcp-manifest.ts
|
|
7101
|
-
import { readFile as
|
|
7102
|
-
import { join as
|
|
7193
|
+
import { readFile as readFile6, writeFile as writeFile3 } from "node:fs/promises";
|
|
7194
|
+
import { join as join10, sep as sep3 } from "node:path";
|
|
7103
7195
|
|
|
7104
7196
|
// packages/utils/src/codegraph/resolve.ts
|
|
7105
7197
|
import { existsSync as existsSync2 } from "node:fs";
|
|
7106
7198
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
7107
|
-
import { basename as basename2, dirname as
|
|
7199
|
+
import { basename as basename2, dirname as dirname4, join as join9 } from "node:path";
|
|
7108
7200
|
import { createRequire } from "node:module";
|
|
7109
7201
|
|
|
7110
7202
|
// packages/utils/src/codegraph/node-support.ts
|
|
@@ -7219,10 +7311,10 @@ function resolveCodegraphNodeSupport(options = {}) {
|
|
|
7219
7311
|
var CODEGRAPH_RELATIVE_ARGS = new Set(["components/codegraph/dist/serve.js", "./components/codegraph/dist/serve.js"]);
|
|
7220
7312
|
var CONTEXT7_API_KEY_ENV = "CONTEXT7_API_KEY";
|
|
7221
7313
|
async function rewriteCachedMcpManifest(pluginRoot, sourceRoot = pluginRoot, options = {}) {
|
|
7222
|
-
const manifestPath =
|
|
7314
|
+
const manifestPath = join10(pluginRoot, ".mcp.json");
|
|
7223
7315
|
if (!await fileExistsStrict(manifestPath))
|
|
7224
7316
|
return;
|
|
7225
|
-
const raw = await
|
|
7317
|
+
const raw = await readFile6(manifestPath, "utf8");
|
|
7226
7318
|
const parsed = JSON.parse(raw);
|
|
7227
7319
|
if (!isPlainRecord(parsed) || !isPlainRecord(parsed.mcpServers))
|
|
7228
7320
|
return;
|
|
@@ -7243,7 +7335,7 @@ async function rewriteCachedMcpManifest(pluginRoot, sourceRoot = pluginRoot, opt
|
|
|
7243
7335
|
if (bundledMcpRuntimeArg !== null)
|
|
7244
7336
|
return bundledMcpRuntimeArg;
|
|
7245
7337
|
if (CODEGRAPH_RELATIVE_ARGS.has(arg))
|
|
7246
|
-
return
|
|
7338
|
+
return join10(pluginRoot, "components", "codegraph", "dist", "serve.js");
|
|
7247
7339
|
if (arg.startsWith("./") || arg.startsWith("../"))
|
|
7248
7340
|
return resolveCachedRuntimePath(pluginRoot, sourceRoot, arg);
|
|
7249
7341
|
return arg;
|
|
@@ -7323,10 +7415,10 @@ function isPlaceholderContext7ApiKey(value) {
|
|
|
7323
7415
|
return normalized.length === 0 || normalized === "your api key";
|
|
7324
7416
|
}
|
|
7325
7417
|
async function rewriteCachedManifestRoot(pluginRoot, fromRoot, toRoot) {
|
|
7326
|
-
const manifestPath =
|
|
7418
|
+
const manifestPath = join10(pluginRoot, ".mcp.json");
|
|
7327
7419
|
if (!await fileExistsStrict(manifestPath))
|
|
7328
7420
|
return;
|
|
7329
|
-
const raw = await
|
|
7421
|
+
const raw = await readFile6(manifestPath, "utf8");
|
|
7330
7422
|
const parsed = JSON.parse(raw);
|
|
7331
7423
|
if (!isPlainRecord(parsed) || !isPlainRecord(parsed.mcpServers))
|
|
7332
7424
|
return;
|
|
@@ -7358,15 +7450,15 @@ async function rewriteCachedManifestRoot(pluginRoot, fromRoot, toRoot) {
|
|
|
7358
7450
|
}
|
|
7359
7451
|
|
|
7360
7452
|
// packages/omo-codex/src/install/codex-hook-targets.ts
|
|
7361
|
-
import { readFile as
|
|
7362
|
-
import { join as
|
|
7453
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
7454
|
+
import { join as join11, sep as sep4 } from "node:path";
|
|
7363
7455
|
var PLUGIN_ROOT_TARGET_PATTERN = /\$\{PLUGIN_ROOT\}[\\/]+([^"']+)/g;
|
|
7364
7456
|
async function findMissingHookCommandTargets(pluginRoot) {
|
|
7365
7457
|
const commands = [];
|
|
7366
7458
|
for (const manifestPath of await hookManifestPaths(pluginRoot)) {
|
|
7367
7459
|
if (!await fileExistsStrict(manifestPath))
|
|
7368
7460
|
continue;
|
|
7369
|
-
const parsed = JSON.parse(await
|
|
7461
|
+
const parsed = JSON.parse(await readFile7(manifestPath, "utf8"));
|
|
7370
7462
|
collectCommands(parsed, commands);
|
|
7371
7463
|
}
|
|
7372
7464
|
const missing = [];
|
|
@@ -7376,7 +7468,7 @@ async function findMissingHookCommandTargets(pluginRoot) {
|
|
|
7376
7468
|
const targetSuffix = match[1];
|
|
7377
7469
|
if (targetSuffix === undefined)
|
|
7378
7470
|
continue;
|
|
7379
|
-
const target =
|
|
7471
|
+
const target = join11(pluginRoot, ...targetSuffix.split(/[\\/]+/));
|
|
7380
7472
|
if (seen.has(target))
|
|
7381
7473
|
continue;
|
|
7382
7474
|
seen.add(target);
|
|
@@ -7387,17 +7479,17 @@ async function findMissingHookCommandTargets(pluginRoot) {
|
|
|
7387
7479
|
return missing;
|
|
7388
7480
|
}
|
|
7389
7481
|
async function hookManifestPaths(pluginRoot) {
|
|
7390
|
-
const pluginManifestPath =
|
|
7482
|
+
const pluginManifestPath = join11(pluginRoot, ".codex-plugin", "plugin.json");
|
|
7391
7483
|
if (!await fileExistsStrict(pluginManifestPath))
|
|
7392
|
-
return [
|
|
7393
|
-
const parsed = JSON.parse(await
|
|
7484
|
+
return [join11(pluginRoot, "hooks", "hooks.json")];
|
|
7485
|
+
const parsed = JSON.parse(await readFile7(pluginManifestPath, "utf8"));
|
|
7394
7486
|
if (!isPlainRecord(parsed))
|
|
7395
7487
|
return [];
|
|
7396
7488
|
if (typeof parsed.hooks === "string" && parsed.hooks.trim() !== "") {
|
|
7397
|
-
return [
|
|
7489
|
+
return [join11(pluginRoot, stripDotSlash(parsed.hooks))];
|
|
7398
7490
|
}
|
|
7399
7491
|
if (Array.isArray(parsed.hooks)) {
|
|
7400
|
-
return parsed.hooks.filter((hookPath) => typeof hookPath === "string" && hookPath.trim() !== "").map((hookPath) =>
|
|
7492
|
+
return parsed.hooks.filter((hookPath) => typeof hookPath === "string" && hookPath.trim() !== "").map((hookPath) => join11(pluginRoot, stripDotSlash(hookPath)));
|
|
7401
7493
|
}
|
|
7402
7494
|
return [];
|
|
7403
7495
|
}
|
|
@@ -7433,9 +7525,9 @@ async function installCachedPlugin(input) {
|
|
|
7433
7525
|
await maybeRunNpmInstall(input.sourcePath, input.runCommand);
|
|
7434
7526
|
await maybeRunNpmBuild(input.sourcePath, input.runCommand);
|
|
7435
7527
|
}
|
|
7436
|
-
const targetPath =
|
|
7528
|
+
const targetPath = join12(input.codexHome, "plugins", "cache", input.marketplaceName, input.name, input.version);
|
|
7437
7529
|
const tempPath = createTempSiblingPath(targetPath);
|
|
7438
|
-
await
|
|
7530
|
+
await rm4(tempPath, { recursive: true, force: true });
|
|
7439
7531
|
try {
|
|
7440
7532
|
await copyDirectory(input.sourcePath, tempPath);
|
|
7441
7533
|
await rewriteCachedPackageLocalFileDependencies(tempPath, input.sourcePath);
|
|
@@ -7451,20 +7543,20 @@ async function installCachedPlugin(input) {
|
|
|
7451
7543
|
await assertHookCommandTargets(tempPath);
|
|
7452
7544
|
await promoteDirectory(tempPath, targetPath, input.renameDirectory ?? rename);
|
|
7453
7545
|
} catch (error) {
|
|
7454
|
-
await
|
|
7546
|
+
await rm4(tempPath, { recursive: true, force: true });
|
|
7455
7547
|
throw error;
|
|
7456
7548
|
}
|
|
7457
7549
|
return { name: input.name, version: input.version, path: targetPath };
|
|
7458
7550
|
}
|
|
7459
7551
|
async function maybeRunNpmInstall(cwd, runCommand, args = ["install"]) {
|
|
7460
|
-
if (!await fileExistsStrict(
|
|
7552
|
+
if (!await fileExistsStrict(join12(cwd, "package.json")))
|
|
7461
7553
|
return;
|
|
7462
7554
|
await runCommand("npm", args, { cwd });
|
|
7463
7555
|
}
|
|
7464
7556
|
async function maybeRunNpmBuild(cwd, runCommand) {
|
|
7465
|
-
if (!await fileExistsStrict(
|
|
7557
|
+
if (!await fileExistsStrict(join12(cwd, "package.json")))
|
|
7466
7558
|
return;
|
|
7467
|
-
const packageJson = JSON.parse(await
|
|
7559
|
+
const packageJson = JSON.parse(await readFile8(join12(cwd, "package.json"), "utf8"));
|
|
7468
7560
|
if (!isPlainRecord(packageJson))
|
|
7469
7561
|
return;
|
|
7470
7562
|
const scripts = packageJson.scripts;
|
|
@@ -7473,9 +7565,9 @@ async function maybeRunNpmBuild(cwd, runCommand) {
|
|
|
7473
7565
|
await runCommand("npm", ["run", "build"], { cwd });
|
|
7474
7566
|
}
|
|
7475
7567
|
async function maybeRunNpmSyncSkills(cwd, runCommand) {
|
|
7476
|
-
if (!await fileExistsStrict(
|
|
7568
|
+
if (!await fileExistsStrict(join12(cwd, "package.json")))
|
|
7477
7569
|
return;
|
|
7478
|
-
const packageJson = JSON.parse(await
|
|
7570
|
+
const packageJson = JSON.parse(await readFile8(join12(cwd, "package.json"), "utf8"));
|
|
7479
7571
|
if (!isPlainRecord(packageJson))
|
|
7480
7572
|
return;
|
|
7481
7573
|
const scripts = packageJson.scripts;
|
|
@@ -7484,18 +7576,18 @@ async function maybeRunNpmSyncSkills(cwd, runCommand) {
|
|
|
7484
7576
|
await runCommand("npm", ["run", "sync:skills"], { cwd });
|
|
7485
7577
|
}
|
|
7486
7578
|
function createTempSiblingPath(targetPath) {
|
|
7487
|
-
return
|
|
7579
|
+
return join12(dirname5(targetPath), `.tmp-${basename3(targetPath)}-${process.pid}-${Date.now()}`);
|
|
7488
7580
|
}
|
|
7489
7581
|
function createBackupSiblingPath(targetPath) {
|
|
7490
|
-
return
|
|
7582
|
+
return join12(dirname5(targetPath), `.backup-${basename3(targetPath)}-${process.pid}-${Date.now()}`);
|
|
7491
7583
|
}
|
|
7492
7584
|
async function copyDirectory(sourcePath, targetPath) {
|
|
7493
|
-
await mkdir3(
|
|
7585
|
+
await mkdir3(dirname5(targetPath), { recursive: true });
|
|
7494
7586
|
await cp2(sourcePath, targetPath, { recursive: true, filter: (source) => shouldCopyPluginPath(source, sourcePath) });
|
|
7495
7587
|
}
|
|
7496
7588
|
async function promoteDirectory(tempPath, targetPath, renameDirectory) {
|
|
7497
7589
|
const backupPath = createBackupSiblingPath(targetPath);
|
|
7498
|
-
await
|
|
7590
|
+
await rm4(backupPath, { recursive: true, force: true });
|
|
7499
7591
|
let backupMoved = false;
|
|
7500
7592
|
try {
|
|
7501
7593
|
if (await fileExistsStrict(targetPath)) {
|
|
@@ -7509,12 +7601,12 @@ async function promoteDirectory(tempPath, targetPath, renameDirectory) {
|
|
|
7509
7601
|
throw error;
|
|
7510
7602
|
}
|
|
7511
7603
|
if (backupMoved)
|
|
7512
|
-
await
|
|
7604
|
+
await rm4(backupPath, { recursive: true, force: true });
|
|
7513
7605
|
}
|
|
7514
7606
|
async function restoreBackupDirectory(backupPath, targetPath, renameDirectory) {
|
|
7515
7607
|
if (!await fileExistsStrict(backupPath))
|
|
7516
7608
|
return;
|
|
7517
|
-
await
|
|
7609
|
+
await rm4(targetPath, { recursive: true, force: true });
|
|
7518
7610
|
await renameDirectory(backupPath, targetPath);
|
|
7519
7611
|
}
|
|
7520
7612
|
function shouldCopyPluginPath(path, root) {
|
|
@@ -7530,18 +7622,18 @@ var removedSparkshellPromptSurfaceFiles = new Set(["directive.md", "plugin.json"
|
|
|
7530
7622
|
var removedSparkshellTextFilePattern = /\.(?:json|md|toml|ya?ml)$/i;
|
|
7531
7623
|
async function assertNoRemovedSparkshellPromptReferences(pluginRoot) {
|
|
7532
7624
|
for (const filePath of await listRemovedSparkshellPromptSurfaceFiles(pluginRoot, "")) {
|
|
7533
|
-
const content = await
|
|
7625
|
+
const content = await readFile8(join12(pluginRoot, filePath), "utf8");
|
|
7534
7626
|
if (!removedSparkshellReferencePattern.test(content))
|
|
7535
7627
|
continue;
|
|
7536
7628
|
throw new Error(`removed sparkshell reference found in Codex plugin prompt surface: ${filePath}`);
|
|
7537
7629
|
}
|
|
7538
7630
|
}
|
|
7539
7631
|
async function listRemovedSparkshellPromptSurfaceFiles(pluginRoot, relativeDirectory) {
|
|
7540
|
-
const directory = relativeDirectory === "" ? pluginRoot :
|
|
7541
|
-
const entries = await
|
|
7632
|
+
const directory = relativeDirectory === "" ? pluginRoot : join12(pluginRoot, relativeDirectory);
|
|
7633
|
+
const entries = await readdir4(directory, { withFileTypes: true });
|
|
7542
7634
|
const files = [];
|
|
7543
7635
|
for (const entry of entries) {
|
|
7544
|
-
const relativePath = relativeDirectory === "" ? entry.name :
|
|
7636
|
+
const relativePath = relativeDirectory === "" ? entry.name : join12(relativeDirectory, entry.name);
|
|
7545
7637
|
if (entry.isDirectory()) {
|
|
7546
7638
|
if (shouldDescendIntoRemovedSparkshellPromptSurface(relativePath)) {
|
|
7547
7639
|
files.push(...await listRemovedSparkshellPromptSurfaceFiles(pluginRoot, relativePath));
|
|
@@ -7581,29 +7673,29 @@ async function copyRootRuntimeDists(input) {
|
|
|
7581
7673
|
if (repoRoot === null)
|
|
7582
7674
|
return;
|
|
7583
7675
|
for (const runtimePath of ["dist/cli", "dist/cli-node"]) {
|
|
7584
|
-
const sourcePath =
|
|
7585
|
-
if (!await fileExistsStrict(
|
|
7676
|
+
const sourcePath = join12(repoRoot, runtimePath);
|
|
7677
|
+
if (!await fileExistsStrict(join12(sourcePath, "index.js")))
|
|
7586
7678
|
continue;
|
|
7587
|
-
await mkdir3(
|
|
7588
|
-
await cp2(sourcePath,
|
|
7679
|
+
await mkdir3(dirname5(join12(input.pluginRoot, runtimePath)), { recursive: true });
|
|
7680
|
+
await cp2(sourcePath, join12(input.pluginRoot, runtimePath), { recursive: true });
|
|
7589
7681
|
}
|
|
7590
7682
|
}
|
|
7591
7683
|
function repoRootForCodexPluginSource(sourcePath) {
|
|
7592
|
-
const codexPackageRoot =
|
|
7593
|
-
const packagesRoot =
|
|
7684
|
+
const codexPackageRoot = dirname5(sourcePath);
|
|
7685
|
+
const packagesRoot = dirname5(codexPackageRoot);
|
|
7594
7686
|
if (basename3(sourcePath) !== "plugin")
|
|
7595
7687
|
return null;
|
|
7596
7688
|
if (basename3(codexPackageRoot) !== "omo-codex")
|
|
7597
7689
|
return null;
|
|
7598
7690
|
if (basename3(packagesRoot) !== "packages")
|
|
7599
7691
|
return null;
|
|
7600
|
-
return
|
|
7692
|
+
return dirname5(packagesRoot);
|
|
7601
7693
|
}
|
|
7602
7694
|
// packages/omo-codex/src/install/codex-cache-prune.ts
|
|
7603
|
-
import { lstat as
|
|
7604
|
-
import { join as
|
|
7695
|
+
import { lstat as lstat5, readdir as readdir5, rm as rm5, stat as stat4 } from "node:fs/promises";
|
|
7696
|
+
import { join as join13 } from "node:path";
|
|
7605
7697
|
async function pruneMarketplaceCache(input) {
|
|
7606
|
-
const cacheRoot =
|
|
7698
|
+
const cacheRoot = join13(input.codexHome, "plugins", "cache", input.marketplaceName);
|
|
7607
7699
|
if (!await fileExistsStrict(cacheRoot))
|
|
7608
7700
|
return;
|
|
7609
7701
|
const keep = new Set(input.keepPluginNames);
|
|
@@ -7611,28 +7703,28 @@ async function pruneMarketplaceCache(input) {
|
|
|
7611
7703
|
for (const entry of entries) {
|
|
7612
7704
|
if (!entry.isDirectory() || keep.has(entry.name))
|
|
7613
7705
|
continue;
|
|
7614
|
-
await
|
|
7706
|
+
await rm5(join13(cacheRoot, entry.name), { recursive: true, force: true });
|
|
7615
7707
|
}
|
|
7616
7708
|
}
|
|
7617
7709
|
async function pruneMarketplacePluginCaches(input) {
|
|
7618
|
-
const cacheRoot =
|
|
7710
|
+
const cacheRoot = join13(input.codexHome, "plugins", "cache", input.marketplaceName);
|
|
7619
7711
|
if (!await fileExistsStrict(cacheRoot))
|
|
7620
7712
|
return;
|
|
7621
7713
|
for (const pluginName of input.pluginNames) {
|
|
7622
|
-
await
|
|
7714
|
+
await rm5(join13(cacheRoot, pluginName), { recursive: true, force: true });
|
|
7623
7715
|
}
|
|
7624
7716
|
const remainingEntries = await readCacheEntryNames(cacheRoot);
|
|
7625
7717
|
if (remainingEntries.length === 0) {
|
|
7626
|
-
await
|
|
7718
|
+
await rm5(cacheRoot, { recursive: true, force: true });
|
|
7627
7719
|
}
|
|
7628
7720
|
}
|
|
7629
7721
|
async function readCacheEntries(path) {
|
|
7630
7722
|
const emptyEntries = [];
|
|
7631
|
-
return readCacheRoot(path, () =>
|
|
7723
|
+
return readCacheRoot(path, () => readdir5(path, { withFileTypes: true }), emptyEntries);
|
|
7632
7724
|
}
|
|
7633
7725
|
async function readCacheEntryNames(path) {
|
|
7634
7726
|
const emptyNames = [];
|
|
7635
|
-
return readCacheRoot(path, () =>
|
|
7727
|
+
return readCacheRoot(path, () => readdir5(path), emptyNames);
|
|
7636
7728
|
}
|
|
7637
7729
|
async function readCacheRoot(path, readEntries, fallback) {
|
|
7638
7730
|
try {
|
|
@@ -7647,7 +7739,7 @@ async function readCacheRoot(path, readEntries, fallback) {
|
|
|
7647
7739
|
}
|
|
7648
7740
|
async function isBrokenCacheSymlink(path) {
|
|
7649
7741
|
try {
|
|
7650
|
-
const entry = await
|
|
7742
|
+
const entry = await lstat5(path);
|
|
7651
7743
|
if (!entry.isSymbolicLink())
|
|
7652
7744
|
return false;
|
|
7653
7745
|
} catch (error) {
|
|
@@ -7656,7 +7748,7 @@ async function isBrokenCacheSymlink(path) {
|
|
|
7656
7748
|
throw error;
|
|
7657
7749
|
}
|
|
7658
7750
|
try {
|
|
7659
|
-
await
|
|
7751
|
+
await stat4(path);
|
|
7660
7752
|
return false;
|
|
7661
7753
|
} catch (error) {
|
|
7662
7754
|
if (isNodeErrorWithCode(error) && error.code === "ENOENT")
|
|
@@ -7665,25 +7757,47 @@ async function isBrokenCacheSymlink(path) {
|
|
|
7665
7757
|
}
|
|
7666
7758
|
}
|
|
7667
7759
|
// packages/omo-codex/src/install/codex-cached-marketplace-manifest.ts
|
|
7668
|
-
import { mkdir as mkdir4, writeFile as writeFile4 } from "node:fs/promises";
|
|
7669
|
-
import { join as
|
|
7760
|
+
import { mkdir as mkdir4, rename as rename2, rm as rm6, stat as stat5, writeFile as writeFile4 } from "node:fs/promises";
|
|
7761
|
+
import { join as join14 } from "node:path";
|
|
7670
7762
|
async function writeCachedMarketplaceManifest(input) {
|
|
7671
|
-
const marketplaceDir =
|
|
7763
|
+
const marketplaceDir = join14(input.marketplaceRoot, ".agents", "plugins");
|
|
7672
7764
|
await mkdir4(marketplaceDir, { recursive: true });
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7765
|
+
for (const plugin of input.plugins) {
|
|
7766
|
+
const pluginPath = join14(input.marketplaceRoot, plugin.name, plugin.version);
|
|
7767
|
+
if (!await isDirectory2(pluginPath))
|
|
7768
|
+
throw new Error(`Cannot write cached marketplace manifest: ${pluginPath} does not exist`);
|
|
7769
|
+
}
|
|
7770
|
+
const manifestPath = join14(marketplaceDir, "marketplace.json");
|
|
7771
|
+
const tempPath = join14(marketplaceDir, `.marketplace.json.tmp-${process.pid}-${Date.now()}`);
|
|
7772
|
+
try {
|
|
7773
|
+
await writeFile4(tempPath, `${JSON.stringify({
|
|
7774
|
+
name: input.marketplaceName,
|
|
7775
|
+
plugins: input.plugins.map((plugin) => ({
|
|
7776
|
+
name: plugin.name,
|
|
7777
|
+
source: { source: "local", path: `./${plugin.name}/${plugin.version}` }
|
|
7778
|
+
}))
|
|
7779
|
+
}, null, "\t")}
|
|
7680
7780
|
`);
|
|
7781
|
+
await rename2(tempPath, manifestPath);
|
|
7782
|
+
} catch (error) {
|
|
7783
|
+
await rm6(tempPath, { force: true });
|
|
7784
|
+
throw error;
|
|
7785
|
+
}
|
|
7786
|
+
}
|
|
7787
|
+
async function isDirectory2(path) {
|
|
7788
|
+
try {
|
|
7789
|
+
return (await stat5(path)).isDirectory();
|
|
7790
|
+
} catch (error) {
|
|
7791
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
7792
|
+
return false;
|
|
7793
|
+
throw error;
|
|
7794
|
+
}
|
|
7681
7795
|
}
|
|
7682
7796
|
|
|
7683
7797
|
// packages/omo-codex/src/install/codex-package-layout.ts
|
|
7684
7798
|
import { existsSync as existsSync3 } from "node:fs";
|
|
7685
|
-
import { readFile as
|
|
7686
|
-
import { join as
|
|
7799
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
7800
|
+
import { join as join15 } from "node:path";
|
|
7687
7801
|
var PACKAGED_CODEX_INSTALLER_NAMES = new Set([
|
|
7688
7802
|
"@code-yeongyu/lazycodex",
|
|
7689
7803
|
"@code-yeongyu/lazycodex-ai",
|
|
@@ -7693,20 +7807,20 @@ var PACKAGED_CODEX_INSTALLER_NAMES = new Set([
|
|
|
7693
7807
|
"oh-my-openagent"
|
|
7694
7808
|
]);
|
|
7695
7809
|
async function shouldBuildSourcePackages(repoRoot) {
|
|
7696
|
-
if (existsSync3(
|
|
7810
|
+
if (existsSync3(join15(repoRoot, "packages", "omo-opencode", "src", "index.ts")))
|
|
7697
7811
|
return true;
|
|
7698
|
-
const packageJsonPath =
|
|
7812
|
+
const packageJsonPath = join15(repoRoot, "package.json");
|
|
7699
7813
|
if (!existsSync3(packageJsonPath))
|
|
7700
7814
|
return true;
|
|
7701
|
-
const packageJson = JSON.parse(await
|
|
7815
|
+
const packageJson = JSON.parse(await readFile9(packageJsonPath, "utf8"));
|
|
7702
7816
|
if (!isPlainRecord(packageJson) || typeof packageJson.name !== "string")
|
|
7703
7817
|
return true;
|
|
7704
7818
|
return !PACKAGED_CODEX_INSTALLER_NAMES.has(packageJson.name);
|
|
7705
7819
|
}
|
|
7706
7820
|
|
|
7707
7821
|
// packages/omo-codex/src/install/codex-config-toml.ts
|
|
7708
|
-
import { mkdir as mkdir5, readFile as
|
|
7709
|
-
import { dirname as
|
|
7822
|
+
import { mkdir as mkdir5, readFile as readFile11 } from "node:fs/promises";
|
|
7823
|
+
import { dirname as dirname7 } from "node:path";
|
|
7710
7824
|
|
|
7711
7825
|
// packages/omo-codex/src/install/toml-section-editor.ts
|
|
7712
7826
|
function findTomlSection(config, header) {
|
|
@@ -8064,13 +8178,13 @@ function tomlKeySegment(value) {
|
|
|
8064
8178
|
}
|
|
8065
8179
|
|
|
8066
8180
|
// packages/omo-codex/src/install/codex-config-atomic-write.ts
|
|
8067
|
-
import { lstat as
|
|
8068
|
-
import { basename as basename4, dirname as
|
|
8181
|
+
import { lstat as lstat6, readlink as readlink4, realpath, rename as rename3, unlink, writeFile as writeFile5 } from "node:fs/promises";
|
|
8182
|
+
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute5, join as join16, resolve as resolve6 } from "node:path";
|
|
8069
8183
|
var RENAME_RETRY_DELAYS_MS = [10, 25, 50];
|
|
8070
8184
|
var RETRIABLE_RENAME_CODES = new Set(["EPERM", "EBUSY"]);
|
|
8071
8185
|
async function writeFileAtomic(targetPath, data) {
|
|
8072
8186
|
const writeTarget = await resolveSymlinkTarget(targetPath);
|
|
8073
|
-
const temporaryPath =
|
|
8187
|
+
const temporaryPath = join16(dirname6(writeTarget), `.tmp-${basename4(writeTarget)}-${process.pid}-${Date.now()}`);
|
|
8074
8188
|
await writeFile5(temporaryPath, data);
|
|
8075
8189
|
try {
|
|
8076
8190
|
await renameWithRetry(temporaryPath, writeTarget);
|
|
@@ -8085,7 +8199,7 @@ async function writeFileAtomic(targetPath, data) {
|
|
|
8085
8199
|
}
|
|
8086
8200
|
async function resolveSymlinkTarget(targetPath) {
|
|
8087
8201
|
try {
|
|
8088
|
-
const linkStats = await
|
|
8202
|
+
const linkStats = await lstat6(targetPath);
|
|
8089
8203
|
if (!linkStats.isSymbolicLink())
|
|
8090
8204
|
return targetPath;
|
|
8091
8205
|
} catch (error) {
|
|
@@ -8098,14 +8212,14 @@ async function resolveSymlinkTarget(targetPath) {
|
|
|
8098
8212
|
} catch (error) {
|
|
8099
8213
|
if (!(error instanceof Error))
|
|
8100
8214
|
throw error;
|
|
8101
|
-
const linkValue = await
|
|
8102
|
-
return
|
|
8215
|
+
const linkValue = await readlink4(targetPath);
|
|
8216
|
+
return isAbsolute5(linkValue) ? linkValue : resolve6(dirname6(targetPath), linkValue);
|
|
8103
8217
|
}
|
|
8104
8218
|
}
|
|
8105
8219
|
async function renameWithRetry(fromPath, toPath) {
|
|
8106
8220
|
for (let attempt = 0;; attempt += 1) {
|
|
8107
8221
|
try {
|
|
8108
|
-
await
|
|
8222
|
+
await rename3(fromPath, toPath);
|
|
8109
8223
|
return;
|
|
8110
8224
|
} catch (error) {
|
|
8111
8225
|
if (!isRetriableRenameError(error) || attempt >= RENAME_RETRY_DELAYS_MS.length) {
|
|
@@ -8440,8 +8554,8 @@ function isRootSetting(line, key) {
|
|
|
8440
8554
|
}
|
|
8441
8555
|
|
|
8442
8556
|
// packages/omo-codex/src/install/codex-model-catalog.ts
|
|
8443
|
-
import { readFile as
|
|
8444
|
-
import { join as
|
|
8557
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
8558
|
+
import { join as join17 } from "node:path";
|
|
8445
8559
|
var FALLBACK_CODEX_MODEL_CATALOG = {
|
|
8446
8560
|
current: {
|
|
8447
8561
|
model: "gpt-5.5",
|
|
@@ -8460,9 +8574,9 @@ var FALLBACK_CODEX_MODEL_CATALOG = {
|
|
|
8460
8574
|
]
|
|
8461
8575
|
};
|
|
8462
8576
|
async function readCodexModelCatalog(codexPackageRoot) {
|
|
8463
|
-
const catalogPath =
|
|
8577
|
+
const catalogPath = join17(codexPackageRoot, "plugin", "model-catalog.json");
|
|
8464
8578
|
try {
|
|
8465
|
-
const parsed = JSON.parse(await
|
|
8579
|
+
const parsed = JSON.parse(await readFile10(catalogPath, "utf8"));
|
|
8466
8580
|
return parseCodexModelCatalog(parsed) ?? FALLBACK_CODEX_MODEL_CATALOG;
|
|
8467
8581
|
} catch (error) {
|
|
8468
8582
|
if (error instanceof Error)
|
|
@@ -8596,10 +8710,10 @@ function readBooleanSetting(sectionText, key) {
|
|
|
8596
8710
|
|
|
8597
8711
|
// packages/omo-codex/src/install/codex-config-toml.ts
|
|
8598
8712
|
async function updateCodexConfig(input) {
|
|
8599
|
-
await mkdir5(
|
|
8713
|
+
await mkdir5(dirname7(input.configPath), { recursive: true });
|
|
8600
8714
|
let config = "";
|
|
8601
8715
|
if (await exists(input.configPath))
|
|
8602
|
-
config = await
|
|
8716
|
+
config = await readFile11(input.configPath, "utf8");
|
|
8603
8717
|
const pluginSet = new Set(input.pluginNames);
|
|
8604
8718
|
for (const legacyMarketplaceName of legacyMarketplaceNames(input.marketplaceName)) {
|
|
8605
8719
|
config = removeMarketplaceBlock(config, legacyMarketplaceName);
|
|
@@ -8635,7 +8749,7 @@ async function updateCodexConfig(input) {
|
|
|
8635
8749
|
}
|
|
8636
8750
|
async function exists(path) {
|
|
8637
8751
|
try {
|
|
8638
|
-
await
|
|
8752
|
+
await readFile11(path, "utf8");
|
|
8639
8753
|
return true;
|
|
8640
8754
|
} catch (error) {
|
|
8641
8755
|
if (error instanceof Error)
|
|
@@ -8646,8 +8760,8 @@ async function exists(path) {
|
|
|
8646
8760
|
|
|
8647
8761
|
// packages/omo-codex/src/install/codex-hook-trust.ts
|
|
8648
8762
|
import { createHash } from "node:crypto";
|
|
8649
|
-
import { readFile as
|
|
8650
|
-
import { join as
|
|
8763
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
8764
|
+
import { join as join18 } from "node:path";
|
|
8651
8765
|
var EVENT_LABELS = new Map([
|
|
8652
8766
|
["PreToolUse", "pre_tool_use"],
|
|
8653
8767
|
["PermissionRequest", "permission_request"],
|
|
@@ -8661,18 +8775,18 @@ var EVENT_LABELS = new Map([
|
|
|
8661
8775
|
["Stop", "stop"]
|
|
8662
8776
|
]);
|
|
8663
8777
|
async function trustedHookStatesForPlugin(input) {
|
|
8664
|
-
const manifestPath =
|
|
8778
|
+
const manifestPath = join18(input.pluginRoot, ".codex-plugin", "plugin.json");
|
|
8665
8779
|
if (!await exists2(manifestPath))
|
|
8666
8780
|
return [];
|
|
8667
|
-
const manifest = JSON.parse(await
|
|
8781
|
+
const manifest = JSON.parse(await readFile12(manifestPath, "utf8"));
|
|
8668
8782
|
if (!isPlainRecord(manifest))
|
|
8669
8783
|
return [];
|
|
8670
8784
|
const states = [];
|
|
8671
8785
|
for (const hookPath of hookManifestPaths2(manifest.hooks)) {
|
|
8672
|
-
const hooksPath =
|
|
8786
|
+
const hooksPath = join18(input.pluginRoot, hookPath);
|
|
8673
8787
|
if (!await exists2(hooksPath))
|
|
8674
8788
|
continue;
|
|
8675
|
-
const parsed = JSON.parse(await
|
|
8789
|
+
const parsed = JSON.parse(await readFile12(hooksPath, "utf8"));
|
|
8676
8790
|
if (!isPlainRecord(parsed) || !isPlainRecord(parsed.hooks))
|
|
8677
8791
|
continue;
|
|
8678
8792
|
states.push(...trustedHookStatesForHooksFile({
|
|
@@ -8755,7 +8869,7 @@ function stripDotSlash2(value) {
|
|
|
8755
8869
|
}
|
|
8756
8870
|
async function exists2(path) {
|
|
8757
8871
|
try {
|
|
8758
|
-
await
|
|
8872
|
+
await readFile12(path, "utf8");
|
|
8759
8873
|
return true;
|
|
8760
8874
|
} catch (error) {
|
|
8761
8875
|
if (error instanceof Error)
|
|
@@ -8769,8 +8883,8 @@ var resolveGitBashForCurrentProcess2 = (input = {}) => {
|
|
|
8769
8883
|
return toCodexResolution(resolveGitBashForCurrentProcess(input));
|
|
8770
8884
|
};
|
|
8771
8885
|
async function prepareGitBashForInstall(input) {
|
|
8772
|
-
const
|
|
8773
|
-
const initialResolution =
|
|
8886
|
+
const resolve7 = input.resolveGitBash ?? (() => resolveGitBashForCurrentProcess2({ platform: input.platform, env: input.env }));
|
|
8887
|
+
const initialResolution = resolve7();
|
|
8774
8888
|
return initialResolution;
|
|
8775
8889
|
}
|
|
8776
8890
|
function toCodexResolution(resolution) {
|
|
@@ -8794,12 +8908,12 @@ function toCodexResolution(resolution) {
|
|
|
8794
8908
|
}
|
|
8795
8909
|
|
|
8796
8910
|
// packages/omo-codex/src/install/link-cached-plugin-agents.ts
|
|
8797
|
-
import { copyFile, lstat as
|
|
8798
|
-
import { basename as basename5, join as
|
|
8911
|
+
import { copyFile, lstat as lstat8, mkdir as mkdir6, readFile as readFile14, readdir as readdir6, rm as rm8, writeFile as writeFile6 } from "node:fs/promises";
|
|
8912
|
+
import { basename as basename5, join as join20 } from "node:path";
|
|
8799
8913
|
|
|
8800
8914
|
// packages/omo-codex/src/install/retired-managed-agent-purge.ts
|
|
8801
|
-
import { lstat as
|
|
8802
|
-
import { join as
|
|
8915
|
+
import { lstat as lstat7, readFile as readFile13, rm as rm7 } from "node:fs/promises";
|
|
8916
|
+
import { join as join19 } from "node:path";
|
|
8803
8917
|
var RETIRED_MANAGED_AGENT_FILES = [
|
|
8804
8918
|
{
|
|
8805
8919
|
fileName: "codex-ultrawork-reviewer.toml",
|
|
@@ -8811,20 +8925,20 @@ var RETIRED_MANAGED_AGENT_FILES = [
|
|
|
8811
8925
|
}
|
|
8812
8926
|
];
|
|
8813
8927
|
async function purgeRetiredManagedAgentFiles(input) {
|
|
8814
|
-
const agentsDir =
|
|
8928
|
+
const agentsDir = join19(input.codexHome, "agents");
|
|
8815
8929
|
if (!await exists3(agentsDir))
|
|
8816
8930
|
return;
|
|
8817
8931
|
for (const retiredAgent of RETIRED_MANAGED_AGENT_FILES) {
|
|
8818
|
-
const agentPath =
|
|
8932
|
+
const agentPath = join19(agentsDir, retiredAgent.fileName);
|
|
8819
8933
|
if (!await exists3(agentPath))
|
|
8820
8934
|
continue;
|
|
8821
|
-
const agentStat = await
|
|
8935
|
+
const agentStat = await lstat7(agentPath);
|
|
8822
8936
|
if (agentStat.isDirectory() && !agentStat.isSymbolicLink())
|
|
8823
8937
|
continue;
|
|
8824
8938
|
const content = await readTextIfExists(agentPath);
|
|
8825
8939
|
if (content === null || !hasRequiredMarkers(content, retiredAgent.requiredMarkers))
|
|
8826
8940
|
continue;
|
|
8827
|
-
await
|
|
8941
|
+
await rm7(agentPath, { force: true });
|
|
8828
8942
|
}
|
|
8829
8943
|
}
|
|
8830
8944
|
function hasRequiredMarkers(content, markers) {
|
|
@@ -8832,7 +8946,7 @@ function hasRequiredMarkers(content, markers) {
|
|
|
8832
8946
|
}
|
|
8833
8947
|
async function readTextIfExists(path) {
|
|
8834
8948
|
try {
|
|
8835
|
-
return await
|
|
8949
|
+
return await readFile13(path, "utf8");
|
|
8836
8950
|
} catch (error) {
|
|
8837
8951
|
if (nodeErrorCode(error) === "ENOENT")
|
|
8838
8952
|
return null;
|
|
@@ -8841,7 +8955,7 @@ async function readTextIfExists(path) {
|
|
|
8841
8955
|
}
|
|
8842
8956
|
async function exists3(path) {
|
|
8843
8957
|
try {
|
|
8844
|
-
await
|
|
8958
|
+
await lstat7(path);
|
|
8845
8959
|
return true;
|
|
8846
8960
|
} catch (error) {
|
|
8847
8961
|
if (nodeErrorCode(error) !== "ENOENT")
|
|
@@ -8858,15 +8972,15 @@ function nodeErrorCode(error) {
|
|
|
8858
8972
|
// packages/omo-codex/src/install/link-cached-plugin-agents.ts
|
|
8859
8973
|
var MANIFEST_FILE = ".installed-agents.json";
|
|
8860
8974
|
async function capturePreservedAgentReasoning(input) {
|
|
8861
|
-
const agentsDir =
|
|
8975
|
+
const agentsDir = join20(input.codexHome, "agents");
|
|
8862
8976
|
if (!await exists4(agentsDir))
|
|
8863
8977
|
return new Map;
|
|
8864
8978
|
const preserved = new Map;
|
|
8865
|
-
const agentEntries = await
|
|
8979
|
+
const agentEntries = await readdir6(agentsDir, { withFileTypes: true });
|
|
8866
8980
|
for (const entry of agentEntries) {
|
|
8867
8981
|
if (!entry.name.endsWith(".toml"))
|
|
8868
8982
|
continue;
|
|
8869
|
-
const content = await readTextIfExists2(
|
|
8983
|
+
const content = await readTextIfExists2(join20(agentsDir, entry.name));
|
|
8870
8984
|
if (content === null)
|
|
8871
8985
|
continue;
|
|
8872
8986
|
const effort = extractReasoningEffort(content);
|
|
@@ -8876,15 +8990,15 @@ async function capturePreservedAgentReasoning(input) {
|
|
|
8876
8990
|
return preserved;
|
|
8877
8991
|
}
|
|
8878
8992
|
async function capturePreservedAgentServiceTier(input) {
|
|
8879
|
-
const agentsDir =
|
|
8993
|
+
const agentsDir = join20(input.codexHome, "agents");
|
|
8880
8994
|
if (!await exists4(agentsDir))
|
|
8881
8995
|
return new Map;
|
|
8882
8996
|
const preserved = new Map;
|
|
8883
|
-
const agentEntries = await
|
|
8997
|
+
const agentEntries = await readdir6(agentsDir, { withFileTypes: true });
|
|
8884
8998
|
for (const entry of agentEntries) {
|
|
8885
8999
|
if (!entry.name.endsWith(".toml"))
|
|
8886
9000
|
continue;
|
|
8887
|
-
const content = await readTextIfExists2(
|
|
9001
|
+
const content = await readTextIfExists2(join20(agentsDir, entry.name));
|
|
8888
9002
|
if (content === null)
|
|
8889
9003
|
continue;
|
|
8890
9004
|
preserved.set(agentNameFromToml(entry.name), extractServiceTier(content));
|
|
@@ -8898,13 +9012,13 @@ async function linkCachedPluginAgents(input) {
|
|
|
8898
9012
|
await writeManifest(input.pluginRoot, []);
|
|
8899
9013
|
return [];
|
|
8900
9014
|
}
|
|
8901
|
-
const agentsDir =
|
|
9015
|
+
const agentsDir = join20(input.codexHome, "agents");
|
|
8902
9016
|
await mkdir6(agentsDir, { recursive: true });
|
|
8903
9017
|
const linked = [];
|
|
8904
9018
|
for (const agentPath of bundledAgents) {
|
|
8905
9019
|
const agentFileName = basename5(agentPath);
|
|
8906
9020
|
const agentName = agentNameFromToml(agentFileName);
|
|
8907
|
-
const linkPath =
|
|
9021
|
+
const linkPath = join20(agentsDir, agentFileName);
|
|
8908
9022
|
await replaceWithCopy(linkPath, agentPath);
|
|
8909
9023
|
await restorePreservedReasoning({
|
|
8910
9024
|
agentName,
|
|
@@ -8925,7 +9039,7 @@ async function linkCachedPluginAgents(input) {
|
|
|
8925
9039
|
async function restorePreservedServiceTier(input) {
|
|
8926
9040
|
if (!input.preserved)
|
|
8927
9041
|
return;
|
|
8928
|
-
const content = await
|
|
9042
|
+
const content = await readFile14(input.linkPath, "utf8");
|
|
8929
9043
|
if (extractServiceTier(content) === input.value)
|
|
8930
9044
|
return;
|
|
8931
9045
|
const replacement = replaceServiceTier(content, input.value);
|
|
@@ -8934,22 +9048,22 @@ async function restorePreservedServiceTier(input) {
|
|
|
8934
9048
|
await writeFile6(input.linkPath, replacement.content);
|
|
8935
9049
|
}
|
|
8936
9050
|
async function discoverBundledAgents(pluginRoot) {
|
|
8937
|
-
const componentsRoot =
|
|
9051
|
+
const componentsRoot = join20(pluginRoot, "components");
|
|
8938
9052
|
if (!await exists4(componentsRoot))
|
|
8939
9053
|
return [];
|
|
8940
|
-
const componentEntries = await
|
|
9054
|
+
const componentEntries = await readdir6(componentsRoot, { withFileTypes: true });
|
|
8941
9055
|
const agents = [];
|
|
8942
9056
|
for (const entry of componentEntries) {
|
|
8943
9057
|
if (!entry.isDirectory())
|
|
8944
9058
|
continue;
|
|
8945
|
-
const agentsRoot =
|
|
9059
|
+
const agentsRoot = join20(componentsRoot, entry.name, "agents");
|
|
8946
9060
|
if (!await exists4(agentsRoot))
|
|
8947
9061
|
continue;
|
|
8948
|
-
const agentEntries = await
|
|
9062
|
+
const agentEntries = await readdir6(agentsRoot, { withFileTypes: true });
|
|
8949
9063
|
for (const file2 of agentEntries) {
|
|
8950
9064
|
if (!file2.isFile() || !file2.name.endsWith(".toml"))
|
|
8951
9065
|
continue;
|
|
8952
|
-
agents.push(
|
|
9066
|
+
agents.push(join20(agentsRoot, file2.name));
|
|
8953
9067
|
}
|
|
8954
9068
|
}
|
|
8955
9069
|
agents.sort();
|
|
@@ -8962,14 +9076,14 @@ async function replaceWithCopy(linkPath, target) {
|
|
|
8962
9076
|
async function prepareReplacement(linkPath) {
|
|
8963
9077
|
if (!await exists4(linkPath))
|
|
8964
9078
|
return;
|
|
8965
|
-
const entryStat = await
|
|
9079
|
+
const entryStat = await lstat8(linkPath);
|
|
8966
9080
|
if (entryStat.isDirectory() && !entryStat.isSymbolicLink()) {
|
|
8967
9081
|
throw new Error(`${linkPath} already exists and is a directory; refusing to replace`);
|
|
8968
9082
|
}
|
|
8969
|
-
await
|
|
9083
|
+
await rm8(linkPath, { force: true });
|
|
8970
9084
|
}
|
|
8971
9085
|
async function writeManifest(pluginRoot, agentPaths) {
|
|
8972
|
-
const manifestPath =
|
|
9086
|
+
const manifestPath = join20(pluginRoot, MANIFEST_FILE);
|
|
8973
9087
|
const payload = { agents: [...agentPaths].sort() };
|
|
8974
9088
|
await writeFile6(manifestPath, `${JSON.stringify(payload, null, "\t")}
|
|
8975
9089
|
`);
|
|
@@ -8977,7 +9091,7 @@ async function writeManifest(pluginRoot, agentPaths) {
|
|
|
8977
9091
|
async function restorePreservedReasoning(input) {
|
|
8978
9092
|
if (input.value === undefined)
|
|
8979
9093
|
return;
|
|
8980
|
-
const content = await
|
|
9094
|
+
const content = await readFile14(input.target, "utf8");
|
|
8981
9095
|
const bundledEffort = extractReasoningEffort(content);
|
|
8982
9096
|
if (bundledEffort === input.value)
|
|
8983
9097
|
return;
|
|
@@ -8988,7 +9102,7 @@ async function restorePreservedReasoning(input) {
|
|
|
8988
9102
|
}
|
|
8989
9103
|
async function readTextIfExists2(path) {
|
|
8990
9104
|
try {
|
|
8991
|
-
return await
|
|
9105
|
+
return await readFile14(path, "utf8");
|
|
8992
9106
|
} catch (error) {
|
|
8993
9107
|
if (nodeErrorCode2(error) === "ENOENT")
|
|
8994
9108
|
return null;
|
|
@@ -9081,7 +9195,7 @@ function parseJsonString(value) {
|
|
|
9081
9195
|
}
|
|
9082
9196
|
async function exists4(path) {
|
|
9083
9197
|
try {
|
|
9084
|
-
await
|
|
9198
|
+
await lstat8(path);
|
|
9085
9199
|
return true;
|
|
9086
9200
|
} catch (error) {
|
|
9087
9201
|
if (nodeErrorCode2(error) !== "ENOENT")
|
|
@@ -9096,12 +9210,12 @@ function nodeErrorCode2(error) {
|
|
|
9096
9210
|
}
|
|
9097
9211
|
|
|
9098
9212
|
// packages/omo-codex/src/install/codex-marketplace.ts
|
|
9099
|
-
import { readFile as
|
|
9100
|
-
import { join as
|
|
9213
|
+
import { readFile as readFile15 } from "node:fs/promises";
|
|
9214
|
+
import { join as join21 } from "node:path";
|
|
9101
9215
|
var DEFAULT_MARKETPLACE_PATH = "packages/omo-codex/marketplace.json";
|
|
9102
9216
|
async function readMarketplace(repoRoot, options) {
|
|
9103
|
-
const marketplacePath = options?.marketplacePath ??
|
|
9104
|
-
const raw = await
|
|
9217
|
+
const marketplacePath = options?.marketplacePath ?? join21(repoRoot, DEFAULT_MARKETPLACE_PATH);
|
|
9218
|
+
const raw = await readFile15(marketplacePath, "utf8");
|
|
9105
9219
|
const parsed = JSON.parse(raw);
|
|
9106
9220
|
if (!isPlainRecord(parsed))
|
|
9107
9221
|
throw new Error("marketplace.json must be an object");
|
|
@@ -9119,10 +9233,10 @@ async function readMarketplace(repoRoot, options) {
|
|
|
9119
9233
|
function resolvePluginSource(repoRoot, plugin, options) {
|
|
9120
9234
|
const sourcePath = localSourcePath(options?.pathOverride ?? plugin.source);
|
|
9121
9235
|
const relativePath = sourcePath.slice(2);
|
|
9122
|
-
return
|
|
9236
|
+
return join21(repoRoot, ...relativePath.split(/[\\/]/));
|
|
9123
9237
|
}
|
|
9124
9238
|
async function readPluginManifest(pluginRoot) {
|
|
9125
|
-
const raw = await
|
|
9239
|
+
const raw = await readFile15(join21(pluginRoot, ".codex-plugin", "plugin.json"), "utf8");
|
|
9126
9240
|
const parsed = JSON.parse(raw);
|
|
9127
9241
|
if (!isPlainRecord(parsed))
|
|
9128
9242
|
throw new Error(`${pluginRoot} plugin.json must be an object`);
|
|
@@ -9203,8 +9317,8 @@ function validateLocalSourcePath(path) {
|
|
|
9203
9317
|
}
|
|
9204
9318
|
|
|
9205
9319
|
// packages/omo-codex/src/install/codex-marketplace-snapshot.ts
|
|
9206
|
-
import { cp as cp3, mkdir as mkdir7, rename as
|
|
9207
|
-
import { join as
|
|
9320
|
+
import { cp as cp3, mkdir as mkdir7, rename as rename4, rm as rm9, writeFile as writeFile7 } from "node:fs/promises";
|
|
9321
|
+
import { join as join22, sep as sep6 } from "node:path";
|
|
9208
9322
|
var INSTALLED_MARKETPLACES_DIR = ".tmp/marketplaces";
|
|
9209
9323
|
async function writeInstalledMarketplaceSnapshot(input) {
|
|
9210
9324
|
const marketplaceRoot = installedMarketplaceRoot(input.codexHome, input.marketplace.name);
|
|
@@ -9217,29 +9331,29 @@ async function writeInstalledMarketplaceSnapshot(input) {
|
|
|
9217
9331
|
return snapshotPlugins;
|
|
9218
9332
|
}
|
|
9219
9333
|
function installedMarketplaceRoot(codexHome, marketplaceName) {
|
|
9220
|
-
return
|
|
9334
|
+
return join22(codexHome, INSTALLED_MARKETPLACES_DIR, marketplaceName);
|
|
9221
9335
|
}
|
|
9222
9336
|
async function writeMarketplaceManifest(marketplaceRoot, marketplace) {
|
|
9223
|
-
const manifestDir =
|
|
9337
|
+
const manifestDir = join22(marketplaceRoot, ".agents", "plugins");
|
|
9224
9338
|
await mkdir7(manifestDir, { recursive: true });
|
|
9225
|
-
const tempPath =
|
|
9339
|
+
const tempPath = join22(manifestDir, `.marketplace-${process.pid}-${Date.now()}.json.tmp`);
|
|
9226
9340
|
await writeFile7(tempPath, `${JSON.stringify(marketplace, null, "\t")}
|
|
9227
9341
|
`);
|
|
9228
|
-
await
|
|
9342
|
+
await rename4(tempPath, join22(manifestDir, "marketplace.json"));
|
|
9229
9343
|
}
|
|
9230
9344
|
async function writeSnapshotPlugin(marketplaceRoot, plugin) {
|
|
9231
|
-
const pluginsDir =
|
|
9345
|
+
const pluginsDir = join22(marketplaceRoot, "plugins");
|
|
9232
9346
|
await mkdir7(pluginsDir, { recursive: true });
|
|
9233
|
-
const targetPath =
|
|
9234
|
-
const tempPath =
|
|
9235
|
-
await
|
|
9347
|
+
const targetPath = join22(pluginsDir, plugin.name);
|
|
9348
|
+
const tempPath = join22(pluginsDir, `.tmp-${plugin.name}-${process.pid}-${Date.now()}`);
|
|
9349
|
+
await rm9(tempPath, { recursive: true, force: true });
|
|
9236
9350
|
await cp3(plugin.sourcePath, tempPath, {
|
|
9237
9351
|
recursive: true,
|
|
9238
9352
|
filter: (source) => shouldCopyMarketplaceSourcePath(source, plugin.sourcePath)
|
|
9239
9353
|
});
|
|
9240
9354
|
await copyBundledMcpRuntimeDists({ pluginRoot: tempPath, sourceRoot: plugin.sourcePath });
|
|
9241
|
-
await
|
|
9242
|
-
await
|
|
9355
|
+
await rm9(targetPath, { recursive: true, force: true });
|
|
9356
|
+
await rename4(tempPath, targetPath);
|
|
9243
9357
|
await rewriteCachedMcpManifest(targetPath, plugin.sourcePath);
|
|
9244
9358
|
return { name: plugin.name, path: targetPath };
|
|
9245
9359
|
}
|
|
@@ -9252,11 +9366,11 @@ function shouldCopyMarketplaceSourcePath(path, root) {
|
|
|
9252
9366
|
}
|
|
9253
9367
|
|
|
9254
9368
|
// packages/omo-codex/src/install/lazycodex-version-stamp.ts
|
|
9255
|
-
import { readdir as
|
|
9256
|
-
import { join as
|
|
9369
|
+
import { readdir as readdir7, readFile as readFile16, writeFile as writeFile8 } from "node:fs/promises";
|
|
9370
|
+
import { join as join23 } from "node:path";
|
|
9257
9371
|
async function readDistributionManifest(repoRoot) {
|
|
9258
9372
|
try {
|
|
9259
|
-
const parsed = JSON.parse(await
|
|
9373
|
+
const parsed = JSON.parse(await readFile16(join23(repoRoot, "package.json"), "utf8"));
|
|
9260
9374
|
if (!isPlainRecord(parsed) || typeof parsed.version !== "string" || parsed.version.trim().length === 0)
|
|
9261
9375
|
return;
|
|
9262
9376
|
return {
|
|
@@ -9276,19 +9390,19 @@ function resolveLazyCodexPluginVersion(input) {
|
|
|
9276
9390
|
return input.manifestVersion ?? "local";
|
|
9277
9391
|
}
|
|
9278
9392
|
async function stampLazyCodexPluginVersion(input) {
|
|
9279
|
-
const manifestPath =
|
|
9393
|
+
const manifestPath = join23(input.pluginRoot, ".codex-plugin", "plugin.json");
|
|
9280
9394
|
const hookPaths = await readPluginHookPaths(manifestPath);
|
|
9281
9395
|
await stampJsonVersion(manifestPath, input.version);
|
|
9282
|
-
await stampJsonVersion(
|
|
9396
|
+
await stampJsonVersion(join23(input.pluginRoot, "package.json"), input.version);
|
|
9283
9397
|
for (const hookPath of hookPaths) {
|
|
9284
|
-
await stampHookStatusMessages(
|
|
9398
|
+
await stampHookStatusMessages(join23(input.pluginRoot, hookPath), input.version);
|
|
9285
9399
|
}
|
|
9286
9400
|
await stampComponentVersions(input);
|
|
9287
9401
|
}
|
|
9288
9402
|
async function writeLazyCodexInstallSnapshot(input) {
|
|
9289
9403
|
if (input.distributionManifest === undefined)
|
|
9290
9404
|
return;
|
|
9291
|
-
await writeFile8(
|
|
9405
|
+
await writeFile8(join23(input.pluginRoot, "lazycodex-install.json"), `${JSON.stringify({
|
|
9292
9406
|
packageName: input.distributionManifest.name,
|
|
9293
9407
|
version: input.distributionManifest.version
|
|
9294
9408
|
}, null, "\t")}
|
|
@@ -9296,7 +9410,7 @@ async function writeLazyCodexInstallSnapshot(input) {
|
|
|
9296
9410
|
}
|
|
9297
9411
|
async function stampJsonVersion(path, version) {
|
|
9298
9412
|
try {
|
|
9299
|
-
const parsed = JSON.parse(await
|
|
9413
|
+
const parsed = JSON.parse(await readFile16(path, "utf8"));
|
|
9300
9414
|
if (!isPlainRecord(parsed))
|
|
9301
9415
|
return;
|
|
9302
9416
|
parsed.version = version;
|
|
@@ -9310,7 +9424,7 @@ async function stampJsonVersion(path, version) {
|
|
|
9310
9424
|
}
|
|
9311
9425
|
async function readPluginHookPaths(manifestPath) {
|
|
9312
9426
|
try {
|
|
9313
|
-
const parsed = JSON.parse(await
|
|
9427
|
+
const parsed = JSON.parse(await readFile16(manifestPath, "utf8"));
|
|
9314
9428
|
if (!isPlainRecord(parsed))
|
|
9315
9429
|
return [];
|
|
9316
9430
|
if (typeof parsed.hooks === "string" && parsed.hooks.trim().length > 0)
|
|
@@ -9330,7 +9444,7 @@ function stripDotSlash3(path) {
|
|
|
9330
9444
|
}
|
|
9331
9445
|
async function stampHookStatusMessages(path, version) {
|
|
9332
9446
|
try {
|
|
9333
|
-
const parsed = JSON.parse(await
|
|
9447
|
+
const parsed = JSON.parse(await readFile16(path, "utf8"));
|
|
9334
9448
|
if (!isPlainRecord(parsed))
|
|
9335
9449
|
return;
|
|
9336
9450
|
stampHookGroups(parsed.hooks, version);
|
|
@@ -9345,16 +9459,16 @@ async function stampHookStatusMessages(path, version) {
|
|
|
9345
9459
|
async function stampComponentVersions(input) {
|
|
9346
9460
|
let entries;
|
|
9347
9461
|
try {
|
|
9348
|
-
entries = await
|
|
9462
|
+
entries = await readdir7(join23(input.pluginRoot, "components"));
|
|
9349
9463
|
} catch (error) {
|
|
9350
9464
|
if (error instanceof Error)
|
|
9351
9465
|
return;
|
|
9352
9466
|
throw error;
|
|
9353
9467
|
}
|
|
9354
9468
|
for (const entry of entries) {
|
|
9355
|
-
const componentRoot =
|
|
9356
|
-
await stampJsonVersion(
|
|
9357
|
-
await stampHookStatusMessages(
|
|
9469
|
+
const componentRoot = join23(input.pluginRoot, "components", entry);
|
|
9470
|
+
await stampJsonVersion(join23(componentRoot, "package.json"), input.version);
|
|
9471
|
+
await stampHookStatusMessages(join23(componentRoot, "hooks", "hooks.json"), input.version);
|
|
9358
9472
|
}
|
|
9359
9473
|
}
|
|
9360
9474
|
function stampHookGroups(hooks, version) {
|
|
@@ -9379,8 +9493,8 @@ function stampHookStatusMessage(hook, version) {
|
|
|
9379
9493
|
}
|
|
9380
9494
|
|
|
9381
9495
|
// packages/omo-codex/src/install/codex-project-local-cleanup.ts
|
|
9382
|
-
import { copyFile as copyFile2, lstat as
|
|
9383
|
-
import { dirname as
|
|
9496
|
+
import { copyFile as copyFile2, lstat as lstat9, readFile as readFile17, writeFile as writeFile9 } from "node:fs/promises";
|
|
9497
|
+
import { dirname as dirname8, join as join24, resolve as resolve7 } from "node:path";
|
|
9384
9498
|
var LEGACY_AGENT_CONFLICT_KEYS = ["max_threads"];
|
|
9385
9499
|
var PROJECT_LOCAL_ARTIFACT_PATHS = [
|
|
9386
9500
|
".codex/hooks.json",
|
|
@@ -9399,7 +9513,7 @@ async function repairNearestProjectLocalCodexArtifacts(input) {
|
|
|
9399
9513
|
const artifacts = await collectProjectLocalArtifacts(project.artifactRoots);
|
|
9400
9514
|
const configs = [];
|
|
9401
9515
|
for (const configPath of project.configPaths) {
|
|
9402
|
-
const original = await
|
|
9516
|
+
const original = await readFile17(configPath, "utf8");
|
|
9403
9517
|
const repair = repairProjectLocalCodexConfigText(original);
|
|
9404
9518
|
if (!repair.changed) {
|
|
9405
9519
|
configs.push({
|
|
@@ -9483,37 +9597,37 @@ async function findProjectLocalCodexConfigs(startDirectory, codexHome) {
|
|
|
9483
9597
|
if (startDirectoryStat !== null && !startDirectoryStat.isDirectory()) {
|
|
9484
9598
|
throw new ProjectLocalCleanupStartDirectoryError(startDirectory);
|
|
9485
9599
|
}
|
|
9486
|
-
const codexHomeConfigPath = codexHome === undefined ? null :
|
|
9487
|
-
let current =
|
|
9600
|
+
const codexHomeConfigPath = codexHome === undefined ? null : join24(resolve7(codexHome), "config.toml");
|
|
9601
|
+
let current = resolve7(startDirectory);
|
|
9488
9602
|
const configPathsFromCwd = [];
|
|
9489
9603
|
while (true) {
|
|
9490
|
-
const configPath =
|
|
9604
|
+
const configPath = join24(current, ".codex", "config.toml");
|
|
9491
9605
|
if (await isRegularProjectLocalConfig(current, configPath)) {
|
|
9492
|
-
if (codexHomeConfigPath === null ||
|
|
9606
|
+
if (codexHomeConfigPath === null || resolve7(configPath) !== codexHomeConfigPath) {
|
|
9493
9607
|
configPathsFromCwd.push(configPath);
|
|
9494
9608
|
}
|
|
9495
9609
|
}
|
|
9496
|
-
if (await exists5(
|
|
9610
|
+
if (await exists5(join24(current, ".git"))) {
|
|
9497
9611
|
return configPathsFromCwd.length === 0 ? null : {
|
|
9498
9612
|
projectRoot: current,
|
|
9499
9613
|
configPaths: [...configPathsFromCwd].reverse(),
|
|
9500
9614
|
artifactRoots: artifactRootsForConfigPaths(configPathsFromCwd)
|
|
9501
9615
|
};
|
|
9502
9616
|
}
|
|
9503
|
-
const parent =
|
|
9617
|
+
const parent = dirname8(current);
|
|
9504
9618
|
if (parent === current) {
|
|
9505
9619
|
const nearestConfigPath = configPathsFromCwd[0];
|
|
9506
9620
|
return nearestConfigPath === undefined ? null : {
|
|
9507
|
-
projectRoot:
|
|
9621
|
+
projectRoot: dirname8(dirname8(nearestConfigPath)),
|
|
9508
9622
|
configPaths: [nearestConfigPath],
|
|
9509
|
-
artifactRoots: [
|
|
9623
|
+
artifactRoots: [dirname8(dirname8(nearestConfigPath))]
|
|
9510
9624
|
};
|
|
9511
9625
|
}
|
|
9512
9626
|
current = parent;
|
|
9513
9627
|
}
|
|
9514
9628
|
}
|
|
9515
9629
|
async function isRegularProjectLocalConfig(directory, configPath) {
|
|
9516
|
-
const codexDirStat = await maybeLstat(
|
|
9630
|
+
const codexDirStat = await maybeLstat(join24(directory, ".codex"));
|
|
9517
9631
|
if (codexDirStat === null || !codexDirStat.isDirectory() || codexDirStat.isSymbolicLink())
|
|
9518
9632
|
return false;
|
|
9519
9633
|
const configStat = await maybeLstat(configPath);
|
|
@@ -9522,7 +9636,7 @@ async function isRegularProjectLocalConfig(directory, configPath) {
|
|
|
9522
9636
|
function artifactRootsForConfigPaths(configPaths) {
|
|
9523
9637
|
const roots = [];
|
|
9524
9638
|
for (const configPath of configPaths) {
|
|
9525
|
-
const root =
|
|
9639
|
+
const root = dirname8(dirname8(configPath));
|
|
9526
9640
|
if (!roots.includes(root))
|
|
9527
9641
|
roots.push(root);
|
|
9528
9642
|
}
|
|
@@ -9533,7 +9647,7 @@ async function collectProjectLocalArtifacts(projectRoots) {
|
|
|
9533
9647
|
const seenPaths = new Set;
|
|
9534
9648
|
for (const projectRoot of projectRoots) {
|
|
9535
9649
|
for (const relativePath of PROJECT_LOCAL_ARTIFACT_PATHS) {
|
|
9536
|
-
const artifactPath =
|
|
9650
|
+
const artifactPath = join24(projectRoot, relativePath);
|
|
9537
9651
|
if (seenPaths.has(artifactPath))
|
|
9538
9652
|
continue;
|
|
9539
9653
|
const entryStat = await maybeLstat(artifactPath);
|
|
@@ -9567,7 +9681,7 @@ function formatBackupTimestamp(date) {
|
|
|
9567
9681
|
}
|
|
9568
9682
|
async function maybeLstat(path) {
|
|
9569
9683
|
try {
|
|
9570
|
-
return await
|
|
9684
|
+
return await lstat9(path);
|
|
9571
9685
|
} catch (error) {
|
|
9572
9686
|
if (nodeErrorCode3(error) === "ENOENT")
|
|
9573
9687
|
return null;
|
|
@@ -9608,34 +9722,34 @@ function formatUnknownError(error) {
|
|
|
9608
9722
|
}
|
|
9609
9723
|
|
|
9610
9724
|
// packages/omo-codex/src/install/lsp-daemon-reaper.ts
|
|
9611
|
-
import { readFile as
|
|
9725
|
+
import { readFile as readFile18, readdir as readdir8, rm as rm10 } from "node:fs/promises";
|
|
9612
9726
|
import { connect } from "node:net";
|
|
9613
|
-
import { join as
|
|
9727
|
+
import { join as join25 } from "node:path";
|
|
9614
9728
|
async function reapLspDaemons(codexHome, deps = {}) {
|
|
9615
9729
|
const killProcess = deps.killProcess ?? sendSigterm;
|
|
9616
9730
|
const isDaemonLive = deps.isDaemonLive ?? probeSocketLive;
|
|
9617
|
-
const daemonRoot =
|
|
9731
|
+
const daemonRoot = join25(codexHome, "codex-lsp", "daemon");
|
|
9618
9732
|
const reaped = [];
|
|
9619
9733
|
let entries;
|
|
9620
9734
|
try {
|
|
9621
|
-
entries = await
|
|
9735
|
+
entries = await readdir8(daemonRoot);
|
|
9622
9736
|
} catch {
|
|
9623
9737
|
return reaped;
|
|
9624
9738
|
}
|
|
9625
9739
|
for (const entry of entries) {
|
|
9626
|
-
const versionDir =
|
|
9627
|
-
const pid = await readPidFile(
|
|
9628
|
-
const socketPath = await readEndpointFile(
|
|
9740
|
+
const versionDir = join25(daemonRoot, entry);
|
|
9741
|
+
const pid = await readPidFile(join25(versionDir, "daemon.pid"));
|
|
9742
|
+
const socketPath = await readEndpointFile(join25(versionDir, "daemon.endpoint"));
|
|
9629
9743
|
if (pid !== null && socketPath !== null && await isDaemonLive(socketPath) && killProcess(pid)) {
|
|
9630
9744
|
reaped.push(pid);
|
|
9631
9745
|
}
|
|
9632
|
-
await
|
|
9746
|
+
await rm10(versionDir, { recursive: true, force: true });
|
|
9633
9747
|
}
|
|
9634
9748
|
return reaped;
|
|
9635
9749
|
}
|
|
9636
9750
|
async function readEndpointFile(path) {
|
|
9637
9751
|
try {
|
|
9638
|
-
const content = (await
|
|
9752
|
+
const content = (await readFile18(path, "utf8")).trim();
|
|
9639
9753
|
return content.length > 0 ? content : null;
|
|
9640
9754
|
} catch {
|
|
9641
9755
|
return null;
|
|
@@ -9643,18 +9757,18 @@ async function readEndpointFile(path) {
|
|
|
9643
9757
|
}
|
|
9644
9758
|
async function readPidFile(path) {
|
|
9645
9759
|
try {
|
|
9646
|
-
const pid = Number.parseInt((await
|
|
9760
|
+
const pid = Number.parseInt((await readFile18(path, "utf8")).trim(), 10);
|
|
9647
9761
|
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
9648
9762
|
} catch {
|
|
9649
9763
|
return null;
|
|
9650
9764
|
}
|
|
9651
9765
|
}
|
|
9652
9766
|
function probeSocketLive(socketPath, timeoutMs = 500) {
|
|
9653
|
-
return new Promise((
|
|
9767
|
+
return new Promise((resolve8) => {
|
|
9654
9768
|
const socket = connect(socketPath);
|
|
9655
9769
|
const done = (ok) => {
|
|
9656
9770
|
socket.destroy();
|
|
9657
|
-
|
|
9771
|
+
resolve8(ok);
|
|
9658
9772
|
};
|
|
9659
9773
|
const timer = setTimeout(() => done(false), timeoutMs);
|
|
9660
9774
|
timer.unref();
|
|
@@ -9679,24 +9793,24 @@ function sendSigterm(pid) {
|
|
|
9679
9793
|
|
|
9680
9794
|
// packages/omo-codex/src/install/codex-installer-bin-dir.ts
|
|
9681
9795
|
import { homedir } from "node:os";
|
|
9682
|
-
import { join as
|
|
9796
|
+
import { join as join26, resolve as resolve8 } from "node:path";
|
|
9683
9797
|
function resolveCodexInstallerBinDir(input) {
|
|
9684
9798
|
const explicitBinDir = input.binDir ?? input.env?.CODEX_LOCAL_BIN_DIR;
|
|
9685
9799
|
if (explicitBinDir !== undefined && explicitBinDir.trim().length > 0)
|
|
9686
|
-
return
|
|
9800
|
+
return resolve8(explicitBinDir.trim());
|
|
9687
9801
|
const homeDir = input.homeDir ?? homedir();
|
|
9688
|
-
const defaultCodexHome =
|
|
9689
|
-
const resolvedCodexHome =
|
|
9802
|
+
const defaultCodexHome = resolve8(homeDir, ".codex");
|
|
9803
|
+
const resolvedCodexHome = resolve8(input.codexHome);
|
|
9690
9804
|
if (resolvedCodexHome !== defaultCodexHome)
|
|
9691
|
-
return
|
|
9692
|
-
return
|
|
9805
|
+
return join26(resolvedCodexHome, "bin");
|
|
9806
|
+
return resolve8(homeDir, ".local", "bin");
|
|
9693
9807
|
}
|
|
9694
9808
|
|
|
9695
9809
|
// packages/omo-codex/src/install/omo-sot-migration.ts
|
|
9696
|
-
import { join as
|
|
9810
|
+
import { join as join27 } from "node:path";
|
|
9697
9811
|
async function seedAndMigrateOmoSot(input) {
|
|
9698
9812
|
const commandEnv = { ...input.env };
|
|
9699
|
-
const scriptPath =
|
|
9813
|
+
const scriptPath = join27(input.repoRoot, "packages", "omo-codex", "plugin", "scripts", "migrate-omo-sot.mjs");
|
|
9700
9814
|
try {
|
|
9701
9815
|
await input.runCommand(process.execPath, [scriptPath, "--seed"], {
|
|
9702
9816
|
cwd: input.repoRoot,
|
|
@@ -9710,7 +9824,7 @@ async function seedAndMigrateOmoSot(input) {
|
|
|
9710
9824
|
}
|
|
9711
9825
|
|
|
9712
9826
|
// packages/omo-codex/src/install/install-ast-grep-sg.ts
|
|
9713
|
-
import { join as
|
|
9827
|
+
import { join as join29 } from "node:path";
|
|
9714
9828
|
|
|
9715
9829
|
// packages/utils/src/deep-merge.ts
|
|
9716
9830
|
var DANGEROUS_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -12682,11 +12796,11 @@ function runtimeSlug(platform = process.platform, arch = process.arch) {
|
|
|
12682
12796
|
// packages/utils/src/ast-grep/install-script.ts
|
|
12683
12797
|
import { spawn as spawn3 } from "node:child_process";
|
|
12684
12798
|
import { existsSync as existsSync4 } from "node:fs";
|
|
12685
|
-
import { join as
|
|
12799
|
+
import { join as join28 } from "node:path";
|
|
12686
12800
|
var AST_GREP_BIN_DIR_ENV_KEY = "OMO_AST_GREP_BIN_DIR";
|
|
12687
12801
|
var AST_GREP_INSTALL_TIMEOUT_MS = 30000;
|
|
12688
12802
|
function astGrepRuntimeDir(baseDir, platform = process.platform, arch = process.arch) {
|
|
12689
|
-
return
|
|
12803
|
+
return join28(baseDir, "runtime", "ast-grep", runtimeSlug(platform, arch));
|
|
12690
12804
|
}
|
|
12691
12805
|
function isMissingExecutable(error) {
|
|
12692
12806
|
if (!("code" in error))
|
|
@@ -12701,12 +12815,12 @@ function defaultSpawnProcess(command, args, options) {
|
|
|
12701
12815
|
windowsHide: true
|
|
12702
12816
|
});
|
|
12703
12817
|
let settled = false;
|
|
12704
|
-
const outcome = new Promise((
|
|
12818
|
+
const outcome = new Promise((resolve9) => {
|
|
12705
12819
|
const settle = (result) => {
|
|
12706
12820
|
if (settled)
|
|
12707
12821
|
return;
|
|
12708
12822
|
settled = true;
|
|
12709
|
-
|
|
12823
|
+
resolve9(result);
|
|
12710
12824
|
};
|
|
12711
12825
|
child.once("error", (error) => {
|
|
12712
12826
|
settle({ kind: "spawn-error", error, missingExecutable: isMissingExecutable(error) });
|
|
@@ -12724,7 +12838,7 @@ function defaultSpawnProcess(command, args, options) {
|
|
|
12724
12838
|
};
|
|
12725
12839
|
}
|
|
12726
12840
|
function scriptPathForPlatform(skillDir, platform) {
|
|
12727
|
-
return
|
|
12841
|
+
return join28(skillDir, platform === "win32" ? "install.ps1" : "install.sh");
|
|
12728
12842
|
}
|
|
12729
12843
|
function invocationsForPlatform(scriptPath, platform) {
|
|
12730
12844
|
if (platform !== "win32")
|
|
@@ -12884,7 +12998,7 @@ init_atomic_write();
|
|
|
12884
12998
|
var DEFAULT_SESSION_IDLE_SETTLE_MS = 150;
|
|
12885
12999
|
var DEFAULT_SESSION_STATUS_TIMEOUT_MS = 5000;
|
|
12886
13000
|
function settleAfterSessionIdle(ms = DEFAULT_SESSION_IDLE_SETTLE_MS) {
|
|
12887
|
-
return ms > 0 ? new Promise((
|
|
13001
|
+
return ms > 0 ? new Promise((resolve10) => setTimeout(resolve10, ms)) : Promise.resolve();
|
|
12888
13002
|
}
|
|
12889
13003
|
function withStatusTimeout(promise, timeoutMs) {
|
|
12890
13004
|
let timeoutID;
|
|
@@ -13535,7 +13649,7 @@ async function installAstGrepForCodex(options) {
|
|
|
13535
13649
|
return;
|
|
13536
13650
|
const platform = options.platform ?? process.platform;
|
|
13537
13651
|
const targetDir = astGrepRuntimeDir(options.codexHome, platform, options.arch ?? process.arch);
|
|
13538
|
-
const skillDir =
|
|
13652
|
+
const skillDir = join29(plugin.path, "skills", "ast-grep");
|
|
13539
13653
|
const installer = options.installer ?? runAstGrepSkillInstall;
|
|
13540
13654
|
try {
|
|
13541
13655
|
const result = await installer({ platform, skillDir, targetDir });
|
|
@@ -13567,9 +13681,9 @@ var SISYPHUS_LEGACY_CACHE_MARKETPLACES = ["lazycodex", "code-yeongyu-codex-plugi
|
|
|
13567
13681
|
async function runCodexInstaller(options = {}) {
|
|
13568
13682
|
const env3 = options.env ?? process.env;
|
|
13569
13683
|
const platform = options.platform ?? process.platform;
|
|
13570
|
-
const repoRoot =
|
|
13571
|
-
const codexHome =
|
|
13572
|
-
const projectDirectory =
|
|
13684
|
+
const repoRoot = resolve11(options.repoRoot ?? findRepoRoot({ importerDir: import.meta.dir, env: env3 }));
|
|
13685
|
+
const codexHome = resolve11(options.codexHome ?? env3.CODEX_HOME ?? join32(homedir2(), ".codex"));
|
|
13686
|
+
const projectDirectory = resolve11(options.projectDirectory ?? env3.OMO_CODEX_PROJECT ?? process.cwd());
|
|
13573
13687
|
const binDir = resolveCodexInstallerBinDir({ binDir: options.binDir, codexHome, env: env3 });
|
|
13574
13688
|
const runCommand = options.runCommand ?? defaultRunCommand;
|
|
13575
13689
|
const log2 = options.log ?? (() => {
|
|
@@ -13584,9 +13698,9 @@ async function runCodexInstaller(options = {}) {
|
|
|
13584
13698
|
if (!gitBashResolution.found) {
|
|
13585
13699
|
throw new Error(gitBashResolution.installHint);
|
|
13586
13700
|
}
|
|
13587
|
-
const codexPackageRoot =
|
|
13701
|
+
const codexPackageRoot = join32(repoRoot, "packages", "omo-codex");
|
|
13588
13702
|
const marketplace = await readMarketplace(repoRoot, {
|
|
13589
|
-
marketplacePath:
|
|
13703
|
+
marketplacePath: join32(codexPackageRoot, "marketplace.json")
|
|
13590
13704
|
});
|
|
13591
13705
|
const distributionManifest = await readDistributionManifest(repoRoot);
|
|
13592
13706
|
const installed = [];
|
|
@@ -13628,7 +13742,7 @@ async function runCodexInstaller(options = {}) {
|
|
|
13628
13742
|
if (runtimeLink !== null)
|
|
13629
13743
|
log2(`Linked ${runtimeLink.name} -> ${runtimeLink.target}`);
|
|
13630
13744
|
else
|
|
13631
|
-
log2(`Warning: skipped the omo runtime wrapper because ${
|
|
13745
|
+
log2(`Warning: skipped the omo runtime wrapper because ${join32(repoRoot, "dist", "cli", "index.js")} is missing; omo ulw-loop commands will be unavailable until a package shipping dist/cli is installed`);
|
|
13632
13746
|
}
|
|
13633
13747
|
pluginSources.push({ name: entry.name, sourcePath });
|
|
13634
13748
|
installed.push(plugin);
|
|
@@ -13682,13 +13796,13 @@ async function runCodexInstaller(options = {}) {
|
|
|
13682
13796
|
});
|
|
13683
13797
|
}
|
|
13684
13798
|
await reapLspDaemons(codexHome).catch(() => []);
|
|
13685
|
-
const marketplaceRoot =
|
|
13799
|
+
const marketplaceRoot = join32(codexHome, "plugins", "cache", marketplace.name);
|
|
13686
13800
|
await writeCachedMarketplaceManifest({
|
|
13687
13801
|
marketplaceName: marketplace.name,
|
|
13688
13802
|
marketplaceRoot,
|
|
13689
13803
|
plugins: installed
|
|
13690
13804
|
});
|
|
13691
|
-
const configPath =
|
|
13805
|
+
const configPath = join32(codexHome, "config.toml");
|
|
13692
13806
|
await updateCodexConfig({
|
|
13693
13807
|
configPath,
|
|
13694
13808
|
repoRoot: codexPackageRoot,
|
|
@@ -13748,25 +13862,25 @@ function findRepoRootFromImporter(importerDir) {
|
|
|
13748
13862
|
for (let depth = 0;depth <= 7; depth += 1) {
|
|
13749
13863
|
if (isRepoRootWithCodexPlugin(current))
|
|
13750
13864
|
return current;
|
|
13751
|
-
for (const wrapperPackageRoot of [
|
|
13865
|
+
for (const wrapperPackageRoot of [join32(current, "node_modules", "oh-my-openagent"), join32(current, "oh-my-openagent")]) {
|
|
13752
13866
|
if (isRepoRootWithCodexPlugin(wrapperPackageRoot))
|
|
13753
13867
|
return wrapperPackageRoot;
|
|
13754
13868
|
}
|
|
13755
|
-
current =
|
|
13869
|
+
current = resolve11(current, "..");
|
|
13756
13870
|
}
|
|
13757
13871
|
throw new Error("Unable to locate vendored Codex plugin: expected packages/omo-codex/plugin/.codex-plugin/plugin.json in this package or sibling oh-my-openagent package within 7 parent levels");
|
|
13758
13872
|
}
|
|
13759
13873
|
function findRepoRoot(input) {
|
|
13760
13874
|
const wrapperPackageRoot = input.env?.OMO_WRAPPER_PACKAGE_ROOT;
|
|
13761
13875
|
if (wrapperPackageRoot !== undefined && wrapperPackageRoot.trim().length > 0) {
|
|
13762
|
-
const resolvedWrapperPackageRoot =
|
|
13876
|
+
const resolvedWrapperPackageRoot = resolve11(wrapperPackageRoot);
|
|
13763
13877
|
if (isRepoRootWithCodexPlugin(resolvedWrapperPackageRoot))
|
|
13764
13878
|
return resolvedWrapperPackageRoot;
|
|
13765
13879
|
}
|
|
13766
13880
|
return findRepoRootFromImporter(input.importerDir);
|
|
13767
13881
|
}
|
|
13768
13882
|
function isRepoRootWithCodexPlugin(repoRoot) {
|
|
13769
|
-
return existsSync7(
|
|
13883
|
+
return existsSync7(join32(repoRoot, "packages", "omo-codex", "plugin", ".codex-plugin", "plugin.json"));
|
|
13770
13884
|
}
|
|
13771
13885
|
function codexMarketplaceSource(marketplaceRoot) {
|
|
13772
13886
|
return { sourceType: "local", source: marketplaceRoot };
|
|
@@ -14079,12 +14193,12 @@ function shellQuote(value) {
|
|
|
14079
14193
|
// packages/omo-codex/src/install/lazycodex-manual-update.ts
|
|
14080
14194
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "node:child_process";
|
|
14081
14195
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
14082
|
-
import { dirname as
|
|
14196
|
+
import { dirname as dirname10, join as join34 } from "node:path";
|
|
14083
14197
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
14084
14198
|
import { fileURLToPath } from "node:url";
|
|
14085
14199
|
|
|
14086
14200
|
// packages/omo-codex/src/install/lazycodex-bun-global-paths.ts
|
|
14087
|
-
import { join as
|
|
14201
|
+
import { join as join33 } from "node:path";
|
|
14088
14202
|
function isBunGlobalEntrypointPath(invokedPath, env3) {
|
|
14089
14203
|
if (typeof invokedPath !== "string" || invokedPath.trim().length === 0)
|
|
14090
14204
|
return false;
|
|
@@ -14095,8 +14209,8 @@ function resolveBunGlobalRoots(env3) {
|
|
|
14095
14209
|
const bunInstallRoot = env3.BUN_INSTALL?.trim();
|
|
14096
14210
|
const homeRoot = env3.HOME?.trim();
|
|
14097
14211
|
return [
|
|
14098
|
-
...bunInstallRoot ? [
|
|
14099
|
-
...homeRoot ? [
|
|
14212
|
+
...bunInstallRoot ? [join33(bunInstallRoot, "bin"), join33(bunInstallRoot, "install", "global", "node_modules")] : [],
|
|
14213
|
+
...homeRoot ? [join33(homeRoot, ".bun", "bin"), join33(homeRoot, ".bun", "install", "global", "node_modules")] : []
|
|
14100
14214
|
].map(normalizePathForPrefix);
|
|
14101
14215
|
}
|
|
14102
14216
|
function normalizePathForPrefix(path2) {
|
|
@@ -14188,8 +14302,8 @@ function resolveArgs(env3) {
|
|
|
14188
14302
|
function resolveCurrentVersion(env3) {
|
|
14189
14303
|
if (env3.LAZYCODEX_CURRENT_VERSION?.trim())
|
|
14190
14304
|
return env3.LAZYCODEX_CURRENT_VERSION.trim();
|
|
14191
|
-
const pluginRoot =
|
|
14192
|
-
return readVersionManifest(resolveInstalledVersionPath(env3, pluginRoot)) ?? readVersionManifest(
|
|
14305
|
+
const pluginRoot = dirname10(dirname10(fileURLToPath(import.meta.url)));
|
|
14306
|
+
return readVersionManifest(resolveInstalledVersionPath(env3, pluginRoot)) ?? readVersionManifest(join34(pluginRoot, "..", "..", "..", "package.json")) ?? readVersionManifest(join34(pluginRoot, ".codex-plugin", "plugin.json"));
|
|
14193
14307
|
}
|
|
14194
14308
|
function resolveLatestVersion(env3) {
|
|
14195
14309
|
if (env3.LAZYCODEX_LATEST_VERSION?.trim())
|
|
@@ -14255,7 +14369,7 @@ function isBunGlobalEntrypoint(invokedPath, env3) {
|
|
|
14255
14369
|
return isBunGlobalEntrypointPath(invokedPath, env3);
|
|
14256
14370
|
}
|
|
14257
14371
|
function defaultRunCommandForManualUpdate(command, args, options) {
|
|
14258
|
-
return new Promise((
|
|
14372
|
+
return new Promise((resolve12, reject) => {
|
|
14259
14373
|
const child = spawn4(command, args, {
|
|
14260
14374
|
cwd: options.cwd,
|
|
14261
14375
|
env: options.env,
|
|
@@ -14265,7 +14379,7 @@ function defaultRunCommandForManualUpdate(command, args, options) {
|
|
|
14265
14379
|
child.once("error", reject);
|
|
14266
14380
|
child.once("close", (code) => {
|
|
14267
14381
|
if (code === 0) {
|
|
14268
|
-
|
|
14382
|
+
resolve12();
|
|
14269
14383
|
return;
|
|
14270
14384
|
}
|
|
14271
14385
|
reject(new Error(`${command} ${args.join(" ")} exited with ${code ?? "unknown status"}`));
|
|
@@ -14305,7 +14419,7 @@ function compareVersions(left, right) {
|
|
|
14305
14419
|
function resolveInstalledVersionPath(env3, pluginRoot) {
|
|
14306
14420
|
if (env3.LAZYCODEX_INSTALLED_VERSION_FILE?.trim())
|
|
14307
14421
|
return env3.LAZYCODEX_INSTALLED_VERSION_FILE.trim();
|
|
14308
|
-
return
|
|
14422
|
+
return join34(pluginRoot, INSTALLED_VERSION_FILE);
|
|
14309
14423
|
}
|
|
14310
14424
|
function readVersionManifest(path2) {
|
|
14311
14425
|
try {
|
|
@@ -14321,15 +14435,15 @@ function readVersionManifest(path2) {
|
|
|
14321
14435
|
}
|
|
14322
14436
|
}
|
|
14323
14437
|
// packages/omo-codex/src/install/codex-git-bash-mcp-env.ts
|
|
14324
|
-
import { readFile as
|
|
14325
|
-
import { join as
|
|
14438
|
+
import { readFile as readFile19, writeFile as writeFile10 } from "node:fs/promises";
|
|
14439
|
+
import { join as join35 } from "node:path";
|
|
14326
14440
|
var GIT_BASH_ENV_KEY2 = "OMO_CODEX_GIT_BASH_PATH";
|
|
14327
14441
|
var CODEGRAPH_RELATIVE_ARGS2 = new Set(["components/codegraph/dist/serve.js", "./components/codegraph/dist/serve.js"]);
|
|
14328
14442
|
async function stampGitBashMcpEnv(input) {
|
|
14329
|
-
const manifestPath =
|
|
14443
|
+
const manifestPath = join35(input.pluginRoot, ".mcp.json");
|
|
14330
14444
|
if (!await fileExistsStrict(manifestPath))
|
|
14331
14445
|
return false;
|
|
14332
|
-
const parsed = JSON.parse(await
|
|
14446
|
+
const parsed = JSON.parse(await readFile19(manifestPath, "utf8"));
|
|
14333
14447
|
if (!isPlainRecord(parsed) || !isPlainRecord(parsed["mcpServers"]))
|
|
14334
14448
|
return false;
|
|
14335
14449
|
let changed = stampCodegraphMcpPath(parsed["mcpServers"], input.pluginRoot);
|
|
@@ -14359,7 +14473,7 @@ function stampCodegraphMcpPath(mcpServers, pluginRoot) {
|
|
|
14359
14473
|
const entrypoint = args[0];
|
|
14360
14474
|
if (typeof entrypoint !== "string" || !CODEGRAPH_RELATIVE_ARGS2.has(entrypoint))
|
|
14361
14475
|
return false;
|
|
14362
|
-
codegraphServer["args"] = [
|
|
14476
|
+
codegraphServer["args"] = [join35(pluginRoot, "components", "codegraph", "dist", "serve.js"), ...args.slice(1)];
|
|
14363
14477
|
return true;
|
|
14364
14478
|
}
|
|
14365
14479
|
|
|
@@ -14368,7 +14482,7 @@ async function installMarketplaceLocally(options = {}) {
|
|
|
14368
14482
|
return runCodexInstaller(options);
|
|
14369
14483
|
}
|
|
14370
14484
|
function resolveDefaultRepoRootForEntrypoint(entrypointPath) {
|
|
14371
|
-
return
|
|
14485
|
+
return resolve12(dirname11(entrypointPath), "..", "..", "..");
|
|
14372
14486
|
}
|
|
14373
14487
|
function resolveDefaultRepoRoot() {
|
|
14374
14488
|
return resolveDefaultRepoRootForEntrypoint(fileURLToPath2(import.meta.url));
|
|
@@ -14380,7 +14494,7 @@ async function runLazyCodexInstallLocalCli(input) {
|
|
|
14380
14494
|
return 0;
|
|
14381
14495
|
}
|
|
14382
14496
|
if (parsed.kind === "version") {
|
|
14383
|
-
const packageJson = JSON.parse(await
|
|
14497
|
+
const packageJson = JSON.parse(await readFile20(join36(input.defaultRepoRoot, "package.json"), "utf8"));
|
|
14384
14498
|
const version2 = typeof packageJson.version === "string" ? packageJson.version : "unknown";
|
|
14385
14499
|
input.log(`lazycodex-ai ${version2}`);
|
|
14386
14500
|
return 0;
|
|
@@ -14396,7 +14510,7 @@ async function runLazyCodexInstallLocalCli(input) {
|
|
|
14396
14510
|
return 0;
|
|
14397
14511
|
}
|
|
14398
14512
|
const result2 = await installMarketplaceLocally({
|
|
14399
|
-
repoRoot:
|
|
14513
|
+
repoRoot: resolve12(parsed.repoRoot),
|
|
14400
14514
|
autonomousPermissions: true,
|
|
14401
14515
|
env: input.env
|
|
14402
14516
|
});
|
|
@@ -14405,7 +14519,7 @@ async function runLazyCodexInstallLocalCli(input) {
|
|
|
14405
14519
|
}
|
|
14406
14520
|
return runLazyCodexManualUpdate({ env: input.env, dryRun: parsed.dryRun, log: input.log, invokedPath: input.invokedPath });
|
|
14407
14521
|
}
|
|
14408
|
-
const repoRoot = parsed.repoRoot ?
|
|
14522
|
+
const repoRoot = parsed.repoRoot ? resolve12(parsed.repoRoot) : input.defaultRepoRoot;
|
|
14409
14523
|
const result = await installMarketplaceLocally({
|
|
14410
14524
|
repoRoot,
|
|
14411
14525
|
autonomousPermissions: parsed.autonomousPermissions,
|