@triedotdev/mcp 1.0.118 → 1.0.120

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.
@@ -3,10 +3,10 @@ import {
3
3
  InteractiveDashboard,
4
4
  StreamingManager,
5
5
  TrieScanTool
6
- } from "../chunk-OZGDXRLD.js";
7
- import "../chunk-OMCEUJ5I.js";
6
+ } from "../chunk-XNAVAA52.js";
7
+ import "../chunk-5TQ7J7UI.js";
8
8
  import "../chunk-IQBHPTV7.js";
9
- import "../chunk-I7XKF5XD.js";
9
+ import "../chunk-GPLRFTMB.js";
10
10
  import "../chunk-Y52SNUW5.js";
11
11
  import {
12
12
  isTrieInitialized
@@ -0,0 +1,187 @@
1
+ import {
2
+ getGuardianState
3
+ } from "./chunk-4BGAVEO6.js";
4
+ import "./chunk-43X6JBEM.js";
5
+ import "./chunk-45Y5TLQZ.js";
6
+ import "./chunk-APMV77PU.js";
7
+ import "./chunk-DGUM43GV.js";
8
+
9
+ // src/guardian/goal-validator.ts
10
+ async function getActiveGoals(projectPath) {
11
+ const guardianState = getGuardianState(projectPath);
12
+ await guardianState.load();
13
+ return guardianState.getAllGoals().filter((g) => g.status === "active");
14
+ }
15
+ async function recordGoalViolationCaught(goal, file, projectPath) {
16
+ const guardianState = getGuardianState(projectPath);
17
+ await guardianState.load();
18
+ const metadata = goal.metadata || {};
19
+ const caughtCount = (metadata.caughtCount || 0) + 1;
20
+ await guardianState.updateGoal(goal.id, {
21
+ metadata: {
22
+ ...metadata,
23
+ caughtCount,
24
+ lastCaught: (/* @__PURE__ */ new Date()).toISOString(),
25
+ lastCaughtFile: file
26
+ }
27
+ });
28
+ }
29
+ async function recordGoalViolationFixed(goal, file, projectPath) {
30
+ const guardianState = getGuardianState(projectPath);
31
+ await guardianState.load();
32
+ const metadata = goal.metadata || {};
33
+ const caughtCount = (metadata.caughtCount || 0) + 1;
34
+ const fixedCount = (metadata.fixedCount || 0) + 1;
35
+ await guardianState.updateGoal(goal.id, {
36
+ metadata: {
37
+ ...metadata,
38
+ caughtCount,
39
+ fixedCount,
40
+ lastFixed: (/* @__PURE__ */ new Date()).toISOString(),
41
+ lastFixedFile: file
42
+ }
43
+ });
44
+ if (goal.type === "reduction") {
45
+ const newValue = Math.max(0, goal.currentValue - 1);
46
+ await guardianState.updateGoal(goal.id, {
47
+ currentValue: newValue
48
+ });
49
+ if (newValue <= goal.target) {
50
+ await guardianState.updateGoal(goal.id, {
51
+ status: "achieved",
52
+ achievedAt: (/* @__PURE__ */ new Date()).toISOString()
53
+ });
54
+ }
55
+ }
56
+ }
57
+ async function checkFilesForGoalViolations(goals, projectPath, filesToCheck) {
58
+ const { isAIAvailable, runAIAnalysis } = await import("./client-PMKE26IV.js");
59
+ if (!isAIAvailable()) {
60
+ throw new Error("AI not available - ANTHROPIC_API_KEY not set");
61
+ }
62
+ let files = [];
63
+ if (filesToCheck && filesToCheck.length > 0) {
64
+ files = filesToCheck;
65
+ } else {
66
+ const { execSync } = await import("child_process");
67
+ const { glob } = await import("glob");
68
+ try {
69
+ const gitOutput = execSync(
70
+ "git diff --name-only HEAD && git ls-files --modified && git ls-files --others --exclude-standard",
71
+ { cwd: projectPath, encoding: "utf-8" }
72
+ ).trim();
73
+ if (gitOutput) {
74
+ const gitFiles = new Set(gitOutput.split("\n").filter(Boolean));
75
+ files = Array.from(gitFiles).map((f) => `${projectPath}/${f}`).filter((f) => {
76
+ return /\.(ts|tsx|js|jsx|py|go|rs|java|c|cpp|h|hpp|cs|rb|php)$/.test(f);
77
+ });
78
+ }
79
+ } catch {
80
+ }
81
+ if (files.length === 0) {
82
+ const pattern = `${projectPath}/**/*.{ts,tsx,js,jsx,py,go,rs,java,c,cpp,h,hpp,cs,rb,php}`;
83
+ const allFiles = await glob(pattern, {
84
+ ignore: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/.git/**"],
85
+ nodir: true
86
+ });
87
+ const { stat } = await import("fs/promises");
88
+ const withStats = await Promise.all(
89
+ allFiles.map(async (f) => {
90
+ try {
91
+ const stats = await stat(f);
92
+ return { file: f, mtime: stats.mtime.getTime() };
93
+ } catch {
94
+ return null;
95
+ }
96
+ })
97
+ );
98
+ files = withStats.filter((f) => f !== null).sort((a, b) => b.mtime - a.mtime).slice(0, 30).map((f) => f.file);
99
+ }
100
+ files = files.slice(0, 20);
101
+ }
102
+ if (files.length === 0) {
103
+ throw new Error("No files found to check");
104
+ }
105
+ const { readFile } = await import("fs/promises");
106
+ const fileContents = await Promise.all(
107
+ files.map(async (filePath) => {
108
+ try {
109
+ const content = await readFile(filePath, "utf-8");
110
+ const relativePath = filePath.replace(projectPath + "/", "");
111
+ return {
112
+ path: relativePath,
113
+ content: content.slice(0, 5e3)
114
+ // Limit content size
115
+ };
116
+ } catch {
117
+ return null;
118
+ }
119
+ })
120
+ );
121
+ const validFiles = fileContents.filter((f) => f !== null);
122
+ if (validFiles.length === 0) {
123
+ throw new Error("Could not read any files");
124
+ }
125
+ const filesBlock = validFiles.map((f) => `--- ${f.path} ---
126
+ ${f.content}`).join("\n\n");
127
+ const goalsSection = `
128
+ USER-DEFINED GOALS (check EVERY file against ALL goals):
129
+ ${goals.map((g, i) => ` ${i + 1}. "${g.description}"`).join("\n")}
130
+
131
+ This is a MANUAL CHECK requested by the user. Report ALL goal violations you find.
132
+ For emoji detection, look for Unicode emoji characters (U+1F300-U+1F9FF, U+2600-U+27BF, etc.).
133
+ `;
134
+ const result = await runAIAnalysis({
135
+ systemPrompt: `You are checking code for GOAL VIOLATIONS ONLY.
136
+ ${goalsSection}
137
+ Reply ONLY with a JSON array. Each element must have:
138
+ - "file": relative file path
139
+ - "severity": "critical" | "major" | "minor"
140
+ - "description": 1-sentence description of the goal violation with specific examples
141
+ - "confidence": number 0-100, how confident you are this is a violation
142
+ - "isGoalViolation": true (always true for this scan)
143
+ - "goalIndex": 0-based index of the violated goal
144
+
145
+ Be thorough. If a goal says "no emojis" and you see ANY emoji character (\u{1F4CA}, \u{1F4AA}, \u{1F525}, \u2713, \u25CF, etc.), report it with the specific emoji found. If a goal says "no console.log" and you see console.log, report it.
146
+
147
+ IMPORTANT: Emojis include any Unicode emoji characters like \u{1F4CA}\u{1F4AA}\u{1F525}\u2713\u25CF\u25CB\u25BA\u25C4\u25B2\u25BC\u2600\u2601\u26A0 etc.
148
+
149
+ If no violations found, reply with: []
150
+ Output ONLY the JSON array, no markdown fences, no commentary.`,
151
+ userPrompt: `Check these ${validFiles.length} files for goal violations:
152
+
153
+ ${filesBlock}`,
154
+ maxTokens: 4096,
155
+ temperature: 0.1
156
+ });
157
+ let issues = [];
158
+ try {
159
+ const cleaned = result.content.replace(/```json?\n?|\n?```/g, "").trim();
160
+ issues = JSON.parse(cleaned);
161
+ if (!Array.isArray(issues)) issues = [];
162
+ } catch {
163
+ throw new Error("Failed to parse AI response");
164
+ }
165
+ const violations = [];
166
+ for (const issue of issues) {
167
+ if (!issue.isGoalViolation || issue.confidence < 50) continue;
168
+ if (issue.goalIndex == null || issue.goalIndex < 0 || issue.goalIndex >= goals.length) continue;
169
+ const goal = goals[issue.goalIndex];
170
+ const severity = issue.severity === "critical" ? "critical" : "warning";
171
+ const message = `Goal "${goal.description}" violated in ${issue.file}: ${issue.description} [${issue.confidence}% confidence]`;
172
+ violations.push({
173
+ file: issue.file,
174
+ message,
175
+ severity
176
+ });
177
+ await recordGoalViolationCaught(goal, issue.file, projectPath);
178
+ }
179
+ return violations;
180
+ }
181
+ export {
182
+ checkFilesForGoalViolations,
183
+ getActiveGoals,
184
+ recordGoalViolationCaught,
185
+ recordGoalViolationFixed
186
+ };
187
+ //# sourceMappingURL=goal-validator-RD6QBQJB.js.map
@@ -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 */\n\nimport type { Goal } from './guardian-state.js';\nimport { getGuardianState } from './guardian-state.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 guardianState = getGuardianState(projectPath);\n await guardianState.load();\n return guardianState.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 guardianState = getGuardianState(projectPath);\n await guardianState.load();\n \n const metadata = goal.metadata || {};\n const caughtCount = (metadata.caughtCount || 0) + 1;\n \n await guardianState.updateGoal(goal.id, {\n metadata: {\n ...metadata,\n caughtCount,\n lastCaught: new Date().toISOString(),\n lastCaughtFile: file,\n },\n });\n}\n\nexport async function recordGoalViolationFixed(\n goal: Goal,\n file: string,\n projectPath: string\n): Promise<void> {\n const guardianState = getGuardianState(projectPath);\n await guardianState.load();\n \n const metadata = goal.metadata || {};\n const caughtCount = (metadata.caughtCount || 0) + 1;\n const fixedCount = (metadata.fixedCount || 0) + 1;\n \n await guardianState.updateGoal(goal.id, {\n metadata: {\n ...metadata,\n caughtCount,\n fixedCount,\n lastFixed: new Date().toISOString(),\n lastFixedFile: file,\n },\n });\n \n if (goal.type === 'reduction') {\n const newValue = Math.max(0, goal.currentValue - 1);\n await guardianState.updateGoal(goal.id, {\n currentValue: newValue,\n });\n \n if (newValue <= goal.target) {\n await guardianState.updateGoal(goal.id, {\n status: 'achieved',\n achievedAt: new Date().toISOString(),\n });\n }\n }\n}\n\n/**\n * Manually check files against goals\n * Returns violations found\n */\nexport async function checkFilesForGoalViolations(\n goals: Goal[],\n projectPath: string,\n filesToCheck?: string[]\n): Promise<Array<{ file: string; message: string; severity: 'critical' | 'warning' | 'info' }>> {\n // Import AI client\n const { isAIAvailable, runAIAnalysis } = await import('../ai/client.js');\n \n if (!isAIAvailable()) {\n throw new Error('AI not available - ANTHROPIC_API_KEY not set');\n }\n \n // Get files to check\n let files: string[] = [];\n if (filesToCheck && filesToCheck.length > 0) {\n files = filesToCheck;\n } else {\n // Find files to check - prioritize modified files, but fall back to all files if none modified\n const { execSync } = await import('child_process');\n const { glob } = await import('glob');\n \n try {\n // Try git first\n const gitOutput = execSync(\n 'git diff --name-only HEAD && git ls-files --modified && git ls-files --others --exclude-standard',\n { cwd: projectPath, encoding: 'utf-8' }\n ).trim();\n \n if (gitOutput) {\n const gitFiles = new Set(gitOutput.split('\\n').filter(Boolean));\n files = Array.from(gitFiles)\n .map(f => `${projectPath}/${f}`)\n .filter(f => {\n // Filter to code files only\n return /\\.(ts|tsx|js|jsx|py|go|rs|java|c|cpp|h|hpp|cs|rb|php)$/.test(f);\n });\n }\n } catch {\n // Git command failed, ignore\n }\n \n // If no git files, scan recently modified files\n if (files.length === 0) {\n const pattern = `${projectPath}/**/*.{ts,tsx,js,jsx,py,go,rs,java,c,cpp,h,hpp,cs,rb,php}`;\n const allFiles = await glob(pattern, {\n ignore: ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.git/**'],\n nodir: true,\n });\n \n // Sort by modification time, take most recent 30\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, 30)\n .map(f => f.file);\n }\n \n // Final limit\n files = files.slice(0, 20);\n }\n \n if (files.length === 0) {\n throw new Error('No files found to check');\n }\n \n // Read file contents\n const { readFile } = await import('fs/promises');\n const fileContents = await Promise.all(\n files.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, 5000), // Limit content size\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) {\n throw new Error('Could not read any files');\n }\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 (U+1F300-U+1F9FF, U+2600-U+27BF, etc.).\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\nBe thorough. If a goal says \"no emojis\" and you see ANY emoji character (📊, 💪, 🔥, ✓, ●, etc.), report it with the specific emoji found. If a goal says \"no console.log\" and you see console.log, report it.\n\nIMPORTANT: Emojis include any Unicode emoji characters like 📊💪🔥✓●○►◄▲▼☀☁⚠ etc.\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: 4096,\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 {\n // Parse failed\n throw new Error('Failed to parse AI response');\n }\n \n // Convert to violation format and record\n const violations: Array<{ file: string; message: string; severity: 'critical' | 'warning' | 'info' }> = [];\n \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 const severity = issue.severity === 'critical' ? 'critical' : 'warning';\n const message = `Goal \"${goal.description}\" violated in ${issue.file}: ${issue.description} [${issue.confidence}% confidence]`;\n \n violations.push({\n file: issue.file,\n message,\n severity,\n });\n \n // Record violation\n await recordGoalViolationCaught(goal, issue.file, projectPath);\n }\n \n return violations;\n}\n"],"mappings":";;;;;;;;;AAmBA,eAAsB,eAAe,aAAsC;AACzE,QAAM,gBAAgB,iBAAiB,WAAW;AAClD,QAAM,cAAc,KAAK;AACzB,SAAO,cAAc,YAAY,EAAE,OAAO,OAAK,EAAE,WAAW,QAAQ;AACtE;AAEA,eAAsB,0BACpB,MACA,MACA,aACe;AACf,QAAM,gBAAgB,iBAAiB,WAAW;AAClD,QAAM,cAAc,KAAK;AAEzB,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,QAAM,eAAe,SAAS,eAAe,KAAK;AAElD,QAAM,cAAc,WAAW,KAAK,IAAI;AAAA,IACtC,UAAU;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,MACnC,gBAAgB;AAAA,IAClB;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,yBACpB,MACA,MACA,aACe;AACf,QAAM,gBAAgB,iBAAiB,WAAW;AAClD,QAAM,cAAc,KAAK;AAEzB,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,QAAM,eAAe,SAAS,eAAe,KAAK;AAClD,QAAM,cAAc,SAAS,cAAc,KAAK;AAEhD,QAAM,cAAc,WAAW,KAAK,IAAI;AAAA,IACtC,UAAU;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,YAAW,o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WAAW;AAAA,EAC/D;AAEA,SAAO;AACT;","names":[]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  GuardianAgent,
3
3
  getGuardian
4
- } from "./chunk-OMCEUJ5I.js";
4
+ } from "./chunk-5TQ7J7UI.js";
5
5
  import "./chunk-IQBHPTV7.js";
6
- import "./chunk-I7XKF5XD.js";
6
+ import "./chunk-GPLRFTMB.js";
7
7
  import "./chunk-Y52SNUW5.js";
8
8
  import "./chunk-FNW7Z7ZS.js";
9
9
  import "./chunk-WRGSH5RT.js";
@@ -22,4 +22,4 @@ export {
22
22
  GuardianAgent,
23
23
  getGuardian
24
24
  };
25
- //# sourceMappingURL=guardian-agent-UY2G56FT.js.map
25
+ //# sourceMappingURL=guardian-agent-ITZIDNQD.js.map
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  HypothesisEngine,
3
3
  clearHypothesisEngines,
4
+ gatherEvidenceForHypothesis,
4
5
  getHypothesisEngine
5
- } from "./chunk-I7XKF5XD.js";
6
+ } from "./chunk-GPLRFTMB.js";
6
7
  import "./chunk-Y52SNUW5.js";
7
8
  import "./chunk-PRFHN2X6.js";
8
9
  import "./chunk-4BGAVEO6.js";
@@ -14,6 +15,7 @@ import "./chunk-DGUM43GV.js";
14
15
  export {
15
16
  HypothesisEngine,
16
17
  clearHypothesisEngines,
18
+ gatherEvidenceForHypothesis,
17
19
  getHypothesisEngine
18
20
  };
19
- //# sourceMappingURL=hypothesis-RUCJ74X7.js.map
21
+ //# sourceMappingURL=hypothesis-PEVD2IJR.js.map
package/dist/index.js CHANGED
@@ -38,10 +38,10 @@ import {
38
38
  getPrompt,
39
39
  getSystemPrompt,
40
40
  handleCheckpointTool
41
- } from "./chunk-OZGDXRLD.js";
42
- import "./chunk-OMCEUJ5I.js";
41
+ } from "./chunk-XNAVAA52.js";
42
+ import "./chunk-5TQ7J7UI.js";
43
43
  import "./chunk-IQBHPTV7.js";
44
- import "./chunk-I7XKF5XD.js";
44
+ import "./chunk-GPLRFTMB.js";
45
45
  import "./chunk-Y52SNUW5.js";
46
46
  import {
47
47
  exportToJson,
@@ -1424,7 +1424,7 @@ ${f.content.slice(0, 1e3)}`
1424
1424
  async checkAndGenerateHypotheses(projectPath) {
1425
1425
  if (!isAIAvailable()) return;
1426
1426
  try {
1427
- const { getHypothesisEngine } = await import("./hypothesis-RUCJ74X7.js");
1427
+ const { getHypothesisEngine } = await import("./hypothesis-PEVD2IJR.js");
1428
1428
  const { getOutputManager: getOutputManager2 } = await import("./output-manager-BOTMXSND.js");
1429
1429
  const hypothesisEngine = getHypothesisEngine(projectPath);
1430
1430
  const recentIssues = Array.from(this.state.issueCache.values()).flat();
@@ -1633,7 +1633,7 @@ ${f.content.slice(0, 1e3)}`
1633
1633
  this.state.lastAutoScan = now;
1634
1634
  try {
1635
1635
  const graph = new ContextGraph(projectPath);
1636
- const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-YSNN23D4.js");
1636
+ const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-RD6QBQJB.js");
1637
1637
  const { appendIssuesToLedger } = await import("./ledger-JMPGJGLB.js");
1638
1638
  const activeGoals = await getActiveGoals(projectPath);
1639
1639
  const hasGoals = activeGoals.length > 0;
@@ -1844,7 +1844,7 @@ ${filesBlock}`,
1844
1844
  if (!isAIAvailable()) return;
1845
1845
  const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
1846
1846
  try {
1847
- const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-YSNN23D4.js");
1847
+ const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-RD6QBQJB.js");
1848
1848
  const activeGoals = await getActiveGoals(projectPath);
1849
1849
  if (activeGoals.length === 0) return;
1850
1850
  if (!isInteractiveMode()) {
@@ -2045,7 +2045,7 @@ Use \`trie_watch start\` to begin autonomous scanning.`
2045
2045
  ).join("\n");
2046
2046
  let agencyStatus = "";
2047
2047
  try {
2048
- const { getGuardian } = await import("./guardian-agent-UY2G56FT.js");
2048
+ const { getGuardian } = await import("./guardian-agent-ITZIDNQD.js");
2049
2049
  const trieAgent = getGuardian(this.watchedDirectory || getWorkingDirectory(void 0, true));
2050
2050
  await trieAgent.initialize();
2051
2051
  const status = await trieAgent.getAgencyStatus();
@@ -0,0 +1,104 @@
1
+ import "./chunk-DGUM43GV.js";
2
+
3
+ // src/utils/terminal-spawn.ts
4
+ import { exec } from "child_process";
5
+ import { promisify } from "util";
6
+ import { platform } from "os";
7
+ var execAsync = promisify(exec);
8
+ async function spawnTerminal(options) {
9
+ const { command, cwd, title, keepOpen = true } = options;
10
+ const os = platform();
11
+ if (os === "darwin") {
12
+ await spawnMacOSTerminal(command, cwd, title, keepOpen);
13
+ } else if (os === "linux") {
14
+ await spawnLinuxTerminal(command, cwd, title, keepOpen);
15
+ } else {
16
+ throw new Error(`Terminal spawning not supported on ${os}`);
17
+ }
18
+ }
19
+ async function spawnMacOSTerminal(command, cwd, title, keepOpen) {
20
+ const escapedCommand = command.replace(/'/g, `'"'"'`);
21
+ const escapedCwd = cwd?.replace(/'/g, `'"'"'`) || process.cwd();
22
+ const escapedTitle = title?.replace(/'/g, `'"'"'`) || "Trie Agent";
23
+ const fullCommand = cwd ? `cd '${escapedCwd}' && ${command}` : command;
24
+ const escapedFullCommand = fullCommand.replace(/'/g, `'"'"'`);
25
+ const script = `
26
+ tell application "Terminal"
27
+ activate
28
+ set newTab to do script "${escapedFullCommand}"
29
+ set custom title of newTab to "${escapedTitle}"
30
+ end tell
31
+ `.trim();
32
+ try {
33
+ await execAsync(`osascript -e '${script.replace(/'/g, `'"'"'`)}'`);
34
+ } catch (error) {
35
+ console.error("Terminal.app spawn failed, trying fallback...");
36
+ const shellCmd = keepOpen ? `${fullCommand}; exec bash` : fullCommand;
37
+ await execAsync(`open -a Terminal "${escapedCwd}" --args -e "${shellCmd}"`);
38
+ }
39
+ }
40
+ async function spawnLinuxTerminal(command, cwd, title, keepOpen) {
41
+ const workDir = cwd || process.cwd();
42
+ const termTitle = title || "Trie Agent";
43
+ const shellCmd = keepOpen ? `${command}; exec bash` : command;
44
+ const terminals = [
45
+ // GNOME Terminal
46
+ {
47
+ command: "gnome-terminal",
48
+ args: `--working-directory="${workDir}" --title="${termTitle}" -- bash -c "${shellCmd}"`
49
+ },
50
+ // Konsole (KDE)
51
+ {
52
+ command: "konsole",
53
+ args: `--workdir "${workDir}" --title "${termTitle}" -e bash -c "${shellCmd}"`
54
+ },
55
+ // xterm (fallback)
56
+ {
57
+ command: "xterm",
58
+ args: `-T "${termTitle}" -e "cd '${workDir}' && ${shellCmd}"`
59
+ }
60
+ ];
61
+ for (const term of terminals) {
62
+ try {
63
+ await execAsync(`which ${term.command}`);
64
+ await execAsync(`${term.command} ${term.args} &`);
65
+ return;
66
+ } catch {
67
+ continue;
68
+ }
69
+ }
70
+ throw new Error("No supported terminal emulator found (tried: gnome-terminal, konsole, xterm)");
71
+ }
72
+ async function spawnClaudeCodeFix(options) {
73
+ const { file, goal, violation, suggestedFix, cwd } = options;
74
+ const promptLines = [
75
+ "Fix this file to satisfy the goal.",
76
+ "",
77
+ `File: ${file}`,
78
+ `Goal: ${goal}`,
79
+ `Violation: ${violation}`
80
+ ];
81
+ if (suggestedFix) {
82
+ promptLines.push(`Suggested fix: ${suggestedFix}`);
83
+ }
84
+ promptLines.push(
85
+ "",
86
+ "Please fix the violation while:",
87
+ "1. Preserving all functionality",
88
+ "2. Maintaining code style",
89
+ "3. Not breaking anything",
90
+ "4. Following the goal exactly"
91
+ );
92
+ const prompt = promptLines.join("\n");
93
+ await spawnTerminal({
94
+ command: `claude "${prompt.replace(/"/g, '\\"')}"`,
95
+ cwd,
96
+ title: `Fixing: ${file}`,
97
+ keepOpen: true
98
+ });
99
+ }
100
+ export {
101
+ spawnClaudeCodeFix,
102
+ spawnTerminal
103
+ };
104
+ //# sourceMappingURL=terminal-spawn-2GU5KLPS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/terminal-spawn.ts"],"sourcesContent":["/**\n * Terminal Spawning Utility\n * \n * Spawns a new terminal window with a command to execute.\n * Supports macOS (Terminal.app, iTerm2) and Linux (gnome-terminal, konsole, xterm).\n */\n\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { platform } from 'os';\n\nconst execAsync = promisify(exec);\n\nexport interface SpawnTerminalOptions {\n /** Command to execute in the new terminal */\n command: string;\n /** Working directory for the command */\n cwd?: string;\n /** Terminal title */\n title?: string;\n /** Keep terminal open after command completes */\n keepOpen?: boolean;\n}\n\n/**\n * Spawn a new terminal window with a command\n */\nexport async function spawnTerminal(options: SpawnTerminalOptions): Promise<void> {\n const { command, cwd, title, keepOpen = true } = options;\n const os = platform();\n\n if (os === 'darwin') {\n await spawnMacOSTerminal(command, cwd, title, keepOpen);\n } else if (os === 'linux') {\n await spawnLinuxTerminal(command, cwd, title, keepOpen);\n } else {\n throw new Error(`Terminal spawning not supported on ${os}`);\n }\n}\n\n/**\n * Spawn terminal on macOS using AppleScript\n * Tries Terminal.app first, falls back to open if Terminal.app fails\n */\nasync function spawnMacOSTerminal(\n command: string,\n cwd?: string,\n title?: string,\n keepOpen?: boolean\n): Promise<void> {\n // Escape single quotes in command\n const escapedCommand = command.replace(/'/g, \"'\\\"'\\\"'\");\n const escapedCwd = cwd?.replace(/'/g, \"'\\\"'\\\"'\") || process.cwd();\n const escapedTitle = title?.replace(/'/g, \"'\\\"'\\\"'\") || 'Trie Agent';\n\n // Build the full command with cd if cwd provided\n const fullCommand = cwd ? `cd '${escapedCwd}' && ${command}` : command;\n const escapedFullCommand = fullCommand.replace(/'/g, \"'\\\"'\\\"'\");\n\n // AppleScript to open Terminal.app with the command\n const script = `\ntell application \"Terminal\"\n activate\n set newTab to do script \"${escapedFullCommand}\"\n set custom title of newTab to \"${escapedTitle}\"\nend tell\n`.trim();\n\n try {\n await execAsync(`osascript -e '${script.replace(/'/g, \"'\\\"'\\\"'\")}'`);\n } catch (error) {\n // Fallback: use open command\n console.error('Terminal.app spawn failed, trying fallback...');\n const shellCmd = keepOpen \n ? `${fullCommand}; exec bash`\n : fullCommand;\n await execAsync(`open -a Terminal \"${escapedCwd}\" --args -e \"${shellCmd}\"`);\n }\n}\n\n/**\n * Spawn terminal on Linux\n * Tries common terminal emulators in order\n */\nasync function spawnLinuxTerminal(\n command: string,\n cwd?: string,\n title?: string,\n keepOpen?: boolean\n): Promise<void> {\n const workDir = cwd || process.cwd();\n const termTitle = title || 'Trie Agent';\n const shellCmd = keepOpen ? `${command}; exec bash` : command;\n\n // Try terminal emulators in order of preference\n const terminals = [\n // GNOME Terminal\n {\n command: 'gnome-terminal',\n args: `--working-directory=\"${workDir}\" --title=\"${termTitle}\" -- bash -c \"${shellCmd}\"`,\n },\n // Konsole (KDE)\n {\n command: 'konsole',\n args: `--workdir \"${workDir}\" --title \"${termTitle}\" -e bash -c \"${shellCmd}\"`,\n },\n // xterm (fallback)\n {\n command: 'xterm',\n args: `-T \"${termTitle}\" -e \"cd '${workDir}' && ${shellCmd}\"`,\n },\n ];\n\n for (const term of terminals) {\n try {\n await execAsync(`which ${term.command}`);\n await execAsync(`${term.command} ${term.args} &`);\n return;\n } catch {\n // Terminal not available, try next\n continue;\n }\n }\n\n throw new Error('No supported terminal emulator found (tried: gnome-terminal, konsole, xterm)');\n}\n\n/**\n * Spawn Claude Code in a new terminal to fix a file\n */\nexport async function spawnClaudeCodeFix(options: {\n file: string;\n goal: string;\n violation: string;\n suggestedFix?: string;\n cwd: string;\n}): Promise<void> {\n const { file, goal, violation, suggestedFix, cwd } = options;\n\n // Build a prompt for Claude CLI\n const promptLines = [\n 'Fix this file to satisfy the goal.',\n '',\n `File: ${file}`,\n `Goal: ${goal}`,\n `Violation: ${violation}`,\n ];\n \n if (suggestedFix) {\n promptLines.push(`Suggested fix: ${suggestedFix}`);\n }\n \n promptLines.push(\n '',\n 'Please fix the violation while:',\n '1. Preserving all functionality',\n '2. Maintaining code style',\n '3. Not breaking anything',\n '4. Following the goal exactly',\n );\n\n const prompt = promptLines.join('\\n');\n\n // Spawn terminal that runs: claude <prompt>\n // This will start claude in interactive mode with the prompt pre-filled\n await spawnTerminal({\n command: `claude \"${prompt.replace(/\"/g, '\\\\\"')}\"`,\n cwd,\n title: `Fixing: ${file}`,\n keepOpen: true,\n });\n}\n"],"mappings":";;;AAOA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAEzB,IAAM,YAAY,UAAU,IAAI;AAgBhC,eAAsB,cAAc,SAA8C;AAChF,QAAM,EAAE,SAAS,KAAK,OAAO,WAAW,KAAK,IAAI;AACjD,QAAM,KAAK,SAAS;AAEpB,MAAI,OAAO,UAAU;AACnB,UAAM,mBAAmB,SAAS,KAAK,OAAO,QAAQ;AAAA,EACxD,WAAW,OAAO,SAAS;AACzB,UAAM,mBAAmB,SAAS,KAAK,OAAO,QAAQ;AAAA,EACxD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,EAAE,EAAE;AAAA,EAC5D;AACF;AAMA,eAAe,mBACb,SACA,KACA,OACA,UACe;AAEf,QAAM,iBAAiB,QAAQ,QAAQ,MAAM,OAAS;AACtD,QAAM,aAAa,KAAK,QAAQ,MAAM,OAAS,KAAK,QAAQ,IAAI;AAChE,QAAM,eAAe,OAAO,QAAQ,MAAM,OAAS,KAAK;AAGxD,QAAM,cAAc,MAAM,OAAO,UAAU,QAAQ,OAAO,KAAK;AAC/D,QAAM,qBAAqB,YAAY,QAAQ,MAAM,OAAS;AAG9D,QAAM,SAAS;AAAA;AAAA;AAAA,6BAGY,kBAAkB;AAAA,mCACZ,YAAY;AAAA;AAAA,EAE7C,KAAK;AAEL,MAAI;AACF,UAAM,UAAU,iBAAiB,OAAO,QAAQ,MAAM,OAAS,CAAC,GAAG;AAAA,EACrE,SAAS,OAAO;AAEd,YAAQ,MAAM,+CAA+C;AAC7D,UAAM,WAAW,WACb,GAAG,WAAW,gBACd;AACJ,UAAM,UAAU,qBAAqB,UAAU,gBAAgB,QAAQ,GAAG;AAAA,EAC5E;AACF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AI;AAAA,IACtB,UAAU;AAAA,EACZ,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triedotdev/mcp",
3
- "version": "1.0.118",
3
+ "version": "1.0.120",
4
4
  "description": "Trainable AI Agent for Maintaining AI-Generated Codebases",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",