better recon info in certain (nested) situations
All checks were successful
port-to-omp / port (push) Successful in 6s
All checks were successful
port-to-omp / port (push) Successful in 6s
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
* @module pygienium/checks/scope
|
||||
*/
|
||||
|
||||
import { readdirSync, statSync } from "node:fs";
|
||||
import type { Dirent } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
/**
|
||||
* Implementation-code file extensions pygienium inspects.
|
||||
*
|
||||
@@ -106,6 +110,38 @@ export function isScopeSource(path: string): boolean {
|
||||
return SCOPE_EXTENSIONS.has(lower.slice(dot));
|
||||
}
|
||||
|
||||
/**
|
||||
* True when the tree rooted at `root` contains at least one in-scope source
|
||||
* file. Walks recursively (honoring {@link SCOPE_EXCLUDE_DIRS}) — a top-level
|
||||
* entry scan alone would skip any repo whose source lives in subdirectories,
|
||||
* e.g. `game/` or `src/`, even though recon's git inventory finds hundreds of
|
||||
* files. A file root is judged by {@link isScopeSource} directly.
|
||||
*/
|
||||
export function hasScopeSources(root: string): boolean {
|
||||
const st = statSync(root, { throwIfNoEntry: false });
|
||||
if (!st) return false;
|
||||
if (st.isFile()) return isScopeSource(root);
|
||||
const stack = [root];
|
||||
while (stack.length > 0) {
|
||||
const dir = stack.pop() as string;
|
||||
let entries: Dirent[];
|
||||
try {
|
||||
entries = readdirSync(dir, { withFileTypes: true });
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
for (const entry of entries) {
|
||||
if (entry.isDirectory()) {
|
||||
if (SCOPE_EXCLUDE_DIRS.has(entry.name)) continue;
|
||||
stack.push(join(dir, entry.name));
|
||||
} else if (entry.isFile() && isScopeSource(entry.name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Markdown section injected into every scan task string so the sub-agent knows
|
||||
* exactly what to inspect and what to skip — stated once here, not copy-pasted
|
||||
|
||||
Reference in New Issue
Block a user