context-mode 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +73 -73
- package/SHA256SUMS +15 -15
- package/cli.mjs +27 -3
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +75 -73
- package/opencode/plugin.js +105 -34
- package/package.json +1 -1
- package/pi/index.js +110 -39
- package/qwen-extension.json +1 -1
- package/run.mjs +27 -3
- package/search.mjs +27 -3
- package/server.mjs +106 -34
package/pi/index.js
CHANGED
|
@@ -11571,7 +11571,7 @@ var DECISION_OPTION_KEY = "option";
|
|
|
11571
11571
|
var DECISION_LABEL_JOIN = " | ";
|
|
11572
11572
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
11573
11573
|
var RELEASE_BRANCH = "release";
|
|
11574
|
-
var BUNDLE_SHA = true ? "
|
|
11574
|
+
var BUNDLE_SHA = true ? "9f1916d761e6a8e55ac43858b99dcdcd3cc53caa" : void 0;
|
|
11575
11575
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
11576
11576
|
var DOCTOR_LABEL = Object.freeze({
|
|
11577
11577
|
D1: "version",
|
|
@@ -11835,6 +11835,7 @@ var REGEX_SPECIAL_CHARS = ".*+?^${}()|[]\\";
|
|
|
11835
11835
|
var REGEX_ESCAPE = "\\";
|
|
11836
11836
|
var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
|
|
11837
11837
|
var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
|
|
11838
|
+
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`;
|
|
11838
11839
|
function D5_SLOW_DETAIL(ms) {
|
|
11839
11840
|
return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
|
|
11840
11841
|
}
|
|
@@ -12246,9 +12247,28 @@ function outputOf(resp) {
|
|
|
12246
12247
|
return err === "" ? out : out === "" ? err : out + "\n" + err;
|
|
12247
12248
|
}
|
|
12248
12249
|
}
|
|
12249
|
-
if (typeof resp === "object" && resp !== null &&
|
|
12250
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp)) {
|
|
12251
|
+
const slot = textSlot(resp);
|
|
12252
|
+
if (slot !== null) return slot.text;
|
|
12253
|
+
}
|
|
12250
12254
|
return JSON.stringify(resp);
|
|
12251
12255
|
}
|
|
12256
|
+
function textSlot(r) {
|
|
12257
|
+
const file2 = r.file;
|
|
12258
|
+
if (r.type === "text" && typeof file2 === "object" && file2 !== null && typeof file2.content === "string") {
|
|
12259
|
+
return { text: file2.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
|
|
12260
|
+
}
|
|
12261
|
+
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
12262
|
+
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
12263
|
+
return { text: r.filenames.join("\n"), put: (o, output) => ({ ...o, filenames: output.split("\n") }) };
|
|
12264
|
+
}
|
|
12265
|
+
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
12266
|
+
return null;
|
|
12267
|
+
}
|
|
12268
|
+
function isShellShape(resp) {
|
|
12269
|
+
const r = resp;
|
|
12270
|
+
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
12271
|
+
}
|
|
12252
12272
|
function isGrepContent(resp) {
|
|
12253
12273
|
const r = resp;
|
|
12254
12274
|
return r.mode === "content" && typeof r.content === "string";
|
|
@@ -12267,7 +12287,10 @@ function readResult2(resp) {
|
|
|
12267
12287
|
const text = outputOf(resp);
|
|
12268
12288
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
12269
12289
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
12270
|
-
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) &&
|
|
12290
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
12291
|
+
if (textSlot(resp) !== null) info.shape = resp;
|
|
12292
|
+
else info.keep = true;
|
|
12293
|
+
}
|
|
12271
12294
|
if (Array.isArray(resp)) {
|
|
12272
12295
|
info.blocks = true;
|
|
12273
12296
|
if (blocksOf(resp).keep) info.keep = true;
|
|
@@ -12304,7 +12327,9 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
12304
12327
|
}
|
|
12305
12328
|
function replaceShape(ev, output) {
|
|
12306
12329
|
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
12307
|
-
|
|
12330
|
+
const shape = ev.result?.shape;
|
|
12331
|
+
const slot = shape === void 0 ? null : textSlot(shape);
|
|
12332
|
+
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
12308
12333
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
12309
12334
|
return output;
|
|
12310
12335
|
}
|
|
@@ -24036,7 +24061,7 @@ function checkV1Leftovers(agent, home, scope = {}) {
|
|
|
24036
24061
|
if (findings.length === 0) return pass("D4");
|
|
24037
24062
|
const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
|
|
24038
24063
|
if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
|
|
24039
|
-
return fail2("D4", detail, DOCTOR_FIX_UPGRADE);
|
|
24064
|
+
return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
|
|
24040
24065
|
}
|
|
24041
24066
|
function parsedOrNull(agent, file2, jsonc) {
|
|
24042
24067
|
try {
|
|
@@ -24359,7 +24384,8 @@ function checkShell(env) {
|
|
|
24359
24384
|
}
|
|
24360
24385
|
|
|
24361
24386
|
// src/core/ops/doctor-hook.ts
|
|
24362
|
-
import { existsSync as existsSync10, readFileSync as readFileSync10, realpathSync as realpathSync7 } from "node:fs";
|
|
24387
|
+
import { existsSync as existsSync10, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
|
|
24388
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
24363
24389
|
import path6 from "node:path";
|
|
24364
24390
|
|
|
24365
24391
|
// src/setup/codex-trust.ts
|
|
@@ -24643,6 +24669,50 @@ function isNativeShape(agent, stdout, exitCode, killed, event) {
|
|
|
24643
24669
|
return COPILOT_KEYS.some((k) => Object.hasOwn(out, k));
|
|
24644
24670
|
}
|
|
24645
24671
|
}
|
|
24672
|
+
var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
|
|
24673
|
+
function readProbePayload(cwd) {
|
|
24674
|
+
const content = Array.from({ length: READ_PROBE_LINES }, (_, n) => "d5 read probe line " + n + " ".padEnd(20, "x")).join("\n");
|
|
24675
|
+
const filePath = path6.join(cwd, "d5-read-probe.txt");
|
|
24676
|
+
return {
|
|
24677
|
+
session_id: "d5-read-probe",
|
|
24678
|
+
transcript_path: "",
|
|
24679
|
+
cwd,
|
|
24680
|
+
hook_event_name: "PostToolUse",
|
|
24681
|
+
tool_name: "Read",
|
|
24682
|
+
tool_use_id: "toolu_d5_read_probe",
|
|
24683
|
+
tool_input: { file_path: filePath },
|
|
24684
|
+
tool_response: { type: "text", file: { filePath, content, numLines: READ_PROBE_LINES, startLine: 1, totalLines: READ_PROBE_LINES } }
|
|
24685
|
+
};
|
|
24686
|
+
}
|
|
24687
|
+
function isReadShape(stdout) {
|
|
24688
|
+
if (stdout.trim() === "") return true;
|
|
24689
|
+
let out;
|
|
24690
|
+
try {
|
|
24691
|
+
out = JSON.parse(stdout);
|
|
24692
|
+
} catch {
|
|
24693
|
+
return false;
|
|
24694
|
+
}
|
|
24695
|
+
if (!isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
|
|
24696
|
+
const r = out.hookSpecificOutput.updatedToolOutput;
|
|
24697
|
+
if (!isObject5(r) || r.type !== "text" || !isObject5(r.file)) return false;
|
|
24698
|
+
const f = r.file;
|
|
24699
|
+
return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
|
|
24700
|
+
}
|
|
24701
|
+
async function readProbeOk(i, timeoutMs) {
|
|
24702
|
+
const home = mkdtempSync(path6.join(tmpdir2(), "cm-d5-read-"));
|
|
24703
|
+
try {
|
|
24704
|
+
const r = await runProcess([process.execPath, path6.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
24705
|
+
cwd: i.bundleDir,
|
|
24706
|
+
env: { ...i.env, HOME: home, USERPROFILE: home },
|
|
24707
|
+
signal: i.signal,
|
|
24708
|
+
timeoutMs,
|
|
24709
|
+
stdin: JSON.stringify(readProbePayload(i.worktree ?? home))
|
|
24710
|
+
});
|
|
24711
|
+
return isReadShape(r.stdout.toString("utf8"));
|
|
24712
|
+
} finally {
|
|
24713
|
+
rmSync2(home, { recursive: true, force: true });
|
|
24714
|
+
}
|
|
24715
|
+
}
|
|
24646
24716
|
function codexHookJournaled(db) {
|
|
24647
24717
|
if (db === null) return false;
|
|
24648
24718
|
return db.raw.prepare("SELECT 1 FROM events WHERE agent = ? LIMIT 1").get("codex") !== void 0;
|
|
@@ -24710,15 +24780,16 @@ async function checkHookRoundTrip(i) {
|
|
|
24710
24780
|
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
24711
24781
|
}
|
|
24712
24782
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
24783
|
+
if (i.agent === "claude-code" && !await readProbeOk(i, timeoutMs)) return row("FAIL", D5_READ_SHAPE_DETAIL, D5_FIX);
|
|
24713
24784
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
24714
24785
|
}
|
|
24715
24786
|
|
|
24716
24787
|
// src/core/ops/db-heal.ts
|
|
24717
|
-
import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as
|
|
24788
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
|
|
24718
24789
|
import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
|
|
24719
24790
|
|
|
24720
24791
|
// src/core/store/owners.ts
|
|
24721
|
-
import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as
|
|
24792
|
+
import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
24722
24793
|
import { basename as basename3, join as join13 } from "node:path";
|
|
24723
24794
|
function ownersDir(configDir, projectKey) {
|
|
24724
24795
|
return join13(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
@@ -24734,7 +24805,7 @@ function writeOwnerPid(configDir, projectKey, serverId) {
|
|
|
24734
24805
|
writeFileSync2(ownerFile(configDir, projectKey, serverId), String(process.pid), "utf8");
|
|
24735
24806
|
}
|
|
24736
24807
|
function removeOwnerPid(configDir, projectKey, serverId) {
|
|
24737
|
-
|
|
24808
|
+
rmSync3(ownerFile(configDir, projectKey, serverId), { force: true });
|
|
24738
24809
|
}
|
|
24739
24810
|
function isLive(pid) {
|
|
24740
24811
|
if (!Number.isSafeInteger(pid) || pid <= 0) return false;
|
|
@@ -24769,7 +24840,7 @@ function listLiveOwners(configDir, projectKey) {
|
|
|
24769
24840
|
}
|
|
24770
24841
|
const serverId = basename3(name, OWNER_PID_EXT);
|
|
24771
24842
|
if (isLive(Number(text.trim()))) live.push(serverId);
|
|
24772
|
-
else
|
|
24843
|
+
else rmSync3(file2, { force: true });
|
|
24773
24844
|
}
|
|
24774
24845
|
return live;
|
|
24775
24846
|
}
|
|
@@ -24781,7 +24852,7 @@ function integrityOk2(rows) {
|
|
|
24781
24852
|
async function healLossless(dbPath) {
|
|
24782
24853
|
const { DatabaseSync } = await import(SQLITE_MODULE);
|
|
24783
24854
|
const tmp = dbPath + HEAL_TMP_SUFFIX;
|
|
24784
|
-
|
|
24855
|
+
rmSync4(tmp, { force: true });
|
|
24785
24856
|
try {
|
|
24786
24857
|
const src = new DatabaseSync(dbPath, { readOnly: true, timeout: DB_TIMEOUT_MS });
|
|
24787
24858
|
try {
|
|
@@ -24797,11 +24868,11 @@ async function healLossless(dbPath) {
|
|
|
24797
24868
|
} finally {
|
|
24798
24869
|
copy.close();
|
|
24799
24870
|
}
|
|
24800
|
-
|
|
24801
|
-
|
|
24871
|
+
rmSync4(dbPath + DB_WAL_SUFFIX, { force: true });
|
|
24872
|
+
rmSync4(dbPath + DB_SHM_SUFFIX, { force: true });
|
|
24802
24873
|
renameWithRetry(tmp, dbPath);
|
|
24803
24874
|
} finally {
|
|
24804
|
-
|
|
24875
|
+
rmSync4(tmp, { force: true });
|
|
24805
24876
|
}
|
|
24806
24877
|
}
|
|
24807
24878
|
function renameAside(dbPath) {
|
|
@@ -25246,8 +25317,8 @@ var ctxDoctor = Object.freeze({
|
|
|
25246
25317
|
});
|
|
25247
25318
|
|
|
25248
25319
|
// src/core/tools/execute.ts
|
|
25249
|
-
import { existsSync as existsSync14, mkdtempSync, rmSync as
|
|
25250
|
-
import { tmpdir as
|
|
25320
|
+
import { existsSync as existsSync14, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
25321
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
25251
25322
|
import { dirname as dirname9, join as join17, parse as parse3, resolve as resolve6 } from "node:path";
|
|
25252
25323
|
|
|
25253
25324
|
// src/core/sandbox/win-build.ts
|
|
@@ -25413,7 +25484,7 @@ async function handler3(raw, ctx) {
|
|
|
25413
25484
|
if (takesDashC(input.language, runtime)) {
|
|
25414
25485
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
25415
25486
|
} else {
|
|
25416
|
-
tmpDir =
|
|
25487
|
+
tmpDir = mkdtempSync2(join17(tmpdir3(), TMP_PREFIX));
|
|
25417
25488
|
const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
25418
25489
|
writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
|
|
25419
25490
|
argv = scriptArgv(input.language, runtime, file2);
|
|
@@ -25437,7 +25508,7 @@ async function handler3(raw, ctx) {
|
|
|
25437
25508
|
}
|
|
25438
25509
|
throw err;
|
|
25439
25510
|
} finally {
|
|
25440
|
-
if (tmpDir !== null && !handedOff)
|
|
25511
|
+
if (tmpDir !== null && !handedOff) rmSync5(tmpDir, { recursive: true, force: true });
|
|
25441
25512
|
}
|
|
25442
25513
|
}
|
|
25443
25514
|
var ctxExecute = {
|
|
@@ -30156,7 +30227,7 @@ var ctxStats = Object.freeze({
|
|
|
30156
30227
|
});
|
|
30157
30228
|
|
|
30158
30229
|
// src/core/tools/upgrade.ts
|
|
30159
|
-
import { existsSync as existsSync21, realpathSync as realpathSync10, rmSync as
|
|
30230
|
+
import { existsSync as existsSync21, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
|
|
30160
30231
|
import { basename as basename7, dirname as dirname12, join as join25 } from "node:path";
|
|
30161
30232
|
|
|
30162
30233
|
// src/core/ops/host-write.ts
|
|
@@ -30227,7 +30298,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
30227
30298
|
}
|
|
30228
30299
|
|
|
30229
30300
|
// src/core/ops/plugin-swap.ts
|
|
30230
|
-
import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as
|
|
30301
|
+
import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
30231
30302
|
import { basename as basename6, join as join21, win32 as win322 } from "node:path";
|
|
30232
30303
|
function linkTarget(path7, win) {
|
|
30233
30304
|
if (!isLink(path7)) return null;
|
|
@@ -30267,13 +30338,13 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
|
30267
30338
|
const keep = /* @__PURE__ */ new Set([sha]);
|
|
30268
30339
|
if (before !== null) keep.add(before);
|
|
30269
30340
|
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join21(agentDir, name));
|
|
30270
|
-
for (const dir of removed)
|
|
30341
|
+
for (const dir of removed) rmSync6(dir, { recursive: true, force: true });
|
|
30271
30342
|
const previous = before !== null && existsSync17(join21(agentDir, before)) ? join21(agentDir, before) : null;
|
|
30272
30343
|
return { current: next, previous, removed };
|
|
30273
30344
|
}
|
|
30274
30345
|
|
|
30275
30346
|
// src/core/ops/release-fetch.ts
|
|
30276
|
-
import { existsSync as existsSync18, mkdirSync as mkdirSync8, rmSync as
|
|
30347
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
|
|
30277
30348
|
import { join as join22 } from "node:path";
|
|
30278
30349
|
function failed(r) {
|
|
30279
30350
|
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
@@ -30289,7 +30360,7 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
30289
30360
|
const agentDir = join22(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
|
|
30290
30361
|
mkdirSync8(agentDir, { recursive: true });
|
|
30291
30362
|
const fetchDir = join22(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
|
|
30292
|
-
|
|
30363
|
+
rmSync7(fetchDir, { recursive: true, force: true });
|
|
30293
30364
|
const gitBin = findRuntime(GIT_BIN, env);
|
|
30294
30365
|
if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
30295
30366
|
const childEnv = buildChildEnv(env, { ...GIT_NO_PROMPT_ENV, ...GIT_NO_CRLF_ENV });
|
|
@@ -30297,17 +30368,17 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
30297
30368
|
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
|
|
30298
30369
|
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
30299
30370
|
const dir = join22(agentDir, sha);
|
|
30300
|
-
if (existsSync18(dir))
|
|
30371
|
+
if (existsSync18(dir)) rmSync7(fetchDir, { recursive: true, force: true });
|
|
30301
30372
|
else renameWithRetry(fetchDir, dir, opts);
|
|
30302
30373
|
return { sha, dir };
|
|
30303
30374
|
} catch (e) {
|
|
30304
|
-
|
|
30375
|
+
rmSync7(fetchDir, { recursive: true, force: true });
|
|
30305
30376
|
throw e;
|
|
30306
30377
|
}
|
|
30307
30378
|
}
|
|
30308
30379
|
|
|
30309
30380
|
// src/core/ops/uninstall.ts
|
|
30310
|
-
import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as
|
|
30381
|
+
import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
30311
30382
|
import { join as join23 } from "node:path";
|
|
30312
30383
|
function row2(area, before, after) {
|
|
30313
30384
|
return { area, before, after };
|
|
@@ -30336,13 +30407,13 @@ function removeCache(adapter, env, configDir) {
|
|
|
30336
30407
|
const cache = join23(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
30337
30408
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
30338
30409
|
}
|
|
30339
|
-
|
|
30410
|
+
rmSync8(root, { recursive: true, force: true });
|
|
30340
30411
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
30341
30412
|
}
|
|
30342
30413
|
case "plugin": {
|
|
30343
30414
|
const agentDir = join23(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
30344
30415
|
if (!existsSync19(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
30345
|
-
|
|
30416
|
+
rmSync8(agentDir, { recursive: true, force: true });
|
|
30346
30417
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
30347
30418
|
}
|
|
30348
30419
|
case "config-mcp":
|
|
@@ -30424,7 +30495,7 @@ function removeProjectData(configDir, projectKey) {
|
|
|
30424
30495
|
if (!existsSync19(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
30425
30496
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
30426
30497
|
for (const name of readdirSync9(dir)) {
|
|
30427
|
-
if (name !== OWNERS_DIR_NAME)
|
|
30498
|
+
if (name !== OWNERS_DIR_NAME) rmSync8(join23(dir, name), { recursive: true, force: true });
|
|
30428
30499
|
}
|
|
30429
30500
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
30430
30501
|
}
|
|
@@ -30437,20 +30508,20 @@ function runUninstall(input) {
|
|
|
30437
30508
|
}
|
|
30438
30509
|
|
|
30439
30510
|
// src/core/ops/v1-remove.ts
|
|
30440
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as
|
|
30511
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
|
|
30441
30512
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
30442
30513
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
30443
30514
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
30444
30515
|
function moveAside(target, undo) {
|
|
30445
30516
|
const trash = target + UPGRADE_TRASH_SUFFIX;
|
|
30446
|
-
|
|
30517
|
+
rmSync9(trash, { recursive: true, force: true });
|
|
30447
30518
|
renameWithRetry(target, trash);
|
|
30448
30519
|
undo.push({ trash, target });
|
|
30449
30520
|
}
|
|
30450
30521
|
function keepOriginal(file2, kept, undo) {
|
|
30451
30522
|
if (kept.has(file2)) return;
|
|
30452
30523
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
30453
|
-
|
|
30524
|
+
rmSync9(trash, { recursive: true, force: true });
|
|
30454
30525
|
copyFileSync2(file2, trash);
|
|
30455
30526
|
kept.add(file2);
|
|
30456
30527
|
undo.push({ trash, target: file2 });
|
|
@@ -30554,12 +30625,12 @@ function removeV1(agent, findings) {
|
|
|
30554
30625
|
return {
|
|
30555
30626
|
rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
|
|
30556
30627
|
commit() {
|
|
30557
|
-
for (const u of undo.splice(0))
|
|
30628
|
+
for (const u of undo.splice(0)) rmSync9(u.trash, { recursive: true, force: true });
|
|
30558
30629
|
},
|
|
30559
30630
|
rollback() {
|
|
30560
30631
|
for (const u of undo.splice(0).reverse()) {
|
|
30561
30632
|
if (!existsSync20(u.trash)) continue;
|
|
30562
|
-
|
|
30633
|
+
rmSync9(u.target, { recursive: true, force: true });
|
|
30563
30634
|
renameWithRetry(u.trash, u.target);
|
|
30564
30635
|
}
|
|
30565
30636
|
}
|
|
@@ -30644,7 +30715,7 @@ async function checkout(adapter, deps) {
|
|
|
30644
30715
|
try {
|
|
30645
30716
|
verifySums(fetched.dir);
|
|
30646
30717
|
} catch (err) {
|
|
30647
|
-
if (!isCurrent(agentDir, fetched.dir))
|
|
30718
|
+
if (!isCurrent(agentDir, fetched.dir)) rmSync10(fetched.dir, { recursive: true, force: true });
|
|
30648
30719
|
throw err;
|
|
30649
30720
|
}
|
|
30650
30721
|
const swap = swapPluginCurrent(agentDir, fetched.sha);
|
|
@@ -30756,7 +30827,7 @@ function checkCall(tool, input) {
|
|
|
30756
30827
|
|
|
30757
30828
|
// src/entries/server.ts
|
|
30758
30829
|
import { randomUUID } from "node:crypto";
|
|
30759
|
-
import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as
|
|
30830
|
+
import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync12 } from "node:fs";
|
|
30760
30831
|
import { dirname as dirname13, join as join27 } from "node:path";
|
|
30761
30832
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
30762
30833
|
|
|
@@ -58822,7 +58893,7 @@ function installExitGuard(opts) {
|
|
|
58822
58893
|
}
|
|
58823
58894
|
|
|
58824
58895
|
// src/core/store/cleanup.ts
|
|
58825
|
-
import { existsSync as existsSync22, readdirSync as readdirSync11, rmSync as
|
|
58896
|
+
import { existsSync as existsSync22, readdirSync as readdirSync11, rmSync as rmSync11 } from "node:fs";
|
|
58826
58897
|
import { join as join26 } from "node:path";
|
|
58827
58898
|
function deleteSource(raw, id) {
|
|
58828
58899
|
raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
|
|
@@ -58887,7 +58958,7 @@ function sweepOne(configDir, projectKey, cutoff) {
|
|
|
58887
58958
|
} finally {
|
|
58888
58959
|
closeDb(db);
|
|
58889
58960
|
}
|
|
58890
|
-
if (dead)
|
|
58961
|
+
if (dead) rmSync11(dir, { recursive: true, force: true });
|
|
58891
58962
|
return dead;
|
|
58892
58963
|
}
|
|
58893
58964
|
function sweepDeadProjects(configDir) {
|
|
@@ -59142,7 +59213,7 @@ async function startServer(argv, env) {
|
|
|
59142
59213
|
try {
|
|
59143
59214
|
const configDir = resolveConfigDir(process.env);
|
|
59144
59215
|
removeOwnerPid(configDir, db.projectKey, serverId);
|
|
59145
|
-
|
|
59216
|
+
rmSync12(stopMarker(configDir, db.projectKey), { force: true });
|
|
59146
59217
|
} catch (err) {
|
|
59147
59218
|
console.error(err);
|
|
59148
59219
|
}
|
package/qwen-extension.json
CHANGED
package/run.mjs
CHANGED
|
@@ -520,9 +520,28 @@ function outputOf(resp) {
|
|
|
520
520
|
return err === "" ? out : out === "" ? err : out + "\n" + err;
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
if (typeof resp === "object" && resp !== null &&
|
|
523
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp)) {
|
|
524
|
+
const slot = textSlot(resp);
|
|
525
|
+
if (slot !== null) return slot.text;
|
|
526
|
+
}
|
|
524
527
|
return JSON.stringify(resp);
|
|
525
528
|
}
|
|
529
|
+
function textSlot(r) {
|
|
530
|
+
const file = r.file;
|
|
531
|
+
if (r.type === "text" && typeof file === "object" && file !== null && typeof file.content === "string") {
|
|
532
|
+
return { text: file.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
|
|
533
|
+
}
|
|
534
|
+
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
535
|
+
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
536
|
+
return { text: r.filenames.join("\n"), put: (o, output) => ({ ...o, filenames: output.split("\n") }) };
|
|
537
|
+
}
|
|
538
|
+
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
function isShellShape(resp) {
|
|
542
|
+
const r = resp;
|
|
543
|
+
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
544
|
+
}
|
|
526
545
|
function isGrepContent(resp) {
|
|
527
546
|
const r = resp;
|
|
528
547
|
return r.mode === "content" && typeof r.content === "string";
|
|
@@ -541,7 +560,10 @@ function readResult(resp) {
|
|
|
541
560
|
const text = outputOf(resp);
|
|
542
561
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
543
562
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
544
|
-
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) &&
|
|
563
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
564
|
+
if (textSlot(resp) !== null) info.shape = resp;
|
|
565
|
+
else info.keep = true;
|
|
566
|
+
}
|
|
545
567
|
if (Array.isArray(resp)) {
|
|
546
568
|
info.blocks = true;
|
|
547
569
|
if (blocksOf(resp).keep) info.keep = true;
|
|
@@ -578,7 +600,9 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
578
600
|
}
|
|
579
601
|
function replaceShape(ev, output) {
|
|
580
602
|
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
581
|
-
|
|
603
|
+
const shape = ev.result?.shape;
|
|
604
|
+
const slot = shape === void 0 ? null : textSlot(shape);
|
|
605
|
+
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
582
606
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
583
607
|
return output;
|
|
584
608
|
}
|
package/search.mjs
CHANGED
|
@@ -520,9 +520,28 @@ function outputOf(resp) {
|
|
|
520
520
|
return err === "" ? out : out === "" ? err : out + "\n" + err;
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
if (typeof resp === "object" && resp !== null &&
|
|
523
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp)) {
|
|
524
|
+
const slot = textSlot(resp);
|
|
525
|
+
if (slot !== null) return slot.text;
|
|
526
|
+
}
|
|
524
527
|
return JSON.stringify(resp);
|
|
525
528
|
}
|
|
529
|
+
function textSlot(r) {
|
|
530
|
+
const file = r.file;
|
|
531
|
+
if (r.type === "text" && typeof file === "object" && file !== null && typeof file.content === "string") {
|
|
532
|
+
return { text: file.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
|
|
533
|
+
}
|
|
534
|
+
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
535
|
+
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
536
|
+
return { text: r.filenames.join("\n"), put: (o, output) => ({ ...o, filenames: output.split("\n") }) };
|
|
537
|
+
}
|
|
538
|
+
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
function isShellShape(resp) {
|
|
542
|
+
const r = resp;
|
|
543
|
+
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
544
|
+
}
|
|
526
545
|
function isGrepContent(resp) {
|
|
527
546
|
const r = resp;
|
|
528
547
|
return r.mode === "content" && typeof r.content === "string";
|
|
@@ -541,7 +560,10 @@ function readResult(resp) {
|
|
|
541
560
|
const text = outputOf(resp);
|
|
542
561
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
543
562
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
544
|
-
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) &&
|
|
563
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
564
|
+
if (textSlot(resp) !== null) info.shape = resp;
|
|
565
|
+
else info.keep = true;
|
|
566
|
+
}
|
|
545
567
|
if (Array.isArray(resp)) {
|
|
546
568
|
info.blocks = true;
|
|
547
569
|
if (blocksOf(resp).keep) info.keep = true;
|
|
@@ -578,7 +600,9 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
578
600
|
}
|
|
579
601
|
function replaceShape(ev, output) {
|
|
580
602
|
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
581
|
-
|
|
603
|
+
const shape = ev.result?.shape;
|
|
604
|
+
const slot = shape === void 0 ? null : textSlot(shape);
|
|
605
|
+
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
582
606
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
583
607
|
return output;
|
|
584
608
|
}
|