@wrongstack/plugins 0.308.5 → 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/import-organizer.js
CHANGED
|
@@ -1,101 +1,26 @@
|
|
|
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/import-organizer/index.ts
|
|
2
16
|
import { spawn } from "node:child_process";
|
|
3
17
|
import { existsSync, statSync } from "node:fs";
|
|
4
|
-
import { basename
|
|
5
|
-
|
|
6
|
-
// src/runtime/index.ts
|
|
7
|
-
import { basename, extname as extname2, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve2 } from "node:path";
|
|
8
|
-
|
|
9
|
-
// src/runtime/local-bin.ts
|
|
10
|
-
import { createRequire } from "node:module";
|
|
11
|
-
import { delimiter, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
12
|
-
import { accessSync, constants, readFileSync } from "node:fs";
|
|
13
|
-
import { buildWin32CmdShimInvocation, resolveWin32Command } from "@wrongstack/tools/win32";
|
|
14
|
-
function resolveExecInvocation(command, args = []) {
|
|
15
|
-
const resolved = resolveWin32Command(command);
|
|
16
|
-
const normalizedResolved = resolved.toLowerCase();
|
|
17
|
-
const needsShell = process.platform === "win32" && (normalizedResolved.endsWith(".cmd") || normalizedResolved.endsWith(".bat"));
|
|
18
|
-
if (needsShell) {
|
|
19
|
-
const shim = buildWin32CmdShimInvocation(resolved, args);
|
|
20
|
-
return { cmd: shim.command, args: shim.args, windowsVerbatimArguments: true };
|
|
21
|
-
}
|
|
22
|
-
return { cmd: resolved, args: [...args], windowsVerbatimArguments: false };
|
|
23
|
-
}
|
|
24
|
-
function isInside(parent, candidate) {
|
|
25
|
-
const rel = relative(parent, candidate);
|
|
26
|
-
return rel === "" || !rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute(rel);
|
|
27
|
-
}
|
|
28
|
-
var binCache = /* @__PURE__ */ new Map();
|
|
29
|
-
var BIN_CACHE_MAX = 64;
|
|
30
|
-
var NEGATIVE_BIN_CACHE_TTL_MS = 5e3;
|
|
31
|
-
function cachePut(key, value) {
|
|
32
|
-
while (binCache.size >= BIN_CACHE_MAX) {
|
|
33
|
-
const oldest = binCache.keys().next().value;
|
|
34
|
-
if (oldest === void 0) break;
|
|
35
|
-
binCache.delete(oldest);
|
|
36
|
-
}
|
|
37
|
-
binCache.set(key, { value, cachedAt: Date.now() });
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
function clearLocalBinCache() {
|
|
41
|
-
binCache.clear();
|
|
42
|
-
}
|
|
43
|
-
function resolveNodeBin(packageName, binName, cwd, extraArgs = []) {
|
|
44
|
-
const key = `${packageName}|${binName}|${cwd}`;
|
|
45
|
-
const cached = binCache.get(key);
|
|
46
|
-
if (cached !== void 0) {
|
|
47
|
-
if (cached.value !== null || Date.now() - cached.cachedAt < NEGATIVE_BIN_CACHE_TTL_MS) {
|
|
48
|
-
return cached.value === null ? null : { ...cached.value, args: [cached.value.entry, ...extraArgs] };
|
|
49
|
-
}
|
|
50
|
-
binCache.delete(key);
|
|
51
|
-
}
|
|
52
|
-
let resolved = null;
|
|
53
|
-
try {
|
|
54
|
-
const requireFromProject = createRequire(resolve(cwd, "package.json"));
|
|
55
|
-
const packagePath = requireFromProject.resolve(`${packageName}/package.json`);
|
|
56
|
-
const packageJson = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
57
|
-
const relativeBin = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin?.[binName] ?? Object.values(packageJson.bin ?? {})[0];
|
|
58
|
-
if (relativeBin && !isAbsolute(relativeBin)) {
|
|
59
|
-
const packageDir = dirname(packagePath);
|
|
60
|
-
const entry = resolve(packageDir, relativeBin);
|
|
61
|
-
if (isInside(packageDir, entry)) {
|
|
62
|
-
resolved = { cmd: process.execPath, args: [entry], entry };
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
} catch {
|
|
66
|
-
resolved = null;
|
|
67
|
-
}
|
|
68
|
-
cachePut(key, resolved);
|
|
69
|
-
return resolved === null ? null : { ...resolved, args: [resolved.entry, ...extraArgs] };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/runtime/handles.ts
|
|
73
|
-
function releaseHandle(off) {
|
|
74
|
-
if (off) {
|
|
75
|
-
try {
|
|
76
|
-
off();
|
|
77
|
-
} catch {
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
18
|
+
import { basename, isAbsolute } from "node:path";
|
|
82
19
|
|
|
83
20
|
// src/runtime/index.ts
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
function withinProjectPath(projectRoot, candidate) {
|
|
89
|
-
if (candidate.length === 0 || candidate.length > 4096) return false;
|
|
90
|
-
if (hasLeadingDash(candidate)) return false;
|
|
91
|
-
const resolved = isAbsolute2(candidate) ? resolve2(candidate) : resolve2(projectRoot, candidate);
|
|
92
|
-
const rel = relative2(projectRoot, resolved);
|
|
93
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
94
|
-
}
|
|
95
|
-
function withinProject(p) {
|
|
96
|
-
const cwd = process.cwd();
|
|
97
|
-
return withinProjectPath(cwd, p) || relative2(cwd, p) === ".";
|
|
98
|
-
}
|
|
21
|
+
var runtime_exports = {};
|
|
22
|
+
__reExport(runtime_exports, runtime_star);
|
|
23
|
+
import * as runtime_star from "@wrongstack/plugin-sdk/runtime";
|
|
99
24
|
|
|
100
25
|
// src/import-organizer/index.ts
|
|
101
26
|
var ALLOWED_FIRST_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -132,7 +57,7 @@ function resolveLocalToolCommand(tokens) {
|
|
|
132
57
|
const rest = tokens.slice(i + 1);
|
|
133
58
|
const pkg = LOCAL_BIN_PACKAGES[toolToken];
|
|
134
59
|
if (!pkg) return null;
|
|
135
|
-
const local = resolveNodeBin(pkg.packageName, pkg.binName, process.cwd(), rest);
|
|
60
|
+
const local = (0, runtime_exports.resolveNodeBin)(pkg.packageName, pkg.binName, process.cwd(), rest);
|
|
136
61
|
if (!local) return null;
|
|
137
62
|
return { cmd: local.cmd, args: local.args };
|
|
138
63
|
}
|
|
@@ -151,7 +76,7 @@ function resolveAllowedCommand(command) {
|
|
|
151
76
|
if (head === "node") {
|
|
152
77
|
const target = tokens[1];
|
|
153
78
|
if (!target) return null;
|
|
154
|
-
const base =
|
|
79
|
+
const base = basename(target);
|
|
155
80
|
if (!(base in LOCAL_BIN_PACKAGES) && !ALLOWED_FIRST_TOKENS.has(base)) return null;
|
|
156
81
|
}
|
|
157
82
|
const local = ALLOWED_FIRST_TOKENS.has(head) ? resolveLocalToolCommand(tokens) : null;
|
|
@@ -159,13 +84,13 @@ function resolveAllowedCommand(command) {
|
|
|
159
84
|
if (ALLOWED_FIRST_TOKENS.has(head)) {
|
|
160
85
|
return { cmd: head, args: tokens.slice(1) };
|
|
161
86
|
}
|
|
162
|
-
if (
|
|
163
|
-
if (!withinProject(head)) return null;
|
|
164
|
-
const base =
|
|
87
|
+
if (isAbsolute(head)) {
|
|
88
|
+
if (!(0, runtime_exports.withinProject)(head)) return null;
|
|
89
|
+
const base = basename(head);
|
|
165
90
|
if (ALLOWED_FIRST_TOKENS.has(base)) return { cmd: head, args: tokens.slice(1) };
|
|
166
91
|
}
|
|
167
|
-
if (!
|
|
168
|
-
const base =
|
|
92
|
+
if (!isAbsolute(head) && (0, runtime_exports.withinProject)(head)) {
|
|
93
|
+
const base = basename(head);
|
|
169
94
|
if (ALLOWED_FIRST_TOKENS.has(base)) return { cmd: head, args: tokens.slice(1) };
|
|
170
95
|
}
|
|
171
96
|
return null;
|
|
@@ -201,13 +126,13 @@ function readConfig(raw) {
|
|
|
201
126
|
}
|
|
202
127
|
var MAX_CAPTURE_BYTES = 4 * 1024 * 1024;
|
|
203
128
|
function runCommand(command, args, timeoutMs, cwd) {
|
|
204
|
-
return new Promise((
|
|
129
|
+
return new Promise((resolve) => {
|
|
205
130
|
let timedOut = false;
|
|
206
131
|
let settled = false;
|
|
207
132
|
const settle = (r) => {
|
|
208
133
|
if (settled) return;
|
|
209
134
|
settled = true;
|
|
210
|
-
|
|
135
|
+
resolve(r);
|
|
211
136
|
};
|
|
212
137
|
const stdoutChunks = [];
|
|
213
138
|
const stderrChunks = [];
|
|
@@ -222,7 +147,7 @@ function runCommand(command, args, timeoutMs, cwd) {
|
|
|
222
147
|
let child;
|
|
223
148
|
let invocation;
|
|
224
149
|
try {
|
|
225
|
-
invocation = resolveExecInvocation(command, args);
|
|
150
|
+
invocation = (0, runtime_exports.resolveExecInvocation)(command, args);
|
|
226
151
|
} catch {
|
|
227
152
|
signal.removeEventListener("abort", onAbort);
|
|
228
153
|
settle({ code: 127, stdout: "", stderr: "", timedOut: false });
|
|
@@ -266,7 +191,7 @@ function runCommand(command, args, timeoutMs, cwd) {
|
|
|
266
191
|
});
|
|
267
192
|
}
|
|
268
193
|
async function organizeImports(filePath, cfg, cwd) {
|
|
269
|
-
if (!withinProject(filePath)) return null;
|
|
194
|
+
if (!(0, runtime_exports.withinProject)(filePath)) return null;
|
|
270
195
|
if (!existsSync(filePath)) return null;
|
|
271
196
|
let bytesBefore;
|
|
272
197
|
try {
|
|
@@ -346,7 +271,7 @@ var plugin = {
|
|
|
346
271
|
state.organizedCount = 0;
|
|
347
272
|
state.cleanCount = 0;
|
|
348
273
|
state.errorCount = 0;
|
|
349
|
-
state.hookUnregister = releaseHandle(state.hookUnregister);
|
|
274
|
+
state.hookUnregister = (0, runtime_exports.releaseHandle)(state.hookUnregister);
|
|
350
275
|
state.lastResult = null;
|
|
351
276
|
state.probeComplete = false;
|
|
352
277
|
state.linterAvailable = false;
|
|
@@ -453,7 +378,7 @@ ${result.stderr.trim()}`
|
|
|
453
378
|
});
|
|
454
379
|
},
|
|
455
380
|
teardown(api) {
|
|
456
|
-
clearLocalBinCache();
|
|
381
|
+
(0, runtime_exports.clearLocalBinCache)();
|
|
457
382
|
if (state.hookUnregister) {
|
|
458
383
|
try {
|
|
459
384
|
state.hookUnregister();
|