@triedotdev/mcp 1.0.113 → 1.0.115
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.
- package/dist/auto-fix-apply-PCAHWLXF.js +10 -0
- package/dist/autonomy-config-JXB7WCZ2.js +30 -0
- package/dist/chunk-2GIAROBF.js +173 -0
- package/dist/chunk-2GIAROBF.js.map +1 -0
- package/dist/{chunk-33WL3D7A.js → chunk-2SIFK7OW.js} +7 -419
- package/dist/chunk-2SIFK7OW.js.map +1 -0
- package/dist/chunk-43X6JBEM.js +36 -0
- package/dist/chunk-43X6JBEM.js.map +1 -0
- package/dist/chunk-55DOQNHJ.js +772 -0
- package/dist/chunk-55DOQNHJ.js.map +1 -0
- package/dist/chunk-6LXSA2OZ.js +425 -0
- package/dist/chunk-6LXSA2OZ.js.map +1 -0
- package/dist/{chunk-SDS3UVFY.js → chunk-AOFYU6T3.js} +113 -559
- package/dist/chunk-AOFYU6T3.js.map +1 -0
- package/dist/{chunk-6QR6QZIX.js → chunk-D3EXBJE2.js} +25 -658
- package/dist/chunk-D3EXBJE2.js.map +1 -0
- package/dist/chunk-DJ2YAGHK.js +50 -0
- package/dist/chunk-DJ2YAGHK.js.map +1 -0
- package/dist/chunk-DZREHOGW.js +706 -0
- package/dist/chunk-DZREHOGW.js.map +1 -0
- package/dist/chunk-I2GFI3AM.js +340 -0
- package/dist/chunk-I2GFI3AM.js.map +1 -0
- package/dist/chunk-KRH642MT.js +947 -0
- package/dist/chunk-KRH642MT.js.map +1 -0
- package/dist/{chunk-QYOACM2C.js → chunk-MVNJPJBK.js} +22 -252
- package/dist/chunk-MVNJPJBK.js.map +1 -0
- package/dist/chunk-NS2MSZMB.js +394 -0
- package/dist/chunk-NS2MSZMB.js.map +1 -0
- package/dist/chunk-SWSK7ANT.js +340 -0
- package/dist/chunk-SWSK7ANT.js.map +1 -0
- package/dist/chunk-VRLMTOB6.js +566 -0
- package/dist/chunk-VRLMTOB6.js.map +1 -0
- package/dist/chunk-YR4BMGYO.js +130 -0
- package/dist/chunk-YR4BMGYO.js.map +1 -0
- package/dist/chunk-ZV2K6M7T.js +74 -0
- package/dist/chunk-ZV2K6M7T.js.map +1 -0
- package/dist/{chunk-2764KZZQ.js → chunk-ZYKEILVK.js} +451 -1069
- package/dist/chunk-ZYKEILVK.js.map +1 -0
- package/dist/cli/main.js +107 -375
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +18 -8
- package/dist/cli/yolo-daemon.js.map +1 -1
- package/dist/client-7XZHCMD3.js +28 -0
- package/dist/client-7XZHCMD3.js.map +1 -0
- package/dist/{goal-manager-AP4LTE6U.js → goal-manager-LMS6ZJB7.js} +7 -3
- package/dist/goal-manager-LMS6ZJB7.js.map +1 -0
- package/dist/goal-validator-T5HEYBC5.js +186 -0
- package/dist/goal-validator-T5HEYBC5.js.map +1 -0
- package/dist/graph-U5JWSAB5.js +10 -0
- package/dist/graph-U5JWSAB5.js.map +1 -0
- package/dist/guardian-agent-EXP7APLC.js +25 -0
- package/dist/guardian-agent-EXP7APLC.js.map +1 -0
- package/dist/hypothesis-KGC3P54C.js +19 -0
- package/dist/hypothesis-KGC3P54C.js.map +1 -0
- package/dist/incident-index-PNIVT47T.js +11 -0
- package/dist/incident-index-PNIVT47T.js.map +1 -0
- package/dist/index.js +369 -43
- package/dist/index.js.map +1 -1
- package/dist/ledger-SR6OEBLO.js +15 -0
- package/dist/ledger-SR6OEBLO.js.map +1 -0
- package/dist/output-manager-BOTMXSND.js +13 -0
- package/dist/output-manager-BOTMXSND.js.map +1 -0
- package/dist/pattern-discovery-F7LU5K6E.js +8 -0
- package/dist/pattern-discovery-F7LU5K6E.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-2764KZZQ.js.map +0 -1
- package/dist/chunk-33WL3D7A.js.map +0 -1
- package/dist/chunk-6JPPYG7F.js +0 -1813
- package/dist/chunk-6JPPYG7F.js.map +0 -1
- package/dist/chunk-6QR6QZIX.js.map +0 -1
- package/dist/chunk-QYOACM2C.js.map +0 -1
- package/dist/chunk-SDS3UVFY.js.map +0 -1
- package/dist/guardian-agent-XEYNG7RH.js +0 -18
- /package/dist/{goal-manager-AP4LTE6U.js.map → auto-fix-apply-PCAHWLXF.js.map} +0 -0
- /package/dist/{guardian-agent-XEYNG7RH.js.map → autonomy-config-JXB7WCZ2.js.map} +0 -0
package/dist/cli/yolo-daemon.js
CHANGED
|
@@ -3,20 +3,30 @@ import {
|
|
|
3
3
|
InteractiveDashboard,
|
|
4
4
|
StreamingManager,
|
|
5
5
|
TrieScanTool
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-ZYKEILVK.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-
|
|
11
|
-
import "../chunk-
|
|
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-
|
|
14
|
-
import "../chunk-
|
|
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,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AAW,OAAO,EAAE;AAChD;AACA;AAAA,MACF,KAAK;AAAA,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,E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analyzeCodeIssues,
|
|
3
|
+
getAIStatusMessage,
|
|
4
|
+
getClient,
|
|
5
|
+
getKeyFromKeychain,
|
|
6
|
+
isAIAvailable,
|
|
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-
|
|
8
|
-
import "./chunk-
|
|
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-
|
|
23
|
+
//# sourceMappingURL=goal-manager-LMS6ZJB7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,186 @@
|
|
|
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 REGEX_RULES = {
|
|
11
|
+
"no-emojis": {
|
|
12
|
+
pattern: /[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{FE00}-\u{FE0F}\u{200D}\u{1F1E0}-\u{1F1FF}\u{E0020}-\u{E007F}]/u,
|
|
13
|
+
description: "Contains emoji",
|
|
14
|
+
severity: "medium",
|
|
15
|
+
autoFixable: true,
|
|
16
|
+
keywords: /emoji/i
|
|
17
|
+
},
|
|
18
|
+
"no-console": {
|
|
19
|
+
pattern: /console\.(log|debug|info|warn|error)\s*\(/,
|
|
20
|
+
description: "Contains console statement",
|
|
21
|
+
severity: "low",
|
|
22
|
+
autoFixable: true,
|
|
23
|
+
keywords: /console/i
|
|
24
|
+
},
|
|
25
|
+
"no-debugger": {
|
|
26
|
+
pattern: /\bdebugger\b/,
|
|
27
|
+
description: "Contains debugger statement",
|
|
28
|
+
severity: "medium",
|
|
29
|
+
autoFixable: true,
|
|
30
|
+
keywords: /debugger/i
|
|
31
|
+
},
|
|
32
|
+
"no-todo": {
|
|
33
|
+
pattern: /\/\/\s*(TODO|FIXME|XXX|HACK)\b/i,
|
|
34
|
+
description: "Contains TODO comment",
|
|
35
|
+
severity: "low",
|
|
36
|
+
autoFixable: false,
|
|
37
|
+
keywords: /todo|fixme/i
|
|
38
|
+
},
|
|
39
|
+
"no-any": {
|
|
40
|
+
pattern: /:\s*any\b/,
|
|
41
|
+
description: "Uses TypeScript any type",
|
|
42
|
+
severity: "medium",
|
|
43
|
+
autoFixable: false,
|
|
44
|
+
keywords: /\bany\b.*type/i
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function matchGoalToRegexRule(goal) {
|
|
48
|
+
const desc = goal.description.toLowerCase();
|
|
49
|
+
for (const [key, rule] of Object.entries(REGEX_RULES)) {
|
|
50
|
+
if (rule.keywords.test(desc)) {
|
|
51
|
+
return key;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
async function validateAgainstGoals(file, content, projectPath) {
|
|
57
|
+
const guardianState = getGuardianState(projectPath);
|
|
58
|
+
await guardianState.load();
|
|
59
|
+
const activeGoals = guardianState.getAllGoals().filter((g) => g.status === "active");
|
|
60
|
+
if (activeGoals.length === 0) {
|
|
61
|
+
return { violations: [], passedGoals: [] };
|
|
62
|
+
}
|
|
63
|
+
const violations = [];
|
|
64
|
+
const passedGoals = [];
|
|
65
|
+
for (const goal of activeGoals) {
|
|
66
|
+
const ruleKey = matchGoalToRegexRule(goal);
|
|
67
|
+
if (!ruleKey) continue;
|
|
68
|
+
const rule = REGEX_RULES[ruleKey];
|
|
69
|
+
const found = findRegexViolations(file, content, goal, rule);
|
|
70
|
+
if (found.length > 0) {
|
|
71
|
+
violations.push(...found);
|
|
72
|
+
} else {
|
|
73
|
+
passedGoals.push(goal);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { violations, passedGoals };
|
|
77
|
+
}
|
|
78
|
+
async function getActiveGoals(projectPath) {
|
|
79
|
+
const guardianState = getGuardianState(projectPath);
|
|
80
|
+
await guardianState.load();
|
|
81
|
+
return guardianState.getAllGoals().filter((g) => g.status === "active");
|
|
82
|
+
}
|
|
83
|
+
function findRegexViolations(file, content, goal, rule) {
|
|
84
|
+
const violations = [];
|
|
85
|
+
const lines = content.split("\n");
|
|
86
|
+
for (let i = 0; i < lines.length; i++) {
|
|
87
|
+
const line = lines[i];
|
|
88
|
+
if (!line) continue;
|
|
89
|
+
const match = line.match(rule.pattern);
|
|
90
|
+
if (match) {
|
|
91
|
+
const violation = {
|
|
92
|
+
goal,
|
|
93
|
+
file,
|
|
94
|
+
line: i + 1,
|
|
95
|
+
column: match.index,
|
|
96
|
+
violation: match[0],
|
|
97
|
+
description: `${rule.description}: "${match[0]}" (Goal: ${goal.description})`,
|
|
98
|
+
severity: rule.severity,
|
|
99
|
+
autoFixable: rule.autoFixable
|
|
100
|
+
};
|
|
101
|
+
if (rule.autoFixable) {
|
|
102
|
+
violation.fixAction = generateFixAction(violation, line, i + 1);
|
|
103
|
+
}
|
|
104
|
+
violations.push(violation);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return violations;
|
|
108
|
+
}
|
|
109
|
+
function generateFixAction(violation, originalLine, lineNumber) {
|
|
110
|
+
const { goal } = violation;
|
|
111
|
+
let type;
|
|
112
|
+
let fixedLine;
|
|
113
|
+
if (/emoji/i.test(goal.description)) {
|
|
114
|
+
type = "remove-emoji";
|
|
115
|
+
fixedLine = originalLine.replace(/[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{FE00}-\u{FE0F}\u{200D}\u{1F1E0}-\u{1F1FF}\u{E0020}-\u{E007F}]/gu, "");
|
|
116
|
+
} else if (/console/i.test(goal.description)) {
|
|
117
|
+
type = "remove-console-log";
|
|
118
|
+
fixedLine = "";
|
|
119
|
+
} else if (/debugger/i.test(goal.description)) {
|
|
120
|
+
type = "remove-debugger";
|
|
121
|
+
fixedLine = "";
|
|
122
|
+
} else {
|
|
123
|
+
type = "goal-violation";
|
|
124
|
+
fixedLine = originalLine;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
id: `fix-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
128
|
+
file: violation.file,
|
|
129
|
+
line: lineNumber,
|
|
130
|
+
original: originalLine,
|
|
131
|
+
fixed: fixedLine,
|
|
132
|
+
type,
|
|
133
|
+
category: "goal-violation",
|
|
134
|
+
description: `Fix goal violation: ${violation.description}`,
|
|
135
|
+
confidence: 0.9
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async function recordGoalViolationCaught(goal, file, projectPath) {
|
|
139
|
+
const guardianState = getGuardianState(projectPath);
|
|
140
|
+
await guardianState.load();
|
|
141
|
+
const metadata = goal.metadata || {};
|
|
142
|
+
const caughtCount = (metadata.caughtCount || 0) + 1;
|
|
143
|
+
await guardianState.updateGoal(goal.id, {
|
|
144
|
+
metadata: {
|
|
145
|
+
...metadata,
|
|
146
|
+
caughtCount,
|
|
147
|
+
lastCaught: (/* @__PURE__ */ new Date()).toISOString(),
|
|
148
|
+
lastCaughtFile: file
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async function recordGoalViolationFixed(goal, file, projectPath) {
|
|
153
|
+
const guardianState = getGuardianState(projectPath);
|
|
154
|
+
await guardianState.load();
|
|
155
|
+
const metadata = goal.metadata || {};
|
|
156
|
+
const caughtCount = (metadata.caughtCount || 0) + 1;
|
|
157
|
+
const fixedCount = (metadata.fixedCount || 0) + 1;
|
|
158
|
+
await guardianState.updateGoal(goal.id, {
|
|
159
|
+
metadata: {
|
|
160
|
+
...metadata,
|
|
161
|
+
caughtCount,
|
|
162
|
+
fixedCount,
|
|
163
|
+
lastFixed: (/* @__PURE__ */ new Date()).toISOString(),
|
|
164
|
+
lastFixedFile: file
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
if (goal.type === "reduction") {
|
|
168
|
+
const newValue = Math.max(0, goal.currentValue - 1);
|
|
169
|
+
await guardianState.updateGoal(goal.id, {
|
|
170
|
+
currentValue: newValue
|
|
171
|
+
});
|
|
172
|
+
if (newValue <= goal.target) {
|
|
173
|
+
await guardianState.updateGoal(goal.id, {
|
|
174
|
+
status: "achieved",
|
|
175
|
+
achievedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
getActiveGoals,
|
|
182
|
+
recordGoalViolationCaught,
|
|
183
|
+
recordGoalViolationFixed,
|
|
184
|
+
validateAgainstGoals
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=goal-validator-T5HEYBC5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/guardian/goal-validator.ts"],"sourcesContent":["/**\n * Goal Validator - Offline regex-based validation of code against user goals\n * \n * This module provides fast, instant detection of common goal violations\n * using regex patterns. It runs on every file change with zero latency.\n * \n * AI-powered goal detection is handled by the watch mode's AI watcher\n * (autoScanFiles in watch.ts) which includes goals in its Claude prompt.\n * This module is the offline fallback / instant-catch layer.\n */\n\nimport type { Goal } from './guardian-state.js';\nimport { getGuardianState } from './guardian-state.js';\nimport type { AutoFixAction } from '../types/autonomy.js';\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\nconst REGEX_RULES: Record<string, {\n pattern: RegExp;\n description: string;\n severity: 'critical' | 'high' | 'medium' | 'low';\n autoFixable: boolean;\n keywords: RegExp;\n}> = {\n 'no-emojis': {\n pattern: /[\\u{1F300}-\\u{1F9FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}\\u{FE00}-\\u{FE0F}\\u{200D}\\u{1F1E0}-\\u{1F1FF}\\u{E0020}-\\u{E007F}]/u,\n description: 'Contains emoji',\n severity: 'medium',\n autoFixable: true,\n keywords: /emoji/i,\n },\n 'no-console': {\n pattern: /console\\.(log|debug|info|warn|error)\\s*\\(/,\n description: 'Contains console statement',\n severity: 'low',\n autoFixable: true,\n keywords: /console/i,\n },\n 'no-debugger': {\n pattern: /\\bdebugger\\b/,\n description: 'Contains debugger statement',\n severity: 'medium',\n autoFixable: true,\n keywords: /debugger/i,\n },\n 'no-todo': {\n pattern: /\\/\\/\\s*(TODO|FIXME|XXX|HACK)\\b/i,\n description: 'Contains TODO comment',\n severity: 'low',\n autoFixable: false,\n keywords: /todo|fixme/i,\n },\n 'no-any': {\n pattern: /:\\s*any\\b/,\n description: 'Uses TypeScript any type',\n severity: 'medium',\n autoFixable: false,\n keywords: /\\bany\\b.*type/i,\n },\n};\n\nfunction matchGoalToRegexRule(goal: Goal): string | null {\n const desc = goal.description.toLowerCase();\n for (const [key, rule] of Object.entries(REGEX_RULES)) {\n if (rule.keywords.test(desc)) {\n return key;\n }\n }\n return null;\n}\n\n/**\n * Fast offline validation using regex patterns only.\n * AI-powered detection is handled by the AI watcher in watch.ts.\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 if (activeGoals.length === 0) {\n return { violations: [], passedGoals: [] };\n }\n\n const violations: GoalViolation[] = [];\n const passedGoals: Goal[] = [];\n\n for (const goal of activeGoals) {\n const ruleKey = matchGoalToRegexRule(goal);\n if (!ruleKey) continue;\n\n const rule = REGEX_RULES[ruleKey];\n const found = findRegexViolations(file, content, goal, rule);\n if (found.length > 0) {\n violations.push(...found);\n } else {\n passedGoals.push(goal);\n }\n }\n\n return { violations, passedGoals };\n}\n\n/**\n * Get active goals for a project (used by the AI watcher)\n */\nexport async function getActiveGoals(projectPath: string): Promise<Goal[]> {\n const guardianState = getGuardianState(projectPath);\n await guardianState.load();\n return guardianState.getAllGoals().filter(g => g.status === 'active');\n}\n\nfunction findRegexViolations(\n file: string,\n content: string,\n goal: Goal,\n rule: typeof REGEX_RULES[string]\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 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\nfunction generateFixAction(\n violation: GoalViolation,\n originalLine: string,\n lineNumber: number\n): AutoFixAction {\n const { goal } = violation;\n \n let type: AutoFixAction['type'];\n let fixedLine: string;\n \n if (/emoji/i.test(goal.description)) {\n type = 'remove-emoji';\n fixedLine = originalLine.replace(/[\\u{1F300}-\\u{1F9FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}\\u{FE00}-\\u{FE0F}\\u{200D}\\u{1F1E0}-\\u{1F1FF}\\u{E0020}-\\u{E007F}]/gu, '');\n } else if (/console/i.test(goal.description)) {\n type = 'remove-console-log';\n fixedLine = '';\n } else if (/debugger/i.test(goal.description)) {\n type = 'remove-debugger';\n fixedLine = '';\n } else {\n type = 'goal-violation';\n fixedLine = originalLine;\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\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 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\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 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 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 if (newValue <= goal.target) {\n await guardianState.updateGoal(goal.id, {\n status: 'achieved',\n achievedAt: new Date().toISOString(),\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;AAgCA,IAAM,cAMD;AAAA,EACH,aAAa;AAAA,IACX,SAAS;AAAA,IACT,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EACA,cAAc;AAAA,IACZ,SAAS;AAAA,IACT,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EACA,eAAe;AAAA,IACb,SAAS;AAAA,IACT,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EACA,WAAW;AAAA,IACT,SAAS;AAAA,IACT,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,IACT,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AACF;AAEA,SAAS,qBAAqB,MAA2B;AACvD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C;AACnC,QAAM,eAAe,SAAS,eAAe,KAAK;AAElD,QAAM,cAAc,WAAW,KAAK,IAAI;AAAA,IACtC,UAAU;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,MACnC,gBAAgB;AAAA,IAClB;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,yBACpB,MACA,MACA,aACe;AACf,QAAM,gBAAgB,iBAAiB,WAAW;AAClD,QAAM,cAAc,KAAK;AAEzB,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,QAAM,eAAe,SAAS,eAAe,KAAK;AAClD,QAAM,cAAc,SAAS,cAAc,KAAK;AAEhD,QAAM,cAAc,WAAW,KAAK,IAAI;AAAA,IACtC,UAAU;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MAClC,eAAe;AAAA,IACjB;AAAA,EACF,CAAC;AAED,MAAI,KAAK,SAAS,aAAa;AAC7B,UAAM,WAAW,KAAK,IAAI,GAAG,KAAK,eAAe,CAAC;AAClD,UAAM,cAAc,WAAW,KAAK,IAAI;AAAA,MACtC,cAAc;AAAA,IAChB,CAAC;AAED,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 @@
|
|
|
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":[]}
|