scanWorkspace()
scanWorkspace(patterns, root, config?): AsyncGenerator<ScanEvent>
Defined in: workspace.ts:412
Scans a workspace using a high-concurrency Async Generator.
This orchestrator bridges @promptshield/core and the filesystem,
providing real-time feedback suitable for CLI progress bars
and LSP diagnostics.
Execution Model:
- Files are processed concurrently (bounded by
concurrency). - Results are yielded in task-creation order (not completion order).
Cache Semantics:
- When caching is enabled, baseline results are computed using
minSeverity: "LOW"with inline ignores enabled. - Presentation-level filtering (
minSeverity,noInlineIgnore) is applied after cache retrieval. - Cache writes are intentionally NOT awaited. This is a deliberate performance trade-off to avoid blocking scan throughput. Cache persistence is best-effort and not part of scan correctness.
Parameters
patterns
string[]
root
string
config?
Omit<WorkspaceScanConfig, "shouldApplyFixes" | "write"> = {}
Returns
AsyncGenerator<ScanEvent>
Example
for await (const { path, result, progress } of scanWorkspace(['**/*.js'], root)) {
console.log(`[${progress}%] Scanned ${path}: ${result.threats.length} threats`);
}