feat(checks): unify inspection scope in checks/scope.ts
Single source of truth for what pygienium inspects (implementation-code extensions, exclude dirs, .d.ts/.min.* exclusions) shared by recon, dead-code, deep-modules, defensive-guards, comments, and complexity. Every scan task and agent prompt injects the shared scope rules instead of copy-pasted per-check lists.
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
||||
type CheckDefinition,
|
||||
type CheckScope,
|
||||
} from "./registry.js";
|
||||
import { isScopeSource, scopeRulesMarkdown } from "./scope.js";
|
||||
|
||||
/** Output directory for this check's persistent reports. */
|
||||
export function deepModulesOutputDir(cwd: string): string {
|
||||
@@ -44,26 +45,6 @@ export function changesPath(cwd: string): string {
|
||||
return join(deepModulesOutputDir(cwd), "changes.md");
|
||||
}
|
||||
|
||||
/** Source extensions this check inspects. */
|
||||
const DEEP_MODULES_EXTENSIONS = new Set([
|
||||
".ts",
|
||||
".tsx",
|
||||
".js",
|
||||
".jsx",
|
||||
".mjs",
|
||||
".cjs",
|
||||
".py",
|
||||
".rb",
|
||||
".go",
|
||||
".rs",
|
||||
".java",
|
||||
".kt",
|
||||
".swift",
|
||||
".php",
|
||||
".cs",
|
||||
".lua",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Gate: skip when the cwd has no inspectable source files at all. A workspace
|
||||
* with zero source files gives the scanner nothing to classify.
|
||||
@@ -73,9 +54,7 @@ function deepModulesGate(cwd: string): string | undefined {
|
||||
try {
|
||||
const entries = readdirSync(cwd);
|
||||
for (const entry of entries) {
|
||||
const dot = entry.lastIndexOf(".");
|
||||
const ext = dot === -1 ? "" : entry.slice(dot).toLowerCase();
|
||||
if (DEEP_MODULES_EXTENSIONS.has(ext)) {
|
||||
if (isScopeSource(entry)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -116,6 +95,8 @@ function buildDeepScanTask(cwd: string, scope: CheckScope): string {
|
||||
`count, recommendation, and risk (low if no external importers, high else).`,
|
||||
`Then emit a one-line summary referencing the findings path.`,
|
||||
"",
|
||||
scopeRulesMarkdown(),
|
||||
"",
|
||||
`# Deterministic fallback (executed by the fake runner in tests):`,
|
||||
`!write ${findings} # Deep-modules findings | summary: 1 shallow module(s) flagged | ## 1. ${target}/wrapper.ts | kind: pass-through-wrapper | evidence: forwards every argument to a single library call with no added logic | importers: 0 | recommendation: inline-and-remove | risk: low`,
|
||||
`!echo deep-modules: 1 issue — see ${findings}`,
|
||||
|
||||
Reference in New Issue
Block a user