context-mode 2.1.7 → 2.1.9
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/plugin.json +1 -1
- package/README.md +72 -72
- package/SHA256SUMS +16 -16
- package/cli.mjs +787 -588
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +99 -99
- package/opencode/plugin.js +562 -271
- package/package.json +1 -1
- package/pi/index.js +416 -165
- package/qwen-extension.json +1 -1
- package/run.mjs +108 -33
- package/search.mjs +108 -33
- package/server.mjs +216 -81
package/server.mjs
CHANGED
|
@@ -3487,7 +3487,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
3487
3487
|
var NONE = 0;
|
|
3488
3488
|
var ASSUMED = 1;
|
|
3489
3489
|
var PROVEN = 2;
|
|
3490
|
-
function isRecursive(inst, stack2,
|
|
3490
|
+
function isRecursive(inst, stack2, resolve10) {
|
|
3491
3491
|
const cached4 = recursive.get(inst);
|
|
3492
3492
|
if (cached4 !== void 0)
|
|
3493
3493
|
return cached4 ? PROVEN : NONE;
|
|
@@ -3497,7 +3497,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3497
3497
|
let result = NONE;
|
|
3498
3498
|
const check2 = (child) => {
|
|
3499
3499
|
if (result !== PROVEN && child?._zod) {
|
|
3500
|
-
const answer3 = isRecursive(child, stack2,
|
|
3500
|
+
const answer3 = isRecursive(child, stack2, resolve10);
|
|
3501
3501
|
if (answer3 > result)
|
|
3502
3502
|
result = answer3;
|
|
3503
3503
|
}
|
|
@@ -3508,7 +3508,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3508
3508
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
3509
3509
|
if (spread && !desc.enumerable)
|
|
3510
3510
|
continue;
|
|
3511
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2,
|
|
3511
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve10) : NONE;
|
|
3512
3512
|
if (child > answer3)
|
|
3513
3513
|
answer3 = child;
|
|
3514
3514
|
}
|
|
@@ -3572,7 +3572,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3572
3572
|
break;
|
|
3573
3573
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
3574
3574
|
case "lazy": {
|
|
3575
|
-
const inner = def._cachedInner ?? (
|
|
3575
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
3576
3576
|
merge5(inner ? isRecursive(inner, stack2, false) : ASSUMED);
|
|
3577
3577
|
break;
|
|
3578
3578
|
}
|
|
@@ -11016,7 +11016,7 @@ var recursive2 = /* @__PURE__ */ new WeakMap();
|
|
|
11016
11016
|
var NONE2 = 0;
|
|
11017
11017
|
var ASSUMED2 = 1;
|
|
11018
11018
|
var PROVEN2 = 2;
|
|
11019
|
-
function isRecursive2(inst, stack2,
|
|
11019
|
+
function isRecursive2(inst, stack2, resolve10) {
|
|
11020
11020
|
const cached4 = recursive2.get(inst);
|
|
11021
11021
|
if (cached4 !== void 0)
|
|
11022
11022
|
return cached4 ? PROVEN2 : NONE2;
|
|
@@ -11026,7 +11026,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11026
11026
|
let result = NONE2;
|
|
11027
11027
|
const check2 = (child) => {
|
|
11028
11028
|
if (result !== PROVEN2 && child?._zod) {
|
|
11029
|
-
const answer3 = isRecursive2(child, stack2,
|
|
11029
|
+
const answer3 = isRecursive2(child, stack2, resolve10);
|
|
11030
11030
|
if (answer3 > result)
|
|
11031
11031
|
result = answer3;
|
|
11032
11032
|
}
|
|
@@ -11037,7 +11037,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11037
11037
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
11038
11038
|
if (spread && !desc.enumerable)
|
|
11039
11039
|
continue;
|
|
11040
|
-
const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2,
|
|
11040
|
+
const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve10) : NONE2;
|
|
11041
11041
|
if (child > answer3)
|
|
11042
11042
|
answer3 = child;
|
|
11043
11043
|
}
|
|
@@ -11101,7 +11101,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11101
11101
|
break;
|
|
11102
11102
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
11103
11103
|
case "lazy": {
|
|
11104
|
-
const inner = def._cachedInner ?? (
|
|
11104
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
11105
11105
|
merge5(inner ? isRecursive2(inner, stack2, false) : ASSUMED2);
|
|
11106
11106
|
break;
|
|
11107
11107
|
}
|
|
@@ -17705,14 +17705,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
17705
17705
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
17706
17706
|
}
|
|
17707
17707
|
function sleep(ms, signal) {
|
|
17708
|
-
return new Promise((
|
|
17708
|
+
return new Promise((resolve10, reject) => {
|
|
17709
17709
|
if (signal?.aborted) {
|
|
17710
17710
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
17711
17711
|
return;
|
|
17712
17712
|
}
|
|
17713
17713
|
const timer = setTimeout(() => {
|
|
17714
17714
|
signal?.removeEventListener("abort", onAbort);
|
|
17715
|
-
|
|
17715
|
+
resolve10();
|
|
17716
17716
|
}, ms);
|
|
17717
17717
|
const onAbort = () => {
|
|
17718
17718
|
clearTimeout(timer);
|
|
@@ -18511,7 +18511,7 @@ var Protocol = class {
|
|
|
18511
18511
|
const flowStartedAt = Date.now();
|
|
18512
18512
|
let onAbort;
|
|
18513
18513
|
let cleanupMessageId;
|
|
18514
|
-
return new Promise((
|
|
18514
|
+
return new Promise((resolve10, reject) => {
|
|
18515
18515
|
const earlyReject = (error42) => {
|
|
18516
18516
|
reject(error42);
|
|
18517
18517
|
};
|
|
@@ -18580,7 +18580,7 @@ var Protocol = class {
|
|
|
18580
18580
|
}
|
|
18581
18581
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
18582
18582
|
if (decoded.kind === "input_required") {
|
|
18583
|
-
if (options?.allowInputRequired === true) return
|
|
18583
|
+
if (options?.allowInputRequired === true) return resolve10(manualInputRequiredValue(decoded));
|
|
18584
18584
|
const flow = {
|
|
18585
18585
|
codec,
|
|
18586
18586
|
request: request2,
|
|
@@ -18592,11 +18592,11 @@ var Protocol = class {
|
|
|
18592
18592
|
params
|
|
18593
18593
|
}, resultSchema, legOptions)
|
|
18594
18594
|
};
|
|
18595
|
-
return
|
|
18595
|
+
return resolve10(this._resolveNonCompleteResult(decoded, flow));
|
|
18596
18596
|
}
|
|
18597
18597
|
const result = decoded.result;
|
|
18598
18598
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
18599
|
-
if (parseResult.success)
|
|
18599
|
+
if (parseResult.success) resolve10(parseResult.data);
|
|
18600
18600
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
18601
18601
|
}, reject);
|
|
18602
18602
|
});
|
|
@@ -21512,7 +21512,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
21512
21512
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
21513
21513
|
const schOrFunc = root.refs[ref];
|
|
21514
21514
|
if (schOrFunc) return schOrFunc;
|
|
21515
|
-
let _sch =
|
|
21515
|
+
let _sch = resolve10.call(this, root, ref);
|
|
21516
21516
|
if (_sch === void 0) {
|
|
21517
21517
|
const schema = (_a5 = root.localRefs) === null || _a5 === void 0 ? void 0 : _a5[ref];
|
|
21518
21518
|
const { schemaId } = this.opts;
|
|
@@ -21538,7 +21538,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
21538
21538
|
function sameSchemaEnv(s1, s2) {
|
|
21539
21539
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
21540
21540
|
}
|
|
21541
|
-
function
|
|
21541
|
+
function resolve10(root, ref) {
|
|
21542
21542
|
let sch;
|
|
21543
21543
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
21544
21544
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -21988,7 +21988,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
21988
21988
|
else if (typeof uri === "object") uri = parse6(serialize(uri, options), options);
|
|
21989
21989
|
return uri;
|
|
21990
21990
|
}
|
|
21991
|
-
function
|
|
21991
|
+
function resolve10(baseURI, relativeURI, options) {
|
|
21992
21992
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
21993
21993
|
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
21994
21994
|
schemelessOptions.skipEscape = true;
|
|
@@ -22162,7 +22162,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
22162
22162
|
const fastUri = {
|
|
22163
22163
|
SCHEMES,
|
|
22164
22164
|
normalize: normalize2,
|
|
22165
|
-
resolve:
|
|
22165
|
+
resolve: resolve10,
|
|
22166
22166
|
resolveComponent,
|
|
22167
22167
|
equal,
|
|
22168
22168
|
serialize,
|
|
@@ -27627,7 +27627,7 @@ var StdioServerTransport = class {
|
|
|
27627
27627
|
}
|
|
27628
27628
|
send(message2) {
|
|
27629
27629
|
if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
|
|
27630
|
-
return new Promise((
|
|
27630
|
+
return new Promise((resolve10, reject) => {
|
|
27631
27631
|
const json2 = serializeMessage(message2);
|
|
27632
27632
|
let settled = false;
|
|
27633
27633
|
const onError = (error42) => {
|
|
@@ -27642,14 +27642,14 @@ var StdioServerTransport = class {
|
|
|
27642
27642
|
settled = true;
|
|
27643
27643
|
this._stdout.off("error", onError);
|
|
27644
27644
|
this._stdout.off("drain", onDrain);
|
|
27645
|
-
|
|
27645
|
+
resolve10();
|
|
27646
27646
|
};
|
|
27647
27647
|
this._stdout.once("error", onError);
|
|
27648
27648
|
if (this._stdout.write(json2)) {
|
|
27649
27649
|
if (settled) return;
|
|
27650
27650
|
settled = true;
|
|
27651
27651
|
this._stdout.off("error", onError);
|
|
27652
|
-
|
|
27652
|
+
resolve10();
|
|
27653
27653
|
} else if (!settled) this._stdout.once("drain", onDrain);
|
|
27654
27654
|
});
|
|
27655
27655
|
}
|
|
@@ -27703,14 +27703,14 @@ var StdioConnectionChannel = class {
|
|
|
27703
27703
|
*/
|
|
27704
27704
|
async whenRequestsAnswered(timeoutMs) {
|
|
27705
27705
|
if (this._closed || this._pendingRequests.size === 0) return true;
|
|
27706
|
-
return await new Promise((
|
|
27706
|
+
return await new Promise((resolve10) => {
|
|
27707
27707
|
const waiter = () => {
|
|
27708
27708
|
clearTimeout(timer);
|
|
27709
|
-
|
|
27709
|
+
resolve10(true);
|
|
27710
27710
|
};
|
|
27711
27711
|
const timer = setTimeout(() => {
|
|
27712
27712
|
this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
|
|
27713
|
-
|
|
27713
|
+
resolve10(false);
|
|
27714
27714
|
}, timeoutMs);
|
|
27715
27715
|
this._drainWaiters.push(waiter);
|
|
27716
27716
|
});
|
|
@@ -28446,7 +28446,7 @@ function PURGE_SUMMARY(rows, scope) {
|
|
|
28446
28446
|
var DECISION_SOURCE = "decision";
|
|
28447
28447
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28448
28448
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28449
|
-
var BUNDLE_SHA = true ? "
|
|
28449
|
+
var BUNDLE_SHA = true ? "9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcde" : void 0;
|
|
28450
28450
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28451
28451
|
var DOCTOR_LABEL = Object.freeze({
|
|
28452
28452
|
D1: "version",
|
|
@@ -28850,6 +28850,14 @@ var V1_SCRIPT_NAMES = Object.freeze([
|
|
|
28850
28850
|
var V1_HOOK_COMMAND = "context-mode hook";
|
|
28851
28851
|
var V1_CODEX_HOOK_COMMAND = "context-mode hook codex";
|
|
28852
28852
|
var V1_CODEX_HOOKS_DIR = Object.freeze(["hooks", "codex"]);
|
|
28853
|
+
var V1_CODEX_SCRIPT_NAMES = Object.freeze([
|
|
28854
|
+
"pretooluse.mjs",
|
|
28855
|
+
"posttooluse.mjs",
|
|
28856
|
+
"sessionstart.mjs",
|
|
28857
|
+
"precompact.mjs",
|
|
28858
|
+
"userpromptsubmit.mjs",
|
|
28859
|
+
"stop.mjs"
|
|
28860
|
+
]);
|
|
28853
28861
|
var V1_CACHE_HEAL_NAME = "context-mode-cache-heal";
|
|
28854
28862
|
var V1_CACHE_HEAL_EXTS = Object.freeze([".mjs", ".sh"]);
|
|
28855
28863
|
var V1_STATUSLINE_COMMAND = "context-mode statusline";
|
|
@@ -28909,7 +28917,6 @@ var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
|
|
|
28909
28917
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
28910
28918
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
28911
28919
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
28912
|
-
var V1_SCRIPT_EXT = ".mjs";
|
|
28913
28920
|
var V1_BIN_COMMAND = SERVER_KEY;
|
|
28914
28921
|
var VSCODE_MCP_SERVERS_KEY = "servers";
|
|
28915
28922
|
var ZCODE_EVENTS_KEY = "events";
|
|
@@ -28925,7 +28932,7 @@ var V1_REASON = Object.freeze({
|
|
|
28925
28932
|
cacheHealFile: "old context-mode cache-heal script file",
|
|
28926
28933
|
statusLine: "old context-mode statusLine (context-mode statusline): report only, never removed",
|
|
28927
28934
|
mcpEntry: "old context-mode MCP entry mcpServers.context-mode",
|
|
28928
|
-
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex
|
|
28935
|
+
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/<event>.mjs",
|
|
28929
28936
|
codexToml: "old context-mode config.toml [mcp_servers.context-mode*] section",
|
|
28930
28937
|
hookFile: "old context-mode hook file context-mode.json (runs context-mode hook)",
|
|
28931
28938
|
vscodeMcp: "old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",
|
|
@@ -28963,7 +28970,6 @@ var HOST_CONFIG_TEXT_PATH = "(given text)";
|
|
|
28963
28970
|
var JSON_INDENT_UNIT = " ";
|
|
28964
28971
|
var MCP_COMMAND_FIELD = "command";
|
|
28965
28972
|
var MCP_ARGS_FIELD = "args";
|
|
28966
|
-
var MCP_ENV_FIELD = "env";
|
|
28967
28973
|
var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
|
|
28968
28974
|
var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
|
|
28969
28975
|
var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
|
|
@@ -29659,10 +29665,10 @@ function resolveConfigDir(env) {
|
|
|
29659
29665
|
}
|
|
29660
29666
|
|
|
29661
29667
|
// src/core/project/resolve.ts
|
|
29662
|
-
import { basename as basename2, dirname as dirname3, join as join3, resolve as
|
|
29668
|
+
import { basename as basename2, dirname as dirname3, join as join3, resolve as resolve3 } from "node:path";
|
|
29663
29669
|
|
|
29664
29670
|
// src/core/project/contain.ts
|
|
29665
|
-
import { dirname as dirname2, join as join2, relative, sep } from "node:path";
|
|
29671
|
+
import { dirname as dirname2, isAbsolute, join as join2, relative, resolve as resolve2, sep } from "node:path";
|
|
29666
29672
|
var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
29667
29673
|
function real(p) {
|
|
29668
29674
|
try {
|
|
@@ -29881,7 +29887,7 @@ function gitDirs(dir) {
|
|
|
29881
29887
|
const gitDir = gitDirAt(join3(cur, GIT_DIR_NAME));
|
|
29882
29888
|
if (gitDir !== null) {
|
|
29883
29889
|
const common = firstLine(join3(gitDir, GIT_COMMONDIR_FILE));
|
|
29884
|
-
return { commonDir: realpathSync3.native(common === null ? gitDir :
|
|
29890
|
+
return { commonDir: realpathSync3.native(common === null ? gitDir : resolve3(gitDir, common)), worktree: cur, start };
|
|
29885
29891
|
}
|
|
29886
29892
|
const up = dirname3(cur);
|
|
29887
29893
|
if (up === cur) return { commonDir: null, start };
|
|
@@ -29896,7 +29902,7 @@ function gitDirAt(dotGit) {
|
|
|
29896
29902
|
} else {
|
|
29897
29903
|
const line = firstLine(dotGit);
|
|
29898
29904
|
if (line === null || !line.startsWith(GITDIR_FILE_PREFIX)) return null;
|
|
29899
|
-
gitDir =
|
|
29905
|
+
gitDir = resolve3(dirname3(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
|
|
29900
29906
|
}
|
|
29901
29907
|
} catch {
|
|
29902
29908
|
return null;
|
|
@@ -44203,6 +44209,13 @@ function pathEntries(value, platform = process.platform, delimiter2 = platform =
|
|
|
44203
44209
|
const win = platform === "win32";
|
|
44204
44210
|
return value.split(delimiter2).map((e) => win && e.length >= 2 && e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e).filter(Boolean);
|
|
44205
44211
|
}
|
|
44212
|
+
function envValue(env, name, platform = process.platform) {
|
|
44213
|
+
const exact = env[name];
|
|
44214
|
+
if (exact !== void 0 || platform !== "win32") return exact;
|
|
44215
|
+
const upper = name.toUpperCase();
|
|
44216
|
+
const key = Object.keys(env).find((k) => k.toUpperCase() === upper);
|
|
44217
|
+
return key === void 0 ? void 0 : env[key];
|
|
44218
|
+
}
|
|
44206
44219
|
|
|
44207
44220
|
// src/core/sandbox/runtimes.ts
|
|
44208
44221
|
var PATHEXT_SEPARATOR = ";";
|
|
@@ -44246,8 +44259,8 @@ function isRunnable(full) {
|
|
|
44246
44259
|
}
|
|
44247
44260
|
function findRuntime(lang, env = process.env) {
|
|
44248
44261
|
if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
|
|
44249
|
-
const dirs = pathEntries(env
|
|
44250
|
-
const pathExt = isWin() ? (env
|
|
44262
|
+
const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
|
|
44263
|
+
const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
|
|
44251
44264
|
const names = candidates(lang);
|
|
44252
44265
|
let shim = null;
|
|
44253
44266
|
for (const dir of dirs) {
|
|
@@ -44310,10 +44323,10 @@ function startArgv(argv) {
|
|
|
44310
44323
|
return sh === null ? null : [sh, ...argv];
|
|
44311
44324
|
}
|
|
44312
44325
|
function runProcess(argv, o) {
|
|
44313
|
-
return new Promise((
|
|
44326
|
+
return new Promise((resolve10) => {
|
|
44314
44327
|
const isWin2 = process.platform === "win32";
|
|
44315
44328
|
const start = startArgv(argv);
|
|
44316
|
-
if (start === null) return
|
|
44329
|
+
if (start === null) return resolve10(NOT_STARTED);
|
|
44317
44330
|
let child;
|
|
44318
44331
|
try {
|
|
44319
44332
|
child = spawn2(start[0], start.slice(1), {
|
|
@@ -44327,7 +44340,7 @@ function runProcess(argv, o) {
|
|
|
44327
44340
|
windowsHide: true
|
|
44328
44341
|
});
|
|
44329
44342
|
} catch {
|
|
44330
|
-
return
|
|
44343
|
+
return resolve10(NOT_STARTED);
|
|
44331
44344
|
}
|
|
44332
44345
|
const stdoutChunks = [];
|
|
44333
44346
|
const stderrChunks = [];
|
|
@@ -44361,7 +44374,7 @@ function runProcess(argv, o) {
|
|
|
44361
44374
|
clearTimeout(drainTimer);
|
|
44362
44375
|
clearTimeout(stopTimer);
|
|
44363
44376
|
o.signal.removeEventListener("abort", onAbort);
|
|
44364
|
-
|
|
44377
|
+
resolve10({
|
|
44365
44378
|
stdout: Buffer.concat(stdoutChunks),
|
|
44366
44379
|
stderr: Buffer.concat(stderrChunks),
|
|
44367
44380
|
exitCode,
|
|
@@ -44808,12 +44821,16 @@ function answer(db, input, scope, ctx, nm, ms, indexed, sort, pick4) {
|
|
|
44808
44821
|
}
|
|
44809
44822
|
async function handler(input, ctx) {
|
|
44810
44823
|
const sort = input.sort ?? "relevance";
|
|
44811
|
-
if (sort === "timeline" && input.offset !==
|
|
44824
|
+
if (sort === "timeline" && (input.offset ?? 0) !== 0) {
|
|
44812
44825
|
return invalid("offset", 'drop offset; page a timeline with "after"');
|
|
44813
44826
|
}
|
|
44814
|
-
if (sort === "relevance" && input.after !==
|
|
44827
|
+
if (sort === "relevance" && (input.after ?? 0) !== 0) {
|
|
44815
44828
|
return invalid("after", 'drop after, or pass sort:"timeline"');
|
|
44816
44829
|
}
|
|
44830
|
+
if (input.source !== void 0 && input.source.trim() === "") {
|
|
44831
|
+
const { source: _blank, ...rest } = input;
|
|
44832
|
+
input = rest;
|
|
44833
|
+
}
|
|
44817
44834
|
const scope = input.scope ?? "worktree";
|
|
44818
44835
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
44819
44836
|
try {
|
|
@@ -45787,6 +45804,7 @@ function readResult6(p) {
|
|
|
45787
45804
|
const text = p.content === void 0 ? "" : typeof p.content === "string" ? p.content : JSON.stringify(p.content);
|
|
45788
45805
|
const info = { isError: p.isError === true, bytes: Buffer.byteLength(text), text };
|
|
45789
45806
|
if (typeof p.exitCode === "number") info.exitCode = p.exitCode;
|
|
45807
|
+
if (p.keep === true) info.keep = true;
|
|
45790
45808
|
return info;
|
|
45791
45809
|
}
|
|
45792
45810
|
function decode11(raw) {
|
|
@@ -45863,6 +45881,11 @@ function decode12(raw) {
|
|
|
45863
45881
|
const event = Object.prototype.hasOwnProperty.call(OPENCODE_EVENTS, native) ? OPENCODE_EVENTS[native] : void 0;
|
|
45864
45882
|
if (event === void 0) throw new Error("opencode: unknown hook event " + String(p.type));
|
|
45865
45883
|
const ev = { event, agent: "opencode", sessionId: String(p.sessionID ?? ""), cwd: String(p.directory ?? "") };
|
|
45884
|
+
if (typeof p.agentID === "string" && p.agentID !== "") {
|
|
45885
|
+
ev.agentId = p.agentID;
|
|
45886
|
+
ev.agentType = p.agentID;
|
|
45887
|
+
}
|
|
45888
|
+
if (Array.isArray(p.agentTools)) ev.agentTools = p.agentTools.filter((t) => typeof t === "string");
|
|
45866
45889
|
if (event === "UserPromptSubmit" && typeof p.message === "string") ev.prompt = p.message;
|
|
45867
45890
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
45868
45891
|
const name = String(p.tool ?? "");
|
|
@@ -45883,7 +45906,7 @@ function encode12(ev, d, _extra) {
|
|
|
45883
45906
|
if (ev.event !== "PreToolUse") return { stdout: "", exitCode: 0 };
|
|
45884
45907
|
return { stdout: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason, exitCode: 2 };
|
|
45885
45908
|
case "replace":
|
|
45886
|
-
return { stdout: "", exitCode: 0 };
|
|
45909
|
+
return { stdout: ev.event === "PostToolUse" ? d.output : "", exitCode: 0 };
|
|
45887
45910
|
}
|
|
45888
45911
|
}
|
|
45889
45912
|
|
|
@@ -46088,7 +46111,7 @@ var ADAPTERS = Object.freeze([
|
|
|
46088
46111
|
}
|
|
46089
46112
|
]);
|
|
46090
46113
|
var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
|
|
46091
|
-
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi"]);
|
|
46114
|
+
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
|
|
46092
46115
|
function hasReplace(row5) {
|
|
46093
46116
|
return REPLACE_ROWS.has(row5.id);
|
|
46094
46117
|
}
|
|
@@ -46120,7 +46143,7 @@ function ownBundleDir() {
|
|
|
46120
46143
|
|
|
46121
46144
|
// src/core/ops/doctor-config.ts
|
|
46122
46145
|
import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
46123
|
-
import { dirname as dirname7, join as join11 } from "node:path";
|
|
46146
|
+
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve4 } from "node:path";
|
|
46124
46147
|
|
|
46125
46148
|
// src/core/ops/host-text.ts
|
|
46126
46149
|
var BOM_CODE = 65279;
|
|
@@ -48806,7 +48829,7 @@ function flatCommands(events, prefix) {
|
|
|
48806
48829
|
return out;
|
|
48807
48830
|
}
|
|
48808
48831
|
var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
|
|
48809
|
-
var isCodexScript = (cmd) =>
|
|
48832
|
+
var isCodexScript = (cmd) => V1_PATH_SEPS.some((sep3) => V1_CODEX_SCRIPT_NAMES.some((name) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep3) + sep3 + name)));
|
|
48810
48833
|
function dataDir(dir, reason, out) {
|
|
48811
48834
|
if (existsSync7(dir)) out.push(finding(dir, "", reason));
|
|
48812
48835
|
}
|
|
@@ -48854,8 +48877,7 @@ function scanCodex(agentHome, out) {
|
|
|
48854
48877
|
const config4 = readTomlValue(tomlFile);
|
|
48855
48878
|
for (const span2 of readTomlTables(tomlFile)) {
|
|
48856
48879
|
if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
|
|
48857
|
-
if (
|
|
48858
|
-
if (span2.path.length === 3 && span2.path[2] === MCP_ENV_FIELD && isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
|
|
48880
|
+
if (isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
|
|
48859
48881
|
out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
|
|
48860
48882
|
}
|
|
48861
48883
|
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
@@ -49018,7 +49040,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
49018
49040
|
|
|
49019
49041
|
// src/core/ops/plugin-root.ts
|
|
49020
49042
|
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync7, realpathSync as realpathSync4 } from "node:fs";
|
|
49021
|
-
import { dirname as dirname6, isAbsolute, join as join10, sep as sep2 } from "node:path";
|
|
49043
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join10, sep as sep2 } from "node:path";
|
|
49022
49044
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
49023
49045
|
function missing(agent, path8) {
|
|
49024
49046
|
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
|
|
@@ -49130,7 +49152,7 @@ function configEntryRoot(adapter, env) {
|
|
|
49130
49152
|
const value = parseHostConfig(adapter.id, file2, current.text, current.format);
|
|
49131
49153
|
const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
|
|
49132
49154
|
const script = Array.isArray(args) ? args[0] : void 0;
|
|
49133
|
-
if (typeof script !== "string" || !
|
|
49155
|
+
if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
|
|
49134
49156
|
return dirname6(script);
|
|
49135
49157
|
}
|
|
49136
49158
|
function candidate(adapter, env, worktree) {
|
|
@@ -49350,11 +49372,122 @@ function nativeMcpWrong(dir, row5) {
|
|
|
49350
49372
|
return true;
|
|
49351
49373
|
}
|
|
49352
49374
|
}
|
|
49375
|
+
function opencodeEntrySpec(entry) {
|
|
49376
|
+
return isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : Array.isArray(entry) ? entry[0] : entry;
|
|
49377
|
+
}
|
|
49378
|
+
function isNativeOpencodeEntry(entry, key) {
|
|
49379
|
+
const spec = opencodeEntrySpec(entry);
|
|
49380
|
+
if (typeof spec !== "string") return false;
|
|
49381
|
+
return spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
49382
|
+
}
|
|
49353
49383
|
function isOwnOpencodeEntry(entry, key, own4) {
|
|
49354
|
-
const spec =
|
|
49384
|
+
const spec = opencodeEntrySpec(entry);
|
|
49355
49385
|
if (typeof spec !== "string") return false;
|
|
49356
|
-
|
|
49357
|
-
|
|
49386
|
+
return spec === OPENCODE_GIT_SPEC || own4.includes(spec) || isNativeOpencodeEntry(entry, key);
|
|
49387
|
+
}
|
|
49388
|
+
function stringLiterals(src) {
|
|
49389
|
+
const out = [];
|
|
49390
|
+
let i = 0;
|
|
49391
|
+
while (i < src.length) {
|
|
49392
|
+
const c = src[i];
|
|
49393
|
+
if (c === "/" && src[i + 1] === "/") {
|
|
49394
|
+
const n = src.indexOf("\n", i);
|
|
49395
|
+
i = n < 0 ? src.length : n;
|
|
49396
|
+
continue;
|
|
49397
|
+
}
|
|
49398
|
+
if (c === "/" && src[i + 1] === "*") {
|
|
49399
|
+
const n = src.indexOf("*/", i + 2);
|
|
49400
|
+
i = n < 0 ? src.length : n + 2;
|
|
49401
|
+
continue;
|
|
49402
|
+
}
|
|
49403
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
49404
|
+
let j = i + 1;
|
|
49405
|
+
let s = "";
|
|
49406
|
+
while (j < src.length && src[j] !== c) {
|
|
49407
|
+
if (src[j] === "\\") {
|
|
49408
|
+
s += src[j + 1] ?? "";
|
|
49409
|
+
j += 2;
|
|
49410
|
+
continue;
|
|
49411
|
+
}
|
|
49412
|
+
s += src[j];
|
|
49413
|
+
j++;
|
|
49414
|
+
}
|
|
49415
|
+
out.push(s);
|
|
49416
|
+
i = j + 1;
|
|
49417
|
+
continue;
|
|
49418
|
+
}
|
|
49419
|
+
i++;
|
|
49420
|
+
}
|
|
49421
|
+
return out;
|
|
49422
|
+
}
|
|
49423
|
+
var OPENCODE_PLUGINS_DIR = "plugins";
|
|
49424
|
+
var OPENCODE_PROJECT_DIR = ".opencode";
|
|
49425
|
+
var OPENCODE_PLUGIN_EXTS = [".js", ".mjs", ".ts"];
|
|
49426
|
+
var OPENCODE_PLUGIN_INDEX = "index";
|
|
49427
|
+
var OPENCODE_DIR_FILE_MAX = 64 * 1024;
|
|
49428
|
+
var OWN_PLUGIN_MODULES = [SERVER_KEY, `${SERVER_KEY}/server`];
|
|
49429
|
+
var FILE_URL_PREFIX = "file://";
|
|
49430
|
+
var NODE_MODULES_DIR = "node_modules";
|
|
49431
|
+
var PACKAGE_JSON_FILE = "package.json";
|
|
49432
|
+
var OPENCODE_PACKAGE_DIR_HINT = `${NODE_MODULES_DIR}/${SERVER_KEY}`;
|
|
49433
|
+
function opencodePluginDirs(configDir, worktree) {
|
|
49434
|
+
return [configDir, opencodeProjectDir(worktree)];
|
|
49435
|
+
}
|
|
49436
|
+
function opencodeProjectDir(worktree) {
|
|
49437
|
+
return join11(worktree, OPENCODE_PROJECT_DIR);
|
|
49438
|
+
}
|
|
49439
|
+
function packageResolves(fromDir) {
|
|
49440
|
+
for (let d = fromDir; ; d = dirname7(d)) {
|
|
49441
|
+
if (existsSync10(join11(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
|
|
49442
|
+
if (dirname7(d) === d) return false;
|
|
49443
|
+
}
|
|
49444
|
+
}
|
|
49445
|
+
function opencodeDirPlugins(dirs) {
|
|
49446
|
+
const bundle = opencodePluginFile();
|
|
49447
|
+
const ownFile = join11(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
|
|
49448
|
+
const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
|
|
49449
|
+
const isPath = (p) => {
|
|
49450
|
+
if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
|
|
49451
|
+
const seg = p.split("/");
|
|
49452
|
+
const n = seg.length;
|
|
49453
|
+
return n >= 3 && seg[n - 1] === "plugin.js" && seg[n - 2] === "opencode" && seg[n - 3] === SERVER_KEY;
|
|
49454
|
+
};
|
|
49455
|
+
const out = [];
|
|
49456
|
+
for (const dir of dirs) {
|
|
49457
|
+
const pdir = join11(dir, OPENCODE_PLUGINS_DIR);
|
|
49458
|
+
let names;
|
|
49459
|
+
try {
|
|
49460
|
+
names = readdirSync7(pdir);
|
|
49461
|
+
} catch {
|
|
49462
|
+
continue;
|
|
49463
|
+
}
|
|
49464
|
+
for (const name of names) {
|
|
49465
|
+
const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join11(pdir, name)] : [];
|
|
49466
|
+
const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join11(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
|
|
49467
|
+
for (const f of files) {
|
|
49468
|
+
let text;
|
|
49469
|
+
try {
|
|
49470
|
+
const b = readFileSync9(f);
|
|
49471
|
+
if (b.length > OPENCODE_DIR_FILE_MAX) continue;
|
|
49472
|
+
text = b.toString("utf8");
|
|
49473
|
+
} catch {
|
|
49474
|
+
continue;
|
|
49475
|
+
}
|
|
49476
|
+
const lits = stringLiterals(text).map((s) => s.split("\\").join("/")).filter((p) => isModule(p) || isPath(p));
|
|
49477
|
+
if (!lits.length) continue;
|
|
49478
|
+
const loads = lits.some((p) => {
|
|
49479
|
+
if (isModule(p)) return packageResolves(dirname7(f));
|
|
49480
|
+
const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
|
|
49481
|
+
return existsSync10(isAbsolute3(bare2) ? bare2 : resolve4(dirname7(f), bare2));
|
|
49482
|
+
});
|
|
49483
|
+
out.push({ file: f, loads });
|
|
49484
|
+
}
|
|
49485
|
+
}
|
|
49486
|
+
}
|
|
49487
|
+
return out;
|
|
49488
|
+
}
|
|
49489
|
+
function opencodeDirPlugin(dirs) {
|
|
49490
|
+
return opencodeDirPlugins(dirs).find((p) => p.loads)?.file;
|
|
49358
49491
|
}
|
|
49359
49492
|
function opencodeMcpOwn(entry) {
|
|
49360
49493
|
if (!isObject4(entry)) return false;
|
|
@@ -49375,7 +49508,8 @@ function opencodeValueListed(value) {
|
|
|
49375
49508
|
}
|
|
49376
49509
|
function opencodeListed(file2, worktree) {
|
|
49377
49510
|
const dirs = [dirname7(file2), worktree];
|
|
49378
|
-
|
|
49511
|
+
if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join11(dir, name)))))) return true;
|
|
49512
|
+
return opencodeDirPlugin(opencodePluginDirs(dirname7(file2), worktree)) !== void 0;
|
|
49379
49513
|
}
|
|
49380
49514
|
function mcpWrong(row5, home, env, worktree) {
|
|
49381
49515
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
@@ -49598,7 +49732,7 @@ async function checkIndex(project) {
|
|
|
49598
49732
|
|
|
49599
49733
|
// src/core/ops/doctor-env.ts
|
|
49600
49734
|
import { existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
49601
|
-
import { isAbsolute as
|
|
49735
|
+
import { isAbsolute as isAbsolute4, join as join12, relative as relative2 } from "node:path";
|
|
49602
49736
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49603
49737
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49604
49738
|
}
|
|
@@ -49767,7 +49901,7 @@ function checkMcp(ctx, adapter) {
|
|
|
49767
49901
|
function piCwdInside(worktree, piCwd) {
|
|
49768
49902
|
if (piCwd === void 0 || !existsSync12(piCwd)) return false;
|
|
49769
49903
|
const rel = relative2(worktree, realpathSync6.native(piCwd));
|
|
49770
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
49904
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
|
|
49771
49905
|
}
|
|
49772
49906
|
function checkProject(i) {
|
|
49773
49907
|
const bad = fail3("D7", D7_DETAIL(i.project.source), D7_FIX);
|
|
@@ -51551,7 +51685,7 @@ function hasType(v, t) {
|
|
|
51551
51685
|
function same(a, b) {
|
|
51552
51686
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
51553
51687
|
}
|
|
51554
|
-
function
|
|
51688
|
+
function resolve5(root, ref) {
|
|
51555
51689
|
const parts = ref.split("/");
|
|
51556
51690
|
if (parts[0] !== "#") throw new Error(`hook-shape: only local $ref is read, got ${ref}`);
|
|
51557
51691
|
let at = root;
|
|
@@ -51564,7 +51698,7 @@ function shapeErrors(schema, value, root = schema, at = "$") {
|
|
|
51564
51698
|
if (!NOTE_KEYS.has(k) && !RULE_KEYS.has(k)) throw new Error(`hook-shape: keyword ${k} at ${at} is not read by the checker`);
|
|
51565
51699
|
}
|
|
51566
51700
|
const errs = [];
|
|
51567
|
-
if (typeof schema.$ref === "string") errs.push(...shapeErrors(
|
|
51701
|
+
if (typeof schema.$ref === "string") errs.push(...shapeErrors(resolve5(root, schema.$ref), value, root, at));
|
|
51568
51702
|
if (Array.isArray(schema.allOf)) for (const s of schema.allOf) errs.push(...shapeErrors(s, value, root, at));
|
|
51569
51703
|
if (schema.type !== void 0) {
|
|
51570
51704
|
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
@@ -51626,7 +51760,7 @@ var WIN_EXT = ".COM;.EXE;.BAT;.CMD";
|
|
|
51626
51760
|
var WIN_SHIM_EXTS = Object.freeze([".cmd", ".bat"]);
|
|
51627
51761
|
var DEFAULT_COMSPEC = "cmd.exe";
|
|
51628
51762
|
function envGet(env, k) {
|
|
51629
|
-
return
|
|
51763
|
+
return envValue(env, k, "win32");
|
|
51630
51764
|
}
|
|
51631
51765
|
function whichBin(bin, env, platform = process.platform) {
|
|
51632
51766
|
const get = (k) => envGet(env, k);
|
|
@@ -51731,14 +51865,14 @@ function pluginHooksFromReply(m, pluginId) {
|
|
|
51731
51865
|
function askPluginHooks(env, pluginId, cwd) {
|
|
51732
51866
|
const bin = whichBin("codex", env);
|
|
51733
51867
|
if (!bin) return Promise.resolve({ kind: "absent" });
|
|
51734
|
-
return new Promise((
|
|
51868
|
+
return new Promise((resolve10) => {
|
|
51735
51869
|
let asked;
|
|
51736
51870
|
const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
|
|
51737
51871
|
let f;
|
|
51738
51872
|
try {
|
|
51739
51873
|
f = spawnForm(bin, ["app-server"], env);
|
|
51740
51874
|
} catch {
|
|
51741
|
-
|
|
51875
|
+
resolve10({ kind: "silent" });
|
|
51742
51876
|
return;
|
|
51743
51877
|
}
|
|
51744
51878
|
const child = spawn3(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
|
|
@@ -51748,7 +51882,7 @@ function askPluginHooks(env, pluginId, cwd) {
|
|
|
51748
51882
|
let result;
|
|
51749
51883
|
const settle3 = () => {
|
|
51750
51884
|
clearTimeout(grace);
|
|
51751
|
-
|
|
51885
|
+
resolve10(done_(result));
|
|
51752
51886
|
};
|
|
51753
51887
|
let grace;
|
|
51754
51888
|
const finish2 = (v) => {
|
|
@@ -52107,14 +52241,14 @@ async function checkHookRoundTrip(i) {
|
|
|
52107
52241
|
}
|
|
52108
52242
|
|
|
52109
52243
|
// src/core/hooks/fallback.ts
|
|
52110
|
-
import { join as join14, resolve as
|
|
52244
|
+
import { join as join14, resolve as resolve7 } from "node:path";
|
|
52111
52245
|
|
|
52112
52246
|
// src/core/policy/read-media.ts
|
|
52113
52247
|
import { extname } from "node:path";
|
|
52114
52248
|
var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
|
|
52115
52249
|
|
|
52116
52250
|
// src/core/policy/own-file.ts
|
|
52117
|
-
import { extname as extname2, join as join13 } from "node:path";
|
|
52251
|
+
import { extname as extname2, join as join13, resolve as resolve6 } from "node:path";
|
|
52118
52252
|
|
|
52119
52253
|
// src/core/hooks/fallback.ts
|
|
52120
52254
|
var fs = process.getBuiltinModule("node:fs");
|
|
@@ -52368,7 +52502,7 @@ function gitVersion(env) {
|
|
|
52368
52502
|
function onPath(env, tool) {
|
|
52369
52503
|
const names = process.platform === "win32" ? [tool + EXE_SUFFIX, tool + ".cmd", tool] : [tool];
|
|
52370
52504
|
const out = [];
|
|
52371
|
-
for (const dir of (env
|
|
52505
|
+
for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
|
|
52372
52506
|
if (dir === "") continue;
|
|
52373
52507
|
for (const n of names) if (existsSync16(join16(dir, n))) {
|
|
52374
52508
|
out.push(join16(dir, n));
|
|
@@ -52690,7 +52824,7 @@ var ctxDoctor = Object.freeze({
|
|
|
52690
52824
|
// src/core/tools/execute.ts
|
|
52691
52825
|
import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
52692
52826
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
52693
|
-
import { dirname as dirname10, join as join18, parse as parse5, resolve as
|
|
52827
|
+
import { dirname as dirname10, join as join18, parse as parse5, resolve as resolve8 } from "node:path";
|
|
52694
52828
|
|
|
52695
52829
|
// src/core/index/select.ts
|
|
52696
52830
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -52876,7 +53010,7 @@ async function handler3(raw, ctx) {
|
|
|
52876
53010
|
const cwd = ctx.project.worktree;
|
|
52877
53011
|
const extra = { ...PLAIN_OUTPUT_ENV2 };
|
|
52878
53012
|
if (input.file !== void 0) {
|
|
52879
|
-
const abs =
|
|
53013
|
+
const abs = resolve8(cwd, input.file);
|
|
52880
53014
|
const bad = fileError(input.file, abs, ctx.project.containmentRoot);
|
|
52881
53015
|
if (bad !== null) return fail4(bad);
|
|
52882
53016
|
extra.CTX_FILE = abs;
|
|
@@ -52931,7 +53065,7 @@ var ctxExecute = {
|
|
|
52931
53065
|
|
|
52932
53066
|
// src/core/tools/index.ts
|
|
52933
53067
|
import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "node:fs";
|
|
52934
|
-
import { dirname as dirname11, extname as extname3, join as join20, relative as relative3, resolve as
|
|
53068
|
+
import { dirname as dirname11, extname as extname3, join as join20, relative as relative3, resolve as resolve9 } from "node:path";
|
|
52935
53069
|
|
|
52936
53070
|
// src/core/index/walk.ts
|
|
52937
53071
|
import { readdirSync as readdirSync9, readFileSync as readFileSync14, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
@@ -53142,15 +53276,15 @@ function parseUrl(raw) {
|
|
|
53142
53276
|
if (u.protocol !== "http:" && u.protocol !== "https:") throw fail5("ERR_INVALID_PROTOCOL");
|
|
53143
53277
|
return u;
|
|
53144
53278
|
}
|
|
53145
|
-
function
|
|
53279
|
+
function envValue2(upper) {
|
|
53146
53280
|
const v = process.env[upper] ?? process.env[upper.toLowerCase()];
|
|
53147
53281
|
return v === void 0 || v.trim() === "" ? void 0 : v.trim();
|
|
53148
53282
|
}
|
|
53149
53283
|
function pickProxy(u) {
|
|
53150
|
-
const raw =
|
|
53284
|
+
const raw = envValue2(u.protocol === "https:" ? "HTTPS_PROXY" : "HTTP_PROXY");
|
|
53151
53285
|
if (raw === void 0) return void 0;
|
|
53152
53286
|
const host = bare(u.hostname).toLowerCase();
|
|
53153
|
-
for (const item of (
|
|
53287
|
+
for (const item of (envValue2("NO_PROXY") ?? "").split(",")) {
|
|
53154
53288
|
let entry = item.trim().toLowerCase();
|
|
53155
53289
|
if (entry.startsWith(".")) entry = entry.slice(1);
|
|
53156
53290
|
if (entry !== "" && (host === entry || host.endsWith("." + entry))) return void 0;
|
|
@@ -53218,18 +53352,18 @@ function request(u, conn, proxy, signal) {
|
|
|
53218
53352
|
const host = bare(u.hostname);
|
|
53219
53353
|
const port = u.port === "" ? defaultPort(u.protocol) : Number(u.port);
|
|
53220
53354
|
const path8 = u.pathname + u.search;
|
|
53221
|
-
return new Promise((
|
|
53355
|
+
return new Promise((resolve10, reject) => {
|
|
53222
53356
|
const onErr = (err) => reject(fail5(causeCode(err)));
|
|
53223
53357
|
if (proxy === void 0) {
|
|
53224
53358
|
const mod = u.protocol === "https:" ? https : http;
|
|
53225
53359
|
const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
|
|
53226
|
-
req.on("response",
|
|
53360
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53227
53361
|
return;
|
|
53228
53362
|
}
|
|
53229
53363
|
const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
|
|
53230
53364
|
if (u.protocol === "http:") {
|
|
53231
53365
|
const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
|
|
53232
|
-
req.on("response",
|
|
53366
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53233
53367
|
return;
|
|
53234
53368
|
}
|
|
53235
53369
|
const authority = (isIP(host) === 6 ? "[" + host + "]" : host) + ":" + port;
|
|
@@ -53249,16 +53383,16 @@ function request(u, conn, proxy, signal) {
|
|
|
53249
53383
|
headers: { host: u.host },
|
|
53250
53384
|
createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
|
|
53251
53385
|
});
|
|
53252
|
-
req.on("response",
|
|
53386
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53253
53387
|
});
|
|
53254
53388
|
tunnel.end();
|
|
53255
53389
|
});
|
|
53256
53390
|
}
|
|
53257
53391
|
function readBody(res) {
|
|
53258
|
-
return new Promise((
|
|
53392
|
+
return new Promise((resolve10, reject) => {
|
|
53259
53393
|
const parts = [];
|
|
53260
53394
|
res.on("data", (b) => parts.push(b));
|
|
53261
|
-
res.on("end", () =>
|
|
53395
|
+
res.on("end", () => resolve10(Buffer.concat(parts)));
|
|
53262
53396
|
res.on("error", (err) => reject(fail5(causeCode(err))));
|
|
53263
53397
|
res.on("aborted", () => reject(fail5("ECONNRESET")));
|
|
53264
53398
|
});
|
|
@@ -57136,7 +57270,7 @@ function missingOrOutside(given, abs, root) {
|
|
|
57136
57270
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
57137
57271
|
}
|
|
57138
57272
|
function pathItems(input, project) {
|
|
57139
|
-
const abs =
|
|
57273
|
+
const abs = resolve9(project.worktree, input.path);
|
|
57140
57274
|
if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
|
|
57141
57275
|
const base = relative3(project.worktree, abs);
|
|
57142
57276
|
if (statSync7(abs).isDirectory()) {
|
|
@@ -57568,7 +57702,8 @@ function reply3(text, isError) {
|
|
|
57568
57702
|
return { text, isError, sandboxBytes: 0 };
|
|
57569
57703
|
}
|
|
57570
57704
|
async function handler6(input, ctx) {
|
|
57571
|
-
const
|
|
57705
|
+
const given = input.session !== void 0 && input.session.trim() !== "" ? input.session : void 0;
|
|
57706
|
+
const sessionId = given ?? ctx.sessionId;
|
|
57572
57707
|
if (sessionId === "") return reply3(RESUME_NO_SESSION_LINE, true);
|
|
57573
57708
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
57574
57709
|
try {
|
|
@@ -58468,12 +58603,12 @@ function sessionIdOf(meta3, agent, env, serverId) {
|
|
|
58468
58603
|
return RUN_SESSION_PREFIX + serverId;
|
|
58469
58604
|
}
|
|
58470
58605
|
var CODEX_SANDBOX_STATE_META = "codex/sandbox-state-meta";
|
|
58471
|
-
var
|
|
58606
|
+
var FILE_URL_PREFIX2 = "file:";
|
|
58472
58607
|
function workspaceFromMeta(meta3) {
|
|
58473
58608
|
const state = meta3?.[CODEX_SANDBOX_STATE_META];
|
|
58474
58609
|
const cwd = typeof state === "object" && state !== null ? state.sandboxCwd : void 0;
|
|
58475
58610
|
if (typeof cwd !== "string" || cwd === "") return void 0;
|
|
58476
|
-
if (!cwd.startsWith(
|
|
58611
|
+
if (!cwd.startsWith(FILE_URL_PREFIX2)) return cwd;
|
|
58477
58612
|
try {
|
|
58478
58613
|
return fileURLToPath3(cwd);
|
|
58479
58614
|
} catch {
|
|
@@ -58497,7 +58632,7 @@ async function workspaceFromRoots(server) {
|
|
|
58497
58632
|
try {
|
|
58498
58633
|
const { roots } = await server.server.listRoots(void 0, { timeout: ROOTS_TIMEOUT_MS });
|
|
58499
58634
|
for (const root of roots) {
|
|
58500
|
-
if (root.uri.startsWith(
|
|
58635
|
+
if (root.uri.startsWith(FILE_URL_PREFIX2)) return fileURLToPath3(root.uri);
|
|
58501
58636
|
}
|
|
58502
58637
|
} catch (err) {
|
|
58503
58638
|
console.error("context-mode: roots/list: " + (err instanceof Error ? err.message : String(err)));
|
|
@@ -58664,7 +58799,7 @@ async function startServer(argv, env) {
|
|
|
58664
58799
|
}
|
|
58665
58800
|
installExitGuard({ onShutdown: shutdown, isTTY: process.stdin.isTTY === true });
|
|
58666
58801
|
handle = serveStdio(createServer);
|
|
58667
|
-
await new Promise((
|
|
58802
|
+
await new Promise((resolve10) => process.once("exit", () => resolve10()));
|
|
58668
58803
|
}
|
|
58669
58804
|
if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
|
|
58670
58805
|
const [, , ...cliArgs] = process.argv;
|