@triedotdev/mcp 1.0.126 → 1.0.127

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.
@@ -7,7 +7,6 @@ import {
7
7
  import {
8
8
  getTrieDirectory
9
9
  } from "./chunk-45Y5TLQZ.js";
10
- import "./chunk-APMV77PU.js";
11
10
  import {
12
11
  __require
13
12
  } from "./chunk-DGUM43GV.js";
@@ -54,28 +53,38 @@ var CodebaseIndex = class {
54
53
  }
55
54
  /**
56
55
  * Add or update a file in the index
56
+ * Returns null if the file doesn't exist or can't be read
57
57
  */
58
58
  async indexFile(filePath) {
59
- const absolutePath = join(this.projectPath, filePath);
60
- const content = await readFile(absolutePath, "utf-8");
61
- const stats = await stat(absolutePath);
62
- const hash = createHash("sha256").update(content).digest("hex");
63
- const metadata = {
64
- path: filePath,
65
- hash,
66
- size: stats.size,
67
- lastModified: stats.mtimeMs,
68
- type: filePath.split(".").pop() || ""
69
- };
70
- const existing = this.trie.search(filePath);
71
- if (existing.found && existing.value) {
72
- if (existing.value.hash === hash) {
73
- metadata.violations = existing.value.violations;
74
- metadata.lastScanned = existing.value.lastScanned;
59
+ if (filePath.startsWith("/")) {
60
+ if (!filePath.toLowerCase().startsWith(this.projectPath.toLowerCase())) {
61
+ return null;
75
62
  }
76
63
  }
77
- this.trie.insert(filePath, metadata);
78
- return metadata;
64
+ const absolutePath = filePath.startsWith("/") ? filePath : join(this.projectPath, filePath);
65
+ try {
66
+ const content = await readFile(absolutePath, "utf-8");
67
+ const stats = await stat(absolutePath);
68
+ const hash = createHash("sha256").update(content).digest("hex");
69
+ const metadata = {
70
+ path: filePath,
71
+ hash,
72
+ size: stats.size,
73
+ lastModified: stats.mtimeMs,
74
+ type: filePath.split(".").pop() || ""
75
+ };
76
+ const existing = this.trie.search(filePath);
77
+ if (existing.found && existing.value) {
78
+ if (existing.value.hash === hash) {
79
+ metadata.violations = existing.value.violations;
80
+ metadata.lastScanned = existing.value.lastScanned;
81
+ }
82
+ }
83
+ this.trie.insert(filePath, metadata);
84
+ return metadata;
85
+ } catch (error) {
86
+ return null;
87
+ }
79
88
  }
80
89
  /**
81
90
  * Get file metadata from index
@@ -88,9 +97,12 @@ var CodebaseIndex = class {
88
97
  * Check if file has changed since last index
89
98
  */
90
99
  async hasChanged(filePath) {
100
+ if (filePath.startsWith("/") && !filePath.toLowerCase().startsWith(this.projectPath.toLowerCase())) {
101
+ return true;
102
+ }
91
103
  const metadata = this.getFile(filePath);
92
104
  if (!metadata) return true;
93
- const absolutePath = join(this.projectPath, filePath);
105
+ const absolutePath = filePath.startsWith("/") ? filePath : join(this.projectPath, filePath);
94
106
  try {
95
107
  const stats = await stat(absolutePath);
96
108
  if (stats.mtimeMs !== metadata.lastModified) return true;
@@ -153,6 +165,12 @@ var CodebaseIndex = class {
153
165
  }
154
166
  return metadata.violations;
155
167
  }
168
+ /**
169
+ * Check if the index is empty (needs initial indexing)
170
+ */
171
+ isEmpty() {
172
+ return this.trie.getWithPrefix("").length === 0;
173
+ }
156
174
  /**
157
175
  * Get statistics about the index
158
176
  */
@@ -191,7 +209,8 @@ var CodebaseIndex = class {
191
209
  return cleared;
192
210
  }
193
211
  };
212
+
194
213
  export {
195
214
  CodebaseIndex
196
215
  };
197
- //# sourceMappingURL=codebase-index-ECJYAEZJ.js.map
216
+ //# sourceMappingURL=chunk-6VIMBFUZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context/codebase-index.ts"],"sourcesContent":["/**\n * Codebase Index - Fast file indexing for goal violation detection\n * \n * Uses Trie structure for efficient file lookup and caching to avoid\n * re-scanning unchanged files.\n * \n * For large codebases, this dramatically improves goal check performance:\n * - Indexes file hashes to detect changes\n * - Caches AI analysis results\n * - Uses Trie for O(m) lookups where m = path length\n * - Stores file metadata (size, type, last modified, etc.)\n */\n\nimport { readFile, stat } from 'fs/promises';\nimport { createHash } from 'crypto';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\nimport { Trie } from '../trie/trie.js';\nimport { getTrieDirectory } from '../utils/workspace.js';\nimport { atomicWriteJSON } from '../utils/atomic-write.js';\n\nexport interface FileMetadata {\n path: string;\n hash: string; // SHA-256 of content\n size: number;\n lastModified: number;\n type: string; // Extension\n lastScanned?: number; // Timestamp of last AI scan\n violations?: {\n goalId: string;\n goalDescription: string;\n found: boolean;\n details?: string;\n confidence?: number;\n timestamp: number;\n }[];\n}\n\nexport interface CodebaseIndexData {\n version: number;\n lastUpdated: string;\n fileCount: number;\n trie: any; // Serialized Trie\n}\n\nexport class CodebaseIndex {\n private trie: Trie<FileMetadata> = new Trie();\n private projectPath: string;\n private indexPath: string;\n\n constructor(projectPath: string) {\n this.projectPath = projectPath;\n this.indexPath = join(getTrieDirectory(projectPath), 'codebase-index.json');\n this.load();\n }\n\n /**\n * Load index from disk if it exists\n */\n private load(): void {\n if (!existsSync(this.indexPath)) return;\n\n try {\n const raw = JSON.parse(require('fs').readFileSync(this.indexPath, 'utf-8'));\n if (raw.trie) {\n this.trie = Trie.fromJSON<FileMetadata>(raw.trie);\n }\n } catch (error) {\n console.error('Failed to load codebase index:', error);\n }\n }\n\n /**\n * Save index to disk\n */\n async save(): Promise<void> {\n const data: CodebaseIndexData = {\n version: 1,\n lastUpdated: new Date().toISOString(),\n fileCount: this.trie.getWithPrefix('').length,\n trie: this.trie.toJSON(),\n };\n\n await atomicWriteJSON(this.indexPath, data);\n }\n\n /**\n * Add or update a file in the index\n * Returns null if the file doesn't exist or can't be read\n */\n async indexFile(filePath: string): Promise<FileMetadata | null> {\n // Safety check: if filePath is already absolute and doesn't start with projectPath,\n // this is likely a bug (stale cache entry from different project)\n if (filePath.startsWith('/')) {\n // Already absolute - check if it's within our project\n if (!filePath.toLowerCase().startsWith(this.projectPath.toLowerCase())) {\n return null; // Wrong project, skip silently\n }\n // It's absolute but within our project - use as-is\n }\n \n // Build absolute path: if filePath is relative, join with projectPath\n // If filePath is absolute (and within project), use it directly\n const absolutePath = filePath.startsWith('/') ? filePath : join(this.projectPath, filePath);\n \n try {\n const content = await readFile(absolutePath, 'utf-8');\n const stats = await stat(absolutePath);\n const hash = createHash('sha256').update(content).digest('hex');\n\n const metadata: FileMetadata = {\n path: filePath,\n hash,\n size: stats.size,\n lastModified: stats.mtimeMs,\n type: filePath.split('.').pop() || '',\n };\n\n // Check if file exists in index\n const existing = this.trie.search(filePath);\n if (existing.found && existing.value) {\n // File exists - preserve violations if hash matches\n if (existing.value.hash === hash) {\n metadata.violations = existing.value.violations;\n metadata.lastScanned = existing.value.lastScanned;\n }\n }\n\n this.trie.insert(filePath, metadata);\n return metadata;\n } catch (error) {\n // File doesn't exist, was deleted, or can't be read - return null\n return null;\n }\n }\n\n /**\n * Get file metadata from index\n */\n getFile(filePath: string): FileMetadata | null {\n const result = this.trie.search(filePath);\n return result.found && result.value ? result.value : null;\n }\n\n /**\n * Check if file has changed since last index\n */\n async hasChanged(filePath: string): Promise<boolean> {\n // Safety check for absolute paths from wrong project\n if (filePath.startsWith('/') && !filePath.toLowerCase().startsWith(this.projectPath.toLowerCase())) {\n return true; // Wrong project, treat as changed (will be skipped later)\n }\n \n const metadata = this.getFile(filePath);\n if (!metadata) return true; // Not indexed = changed\n\n // Build absolute path correctly\n const absolutePath = filePath.startsWith('/') ? filePath : join(this.projectPath, filePath);\n try {\n const stats = await stat(absolutePath);\n if (stats.mtimeMs !== metadata.lastModified) return true;\n\n // Double-check with hash for certainty\n const content = await readFile(absolutePath, 'utf-8');\n const hash = createHash('sha256').update(content).digest('hex');\n return hash !== metadata.hash;\n } catch {\n return true; // Error = assume changed\n }\n }\n\n /**\n * Get files in a directory\n */\n getDirectoryFiles(directoryPath: string): FileMetadata[] {\n const prefix = directoryPath.endsWith('/') ? directoryPath : `${directoryPath}/`;\n const matches = this.trie.getWithPrefix(prefix);\n return matches.map(m => m.value).filter((v): v is FileMetadata => v !== null);\n }\n\n /**\n * Get files that match a pattern (uses Trie prefix matching)\n */\n getFilesWithPrefix(prefix: string): FileMetadata[] {\n const matches = this.trie.getWithPrefix(prefix);\n return matches.map(m => m.value).filter((v): v is FileMetadata => v !== null);\n }\n\n /**\n * Get files by type (extension)\n */\n getFilesByType(type: string): FileMetadata[] {\n const allFiles = this.trie.getWithPrefix('');\n return allFiles\n .map(m => m.value)\n .filter((v): v is FileMetadata => v !== null && v.type === type);\n }\n\n /**\n * Record goal violation scan result for a file\n */\n recordViolation(\n filePath: string,\n goalId: string,\n goalDescription: string,\n found: boolean,\n details?: string,\n confidence?: number\n ): void {\n const metadata = this.getFile(filePath);\n if (!metadata) return;\n\n metadata.lastScanned = Date.now();\n if (!metadata.violations) metadata.violations = [];\n\n // Remove existing violation for this goal\n metadata.violations = metadata.violations.filter(v => v.goalId !== goalId);\n\n // Add new violation result\n metadata.violations.push({\n goalId,\n goalDescription,\n found,\n details,\n confidence,\n timestamp: Date.now(),\n });\n\n this.trie.insert(filePath, metadata);\n }\n\n /**\n * Get cached violation results for a file\n */\n getCachedViolations(filePath: string, goalId?: string): FileMetadata['violations'] {\n const metadata = this.getFile(filePath);\n if (!metadata || !metadata.violations) return undefined;\n\n if (goalId) {\n return metadata.violations.filter(v => v.goalId === goalId);\n }\n\n return metadata.violations;\n }\n\n /**\n * Check if the index is empty (needs initial indexing)\n */\n isEmpty(): boolean {\n return this.trie.getWithPrefix('').length === 0;\n }\n\n /**\n * Get statistics about the index\n */\n getStats(): {\n totalFiles: number;\n totalSize: number;\n filesByType: Record<string, number>;\n scannedFiles: number;\n filesWithViolations: number;\n } {\n const allFiles = this.trie.getWithPrefix('').map(m => m.value).filter((v): v is FileMetadata => v !== null);\n\n const stats = {\n totalFiles: allFiles.length,\n totalSize: allFiles.reduce((sum, f) => sum + f.size, 0),\n filesByType: {} as Record<string, number>,\n scannedFiles: allFiles.filter(f => f.lastScanned).length,\n filesWithViolations: allFiles.filter(f => f.violations && f.violations.some(v => v.found)).length,\n };\n\n for (const file of allFiles) {\n stats.filesByType[file.type] = (stats.filesByType[file.type] || 0) + 1;\n }\n\n return stats;\n }\n\n /**\n * Clear stale cached results (older than maxAgeMs)\n */\n clearStaleCache(maxAgeMs: number = 7 * 24 * 60 * 60 * 1000): number {\n const allFiles = this.trie.getWithPrefix('').map(m => m.value).filter((v): v is FileMetadata => v !== null);\n const cutoff = Date.now() - maxAgeMs;\n let cleared = 0;\n\n for (const file of allFiles) {\n if (file.violations) {\n const before = file.violations.length;\n file.violations = file.violations.filter(v => v.timestamp > cutoff);\n cleared += before - file.violations.length;\n if (file.violations.length === 0) {\n file.lastScanned = undefined;\n }\n this.trie.insert(file.path, file);\n }\n }\n\n return cleared;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAS,UAAU,YAAY;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,kBAAkB;AA6BpB,IAAM,gBAAN,MAAoB;AAAA,EACjB,OAA2B,IAAI,KAAK;AAAA,EACpC;AAAA,EACA;AAAA,EAER,YAAY,aAAqB;AAC/B,SAAK,cAAc;AACnB,SAAK,YAAY,KAAK,iBAAiB,WAAW,GAAG,qBAAqB;AAC1E,SAAK,KAAK;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAKQ,OAAa;AACnB,QAAI,CAAC,WAAW,KAAK,SAAS,EAAG;AAEjC,QAAI;AACF,YAAM,MAAM,KAAK,MAAM,UAAQ,IAAI,EAAE,aAAa,KAAK,WAAW,OAAO,CAAC;AAC1E,UAAI,IAAI,MAAM;AACZ,aAAK,OAAO,KAAK,SAAuB,IAAI,IAAI;AAAA,MAClD;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,kCAAkC,KAAK;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAsB;AAC1B,UAAM,OAA0B;AAAA,MAC9B,SAAS;AAAA,MACT,cAAa,oBAAI,KAAK,GAAE,YAAY;AAAA,MACpC,WAAW,KAAK,KAAK,cAAc,EAAE,EAAE;AAAA,MACvC,MAAM,KAAK,KAAK,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A,IACvE;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAgB,WAAmB,IAAI,KAAK,KAAK,KAAK,KAAc;AAClE,UAAM,WAAW,KAAK,KAAK,cAAc,EAAE,EAAE,IAAI,OAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAyB,MAAM,IAAI;AAC1G,UAAM,SAAS,KAAK,IAAI,IAAI;AAC5B,QAAI,UAAU;AAEd,eAAW,QAAQ,UAAU;AAC3B,UAAI,KAAK,YAAY;AACnB,cAAM,SAAS,KAAK,WAAW;AAC/B,aAAK,aAAa,KAAK,WAAW,OAAO,OAAK,EAAE,YAAY,MAAM;AAClE,mBAAW,SAAS,KAAK,WAAW;AACpC,YAAI,KAAK,WAAW,WAAW,GAAG;AAChC,eAAK,cAAc;AAAA,QACrB;AACA,aAAK,KAAK,OAAO,KAAK,MAAM,IAAI;AAAA,MAClC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1886,8 +1886,15 @@ function GoalsView() {
1886
1886
  const goal = goalsPanel.goals.find((g) => g.id === goalId);
1887
1887
  if (!goal) return;
1888
1888
  dispatch({ type: "ADD_ACTIVITY", message: `Checking goal: ${goal.description.slice(0, 30)}...` });
1889
- dispatch({ type: "SHOW_NOTIFICATION", message: `Scanning files... This may take a moment for large codebases`, severity: "info", autoHideMs: 5e3 });
1890
- const { checkFilesForGoalViolations } = await import("./goal-validator-4RA64F37.js");
1889
+ const { CodebaseIndex } = await import("./codebase-index-CR6Q2HEI.js");
1890
+ const codebaseIndex = new CodebaseIndex(workDir);
1891
+ if (codebaseIndex.isEmpty()) {
1892
+ dispatch({ type: "SHOW_NOTIFICATION", message: `Building codebase index (one-time)... This will speed up future checks.`, severity: "info", autoHideMs: 1e4 });
1893
+ dispatch({ type: "ADD_ACTIVITY", message: `Building codebase index...` });
1894
+ } else {
1895
+ dispatch({ type: "SHOW_NOTIFICATION", message: `Scanning files...`, severity: "info", autoHideMs: 5e3 });
1896
+ }
1897
+ const { checkFilesForGoalViolations } = await import("./goal-validator-NLOJJ7FF.js");
1891
1898
  const violations = await checkFilesForGoalViolations([goal], workDir);
1892
1899
  if (violations.length === 0) {
1893
1900
  dispatch({ type: "SHOW_NOTIFICATION", message: `\u2713 No violations found for: ${goal.description.slice(0, 40)}`, severity: "info", autoHideMs: 5e3 });
@@ -2088,7 +2095,14 @@ function HypothesesView() {
2088
2095
  const hypo = hypothesesPanel.hypotheses.find((h) => h.id === hypoId);
2089
2096
  if (!hypo) return;
2090
2097
  dispatch({ type: "ADD_ACTIVITY", message: `Testing hypothesis: ${hypo.statement.slice(0, 30)}...` });
2091
- dispatch({ type: "SHOW_NOTIFICATION", message: `Gathering evidence for hypothesis...`, severity: "info", autoHideMs: 3e3 });
2098
+ const { CodebaseIndex } = await import("./codebase-index-CR6Q2HEI.js");
2099
+ const codebaseIndex = new CodebaseIndex(workDir);
2100
+ if (codebaseIndex.isEmpty()) {
2101
+ dispatch({ type: "SHOW_NOTIFICATION", message: `Building codebase index (one-time)...`, severity: "info", autoHideMs: 8e3 });
2102
+ dispatch({ type: "ADD_ACTIVITY", message: `Building codebase index...` });
2103
+ } else {
2104
+ dispatch({ type: "SHOW_NOTIFICATION", message: `Gathering evidence for hypothesis...`, severity: "info", autoHideMs: 3e3 });
2105
+ }
2092
2106
  const { gatherEvidenceForHypothesis } = await import("./hypothesis-HFYZNIMZ.js");
2093
2107
  const evidence = await gatherEvidenceForHypothesis(hypoId, workDir);
2094
2108
  if (evidence.length === 0) {
@@ -5249,7 +5263,8 @@ ${truncated}`;
5249
5263
  case "trie_scan_for_goal_violations": {
5250
5264
  const goalId = input.goalId ? String(input.goalId).trim() : void 0;
5251
5265
  try {
5252
- const { checkFilesForGoalViolations, getActiveGoals } = await import("./goal-validator-4RA64F37.js");
5266
+ const { checkFilesForGoalViolations, getActiveGoals } = await import("./goal-validator-NLOJJ7FF.js");
5267
+ const { CodebaseIndex } = await import("./codebase-index-CR6Q2HEI.js");
5253
5268
  const agentState = getGuardianState(directory);
5254
5269
  await agentState.load();
5255
5270
  const allGoals = await getActiveGoals(directory);
@@ -5257,11 +5272,13 @@ ${truncated}`;
5257
5272
  if (goalsToCheck.length === 0) {
5258
5273
  return goalId ? `No active goal found with ID: ${goalId}` : "No active goals to check. Add goals in the Goals view first.";
5259
5274
  }
5275
+ const codebaseIndex = new CodebaseIndex(directory);
5276
+ const indexMessage = codebaseIndex.isEmpty() ? "\u{1F4CB} Building codebase index (one-time operation)...\n\n" : "";
5260
5277
  const violations = await checkFilesForGoalViolations(goalsToCheck, directory);
5261
5278
  if (violations.length === 0) {
5262
- return `\u2713 Scan complete! No violations found for ${goalsToCheck.length} goal(s).`;
5279
+ return `${indexMessage}\u2713 Scan complete! No violations found for ${goalsToCheck.length} goal(s).`;
5263
5280
  }
5264
- let result = `Found ${violations.length} violation(s):
5281
+ let result = `${indexMessage}Found ${violations.length} violation(s):
5265
5282
 
5266
5283
  `;
5267
5284
  for (const v of violations) {
@@ -5994,7 +6011,7 @@ ${content}
5994
6011
  fixedContent = fixedContent.replace(/^```\w*\n?/, "").replace(/\n?```$/, "");
5995
6012
  }
5996
6013
  await writeFile(fullPath, fixedContent, "utf-8");
5997
- const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-4RA64F37.js");
6014
+ const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-NLOJJ7FF.js");
5998
6015
  const goals = await getActiveGoals(projectPath);
5999
6016
  const matchedGoal = goals.find((g) => g.description === fix.goalDescription);
6000
6017
  if (matchedGoal) {
@@ -6356,4 +6373,4 @@ export {
6356
6373
  handleCheckpointTool,
6357
6374
  InteractiveDashboard
6358
6375
  };
6359
- //# sourceMappingURL=chunk-KCVXTYHO.js.map
6376
+ //# sourceMappingURL=chunk-WBNYLTW6.js.map