context-mode 2.1.8 → 2.1.10
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 +198 -178
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +98 -98
- package/opencode/plugin.js +168 -62
- package/package.json +1 -1
- package/pi/index.js +168 -64
- package/qwen-extension.json +1 -1
- package/run.mjs +43 -8
- package/search.mjs +43 -8
- package/server.mjs +62 -27
package/opencode/plugin.js
CHANGED
|
@@ -40,6 +40,15 @@ function REPLACE_HANDLE_LINE(intent, handle, bytes5, prefix = "", asked = "") {
|
|
|
40
40
|
const queries = asked === "" ? [intent] : [intent, asked];
|
|
41
41
|
return prefix + "ctx_search({queries:[" + queries.map((q) => JSON.stringify(q)).join(",") + "], source:" + JSON.stringify(handle) + "}) searches the whole output (" + bytes5 + " B).";
|
|
42
42
|
}
|
|
43
|
+
function SUBAGENT_HANDLE_LINE(handle, bytes5, read3) {
|
|
44
|
+
return "The full output (" + bytes5 + " B) is stored as " + handle + "; above is the best-matching part." + (read3 ? " Read the file with offset and limit for other lines." : "");
|
|
45
|
+
}
|
|
46
|
+
function SEARCH_TWIN_LINE(searchPath, handle, terms, projectDir) {
|
|
47
|
+
return " Or run: node " + shellWord(searchPath) + " " + handle + " " + shellWord(terms) + " " + shellWord(projectDir);
|
|
48
|
+
}
|
|
49
|
+
function shellWord(s) {
|
|
50
|
+
return "'" + s.split("'").join("'\\''") + "'";
|
|
51
|
+
}
|
|
43
52
|
var HANDLE_PROMPT_WORDS = 3;
|
|
44
53
|
var MAX_CHUNK_BYTES = 4096;
|
|
45
54
|
var SEARCH_PAGE_SIZE = 20;
|
|
@@ -224,6 +233,8 @@ var CANCELLED_LINE = "Cancelled.";
|
|
|
224
233
|
var BACKGROUND_REPLY_PREFIX = "started in background, pid ";
|
|
225
234
|
var PLAIN_OUTPUT_ENV = Object.freeze({ NO_COLOR: "1", FORCE_COLOR: "0" });
|
|
226
235
|
var RUN_LABEL_PREFIX = "run.mjs:";
|
|
236
|
+
var SEARCH_WRAPPER_FILE = "search.mjs";
|
|
237
|
+
var RUN_WRAPPER_AGENT = "claude-code";
|
|
227
238
|
var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" });
|
|
228
239
|
var NODE_MIN = "24.15.0";
|
|
229
240
|
var DATA_ROOT = "~/.context-mode";
|
|
@@ -233,6 +244,7 @@ var REQUIRE_SECURITY_ENV = "CONTEXT_MODE_REQUIRE_SECURITY";
|
|
|
233
244
|
var HOST_CONFIG_DIR_NAME = ".claude";
|
|
234
245
|
var AGENTS_DIR_NAME = "agents";
|
|
235
246
|
var AGENT_FILE_EXT = ".md";
|
|
247
|
+
var SYNCED_PLUGINS_DIR_NAME = "synced";
|
|
236
248
|
var HOST_PLUGINS_DIR_NAME = "plugins";
|
|
237
249
|
var INSTALLED_PLUGINS_FILE = "installed_plugins.json";
|
|
238
250
|
var PLUGIN_AGENT_SEPARATOR = ":";
|
|
@@ -468,7 +480,7 @@ var DECISION_ANSWERS_KEY = "answers";
|
|
|
468
480
|
var DECISION_OPTION_KEY = "option";
|
|
469
481
|
var DECISION_LABEL_JOIN = " | ";
|
|
470
482
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
471
|
-
var BUNDLE_SHA = true ? "
|
|
483
|
+
var BUNDLE_SHA = true ? "877eebcc432f90882c2b5ea04ad22fc95e9dc6c2" : void 0;
|
|
472
484
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
473
485
|
var DOCTOR_LABEL = Object.freeze({
|
|
474
486
|
D1: "version",
|
|
@@ -809,9 +821,14 @@ var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace
|
|
|
809
821
|
var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
|
|
810
822
|
var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
|
|
811
823
|
var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
|
|
812
|
-
|
|
813
|
-
|
|
824
|
+
var D5_BARE_SHARE = 0.5;
|
|
825
|
+
function D5_SLOW_DETAIL(ms, bound = HOOK_P95_MS) {
|
|
826
|
+
return `hook round trip took ${ms} ms over bare node, over ${bound} ms`;
|
|
827
|
+
}
|
|
828
|
+
function D5_SLOW_START_DETAIL(ms, bare2, bound) {
|
|
829
|
+
return `hook adds ${ms} ms to a ${bare2} ms node start, inside ${bound} ms (half a start): node starts slowly on this machine`;
|
|
814
830
|
}
|
|
831
|
+
var D5_IN_PROCESS_DETAIL = "native shape ok; hooks run inside the host process, so a tool call pays no node start";
|
|
815
832
|
var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
|
|
816
833
|
var D5_FIX = "run ctx_upgrade";
|
|
817
834
|
var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
|
|
@@ -3680,7 +3697,15 @@ function resolveConfigDir(env) {
|
|
|
3680
3697
|
}
|
|
3681
3698
|
|
|
3682
3699
|
// src/core/policy/subagent.ts
|
|
3683
|
-
var { readFileSync: readFileSync2 } = process.getBuiltinModule("node:fs");
|
|
3700
|
+
var { readFileSync: readFileSync2, readdirSync: readdirSync2 } = process.getBuiltinModule("node:fs");
|
|
3701
|
+
var CC_READ_ONLY_DENY = Object.freeze(["Agent", "Artifact", "ArtifactComments", "ArtifactData", "ArtifactCheck", "ExitPlanMode", "Edit", "Write", "NotebookEdit"]);
|
|
3702
|
+
var CLAUDE_CODE_BUILT_INS = Object.freeze({
|
|
3703
|
+
"general-purpose": { tools: null, disallowed: [] },
|
|
3704
|
+
fork: { tools: null, disallowed: [] },
|
|
3705
|
+
Explore: { tools: null, disallowed: [...CC_READ_ONLY_DENY] },
|
|
3706
|
+
Plan: { tools: null, disallowed: [...CC_READ_ONLY_DENY] }
|
|
3707
|
+
});
|
|
3708
|
+
var BUILT_IN_AGENT = "claude-code";
|
|
3684
3709
|
function isSubagentCall(ev) {
|
|
3685
3710
|
return ev.agentId !== void 0 && ev.agentId !== "";
|
|
3686
3711
|
}
|
|
@@ -3697,7 +3722,7 @@ function toolSetForAgentType(ev, src) {
|
|
|
3697
3722
|
const row5 = getAdapter(ev.agent);
|
|
3698
3723
|
if (src.manifestTools !== void 0) return unique(src.manifestTools.map((n) => norm(row5, n)));
|
|
3699
3724
|
const type = ev.agentType ?? "";
|
|
3700
|
-
const def = findDef(type, src);
|
|
3725
|
+
const def = findDef(type, src) ?? builtIn(ev.agent, type);
|
|
3701
3726
|
if (def === null) return null;
|
|
3702
3727
|
const tools = (def.tools ?? allKnownToolNames(row5)).map((n) => norm(row5, n));
|
|
3703
3728
|
const deny2 = def.disallowed.map((n) => norm(row5, n));
|
|
@@ -3725,6 +3750,11 @@ function findDef(type, src) {
|
|
|
3725
3750
|
}
|
|
3726
3751
|
return null;
|
|
3727
3752
|
}
|
|
3753
|
+
function builtIn(agent, type) {
|
|
3754
|
+
if (agent !== BUILT_IN_AGENT || !Object.prototype.hasOwnProperty.call(CLAUDE_CODE_BUILT_INS, type)) return null;
|
|
3755
|
+
const d = CLAUDE_CODE_BUILT_INS[type];
|
|
3756
|
+
return { tools: d.tools, disallowed: [...d.disallowed] };
|
|
3757
|
+
}
|
|
3728
3758
|
function safeType(type) {
|
|
3729
3759
|
if (type === "" || type === "." || type === "..") return false;
|
|
3730
3760
|
if (type.indexOf("/") >= 0 || type.indexOf("\\") >= 0) return false;
|
|
@@ -3739,6 +3769,9 @@ function readPluginAgent(claudeDir, type) {
|
|
|
3739
3769
|
const plugin = type.slice(0, cut);
|
|
3740
3770
|
const agent = type.slice(cut + PLUGIN_AGENT_SEPARATOR.length);
|
|
3741
3771
|
if (agent.indexOf(PLUGIN_AGENT_SEPARATOR) >= 0) return null;
|
|
3772
|
+
return installedPluginAgent(claudeDir, plugin, agent) ?? syncedPluginAgent(claudeDir, plugin, agent);
|
|
3773
|
+
}
|
|
3774
|
+
function installedPluginAgent(claudeDir, plugin, agent) {
|
|
3742
3775
|
let parsed;
|
|
3743
3776
|
try {
|
|
3744
3777
|
parsed = JSON.parse(hostText(readFileSync2(join2(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE), "utf8")));
|
|
@@ -3761,6 +3794,21 @@ function readPluginAgent(claudeDir, type) {
|
|
|
3761
3794
|
}
|
|
3762
3795
|
return null;
|
|
3763
3796
|
}
|
|
3797
|
+
function syncedPluginAgent(claudeDir, plugin, agent) {
|
|
3798
|
+
const root = join2(claudeDir, HOST_PLUGINS_DIR_NAME, SYNCED_PLUGINS_DIR_NAME);
|
|
3799
|
+
let ids;
|
|
3800
|
+
try {
|
|
3801
|
+
ids = readdirSync2(root).sort();
|
|
3802
|
+
} catch {
|
|
3803
|
+
return null;
|
|
3804
|
+
}
|
|
3805
|
+
for (const id2 of ids) {
|
|
3806
|
+
if (id2.startsWith(".")) continue;
|
|
3807
|
+
const d = readAgentFile(join2(root, id2, plugin, AGENTS_DIR_NAME, agent + AGENT_FILE_EXT));
|
|
3808
|
+
if (d !== null) return d;
|
|
3809
|
+
}
|
|
3810
|
+
return null;
|
|
3811
|
+
}
|
|
3764
3812
|
function readAgentFile(path8) {
|
|
3765
3813
|
let text;
|
|
3766
3814
|
try {
|
|
@@ -8998,18 +9046,24 @@ function bigRead(agent, input, cwd) {
|
|
|
8998
9046
|
const many = Array.isArray(input[READ_PATH_LIST_KEY]) ? input[READ_PATH_LIST_KEY].filter((x) => typeof x === "string") : [];
|
|
8999
9047
|
return [firstString(input, READ_PATH_KEYS), ...many].some((p) => p !== "" && bigFile(resolve7(cwd, p)) && !isMediaRead(agent, resolve7(cwd, p)) && !isOwnFile(agent, cwd, p));
|
|
9000
9048
|
}
|
|
9049
|
+
function allowOutput(agent) {
|
|
9050
|
+
try {
|
|
9051
|
+
return getAdapter(agent).encode({ event: "PreToolUse", agent, sessionId: "", cwd: "", turn: 0 }, { kind: "allow" });
|
|
9052
|
+
} catch {
|
|
9053
|
+
return { stdout: "", exitCode: 0 };
|
|
9054
|
+
}
|
|
9055
|
+
}
|
|
9001
9056
|
function failureOutput(agent, raw, err, cwdFallback = "") {
|
|
9002
9057
|
const row5 = getAdapter(agent);
|
|
9003
|
-
const allow = () => row5.encode({ event: "PreToolUse", agent, sessionId: "", cwd: "", turn: 0 }, { kind: "allow" });
|
|
9004
9058
|
try {
|
|
9005
|
-
if (!isRec(raw)) return
|
|
9006
|
-
if (!isPreTool(row5, firstString(raw, HOOK_FAIL_EVENT_KEYS))) return
|
|
9059
|
+
if (!isRec(raw)) return allowOutput(agent);
|
|
9060
|
+
if (!isPreTool(row5, firstString(raw, HOOK_FAIL_EVENT_KEYS))) return allowOutput(agent);
|
|
9007
9061
|
const name = firstString(raw, HOOK_FAIL_TOOL_KEYS);
|
|
9008
|
-
if (name === "" || name.includes(OWN_TOOL_PREFIX)) return
|
|
9062
|
+
if (name === "" || name.includes(OWN_TOOL_PREFIX)) return allowOutput(agent);
|
|
9009
9063
|
const kind = kindOf(row5, name);
|
|
9010
|
-
if (kind === null) return
|
|
9064
|
+
if (kind === null) return allowOutput(agent);
|
|
9011
9065
|
const cwd = firstString(raw, HOOK_FAIL_CWD_KEYS) || cwdFallback;
|
|
9012
|
-
if (kind === "read" && !bigRead(agent, inputOf(raw), cwd)) return
|
|
9066
|
+
if (kind === "read" && !bigRead(agent, inputOf(raw), cwd)) return allowOutput(agent);
|
|
9013
9067
|
const redirect = kind === "read" ? HOOK_FAIL_REDIRECT.read : HOOK_FAIL_REDIRECT[kind];
|
|
9014
9068
|
const reason = prefixToolNames(redirect, row5.toolNamePrefix) + "\n" + HOOK_FAIL_LINE(errorLabel(err), row5.toolNamePrefix);
|
|
9015
9069
|
return row5.encode({ event: "PreToolUse", agent, sessionId: "", cwd, turn: 0 }, { kind: "deny", reason });
|
|
@@ -9041,12 +9095,20 @@ async function handleHook(agent, raw, env) {
|
|
|
9041
9095
|
return EMPTY5;
|
|
9042
9096
|
}
|
|
9043
9097
|
const row5 = getAdapter(agent);
|
|
9044
|
-
const
|
|
9098
|
+
const report2 = (stage, err, line) => {
|
|
9045
9099
|
logHookError(env, agent, stage, err);
|
|
9046
9100
|
process.stderr.write(line ?? "hooks: " + stage + " failed: " + message(err) + "\n");
|
|
9101
|
+
};
|
|
9102
|
+
const fail7 = (stage, err, line) => {
|
|
9103
|
+
report2(stage, err, line);
|
|
9047
9104
|
return failureOutput(agent, raw, err);
|
|
9048
9105
|
};
|
|
9049
|
-
if (nodeTooOld(process.version))
|
|
9106
|
+
if (nodeTooOld(process.version)) {
|
|
9107
|
+
const err = new CtxError("NODE_TOO_OLD", { v: process.version });
|
|
9108
|
+
if (row5.installMode === "in-process") return fail7("node", err);
|
|
9109
|
+
report2("node", err);
|
|
9110
|
+
return allowOutput(agent);
|
|
9111
|
+
}
|
|
9050
9112
|
let ev;
|
|
9051
9113
|
try {
|
|
9052
9114
|
fault(env, "decode");
|
|
@@ -9377,14 +9439,21 @@ async function postReplace(ev, row5, project, env, tool, result, text) {
|
|
|
9377
9439
|
if (result.keep === true) return ALLOW2;
|
|
9378
9440
|
if (!hasReplace(row5)) return ALLOW2;
|
|
9379
9441
|
let label2;
|
|
9442
|
+
let caller = { ctx: true, shell: true, read: false };
|
|
9380
9443
|
if (isSubagentCall(ev)) {
|
|
9381
|
-
const
|
|
9382
|
-
|
|
9383
|
-
|
|
9444
|
+
const set3 = toolSetForAgentType(ev, toolSetSources(ev, project, env));
|
|
9445
|
+
const subCase = pickSubagentCase(ev, set3);
|
|
9446
|
+
const has3 = (names) => set3 !== null && names.some((n) => set3.includes(n));
|
|
9447
|
+
caller = {
|
|
9448
|
+
ctx: subCase === "A",
|
|
9449
|
+
shell: has3(row5.nativeTools.shell),
|
|
9450
|
+
read: RANGE_READ_TOOLS.includes(tool.canonicalName) && has3(row5.nativeTools.read ?? [])
|
|
9451
|
+
};
|
|
9452
|
+
label2 = SUBAGENT_SOURCE_PREFIX + tool.canonicalName + ":" + (tool.callId ?? String(ev.turn ?? 0));
|
|
9384
9453
|
} else {
|
|
9385
9454
|
label2 = mainLabel(tool, ev);
|
|
9386
9455
|
}
|
|
9387
|
-
const intent = [tool.input.description, tool.input.command, tool.input.file_path, tool.input.pattern, tool.input.url].map(str2).find((v) => v.trim() !== "") ??
|
|
9456
|
+
const intent = [tool.input.description, tool.input.command, tool.input.file_path, tool.input.pattern, tool.input.url, tool.name].map(str2).find((v) => v.trim() !== "") ?? tool.canonicalName;
|
|
9388
9457
|
const chunks = chunkText(text, "text", REPLACE_CHUNK_BYTES);
|
|
9389
9458
|
const db = await openDb(project);
|
|
9390
9459
|
let sourceId;
|
|
@@ -9398,12 +9467,17 @@ async function postReplace(ev, row5, project, env, tool, result, text) {
|
|
|
9398
9467
|
const handle = sourceHandle(sourceId);
|
|
9399
9468
|
const prompt = await lastPrompt(project, ev.sessionId);
|
|
9400
9469
|
const rankQuery = prompt.trim() === "" ? void 0 : intent + " " + prompt;
|
|
9401
|
-
const handleLine = REPLACE_HANDLE_LINE(intent, handle, result.bytes, row5.toolNamePrefix, askedWords(intent, prompt, text));
|
|
9470
|
+
const handleLine = caller.ctx ? REPLACE_HANDLE_LINE(intent, handle, result.bytes, row5.toolNamePrefix, askedWords(intent, prompt, text)) : SUBAGENT_HANDLE_LINE(handle, result.bytes, caller.read);
|
|
9402
9471
|
const budget = replaceBudget(handleLine, moreLine2(intent, label2));
|
|
9472
|
+
const pointer = handleLine + (caller.shell && ev.agent === RUN_WRAPPER_AGENT ? searchTwin(handle, intent, project) : "");
|
|
9403
9473
|
const digest = shapeDigest(text, rankQuery ?? intent, SHAPE_RETURN_BYTES);
|
|
9404
|
-
if (digest !== null) return { kind: "replace", output: replaceOutput(digest,
|
|
9474
|
+
if (digest !== null) return { kind: "replace", output: replaceOutput(digest, pointer) };
|
|
9405
9475
|
const selected = selectChunksInMemory(chunks, intent, budget, label2, rankQuery);
|
|
9406
|
-
return { kind: "replace", output: selected.more !== null ? replaceOutput(selected.text,
|
|
9476
|
+
return { kind: "replace", output: selected.more !== null ? replaceOutput(selected.text, pointer) : selected.text };
|
|
9477
|
+
}
|
|
9478
|
+
function searchTwin(handle, intent, project) {
|
|
9479
|
+
const terms = Buffer.byteLength(intent, "utf8") > ECHO_MAX_BYTES ? "" : intent;
|
|
9480
|
+
return SEARCH_TWIN_LINE(join8(dirname4(process.argv[1] ?? ""), SEARCH_WRAPPER_FILE), handle, terms, project.worktree);
|
|
9407
9481
|
}
|
|
9408
9482
|
function boundedRead(tool) {
|
|
9409
9483
|
return RANGE_READ_TOOLS.includes(tool.canonicalName) && READ_RANGE_KEYS.some((k) => tool.input[k] !== void 0 && tool.input[k] !== null);
|
|
@@ -20689,6 +20763,13 @@ function pathEntries(value, platform = process.platform, delimiter2 = platform =
|
|
|
20689
20763
|
const win = platform === "win32";
|
|
20690
20764
|
return value.split(delimiter2).map((e) => win && e.length >= 2 && e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e).filter(Boolean);
|
|
20691
20765
|
}
|
|
20766
|
+
function envValue(env, name, platform = process.platform) {
|
|
20767
|
+
const exact = env[name];
|
|
20768
|
+
if (exact !== void 0 || platform !== "win32") return exact;
|
|
20769
|
+
const upper = name.toUpperCase();
|
|
20770
|
+
const key = Object.keys(env).find((k) => k.toUpperCase() === upper);
|
|
20771
|
+
return key === void 0 ? void 0 : env[key];
|
|
20772
|
+
}
|
|
20692
20773
|
|
|
20693
20774
|
// src/core/sandbox/runtimes.ts
|
|
20694
20775
|
var PATHEXT_SEPARATOR = ";";
|
|
@@ -20732,8 +20813,8 @@ function isRunnable(full) {
|
|
|
20732
20813
|
}
|
|
20733
20814
|
function findRuntime(lang, env = process.env) {
|
|
20734
20815
|
if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
|
|
20735
|
-
const dirs = pathEntries(env
|
|
20736
|
-
const pathExt = isWin() ? (env
|
|
20816
|
+
const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
|
|
20817
|
+
const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
|
|
20737
20818
|
const names = candidates(lang);
|
|
20738
20819
|
let shim = null;
|
|
20739
20820
|
for (const dir of dirs) {
|
|
@@ -20894,7 +20975,7 @@ function runProcess(argv, o) {
|
|
|
20894
20975
|
}
|
|
20895
20976
|
|
|
20896
20977
|
// src/core/index/auto-memory.ts
|
|
20897
|
-
import { readdirSync as
|
|
20978
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync4 } from "node:fs";
|
|
20898
20979
|
import { join as join9 } from "node:path";
|
|
20899
20980
|
var MEMORY_FILES = Object.freeze([
|
|
20900
20981
|
Object.freeze(["CLAUDE.md"]),
|
|
@@ -20909,7 +20990,7 @@ var KIRO_STEERING = Object.freeze([".kiro", "steering"]);
|
|
|
20909
20990
|
var MD = ".md";
|
|
20910
20991
|
function steeringFiles(worktree) {
|
|
20911
20992
|
try {
|
|
20912
|
-
return
|
|
20993
|
+
return readdirSync3(join9(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
|
|
20913
20994
|
} catch {
|
|
20914
20995
|
return [];
|
|
20915
20996
|
}
|
|
@@ -21503,7 +21584,7 @@ var ctxBatch = Object.freeze({
|
|
|
21503
21584
|
});
|
|
21504
21585
|
|
|
21505
21586
|
// src/core/tools/doctor.ts
|
|
21506
|
-
import { readdirSync as
|
|
21587
|
+
import { readdirSync as readdirSync8, readFileSync as readFileSync16, existsSync as existsSync16 } from "node:fs";
|
|
21507
21588
|
import { basename as basename5, join as join19 } from "node:path";
|
|
21508
21589
|
|
|
21509
21590
|
// src/core/ops/bundle-dir.ts
|
|
@@ -21529,11 +21610,11 @@ function ownBundleDir() {
|
|
|
21529
21610
|
}
|
|
21530
21611
|
|
|
21531
21612
|
// src/core/ops/doctor-config.ts
|
|
21532
|
-
import { existsSync as existsSync9, readdirSync as
|
|
21613
|
+
import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as readFileSync11 } from "node:fs";
|
|
21533
21614
|
import { dirname as dirname8, isAbsolute as isAbsolute4, join as join14, resolve as resolve9 } from "node:path";
|
|
21534
21615
|
|
|
21535
21616
|
// src/core/ops/detect-v1.ts
|
|
21536
|
-
import { existsSync as existsSync6, opendirSync, readdirSync as
|
|
21617
|
+
import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync8 } from "node:fs";
|
|
21537
21618
|
import { tmpdir } from "node:os";
|
|
21538
21619
|
import { join as join12 } from "node:path";
|
|
21539
21620
|
|
|
@@ -24270,7 +24351,7 @@ function scanVscode(agentHome, project, out) {
|
|
|
24270
24351
|
}
|
|
24271
24352
|
function jsonFiles(dir) {
|
|
24272
24353
|
try {
|
|
24273
|
-
return
|
|
24354
|
+
return readdirSync4(dir).filter((name) => name.endsWith(KIRO_AGENT_FILE_EXT)).sort();
|
|
24274
24355
|
} catch {
|
|
24275
24356
|
return [];
|
|
24276
24357
|
}
|
|
@@ -24403,7 +24484,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
24403
24484
|
}
|
|
24404
24485
|
|
|
24405
24486
|
// src/core/ops/plugin-root.ts
|
|
24406
|
-
import { existsSync as existsSync7, readdirSync as
|
|
24487
|
+
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync9, realpathSync as realpathSync4 } from "node:fs";
|
|
24407
24488
|
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join13, sep as sep4 } from "node:path";
|
|
24408
24489
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24409
24490
|
function missing(agent, path8) {
|
|
@@ -24503,7 +24584,7 @@ function marketplaceRoot(adapter, env, worktree) {
|
|
|
24503
24584
|
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep4) && existsSync7(join13(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
24504
24585
|
const pattern = join13(cache, "*", PLUGIN_NAME);
|
|
24505
24586
|
if (!existsSync7(cache)) throw missing(adapter.id, pattern);
|
|
24506
|
-
const found =
|
|
24587
|
+
const found = readdirSync5(cache).sort().map((marketplace) => join13(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync7(dir));
|
|
24507
24588
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
24508
24589
|
return found[0];
|
|
24509
24590
|
}
|
|
@@ -24715,10 +24796,10 @@ function codexNativeDir(env, home) {
|
|
|
24715
24796
|
const cache = join14(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
24716
24797
|
if (!existsSync9(cache)) return null;
|
|
24717
24798
|
const found = [];
|
|
24718
|
-
for (const market of
|
|
24799
|
+
for (const market of readdirSync6(cache)) {
|
|
24719
24800
|
const plugin = join14(cache, market, SERVER_KEY);
|
|
24720
24801
|
if (!existsSync9(plugin)) continue;
|
|
24721
|
-
for (const version2 of
|
|
24802
|
+
for (const version2 of readdirSync6(plugin).sort()) {
|
|
24722
24803
|
const dir = join14(plugin, version2, CODEX_PLUGIN_SUBDIR);
|
|
24723
24804
|
if (existsSync9(join14(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
24724
24805
|
}
|
|
@@ -24821,7 +24902,7 @@ function opencodeDirPlugins(dirs) {
|
|
|
24821
24902
|
const pdir = join14(dir, OPENCODE_PLUGINS_DIR);
|
|
24822
24903
|
let names;
|
|
24823
24904
|
try {
|
|
24824
|
-
names =
|
|
24905
|
+
names = readdirSync6(pdir);
|
|
24825
24906
|
} catch {
|
|
24826
24907
|
continue;
|
|
24827
24908
|
}
|
|
@@ -27124,7 +27205,7 @@ var WIN_EXT = ".COM;.EXE;.BAT;.CMD";
|
|
|
27124
27205
|
var WIN_SHIM_EXTS = Object.freeze([".cmd", ".bat"]);
|
|
27125
27206
|
var DEFAULT_COMSPEC = "cmd.exe";
|
|
27126
27207
|
function envGet(env, k) {
|
|
27127
|
-
return
|
|
27208
|
+
return envValue(env, k, "win32");
|
|
27128
27209
|
}
|
|
27129
27210
|
function whichBin(bin, env, platform = process.platform) {
|
|
27130
27211
|
const get = (k) => envGet(env, k);
|
|
@@ -27579,10 +27660,13 @@ async function checkHookRoundTrip(i) {
|
|
|
27579
27660
|
await runProcess([node.file, "-e", ""], { cwd: i.bundleDir, env: node.env, signal: i.signal, timeoutMs });
|
|
27580
27661
|
return performance.now() - t;
|
|
27581
27662
|
});
|
|
27663
|
+
const inProcess = getAdapter(i.agent).installMode === "in-process";
|
|
27582
27664
|
const hookWalls = [];
|
|
27583
27665
|
const bareWalls = [];
|
|
27584
27666
|
let ms = 0;
|
|
27585
|
-
|
|
27667
|
+
let fastBare = 0;
|
|
27668
|
+
let bound = HOOK_P95_MS;
|
|
27669
|
+
for (let n = 1; n <= (inProcess ? 1 : maxPairs); n++) {
|
|
27586
27670
|
const start = now();
|
|
27587
27671
|
const node = nodeLaunch(i.env);
|
|
27588
27672
|
const r = await runProcess([node.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
@@ -27594,13 +27678,17 @@ async function checkHookRoundTrip(i) {
|
|
|
27594
27678
|
});
|
|
27595
27679
|
hookWalls.push(now() - start);
|
|
27596
27680
|
if (!isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
|
|
27681
|
+
if (inProcess) return row("PASS", D5_IN_PROCESS_DETAIL);
|
|
27597
27682
|
bareWalls.push(await bareMs());
|
|
27598
|
-
|
|
27599
|
-
|
|
27683
|
+
fastBare = Math.round(Math.min(...bareWalls));
|
|
27684
|
+
ms = Math.max(0, Math.round(Math.min(...hookWalls)) - fastBare);
|
|
27685
|
+
bound = Math.max(HOOK_P95_MS, Math.round(D5_BARE_SHARE * fastBare));
|
|
27686
|
+
if (n >= minPairs && ms <= bound) break;
|
|
27600
27687
|
}
|
|
27601
|
-
if (ms >
|
|
27688
|
+
if (ms > bound) return row("FAIL", D5_SLOW_DETAIL(ms, bound), D5_FIX);
|
|
27602
27689
|
const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
|
|
27603
27690
|
if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
|
|
27691
|
+
if (ms > HOOK_P95_MS) return row("PASS", D5_SLOW_START_DETAIL(ms, fastBare, bound));
|
|
27604
27692
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
27605
27693
|
}
|
|
27606
27694
|
|
|
@@ -27609,7 +27697,7 @@ import { existsSync as existsSync14, mkdirSync as mkdirSync6, rmSync as rmSync4
|
|
|
27609
27697
|
import { basename as basename4, dirname as dirname9, join as join17 } from "node:path";
|
|
27610
27698
|
|
|
27611
27699
|
// src/core/store/owners.ts
|
|
27612
|
-
import { mkdirSync as mkdirSync5, readdirSync as
|
|
27700
|
+
import { mkdirSync as mkdirSync5, readdirSync as readdirSync7, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
27613
27701
|
import { basename as basename3, join as join16 } from "node:path";
|
|
27614
27702
|
function ownersDir(configDir, projectKey) {
|
|
27615
27703
|
return join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
@@ -27632,7 +27720,7 @@ function listLiveOwners(configDir, projectKey) {
|
|
|
27632
27720
|
const dir = ownersDir(configDir, projectKey);
|
|
27633
27721
|
let names;
|
|
27634
27722
|
try {
|
|
27635
|
-
names =
|
|
27723
|
+
names = readdirSync7(dir);
|
|
27636
27724
|
} catch (err) {
|
|
27637
27725
|
if (errCode2(err) === "ENOENT") return [];
|
|
27638
27726
|
throw err;
|
|
@@ -27828,7 +27916,7 @@ function unsupportedHostOf(sig) {
|
|
|
27828
27916
|
// src/core/ops/doctor-issue.ts
|
|
27829
27917
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
27830
27918
|
import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync15, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
|
|
27831
|
-
import { delimiter, join as join18 } from "node:path";
|
|
27919
|
+
import { delimiter, dirname as dirname10, join as join18 } from "node:path";
|
|
27832
27920
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
27833
27921
|
function tildeOf(env) {
|
|
27834
27922
|
const home = homeDirOf(env);
|
|
@@ -27851,13 +27939,28 @@ function maskLine(line) {
|
|
|
27851
27939
|
const at2 = Math.max(line.indexOf(":"), line.indexOf("="));
|
|
27852
27940
|
return at2 === -1 ? DOCTOR_MASK : line.slice(0, at2 + 1) + " " + DOCTOR_MASK;
|
|
27853
27941
|
}
|
|
27854
|
-
function
|
|
27942
|
+
async function runtimeInfo(env, signal, host = { bun: process.versions.bun, node: process.version }) {
|
|
27943
|
+
if (host.bun === void 0) return { node: host.node };
|
|
27944
|
+
const node = findRuntime("javascript", env);
|
|
27945
|
+
if (node === null) return { node: host.node, bun: host.bun, pathNode: null };
|
|
27946
|
+
const childEnv = {};
|
|
27947
|
+
for (const [k, v] of Object.entries(env)) if (v !== void 0) childEnv[k] = v;
|
|
27948
|
+
const r = await runProcess([node, "--version"], { cwd: dirname10(node), env: childEnv, signal, timeoutMs: DOCTOR_GIT_VERSION_TIMEOUT_MS });
|
|
27949
|
+
const out = r.stdout.toString("utf8").trim();
|
|
27950
|
+
return { node: host.node, bun: host.bun, pathNode: r.exitCode === 0 && out !== "" ? out : null };
|
|
27951
|
+
}
|
|
27952
|
+
function environmentLine(ctx, adapter, env, version2, rt) {
|
|
27855
27953
|
const sha = BUNDLE_SHA === void 0 ? "dev build" : BUNDLE_SHA.slice(0, 7);
|
|
27856
27954
|
const client = ctx.clientInfo;
|
|
27857
27955
|
const agent = client === void 0 ? adapter.id : client.name === adapter.id ? `${adapter.id} ${client.version}` : `${adapter.id} ${client.version} (client ${client.name})`;
|
|
27858
27956
|
const shell = env.SHELL ?? env.ComSpec ?? "sh";
|
|
27859
|
-
|
|
27860
|
-
|
|
27957
|
+
const what = `${DOCTOR_ENV_PREFIX}context-mode ${version2 ?? "source checkout"} (${sha}), agent ${agent}
|
|
27958
|
+
`;
|
|
27959
|
+
const os = `${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}`;
|
|
27960
|
+
if (rt.bun === void 0) return what + `${os}, Node ${rt.node}, shell ${shell}`;
|
|
27961
|
+
const pathNode = rt.pathNode === null || rt.pathNode === void 0 ? "ctx_execute node: none on PATH" : `ctx_execute node ${rt.pathNode} (PATH)`;
|
|
27962
|
+
return what + `${os}, host runtime Bun ${rt.bun} (node-compat ${rt.node})
|
|
27963
|
+
${DOCTOR_ENV_PREFIX}${pathNode}, shell ${shell}`;
|
|
27861
27964
|
}
|
|
27862
27965
|
function gitVersion(env) {
|
|
27863
27966
|
const r = spawnSync3("git", ["--version"], { env, encoding: "utf8", timeout: DOCTOR_GIT_VERSION_TIMEOUT_MS, windowsHide: true });
|
|
@@ -27867,7 +27970,7 @@ function gitVersion(env) {
|
|
|
27867
27970
|
function onPath(env, tool) {
|
|
27868
27971
|
const names = process.platform === "win32" ? [tool + EXE_SUFFIX, tool + ".cmd", tool] : [tool];
|
|
27869
27972
|
const out = [];
|
|
27870
|
-
for (const dir of (env
|
|
27973
|
+
for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
|
|
27871
27974
|
if (dir === "") continue;
|
|
27872
27975
|
for (const n of names) if (existsSync15(join18(dir, n))) {
|
|
27873
27976
|
out.push(join18(dir, n));
|
|
@@ -28068,7 +28171,7 @@ async function hookRow(ctx, adapter, host) {
|
|
|
28068
28171
|
function ownServerId(configDir, projectKey) {
|
|
28069
28172
|
const dir = join19(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
28070
28173
|
if (!existsSync16(dir)) return "";
|
|
28071
|
-
for (const name of
|
|
28174
|
+
for (const name of readdirSync8(dir)) {
|
|
28072
28175
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
28073
28176
|
if (readFileSync16(join19(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
28074
28177
|
}
|
|
@@ -28127,11 +28230,12 @@ function reportEnv(env) {
|
|
|
28127
28230
|
}
|
|
28128
28231
|
async function doctorReply(ctx, host) {
|
|
28129
28232
|
const adapter = getAdapter(ctx.project.agent);
|
|
28233
|
+
const runtime = runtimeInfo(host.env, ctx.signal);
|
|
28130
28234
|
const rows = await runDoctorChecks(ctx, adapter, host);
|
|
28131
28235
|
const failed = rows.some((r) => r.status === "FAIL");
|
|
28132
28236
|
const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
|
|
28133
28237
|
const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
|
|
28134
|
-
const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
|
|
28238
|
+
const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
|
|
28135
28239
|
const table3 = buildReport(input);
|
|
28136
28240
|
let notes = [];
|
|
28137
28241
|
if (failed) {
|
|
@@ -28170,7 +28274,7 @@ var ctxDoctor = Object.freeze({
|
|
|
28170
28274
|
// src/core/tools/execute.ts
|
|
28171
28275
|
import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
28172
28276
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
28173
|
-
import { dirname as
|
|
28277
|
+
import { dirname as dirname12, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
|
|
28174
28278
|
|
|
28175
28279
|
// src/core/sandbox/win-build.ts
|
|
28176
28280
|
var SEPARATORS2 = ";&|(\n";
|
|
@@ -28253,7 +28357,7 @@ function schemaLine(issue2) {
|
|
|
28253
28357
|
}
|
|
28254
28358
|
function fileError(given, abs, root) {
|
|
28255
28359
|
let dir = abs;
|
|
28256
|
-
while (!existsSync17(dir) &&
|
|
28360
|
+
while (!existsSync17(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
|
|
28257
28361
|
if (isInside(root, dir)) return null;
|
|
28258
28362
|
return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
|
|
28259
28363
|
}
|
|
@@ -28372,10 +28476,10 @@ var ctxExecute = {
|
|
|
28372
28476
|
|
|
28373
28477
|
// src/core/tools/index.ts
|
|
28374
28478
|
import { existsSync as existsSync18, readFileSync as readFileSync18, statSync as statSync8 } from "node:fs";
|
|
28375
|
-
import { dirname as
|
|
28479
|
+
import { dirname as dirname13, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
|
|
28376
28480
|
|
|
28377
28481
|
// src/core/index/walk.ts
|
|
28378
|
-
import { readdirSync as
|
|
28482
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
|
|
28379
28483
|
import { join as join21 } from "node:path";
|
|
28380
28484
|
var GITIGNORE = ".gitignore";
|
|
28381
28485
|
var GIT_DIR = ".git";
|
|
@@ -28390,7 +28494,7 @@ function walkDir(root, containmentRoot) {
|
|
|
28390
28494
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
28391
28495
|
let entries;
|
|
28392
28496
|
try {
|
|
28393
|
-
entries =
|
|
28497
|
+
entries = readdirSync9(abs, { withFileTypes: true });
|
|
28394
28498
|
} catch {
|
|
28395
28499
|
return;
|
|
28396
28500
|
}
|
|
@@ -28583,15 +28687,15 @@ function parseUrl(raw) {
|
|
|
28583
28687
|
if (u.protocol !== "http:" && u.protocol !== "https:") throw fail6("ERR_INVALID_PROTOCOL");
|
|
28584
28688
|
return u;
|
|
28585
28689
|
}
|
|
28586
|
-
function
|
|
28690
|
+
function envValue2(upper) {
|
|
28587
28691
|
const v = process.env[upper] ?? process.env[upper.toLowerCase()];
|
|
28588
28692
|
return v === void 0 || v.trim() === "" ? void 0 : v.trim();
|
|
28589
28693
|
}
|
|
28590
28694
|
function pickProxy(u) {
|
|
28591
|
-
const raw =
|
|
28695
|
+
const raw = envValue2(u.protocol === "https:" ? "HTTPS_PROXY" : "HTTP_PROXY");
|
|
28592
28696
|
if (raw === void 0) return void 0;
|
|
28593
28697
|
const host = bare(u.hostname).toLowerCase();
|
|
28594
|
-
for (const item of (
|
|
28698
|
+
for (const item of (envValue2("NO_PROXY") ?? "").split(",")) {
|
|
28595
28699
|
let entry = item.trim().toLowerCase();
|
|
28596
28700
|
if (entry.startsWith(".")) entry = entry.slice(1);
|
|
28597
28701
|
if (entry !== "" && (host === entry || host.endsWith("." + entry))) return void 0;
|
|
@@ -32572,7 +32676,7 @@ function readUtf8(absPath) {
|
|
|
32572
32676
|
}
|
|
32573
32677
|
function missingOrOutside(given, abs, root) {
|
|
32574
32678
|
let dir = abs;
|
|
32575
|
-
while (!existsSync18(dir) &&
|
|
32679
|
+
while (!existsSync18(dir) && dirname13(dir) !== dir) dir = dirname13(dir);
|
|
32576
32680
|
if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
|
|
32577
32681
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
32578
32682
|
}
|
|
@@ -33124,7 +33228,7 @@ var ctxStats = Object.freeze({
|
|
|
33124
33228
|
|
|
33125
33229
|
// src/core/ops/host-write.ts
|
|
33126
33230
|
import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
33127
|
-
import { dirname as
|
|
33231
|
+
import { dirname as dirname14, join as join23 } from "node:path";
|
|
33128
33232
|
function defaultWrite(file2, text) {
|
|
33129
33233
|
writeFileSync6(file2, text, "utf8");
|
|
33130
33234
|
}
|
|
@@ -33156,7 +33260,7 @@ function writeWithRollback(file2, text, write2, atomic) {
|
|
|
33156
33260
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
33157
33261
|
const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
|
|
33158
33262
|
const had = existsSync19(file2);
|
|
33159
|
-
mkdirSync8(
|
|
33263
|
+
mkdirSync8(dirname14(file2), { recursive: true });
|
|
33160
33264
|
if (had) copyFileSync(file2, trash);
|
|
33161
33265
|
try {
|
|
33162
33266
|
write2(tmp, text);
|
|
@@ -33193,7 +33297,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
33193
33297
|
}
|
|
33194
33298
|
|
|
33195
33299
|
// src/core/ops/uninstall.ts
|
|
33196
|
-
import { existsSync as existsSync20, readdirSync as
|
|
33300
|
+
import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
|
|
33197
33301
|
import { join as join24 } from "node:path";
|
|
33198
33302
|
function row2(area, before, after) {
|
|
33199
33303
|
return { area, before, after };
|
|
@@ -33309,7 +33413,7 @@ function removeProjectData(configDir, projectKey) {
|
|
|
33309
33413
|
const dir = join24(projects, projectKey);
|
|
33310
33414
|
if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
33311
33415
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
33312
|
-
for (const name of
|
|
33416
|
+
for (const name of readdirSync10(dir)) {
|
|
33313
33417
|
if (name !== OWNERS_DIR_NAME) rmSync6(join24(dir, name), { recursive: true, force: true });
|
|
33314
33418
|
}
|
|
33315
33419
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
@@ -33853,11 +33957,13 @@ async function setup(ctx) {
|
|
|
33853
33957
|
await ctx.session.hook("prompt", async (p) => {
|
|
33854
33958
|
await hooks["chat.message"]({ sessionID: p.sessionID }, { parts: [{ type: "text", text: p.prompt?.text ?? "" }] });
|
|
33855
33959
|
});
|
|
33856
|
-
|
|
33960
|
+
const injectSystem = async (c) => {
|
|
33857
33961
|
const system = [];
|
|
33858
33962
|
await hooks["experimental.chat.system.transform"]({ sessionID: c.sessionID }, { system });
|
|
33859
33963
|
for (const text of system) if (!c.system.some((p) => p.text === text)) c.system.push({ type: "text", text });
|
|
33860
|
-
}
|
|
33964
|
+
};
|
|
33965
|
+
await ctx.session.hook("context", injectSystem);
|
|
33966
|
+
await ctx.session.hook("generate", injectSystem);
|
|
33861
33967
|
await ctx.session.hook("compaction", async (c) => {
|
|
33862
33968
|
await hooks["experimental.session.compacting"]({ sessionID: c.sessionID });
|
|
33863
33969
|
});
|
package/package.json
CHANGED