@exorcist-98/cli 0.3.4 → 0.3.5
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/README.md +8 -8
- package/dist/index.mjs +112 -100
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Needs Node 20 or newer.
|
|
|
11
11
|
## Scan a project
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
npx -y @exorcist-98/cli@0.3.
|
|
14
|
+
npx -y @exorcist-98/cli@0.3.5 scan .
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
Every finding shows the file, line, the exact text, how serious it is and how
|
|
@@ -39,7 +39,7 @@ request.
|
|
|
39
39
|
## Map the haunted house
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
npx -y @exorcist-98/cli@0.3.
|
|
42
|
+
npx -y @exorcist-98/cli@0.3.5 map .
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
For every MCP config in the folder, lists which servers sit in the three rooms
|
|
@@ -52,8 +52,8 @@ data. The rules are in `definitions/capabilities.yaml`.
|
|
|
52
52
|
## Disinfect (exorcise)
|
|
53
53
|
|
|
54
54
|
```sh
|
|
55
|
-
npx -y @exorcist-98/cli@0.3.
|
|
56
|
-
npx -y @exorcist-98/cli@0.3.
|
|
55
|
+
npx -y @exorcist-98/cli@0.3.5 exorcise . # dry run: prints a unified diff
|
|
56
|
+
npx -y @exorcist-98/cli@0.3.5 exorcise . --write # apply, with a vault backup first
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
Only threats with one safe, mechanical fix are repaired: hidden characters
|
|
@@ -67,7 +67,7 @@ human"), and `exorcist vault restore <id>` puts every file back byte for byte.
|
|
|
67
67
|
## Protect your MCP servers
|
|
68
68
|
|
|
69
69
|
```sh
|
|
70
|
-
npx -y @exorcist-98/cli@0.3.
|
|
70
|
+
npx -y @exorcist-98/cli@0.3.5 wrap .kiro/settings/mcp.json
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
`wrap` puts every server in the file, local or remote, behind the Real-Time
|
|
@@ -79,9 +79,9 @@ instruct your agent. `unwrap` restores the file exactly. See
|
|
|
79
79
|
## Share approved tools with your team: exorcist.lock
|
|
80
80
|
|
|
81
81
|
```sh
|
|
82
|
-
npx -y @exorcist-98/cli@0.3.
|
|
83
|
-
npx -y @exorcist-98/cli@0.3.
|
|
84
|
-
npx -y @exorcist-98/cli@0.3.
|
|
82
|
+
npx -y @exorcist-98/cli@0.3.5 lock # write exorcist.lock, then commit it
|
|
83
|
+
npx -y @exorcist-98/cli@0.3.5 lock --check # exit 1 if any tool or program changed
|
|
84
|
+
npx -y @exorcist-98/cli@0.3.5 lock --check --static # starts nothing: names, programs, URLs only
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
`exorcist.lock` records the fingerprint of every tool your MCP servers list,
|
package/dist/index.mjs
CHANGED
|
@@ -21762,7 +21762,7 @@ function checkPathSegment(name) {
|
|
|
21762
21762
|
}
|
|
21763
21763
|
|
|
21764
21764
|
// ../core/src/lifecycle-scripts.ts
|
|
21765
|
-
import { closeSync, existsSync, lstatSync, openSync, readdirSync, readSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
21765
|
+
import { closeSync, existsSync as existsSync2, lstatSync, openSync, readdirSync, readSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
21766
21766
|
import { isAbsolute as isAbsolute5, join as join7, posix as posix2, relative as relative5, resolve as resolve5, sep } from "node:path";
|
|
21767
21767
|
|
|
21768
21768
|
// ../core/src/install-hooks.ts
|
|
@@ -22592,7 +22592,7 @@ function parseShell(command, sub = false) {
|
|
|
22592
22592
|
|
|
22593
22593
|
// ../core/src/dev-tools.ts
|
|
22594
22594
|
init_zod();
|
|
22595
|
-
import { readFileSync as readFileSync3, statSync } from "node:fs";
|
|
22595
|
+
import { existsSync, readFileSync as readFileSync3, statSync } from "node:fs";
|
|
22596
22596
|
import { homedir as homedir2 } from "node:os";
|
|
22597
22597
|
import { isAbsolute as isAbsolute4, join as join6, normalize as normalize2, relative as relative4, resolve as resolve3 } from "node:path";
|
|
22598
22598
|
|
|
@@ -22906,14 +22906,26 @@ function envFamilyOwners(name) {
|
|
|
22906
22906
|
return null;
|
|
22907
22907
|
}
|
|
22908
22908
|
var PATH_VAR = /(?:CONFIG|_FILES?|_DIR|_HOME|_PATH|_PLUGINS?|CACHEDIR|_CERT\w*|_CA\w*)$/;
|
|
22909
|
+
var PROGRAM_VAR = /(?:EDITOR|PAGER|BROWSER|_CMD|_COMMAND|_HELPER|_PROGRAM|_EXEC|_SHELL|_ARGS(?:_\w+)?)$/u;
|
|
22909
22910
|
var ENDPOINT_VAR = /(?:_HOST|_URL|_ENDPOINT|_SERVER)$/;
|
|
22910
22911
|
function unlockedValueRisk(name, value, cwd, dynamic) {
|
|
22911
22912
|
const runtime = dynamic || /[$`]/.test(value);
|
|
22912
22913
|
const say = `${name} is set to a path inside the project, or to a value built at run time, and a tool config can name a program to run or a daemon to reach`;
|
|
22913
22914
|
if (runtime) return say;
|
|
22914
22915
|
if (PATH_VAR.test(name) && anyInside(value, cwd)) return say;
|
|
22915
|
-
|
|
22916
|
-
|
|
22916
|
+
const parts2 = value.split(/[\s:,;=]+/u).filter((x) => x !== "");
|
|
22917
|
+
if (PROGRAM_VAR.test(name)) {
|
|
22918
|
+
const only = parts2.length === 1 && value.trim() === parts2[0] ? parts2[0] : void 0;
|
|
22919
|
+
const ok2 = only !== void 0 && (isAbsolute4(only) ? !insideProject(only, cwd) : !/[/\\~]/u.test(only) && cwd !== void 0 && !existsSync(resolve3(cwd, only)));
|
|
22920
|
+
if (!ok2) return `${name} names a program or arguments for the tool, and only one word is allowed: an absolute path outside the project, or a program name that is not a file in the project`;
|
|
22921
|
+
}
|
|
22922
|
+
for (const part of parts2) {
|
|
22923
|
+
if (/^[./~]/u.test(part) || part.includes("/")) {
|
|
22924
|
+
if (insideProject(part, cwd)) return say;
|
|
22925
|
+
} else {
|
|
22926
|
+
const bare = part.replace(/^-+/u, "");
|
|
22927
|
+
if (bare !== "" && (cwd === void 0 || existsSync(resolve3(cwd, bare)))) return say;
|
|
22928
|
+
}
|
|
22917
22929
|
}
|
|
22918
22930
|
if (ENDPOINT_VAR.test(name)) {
|
|
22919
22931
|
const m = /^(?:unix|npipe|file):\/\/(.*)$/.exec(value);
|
|
@@ -24818,7 +24830,7 @@ function readLocalText(pkgDir, rel) {
|
|
|
24818
24830
|
const r = relative5(root, p);
|
|
24819
24831
|
return r !== "" && !r.startsWith("..") && !isAbsolute5(r) && !r.split(sep).includes("..");
|
|
24820
24832
|
};
|
|
24821
|
-
if (!within(pkgDir, abs) || !
|
|
24833
|
+
if (!within(pkgDir, abs) || !existsSync2(abs)) return null;
|
|
24822
24834
|
const real = realpathSync2(abs);
|
|
24823
24835
|
if (!within(realpathSync2(pkgDir), real)) return null;
|
|
24824
24836
|
const st = statSync2(real);
|
|
@@ -25777,7 +25789,7 @@ async function* scanRepo(root, options) {
|
|
|
25777
25789
|
init_zod();
|
|
25778
25790
|
|
|
25779
25791
|
// ../core/src/version.ts
|
|
25780
|
-
var SCANNER_VERSION = "0.3.
|
|
25792
|
+
var SCANNER_VERSION = "0.3.5";
|
|
25781
25793
|
|
|
25782
25794
|
// ../core/src/reporters/json-reporter.ts
|
|
25783
25795
|
var ScanStatsSchema = external_exports.object({
|
|
@@ -27143,7 +27155,7 @@ import { isAbsolute as isAbsolute7, join as join12, relative as relative6, resol
|
|
|
27143
27155
|
|
|
27144
27156
|
// ../core/src/repo-config-guard.ts
|
|
27145
27157
|
import { execFile } from "node:child_process";
|
|
27146
|
-
import { existsSync as
|
|
27158
|
+
import { existsSync as existsSync3, readFileSync as readFileSync5, realpathSync as realpathSync3, statSync as statSync4 } from "node:fs";
|
|
27147
27159
|
import { tmpdir } from "node:os";
|
|
27148
27160
|
import { dirname as dirname3, isAbsolute as isAbsolute6, join as join11, resolve as resolve7 } from "node:path";
|
|
27149
27161
|
function stripComment(s) {
|
|
@@ -27231,7 +27243,7 @@ function locateRepo(start) {
|
|
|
27231
27243
|
}
|
|
27232
27244
|
for (; ; ) {
|
|
27233
27245
|
const dotGit = join11(dir, ".git");
|
|
27234
|
-
if (
|
|
27246
|
+
if (existsSync3(dotGit)) {
|
|
27235
27247
|
let gitDir = null;
|
|
27236
27248
|
try {
|
|
27237
27249
|
if (statSync4(dotGit).isDirectory()) gitDir = dotGit;
|
|
@@ -27242,14 +27254,14 @@ function locateRepo(start) {
|
|
|
27242
27254
|
} catch {
|
|
27243
27255
|
return null;
|
|
27244
27256
|
}
|
|
27245
|
-
if (!gitDir || !
|
|
27257
|
+
if (!gitDir || !existsSync3(gitDir)) return null;
|
|
27246
27258
|
let commonDir = gitDir;
|
|
27247
27259
|
const commonFile = join11(gitDir, "commondir");
|
|
27248
|
-
if (
|
|
27260
|
+
if (existsSync3(commonFile)) {
|
|
27249
27261
|
const c = readFileSync5(commonFile, "utf8").trim();
|
|
27250
27262
|
commonDir = isAbsolute6(c) ? c : resolve7(gitDir, c);
|
|
27251
27263
|
}
|
|
27252
|
-
const configFiles = [join11(commonDir, "config"), join11(gitDir, "config.worktree")].filter((f, i, all) => all.indexOf(f) === i &&
|
|
27264
|
+
const configFiles = [join11(commonDir, "config"), join11(gitDir, "config.worktree")].filter((f, i, all) => all.indexOf(f) === i && existsSync3(f));
|
|
27253
27265
|
return { workTree: dir, gitDir, configFiles };
|
|
27254
27266
|
}
|
|
27255
27267
|
const up = dirname3(dir);
|
|
@@ -27676,7 +27688,7 @@ function buildTimeline(traced) {
|
|
|
27676
27688
|
// ../core/src/hook-guard.ts
|
|
27677
27689
|
init_secrets_check();
|
|
27678
27690
|
init_canary();
|
|
27679
|
-
import { existsSync as
|
|
27691
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6, statSync as statSync5 } from "node:fs";
|
|
27680
27692
|
import { homedir as homedir4 } from "node:os";
|
|
27681
27693
|
import { dirname as dirname4, join as join13, resolve as resolve9 } from "node:path";
|
|
27682
27694
|
function strings3(value, out = [], depth = 0) {
|
|
@@ -27707,7 +27719,7 @@ function readAliases(cwd, home) {
|
|
|
27707
27719
|
const files = [join13(home, ".gitconfig"), join13(home, ".config", "git", "config")];
|
|
27708
27720
|
let d = resolve9(cwd);
|
|
27709
27721
|
for (let i = 0; i < 40; i++) {
|
|
27710
|
-
if (
|
|
27722
|
+
if (existsSync4(join13(d, ".git"))) {
|
|
27711
27723
|
files.push(join13(d, ".git", "config"));
|
|
27712
27724
|
break;
|
|
27713
27725
|
}
|
|
@@ -27816,14 +27828,14 @@ A trap token has been copied out of its trap. Find what copied it, remove the co
|
|
|
27816
27828
|
}
|
|
27817
27829
|
|
|
27818
27830
|
// ../core/src/on-access.ts
|
|
27819
|
-
import { closeSync as closeSync2, existsSync as
|
|
27831
|
+
import { closeSync as closeSync2, existsSync as existsSync7, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync8, readSync as readSync2, realpathSync as realpathSync5, statSync as statSync7 } from "node:fs";
|
|
27820
27832
|
import { createHash as createHash3 } from "node:crypto";
|
|
27821
27833
|
import { basename as basename5, isAbsolute as isAbsolute11, relative as relative8, resolve as resolve13 } from "node:path";
|
|
27822
27834
|
|
|
27823
27835
|
// ../core/src/allowed-reads.ts
|
|
27824
27836
|
init_zod();
|
|
27825
27837
|
import { createHash as createHash2 } from "node:crypto";
|
|
27826
|
-
import { existsSync as
|
|
27838
|
+
import { existsSync as existsSync5, mkdirSync, readFileSync as readFileSync7, realpathSync as realpathSync4, renameSync, statSync as statSync6, writeFileSync } from "node:fs";
|
|
27827
27839
|
import { homedir as homedir5 } from "node:os";
|
|
27828
27840
|
import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute8, join as join14, parse, relative as relative7, resolve as resolve10 } from "node:path";
|
|
27829
27841
|
var Hash = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
@@ -27835,7 +27847,7 @@ function sha256Bytes(data) {
|
|
|
27835
27847
|
}
|
|
27836
27848
|
function sha256File(file) {
|
|
27837
27849
|
try {
|
|
27838
|
-
if (!
|
|
27850
|
+
if (!existsSync5(file) || !statSync6(file).isFile()) return null;
|
|
27839
27851
|
return sha256Bytes(readFileSync7(file));
|
|
27840
27852
|
} catch {
|
|
27841
27853
|
return null;
|
|
@@ -27857,7 +27869,7 @@ function findProjectRoot(cwd) {
|
|
|
27857
27869
|
const start = realPath(cwd);
|
|
27858
27870
|
const { root } = parse(start);
|
|
27859
27871
|
for (let dir = start; ; dir = dirname5(dir)) {
|
|
27860
|
-
if (PROJECT_MARKERS.some((m) =>
|
|
27872
|
+
if (PROJECT_MARKERS.some((m) => existsSync5(join14(dir, m)))) return dir;
|
|
27861
27873
|
if (dir === root || dirname5(dir) === dir) break;
|
|
27862
27874
|
}
|
|
27863
27875
|
return start;
|
|
@@ -27881,7 +27893,7 @@ function allowKey(realAbsPath, sha2564) {
|
|
|
27881
27893
|
}
|
|
27882
27894
|
function readAllowedReads(cwd, env = process.env) {
|
|
27883
27895
|
const loc = allowedReadsLocation(cwd, env);
|
|
27884
|
-
if (!loc.ok || !
|
|
27896
|
+
if (!loc.ok || !existsSync5(loc.file)) return /* @__PURE__ */ new Set();
|
|
27885
27897
|
try {
|
|
27886
27898
|
if (isInside2(loc.file, loc.project)) return /* @__PURE__ */ new Set();
|
|
27887
27899
|
const result = AllowedReadsSchema.safeParse(JSON.parse(readFileSync7(loc.file, "utf8")));
|
|
@@ -27899,7 +27911,7 @@ function addAllowedRead(cwd, file, env = process.env, expected) {
|
|
|
27899
27911
|
const loc = allowedReadsLocation(cwd, env);
|
|
27900
27912
|
if (!loc.ok) return loc;
|
|
27901
27913
|
let entries = [];
|
|
27902
|
-
if (
|
|
27914
|
+
if (existsSync5(loc.file)) {
|
|
27903
27915
|
try {
|
|
27904
27916
|
const parsed = AllowedReadsSchema.safeParse(JSON.parse(readFileSync7(loc.file, "utf8")));
|
|
27905
27917
|
if (parsed.success && parsed.data.project === loc.project) entries = parsed.data.entries;
|
|
@@ -27916,7 +27928,7 @@ function addAllowedRead(cwd, file, env = process.env, expected) {
|
|
|
27916
27928
|
}
|
|
27917
27929
|
|
|
27918
27930
|
// ../core/src/fs-expand.ts
|
|
27919
|
-
import { existsSync as
|
|
27931
|
+
import { existsSync as existsSync6, lstatSync as lstatSync2, readdirSync as readdirSync2 } from "node:fs";
|
|
27920
27932
|
import { isAbsolute as isAbsolute9, resolve as resolve11 } from "node:path";
|
|
27921
27933
|
var MAX_TARGETS = 100;
|
|
27922
27934
|
var MAX_RECURSIVE_FILES = 500;
|
|
@@ -27995,7 +28007,7 @@ function expandGlob(word, dir) {
|
|
|
27995
28007
|
level = next;
|
|
27996
28008
|
}
|
|
27997
28009
|
for (const p of level) {
|
|
27998
|
-
if (!
|
|
28010
|
+
if (!existsSync6(p)) continue;
|
|
27999
28011
|
out.push(p);
|
|
28000
28012
|
if (out.length >= cap3) return out;
|
|
28001
28013
|
}
|
|
@@ -28455,7 +28467,7 @@ function decideRead(event, defs, opts = {}) {
|
|
|
28455
28467
|
let text;
|
|
28456
28468
|
let bytes;
|
|
28457
28469
|
try {
|
|
28458
|
-
if (!
|
|
28470
|
+
if (!existsSync7(abs)) continue;
|
|
28459
28471
|
const stat4 = statSync7(abs);
|
|
28460
28472
|
if (!stat4.isFile()) continue;
|
|
28461
28473
|
if (stat4.size > MAX_SCAN_BYTES) {
|
|
@@ -29148,7 +29160,7 @@ function webFetchBlockMessage(d) {
|
|
|
29148
29160
|
init_zod();
|
|
29149
29161
|
|
|
29150
29162
|
// ../core/src/gitignore.ts
|
|
29151
|
-
import { existsSync as
|
|
29163
|
+
import { existsSync as existsSync8, readFileSync as readFileSync10, statSync as statSync9 } from "node:fs";
|
|
29152
29164
|
import { dirname as dirname7, join as join16, relative as relative9, resolve as resolve15, sep as sep3 } from "node:path";
|
|
29153
29165
|
var MAX_IGNORE_BYTES = 256 * 1024;
|
|
29154
29166
|
function globToRe(glob) {
|
|
@@ -29210,7 +29222,7 @@ function parseGitignore(text) {
|
|
|
29210
29222
|
}
|
|
29211
29223
|
function readIgnore(path) {
|
|
29212
29224
|
try {
|
|
29213
|
-
if (!
|
|
29225
|
+
if (!existsSync8(path) || statSync9(path).size > MAX_IGNORE_BYTES) return [];
|
|
29214
29226
|
return parseGitignore(readFileSync10(path, "utf8"));
|
|
29215
29227
|
} catch {
|
|
29216
29228
|
return [];
|
|
@@ -29219,7 +29231,7 @@ function readIgnore(path) {
|
|
|
29219
29231
|
function repoRootOf(from) {
|
|
29220
29232
|
let d = resolve15(from);
|
|
29221
29233
|
for (let i = 0; i < 40; i++) {
|
|
29222
|
-
if (
|
|
29234
|
+
if (existsSync8(join16(d, ".git"))) return d;
|
|
29223
29235
|
const up = dirname7(d);
|
|
29224
29236
|
if (up === d) return null;
|
|
29225
29237
|
d = up;
|
|
@@ -30373,7 +30385,7 @@ var SessionJsonSchema = external_exports.object({
|
|
|
30373
30385
|
}).passthrough();
|
|
30374
30386
|
|
|
30375
30387
|
// ../core/src/run-scripts-guard.ts
|
|
30376
|
-
import { existsSync as
|
|
30388
|
+
import { existsSync as existsSync9, readFileSync as readFileSync13, realpathSync as realpathSync7, statSync as statSync11 } from "node:fs";
|
|
30377
30389
|
import { isAbsolute as isAbsolute14, join as join19, relative as relative11, resolve as resolve18, sep as sep4 } from "node:path";
|
|
30378
30390
|
var MAX_PKG_BYTES = 1048576;
|
|
30379
30391
|
var MAX_WORKSPACE_PACKAGES = 300;
|
|
@@ -30395,7 +30407,7 @@ var insideOf = (root, p) => {
|
|
|
30395
30407
|
function readPackage(dir) {
|
|
30396
30408
|
try {
|
|
30397
30409
|
const p = join19(dir, "package.json");
|
|
30398
|
-
if (!
|
|
30410
|
+
if (!existsSync9(p) || statSync11(p).size > MAX_PKG_BYTES) return null;
|
|
30399
30411
|
return readFileSync13(p, "utf8");
|
|
30400
30412
|
} catch {
|
|
30401
30413
|
return null;
|
|
@@ -30456,7 +30468,7 @@ function expandGlob2(root, pattern) {
|
|
|
30456
30468
|
} else if (/[*?]/.test(seg)) {
|
|
30457
30469
|
const re2 = new RegExp(`^${seg.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]")}$`);
|
|
30458
30470
|
for (const e of listLocal(base, ".") ?? []) if (e.endsWith("/") && re2.test(e.slice(0, -1)) && e !== "node_modules/") next.push(join19(base, e.slice(0, -1)));
|
|
30459
|
-
} else if (
|
|
30471
|
+
} else if (existsSync9(join19(base, seg))) next.push(join19(base, seg));
|
|
30460
30472
|
}
|
|
30461
30473
|
level = next;
|
|
30462
30474
|
if (level.length > MAX_WORKSPACE_PACKAGES) break;
|
|
@@ -30469,13 +30481,13 @@ function workspacePackages(root) {
|
|
|
30469
30481
|
const include = globs.filter((g) => !g.startsWith("!"));
|
|
30470
30482
|
const exclude = globs.filter((g) => g.startsWith("!")).flatMap((g) => expandGlob2(root, g.slice(1)));
|
|
30471
30483
|
const dirs = /* @__PURE__ */ new Set();
|
|
30472
|
-
for (const g of include) for (const d of expandGlob2(root, g)) if (!exclude.includes(d) &&
|
|
30484
|
+
for (const g of include) for (const d of expandGlob2(root, g)) if (!exclude.includes(d) && existsSync9(join19(d, "package.json"))) dirs.add(d);
|
|
30473
30485
|
return [...dirs].slice(0, MAX_WORKSPACE_PACKAGES).map((dir) => ({ dir, name: packageInfo(dir).name }));
|
|
30474
30486
|
}
|
|
30475
30487
|
function nearestPackageDir(from) {
|
|
30476
30488
|
let d = from;
|
|
30477
30489
|
for (let i = 0; i < 10; i++) {
|
|
30478
|
-
if (
|
|
30490
|
+
if (existsSync9(join19(d, "package.json"))) return d;
|
|
30479
30491
|
const up = resolve18(d, "..");
|
|
30480
30492
|
if (up === d) break;
|
|
30481
30493
|
d = up;
|
|
@@ -30486,7 +30498,7 @@ function findWorkspaceRoot(from) {
|
|
|
30486
30498
|
let d = from;
|
|
30487
30499
|
let best = null;
|
|
30488
30500
|
for (let i = 0; i < 10; i++) {
|
|
30489
|
-
if (
|
|
30501
|
+
if (existsSync9(join19(d, "pnpm-workspace.yaml")) || packageInfo(d).workspaces.length > 0) best = d;
|
|
30490
30502
|
const up = resolve18(d, "..");
|
|
30491
30503
|
if (up === d) break;
|
|
30492
30504
|
d = up;
|
|
@@ -30547,7 +30559,7 @@ function checkReadable(dir, rels, label) {
|
|
|
30547
30559
|
const abs = resolve18(dir, rel);
|
|
30548
30560
|
let isFile = false;
|
|
30549
30561
|
try {
|
|
30550
|
-
isFile =
|
|
30562
|
+
isFile = existsSync9(abs) && statSync11(abs).isFile();
|
|
30551
30563
|
} catch {
|
|
30552
30564
|
isFile = false;
|
|
30553
30565
|
}
|
|
@@ -30567,7 +30579,7 @@ function findLocalBin(dir, bin) {
|
|
|
30567
30579
|
let d = dir;
|
|
30568
30580
|
for (let i = 0; i < 8; i++) {
|
|
30569
30581
|
const link = join19(d, "node_modules", ".bin", bin);
|
|
30570
|
-
if (
|
|
30582
|
+
if (existsSync9(link)) return link;
|
|
30571
30583
|
const up = resolve18(d, "..");
|
|
30572
30584
|
if (up === d) break;
|
|
30573
30585
|
d = up;
|
|
@@ -30598,7 +30610,7 @@ function runExec(e, dirs, ctx) {
|
|
|
30598
30610
|
for (const dir of dirs) {
|
|
30599
30611
|
if (e.localPath !== null) {
|
|
30600
30612
|
const abs = resolve18(dir, e.localPath);
|
|
30601
|
-
if (
|
|
30613
|
+
if (existsSync9(abs)) {
|
|
30602
30614
|
checkReadable(dir, [e.localPath], e.localPath);
|
|
30603
30615
|
const v = evaluateTargets(targetsOfExec(e), fsFor(dir), true);
|
|
30604
30616
|
if (v) blockHit(e.rawProg, e.rawProg, v, dir);
|
|
@@ -30645,7 +30657,7 @@ function runAction(a, e, dir, dirs, ctx) {
|
|
|
30645
30657
|
});
|
|
30646
30658
|
const hit = hits[0];
|
|
30647
30659
|
if (hit) throw new Stop({ block: true, hit, dir: pkgDir });
|
|
30648
|
-
if (a.serverJs &&
|
|
30660
|
+
if (a.serverJs && existsSync9(join19(pkgDir, "server.js"))) {
|
|
30649
30661
|
const v = evaluateTargets({ files: ["server.js"], inline: [], scripts: [], runners: [], dotenv: false, unclear: [] }, fsFor(pkgDir), true);
|
|
30650
30662
|
if (v) blockHit("npm start (server.js)", "node server.js", v, pkgDir);
|
|
30651
30663
|
}
|
|
@@ -31170,7 +31182,7 @@ function decideShellRead(event, defs, opts = {}, fallbackCwd = process.cwd()) {
|
|
|
31170
31182
|
}
|
|
31171
31183
|
|
|
31172
31184
|
// src/commands/approve.ts
|
|
31173
|
-
import { existsSync as
|
|
31185
|
+
import { existsSync as existsSync19, readFileSync as readFileSync27 } from "node:fs";
|
|
31174
31186
|
|
|
31175
31187
|
// ../shield/src/hash.ts
|
|
31176
31188
|
import { createHash as createHash7 } from "node:crypto";
|
|
@@ -31276,7 +31288,7 @@ var LineSplitter = class {
|
|
|
31276
31288
|
|
|
31277
31289
|
// ../shield/src/policy.ts
|
|
31278
31290
|
init_zod();
|
|
31279
|
-
import { existsSync as
|
|
31291
|
+
import { existsSync as existsSync10, lstatSync as lstatSync6, readFileSync as readFileSync15, writeFileSync as writeFileSync3 } from "node:fs";
|
|
31280
31292
|
import { join as join21 } from "node:path";
|
|
31281
31293
|
|
|
31282
31294
|
// ../shield/src/userkey.ts
|
|
@@ -31537,7 +31549,7 @@ function loadPolicy(path) {
|
|
|
31537
31549
|
const user = loadUserPolicy(notes);
|
|
31538
31550
|
if (!user.ok) return user;
|
|
31539
31551
|
let merged = { ...user.raw };
|
|
31540
|
-
if (
|
|
31552
|
+
if (existsSync10(path)) {
|
|
31541
31553
|
let text;
|
|
31542
31554
|
try {
|
|
31543
31555
|
text = readFileSync15(path, "utf8");
|
|
@@ -32528,7 +32540,7 @@ function defaultOsAuth(o = {}) {
|
|
|
32528
32540
|
|
|
32529
32541
|
// ../shield/src/state.ts
|
|
32530
32542
|
init_zod();
|
|
32531
|
-
import { appendFileSync, existsSync as
|
|
32543
|
+
import { appendFileSync, existsSync as existsSync11, mkdirSync as mkdirSync5, readFileSync as readFileSync19, renameSync as renameSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
32532
32544
|
import { dirname as dirname9, join as join26 } from "node:path";
|
|
32533
32545
|
var Sha256 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
32534
32546
|
var PinSchema = external_exports.object({
|
|
@@ -32587,7 +32599,7 @@ function pinsText(raw) {
|
|
|
32587
32599
|
return canonicalJson({ version: raw.version, servers: raw.servers });
|
|
32588
32600
|
}
|
|
32589
32601
|
function loadState(path) {
|
|
32590
|
-
if (!
|
|
32602
|
+
if (!existsSync11(path)) return { ok: true, state: emptyState() };
|
|
32591
32603
|
let json2;
|
|
32592
32604
|
try {
|
|
32593
32605
|
json2 = JSON.parse(readFileSync19(path, "utf8"));
|
|
@@ -33272,7 +33284,7 @@ function throttle(o = {}) {
|
|
|
33272
33284
|
}
|
|
33273
33285
|
|
|
33274
33286
|
// ../shield/src/canary.ts
|
|
33275
|
-
import { existsSync as
|
|
33287
|
+
import { existsSync as existsSync12, lstatSync as lstatSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync20, readdirSync as readdirSync9, realpathSync as realpathSync8, rmdirSync, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
33276
33288
|
import { dirname as dirname10, isAbsolute as isAbsolute17, join as join27, resolve as resolve21 } from "node:path";
|
|
33277
33289
|
var TRAPS = [
|
|
33278
33290
|
{
|
|
@@ -33317,18 +33329,18 @@ function plantCanaries(root, o = {}) {
|
|
|
33317
33329
|
}
|
|
33318
33330
|
for (const d of [".exorcist", CANARY_TRAP_DIR]) {
|
|
33319
33331
|
const path = join27(root, d);
|
|
33320
|
-
if (
|
|
33332
|
+
if (existsSync12(path) || isSymlink(path)) {
|
|
33321
33333
|
if (!isRealDir(path)) return { ok: false, error: `${path} is not a real folder (a symlink or a file); no traps were planted.` };
|
|
33322
33334
|
}
|
|
33323
33335
|
}
|
|
33324
33336
|
const traps = TRAPS.slice(0, count);
|
|
33325
33337
|
for (const t2 of traps) {
|
|
33326
33338
|
const path = join27(root, CANARY_TRAP_DIR, t2.name);
|
|
33327
|
-
if (
|
|
33339
|
+
if (existsSync12(path)) return { ok: false, error: `${path} already exists; it was not overwritten.` };
|
|
33328
33340
|
}
|
|
33329
33341
|
const created = (o.now ? o.now() : /* @__PURE__ */ new Date()).toISOString();
|
|
33330
33342
|
const records = [];
|
|
33331
|
-
const madeDirs = [".exorcist", CANARY_TRAP_DIR].filter((d) => !
|
|
33343
|
+
const madeDirs = [".exorcist", CANARY_TRAP_DIR].filter((d) => !existsSync12(join27(root, d)));
|
|
33332
33344
|
try {
|
|
33333
33345
|
mkdirSync6(join27(root, CANARY_TRAP_DIR), { recursive: true });
|
|
33334
33346
|
for (const t2 of traps) {
|
|
@@ -33455,7 +33467,7 @@ function removeCanaries(root, o = {}) {
|
|
|
33455
33467
|
}
|
|
33456
33468
|
function readPolicyObject(stateDir2) {
|
|
33457
33469
|
const path = policyPath(stateDir2);
|
|
33458
|
-
if (!
|
|
33470
|
+
if (!existsSync12(path)) return { ok: true, obj: {} };
|
|
33459
33471
|
try {
|
|
33460
33472
|
const json2 = JSON.parse(readFileSync20(path, "utf8"));
|
|
33461
33473
|
if (!json2 || typeof json2 !== "object" || Array.isArray(json2)) return { ok: false, error: `${path} is not a JSON object.` };
|
|
@@ -33470,7 +33482,7 @@ function setPolicyCanaries(stateDir2, recordsFile) {
|
|
|
33470
33482
|
try {
|
|
33471
33483
|
mkdirSync6(stateDir2, { recursive: true });
|
|
33472
33484
|
const file = policyPath(stateDir2);
|
|
33473
|
-
const sign = !
|
|
33485
|
+
const sign = !existsSync12(file) || policyIsSigned(file);
|
|
33474
33486
|
writeFileSync6(file, `${JSON.stringify({ ...p.obj, canaries: resolve21(recordsFile) }, null, 2)}
|
|
33475
33487
|
`);
|
|
33476
33488
|
if (sign) signPolicyFile(file);
|
|
@@ -34768,11 +34780,11 @@ var ShieldEngine = class {
|
|
|
34768
34780
|
|
|
34769
34781
|
// ../shield/src/proxy.ts
|
|
34770
34782
|
import { spawn as spawn3 } from "node:child_process";
|
|
34771
|
-
import { existsSync as
|
|
34783
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync26, statSync as statSync15 } from "node:fs";
|
|
34772
34784
|
import { dirname as dirname14 } from "node:path";
|
|
34773
34785
|
|
|
34774
34786
|
// ../shield/src/lockfile.ts
|
|
34775
|
-
import { existsSync as
|
|
34787
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
34776
34788
|
import { dirname as dirname11, join as join28, parse as parsePath, resolve as resolve22 } from "node:path";
|
|
34777
34789
|
init_zod();
|
|
34778
34790
|
var Sha2562 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
@@ -34949,8 +34961,8 @@ function findLockFile(starts) {
|
|
|
34949
34961
|
const { root } = parsePath(resolve22(start));
|
|
34950
34962
|
for (let dir = resolve22(start); ; dir = dirname11(dir)) {
|
|
34951
34963
|
const candidate = join28(dir, LOCK_FILE);
|
|
34952
|
-
if (
|
|
34953
|
-
if (PROJECT_MARKERS2.some((m) =>
|
|
34964
|
+
if (existsSync13(candidate)) return candidate;
|
|
34965
|
+
if (PROJECT_MARKERS2.some((m) => existsSync13(join28(dir, m)))) break;
|
|
34954
34966
|
if (dir === root || dirname11(dir) === dir) break;
|
|
34955
34967
|
}
|
|
34956
34968
|
}
|
|
@@ -34959,7 +34971,7 @@ function findLockFile(starts) {
|
|
|
34959
34971
|
|
|
34960
34972
|
// ../shield/src/vault.ts
|
|
34961
34973
|
import { createHash as createHash11, randomBytes as randomBytes7 } from "node:crypto";
|
|
34962
|
-
import { closeSync as closeSync7, constants as constants6, copyFileSync, existsSync as
|
|
34974
|
+
import { closeSync as closeSync7, constants as constants6, copyFileSync, existsSync as existsSync14, fstatSync as fstatSync3, lstatSync as lstatSync11, mkdirSync as mkdirSync7, openSync as openSync7, readFileSync as readFileSync21, readdirSync as readdirSync10, realpathSync as realpathSync9, rmSync as rmSync4, statSync as statSync13, writeFileSync as writeFileSync7, writeSync as writeSync4 } from "node:fs";
|
|
34963
34975
|
import { basename as basename8, dirname as dirname12, isAbsolute as isAbsolute18, join as join29, resolve as resolve23, sep as sep6 } from "node:path";
|
|
34964
34976
|
init_zod();
|
|
34965
34977
|
var SafeRel = external_exports.string().min(1).max(1024).refine(
|
|
@@ -35045,7 +35057,7 @@ function targetProblem(e) {
|
|
|
35045
35057
|
const dir = e.kind === "exorcise" ? e.target : dirname12(e.target);
|
|
35046
35058
|
let real;
|
|
35047
35059
|
try {
|
|
35048
|
-
real = realpathSync9(
|
|
35060
|
+
real = realpathSync9(existsSync14(dir) ? dir : dirname12(dir));
|
|
35049
35061
|
} catch {
|
|
35050
35062
|
return `${e.target} cannot be resolved.`;
|
|
35051
35063
|
}
|
|
@@ -35077,12 +35089,12 @@ function writeManifest(vaultDir, e) {
|
|
|
35077
35089
|
`);
|
|
35078
35090
|
}
|
|
35079
35091
|
function listEntries(vaultDir) {
|
|
35080
|
-
if (!
|
|
35092
|
+
if (!existsSync14(vaultDir)) return [];
|
|
35081
35093
|
const key = getUserKey();
|
|
35082
35094
|
const out = [];
|
|
35083
35095
|
for (const name of readdirSync10(vaultDir)) {
|
|
35084
35096
|
const file = join29(vaultDir, name, "manifest.json");
|
|
35085
|
-
if (!
|
|
35097
|
+
if (!existsSync14(file)) continue;
|
|
35086
35098
|
try {
|
|
35087
35099
|
const st = lstatSync11(file);
|
|
35088
35100
|
if (!st.isFile()) continue;
|
|
@@ -35157,7 +35169,7 @@ function quarantineServer(o) {
|
|
|
35157
35169
|
}
|
|
35158
35170
|
function quarantineFile(o) {
|
|
35159
35171
|
const target = resolve23(o.filePath);
|
|
35160
|
-
if (!
|
|
35172
|
+
if (!existsSync14(target) || !statSync13(target).isFile()) return fail3(`${target} is not a file.`);
|
|
35161
35173
|
if (activeFor(o.vaultDir, target)) return fail3(`${target} is already in the vault.`);
|
|
35162
35174
|
const safe2 = ensureSafeVault(o.vaultDir);
|
|
35163
35175
|
if (safe2 !== null) return fail3(safe2);
|
|
@@ -35185,7 +35197,7 @@ function backupAndRewrite(o) {
|
|
|
35185
35197
|
for (const f of o.files) {
|
|
35186
35198
|
if (!SafeRel.safeParse(f.rel).success) return fail3(`Refusing to write outside ${root}: ${f.rel}`);
|
|
35187
35199
|
const path = join29(root, f.rel);
|
|
35188
|
-
if (!
|
|
35200
|
+
if (!existsSync14(path)) return fail3(`${f.rel} is gone; nothing was changed.`);
|
|
35189
35201
|
if (sha2562(readFileSync21(path)) !== sha2562(Buffer.from(f.before, "utf8"))) {
|
|
35190
35202
|
return fail3(`${f.rel} changed since it was scanned; nothing was changed. Run exorcise again.`);
|
|
35191
35203
|
}
|
|
@@ -35229,7 +35241,7 @@ function restoreExorcised(vaultDir, e, force) {
|
|
|
35229
35241
|
const files = e.files ?? [];
|
|
35230
35242
|
const blocked2 = files.filter((f) => {
|
|
35231
35243
|
const path = join29(e.target, f.rel);
|
|
35232
|
-
if (!
|
|
35244
|
+
if (!existsSync14(path)) return false;
|
|
35233
35245
|
const now = sha2562(readFileSync21(path));
|
|
35234
35246
|
return now !== f.after && now !== f.sha256;
|
|
35235
35247
|
});
|
|
@@ -35257,7 +35269,7 @@ function diffEntry(vaultDir, id) {
|
|
|
35257
35269
|
const parts2 = (e.files ?? []).map((f) => {
|
|
35258
35270
|
const path = join29(e.target, f.rel);
|
|
35259
35271
|
const before2 = readFileSync21(join29(entryDir(vaultDir, e.id), "files", f.rel), "utf8");
|
|
35260
|
-
const after2 =
|
|
35272
|
+
const after2 = existsSync14(path) ? readFileSync21(path, "utf8") : "";
|
|
35261
35273
|
return createTwoFilesPatch(`${f.rel} (backup)`, `${f.rel} (now)`, before2, after2, "", "", { context: 3 });
|
|
35262
35274
|
});
|
|
35263
35275
|
return { ok: true, value: parts2.join("") };
|
|
@@ -35269,7 +35281,7 @@ function diffEntry(vaultDir, id) {
|
|
|
35269
35281
|
const now = cfg.ok ? cfg.value.mcpServers?.[e.serverName ?? ""] : void 0;
|
|
35270
35282
|
after = now ? `${JSON.stringify(now, null, 2)}
|
|
35271
35283
|
` : "";
|
|
35272
|
-
} else if (
|
|
35284
|
+
} else if (existsSync14(e.target)) {
|
|
35273
35285
|
after = readFileSync21(e.target, "utf8");
|
|
35274
35286
|
}
|
|
35275
35287
|
const label = e.kind === "mcp-server" ? `${e.serverName} in ${basename8(e.target)}` : basename8(e.target);
|
|
@@ -35306,7 +35318,7 @@ function restoreEntry(vaultDir, id, opts = {}) {
|
|
|
35306
35318
|
writeConfig(e.target, cfg.value);
|
|
35307
35319
|
} else {
|
|
35308
35320
|
const stored = backupFile(vaultDir, e);
|
|
35309
|
-
if (
|
|
35321
|
+
if (existsSync14(e.target) && sha2562(readFileSync21(e.target)) !== e.sha256 && !opts.force) {
|
|
35310
35322
|
return fail3(`${e.target} exists and is different from the quarantined file. Use --force to overwrite it.`);
|
|
35311
35323
|
}
|
|
35312
35324
|
mkdirSync7(resolve23(e.target, ".."), { recursive: true });
|
|
@@ -36228,7 +36240,7 @@ var EventTail = class {
|
|
|
36228
36240
|
|
|
36229
36241
|
// ../shield/src/launch.ts
|
|
36230
36242
|
import { createHash as createHash13 } from "node:crypto";
|
|
36231
|
-
import { existsSync as
|
|
36243
|
+
import { existsSync as existsSync15, readFileSync as readFileSync25, statSync as statSync14 } from "node:fs";
|
|
36232
36244
|
import { dirname as dirname13, isAbsolute as isAbsolute19, join as join32, parse as parsePath2, relative as relative13, resolve as resolve24, sep as sep7 } from "node:path";
|
|
36233
36245
|
var sha2563 = (b) => createHash13("sha256").update(b).digest("hex");
|
|
36234
36246
|
var MAX_HASHED_BYTES = 64 * 1024 * 1024;
|
|
@@ -36306,7 +36318,7 @@ function configLabel(configPath) {
|
|
|
36306
36318
|
const abs = resolve24(configPath);
|
|
36307
36319
|
const { root } = parsePath2(abs);
|
|
36308
36320
|
for (let dir = dirname13(abs); ; dir = dirname13(dir)) {
|
|
36309
|
-
if (PROJECT_MARKERS3.some((m) =>
|
|
36321
|
+
if (PROJECT_MARKERS3.some((m) => existsSync15(join32(dir, m)))) return relative13(dir, abs).split(sep7).join("/");
|
|
36310
36322
|
if (dir === root || dirname13(dir) === dir) return abs;
|
|
36311
36323
|
}
|
|
36312
36324
|
}
|
|
@@ -36487,13 +36499,13 @@ async function prepareShield(o) {
|
|
|
36487
36499
|
log(canariesFile.error);
|
|
36488
36500
|
return FAIL_CLOSED_EXIT;
|
|
36489
36501
|
}
|
|
36490
|
-
if (policy.policy.canaries && !
|
|
36502
|
+
if (policy.policy.canaries && !existsSync16(canariesAt)) log(`The policy names canary records at ${canariesAt}, but there is no such file; no canary traps are active.`);
|
|
36491
36503
|
const canaries = canariesFile.canaries.map((r) => ({ token: r.token, file: r.file }));
|
|
36492
36504
|
if (canaries.length > 0) log(`Watching for ${canaries.length} canary token${canaries.length === 1 ? "" : "s"} (EX-022).`);
|
|
36493
36505
|
let lockExpected;
|
|
36494
36506
|
let lockLaunch;
|
|
36495
36507
|
const lockFile = o.lockPath === void 0 ? findLockFile([...o.configPath ? [dirname14(o.configPath)] : [], process.cwd()]) : o.lockPath;
|
|
36496
|
-
if (lockFile &&
|
|
36508
|
+
if (lockFile && existsSync16(lockFile)) {
|
|
36497
36509
|
let text;
|
|
36498
36510
|
try {
|
|
36499
36511
|
text = readFileSync26(lockFile, "utf8");
|
|
@@ -37067,7 +37079,7 @@ async function runRemoteProxy(o) {
|
|
|
37067
37079
|
}
|
|
37068
37080
|
|
|
37069
37081
|
// ../shield/src/locate.ts
|
|
37070
|
-
import { existsSync as
|
|
37082
|
+
import { existsSync as existsSync17, readdirSync as readdirSync11, statSync as statSync16 } from "node:fs";
|
|
37071
37083
|
import { dirname as dirname15, isAbsolute as isAbsolute20, join as join33, parse as parse2, resolve as resolve25 } from "node:path";
|
|
37072
37084
|
import { fileURLToPath } from "node:url";
|
|
37073
37085
|
function hasDefinitions(dir) {
|
|
@@ -37098,7 +37110,7 @@ function findStateDir(o = {}) {
|
|
|
37098
37110
|
if (fromEnv) return isAbsolute20(fromEnv) ? fromEnv : resolve25(cwd, fromEnv);
|
|
37099
37111
|
const { root } = parse2(cwd);
|
|
37100
37112
|
for (let dir = cwd; ; dir = dirname15(dir)) {
|
|
37101
|
-
if (PROJECT_MARKERS4.some((m) =>
|
|
37113
|
+
if (PROJECT_MARKERS4.some((m) => existsSync17(join33(dir, m)))) return join33(dir, ".exorcist");
|
|
37102
37114
|
if (dir === root || dirname15(dir) === dir) break;
|
|
37103
37115
|
}
|
|
37104
37116
|
return join33(cwd, ".exorcist");
|
|
@@ -37284,7 +37296,7 @@ var DEFAULT_DIR = "the project's .exorcist folder (or EXORCIST_DIR)";
|
|
|
37284
37296
|
// src/commands/on-access.ts
|
|
37285
37297
|
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
37286
37298
|
import { execFile as execFile3 } from "node:child_process";
|
|
37287
|
-
import { existsSync as
|
|
37299
|
+
import { existsSync as existsSync18, statSync as statSync17 } from "node:fs";
|
|
37288
37300
|
import { resolve as resolve26 } from "node:path";
|
|
37289
37301
|
import { createInterface } from "node:readline";
|
|
37290
37302
|
var ALLOW_READ_HELP = `Usage: exorcist allow-read <file>
|
|
@@ -37478,7 +37490,7 @@ ${ALLOW_READ_HELP}`);
|
|
|
37478
37490
|
return 1;
|
|
37479
37491
|
}
|
|
37480
37492
|
const file = resolve26(target);
|
|
37481
|
-
if (!
|
|
37493
|
+
if (!existsSync18(file) || !statSync17(file).isFile()) {
|
|
37482
37494
|
io.err(`Not a readable file: ${shownName(target)}`);
|
|
37483
37495
|
return 1;
|
|
37484
37496
|
}
|
|
@@ -37585,7 +37597,7 @@ ${APPROVE_HELP}`);
|
|
|
37585
37597
|
return 1;
|
|
37586
37598
|
}
|
|
37587
37599
|
const file = policyPath(stateDir(str4(p.values["dir"])));
|
|
37588
|
-
if (!
|
|
37600
|
+
if (!existsSync19(file)) {
|
|
37589
37601
|
io.err(`There is no policy file at ${file}.`);
|
|
37590
37602
|
return 1;
|
|
37591
37603
|
}
|
|
@@ -37646,7 +37658,7 @@ async function alertsCommand(argv, io) {
|
|
|
37646
37658
|
if (!h.ok) io.out(`Event log head: unreadable (${h.error.replace(/[^\x20-\x7e]/g, "?")}).`);
|
|
37647
37659
|
else io.out(h.value === null ? "Event log head: none yet (nothing has been logged in this folder)." : `Event log head: ${h.value.hash} (event ${h.value.seq})`);
|
|
37648
37660
|
};
|
|
37649
|
-
if (!
|
|
37661
|
+
if (!existsSync19(file)) {
|
|
37650
37662
|
io.out("No alerts.");
|
|
37651
37663
|
printHead();
|
|
37652
37664
|
return 0;
|
|
@@ -37669,12 +37681,12 @@ import { statSync as statSync20, writeFileSync as writeFileSync9 } from "node:fs
|
|
|
37669
37681
|
import { join as join36, resolve as resolve29 } from "node:path";
|
|
37670
37682
|
|
|
37671
37683
|
// src/commands/scan.ts
|
|
37672
|
-
import { existsSync as
|
|
37684
|
+
import { existsSync as existsSync21, readFileSync as readFileSync29, realpathSync as realpathSync10, statSync as statSync19, writeFileSync as writeFileSync8 } from "node:fs";
|
|
37673
37685
|
import { basename as basename10, dirname as dirname16, isAbsolute as isAbsolute21, join as join35, relative as relative14, resolve as resolve28 } from "node:path";
|
|
37674
37686
|
init_bedrock();
|
|
37675
37687
|
|
|
37676
37688
|
// src/commands/detonate.ts
|
|
37677
|
-
import { existsSync as
|
|
37689
|
+
import { existsSync as existsSync20, readFileSync as readFileSync28, statSync as statSync18 } from "node:fs";
|
|
37678
37690
|
import { basename as basename9, join as join34, resolve as resolve27 } from "node:path";
|
|
37679
37691
|
init_bedrock();
|
|
37680
37692
|
var DEFAULT_DETONATE_MAX = 10;
|
|
@@ -37818,7 +37830,7 @@ ${DETONATE_HELP}`);
|
|
|
37818
37830
|
return 2;
|
|
37819
37831
|
}
|
|
37820
37832
|
const abs = resolve27(target);
|
|
37821
|
-
if (!
|
|
37833
|
+
if (!existsSync20(abs) || !statSync18(abs).isFile()) {
|
|
37822
37834
|
io.err(`File not found: ${target}`);
|
|
37823
37835
|
return 2;
|
|
37824
37836
|
}
|
|
@@ -37902,7 +37914,7 @@ function readIgnoreFile(root) {
|
|
|
37902
37914
|
return readIgnoreEntries(join35(root, ".exorcistignore"));
|
|
37903
37915
|
}
|
|
37904
37916
|
function readIgnoreEntries(file) {
|
|
37905
|
-
if (!
|
|
37917
|
+
if (!existsSync21(file)) return [];
|
|
37906
37918
|
return readFileSync29(file, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
37907
37919
|
}
|
|
37908
37920
|
function isIgnored(rel, prefixes) {
|
|
@@ -38008,7 +38020,7 @@ async function makeAiClient(rawMax, io, real) {
|
|
|
38008
38020
|
}
|
|
38009
38021
|
async function runScan(opts, io) {
|
|
38010
38022
|
const abs = resolve28(opts.target);
|
|
38011
|
-
if (!
|
|
38023
|
+
if (!existsSync21(abs)) {
|
|
38012
38024
|
io.err(`Path not found: ${opts.target}`);
|
|
38013
38025
|
return { ok: false, code: 2 };
|
|
38014
38026
|
}
|
|
@@ -38165,7 +38177,7 @@ ${SCAN_HELP}`);
|
|
|
38165
38177
|
const ignoreFilePath = str4(p.values["ignore-file"]);
|
|
38166
38178
|
let userIgnore = [];
|
|
38167
38179
|
if (ignoreFilePath !== void 0) {
|
|
38168
|
-
if (!
|
|
38180
|
+
if (!existsSync21(resolve28(ignoreFilePath))) {
|
|
38169
38181
|
io.err(`Could not read the ignore file ${ignoreFilePath}. Check the path.`);
|
|
38170
38182
|
return 2;
|
|
38171
38183
|
}
|
|
@@ -38416,7 +38428,7 @@ function remove(io, dir, state) {
|
|
|
38416
38428
|
|
|
38417
38429
|
// src/commands/config.ts
|
|
38418
38430
|
import { createHash as createHash14 } from "node:crypto";
|
|
38419
|
-
import { existsSync as
|
|
38431
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync10, readFileSync as readFileSync30, rmSync as rmSync5, writeFileSync as writeFileSync10 } from "node:fs";
|
|
38420
38432
|
import { join as join37, resolve as resolve31 } from "node:path";
|
|
38421
38433
|
var WRAP_HELP = `Usage: exorcist wrap <mcp.json> [options]
|
|
38422
38434
|
exorcist unwrap <mcp.json>
|
|
@@ -38428,7 +38440,7 @@ unwrap Put the original file back byte for byte, if it was not edited since
|
|
|
38428
38440
|
|
|
38429
38441
|
Options (wrap):
|
|
38430
38442
|
--bin <command> Command that runs the shield (default: exorcist)
|
|
38431
|
-
--bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.
|
|
38443
|
+
--bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.5
|
|
38432
38444
|
--dir <folder> State folder (default: ${DEFAULT_DIR})
|
|
38433
38445
|
--dry-run Show the result without writing the file
|
|
38434
38446
|
`;
|
|
@@ -38455,7 +38467,7 @@ function dirsInConfig(cfg) {
|
|
|
38455
38467
|
return out;
|
|
38456
38468
|
}
|
|
38457
38469
|
function readConfig2(path, io) {
|
|
38458
|
-
if (!
|
|
38470
|
+
if (!existsSync22(path)) {
|
|
38459
38471
|
io.err(`File not found: ${path}`);
|
|
38460
38472
|
return null;
|
|
38461
38473
|
}
|
|
@@ -39748,7 +39760,7 @@ ${CONSOLE_HELP}`);
|
|
|
39748
39760
|
}
|
|
39749
39761
|
|
|
39750
39762
|
// src/commands/exorcise.ts
|
|
39751
|
-
import { existsSync as
|
|
39763
|
+
import { existsSync as existsSync23, readFileSync as readFileSync31, statSync as statSync21 } from "node:fs";
|
|
39752
39764
|
import { basename as basename11, dirname as dirname17, isAbsolute as isAbsolute22, relative as relative15, resolve as resolve32 } from "node:path";
|
|
39753
39765
|
var EXORCISE_HELP = `Usage: exorcist exorcise [path] [options]
|
|
39754
39766
|
|
|
@@ -39834,7 +39846,7 @@ ${EXORCISE_HELP}`);
|
|
|
39834
39846
|
}
|
|
39835
39847
|
const target = p.positionals[0] ?? ".";
|
|
39836
39848
|
const abs = resolve32(target);
|
|
39837
|
-
if (!
|
|
39849
|
+
if (!existsSync23(abs)) {
|
|
39838
39850
|
io.err(`Path not found: ${target}`);
|
|
39839
39851
|
return 2;
|
|
39840
39852
|
}
|
|
@@ -39926,7 +39938,7 @@ ${EXORCISE_HELP}`);
|
|
|
39926
39938
|
}
|
|
39927
39939
|
|
|
39928
39940
|
// src/commands/gate.ts
|
|
39929
|
-
import { existsSync as
|
|
39941
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
39930
39942
|
import { lstat as lstat2, readFile as readFile6 } from "node:fs/promises";
|
|
39931
39943
|
import { resolve as resolve33 } from "node:path";
|
|
39932
39944
|
var GATE_HELP = `Usage: exorcist gate [dir] [--fail-on <critical|high|medium|low>] [--dir <state folder>]
|
|
@@ -40013,7 +40025,7 @@ ${GATE_HELP}`);
|
|
|
40013
40025
|
return 2;
|
|
40014
40026
|
}
|
|
40015
40027
|
const start = resolve33(p.positionals[0] ?? ".");
|
|
40016
|
-
if (!
|
|
40028
|
+
if (!existsSync24(start)) return nothingChecked(io, "that folder does not exist");
|
|
40017
40029
|
const top = await gitRepoRoot(start);
|
|
40018
40030
|
if (!top) return nothingChecked(io, "this folder is not a git repository, or git is not available");
|
|
40019
40031
|
const repo = { root: top };
|
|
@@ -40356,7 +40368,7 @@ async function guardShellReadCommand(stdin, io) {
|
|
|
40356
40368
|
}
|
|
40357
40369
|
|
|
40358
40370
|
// src/commands/hook-scan.ts
|
|
40359
|
-
import { existsSync as
|
|
40371
|
+
import { existsSync as existsSync25, statSync as statSync22 } from "node:fs";
|
|
40360
40372
|
import { resolve as resolve34 } from "node:path";
|
|
40361
40373
|
async function hookScanCommand(stdin, io) {
|
|
40362
40374
|
let event;
|
|
@@ -40368,12 +40380,12 @@ async function hookScanCommand(stdin, io) {
|
|
|
40368
40380
|
if (typeof event.file_path !== "string" || event.file_path === "") return 0;
|
|
40369
40381
|
const base = typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd();
|
|
40370
40382
|
const file = resolve34(base, event.file_path);
|
|
40371
|
-
if (!
|
|
40383
|
+
if (!existsSync25(file) || !statSync22(file).isFile()) return 0;
|
|
40372
40384
|
return await scanCommand([file, "--fail-on", "high"], { out: io.err, err: io.err });
|
|
40373
40385
|
}
|
|
40374
40386
|
|
|
40375
40387
|
// src/commands/init.ts
|
|
40376
|
-
import { chmodSync, existsSync as
|
|
40388
|
+
import { chmodSync, existsSync as existsSync26, lstatSync as lstatSync15, mkdirSync as mkdirSync11, readFileSync as readFileSync33, writeFileSync as writeFileSync12 } from "node:fs";
|
|
40377
40389
|
import { dirname as dirname18, join as join39, resolve as resolve35 } from "node:path";
|
|
40378
40390
|
|
|
40379
40391
|
// src/kiro-hook-script.ts
|
|
@@ -40502,8 +40514,8 @@ function reviewerAgentForProject(mcpCommand) {
|
|
|
40502
40514
|
}
|
|
40503
40515
|
|
|
40504
40516
|
// src/commands/init.ts
|
|
40505
|
-
var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.
|
|
40506
|
-
var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.
|
|
40517
|
+
var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.5";
|
|
40518
|
+
var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.5";
|
|
40507
40519
|
var MISSING_FROM_DEFAULT_BIN = /* @__PURE__ */ new Set();
|
|
40508
40520
|
var INIT_HELP = `Usage: exorcist init [folder] [--kiro] [--shield] [--sandbox] [--no-agent] [--force]
|
|
40509
40521
|
[--bin <command>] [--mcp-bin <command>]
|
|
@@ -40616,7 +40628,7 @@ function splitCommand(s) {
|
|
|
40616
40628
|
}
|
|
40617
40629
|
var MAX_NAME = 60;
|
|
40618
40630
|
function describeMcpConfig(path) {
|
|
40619
|
-
if (!
|
|
40631
|
+
if (!existsSync26(path)) return { exists: false, warnings: [], line: "no .kiro/settings/mcp.json yet (the mcp-scan hook scans it once you add one)" };
|
|
40620
40632
|
try {
|
|
40621
40633
|
const cfg = JSON.parse(readFileSync33(path, "utf8"));
|
|
40622
40634
|
const entries = Object.entries(cfg.mcpServers ?? {});
|
|
@@ -40801,7 +40813,7 @@ ${INIT_HELP}`);
|
|
|
40801
40813
|
const done = [];
|
|
40802
40814
|
for (const f of files) {
|
|
40803
40815
|
const path = join39(root, f.rel);
|
|
40804
|
-
if (
|
|
40816
|
+
if (existsSync26(path) && !force) {
|
|
40805
40817
|
io.err(`Kept existing ${f.rel} (use --force to replace it).`);
|
|
40806
40818
|
done.push({ f, wrote: false });
|
|
40807
40819
|
continue;
|
|
@@ -40872,7 +40884,7 @@ ${INIT_HELP}`);
|
|
|
40872
40884
|
"then reconnect MCP servers in the MCP panel so they start through the Shield."
|
|
40873
40885
|
];
|
|
40874
40886
|
if (isDefaultBin) {
|
|
40875
|
-
lines.push("Commands run through npx (@exorcist-98/cli@0.3.
|
|
40887
|
+
lines.push("Commands run through npx (@exorcist-98/cli@0.3.5). If Kiro cannot start a wrapped server or a hook cannot find npx,");
|
|
40876
40888
|
lines.push('rerun with --bin "<absolute path to node> <absolute path to the exorcist CLI>" and --force.');
|
|
40877
40889
|
}
|
|
40878
40890
|
io.out(lines.join("\n"));
|
|
@@ -40881,7 +40893,7 @@ ${INIT_HELP}`);
|
|
|
40881
40893
|
}
|
|
40882
40894
|
|
|
40883
40895
|
// src/commands/lock.ts
|
|
40884
|
-
import { existsSync as
|
|
40896
|
+
import { existsSync as existsSync27, readFileSync as readFileSync34, writeFileSync as writeFileSync13 } from "node:fs";
|
|
40885
40897
|
import { isAbsolute as isAbsolute27, join as join40, resolve as resolve36 } from "node:path";
|
|
40886
40898
|
|
|
40887
40899
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
|
|
@@ -48255,7 +48267,7 @@ var RawToolsPage = external_exports.object({ tools: external_exports.array(exter
|
|
|
48255
48267
|
var firstLine2 = (err) => (err instanceof Error ? err.message : String(err)).split("\n")[0]?.slice(0, 300) ?? "unknown error";
|
|
48256
48268
|
async function listTools(o) {
|
|
48257
48269
|
const transport = new StdioClientTransport({ command: o.command, args: o.args, env: o.env, cwd: o.cwd, stderr: "ignore" });
|
|
48258
|
-
const client = new Client({ name: "exorcist-lock", version: "0.3.
|
|
48270
|
+
const client = new Client({ name: "exorcist-lock", version: "0.3.5" }, { capabilities: {} });
|
|
48259
48271
|
let timer;
|
|
48260
48272
|
const timedOut = new Promise((res) => {
|
|
48261
48273
|
timer = setTimeout(() => res({ ok: false, error: `it did not list its tools within ${o.timeoutMs} ms.` }), o.timeoutMs);
|
|
@@ -48420,7 +48432,7 @@ ${LOCK_HELP}`);
|
|
|
48420
48432
|
return 2;
|
|
48421
48433
|
}
|
|
48422
48434
|
let previous;
|
|
48423
|
-
if (
|
|
48435
|
+
if (existsSync27(lockPath2)) {
|
|
48424
48436
|
let text2;
|
|
48425
48437
|
try {
|
|
48426
48438
|
text2 = readFileSync34(lockPath2, "utf8");
|
|
@@ -48449,7 +48461,7 @@ ${LOCK_HELP}`);
|
|
|
48449
48461
|
current = pinsToLock(st.state);
|
|
48450
48462
|
} else {
|
|
48451
48463
|
const configPath = resolve36(str4(p.values["config"]) ?? DEFAULT_CONFIG);
|
|
48452
|
-
if (!
|
|
48464
|
+
if (!existsSync27(configPath)) {
|
|
48453
48465
|
io.err(`MCP config not found: ${configPath}. Pass --config <file>, or --from-shield.`);
|
|
48454
48466
|
return 2;
|
|
48455
48467
|
}
|
|
@@ -48497,7 +48509,7 @@ ${LOCK_HELP}`);
|
|
|
48497
48509
|
}
|
|
48498
48510
|
|
|
48499
48511
|
// src/commands/map.ts
|
|
48500
|
-
import { existsSync as
|
|
48512
|
+
import { existsSync as existsSync28, statSync as statSync23 } from "node:fs";
|
|
48501
48513
|
import { resolve as resolve37 } from "node:path";
|
|
48502
48514
|
var MAP_HELP = `Usage: exorcist map [dir] [options]
|
|
48503
48515
|
|
|
@@ -48594,7 +48606,7 @@ ${MAP_HELP}`);
|
|
|
48594
48606
|
}
|
|
48595
48607
|
const target = p.positionals[0] ?? ".";
|
|
48596
48608
|
const root = resolve37(target);
|
|
48597
|
-
if (!
|
|
48609
|
+
if (!existsSync28(root) || !statSync23(root).isDirectory()) {
|
|
48598
48610
|
io.err(`Folder not found: ${target}`);
|
|
48599
48611
|
return 2;
|
|
48600
48612
|
}
|
|
@@ -48616,7 +48628,7 @@ ${MAP_HELP}`);
|
|
|
48616
48628
|
}
|
|
48617
48629
|
|
|
48618
48630
|
// src/commands/origin.ts
|
|
48619
|
-
import { existsSync as
|
|
48631
|
+
import { existsSync as existsSync29, realpathSync as realpathSync11, statSync as statSync24 } from "node:fs";
|
|
48620
48632
|
import { posix as posix3, relative as relative16, resolve as resolve38, sep as sep8 } from "node:path";
|
|
48621
48633
|
var ORIGIN_HELP = `Usage: exorcist origin [dir] [options]
|
|
48622
48634
|
|
|
@@ -48740,7 +48752,7 @@ ${ORIGIN_HELP}`);
|
|
|
48740
48752
|
return 2;
|
|
48741
48753
|
}
|
|
48742
48754
|
const target = resolve38(p.positionals[0] ?? ".");
|
|
48743
|
-
if (!
|
|
48755
|
+
if (!existsSync29(target) || !statSync24(target).isDirectory()) {
|
|
48744
48756
|
io.err(`Not a directory: ${target}`);
|
|
48745
48757
|
return 2;
|
|
48746
48758
|
}
|
|
@@ -49153,7 +49165,7 @@ ${VAULT_HELP}`);
|
|
|
49153
49165
|
}
|
|
49154
49166
|
|
|
49155
49167
|
// src/index.ts
|
|
49156
|
-
var VERSION = "0.3.
|
|
49168
|
+
var VERSION = "0.3.5";
|
|
49157
49169
|
var HELP = `Exorcist 98 ${VERSION}: antivirus for AI coding agents
|
|
49158
49170
|
|
|
49159
49171
|
Usage: exorcist <command> [options]
|