@triedotdev/mcp 1.0.136 → 1.0.137
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/{chunk-DFHMB44X.js → chunk-4JQ6W7LW.js} +3 -4
- package/dist/chunk-4JQ6W7LW.js.map +1 -0
- package/dist/{chunk-WS6OA7H6.js → chunk-4MJ52WBH.js} +2 -3
- package/dist/chunk-4MJ52WBH.js.map +1 -0
- package/dist/{chunk-UHMMANC2.js → chunk-6EP2VTHC.js} +15 -15
- package/dist/chunk-6EP2VTHC.js.map +1 -0
- package/dist/{chunk-T4THB2OR.js → chunk-A6PWS6ZV.js} +38 -27
- package/dist/chunk-A6PWS6ZV.js.map +1 -0
- package/dist/{chunk-POHBQUG7.js → chunk-AXYNWBME.js} +272 -187
- package/dist/chunk-AXYNWBME.js.map +1 -0
- package/dist/{chunk-AJ34GCMD.js → chunk-DPZLABUC.js} +32 -32
- package/dist/chunk-DPZLABUC.js.map +1 -0
- package/dist/{chunk-UHX4462X.js → chunk-G74XEI7K.js} +13 -14
- package/dist/chunk-G74XEI7K.js.map +1 -0
- package/dist/{goal-validator-PDKYZSNP.js → chunk-HUR67JXG.js} +71 -33
- package/dist/chunk-HUR67JXG.js.map +1 -0
- package/dist/{chunk-6OUWNVLX.js → chunk-K6NTRSDF.js} +4 -4
- package/dist/{chunk-G5PRBQIQ.js → chunk-QM5VIDFN.js} +75 -71
- package/dist/chunk-QM5VIDFN.js.map +1 -0
- package/dist/{chunk-4YJ6KLGI.js → chunk-QNKBXOIQ.js} +7 -5
- package/dist/chunk-QNKBXOIQ.js.map +1 -0
- package/dist/{chunk-JAKMZI5S.js → chunk-R3WZI6QZ.js} +290 -179
- package/dist/chunk-R3WZI6QZ.js.map +1 -0
- package/dist/{chunk-VRLMTOB6.js → chunk-TIMIKBY2.js} +1 -1
- package/dist/chunk-TIMIKBY2.js.map +1 -0
- package/dist/cli/main.js +104 -100
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +13 -13
- package/dist/cli/yolo-daemon.js.map +1 -1
- package/dist/{goal-manager-FAK7H4RR.js → goal-manager-62IL6WGY.js} +6 -7
- package/dist/goal-validator-HPPBSDXD.js +22 -0
- package/dist/guardian-agent-YKG5XURG.js +30 -0
- package/dist/{hypothesis-L5446W36.js → hypothesis-W37VG6DA.js} +6 -7
- package/dist/index.js +265 -259
- package/dist/index.js.map +1 -1
- package/dist/{insight-store-F5KDBY5Y.js → insight-store-U3NYTOJE.js} +5 -3
- package/dist/issue-store-EZMBHOVN.js +32 -0
- package/dist/{output-manager-BOTMXSND.js → output-manager-DZO5LGSG.js} +2 -2
- package/dist/output-manager-DZO5LGSG.js.map +1 -0
- package/dist/ui/chat.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-4YJ6KLGI.js.map +0 -1
- package/dist/chunk-AJ34GCMD.js.map +0 -1
- package/dist/chunk-DFHMB44X.js.map +0 -1
- package/dist/chunk-G5PRBQIQ.js.map +0 -1
- package/dist/chunk-JAKMZI5S.js.map +0 -1
- package/dist/chunk-PEJEYWVR.js +0 -135
- package/dist/chunk-PEJEYWVR.js.map +0 -1
- package/dist/chunk-POHBQUG7.js.map +0 -1
- package/dist/chunk-T4THB2OR.js.map +0 -1
- package/dist/chunk-UHMMANC2.js.map +0 -1
- package/dist/chunk-UHX4462X.js.map +0 -1
- package/dist/chunk-VRLMTOB6.js.map +0 -1
- package/dist/chunk-WS6OA7H6.js.map +0 -1
- package/dist/goal-validator-PDKYZSNP.js.map +0 -1
- package/dist/guardian-agent-4RHGIXUD.js +0 -27
- package/dist/ledger-WKVJWHBX.js +0 -17
- /package/dist/{chunk-6OUWNVLX.js.map → chunk-K6NTRSDF.js.map} +0 -0
- /package/dist/{goal-manager-FAK7H4RR.js.map → goal-manager-62IL6WGY.js.map} +0 -0
- /package/dist/{guardian-agent-4RHGIXUD.js.map → goal-validator-HPPBSDXD.js.map} +0 -0
- /package/dist/{hypothesis-L5446W36.js.map → guardian-agent-YKG5XURG.js.map} +0 -0
- /package/dist/{insight-store-F5KDBY5Y.js.map → hypothesis-W37VG6DA.js.map} +0 -0
- /package/dist/{ledger-WKVJWHBX.js.map → insight-store-U3NYTOJE.js.map} +0 -0
- /package/dist/{output-manager-BOTMXSND.js.map → issue-store-EZMBHOVN.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/guardian/goal-validator.ts"],"sourcesContent":["/**\n * Goal Validator - Helpers for goal tracking\n * \n * Goal detection is handled entirely by the AI watcher in watch.ts.\n * The AI (Anthropic) checks every changed file against user-defined goals,\n * using the Trie's priority scoring for cost control.\n * \n * This module provides:\n * - getActiveGoals: loads active goals for the AI prompt\n * - recordGoalViolationCaught: tracks when a violation is detected\n * - recordGoalViolationFixed: tracks when a violation is auto-fixed\n * - measureInitialGoalValue: measures current state for new goals\n */\n\nimport type { Goal } from './guardian-state.js';\nimport { getProjectState } from './guardian-state.js';\nimport { searchIssues } from '../memory/issue-store.js';\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 projectState = getProjectState(projectPath);\n await projectState.load();\n return projectState.getAllGoals().filter(g => g.status === 'active');\n}\n\nexport async function recordGoalViolationCaught(\n goal: Goal,\n file: string,\n projectPath: string\n): Promise<void> {\n const projectState = getProjectState(projectPath);\n await projectState.load();\n \n const metadata = goal.metadata || {};\n const caughtCount = (metadata.caughtCount || 0) + 1;\n \n await projectState.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 projectState = getProjectState(projectPath);\n await projectState.load();\n \n const metadata = goal.metadata || {};\n const fixedCount = (metadata.fixedCount || 0) + 1;\n \n await projectState.updateGoal(goal.id, {\n metadata: {\n ...metadata,\n fixedCount,\n lastFixed: new Date().toISOString(),\n lastFixedFile: file,\n },\n });\n \n // Resolve the goal-violation issue in the issue store\n // This is the source of truth - measureGoalMetric() will query from here\n const { resolveGoalViolation } = await import('../memory/issue-store.js');\n await resolveGoalViolation(file, goal.description, projectPath);\n \n // Trigger immediate progress update so UI reflects the fix\n const { getGoalManager } = await import('./goal-manager.js');\n const goalManager = getGoalManager(projectPath);\n await goalManager.updateGoalProgress();\n}\n\n/**\n * Measure the initial value for a new goal based on existing issues.\n * This sets a proper baseline so progress calculation works correctly.\n * \n * For reduction goals (like \"no emojis\"), we count current violations.\n * For other goals, we use semantic matching against existing issues.\n * \n * Returns the count to use as both startValue and currentValue.\n */\nexport async function measureInitialGoalValue(\n description: string,\n projectPath: string\n): Promise<number> {\n try {\n const issues = await searchIssues('', {\n workDir: projectPath,\n limit: 1000,\n includeResolved: false,\n });\n \n if (issues.length === 0) {\n return 0;\n }\n \n const desc = description.toLowerCase();\n \n // Check for goal-violation issues that might already exist for similar goals\n const goalViolations = issues.filter(r => \n r.issue.agent === 'goal-violation' &&\n r.issue.issue.toLowerCase().includes(desc.slice(0, 30))\n );\n if (goalViolations.length > 0) {\n return goalViolations.length;\n }\n \n // Security goals\n if (desc.includes('security') || desc.includes('vulnerab')) {\n return issues.filter(r => \n r.issue.agent === 'security' || r.issue.severity === 'critical'\n ).length;\n }\n \n // Type safety goals\n if (desc.includes('type') || desc.includes('typescript') || desc.includes('any type')) {\n return issues.filter(r => \n r.issue.agent === 'typecheck' ||\n r.issue.issue.toLowerCase().includes('type')\n ).length;\n }\n \n // Bug-related goals\n if (desc.includes('bug') || desc.includes('error')) {\n return issues.filter(r => \n r.issue.agent === 'bug-finding' ||\n r.issue.severity === 'critical' ||\n r.issue.severity === 'serious'\n ).length;\n }\n \n // Dead code / unused code goals\n if (desc.includes('dead code') || desc.includes('unused')) {\n return issues.filter(r => {\n const msg = r.issue.issue.toLowerCase();\n return msg.includes('unused') || msg.includes('dead code') || msg.includes('never used');\n }).length;\n }\n \n // For custom goals like \"no emojis\", we start at 0 and let the AI scanner find violations\n // This is correct because we don't know the count until a scan runs\n return 0;\n } catch {\n return 0;\n }\n}\n\n/**\n * Manually check files against goals\n * Returns violations found\n * \n * NOW WITH CACHING: Uses CodebaseIndex to avoid re-scanning unchanged files\n */\nexport async function checkFilesForGoalViolations(\n goals: Goal[],\n projectPath: string,\n filesToCheck?: string[],\n onProgress?: (message: string) => void\n): Promise<Array<{ file: string; message: string; severity: 'critical' | 'warning' | 'info' }>> {\n // Import AI client and codebase index\n const { isAIAvailable, runAIAnalysis } = await import('../ai/client.js');\n const { CodebaseIndex } = await import('../context/codebase-index.js');\n \n if (!isAIAvailable()) {\n throw new Error('AI not available - ANTHROPIC_API_KEY not set');\n }\n \n // Initialize codebase index for caching\n const codebaseIndex = new CodebaseIndex(projectPath);\n \n // Check if index needs to be built\n if (codebaseIndex.isEmpty()) {\n onProgress?.('Building codebase index (first-time, may take a minute)...');\n console.error('[Goal Check] Codebase index is empty - building index first...');\n console.error('[Goal Check] This is a one-time operation. Future checks will be much faster.');\n \n // Auto-index the codebase\n const { glob } = await import('glob');\n const indexPattern = `${projectPath}/**/*.{ts,tsx,js,jsx,mjs,vue,svelte,astro,py,go,rs,java,c,cpp,h,hpp,cs,rb,php,css,scss,html}`;\n const indexFiles = await glob(indexPattern, {\n ignore: ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.git/**', '**/.trie/**', '**/coverage/**'],\n nodir: true,\n });\n \n let indexed = 0;\n const total = Math.min(indexFiles.length, 500); // Cap at 500 files for initial index\n for (const filePath of indexFiles.slice(0, 500)) {\n let relativePath = filePath;\n if (filePath.toLowerCase().startsWith(projectPath.toLowerCase() + '/')) {\n relativePath = filePath.slice(projectPath.length + 1);\n }\n const result = await codebaseIndex.indexFile(relativePath);\n if (result) indexed++;\n \n // Progress indicator every 50 files\n if (indexed % 50 === 0) {\n onProgress?.(`Indexing files (${indexed}/${total})...`);\n console.error(`[Goal Check] Indexed ${indexed}/${total} files...`);\n }\n }\n \n await codebaseIndex.save();\n console.error(`[Goal Check] Index built: ${indexed} files indexed`);\n }\n \n // Get files to check\n let files: string[] = [];\n if (filesToCheck && filesToCheck.length > 0) {\n files = filesToCheck;\n } else {\n // MANUAL CHECK MODE: Scan ALL relevant files, not just recently modified\n const { glob } = await import('glob');\n \n const pattern = `${projectPath}/**/*.{ts,tsx,js,jsx,py,go,rs,java,c,cpp,h,hpp,cs,rb,php,css,scss,html,vue,svelte}`;\n const allFiles = await glob(pattern, {\n ignore: ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.git/**', '**/.trie/**', '**/coverage/**'],\n nodir: true,\n });\n \n // For manual checks, use more files but still reasonable limit\n // Sort by modification time to prioritize recently modified\n const { stat } = await import('fs/promises');\n const withStats = await Promise.all(\n allFiles.map(async (f) => {\n try {\n const stats = await stat(f);\n return { file: f, mtime: stats.mtime.getTime() };\n } catch {\n return null;\n }\n })\n );\n \n files = withStats\n .filter((f): f is { file: string; mtime: number } => f !== null)\n .sort((a, b) => b.mtime - a.mtime)\n .slice(0, 100) // Check up to 100 files for manual scans\n .map(f => f.file);\n }\n \n if (files.length === 0) {\n throw new Error('No files found to check');\n }\n \n // Check which files need scanning vs can use cached results\n const filesToScan: string[] = [];\n const cachedViolations: Array<{ file: string; message: string; severity: 'critical' | 'warning' | 'info' }> = [];\n \n for (const filePath of files) {\n // Handle case-insensitive filesystems (macOS) and ensure we get a proper relative path\n let relativePath = filePath;\n if (filePath.toLowerCase().startsWith(projectPath.toLowerCase() + '/')) {\n relativePath = filePath.slice(projectPath.length + 1);\n } else if (filePath.startsWith('/')) {\n // Already absolute but doesn't match projectPath - skip this file\n // This can happen with stale cache entries from different projects\n continue;\n }\n const hasChanged = await codebaseIndex.hasChanged(relativePath);\n \n if (hasChanged) {\n // File changed or not indexed - needs scanning\n // Try to index the file first; skip if it doesn't exist\n const indexed = await codebaseIndex.indexFile(relativePath);\n if (indexed) {\n filesToScan.push(filePath);\n }\n // If indexFile returns null, file doesn't exist - skip it silently\n } else {\n // File unchanged - check cache for each goal\n for (const goal of goals) {\n const cached = codebaseIndex.getCachedViolations(relativePath, goal.id);\n if (cached && cached.length > 0) {\n const violation = cached[0];\n if (violation && violation.found) {\n cachedViolations.push({\n file: relativePath,\n message: `Goal \"${goal.description}\" violated in ${relativePath}: ${violation.details || 'Violation found'} [${violation.confidence || 90}% confidence] (cached)`,\n severity: 'warning',\n });\n }\n } else {\n // No cache for this goal - needs scanning\n if (!filesToScan.includes(filePath)) {\n filesToScan.push(filePath);\n }\n }\n }\n }\n }\n \n onProgress?.(`Checking ${filesToScan.length} files for violations...`);\n console.error(`[Goal Check] ${files.length} files total, ${filesToScan.length} need scanning, ${files.length - filesToScan.length} using cache`);\n \n // Process files that need scanning in batches\n const allViolations: Array<{ file: string; message: string; severity: 'critical' | 'warning' | 'info' }> = [...cachedViolations];\n \n if (filesToScan.length === 0) {\n // All results from cache!\n await codebaseIndex.save();\n return allViolations;\n }\n \n // For large file sets, process in batches to avoid token limits\n const BATCH_SIZE = 25; // Process 25 files at a time\n \n const totalBatches = Math.ceil(filesToScan.length / BATCH_SIZE);\n for (let batchStart = 0; batchStart < filesToScan.length; batchStart += BATCH_SIZE) {\n const batchNum = Math.floor(batchStart / BATCH_SIZE) + 1;\n onProgress?.(`Analyzing files (batch ${batchNum}/${totalBatches})...`);\n const batchFiles = filesToScan.slice(batchStart, batchStart + BATCH_SIZE);\n \n // Read file contents for this batch\n const { readFile } = await import('fs/promises');\n const fileContents = await Promise.all(\n batchFiles.map(async (filePath) => {\n try {\n const content = await readFile(filePath, 'utf-8');\n const relativePath = filePath.replace(projectPath + '/', '');\n return {\n path: relativePath,\n content: content.slice(0, 10000), // Increased limit for manual checks\n };\n } catch {\n return null;\n }\n })\n );\n \n const validFiles = fileContents.filter((f): f is { path: string; content: string } => f !== null);\n \n if (validFiles.length === 0) continue;\n \n // Build files block for AI\n const filesBlock = validFiles\n .map(f => `--- ${f.path} ---\\n${f.content}`)\n .join('\\n\\n');\n \n // Build goals section\n const goalsSection = `\nUSER-DEFINED GOALS (check EVERY file against ALL goals):\n${goals.map((g, i) => ` ${i + 1}. \"${g.description}\"`).join('\\n')}\n\nThis is a MANUAL CHECK requested by the user. Report ALL goal violations you find.\nFor emoji detection, look for Unicode emoji characters.\n`;\n \n // Run AI analysis\n const result = await runAIAnalysis({\n systemPrompt: `You are checking code for GOAL VIOLATIONS ONLY.\n${goalsSection}\nReply ONLY with a JSON array. Each element must have:\n- \"file\": relative file path\n- \"severity\": \"critical\" | \"major\" | \"minor\"\n- \"description\": 1-sentence description of the goal violation with specific examples\n- \"confidence\": number 0-100, how confident you are this is a violation\n- \"isGoalViolation\": true (always true for this scan)\n- \"goalIndex\": 0-based index of the violated goal\n\nCRITICAL DETECTION RULES:\n\n**EMOJIS**: Any Unicode emoji characters including but not limited to:\n- Emoticons: 😀😃😄😊🙂🙃😉😇🥰😍🤩😘😗☺️😚😙🥲\n- Symbols: ⚡️⚠️✅❌➜→←↑↓►◄▲▼★☆●○◆◇■□▪️▫️\n- Objects: 📊📈📉💻🖥️📱⌨️🖱️💾💿📀🔧🔨⚙️🛠️\n- Actions: 🔥💪👍👎👏🙌🤝✊👊🎯🎉🎊🚀\n- Weather: ☀️🌤️⛅☁️🌦️🌧️⛈️🌩️🌨️❄️\n- ALL OTHER Unicode emoji in ranges U+1F300-U+1F9FF, U+2600-U+27BF, U+2B00-U+2BFF\n\n**COLORS**: For \"purple\" or \"gradient\" goals, check:\n- CSS: purple, #purple, hsl(purple), rgb(purple), violet, #8B00FF, #9B59D6, etc.\n- Gradients: linear-gradient, radial-gradient, conic-gradient, background-image with gradients\n- Tailwind: purple-*, violet-*, bg-gradient-*\n- Styled components or CSS-in-JS with purple/violet/gradient\n\nBe EXTREMELY thorough. Check:\n1. String literals and template literals\n2. JSX/HTML content\n3. CSS files and style blocks\n4. Comments (emojis in comments still violate \"no emojis\")\n5. console.log statements\n6. Component names, variable names (if they contain emojis)\n\nIf a goal says \"no emojis\" and you see ANY emoji ANYWHERE in the file, report it.\nIf a goal says \"no console.log\" and you see console.log ANYWHERE, report it.\nIf a goal says \"no purple/gradient\" and you see ANY purple color or gradient, report it.\n\nIf no violations found, reply with: []\nOutput ONLY the JSON array, no markdown fences, no commentary.`,\n userPrompt: `Check these ${validFiles.length} files for goal violations:\\n\\n${filesBlock}`,\n maxTokens: 8192, // Increased for larger codebases\n temperature: 0.1,\n });\n \n // Parse response\n let issues: Array<{\n file: string;\n severity: 'critical' | 'major' | 'minor';\n description: string;\n confidence: number;\n isGoalViolation: boolean;\n goalIndex?: number;\n }> = [];\n \n try {\n const cleaned = result.content.replace(/```json?\\n?|\\n?```/g, '').trim();\n issues = JSON.parse(cleaned);\n if (!Array.isArray(issues)) issues = [];\n } catch (err) {\n // Parse failed - continue to next batch\n console.debug('[Goal Check] Batch parse failed:', err);\n continue;\n }\n \n // Convert to violation format and record\n for (const issue of issues) {\n if (!issue.isGoalViolation || issue.confidence < 50) continue;\n if (issue.goalIndex == null || issue.goalIndex < 0 || issue.goalIndex >= goals.length) continue;\n \n const goal = goals[issue.goalIndex];\n if (!goal) continue; // Defensive check\n const severity = issue.severity === 'critical' ? 'critical' : 'warning';\n const message = `Goal \"${goal.description}\" violated in ${issue.file}: ${issue.description} [${issue.confidence}% confidence]`;\n \n allViolations.push({\n file: issue.file,\n message,\n severity,\n });\n \n // Cache the result in codebase index\n codebaseIndex.recordViolation(\n issue.file,\n goal.id,\n goal.description,\n true, // found\n issue.description,\n issue.confidence\n );\n \n // Record violation\n await recordGoalViolationCaught(goal, issue.file, projectPath);\n }\n \n // Also record \"no violation\" for scanned files\n for (const file of validFiles) {\n for (let goalIdx = 0; goalIdx < goals.length; goalIdx++) {\n const goal = goals[goalIdx];\n if (!goal) continue;\n const hasViolation = issues.some(i => i.file === file.path && i.goalIndex === goalIdx);\n if (!hasViolation) {\n codebaseIndex.recordViolation(\n file.path,\n goal.id,\n goal.description,\n false, // not found\n undefined,\n 100\n );\n }\n }\n }\n }\n \n // Save updated index\n await codebaseIndex.save();\n \n return allViolations;\n}\n"],"mappings":";;;;;;;;AAqBA,eAAsB,eAAe,aAAsC;AACzE,QAAM,eAAe,gBAAgB,WAAW;AAChD,QAAM,aAAa,KAAK;AACxB,SAAO,aAAa,YAAY,EAAE,OAAO,OAAK,EAAE,WAAW,QAAQ;AACrE;AAEA,eAAsB,0BACpB,MACA,MACA,aACe;AACf,QAAM,eAAe,gBAAgB,WAAW;AAChD,QAAM,aAAa,KAAK;AAExB,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,QAAM,eAAe,SAAS,eAAe,KAAK;AAElD,QAAM,aAAa,WAAW,KAAK,IAAI;AAAA,IACrC,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,eAAe,gBAAgB,WAAW;AAChD,QAAM,aAAa,KAAK;AAExB,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,QAAM,cAAc,SAAS,cAAc,KAAK;AAEhD,QAAM,aAAa,WAAW,KAAK,IAAI;AAAA,IACrC,UAAU;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MAClC,eAAe;AAAA,IACjB;AAAA,EACF,CAAC;AAID,QAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,2BAA0B;AACxE,QAAM,qBAAqB,MAAM,KAAK,aAAa,WAAW;AAG9D,QAAM,EAAE,eAAe,IAAI,MAAM,OAAO,4BAAmB;AAC3D,QAAM,cAAc,eAAe,WAAW;AAC9C,QAAM,YAAY,mBAAmB;AACvC;AAWA,eAAsB,wBACpB,aACA,aACiB;AACjB,MAAI;AACF,UAAM,SAAS,MAAM,aAAa,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO;AAAA,MACP,i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GAAI;AACrD,UAAI,MAAM,aAAa,QAAQ,MAAM,YAAY,KAAK,MAAM,aAAa,MAAM,OAAQ;AAEvF,YAAM,OAAO,MAAM,MAAM,SAAS;AAClC,UAAI,CAAC,KAAM;AACX,YAAM,WAAW,MAAM,aAAa,aAAa,aAAa;AAC9D,YAAM,UAAU,SAAS,KAAK,WAAW,iBAAiB,MAAM,IAAI,KAAK,MAAM,WAAW,KAAK,MAAM,UAAU;AAE/G,oBAAc,KAAK;AAAA,QACjB,MAAM,MAAM;AAAA,QACZ;AAAA,QACA;AAAA,MACF,CAAC;AAGD,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,KAAK;AAAA,QACL,KAAK;AAAA,QACL;AAAA;AAAA,QACA,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAGA,YAAM,0BAA0B,MAAM,MAAM,MAAM,WAAW;AAAA,IAC/D;AAGA,eAAW,QAAQ,YAAY;AAC7B,eAAS,UAAU,GAAG,UAAU,MAAM,QAAQ,WAAW;AACvD,cAAM,OAAO,MAAM,OAAO;AAC1B,YAAI,CAAC,KAAM;AACX,cAAM,eAAe,OAAO,KAAK,OAAK,EAAE,SAAS,KAAK,QAAQ,EAAE,cAAc,OAAO;AACrF,YAAI,CAAC,cAAc;AACjB,wBAAc;AAAA,YACZ,KAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AAAA,YACL;AAAA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,cAAc,KAAK;AAEzB,SAAO;AACT;","names":[]}
|
|
@@ -4,9 +4,6 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
TriePatternDiscovery
|
|
6
6
|
} from "./chunk-ZV2K6M7T.js";
|
|
7
|
-
import {
|
|
8
|
-
storeIssues
|
|
9
|
-
} from "./chunk-JAKMZI5S.js";
|
|
10
7
|
import {
|
|
11
8
|
scanForVulnerabilities
|
|
12
9
|
} from "./chunk-F4NJ4CBP.js";
|
|
@@ -16,6 +13,9 @@ import {
|
|
|
16
13
|
import {
|
|
17
14
|
ContextGraph
|
|
18
15
|
} from "./chunk-55CBWOEZ.js";
|
|
16
|
+
import {
|
|
17
|
+
storeIssues
|
|
18
|
+
} from "./chunk-R3WZI6QZ.js";
|
|
19
19
|
import {
|
|
20
20
|
getTrieDirectory,
|
|
21
21
|
getWorkingDirectory
|
|
@@ -1756,4 +1756,4 @@ export {
|
|
|
1756
1756
|
handleCheckpointCommand,
|
|
1757
1757
|
isTrieInitialized
|
|
1758
1758
|
};
|
|
1759
|
-
//# sourceMappingURL=chunk-
|
|
1759
|
+
//# sourceMappingURL=chunk-K6NTRSDF.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getGoalManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A6PWS6ZV.js";
|
|
4
4
|
import {
|
|
5
5
|
getHypothesisEngine
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DPZLABUC.js";
|
|
7
7
|
import {
|
|
8
8
|
getInsightStore
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QNKBXOIQ.js";
|
|
10
10
|
import {
|
|
11
11
|
GotchaPredictor,
|
|
12
12
|
findCrossProjectPatterns,
|
|
13
13
|
recordToGlobalMemory
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-G74XEI7K.js";
|
|
15
15
|
import {
|
|
16
16
|
isAIAvailable,
|
|
17
17
|
runAIAnalysis
|
|
18
18
|
} from "./chunk-O6OTJI3W.js";
|
|
19
|
+
import {
|
|
20
|
+
getProjectState
|
|
21
|
+
} from "./chunk-6EP2VTHC.js";
|
|
22
|
+
import {
|
|
23
|
+
ContextGraph
|
|
24
|
+
} from "./chunk-55CBWOEZ.js";
|
|
19
25
|
import {
|
|
20
26
|
autoResolveIssues,
|
|
21
27
|
getHistoricalInsights,
|
|
22
28
|
getIssueHash,
|
|
23
29
|
searchIssues,
|
|
24
30
|
storeIssues
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
getGuardianState
|
|
28
|
-
} from "./chunk-UHMMANC2.js";
|
|
29
|
-
import {
|
|
30
|
-
ContextGraph
|
|
31
|
-
} from "./chunk-55CBWOEZ.js";
|
|
31
|
+
} from "./chunk-R3WZI6QZ.js";
|
|
32
32
|
|
|
33
33
|
// src/guardian/guardian-agent.ts
|
|
34
34
|
import { basename as basename2 } from "path";
|
|
@@ -719,14 +719,14 @@ var DEFAULT_CONFIG2 = {
|
|
|
719
719
|
var EscalationManager = class {
|
|
720
720
|
projectPath;
|
|
721
721
|
config;
|
|
722
|
-
|
|
722
|
+
projectState;
|
|
723
723
|
insightStore;
|
|
724
724
|
escalationHistory = [];
|
|
725
725
|
slackClient;
|
|
726
726
|
constructor(projectPath, config = {}) {
|
|
727
727
|
this.projectPath = projectPath;
|
|
728
728
|
this.config = { ...DEFAULT_CONFIG2, ...config };
|
|
729
|
-
this.
|
|
729
|
+
this.projectState = getProjectState(projectPath);
|
|
730
730
|
this.insightStore = getInsightStore(projectPath);
|
|
731
731
|
const slackTarget = this.config.targets.find((t) => t.type === "slack" && t.enabled);
|
|
732
732
|
if (slackTarget?.config.webhookUrl) {
|
|
@@ -751,7 +751,7 @@ var EscalationManager = class {
|
|
|
751
751
|
if (!isSecurityIssue) {
|
|
752
752
|
return false;
|
|
753
753
|
}
|
|
754
|
-
if (this.
|
|
754
|
+
if (this.projectState.isQuietHours()) {
|
|
755
755
|
if (!this.config.criticalBypassQuietHours) {
|
|
756
756
|
return false;
|
|
757
757
|
}
|
|
@@ -787,7 +787,7 @@ var EscalationManager = class {
|
|
|
787
787
|
async autoEscalateIfCritical(issue) {
|
|
788
788
|
if (!this.shouldAutoEscalate(issue)) {
|
|
789
789
|
if (issue.severity === "critical" && this.config.draftFallbackEnabled) {
|
|
790
|
-
if (this.
|
|
790
|
+
if (this.projectState.isQuietHours()) {
|
|
791
791
|
return this.createDraftEscalation([issue], "Blocked by quiet hours");
|
|
792
792
|
}
|
|
793
793
|
}
|
|
@@ -802,7 +802,7 @@ var EscalationManager = class {
|
|
|
802
802
|
this.escalationHistory.push(message);
|
|
803
803
|
await this.insightStore.markInsightCreated("auto-escalation");
|
|
804
804
|
await this.createEscalationInsight(message);
|
|
805
|
-
await this.
|
|
805
|
+
await this.projectState.useRiskBudget(1);
|
|
806
806
|
return {
|
|
807
807
|
action: "auto_escalated",
|
|
808
808
|
reason: "Critical security issue auto-escalated",
|
|
@@ -833,7 +833,7 @@ var EscalationManager = class {
|
|
|
833
833
|
reason: "No critical security issues to escalate"
|
|
834
834
|
};
|
|
835
835
|
}
|
|
836
|
-
if (this.
|
|
836
|
+
if (this.projectState.isQuietHours() && !this.config.criticalBypassQuietHours) {
|
|
837
837
|
return this.createDraftEscalation(criticalSecurityIssues, "Blocked by quiet hours");
|
|
838
838
|
}
|
|
839
839
|
const message = this.createEscalationMessage(criticalSecurityIssues);
|
|
@@ -1100,12 +1100,12 @@ function getEscalationManager(projectPath) {
|
|
|
1100
1100
|
|
|
1101
1101
|
// src/guardian/meta-learning.ts
|
|
1102
1102
|
var MetaLearner = class {
|
|
1103
|
-
|
|
1103
|
+
projectState;
|
|
1104
1104
|
insightStore;
|
|
1105
1105
|
feedbackHistory = [];
|
|
1106
1106
|
weights;
|
|
1107
1107
|
constructor(projectPath) {
|
|
1108
|
-
this.
|
|
1108
|
+
this.projectState = getProjectState(projectPath);
|
|
1109
1109
|
this.insightStore = getInsightStore(projectPath);
|
|
1110
1110
|
this.weights = {
|
|
1111
1111
|
security: 1,
|
|
@@ -1137,7 +1137,7 @@ var MetaLearner = class {
|
|
|
1137
1137
|
record.latencyMs = context.latencyMs;
|
|
1138
1138
|
}
|
|
1139
1139
|
this.feedbackHistory.push(record);
|
|
1140
|
-
await this.
|
|
1140
|
+
await this.projectState.recordInsightFeedback(
|
|
1141
1141
|
feedback === "dismissed" ? "dismissed" : feedback === "acted" ? "acted" : "helpful"
|
|
1142
1142
|
);
|
|
1143
1143
|
await this.adjustWeights(record);
|
|
@@ -1217,14 +1217,14 @@ var MetaLearner = class {
|
|
|
1217
1217
|
* Get agent effectiveness metrics
|
|
1218
1218
|
*/
|
|
1219
1219
|
getEffectiveness() {
|
|
1220
|
-
return this.
|
|
1220
|
+
return this.projectState.getMetrics();
|
|
1221
1221
|
}
|
|
1222
1222
|
/**
|
|
1223
1223
|
* Generate a comprehensive effectiveness report
|
|
1224
1224
|
*/
|
|
1225
1225
|
async generateEffectivenessReport() {
|
|
1226
|
-
await this.
|
|
1227
|
-
const metrics = this.
|
|
1226
|
+
await this.projectState.load();
|
|
1227
|
+
const metrics = this.projectState.getMetrics();
|
|
1228
1228
|
const categoryBreakdown = this.calculateCategoryEffectiveness();
|
|
1229
1229
|
const overallScore = metrics.userSatisfaction * 0.4 + metrics.predictiveAccuracy * 0.3 + (1 - metrics.falsePositiveRate) * 0.3;
|
|
1230
1230
|
const recommendations = this.generateRecommendations(metrics, categoryBreakdown);
|
|
@@ -1419,15 +1419,15 @@ var PERSONALITY = {
|
|
|
1419
1419
|
"Quick question:"
|
|
1420
1420
|
]
|
|
1421
1421
|
};
|
|
1422
|
-
var
|
|
1422
|
+
var TrieAgent = class {
|
|
1423
1423
|
projectPath;
|
|
1424
1424
|
projectName;
|
|
1425
1425
|
lastIssueHashes = /* @__PURE__ */ new Set();
|
|
1426
1426
|
initialized = false;
|
|
1427
|
-
// Persistent stores
|
|
1427
|
+
// Persistent stores
|
|
1428
1428
|
insightStore;
|
|
1429
|
-
|
|
1430
|
-
// Agency modules
|
|
1429
|
+
projectState;
|
|
1430
|
+
// Agency modules
|
|
1431
1431
|
goalManager;
|
|
1432
1432
|
riskPredictor;
|
|
1433
1433
|
hypothesisEngine;
|
|
@@ -1438,7 +1438,7 @@ var GuardianAgent = class {
|
|
|
1438
1438
|
this.projectPath = projectPath;
|
|
1439
1439
|
this.projectName = basename2(projectPath);
|
|
1440
1440
|
this.insightStore = getInsightStore(projectPath);
|
|
1441
|
-
this.
|
|
1441
|
+
this.projectState = getProjectState(projectPath);
|
|
1442
1442
|
this.goalManager = getGoalManager(projectPath);
|
|
1443
1443
|
this.riskPredictor = getRiskPredictor(projectPath);
|
|
1444
1444
|
this.hypothesisEngine = getHypothesisEngine(projectPath);
|
|
@@ -1447,14 +1447,14 @@ var GuardianAgent = class {
|
|
|
1447
1447
|
this.gotchaPredictor = new GotchaPredictor(projectPath, new ContextGraph(projectPath));
|
|
1448
1448
|
}
|
|
1449
1449
|
/**
|
|
1450
|
-
* Initialize the
|
|
1450
|
+
* Initialize the agent - loads persistent state and historical data
|
|
1451
1451
|
*/
|
|
1452
1452
|
async initialize() {
|
|
1453
1453
|
if (this.initialized) return;
|
|
1454
1454
|
try {
|
|
1455
1455
|
await this.insightStore.load();
|
|
1456
|
-
await this.
|
|
1457
|
-
await this.
|
|
1456
|
+
await this.projectState.load();
|
|
1457
|
+
await this.projectState.touchActive();
|
|
1458
1458
|
const historical = await getHistoricalInsights(this.projectPath);
|
|
1459
1459
|
if (historical && historical.totalHistoricalIssues > 0) {
|
|
1460
1460
|
const trend = historical.improvementTrend;
|
|
@@ -1489,22 +1489,22 @@ var GuardianAgent = class {
|
|
|
1489
1489
|
return this.insightStore.addInsight(insight);
|
|
1490
1490
|
}
|
|
1491
1491
|
/**
|
|
1492
|
-
* Restart the
|
|
1492
|
+
* Restart the agent (reload state from disk)
|
|
1493
1493
|
*/
|
|
1494
1494
|
async restart() {
|
|
1495
1495
|
this.initialized = false;
|
|
1496
1496
|
await this.insightStore.reload();
|
|
1497
|
-
await this.
|
|
1497
|
+
await this.projectState.reload();
|
|
1498
1498
|
await this.initialize();
|
|
1499
1499
|
}
|
|
1500
1500
|
/**
|
|
1501
1501
|
* Load state from disk (for testing)
|
|
1502
1502
|
*/
|
|
1503
1503
|
async loadState() {
|
|
1504
|
-
await this.
|
|
1504
|
+
await this.projectState.load();
|
|
1505
1505
|
return {
|
|
1506
|
-
goals: this.
|
|
1507
|
-
riskBudget: this.
|
|
1506
|
+
goals: this.projectState.getAllGoals(),
|
|
1507
|
+
riskBudget: this.projectState.getRiskBudget()
|
|
1508
1508
|
};
|
|
1509
1509
|
}
|
|
1510
1510
|
/**
|
|
@@ -1782,7 +1782,7 @@ var GuardianAgent = class {
|
|
|
1782
1782
|
await this.goalManager.autoGenerateGoals();
|
|
1783
1783
|
}
|
|
1784
1784
|
await this.goalManager.updateGoalProgress();
|
|
1785
|
-
const goals = this.
|
|
1785
|
+
const goals = this.projectState.getAllGoals();
|
|
1786
1786
|
for (const goal of goals.filter((g) => g.status === "active")) {
|
|
1787
1787
|
const startVal = goal.startValue ?? goal.currentValue;
|
|
1788
1788
|
if (startVal > 0 && goal.currentValue <= startVal) {
|
|
@@ -1857,7 +1857,7 @@ var GuardianAgent = class {
|
|
|
1857
1857
|
}
|
|
1858
1858
|
if (this.canCreateInsight("hypothesis-update")) {
|
|
1859
1859
|
try {
|
|
1860
|
-
const hypotheses = this.
|
|
1860
|
+
const hypotheses = this.projectState.getAllHypotheses();
|
|
1861
1861
|
const testingHypotheses = hypotheses.filter((h) => h.status === "testing");
|
|
1862
1862
|
if (testingHypotheses.length < 3) {
|
|
1863
1863
|
await this.hypothesisEngine.autoGenerateHypotheses();
|
|
@@ -1907,12 +1907,12 @@ var GuardianAgent = class {
|
|
|
1907
1907
|
}
|
|
1908
1908
|
}
|
|
1909
1909
|
this.lastIssueHashes = currentHashes;
|
|
1910
|
-
await this.
|
|
1910
|
+
await this.projectState.recordScan();
|
|
1911
1911
|
try {
|
|
1912
1912
|
const riskLevel = issues.filter((i) => i.severity === "critical").length > 0 ? "critical" : issues.filter((i) => i.severity === "serious").length >= 3 ? "high" : issues.length > 10 ? "medium" : "low";
|
|
1913
|
-
const { calculateAdaptiveScanFrequency } = await import("./goal-manager-
|
|
1913
|
+
const { calculateAdaptiveScanFrequency } = await import("./goal-manager-62IL6WGY.js");
|
|
1914
1914
|
const result = await calculateAdaptiveScanFrequency(riskLevel);
|
|
1915
|
-
await this.
|
|
1915
|
+
await this.projectState.setScanFrequency(result.frequencyMs);
|
|
1916
1916
|
} catch {
|
|
1917
1917
|
}
|
|
1918
1918
|
return newInsights;
|
|
@@ -1931,7 +1931,7 @@ var GuardianAgent = class {
|
|
|
1931
1931
|
agent: i.agent
|
|
1932
1932
|
}));
|
|
1933
1933
|
const result = await runAIAnalysis({
|
|
1934
|
-
systemPrompt: `You are a helpful code
|
|
1934
|
+
systemPrompt: `You are a helpful code reviewer. Analyze these issues and provide ONE brief, conversational insight.
|
|
1935
1935
|
Be specific and actionable. Speak like a helpful colleague, not a system.
|
|
1936
1936
|
Keep your response under 100 words. Focus on the most important pattern or concern.`,
|
|
1937
1937
|
userPrompt: `New issues found:
|
|
@@ -1957,19 +1957,17 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
1957
1957
|
}
|
|
1958
1958
|
/**
|
|
1959
1959
|
* Get active insights (not dismissed, still relevant)
|
|
1960
|
-
* Now uses persistent storage (Phase 1 Guardian Agency)
|
|
1961
1960
|
*/
|
|
1962
1961
|
getActiveInsights() {
|
|
1963
1962
|
return this.insightStore.getActiveInsights();
|
|
1964
1963
|
}
|
|
1965
1964
|
/**
|
|
1966
1965
|
* Dismiss an insight
|
|
1967
|
-
* Now persists to disk (Phase 1 Guardian Agency)
|
|
1968
1966
|
*/
|
|
1969
1967
|
async dismissInsight(insightId) {
|
|
1970
1968
|
const result = await this.insightStore.dismissInsight(insightId);
|
|
1971
1969
|
if (result) {
|
|
1972
|
-
await this.
|
|
1970
|
+
await this.projectState.recordInsightFeedback("dismissed");
|
|
1973
1971
|
}
|
|
1974
1972
|
return result;
|
|
1975
1973
|
}
|
|
@@ -1977,13 +1975,13 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
1977
1975
|
* Record that a user found an insight helpful
|
|
1978
1976
|
*/
|
|
1979
1977
|
async markInsightHelpful(_insightId) {
|
|
1980
|
-
await this.
|
|
1978
|
+
await this.projectState.recordInsightFeedback("helpful");
|
|
1981
1979
|
}
|
|
1982
1980
|
/**
|
|
1983
1981
|
* Record that a user acted on an insight
|
|
1984
1982
|
*/
|
|
1985
1983
|
async markInsightActedOn(_insightId) {
|
|
1986
|
-
await this.
|
|
1984
|
+
await this.projectState.recordInsightFeedback("acted");
|
|
1987
1985
|
}
|
|
1988
1986
|
/**
|
|
1989
1987
|
* Get insight statistics
|
|
@@ -1995,19 +1993,19 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
1995
1993
|
* Get agent metrics (for dashboard display)
|
|
1996
1994
|
*/
|
|
1997
1995
|
getAgentMetrics() {
|
|
1998
|
-
return this.
|
|
1996
|
+
return this.projectState.getMetrics();
|
|
1999
1997
|
}
|
|
2000
1998
|
/**
|
|
2001
1999
|
* Check if in quiet hours
|
|
2002
2000
|
*/
|
|
2003
2001
|
isQuietHours() {
|
|
2004
|
-
return this.
|
|
2002
|
+
return this.projectState.isQuietHours();
|
|
2005
2003
|
}
|
|
2006
2004
|
/**
|
|
2007
2005
|
* Check if in crunch mode
|
|
2008
2006
|
*/
|
|
2009
2007
|
isInCrunchMode() {
|
|
2010
|
-
return this.
|
|
2008
|
+
return this.projectState.isInCrunchMode();
|
|
2011
2009
|
}
|
|
2012
2010
|
/**
|
|
2013
2011
|
* Get the insight store (for advanced operations)
|
|
@@ -2016,10 +2014,14 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
2016
2014
|
return this.insightStore;
|
|
2017
2015
|
}
|
|
2018
2016
|
/**
|
|
2019
|
-
* Get the
|
|
2017
|
+
* Get the project state (for advanced operations)
|
|
2020
2018
|
*/
|
|
2019
|
+
getProjectState() {
|
|
2020
|
+
return this.projectState;
|
|
2021
|
+
}
|
|
2022
|
+
/** @deprecated Use getProjectState instead */
|
|
2021
2023
|
getGuardianState() {
|
|
2022
|
-
return this.
|
|
2024
|
+
return this.projectState;
|
|
2023
2025
|
}
|
|
2024
2026
|
/**
|
|
2025
2027
|
* Get agency modules (for watch mode integration)
|
|
@@ -2043,14 +2045,14 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
2043
2045
|
* Get a rich agency status for display in watch mode
|
|
2044
2046
|
*/
|
|
2045
2047
|
async getAgencyStatus() {
|
|
2046
|
-
const goals = this.
|
|
2048
|
+
const goals = this.projectState.getAllGoals();
|
|
2047
2049
|
const activeGoals = goals.filter((g) => g.status === "active");
|
|
2048
2050
|
const completedGoals = goals.filter((g) => g.status === "achieved");
|
|
2049
|
-
const hypotheses = this.
|
|
2051
|
+
const hypotheses = this.projectState.getAllHypotheses();
|
|
2050
2052
|
const testingHypotheses = hypotheses.filter((h) => h.status === "testing");
|
|
2051
2053
|
const validatedHypotheses = hypotheses.filter((h) => h.status === "validated");
|
|
2052
|
-
const metrics = this.
|
|
2053
|
-
const budget = this.
|
|
2054
|
+
const metrics = this.projectState.getMetrics();
|
|
2055
|
+
const budget = this.projectState.getRiskBudget();
|
|
2054
2056
|
const dailyActionsRemaining = budget.daily - budget.usedToday;
|
|
2055
2057
|
let riskLevel = "low";
|
|
2056
2058
|
if (dailyActionsRemaining <= 1) riskLevel = "critical";
|
|
@@ -2070,9 +2072,9 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
2070
2072
|
validated: validatedHypotheses.length
|
|
2071
2073
|
},
|
|
2072
2074
|
riskLevel,
|
|
2073
|
-
scanFrequency: this.
|
|
2075
|
+
scanFrequency: this.projectState.getScanFrequencyMs(),
|
|
2074
2076
|
effectiveness,
|
|
2075
|
-
isQuietHours: this.
|
|
2077
|
+
isQuietHours: this.projectState.isQuietHours()
|
|
2076
2078
|
};
|
|
2077
2079
|
if (topGoal) result.goals.topGoal = topGoal;
|
|
2078
2080
|
if (topHypothesis) result.hypotheses.topHypothesis = topHypothesis;
|
|
@@ -2104,14 +2106,12 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
2104
2106
|
}
|
|
2105
2107
|
/**
|
|
2106
2108
|
* Check if we should create an insight of this type (cooldown not expired)
|
|
2107
|
-
* Now uses persistent storage (Phase 1 Guardian Agency)
|
|
2108
2109
|
*/
|
|
2109
2110
|
canCreateInsight(insightKey) {
|
|
2110
2111
|
return this.insightStore.canCreateInsight(insightKey);
|
|
2111
2112
|
}
|
|
2112
2113
|
/**
|
|
2113
2114
|
* Mark that we created an insight of this type
|
|
2114
|
-
* Now persists to disk (Phase 1 Guardian Agency)
|
|
2115
2115
|
*/
|
|
2116
2116
|
async markInsightCreated(insightKey) {
|
|
2117
2117
|
await this.insightStore.markInsightCreated(insightKey);
|
|
@@ -2129,18 +2129,22 @@ What's the most important thing the developer should know? Provide a brief, conv
|
|
|
2129
2129
|
return arr[Math.floor(Math.random() * arr.length)];
|
|
2130
2130
|
}
|
|
2131
2131
|
};
|
|
2132
|
-
var
|
|
2133
|
-
function
|
|
2134
|
-
let
|
|
2135
|
-
if (!
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
}
|
|
2139
|
-
return
|
|
2132
|
+
var agentInstances = /* @__PURE__ */ new Map();
|
|
2133
|
+
function getTrieAgent(projectPath) {
|
|
2134
|
+
let agent = agentInstances.get(projectPath);
|
|
2135
|
+
if (!agent) {
|
|
2136
|
+
agent = new TrieAgent(projectPath);
|
|
2137
|
+
agentInstances.set(projectPath, agent);
|
|
2138
|
+
}
|
|
2139
|
+
return agent;
|
|
2140
2140
|
}
|
|
2141
|
+
var getGuardian = getTrieAgent;
|
|
2142
|
+
var GuardianAgent = TrieAgent;
|
|
2141
2143
|
|
|
2142
2144
|
export {
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
+
TrieAgent,
|
|
2146
|
+
getTrieAgent,
|
|
2147
|
+
getGuardian,
|
|
2148
|
+
GuardianAgent
|
|
2145
2149
|
};
|
|
2146
|
-
//# sourceMappingURL=chunk-
|
|
2150
|
+
//# sourceMappingURL=chunk-QM5VIDFN.js.map
|