@yawlabs/ctxlint 0.25.2 → 0.25.3
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/.pre-commit-hooks.yaml +1 -1
- package/CONTEXT_LINT_SPEC.md +50 -12
- package/README.md +2 -2
- package/context-lint-rules.json +20 -0
- package/dist/index.js +1561 -423
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1330,8 +1330,8 @@ var require_semaphore = __commonJS({
|
|
|
1330
1330
|
this._waiting = [];
|
|
1331
1331
|
}
|
|
1332
1332
|
lock(thunk) {
|
|
1333
|
-
return new Promise((
|
|
1334
|
-
this._waiting.push({ thunk, resolve:
|
|
1333
|
+
return new Promise((resolve22, reject) => {
|
|
1334
|
+
this._waiting.push({ thunk, resolve: resolve22, reject });
|
|
1335
1335
|
this.runNext();
|
|
1336
1336
|
});
|
|
1337
1337
|
}
|
|
@@ -2960,9 +2960,9 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2960
2960
|
if (typeof cancellationStrategy.sender.enableCancellation === "function") {
|
|
2961
2961
|
cancellationStrategy.sender.enableCancellation(requestMessage);
|
|
2962
2962
|
}
|
|
2963
|
-
return new Promise(async (
|
|
2963
|
+
return new Promise(async (resolve22, reject) => {
|
|
2964
2964
|
const resolveWithCleanup = (r2) => {
|
|
2965
|
-
|
|
2965
|
+
resolve22(r2);
|
|
2966
2966
|
cancellationStrategy.sender.cleanup(id);
|
|
2967
2967
|
disposable?.dispose();
|
|
2968
2968
|
};
|
|
@@ -8645,8 +8645,8 @@ var require_server = __commonJS({
|
|
|
8645
8645
|
if (value instanceof Promise) {
|
|
8646
8646
|
return value;
|
|
8647
8647
|
} else if (Is3.thenable(value)) {
|
|
8648
|
-
return new Promise((
|
|
8649
|
-
value.then((resolved) =>
|
|
8648
|
+
return new Promise((resolve22, reject) => {
|
|
8649
|
+
value.then((resolved) => resolve22(resolved), (error52) => reject(error52));
|
|
8650
8650
|
});
|
|
8651
8651
|
} else {
|
|
8652
8652
|
return Promise.resolve(value);
|
|
@@ -8928,13 +8928,13 @@ var require_files = __commonJS({
|
|
|
8928
8928
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8929
8929
|
exports.FileSystem = void 0;
|
|
8930
8930
|
exports.uriToFilePath = uriToFilePath;
|
|
8931
|
-
exports.resolve =
|
|
8931
|
+
exports.resolve = resolve22;
|
|
8932
8932
|
exports.resolveGlobalNodePath = resolveGlobalNodePath;
|
|
8933
8933
|
exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
|
|
8934
8934
|
exports.resolveModulePath = resolveModulePath;
|
|
8935
8935
|
var url2 = __importStar(__require("url"));
|
|
8936
|
-
var
|
|
8937
|
-
var
|
|
8936
|
+
var path23 = __importStar(__require("path"));
|
|
8937
|
+
var fs18 = __importStar(__require("fs"));
|
|
8938
8938
|
var child_process_1 = __require("child_process");
|
|
8939
8939
|
function uriToFilePath(uri) {
|
|
8940
8940
|
const parsed = url2.parse(uri);
|
|
@@ -8952,12 +8952,12 @@ var require_files = __commonJS({
|
|
|
8952
8952
|
segments.shift();
|
|
8953
8953
|
}
|
|
8954
8954
|
}
|
|
8955
|
-
return
|
|
8955
|
+
return path23.normalize(segments.join("/"));
|
|
8956
8956
|
}
|
|
8957
8957
|
function isWindows() {
|
|
8958
8958
|
return process.platform === "win32";
|
|
8959
8959
|
}
|
|
8960
|
-
function
|
|
8960
|
+
function resolve22(moduleName, nodePath, cwd, tracer) {
|
|
8961
8961
|
const nodePathKey = "NODE_PATH";
|
|
8962
8962
|
const app = [
|
|
8963
8963
|
"var p = process;",
|
|
@@ -8976,13 +8976,13 @@ var require_files = __commonJS({
|
|
|
8976
8976
|
"}",
|
|
8977
8977
|
"});"
|
|
8978
8978
|
].join("");
|
|
8979
|
-
return new Promise((
|
|
8979
|
+
return new Promise((resolve23, reject) => {
|
|
8980
8980
|
const env2 = process.env;
|
|
8981
8981
|
const newEnv = /* @__PURE__ */ Object.create(null);
|
|
8982
8982
|
Object.keys(env2).forEach((key) => newEnv[key] = env2[key]);
|
|
8983
|
-
if (nodePath &&
|
|
8983
|
+
if (nodePath && fs18.existsSync(nodePath)) {
|
|
8984
8984
|
if (newEnv[nodePathKey]) {
|
|
8985
|
-
newEnv[nodePathKey] = nodePath +
|
|
8985
|
+
newEnv[nodePathKey] = nodePath + path23.delimiter + newEnv[nodePathKey];
|
|
8986
8986
|
} else {
|
|
8987
8987
|
newEnv[nodePathKey] = nodePath;
|
|
8988
8988
|
}
|
|
@@ -9008,7 +9008,7 @@ var require_files = __commonJS({
|
|
|
9008
9008
|
if (message2.c === "r") {
|
|
9009
9009
|
cp.send({ c: "e" });
|
|
9010
9010
|
if (message2.s) {
|
|
9011
|
-
|
|
9011
|
+
resolve23(message2.r);
|
|
9012
9012
|
} else {
|
|
9013
9013
|
reject(new Error(`Failed to resolve module: ${moduleName}`));
|
|
9014
9014
|
}
|
|
@@ -9054,9 +9054,9 @@ var require_files = __commonJS({
|
|
|
9054
9054
|
}
|
|
9055
9055
|
if (prefix.length > 0) {
|
|
9056
9056
|
if (isWindows()) {
|
|
9057
|
-
return
|
|
9057
|
+
return path23.join(prefix, "node_modules");
|
|
9058
9058
|
} else {
|
|
9059
|
-
return
|
|
9059
|
+
return path23.join(prefix, "lib", "node_modules");
|
|
9060
9060
|
}
|
|
9061
9061
|
}
|
|
9062
9062
|
return void 0;
|
|
@@ -9095,7 +9095,7 @@ var require_files = __commonJS({
|
|
|
9095
9095
|
try {
|
|
9096
9096
|
const yarn = JSON.parse(line);
|
|
9097
9097
|
if (yarn.type === "log") {
|
|
9098
|
-
return
|
|
9098
|
+
return path23.join(yarn.data, "node_modules");
|
|
9099
9099
|
}
|
|
9100
9100
|
} catch (e) {
|
|
9101
9101
|
}
|
|
@@ -9117,36 +9117,36 @@ var require_files = __commonJS({
|
|
|
9117
9117
|
if (process.platform === "win32") {
|
|
9118
9118
|
_isCaseSensitive = false;
|
|
9119
9119
|
} else {
|
|
9120
|
-
_isCaseSensitive = !
|
|
9120
|
+
_isCaseSensitive = !fs18.existsSync(__filename.toUpperCase()) || !fs18.existsSync(__filename.toLowerCase());
|
|
9121
9121
|
}
|
|
9122
9122
|
return _isCaseSensitive;
|
|
9123
9123
|
}
|
|
9124
9124
|
FileSystem2.isCaseSensitive = isCaseSensitive;
|
|
9125
9125
|
function isParent(parent, child) {
|
|
9126
9126
|
if (isCaseSensitive()) {
|
|
9127
|
-
return
|
|
9127
|
+
return path23.normalize(child).indexOf(path23.normalize(parent)) === 0;
|
|
9128
9128
|
} else {
|
|
9129
|
-
return
|
|
9129
|
+
return path23.normalize(child).toLowerCase().indexOf(path23.normalize(parent).toLowerCase()) === 0;
|
|
9130
9130
|
}
|
|
9131
9131
|
}
|
|
9132
9132
|
FileSystem2.isParent = isParent;
|
|
9133
9133
|
})(FileSystem || (exports.FileSystem = FileSystem = {}));
|
|
9134
9134
|
function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
|
|
9135
9135
|
if (nodePath) {
|
|
9136
|
-
if (!
|
|
9137
|
-
nodePath =
|
|
9136
|
+
if (!path23.isAbsolute(nodePath)) {
|
|
9137
|
+
nodePath = path23.join(workspaceRoot, nodePath);
|
|
9138
9138
|
}
|
|
9139
|
-
return
|
|
9139
|
+
return resolve22(moduleName, nodePath, nodePath, tracer).then((value) => {
|
|
9140
9140
|
if (FileSystem.isParent(nodePath, value)) {
|
|
9141
9141
|
return value;
|
|
9142
9142
|
} else {
|
|
9143
9143
|
return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
|
|
9144
9144
|
}
|
|
9145
9145
|
}).then(void 0, (_error) => {
|
|
9146
|
-
return
|
|
9146
|
+
return resolve22(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
|
9147
9147
|
});
|
|
9148
9148
|
} else {
|
|
9149
|
-
return
|
|
9149
|
+
return resolve22(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
|
9150
9150
|
}
|
|
9151
9151
|
}
|
|
9152
9152
|
}
|
|
@@ -9229,10 +9229,10 @@ var require_ril = __commonJS({
|
|
|
9229
9229
|
return api_1.Disposable.create(() => this.stream.off("end", listener));
|
|
9230
9230
|
}
|
|
9231
9231
|
write(data, encoding) {
|
|
9232
|
-
return new Promise((
|
|
9232
|
+
return new Promise((resolve22, reject) => {
|
|
9233
9233
|
const callback = (error52) => {
|
|
9234
9234
|
if (error52 === void 0 || error52 === null) {
|
|
9235
|
-
|
|
9235
|
+
resolve22();
|
|
9236
9236
|
} else {
|
|
9237
9237
|
reject(error52);
|
|
9238
9238
|
}
|
|
@@ -9369,9 +9369,9 @@ var require_main = __commonJS({
|
|
|
9369
9369
|
exports.createMessageConnection = createMessageConnection;
|
|
9370
9370
|
var ril_1 = __importDefault(require_ril());
|
|
9371
9371
|
ril_1.default.install();
|
|
9372
|
-
var
|
|
9372
|
+
var path23 = __importStar(__require("path"));
|
|
9373
9373
|
var os7 = __importStar(__require("os"));
|
|
9374
|
-
var
|
|
9374
|
+
var fs18 = __importStar(__require("fs"));
|
|
9375
9375
|
var crypto_1 = __require("crypto");
|
|
9376
9376
|
var net_1 = __require("net");
|
|
9377
9377
|
var api_1 = require_api();
|
|
@@ -9512,7 +9512,7 @@ var require_main = __commonJS({
|
|
|
9512
9512
|
}
|
|
9513
9513
|
let randomLength = 32;
|
|
9514
9514
|
const fixedLength = "/lsp-.sock".length;
|
|
9515
|
-
const tmpDir =
|
|
9515
|
+
const tmpDir = fs18.realpathSync(XDG_RUNTIME_DIR ?? os7.tmpdir());
|
|
9516
9516
|
const limit = safeIpcPathLengths.get(process.platform);
|
|
9517
9517
|
if (limit !== void 0) {
|
|
9518
9518
|
randomLength = Math.min(limit - tmpDir.length - fixedLength, randomLength);
|
|
@@ -9521,14 +9521,14 @@ var require_main = __commonJS({
|
|
|
9521
9521
|
throw new Error(`Unable to generate a random pipe name with ${randomLength} characters.`);
|
|
9522
9522
|
}
|
|
9523
9523
|
const randomSuffix = (0, crypto_1.randomBytes)(Math.floor(randomLength / 2)).toString("hex");
|
|
9524
|
-
return
|
|
9524
|
+
return path23.join(tmpDir, `lsp-${randomSuffix}.sock`);
|
|
9525
9525
|
}
|
|
9526
9526
|
function createClientPipeTransport(pipeName, encoding = "utf-8") {
|
|
9527
9527
|
let connectResolve;
|
|
9528
|
-
const connected = new Promise((
|
|
9529
|
-
connectResolve =
|
|
9528
|
+
const connected = new Promise((resolve22, _reject) => {
|
|
9529
|
+
connectResolve = resolve22;
|
|
9530
9530
|
});
|
|
9531
|
-
return new Promise((
|
|
9531
|
+
return new Promise((resolve22, reject) => {
|
|
9532
9532
|
const server2 = (0, net_1.createServer)((socket) => {
|
|
9533
9533
|
server2.close();
|
|
9534
9534
|
connectResolve([
|
|
@@ -9539,7 +9539,7 @@ var require_main = __commonJS({
|
|
|
9539
9539
|
server2.on("error", reject);
|
|
9540
9540
|
server2.listen(pipeName, () => {
|
|
9541
9541
|
server2.removeListener("error", reject);
|
|
9542
|
-
|
|
9542
|
+
resolve22({
|
|
9543
9543
|
onConnected: () => {
|
|
9544
9544
|
return connected;
|
|
9545
9545
|
}
|
|
@@ -9556,10 +9556,10 @@ var require_main = __commonJS({
|
|
|
9556
9556
|
}
|
|
9557
9557
|
function createClientSocketTransport(port, encoding = "utf-8") {
|
|
9558
9558
|
let connectResolve;
|
|
9559
|
-
const connected = new Promise((
|
|
9560
|
-
connectResolve =
|
|
9559
|
+
const connected = new Promise((resolve22, _reject) => {
|
|
9560
|
+
connectResolve = resolve22;
|
|
9561
9561
|
});
|
|
9562
|
-
return new Promise((
|
|
9562
|
+
return new Promise((resolve22, reject) => {
|
|
9563
9563
|
const server2 = (0, net_1.createServer)((socket) => {
|
|
9564
9564
|
server2.close();
|
|
9565
9565
|
connectResolve([
|
|
@@ -9570,7 +9570,7 @@ var require_main = __commonJS({
|
|
|
9570
9570
|
server2.on("error", reject);
|
|
9571
9571
|
server2.listen(port, "127.0.0.1", () => {
|
|
9572
9572
|
server2.removeListener("error", reject);
|
|
9573
|
-
|
|
9573
|
+
resolve22({
|
|
9574
9574
|
onConnected: () => {
|
|
9575
9575
|
return connected;
|
|
9576
9576
|
}
|
|
@@ -13567,8 +13567,8 @@ var require_utils = __commonJS({
|
|
|
13567
13567
|
}
|
|
13568
13568
|
return output;
|
|
13569
13569
|
};
|
|
13570
|
-
exports.basename = (
|
|
13571
|
-
const segs =
|
|
13570
|
+
exports.basename = (path23, { windows } = {}) => {
|
|
13571
|
+
const segs = path23.split(windows ? /[\\/]/ : "/");
|
|
13572
13572
|
const last2 = segs[segs.length - 1];
|
|
13573
13573
|
if (last2 === "") {
|
|
13574
13574
|
return segs[segs.length - 2];
|
|
@@ -13943,7 +13943,7 @@ var require_parse = __commonJS({
|
|
|
13943
13943
|
const parts = [];
|
|
13944
13944
|
let bracket = 0;
|
|
13945
13945
|
let paren = 0;
|
|
13946
|
-
let
|
|
13946
|
+
let quote2 = 0;
|
|
13947
13947
|
let value = "";
|
|
13948
13948
|
let escaped = false;
|
|
13949
13949
|
for (const ch of input) {
|
|
@@ -13958,11 +13958,11 @@ var require_parse = __commonJS({
|
|
|
13958
13958
|
continue;
|
|
13959
13959
|
}
|
|
13960
13960
|
if (ch === '"') {
|
|
13961
|
-
|
|
13961
|
+
quote2 = quote2 === 1 ? 0 : 1;
|
|
13962
13962
|
value += ch;
|
|
13963
13963
|
continue;
|
|
13964
13964
|
}
|
|
13965
|
-
if (
|
|
13965
|
+
if (quote2 === 0) {
|
|
13966
13966
|
if (ch === "[") {
|
|
13967
13967
|
bracket++;
|
|
13968
13968
|
} else if (ch === "]" && bracket > 0) {
|
|
@@ -14039,7 +14039,7 @@ var require_parse = __commonJS({
|
|
|
14039
14039
|
}
|
|
14040
14040
|
let bracket = 0;
|
|
14041
14041
|
let paren = 0;
|
|
14042
|
-
let
|
|
14042
|
+
let quote2 = 0;
|
|
14043
14043
|
let escaped = false;
|
|
14044
14044
|
for (let i2 = 1; i2 < pattern.length; i2++) {
|
|
14045
14045
|
const ch = pattern[i2];
|
|
@@ -14052,10 +14052,10 @@ var require_parse = __commonJS({
|
|
|
14052
14052
|
continue;
|
|
14053
14053
|
}
|
|
14054
14054
|
if (ch === '"') {
|
|
14055
|
-
|
|
14055
|
+
quote2 = quote2 === 1 ? 0 : 1;
|
|
14056
14056
|
continue;
|
|
14057
14057
|
}
|
|
14058
|
-
if (
|
|
14058
|
+
if (quote2 === 1) {
|
|
14059
14059
|
continue;
|
|
14060
14060
|
}
|
|
14061
14061
|
if (ch === "[") {
|
|
@@ -14432,9 +14432,9 @@ var require_parse = __commonJS({
|
|
|
14432
14432
|
const idx = prev.value.lastIndexOf("[");
|
|
14433
14433
|
const pre = prev.value.slice(0, idx);
|
|
14434
14434
|
const rest2 = prev.value.slice(idx + 2);
|
|
14435
|
-
const
|
|
14436
|
-
if (
|
|
14437
|
-
prev.value = pre +
|
|
14435
|
+
const posix3 = POSIX_REGEX_SOURCE[rest2];
|
|
14436
|
+
if (posix3) {
|
|
14437
|
+
prev.value = pre + posix3;
|
|
14438
14438
|
state.backtrack = true;
|
|
14439
14439
|
advance();
|
|
14440
14440
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
@@ -14951,7 +14951,7 @@ var require_picomatch = __commonJS({
|
|
|
14951
14951
|
throw new TypeError("Expected pattern to be a non-empty string");
|
|
14952
14952
|
}
|
|
14953
14953
|
const opts = options || {};
|
|
14954
|
-
const
|
|
14954
|
+
const posix3 = opts.windows;
|
|
14955
14955
|
const regex2 = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
14956
14956
|
const state = regex2.state;
|
|
14957
14957
|
delete regex2.state;
|
|
@@ -14961,8 +14961,8 @@ var require_picomatch = __commonJS({
|
|
|
14961
14961
|
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
14962
14962
|
}
|
|
14963
14963
|
const matcher = (input, returnObject = false) => {
|
|
14964
|
-
const { isMatch, match, output } = picomatch2.test(input, regex2, options, { glob, posix:
|
|
14965
|
-
const result = { glob, state, regex: regex2, posix:
|
|
14964
|
+
const { isMatch, match, output } = picomatch2.test(input, regex2, options, { glob, posix: posix3 });
|
|
14965
|
+
const result = { glob, state, regex: regex2, posix: posix3, input, output, match, isMatch };
|
|
14966
14966
|
if (typeof opts.onResult === "function") {
|
|
14967
14967
|
opts.onResult(result);
|
|
14968
14968
|
}
|
|
@@ -14987,7 +14987,7 @@ var require_picomatch = __commonJS({
|
|
|
14987
14987
|
}
|
|
14988
14988
|
return matcher;
|
|
14989
14989
|
};
|
|
14990
|
-
picomatch2.test = (input, regex2, options, { glob, posix:
|
|
14990
|
+
picomatch2.test = (input, regex2, options, { glob, posix: posix3 } = {}) => {
|
|
14991
14991
|
if (typeof input !== "string") {
|
|
14992
14992
|
throw new TypeError("Expected input to be a string");
|
|
14993
14993
|
}
|
|
@@ -14995,7 +14995,7 @@ var require_picomatch = __commonJS({
|
|
|
14995
14995
|
return { isMatch: false, output: "" };
|
|
14996
14996
|
}
|
|
14997
14997
|
const opts = options || {};
|
|
14998
|
-
const format3 = opts.format || (
|
|
14998
|
+
const format3 = opts.format || (posix3 ? utils.toPosixSlashes : null);
|
|
14999
14999
|
let match = input === glob;
|
|
15000
15000
|
let output = match && format3 ? format3(input) : input;
|
|
15001
15001
|
if (match === false) {
|
|
@@ -15004,16 +15004,16 @@ var require_picomatch = __commonJS({
|
|
|
15004
15004
|
}
|
|
15005
15005
|
if (match === false || opts.capture === true) {
|
|
15006
15006
|
if (opts.matchBase === true || opts.basename === true) {
|
|
15007
|
-
match = picomatch2.matchBase(input, regex2, options,
|
|
15007
|
+
match = picomatch2.matchBase(input, regex2, options, posix3);
|
|
15008
15008
|
} else {
|
|
15009
15009
|
match = regex2.exec(output);
|
|
15010
15010
|
}
|
|
15011
15011
|
}
|
|
15012
15012
|
return { isMatch: Boolean(match), match, output };
|
|
15013
15013
|
};
|
|
15014
|
-
picomatch2.matchBase = (input, glob, options,
|
|
15014
|
+
picomatch2.matchBase = (input, glob, options, posix3 = options && options.windows) => {
|
|
15015
15015
|
const regex2 = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
|
|
15016
|
-
return regex2.test(utils.basename(input, { windows:
|
|
15016
|
+
return regex2.test(utils.basename(input, { windows: posix3 }));
|
|
15017
15017
|
};
|
|
15018
15018
|
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
15019
15019
|
picomatch2.parse = (pattern, options) => {
|
|
@@ -15723,7 +15723,7 @@ var init_parser = __esm({
|
|
|
15723
15723
|
"node_modules"
|
|
15724
15724
|
]);
|
|
15725
15725
|
COMMAND_PREFIXES = /^\s*[\$>]\s+(.+)$/;
|
|
15726
|
-
COMMON_COMMANDS = /^(npm|npx|pnpm|yarn|make|cargo|go\s+(run|build|test)|python|pytest|vitest|jest|mocha|tsc|eslint|prettier|bun|deno)\b/;
|
|
15726
|
+
COMMON_COMMANDS = /^(?:(?:npm|npx|pnpm|yarn|make|cargo|go\s+(?:run|build|test)|python|pytest|vitest|jest|mocha|tsc|eslint|prettier|bun|deno)\b|(?:\.[\\/])?(?:gradlew(?:\.bat)?|mvnw(?:\.cmd)?)(?=\s|$)|(?:gradle|mvn(?:\.cmd)?)(?=\s|$))/;
|
|
15727
15727
|
}
|
|
15728
15728
|
});
|
|
15729
15729
|
|
|
@@ -16528,10 +16528,10 @@ var require_src2 = __commonJS({
|
|
|
16528
16528
|
var fs_1 = __require("fs");
|
|
16529
16529
|
var debug_1 = __importDefault(require_src());
|
|
16530
16530
|
var log = debug_1.default("@kwsites/file-exists");
|
|
16531
|
-
function check2(
|
|
16532
|
-
log(`checking %s`,
|
|
16531
|
+
function check2(path23, isFile, isDirectory2) {
|
|
16532
|
+
log(`checking %s`, path23);
|
|
16533
16533
|
try {
|
|
16534
|
-
const stat3 = fs_1.statSync(
|
|
16534
|
+
const stat3 = fs_1.statSync(path23);
|
|
16535
16535
|
if (stat3.isFile() && isFile) {
|
|
16536
16536
|
log(`[OK] path represents a file`);
|
|
16537
16537
|
return true;
|
|
@@ -16551,8 +16551,8 @@ var require_src2 = __commonJS({
|
|
|
16551
16551
|
throw e;
|
|
16552
16552
|
}
|
|
16553
16553
|
}
|
|
16554
|
-
function exists2(
|
|
16555
|
-
return check2(
|
|
16554
|
+
function exists2(path23, type = exports.READABLE) {
|
|
16555
|
+
return check2(path23, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
16556
16556
|
}
|
|
16557
16557
|
exports.exists = exists2;
|
|
16558
16558
|
exports.FILE = 1;
|
|
@@ -17150,8 +17150,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
17150
17150
|
function forEachLineWithContent(input, callback) {
|
|
17151
17151
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
17152
17152
|
}
|
|
17153
|
-
function folderExists(
|
|
17154
|
-
return (0, import_file_exists.exists)(
|
|
17153
|
+
function folderExists(path23) {
|
|
17154
|
+
return (0, import_file_exists.exists)(path23, import_file_exists.FOLDER);
|
|
17155
17155
|
}
|
|
17156
17156
|
function append(target, item) {
|
|
17157
17157
|
if (Array.isArray(target)) {
|
|
@@ -17342,8 +17342,8 @@ function checkIsRepoRootTask() {
|
|
|
17342
17342
|
commands,
|
|
17343
17343
|
format: "utf-8",
|
|
17344
17344
|
onError,
|
|
17345
|
-
parser(
|
|
17346
|
-
return /^\.(git)?$/.test(
|
|
17345
|
+
parser(path23) {
|
|
17346
|
+
return /^\.(git)?$/.test(path23.trim());
|
|
17347
17347
|
}
|
|
17348
17348
|
};
|
|
17349
17349
|
}
|
|
@@ -17599,11 +17599,11 @@ function parseGrep(grep) {
|
|
|
17599
17599
|
const paths = /* @__PURE__ */ new Set();
|
|
17600
17600
|
const results = {};
|
|
17601
17601
|
forEachLineWithContent(grep, (input) => {
|
|
17602
|
-
const [
|
|
17603
|
-
paths.add(
|
|
17604
|
-
(results[
|
|
17602
|
+
const [path23, line, preview] = input.split(NULL);
|
|
17603
|
+
paths.add(path23);
|
|
17604
|
+
(results[path23] = results[path23] || []).push({
|
|
17605
17605
|
line: asNumber(line),
|
|
17606
|
-
path:
|
|
17606
|
+
path: path23,
|
|
17607
17607
|
preview
|
|
17608
17608
|
});
|
|
17609
17609
|
});
|
|
@@ -17900,14 +17900,14 @@ function hashObjectTask(filePath, write) {
|
|
|
17900
17900
|
}
|
|
17901
17901
|
return straightThroughStringTask(commands, true);
|
|
17902
17902
|
}
|
|
17903
|
-
function parseInit(bare,
|
|
17903
|
+
function parseInit(bare, path23, text) {
|
|
17904
17904
|
const response = String(text).trim();
|
|
17905
17905
|
let result;
|
|
17906
17906
|
if (result = initResponseRegex.exec(response)) {
|
|
17907
|
-
return new InitSummary(bare,
|
|
17907
|
+
return new InitSummary(bare, path23, false, result[1]);
|
|
17908
17908
|
}
|
|
17909
17909
|
if (result = reInitResponseRegex.exec(response)) {
|
|
17910
|
-
return new InitSummary(bare,
|
|
17910
|
+
return new InitSummary(bare, path23, true, result[1]);
|
|
17911
17911
|
}
|
|
17912
17912
|
let gitDir = "";
|
|
17913
17913
|
const tokens = response.split(" ");
|
|
@@ -17918,12 +17918,12 @@ function parseInit(bare, path21, text) {
|
|
|
17918
17918
|
break;
|
|
17919
17919
|
}
|
|
17920
17920
|
}
|
|
17921
|
-
return new InitSummary(bare,
|
|
17921
|
+
return new InitSummary(bare, path23, /^re/i.test(response), gitDir);
|
|
17922
17922
|
}
|
|
17923
17923
|
function hasBareCommand(command) {
|
|
17924
17924
|
return command.includes(bareCommand);
|
|
17925
17925
|
}
|
|
17926
|
-
function initTask(bare = false,
|
|
17926
|
+
function initTask(bare = false, path23, customArgs) {
|
|
17927
17927
|
const commands = ["init", ...customArgs];
|
|
17928
17928
|
if (bare && !hasBareCommand(commands)) {
|
|
17929
17929
|
commands.splice(1, 0, bareCommand);
|
|
@@ -17932,7 +17932,7 @@ function initTask(bare = false, path21, customArgs) {
|
|
|
17932
17932
|
commands,
|
|
17933
17933
|
format: "utf-8",
|
|
17934
17934
|
parser(text) {
|
|
17935
|
-
return parseInit(commands.includes("--bare"),
|
|
17935
|
+
return parseInit(commands.includes("--bare"), path23, text);
|
|
17936
17936
|
}
|
|
17937
17937
|
};
|
|
17938
17938
|
}
|
|
@@ -18211,14 +18211,14 @@ function splitLine(result, lineStr) {
|
|
|
18211
18211
|
default:
|
|
18212
18212
|
return;
|
|
18213
18213
|
}
|
|
18214
|
-
function data(index, workingDir,
|
|
18214
|
+
function data(index, workingDir, path23) {
|
|
18215
18215
|
const raw = `${index}${workingDir}`;
|
|
18216
18216
|
const handler = parsers6.get(raw);
|
|
18217
18217
|
if (handler) {
|
|
18218
|
-
handler(result,
|
|
18218
|
+
handler(result, path23);
|
|
18219
18219
|
}
|
|
18220
18220
|
if (raw !== "##" && raw !== "!!") {
|
|
18221
|
-
result.files.push(new FileStatusSummary(
|
|
18221
|
+
result.files.push(new FileStatusSummary(path23, index, workingDir));
|
|
18222
18222
|
}
|
|
18223
18223
|
}
|
|
18224
18224
|
}
|
|
@@ -18405,8 +18405,8 @@ function deleteBranchTask(branch, forceDelete = false) {
|
|
|
18405
18405
|
return task;
|
|
18406
18406
|
}
|
|
18407
18407
|
function toPath(input) {
|
|
18408
|
-
const
|
|
18409
|
-
return
|
|
18408
|
+
const path23 = input.trim().replace(/^["']|["']$/g, "");
|
|
18409
|
+
return path23 && normalize2(path23);
|
|
18410
18410
|
}
|
|
18411
18411
|
function checkIgnoreTask(paths) {
|
|
18412
18412
|
return {
|
|
@@ -18545,8 +18545,8 @@ function stashListTask(opt = {}, customArgs) {
|
|
|
18545
18545
|
parser: parser4
|
|
18546
18546
|
};
|
|
18547
18547
|
}
|
|
18548
|
-
function addSubModuleTask(repo,
|
|
18549
|
-
return subModuleTask(["add", repo,
|
|
18548
|
+
function addSubModuleTask(repo, path23) {
|
|
18549
|
+
return subModuleTask(["add", repo, path23]);
|
|
18550
18550
|
}
|
|
18551
18551
|
function initSubModuleTask(customArgs) {
|
|
18552
18552
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -19809,9 +19809,9 @@ var init_esm = __esm({
|
|
|
19809
19809
|
"src/lib/responses/InitSummary.ts"() {
|
|
19810
19810
|
"use strict";
|
|
19811
19811
|
InitSummary = class {
|
|
19812
|
-
constructor(bare,
|
|
19812
|
+
constructor(bare, path23, existing, gitDir) {
|
|
19813
19813
|
this.bare = bare;
|
|
19814
|
-
this.path =
|
|
19814
|
+
this.path = path23;
|
|
19815
19815
|
this.existing = existing;
|
|
19816
19816
|
this.gitDir = gitDir;
|
|
19817
19817
|
}
|
|
@@ -20344,12 +20344,12 @@ var init_esm = __esm({
|
|
|
20344
20344
|
"use strict";
|
|
20345
20345
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
20346
20346
|
FileStatusSummary = class {
|
|
20347
|
-
constructor(
|
|
20348
|
-
this.path =
|
|
20347
|
+
constructor(path23, index, working_dir) {
|
|
20348
|
+
this.path = path23;
|
|
20349
20349
|
this.index = index;
|
|
20350
20350
|
this.working_dir = working_dir;
|
|
20351
20351
|
if (index === "R" || working_dir === "R") {
|
|
20352
|
-
const detail = fromPathRegex.exec(
|
|
20352
|
+
const detail = fromPathRegex.exec(path23) || [null, path23, path23];
|
|
20353
20353
|
this.from = detail[2] || "";
|
|
20354
20354
|
this.path = detail[1] || "";
|
|
20355
20355
|
}
|
|
@@ -20611,9 +20611,9 @@ var init_esm = __esm({
|
|
|
20611
20611
|
next
|
|
20612
20612
|
);
|
|
20613
20613
|
}
|
|
20614
|
-
hashObject(
|
|
20614
|
+
hashObject(path23, write) {
|
|
20615
20615
|
return this._runTask(
|
|
20616
|
-
hashObjectTask(
|
|
20616
|
+
hashObjectTask(path23, write === true),
|
|
20617
20617
|
trailingFunctionArgument(arguments)
|
|
20618
20618
|
);
|
|
20619
20619
|
}
|
|
@@ -21250,8 +21250,8 @@ var init_esm = __esm({
|
|
|
21250
21250
|
}
|
|
21251
21251
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
21252
21252
|
};
|
|
21253
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
21254
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
21253
|
+
Git2.prototype.submoduleAdd = function(repo, path23, then) {
|
|
21254
|
+
return this._runTask(addSubModuleTask2(repo, path23), trailingFunctionArgument2(arguments));
|
|
21255
21255
|
};
|
|
21256
21256
|
Git2.prototype.submoduleUpdate = function(args2, then) {
|
|
21257
21257
|
return this._runTask(
|
|
@@ -22212,7 +22212,7 @@ var require_levenshtein = __commonJS({
|
|
|
22212
22212
|
} catch (err) {
|
|
22213
22213
|
console.log("Collator could not be initialized and wouldn't be used");
|
|
22214
22214
|
}
|
|
22215
|
-
var
|
|
22215
|
+
var levenshtein4 = (init_mod(), __toCommonJS(mod_exports));
|
|
22216
22216
|
var prevRow = [], str2Char = [];
|
|
22217
22217
|
var Levenshtein = {
|
|
22218
22218
|
/**
|
|
@@ -22257,7 +22257,7 @@ var require_levenshtein = __commonJS({
|
|
|
22257
22257
|
}
|
|
22258
22258
|
return nextCol;
|
|
22259
22259
|
}
|
|
22260
|
-
return
|
|
22260
|
+
return levenshtein4.distance(str1, str2);
|
|
22261
22261
|
}
|
|
22262
22262
|
};
|
|
22263
22263
|
if (typeof define !== "undefined" && define !== null && define.amd) {
|
|
@@ -23053,12 +23053,12 @@ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
23053
23053
|
}
|
|
23054
23054
|
return result;
|
|
23055
23055
|
}
|
|
23056
|
-
function findNodeAtLocation(root,
|
|
23056
|
+
function findNodeAtLocation(root, path23) {
|
|
23057
23057
|
if (!root) {
|
|
23058
23058
|
return void 0;
|
|
23059
23059
|
}
|
|
23060
23060
|
let node = root;
|
|
23061
|
-
for (let segment of
|
|
23061
|
+
for (let segment of path23) {
|
|
23062
23062
|
if (typeof segment === "string") {
|
|
23063
23063
|
if (node.type !== "object" || !Array.isArray(node.children)) {
|
|
23064
23064
|
return void 0;
|
|
@@ -23560,20 +23560,20 @@ function splitSegments(cmd) {
|
|
|
23560
23560
|
const out = [];
|
|
23561
23561
|
let buf = "";
|
|
23562
23562
|
let op = "";
|
|
23563
|
-
let
|
|
23563
|
+
let quote2 = null;
|
|
23564
23564
|
for (let i2 = 0; i2 < cmd.length; i2++) {
|
|
23565
23565
|
const ch = cmd[i2];
|
|
23566
|
-
if (
|
|
23566
|
+
if (quote2) {
|
|
23567
23567
|
buf += ch;
|
|
23568
|
-
if (ch === "\\" &&
|
|
23568
|
+
if (ch === "\\" && quote2 !== "'") {
|
|
23569
23569
|
if (i2 + 1 < cmd.length) buf += cmd[++i2];
|
|
23570
23570
|
continue;
|
|
23571
23571
|
}
|
|
23572
|
-
if (ch ===
|
|
23572
|
+
if (ch === quote2) quote2 = null;
|
|
23573
23573
|
continue;
|
|
23574
23574
|
}
|
|
23575
23575
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
23576
|
-
|
|
23576
|
+
quote2 = ch;
|
|
23577
23577
|
buf += ch;
|
|
23578
23578
|
continue;
|
|
23579
23579
|
}
|
|
@@ -23609,20 +23609,20 @@ function splitSegments(cmd) {
|
|
|
23609
23609
|
function splitPipes(segment) {
|
|
23610
23610
|
const out = [];
|
|
23611
23611
|
let buf = "";
|
|
23612
|
-
let
|
|
23612
|
+
let quote2 = null;
|
|
23613
23613
|
for (let i2 = 0; i2 < segment.length; i2++) {
|
|
23614
23614
|
const ch = segment[i2];
|
|
23615
|
-
if (
|
|
23615
|
+
if (quote2) {
|
|
23616
23616
|
buf += ch;
|
|
23617
|
-
if (ch === "\\" &&
|
|
23617
|
+
if (ch === "\\" && quote2 !== "'") {
|
|
23618
23618
|
if (i2 + 1 < segment.length) buf += segment[++i2];
|
|
23619
23619
|
continue;
|
|
23620
23620
|
}
|
|
23621
|
-
if (ch ===
|
|
23621
|
+
if (ch === quote2) quote2 = null;
|
|
23622
23622
|
continue;
|
|
23623
23623
|
}
|
|
23624
23624
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
23625
|
-
|
|
23625
|
+
quote2 = ch;
|
|
23626
23626
|
buf += ch;
|
|
23627
23627
|
continue;
|
|
23628
23628
|
}
|
|
@@ -23840,7 +23840,7 @@ function stripComments2(src) {
|
|
|
23840
23840
|
continue;
|
|
23841
23841
|
}
|
|
23842
23842
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
23843
|
-
const
|
|
23843
|
+
const quote2 = ch;
|
|
23844
23844
|
push(ch, false);
|
|
23845
23845
|
i2++;
|
|
23846
23846
|
while (i2 < src.length) {
|
|
@@ -23850,7 +23850,7 @@ function stripComments2(src) {
|
|
|
23850
23850
|
i2 += 2;
|
|
23851
23851
|
continue;
|
|
23852
23852
|
}
|
|
23853
|
-
if (src[i2] ===
|
|
23853
|
+
if (src[i2] === quote2) break;
|
|
23854
23854
|
push(src[i2], true);
|
|
23855
23855
|
i2++;
|
|
23856
23856
|
}
|
|
@@ -24041,6 +24041,1021 @@ var init_cli_subcommands = __esm({
|
|
|
24041
24041
|
}
|
|
24042
24042
|
});
|
|
24043
24043
|
|
|
24044
|
+
// src/core/checks/gradle-projects.ts
|
|
24045
|
+
import * as fs6 from "node:fs";
|
|
24046
|
+
import * as path7 from "node:path";
|
|
24047
|
+
function findGradleBuildRoot(contextFile, projectRoot, requireWrapper = false) {
|
|
24048
|
+
const root = path7.resolve(projectRoot);
|
|
24049
|
+
let dir = path7.dirname(path7.resolve(contextFile));
|
|
24050
|
+
for (; ; ) {
|
|
24051
|
+
if (SETTINGS_FILES.some((f) => fs6.existsSync(path7.join(dir, f)))) {
|
|
24052
|
+
if (!requireWrapper) return dir;
|
|
24053
|
+
return WRAPPER_FILES.some((f) => fs6.existsSync(path7.join(dir, f))) ? dir : null;
|
|
24054
|
+
}
|
|
24055
|
+
if (dir === root) return null;
|
|
24056
|
+
const parent = path7.dirname(dir);
|
|
24057
|
+
const rel = path7.relative(root, parent);
|
|
24058
|
+
if (parent === dir || rel.startsWith("..") || path7.isAbsolute(rel)) return null;
|
|
24059
|
+
dir = parent;
|
|
24060
|
+
}
|
|
24061
|
+
}
|
|
24062
|
+
function readGradleProjectSet(buildRoot) {
|
|
24063
|
+
const present = SETTINGS_FILES.filter((f) => fs6.existsSync(path7.join(buildRoot, f)));
|
|
24064
|
+
if (present.length !== 1) return null;
|
|
24065
|
+
const parsed = readSettingsFile(path7.join(buildRoot, present[0]));
|
|
24066
|
+
if (!parsed) return null;
|
|
24067
|
+
if (isValidBuildSrc(path7.join(buildRoot, "buildSrc"))) parsed.builds.add("buildSrc");
|
|
24068
|
+
const visited = /* @__PURE__ */ new Set([path7.resolve(buildRoot)]);
|
|
24069
|
+
const queue = parsed.buildDirs.map((d) => ({ dir: path7.resolve(buildRoot, d), depth: 1 }));
|
|
24070
|
+
while (queue.length > 0) {
|
|
24071
|
+
const { dir, depth } = queue.shift();
|
|
24072
|
+
if (visited.has(dir)) continue;
|
|
24073
|
+
visited.add(dir);
|
|
24074
|
+
if (depth > MAX_INCLUDED_BUILD_DEPTH) return null;
|
|
24075
|
+
const files = SETTINGS_FILES.filter((f) => fs6.existsSync(path7.join(dir, f)));
|
|
24076
|
+
if (files.length === 0) continue;
|
|
24077
|
+
if (files.length > 1) return null;
|
|
24078
|
+
const nested = readSettingsFile(path7.join(dir, files[0]));
|
|
24079
|
+
if (!nested) return null;
|
|
24080
|
+
for (const name of nested.builds) parsed.builds.add(name);
|
|
24081
|
+
for (const d of nested.buildDirs) queue.push({ dir: path7.resolve(dir, d), depth: depth + 1 });
|
|
24082
|
+
}
|
|
24083
|
+
return { paths: parsed.paths, builds: parsed.builds, settingsFile: present[0] };
|
|
24084
|
+
}
|
|
24085
|
+
function readSettingsFile(file2) {
|
|
24086
|
+
try {
|
|
24087
|
+
const buf = fs6.readFileSync(file2);
|
|
24088
|
+
if (buf.includes(0)) return null;
|
|
24089
|
+
return parseSettings(stripBom(buf.toString("utf-8")));
|
|
24090
|
+
} catch {
|
|
24091
|
+
return null;
|
|
24092
|
+
}
|
|
24093
|
+
}
|
|
24094
|
+
function isValidBuildSrc(dir) {
|
|
24095
|
+
try {
|
|
24096
|
+
if (!fs6.statSync(dir).isDirectory()) return false;
|
|
24097
|
+
} catch {
|
|
24098
|
+
return false;
|
|
24099
|
+
}
|
|
24100
|
+
const markers = ["settings.gradle", "settings.gradle.kts", "build.gradle", "build.gradle.kts"];
|
|
24101
|
+
if (markers.some((m) => fs6.existsSync(path7.join(dir, m)))) return true;
|
|
24102
|
+
return fs6.existsSync(path7.join(dir, "src"));
|
|
24103
|
+
}
|
|
24104
|
+
function parseSettings(source) {
|
|
24105
|
+
const tokens = tokenize(source);
|
|
24106
|
+
if (!tokens) return null;
|
|
24107
|
+
const paths = /* @__PURE__ */ new Set();
|
|
24108
|
+
const builds = /* @__PURE__ */ new Set();
|
|
24109
|
+
const buildDirs = [];
|
|
24110
|
+
const renames = [];
|
|
24111
|
+
const blocks = [];
|
|
24112
|
+
let pluginManagementEnd = -1;
|
|
24113
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
24114
|
+
const t2 = tokens[i2];
|
|
24115
|
+
if (t2.kind === "punct") {
|
|
24116
|
+
if (t2.text === "{") blocks.push(blockOpener(tokens, i2));
|
|
24117
|
+
else if (t2.text === "}") blocks.pop();
|
|
24118
|
+
continue;
|
|
24119
|
+
}
|
|
24120
|
+
if (t2.kind === "string") {
|
|
24121
|
+
const before = tokens[i2 - 1];
|
|
24122
|
+
if (before?.kind === "punct" && (before.text === "." || before.text === "?.")) return null;
|
|
24123
|
+
if (before?.kind === "punct" && before.text === "[" && (t2.text === "name" || t2.text === "setName")) {
|
|
24124
|
+
return null;
|
|
24125
|
+
}
|
|
24126
|
+
continue;
|
|
24127
|
+
}
|
|
24128
|
+
if (t2.kind !== "ident") continue;
|
|
24129
|
+
if (t2.text === "apply") {
|
|
24130
|
+
if (!appliesBenignPlugin(tokens, i2)) return null;
|
|
24131
|
+
continue;
|
|
24132
|
+
}
|
|
24133
|
+
if (t2.text === "pluginManagement" && tokens[i2 + 1]?.text === "{") {
|
|
24134
|
+
pluginManagementEnd = Math.max(pluginManagementEnd, skipBalanced(tokens, i2 + 1));
|
|
24135
|
+
continue;
|
|
24136
|
+
}
|
|
24137
|
+
const prev = tokens[i2 - 1];
|
|
24138
|
+
const receiverDot = prev?.kind === "punct" && (prev.text === "." || prev.text === "?.");
|
|
24139
|
+
const receiver = receiverDot ? tokens[i2 - 2] : void 0;
|
|
24140
|
+
if (OPEN_IDENTIFIERS.has(t2.text)) {
|
|
24141
|
+
const systemProperty = t2.text === "setProperty" && receiver?.kind === "ident" && receiver.text === "System";
|
|
24142
|
+
if (!systemProperty) return null;
|
|
24143
|
+
}
|
|
24144
|
+
if (t2.text === "include" || t2.text === "includeFlat") {
|
|
24145
|
+
const args2 = literalArguments(tokens, i2 + 1);
|
|
24146
|
+
if (!args2) return null;
|
|
24147
|
+
for (const arg of args2) {
|
|
24148
|
+
if (t2.text === "includeFlat") paths.add(`:${arg}`);
|
|
24149
|
+
else addIncludePath(paths, arg);
|
|
24150
|
+
}
|
|
24151
|
+
continue;
|
|
24152
|
+
}
|
|
24153
|
+
if (t2.text === "includeBuild") {
|
|
24154
|
+
if (receiverDot) return null;
|
|
24155
|
+
const args2 = literalArguments(tokens, i2 + 1, 1);
|
|
24156
|
+
if (!args2 || args2.length !== 1) return null;
|
|
24157
|
+
const base = path7.posix.basename(args2[0].replace(/\\/g, "/").replace(/\/+$/, ""));
|
|
24158
|
+
if (!base || base === "." || base === "..") return null;
|
|
24159
|
+
builds.add(base);
|
|
24160
|
+
buildDirs.push(args2[0]);
|
|
24161
|
+
const override = includeBuildNameOverride(tokens, i2 + 1);
|
|
24162
|
+
if (override === null) return null;
|
|
24163
|
+
if (override) builds.add(override);
|
|
24164
|
+
continue;
|
|
24165
|
+
}
|
|
24166
|
+
if (t2.text === "plugins" && tokens[i2 + 1]?.kind === "punct" && tokens[i2 + 1].text === "{") {
|
|
24167
|
+
if (i2 >= pluginManagementEnd && !pluginsBlockIsBenign(tokens, i2 + 1)) return null;
|
|
24168
|
+
i2 = skipBalanced(tokens, i2 + 1) - 1;
|
|
24169
|
+
continue;
|
|
24170
|
+
}
|
|
24171
|
+
if (t2.text === "name" || t2.text === "setName") {
|
|
24172
|
+
const next = tokens[i2 + 1];
|
|
24173
|
+
const after = tokens[i2 + 2];
|
|
24174
|
+
const isAssign = next?.kind === "punct" && next.text === "=";
|
|
24175
|
+
const isCompound = next?.kind === "punct" && /^[-+*/%]$/.test(next.text) && after?.text === "=";
|
|
24176
|
+
const isSetter = t2.text === "setName" && next !== void 0 && next.line === t2.line;
|
|
24177
|
+
if (!isAssign && !isCompound && !isSetter) continue;
|
|
24178
|
+
const local = prev?.kind === "ident" && ["def", "val", "var"].includes(prev.text);
|
|
24179
|
+
if (local) continue;
|
|
24180
|
+
if (receiverDot) {
|
|
24181
|
+
if (receiver?.kind === "ident" && receiver.text === "rootProject") continue;
|
|
24182
|
+
if (isCompound) return null;
|
|
24183
|
+
const target = literalProjectCall(tokens, i2 - 2);
|
|
24184
|
+
const value = isAssign ? literalValue(tokens, i2 + 2) : literalArguments(tokens, i2 + 1, 1)?.[0];
|
|
24185
|
+
if (!target || !value) return null;
|
|
24186
|
+
renames.push({ from: normalizeProjectPath(target), to: value });
|
|
24187
|
+
continue;
|
|
24188
|
+
}
|
|
24189
|
+
const unsafe = blocks.some((b2) => !NAME_SAFE_BLOCKS.has(b2) && !TRANSPARENT_BLOCKS.has(b2));
|
|
24190
|
+
if (unsafe) return null;
|
|
24191
|
+
}
|
|
24192
|
+
}
|
|
24193
|
+
for (const { from, to } of renames) {
|
|
24194
|
+
const parent = from.slice(0, from.lastIndexOf(":"));
|
|
24195
|
+
const moved = `${parent}:${to}`;
|
|
24196
|
+
for (const p2 of [...paths]) {
|
|
24197
|
+
if (p2 === from) paths.add(moved);
|
|
24198
|
+
else if (p2.startsWith(`${from}:`)) paths.add(moved + p2.slice(from.length));
|
|
24199
|
+
}
|
|
24200
|
+
}
|
|
24201
|
+
return { paths, builds, buildDirs };
|
|
24202
|
+
}
|
|
24203
|
+
function addIncludePath(paths, arg) {
|
|
24204
|
+
const segments = arg.replace(/^:/, "").split(":");
|
|
24205
|
+
if (segments.some((s) => s.length === 0)) return;
|
|
24206
|
+
let acc = "";
|
|
24207
|
+
for (const s of segments) {
|
|
24208
|
+
acc += `:${s}`;
|
|
24209
|
+
paths.add(acc);
|
|
24210
|
+
}
|
|
24211
|
+
}
|
|
24212
|
+
function normalizeProjectPath(p2) {
|
|
24213
|
+
return p2.startsWith(":") ? p2 : `:${p2}`;
|
|
24214
|
+
}
|
|
24215
|
+
function literalArguments(tokens, start, max = Infinity) {
|
|
24216
|
+
const out = [];
|
|
24217
|
+
let i2 = start;
|
|
24218
|
+
const first2 = tokens[i2];
|
|
24219
|
+
if (!first2) return null;
|
|
24220
|
+
const parenthesized = first2.kind === "punct" && first2.text === "(";
|
|
24221
|
+
if (parenthesized) i2++;
|
|
24222
|
+
const line = first2.line;
|
|
24223
|
+
for (; ; ) {
|
|
24224
|
+
let t2 = tokens[i2];
|
|
24225
|
+
if (!t2) return parenthesized ? null : out.length ? out : null;
|
|
24226
|
+
if (parenthesized && t2.kind === "punct" && t2.text === ")") return out;
|
|
24227
|
+
if (t2.kind === "punct" && t2.text === "*") t2 = tokens[++i2];
|
|
24228
|
+
if (t2 && t2.kind === "ident" && ["listOf", "arrayOf", "setOf"].includes(t2.text) && tokens[i2 + 1]?.text === "(") {
|
|
24229
|
+
const inner = literalArguments(tokens, i2 + 1);
|
|
24230
|
+
if (!inner) return null;
|
|
24231
|
+
out.push(...inner);
|
|
24232
|
+
i2 = skipBalanced(tokens, i2 + 1);
|
|
24233
|
+
} else if (t2 && t2.kind === "punct" && t2.text === "[") {
|
|
24234
|
+
const inner = literalList(tokens, i2);
|
|
24235
|
+
if (!inner) return null;
|
|
24236
|
+
out.push(...inner.values);
|
|
24237
|
+
i2 = inner.next;
|
|
24238
|
+
} else if (t2 && t2.kind === "string" && !t2.interpolated) {
|
|
24239
|
+
out.push(t2.text);
|
|
24240
|
+
i2++;
|
|
24241
|
+
} else if (t2 && t2.kind === "ident" && t2.text === "file" && tokens[i2 + 1]?.text === "(" && literalValue(tokens, i2 + 2) !== null && tokens[i2 + 3]?.text === ")") {
|
|
24242
|
+
out.push(literalValue(tokens, i2 + 2));
|
|
24243
|
+
i2 += 4;
|
|
24244
|
+
} else {
|
|
24245
|
+
return null;
|
|
24246
|
+
}
|
|
24247
|
+
if (out.length > max) return null;
|
|
24248
|
+
const sep2 = tokens[i2];
|
|
24249
|
+
if (sep2?.kind === "punct" && sep2.text === ",") {
|
|
24250
|
+
i2++;
|
|
24251
|
+
continue;
|
|
24252
|
+
}
|
|
24253
|
+
if (parenthesized) {
|
|
24254
|
+
return sep2?.kind === "punct" && sep2.text === ")" ? out : null;
|
|
24255
|
+
}
|
|
24256
|
+
if (!sep2 || sep2.line > (tokens[i2 - 1]?.line ?? line) || sep2.text === ";" || sep2.text === "}") {
|
|
24257
|
+
return out;
|
|
24258
|
+
}
|
|
24259
|
+
return null;
|
|
24260
|
+
}
|
|
24261
|
+
}
|
|
24262
|
+
function literalList(tokens, start) {
|
|
24263
|
+
const values = [];
|
|
24264
|
+
let i2 = start + 1;
|
|
24265
|
+
for (; ; ) {
|
|
24266
|
+
const t2 = tokens[i2];
|
|
24267
|
+
if (!t2) return null;
|
|
24268
|
+
if (t2.kind === "punct" && t2.text === "]") return { values, next: i2 + 1 };
|
|
24269
|
+
if (t2.kind !== "string" || t2.interpolated) return null;
|
|
24270
|
+
values.push(t2.text);
|
|
24271
|
+
i2++;
|
|
24272
|
+
const sep2 = tokens[i2];
|
|
24273
|
+
if (sep2?.kind === "punct" && sep2.text === ",") i2++;
|
|
24274
|
+
}
|
|
24275
|
+
}
|
|
24276
|
+
function skipBalanced(tokens, start) {
|
|
24277
|
+
const open = tokens[start].text;
|
|
24278
|
+
const close = open === "(" ? ")" : open === "[" ? "]" : "}";
|
|
24279
|
+
let depth = 0;
|
|
24280
|
+
for (let i2 = start; i2 < tokens.length; i2++) {
|
|
24281
|
+
const t2 = tokens[i2];
|
|
24282
|
+
if (t2.kind !== "punct") continue;
|
|
24283
|
+
if (t2.text === open) depth++;
|
|
24284
|
+
else if (t2.text === close && --depth === 0) return i2 + 1;
|
|
24285
|
+
}
|
|
24286
|
+
return tokens.length;
|
|
24287
|
+
}
|
|
24288
|
+
function literalValue(tokens, i2) {
|
|
24289
|
+
const t2 = tokens[i2];
|
|
24290
|
+
return t2?.kind === "string" && !t2.interpolated ? t2.text : null;
|
|
24291
|
+
}
|
|
24292
|
+
function literalProjectCall(tokens, end) {
|
|
24293
|
+
let i2 = end;
|
|
24294
|
+
while (tokens[i2]?.kind === "punct" && tokens[i2].text === "!") i2--;
|
|
24295
|
+
if (tokens[i2]?.text !== ")") return null;
|
|
24296
|
+
const lit = tokens[i2 - 1];
|
|
24297
|
+
const open = tokens[i2 - 2];
|
|
24298
|
+
const fn = tokens[i2 - 3];
|
|
24299
|
+
if (lit?.kind !== "string" || lit.interpolated) return null;
|
|
24300
|
+
if (open?.text !== "(" || fn?.kind !== "ident") return null;
|
|
24301
|
+
if (fn.text !== "project" && fn.text !== "findProject") return null;
|
|
24302
|
+
return lit.text;
|
|
24303
|
+
}
|
|
24304
|
+
function includeBuildNameOverride(tokens, argsStart) {
|
|
24305
|
+
let i2 = argsStart;
|
|
24306
|
+
if (tokens[i2]?.text === "(") i2 = skipBalanced(tokens, i2);
|
|
24307
|
+
else while (tokens[i2]?.kind === "string") i2++;
|
|
24308
|
+
if (tokens[i2]?.text !== "{") return "";
|
|
24309
|
+
const end = skipBalanced(tokens, i2);
|
|
24310
|
+
let found = "";
|
|
24311
|
+
for (let j3 = i2 + 1; j3 < end; j3++) {
|
|
24312
|
+
const t2 = tokens[j3];
|
|
24313
|
+
if (t2.kind !== "ident" || t2.text !== "name" && t2.text !== "setName") continue;
|
|
24314
|
+
let value;
|
|
24315
|
+
if (t2.text === "name" && tokens[j3 + 1]?.text === "=" && tokens[j3 + 2]?.text !== "=") {
|
|
24316
|
+
value = literalValue(tokens, j3 + 2);
|
|
24317
|
+
} else if (t2.text === "setName") {
|
|
24318
|
+
value = literalArguments(tokens, j3 + 1, 1)?.[0] ?? null;
|
|
24319
|
+
} else if (tokens[j3 + 1]?.kind === "punct" && /^[-+*/%]$/.test(tokens[j3 + 1].text)) {
|
|
24320
|
+
return null;
|
|
24321
|
+
} else {
|
|
24322
|
+
continue;
|
|
24323
|
+
}
|
|
24324
|
+
if (value === null) return null;
|
|
24325
|
+
found = value;
|
|
24326
|
+
}
|
|
24327
|
+
return found;
|
|
24328
|
+
}
|
|
24329
|
+
function pluginsBlockIsBenign(tokens, braceIndex) {
|
|
24330
|
+
const end = skipBalanced(tokens, braceIndex);
|
|
24331
|
+
for (let j3 = braceIndex + 1; j3 < end - 1; j3++) {
|
|
24332
|
+
const t2 = tokens[j3];
|
|
24333
|
+
if (t2.kind !== "ident") continue;
|
|
24334
|
+
if (t2.text === "id") {
|
|
24335
|
+
const id = literalValue(tokens, tokens[j3 + 1]?.text === "(" ? j3 + 2 : j3 + 1);
|
|
24336
|
+
if (!id) return false;
|
|
24337
|
+
let applyFalse = false;
|
|
24338
|
+
for (let k3 = j3 + 1; k3 < end - 1 && tokens[k3].line === t2.line; k3++) {
|
|
24339
|
+
if (tokens[k3].text === ";" || tokens[k3].kind === "ident" && tokens[k3].text === "id")
|
|
24340
|
+
break;
|
|
24341
|
+
if (tokens[k3].kind === "ident" && tokens[k3].text === "apply") {
|
|
24342
|
+
const n7 = tokens[k3 + 1]?.text === "(" ? tokens[k3 + 2] : tokens[k3 + 1];
|
|
24343
|
+
applyFalse = n7?.kind === "ident" && n7.text === "false";
|
|
24344
|
+
}
|
|
24345
|
+
}
|
|
24346
|
+
if (!applyFalse && !BENIGN_SETTINGS_PLUGINS.has(id)) return false;
|
|
24347
|
+
} else if (!["version", "apply", "false"].includes(t2.text)) {
|
|
24348
|
+
return false;
|
|
24349
|
+
}
|
|
24350
|
+
}
|
|
24351
|
+
return true;
|
|
24352
|
+
}
|
|
24353
|
+
function appliesBenignPlugin(tokens, i2) {
|
|
24354
|
+
let j3 = i2 + 1;
|
|
24355
|
+
if (tokens[j3]?.text === "(") j3++;
|
|
24356
|
+
const key = tokens[j3];
|
|
24357
|
+
const sep2 = tokens[j3 + 1];
|
|
24358
|
+
if (key?.kind !== "ident" || key.text !== "plugin") return false;
|
|
24359
|
+
if (sep2?.text !== ":" && sep2?.text !== "=") return false;
|
|
24360
|
+
const id = literalValue(tokens, j3 + 2);
|
|
24361
|
+
if (tokens[j3 + 3]?.text === ",") return false;
|
|
24362
|
+
return id !== null && BENIGN_SETTINGS_PLUGINS.has(id);
|
|
24363
|
+
}
|
|
24364
|
+
function blockOpener(tokens, braceIndex) {
|
|
24365
|
+
let j3 = braceIndex - 1;
|
|
24366
|
+
if (tokens[j3]?.text === ")") {
|
|
24367
|
+
let depth = 0;
|
|
24368
|
+
for (; j3 >= 0; j3--) {
|
|
24369
|
+
if (tokens[j3].text === ")") depth++;
|
|
24370
|
+
else if (tokens[j3].text === "(" && --depth === 0) break;
|
|
24371
|
+
}
|
|
24372
|
+
j3--;
|
|
24373
|
+
}
|
|
24374
|
+
const t2 = tokens[j3];
|
|
24375
|
+
return t2?.kind === "ident" ? t2.text : "";
|
|
24376
|
+
}
|
|
24377
|
+
function tokenize(src) {
|
|
24378
|
+
const tokens = [];
|
|
24379
|
+
let line = 1;
|
|
24380
|
+
let i2 = 0;
|
|
24381
|
+
const n7 = src.length;
|
|
24382
|
+
while (i2 < n7) {
|
|
24383
|
+
const c3 = src[i2];
|
|
24384
|
+
if (c3 === "\n") {
|
|
24385
|
+
line++;
|
|
24386
|
+
i2++;
|
|
24387
|
+
continue;
|
|
24388
|
+
}
|
|
24389
|
+
if (c3 === " " || c3 === " " || c3 === "\r") {
|
|
24390
|
+
i2++;
|
|
24391
|
+
continue;
|
|
24392
|
+
}
|
|
24393
|
+
if (c3 === "/" && src[i2 + 1] === "/") {
|
|
24394
|
+
while (i2 < n7 && src[i2] !== "\n") i2++;
|
|
24395
|
+
continue;
|
|
24396
|
+
}
|
|
24397
|
+
if (c3 === "/" && src[i2 + 1] === "*") {
|
|
24398
|
+
const end = src.indexOf("*/", i2 + 2);
|
|
24399
|
+
if (end < 0) return null;
|
|
24400
|
+
for (let k3 = i2; k3 < end; k3++) if (src[k3] === "\n") line++;
|
|
24401
|
+
i2 = end + 2;
|
|
24402
|
+
continue;
|
|
24403
|
+
}
|
|
24404
|
+
if (c3 === "/") {
|
|
24405
|
+
const last2 = tokens[tokens.length - 1];
|
|
24406
|
+
const operandPosition = !last2 || last2.kind === "punct" && ["=", "==", "(", ",", "[", "{", ":", "~", "!", ";"].includes(last2.text) || last2.kind === "ident" && last2.text === "return";
|
|
24407
|
+
if (operandPosition) return null;
|
|
24408
|
+
}
|
|
24409
|
+
if (c3 === "$" && src[i2 + 1] === "/") return null;
|
|
24410
|
+
if (c3 === '"' || c3 === "'") {
|
|
24411
|
+
const triple = src.startsWith(c3.repeat(3), i2);
|
|
24412
|
+
const delim = triple ? c3.repeat(3) : c3;
|
|
24413
|
+
const startLine = line;
|
|
24414
|
+
let j3 = i2 + delim.length;
|
|
24415
|
+
let text = "";
|
|
24416
|
+
let interpolated = false;
|
|
24417
|
+
let closed = false;
|
|
24418
|
+
while (j3 < n7) {
|
|
24419
|
+
if (src.startsWith(delim, j3)) {
|
|
24420
|
+
closed = true;
|
|
24421
|
+
j3 += delim.length;
|
|
24422
|
+
break;
|
|
24423
|
+
}
|
|
24424
|
+
const ch = src[j3];
|
|
24425
|
+
if (ch === "\n") {
|
|
24426
|
+
if (!triple) return null;
|
|
24427
|
+
line++;
|
|
24428
|
+
}
|
|
24429
|
+
if (ch === "\\" && j3 + 1 < n7) {
|
|
24430
|
+
text += src[j3 + 1];
|
|
24431
|
+
j3 += 2;
|
|
24432
|
+
continue;
|
|
24433
|
+
}
|
|
24434
|
+
if (ch === "$" && c3 === '"') {
|
|
24435
|
+
interpolated = true;
|
|
24436
|
+
if (src[j3 + 1] === "{") {
|
|
24437
|
+
const end = skipTemplate(src, j3 + 1);
|
|
24438
|
+
if (end < 0) return null;
|
|
24439
|
+
for (let k3 = j3; k3 < end; k3++) if (src[k3] === "\n") line++;
|
|
24440
|
+
j3 = end;
|
|
24441
|
+
continue;
|
|
24442
|
+
}
|
|
24443
|
+
}
|
|
24444
|
+
text += ch;
|
|
24445
|
+
j3++;
|
|
24446
|
+
}
|
|
24447
|
+
if (!closed) return null;
|
|
24448
|
+
tokens.push({ kind: "string", text, interpolated, line: startLine });
|
|
24449
|
+
i2 = j3;
|
|
24450
|
+
continue;
|
|
24451
|
+
}
|
|
24452
|
+
if (/[A-Za-z_$]/.test(c3)) {
|
|
24453
|
+
let j3 = i2 + 1;
|
|
24454
|
+
while (j3 < n7 && /[\w$]/.test(src[j3])) j3++;
|
|
24455
|
+
tokens.push({ kind: "ident", text: src.slice(i2, j3), line });
|
|
24456
|
+
i2 = j3;
|
|
24457
|
+
continue;
|
|
24458
|
+
}
|
|
24459
|
+
if (c3 === "`") {
|
|
24460
|
+
const end = src.indexOf("`", i2 + 1);
|
|
24461
|
+
if (end < 0) return null;
|
|
24462
|
+
tokens.push({ kind: "ident", text: src.slice(i2 + 1, end), line });
|
|
24463
|
+
i2 = end + 1;
|
|
24464
|
+
continue;
|
|
24465
|
+
}
|
|
24466
|
+
if (c3 === "?" && src[i2 + 1] === ".") {
|
|
24467
|
+
tokens.push({ kind: "punct", text: "?.", line });
|
|
24468
|
+
i2 += 2;
|
|
24469
|
+
continue;
|
|
24470
|
+
}
|
|
24471
|
+
if (c3 === "=" && src[i2 + 1] === "=") {
|
|
24472
|
+
tokens.push({ kind: "punct", text: "==", line });
|
|
24473
|
+
i2 += 2;
|
|
24474
|
+
continue;
|
|
24475
|
+
}
|
|
24476
|
+
tokens.push({ kind: "punct", text: c3, line });
|
|
24477
|
+
i2++;
|
|
24478
|
+
}
|
|
24479
|
+
return tokens;
|
|
24480
|
+
}
|
|
24481
|
+
function skipTemplate(src, open) {
|
|
24482
|
+
let depth = 0;
|
|
24483
|
+
for (let j3 = open; j3 < src.length; j3++) {
|
|
24484
|
+
const ch = src[j3];
|
|
24485
|
+
if (ch === "{") depth++;
|
|
24486
|
+
else if (ch === "}" && --depth === 0) return j3 + 1;
|
|
24487
|
+
else if (ch === '"' || ch === "'") {
|
|
24488
|
+
const end = src.indexOf(ch, j3 + 1);
|
|
24489
|
+
if (end < 0) return -1;
|
|
24490
|
+
j3 = end;
|
|
24491
|
+
}
|
|
24492
|
+
}
|
|
24493
|
+
return -1;
|
|
24494
|
+
}
|
|
24495
|
+
function quote(s) {
|
|
24496
|
+
return s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
24497
|
+
}
|
|
24498
|
+
function patternForName(name, boundary, add) {
|
|
24499
|
+
let out = "";
|
|
24500
|
+
let pos = 0;
|
|
24501
|
+
boundary.lastIndex = 0;
|
|
24502
|
+
for (const m of name.matchAll(boundary)) {
|
|
24503
|
+
const start = m.index ?? 0;
|
|
24504
|
+
if (start > pos) out += quote(name.slice(pos, start));
|
|
24505
|
+
out += add(pos, m[0]);
|
|
24506
|
+
pos = start + m[0].length;
|
|
24507
|
+
}
|
|
24508
|
+
if (pos < name.length) out += quote(name.slice(pos));
|
|
24509
|
+
return out;
|
|
24510
|
+
}
|
|
24511
|
+
function matchGradleName(pattern, items) {
|
|
24512
|
+
const list = [...items];
|
|
24513
|
+
if (list.includes(pattern)) return pattern;
|
|
24514
|
+
if (!pattern) return null;
|
|
24515
|
+
const camel = patternForName(
|
|
24516
|
+
pattern,
|
|
24517
|
+
CAMEL_BOUNDARY,
|
|
24518
|
+
(_pos, part) => `${quote(part)}[${LOWER}]*`
|
|
24519
|
+
);
|
|
24520
|
+
const kebab = patternForName(
|
|
24521
|
+
pattern,
|
|
24522
|
+
KEBAB_BOUNDARY,
|
|
24523
|
+
(pos, part) => `${pos > 0 ? "-" : ""}${quote(part.toLowerCase())}[${LOWER}0-9]*`
|
|
24524
|
+
);
|
|
24525
|
+
const camelFull = new RegExp(`^(?:${camel})$`, "u");
|
|
24526
|
+
const camelPrefix = new RegExp(`^(?:${camel})`, "u");
|
|
24527
|
+
const camelPrefixCi = new RegExp(`^(?:${camel})`, "iu");
|
|
24528
|
+
const kebabFull = new RegExp(`^(?:${kebab})$`, "u");
|
|
24529
|
+
const kebabPrefix = new RegExp(`^(?:${kebab})[${LOWER}0-9-]*$`, "u");
|
|
24530
|
+
const ci2 = [];
|
|
24531
|
+
const camelMatches = [];
|
|
24532
|
+
const prefixMatches = [];
|
|
24533
|
+
const ciCamel = [];
|
|
24534
|
+
const kebabMatches = [];
|
|
24535
|
+
const kebabPrefixMatches = [];
|
|
24536
|
+
const upper = pattern.toUpperCase();
|
|
24537
|
+
for (const c3 of list) {
|
|
24538
|
+
if (c3.toUpperCase() === upper) ci2.push(c3);
|
|
24539
|
+
if (camelFull.test(c3)) camelMatches.push(c3);
|
|
24540
|
+
if (camelPrefix.test(c3)) prefixMatches.push(c3);
|
|
24541
|
+
if (camelPrefixCi.test(c3)) ciCamel.push(c3);
|
|
24542
|
+
if (kebabFull.test(c3)) kebabMatches.push(c3);
|
|
24543
|
+
if (kebabPrefix.test(c3)) kebabPrefixMatches.push(c3);
|
|
24544
|
+
}
|
|
24545
|
+
const matches = /* @__PURE__ */ new Set();
|
|
24546
|
+
if (ci2.length) ci2.forEach((m) => matches.add(m));
|
|
24547
|
+
else if (camelMatches.length) camelMatches.forEach((m) => matches.add(m));
|
|
24548
|
+
else if (prefixMatches.length) prefixMatches.forEach((m) => matches.add(m));
|
|
24549
|
+
else if (!kebabMatches.length && !kebabPrefixMatches.length)
|
|
24550
|
+
ciCamel.forEach((m) => matches.add(m));
|
|
24551
|
+
if (kebabMatches.length) kebabMatches.forEach((m) => matches.add(m));
|
|
24552
|
+
else kebabPrefixMatches.forEach((m) => matches.add(m));
|
|
24553
|
+
if (matches.size === 1) return [...matches][0];
|
|
24554
|
+
return matches.size > 1 ? "ambiguous" : null;
|
|
24555
|
+
}
|
|
24556
|
+
function gradleProjectRefs(cmd) {
|
|
24557
|
+
const tokens = shellWords(cmd);
|
|
24558
|
+
if (!tokens || tokens.length === 0 || !GRADLE_HEAD.test(tokens[0])) return null;
|
|
24559
|
+
if (tokens.length > 1 && CONTINUATION.test(tokens[tokens.length - 1])) return null;
|
|
24560
|
+
const refs = [];
|
|
24561
|
+
for (let i2 = 1; i2 < tokens.length; i2++) {
|
|
24562
|
+
const tok = tokens[i2];
|
|
24563
|
+
if (tok.startsWith("-")) {
|
|
24564
|
+
const bare = tok.includes("=") ? tok.slice(0, tok.indexOf("=")) : tok;
|
|
24565
|
+
if (RETARGET_OPTIONS.has(bare)) return null;
|
|
24566
|
+
if (!tok.startsWith("--") && tok.length > 2) {
|
|
24567
|
+
if (RETARGET_OPTIONS.has(tok.slice(0, 2))) return null;
|
|
24568
|
+
continue;
|
|
24569
|
+
}
|
|
24570
|
+
if (tok.includes("=")) continue;
|
|
24571
|
+
if (VALUE_OPTIONS.has(tok)) {
|
|
24572
|
+
i2++;
|
|
24573
|
+
continue;
|
|
24574
|
+
}
|
|
24575
|
+
if (tok.startsWith("--") && !BOOLEAN_LONG_OPTIONS.has(tok)) {
|
|
24576
|
+
if (tokens[i2 + 1] && !tokens[i2 + 1].startsWith("-")) i2++;
|
|
24577
|
+
}
|
|
24578
|
+
continue;
|
|
24579
|
+
}
|
|
24580
|
+
if (!TASK_PATH.test(tok)) continue;
|
|
24581
|
+
const absolute = tok.startsWith(":");
|
|
24582
|
+
const segments = (absolute ? tok.slice(1) : tok).split(":");
|
|
24583
|
+
const projectSegments = segments.slice(0, -1);
|
|
24584
|
+
if (projectSegments.length === 0) continue;
|
|
24585
|
+
if (projectSegments.some((s) => PLACEHOLDER_SEGMENT.test(s))) continue;
|
|
24586
|
+
refs.push({ token: tok, segments: projectSegments, absolute });
|
|
24587
|
+
}
|
|
24588
|
+
return refs;
|
|
24589
|
+
}
|
|
24590
|
+
function shellWords(cmd) {
|
|
24591
|
+
const words = [];
|
|
24592
|
+
let buf = "";
|
|
24593
|
+
let inWord = false;
|
|
24594
|
+
let quote2 = null;
|
|
24595
|
+
for (let i2 = 0; i2 < cmd.length; i2++) {
|
|
24596
|
+
const ch = cmd[i2];
|
|
24597
|
+
if (quote2) {
|
|
24598
|
+
if (ch === quote2) quote2 = null;
|
|
24599
|
+
else buf += ch;
|
|
24600
|
+
continue;
|
|
24601
|
+
}
|
|
24602
|
+
if (ch === '"' || ch === "'") {
|
|
24603
|
+
quote2 = ch;
|
|
24604
|
+
inWord = true;
|
|
24605
|
+
continue;
|
|
24606
|
+
}
|
|
24607
|
+
if (ch === " " || ch === " ") {
|
|
24608
|
+
if (inWord) words.push(buf);
|
|
24609
|
+
buf = "";
|
|
24610
|
+
inWord = false;
|
|
24611
|
+
continue;
|
|
24612
|
+
}
|
|
24613
|
+
if (!inWord && ch === "#") break;
|
|
24614
|
+
if (ch === "<") {
|
|
24615
|
+
const close = cmd.slice(i2).search(/>|\s/);
|
|
24616
|
+
if (close > 1 && cmd[i2 + close] === ">") {
|
|
24617
|
+
buf += cmd.slice(i2, i2 + close + 1);
|
|
24618
|
+
i2 += close;
|
|
24619
|
+
inWord = true;
|
|
24620
|
+
continue;
|
|
24621
|
+
}
|
|
24622
|
+
}
|
|
24623
|
+
if (ch === "&" || ch === "|" || ch === ";" || ch === ">" || ch === "<") break;
|
|
24624
|
+
buf += ch;
|
|
24625
|
+
inWord = true;
|
|
24626
|
+
}
|
|
24627
|
+
if (quote2) return null;
|
|
24628
|
+
if (inWord) words.push(buf);
|
|
24629
|
+
return words;
|
|
24630
|
+
}
|
|
24631
|
+
function unresolvedGradleProject(ref, set2) {
|
|
24632
|
+
let current = "";
|
|
24633
|
+
for (let depth = 0; depth < ref.segments.length; depth++) {
|
|
24634
|
+
const seg = ref.segments[depth];
|
|
24635
|
+
const children = childNames(set2.paths, current);
|
|
24636
|
+
if (depth === 0) {
|
|
24637
|
+
const match2 = matchGradleName(seg, [...children, ...set2.builds]);
|
|
24638
|
+
if (match2 === null) return `:${seg}`;
|
|
24639
|
+
if (match2 === "ambiguous" || set2.builds.has(match2)) return null;
|
|
24640
|
+
current = `:${match2}`;
|
|
24641
|
+
continue;
|
|
24642
|
+
}
|
|
24643
|
+
const match = matchGradleName(seg, children);
|
|
24644
|
+
if (match === null) return `${current}:${seg}`;
|
|
24645
|
+
if (match === "ambiguous") return null;
|
|
24646
|
+
current = `${current}:${match}`;
|
|
24647
|
+
}
|
|
24648
|
+
return null;
|
|
24649
|
+
}
|
|
24650
|
+
function childNames(paths, parent) {
|
|
24651
|
+
const out = /* @__PURE__ */ new Set();
|
|
24652
|
+
const prefix = `${parent}:`;
|
|
24653
|
+
for (const p2 of paths) {
|
|
24654
|
+
if (!p2.startsWith(prefix)) continue;
|
|
24655
|
+
const rest = p2.slice(prefix.length);
|
|
24656
|
+
if (rest && !rest.includes(":")) out.add(rest);
|
|
24657
|
+
}
|
|
24658
|
+
return out;
|
|
24659
|
+
}
|
|
24660
|
+
var SETTINGS_FILES, BENIGN_SETTINGS_PLUGINS, OPEN_IDENTIFIERS, WRAPPER_FILES, MAX_INCLUDED_BUILD_DEPTH, NAME_SAFE_BLOCKS, TRANSPARENT_BLOCKS, PUNCT, LOWER, UPPER, CAMEL_BOUNDARY, KEBAB_BOUNDARY, GRADLE_HEAD, VALUE_OPTIONS, RETARGET_OPTIONS, BOOLEAN_LONG_OPTIONS, CONTINUATION, TASK_PATH, PLACEHOLDER_SEGMENT;
|
|
24661
|
+
var init_gradle_projects = __esm({
|
|
24662
|
+
"src/core/checks/gradle-projects.ts"() {
|
|
24663
|
+
"use strict";
|
|
24664
|
+
init_define_WEB_FIRST_SEGMENTS();
|
|
24665
|
+
init_fs();
|
|
24666
|
+
SETTINGS_FILES = ["settings.gradle", "settings.gradle.kts"];
|
|
24667
|
+
BENIGN_SETTINGS_PLUGINS = /* @__PURE__ */ new Set([
|
|
24668
|
+
"com.gradle.develocity",
|
|
24669
|
+
"com.gradle.enterprise",
|
|
24670
|
+
"com.gradle.common-custom-user-data-gradle-plugin",
|
|
24671
|
+
"org.gradle.toolchains.foojay-resolver",
|
|
24672
|
+
"org.gradle.toolchains.foojay-resolver-convention"
|
|
24673
|
+
]);
|
|
24674
|
+
OPEN_IDENTIFIERS = /* @__PURE__ */ new Set([
|
|
24675
|
+
"pluginManager",
|
|
24676
|
+
"settingsEvaluated",
|
|
24677
|
+
"beforeSettings",
|
|
24678
|
+
"evaluate",
|
|
24679
|
+
"GroovyShell",
|
|
24680
|
+
"Eval",
|
|
24681
|
+
"ScriptEngineManager",
|
|
24682
|
+
"createProjectDescriptor",
|
|
24683
|
+
// A settings `buildscript {}` puts a jar on the settings classpath, which can
|
|
24684
|
+
// contribute extension functions on Settings; `classpath` alone misses
|
|
24685
|
+
// `add('classpath', ...)` and Kotlin `"classpath"(...)`.
|
|
24686
|
+
"buildscript",
|
|
24687
|
+
"classpath",
|
|
24688
|
+
"invokeMethod",
|
|
24689
|
+
"metaClass",
|
|
24690
|
+
"methodMissing",
|
|
24691
|
+
"setProperty"
|
|
24692
|
+
]);
|
|
24693
|
+
WRAPPER_FILES = ["gradlew", "gradlew.bat"];
|
|
24694
|
+
MAX_INCLUDED_BUILD_DEPTH = 8;
|
|
24695
|
+
NAME_SAFE_BLOCKS = /* @__PURE__ */ new Set([
|
|
24696
|
+
"pluginManagement",
|
|
24697
|
+
"dependencyResolutionManagement",
|
|
24698
|
+
"repositories",
|
|
24699
|
+
"maven",
|
|
24700
|
+
"ivy",
|
|
24701
|
+
"exclusiveContent",
|
|
24702
|
+
"forRepository",
|
|
24703
|
+
"filter",
|
|
24704
|
+
"content",
|
|
24705
|
+
"credentials",
|
|
24706
|
+
"authentication",
|
|
24707
|
+
"versionCatalogs",
|
|
24708
|
+
"create",
|
|
24709
|
+
"register",
|
|
24710
|
+
"develocity",
|
|
24711
|
+
"gradleEnterprise",
|
|
24712
|
+
"buildScan",
|
|
24713
|
+
"buildCache",
|
|
24714
|
+
"local",
|
|
24715
|
+
"remote",
|
|
24716
|
+
"toolchainManagement",
|
|
24717
|
+
"jvm",
|
|
24718
|
+
"javaRepositories",
|
|
24719
|
+
"includeBuild",
|
|
24720
|
+
"dependencySubstitution"
|
|
24721
|
+
]);
|
|
24722
|
+
TRANSPARENT_BLOCKS = /* @__PURE__ */ new Set([
|
|
24723
|
+
"if",
|
|
24724
|
+
"else",
|
|
24725
|
+
"for",
|
|
24726
|
+
"while",
|
|
24727
|
+
"try",
|
|
24728
|
+
"catch",
|
|
24729
|
+
"finally",
|
|
24730
|
+
"when"
|
|
24731
|
+
]);
|
|
24732
|
+
PUNCT = "[!\"#$%&'()*+,\\-./:;<=>?@\\[\\\\\\]^_`{|}~]";
|
|
24733
|
+
LOWER = "\\p{Lowercase}";
|
|
24734
|
+
UPPER = "\\p{Uppercase}";
|
|
24735
|
+
CAMEL_BOUNDARY = new RegExp(`((^|${PUNCT})${LOWER}+)|((${UPPER}|[0-9])${LOWER}*)`, "gu");
|
|
24736
|
+
KEBAB_BOUNDARY = new RegExp(`((^|${PUNCT})${LOWER}+)|(${UPPER}${LOWER}*)`, "gu");
|
|
24737
|
+
GRADLE_HEAD = /^(?:\.[\\/])?gradlew(?:\.bat)?$|^gradle$/;
|
|
24738
|
+
VALUE_OPTIONS = /* @__PURE__ */ new Set([
|
|
24739
|
+
"-x",
|
|
24740
|
+
"--exclude-task",
|
|
24741
|
+
"-g",
|
|
24742
|
+
"--gradle-user-home",
|
|
24743
|
+
"--project-cache-dir",
|
|
24744
|
+
"--console",
|
|
24745
|
+
"--console-unicode",
|
|
24746
|
+
"--warning-mode",
|
|
24747
|
+
"--max-workers",
|
|
24748
|
+
"--priority",
|
|
24749
|
+
"--develocity-url",
|
|
24750
|
+
"--develocity-plugin-version",
|
|
24751
|
+
"--write-verification-metadata",
|
|
24752
|
+
"-F",
|
|
24753
|
+
"--dependency-verification",
|
|
24754
|
+
"--update-locks",
|
|
24755
|
+
"--configuration-cache-problems",
|
|
24756
|
+
"-D",
|
|
24757
|
+
"--system-prop",
|
|
24758
|
+
"-P",
|
|
24759
|
+
"--project-prop"
|
|
24760
|
+
]);
|
|
24761
|
+
RETARGET_OPTIONS = /* @__PURE__ */ new Set([
|
|
24762
|
+
"-p",
|
|
24763
|
+
"--project-dir",
|
|
24764
|
+
"-c",
|
|
24765
|
+
"--settings-file",
|
|
24766
|
+
"-b",
|
|
24767
|
+
"--build-file",
|
|
24768
|
+
"--include-build",
|
|
24769
|
+
"-I",
|
|
24770
|
+
"--init-script"
|
|
24771
|
+
]);
|
|
24772
|
+
BOOLEAN_LONG_OPTIONS = /* @__PURE__ */ new Set([
|
|
24773
|
+
"--rerun-tasks",
|
|
24774
|
+
"--profile",
|
|
24775
|
+
"--continue",
|
|
24776
|
+
"--no-continue",
|
|
24777
|
+
"--offline",
|
|
24778
|
+
"--refresh-dependencies",
|
|
24779
|
+
"--dry-run",
|
|
24780
|
+
"--continuous",
|
|
24781
|
+
"--no-rebuild",
|
|
24782
|
+
"--configure-on-demand",
|
|
24783
|
+
"--no-configure-on-demand",
|
|
24784
|
+
"--build-cache",
|
|
24785
|
+
"--no-build-cache",
|
|
24786
|
+
"--watch-fs",
|
|
24787
|
+
"--no-watch-fs",
|
|
24788
|
+
"--scan",
|
|
24789
|
+
"--no-scan",
|
|
24790
|
+
"--write-locks",
|
|
24791
|
+
"--refresh-keys",
|
|
24792
|
+
"--export-keys",
|
|
24793
|
+
"--configuration-cache",
|
|
24794
|
+
"--no-configuration-cache",
|
|
24795
|
+
"--property-upgrade-report",
|
|
24796
|
+
"--problems-report",
|
|
24797
|
+
"--no-problems-report",
|
|
24798
|
+
"--task-graph",
|
|
24799
|
+
"--quiet",
|
|
24800
|
+
"--warn",
|
|
24801
|
+
"--info",
|
|
24802
|
+
"--debug",
|
|
24803
|
+
"--stacktrace",
|
|
24804
|
+
"--full-stacktrace",
|
|
24805
|
+
"--non-interactive",
|
|
24806
|
+
"--parallel",
|
|
24807
|
+
"--no-parallel",
|
|
24808
|
+
"--daemon",
|
|
24809
|
+
"--no-daemon",
|
|
24810
|
+
"--foreground",
|
|
24811
|
+
"--stop",
|
|
24812
|
+
"--status",
|
|
24813
|
+
"--help",
|
|
24814
|
+
"--version",
|
|
24815
|
+
"--show-version"
|
|
24816
|
+
]);
|
|
24817
|
+
CONTINUATION = /^[\\^`]$/;
|
|
24818
|
+
TASK_PATH = /^:?[\w.-]+(?::[\w.-]+)+$|^:[\w.-]+$/;
|
|
24819
|
+
PLACEHOLDER_SEGMENT = /^(?:module|project|subproject|submodule|component|feature)(?:[-_]?(?:name|path|id))?$|^(?:my|your|some|example|sample)[-_]|^(?:foo|bar|baz|xxx|name)$/i;
|
|
24820
|
+
}
|
|
24821
|
+
});
|
|
24822
|
+
|
|
24823
|
+
// src/core/checks/maven-modules.ts
|
|
24824
|
+
import * as fs7 from "node:fs";
|
|
24825
|
+
import * as path8 from "node:path";
|
|
24826
|
+
function readMavenReactor(baseDir) {
|
|
24827
|
+
const rootPom = path8.join(baseDir, "pom.xml");
|
|
24828
|
+
if (!fs7.existsSync(rootPom)) return null;
|
|
24829
|
+
const projects = [];
|
|
24830
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24831
|
+
const queue = [path8.resolve(rootPom)];
|
|
24832
|
+
while (queue.length > 0) {
|
|
24833
|
+
const pomFile = realPath(queue.shift());
|
|
24834
|
+
if (pomFile === null) return null;
|
|
24835
|
+
if (seen.has(pomFile)) continue;
|
|
24836
|
+
seen.add(pomFile);
|
|
24837
|
+
if (seen.size > MAX_POMS) return null;
|
|
24838
|
+
let xml;
|
|
24839
|
+
try {
|
|
24840
|
+
xml = readXml(pomFile);
|
|
24841
|
+
} catch {
|
|
24842
|
+
return null;
|
|
24843
|
+
}
|
|
24844
|
+
const model = parsePom(xml);
|
|
24845
|
+
if (!model) return null;
|
|
24846
|
+
const basedir = path8.dirname(pomFile);
|
|
24847
|
+
projects.push({ basedir, pomFile, artifactId: model.artifactId, groupId: model.groupId });
|
|
24848
|
+
for (const module of model.modules) {
|
|
24849
|
+
const target = path8.resolve(basedir, module);
|
|
24850
|
+
let childPom = target;
|
|
24851
|
+
try {
|
|
24852
|
+
if (fs7.statSync(target).isDirectory()) childPom = path8.join(target, "pom.xml");
|
|
24853
|
+
} catch {
|
|
24854
|
+
return null;
|
|
24855
|
+
}
|
|
24856
|
+
queue.push(childPom);
|
|
24857
|
+
}
|
|
24858
|
+
}
|
|
24859
|
+
return projects;
|
|
24860
|
+
}
|
|
24861
|
+
function realPath(p2) {
|
|
24862
|
+
try {
|
|
24863
|
+
return fs7.realpathSync.native(p2);
|
|
24864
|
+
} catch {
|
|
24865
|
+
return null;
|
|
24866
|
+
}
|
|
24867
|
+
}
|
|
24868
|
+
function readXml(file2) {
|
|
24869
|
+
const buf = fs7.readFileSync(file2);
|
|
24870
|
+
if (buf.includes(0)) throw new Error("not UTF-8");
|
|
24871
|
+
return stripBom(buf.toString("utf-8"));
|
|
24872
|
+
}
|
|
24873
|
+
function parsePom(xml) {
|
|
24874
|
+
const cleaned = xml.replace(/<!--[\s\S]*?-->/g, "").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, "");
|
|
24875
|
+
const tagRe = /<(\/?)([A-Za-z_][\w.:-]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g;
|
|
24876
|
+
const stack = [];
|
|
24877
|
+
const text = {};
|
|
24878
|
+
const modules = [];
|
|
24879
|
+
let hasModuleList = false;
|
|
24880
|
+
let namespaceVersion = null;
|
|
24881
|
+
let lastEnd = 0;
|
|
24882
|
+
for (const m of cleaned.matchAll(tagRe)) {
|
|
24883
|
+
const [whole, closing, rawName, attrs, selfClosing] = m;
|
|
24884
|
+
const name = rawName.includes(":") ? rawName.slice(rawName.indexOf(":") + 1) : rawName;
|
|
24885
|
+
const start = m.index ?? 0;
|
|
24886
|
+
if (closing) {
|
|
24887
|
+
if (stack[stack.length - 1] !== name) return null;
|
|
24888
|
+
const elementPath = stack.join("/");
|
|
24889
|
+
const value2 = cleaned.slice(lastEnd, start).trim();
|
|
24890
|
+
if (/^project\/(?:artifactId|groupId|modelVersion|packaging)$/.test(elementPath)) {
|
|
24891
|
+
text[elementPath] = value2;
|
|
24892
|
+
}
|
|
24893
|
+
if (elementPath === "project/parent/groupId") text[elementPath] = value2;
|
|
24894
|
+
if (/^project\/(?:profiles\/profile\/)?(?:modules\/module|subprojects\/subproject)$/.test(
|
|
24895
|
+
elementPath
|
|
24896
|
+
)) {
|
|
24897
|
+
if (!value2 || value2.includes("${")) return null;
|
|
24898
|
+
modules.push(decodeEntities(value2));
|
|
24899
|
+
}
|
|
24900
|
+
stack.pop();
|
|
24901
|
+
} else {
|
|
24902
|
+
const elementPath = [...stack, name].join("/");
|
|
24903
|
+
if (elementPath === "project") {
|
|
24904
|
+
namespaceVersion = /xmlns\s*=\s*["']http:\/\/maven\.apache\.org\/POM\/(\d+\.\d+\.\d+)["']/.exec(
|
|
24905
|
+
attrs
|
|
24906
|
+
)?.[1] ?? null;
|
|
24907
|
+
}
|
|
24908
|
+
if (elementPath === "project/modules" || elementPath === "project/subprojects") {
|
|
24909
|
+
hasModuleList = true;
|
|
24910
|
+
}
|
|
24911
|
+
if (!selfClosing) stack.push(name);
|
|
24912
|
+
}
|
|
24913
|
+
lastEnd = start + whole.length;
|
|
24914
|
+
}
|
|
24915
|
+
if (stack.length > 0) return null;
|
|
24916
|
+
const modelVersion = text["project/modelVersion"] || namespaceVersion;
|
|
24917
|
+
const packaging = text["project/packaging"] || "jar";
|
|
24918
|
+
const aggregator = packaging === "pom" || packaging.includes("${");
|
|
24919
|
+
if (aggregator && !hasModuleList && modelVersion !== "4.0.0") return null;
|
|
24920
|
+
const value = (v2) => v2 ? decodeEntities(v2) : null;
|
|
24921
|
+
return {
|
|
24922
|
+
artifactId: value(text["project/artifactId"]),
|
|
24923
|
+
groupId: value(text["project/groupId"] ?? text["project/parent/groupId"]),
|
|
24924
|
+
modules
|
|
24925
|
+
};
|
|
24926
|
+
}
|
|
24927
|
+
function decodeEntities(s) {
|
|
24928
|
+
const codePoint = (n7, raw) => {
|
|
24929
|
+
try {
|
|
24930
|
+
return String.fromCodePoint(n7);
|
|
24931
|
+
} catch {
|
|
24932
|
+
return raw;
|
|
24933
|
+
}
|
|
24934
|
+
};
|
|
24935
|
+
return s.replace(/&#x([0-9a-fA-F]+);/g, (raw, h2) => codePoint(parseInt(h2, 16), raw)).replace(/&#(\d+);/g, (raw, d) => codePoint(Number(d), raw)).replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
24936
|
+
}
|
|
24937
|
+
function mavenSelectors(cmd) {
|
|
24938
|
+
const tokens = shellWords(cmd);
|
|
24939
|
+
if (!tokens || tokens.length === 0 || !MAVEN_HEAD.test(tokens[0])) return null;
|
|
24940
|
+
if (tokens.some((t2) => CONTINUATION.test(t2))) return null;
|
|
24941
|
+
const out = [];
|
|
24942
|
+
const addList = (option, value, isList) => {
|
|
24943
|
+
for (const raw of isList ? value.split(",") : [value]) {
|
|
24944
|
+
let sel = raw.trim();
|
|
24945
|
+
if (isList) sel = sel.replace(/^[!+-]/, "");
|
|
24946
|
+
if (!sel || sel.startsWith("?")) continue;
|
|
24947
|
+
const idPart = sel.slice(sel.lastIndexOf(":") + 1);
|
|
24948
|
+
if (PLACEHOLDER.test(sel) || PLACEHOLDER.test(idPart)) continue;
|
|
24949
|
+
out.push({ selector: sel, option });
|
|
24950
|
+
}
|
|
24951
|
+
};
|
|
24952
|
+
for (let i2 = 1; i2 < tokens.length; i2++) {
|
|
24953
|
+
const tok = tokens[i2];
|
|
24954
|
+
if (!tok.startsWith("-")) continue;
|
|
24955
|
+
const eq = tok.indexOf("=");
|
|
24956
|
+
const bare = eq > 0 && tok.startsWith("--") ? tok.slice(0, eq) : tok;
|
|
24957
|
+
if (RETARGET_OPTIONS2.has(bare)) return null;
|
|
24958
|
+
if (/^-f[^\w-]?.+/.test(tok) && !/^-(?:fae|ff|fn|fos)$/.test(tok)) return null;
|
|
24959
|
+
if (bare === "-pl" || bare === "--projects" || bare === "-rf" || bare === "--resume-from") {
|
|
24960
|
+
const isList = bare === "-pl" || bare === "--projects";
|
|
24961
|
+
const option = isList ? "-pl" : "-rf";
|
|
24962
|
+
if (eq > 0 && tok.startsWith("--")) {
|
|
24963
|
+
addList(option, tok.slice(eq + 1), isList);
|
|
24964
|
+
} else if (tokens[i2 + 1] !== void 0) {
|
|
24965
|
+
addList(option, tokens[++i2], isList);
|
|
24966
|
+
}
|
|
24967
|
+
continue;
|
|
24968
|
+
}
|
|
24969
|
+
if (VALUE_OPTIONS2.has(tok)) i2++;
|
|
24970
|
+
}
|
|
24971
|
+
return out;
|
|
24972
|
+
}
|
|
24973
|
+
function selectorMatches(selector, reactor, baseDir) {
|
|
24974
|
+
if (selector.includes(":")) {
|
|
24975
|
+
if (selector.startsWith(":")) {
|
|
24976
|
+
const artifactId2 = selector.slice(1);
|
|
24977
|
+
return reactor.some((p2) => templateMatches(p2.artifactId, artifactId2));
|
|
24978
|
+
}
|
|
24979
|
+
const [groupId, artifactId, ...rest] = selector.split(":");
|
|
24980
|
+
if (rest.length > 0) return true;
|
|
24981
|
+
return reactor.some(
|
|
24982
|
+
(p2) => templateMatches(p2.artifactId, artifactId) && templateMatches(p2.groupId, groupId)
|
|
24983
|
+
);
|
|
24984
|
+
}
|
|
24985
|
+
const target = realPath(path8.resolve(baseDir, selector));
|
|
24986
|
+
if (target === null) return false;
|
|
24987
|
+
if (fs7.statSync(target).isFile()) return reactor.some((p2) => samePath(p2.pomFile, target));
|
|
24988
|
+
return reactor.some((p2) => samePath(p2.basedir, target));
|
|
24989
|
+
}
|
|
24990
|
+
function templateMatches(template, value) {
|
|
24991
|
+
if (template === null) return true;
|
|
24992
|
+
if (!template.includes("${")) return template === value;
|
|
24993
|
+
const pattern = template.split(/\$\{[^}]*\}/).map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
24994
|
+
return new RegExp(`^${pattern}$`).test(value);
|
|
24995
|
+
}
|
|
24996
|
+
function samePath(a, b2) {
|
|
24997
|
+
return path8.resolve(a) === path8.resolve(b2);
|
|
24998
|
+
}
|
|
24999
|
+
function mavenBaseDirs(contextFile, projectRoot) {
|
|
25000
|
+
const root = path8.resolve(projectRoot);
|
|
25001
|
+
const dirs = [root];
|
|
25002
|
+
let dir = path8.dirname(path8.resolve(contextFile));
|
|
25003
|
+
for (; ; ) {
|
|
25004
|
+
const rel = path8.relative(root, dir);
|
|
25005
|
+
if (rel === "" || rel.startsWith("..") || path8.isAbsolute(rel)) break;
|
|
25006
|
+
if (fs7.existsSync(path8.join(dir, "pom.xml"))) dirs.push(dir);
|
|
25007
|
+
const parent = path8.dirname(dir);
|
|
25008
|
+
if (parent === dir) break;
|
|
25009
|
+
dir = parent;
|
|
25010
|
+
}
|
|
25011
|
+
return dirs;
|
|
25012
|
+
}
|
|
25013
|
+
var MAX_POMS, MAVEN_HEAD, VALUE_OPTIONS2, RETARGET_OPTIONS2, PLACEHOLDER;
|
|
25014
|
+
var init_maven_modules = __esm({
|
|
25015
|
+
"src/core/checks/maven-modules.ts"() {
|
|
25016
|
+
"use strict";
|
|
25017
|
+
init_define_WEB_FIRST_SEGMENTS();
|
|
25018
|
+
init_fs();
|
|
25019
|
+
init_gradle_projects();
|
|
25020
|
+
MAX_POMS = 2e4;
|
|
25021
|
+
MAVEN_HEAD = /^(?:\.[\\/])?mvnw(?:\.cmd)?$|^mvn(?:\.cmd)?$/;
|
|
25022
|
+
VALUE_OPTIONS2 = /* @__PURE__ */ new Set([
|
|
25023
|
+
"-D",
|
|
25024
|
+
"--define",
|
|
25025
|
+
"-P",
|
|
25026
|
+
"--activate-profiles",
|
|
25027
|
+
"-s",
|
|
25028
|
+
"--settings",
|
|
25029
|
+
"-gs",
|
|
25030
|
+
"--global-settings",
|
|
25031
|
+
"-t",
|
|
25032
|
+
"--toolchains",
|
|
25033
|
+
"-gt",
|
|
25034
|
+
"--global-toolchains",
|
|
25035
|
+
"-ps",
|
|
25036
|
+
"--project-settings",
|
|
25037
|
+
"-is",
|
|
25038
|
+
"--install-settings",
|
|
25039
|
+
"-it",
|
|
25040
|
+
"--install-toolchains",
|
|
25041
|
+
"-fos",
|
|
25042
|
+
"--fail-on-severity",
|
|
25043
|
+
"-l",
|
|
25044
|
+
"--log-file",
|
|
25045
|
+
"-T",
|
|
25046
|
+
"--threads",
|
|
25047
|
+
"-b",
|
|
25048
|
+
"--builder",
|
|
25049
|
+
"-canf",
|
|
25050
|
+
"--cache-artifact-not-found",
|
|
25051
|
+
"-sadp",
|
|
25052
|
+
"--strict-artifact-descriptor-policy"
|
|
25053
|
+
]);
|
|
25054
|
+
RETARGET_OPTIONS2 = /* @__PURE__ */ new Set(["-f", "--file", "-N", "--non-recursive", "-af", "--at-file"]);
|
|
25055
|
+
PLACEHOLDER = /[<>{}$*%[\]]|\.\.\.|^path\/to\/|^(?:module|project|submodule|component|feature)(?:[-_]?(?:name|path|id))?$|^(?:my|your|some|example|sample)[-_]|^(?:foo|bar|baz|xxx|name)$/i;
|
|
25056
|
+
}
|
|
25057
|
+
});
|
|
25058
|
+
|
|
24044
25059
|
// src/utils/markdown.ts
|
|
24045
25060
|
function inlineCodeSpans(line) {
|
|
24046
25061
|
const spans = [];
|
|
@@ -24116,8 +25131,8 @@ var init_markdown = __esm({
|
|
|
24116
25131
|
});
|
|
24117
25132
|
|
|
24118
25133
|
// src/core/checks/commands.ts
|
|
24119
|
-
import * as
|
|
24120
|
-
import * as
|
|
25134
|
+
import * as fs8 from "node:fs";
|
|
25135
|
+
import * as path9 from "node:path";
|
|
24121
25136
|
function isManagerBuiltin(manager, sub) {
|
|
24122
25137
|
return PM_MANAGER_BUILTINS[manager]?.has(sub) ?? false;
|
|
24123
25138
|
}
|
|
@@ -24158,7 +25173,7 @@ function loadDeniedCommandPrefixes(projectRoot) {
|
|
|
24158
25173
|
for (const rel of ["settings.json", "settings.local.json"]) {
|
|
24159
25174
|
let content;
|
|
24160
25175
|
try {
|
|
24161
|
-
content = stripBom(
|
|
25176
|
+
content = stripBom(fs8.readFileSync(path9.join(projectRoot, ".claude", rel), "utf-8"));
|
|
24162
25177
|
} catch {
|
|
24163
25178
|
continue;
|
|
24164
25179
|
}
|
|
@@ -24231,6 +25246,7 @@ async function checkCommands(file2, projectRoot) {
|
|
|
24231
25246
|
}
|
|
24232
25247
|
}
|
|
24233
25248
|
issues.push(...checkUnknownSubcommand(file2, projectRoot, pkgJson, deniedPrefixes, contentLines));
|
|
25249
|
+
const jvmCache = { gradle: /* @__PURE__ */ new Map(), maven: /* @__PURE__ */ new Map() };
|
|
24234
25250
|
for (const ref of file2.references.commands) {
|
|
24235
25251
|
if (inHtmlComment(ref.line, ref.column)) continue;
|
|
24236
25252
|
const cmd = ref.value;
|
|
@@ -24247,6 +25263,16 @@ async function checkCommands(file2, projectRoot) {
|
|
|
24247
25263
|
});
|
|
24248
25264
|
}
|
|
24249
25265
|
if (isDeniedCommand(cmd, deniedPrefixes) || isProhibitedRef(contentLines, ref)) continue;
|
|
25266
|
+
const gradleIssues = checkGradleProjects(file2, ref, projectRoot, jvmCache);
|
|
25267
|
+
if (gradleIssues) {
|
|
25268
|
+
issues.push(...gradleIssues);
|
|
25269
|
+
continue;
|
|
25270
|
+
}
|
|
25271
|
+
const mavenIssues = checkMavenModules(file2, ref, projectRoot, jvmCache);
|
|
25272
|
+
if (mavenIssues) {
|
|
25273
|
+
issues.push(...mavenIssues);
|
|
25274
|
+
continue;
|
|
25275
|
+
}
|
|
24250
25276
|
const scriptMatch = cmd.match(NPM_SCRIPT_PATTERN);
|
|
24251
25277
|
if (scriptMatch && pkgJson) {
|
|
24252
25278
|
const scriptName = scriptNameFromMatch(scriptMatch);
|
|
@@ -24289,9 +25315,9 @@ async function checkCommands(file2, projectRoot) {
|
|
|
24289
25315
|
...pkgJson.optionalDependencies
|
|
24290
25316
|
};
|
|
24291
25317
|
if (!(pkgName in allDeps)) {
|
|
24292
|
-
const binPath =
|
|
25318
|
+
const binPath = path9.join(projectRoot, "node_modules", ".bin", pkgName);
|
|
24293
25319
|
try {
|
|
24294
|
-
|
|
25320
|
+
fs8.accessSync(binPath);
|
|
24295
25321
|
} catch {
|
|
24296
25322
|
issues.push({
|
|
24297
25323
|
severity: "warning",
|
|
@@ -24339,9 +25365,9 @@ async function checkCommands(file2, projectRoot) {
|
|
|
24339
25365
|
...pkgJson.optionalDependencies
|
|
24340
25366
|
};
|
|
24341
25367
|
if (!(pkgName in allDeps)) {
|
|
24342
|
-
const binPath =
|
|
25368
|
+
const binPath = path9.join(projectRoot, "node_modules", ".bin", tool);
|
|
24343
25369
|
try {
|
|
24344
|
-
|
|
25370
|
+
fs8.accessSync(binPath);
|
|
24345
25371
|
} catch {
|
|
24346
25372
|
issues.push({
|
|
24347
25373
|
severity: "warning",
|
|
@@ -24385,9 +25411,117 @@ function checkUnknownSubcommand(file2, projectRoot, pkgJson, deniedPrefixes, con
|
|
|
24385
25411
|
}
|
|
24386
25412
|
return issues;
|
|
24387
25413
|
}
|
|
25414
|
+
function checkGradleProjects(file2, ref, projectRoot, cache2) {
|
|
25415
|
+
const refs = gradleProjectRefs(ref.value);
|
|
25416
|
+
if (refs === null) return null;
|
|
25417
|
+
if (refs.length === 0 || cdEarlierInFence(file2.content, ref.line)) return [];
|
|
25418
|
+
const wrapper = !/^gradle(?:\s|$)/.test(ref.value);
|
|
25419
|
+
const buildRoot = findGradleBuildRoot(file2.filePath, projectRoot, wrapper);
|
|
25420
|
+
if (!buildRoot) return [];
|
|
25421
|
+
if (!cache2.gradle.has(buildRoot)) cache2.gradle.set(buildRoot, readGradleProjectSet(buildRoot));
|
|
25422
|
+
const set2 = cache2.gradle.get(buildRoot);
|
|
25423
|
+
if (!set2) return [];
|
|
25424
|
+
const atBuildRoot = path9.resolve(path9.dirname(file2.filePath)) === path9.resolve(buildRoot);
|
|
25425
|
+
const issues = [];
|
|
25426
|
+
for (const projectRef of refs) {
|
|
25427
|
+
if (!projectRef.absolute && !atBuildRoot) continue;
|
|
25428
|
+
const missing = unresolvedGradleProject(projectRef, set2);
|
|
25429
|
+
if (!missing) continue;
|
|
25430
|
+
issues.push({
|
|
25431
|
+
severity: "error",
|
|
25432
|
+
check: "commands",
|
|
25433
|
+
ruleId: "commands/gradle-project-not-found",
|
|
25434
|
+
line: ref.line,
|
|
25435
|
+
message: `"${ref.value}" \u2014 project "${missing}" not found in ${set2.settingsFile}`,
|
|
25436
|
+
suggestion: closestSuggestion(missing, [...set2.paths])
|
|
25437
|
+
});
|
|
25438
|
+
}
|
|
25439
|
+
return issues;
|
|
25440
|
+
}
|
|
25441
|
+
function checkMavenModules(file2, ref, projectRoot, cache2) {
|
|
25442
|
+
const selectors = mavenSelectors(ref.value);
|
|
25443
|
+
if (selectors === null) return null;
|
|
25444
|
+
if (selectors.length === 0 || cdEarlierInFence(file2.content, ref.line)) return [];
|
|
25445
|
+
const bases = [];
|
|
25446
|
+
for (const dir of mavenBaseDirs(file2.filePath, projectRoot)) {
|
|
25447
|
+
if (!fs8.existsSync(path9.join(dir, "pom.xml"))) continue;
|
|
25448
|
+
if (mavenConfigRetargets(dir)) return [];
|
|
25449
|
+
if (!cache2.maven.has(dir)) cache2.maven.set(dir, readMavenReactor(dir));
|
|
25450
|
+
const reactor = cache2.maven.get(dir);
|
|
25451
|
+
if (!reactor) return [];
|
|
25452
|
+
bases.push({ dir, reactor });
|
|
25453
|
+
}
|
|
25454
|
+
if (bases.length === 0) return [];
|
|
25455
|
+
const issues = [];
|
|
25456
|
+
for (const { selector, option } of selectors) {
|
|
25457
|
+
const allProjects = bases.flatMap((b2) => b2.reactor);
|
|
25458
|
+
if (bases.some((b2) => selectorMatches(selector, allProjects, b2.dir))) continue;
|
|
25459
|
+
if (!selector.includes(":") && bases.every((b2) => outside(projectRoot, b2.dir, selector))) {
|
|
25460
|
+
continue;
|
|
25461
|
+
}
|
|
25462
|
+
const known = bases[0].reactor.flatMap((p2) => [
|
|
25463
|
+
path9.relative(bases[0].dir, p2.basedir).replace(/\\/g, "/"),
|
|
25464
|
+
...p2.artifactId && !p2.artifactId.includes("${") ? [`:${p2.artifactId}`] : []
|
|
25465
|
+
]);
|
|
25466
|
+
issues.push({
|
|
25467
|
+
severity: "error",
|
|
25468
|
+
check: "commands",
|
|
25469
|
+
ruleId: "commands/maven-module-not-found",
|
|
25470
|
+
line: ref.line,
|
|
25471
|
+
message: `"${ref.value}" \u2014 ${option} "${selector}" matches no module in the Maven reactor`,
|
|
25472
|
+
suggestion: closestSuggestion(selector, known.filter(Boolean))
|
|
25473
|
+
});
|
|
25474
|
+
}
|
|
25475
|
+
return issues;
|
|
25476
|
+
}
|
|
25477
|
+
function cdEarlierInFence(content, line) {
|
|
25478
|
+
const lines = content.split("\n");
|
|
25479
|
+
const idx = line - 1;
|
|
25480
|
+
const changesDir = (text) => /(?:^|[\s;&|(])(?:cd|pushd)(?:\s|$)/.test(text);
|
|
25481
|
+
let fenceStart = -1;
|
|
25482
|
+
for (let i2 = 0; i2 < idx && i2 < lines.length; i2++) {
|
|
25483
|
+
if (/^\s*```/.test(lines[i2])) fenceStart = fenceStart < 0 ? i2 + 1 : -1;
|
|
25484
|
+
}
|
|
25485
|
+
if (fenceStart >= 0) {
|
|
25486
|
+
for (let i2 = fenceStart; i2 < idx; i2++) if (changesDir(lines[i2])) return true;
|
|
25487
|
+
return false;
|
|
25488
|
+
}
|
|
25489
|
+
for (let i2 = idx - 1; i2 >= 0 && /^\s*[$>]\s+\S/.test(lines[i2]); i2--) {
|
|
25490
|
+
if (changesDir(lines[i2].replace(/^\s*[$>]\s+/, ""))) return true;
|
|
25491
|
+
}
|
|
25492
|
+
return false;
|
|
25493
|
+
}
|
|
25494
|
+
function outside(projectRoot, base, selector) {
|
|
25495
|
+
const rel = path9.relative(path9.resolve(projectRoot), path9.resolve(base, selector));
|
|
25496
|
+
return rel.startsWith("..") || path9.isAbsolute(rel);
|
|
25497
|
+
}
|
|
25498
|
+
function mavenConfigRetargets(dir) {
|
|
25499
|
+
try {
|
|
25500
|
+
const config2 = fs8.readFileSync(path9.join(dir, ".mvn", "maven.config"), "utf-8");
|
|
25501
|
+
return /(?:^|\s)(?:-f(?!(?:ae|f|n|os)(?:\s|$))|--file|-pl|--projects|-N|--non-recursive)/.test(
|
|
25502
|
+
config2
|
|
25503
|
+
);
|
|
25504
|
+
} catch {
|
|
25505
|
+
return false;
|
|
25506
|
+
}
|
|
25507
|
+
}
|
|
25508
|
+
function closestSuggestion(target, candidates) {
|
|
25509
|
+
let best;
|
|
25510
|
+
let bestDist = Infinity;
|
|
25511
|
+
for (const c3 of candidates) {
|
|
25512
|
+
const d = levenshtein2(target.toLowerCase(), c3.toLowerCase());
|
|
25513
|
+
if (d < bestDist) {
|
|
25514
|
+
bestDist = d;
|
|
25515
|
+
best = c3;
|
|
25516
|
+
}
|
|
25517
|
+
}
|
|
25518
|
+
if (best === void 0 || bestDist > Math.max(2, Math.floor(target.length * 0.3)))
|
|
25519
|
+
return void 0;
|
|
25520
|
+
return `Did you mean "${best}"?`;
|
|
25521
|
+
}
|
|
24388
25522
|
function loadMakefile(projectRoot) {
|
|
24389
25523
|
try {
|
|
24390
|
-
return stripBom(
|
|
25524
|
+
return stripBom(fs8.readFileSync(path9.join(projectRoot, "Makefile"), "utf-8"));
|
|
24391
25525
|
} catch {
|
|
24392
25526
|
return null;
|
|
24393
25527
|
}
|
|
@@ -24405,16 +25539,20 @@ function hasMakeTarget(makefile, target) {
|
|
|
24405
25539
|
const pattern = new RegExp(`^${escaped}\\s*:(?!:?=)`, "m");
|
|
24406
25540
|
return pattern.test(makefile);
|
|
24407
25541
|
}
|
|
24408
|
-
var NPM_SCRIPT_PATTERN, MAKE_PATTERN, PM_BUILTIN_SUBCOMMANDS, PM_MANAGER_BUILTINS, PKG_DEPENDENT_TOOL_PATTERN, BIN_TO_PACKAGE, PKG_SHORTHAND_PATTERN, PROHIBITION_TOKEN, CLAUSE_TERMINATOR, RECOMMENDATION_VERB;
|
|
25542
|
+
var import_fast_levenshtein2, levenshtein2, NPM_SCRIPT_PATTERN, MAKE_PATTERN, PM_BUILTIN_SUBCOMMANDS, PM_MANAGER_BUILTINS, PKG_DEPENDENT_TOOL_PATTERN, BIN_TO_PACKAGE, PKG_SHORTHAND_PATTERN, PROHIBITION_TOKEN, CLAUSE_TERMINATOR, RECOMMENDATION_VERB;
|
|
24409
25543
|
var init_commands = __esm({
|
|
24410
25544
|
"src/core/checks/commands.ts"() {
|
|
24411
25545
|
"use strict";
|
|
24412
25546
|
init_define_WEB_FIRST_SEGMENTS();
|
|
24413
25547
|
init_main3();
|
|
25548
|
+
import_fast_levenshtein2 = __toESM(require_levenshtein(), 1);
|
|
24414
25549
|
init_fs();
|
|
24415
25550
|
init_exit_status();
|
|
24416
25551
|
init_cli_subcommands();
|
|
25552
|
+
init_gradle_projects();
|
|
25553
|
+
init_maven_modules();
|
|
24417
25554
|
init_markdown();
|
|
25555
|
+
levenshtein2 = import_fast_levenshtein2.default.get;
|
|
24418
25556
|
NPM_SCRIPT_PATTERN = /^(?:npm\s+run|(pnpm|yarn|bun)(?:\s+(run))?)\s+(\S+)/;
|
|
24419
25557
|
MAKE_PATTERN = /^make\s+\S/;
|
|
24420
25558
|
PM_BUILTIN_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
@@ -24491,13 +25629,13 @@ var init_commands = __esm({
|
|
|
24491
25629
|
});
|
|
24492
25630
|
|
|
24493
25631
|
// src/core/checks/staleness.ts
|
|
24494
|
-
import * as
|
|
25632
|
+
import * as path10 from "node:path";
|
|
24495
25633
|
async function checkStaleness(file2, projectRoot) {
|
|
24496
25634
|
const issues = [];
|
|
24497
25635
|
if (!await isGitRepo(projectRoot)) {
|
|
24498
25636
|
return issues;
|
|
24499
25637
|
}
|
|
24500
|
-
const relativePath =
|
|
25638
|
+
const relativePath = path10.relative(projectRoot, file2.filePath).replace(/\\/g, "/");
|
|
24501
25639
|
const lastModified = await getFileLastModified(projectRoot, relativePath);
|
|
24502
25640
|
if (!lastModified || isNaN(lastModified.getTime())) {
|
|
24503
25641
|
return issues;
|
|
@@ -24688,9 +25826,9 @@ var init_tokens2 = __esm({
|
|
|
24688
25826
|
});
|
|
24689
25827
|
|
|
24690
25828
|
// src/core/checks/tier-tokens.ts
|
|
24691
|
-
import * as
|
|
25829
|
+
import * as fs9 from "node:fs";
|
|
24692
25830
|
import * as os2 from "node:os";
|
|
24693
|
-
import * as
|
|
25831
|
+
import * as path11 from "node:path";
|
|
24694
25832
|
function hasFrontmatterList(content, field) {
|
|
24695
25833
|
const lines = content.split("\n");
|
|
24696
25834
|
if (lines[0]?.trim() !== "---") return false;
|
|
@@ -24778,7 +25916,7 @@ function findInviolableCommand(line) {
|
|
|
24778
25916
|
function fingerprintFiles(paths) {
|
|
24779
25917
|
return paths.map((p2) => {
|
|
24780
25918
|
try {
|
|
24781
|
-
const st2 =
|
|
25919
|
+
const st2 = fs9.statSync(p2);
|
|
24782
25920
|
return `${st2.mtimeMs}:${st2.size}`;
|
|
24783
25921
|
} catch {
|
|
24784
25922
|
return "absent";
|
|
@@ -24787,11 +25925,11 @@ function fingerprintFiles(paths) {
|
|
|
24787
25925
|
}
|
|
24788
25926
|
function loadSettingsSources(projectRoot, includeGlobal) {
|
|
24789
25927
|
const candidates = [
|
|
24790
|
-
|
|
24791
|
-
|
|
25928
|
+
path11.join(projectRoot, ".claude", "settings.json"),
|
|
25929
|
+
path11.join(projectRoot, ".claude", "settings.local.json")
|
|
24792
25930
|
];
|
|
24793
25931
|
if (includeGlobal) {
|
|
24794
|
-
candidates.push(
|
|
25932
|
+
candidates.push(path11.join(os2.homedir(), ".claude", "settings.json"));
|
|
24795
25933
|
}
|
|
24796
25934
|
const fingerprint = fingerprintFiles(candidates);
|
|
24797
25935
|
if (settingsCache?.root === projectRoot && settingsCache.includeGlobal === includeGlobal && settingsCache.fingerprint === fingerprint) {
|
|
@@ -24801,7 +25939,7 @@ function loadSettingsSources(projectRoot, includeGlobal) {
|
|
|
24801
25939
|
for (const p2 of candidates) {
|
|
24802
25940
|
let content;
|
|
24803
25941
|
try {
|
|
24804
|
-
content = stripBom(
|
|
25942
|
+
content = stripBom(fs9.readFileSync(p2, "utf-8"));
|
|
24805
25943
|
} catch {
|
|
24806
25944
|
continue;
|
|
24807
25945
|
}
|
|
@@ -24979,7 +26117,7 @@ var init_similarity = __esm({
|
|
|
24979
26117
|
});
|
|
24980
26118
|
|
|
24981
26119
|
// src/core/checks/redundancy.ts
|
|
24982
|
-
import * as
|
|
26120
|
+
import * as path12 from "node:path";
|
|
24983
26121
|
function compilePatterns(allDeps) {
|
|
24984
26122
|
const compiled = [];
|
|
24985
26123
|
for (const [pkg, mentions] of Object.entries(PACKAGE_TECH_MAP)) {
|
|
@@ -25059,8 +26197,8 @@ async function checkRedundancy(file2, projectRoot) {
|
|
|
25059
26197
|
);
|
|
25060
26198
|
if (dirMatch) {
|
|
25061
26199
|
const dir = dirMatch[1].replace(/[`"]/g, "");
|
|
25062
|
-
const baseDir = dir.startsWith("./") || dir.startsWith("../") ?
|
|
25063
|
-
const fullPath =
|
|
26200
|
+
const baseDir = dir.startsWith("./") || dir.startsWith("../") ? path12.dirname(file2.filePath) : projectRoot;
|
|
26201
|
+
const fullPath = path12.resolve(baseDir, dir);
|
|
25064
26202
|
if (isDirectory(fullPath)) {
|
|
25065
26203
|
issues.push({
|
|
25066
26204
|
severity: "info",
|
|
@@ -26088,8 +27226,8 @@ var init_security = __esm({
|
|
|
26088
27226
|
});
|
|
26089
27227
|
|
|
26090
27228
|
// src/core/checks/mcp/commands.ts
|
|
26091
|
-
import * as
|
|
26092
|
-
import * as
|
|
27229
|
+
import * as fs10 from "node:fs";
|
|
27230
|
+
import * as path13 from "node:path";
|
|
26093
27231
|
async function checkMcpCommands(config2, projectRoot) {
|
|
26094
27232
|
const issues = [];
|
|
26095
27233
|
if (config2.parseErrors.length > 0) return issues;
|
|
@@ -26106,7 +27244,7 @@ async function checkMcpCommands(config2, projectRoot) {
|
|
|
26106
27244
|
});
|
|
26107
27245
|
}
|
|
26108
27246
|
if (config2.scope === "project" && LOCAL_PATH_PATTERN.test(server2.command)) {
|
|
26109
|
-
const resolved =
|
|
27247
|
+
const resolved = path13.resolve(projectRoot, server2.command);
|
|
26110
27248
|
if (!fileExistsSafe(resolved)) {
|
|
26111
27249
|
issues.push({
|
|
26112
27250
|
severity: "warning",
|
|
@@ -26121,8 +27259,8 @@ async function checkMcpCommands(config2, projectRoot) {
|
|
|
26121
27259
|
for (const arg of server2.args) {
|
|
26122
27260
|
if (URL_PREFIX.test(arg)) continue;
|
|
26123
27261
|
if (!LOCAL_PATH_PATTERN.test(arg) && !FILE_PATH_PATTERN.test(arg)) continue;
|
|
26124
|
-
if (config2.scope !== "project" && !
|
|
26125
|
-
const resolved =
|
|
27262
|
+
if (config2.scope !== "project" && !path13.isAbsolute(arg)) continue;
|
|
27263
|
+
const resolved = path13.resolve(projectRoot, arg);
|
|
26126
27264
|
if (!fileExistsSafe(resolved)) {
|
|
26127
27265
|
issues.push({
|
|
26128
27266
|
severity: "warning",
|
|
@@ -26139,7 +27277,7 @@ async function checkMcpCommands(config2, projectRoot) {
|
|
|
26139
27277
|
}
|
|
26140
27278
|
function fileExistsSafe(filePath) {
|
|
26141
27279
|
try {
|
|
26142
|
-
|
|
27280
|
+
fs10.accessSync(filePath);
|
|
26143
27281
|
return true;
|
|
26144
27282
|
} catch {
|
|
26145
27283
|
return false;
|
|
@@ -26570,16 +27708,16 @@ var init_redundancy2 = __esm({
|
|
|
26570
27708
|
|
|
26571
27709
|
// src/core/session-parser.ts
|
|
26572
27710
|
import { readFile } from "node:fs/promises";
|
|
26573
|
-
import { readFileSync as
|
|
26574
|
-
import { dirname as
|
|
27711
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
27712
|
+
import { dirname as dirname7, resolve as resolve10 } from "node:path";
|
|
26575
27713
|
import { fileURLToPath } from "node:url";
|
|
26576
27714
|
function loadWebFirstSegments() {
|
|
26577
27715
|
if (typeof define_WEB_FIRST_SEGMENTS_default !== "undefined") {
|
|
26578
27716
|
return new Set(define_WEB_FIRST_SEGMENTS_default);
|
|
26579
27717
|
}
|
|
26580
|
-
const __dir =
|
|
26581
|
-
const fixturePath =
|
|
26582
|
-
const raw = JSON.parse(
|
|
27718
|
+
const __dir = dirname7(fileURLToPath(import.meta.url));
|
|
27719
|
+
const fixturePath = resolve10(__dir, "../../tests/fixtures/web-first-segments.json");
|
|
27720
|
+
const raw = JSON.parse(readFileSync7(fixturePath, "utf-8"));
|
|
26583
27721
|
const list = Array.isArray(raw) ? raw : raw.segments;
|
|
26584
27722
|
return new Set(list);
|
|
26585
27723
|
}
|
|
@@ -26701,14 +27839,14 @@ import { readdir, stat } from "node:fs/promises";
|
|
|
26701
27839
|
import { createReadStream } from "node:fs";
|
|
26702
27840
|
import { homedir as homedir3 } from "node:os";
|
|
26703
27841
|
import { createInterface } from "node:readline";
|
|
26704
|
-
import { dirname as
|
|
26705
|
-
import { existsSync } from "node:fs";
|
|
27842
|
+
import { dirname as dirname8, join as join7, resolve as resolve11 } from "node:path";
|
|
27843
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
26706
27844
|
function detectProviders() {
|
|
26707
27845
|
if (!home) return [];
|
|
26708
|
-
return AGENT_DIRS.filter((a) =>
|
|
27846
|
+
return AGENT_DIRS.filter((a) => existsSync4(a.dir)).map((a) => a.provider);
|
|
26709
27847
|
}
|
|
26710
27848
|
async function parseJsonlFiltered(filePath, filter) {
|
|
26711
|
-
if (!
|
|
27849
|
+
if (!existsSync4(filePath)) return [];
|
|
26712
27850
|
const results = [];
|
|
26713
27851
|
const rl = createInterface({
|
|
26714
27852
|
input: createReadStream(filePath, { encoding: "utf-8" }),
|
|
@@ -26755,7 +27893,7 @@ async function readJsonlHistory(opts) {
|
|
|
26755
27893
|
}
|
|
26756
27894
|
function agentHistoryPath(provider) {
|
|
26757
27895
|
const agent = AGENT_DIRS.find((a) => a.provider === provider);
|
|
26758
|
-
return agent?.historyFile ?
|
|
27896
|
+
return agent?.historyFile ? join7(agent.dir, agent.historyFile) : "";
|
|
26759
27897
|
}
|
|
26760
27898
|
async function readClaudeHistory() {
|
|
26761
27899
|
return readJsonlHistory({
|
|
@@ -26776,18 +27914,18 @@ async function readCodexHistory() {
|
|
|
26776
27914
|
});
|
|
26777
27915
|
}
|
|
26778
27916
|
async function readClaudeMemories() {
|
|
26779
|
-
const projectsDir =
|
|
26780
|
-
if (!
|
|
27917
|
+
const projectsDir = join7(home, ".claude", "projects");
|
|
27918
|
+
if (!existsSync4(projectsDir)) return [];
|
|
26781
27919
|
const memories = [];
|
|
26782
27920
|
const projectDirs = await readdir(projectsDir).catch(() => []);
|
|
26783
27921
|
for (const projDir of projectDirs) {
|
|
26784
|
-
const memoryDir =
|
|
26785
|
-
if (!
|
|
27922
|
+
const memoryDir = join7(projectsDir, projDir, "memory");
|
|
27923
|
+
if (!existsSync4(memoryDir)) continue;
|
|
26786
27924
|
const files = await readdir(memoryDir).catch(() => []);
|
|
26787
27925
|
for (const file2 of files) {
|
|
26788
27926
|
if (!file2.endsWith(".md") || file2 === "MEMORY.md") continue;
|
|
26789
27927
|
try {
|
|
26790
|
-
const entry = await parseMemoryFile(
|
|
27928
|
+
const entry = await parseMemoryFile(join7(memoryDir, file2), projDir);
|
|
26791
27929
|
memories.push(entry);
|
|
26792
27930
|
} catch {
|
|
26793
27931
|
}
|
|
@@ -26797,7 +27935,7 @@ async function readClaudeMemories() {
|
|
|
26797
27935
|
}
|
|
26798
27936
|
function detectAiderInSiblings(siblings) {
|
|
26799
27937
|
for (const sib of siblings) {
|
|
26800
|
-
if (
|
|
27938
|
+
if (existsSync4(join7(sib.path, ".aider.chat.history.md"))) {
|
|
26801
27939
|
return "aider";
|
|
26802
27940
|
}
|
|
26803
27941
|
}
|
|
@@ -26816,7 +27954,7 @@ async function mapWithConcurrency(items, limit, fn) {
|
|
|
26816
27954
|
return results;
|
|
26817
27955
|
}
|
|
26818
27956
|
async function detectSiblings(projectRoot) {
|
|
26819
|
-
const parentDir =
|
|
27957
|
+
const parentDir = dirname8(resolve11(projectRoot));
|
|
26820
27958
|
let entries;
|
|
26821
27959
|
try {
|
|
26822
27960
|
entries = await readdir(parentDir);
|
|
@@ -26826,16 +27964,16 @@ async function detectSiblings(projectRoot) {
|
|
|
26826
27964
|
const candidates = [];
|
|
26827
27965
|
for (const entry of entries) {
|
|
26828
27966
|
if (entry.startsWith(".") || entry === "node_modules") continue;
|
|
26829
|
-
const fullPath =
|
|
26830
|
-
const entryPath =
|
|
26831
|
-
if (entryPath ===
|
|
27967
|
+
const fullPath = join7(parentDir, entry);
|
|
27968
|
+
const entryPath = resolve11(fullPath);
|
|
27969
|
+
if (entryPath === resolve11(projectRoot)) continue;
|
|
26832
27970
|
try {
|
|
26833
27971
|
const s = await stat(fullPath);
|
|
26834
27972
|
if (!s.isDirectory()) continue;
|
|
26835
27973
|
} catch {
|
|
26836
27974
|
continue;
|
|
26837
27975
|
}
|
|
26838
|
-
const isProject =
|
|
27976
|
+
const isProject = existsSync4(join7(fullPath, ".git")) || existsSync4(join7(fullPath, "package.json")) || existsSync4(join7(fullPath, "Cargo.toml")) || existsSync4(join7(fullPath, "go.mod")) || existsSync4(join7(fullPath, "pyproject.toml"));
|
|
26839
27977
|
if (!isProject) continue;
|
|
26840
27978
|
candidates.push({ fullPath, entryPath, name: entry });
|
|
26841
27979
|
}
|
|
@@ -26863,7 +28001,7 @@ async function detectSiblings(projectRoot) {
|
|
|
26863
28001
|
}
|
|
26864
28002
|
async function resolveSibling(c3) {
|
|
26865
28003
|
const sibling = { path: c3.entryPath.replace(/\\/g, "/"), name: c3.name };
|
|
26866
|
-
if (!
|
|
28004
|
+
if (!existsSync4(join7(c3.fullPath, ".git"))) return sibling;
|
|
26867
28005
|
try {
|
|
26868
28006
|
const git = simpleGit(c3.fullPath);
|
|
26869
28007
|
const remotes = await git.getRemotes(true);
|
|
@@ -26895,7 +28033,7 @@ async function scanSessionData(projectRoot) {
|
|
|
26895
28033
|
history: histories,
|
|
26896
28034
|
memories,
|
|
26897
28035
|
siblings,
|
|
26898
|
-
currentProject:
|
|
28036
|
+
currentProject: resolve11(projectRoot).replace(/\\/g, "/"),
|
|
26899
28037
|
providers
|
|
26900
28038
|
};
|
|
26901
28039
|
}
|
|
@@ -26909,12 +28047,12 @@ var init_session_scanner = __esm({
|
|
|
26909
28047
|
init_fs();
|
|
26910
28048
|
home = process.env.HOME || process.env.USERPROFILE || homedir3();
|
|
26911
28049
|
AGENT_DIRS = [
|
|
26912
|
-
{ provider: "claude-code", dir:
|
|
26913
|
-
{ provider: "codex-cli", dir:
|
|
26914
|
-
{ provider: "vibe-cli", dir:
|
|
28050
|
+
{ provider: "claude-code", dir: join7(home, ".claude"), historyFile: "history.jsonl" },
|
|
28051
|
+
{ provider: "codex-cli", dir: join7(home, ".codex"), historyFile: "history.jsonl" },
|
|
28052
|
+
{ provider: "vibe-cli", dir: join7(home, ".vibe") },
|
|
26915
28053
|
{
|
|
26916
28054
|
provider: "amazon-q",
|
|
26917
|
-
dir:
|
|
28055
|
+
dir: join7(home, ".aws", "amazonq")
|
|
26918
28056
|
},
|
|
26919
28057
|
{
|
|
26920
28058
|
provider: "goose",
|
|
@@ -26923,12 +28061,12 @@ var init_session_scanner = __esm({
|
|
|
26923
28061
|
// which the HOME guard in `detectProviders` does NOT catch (HOME/USERPROFILE
|
|
26924
28062
|
// may still be set). Leave the dir empty so `existsSync('')` is always false
|
|
26925
28063
|
// and we never match a cwd-relative `Block/goose`, mirroring the HOME-guard intent.
|
|
26926
|
-
dir: process.platform === "win32" ? process.env.APPDATA ?
|
|
28064
|
+
dir: process.platform === "win32" ? process.env.APPDATA ? join7(process.env.APPDATA, "Block", "goose") : "" : join7(home, ".config", "goose")
|
|
26927
28065
|
},
|
|
26928
|
-
{ provider: "continue", dir:
|
|
28066
|
+
{ provider: "continue", dir: join7(home, ".continue") },
|
|
26929
28067
|
{
|
|
26930
28068
|
provider: "windsurf",
|
|
26931
|
-
dir:
|
|
28069
|
+
dir: join7(home, ".windsurf")
|
|
26932
28070
|
}
|
|
26933
28071
|
];
|
|
26934
28072
|
SIBLING_RESOLVE_CONCURRENCY = 8;
|
|
@@ -26936,9 +28074,9 @@ var init_session_scanner = __esm({
|
|
|
26936
28074
|
});
|
|
26937
28075
|
|
|
26938
28076
|
// src/core/checks/session/missing-secret.ts
|
|
26939
|
-
import { resolve as
|
|
28077
|
+
import { resolve as resolve12, basename as basename3 } from "node:path";
|
|
26940
28078
|
function normalizePath2(p2) {
|
|
26941
|
-
return
|
|
28079
|
+
return resolve12(p2).replace(/\\/g, "/").toLowerCase();
|
|
26942
28080
|
}
|
|
26943
28081
|
function extractSecretName(display) {
|
|
26944
28082
|
const prefixMatch = display.match(SECRET_SET_PREFIX);
|
|
@@ -26951,9 +28089,9 @@ function extractSecretName(display) {
|
|
|
26951
28089
|
if (VALUE_FLAGS.has(tok) && !tok.includes("=")) {
|
|
26952
28090
|
i2++;
|
|
26953
28091
|
const val = tokens[i2];
|
|
26954
|
-
const
|
|
26955
|
-
if (
|
|
26956
|
-
while (i2 + 1 < tokens.length && !tokens[i2].endsWith(
|
|
28092
|
+
const quote2 = val && (val[0] === '"' || val[0] === "'") ? val[0] : void 0;
|
|
28093
|
+
if (quote2 && !(val.length > 1 && val.endsWith(quote2))) {
|
|
28094
|
+
while (i2 + 1 < tokens.length && !tokens[i2].endsWith(quote2)) i2++;
|
|
26957
28095
|
}
|
|
26958
28096
|
}
|
|
26959
28097
|
}
|
|
@@ -27056,8 +28194,8 @@ var init_missing_secret = __esm({
|
|
|
27056
28194
|
|
|
27057
28195
|
// src/core/checks/session/diverged-file.ts
|
|
27058
28196
|
import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
27059
|
-
import { join as
|
|
27060
|
-
import { existsSync as
|
|
28197
|
+
import { join as join8, resolve as resolve13 } from "node:path";
|
|
28198
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
27061
28199
|
async function loadLineSet(absPath) {
|
|
27062
28200
|
let mtimeMs;
|
|
27063
28201
|
let size;
|
|
@@ -27091,14 +28229,14 @@ async function loadLineSet(absPath) {
|
|
|
27091
28229
|
async function checkDivergedFile(ctx) {
|
|
27092
28230
|
const issues = [];
|
|
27093
28231
|
for (const fileName of CANONICAL_FILES) {
|
|
27094
|
-
const currentPath =
|
|
27095
|
-
if (!
|
|
28232
|
+
const currentPath = join8(ctx.currentProject, fileName);
|
|
28233
|
+
if (!existsSync5(currentPath)) continue;
|
|
27096
28234
|
const currentLineSet = await loadLineSet(currentPath);
|
|
27097
28235
|
if (!currentLineSet) continue;
|
|
27098
28236
|
const diverged = [];
|
|
27099
28237
|
for (const sib of ctx.siblings) {
|
|
27100
|
-
const sibPath =
|
|
27101
|
-
if (!
|
|
28238
|
+
const sibPath = join8(sib.path, fileName);
|
|
28239
|
+
if (!existsSync5(sibPath)) continue;
|
|
27102
28240
|
const sibLineSet = await loadLineSet(sibPath);
|
|
27103
28241
|
if (!sibLineSet) continue;
|
|
27104
28242
|
const overlap = jaccardSimilarityFromSets(currentLineSet, sibLineSet, {
|
|
@@ -27108,7 +28246,7 @@ async function checkDivergedFile(ctx) {
|
|
|
27108
28246
|
diverged.push({
|
|
27109
28247
|
sibling: sib.name,
|
|
27110
28248
|
overlap: Math.round(overlap * 100),
|
|
27111
|
-
path:
|
|
28249
|
+
path: resolve13(sibPath)
|
|
27112
28250
|
});
|
|
27113
28251
|
}
|
|
27114
28252
|
}
|
|
@@ -27123,7 +28261,7 @@ async function checkDivergedFile(ctx) {
|
|
|
27123
28261
|
line: 0,
|
|
27124
28262
|
message: `${fileName} has diverged from sibling repos: ${details}`,
|
|
27125
28263
|
suggestion: `Compare with sibling versions to identify unintentional drift`,
|
|
27126
|
-
detail: `File: ${
|
|
28264
|
+
detail: `File: ${resolve13(currentPath)}
|
|
27127
28265
|
Diverged siblings:
|
|
27128
28266
|
${sibPaths}`
|
|
27129
28267
|
});
|
|
@@ -27156,14 +28294,14 @@ var init_diverged_file = __esm({
|
|
|
27156
28294
|
|
|
27157
28295
|
// src/core/checks/session/missing-workflow.ts
|
|
27158
28296
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
27159
|
-
import { join as
|
|
27160
|
-
import { existsSync as
|
|
28297
|
+
import { join as join9 } from "node:path";
|
|
28298
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
27161
28299
|
async function checkMissingWorkflow(ctx) {
|
|
27162
28300
|
const issues = [];
|
|
27163
|
-
const currentWorkflowDir =
|
|
27164
|
-
if (!
|
|
28301
|
+
const currentWorkflowDir = join9(ctx.currentProject, ".github", "workflows");
|
|
28302
|
+
if (!existsSync6(join9(ctx.currentProject, ".github"))) return issues;
|
|
27165
28303
|
const currentWorkflows = /* @__PURE__ */ new Set();
|
|
27166
|
-
if (
|
|
28304
|
+
if (existsSync6(currentWorkflowDir)) {
|
|
27167
28305
|
try {
|
|
27168
28306
|
const files = await readdir2(currentWorkflowDir);
|
|
27169
28307
|
for (const f of files) {
|
|
@@ -27174,8 +28312,8 @@ async function checkMissingWorkflow(ctx) {
|
|
|
27174
28312
|
}
|
|
27175
28313
|
const workflowMap = /* @__PURE__ */ new Map();
|
|
27176
28314
|
for (const sib of ctx.siblings) {
|
|
27177
|
-
const sibWorkflowDir =
|
|
27178
|
-
if (!
|
|
28315
|
+
const sibWorkflowDir = join9(sib.path, ".github", "workflows");
|
|
28316
|
+
if (!existsSync6(sibWorkflowDir)) continue;
|
|
27179
28317
|
try {
|
|
27180
28318
|
const files = await readdir2(sibWorkflowDir);
|
|
27181
28319
|
for (const f of files) {
|
|
@@ -27211,17 +28349,17 @@ var init_missing_workflow = __esm({
|
|
|
27211
28349
|
});
|
|
27212
28350
|
|
|
27213
28351
|
// src/core/checks/session/stale-memory.ts
|
|
27214
|
-
import { existsSync as
|
|
28352
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
27215
28353
|
import { homedir as homedir4 } from "node:os";
|
|
27216
|
-
import { resolve as
|
|
28354
|
+
import { resolve as resolve14, isAbsolute as isAbsolute8 } from "node:path";
|
|
27217
28355
|
function resolveRef(ref, projectRoot) {
|
|
27218
28356
|
if (ref.startsWith("~/") || ref === "~") {
|
|
27219
28357
|
const home2 = process.env.HOME || process.env.USERPROFILE || homedir4();
|
|
27220
28358
|
if (!home2) return null;
|
|
27221
|
-
return ref === "~" ? home2 :
|
|
28359
|
+
return ref === "~" ? home2 : resolve14(home2, ref.slice(2));
|
|
27222
28360
|
}
|
|
27223
|
-
if (
|
|
27224
|
-
return
|
|
28361
|
+
if (isAbsolute8(ref)) return ref;
|
|
28362
|
+
return resolve14(projectRoot, ref);
|
|
27225
28363
|
}
|
|
27226
28364
|
async function checkStaleMemory(ctx) {
|
|
27227
28365
|
const issues = [];
|
|
@@ -27233,7 +28371,7 @@ async function checkStaleMemory(ctx) {
|
|
|
27233
28371
|
for (const ref of mem.referencedPaths) {
|
|
27234
28372
|
const fullPath = resolveRef(ref, ctx.currentProject);
|
|
27235
28373
|
if (!fullPath) continue;
|
|
27236
|
-
if (!
|
|
28374
|
+
if (!existsSync7(fullPath)) {
|
|
27237
28375
|
brokenPaths.push(ref);
|
|
27238
28376
|
}
|
|
27239
28377
|
}
|
|
@@ -27318,9 +28456,9 @@ var init_duplicate_memory = __esm({
|
|
|
27318
28456
|
});
|
|
27319
28457
|
|
|
27320
28458
|
// src/core/checks/session/loop-detection.ts
|
|
27321
|
-
import { resolve as
|
|
28459
|
+
import { resolve as resolve15 } from "node:path";
|
|
27322
28460
|
function normalizeProject(p2) {
|
|
27323
|
-
return
|
|
28461
|
+
return resolve15(p2).replace(/\\/g, "/");
|
|
27324
28462
|
}
|
|
27325
28463
|
function findConsecutiveRepeats(displays) {
|
|
27326
28464
|
const results = [];
|
|
@@ -27473,14 +28611,14 @@ var init_loop_detection = __esm({
|
|
|
27473
28611
|
// src/core/checks/session/memory-index-overflow.ts
|
|
27474
28612
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
27475
28613
|
import { homedir as homedir5 } from "node:os";
|
|
27476
|
-
import { join as
|
|
28614
|
+
import { join as join10 } from "node:path";
|
|
27477
28615
|
async function checkMemoryIndexOverflow(ctx) {
|
|
27478
28616
|
const home2 = process.env.HOME || process.env.USERPROFILE || homedir5();
|
|
27479
28617
|
if (!home2) return [];
|
|
27480
28618
|
let content = "";
|
|
27481
28619
|
let memoryFile = "";
|
|
27482
28620
|
for (const encoded of projectDirCandidates(ctx.currentProject)) {
|
|
27483
|
-
const candidate =
|
|
28621
|
+
const candidate = join10(home2, ".claude", "projects", encoded, "memory", "MEMORY.md");
|
|
27484
28622
|
try {
|
|
27485
28623
|
content = stripBom(await readFile3(candidate, "utf-8"));
|
|
27486
28624
|
} catch {
|
|
@@ -27535,10 +28673,10 @@ var init_memory_index_overflow = __esm({
|
|
|
27535
28673
|
});
|
|
27536
28674
|
|
|
27537
28675
|
// src/core/transcript.ts
|
|
27538
|
-
import { createReadStream as createReadStream2, existsSync as
|
|
28676
|
+
import { createReadStream as createReadStream2, existsSync as existsSync8, statSync as statSync7 } from "node:fs";
|
|
27539
28677
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
27540
28678
|
import { homedir as homedir6 } from "node:os";
|
|
27541
|
-
import { join as
|
|
28679
|
+
import { join as join11 } from "node:path";
|
|
27542
28680
|
import { createInterface as createInterface2 } from "node:readline";
|
|
27543
28681
|
function emptyRead() {
|
|
27544
28682
|
return {
|
|
@@ -27578,8 +28716,8 @@ function clearTranscriptCache() {
|
|
|
27578
28716
|
cache.clear();
|
|
27579
28717
|
}
|
|
27580
28718
|
function candidateDirs(project, home2) {
|
|
27581
|
-
const root =
|
|
27582
|
-
return projectDirCandidates(project).map((n7) =>
|
|
28719
|
+
const root = join11(home2, ".claude", "projects");
|
|
28720
|
+
return projectDirCandidates(project).map((n7) => join11(root, n7)).filter((d) => existsSync8(d));
|
|
27583
28721
|
}
|
|
27584
28722
|
async function readUncached(project, home2) {
|
|
27585
28723
|
if (!home2 || !project) return emptyRead();
|
|
@@ -27592,9 +28730,9 @@ async function readUncached(project, home2) {
|
|
|
27592
28730
|
}
|
|
27593
28731
|
}
|
|
27594
28732
|
const files = names.filter(({ name }) => name.endsWith(".jsonl")).map(({ dir, name }) => {
|
|
27595
|
-
const p2 =
|
|
28733
|
+
const p2 = join11(dir, name);
|
|
27596
28734
|
try {
|
|
27597
|
-
return { p: p2, mtime:
|
|
28735
|
+
return { p: p2, mtime: statSync7(p2).mtimeMs };
|
|
27598
28736
|
} catch {
|
|
27599
28737
|
return null;
|
|
27600
28738
|
}
|
|
@@ -27674,13 +28812,13 @@ function turnOf(rec, message, st2, sessionId) {
|
|
|
27674
28812
|
function isSet(v2) {
|
|
27675
28813
|
return v2 !== void 0 && v2 !== null && v2 !== "";
|
|
27676
28814
|
}
|
|
27677
|
-
function readResultLines(rec,
|
|
28815
|
+
function readResultLines(rec, path23) {
|
|
27678
28816
|
const result = rec.toolUseResult;
|
|
27679
28817
|
if (!result || typeof result !== "object") return void 0;
|
|
27680
28818
|
const file2 = result.file;
|
|
27681
28819
|
if (!file2 || typeof file2 !== "object") return void 0;
|
|
27682
28820
|
const { filePath, numLines } = file2;
|
|
27683
|
-
if (filePath !==
|
|
28821
|
+
if (filePath !== path23) return void 0;
|
|
27684
28822
|
return typeof numLines === "number" ? numLines : void 0;
|
|
27685
28823
|
}
|
|
27686
28824
|
function collect(rec, st2) {
|
|
@@ -28146,7 +29284,7 @@ var init_unresolvable_sha = __esm({
|
|
|
28146
29284
|
});
|
|
28147
29285
|
|
|
28148
29286
|
// src/core/checks/session/large-read.ts
|
|
28149
|
-
import { isAbsolute as
|
|
29287
|
+
import { isAbsolute as isAbsolute9, relative as relative9 } from "node:path";
|
|
28150
29288
|
function qualifies(ev) {
|
|
28151
29289
|
if (ev.kind !== "file-read" || ev.partial || ev.isError) return false;
|
|
28152
29290
|
return (ev.outputTokens ?? 0) >= LARGE_READ_TOKENS;
|
|
@@ -28154,13 +29292,13 @@ function qualifies(ev) {
|
|
|
28154
29292
|
function fmt(n7) {
|
|
28155
29293
|
return n7.toLocaleString("en-US");
|
|
28156
29294
|
}
|
|
28157
|
-
function displayPath(
|
|
28158
|
-
const rel =
|
|
28159
|
-
if (rel && !rel.startsWith("..") && !
|
|
28160
|
-
return
|
|
29295
|
+
function displayPath(path23, project) {
|
|
29296
|
+
const rel = relative9(project, path23);
|
|
29297
|
+
if (rel && !rel.startsWith("..") && !isAbsolute9(rel)) return rel.replace(/\\/g, "/");
|
|
29298
|
+
return path23;
|
|
28161
29299
|
}
|
|
28162
|
-
function fileKey(
|
|
28163
|
-
const slashed =
|
|
29300
|
+
function fileKey(path23) {
|
|
29301
|
+
const slashed = path23.replace(/\\/g, "/");
|
|
28164
29302
|
return process.platform === "win32" ? slashed.toLowerCase() : slashed;
|
|
28165
29303
|
}
|
|
28166
29304
|
async function checkLargeRead(ctx) {
|
|
@@ -28234,11 +29372,11 @@ var init_large_read = __esm({
|
|
|
28234
29372
|
|
|
28235
29373
|
// src/core/checks/ci-coverage.ts
|
|
28236
29374
|
import { readdir as readdir4, readFile as readFile4 } from "node:fs/promises";
|
|
28237
|
-
import { join as
|
|
28238
|
-
import { existsSync as
|
|
29375
|
+
import { join as join12 } from "node:path";
|
|
29376
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
28239
29377
|
async function findReleaseWorkflows(projectRoot) {
|
|
28240
|
-
const workflowDir =
|
|
28241
|
-
if (!
|
|
29378
|
+
const workflowDir = join12(projectRoot, ".github", "workflows");
|
|
29379
|
+
if (!existsSync9(workflowDir)) return [];
|
|
28242
29380
|
let files;
|
|
28243
29381
|
try {
|
|
28244
29382
|
files = await readdir4(workflowDir);
|
|
@@ -28253,7 +29391,7 @@ async function findReleaseWorkflows(projectRoot) {
|
|
|
28253
29391
|
continue;
|
|
28254
29392
|
}
|
|
28255
29393
|
try {
|
|
28256
|
-
const content = stripBom(await readFile4(
|
|
29394
|
+
const content = stripBom(await readFile4(join12(workflowDir, f), "utf-8"));
|
|
28257
29395
|
const nameMatch = content.match(/^\s*name:\s*(.+?)\s*$/m);
|
|
28258
29396
|
if (nameMatch) {
|
|
28259
29397
|
const name = nameMatch[1].replace(/^(['"])(.*)\1$/, "$2");
|
|
@@ -28313,11 +29451,11 @@ var init_ci_coverage = __esm({
|
|
|
28313
29451
|
|
|
28314
29452
|
// src/core/checks/ci-secrets.ts
|
|
28315
29453
|
import { readdir as readdir5, readFile as readFile5 } from "node:fs/promises";
|
|
28316
|
-
import { join as
|
|
28317
|
-
import { existsSync as
|
|
29454
|
+
import { join as join13 } from "node:path";
|
|
29455
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
28318
29456
|
async function findSecretUsages(projectRoot) {
|
|
28319
|
-
const workflowDir =
|
|
28320
|
-
if (!
|
|
29457
|
+
const workflowDir = join13(projectRoot, ".github", "workflows");
|
|
29458
|
+
if (!existsSync10(workflowDir)) return [];
|
|
28321
29459
|
let files;
|
|
28322
29460
|
try {
|
|
28323
29461
|
files = await readdir5(workflowDir);
|
|
@@ -28329,7 +29467,7 @@ async function findSecretUsages(projectRoot) {
|
|
|
28329
29467
|
if (!(f.endsWith(".yml") || f.endsWith(".yaml"))) continue;
|
|
28330
29468
|
let content;
|
|
28331
29469
|
try {
|
|
28332
|
-
content = stripBom(await readFile5(
|
|
29470
|
+
content = stripBom(await readFile5(join13(workflowDir, f), "utf-8"));
|
|
28333
29471
|
} catch {
|
|
28334
29472
|
continue;
|
|
28335
29473
|
}
|
|
@@ -28643,26 +29781,26 @@ var init_positions = __esm({
|
|
|
28643
29781
|
});
|
|
28644
29782
|
|
|
28645
29783
|
// src/core/checks/hook-coverage.ts
|
|
28646
|
-
import * as
|
|
29784
|
+
import * as fs11 from "node:fs";
|
|
28647
29785
|
import * as os3 from "node:os";
|
|
28648
|
-
import * as
|
|
29786
|
+
import * as path14 from "node:path";
|
|
28649
29787
|
function loadSettingsSources2(projectRoot, homeDir, includeUserGlobal) {
|
|
28650
29788
|
const home2 = homeDir;
|
|
28651
29789
|
const candidates = [
|
|
28652
29790
|
{
|
|
28653
|
-
filePath:
|
|
28654
|
-
displayPath:
|
|
29791
|
+
filePath: path14.join(projectRoot, ".claude", "settings.json"),
|
|
29792
|
+
displayPath: path14.join(".claude", "settings.json"),
|
|
28655
29793
|
isUserGlobal: false
|
|
28656
29794
|
},
|
|
28657
29795
|
{
|
|
28658
|
-
filePath:
|
|
28659
|
-
displayPath:
|
|
29796
|
+
filePath: path14.join(projectRoot, ".claude", "settings.local.json"),
|
|
29797
|
+
displayPath: path14.join(".claude", "settings.local.json"),
|
|
28660
29798
|
isUserGlobal: false
|
|
28661
29799
|
}
|
|
28662
29800
|
];
|
|
28663
29801
|
if (includeUserGlobal) {
|
|
28664
29802
|
candidates.push({
|
|
28665
|
-
filePath:
|
|
29803
|
+
filePath: path14.join(home2, ".claude", "settings.json"),
|
|
28666
29804
|
displayPath: "~/.claude/settings.json",
|
|
28667
29805
|
isUserGlobal: true
|
|
28668
29806
|
});
|
|
@@ -28671,7 +29809,7 @@ function loadSettingsSources2(projectRoot, homeDir, includeUserGlobal) {
|
|
|
28671
29809
|
for (const c3 of candidates) {
|
|
28672
29810
|
let content;
|
|
28673
29811
|
try {
|
|
28674
|
-
content = stripBom(
|
|
29812
|
+
content = stripBom(fs11.readFileSync(c3.filePath, "utf-8"));
|
|
28675
29813
|
} catch {
|
|
28676
29814
|
continue;
|
|
28677
29815
|
}
|
|
@@ -28683,11 +29821,11 @@ function loadSettingsSources2(projectRoot, homeDir, includeUserGlobal) {
|
|
|
28683
29821
|
function expandPath(raw, projectRoot, homeDir, platform) {
|
|
28684
29822
|
let s = raw;
|
|
28685
29823
|
if (s === "~" || s.startsWith("~/") || s.startsWith("~\\")) {
|
|
28686
|
-
s =
|
|
29824
|
+
s = path14.join(homeDir, s.slice(1));
|
|
28687
29825
|
}
|
|
28688
29826
|
const replacements = {
|
|
28689
29827
|
CLAUDE_PROJECT_DIR: projectRoot,
|
|
28690
|
-
CLAUDE_CONFIG_DIR:
|
|
29828
|
+
CLAUDE_CONFIG_DIR: path14.join(homeDir, ".claude"),
|
|
28691
29829
|
HOME: homeDir,
|
|
28692
29830
|
USERPROFILE: homeDir
|
|
28693
29831
|
};
|
|
@@ -28702,7 +29840,7 @@ function expandPath(raw, projectRoot, homeDir, platform) {
|
|
|
28702
29840
|
if (/\$\{?[A-Za-z_]/.test(s)) return null;
|
|
28703
29841
|
if (/%[A-Za-z_][A-Za-z0-9_]*%/.test(s)) return null;
|
|
28704
29842
|
s = translateMsysDrivePath(s, platform);
|
|
28705
|
-
if (!
|
|
29843
|
+
if (!path14.isAbsolute(s)) s = path14.resolve(projectRoot, s);
|
|
28706
29844
|
return s;
|
|
28707
29845
|
}
|
|
28708
29846
|
function looksLikePath(token) {
|
|
@@ -28840,19 +29978,19 @@ var init_hook_coverage = __esm({
|
|
|
28840
29978
|
});
|
|
28841
29979
|
|
|
28842
29980
|
// src/core/skill-scanner.ts
|
|
28843
|
-
import * as
|
|
29981
|
+
import * as fs12 from "node:fs";
|
|
28844
29982
|
import * as os4 from "node:os";
|
|
28845
|
-
import * as
|
|
29983
|
+
import * as path15 from "node:path";
|
|
28846
29984
|
function defaultHome() {
|
|
28847
29985
|
return process.env.HOME || process.env.USERPROFILE || os4.homedir();
|
|
28848
29986
|
}
|
|
28849
29987
|
function scanSkillFiles(homeDir = defaultHome()) {
|
|
28850
29988
|
const files = [];
|
|
28851
29989
|
const orphanedSkillDirs = [];
|
|
28852
|
-
const claudeDir =
|
|
28853
|
-
const skillsRoot =
|
|
29990
|
+
const claudeDir = path15.join(homeDir, ".claude");
|
|
29991
|
+
const skillsRoot = path15.join(claudeDir, "skills");
|
|
28854
29992
|
for (const name of safeReadDir(skillsRoot, "dir")) {
|
|
28855
|
-
const skillMd =
|
|
29993
|
+
const skillMd = path15.join(skillsRoot, name, "SKILL.md");
|
|
28856
29994
|
const content = safeRead(skillMd);
|
|
28857
29995
|
if (content === null) {
|
|
28858
29996
|
orphanedSkillDirs.push({ name, displayPath: `~/.claude/skills/${name}/` });
|
|
@@ -28866,10 +30004,10 @@ function scanSkillFiles(homeDir = defaultHome()) {
|
|
|
28866
30004
|
content
|
|
28867
30005
|
});
|
|
28868
30006
|
}
|
|
28869
|
-
const agentsRoot =
|
|
30007
|
+
const agentsRoot = path15.join(claudeDir, "agents");
|
|
28870
30008
|
for (const fileName of safeReadDir(agentsRoot, "file")) {
|
|
28871
30009
|
if (!fileName.endsWith(".md")) continue;
|
|
28872
|
-
const agentMd =
|
|
30010
|
+
const agentMd = path15.join(agentsRoot, fileName);
|
|
28873
30011
|
const content = safeRead(agentMd);
|
|
28874
30012
|
if (content === null) continue;
|
|
28875
30013
|
files.push({
|
|
@@ -28885,7 +30023,7 @@ function scanSkillFiles(homeDir = defaultHome()) {
|
|
|
28885
30023
|
function safeReadDir(dir, want) {
|
|
28886
30024
|
let entries;
|
|
28887
30025
|
try {
|
|
28888
|
-
entries =
|
|
30026
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
28889
30027
|
} catch {
|
|
28890
30028
|
return [];
|
|
28891
30029
|
}
|
|
@@ -28893,7 +30031,7 @@ function safeReadDir(dir, want) {
|
|
|
28893
30031
|
if (want === "dir" ? e.isDirectory() : e.isFile()) return true;
|
|
28894
30032
|
if (!e.isSymbolicLink()) return false;
|
|
28895
30033
|
try {
|
|
28896
|
-
const target =
|
|
30034
|
+
const target = fs12.statSync(path15.join(dir, e.name));
|
|
28897
30035
|
return want === "dir" ? target.isDirectory() : target.isFile();
|
|
28898
30036
|
} catch {
|
|
28899
30037
|
return false;
|
|
@@ -28902,7 +30040,7 @@ function safeReadDir(dir, want) {
|
|
|
28902
30040
|
}
|
|
28903
30041
|
function safeRead(file2) {
|
|
28904
30042
|
try {
|
|
28905
|
-
return stripBom(
|
|
30043
|
+
return stripBom(fs12.readFileSync(file2, "utf-8"));
|
|
28906
30044
|
} catch {
|
|
28907
30045
|
return null;
|
|
28908
30046
|
}
|
|
@@ -28916,7 +30054,7 @@ var init_skill_scanner = __esm({
|
|
|
28916
30054
|
});
|
|
28917
30055
|
|
|
28918
30056
|
// src/core/checks/skills.ts
|
|
28919
|
-
import * as
|
|
30057
|
+
import * as path16 from "node:path";
|
|
28920
30058
|
function parseFrontmatter3(content) {
|
|
28921
30059
|
const lines = content.split("\n");
|
|
28922
30060
|
if (lines[0]?.trim() !== "---") {
|
|
@@ -28993,7 +30131,7 @@ function checkMissingFrontmatter(file2, fm) {
|
|
|
28993
30131
|
}
|
|
28994
30132
|
function checkBrokenRefs(file2, fmEndLine) {
|
|
28995
30133
|
const issues = [];
|
|
28996
|
-
const skillDir =
|
|
30134
|
+
const skillDir = path16.dirname(file2.filePath);
|
|
28997
30135
|
const lines = file2.content.split("\n");
|
|
28998
30136
|
let inCode = false;
|
|
28999
30137
|
let codeLang = "";
|
|
@@ -29013,7 +30151,7 @@ function checkBrokenRefs(file2, fmEndLine) {
|
|
|
29013
30151
|
if (PATH_SKIP.test(value)) continue;
|
|
29014
30152
|
if (!value.startsWith("./") && !value.startsWith("../")) continue;
|
|
29015
30153
|
while (/[.,;:]$/.test(value)) value = value.slice(0, -1);
|
|
29016
|
-
const resolved =
|
|
30154
|
+
const resolved = path16.resolve(skillDir, value);
|
|
29017
30155
|
if (fileExists(resolved) || isDirectory(resolved)) continue;
|
|
29018
30156
|
issues.push({
|
|
29019
30157
|
severity: "warning",
|
|
@@ -29278,15 +30416,15 @@ var init_types = __esm({
|
|
|
29278
30416
|
});
|
|
29279
30417
|
|
|
29280
30418
|
// src/version.ts
|
|
29281
|
-
import { readFileSync as
|
|
29282
|
-
import { resolve as
|
|
30419
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30420
|
+
import { resolve as resolve18, dirname as dirname10 } from "node:path";
|
|
29283
30421
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
29284
30422
|
function loadVersion() {
|
|
29285
|
-
if (true) return "0.25.
|
|
30423
|
+
if (true) return "0.25.3";
|
|
29286
30424
|
try {
|
|
29287
|
-
const __dir =
|
|
29288
|
-
const pkgPath =
|
|
29289
|
-
const pkg = JSON.parse(
|
|
30425
|
+
const __dir = dirname10(fileURLToPath2(import.meta.url));
|
|
30426
|
+
const pkgPath = resolve18(__dir, "../package.json");
|
|
30427
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf-8"));
|
|
29290
30428
|
return pkg.version ?? "0.0.0-dev";
|
|
29291
30429
|
} catch {
|
|
29292
30430
|
return "0.0.0-dev";
|
|
@@ -29302,9 +30440,9 @@ var init_version2 = __esm({
|
|
|
29302
30440
|
});
|
|
29303
30441
|
|
|
29304
30442
|
// src/core/audit.ts
|
|
29305
|
-
import * as
|
|
30443
|
+
import * as fs13 from "node:fs";
|
|
29306
30444
|
import * as os5 from "node:os";
|
|
29307
|
-
import * as
|
|
30445
|
+
import * as path17 from "node:path";
|
|
29308
30446
|
function hasMcpChecks(checks) {
|
|
29309
30447
|
return checks.some((c3) => c3.startsWith("mcp-"));
|
|
29310
30448
|
}
|
|
@@ -29341,7 +30479,7 @@ async function runAudit(projectRoot, activeChecks, options = {}) {
|
|
|
29341
30479
|
const absPath = discoveredFile.absolutePath;
|
|
29342
30480
|
let stat3 = null;
|
|
29343
30481
|
try {
|
|
29344
|
-
const s =
|
|
30482
|
+
const s = fs13.statSync(absPath);
|
|
29345
30483
|
stat3 = { mtimeMs: s.mtimeMs, size: s.size };
|
|
29346
30484
|
} catch {
|
|
29347
30485
|
}
|
|
@@ -29668,12 +30806,12 @@ async function runAudit(projectRoot, activeChecks, options = {}) {
|
|
|
29668
30806
|
return result;
|
|
29669
30807
|
}
|
|
29670
30808
|
async function runAuditOnContent(filePath, content, projectRoot, options = {}) {
|
|
29671
|
-
const tmpDir =
|
|
29672
|
-
const ext =
|
|
29673
|
-
const tmpFile =
|
|
30809
|
+
const tmpDir = fs13.mkdtempSync(path17.join(os5.tmpdir(), "ctxlint-lsp-"));
|
|
30810
|
+
const ext = path17.extname(filePath) || ".md";
|
|
30811
|
+
const tmpFile = path17.join(tmpDir, "content" + ext);
|
|
29674
30812
|
try {
|
|
29675
|
-
|
|
29676
|
-
const tmpRelative =
|
|
30813
|
+
fs13.writeFileSync(tmpFile, content, "utf-8");
|
|
30814
|
+
const tmpRelative = path17.relative(tmpDir, tmpFile);
|
|
29677
30815
|
const rawResult = await runAudit(
|
|
29678
30816
|
tmpDir,
|
|
29679
30817
|
options.depth !== void 0 ? ALL_CHECKS : ALL_CHECKS,
|
|
@@ -29688,13 +30826,13 @@ async function runAuditOnContent(filePath, content, projectRoot, options = {}) {
|
|
|
29688
30826
|
}
|
|
29689
30827
|
);
|
|
29690
30828
|
const remapped = rawResult.files.map((fr) => {
|
|
29691
|
-
const isTmp = fr.path === tmpRelative || fr.path === tmpFile ||
|
|
30829
|
+
const isTmp = fr.path === tmpRelative || fr.path === tmpFile || path17.resolve(tmpDir, fr.path) === tmpFile;
|
|
29692
30830
|
return isTmp ? { ...fr, path: filePath } : fr;
|
|
29693
30831
|
});
|
|
29694
30832
|
return { ...rawResult, files: remapped, projectRoot };
|
|
29695
30833
|
} finally {
|
|
29696
30834
|
try {
|
|
29697
|
-
|
|
30835
|
+
fs13.rmSync(tmpDir, { recursive: true, force: true });
|
|
29698
30836
|
} catch {
|
|
29699
30837
|
}
|
|
29700
30838
|
}
|
|
@@ -29802,7 +30940,7 @@ var server_exports = {};
|
|
|
29802
30940
|
__export(server_exports, {
|
|
29803
30941
|
startLspServer: () => startLspServer
|
|
29804
30942
|
});
|
|
29805
|
-
import * as
|
|
30943
|
+
import * as path18 from "node:path";
|
|
29806
30944
|
async function startLspServer() {
|
|
29807
30945
|
const connection = (0, import_node.createConnection)(import_node.ProposedFeatures.all);
|
|
29808
30946
|
const documents = new import_node.TextDocuments(TextDocument2);
|
|
@@ -29817,7 +30955,7 @@ async function startLspServer() {
|
|
|
29817
30955
|
const uri = doc.uri;
|
|
29818
30956
|
let filePath = uri.startsWith("file://") ? decodeURIComponent(uri.slice(7)) : uri;
|
|
29819
30957
|
filePath = filePath.replace(/^\/([A-Za-z]:)/, "$1");
|
|
29820
|
-
const projectRoot =
|
|
30958
|
+
const projectRoot = path18.dirname(filePath);
|
|
29821
30959
|
try {
|
|
29822
30960
|
const result = await runAuditOnContent(filePath, doc.getText(), projectRoot, {
|
|
29823
30961
|
depth: 2
|
|
@@ -30269,8 +31407,8 @@ var init_parseUtil = __esm({
|
|
|
30269
31407
|
init_errors();
|
|
30270
31408
|
init_en();
|
|
30271
31409
|
makeIssue = (params) => {
|
|
30272
|
-
const { data, path:
|
|
30273
|
-
const fullPath = [...
|
|
31410
|
+
const { data, path: path23, errorMaps, issueData } = params;
|
|
31411
|
+
const fullPath = [...path23, ...issueData.path || []];
|
|
30274
31412
|
const fullIssue = {
|
|
30275
31413
|
...issueData,
|
|
30276
31414
|
path: fullPath
|
|
@@ -30553,11 +31691,11 @@ var init_types2 = __esm({
|
|
|
30553
31691
|
init_parseUtil();
|
|
30554
31692
|
init_util2();
|
|
30555
31693
|
ParseInputLazyPath = class {
|
|
30556
|
-
constructor(parent, value,
|
|
31694
|
+
constructor(parent, value, path23, key) {
|
|
30557
31695
|
this._cachedPath = [];
|
|
30558
31696
|
this.parent = parent;
|
|
30559
31697
|
this.data = value;
|
|
30560
|
-
this._path =
|
|
31698
|
+
this._path = path23;
|
|
30561
31699
|
this._key = key;
|
|
30562
31700
|
}
|
|
30563
31701
|
get path() {
|
|
@@ -34059,10 +35197,10 @@ function mergeDefs(...defs) {
|
|
|
34059
35197
|
function cloneDef(schema) {
|
|
34060
35198
|
return mergeDefs(schema._zod.def);
|
|
34061
35199
|
}
|
|
34062
|
-
function getElementAtPath(obj,
|
|
34063
|
-
if (!
|
|
35200
|
+
function getElementAtPath(obj, path23) {
|
|
35201
|
+
if (!path23)
|
|
34064
35202
|
return obj;
|
|
34065
|
-
return
|
|
35203
|
+
return path23.reduce((acc, key) => acc?.[key], obj);
|
|
34066
35204
|
}
|
|
34067
35205
|
function promiseAllObject(promisesObj) {
|
|
34068
35206
|
const keys = Object.keys(promisesObj);
|
|
@@ -34390,11 +35528,11 @@ function explicitlyAborted(x3, startIndex = 0) {
|
|
|
34390
35528
|
}
|
|
34391
35529
|
return false;
|
|
34392
35530
|
}
|
|
34393
|
-
function prefixIssues(
|
|
35531
|
+
function prefixIssues(path23, issues) {
|
|
34394
35532
|
return issues.map((iss) => {
|
|
34395
35533
|
var _a4;
|
|
34396
35534
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
34397
|
-
iss.path.unshift(
|
|
35535
|
+
iss.path.unshift(path23);
|
|
34398
35536
|
return iss;
|
|
34399
35537
|
});
|
|
34400
35538
|
}
|
|
@@ -34612,16 +35750,16 @@ function flattenError(error52, mapper = (issue2) => issue2.message) {
|
|
|
34612
35750
|
}
|
|
34613
35751
|
function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
34614
35752
|
const fieldErrors = { _errors: [] };
|
|
34615
|
-
const processError = (error53,
|
|
35753
|
+
const processError = (error53, path23 = []) => {
|
|
34616
35754
|
for (const issue2 of error53.issues) {
|
|
34617
35755
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
34618
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
35756
|
+
issue2.errors.map((issues) => processError({ issues }, [...path23, ...issue2.path]));
|
|
34619
35757
|
} else if (issue2.code === "invalid_key") {
|
|
34620
|
-
processError({ issues: issue2.issues }, [...
|
|
35758
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
34621
35759
|
} else if (issue2.code === "invalid_element") {
|
|
34622
|
-
processError({ issues: issue2.issues }, [...
|
|
35760
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
34623
35761
|
} else {
|
|
34624
|
-
const fullpath = [...
|
|
35762
|
+
const fullpath = [...path23, ...issue2.path];
|
|
34625
35763
|
if (fullpath.length === 0) {
|
|
34626
35764
|
fieldErrors._errors.push(mapper(issue2));
|
|
34627
35765
|
} else {
|
|
@@ -34648,17 +35786,17 @@ function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
|
34648
35786
|
}
|
|
34649
35787
|
function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
34650
35788
|
const result = { errors: [] };
|
|
34651
|
-
const processError = (error53,
|
|
35789
|
+
const processError = (error53, path23 = []) => {
|
|
34652
35790
|
var _a4, _b;
|
|
34653
35791
|
for (const issue2 of error53.issues) {
|
|
34654
35792
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
34655
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
35793
|
+
issue2.errors.map((issues) => processError({ issues }, [...path23, ...issue2.path]));
|
|
34656
35794
|
} else if (issue2.code === "invalid_key") {
|
|
34657
|
-
processError({ issues: issue2.issues }, [...
|
|
35795
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
34658
35796
|
} else if (issue2.code === "invalid_element") {
|
|
34659
|
-
processError({ issues: issue2.issues }, [...
|
|
35797
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
34660
35798
|
} else {
|
|
34661
|
-
const fullpath = [...
|
|
35799
|
+
const fullpath = [...path23, ...issue2.path];
|
|
34662
35800
|
if (fullpath.length === 0) {
|
|
34663
35801
|
result.errors.push(mapper(issue2));
|
|
34664
35802
|
continue;
|
|
@@ -34690,8 +35828,8 @@ function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
|
34690
35828
|
}
|
|
34691
35829
|
function toDotPath(_path) {
|
|
34692
35830
|
const segs = [];
|
|
34693
|
-
const
|
|
34694
|
-
for (const seg of
|
|
35831
|
+
const path23 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
35832
|
+
for (const seg of path23) {
|
|
34695
35833
|
if (typeof seg === "number")
|
|
34696
35834
|
segs.push(`[${seg}]`);
|
|
34697
35835
|
else if (typeof seg === "symbol")
|
|
@@ -48452,13 +49590,13 @@ function resolveRef2(ref, ctx) {
|
|
|
48452
49590
|
if (!ref.startsWith("#")) {
|
|
48453
49591
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
48454
49592
|
}
|
|
48455
|
-
const
|
|
48456
|
-
if (
|
|
49593
|
+
const path23 = ref.slice(1).split("/").filter(Boolean);
|
|
49594
|
+
if (path23.length === 0) {
|
|
48457
49595
|
return ctx.rootSchema;
|
|
48458
49596
|
}
|
|
48459
49597
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
48460
|
-
if (
|
|
48461
|
-
const key =
|
|
49598
|
+
if (path23[0] === defsKey) {
|
|
49599
|
+
const key = path23[1];
|
|
48462
49600
|
if (!key || !ctx.defs[key]) {
|
|
48463
49601
|
throw new Error(`Reference not found: ${ref}`);
|
|
48464
49602
|
}
|
|
@@ -52972,7 +54110,7 @@ var init_protocol = __esm({
|
|
|
52972
54110
|
return;
|
|
52973
54111
|
}
|
|
52974
54112
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
52975
|
-
await new Promise((
|
|
54113
|
+
await new Promise((resolve22) => setTimeout(resolve22, pollInterval));
|
|
52976
54114
|
options?.signal?.throwIfAborted();
|
|
52977
54115
|
}
|
|
52978
54116
|
} catch (error52) {
|
|
@@ -52989,7 +54127,7 @@ var init_protocol = __esm({
|
|
|
52989
54127
|
*/
|
|
52990
54128
|
request(request, resultSchema, options) {
|
|
52991
54129
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
52992
|
-
return new Promise((
|
|
54130
|
+
return new Promise((resolve22, reject) => {
|
|
52993
54131
|
const earlyReject = (error52) => {
|
|
52994
54132
|
reject(error52);
|
|
52995
54133
|
};
|
|
@@ -53067,7 +54205,7 @@ var init_protocol = __esm({
|
|
|
53067
54205
|
if (!parseResult.success) {
|
|
53068
54206
|
reject(parseResult.error);
|
|
53069
54207
|
} else {
|
|
53070
|
-
|
|
54208
|
+
resolve22(parseResult.data);
|
|
53071
54209
|
}
|
|
53072
54210
|
} catch (error52) {
|
|
53073
54211
|
reject(error52);
|
|
@@ -53328,12 +54466,12 @@ var init_protocol = __esm({
|
|
|
53328
54466
|
}
|
|
53329
54467
|
} catch {
|
|
53330
54468
|
}
|
|
53331
|
-
return new Promise((
|
|
54469
|
+
return new Promise((resolve22, reject) => {
|
|
53332
54470
|
if (signal.aborted) {
|
|
53333
54471
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
53334
54472
|
return;
|
|
53335
54473
|
}
|
|
53336
|
-
const timeoutId = setTimeout(
|
|
54474
|
+
const timeoutId = setTimeout(resolve22, interval);
|
|
53337
54475
|
signal.addEventListener("abort", () => {
|
|
53338
54476
|
clearTimeout(timeoutId);
|
|
53339
54477
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -56381,7 +57519,7 @@ var require_compile = __commonJS({
|
|
|
56381
57519
|
const schOrFunc = root.refs[ref];
|
|
56382
57520
|
if (schOrFunc)
|
|
56383
57521
|
return schOrFunc;
|
|
56384
|
-
let _sch =
|
|
57522
|
+
let _sch = resolve22.call(this, root, ref);
|
|
56385
57523
|
if (_sch === void 0) {
|
|
56386
57524
|
const schema = (_a4 = root.localRefs) === null || _a4 === void 0 ? void 0 : _a4[ref];
|
|
56387
57525
|
const { schemaId } = this.opts;
|
|
@@ -56408,7 +57546,7 @@ var require_compile = __commonJS({
|
|
|
56408
57546
|
function sameSchemaEnv(s1, s2) {
|
|
56409
57547
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
56410
57548
|
}
|
|
56411
|
-
function
|
|
57549
|
+
function resolve22(root, ref) {
|
|
56412
57550
|
let sch;
|
|
56413
57551
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
56414
57552
|
ref = sch;
|
|
@@ -56627,8 +57765,8 @@ var require_utils2 = __commonJS({
|
|
|
56627
57765
|
}
|
|
56628
57766
|
return ind;
|
|
56629
57767
|
}
|
|
56630
|
-
function removeDotSegments(
|
|
56631
|
-
let input =
|
|
57768
|
+
function removeDotSegments(path23) {
|
|
57769
|
+
let input = path23;
|
|
56632
57770
|
const output = [];
|
|
56633
57771
|
let nextSlash = -1;
|
|
56634
57772
|
let len = 0;
|
|
@@ -56881,8 +58019,8 @@ var require_schemes = __commonJS({
|
|
|
56881
58019
|
wsComponent.secure = void 0;
|
|
56882
58020
|
}
|
|
56883
58021
|
if (wsComponent.resourceName) {
|
|
56884
|
-
const [
|
|
56885
|
-
wsComponent.path =
|
|
58022
|
+
const [path23, query] = wsComponent.resourceName.split("?");
|
|
58023
|
+
wsComponent.path = path23 && path23 !== "/" ? path23 : void 0;
|
|
56886
58024
|
wsComponent.query = query;
|
|
56887
58025
|
wsComponent.resourceName = void 0;
|
|
56888
58026
|
}
|
|
@@ -57042,55 +58180,55 @@ var require_fast_uri = __commonJS({
|
|
|
57042
58180
|
}
|
|
57043
58181
|
return uri;
|
|
57044
58182
|
}
|
|
57045
|
-
function
|
|
58183
|
+
function resolve22(baseURI, relativeURI, options) {
|
|
57046
58184
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
57047
58185
|
const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
57048
58186
|
schemelessOptions.skipEscape = true;
|
|
57049
58187
|
return serialize(resolved, schemelessOptions);
|
|
57050
58188
|
}
|
|
57051
|
-
function resolveComponent(base,
|
|
58189
|
+
function resolveComponent(base, relative12, options, skipNormalization) {
|
|
57052
58190
|
const target = {};
|
|
57053
58191
|
if (!skipNormalization) {
|
|
57054
58192
|
base = parse5(serialize(base, options), options);
|
|
57055
|
-
|
|
58193
|
+
relative12 = parse5(serialize(relative12, options), options);
|
|
57056
58194
|
}
|
|
57057
58195
|
options = options || {};
|
|
57058
|
-
if (!options.tolerant &&
|
|
57059
|
-
target.scheme =
|
|
57060
|
-
target.userinfo =
|
|
57061
|
-
target.host =
|
|
57062
|
-
target.port =
|
|
57063
|
-
target.path = removeDotSegments(
|
|
57064
|
-
target.query =
|
|
58196
|
+
if (!options.tolerant && relative12.scheme) {
|
|
58197
|
+
target.scheme = relative12.scheme;
|
|
58198
|
+
target.userinfo = relative12.userinfo;
|
|
58199
|
+
target.host = relative12.host;
|
|
58200
|
+
target.port = relative12.port;
|
|
58201
|
+
target.path = removeDotSegments(relative12.path || "");
|
|
58202
|
+
target.query = relative12.query;
|
|
57065
58203
|
} else {
|
|
57066
|
-
if (
|
|
57067
|
-
target.userinfo =
|
|
57068
|
-
target.host =
|
|
57069
|
-
target.port =
|
|
57070
|
-
target.path = removeDotSegments(
|
|
57071
|
-
target.query =
|
|
58204
|
+
if (relative12.userinfo !== void 0 || relative12.host !== void 0 || relative12.port !== void 0) {
|
|
58205
|
+
target.userinfo = relative12.userinfo;
|
|
58206
|
+
target.host = relative12.host;
|
|
58207
|
+
target.port = relative12.port;
|
|
58208
|
+
target.path = removeDotSegments(relative12.path || "");
|
|
58209
|
+
target.query = relative12.query;
|
|
57072
58210
|
} else {
|
|
57073
|
-
if (!
|
|
58211
|
+
if (!relative12.path) {
|
|
57074
58212
|
target.path = base.path;
|
|
57075
|
-
if (
|
|
57076
|
-
target.query =
|
|
58213
|
+
if (relative12.query !== void 0) {
|
|
58214
|
+
target.query = relative12.query;
|
|
57077
58215
|
} else {
|
|
57078
58216
|
target.query = base.query;
|
|
57079
58217
|
}
|
|
57080
58218
|
} else {
|
|
57081
|
-
if (
|
|
57082
|
-
target.path = removeDotSegments(
|
|
58219
|
+
if (relative12.path[0] === "/") {
|
|
58220
|
+
target.path = removeDotSegments(relative12.path);
|
|
57083
58221
|
} else {
|
|
57084
58222
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
57085
|
-
target.path = "/" +
|
|
58223
|
+
target.path = "/" + relative12.path;
|
|
57086
58224
|
} else if (!base.path) {
|
|
57087
|
-
target.path =
|
|
58225
|
+
target.path = relative12.path;
|
|
57088
58226
|
} else {
|
|
57089
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
58227
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative12.path;
|
|
57090
58228
|
}
|
|
57091
58229
|
target.path = removeDotSegments(target.path);
|
|
57092
58230
|
}
|
|
57093
|
-
target.query =
|
|
58231
|
+
target.query = relative12.query;
|
|
57094
58232
|
}
|
|
57095
58233
|
target.userinfo = base.userinfo;
|
|
57096
58234
|
target.host = base.host;
|
|
@@ -57098,7 +58236,7 @@ var require_fast_uri = __commonJS({
|
|
|
57098
58236
|
}
|
|
57099
58237
|
target.scheme = base.scheme;
|
|
57100
58238
|
}
|
|
57101
|
-
target.fragment =
|
|
58239
|
+
target.fragment = relative12.fragment;
|
|
57102
58240
|
return target;
|
|
57103
58241
|
}
|
|
57104
58242
|
function equal(uriA, uriB, options) {
|
|
@@ -57300,7 +58438,7 @@ var require_fast_uri = __commonJS({
|
|
|
57300
58438
|
var fastUri = {
|
|
57301
58439
|
SCHEMES,
|
|
57302
58440
|
normalize: normalize4,
|
|
57303
|
-
resolve:
|
|
58441
|
+
resolve: resolve22,
|
|
57304
58442
|
resolveComponent,
|
|
57305
58443
|
equal,
|
|
57306
58444
|
serialize,
|
|
@@ -60321,12 +61459,12 @@ var require_dist3 = __commonJS({
|
|
|
60321
61459
|
throw new Error(`Unknown format "${name}"`);
|
|
60322
61460
|
return f;
|
|
60323
61461
|
};
|
|
60324
|
-
function addFormats(ajv, list,
|
|
61462
|
+
function addFormats(ajv, list, fs18, exportName) {
|
|
60325
61463
|
var _a4;
|
|
60326
61464
|
var _b;
|
|
60327
61465
|
(_a4 = (_b = ajv.opts.code).formats) !== null && _a4 !== void 0 ? _a4 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
60328
61466
|
for (const f of list)
|
|
60329
|
-
ajv.addFormat(f,
|
|
61467
|
+
ajv.addFormat(f, fs18[f]);
|
|
60330
61468
|
}
|
|
60331
61469
|
module.exports = exports = formatsPlugin;
|
|
60332
61470
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -61482,7 +62620,7 @@ var init_mcp = __esm({
|
|
|
61482
62620
|
let task = createTaskResult.task;
|
|
61483
62621
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
61484
62622
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
61485
|
-
await new Promise((
|
|
62623
|
+
await new Promise((resolve22) => setTimeout(resolve22, pollInterval));
|
|
61486
62624
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
61487
62625
|
if (!updatedTask) {
|
|
61488
62626
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -62078,12 +63216,12 @@ var init_stdio2 = __esm({
|
|
|
62078
63216
|
this.onclose?.();
|
|
62079
63217
|
}
|
|
62080
63218
|
send(message) {
|
|
62081
|
-
return new Promise((
|
|
63219
|
+
return new Promise((resolve22) => {
|
|
62082
63220
|
const json2 = serializeMessage(message);
|
|
62083
63221
|
if (this._stdout.write(json2)) {
|
|
62084
|
-
|
|
63222
|
+
resolve22();
|
|
62085
63223
|
} else {
|
|
62086
|
-
this._stdout.once("drain",
|
|
63224
|
+
this._stdout.once("drain", resolve22);
|
|
62087
63225
|
}
|
|
62088
63226
|
});
|
|
62089
63227
|
}
|
|
@@ -62634,7 +63772,7 @@ var init_source = __esm({
|
|
|
62634
63772
|
});
|
|
62635
63773
|
|
|
62636
63774
|
// src/core/fixer.ts
|
|
62637
|
-
import * as
|
|
63775
|
+
import * as fs14 from "node:fs";
|
|
62638
63776
|
function applyFixes(result, options = {}) {
|
|
62639
63777
|
const log = options.quiet ? () => {
|
|
62640
63778
|
} : console.log.bind(console);
|
|
@@ -62672,7 +63810,7 @@ function applyFixes(result, options = {}) {
|
|
|
62672
63810
|
for (const [filePath, fixes] of fixesByFile) {
|
|
62673
63811
|
let content;
|
|
62674
63812
|
try {
|
|
62675
|
-
content =
|
|
63813
|
+
content = fs14.readFileSync(filePath, "utf-8");
|
|
62676
63814
|
} catch (err) {
|
|
62677
63815
|
log(source_default.yellow(" Skipped") + ` ${filePath}: ${err.message}`);
|
|
62678
63816
|
continue;
|
|
@@ -62757,7 +63895,7 @@ function applyFixes(result, options = {}) {
|
|
|
62757
63895
|
}
|
|
62758
63896
|
if (!dryRun) {
|
|
62759
63897
|
try {
|
|
62760
|
-
|
|
63898
|
+
fs14.writeFileSync(filePath, newContent, "utf-8");
|
|
62761
63899
|
} catch (err) {
|
|
62762
63900
|
log(source_default.yellow(" Skipped") + ` ${filePath}: ${err.message}`);
|
|
62763
63901
|
continue;
|
|
@@ -62779,8 +63917,8 @@ var init_fixer = __esm({
|
|
|
62779
63917
|
});
|
|
62780
63918
|
|
|
62781
63919
|
// src/core/config.ts
|
|
62782
|
-
import * as
|
|
62783
|
-
import * as
|
|
63920
|
+
import * as fs15 from "node:fs";
|
|
63921
|
+
import * as path19 from "node:path";
|
|
62784
63922
|
function formatJsonError(content, err) {
|
|
62785
63923
|
const msg = err instanceof Error ? err.message : String(err);
|
|
62786
63924
|
const posMatch = msg.match(/position (\d+)/);
|
|
@@ -62820,7 +63958,7 @@ function suggestKey(unknown2) {
|
|
|
62820
63958
|
let best = null;
|
|
62821
63959
|
let bestDist = Infinity;
|
|
62822
63960
|
for (const known of KNOWN_CONFIG_KEYS) {
|
|
62823
|
-
const d =
|
|
63961
|
+
const d = levenshtein3(unknown2, known);
|
|
62824
63962
|
if (d < bestDist) {
|
|
62825
63963
|
bestDist = d;
|
|
62826
63964
|
best = known;
|
|
@@ -62878,10 +64016,10 @@ function warnIgnoreRulePathPatternMisuse(config2, source) {
|
|
|
62878
64016
|
}
|
|
62879
64017
|
function loadConfig(projectRoot) {
|
|
62880
64018
|
for (const filename of CONFIG_FILENAMES) {
|
|
62881
|
-
const filePath =
|
|
64019
|
+
const filePath = path19.join(projectRoot, filename);
|
|
62882
64020
|
let content;
|
|
62883
64021
|
try {
|
|
62884
|
-
content = stripBom(
|
|
64022
|
+
content = stripBom(fs15.readFileSync(filePath, "utf-8"));
|
|
62885
64023
|
} catch {
|
|
62886
64024
|
continue;
|
|
62887
64025
|
}
|
|
@@ -62892,22 +64030,22 @@ function loadConfig(projectRoot) {
|
|
|
62892
64030
|
function loadConfigFromExplicitPath(configPath) {
|
|
62893
64031
|
let content;
|
|
62894
64032
|
try {
|
|
62895
|
-
content = stripBom(
|
|
64033
|
+
content = stripBom(fs15.readFileSync(configPath, "utf-8"));
|
|
62896
64034
|
} catch (err) {
|
|
62897
64035
|
const detail = err instanceof Error ? err.message : String(err);
|
|
62898
64036
|
throw new Error(`could not load config from ${configPath}: ${detail}`, { cause: err });
|
|
62899
64037
|
}
|
|
62900
64038
|
return parseConfigContent(content, configPath);
|
|
62901
64039
|
}
|
|
62902
|
-
var
|
|
64040
|
+
var import_fast_levenshtein3, levenshtein3, KNOWN_CONFIG_KEYS, CONFIG_FILENAMES;
|
|
62903
64041
|
var init_config2 = __esm({
|
|
62904
64042
|
"src/core/config.ts"() {
|
|
62905
64043
|
"use strict";
|
|
62906
64044
|
init_define_WEB_FIRST_SEGMENTS();
|
|
62907
|
-
|
|
64045
|
+
import_fast_levenshtein3 = __toESM(require_levenshtein(), 1);
|
|
62908
64046
|
init_fs();
|
|
62909
64047
|
init_positions();
|
|
62910
|
-
|
|
64048
|
+
levenshtein3 = import_fast_levenshtein3.default.get;
|
|
62911
64049
|
KNOWN_CONFIG_KEYS = [
|
|
62912
64050
|
"checks",
|
|
62913
64051
|
"ignore",
|
|
@@ -62935,7 +64073,7 @@ __export(server_exports2, {
|
|
|
62935
64073
|
server: () => server,
|
|
62936
64074
|
startServer: () => startServer
|
|
62937
64075
|
});
|
|
62938
|
-
import * as
|
|
64076
|
+
import * as path20 from "node:path";
|
|
62939
64077
|
function describeDisallowed(rawPath) {
|
|
62940
64078
|
const m = rawPath.match(PATH_DISALLOWED);
|
|
62941
64079
|
if (!m) return "unknown";
|
|
@@ -62948,7 +64086,7 @@ function validateProjectPath(rawPath) {
|
|
|
62948
64086
|
`projectPath contains disallowed character ${describeDisallowed(rawPath)} (control chars and shell metacharacters are rejected)`
|
|
62949
64087
|
);
|
|
62950
64088
|
}
|
|
62951
|
-
const resolved =
|
|
64089
|
+
const resolved = path20.resolve(rawPath);
|
|
62952
64090
|
if (!isDirectory(resolved)) {
|
|
62953
64091
|
throw new Error("projectPath is not an existing directory");
|
|
62954
64092
|
}
|
|
@@ -62972,10 +64110,10 @@ function validateFilePathInput(rawPath) {
|
|
|
62972
64110
|
}
|
|
62973
64111
|
}
|
|
62974
64112
|
function resolveWithinRoot(filePath, root) {
|
|
62975
|
-
const resolvedRoot =
|
|
62976
|
-
const resolved =
|
|
62977
|
-
const rel =
|
|
62978
|
-
if (rel.startsWith("..") ||
|
|
64113
|
+
const resolvedRoot = path20.resolve(root);
|
|
64114
|
+
const resolved = path20.resolve(resolvedRoot, filePath);
|
|
64115
|
+
const rel = path20.relative(resolvedRoot, resolved);
|
|
64116
|
+
if (rel.startsWith("..") || path20.isAbsolute(rel)) {
|
|
62979
64117
|
throw new Error("path escapes the project root");
|
|
62980
64118
|
}
|
|
62981
64119
|
return resolved;
|
|
@@ -63074,7 +64212,7 @@ var init_server4 = __esm({
|
|
|
63074
64212
|
exists: fileExists(resolved) || isDirectory(resolved)
|
|
63075
64213
|
};
|
|
63076
64214
|
if (!result.exists) {
|
|
63077
|
-
const rename = await findRenames(root,
|
|
64215
|
+
const rename = await findRenames(root, path20.relative(root, resolved));
|
|
63078
64216
|
if (rename) {
|
|
63079
64217
|
result.renamed = true;
|
|
63080
64218
|
result.newPath = rename.newPath;
|
|
@@ -64495,8 +65633,8 @@ var init_suggestSimilar = __esm({
|
|
|
64495
65633
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/command.js
|
|
64496
65634
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
64497
65635
|
import childProcess from "node:child_process";
|
|
64498
|
-
import
|
|
64499
|
-
import
|
|
65636
|
+
import path21 from "node:path";
|
|
65637
|
+
import fs16 from "node:fs";
|
|
64500
65638
|
import process5 from "node:process";
|
|
64501
65639
|
import { stripVTControlCharacters as stripVTControlCharacters2 } from "node:util";
|
|
64502
65640
|
function incrementNodeInspectorPort(args2) {
|
|
@@ -65534,7 +66672,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
65534
66672
|
* @param {string} subcommandName
|
|
65535
66673
|
*/
|
|
65536
66674
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
65537
|
-
if (
|
|
66675
|
+
if (fs16.existsSync(executableFile)) return;
|
|
65538
66676
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
65539
66677
|
const executableMissing = `'${executableFile}' does not exist
|
|
65540
66678
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -65551,11 +66689,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
65551
66689
|
args2 = args2.slice();
|
|
65552
66690
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
65553
66691
|
function findFile(baseDir, baseName) {
|
|
65554
|
-
const localBin =
|
|
65555
|
-
if (
|
|
65556
|
-
if (sourceExt.includes(
|
|
66692
|
+
const localBin = path21.resolve(baseDir, baseName);
|
|
66693
|
+
if (fs16.existsSync(localBin)) return localBin;
|
|
66694
|
+
if (sourceExt.includes(path21.extname(baseName))) return void 0;
|
|
65557
66695
|
const foundExt = sourceExt.find(
|
|
65558
|
-
(ext) =>
|
|
66696
|
+
(ext) => fs16.existsSync(`${localBin}${ext}`)
|
|
65559
66697
|
);
|
|
65560
66698
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
65561
66699
|
return void 0;
|
|
@@ -65567,21 +66705,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
65567
66705
|
if (this._scriptPath) {
|
|
65568
66706
|
let resolvedScriptPath;
|
|
65569
66707
|
try {
|
|
65570
|
-
resolvedScriptPath =
|
|
66708
|
+
resolvedScriptPath = fs16.realpathSync(this._scriptPath);
|
|
65571
66709
|
} catch {
|
|
65572
66710
|
resolvedScriptPath = this._scriptPath;
|
|
65573
66711
|
}
|
|
65574
|
-
executableDir =
|
|
65575
|
-
|
|
66712
|
+
executableDir = path21.resolve(
|
|
66713
|
+
path21.dirname(resolvedScriptPath),
|
|
65576
66714
|
executableDir
|
|
65577
66715
|
);
|
|
65578
66716
|
}
|
|
65579
66717
|
if (executableDir) {
|
|
65580
66718
|
let localFile = findFile(executableDir, executableFile);
|
|
65581
66719
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
65582
|
-
const legacyName =
|
|
66720
|
+
const legacyName = path21.basename(
|
|
65583
66721
|
this._scriptPath,
|
|
65584
|
-
|
|
66722
|
+
path21.extname(this._scriptPath)
|
|
65585
66723
|
);
|
|
65586
66724
|
if (legacyName !== this._name) {
|
|
65587
66725
|
localFile = findFile(
|
|
@@ -65592,7 +66730,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
65592
66730
|
}
|
|
65593
66731
|
executableFile = localFile || executableFile;
|
|
65594
66732
|
}
|
|
65595
|
-
const launchWithNode = sourceExt.includes(
|
|
66733
|
+
const launchWithNode = sourceExt.includes(path21.extname(executableFile));
|
|
65596
66734
|
let proc;
|
|
65597
66735
|
if (process5.platform !== "win32") {
|
|
65598
66736
|
if (launchWithNode) {
|
|
@@ -66509,7 +67647,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
66509
67647
|
* @return {Command}
|
|
66510
67648
|
*/
|
|
66511
67649
|
nameFromFilename(filename) {
|
|
66512
|
-
this._name =
|
|
67650
|
+
this._name = path21.basename(filename, path21.extname(filename));
|
|
66513
67651
|
return this;
|
|
66514
67652
|
}
|
|
66515
67653
|
/**
|
|
@@ -66523,9 +67661,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
66523
67661
|
* @param {string} [path]
|
|
66524
67662
|
* @return {(string|null|Command)}
|
|
66525
67663
|
*/
|
|
66526
|
-
executableDir(
|
|
66527
|
-
if (
|
|
66528
|
-
this._executableDir =
|
|
67664
|
+
executableDir(path23) {
|
|
67665
|
+
if (path23 === void 0) return this._executableDir;
|
|
67666
|
+
this._executableDir = path23;
|
|
66529
67667
|
return this;
|
|
66530
67668
|
}
|
|
66531
67669
|
/**
|
|
@@ -69858,8 +70996,8 @@ var init_ora = __esm({
|
|
|
69858
70996
|
});
|
|
69859
70997
|
|
|
69860
70998
|
// src/core/reporter.ts
|
|
69861
|
-
import { existsSync as
|
|
69862
|
-
import { join as
|
|
70999
|
+
import { existsSync as existsSync11, readFileSync as readFileSync13 } from "node:fs";
|
|
71000
|
+
import { join as join18 } from "node:path";
|
|
69863
71001
|
function classifyFile(f) {
|
|
69864
71002
|
if (f.path === "(project)") return "context";
|
|
69865
71003
|
if (f.path === "(mcp)") return "mcp";
|
|
@@ -69883,9 +71021,9 @@ function isSyntheticBucket(p2) {
|
|
|
69883
71021
|
}
|
|
69884
71022
|
function detectVersionSkew(projectRoot, runningVersion) {
|
|
69885
71023
|
try {
|
|
69886
|
-
const pkgPath =
|
|
69887
|
-
if (!
|
|
69888
|
-
const raw =
|
|
71024
|
+
const pkgPath = join18(projectRoot, "package.json");
|
|
71025
|
+
if (!existsSync11(pkgPath)) return null;
|
|
71026
|
+
const raw = readFileSync13(pkgPath, "utf8").replace(/^\uFEFF/, "");
|
|
69889
71027
|
const pkg = JSON.parse(raw);
|
|
69890
71028
|
const name = pkg.name ?? "";
|
|
69891
71029
|
if (name !== "ctxlint" && name !== "@yawlabs/ctxlint") return null;
|
|
@@ -70385,11 +71523,11 @@ __export(cli_exports, {
|
|
|
70385
71523
|
promptYesNo: () => promptYesNo,
|
|
70386
71524
|
runCli: () => runCli
|
|
70387
71525
|
});
|
|
70388
|
-
import * as
|
|
70389
|
-
import * as
|
|
71526
|
+
import * as fs17 from "node:fs";
|
|
71527
|
+
import * as path22 from "node:path";
|
|
70390
71528
|
function existsAsDirectory(p2) {
|
|
70391
71529
|
try {
|
|
70392
|
-
return
|
|
71530
|
+
return fs17.statSync(p2).isDirectory();
|
|
70393
71531
|
} catch {
|
|
70394
71532
|
return false;
|
|
70395
71533
|
}
|
|
@@ -70416,7 +71554,7 @@ async function runCli() {
|
|
|
70416
71554
|
"Also scan the user-global ~/.claude/settings.json in the dead-hook check (off by default; the standard run only reads project .claude/settings.json[.local])",
|
|
70417
71555
|
false
|
|
70418
71556
|
).option("--no-ignore-file", "Disable .ctxlintignore suppression (see all findings)").option("--watch", "Re-lint on context file changes", false).action(async (projectPath, opts) => {
|
|
70419
|
-
const resolvedPath =
|
|
71557
|
+
const resolvedPath = path22.resolve(projectPath);
|
|
70420
71558
|
if (!existsAsDirectory(resolvedPath)) {
|
|
70421
71559
|
console.error(
|
|
70422
71560
|
`Error: ${resolvedPath} is not an existing directory. Check the path argument.`
|
|
@@ -70555,41 +71693,41 @@ Fixed ${applied.totalFixes} issue${applied.totalFixes !== 1 ? "s" : ""} in ${app
|
|
|
70555
71693
|
const chalk2 = (await Promise.resolve().then(() => (init_source(), source_exports))).default;
|
|
70556
71694
|
console.log(chalk2.dim("\nWatching for changes... (Ctrl+C to stop)\n"));
|
|
70557
71695
|
const watchPaths = [
|
|
70558
|
-
|
|
70559
|
-
|
|
70560
|
-
|
|
70561
|
-
|
|
70562
|
-
|
|
70563
|
-
|
|
70564
|
-
|
|
70565
|
-
|
|
70566
|
-
|
|
70567
|
-
|
|
70568
|
-
|
|
70569
|
-
|
|
70570
|
-
|
|
70571
|
-
|
|
70572
|
-
|
|
71696
|
+
path22.join(resolvedPath, "CLAUDE.md"),
|
|
71697
|
+
path22.join(resolvedPath, "CLAUDE.local.md"),
|
|
71698
|
+
path22.join(resolvedPath, "AGENTS.md"),
|
|
71699
|
+
path22.join(resolvedPath, "AGENT.md"),
|
|
71700
|
+
path22.join(resolvedPath, ".cursorrules"),
|
|
71701
|
+
path22.join(resolvedPath, ".windsurfrules"),
|
|
71702
|
+
path22.join(resolvedPath, ".clinerules"),
|
|
71703
|
+
path22.join(resolvedPath, ".aiderules"),
|
|
71704
|
+
path22.join(resolvedPath, ".continuerules"),
|
|
71705
|
+
path22.join(resolvedPath, ".rules"),
|
|
71706
|
+
path22.join(resolvedPath, ".goosehints"),
|
|
71707
|
+
path22.join(resolvedPath, "GEMINI.md"),
|
|
71708
|
+
path22.join(resolvedPath, "replit.md"),
|
|
71709
|
+
path22.join(resolvedPath, "package.json"),
|
|
71710
|
+
path22.join(resolvedPath, ".mcp.json"),
|
|
70573
71711
|
// ctxlint config — re-resolve on edit so threshold changes,
|
|
70574
71712
|
// ignore-list edits, and check-list overrides take effect without
|
|
70575
71713
|
// restarting the watcher.
|
|
70576
|
-
|
|
70577
|
-
|
|
71714
|
+
path22.join(resolvedPath, ".ctxlintrc"),
|
|
71715
|
+
path22.join(resolvedPath, ".ctxlintrc.json"),
|
|
70578
71716
|
// .ctxlintignore — re-lint when suppression rules change.
|
|
70579
|
-
|
|
71717
|
+
path22.join(resolvedPath, ".ctxlintignore")
|
|
70580
71718
|
];
|
|
70581
71719
|
const watchDirs = [
|
|
70582
|
-
|
|
70583
|
-
|
|
70584
|
-
|
|
70585
|
-
|
|
70586
|
-
|
|
70587
|
-
|
|
70588
|
-
|
|
70589
|
-
|
|
70590
|
-
|
|
70591
|
-
|
|
70592
|
-
|
|
71720
|
+
path22.join(resolvedPath, ".claude"),
|
|
71721
|
+
path22.join(resolvedPath, ".cursor"),
|
|
71722
|
+
path22.join(resolvedPath, ".github"),
|
|
71723
|
+
path22.join(resolvedPath, ".windsurf"),
|
|
71724
|
+
path22.join(resolvedPath, ".aide"),
|
|
71725
|
+
path22.join(resolvedPath, ".amazonq"),
|
|
71726
|
+
path22.join(resolvedPath, ".goose"),
|
|
71727
|
+
path22.join(resolvedPath, ".junie"),
|
|
71728
|
+
path22.join(resolvedPath, ".aiassistant"),
|
|
71729
|
+
path22.join(resolvedPath, ".continue"),
|
|
71730
|
+
path22.join(resolvedPath, ".vscode")
|
|
70593
71731
|
];
|
|
70594
71732
|
const watchers = [];
|
|
70595
71733
|
let debounceTimer = null;
|
|
@@ -70653,13 +71791,13 @@ Fixed ${applied.totalFixes} issue${applied.totalFixes !== 1 ? "s" : ""} in ${app
|
|
|
70653
71791
|
};
|
|
70654
71792
|
for (const filePath of watchPaths) {
|
|
70655
71793
|
try {
|
|
70656
|
-
watchers.push(
|
|
71794
|
+
watchers.push(fs17.watch(filePath, rerun));
|
|
70657
71795
|
} catch {
|
|
70658
71796
|
}
|
|
70659
71797
|
}
|
|
70660
71798
|
for (const dir of watchDirs) {
|
|
70661
71799
|
try {
|
|
70662
|
-
watchers.push(
|
|
71800
|
+
watchers.push(fs17.watch(dir, { recursive: true }, rerun));
|
|
70663
71801
|
} catch {
|
|
70664
71802
|
}
|
|
70665
71803
|
}
|
|
@@ -70680,17 +71818,17 @@ Fixed ${applied.totalFixes} issue${applied.totalFixes !== 1 ? "s" : ""} in ${app
|
|
|
70680
71818
|
}
|
|
70681
71819
|
});
|
|
70682
71820
|
program2.command("init").description("Set up a git pre-commit hook that runs ctxlint --strict").argument("[path]", "Project directory", ".").action(async (projectPath) => {
|
|
70683
|
-
const resolvedRoot =
|
|
70684
|
-
const gitDir =
|
|
70685
|
-
const hooksDir =
|
|
70686
|
-
if (!
|
|
71821
|
+
const resolvedRoot = path22.resolve(projectPath);
|
|
71822
|
+
const gitDir = path22.join(resolvedRoot, ".git");
|
|
71823
|
+
const hooksDir = path22.join(gitDir, "hooks");
|
|
71824
|
+
if (!fs17.existsSync(gitDir)) {
|
|
70687
71825
|
console.error('Error: not a git repository. Run "git init" first.');
|
|
70688
71826
|
process.exit(1);
|
|
70689
71827
|
}
|
|
70690
|
-
if (!
|
|
70691
|
-
|
|
71828
|
+
if (!fs17.existsSync(hooksDir)) {
|
|
71829
|
+
fs17.mkdirSync(hooksDir, { recursive: true });
|
|
70692
71830
|
}
|
|
70693
|
-
const hookPath =
|
|
71831
|
+
const hookPath = path22.join(hooksDir, "pre-commit");
|
|
70694
71832
|
const fullHookContent = `#!/bin/sh
|
|
70695
71833
|
# ctxlint pre-commit hook
|
|
70696
71834
|
npx @yawlabs/ctxlint@${VERSION} --strict
|
|
@@ -70699,15 +71837,15 @@ npx @yawlabs/ctxlint@${VERSION} --strict
|
|
|
70699
71837
|
# ctxlint pre-commit hook
|
|
70700
71838
|
npx @yawlabs/ctxlint@${VERSION} --strict
|
|
70701
71839
|
`;
|
|
70702
|
-
if (
|
|
70703
|
-
const existing =
|
|
71840
|
+
if (fs17.existsSync(hookPath)) {
|
|
71841
|
+
const existing = fs17.readFileSync(hookPath, "utf-8");
|
|
70704
71842
|
const installed = existing.match(
|
|
70705
71843
|
/^[^#\r\n]*\bnpx\s+(?:-y\s+|--yes\s+)?@yawlabs\/ctxlint(?:@(\d+\.\d+\.\d+))?/m
|
|
70706
71844
|
);
|
|
70707
71845
|
if (installed) {
|
|
70708
71846
|
const pinned = installed[1];
|
|
70709
71847
|
if (pinned && pinned !== VERSION) {
|
|
70710
|
-
|
|
71848
|
+
fs17.writeFileSync(
|
|
70711
71849
|
hookPath,
|
|
70712
71850
|
existing.replace(/(@yawlabs\/ctxlint@)\d+\.\d+\.\d+/g, `$1${VERSION}`)
|
|
70713
71851
|
);
|
|
@@ -70717,10 +71855,10 @@ npx @yawlabs/ctxlint@${VERSION} --strict
|
|
|
70717
71855
|
}
|
|
70718
71856
|
return;
|
|
70719
71857
|
}
|
|
70720
|
-
|
|
71858
|
+
fs17.appendFileSync(hookPath, appendHookContent);
|
|
70721
71859
|
console.log("Added ctxlint to existing pre-commit hook.");
|
|
70722
71860
|
} else {
|
|
70723
|
-
|
|
71861
|
+
fs17.writeFileSync(hookPath, fullHookContent, { mode: 493 });
|
|
70724
71862
|
console.log("Created pre-commit hook at .git/hooks/pre-commit");
|
|
70725
71863
|
}
|
|
70726
71864
|
console.log("ctxlint will now run automatically before each commit.");
|
|
@@ -70742,7 +71880,7 @@ function resolveDepth(raw) {
|
|
|
70742
71880
|
return Number.isNaN(parsed) ? 2 : Math.max(0, Math.min(parsed, 10));
|
|
70743
71881
|
}
|
|
70744
71882
|
function resolveSession(resolvedPath, opts, throwOnConfigError = false) {
|
|
70745
|
-
const configPath = opts.config ?
|
|
71883
|
+
const configPath = opts.config ? path22.resolve(opts.config) : void 0;
|
|
70746
71884
|
const config2 = configPath ? loadConfigFromPath(configPath, throwOnConfigError) : loadDiscoveredConfig(resolvedPath, throwOnConfigError);
|
|
70747
71885
|
const mcpGlobal = opts.mcpGlobal || config2?.mcpGlobal || false;
|
|
70748
71886
|
const mcpOnly = opts.mcpOnly || config2?.mcpOnly || false;
|