Commit Graph
5 Commits
Author SHA1 Message Date
Willie 1b9ba78719 fix(audit): scan agents as individual files, not directories
Agents are individual .md files discovered by resource.AgentKind{}.Discover(),
but audit was using collectInstalledSkillPaths() which calls
sync.DiscoverSourceSkillsLite() — designed for skill directories. Then
ParallelScan() called ScanSkill() which expects directories, not files.

Changes:
- Add IsFile flag to audit.SkillInput; when set, ParallelScan uses
  ScanFile/ScanFileForProject instead of ScanSkill variants
- Add collectInstalledAgentPaths() using resource.AgentKind{}.Discover()
  and resource.ActiveAgents() for proper agent file discovery
- Add toAgentAuditInputs() helper that sets IsFile=true
- Branch on kindAgents in auditInstalled(), auditFiltered(), and
  launchAuditTUIWithTabs() to use agent-specific discovery and inputs
- Add discoverAuditAgents() in server handler and update
  resolveAuditSource() to return isAgents flag
- Update handleAuditAll, handleAuditStream to use agent-aware discovery
  and build SkillInput with IsFile=true for agents
2026-04-09 14:45:24 +08:00
Willie 6aac91776b refactor(audit): simplify registry, dedupe, colorize, and API signatures
- Make DefaultRegistry() a singleton (stateless analyzers, safe to share)
- Consolidate duplicate ANSI regex into ui.StripANSI(); broaden pattern
  to match all CSI sequences ([a-zA-Z] terminator, not just 'm')
- Extract shared policyProfileLabel/policyDedupeLabel/policyAnalyzersLabel
  helpers; unify formatPolicyLine and formatPolicyLineFromPolicy
- Remove redundant applyPolicyToSummary calls inside auditInstalled and
  auditFiltered (cmdAudit already applies it centrally)
- Fix double isMarkdown check in scanSkillImpl walk loop
- Convert variadic ...*Registry to regular *Registry parameter across
  scanSkillImpl, ParallelScan, scanSkillPath, and scanPathTarget
- Pre-compute registry.Has() before walk loop to avoid per-file O(n) scan
2026-03-03 16:08:11 +08:00
Willie d1e7f6558a feat(audit): wire --analyzer CLI flag, config field, and update docs
- Add EnabledAnalyzers []string to AuditConfig struct
- Add enabled_analyzers to both JSON schemas (config + project)
- Parse --analyzer repeatable flag in audit command
- Wire config → PolicyInputs → Registry for all scan paths
  (ParallelScan, single skill, single path, filtered)
- Add PolicyAnalyzers to JSON summary output
- Server handler also reads config enabled_analyzers
- Update audit.md: Policy & Profiles section, Finding Schema table,
  --profile/--dedupe/--analyzer in Options table and examples
- Update configuration.md: expanded audit section with all new fields,
  profile table, analyzer IDs, precedence rules
2026-03-03 16:08:11 +08:00
Willie defff26147 feat(audit): add interactive TUI, progress bar, and large-scan UX improvements
- Add bubbletea TUI for multi-skill audit results (side-by-side layout
  with skill list + detail panel, severity sorting, fuzzy filter)
- Add progress bar during parallel scan via onDone callback
- Add --quiet/-q flag to suppress clean skill lines
- Add --yes/-y flag to skip large-scan confirmation prompt (>1000 skills)
- Add --no-tui flag to force plain text output
- Scale parallel workers to NumCPU (bounded 2–32) instead of fixed 8
- Use file cache in content-integrity check to avoid redundant disk reads
- Replace line splitting with streaming scan (avoid full []string alloc)
- Remove snippet truncation (preserve full trimmed line)
- Differentiate LOW (bright blue) and INFO (medium gray) severity colors
- Centralize log TUI color styles into `lc` struct
- Export DisplayWidth and add BoxWithMinWidth/HeaderBoxWithMinWidth for
  aligned header + summary box widths
- Update docs with TUI controls, new flags, and CI/CD auto-skip behavior
2026-02-26 22:27:23 +08:00
Willie 97e2a2d5c6 refactor: extract shared parallel audit scan helper
Deduplicate bounded-concurrency worker pool that was repeated in
auditInstalled(), auditFiltered(), and handleAuditAll(). The new
audit.ParallelScan() centralises the pattern with index-aligned
results, reducing ~90 lines to a single reusable function.
2026-02-22 15:13:10 +08:00