@triedotdev/mcp 1.0.113 → 1.0.114

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.
Files changed (75) hide show
  1. package/dist/auto-fix-apply-PCAHWLXF.js +10 -0
  2. package/dist/autonomy-config-O4H3Z7YV.js +30 -0
  3. package/dist/chunk-2GIAROBF.js +173 -0
  4. package/dist/chunk-2GIAROBF.js.map +1 -0
  5. package/dist/{chunk-33WL3D7A.js → chunk-2SIFK7OW.js} +7 -419
  6. package/dist/chunk-2SIFK7OW.js.map +1 -0
  7. package/dist/chunk-43X6JBEM.js +36 -0
  8. package/dist/chunk-43X6JBEM.js.map +1 -0
  9. package/dist/{chunk-2764KZZQ.js → chunk-4SBZXIMG.js} +133 -595
  10. package/dist/chunk-4SBZXIMG.js.map +1 -0
  11. package/dist/chunk-55DOQNHJ.js +772 -0
  12. package/dist/chunk-55DOQNHJ.js.map +1 -0
  13. package/dist/chunk-6LXSA2OZ.js +425 -0
  14. package/dist/chunk-6LXSA2OZ.js.map +1 -0
  15. package/dist/{chunk-SDS3UVFY.js → chunk-AOFYU6T3.js} +113 -559
  16. package/dist/chunk-AOFYU6T3.js.map +1 -0
  17. package/dist/{chunk-6QR6QZIX.js → chunk-D3EXBJE2.js} +25 -658
  18. package/dist/chunk-D3EXBJE2.js.map +1 -0
  19. package/dist/chunk-DJ2YAGHK.js +50 -0
  20. package/dist/chunk-DJ2YAGHK.js.map +1 -0
  21. package/dist/chunk-DRDEEF6G.js +328 -0
  22. package/dist/chunk-DRDEEF6G.js.map +1 -0
  23. package/dist/chunk-DZREHOGW.js +706 -0
  24. package/dist/chunk-DZREHOGW.js.map +1 -0
  25. package/dist/chunk-KRH642MT.js +947 -0
  26. package/dist/chunk-KRH642MT.js.map +1 -0
  27. package/dist/{chunk-QYOACM2C.js → chunk-MVNJPJBK.js} +22 -252
  28. package/dist/chunk-MVNJPJBK.js.map +1 -0
  29. package/dist/chunk-NS2MSZMB.js +394 -0
  30. package/dist/chunk-NS2MSZMB.js.map +1 -0
  31. package/dist/chunk-SWSK7ANT.js +340 -0
  32. package/dist/chunk-SWSK7ANT.js.map +1 -0
  33. package/dist/chunk-VRLMTOB6.js +566 -0
  34. package/dist/chunk-VRLMTOB6.js.map +1 -0
  35. package/dist/chunk-YR4BMGYO.js +130 -0
  36. package/dist/chunk-YR4BMGYO.js.map +1 -0
  37. package/dist/chunk-ZV2K6M7T.js +74 -0
  38. package/dist/chunk-ZV2K6M7T.js.map +1 -0
  39. package/dist/cli/main.js +107 -375
  40. package/dist/cli/main.js.map +1 -1
  41. package/dist/cli/yolo-daemon.js +18 -8
  42. package/dist/cli/yolo-daemon.js.map +1 -1
  43. package/dist/client-7XZHCMD3.js +28 -0
  44. package/dist/client-7XZHCMD3.js.map +1 -0
  45. package/dist/{goal-manager-AP4LTE6U.js → goal-manager-LMS6ZJB7.js} +7 -3
  46. package/dist/goal-manager-LMS6ZJB7.js.map +1 -0
  47. package/dist/goal-validator-7UPLOVAZ.js +184 -0
  48. package/dist/goal-validator-7UPLOVAZ.js.map +1 -0
  49. package/dist/graph-U5JWSAB5.js +10 -0
  50. package/dist/graph-U5JWSAB5.js.map +1 -0
  51. package/dist/guardian-agent-EXP7APLC.js +25 -0
  52. package/dist/guardian-agent-EXP7APLC.js.map +1 -0
  53. package/dist/hypothesis-KGC3P54C.js +19 -0
  54. package/dist/hypothesis-KGC3P54C.js.map +1 -0
  55. package/dist/incident-index-PNIVT47T.js +11 -0
  56. package/dist/incident-index-PNIVT47T.js.map +1 -0
  57. package/dist/index.js +285 -16
  58. package/dist/index.js.map +1 -1
  59. package/dist/ledger-SR6OEBLO.js +15 -0
  60. package/dist/ledger-SR6OEBLO.js.map +1 -0
  61. package/dist/output-manager-BOTMXSND.js +13 -0
  62. package/dist/output-manager-BOTMXSND.js.map +1 -0
  63. package/dist/pattern-discovery-F7LU5K6E.js +8 -0
  64. package/dist/pattern-discovery-F7LU5K6E.js.map +1 -0
  65. package/package.json +1 -1
  66. package/dist/chunk-2764KZZQ.js.map +0 -1
  67. package/dist/chunk-33WL3D7A.js.map +0 -1
  68. package/dist/chunk-6JPPYG7F.js +0 -1813
  69. package/dist/chunk-6JPPYG7F.js.map +0 -1
  70. package/dist/chunk-6QR6QZIX.js.map +0 -1
  71. package/dist/chunk-QYOACM2C.js.map +0 -1
  72. package/dist/chunk-SDS3UVFY.js.map +0 -1
  73. package/dist/guardian-agent-XEYNG7RH.js +0 -18
  74. /package/dist/{goal-manager-AP4LTE6U.js.map → auto-fix-apply-PCAHWLXF.js.map} +0 -0
  75. /package/dist/{guardian-agent-XEYNG7RH.js.map → autonomy-config-O4H3Z7YV.js.map} +0 -0
@@ -3,20 +3,30 @@ import {
3
3
  InteractiveDashboard,
4
4
  StreamingManager,
5
5
  TrieScanTool
6
- } from "../chunk-2764KZZQ.js";
7
- import "../chunk-SDS3UVFY.js";
6
+ } from "../chunk-4SBZXIMG.js";
7
+ import "../chunk-AOFYU6T3.js";
8
+ import "../chunk-2SIFK7OW.js";
9
+ import "../chunk-DZREHOGW.js";
10
+ import "../chunk-6LXSA2OZ.js";
8
11
  import {
9
12
  isTrieInitialized
10
- } from "../chunk-QYOACM2C.js";
11
- import "../chunk-6QR6QZIX.js";
13
+ } from "../chunk-MVNJPJBK.js";
14
+ import "../chunk-D3EXBJE2.js";
15
+ import "../chunk-SWSK7ANT.js";
16
+ import "../chunk-55DOQNHJ.js";
17
+ import "../chunk-KRH642MT.js";
18
+ import "../chunk-F4NJ4CBP.js";
12
19
  import "../chunk-IXO4G4D3.js";
13
- import "../chunk-33WL3D7A.js";
14
- import "../chunk-6JPPYG7F.js";
20
+ import "../chunk-NS2MSZMB.js";
21
+ import "../chunk-2GIAROBF.js";
22
+ import "../chunk-6NLHFIYA.js";
23
+ import "../chunk-ZV2K6M7T.js";
24
+ import "../chunk-VRLMTOB6.js";
25
+ import "../chunk-YR4BMGYO.js";
26
+ import "../chunk-43X6JBEM.js";
15
27
  import {
16
28
  getWorkingDirectory
17
29
  } from "../chunk-R4AAPFXC.js";
18
- import "../chunk-F4NJ4CBP.js";
19
- import "../chunk-6NLHFIYA.js";
20
30
  import {
21
31
  isInteractiveMode,
22
32
  setInteractiveMode
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/yolo-daemon.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Trie Guardian - File Watcher & Scanner\n * \n * Watches a directory and reports issues as they occur.\n * Also handles one-shot scanning via --once flag.\n * \n * Usage:\n * trie watch [options] # Watch for changes\n * trie scan [options] # Scan once and exit\n * \n * See `trie watch --help` for all options.\n */\n\nimport { watch, existsSync, statSync, readFileSync } from 'fs';\nimport { readdir } from 'fs/promises';\nimport { join, extname, basename, resolve } from 'path';\nimport { TrieScanTool } from '../tools/scan.js';\nimport { StreamingManager } from '../utils/streaming.js';\nimport { InteractiveDashboard } from './interactive-dashboard.js';\nimport { getWorkingDirectory } from '../utils/workspace.js';\nimport { isInteractiveMode, setInteractiveMode } from '../utils/progress.js';\nimport { isTrieInitialized } from '../utils/trie-init.js';\n\n// File extensions to watch\nconst WATCH_EXTENSIONS = new Set([\n '.ts', '.tsx', '.js', '.jsx', '.mjs',\n '.vue', '.svelte', '.astro',\n '.py', '.go', '.rs'\n]);\n\n// Directories to skip\nconst SKIP_DIRS = new Set([\n 'node_modules', '.git', 'dist', 'build', '.next', '.nuxt',\n 'coverage', '.turbo', '.cache', '__pycache__', '.venv'\n]);\n\ninterface DaemonConfig {\n directory: string;\n debounceMs: number;\n jsonOutput: boolean;\n runOnce: boolean;\n format?: 'text' | 'json';\n output?: string;\n parallel?: boolean;\n cache?: boolean;\n maxConcurrency?: number;\n streaming?: boolean;\n interactive?: boolean;\n workers?: boolean;\n timeoutMs?: number;\n files?: string[];\n /** Comma-separated list of scouts to run (e.g., \"security,legal\") */\n forceScouts?: string[];\n /** User count for cost estimation (default: 250) */\n userCount?: number;\n}\n\ninterface DaemonStats {\n filesScanned: number;\n issuesFound: number;\n errors: number;\n startTime: number;\n}\n\nclass WatchDaemon {\n private config: DaemonConfig;\n private stats: DaemonStats;\n private scanTool = new TrieScanTool();\n private watchers: Map<string, ReturnType<typeof watch>> = new Map();\n private pendingFiles: Set<string> = new Set();\n private debounceTimer: NodeJS.Timeout | null = null;\n private isProcessing = false;\n private streamingManager: StreamingManager | undefined = undefined;\n private dashboard: InteractiveDashboard | undefined = undefined;\n\n constructor(config: DaemonConfig) {\n this.config = config;\n this.stats = {\n filesScanned: 0,\n issuesFound: 0,\n errors: 0,\n startTime: Date.now()\n };\n }\n\n /**\n * Start the daemon\n */\n async start(): Promise<void> {\n // Enable global interactive mode when TTY and not explicitly disabled\n if (this.config.interactive !== false && process.stdout.isTTY) {\n setInteractiveMode(true);\n }\n if (!isTrieInitialized(this.config.directory)) {\n if (!isInteractiveMode()) {\n console.error('Trie is not initialized for this project.');\n console.error('Run `trie init` first.');\n }\n process.exit(1);\n }\n\n this.log('info', 'Starting Trie Agent', {\n directory: this.config.directory,\n debounceMs: this.config.debounceMs\n });\n if (!isInteractiveMode()) {\n console.error('\\nYour Trie agent is watching over your codebase.\\n');\n }\n\n // Validate directory\n if (!existsSync(this.config.directory)) {\n this.log('error', 'Directory not found', { directory: this.config.directory });\n process.exit(1);\n }\n\n // Start interactive dashboard if enabled\n if (isInteractiveMode()) {\n this.streamingManager = new StreamingManager();\n this.dashboard = new InteractiveDashboard();\n this.streamingManager.subscribe(update => this.dashboard?.handleStreamUpdate(update));\n await this.dashboard.start();\n this.streamingManager.reportWatchStatus({\n watching: !this.config.runOnce,\n directories: 0,\n debounceMs: this.config.debounceMs\n });\n }\n\n // Run initial scan\n this.log('info', 'Running initial scan...');\n await this.runScan(this.config.files);\n\n // If run-once mode, exit after initial scan\n if (this.config.runOnce) {\n this.log('info', 'Run-once mode: exiting after initial scan', { ...this.stats });\n process.exit(this.stats.issuesFound > 0 ? 1 : 0);\n }\n\n // Start watching\n await this.watchDirectory(this.config.directory);\n this.streamingManager?.reportWatchStatus({\n watching: true,\n directories: this.watchers.size,\n debounceMs: this.config.debounceMs\n });\n this.log('info', 'Guardian is watching for changes...', { \n directories: this.watchers.size \n });\n\n // Handle graceful shutdown\n process.on('SIGINT', () => this.shutdown('SIGINT'));\n process.on('SIGTERM', () => this.shutdown('SIGTERM'));\n }\n\n /**\n * Run a scan on all files or specific files\n */\n private async runScan(files?: string[]): Promise<void> {\n try {\n const scanArgs: Record<string, unknown> = files\n ? { files }\n : { directory: this.config.directory };\n\n if (this.config.format) scanArgs.format = this.config.format;\n if (this.config.output) scanArgs.output = this.config.output;\n if (this.config.parallel !== undefined) scanArgs.parallel = this.config.parallel;\n if (this.config.cache !== undefined) scanArgs.cache = this.config.cache;\n if (this.config.maxConcurrency) scanArgs.maxConcurrency = this.config.maxConcurrency;\n if (this.config.streaming !== undefined) scanArgs.streaming = this.config.streaming;\n if (this.config.interactive !== undefined) scanArgs.interactive = this.config.interactive;\n if (this.config.workers !== undefined) scanArgs.workers = this.config.workers;\n if (this.config.timeoutMs) scanArgs.timeoutMs = this.config.timeoutMs;\n if (this.config.forceScouts) scanArgs.forceAgents = this.config.forceScouts;\n if (this.dashboard && typeof this.dashboard.getAgentConfig === 'function') {\n const agentConfig = this.dashboard.getAgentConfig();\n scanArgs.parallel = agentConfig.performance.parallel;\n scanArgs.cache = agentConfig.performance.cache;\n scanArgs.maxConcurrency = agentConfig.performance.maxConcurrency;\n scanArgs.timeoutMs = agentConfig.performance.timeoutMs;\n scanArgs.workers = agentConfig.performance.workers;\n scanArgs.streaming = agentConfig.performance.streaming;\n }\n\n if (this.streamingManager) scanArgs.streamingManager = this.streamingManager;\n if (this.dashboard) scanArgs.dashboard = this.dashboard;\n\n const result = await this.scanTool.execute(scanArgs);\n const resultText = result.content?.[0]?.text || '';\n\n // PRINT THE FULL REPORT TO STDOUT (for terminal/chat display)\n if (resultText && this.config.runOnce && !isInteractiveMode()) {\n console.log(resultText);\n }\n\n // Parse results - try multiple patterns to extract issue count\n let issueCount = 0;\n if (this.config.format === 'json' && this.config.output && existsSync(this.config.output)) {\n try {\n const report = JSON.parse(readFileSync(this.config.output, 'utf-8'));\n issueCount = report?.results?.totalIssues ?? 0;\n } catch {\n issueCount = 0;\n }\n } else {\n // Try multiple patterns to catch issue counts\n const patterns = [\n /(\\d+)\\s+actionable\\s+issues?\\s+found/i, // \"30 actionable issues found\"\n /(\\d+)\\s+Issues?\\s+Found/i, // \"30 Issues Found\"\n /Found\\s+(\\d+)\\s+issues?/i, // \"Found 30 issues\"\n /\\[COMPLETE\\]\\s+(\\d+)\\s+issues?/i, // \"[COMPLETE] 30 issues\"\n /(\\d+)\\s+total/i, // \"30 total\" (fallback)\n ];\n \n for (const pattern of patterns) {\n const match = resultText.match(pattern);\n if (match && match[1]) {\n issueCount = parseInt(match[1], 10);\n break;\n }\n }\n }\n\n this.stats.filesScanned += files?.length || 1;\n this.stats.issuesFound += issueCount;\n\n // Don't log \"No issues found\" after a full scan that displayed a report\n // The report already shows the issue count prominently\n if (issueCount > 0) {\n // Parse severity breakdown for additional logging\n const criticalMatch = resultText.match(/(\\d+)\\s+critical/i);\n const seriousMatch = resultText.match(/(\\d+)\\s+serious|(\\d+)\\s+important/i);\n\n if (criticalMatch && criticalMatch[1] && parseInt(criticalMatch[1], 10) > 0) {\n this.log('error', 'Critical issues detected', { count: parseInt(criticalMatch[1], 10) });\n }\n if (seriousMatch && (seriousMatch[1] || seriousMatch[2])) {\n const count = parseInt(seriousMatch[1] || seriousMatch[2] || '0', 10);\n if (count > 0) {\n this.log('warn', 'Serious issues detected', { count });\n }\n }\n }\n // NOTE: Removed the \"No issues found\" log because it was confusing\n // when printed after a full scan report that already shows issue counts\n } catch (error) {\n this.stats.errors++;\n this.log('error', 'Scan failed', { \n error: error instanceof Error ? error.message : String(error) \n });\n }\n }\n\n /**\n * Watch a directory recursively\n */\n private async watchDirectory(dir: string): Promise<void> {\n if (!existsSync(dir)) return;\n\n try {\n const stat = statSync(dir);\n if (!stat.isDirectory()) return;\n\n const dirName = basename(dir);\n if (SKIP_DIRS.has(dirName) || dirName.startsWith('.')) return;\n\n // Watch this directory\n const watcher = watch(dir, { persistent: true }, (_eventType, filename) => {\n if (!filename) return;\n\n const fullPath = join(dir, filename);\n const ext = extname(filename).toLowerCase();\n\n if (!WATCH_EXTENSIONS.has(ext)) return;\n if (!existsSync(fullPath)) return;\n\n this.pendingFiles.add(fullPath);\n this.streamingManager?.reportWatchChange(fullPath);\n this.scheduleProcessing();\n });\n\n this.watchers.set(dir, watcher);\n\n // Recursively watch subdirectories\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n await this.watchDirectory(join(dir, entry.name));\n }\n }\n } catch (error) {\n // Skip inaccessible directories\n }\n }\n\n /**\n * Schedule processing of pending files (debounced)\n */\n private scheduleProcessing(): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n }\n\n this.debounceTimer = setTimeout(() => {\n this.processPendingFiles();\n }, this.config.debounceMs);\n }\n\n /**\n * Process all pending files\n */\n private async processPendingFiles(): Promise<void> {\n if (this.isProcessing || this.pendingFiles.size === 0) return;\n\n this.isProcessing = true;\n const files = Array.from(this.pendingFiles);\n this.pendingFiles.clear();\n\n this.log('info', 'Processing changed files', { \n count: files.length,\n files: files.map(f => basename(f))\n });\n\n await this.runScan(files);\n this.isProcessing = false;\n }\n\n\n /**\n * Log a message\n */\n private log(level: 'info' | 'warn' | 'error', message: string, data?: Record<string, unknown>): void {\n const timestamp = new Date().toISOString();\n const uptime = Math.round((Date.now() - this.stats.startTime) / 1000);\n\n // Suppress human-readable logs when interactive dashboard is active\n if (!this.config.jsonOutput && isInteractiveMode()) {\n return;\n }\n\n if (this.config.jsonOutput) {\n console.log(JSON.stringify({\n timestamp,\n level,\n message,\n uptime,\n ...data,\n stats: this.stats\n }));\n } else {\n const levelEmoji = { info: '[i]', warn: '[!]', error: '[X]' }[level];\n const dataStr = data ? ` ${JSON.stringify(data)}` : '';\n console.log(`[${timestamp}] ${levelEmoji} ${message}${dataStr}`);\n }\n }\n\n /**\n * Graceful shutdown\n */\n private shutdown(signal: string): void {\n this.log('info', 'Shutting down', { signal, stats: this.stats });\n\n // Close all watchers\n for (const watcher of this.watchers.values()) {\n watcher.close();\n }\n\n // Clear timers\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n }\n\n if (this.streamingManager) {\n this.streamingManager.reportWatchStatus({\n watching: false,\n directories: 0\n });\n }\n if (this.dashboard) {\n this.dashboard.stop();\n }\n\n process.exit(0);\n }\n}\n\n/**\n * Parse command line arguments\n */\nfunction parseArgs(): DaemonConfig {\n const args = process.argv.slice(2);\n const config: DaemonConfig = {\n // Silent mode for initial workspace detection (TUI will handle display)\n directory: getWorkingDirectory(undefined, true),\n debounceMs: 1000,\n jsonOutput: false,\n runOnce: false,\n // Default to interactive mode for TTY terminals\n interactive: process.stdout.isTTY === true\n };\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n const nextArg = args[i + 1];\n\n switch (arg) {\n case '--dir':\n case '-d':\n config.directory = resolve(nextArg || '.');\n i++;\n break;\n case '--debounce':\n case '-D':\n config.debounceMs = parseInt(nextArg || '1000', 10);\n i++;\n break;\n case '--json':\n config.jsonOutput = true;\n break;\n case '--format':\n if (nextArg) {\n config.format = nextArg === 'json' ? 'json' : 'text';\n i++;\n }\n break;\n case '--output':\n if (nextArg) {\n config.output = nextArg;\n i++;\n }\n break;\n case '--parallel':\n config.parallel = true;\n break;\n case '--no-parallel':\n config.parallel = false;\n break;\n case '--cache':\n config.cache = true;\n break;\n case '--no-cache':\n config.cache = false;\n break;\n case '--force-rescan':\n case '--force':\n config.cache = false; // Force rescan by disabling cache\n break;\n case '--max-concurrency':\n config.maxConcurrency = parseInt(nextArg || '4', 10);\n i++;\n break;\n case '--streaming':\n config.streaming = true;\n break;\n case '--no-streaming':\n config.streaming = false;\n break;\n case '--interactive':\n config.interactive = true;\n break;\n case '--no-interactive':\n config.interactive = false;\n break;\n case '--workers':\n config.workers = true;\n break;\n case '--no-workers':\n config.workers = false;\n break;\n case '--timeout':\n config.timeoutMs = parseInt(nextArg || '120000', 10);\n i++;\n break;\n case '--files':\n if (nextArg) {\n config.files = nextArg.split(',').map(f => f.trim()).filter(Boolean);\n i++;\n }\n break;\n case '--scouts':\n case '--agents': // Alias for backward compatibility\n if (nextArg) {\n config.forceScouts = nextArg.split(',').map(s => s.trim()).filter(Boolean);\n i++;\n }\n break;\n case '--once':\n config.runOnce = true;\n break;\n case '--users':\n case '-u':\n config.userCount = parseInt(nextArg || '250', 10);\n i++;\n break;\n case '--help':\n case '-h':\n console.log(`\nTrie Agent - File Watcher & Scanner\n\nUSAGE:\n trie watch [options] Watch for changes and scan continuously\n trie scan [options] Scan once and exit\n\nOPTIONS:\n --dir, -d <path> Directory to watch/scan (default: current directory)\n --debounce, -D <ms> Debounce time in ms (default: 1000)\n --scouts <list> Comma-separated scouts to run (e.g., security,legal)\n --agents <list> Alias for --scouts (backward compatibility)\n --files <list> Comma-separated file list to scan\n --users, -u <count> User count for cost estimation (default: 250)\n\nOUTPUT:\n --json Output as JSON (for log aggregation)\n --format <text|json> Scan output format\n --output <path> Output file path for json format\n\nPERFORMANCE:\n --parallel Enable parallel execution\n --no-parallel Disable parallel execution\n --cache Enable result caching\n --no-cache Disable result caching\n --force-rescan Force rescan (bypasses cache, same as --no-cache)\n --max-concurrency <n> Max parallel scouts\n --streaming Enable streaming updates\n --no-streaming Disable streaming updates\n --workers Use worker threads for scouts\n --no-workers Disable worker threads\n --timeout <ms> Scout timeout in ms\n\nDISPLAY:\n --interactive Enable interactive dashboard (default for TTY)\n --no-interactive Disable interactive dashboard (for CI/scripts)\n\nEXAMPLES:\n trie watch # Watch current directory\n trie scan # Scan once and exit\n trie scan --scouts security,legal # Scan with specific scouts\n trie scan --users 1000 --industry fintech # Scale for fintech with 1K users\n trie watch --no-interactive # CI mode: watch without dashboard\n trie scan --json --output report.json\n`);\n process.exit(0);\n }\n }\n\n return config;\n}\n\n// Run the daemon\nconst config = parseArgs();\nconst daemon = new WatchDaemon(config);\ndaemon.start().catch(error => {\n if (!process.stdout.isTTY || process.argv.includes('--non-interactive')) {\n console.error('Failed to start daemon:', error);\n }\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,OAAO,YAAY,UAAU,oBAAoB;AAC1D,SAAS,eAAe;AACxB,SAAS,MAAM,SAAS,UAAU,eAAe;AASjD,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAQ;AAAA,EAC9B;AAAA,EAAQ;AAAA,EAAW;AAAA,EACnB;AAAA,EAAO;AAAA,EAAO;AAChB,CAAC;AAGD,IAAM,YAAY,oBAAI,IAAI;AAAA,EACxB;AAAA,EAAgB;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAS;AAAA,EAClD;AAAA,EAAY;AAAA,EAAU;AAAA,EAAU;AAAA,EAAe;AACjD,CAAC;AA8BD,IAAM,cAAN,MAAkB;AAAA,EACR;AAAA,EACA;AAAA,EACA,WAAW,IAAI,aAAa;AAAA,EAC5B,WAAkD,oBAAI,IAAI;AAAA,EAC1D,eAA4B,oBAAI,IAAI;AAAA,EACpC,gBAAuC;AAAA,EACvC,eAAe;AAAA,EACf,mBAAiD;AAAA,EACjD,YAA8C;AAAA,EAEtD,YAAYA,SAAsB;AAChC,SAAK,SAASA;AACd,SAAK,QAAQ;AAAA,MACX,cAAc;AAAA,MACd,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,WAAW,KAAK,IAAI;AAAA,IACtB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAuB;AAE3B,QAAI,KAAK,OAAO,gBAAgB,SAAS,QAAQ,OAAO,OAAO;AAC7D,yBAAmB,IAAI;AAAA,IACzB;AACA,QAAI,CAAC,kBAAkB,KAAK,OAAO,SAAS,GAAG;AAC7C,UAAI,CA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A,MACL,KAAK;AACH,gBAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CA4CnB;AACO,gBAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACF;AAEA,SAAOA;AACT;AAGA,IAAM,SAAS,UAAU;AACzB,IAAM,SAAS,IAAI,YAAY,MAAM;AACrC,OAAO,MAAM,EAAE,MAAM,WAAS;AAC5B,MAAI,CAAC,QAAQ,OAAO,SAAS,QAAQ,KAAK,SAAS,mBAAmB,GAAG;AACvE,YAAQ,MAAM,2BAA2B,KAAK;AAAA,EAChD;AACA,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["config"]}
1
+ {"version":3,"sources":["../../src/cli/yolo-daemon.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Trie Guardian - File Watcher & Scanner\n * \n * Watches a directory and reports issues as they occur.\n * Also handles one-shot scanning via --once flag.\n * \n * Usage:\n * trie watch [options] # Watch for changes\n * trie scan [options] # Scan once and exit\n * \n * See `trie watch --help` for all options.\n */\n\nimport { watch, existsSync, statSync, readFileSync } from 'fs';\nimport { readdir } from 'fs/promises';\nimport { join, extname, basename, resolve } from 'path';\nimport { TrieScanTool } from '../tools/scan.js';\nimport { StreamingManager } from '../utils/streaming.js';\nimport { InteractiveDashboard } from './interactive-dashboard.js';\nimport { getWorkingDirectory } from '../utils/workspace.js';\nimport { isInteractiveMode, setInteractiveMode } from '../utils/progress.js';\nimport { isTrieInitialized } from '../utils/trie-init.js';\n\n// File extensions to watch\nconst WATCH_EXTENSIONS = new Set([\n '.ts', '.tsx', '.js', '.jsx', '.mjs',\n '.vue', '.svelte', '.astro',\n '.py', '.go', '.rs'\n]);\n\n// Directories to skip\nconst SKIP_DIRS = new Set([\n 'node_modules', '.git', 'dist', 'build', '.next', '.nuxt',\n 'coverage', '.turbo', '.cache', '__pycache__', '.venv'\n]);\n\ninterface DaemonConfig {\n directory: string;\n debounceMs: number;\n jsonOutput: boolean;\n runOnce: boolean;\n format?: 'text' | 'json';\n output?: string;\n parallel?: boolean;\n cache?: boolean;\n maxConcurrency?: number;\n streaming?: boolean;\n interactive?: boolean;\n workers?: boolean;\n timeoutMs?: number;\n files?: string[];\n /** Comma-separated list of scouts to run (e.g., \"security,legal\") */\n forceScouts?: string[];\n /** User count for cost estimation (default: 250) */\n userCount?: number;\n}\n\ninterface DaemonStats {\n filesScanned: number;\n issuesFound: number;\n errors: number;\n startTime: number;\n}\n\nclass WatchDaemon {\n private config: DaemonConfig;\n private stats: DaemonStats;\n private scanTool = new TrieScanTool();\n private watchers: Map<string, ReturnType<typeof watch>> = new Map();\n private pendingFiles: Set<string> = new Set();\n private debounceTimer: NodeJS.Timeout | null = null;\n private isProcessing = false;\n private streamingManager: StreamingManager | undefined = undefined;\n private dashboard: InteractiveDashboard | undefined = undefined;\n\n constructor(config: DaemonConfig) {\n this.config = config;\n this.stats = {\n filesScanned: 0,\n issuesFound: 0,\n errors: 0,\n startTime: Date.now()\n };\n }\n\n /**\n * Start the daemon\n */\n async start(): Promise<void> {\n // Enable global interactive mode when TTY and not explicitly disabled\n if (this.config.interactive !== false && process.stdout.isTTY) {\n setInteractiveMode(true);\n }\n if (!isTrieInitialized(this.config.directory)) {\n if (!isInteractiveMode()) {\n console.error('Trie is not initialized for this project.');\n console.error('Run `trie init` first.');\n }\n process.exit(1);\n }\n\n this.log('info', 'Starting Trie Agent', {\n directory: this.config.directory,\n debounceMs: this.config.debounceMs\n });\n if (!isInteractiveMode()) {\n console.error('\\nYour Trie agent is watching over your codebase.\\n');\n }\n\n // Validate directory\n if (!existsSync(this.config.directory)) {\n this.log('error', 'Directory not found', { directory: this.config.directory });\n process.exit(1);\n }\n\n // Start interactive dashboard if enabled\n if (isInteractiveMode()) {\n this.streamingManager = new StreamingManager();\n this.dashboard = new InteractiveDashboard();\n this.streamingManager.subscribe(update => this.dashboard?.handleStreamUpdate(update));\n await this.dashboard.start();\n this.streamingManager.reportWatchStatus({\n watching: !this.config.runOnce,\n directories: 0,\n debounceMs: this.config.debounceMs\n });\n }\n\n // Run initial scan\n this.log('info', 'Running initial scan...');\n await this.runScan(this.config.files);\n\n // If run-once mode, exit after initial scan\n if (this.config.runOnce) {\n this.log('info', 'Run-once mode: exiting after initial scan', { ...this.stats });\n process.exit(this.stats.issuesFound > 0 ? 1 : 0);\n }\n\n // Start watching\n await this.watchDirectory(this.config.directory);\n this.streamingManager?.reportWatchStatus({\n watching: true,\n directories: this.watchers.size,\n debounceMs: this.config.debounceMs\n });\n this.log('info', 'Guardian is watching for changes...', { \n directories: this.watchers.size \n });\n\n // Handle graceful shutdown\n process.on('SIGINT', () => this.shutdown('SIGINT'));\n process.on('SIGTERM', () => this.shutdown('SIGTERM'));\n }\n\n /**\n * Run a scan on all files or specific files\n */\n private async runScan(files?: string[]): Promise<void> {\n try {\n const scanArgs: Record<string, unknown> = files\n ? { files }\n : { directory: this.config.directory };\n\n if (this.config.format) scanArgs.format = this.config.format;\n if (this.config.output) scanArgs.output = this.config.output;\n if (this.config.parallel !== undefined) scanArgs.parallel = this.config.parallel;\n if (this.config.cache !== undefined) scanArgs.cache = this.config.cache;\n if (this.config.maxConcurrency) scanArgs.maxConcurrency = this.config.maxConcurrency;\n if (this.config.streaming !== undefined) scanArgs.streaming = this.config.streaming;\n if (this.config.interactive !== undefined) scanArgs.interactive = this.config.interactive;\n if (this.config.workers !== undefined) scanArgs.workers = this.config.workers;\n if (this.config.timeoutMs) scanArgs.timeoutMs = this.config.timeoutMs;\n if (this.config.forceScouts) scanArgs.forceAgents = this.config.forceScouts;\n if (this.dashboard && typeof this.dashboard.getAgentConfig === 'function') {\n const agentConfig = this.dashboard.getAgentConfig();\n scanArgs.parallel = agentConfig.performance.parallel;\n scanArgs.cache = agentConfig.performance.cache;\n scanArgs.maxConcurrency = agentConfig.performance.maxConcurrency;\n scanArgs.timeoutMs = agentConfig.performance.timeoutMs;\n scanArgs.workers = agentConfig.performance.workers;\n scanArgs.streaming = agentConfig.performance.streaming;\n }\n\n if (this.streamingManager) scanArgs.streamingManager = this.streamingManager;\n if (this.dashboard) scanArgs.dashboard = this.dashboard;\n\n const result = await this.scanTool.execute(scanArgs);\n const resultText = result.content?.[0]?.text || '';\n\n // PRINT THE FULL REPORT TO STDOUT (for terminal/chat display)\n if (resultText && this.config.runOnce && !isInteractiveMode()) {\n console.log(resultText);\n }\n\n // Parse results - try multiple patterns to extract issue count\n let issueCount = 0;\n if (this.config.format === 'json' && this.config.output && existsSync(this.config.output)) {\n try {\n const report = JSON.parse(readFileSync(this.config.output, 'utf-8'));\n issueCount = report?.results?.totalIssues ?? 0;\n } catch {\n issueCount = 0;\n }\n } else {\n // Try multiple patterns to catch issue counts\n const patterns = [\n /(\\d+)\\s+actionable\\s+issues?\\s+found/i, // \"30 actionable issues found\"\n /(\\d+)\\s+Issues?\\s+Found/i, // \"30 Issues Found\"\n /Found\\s+(\\d+)\\s+issues?/i, // \"Found 30 issues\"\n /\\[COMPLETE\\]\\s+(\\d+)\\s+issues?/i, // \"[COMPLETE] 30 issues\"\n /(\\d+)\\s+total/i, // \"30 total\" (fallback)\n ];\n \n for (const pattern of patterns) {\n const match = resultText.match(pattern);\n if (match && match[1]) {\n issueCount = parseInt(match[1], 10);\n break;\n }\n }\n }\n\n this.stats.filesScanned += files?.length || 1;\n this.stats.issuesFound += issueCount;\n\n // Don't log \"No issues found\" after a full scan that displayed a report\n // The report already shows the issue count prominently\n if (issueCount > 0) {\n // Parse severity breakdown for additional logging\n const criticalMatch = resultText.match(/(\\d+)\\s+critical/i);\n const seriousMatch = resultText.match(/(\\d+)\\s+serious|(\\d+)\\s+important/i);\n\n if (criticalMatch && criticalMatch[1] && parseInt(criticalMatch[1], 10) > 0) {\n this.log('error', 'Critical issues detected', { count: parseInt(criticalMatch[1], 10) });\n }\n if (seriousMatch && (seriousMatch[1] || seriousMatch[2])) {\n const count = parseInt(seriousMatch[1] || seriousMatch[2] || '0', 10);\n if (count > 0) {\n this.log('warn', 'Serious issues detected', { count });\n }\n }\n }\n // NOTE: Removed the \"No issues found\" log because it was confusing\n // when printed after a full scan report that already shows issue counts\n } catch (error) {\n this.stats.errors++;\n this.log('error', 'Scan failed', { \n error: error instanceof Error ? error.message : String(error) \n });\n }\n }\n\n /**\n * Watch a directory recursively\n */\n private async watchDirectory(dir: string): Promise<void> {\n if (!existsSync(dir)) return;\n\n try {\n const stat = statSync(dir);\n if (!stat.isDirectory()) return;\n\n const dirName = basename(dir);\n if (SKIP_DIRS.has(dirName) || dirName.startsWith('.')) return;\n\n // Watch this directory\n const watcher = watch(dir, { persistent: true }, (_eventType, filename) => {\n if (!filename) return;\n\n const fullPath = join(dir, filename);\n const ext = extname(filename).toLowerCase();\n\n if (!WATCH_EXTENSIONS.has(ext)) return;\n if (!existsSync(fullPath)) return;\n\n this.pendingFiles.add(fullPath);\n this.streamingManager?.reportWatchChange(fullPath);\n this.scheduleProcessing();\n });\n\n this.watchers.set(dir, watcher);\n\n // Recursively watch subdirectories\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n await this.watchDirectory(join(dir, entry.name));\n }\n }\n } catch (error) {\n // Skip inaccessible directories\n }\n }\n\n /**\n * Schedule processing of pending files (debounced)\n */\n private scheduleProcessing(): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n }\n\n this.debounceTimer = setTimeout(() => {\n this.processPendingFiles();\n }, this.config.debounceMs);\n }\n\n /**\n * Process all pending files\n */\n private async processPendingFiles(): Promise<void> {\n if (this.isProcessing || this.pendingFiles.size === 0) return;\n\n this.isProcessing = true;\n const files = Array.from(this.pendingFiles);\n this.pendingFiles.clear();\n\n this.log('info', 'Processing changed files', { \n count: files.length,\n files: files.map(f => basename(f))\n });\n\n await this.runScan(files);\n this.isProcessing = false;\n }\n\n\n /**\n * Log a message\n */\n private log(level: 'info' | 'warn' | 'error', message: string, data?: Record<string, unknown>): void {\n const timestamp = new Date().toISOString();\n const uptime = Math.round((Date.now() - this.stats.startTime) / 1000);\n\n // Suppress human-readable logs when interactive dashboard is active\n if (!this.config.jsonOutput && isInteractiveMode()) {\n return;\n }\n\n if (this.config.jsonOutput) {\n console.log(JSON.stringify({\n timestamp,\n level,\n message,\n uptime,\n ...data,\n stats: this.stats\n }));\n } else {\n const levelEmoji = { info: '[i]', warn: '[!]', error: '[X]' }[level];\n const dataStr = data ? ` ${JSON.stringify(data)}` : '';\n console.log(`[${timestamp}] ${levelEmoji} ${message}${dataStr}`);\n }\n }\n\n /**\n * Graceful shutdown\n */\n private shutdown(signal: string): void {\n this.log('info', 'Shutting down', { signal, stats: this.stats });\n\n // Close all watchers\n for (const watcher of this.watchers.values()) {\n watcher.close();\n }\n\n // Clear timers\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n }\n\n if (this.streamingManager) {\n this.streamingManager.reportWatchStatus({\n watching: false,\n directories: 0\n });\n }\n if (this.dashboard) {\n this.dashboard.stop();\n }\n\n process.exit(0);\n }\n}\n\n/**\n * Parse command line arguments\n */\nfunction parseArgs(): DaemonConfig {\n const args = process.argv.slice(2);\n const config: DaemonConfig = {\n // Silent mode for initial workspace detection (TUI will handle display)\n directory: getWorkingDirectory(undefined, true),\n debounceMs: 1000,\n jsonOutput: false,\n runOnce: false,\n // Default to interactive mode for TTY terminals\n interactive: process.stdout.isTTY === true\n };\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n const nextArg = args[i + 1];\n\n switch (arg) {\n case '--dir':\n case '-d':\n config.directory = resolve(nextArg || '.');\n i++;\n break;\n case '--debounce':\n case '-D':\n config.debounceMs = parseInt(nextArg || '1000', 10);\n i++;\n break;\n case '--json':\n config.jsonOutput = true;\n break;\n case '--format':\n if (nextArg) {\n config.format = nextArg === 'json' ? 'json' : 'text';\n i++;\n }\n break;\n case '--output':\n if (nextArg) {\n config.output = nextArg;\n i++;\n }\n break;\n case '--parallel':\n config.parallel = true;\n break;\n case '--no-parallel':\n config.parallel = false;\n break;\n case '--cache':\n config.cache = true;\n break;\n case '--no-cache':\n config.cache = false;\n break;\n case '--force-rescan':\n case '--force':\n config.cache = false; // Force rescan by disabling cache\n break;\n case '--max-concurrency':\n config.maxConcurrency = parseInt(nextArg || '4', 10);\n i++;\n break;\n case '--streaming':\n config.streaming = true;\n break;\n case '--no-streaming':\n config.streaming = false;\n break;\n case '--interactive':\n config.interactive = true;\n break;\n case '--no-interactive':\n config.interactive = false;\n break;\n case '--workers':\n config.workers = true;\n break;\n case '--no-workers':\n config.workers = false;\n break;\n case '--timeout':\n config.timeoutMs = parseInt(nextArg || '120000', 10);\n i++;\n break;\n case '--files':\n if (nextArg) {\n config.files = nextArg.split(',').map(f => f.trim()).filter(Boolean);\n i++;\n }\n break;\n case '--scouts':\n case '--agents': // Alias for backward compatibility\n if (nextArg) {\n config.forceScouts = nextArg.split(',').map(s => s.trim()).filter(Boolean);\n i++;\n }\n break;\n case '--once':\n config.runOnce = true;\n break;\n case '--users':\n case '-u':\n config.userCount = parseInt(nextArg || '250', 10);\n i++;\n break;\n case '--help':\n case '-h':\n console.log(`\nTrie Agent - File Watcher & Scanner\n\nUSAGE:\n trie watch [options] Watch for changes and scan continuously\n trie scan [options] Scan once and exit\n\nOPTIONS:\n --dir, -d <path> Directory to watch/scan (default: current directory)\n --debounce, -D <ms> Debounce time in ms (default: 1000)\n --scouts <list> Comma-separated scouts to run (e.g., security,legal)\n --agents <list> Alias for --scouts (backward compatibility)\n --files <list> Comma-separated file list to scan\n --users, -u <count> User count for cost estimation (default: 250)\n\nOUTPUT:\n --json Output as JSON (for log aggregation)\n --format <text|json> Scan output format\n --output <path> Output file path for json format\n\nPERFORMANCE:\n --parallel Enable parallel execution\n --no-parallel Disable parallel execution\n --cache Enable result caching\n --no-cache Disable result caching\n --force-rescan Force rescan (bypasses cache, same as --no-cache)\n --max-concurrency <n> Max parallel scouts\n --streaming Enable streaming updates\n --no-streaming Disable streaming updates\n --workers Use worker threads for scouts\n --no-workers Disable worker threads\n --timeout <ms> Scout timeout in ms\n\nDISPLAY:\n --interactive Enable interactive dashboard (default for TTY)\n --no-interactive Disable interactive dashboard (for CI/scripts)\n\nEXAMPLES:\n trie watch # Watch current directory\n trie scan # Scan once and exit\n trie scan --scouts security,legal # Scan with specific scouts\n trie scan --users 1000 --industry fintech # Scale for fintech with 1K users\n trie watch --no-interactive # CI mode: watch without dashboard\n trie scan --json --output report.json\n`);\n process.exit(0);\n }\n }\n\n return config;\n}\n\n// Run the daemon\nconst config = parseArgs();\nconst daemon = new WatchDaemon(config);\ndaemon.start().catch(error => {\n if (!process.stdout.isTTY || process.argv.includes('--non-interactive')) {\n console.error('Failed to start daemon:', error);\n }\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,OAAO,YAAY,UAAU,oBAAoB;AAC1D,SAAS,eAAe;AACxB,SAAS,MAAM,SAAS,UAAU,eAAe;AASjD,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAQ;AAAA,EAC9B;AAAA,EAAQ;AAAA,EAAW;AAAA,EACnB;AAAA,EAAO;AAAA,EAAO;AAChB,CAAC;AAGD,IAAM,YAAY,oBAAI,IAAI;AAAA,EACxB;AAAA,EAAgB;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAS;AAAA,EAClD;AAAA,EAAY;AAAA,EAAU;AAAA,EAAU;AAAA,EAAe;AACjD,CAAC;AA8BD,IAAM,cAAN,MAAkB;AAAA,EACR;AAAA,EACA;AAAA,EACA,WAAW,IAAI,aAAa;AAAA,EAC5B,WAAkD,oB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
7
+ runAIAnalysis,
8
+ runAIWithTools,
9
+ saveKeyToKeychain,
10
+ setAPIKey,
11
+ tryGetClient
12
+ } from "./chunk-SWSK7ANT.js";
13
+ import "./chunk-R4AAPFXC.js";
14
+ import "./chunk-APMV77PU.js";
15
+ import "./chunk-DGUM43GV.js";
16
+ export {
17
+ analyzeCodeIssues,
18
+ getAIStatusMessage,
19
+ getClient,
20
+ getKeyFromKeychain,
21
+ isAIAvailable,
22
+ runAIAnalysis,
23
+ runAIWithTools,
24
+ saveKeyToKeychain,
25
+ setAPIKey,
26
+ tryGetClient
27
+ };
28
+ //# sourceMappingURL=client-7XZHCMD3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -4,8 +4,12 @@ import {
4
4
  calculateAdaptiveScanFrequency,
5
5
  clearGoalManagers,
6
6
  getGoalManager
7
- } from "./chunk-33WL3D7A.js";
8
- import "./chunk-6JPPYG7F.js";
7
+ } from "./chunk-2SIFK7OW.js";
8
+ import "./chunk-6LXSA2OZ.js";
9
+ import "./chunk-55DOQNHJ.js";
10
+ import "./chunk-KRH642MT.js";
11
+ import "./chunk-YR4BMGYO.js";
12
+ import "./chunk-43X6JBEM.js";
9
13
  import "./chunk-R4AAPFXC.js";
10
14
  import "./chunk-APMV77PU.js";
11
15
  import "./chunk-DGUM43GV.js";
@@ -16,4 +20,4 @@ export {
16
20
  clearGoalManagers,
17
21
  getGoalManager
18
22
  };
19
- //# sourceMappingURL=goal-manager-AP4LTE6U.js.map
23
+ //# sourceMappingURL=goal-manager-LMS6ZJB7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,184 @@
1
+ import {
2
+ getGuardianState
3
+ } from "./chunk-KRH642MT.js";
4
+ import "./chunk-43X6JBEM.js";
5
+ import "./chunk-R4AAPFXC.js";
6
+ import "./chunk-APMV77PU.js";
7
+ import "./chunk-DGUM43GV.js";
8
+
9
+ // src/guardian/goal-validator.ts
10
+ var GOAL_RULES = {
11
+ "no-emojis": {
12
+ pattern: /[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u,
13
+ description: "Contains emoji",
14
+ severity: "medium",
15
+ autoFixable: true
16
+ },
17
+ "no-console": {
18
+ pattern: /console\.(log|debug|info|warn|error)/,
19
+ description: "Contains console statement",
20
+ severity: "low",
21
+ autoFixable: true
22
+ },
23
+ "no-debugger": {
24
+ pattern: /\bdebugger\b/,
25
+ description: "Contains debugger statement",
26
+ severity: "medium",
27
+ autoFixable: true
28
+ },
29
+ "no-todo": {
30
+ pattern: /\b(TODO|FIXME|XXX|HACK)\b/i,
31
+ description: "Contains TODO comment",
32
+ severity: "low",
33
+ autoFixable: false
34
+ },
35
+ "no-any": {
36
+ pattern: /:\s*any\b/,
37
+ description: "Uses TypeScript any type",
38
+ severity: "medium",
39
+ autoFixable: false
40
+ }
41
+ };
42
+ function matchGoalToRule(goal) {
43
+ const desc = goal.description.toLowerCase();
44
+ if (/no emoji|remove emoji|emoji.*free/i.test(desc)) {
45
+ return "no-emojis";
46
+ }
47
+ if (/no console|remove console|console.*free/i.test(desc)) {
48
+ return "no-console";
49
+ }
50
+ if (/no debugger|remove debugger/i.test(desc)) {
51
+ return "no-debugger";
52
+ }
53
+ if (/no (todo|fixme)|clean.*todo/i.test(desc)) {
54
+ return "no-todo";
55
+ }
56
+ if (/no any|avoid any|typescript.*any/i.test(desc)) {
57
+ return "no-any";
58
+ }
59
+ return null;
60
+ }
61
+ async function validateAgainstGoals(file, content, projectPath) {
62
+ const guardianState = getGuardianState(projectPath);
63
+ await guardianState.load();
64
+ const activeGoals = guardianState.getAllGoals().filter((g) => g.status === "active");
65
+ const violations = [];
66
+ const passedGoals = [];
67
+ for (const goal of activeGoals) {
68
+ const ruleKey = matchGoalToRule(goal);
69
+ if (!ruleKey) {
70
+ continue;
71
+ }
72
+ const rule = GOAL_RULES[ruleKey];
73
+ const foundViolations = findViolations(file, content, goal, rule);
74
+ if (foundViolations.length > 0) {
75
+ violations.push(...foundViolations);
76
+ } else {
77
+ passedGoals.push(goal);
78
+ }
79
+ }
80
+ return { violations, passedGoals };
81
+ }
82
+ function findViolations(file, content, goal, rule) {
83
+ const violations = [];
84
+ const lines = content.split("\n");
85
+ for (let i = 0; i < lines.length; i++) {
86
+ const line = lines[i];
87
+ if (!line) continue;
88
+ const match = line.match(rule.pattern);
89
+ if (match) {
90
+ const violation = {
91
+ goal,
92
+ file,
93
+ line: i + 1,
94
+ column: match.index,
95
+ violation: match[0],
96
+ description: `${rule.description}: "${match[0]}" (Goal: ${goal.description})`,
97
+ severity: rule.severity,
98
+ autoFixable: rule.autoFixable
99
+ };
100
+ if (rule.autoFixable) {
101
+ violation.fixAction = generateFixAction(violation, line, i + 1);
102
+ }
103
+ violations.push(violation);
104
+ }
105
+ }
106
+ return violations;
107
+ }
108
+ function generateFixAction(violation, originalLine, lineNumber) {
109
+ const { violation: match, goal } = violation;
110
+ let type;
111
+ let fixedLine;
112
+ if (/emoji/i.test(goal.description)) {
113
+ type = "remove-emoji";
114
+ fixedLine = originalLine.replace(/[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu, "");
115
+ } else if (/console/i.test(goal.description)) {
116
+ type = "remove-console-log";
117
+ fixedLine = "";
118
+ } else if (/debugger/i.test(goal.description)) {
119
+ type = "remove-debugger";
120
+ fixedLine = "";
121
+ } else {
122
+ type = "custom";
123
+ fixedLine = originalLine;
124
+ }
125
+ return {
126
+ id: `fix-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
127
+ file: violation.file,
128
+ line: lineNumber,
129
+ original: originalLine,
130
+ fixed: fixedLine,
131
+ type,
132
+ category: "goal-violation",
133
+ description: `Fix goal violation: ${violation.description}`,
134
+ confidence: 0.9
135
+ };
136
+ }
137
+ async function recordGoalViolationCaught(goal, file, projectPath) {
138
+ const guardianState = getGuardianState(projectPath);
139
+ await guardianState.load();
140
+ const metadata = goal.metadata || {};
141
+ const caughtCount = (metadata.caughtCount || 0) + 1;
142
+ await guardianState.updateGoal(goal.id, {
143
+ metadata: {
144
+ ...metadata,
145
+ caughtCount,
146
+ lastCaught: (/* @__PURE__ */ new Date()).toISOString(),
147
+ lastCaughtFile: file
148
+ }
149
+ });
150
+ }
151
+ async function recordGoalViolationFixed(goal, file, projectPath) {
152
+ const guardianState = getGuardianState(projectPath);
153
+ await guardianState.load();
154
+ const metadata = goal.metadata || {};
155
+ const caughtCount = (metadata.caughtCount || 0) + 1;
156
+ const fixedCount = (metadata.fixedCount || 0) + 1;
157
+ await guardianState.updateGoal(goal.id, {
158
+ metadata: {
159
+ ...metadata,
160
+ caughtCount,
161
+ fixedCount,
162
+ lastFixed: (/* @__PURE__ */ new Date()).toISOString(),
163
+ lastFixedFile: file
164
+ }
165
+ });
166
+ if (goal.type === "reduction") {
167
+ const newValue = Math.max(0, goal.currentValue - 1);
168
+ await guardianState.updateGoal(goal.id, {
169
+ currentValue: newValue
170
+ });
171
+ if (newValue <= goal.target) {
172
+ await guardianState.updateGoal(goal.id, {
173
+ status: "achieved",
174
+ achievedAt: (/* @__PURE__ */ new Date()).toISOString()
175
+ });
176
+ }
177
+ }
178
+ }
179
+ export {
180
+ recordGoalViolationCaught,
181
+ recordGoalViolationFixed,
182
+ validateAgainstGoals
183
+ };
184
+ //# sourceMappingURL=goal-validator-7UPLOVAZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/guardian/goal-validator.ts"],"sourcesContent":["/**\n * Goal Validator - Validates code changes against active user goals\n * \n * This module checks file changes in watch mode against active goals\n * and detects violations (e.g., \"no emojis\" goal violated by emoji usage)\n * \n * Integration points:\n * - Called by watch mode when files change\n * - Triggers auto-fix if enabled\n * - Records violations in ledger\n * - Updates goal progress tracking\n */\n\nimport type { Goal } from './guardian-state.js';\nimport { getGuardianState } from './guardian-state.js';\nimport type { AutoFixAction } from '../types/autonomy.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface GoalViolation {\n goal: Goal;\n file: string;\n line?: number;\n column?: number;\n violation: string;\n description: string;\n severity: 'critical' | 'high' | 'medium' | 'low';\n autoFixable: boolean;\n fixAction?: AutoFixAction;\n}\n\nexport interface ValidationResult {\n violations: GoalViolation[];\n passedGoals: Goal[];\n}\n\n// ============================================================================\n// Goal Validation Rules\n// ============================================================================\n\n/**\n * Rule definitions for common goals\n */\nconst GOAL_RULES = {\n 'no-emojis': {\n pattern: /[\\u{1F300}-\\u{1F9FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}]/u,\n description: 'Contains emoji',\n severity: 'medium' as const,\n autoFixable: true,\n },\n 'no-console': {\n pattern: /console\\.(log|debug|info|warn|error)/,\n description: 'Contains console statement',\n severity: 'low' as const,\n autoFixable: true,\n },\n 'no-debugger': {\n pattern: /\\bdebugger\\b/,\n description: 'Contains debugger statement',\n severity: 'medium' as const,\n autoFixable: true,\n },\n 'no-todo': {\n pattern: /\\b(TODO|FIXME|XXX|HACK)\\b/i,\n description: 'Contains TODO comment',\n severity: 'low' as const,\n autoFixable: false,\n },\n 'no-any': {\n pattern: /:\\s*any\\b/,\n description: 'Uses TypeScript any type',\n severity: 'medium' as const,\n autoFixable: false,\n },\n};\n\n/**\n * Match goal descriptions to validation rules\n */\nfunction matchGoalToRule(goal: Goal): keyof typeof GOAL_RULES | null {\n const desc = goal.description.toLowerCase();\n \n if (/no emoji|remove emoji|emoji.*free/i.test(desc)) {\n return 'no-emojis';\n }\n if (/no console|remove console|console.*free/i.test(desc)) {\n return 'no-console';\n }\n if (/no debugger|remove debugger/i.test(desc)) {\n return 'no-debugger';\n }\n if (/no (todo|fixme)|clean.*todo/i.test(desc)) {\n return 'no-todo';\n }\n if (/no any|avoid any|typescript.*any/i.test(desc)) {\n return 'no-any';\n }\n \n return null;\n}\n\n// ============================================================================\n// Validation Logic\n// ============================================================================\n\n/**\n * Validate file content against active goals\n */\nexport async function validateAgainstGoals(\n file: string,\n content: string,\n projectPath: string\n): Promise<ValidationResult> {\n const guardianState = getGuardianState(projectPath);\n await guardianState.load();\n \n const activeGoals = guardianState.getAllGoals().filter(g => g.status === 'active');\n const violations: GoalViolation[] = [];\n const passedGoals: Goal[] = [];\n \n for (const goal of activeGoals) {\n const ruleKey = matchGoalToRule(goal);\n if (!ruleKey) {\n continue; // No validation rule for this goal\n }\n \n const rule = GOAL_RULES[ruleKey];\n const foundViolations = findViolations(file, content, goal, rule);\n \n if (foundViolations.length > 0) {\n violations.push(...foundViolations);\n } else {\n passedGoals.push(goal);\n }\n }\n \n return { violations, passedGoals };\n}\n\n/**\n * Find all violations of a rule in file content\n */\nfunction findViolations(\n file: string,\n content: string,\n goal: Goal,\n rule: typeof GOAL_RULES[keyof typeof GOAL_RULES]\n): GoalViolation[] {\n const violations: GoalViolation[] = [];\n const lines = content.split('\\n');\n \n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (!line) continue;\n \n const match = line.match(rule.pattern);\n if (match) {\n const violation: GoalViolation = {\n goal,\n file,\n line: i + 1,\n column: match.index,\n violation: match[0],\n description: `${rule.description}: \"${match[0]}\" (Goal: ${goal.description})`,\n severity: rule.severity,\n autoFixable: rule.autoFixable,\n };\n \n // Generate fix action if auto-fixable\n if (rule.autoFixable) {\n violation.fixAction = generateFixAction(violation, line, i + 1);\n }\n \n violations.push(violation);\n }\n }\n \n return violations;\n}\n\n/**\n * Generate an auto-fix action for a violation\n */\nfunction generateFixAction(\n violation: GoalViolation,\n originalLine: string,\n lineNumber: number\n): AutoFixAction {\n const { violation: match, goal } = violation;\n \n // Determine fix type based on violation\n let type: AutoFixAction['type'];\n let fixedLine: string;\n \n if (/emoji/i.test(goal.description)) {\n type = 'remove-emoji';\n // Remove emoji from the line\n fixedLine = originalLine.replace(/[\\u{1F300}-\\u{1F9FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}]/gu, '');\n } else if (/console/i.test(goal.description)) {\n type = 'remove-console-log';\n fixedLine = ''; // Remove entire line\n } else if (/debugger/i.test(goal.description)) {\n type = 'remove-debugger';\n fixedLine = ''; // Remove entire line\n } else {\n type = 'custom';\n fixedLine = originalLine; // Generic\n }\n \n return {\n id: `fix-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n file: violation.file,\n line: lineNumber,\n original: originalLine,\n fixed: fixedLine,\n type,\n category: 'goal-violation',\n description: `Fix goal violation: ${violation.description}`,\n confidence: 0.9,\n };\n}\n\n// ============================================================================\n// Goal Progress Tracking\n// ============================================================================\n\n/**\n * Record that a goal violation was caught\n */\nexport async function recordGoalViolationCaught(\n goal: Goal,\n file: string,\n projectPath: string\n): Promise<void> {\n const guardianState = getGuardianState(projectPath);\n await guardianState.load();\n \n // Increment caught count (stored in metadata)\n const metadata = goal.metadata || {};\n const caughtCount = (metadata.caughtCount || 0) + 1;\n \n await guardianState.updateGoal(goal.id, {\n metadata: {\n ...metadata,\n caughtCount,\n lastCaught: new Date().toISOString(),\n lastCaughtFile: file,\n },\n });\n}\n\n/**\n * Record that a goal violation was automatically fixed\n */\nexport async function recordGoalViolationFixed(\n goal: Goal,\n file: string,\n projectPath: string\n): Promise<void> {\n const guardianState = getGuardianState(projectPath);\n await guardianState.load();\n \n // Increment both caught and fixed counts\n const metadata = goal.metadata || {};\n const caughtCount = (metadata.caughtCount || 0) + 1;\n const fixedCount = (metadata.fixedCount || 0) + 1;\n \n await guardianState.updateGoal(goal.id, {\n metadata: {\n ...metadata,\n caughtCount,\n fixedCount,\n lastFixed: new Date().toISOString(),\n lastFixedFile: file,\n },\n });\n \n // Update goal progress (currentValue decreases for reduction goals)\n if (goal.type === 'reduction') {\n const newValue = Math.max(0, goal.currentValue - 1);\n await guardianState.updateGoal(goal.id, {\n currentValue: newValue,\n });\n \n // Check if goal is achieved\n if (newValue <= goal.target) {\n await guardianState.updateGoal(goal.id, {\n status: 'achieved',\n achievedAt: new Date().toISOString(),\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;AA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AC;AAGD,QAAI,YAAY,KAAK,QAAQ;AAC3B,YAAM,cAAc,WAAW,KAAK,IAAI;AAAA,QACtC,QAAQ;AAAA,QACR,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,10 @@
1
+ import {
2
+ ContextGraph
3
+ } from "./chunk-NS2MSZMB.js";
4
+ import "./chunk-R4AAPFXC.js";
5
+ import "./chunk-APMV77PU.js";
6
+ import "./chunk-DGUM43GV.js";
7
+ export {
8
+ ContextGraph
9
+ };
10
+ //# sourceMappingURL=graph-U5JWSAB5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,25 @@
1
+ import {
2
+ GuardianAgent,
3
+ getGuardian
4
+ } from "./chunk-AOFYU6T3.js";
5
+ import "./chunk-2SIFK7OW.js";
6
+ import "./chunk-DZREHOGW.js";
7
+ import "./chunk-6LXSA2OZ.js";
8
+ import "./chunk-D3EXBJE2.js";
9
+ import "./chunk-SWSK7ANT.js";
10
+ import "./chunk-55DOQNHJ.js";
11
+ import "./chunk-KRH642MT.js";
12
+ import "./chunk-F4NJ4CBP.js";
13
+ import "./chunk-IXO4G4D3.js";
14
+ import "./chunk-NS2MSZMB.js";
15
+ import "./chunk-6NLHFIYA.js";
16
+ import "./chunk-YR4BMGYO.js";
17
+ import "./chunk-43X6JBEM.js";
18
+ import "./chunk-R4AAPFXC.js";
19
+ import "./chunk-APMV77PU.js";
20
+ import "./chunk-DGUM43GV.js";
21
+ export {
22
+ GuardianAgent,
23
+ getGuardian
24
+ };
25
+ //# sourceMappingURL=guardian-agent-EXP7APLC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ import {
2
+ HypothesisEngine,
3
+ clearHypothesisEngines,
4
+ getHypothesisEngine
5
+ } from "./chunk-DZREHOGW.js";
6
+ import "./chunk-6LXSA2OZ.js";
7
+ import "./chunk-55DOQNHJ.js";
8
+ import "./chunk-KRH642MT.js";
9
+ import "./chunk-YR4BMGYO.js";
10
+ import "./chunk-43X6JBEM.js";
11
+ import "./chunk-R4AAPFXC.js";
12
+ import "./chunk-APMV77PU.js";
13
+ import "./chunk-DGUM43GV.js";
14
+ export {
15
+ HypothesisEngine,
16
+ clearHypothesisEngines,
17
+ getHypothesisEngine
18
+ };
19
+ //# sourceMappingURL=hypothesis-KGC3P54C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ import {
2
+ IncidentIndex
3
+ } from "./chunk-2GIAROBF.js";
4
+ import "./chunk-6NLHFIYA.js";
5
+ import "./chunk-R4AAPFXC.js";
6
+ import "./chunk-APMV77PU.js";
7
+ import "./chunk-DGUM43GV.js";
8
+ export {
9
+ IncidentIndex
10
+ };
11
+ //# sourceMappingURL=incident-index-PNIVT47T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}