context-mode 2.0.1 → 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/server.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/entries/server.ts
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as
|
|
10
|
+
import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync12 } from "node:fs";
|
|
11
11
|
import { dirname as dirname12, join as join24 } from "node:path";
|
|
12
12
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13
13
|
|
|
@@ -28065,6 +28065,7 @@ var REPORT_CAP = 4096;
|
|
|
28065
28065
|
var POINTER_MIN = 640;
|
|
28066
28066
|
var STATE_CLOSE_TAG = "</context_mode_state>";
|
|
28067
28067
|
var INDEX_WRITE_CHUNK = 1048576;
|
|
28068
|
+
var REPLACE_TRIGGER_BYTES = 4096;
|
|
28068
28069
|
var MAX_CHUNK_BYTES = 4096;
|
|
28069
28070
|
var SEARCH_PAGE_SIZE = 20;
|
|
28070
28071
|
var MEMORY_LABEL_PREFIX = "memory ";
|
|
@@ -28406,7 +28407,7 @@ var DECISION_SOURCE = "decision";
|
|
|
28406
28407
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28407
28408
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28408
28409
|
var RELEASE_BRANCH = "release";
|
|
28409
|
-
var BUNDLE_SHA = true ? "
|
|
28410
|
+
var BUNDLE_SHA = true ? "9f1916d761e6a8e55ac43858b99dcdcd3cc53caa" : void 0;
|
|
28410
28411
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28411
28412
|
var DOCTOR_LABEL = Object.freeze({
|
|
28412
28413
|
D1: "version",
|
|
@@ -28670,6 +28671,7 @@ var REGEX_SPECIAL_CHARS = ".*+?^${}()|[]\\";
|
|
|
28670
28671
|
var REGEX_ESCAPE = "\\";
|
|
28671
28672
|
var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
|
|
28672
28673
|
var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
|
|
28674
|
+
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`;
|
|
28673
28675
|
function D5_SLOW_DETAIL(ms) {
|
|
28674
28676
|
return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
|
|
28675
28677
|
}
|
|
@@ -44795,9 +44797,28 @@ function outputOf(resp) {
|
|
|
44795
44797
|
return err === "" ? out : out === "" ? err : out + "\n" + err;
|
|
44796
44798
|
}
|
|
44797
44799
|
}
|
|
44798
|
-
if (typeof resp === "object" && resp !== null &&
|
|
44800
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp)) {
|
|
44801
|
+
const slot = textSlot(resp);
|
|
44802
|
+
if (slot !== null) return slot.text;
|
|
44803
|
+
}
|
|
44799
44804
|
return JSON.stringify(resp);
|
|
44800
44805
|
}
|
|
44806
|
+
function textSlot(r) {
|
|
44807
|
+
const file2 = r.file;
|
|
44808
|
+
if (r.type === "text" && typeof file2 === "object" && file2 !== null && typeof file2.content === "string") {
|
|
44809
|
+
return { text: file2.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
|
|
44810
|
+
}
|
|
44811
|
+
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
44812
|
+
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
44813
|
+
return { text: r.filenames.join("\n"), put: (o, output) => ({ ...o, filenames: output.split("\n") }) };
|
|
44814
|
+
}
|
|
44815
|
+
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
44816
|
+
return null;
|
|
44817
|
+
}
|
|
44818
|
+
function isShellShape(resp) {
|
|
44819
|
+
const r = resp;
|
|
44820
|
+
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
44821
|
+
}
|
|
44801
44822
|
function isGrepContent(resp) {
|
|
44802
44823
|
const r = resp;
|
|
44803
44824
|
return r.mode === "content" && typeof r.content === "string";
|
|
@@ -44816,7 +44837,10 @@ function readResult(resp) {
|
|
|
44816
44837
|
const text = outputOf(resp);
|
|
44817
44838
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
44818
44839
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
44819
|
-
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) &&
|
|
44840
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
44841
|
+
if (textSlot(resp) !== null) info.shape = resp;
|
|
44842
|
+
else info.keep = true;
|
|
44843
|
+
}
|
|
44820
44844
|
if (Array.isArray(resp)) {
|
|
44821
44845
|
info.blocks = true;
|
|
44822
44846
|
if (blocksOf(resp).keep) info.keep = true;
|
|
@@ -44853,7 +44877,9 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
44853
44877
|
}
|
|
44854
44878
|
function replaceShape(ev, output) {
|
|
44855
44879
|
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
44856
|
-
|
|
44880
|
+
const shape = ev.result?.shape;
|
|
44881
|
+
const slot = shape === void 0 ? null : textSlot(shape);
|
|
44882
|
+
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
44857
44883
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
44858
44884
|
return output;
|
|
44859
44885
|
}
|
|
@@ -48870,7 +48896,7 @@ function checkV1Leftovers(agent, home, scope = {}) {
|
|
|
48870
48896
|
if (findings.length === 0) return pass("D4");
|
|
48871
48897
|
const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
|
|
48872
48898
|
if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
|
|
48873
|
-
return fail("D4", detail, DOCTOR_FIX_UPGRADE);
|
|
48899
|
+
return { ...fail("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
|
|
48874
48900
|
}
|
|
48875
48901
|
function parsedOrNull(agent, file2, jsonc) {
|
|
48876
48902
|
try {
|
|
@@ -49193,7 +49219,8 @@ function checkShell(env) {
|
|
|
49193
49219
|
}
|
|
49194
49220
|
|
|
49195
49221
|
// src/core/ops/doctor-hook.ts
|
|
49196
|
-
import { existsSync as existsSync11, readFileSync as readFileSync8, realpathSync as realpathSync7 } from "node:fs";
|
|
49222
|
+
import { existsSync as existsSync11, mkdtempSync, readFileSync as readFileSync8, realpathSync as realpathSync7, rmSync as rmSync4 } from "node:fs";
|
|
49223
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
49197
49224
|
import path6 from "node:path";
|
|
49198
49225
|
|
|
49199
49226
|
// src/setup/codex-trust.ts
|
|
@@ -49477,6 +49504,50 @@ function isNativeShape(agent, stdout, exitCode, killed, event) {
|
|
|
49477
49504
|
return COPILOT_KEYS.some((k) => Object.hasOwn(out, k));
|
|
49478
49505
|
}
|
|
49479
49506
|
}
|
|
49507
|
+
var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
|
|
49508
|
+
function readProbePayload(cwd) {
|
|
49509
|
+
const content = Array.from({ length: READ_PROBE_LINES }, (_, n) => "d5 read probe line " + n + " ".padEnd(20, "x")).join("\n");
|
|
49510
|
+
const filePath = path6.join(cwd, "d5-read-probe.txt");
|
|
49511
|
+
return {
|
|
49512
|
+
session_id: "d5-read-probe",
|
|
49513
|
+
transcript_path: "",
|
|
49514
|
+
cwd,
|
|
49515
|
+
hook_event_name: "PostToolUse",
|
|
49516
|
+
tool_name: "Read",
|
|
49517
|
+
tool_use_id: "toolu_d5_read_probe",
|
|
49518
|
+
tool_input: { file_path: filePath },
|
|
49519
|
+
tool_response: { type: "text", file: { filePath, content, numLines: READ_PROBE_LINES, startLine: 1, totalLines: READ_PROBE_LINES } }
|
|
49520
|
+
};
|
|
49521
|
+
}
|
|
49522
|
+
function isReadShape(stdout) {
|
|
49523
|
+
if (stdout.trim() === "") return true;
|
|
49524
|
+
let out;
|
|
49525
|
+
try {
|
|
49526
|
+
out = JSON.parse(stdout);
|
|
49527
|
+
} catch {
|
|
49528
|
+
return false;
|
|
49529
|
+
}
|
|
49530
|
+
if (!isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
|
|
49531
|
+
const r = out.hookSpecificOutput.updatedToolOutput;
|
|
49532
|
+
if (!isObject5(r) || r.type !== "text" || !isObject5(r.file)) return false;
|
|
49533
|
+
const f = r.file;
|
|
49534
|
+
return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
|
|
49535
|
+
}
|
|
49536
|
+
async function readProbeOk(i, timeoutMs) {
|
|
49537
|
+
const home = mkdtempSync(path6.join(tmpdir2(), "cm-d5-read-"));
|
|
49538
|
+
try {
|
|
49539
|
+
const r = await runProcess([process.execPath, path6.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49540
|
+
cwd: i.bundleDir,
|
|
49541
|
+
env: { ...i.env, HOME: home, USERPROFILE: home },
|
|
49542
|
+
signal: i.signal,
|
|
49543
|
+
timeoutMs,
|
|
49544
|
+
stdin: JSON.stringify(readProbePayload(i.worktree ?? home))
|
|
49545
|
+
});
|
|
49546
|
+
return isReadShape(r.stdout.toString("utf8"));
|
|
49547
|
+
} finally {
|
|
49548
|
+
rmSync4(home, { recursive: true, force: true });
|
|
49549
|
+
}
|
|
49550
|
+
}
|
|
49480
49551
|
function codexHookJournaled(db) {
|
|
49481
49552
|
if (db === null) return false;
|
|
49482
49553
|
return db.raw.prepare("SELECT 1 FROM events WHERE agent = ? LIMIT 1").get("codex") !== void 0;
|
|
@@ -49544,6 +49615,7 @@ async function checkHookRoundTrip(i) {
|
|
|
49544
49615
|
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
49545
49616
|
}
|
|
49546
49617
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
49618
|
+
if (i.agent === "claude-code" && !await readProbeOk(i, timeoutMs)) return row("FAIL", D5_READ_SHAPE_DETAIL, D5_FIX);
|
|
49547
49619
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
49548
49620
|
}
|
|
49549
49621
|
|
|
@@ -49585,7 +49657,7 @@ function lastHookError(env) {
|
|
|
49585
49657
|
}
|
|
49586
49658
|
|
|
49587
49659
|
// src/core/ops/db-heal.ts
|
|
49588
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync5, rmSync as
|
|
49660
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync5, rmSync as rmSync5 } from "node:fs";
|
|
49589
49661
|
import { basename as basename4, dirname as dirname6, join as join12 } from "node:path";
|
|
49590
49662
|
function integrityOk2(rows) {
|
|
49591
49663
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
@@ -49593,7 +49665,7 @@ function integrityOk2(rows) {
|
|
|
49593
49665
|
async function healLossless(dbPath) {
|
|
49594
49666
|
const { DatabaseSync } = await import(SQLITE_MODULE);
|
|
49595
49667
|
const tmp = dbPath + HEAL_TMP_SUFFIX;
|
|
49596
|
-
|
|
49668
|
+
rmSync5(tmp, { force: true });
|
|
49597
49669
|
try {
|
|
49598
49670
|
const src = new DatabaseSync(dbPath, { readOnly: true, timeout: DB_TIMEOUT_MS });
|
|
49599
49671
|
try {
|
|
@@ -49609,11 +49681,11 @@ async function healLossless(dbPath) {
|
|
|
49609
49681
|
} finally {
|
|
49610
49682
|
copy.close();
|
|
49611
49683
|
}
|
|
49612
|
-
|
|
49613
|
-
|
|
49684
|
+
rmSync5(dbPath + DB_WAL_SUFFIX, { force: true });
|
|
49685
|
+
rmSync5(dbPath + DB_SHM_SUFFIX, { force: true });
|
|
49614
49686
|
renameWithRetry(tmp, dbPath);
|
|
49615
49687
|
} finally {
|
|
49616
|
-
|
|
49688
|
+
rmSync5(tmp, { force: true });
|
|
49617
49689
|
}
|
|
49618
49690
|
}
|
|
49619
49691
|
function renameAside(dbPath) {
|
|
@@ -50077,8 +50149,8 @@ var ctxDoctor = Object.freeze({
|
|
|
50077
50149
|
});
|
|
50078
50150
|
|
|
50079
50151
|
// src/core/tools/execute.ts
|
|
50080
|
-
import { existsSync as existsSync15, mkdtempSync, rmSync as
|
|
50081
|
-
import { tmpdir as
|
|
50152
|
+
import { existsSync as existsSync15, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
50153
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
50082
50154
|
import { dirname as dirname8, join as join15, parse as parse5, resolve as resolve4 } from "node:path";
|
|
50083
50155
|
|
|
50084
50156
|
// src/core/index/select.ts
|
|
@@ -50283,7 +50355,7 @@ async function handler3(raw, ctx) {
|
|
|
50283
50355
|
if (takesDashC(input.language, runtime)) {
|
|
50284
50356
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
50285
50357
|
} else {
|
|
50286
|
-
tmpDir =
|
|
50358
|
+
tmpDir = mkdtempSync2(join15(tmpdir3(), TMP_PREFIX));
|
|
50287
50359
|
const file2 = join15(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
50288
50360
|
writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
|
|
50289
50361
|
argv = scriptArgv(input.language, runtime, file2);
|
|
@@ -50307,7 +50379,7 @@ async function handler3(raw, ctx) {
|
|
|
50307
50379
|
}
|
|
50308
50380
|
throw err;
|
|
50309
50381
|
} finally {
|
|
50310
|
-
if (tmpDir !== null && !handedOff)
|
|
50382
|
+
if (tmpDir !== null && !handedOff) rmSync6(tmpDir, { recursive: true, force: true });
|
|
50311
50383
|
}
|
|
50312
50384
|
}
|
|
50313
50385
|
var ctxExecute = {
|
|
@@ -55291,7 +55363,7 @@ var ctxStats = Object.freeze({
|
|
|
55291
55363
|
});
|
|
55292
55364
|
|
|
55293
55365
|
// src/core/tools/upgrade.ts
|
|
55294
|
-
import { existsSync as existsSync22, realpathSync as realpathSync10, rmSync as
|
|
55366
|
+
import { existsSync as existsSync22, realpathSync as realpathSync10, rmSync as rmSync11 } from "node:fs";
|
|
55295
55367
|
import { basename as basename7, dirname as dirname11, join as join23 } from "node:path";
|
|
55296
55368
|
|
|
55297
55369
|
// src/core/ops/host-write.ts
|
|
@@ -55362,7 +55434,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55362
55434
|
}
|
|
55363
55435
|
|
|
55364
55436
|
// src/core/ops/plugin-swap.ts
|
|
55365
|
-
import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as
|
|
55437
|
+
import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync7, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55366
55438
|
import { basename as basename6, join as join19, win32 as win322 } from "node:path";
|
|
55367
55439
|
function linkTarget(path7, win) {
|
|
55368
55440
|
if (!isLink(path7)) return null;
|
|
@@ -55402,13 +55474,13 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
|
55402
55474
|
const keep = /* @__PURE__ */ new Set([sha]);
|
|
55403
55475
|
if (before !== null) keep.add(before);
|
|
55404
55476
|
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join19(agentDir, name));
|
|
55405
|
-
for (const dir of removed)
|
|
55477
|
+
for (const dir of removed) rmSync7(dir, { recursive: true, force: true });
|
|
55406
55478
|
const previous = before !== null && existsSync18(join19(agentDir, before)) ? join19(agentDir, before) : null;
|
|
55407
55479
|
return { current: next, previous, removed };
|
|
55408
55480
|
}
|
|
55409
55481
|
|
|
55410
55482
|
// src/core/ops/release-fetch.ts
|
|
55411
|
-
import { existsSync as existsSync19, mkdirSync as mkdirSync8, rmSync as
|
|
55483
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync8, rmSync as rmSync8 } from "node:fs";
|
|
55412
55484
|
import { join as join20 } from "node:path";
|
|
55413
55485
|
function failed(r) {
|
|
55414
55486
|
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
@@ -55424,7 +55496,7 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55424
55496
|
const agentDir = join20(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
|
|
55425
55497
|
mkdirSync8(agentDir, { recursive: true });
|
|
55426
55498
|
const fetchDir = join20(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
|
|
55427
|
-
|
|
55499
|
+
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55428
55500
|
const gitBin = findRuntime(GIT_BIN, env);
|
|
55429
55501
|
if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55430
55502
|
const childEnv = buildChildEnv(env, { ...GIT_NO_PROMPT_ENV, ...GIT_NO_CRLF_ENV });
|
|
@@ -55432,17 +55504,17 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55432
55504
|
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
|
|
55433
55505
|
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
55434
55506
|
const dir = join20(agentDir, sha);
|
|
55435
|
-
if (existsSync19(dir))
|
|
55507
|
+
if (existsSync19(dir)) rmSync8(fetchDir, { recursive: true, force: true });
|
|
55436
55508
|
else renameWithRetry(fetchDir, dir, opts);
|
|
55437
55509
|
return { sha, dir };
|
|
55438
55510
|
} catch (e) {
|
|
55439
|
-
|
|
55511
|
+
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55440
55512
|
throw e;
|
|
55441
55513
|
}
|
|
55442
55514
|
}
|
|
55443
55515
|
|
|
55444
55516
|
// src/core/ops/uninstall.ts
|
|
55445
|
-
import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as
|
|
55517
|
+
import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as rmSync9, writeFileSync as writeFileSync6 } from "node:fs";
|
|
55446
55518
|
import { join as join21 } from "node:path";
|
|
55447
55519
|
function row2(area, before, after) {
|
|
55448
55520
|
return { area, before, after };
|
|
@@ -55471,13 +55543,13 @@ function removeCache(adapter, env, configDir) {
|
|
|
55471
55543
|
const cache = join21(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
55472
55544
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
55473
55545
|
}
|
|
55474
|
-
|
|
55546
|
+
rmSync9(root, { recursive: true, force: true });
|
|
55475
55547
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
55476
55548
|
}
|
|
55477
55549
|
case "plugin": {
|
|
55478
55550
|
const agentDir = join21(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
55479
55551
|
if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55480
|
-
|
|
55552
|
+
rmSync9(agentDir, { recursive: true, force: true });
|
|
55481
55553
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
55482
55554
|
}
|
|
55483
55555
|
case "config-mcp":
|
|
@@ -55559,7 +55631,7 @@ function removeProjectData(configDir, projectKey) {
|
|
|
55559
55631
|
if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55560
55632
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55561
55633
|
for (const name of readdirSync10(dir)) {
|
|
55562
|
-
if (name !== OWNERS_DIR_NAME)
|
|
55634
|
+
if (name !== OWNERS_DIR_NAME) rmSync9(join21(dir, name), { recursive: true, force: true });
|
|
55563
55635
|
}
|
|
55564
55636
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
55565
55637
|
}
|
|
@@ -55572,20 +55644,20 @@ function runUninstall(input) {
|
|
|
55572
55644
|
}
|
|
55573
55645
|
|
|
55574
55646
|
// src/core/ops/v1-remove.ts
|
|
55575
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync13, rmSync as
|
|
55647
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync13, rmSync as rmSync10 } from "node:fs";
|
|
55576
55648
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55577
55649
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
55578
55650
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
55579
55651
|
function moveAside(target, undo) {
|
|
55580
55652
|
const trash = target + UPGRADE_TRASH_SUFFIX;
|
|
55581
|
-
|
|
55653
|
+
rmSync10(trash, { recursive: true, force: true });
|
|
55582
55654
|
renameWithRetry(target, trash);
|
|
55583
55655
|
undo.push({ trash, target });
|
|
55584
55656
|
}
|
|
55585
55657
|
function keepOriginal(file2, kept, undo) {
|
|
55586
55658
|
if (kept.has(file2)) return;
|
|
55587
55659
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
55588
|
-
|
|
55660
|
+
rmSync10(trash, { recursive: true, force: true });
|
|
55589
55661
|
copyFileSync2(file2, trash);
|
|
55590
55662
|
kept.add(file2);
|
|
55591
55663
|
undo.push({ trash, target: file2 });
|
|
@@ -55689,12 +55761,12 @@ function removeV1(agent, findings) {
|
|
|
55689
55761
|
return {
|
|
55690
55762
|
rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
|
|
55691
55763
|
commit() {
|
|
55692
|
-
for (const u of undo.splice(0))
|
|
55764
|
+
for (const u of undo.splice(0)) rmSync10(u.trash, { recursive: true, force: true });
|
|
55693
55765
|
},
|
|
55694
55766
|
rollback() {
|
|
55695
55767
|
for (const u of undo.splice(0).reverse()) {
|
|
55696
55768
|
if (!existsSync21(u.trash)) continue;
|
|
55697
|
-
|
|
55769
|
+
rmSync10(u.target, { recursive: true, force: true });
|
|
55698
55770
|
renameWithRetry(u.trash, u.target);
|
|
55699
55771
|
}
|
|
55700
55772
|
}
|
|
@@ -55779,7 +55851,7 @@ async function checkout(adapter, deps) {
|
|
|
55779
55851
|
try {
|
|
55780
55852
|
verifySums(fetched.dir);
|
|
55781
55853
|
} catch (err) {
|
|
55782
|
-
if (!isCurrent(agentDir, fetched.dir))
|
|
55854
|
+
if (!isCurrent(agentDir, fetched.dir)) rmSync11(fetched.dir, { recursive: true, force: true });
|
|
55783
55855
|
throw err;
|
|
55784
55856
|
}
|
|
55785
55857
|
const swap = swapPluginCurrent(agentDir, fetched.sha);
|
|
@@ -56120,7 +56192,7 @@ async function startServer(argv, env) {
|
|
|
56120
56192
|
try {
|
|
56121
56193
|
const configDir = resolveConfigDir(process.env);
|
|
56122
56194
|
removeOwnerPid(configDir, db.projectKey, serverId);
|
|
56123
|
-
|
|
56195
|
+
rmSync12(stopMarker(configDir, db.projectKey), { force: true });
|
|
56124
56196
|
} catch (err) {
|
|
56125
56197
|
console.error(err);
|
|
56126
56198
|
}
|