@wrongstack/plugins 0.308.6 → 0.308.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessibility-auditor.js +26 -82
- package/dist/agent-handoff.js +16 -26
- package/dist/auto-i18n-extractor.js +19 -23
- package/dist/branch-guard.js +19 -111
- package/dist/changelog-writer.js +20 -133
- package/dist/code-metrics.js +26 -71
- package/dist/commit-validator.js +16 -14
- package/dist/config-validator.js +18 -22
- package/dist/cost-tracker.js +15 -96
- package/dist/dead-code-detector.js +27 -31
- package/dist/dependency-vulnerability-gate.js +18 -15
- package/dist/diff-summary.js +19 -128
- package/dist/doc-sync-guard.js +24 -39
- package/dist/duplicate-code-detector.js +30 -169
- package/dist/feature-flag-tracker.js +26 -71
- package/dist/file-watcher.js +19 -23
- package/dist/format-on-save.js +25 -214
- package/dist/import-organizer.js +31 -106
- package/dist/index.js +452 -1236
- package/dist/interface-contract-guard.js +26 -71
- package/dist/lint-gate.js +19 -111
- package/dist/migration-planner.js +28 -120
- package/dist/notify-hub.js +18 -28
- package/dist/path-guard.js +27 -102
- package/dist/pr-drafter.js +18 -16
- package/dist/prompt-firewall.js +8 -205
- package/dist/refactor-suggester.js +27 -166
- package/dist/release-notes-generator.js +6 -35
- package/dist/runtime/bounded-map.d.ts +2 -85
- package/dist/runtime/credential-patterns.d.ts +2 -41
- package/dist/runtime/h1-state.d.ts +2 -61
- package/dist/runtime/handles.d.ts +2 -45
- package/dist/runtime/index.d.ts +8 -180
- package/dist/runtime/llm.d.ts +2 -43
- package/dist/runtime/local-bin.d.ts +2 -119
- package/dist/runtime/redos-guard.d.ts +2 -68
- package/dist/runtime/safe-json.d.ts +2 -24
- package/dist/runtime/sandbox.d.ts +2 -58
- package/dist/runtime.js +1 -868
- package/dist/schema-evolution-guard.js +20 -24
- package/dist/secret-scanner.js +22 -146
- package/dist/security-hotspot-scanner.js +24 -154
- package/dist/session-recap.js +16 -14
- package/dist/spec-linker.js +19 -17
- package/dist/template-engine.js +22 -37
- package/dist/test-coverage-gate.js +19 -34
- package/dist/test-generator.js +6 -35
- package/dist/test-runner-gate.js +34 -143
- package/dist/todo-listener.js +17 -38
- package/dist/type-gate.js +23 -311
- package/package.json +4 -3
package/dist/code-metrics.js
CHANGED
|
@@ -1,70 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
|
|
1
15
|
// src/code-metrics/index.ts
|
|
2
16
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { isAbsolute
|
|
4
|
-
|
|
5
|
-
// src/runtime/index.ts
|
|
6
|
-
import { basename, extname, isAbsolute, relative, resolve } from "node:path";
|
|
7
|
-
|
|
8
|
-
// src/runtime/local-bin.ts
|
|
9
|
-
import { buildWin32CmdShimInvocation, resolveWin32Command } from "@wrongstack/tools/win32";
|
|
17
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
10
18
|
|
|
11
19
|
// src/runtime/index.ts
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
function withinProjectPath(projectRoot, candidate) {
|
|
17
|
-
if (candidate.length === 0 || candidate.length > 4096) return false;
|
|
18
|
-
if (hasLeadingDash(candidate)) return false;
|
|
19
|
-
const resolved = isAbsolute(candidate) ? resolve(candidate) : resolve(projectRoot, candidate);
|
|
20
|
-
const rel = relative(projectRoot, resolved);
|
|
21
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
22
|
-
}
|
|
23
|
-
function withinProject(p) {
|
|
24
|
-
const cwd = process.cwd();
|
|
25
|
-
return withinProjectPath(cwd, p) || relative(cwd, p) === ".";
|
|
26
|
-
}
|
|
27
|
-
var DEFAULT_EXCLUDE_DIRS = ["node_modules", "dist", ".git", "coverage"];
|
|
28
|
-
async function collectSourceFilesAsync(root, opts) {
|
|
29
|
-
const { readdir, stat } = await import("node:fs/promises");
|
|
30
|
-
const files = [];
|
|
31
|
-
try {
|
|
32
|
-
const s = await stat(root);
|
|
33
|
-
if (s.isFile()) {
|
|
34
|
-
if (matchesExtension(root, opts.extensions)) files.push(root);
|
|
35
|
-
return files;
|
|
36
|
-
}
|
|
37
|
-
if (!s.isDirectory()) return files;
|
|
38
|
-
} catch {
|
|
39
|
-
return files;
|
|
40
|
-
}
|
|
41
|
-
const exclude = opts.excludeDirs ?? DEFAULT_EXCLUDE_DIRS;
|
|
42
|
-
const excludeSet = new Set(exclude);
|
|
43
|
-
async function walk(dir, depth) {
|
|
44
|
-
if (opts.maxDepth !== void 0 && depth > opts.maxDepth) return;
|
|
45
|
-
let entries;
|
|
46
|
-
try {
|
|
47
|
-
entries = await readdir(dir, { withFileTypes: true });
|
|
48
|
-
} catch {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
52
|
-
for (const entry of entries) {
|
|
53
|
-
if (excludeSet.has(entry.name)) continue;
|
|
54
|
-
const full = resolve(dir, entry.name);
|
|
55
|
-
if (entry.isDirectory()) {
|
|
56
|
-
await walk(full, depth + 1);
|
|
57
|
-
} else if (entry.isFile() && matchesExtension(full, opts.extensions)) {
|
|
58
|
-
files.push(full);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
await walk(root, 0);
|
|
63
|
-
return files;
|
|
64
|
-
}
|
|
65
|
-
function matchesExtension(p, exts) {
|
|
66
|
-
return exts.includes(extname(p).toLowerCase());
|
|
67
|
-
}
|
|
20
|
+
var runtime_exports = {};
|
|
21
|
+
__reExport(runtime_exports, runtime_star);
|
|
22
|
+
import * as runtime_star from "@wrongstack/plugin-sdk/runtime";
|
|
68
23
|
|
|
69
24
|
// src/code-metrics/index.ts
|
|
70
25
|
var API_VERSION = "^0.1.10";
|
|
@@ -96,7 +51,7 @@ function toPosix(p) {
|
|
|
96
51
|
return p.replace(/\\/g, "/");
|
|
97
52
|
}
|
|
98
53
|
function relativePath(p) {
|
|
99
|
-
return toPosix(
|
|
54
|
+
return toPosix(relative(process.cwd(), p));
|
|
100
55
|
}
|
|
101
56
|
function countFunctions(content) {
|
|
102
57
|
let count = 0;
|
|
@@ -202,9 +157,9 @@ function analyzeFile(filePath, content) {
|
|
|
202
157
|
}
|
|
203
158
|
async function measurePath(rawPath, cfg) {
|
|
204
159
|
const root = process.cwd();
|
|
205
|
-
const resolved =
|
|
160
|
+
const resolved = isAbsolute(rawPath) ? resolve(rawPath) : resolve(root, rawPath);
|
|
206
161
|
const exts = normalizeExtensions(cfg.extensions);
|
|
207
|
-
const allFiles = await collectSourceFilesAsync(resolved, { extensions: exts });
|
|
162
|
+
const allFiles = await (0, runtime_exports.collectSourceFilesAsync)(resolved, { extensions: exts });
|
|
208
163
|
const files = allFiles.slice(0, cfg.maxFiles);
|
|
209
164
|
const metrics = [];
|
|
210
165
|
for (const p of files) {
|
|
@@ -261,11 +216,11 @@ var plugin = {
|
|
|
261
216
|
const inp = input.toolInput ?? {};
|
|
262
217
|
const sourcePath = inp["path"];
|
|
263
218
|
if (!sourcePath || typeof sourcePath !== "string") return;
|
|
264
|
-
if (!withinProject(sourcePath)) return;
|
|
219
|
+
if (!(0, runtime_exports.withinProject)(sourcePath)) return;
|
|
265
220
|
const exts = normalizeExtensions(cfg.extensions);
|
|
266
|
-
if (!matchesExtension(sourcePath, exts)) return;
|
|
221
|
+
if (!(0, runtime_exports.matchesExtension)(sourcePath, exts)) return;
|
|
267
222
|
state.hookInvocationCount += 1;
|
|
268
|
-
const resolved =
|
|
223
|
+
const resolved = resolve(process.cwd(), sourcePath);
|
|
269
224
|
let content;
|
|
270
225
|
try {
|
|
271
226
|
content = await readFile(resolved, "utf-8");
|
|
@@ -295,7 +250,7 @@ var plugin = {
|
|
|
295
250
|
async execute(input) {
|
|
296
251
|
if (!cfg.enabled) return { ok: false, error: "code-metrics is disabled" };
|
|
297
252
|
const rawPath = typeof input.path === "string" ? input.path : ".";
|
|
298
|
-
if (!withinProject(rawPath)) {
|
|
253
|
+
if (!(0, runtime_exports.withinProject)(rawPath)) {
|
|
299
254
|
return { ok: false, error: "path is outside the project root" };
|
|
300
255
|
}
|
|
301
256
|
state.measureCount += 1;
|
|
@@ -309,7 +264,7 @@ var plugin = {
|
|
|
309
264
|
state.fileCount += result.files.length;
|
|
310
265
|
return {
|
|
311
266
|
ok: true,
|
|
312
|
-
path: relativePath(
|
|
267
|
+
path: relativePath(resolve(process.cwd(), rawPath)),
|
|
313
268
|
files: result.files,
|
|
314
269
|
totalFiles: result.totalFiles,
|
|
315
270
|
capped: result.totalFiles > cfg.maxFiles
|
package/dist/commit-validator.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
10
|
}
|
|
12
|
-
return
|
|
13
|
-
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
14
|
|
|
15
15
|
// src/runtime/index.ts
|
|
16
|
-
var
|
|
16
|
+
var runtime_exports = {};
|
|
17
|
+
__reExport(runtime_exports, runtime_star);
|
|
18
|
+
import * as runtime_star from "@wrongstack/plugin-sdk/runtime";
|
|
17
19
|
|
|
18
20
|
// src/commit-validator/index.ts
|
|
19
21
|
var API_VERSION = "^0.1.10";
|
|
@@ -209,7 +211,7 @@ var plugin = {
|
|
|
209
211
|
state.invalidCount = 0;
|
|
210
212
|
state.suggestFixCount = 0;
|
|
211
213
|
state.suggestFixErrors = 0;
|
|
212
|
-
state.hookUnregister = releaseHandle(state.hookUnregister);
|
|
214
|
+
state.hookUnregister = (0, runtime_exports.releaseHandle)(state.hookUnregister);
|
|
213
215
|
state.lastValidation = null;
|
|
214
216
|
const cfg = readConfig(api.config.extensions?.["commit-validator"]);
|
|
215
217
|
const hook = async (input) => {
|
package/dist/config-validator.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
|
|
1
15
|
// src/config-validator/index.ts
|
|
2
16
|
import { readFileSync, statSync } from "node:fs";
|
|
3
17
|
|
|
4
18
|
// src/runtime/index.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { buildWin32CmdShimInvocation, resolveWin32Command } from "@wrongstack/tools/win32";
|
|
9
|
-
|
|
10
|
-
// src/runtime/index.ts
|
|
11
|
-
var MAX_BUFFER_BYTES = 16 * 1024 * 1024;
|
|
12
|
-
function hasLeadingDash(arg) {
|
|
13
|
-
return arg.length > 0 && arg.startsWith("-");
|
|
14
|
-
}
|
|
15
|
-
function withinProjectPath(projectRoot, candidate) {
|
|
16
|
-
if (candidate.length === 0 || candidate.length > 4096) return false;
|
|
17
|
-
if (hasLeadingDash(candidate)) return false;
|
|
18
|
-
const resolved = isAbsolute(candidate) ? resolve(candidate) : resolve(projectRoot, candidate);
|
|
19
|
-
const rel = relative(projectRoot, resolved);
|
|
20
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
21
|
-
}
|
|
22
|
-
function withinProject(p) {
|
|
23
|
-
const cwd = process.cwd();
|
|
24
|
-
return withinProjectPath(cwd, p) || relative(cwd, p) === ".";
|
|
25
|
-
}
|
|
19
|
+
var runtime_exports = {};
|
|
20
|
+
__reExport(runtime_exports, runtime_star);
|
|
21
|
+
import * as runtime_star from "@wrongstack/plugin-sdk/runtime";
|
|
26
22
|
|
|
27
23
|
// src/config-validator/index.ts
|
|
28
24
|
var state = {
|
|
@@ -285,7 +281,7 @@ var plugin = {
|
|
|
285
281
|
const ti = input.toolInput ?? {};
|
|
286
282
|
const raw = ti["path"] ?? ti["file_path"] ?? ti["filePath"];
|
|
287
283
|
if (typeof raw !== "string" || raw.length === 0) return;
|
|
288
|
-
if (!withinProject(raw)) return;
|
|
284
|
+
if (!(0, runtime_exports.withinProject)(raw)) return;
|
|
289
285
|
const lower = raw.toLowerCase();
|
|
290
286
|
if (!cfg.extensions.some((ext) => lower.endsWith(ext))) return;
|
|
291
287
|
let text;
|
package/dist/cost-tracker.js
CHANGED
|
@@ -1,102 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** Entries dropped to stay under `max`. Surfaced by plugin health(). */
|
|
11
|
-
evictions = 0;
|
|
12
|
-
constructor(options) {
|
|
13
|
-
const normalizedMax = Math.floor(options.max);
|
|
14
|
-
this.max = Number.isSafeInteger(normalizedMax) ? Math.max(1, normalizedMax) : 1;
|
|
15
|
-
this.ttlMs = options.ttlMs;
|
|
16
|
-
this.now = options.now ?? Date.now;
|
|
17
|
-
}
|
|
18
|
-
expired(entry) {
|
|
19
|
-
return this.ttlMs !== void 0 && this.now() - entry.storedAt > this.ttlMs;
|
|
20
|
-
}
|
|
21
|
-
get(key) {
|
|
22
|
-
const entry = this.map.get(key);
|
|
23
|
-
if (entry === void 0) return void 0;
|
|
24
|
-
if (this.expired(entry)) {
|
|
25
|
-
this.map.delete(key);
|
|
26
|
-
return void 0;
|
|
27
|
-
}
|
|
28
|
-
this.map.delete(key);
|
|
29
|
-
this.map.set(key, entry);
|
|
30
|
-
return entry.value;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Read without promoting the key to most-recently-used. Use for
|
|
34
|
-
* diagnostics that must not perturb the eviction order.
|
|
35
|
-
*/
|
|
36
|
-
peek(key) {
|
|
37
|
-
const entry = this.map.get(key);
|
|
38
|
-
if (entry === void 0 || this.expired(entry)) return void 0;
|
|
39
|
-
return entry.value;
|
|
40
|
-
}
|
|
41
|
-
has(key) {
|
|
42
|
-
const entry = this.map.get(key);
|
|
43
|
-
if (entry === void 0) return false;
|
|
44
|
-
if (this.expired(entry)) {
|
|
45
|
-
this.map.delete(key);
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
set(key, value) {
|
|
51
|
-
this.map.delete(key);
|
|
52
|
-
this.map.set(key, { value, storedAt: this.now() });
|
|
53
|
-
while (this.map.size > this.max) {
|
|
54
|
-
const coldest = this.map.keys().next().value;
|
|
55
|
-
if (coldest === void 0) break;
|
|
56
|
-
this.map.delete(coldest);
|
|
57
|
-
this.evictions += 1;
|
|
58
|
-
}
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
delete(key) {
|
|
62
|
-
return this.map.delete(key);
|
|
63
|
-
}
|
|
64
|
-
clear() {
|
|
65
|
-
this.map.clear();
|
|
66
|
-
this.evictions = 0;
|
|
67
|
-
}
|
|
68
|
-
get size() {
|
|
69
|
-
return this.map.size;
|
|
70
|
-
}
|
|
71
|
-
/** How many entries have been dropped to respect `max`, since the last clear. */
|
|
72
|
-
get evictionCount() {
|
|
73
|
-
return this.evictions;
|
|
74
|
-
}
|
|
75
|
-
/** Drop every expired entry. Cheap enough to call from a status tool. */
|
|
76
|
-
prune() {
|
|
77
|
-
if (this.ttlMs === void 0) return 0;
|
|
78
|
-
let removed = 0;
|
|
79
|
-
for (const [key, entry] of this.map) {
|
|
80
|
-
if (this.expired(entry)) {
|
|
81
|
-
this.map.delete(key);
|
|
82
|
-
removed += 1;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return removed;
|
|
86
|
-
}
|
|
87
|
-
/** Live (non-expired) entries, coldest first. */
|
|
88
|
-
*entries() {
|
|
89
|
-
for (const [key, entry] of this.map) {
|
|
90
|
-
if (!this.expired(entry)) yield [key, entry.value];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
[Symbol.iterator]() {
|
|
94
|
-
return this.entries();
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
95
10
|
}
|
|
11
|
+
return to;
|
|
96
12
|
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
97
14
|
|
|
98
15
|
// src/runtime/index.ts
|
|
99
|
-
var
|
|
16
|
+
var runtime_exports = {};
|
|
17
|
+
__reExport(runtime_exports, runtime_star);
|
|
18
|
+
import * as runtime_star from "@wrongstack/plugin-sdk/runtime";
|
|
100
19
|
|
|
101
20
|
// src/cost-tracker/index.ts
|
|
102
21
|
import { expectDefined } from "@wrongstack/core/utils";
|
|
@@ -128,7 +47,7 @@ function readCostTrackerConfig(raw) {
|
|
|
128
47
|
mailboxDigestTo: typeof digestTo === "string" && digestTo.length > 0 ? digestTo : "cost-tracker"
|
|
129
48
|
};
|
|
130
49
|
}
|
|
131
|
-
var modelKeyCache = new BoundedMap({ max: 256 });
|
|
50
|
+
var modelKeyCache = new runtime_exports.BoundedMap({ max: 256 });
|
|
132
51
|
function estimateCost(model, promptTokens, completionTokens) {
|
|
133
52
|
let key = modelKeyCache.get(model);
|
|
134
53
|
if (!key) {
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
|
|
1
15
|
// src/dead-code-detector/index.ts
|
|
2
16
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
3
|
-
import { extname
|
|
17
|
+
import { extname, join, relative, resolve } from "node:path";
|
|
4
18
|
|
|
5
19
|
// src/runtime/index.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { buildWin32CmdShimInvocation, resolveWin32Command } from "@wrongstack/tools/win32";
|
|
10
|
-
|
|
11
|
-
// src/runtime/index.ts
|
|
12
|
-
var MAX_BUFFER_BYTES = 16 * 1024 * 1024;
|
|
13
|
-
function hasLeadingDash(arg) {
|
|
14
|
-
return arg.length > 0 && arg.startsWith("-");
|
|
15
|
-
}
|
|
16
|
-
function withinProjectPath(projectRoot, candidate) {
|
|
17
|
-
if (candidate.length === 0 || candidate.length > 4096) return false;
|
|
18
|
-
if (hasLeadingDash(candidate)) return false;
|
|
19
|
-
const resolved = isAbsolute(candidate) ? resolve(candidate) : resolve(projectRoot, candidate);
|
|
20
|
-
const rel = relative(projectRoot, resolved);
|
|
21
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
22
|
-
}
|
|
23
|
-
function withinProject(p) {
|
|
24
|
-
const cwd = process.cwd();
|
|
25
|
-
return withinProjectPath(cwd, p) || relative(cwd, p) === ".";
|
|
26
|
-
}
|
|
20
|
+
var runtime_exports = {};
|
|
21
|
+
__reExport(runtime_exports, runtime_star);
|
|
22
|
+
import * as runtime_star from "@wrongstack/plugin-sdk/runtime";
|
|
27
23
|
|
|
28
24
|
// src/dead-code-detector/index.ts
|
|
29
25
|
var API_VERSION = "^0.1.10";
|
|
@@ -71,14 +67,14 @@ async function gatherFiles(root, depth, cfg) {
|
|
|
71
67
|
await walk(join(dir, entry.name), remaining - 1);
|
|
72
68
|
}
|
|
73
69
|
} else if (entry.isFile()) {
|
|
74
|
-
const ext =
|
|
70
|
+
const ext = extname(entry.name).toLowerCase();
|
|
75
71
|
if (cfg.extensions.includes(ext)) {
|
|
76
72
|
files.push(join(dir, entry.name));
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
|
-
await walk(
|
|
77
|
+
await walk(resolve(root), depth);
|
|
82
78
|
return files;
|
|
83
79
|
}
|
|
84
80
|
function stripNoise(content) {
|
|
@@ -171,11 +167,11 @@ async function scan(root, depth, cfg) {
|
|
|
171
167
|
return { findings: await findUnusedSymbols(files), scannedFiles: files.length };
|
|
172
168
|
}
|
|
173
169
|
async function resolveScanRoot(rawPath) {
|
|
174
|
-
const resolved =
|
|
170
|
+
const resolved = resolve(process.cwd(), rawPath);
|
|
175
171
|
try {
|
|
176
172
|
const stats = await stat(resolved);
|
|
177
173
|
if (!stats.isDirectory()) {
|
|
178
|
-
return
|
|
174
|
+
return resolve(resolved, "..");
|
|
179
175
|
}
|
|
180
176
|
} catch {
|
|
181
177
|
}
|
|
@@ -185,7 +181,7 @@ function toPosix(p) {
|
|
|
185
181
|
return p.replace(/\\/g, "/");
|
|
186
182
|
}
|
|
187
183
|
function relativePath(p) {
|
|
188
|
-
return toPosix(
|
|
184
|
+
return toPosix(relative(process.cwd(), p));
|
|
189
185
|
}
|
|
190
186
|
var plugin = {
|
|
191
187
|
name: "dead-code-detector",
|
|
@@ -244,7 +240,7 @@ var plugin = {
|
|
|
244
240
|
const inp = input.toolInput ?? {};
|
|
245
241
|
const sourcePath = inp["path"];
|
|
246
242
|
if (!sourcePath || typeof sourcePath !== "string") return;
|
|
247
|
-
if (!withinProject(sourcePath)) return;
|
|
243
|
+
if (!(0, runtime_exports.withinProject)(sourcePath)) return;
|
|
248
244
|
const ext = sourcePath.includes(".") ? sourcePath.slice(sourcePath.lastIndexOf(".")).toLowerCase() : "";
|
|
249
245
|
if (!cfg.extensions.includes(ext)) return;
|
|
250
246
|
state.hookInvocationCount += 1;
|
|
@@ -256,8 +252,8 @@ var plugin = {
|
|
|
256
252
|
state.errorCount += 1;
|
|
257
253
|
return;
|
|
258
254
|
}
|
|
259
|
-
const changedFile =
|
|
260
|
-
const relevant = result.findings.filter((f) =>
|
|
255
|
+
const changedFile = resolve(process.cwd(), sourcePath);
|
|
256
|
+
const relevant = result.findings.filter((f) => resolve(f.file) === changedFile);
|
|
261
257
|
if (relevant.length === 0) {
|
|
262
258
|
state.missCount += 1;
|
|
263
259
|
return;
|
|
@@ -302,7 +298,7 @@ Consider removing the export if it is not part of the public API.`;
|
|
|
302
298
|
const rawPath = typeof input.path === "string" ? input.path : ".";
|
|
303
299
|
const rawDepth = typeof input.depth === "number" ? input.depth : cfg.defaultDepth;
|
|
304
300
|
const depth = Math.max(0, Math.min(Math.floor(rawDepth), cfg.maxDepth));
|
|
305
|
-
if (!withinProject(rawPath)) {
|
|
301
|
+
if (!(0, runtime_exports.withinProject)(rawPath)) {
|
|
306
302
|
return { ok: false, error: "scan path is outside the project root" };
|
|
307
303
|
}
|
|
308
304
|
state.scanCount += 1;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
|
|
1
15
|
// src/dependency-vulnerability-gate/index.ts
|
|
2
16
|
import { execFile } from "node:child_process";
|
|
3
17
|
import { access } from "node:fs/promises";
|
|
4
18
|
|
|
5
|
-
// src/runtime/local-bin.ts
|
|
6
|
-
import { buildWin32CmdShimInvocation, resolveWin32Command } from "@wrongstack/tools/win32";
|
|
7
|
-
function resolveExecInvocation(command, args = []) {
|
|
8
|
-
const resolved = resolveWin32Command(command);
|
|
9
|
-
const normalizedResolved = resolved.toLowerCase();
|
|
10
|
-
const needsShell = process.platform === "win32" && (normalizedResolved.endsWith(".cmd") || normalizedResolved.endsWith(".bat"));
|
|
11
|
-
if (needsShell) {
|
|
12
|
-
const shim = buildWin32CmdShimInvocation(resolved, args);
|
|
13
|
-
return { cmd: shim.command, args: shim.args, windowsVerbatimArguments: true };
|
|
14
|
-
}
|
|
15
|
-
return { cmd: resolved, args: [...args], windowsVerbatimArguments: false };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
19
|
// src/runtime/index.ts
|
|
19
|
-
var
|
|
20
|
+
var runtime_exports = {};
|
|
21
|
+
__reExport(runtime_exports, runtime_star);
|
|
22
|
+
import * as runtime_star from "@wrongstack/plugin-sdk/runtime";
|
|
20
23
|
|
|
21
24
|
// src/dep-guard/index.ts
|
|
22
25
|
var state = {
|
|
@@ -524,7 +527,7 @@ async function runAudit(cfg) {
|
|
|
524
527
|
const start = Date.now();
|
|
525
528
|
let invocation;
|
|
526
529
|
try {
|
|
527
|
-
invocation = resolveExecInvocation(manager, ["audit", "--json"]);
|
|
530
|
+
invocation = (0, runtime_exports.resolveExecInvocation)(manager, ["audit", "--json"]);
|
|
528
531
|
} catch {
|
|
529
532
|
return null;
|
|
530
533
|
}
|