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