@triedotdev/mcp 1.0.147 → 1.0.149

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +135 -74
  2. package/dist/{chunk-4PAAGLKO.js → chunk-53KUI7RQ.js} +6 -4
  3. package/dist/{chunk-4PAAGLKO.js.map → chunk-53KUI7RQ.js.map} +1 -1
  4. package/dist/{chunk-XTTZAQWJ.js → chunk-72KSLD7A.js} +4 -4
  5. package/dist/{chunk-WMDFK7LI.js → chunk-B2AHQ2IR.js} +12 -12
  6. package/dist/{chunk-LT6VUZG2.js → chunk-CU5VDH6F.js} +2 -2
  7. package/dist/{chunk-4MJ52WBH.js → chunk-EFWVF6TI.js} +4 -2
  8. package/dist/chunk-EFWVF6TI.js.map +1 -0
  9. package/dist/{chunk-N2EDZTKG.js → chunk-GAL7OIYU.js} +11 -11
  10. package/dist/{chunk-2354SRJM.js → chunk-HYNDXZAU.js} +85 -115
  11. package/dist/chunk-HYNDXZAU.js.map +1 -0
  12. package/dist/{chunk-YEIJW6X6.js → chunk-ILGMFND2.js} +4 -4
  13. package/dist/{chunk-3MUCUZ46.js → chunk-OTQEFXHU.js} +2 -2
  14. package/dist/chunk-QH77RQB3.js +783 -0
  15. package/dist/chunk-QH77RQB3.js.map +1 -0
  16. package/dist/{chunk-T6PS3MXJ.js → chunk-ZDDE442Q.js} +5 -5
  17. package/dist/{chunk-62POBLFC.js → chunk-ZUEAHFSY.js} +180 -965
  18. package/dist/chunk-ZUEAHFSY.js.map +1 -0
  19. package/dist/cli/main.js +85 -90
  20. package/dist/cli/main.js.map +1 -1
  21. package/dist/cli/yolo-daemon.js +24 -148
  22. package/dist/cli/yolo-daemon.js.map +1 -1
  23. package/dist/{fast-analyzer-MWKCDRGD.js → fast-analyzer-CTT3MCPE.js} +3 -3
  24. package/dist/{goal-manager-ZBWKWEML.js → goal-manager-IGUMDGCA.js} +7 -6
  25. package/dist/{goal-validator-DA3JQ6JN.js → goal-validator-DV6DRSGF.js} +6 -5
  26. package/dist/{hypothesis-JCUMZKTG.js → hypothesis-O72ZLVOW.js} +7 -6
  27. package/dist/index.js +33 -119
  28. package/dist/index.js.map +1 -1
  29. package/dist/{insight-store-A5XXMFD6.js → insight-store-Q62UGMTF.js} +3 -3
  30. package/dist/{issue-store-LZWZIGM7.js → issue-store-4FPABLC6.js} +6 -3
  31. package/dist/ledger-43SIVE7X.js +43 -0
  32. package/dist/{trie-agent-6A7YBNTQ.js → trie-agent-ET3DAP5Y.js} +11 -10
  33. package/dist/trie-agent-ET3DAP5Y.js.map +1 -0
  34. package/package.json +5 -1
  35. package/dist/chunk-2354SRJM.js.map +0 -1
  36. package/dist/chunk-4MJ52WBH.js.map +0 -1
  37. package/dist/chunk-62POBLFC.js.map +0 -1
  38. /package/dist/{chunk-XTTZAQWJ.js.map → chunk-72KSLD7A.js.map} +0 -0
  39. /package/dist/{chunk-WMDFK7LI.js.map → chunk-B2AHQ2IR.js.map} +0 -0
  40. /package/dist/{chunk-LT6VUZG2.js.map → chunk-CU5VDH6F.js.map} +0 -0
  41. /package/dist/{chunk-N2EDZTKG.js.map → chunk-GAL7OIYU.js.map} +0 -0
  42. /package/dist/{chunk-YEIJW6X6.js.map → chunk-ILGMFND2.js.map} +0 -0
  43. /package/dist/{chunk-3MUCUZ46.js.map → chunk-OTQEFXHU.js.map} +0 -0
  44. /package/dist/{chunk-T6PS3MXJ.js.map → chunk-ZDDE442Q.js.map} +0 -0
  45. /package/dist/{fast-analyzer-MWKCDRGD.js.map → fast-analyzer-CTT3MCPE.js.map} +0 -0
  46. /package/dist/{goal-manager-ZBWKWEML.js.map → goal-manager-IGUMDGCA.js.map} +0 -0
  47. /package/dist/{goal-validator-DA3JQ6JN.js.map → goal-validator-DV6DRSGF.js.map} +0 -0
  48. /package/dist/{hypothesis-JCUMZKTG.js.map → hypothesis-O72ZLVOW.js.map} +0 -0
  49. /package/dist/{insight-store-A5XXMFD6.js.map → insight-store-Q62UGMTF.js.map} +0 -0
  50. /package/dist/{issue-store-LZWZIGM7.js.map → issue-store-4FPABLC6.js.map} +0 -0
  51. /package/dist/{trie-agent-6A7YBNTQ.js.map → ledger-43SIVE7X.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/backup-manager.ts","../src/memory/validation.ts"],"sourcesContent":["/**\n * Backup Manager\n * \n * Maintains rotational backups of critical data files.\n * Provides automatic recovery from corrupted files.\n * \n * Features:\n * - N rotational backups (default: 5)\n * - Automatic pruning of old backups\n * - Validation before recovery\n * - Timestamp-based backup naming\n */\n\nimport { copyFile, readdir, unlink, readFile, stat } from 'fs/promises';\nimport { existsSync } from 'fs';\nimport { dirname, basename, join } from 'path';\n\nexport interface BackupOptions {\n /**\n * Maximum number of backups to keep\n * @default 5\n */\n maxBackups?: number;\n \n /**\n * Custom validator function for backup validation\n * Returns true if the backup is valid\n */\n validator?: (content: string) => boolean;\n}\n\nexport interface BackupInfo {\n path: string;\n timestamp: number;\n size: number;\n}\n\n/**\n * Manages rotational backups for a file\n * \n * @example\n * ```typescript\n * const manager = new BackupManager('/path/to/issues.json');\n * \n * // Create backup before modifying\n * await manager.createBackup();\n * \n * // If corruption detected, recover\n * if (await manager.recoverFromBackup()) {\n * console.log('Recovered from backup');\n * }\n * ```\n */\nexport class BackupManager {\n private readonly filePath: string;\n private readonly maxBackups: number;\n private readonly validator: ((content: string) => boolean) | undefined;\n private readonly backupDir: string;\n private readonly baseFileName: string;\n\n constructor(filePath: string, options: BackupOptions = {}) {\n this.filePath = filePath;\n this.maxBackups = options.maxBackups ?? 5;\n this.validator = options.validator;\n this.backupDir = dirname(filePath);\n this.baseFileName = basename(filePath);\n }\n\n /**\n * Create a backup of the current file\n * \n * @returns The backup file path, or null if source doesn't exist\n */\n async createBackup(): Promise<string | null> {\n if (!existsSync(this.filePath)) {\n return null;\n }\n\n const timestamp = Date.now();\n const backupPath = this.getBackupPath(timestamp);\n\n await copyFile(this.filePath, backupPath);\n await this.pruneOldBackups();\n\n return backupPath;\n }\n\n /**\n * List all backups sorted by timestamp (newest first)\n */\n async listBackups(): Promise<BackupInfo[]> {\n if (!existsSync(this.backupDir)) {\n return [];\n }\n\n const files = await readdir(this.backupDir);\n const backupPattern = new RegExp(\n `^${this.escapeRegex(this.baseFileName)}\\\\.backup\\\\.(\\\\d+)$`\n );\n\n const backups: BackupInfo[] = [];\n\n for (const file of files) {\n const match = file.match(backupPattern);\n if (match) {\n const timestamp = parseInt(match[1]!, 10);\n const backupPath = join(this.backupDir, file);\n \n try {\n const stats = await stat(backupPath);\n backups.push({\n path: backupPath,\n timestamp,\n size: stats.size,\n });\n } catch {\n // Skip files we can't stat\n }\n }\n }\n\n // Sort by timestamp, newest first\n return backups.sort((a, b) => b.timestamp - a.timestamp);\n }\n\n /**\n * Find the first valid backup\n * \n * Iterates through backups from newest to oldest,\n * returning the first one that passes validation.\n * \n * @returns Path to valid backup, or null if none found\n */\n async findValidBackup(): Promise<string | null> {\n const backups = await this.listBackups();\n\n for (const backup of backups) {\n if (await this.validateBackup(backup.path)) {\n return backup.path;\n }\n }\n\n return null;\n }\n\n /**\n * Validate a backup file\n * \n * If a custom validator was provided, uses that.\n * Otherwise, attempts JSON parse for .json files.\n * \n * @returns true if backup is valid\n */\n async validateBackup(backupPath: string): Promise<boolean> {\n try {\n const content = await readFile(backupPath, 'utf-8');\n\n // Use custom validator if provided\n if (this.validator) {\n return this.validator(content);\n }\n\n // Default validation: check if it's valid JSON for .json files\n if (this.filePath.endsWith('.json')) {\n JSON.parse(content);\n return true;\n }\n\n // For non-JSON files, just check it's readable\n return content.length > 0;\n } catch {\n return false;\n }\n }\n\n /**\n * Recover from the most recent valid backup\n * \n * @returns true if recovery was successful\n */\n async recoverFromBackup(): Promise<boolean> {\n const validBackup = await this.findValidBackup();\n \n if (!validBackup) {\n return false;\n }\n\n await copyFile(validBackup, this.filePath);\n return true;\n }\n\n /**\n * Remove old backups beyond the max limit\n */\n private async pruneOldBackups(): Promise<void> {\n const backups = await this.listBackups();\n\n // Remove backups beyond the limit\n const toRemove = backups.slice(this.maxBackups);\n \n for (const backup of toRemove) {\n try {\n await unlink(backup.path);\n } catch {\n // Ignore errors - backup might already be removed\n }\n }\n }\n\n /**\n * Get the backup path for a given timestamp\n */\n private getBackupPath(timestamp: number): string {\n return join(this.backupDir, `${this.baseFileName}.backup.${timestamp}`);\n }\n\n /**\n * Escape special regex characters in a string\n */\n private escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n\n /**\n * Get the number of existing backups\n */\n async getBackupCount(): Promise<number> {\n const backups = await this.listBackups();\n return backups.length;\n }\n\n /**\n * Get the most recent backup timestamp\n */\n async getLatestBackupTime(): Promise<number | null> {\n const backups = await this.listBackups();\n return backups[0]?.timestamp ?? null;\n }\n\n /**\n * Delete all backups\n */\n async clearBackups(): Promise<number> {\n const backups = await this.listBackups();\n let deleted = 0;\n\n for (const backup of backups) {\n try {\n await unlink(backup.path);\n deleted++;\n } catch {\n // Ignore errors\n }\n }\n\n return deleted;\n }\n}\n\n/**\n * Default JSON validator\n * \n * Validates that content is valid JSON and optionally\n * checks for required fields.\n */\nexport function createJSONValidator(requiredFields?: string[]): (content: string) => boolean {\n return (content: string): boolean => {\n try {\n const parsed = JSON.parse(content);\n \n if (requiredFields && Array.isArray(parsed)) {\n // For arrays, check first element has required fields\n if (parsed.length > 0) {\n const first = parsed[0];\n return requiredFields.every(field => field in first);\n }\n // Empty array is valid\n return true;\n }\n \n if (requiredFields && typeof parsed === 'object' && parsed !== null) {\n return requiredFields.every(field => field in parsed);\n }\n \n return true;\n } catch {\n return false;\n }\n };\n}\n","/**\n * Memory Validation\n * \n * Schema validation for memory storage files using Zod.\n * Catches corruption early and provides clear error messages.\n * \n * Used by:\n * - issue-store.ts for issues.json\n * - global-memory.ts for global-patterns.json\n * - compactor.ts for compacted-summaries.json\n */\n\nimport { z } from 'zod';\n\n// ============================================================================\n// Issue Schemas\n// ============================================================================\n\n/**\n * Schema for a stored issue in issues.json\n */\nexport const StoredIssueSchema = z.object({\n id: z.string(),\n hash: z.string(),\n severity: z.string(),\n issue: z.string(),\n fix: z.string(),\n file: z.string(),\n line: z.number().optional(),\n agent: z.string(),\n category: z.string().optional(),\n timestamp: z.string(),\n project: z.string(),\n resolved: z.boolean().optional(),\n resolvedAt: z.string().optional(),\n ledgerBlockHash: z.string().optional(), // Link to immutable ledger record\n});\n\nexport type ValidatedStoredIssue = z.infer<typeof StoredIssueSchema>;\n\n/**\n * Schema for the issues.json file (array of issues)\n */\nexport const IssueIndexSchema = z.array(StoredIssueSchema);\n\n// ============================================================================\n// Global Pattern Schemas\n// ============================================================================\n\n/**\n * Schema for a fix applied record\n */\nexport const FixAppliedSchema = z.object({\n project: z.string(),\n timestamp: z.string(),\n fix: z.string(),\n});\n\n/**\n * Schema for a global pattern in global-patterns.json\n */\nexport const GlobalPatternSchema = z.object({\n id: z.string(),\n pattern: z.string(),\n description: z.string(),\n severity: z.string(),\n agent: z.string(),\n occurrences: z.number(),\n projects: z.array(z.string()),\n firstSeen: z.string(),\n lastSeen: z.string(),\n fixApplied: FixAppliedSchema.optional(),\n});\n\nexport type ValidatedGlobalPattern = z.infer<typeof GlobalPatternSchema>;\n\n/**\n * Schema for global-patterns.json (array of patterns)\n */\nexport const GlobalPatternsIndexSchema = z.array(GlobalPatternSchema);\n\n// ============================================================================\n// Project Summary Schemas\n// ============================================================================\n\n/**\n * Schema for a project summary\n */\nexport const ProjectSummarySchema = z.object({\n name: z.string(),\n path: z.string(),\n lastScan: z.string(),\n totalIssues: z.number(),\n patterns: z.array(z.string()),\n}).passthrough(); // Allow legacy healthScore in old project files\n\nexport type ValidatedProjectSummary = z.infer<typeof ProjectSummarySchema>;\n\n// ============================================================================\n// Compacted Summary Schemas\n// ============================================================================\n\n/**\n * Schema for a pattern summary in compacted data\n */\nexport const PatternSummarySchema = z.object({\n pattern: z.string(),\n count: z.number(),\n severity: z.string(),\n agent: z.string(),\n exampleFix: z.string(),\n});\n\n/**\n * Schema for a hot file entry\n */\nexport const HotFileSchema = z.object({\n file: z.string(),\n count: z.number(),\n});\n\n/**\n * Schema for a compacted summary\n */\nexport const CompactedSummarySchema = z.object({\n period: z.string(),\n startDate: z.string(),\n endDate: z.string(),\n totalIssues: z.number(),\n resolvedCount: z.number(),\n bySeverity: z.record(z.string(), z.number()),\n byAgent: z.record(z.string(), z.number()),\n topPatterns: z.array(PatternSummarySchema),\n hotFiles: z.array(HotFileSchema),\n compactedAt: z.string(),\n});\n\nexport type ValidatedCompactedSummary = z.infer<typeof CompactedSummarySchema>;\n\n/**\n * Schema for compacted-summaries.json (array of summaries)\n */\nexport const CompactedSummariesIndexSchema = z.array(CompactedSummarySchema);\n\n// ============================================================================\n// Validation Error\n// ============================================================================\n\n/**\n * Custom error for validation failures\n */\nexport class ValidationError extends Error {\n constructor(\n message: string,\n public readonly zodError: z.ZodError,\n public readonly filePath?: string\n ) {\n super(message);\n this.name = 'ValidationError';\n }\n\n /**\n * Get a human-readable summary of validation errors\n */\n getSummary(): string {\n const issues = this.zodError.issues.slice(0, 5);\n const lines = issues.map(issue => {\n const path = issue.path.join('.');\n return ` - ${path}: ${issue.message}`;\n });\n \n if (this.zodError.issues.length > 5) {\n lines.push(` ... and ${this.zodError.issues.length - 5} more errors`);\n }\n \n return lines.join('\\n');\n }\n}\n\n// ============================================================================\n// Validation Functions\n// ============================================================================\n\n/**\n * Validate issue index data\n * \n * @throws ValidationError if data is invalid\n * @returns Validated issue array\n */\nexport function validateIssueIndex(\n data: unknown,\n filePath?: string\n): ValidatedStoredIssue[] {\n const result = IssueIndexSchema.safeParse(data);\n \n if (!result.success) {\n throw new ValidationError(\n `Issue index validation failed${filePath ? ` (${filePath})` : ''}`,\n result.error,\n filePath\n );\n }\n \n return result.data;\n}\n\n/**\n * Validate global patterns data\n * \n * @throws ValidationError if data is invalid\n * @returns Validated patterns array\n */\nexport function validateGlobalPatterns(\n data: unknown,\n filePath?: string\n): ValidatedGlobalPattern[] {\n const result = GlobalPatternsIndexSchema.safeParse(data);\n \n if (!result.success) {\n throw new ValidationError(\n `Global patterns validation failed${filePath ? ` (${filePath})` : ''}`,\n result.error,\n filePath\n );\n }\n \n return result.data;\n}\n\n/**\n * Validate project summary data\n * \n * @throws ValidationError if data is invalid\n * @returns Validated project summary\n */\nexport function validateProjectSummary(\n data: unknown,\n filePath?: string\n): ValidatedProjectSummary {\n const result = ProjectSummarySchema.safeParse(data);\n \n if (!result.success) {\n throw new ValidationError(\n `Project summary validation failed${filePath ? ` (${filePath})` : ''}`,\n result.error,\n filePath\n );\n }\n \n return result.data;\n}\n\n/**\n * Validate compacted summaries data\n * \n * @throws ValidationError if data is invalid\n * @returns Validated summaries array\n */\nexport function validateCompactedSummaries(\n data: unknown,\n filePath?: string\n): ValidatedCompactedSummary[] {\n const result = CompactedSummariesIndexSchema.safeParse(data);\n \n if (!result.success) {\n throw new ValidationError(\n `Compacted summaries validation failed${filePath ? ` (${filePath})` : ''}`,\n result.error,\n filePath\n );\n }\n \n return result.data;\n}\n\n/**\n * Safely parse and validate JSON\n * \n * Combines JSON parsing with schema validation.\n * Returns null on any error instead of throwing.\n */\nexport function safeParseAndValidate<T>(\n content: string,\n schema: z.ZodSchema<T>\n): { success: true; data: T } | { success: false; error: string } {\n try {\n const parsed = JSON.parse(content);\n const result = schema.safeParse(parsed);\n \n if (result.success) {\n return { success: true, data: result.data };\n }\n \n return {\n success: false,\n error: `Validation failed: ${result.error.issues[0]?.message || 'Unknown error'}`,\n };\n } catch (error) {\n return {\n success: false,\n error: `JSON parse failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n };\n }\n}\n\n/**\n * Check if data matches a schema (non-throwing)\n */\nexport function isValidSchema<T>(data: unknown, schema: z.ZodSchema<T>): boolean {\n return schema.safeParse(data).success;\n}\n"],"mappings":";AAaA,SAAS,UAAU,SAAS,QAAQ,UAAU,YAAY;AAC1D,SAAS,kBAAkB;AAC3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YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;AAAA,EAC3C,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;AAAA,EACxC,aAAa,EAAE,MAAM,oBAAoB;AAAA,EACzC,UAAU,EAAE,MAAM,aAAa;AAAA,EAC/B,aAAa,EAAE,OAAO;AACxB,CAAC;AAOM,IAAM,gCAAgC,EAAE,MAAM,sBAAsB;AA2IpE,SAAS,qBACd,SACA,QACgE;AAChE,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,OAAO;AACjC,UAAM,SAAS,OAAO,UAAU,MAAM;AAEtC,QAAI,OAAO,SAAS;AAClB,aAAO,EAAE,SAAS,MAAM,MAAM,OAAO,KAAK;AAAA,IAC5C;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO,sBAAsB,OAAO,MAAM,OAAO,CAAC,GAAG,WAAW,eAAe;AAAA,IACjF;AAAA,EACF,SAAS,OAAO;AACd,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO,sBAAsB,iBAAiB,QAAQ,MAAM,UAAU,eAAe;AAAA,IACvF;AAAA,EACF;AACF;","names":[]}
@@ -1,18 +1,21 @@
1
1
  import {
2
2
  getGoalManager
3
- } from "./chunk-YEIJW6X6.js";
3
+ } from "./chunk-ILGMFND2.js";
4
4
  import {
5
5
  getHypothesisEngine
6
- } from "./chunk-XTTZAQWJ.js";
6
+ } from "./chunk-72KSLD7A.js";
7
7
  import {
8
8
  getInsightStore
9
- } from "./chunk-3MUCUZ46.js";
9
+ } from "./chunk-OTQEFXHU.js";
10
10
  import {
11
11
  GotchaPredictor,
12
12
  SlackIntegration,
13
13
  findCrossProjectPatterns,
14
14
  recordToGlobalMemory
15
- } from "./chunk-WMDFK7LI.js";
15
+ } from "./chunk-B2AHQ2IR.js";
16
+ import {
17
+ getStorage
18
+ } from "./chunk-FG467PDD.js";
16
19
  import {
17
20
  ContextGraph
18
21
  } from "./chunk-FH335WL5.js";
@@ -22,17 +25,14 @@ import {
22
25
  } from "./chunk-FPEMP54L.js";
23
26
  import {
24
27
  getProjectState
25
- } from "./chunk-LT6VUZG2.js";
26
- import {
27
- getStorage
28
- } from "./chunk-FG467PDD.js";
28
+ } from "./chunk-CU5VDH6F.js";
29
29
  import {
30
30
  autoResolveIssues,
31
31
  getHistoricalInsights,
32
32
  getIssueHash,
33
33
  searchIssues,
34
34
  storeIssues
35
- } from "./chunk-62POBLFC.js";
35
+ } from "./chunk-QH77RQB3.js";
36
36
 
37
37
  // src/agent/trie-agent.ts
38
38
  import { basename as basename2 } from "path";
@@ -1581,7 +1581,7 @@ var TrieAgent = class {
1581
1581
  await this.projectState.recordScan();
1582
1582
  try {
1583
1583
  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";
1584
- const { calculateAdaptiveScanFrequency } = await import("./goal-manager-ZBWKWEML.js");
1584
+ const { calculateAdaptiveScanFrequency } = await import("./goal-manager-IGUMDGCA.js");
1585
1585
  const result = await calculateAdaptiveScanFrequency(riskLevel);
1586
1586
  await this.projectState.setScanFrequency(result.frequencyMs);
1587
1587
  } catch {
@@ -1810,4 +1810,4 @@ export {
1810
1810
  TrieAgent,
1811
1811
  getTrieAgent
1812
1812
  };
1813
- //# sourceMappingURL=chunk-N2EDZTKG.js.map
1813
+ //# sourceMappingURL=chunk-GAL7OIYU.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-23RJT5WT.js";
4
4
  import {
5
5
  getTrieAgent
6
- } from "./chunk-N2EDZTKG.js";
6
+ } from "./chunk-GAL7OIYU.js";
7
7
  import {
8
8
  getOutputManager
9
9
  } from "./chunk-TIMIKBY2.js";
@@ -16,7 +16,7 @@ import {
16
16
  perceiveCurrentChanges,
17
17
  reasonAboutChangesHumanReadable,
18
18
  saveCheckpoint
19
- } from "./chunk-4PAAGLKO.js";
19
+ } from "./chunk-53KUI7RQ.js";
20
20
  import {
21
21
  loadConfig,
22
22
  saveConfig
@@ -26,13 +26,17 @@ import {
26
26
  } from "./chunk-4C67GV3O.js";
27
27
  import {
28
28
  findCrossProjectPatterns
29
- } from "./chunk-WMDFK7LI.js";
29
+ } from "./chunk-B2AHQ2IR.js";
30
+ import {
31
+ TieredStorage,
32
+ getStorage
33
+ } from "./chunk-FG467PDD.js";
30
34
  import {
31
35
  ContextGraph
32
36
  } from "./chunk-FH335WL5.js";
33
37
  import {
34
38
  measureInitialGoalValue
35
- } from "./chunk-T6PS3MXJ.js";
39
+ } from "./chunk-ZDDE442Q.js";
36
40
  import {
37
41
  getKeyFromKeychain,
38
42
  isAIAvailable,
@@ -41,19 +45,14 @@ import {
41
45
  } from "./chunk-FPEMP54L.js";
42
46
  import {
43
47
  getProjectState
44
- } from "./chunk-LT6VUZG2.js";
45
- import {
46
- TieredStorage,
47
- getStorage
48
- } from "./chunk-FG467PDD.js";
48
+ } from "./chunk-CU5VDH6F.js";
49
49
  import {
50
50
  loadAutonomyConfig,
51
51
  saveAutonomyConfig
52
52
  } from "./chunk-5KJ4UJOY.js";
53
53
  import {
54
- deleteBlocks,
55
54
  getLedgerBlocks
56
- } from "./chunk-62POBLFC.js";
55
+ } from "./chunk-ZUEAHFSY.js";
57
56
  import {
58
57
  getTrieDirectory,
59
58
  getWorkingDirectory
@@ -62,26 +61,6 @@ import {
62
61
  isInteractiveMode
63
62
  } from "./chunk-APMV77PU.js";
64
63
 
65
- // src/tools/scan.ts
66
- var hasLoggedRefocus = false;
67
- var TrieScanTool = class {
68
- async execute(_input) {
69
- if (!isInteractiveMode() && !hasLoggedRefocus) {
70
- hasLoggedRefocus = true;
71
- console.error("Trie scan has been refocused on decision ledger");
72
- console.error(" trie tell - report incidents");
73
- console.error(" trie gotcha - predict risks");
74
- console.error(" trie learn - learn from history");
75
- }
76
- return {
77
- content: [{
78
- type: "text",
79
- text: "Scan functionality has been refocused on decision ledger.\n\nUse:\n- trie tell - to report incidents\n- trie gotcha - to predict risks\n- trie learn - to learn from history"
80
- }]
81
- };
82
- }
83
- };
84
-
85
64
  // src/utils/streaming.ts
86
65
  var shouldSuppressConsole = () => isInteractiveMode();
87
66
  var StreamingManager = class {
@@ -516,9 +495,6 @@ function dashboardReducer(state, action) {
516
495
  return handleStreamUpdate(state, action.update);
517
496
  case "SET_VIEW": {
518
497
  const next = { ...state, previousView: state.view, view: action.view };
519
- if (action.view !== "memory" && state.memoryTree.pendingLedgerDelete) {
520
- next.memoryTree = { ...state.memoryTree, pendingLedgerDelete: null };
521
- }
522
498
  return next;
523
499
  }
524
500
  case "GO_BACK":
@@ -701,8 +677,6 @@ function dashboardReducer(state, action) {
701
677
  return { ...state, memoryTree: { ...state.memoryTree, selectedNode: action.nodeId } };
702
678
  case "SET_MEMORY_EXPANDED_ITEM":
703
679
  return { ...state, memoryTree: { ...state.memoryTree, expandedItemId: action.itemId } };
704
- case "SET_PENDING_LEDGER_DELETE":
705
- return { ...state, memoryTree: { ...state.memoryTree, pendingLedgerDelete: action.date } };
706
680
  case "TOGGLE_MEMORY_NODE": {
707
681
  const expandable = ["decisions", "incidents", "patterns", "cross-project", "hotspots", "ledger-chain"];
708
682
  if (expandable.includes(action.nodeId)) {
@@ -956,7 +930,7 @@ function createInitialState() {
956
930
  },
957
931
  goalsPanel: { goals: [], selectedIndex: 0, selectedAchievedIndex: 0, inputMode: "browse", inputBuffer: "", lastRefresh: 0, scanningGoalId: null, scanningProgress: "" },
958
932
  hypothesesPanel: { hypotheses: [], selectedIndex: 0, selectedCompletedIndex: 0, inputMode: "browse", inputBuffer: "", lastRefresh: 0, scanningHypothesisId: null, scanningProgress: "" },
959
- memoryTree: { loaded: false, snapshot: null, globalPatterns: [], storageGovernance: [], storageGotchas: [], ledgerBlocks: [], expandedNodes: /* @__PURE__ */ new Set(["decisions"]), expandedItemId: null, selectedNode: "decisions", scrollPosition: 0, lastRefresh: 0, pendingLedgerDelete: null },
933
+ memoryTree: { loaded: false, snapshot: null, globalPatterns: [], storageGovernance: [], storageGotchas: [], ledgerBlocks: [], expandedNodes: /* @__PURE__ */ new Set(["decisions"]), expandedItemId: null, selectedNode: "decisions", scrollPosition: 0, lastRefresh: 0 },
960
934
  agentBrain: { loaded: false, governance: [], patterns: [], ledgerHash: null, selectedIndex: 0, expandedIndex: null },
961
935
  chatState: { messages: [], inputBuffer: "", loading: false, progress: null, messageQueue: [], currentSessionId: null, currentSessionTitle: null },
962
936
  chatArchivePanel: { sessions: [], selectedIndex: 0, showArchived: false, loading: false, inputMode: "browse", inputBuffer: "" },
@@ -1951,7 +1925,7 @@ function AgentView() {
1951
1925
  if (!insight) return;
1952
1926
  try {
1953
1927
  const workDir = getWorkingDirectory(void 0, true);
1954
- const { getInsightStore } = await import("./insight-store-A5XXMFD6.js");
1928
+ const { getInsightStore } = await import("./insight-store-Q62UGMTF.js");
1955
1929
  const store = getInsightStore(workDir);
1956
1930
  await store.dismissInsight(insight.id);
1957
1931
  const { getStorage: getStorage2 } = await import("./tiered-storage-VZL7KK64.js");
@@ -2303,7 +2277,7 @@ function GoalsView() {
2303
2277
  dispatch({ type: "SET_GOAL_SCANNING", goalId, progress: "Starting scan..." });
2304
2278
  dispatch({ type: "ADD_ACTIVITY", message: `Scanning goal: ${goalSummary.description}...` });
2305
2279
  dispatch({ type: "SET_GOAL_SCANNING", goalId, progress: "Loading goal configuration..." });
2306
- const { checkFilesForGoalViolations } = await import("./goal-validator-DA3JQ6JN.js");
2280
+ const { checkFilesForGoalViolations } = await import("./goal-validator-DV6DRSGF.js");
2307
2281
  const agentState = getProjectState(workDir);
2308
2282
  await agentState.load();
2309
2283
  const fullGoal = agentState.getAllGoals().find((g) => g.id === goalId);
@@ -2579,7 +2553,7 @@ function HypothesesView() {
2579
2553
  dispatch({ type: "SET_HYPOTHESIS_SCANNING", hypothesisId: hypoId, progress: "Gathering evidence..." });
2580
2554
  dispatch({ type: "ADD_ACTIVITY", message: `Testing hypothesis: ${hypo.statement}` });
2581
2555
  dispatch({ type: "SHOW_NOTIFICATION", message: `Gathering evidence for hypothesis...`, severity: "info", autoHideMs: 3e3 });
2582
- const { gatherEvidenceForHypothesis } = await import("./hypothesis-JCUMZKTG.js");
2556
+ const { gatherEvidenceForHypothesis } = await import("./hypothesis-O72ZLVOW.js");
2583
2557
  const evidence = await gatherEvidenceForHypothesis(hypoId, workDir, signal);
2584
2558
  scanAbortRef.current = null;
2585
2559
  dispatch({ type: "SET_HYPOTHESIS_SCANNING", hypothesisId: null, progress: "" });
@@ -2751,7 +2725,7 @@ function timeAgo2(iso) {
2751
2725
  function MemoryTreeView() {
2752
2726
  const { state, dispatch } = useDashboard();
2753
2727
  const { memoryTree } = state;
2754
- const { snapshot, globalPatterns, storageGovernance, storageGotchas, ledgerBlocks, expandedNodes, expandedItemId, selectedNode, loaded, pendingLedgerDelete } = memoryTree;
2728
+ const { snapshot, globalPatterns, storageGovernance, storageGotchas, ledgerBlocks, expandedNodes, expandedItemId, selectedNode, loaded } = memoryTree;
2755
2729
  const { stdout } = useStdout8();
2756
2730
  const cols = stdout?.columns || 80;
2757
2731
  const narrow = cols < 60;
@@ -2797,57 +2771,13 @@ function MemoryTreeView() {
2797
2771
  dispatch({ type: "ADD_ACTIVITY", message: "Failed to update incident" });
2798
2772
  }
2799
2773
  }, [selectedNode, expandedItemId, loadData, dispatch]);
2800
- const handleLedgerBlockDelete = useCallback4(async () => {
2801
- const dateToDelete = pendingLedgerDelete;
2802
- if (!dateToDelete) return;
2803
- try {
2804
- dispatch({ type: "ADD_ACTIVITY", message: `Attempting to delete ledger block ${dateToDelete}...` });
2805
- const workDir = getWorkingDirectory(void 0, true);
2806
- const result = await deleteBlocks([dateToDelete], workDir, true);
2807
- if (result.success) {
2808
- dispatch({ type: "ADD_ACTIVITY", message: `Ledger block ${dateToDelete} deleted permanently` });
2809
- dispatch({ type: "SET_MEMORY_EXPANDED_ITEM", itemId: null });
2810
- dispatch({ type: "SET_PENDING_LEDGER_DELETE", date: null });
2811
- void loadData();
2812
- } else {
2813
- dispatch({ type: "ADD_ACTIVITY", message: `Failed to delete block: ${result.error}` });
2814
- dispatch({ type: "SHOW_NOTIFICATION", message: result.error ?? "Delete failed", severity: "warning" });
2815
- dispatch({ type: "SET_PENDING_LEDGER_DELETE", date: null });
2816
- }
2817
- } catch (err) {
2818
- const msg = err instanceof Error ? err.message : "unknown error";
2819
- dispatch({ type: "ADD_ACTIVITY", message: `Failed to delete ledger block: ${msg}` });
2820
- dispatch({ type: "SHOW_NOTIFICATION", message: `Delete failed: ${msg}`, severity: "warning" });
2821
- dispatch({ type: "SET_PENDING_LEDGER_DELETE", date: null });
2822
- }
2823
- }, [pendingLedgerDelete, loadData, dispatch]);
2824
2774
  useInput6((_input, key) => {
2825
2775
  const incidentSelected = selectedNode?.startsWith("incident-") || expandedItemId?.startsWith("incident-");
2826
2776
  const ledgerBlockSelected = selectedNode?.startsWith("ledger-block-") || expandedItemId?.startsWith("ledger-block-");
2827
- if (pendingLedgerDelete) {
2828
- if (_input === "y" || _input === "Y" || key.return) {
2829
- void handleLedgerBlockDelete();
2830
- return;
2831
- }
2832
- if (_input === "n" || _input === "N" || key.escape) {
2833
- dispatch({ type: "SET_PENDING_LEDGER_DELETE", date: null });
2834
- return;
2835
- }
2836
- return;
2837
- }
2838
2777
  if (incidentSelected && (_input === "d" || _input === "D")) {
2839
2778
  void handleIncidentAction("delete");
2840
2779
  return;
2841
2780
  }
2842
- if (ledgerBlockSelected && (_input === "d" || _input === "D")) {
2843
- const blockNodeId = selectedNode?.startsWith("ledger-block-") ? selectedNode : expandedItemId?.startsWith("ledger-block-") ? expandedItemId : null;
2844
- const blockIndex = blockNodeId ? parseInt(blockNodeId.replace("ledger-block-", ""), 10) : -1;
2845
- const block = blockIndex >= 0 ? ledgerBlocks[blockIndex] : null;
2846
- if (block) {
2847
- dispatch({ type: "SET_PENDING_LEDGER_DELETE", date: block.date });
2848
- }
2849
- return;
2850
- }
2851
2781
  if (incidentSelected && (_input === "r" || _input === "c")) {
2852
2782
  void handleIncidentAction("resolve");
2853
2783
  return;
@@ -3080,23 +3010,6 @@ function MemoryTreeView() {
3080
3010
  expandedLedgerBlock.createdAt
3081
3011
  ] }) })
3082
3012
  ] }),
3083
- pendingLedgerDelete && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: 1, borderStyle: "single", borderColor: "red", paddingX: 1, paddingY: 1, children: [
3084
- /* @__PURE__ */ jsx11(Text10, { bold: true, color: "red", children: "\u26A0\uFE0F DANGER: PERMANENT DELETION" }),
3085
- /* @__PURE__ */ jsx11(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text10, { children: "You are about to permanently delete ledger block:" }) }),
3086
- /* @__PURE__ */ jsx11(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text10, { bold: true, color: "cyan", children: pendingLedgerDelete }) }),
3087
- /* @__PURE__ */ jsx11(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text10, { color: "red", children: "This operation cannot be undone and will permanently" }) }),
3088
- /* @__PURE__ */ jsx11(Box10, { marginTop: 0, children: /* @__PURE__ */ jsx11(Text10, { color: "red", children: "remove all issues and data from this block." }) }),
3089
- /* @__PURE__ */ jsx11(Box10, { marginTop: 1, children: /* @__PURE__ */ jsxs10(Text10, { children: [
3090
- /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "y" }),
3091
- " or ",
3092
- /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "Enter" }),
3093
- " to confirm \xB7 ",
3094
- /* @__PURE__ */ jsx11(Text10, { bold: true, children: "n" }),
3095
- " or ",
3096
- /* @__PURE__ */ jsx11(Text10, { bold: true, children: "Esc" }),
3097
- " to cancel"
3098
- ] }) })
3099
- ] }),
3100
3013
  /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: 1, children: [
3101
3014
  renderHeader("decisions", "Product Governance", governance.length, "-- use trie tell or chat"),
3102
3015
  expandedNodes.has("decisions") && governance.slice(0, 10).map((g) => {
@@ -6316,7 +6229,7 @@ function getPendingFixes() {
6316
6229
  }
6317
6230
  async function loadPendingFixesFromMemory() {
6318
6231
  try {
6319
- const { getRecentIssues } = await import("./issue-store-LZWZIGM7.js");
6232
+ const { getRecentIssues } = await import("./issue-store-4FPABLC6.js");
6320
6233
  pendingFixes.clear();
6321
6234
  const recentIssues = await getRecentIssues({ limit: 50, includeResolved: false });
6322
6235
  for (const storedIssue of recentIssues) {
@@ -6618,7 +6531,7 @@ var TrieCloudFixTool = class {
6618
6531
  if (pending.length === 0) {
6619
6532
  try {
6620
6533
  console.log("Loading issues from memory...");
6621
- const { getRecentIssues } = await import("./issue-store-LZWZIGM7.js");
6534
+ const { getRecentIssues } = await import("./issue-store-4FPABLC6.js");
6622
6535
  const recentIssues = await getRecentIssues({ limit: 50, includeResolved: false });
6623
6536
  console.log(`Found ${recentIssues.length} recent issues in memory`);
6624
6537
  const memoryIssues = recentIssues.map((storedIssue) => ({
@@ -6908,6 +6821,28 @@ function formatNudges(nudges) {
6908
6821
  }
6909
6822
  return out;
6910
6823
  }
6824
+ function formatIncidents(incidents) {
6825
+ if (incidents.length === 0) return "No incidents found.";
6826
+ let out = `Found ${incidents.length} incident(s):
6827
+
6828
+ `;
6829
+ for (const inc of incidents) {
6830
+ const emoji = inc.severity === "critical" ? "\u{1F534}" : inc.severity === "major" ? "\u{1F7E0}" : "\u{1F7E1}";
6831
+ const status = inc.resolved ? "\u2705 RESOLVED" : "\u26A0\uFE0F ACTIVE";
6832
+ out += `${emoji} [${inc.severity.toUpperCase()}] ${status}
6833
+ `;
6834
+ out += ` ${inc.description}
6835
+ `;
6836
+ if (inc.affectedUsers != null) {
6837
+ out += ` Affected Users: ${inc.affectedUsers}
6838
+ `;
6839
+ }
6840
+ out += ` Reported: ${new Date(inc.timestamp).toLocaleString()}
6841
+ `;
6842
+ out += "\n";
6843
+ }
6844
+ return out;
6845
+ }
6911
6846
  var TrieQueryContextTool = class {
6912
6847
  async execute(input) {
6913
6848
  const workDir = input.directory || getWorkingDirectory(void 0, true);
@@ -6923,6 +6858,7 @@ var TrieQueryContextTool = class {
6923
6858
  const includeNudges = !input.type || input.type === "nudges" || input.type === "all";
6924
6859
  const includeGovernance = !input.type || input.type === "governance" || input.type === "decisions" || input.type === "all";
6925
6860
  const includeBlockers = !input.type || input.type === "blockers" || input.type === "all";
6861
+ const includeIncidents = !input.type || input.type === "incidents" || input.type === "all";
6926
6862
  if (includeGoals) {
6927
6863
  try {
6928
6864
  const projectState = getProjectState(workDir);
@@ -7033,6 +6969,42 @@ var TrieQueryContextTool = class {
7033
6969
  output += new TrieGetBlockersTool().formatBlockers(matches);
7034
6970
  }
7035
6971
  }
6972
+ if (includeIncidents) {
6973
+ try {
6974
+ const { ContextGraph: ContextGraph2 } = await import("./graph-J4OGTYCO.js");
6975
+ const graph = new ContextGraph2(workDir);
6976
+ const allNodes = await graph.listNodes();
6977
+ const incidentNodes = allNodes.filter((n) => n.type === "incident");
6978
+ const matches = incidentNodes.filter((n) => {
6979
+ const data = n.data;
6980
+ if (keywords.length > 0 && !keywords.some((kw) => kw === "incident" || kw === "incidents" || kw === "all")) {
6981
+ return keywords.some(
6982
+ (kw) => data.description.toLowerCase().includes(kw) || data.severity.toLowerCase().includes(kw)
6983
+ );
6984
+ }
6985
+ return true;
6986
+ }).slice(0, limit);
6987
+ if (matches.length > 0) {
6988
+ output += `\u{1F6A8} INCIDENTS (${matches.length}):
6989
+ `;
6990
+ output += formatIncidents(matches.map((n) => {
6991
+ const data = n.data;
6992
+ return {
6993
+ description: data.description,
6994
+ severity: data.severity,
6995
+ timestamp: data.timestamp,
6996
+ resolved: data.resolved,
6997
+ affectedUsers: data.affectedUsers
6998
+ };
6999
+ }));
7000
+ output += "\n";
7001
+ }
7002
+ } catch (e) {
7003
+ output += `(Incidents unavailable: ${e instanceof Error ? e.message : "unknown"})
7004
+
7005
+ `;
7006
+ }
7007
+ }
7036
7008
  return {
7037
7009
  content: [{
7038
7010
  type: "text",
@@ -7736,12 +7708,12 @@ var CHAT_TOOLS = [
7736
7708
  },
7737
7709
  {
7738
7710
  name: "trie_query_context",
7739
- description: 'Natural-language search across ALL Trie context: goals, hypotheses, nudges (goal violations), governance, blockers, facts, and questions. Use for "what are my goals", "show hypotheses", "any nudges", "recent governance", etc.',
7711
+ description: 'Natural-language search across ALL Trie context: goals, hypotheses, nudges (goal violations), incidents, governance, blockers, facts, and questions. Use for "what are my goals", "show hypotheses", "any nudges", "show incidents", "recent governance", etc.',
7740
7712
  input_schema: {
7741
7713
  type: "object",
7742
7714
  properties: {
7743
- query: { type: "string", description: 'Natural language search query (e.g. "goals", "hypotheses", "nudges", "governance")' },
7744
- type: { type: "string", enum: ["goals", "hypotheses", "nudges", "governance", "decisions", "blockers", "facts", "questions", "all"], description: "Narrow to a specific category (default all)" },
7715
+ query: { type: "string", description: 'Natural language search query (e.g. "goals", "hypotheses", "nudges", "incidents", "governance")' },
7716
+ type: { type: "string", enum: ["goals", "hypotheses", "nudges", "incidents", "governance", "decisions", "blockers", "facts", "questions", "all"], description: "Narrow to a specific category (default all)" },
7745
7717
  limit: { type: "number", description: "Max results (default 10)" }
7746
7718
  },
7747
7719
  required: ["query"]
@@ -8264,7 +8236,7 @@ ${truncated}`;
8264
8236
  const goalId = input.goalId ? String(input.goalId).trim() : void 0;
8265
8237
  try {
8266
8238
  onProgress?.("Loading goals...");
8267
- const { getActiveGoals } = await import("./goal-validator-DA3JQ6JN.js");
8239
+ const { getActiveGoals } = await import("./goal-validator-DV6DRSGF.js");
8268
8240
  const agentState = getProjectState(directory);
8269
8241
  await agentState.load();
8270
8242
  const allGoals = await getActiveGoals(directory);
@@ -8273,7 +8245,7 @@ ${truncated}`;
8273
8245
  return goalId ? `No active goal found with ID: ${goalId}` : "No active goals to check. Add goals in the Goals view first.";
8274
8246
  }
8275
8247
  onProgress?.("Scanning codebase for violations...");
8276
- const { analyzeFilesRapidly } = await import("./fast-analyzer-MWKCDRGD.js");
8248
+ const { analyzeFilesRapidly } = await import("./fast-analyzer-CTT3MCPE.js");
8277
8249
  const analysisOptions = {
8278
8250
  maxFiles: 50,
8279
8251
  enableSmartBatching: true
@@ -8287,7 +8259,7 @@ ${truncated}`;
8287
8259
  const cacheInfo2 = analysisResult.cacheHitRatio > 0 ? ` (${Math.round(analysisResult.cacheHitRatio * 100)}% cache hit, ${analysisResult.timeMs}ms)` : ` (${analysisResult.timeMs}ms)`;
8288
8260
  return `\u2713 Scan complete! No violations found for ${goalsToCheck.length} goal(s).${cacheInfo2}`;
8289
8261
  }
8290
- const { storeIssues } = await import("./issue-store-LZWZIGM7.js");
8262
+ const { storeIssues } = await import("./issue-store-4FPABLC6.js");
8291
8263
  const { basename } = await import("path");
8292
8264
  const issuesToStore = violations.map((v, i) => ({
8293
8265
  id: `goal-violation-${Date.now()}-${i}`,
@@ -8366,7 +8338,7 @@ ${truncated}`;
8366
8338
  }
8367
8339
  try {
8368
8340
  onProgress?.("Gathering evidence for hypothesis...");
8369
- const { gatherEvidenceForHypothesis } = await import("./hypothesis-JCUMZKTG.js");
8341
+ const { gatherEvidenceForHypothesis } = await import("./hypothesis-O72ZLVOW.js");
8370
8342
  const evidence = await gatherEvidenceForHypothesis(hypothesisId, directory);
8371
8343
  if (evidence.length === 0) {
8372
8344
  return `No evidence found for this hypothesis yet. The codebase may not have enough data to validate it \u2014 try running trie_scan_for_goal_violations first to populate issues, or add more context.`;
@@ -9292,7 +9264,7 @@ ${content}
9292
9264
  fixedContent = fixedContent.replace(/^```\w*\n?/, "").replace(/\n?```$/, "");
9293
9265
  }
9294
9266
  await writeFile2(fullPath, fixedContent, "utf-8");
9295
- const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-DA3JQ6JN.js");
9267
+ const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-DV6DRSGF.js");
9296
9268
  const goals = await getActiveGoals(projectPath);
9297
9269
  const matchedGoal = goals.find((g) => g.description === fix.goalDescription);
9298
9270
  if (matchedGoal) {
@@ -9503,7 +9475,6 @@ function DashboardApp({ onReady }) {
9503
9475
  }, [state.pendingFixes]);
9504
9476
  useInput10((input, key) => {
9505
9477
  if (showConfig) return;
9506
- if (state.memoryTree.pendingLedgerDelete) return;
9507
9478
  const inAddMode = state.view === "goals" && state.goalsPanel.inputMode === "add" || state.view === "hypotheses" && state.hypothesesPanel.inputMode === "add";
9508
9479
  const inChat = state.view === "chat";
9509
9480
  const scanningGoal = !!state.goalsPanel.scanningGoalId;
@@ -9657,7 +9628,6 @@ var InteractiveDashboard = class {
9657
9628
  };
9658
9629
 
9659
9630
  export {
9660
- TrieScanTool,
9661
9631
  getPrompt,
9662
9632
  getSystemPrompt,
9663
9633
  TrieFixTool,
@@ -9679,4 +9649,4 @@ export {
9679
9649
  GitHubBranchesTool,
9680
9650
  InteractiveDashboard
9681
9651
  };
9682
- //# sourceMappingURL=chunk-2354SRJM.js.map
9652
+ //# sourceMappingURL=chunk-HYNDXZAU.js.map