@wrongstack/plugins 0.318.0 → 0.319.1
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 +21 -4
- package/dist/api-compatibility-gate.js +3 -1
- package/dist/auto-i18n-extractor.js +9 -3
- package/dist/changelog-writer.js +1 -4
- package/dist/code-metrics.js +3 -1
- package/dist/config-validator.js +6 -2
- package/dist/context-pins.js +4 -1
- package/dist/cost-tracker.js +3 -1
- package/dist/cron.js +8 -2
- package/dist/dep-guard.js +3 -1
- package/dist/dependency-vulnerability-gate.js +3 -1
- package/dist/diff-summary.js +9 -3
- package/dist/doc-sync-guard.js +6 -2
- package/dist/feature-flag-tracker.js +3 -1
- package/dist/format-on-save.js +3 -1
- package/dist/import-organizer.js +3 -1
- package/dist/index.js +342 -121
- package/dist/interface-contract-guard.js +3 -1
- package/dist/knowledge-graph.js +9 -4
- package/dist/license-audit-gate.js +15 -3
- package/dist/path-guard.js +8 -2
- package/dist/pr-drafter.js +3 -1
- package/dist/process-guard.js +3 -1
- package/dist/prompt-firewall.js +14 -4
- package/dist/refactor-suggester.js +3 -1
- package/dist/security-hotspot-scanner.js +21 -3
- package/dist/semantic-search-indexer/index.d.ts +26 -0
- package/dist/semantic-search-indexer.js +100 -12
- package/dist/semver-bump.js +17 -12
- package/dist/shell-check.js +7 -10
- package/dist/smart-rename.js +8 -6
- package/dist/spec-linker.js +3 -1
- package/dist/template-engine.js +18 -12
- package/dist/test-flake-detector.js +1 -4
- package/dist/test-generator.js +3 -1
- package/dist/test-runner-gate.js +27 -15
- package/dist/type-gate.js +3 -1
- package/package.json +5 -5
|
@@ -200,7 +200,9 @@ var plugin = {
|
|
|
200
200
|
If you changed member shapes, search the project for implementers/\`satisfies\`/\`as\` usages and update them accordingly.`
|
|
201
201
|
};
|
|
202
202
|
};
|
|
203
|
-
state.hookUnregister = api.registerHook("PostToolUse", "write|edit", hook, {
|
|
203
|
+
state.hookUnregister = api.registerHook("PostToolUse", "write|edit", hook, {
|
|
204
|
+
background: true
|
|
205
|
+
});
|
|
204
206
|
api.tools.register({
|
|
205
207
|
name: "check_interface_contracts",
|
|
206
208
|
description: "Scan TypeScript files for interface declarations that have no visible implementer (implements / as / satisfies).",
|
package/dist/knowledge-graph.js
CHANGED
|
@@ -240,9 +240,12 @@ var plugin = {
|
|
|
240
240
|
const hasMatch = f.subject.toLowerCase().includes(q) || f.relation.toLowerCase().includes(q) || f.object.toLowerCase().includes(q);
|
|
241
241
|
if (!hasMatch) return false;
|
|
242
242
|
}
|
|
243
|
-
if (input.subject && !f.subject.toLowerCase().includes(input.subject.toLowerCase()))
|
|
244
|
-
|
|
245
|
-
if (input.
|
|
243
|
+
if (input.subject && !f.subject.toLowerCase().includes(input.subject.toLowerCase()))
|
|
244
|
+
return false;
|
|
245
|
+
if (input.relation && !f.relation.toLowerCase().includes(input.relation.toLowerCase()))
|
|
246
|
+
return false;
|
|
247
|
+
if (input.object && !f.object.toLowerCase().includes(input.object.toLowerCase()))
|
|
248
|
+
return false;
|
|
246
249
|
if (filterConf && f.confidence.toLowerCase() !== filterConf) return false;
|
|
247
250
|
return true;
|
|
248
251
|
});
|
|
@@ -274,7 +277,9 @@ var plugin = {
|
|
|
274
277
|
const raw = input ?? {};
|
|
275
278
|
const rawId = String(input.id ?? raw["factId"] ?? raw["fact_id"] ?? "").trim();
|
|
276
279
|
const normalized = rawId.toLowerCase().startsWith("kg-") ? rawId.toLowerCase() : `kg-${rawId.toLowerCase()}`;
|
|
277
|
-
state.facts = state.facts.filter(
|
|
280
|
+
state.facts = state.facts.filter(
|
|
281
|
+
(f) => f.id.toLowerCase() !== normalized && f.id !== rawId
|
|
282
|
+
);
|
|
278
283
|
const removed = before - state.facts.length;
|
|
279
284
|
if (removed === 0) return { ok: false, error: `no fact matches "${input.id ?? rawId}"` };
|
|
280
285
|
state.removals += removed;
|
|
@@ -52,7 +52,9 @@ function parseInstallCommands(command) {
|
|
|
52
52
|
if (!cleaned) continue;
|
|
53
53
|
let name = cleaned;
|
|
54
54
|
let version = null;
|
|
55
|
-
const pipMatch = /^([A-Za-z0-9_.-]+(?:\[[^\]]+\])?)\s*(==|>=|<=|~=|!=|>|<)\s*(.+)$/.exec(
|
|
55
|
+
const pipMatch = /^([A-Za-z0-9_.-]+(?:\[[^\]]+\])?)\s*(==|>=|<=|~=|!=|>|<)\s*(.+)$/.exec(
|
|
56
|
+
cleaned
|
|
57
|
+
);
|
|
56
58
|
if (pipMatch?.[1]) {
|
|
57
59
|
name = pipMatch[1];
|
|
58
60
|
const op = pipMatch[2] ?? "";
|
|
@@ -391,7 +393,15 @@ var state2 = {
|
|
|
391
393
|
};
|
|
392
394
|
var DEFAULTS2 = {
|
|
393
395
|
enabled: true,
|
|
394
|
-
allowedLicenses: [
|
|
396
|
+
allowedLicenses: [
|
|
397
|
+
"MIT",
|
|
398
|
+
"Apache-2.0",
|
|
399
|
+
"BSD-2-Clause",
|
|
400
|
+
"BSD-3-Clause",
|
|
401
|
+
"ISC",
|
|
402
|
+
"0BSD",
|
|
403
|
+
"Unlicense"
|
|
404
|
+
],
|
|
395
405
|
block: true
|
|
396
406
|
};
|
|
397
407
|
function normalizeStrings(v) {
|
|
@@ -430,7 +440,9 @@ function extractLicenseStrings(pkg) {
|
|
|
430
440
|
}
|
|
431
441
|
function parsePackageNames(command) {
|
|
432
442
|
return [
|
|
433
|
-
...new Set(
|
|
443
|
+
...new Set(
|
|
444
|
+
parseInstallCommands(command).flatMap((entry) => entry.packages.map((pkg) => pkg.name))
|
|
445
|
+
)
|
|
434
446
|
];
|
|
435
447
|
}
|
|
436
448
|
function splitTopLevel(expr, separator) {
|
package/dist/path-guard.js
CHANGED
|
@@ -1469,9 +1469,15 @@ var plugin = {
|
|
|
1469
1469
|
kind: isRootPathScope(path) && deletesImplicitScope || isUnresolvedPathScope(path) || recursivelyDeletes && (isDirectoryAmbiguousPath(path) || hasConfiguredProtectedDescendant(path, cfg.protect)) ? "deletion-scope" : "file"
|
|
1470
1470
|
};
|
|
1471
1471
|
if (targetFullyAllowed(target, cfg.allow, allowRes)) return null;
|
|
1472
|
-
const protectedShellTarget = await targetIntersectsPatternsGuarded(target, cfg.protect, protectRes, {
|
|
1472
|
+
const protectedShellTarget = await targetIntersectsPatternsGuarded(target, cfg.protect, protectRes, {
|
|
1473
1473
|
onTimeout: bumpRedos
|
|
1474
|
-
})
|
|
1474
|
+
}) || await matchesAnyGuarded(
|
|
1475
|
+
`${target.path.replace(/\/$/, "")}/.path-guard-probe`,
|
|
1476
|
+
protectRes,
|
|
1477
|
+
{
|
|
1478
|
+
onTimeout: bumpRedos
|
|
1479
|
+
}
|
|
1480
|
+
);
|
|
1475
1481
|
return protectedShellTarget ? target : null;
|
|
1476
1482
|
})
|
|
1477
1483
|
);
|
package/dist/pr-drafter.js
CHANGED
|
@@ -286,7 +286,9 @@ var plugin = {
|
|
|
286
286
|
async execute(input = {}) {
|
|
287
287
|
if (!cfg.enabled) return { ok: false, error: "pr-drafter is disabled" };
|
|
288
288
|
const raw = input ?? {};
|
|
289
|
-
const preview = Boolean(
|
|
289
|
+
const preview = Boolean(
|
|
290
|
+
input?.preview ?? raw["dryRun"] ?? raw["dry_run"] ?? raw["dry"] ?? raw["previewOnly"]
|
|
291
|
+
);
|
|
290
292
|
const rawOutputPath = raw["outputPath"] ?? raw["output_path"] ?? raw["path"] ?? raw["filePath"] ?? raw["file"] ?? raw["TargetFile"] ?? raw["targetFile"] ?? cfg.outputPath;
|
|
291
293
|
const outputPathStr = typeof rawOutputPath === "string" && rawOutputPath.trim().length > 0 ? rawOutputPath.trim() : cfg.outputPath;
|
|
292
294
|
const draft = await buildDraft(cfg, api.llm);
|
package/dist/process-guard.js
CHANGED
|
@@ -64,7 +64,9 @@ var plugin = {
|
|
|
64
64
|
const rawCmd = ti["command"] ?? ti["CommandLine"] ?? ti["cmd"] ?? ti["script"] ?? ti["input"];
|
|
65
65
|
const command = typeof rawCmd === "string" ? rawCmd : "";
|
|
66
66
|
if (!command) return;
|
|
67
|
-
const isKillRelated = /\b(?:kill|taskkill|stop-process|tskill|pkill|killall|wmic)\b/i.test(
|
|
67
|
+
const isKillRelated = /\b(?:kill|taskkill|stop-process|tskill|pkill|killall|wmic)\b/i.test(
|
|
68
|
+
command
|
|
69
|
+
);
|
|
68
70
|
if (!isKillRelated) return;
|
|
69
71
|
state.detections += 1;
|
|
70
72
|
state.lastDetection = {
|
package/dist/prompt-firewall.js
CHANGED
|
@@ -293,9 +293,12 @@ function surfaceScanTrips(api, tripped) {
|
|
|
293
293
|
}
|
|
294
294
|
state.timeoutCount += 1;
|
|
295
295
|
api.metrics.counter("redos_skips", 1);
|
|
296
|
-
api.log.warn(
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
api.log.warn(
|
|
297
|
+
"prompt-firewall: scan-pass budget exceeded \u2014 patterns skipped mid-pass (issue #370)",
|
|
298
|
+
{
|
|
299
|
+
skipped: [...tripped]
|
|
300
|
+
}
|
|
301
|
+
);
|
|
299
302
|
}
|
|
300
303
|
var plugin = {
|
|
301
304
|
name: "prompt-firewall",
|
|
@@ -397,7 +400,14 @@ var plugin = {
|
|
|
397
400
|
if (cfg.mode === "redact") {
|
|
398
401
|
const counter = { n: 0 };
|
|
399
402
|
const deadline = createScanDeadline();
|
|
400
|
-
const redactedReq = redactDeep(
|
|
403
|
+
const redactedReq = redactDeep(
|
|
404
|
+
req,
|
|
405
|
+
cfg.allow,
|
|
406
|
+
counter,
|
|
407
|
+
skipSet,
|
|
408
|
+
void 0,
|
|
409
|
+
deadline
|
|
410
|
+
);
|
|
401
411
|
state.requestRedactions += counter.n;
|
|
402
412
|
api.metrics.counter("request_redactions", counter.n);
|
|
403
413
|
if (deadline.tripped.size > 0) surfaceScanTrips(api, deadline.tripped);
|
|
@@ -295,7 +295,9 @@ var plugin = {
|
|
|
295
295
|
contextAs: "separate"
|
|
296
296
|
};
|
|
297
297
|
};
|
|
298
|
-
state.hookUnregister = api.registerHook("PostToolUse", "write|edit", hook, {
|
|
298
|
+
state.hookUnregister = api.registerHook("PostToolUse", "write|edit", hook, {
|
|
299
|
+
background: true
|
|
300
|
+
});
|
|
299
301
|
api.tools.register({
|
|
300
302
|
name: "suggest_refactors",
|
|
301
303
|
description: "Scan source files for refactoring smells: long functions, deep nesting, many parameters, magic numbers, and console logging.",
|
|
@@ -38,7 +38,19 @@ var DEFAULTS = {
|
|
|
38
38
|
enabled: false,
|
|
39
39
|
severity: "warn",
|
|
40
40
|
maxFindings: 10,
|
|
41
|
-
scanOnChange: [
|
|
41
|
+
scanOnChange: [
|
|
42
|
+
".js",
|
|
43
|
+
".jsx",
|
|
44
|
+
".ts",
|
|
45
|
+
".tsx",
|
|
46
|
+
".mjs",
|
|
47
|
+
".cjs",
|
|
48
|
+
".py",
|
|
49
|
+
".java",
|
|
50
|
+
".go",
|
|
51
|
+
".rb",
|
|
52
|
+
".php"
|
|
53
|
+
]
|
|
42
54
|
};
|
|
43
55
|
var scanOnChangeSet = new Set(DEFAULTS.scanOnChange);
|
|
44
56
|
function readConfig(raw) {
|
|
@@ -61,7 +73,11 @@ function readConfig(raw) {
|
|
|
61
73
|
}
|
|
62
74
|
var PATTERNS = [
|
|
63
75
|
{ type: "eval_call", severity: "high", regex: /\beval\s*\(/i },
|
|
64
|
-
{
|
|
76
|
+
{
|
|
77
|
+
type: "function_constructor",
|
|
78
|
+
severity: "high",
|
|
79
|
+
regex: /\bnew\s+Function\s*\(|\bFunction\s*\(/i
|
|
80
|
+
},
|
|
65
81
|
{
|
|
66
82
|
type: "unsafe_html",
|
|
67
83
|
severity: "high",
|
|
@@ -299,7 +315,9 @@ Review or remove the risky pattern(s).`;
|
|
|
299
315
|
}
|
|
300
316
|
return { additionalContext: message };
|
|
301
317
|
};
|
|
302
|
-
state.hookUnregister = api.registerHook("PostToolUse", "write|edit", hook, {
|
|
318
|
+
state.hookUnregister = api.registerHook("PostToolUse", "write|edit", hook, {
|
|
319
|
+
background: true
|
|
320
|
+
});
|
|
303
321
|
api.tools.register({
|
|
304
322
|
name: "security_hotspot_scan",
|
|
305
323
|
description: "Scan a file or directory for security anti-patterns (eval, Function constructor, innerHTML, SQL concatenation, http URLs, credential logging, variable exec commands).",
|
|
@@ -42,6 +42,32 @@ interface SemanticSearchConfig {
|
|
|
42
42
|
maxFiles: number;
|
|
43
43
|
}
|
|
44
44
|
export declare function readConfig(raw: unknown): SemanticSearchConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Remove one indexed file's entries (postings + file record) from the index.
|
|
47
|
+
* The stored lines re-derive exactly the terms that were indexed for the
|
|
48
|
+
* file, so each term's posting for it can be dropped and emptied posting
|
|
49
|
+
* maps pruned — no rebuild needed.
|
|
50
|
+
*/
|
|
51
|
+
declare function removeFileFromIndex(relPath: string, cfg: SemanticSearchConfig): void;
|
|
52
|
+
/**
|
|
53
|
+
* Stat-scan the indexed files and drop entries whose file no longer exists —
|
|
54
|
+
* the delete-side counterpart of the write-path generation bump. Shell tools
|
|
55
|
+
* cannot be matched to exact deleted paths reliably, so instead of a full
|
|
56
|
+
* rebuild we prune exactly the dead entries. Throttled and single-flight;
|
|
57
|
+
* resolves with the number of entries removed.
|
|
58
|
+
*/
|
|
59
|
+
declare function pruneDeletedFiles(rootPath: string, cfg: SemanticSearchConfig, opts?: {
|
|
60
|
+
force?: boolean;
|
|
61
|
+
}): Promise<number>;
|
|
45
62
|
declare const plugin: Plugin;
|
|
63
|
+
/**
|
|
64
|
+
* Test seam: direct access to the incremental delete-prune. `force` bypasses
|
|
65
|
+
* the throttle window (production callers go through the PostToolUse hook).
|
|
66
|
+
*/
|
|
67
|
+
export declare const semanticIndexerCoverage: {
|
|
68
|
+
removeFileFromIndex: typeof removeFileFromIndex;
|
|
69
|
+
pruneDeletedFiles: typeof pruneDeletedFiles;
|
|
70
|
+
readConfig: typeof readConfig;
|
|
71
|
+
};
|
|
46
72
|
export default plugin;
|
|
47
73
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -16,7 +16,10 @@ var state = {
|
|
|
16
16
|
buildPromise: null,
|
|
17
17
|
buildGeneration: 0,
|
|
18
18
|
publishedGeneration: 0,
|
|
19
|
-
hookUnregister: null
|
|
19
|
+
hookUnregister: null,
|
|
20
|
+
deleteHookUnregister: null,
|
|
21
|
+
lastPruneAt: 0,
|
|
22
|
+
pruneInFlight: null
|
|
20
23
|
};
|
|
21
24
|
var DEFAULTS = {
|
|
22
25
|
enabled: true,
|
|
@@ -49,11 +52,7 @@ var DEFAULTS = {
|
|
|
49
52
|
".scss",
|
|
50
53
|
".html"
|
|
51
54
|
],
|
|
52
|
-
excludePatterns: [
|
|
53
|
-
...DEFAULT_WALK_IGNORE_DIRS.map(escapeRegex),
|
|
54
|
-
"\\.wrongstack",
|
|
55
|
-
"\\.temp_files"
|
|
56
|
-
],
|
|
55
|
+
excludePatterns: [...DEFAULT_WALK_IGNORE_DIRS.map(escapeRegex), "\\.wrongstack", "\\.temp_files"],
|
|
57
56
|
maxFileBytes: 1e6,
|
|
58
57
|
defaultLimit: 10,
|
|
59
58
|
minTokenLength: 2,
|
|
@@ -61,7 +60,12 @@ var DEFAULTS = {
|
|
|
61
60
|
maxFiles: 5e3
|
|
62
61
|
};
|
|
63
62
|
function readConfig(raw) {
|
|
64
|
-
if (!raw || typeof raw !== "object")
|
|
63
|
+
if (!raw || typeof raw !== "object")
|
|
64
|
+
return {
|
|
65
|
+
...DEFAULTS,
|
|
66
|
+
includeExtensions: [...DEFAULTS.includeExtensions],
|
|
67
|
+
excludePatterns: [...DEFAULTS.excludePatterns]
|
|
68
|
+
};
|
|
65
69
|
const r = raw;
|
|
66
70
|
const rawExts = r["includeExtensions"] ?? r["include_extensions"] ?? r["extensions"] ?? r["file_extensions"];
|
|
67
71
|
const includeExtensions = Array.isArray(rawExts) ? rawExts.filter((x) => typeof x === "string") : [...DEFAULTS.includeExtensions];
|
|
@@ -131,11 +135,11 @@ var YIELD_EVERY_FILES = 64;
|
|
|
131
135
|
function yieldEventLoop() {
|
|
132
136
|
return new Promise((resolve2) => setImmediate(resolve2));
|
|
133
137
|
}
|
|
134
|
-
function addFileToIndex(relPath, content, size, cfg) {
|
|
138
|
+
function addFileToIndex(relPath, absPath, content, size, cfg) {
|
|
135
139
|
if (!state.index || content.includes("\0")) return;
|
|
136
140
|
state.bytesIndexed += content.length;
|
|
137
141
|
const lines = content.split(/\r?\n/);
|
|
138
|
-
state.index.files.set(relPath, { lines, size });
|
|
142
|
+
state.index.files.set(relPath, { lines, size, absPath });
|
|
139
143
|
for (let i = 0; i < lines.length; i += 1) {
|
|
140
144
|
const terms = tokenize(lines[i], cfg.minTokenLength);
|
|
141
145
|
for (const term of terms) {
|
|
@@ -161,7 +165,7 @@ async function indexFileFromStats(absPath, relPath, stats, cfg) {
|
|
|
161
165
|
} catch {
|
|
162
166
|
return;
|
|
163
167
|
}
|
|
164
|
-
addFileToIndex(relPath, content, stats.size, cfg);
|
|
168
|
+
addFileToIndex(relPath, absPath, content, stats.size, cfg);
|
|
165
169
|
}
|
|
166
170
|
async function flushFileBatch(batch, cfg) {
|
|
167
171
|
if (batch.length === 0) return;
|
|
@@ -254,6 +258,51 @@ async function ensureIndex(rootPath, cfg) {
|
|
|
254
258
|
state.cachedPath = null;
|
|
255
259
|
}
|
|
256
260
|
}
|
|
261
|
+
var PRUNE_MIN_INTERVAL_MS = 3e4;
|
|
262
|
+
function removeFileFromIndex(relPath, cfg) {
|
|
263
|
+
const index = state.index;
|
|
264
|
+
if (!index) return;
|
|
265
|
+
const entry = index.files.get(relPath);
|
|
266
|
+
if (!entry) return;
|
|
267
|
+
const terms = /* @__PURE__ */ new Set();
|
|
268
|
+
for (const line of entry.lines) {
|
|
269
|
+
for (const term of tokenize(line, cfg.minTokenLength)) terms.add(term);
|
|
270
|
+
}
|
|
271
|
+
for (const term of terms) {
|
|
272
|
+
const postings = index.terms.get(term);
|
|
273
|
+
if (!postings) continue;
|
|
274
|
+
postings.delete(relPath);
|
|
275
|
+
if (postings.size === 0) index.terms.delete(term);
|
|
276
|
+
}
|
|
277
|
+
index.files.delete(relPath);
|
|
278
|
+
state.fileCount = Math.max(0, state.fileCount - 1);
|
|
279
|
+
state.bytesIndexed = Math.max(0, state.bytesIndexed - entry.size);
|
|
280
|
+
state.termCount = index.terms.size;
|
|
281
|
+
}
|
|
282
|
+
async function pruneDeletedFiles(rootPath, cfg, opts) {
|
|
283
|
+
const index = state.index;
|
|
284
|
+
if (!index || state.cachedPath !== rootPath) return 0;
|
|
285
|
+
if (state.pruneInFlight) return state.pruneInFlight;
|
|
286
|
+
const now = Date.now();
|
|
287
|
+
if (!opts?.force && now - state.lastPruneAt < PRUNE_MIN_INTERVAL_MS) return 0;
|
|
288
|
+
state.lastPruneAt = now;
|
|
289
|
+
const pass = (async () => {
|
|
290
|
+
const missing = [];
|
|
291
|
+
for (const [relPath, entry] of index.files) {
|
|
292
|
+
try {
|
|
293
|
+
await fs.stat(entry.absPath);
|
|
294
|
+
} catch {
|
|
295
|
+
missing.push(relPath);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
for (const relPath of missing) removeFileFromIndex(relPath, cfg);
|
|
299
|
+
return missing.length;
|
|
300
|
+
})();
|
|
301
|
+
state.pruneInFlight = pass.finally(() => {
|
|
302
|
+
state.pruneInFlight = null;
|
|
303
|
+
});
|
|
304
|
+
return pass;
|
|
305
|
+
}
|
|
257
306
|
function compareRankedCandidates(a, b) {
|
|
258
307
|
return b.score - a.score || a.path.localeCompare(b.path);
|
|
259
308
|
}
|
|
@@ -327,7 +376,11 @@ var plugin = {
|
|
|
327
376
|
description: "Builds an in-memory keyword index over project source files and answers ranked search queries",
|
|
328
377
|
apiVersion: API_VERSION,
|
|
329
378
|
capabilities: { tools: true },
|
|
330
|
-
defaultConfig: {
|
|
379
|
+
defaultConfig: {
|
|
380
|
+
...DEFAULTS,
|
|
381
|
+
includeExtensions: [...DEFAULTS.includeExtensions],
|
|
382
|
+
excludePatterns: [...DEFAULTS.excludePatterns]
|
|
383
|
+
},
|
|
331
384
|
configSchema: {
|
|
332
385
|
type: "object",
|
|
333
386
|
properties: {
|
|
@@ -400,6 +453,15 @@ var plugin = {
|
|
|
400
453
|
}
|
|
401
454
|
state.hookUnregister = null;
|
|
402
455
|
}
|
|
456
|
+
if (state.deleteHookUnregister) {
|
|
457
|
+
try {
|
|
458
|
+
state.deleteHookUnregister();
|
|
459
|
+
} catch {
|
|
460
|
+
}
|
|
461
|
+
state.deleteHookUnregister = null;
|
|
462
|
+
}
|
|
463
|
+
state.lastPruneAt = 0;
|
|
464
|
+
state.pruneInFlight = null;
|
|
403
465
|
const cfg = readConfig(api.config.extensions?.["semantic-search-indexer"]);
|
|
404
466
|
api.tools.register({
|
|
405
467
|
name: "semantic_search",
|
|
@@ -509,6 +571,17 @@ var plugin = {
|
|
|
509
571
|
{ background: true }
|
|
510
572
|
);
|
|
511
573
|
}
|
|
574
|
+
if (typeof api.registerHook === "function") {
|
|
575
|
+
state.deleteHookUnregister = api.registerHook(
|
|
576
|
+
"PostToolUse",
|
|
577
|
+
"bash|exec|pwsh|delete_file|remove_file",
|
|
578
|
+
(() => {
|
|
579
|
+
const root = state.cachedPath;
|
|
580
|
+
if (root) void pruneDeletedFiles(root, cfg);
|
|
581
|
+
}),
|
|
582
|
+
{ background: true }
|
|
583
|
+
);
|
|
584
|
+
}
|
|
512
585
|
api.log.info("semantic-search-indexer plugin loaded", {
|
|
513
586
|
version: "0.1.0",
|
|
514
587
|
defaultLimit: cfg.defaultLimit,
|
|
@@ -523,6 +596,13 @@ var plugin = {
|
|
|
523
596
|
}
|
|
524
597
|
state.hookUnregister = null;
|
|
525
598
|
}
|
|
599
|
+
if (state.deleteHookUnregister) {
|
|
600
|
+
try {
|
|
601
|
+
state.deleteHookUnregister();
|
|
602
|
+
} catch {
|
|
603
|
+
}
|
|
604
|
+
state.deleteHookUnregister = null;
|
|
605
|
+
}
|
|
526
606
|
const final = {
|
|
527
607
|
fileCount: state.fileCount,
|
|
528
608
|
termCount: state.termCount,
|
|
@@ -540,6 +620,8 @@ var plugin = {
|
|
|
540
620
|
state.buildPromise = null;
|
|
541
621
|
state.buildGeneration = 0;
|
|
542
622
|
state.publishedGeneration = 0;
|
|
623
|
+
state.lastPruneAt = 0;
|
|
624
|
+
state.pruneInFlight = null;
|
|
543
625
|
api.log.info("semantic-search-indexer: teardown complete", { final });
|
|
544
626
|
},
|
|
545
627
|
async health() {
|
|
@@ -556,8 +638,14 @@ var plugin = {
|
|
|
556
638
|
};
|
|
557
639
|
}
|
|
558
640
|
};
|
|
641
|
+
var semanticIndexerCoverage = {
|
|
642
|
+
removeFileFromIndex,
|
|
643
|
+
pruneDeletedFiles,
|
|
644
|
+
readConfig
|
|
645
|
+
};
|
|
559
646
|
var semantic_search_indexer_default = plugin;
|
|
560
647
|
export {
|
|
561
648
|
semantic_search_indexer_default as default,
|
|
562
|
-
readConfig
|
|
649
|
+
readConfig,
|
|
650
|
+
semanticIndexerCoverage
|
|
563
651
|
};
|
package/dist/semver-bump.js
CHANGED
|
@@ -23,19 +23,24 @@ var state = {
|
|
|
23
23
|
};
|
|
24
24
|
function runCommand(command, args, cwd) {
|
|
25
25
|
return new Promise((resolve2, reject) => {
|
|
26
|
-
execFile(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
execFile(
|
|
27
|
+
command,
|
|
28
|
+
args,
|
|
29
|
+
{
|
|
30
|
+
encoding: "utf-8",
|
|
31
|
+
cwd,
|
|
32
|
+
timeout: 3e4,
|
|
33
|
+
windowsHide: true
|
|
34
|
+
},
|
|
35
|
+
(err, stdout, stderr) => {
|
|
36
|
+
if (!err) {
|
|
37
|
+
resolve2(stdout.trim());
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const failure = err;
|
|
41
|
+
reject(Object.assign(failure, { stderr: stderr || void 0 }));
|
|
35
42
|
}
|
|
36
|
-
|
|
37
|
-
reject(Object.assign(failure, { stderr: stderr || void 0 }));
|
|
38
|
-
});
|
|
43
|
+
);
|
|
39
44
|
});
|
|
40
45
|
}
|
|
41
46
|
async function runGit(args, cwd) {
|
package/dist/shell-check.js
CHANGED
|
@@ -26,15 +26,10 @@ var state = {
|
|
|
26
26
|
async function runShellCheck(files, severity, cwd) {
|
|
27
27
|
try {
|
|
28
28
|
await new Promise((resolvePromise, rejectPromise) => {
|
|
29
|
-
execFile(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(err) => {
|
|
34
|
-
if (err) rejectPromise(err);
|
|
35
|
-
else resolvePromise();
|
|
36
|
-
}
|
|
37
|
-
);
|
|
29
|
+
execFile("shellcheck", ["--version"], { encoding: "utf-8", windowsHide: true }, (err) => {
|
|
30
|
+
if (err) rejectPromise(err);
|
|
31
|
+
else resolvePromise();
|
|
32
|
+
});
|
|
38
33
|
});
|
|
39
34
|
} catch {
|
|
40
35
|
throw new Error(
|
|
@@ -195,7 +190,9 @@ var plugin = {
|
|
|
195
190
|
if (typeof rawFiles === "string" && rawFiles.trim().length > 0) {
|
|
196
191
|
files = [rawFiles.trim()];
|
|
197
192
|
} else if (Array.isArray(rawFiles)) {
|
|
198
|
-
files = rawFiles.filter(
|
|
193
|
+
files = rawFiles.filter(
|
|
194
|
+
(f) => typeof f === "string" && f.trim().length > 0
|
|
195
|
+
);
|
|
199
196
|
}
|
|
200
197
|
}
|
|
201
198
|
const rawDirectory = inp.directory ?? input["dir"] ?? input["SearchDirectory"];
|
package/dist/smart-rename.js
CHANGED
|
@@ -15,7 +15,8 @@ function normalizeExtensions(exts) {
|
|
|
15
15
|
return exts.map((e) => e.startsWith(".") ? e.toLowerCase() : `.${e.toLowerCase()}`);
|
|
16
16
|
}
|
|
17
17
|
function readConfig(raw) {
|
|
18
|
-
if (!raw || typeof raw !== "object")
|
|
18
|
+
if (!raw || typeof raw !== "object")
|
|
19
|
+
return { ...DEFAULTS, extensions: normalizeExtensions(DEFAULTS.extensions) };
|
|
19
20
|
const r = raw;
|
|
20
21
|
const rawExts = r["extensions"] ?? r["file_extensions"] ?? r["fileExtensions"];
|
|
21
22
|
const exts = Array.isArray(rawExts) ? rawExts.filter((x) => typeof x === "string") : DEFAULTS.extensions;
|
|
@@ -48,10 +49,7 @@ function isIdentifier(name) {
|
|
|
48
49
|
return IDENTIFIER_RE.test(name);
|
|
49
50
|
}
|
|
50
51
|
function renameInContent(content, oldName, newName) {
|
|
51
|
-
const re = new RegExp(
|
|
52
|
-
`(?<![A-Za-z0-9_$])${escapeRegex(oldName)}(?![A-Za-z0-9_$])`,
|
|
53
|
-
"g"
|
|
54
|
-
);
|
|
52
|
+
const re = new RegExp(`(?<![A-Za-z0-9_$])${escapeRegex(oldName)}(?![A-Za-z0-9_$])`, "g");
|
|
55
53
|
let replacements = 0;
|
|
56
54
|
const preview = content.replace(re, () => {
|
|
57
55
|
replacements++;
|
|
@@ -92,7 +90,11 @@ var plugin = {
|
|
|
92
90
|
path: { type: "string", description: "Source file path (relative to project root)." },
|
|
93
91
|
oldName: { type: "string", description: "Identifier to replace." },
|
|
94
92
|
newName: { type: "string", description: "New identifier." },
|
|
95
|
-
apply: {
|
|
93
|
+
apply: {
|
|
94
|
+
type: "boolean",
|
|
95
|
+
default: false,
|
|
96
|
+
description: "When true, write the preview back to disk."
|
|
97
|
+
}
|
|
96
98
|
},
|
|
97
99
|
required: ["path", "oldName", "newName"]
|
|
98
100
|
},
|
package/dist/spec-linker.js
CHANGED
|
@@ -434,7 +434,9 @@ var plugin = {
|
|
|
434
434
|
${lines}${overflowNote}`
|
|
435
435
|
};
|
|
436
436
|
};
|
|
437
|
-
state.postHookUnregister = api.registerHook("PostToolUse", "write|edit", postHook, {
|
|
437
|
+
state.postHookUnregister = api.registerHook("PostToolUse", "write|edit", postHook, {
|
|
438
|
+
background: true
|
|
439
|
+
});
|
|
438
440
|
if (cfg.autoFix) {
|
|
439
441
|
const preHook = async (input) => {
|
|
440
442
|
if (!cfg.enabled) return;
|
package/dist/template-engine.js
CHANGED
|
@@ -43,21 +43,27 @@ function expandTemplate(template, variables) {
|
|
|
43
43
|
return result;
|
|
44
44
|
}
|
|
45
45
|
function expandConditionals(template, variables) {
|
|
46
|
-
return template.replace(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
return template.replace(
|
|
47
|
+
/\{\{#if\s+([\w.-]+)\s*\}\}([\s\S]*?)\{\{\/if\}\}/g,
|
|
48
|
+
(_, key, content) => {
|
|
49
|
+
const val = variables[key];
|
|
50
|
+
return val !== void 0 && val !== "" && val !== "false" && val !== "0" ? content : "";
|
|
51
|
+
}
|
|
52
|
+
);
|
|
50
53
|
}
|
|
51
54
|
function expandLoops(template, variables) {
|
|
52
|
-
return template.replace(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
return template.replace(
|
|
56
|
+
/\{\{#each\s+([\w.-]+)\s*\}\}([\s\S]*?)\{\{\/each\}\}/g,
|
|
57
|
+
(_, key, content) => {
|
|
58
|
+
const val = variables[key];
|
|
59
|
+
if (!val) return "";
|
|
60
|
+
if (typeof val === "string" && val.includes(",")) {
|
|
61
|
+
const items = val.split(",").map((s) => s.trim());
|
|
62
|
+
return items.map((item) => expandTemplate(content, { ...variables, [key]: item, item })).join("\n");
|
|
63
|
+
}
|
|
64
|
+
return expandTemplate(content, variables);
|
|
58
65
|
}
|
|
59
|
-
|
|
60
|
-
});
|
|
66
|
+
);
|
|
61
67
|
}
|
|
62
68
|
function renderTemplate(template, variables, escapeHtml = true) {
|
|
63
69
|
let result = template;
|
|
@@ -283,10 +283,7 @@ var plugin = {
|
|
|
283
283
|
const commandString = typeof rawCommand === "string" && rawCommand.trim().length > 0 ? rawCommand.trim() : cfg.defaultCommand;
|
|
284
284
|
const rawRuns = input.runs ?? raw["runsRequested"] ?? raw["count"] ?? raw["repeat"] ?? raw["times"];
|
|
285
285
|
const requestedRuns = typeof rawRuns === "number" && rawRuns >= 1 ? Math.min(Math.floor(rawRuns), cfg.maxRuns) : 5;
|
|
286
|
-
const command = resolveTestCommand(
|
|
287
|
-
commandString,
|
|
288
|
-
testPattern
|
|
289
|
-
);
|
|
286
|
+
const command = resolveTestCommand(commandString, testPattern);
|
|
290
287
|
if (!command) {
|
|
291
288
|
return {
|
|
292
289
|
ok: false,
|
package/dist/test-generator.js
CHANGED
|
@@ -180,7 +180,9 @@ function generateTestContent(sourcePath, sourceModule, detected, cfg) {
|
|
|
180
180
|
}
|
|
181
181
|
if (detected.length === 0) {
|
|
182
182
|
lines.push(` it('has no exported symbols to test', () => {`);
|
|
183
|
-
lines.push(
|
|
183
|
+
lines.push(
|
|
184
|
+
cfg.framework === "node:test" ? ` assert.ok(true);` : ` expect(true).toBe(true);`
|
|
185
|
+
);
|
|
184
186
|
lines.push(` });`);
|
|
185
187
|
}
|
|
186
188
|
lines.push(`});`);
|