@triedotdev/mcp 1.0.136 → 1.0.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DFHMB44X.js → chunk-4JQ6W7LW.js} +3 -4
- package/dist/chunk-4JQ6W7LW.js.map +1 -0
- package/dist/{chunk-WS6OA7H6.js → chunk-4MJ52WBH.js} +2 -3
- package/dist/chunk-4MJ52WBH.js.map +1 -0
- package/dist/{chunk-UHMMANC2.js → chunk-6EP2VTHC.js} +15 -15
- package/dist/chunk-6EP2VTHC.js.map +1 -0
- package/dist/{chunk-T4THB2OR.js → chunk-A6PWS6ZV.js} +38 -27
- package/dist/chunk-A6PWS6ZV.js.map +1 -0
- package/dist/{chunk-POHBQUG7.js → chunk-AXYNWBME.js} +272 -187
- package/dist/chunk-AXYNWBME.js.map +1 -0
- package/dist/{chunk-AJ34GCMD.js → chunk-DPZLABUC.js} +32 -32
- package/dist/chunk-DPZLABUC.js.map +1 -0
- package/dist/{chunk-UHX4462X.js → chunk-G74XEI7K.js} +13 -14
- package/dist/chunk-G74XEI7K.js.map +1 -0
- package/dist/{goal-validator-PDKYZSNP.js → chunk-HUR67JXG.js} +71 -33
- package/dist/chunk-HUR67JXG.js.map +1 -0
- package/dist/{chunk-6OUWNVLX.js → chunk-K6NTRSDF.js} +4 -4
- package/dist/{chunk-G5PRBQIQ.js → chunk-QM5VIDFN.js} +75 -71
- package/dist/chunk-QM5VIDFN.js.map +1 -0
- package/dist/{chunk-4YJ6KLGI.js → chunk-QNKBXOIQ.js} +7 -5
- package/dist/chunk-QNKBXOIQ.js.map +1 -0
- package/dist/{chunk-JAKMZI5S.js → chunk-R3WZI6QZ.js} +290 -179
- package/dist/chunk-R3WZI6QZ.js.map +1 -0
- package/dist/{chunk-VRLMTOB6.js → chunk-TIMIKBY2.js} +1 -1
- package/dist/chunk-TIMIKBY2.js.map +1 -0
- package/dist/cli/main.js +104 -100
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +13 -13
- package/dist/cli/yolo-daemon.js.map +1 -1
- package/dist/{goal-manager-FAK7H4RR.js → goal-manager-62IL6WGY.js} +6 -7
- package/dist/goal-validator-HPPBSDXD.js +22 -0
- package/dist/guardian-agent-YKG5XURG.js +30 -0
- package/dist/{hypothesis-L5446W36.js → hypothesis-W37VG6DA.js} +6 -7
- package/dist/index.js +265 -259
- package/dist/index.js.map +1 -1
- package/dist/{insight-store-F5KDBY5Y.js → insight-store-U3NYTOJE.js} +5 -3
- package/dist/issue-store-EZMBHOVN.js +32 -0
- package/dist/{output-manager-BOTMXSND.js → output-manager-DZO5LGSG.js} +2 -2
- package/dist/output-manager-DZO5LGSG.js.map +1 -0
- package/dist/ui/chat.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-4YJ6KLGI.js.map +0 -1
- package/dist/chunk-AJ34GCMD.js.map +0 -1
- package/dist/chunk-DFHMB44X.js.map +0 -1
- package/dist/chunk-G5PRBQIQ.js.map +0 -1
- package/dist/chunk-JAKMZI5S.js.map +0 -1
- package/dist/chunk-PEJEYWVR.js +0 -135
- package/dist/chunk-PEJEYWVR.js.map +0 -1
- package/dist/chunk-POHBQUG7.js.map +0 -1
- package/dist/chunk-T4THB2OR.js.map +0 -1
- package/dist/chunk-UHMMANC2.js.map +0 -1
- package/dist/chunk-UHX4462X.js.map +0 -1
- package/dist/chunk-VRLMTOB6.js.map +0 -1
- package/dist/chunk-WS6OA7H6.js.map +0 -1
- package/dist/goal-validator-PDKYZSNP.js.map +0 -1
- package/dist/guardian-agent-4RHGIXUD.js +0 -27
- package/dist/ledger-WKVJWHBX.js +0 -17
- /package/dist/{chunk-6OUWNVLX.js.map → chunk-K6NTRSDF.js.map} +0 -0
- /package/dist/{goal-manager-FAK7H4RR.js.map → goal-manager-62IL6WGY.js.map} +0 -0
- /package/dist/{guardian-agent-4RHGIXUD.js.map → goal-validator-HPPBSDXD.js.map} +0 -0
- /package/dist/{hypothesis-L5446W36.js.map → guardian-agent-YKG5XURG.js.map} +0 -0
- /package/dist/{insight-store-F5KDBY5Y.js.map → hypothesis-W37VG6DA.js.map} +0 -0
- /package/dist/{ledger-WKVJWHBX.js.map → insight-store-U3NYTOJE.js.map} +0 -0
- /package/dist/{output-manager-BOTMXSND.js.map → issue-store-EZMBHOVN.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CodebaseIndex
|
|
4
4
|
} from "./chunk-6VIMBFUZ.js";
|
|
5
|
+
import {
|
|
6
|
+
getSkillRegistry
|
|
7
|
+
} from "./chunk-G76DYVGX.js";
|
|
5
8
|
import {
|
|
6
9
|
LinearIngester,
|
|
7
10
|
appendToSection,
|
|
@@ -21,7 +24,7 @@ import {
|
|
|
21
24
|
needsBootstrap,
|
|
22
25
|
projectInfoExists,
|
|
23
26
|
updateProjectSection
|
|
24
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-4JQ6W7LW.js";
|
|
25
28
|
import {
|
|
26
29
|
getAutonomyConfig
|
|
27
30
|
} from "./chunk-ZEXMMTIQ.js";
|
|
@@ -41,12 +44,12 @@ import {
|
|
|
41
44
|
getPrompt,
|
|
42
45
|
getSystemPrompt,
|
|
43
46
|
handleCheckpointTool
|
|
44
|
-
} from "./chunk-
|
|
45
|
-
import "./chunk-
|
|
47
|
+
} from "./chunk-AXYNWBME.js";
|
|
48
|
+
import "./chunk-QM5VIDFN.js";
|
|
46
49
|
import "./chunk-DFPVUMVE.js";
|
|
47
|
-
import "./chunk-
|
|
48
|
-
import "./chunk-
|
|
49
|
-
import "./chunk-
|
|
50
|
+
import "./chunk-A6PWS6ZV.js";
|
|
51
|
+
import "./chunk-DPZLABUC.js";
|
|
52
|
+
import "./chunk-QNKBXOIQ.js";
|
|
50
53
|
import {
|
|
51
54
|
exportToJson,
|
|
52
55
|
formatFriendlyError,
|
|
@@ -55,7 +58,7 @@ import {
|
|
|
55
58
|
importFromJson,
|
|
56
59
|
isTrieInitialized,
|
|
57
60
|
runShellCommandSync
|
|
58
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-K6NTRSDF.js";
|
|
59
62
|
import "./chunk-WHIQAGB7.js";
|
|
60
63
|
import "./chunk-ZV2K6M7T.js";
|
|
61
64
|
import {
|
|
@@ -63,21 +66,13 @@ import {
|
|
|
63
66
|
getGlobalMemoryStats,
|
|
64
67
|
listTrackedProjects,
|
|
65
68
|
searchGlobalPatterns
|
|
66
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-G74XEI7K.js";
|
|
70
|
+
import "./chunk-HUR67JXG.js";
|
|
67
71
|
import {
|
|
68
72
|
isAIAvailable,
|
|
69
73
|
runAIAnalysis
|
|
70
74
|
} from "./chunk-O6OTJI3W.js";
|
|
71
|
-
import
|
|
72
|
-
findSimilarIssues,
|
|
73
|
-
getMemoryStats,
|
|
74
|
-
getRecentIssues,
|
|
75
|
-
markIssueResolved,
|
|
76
|
-
purgeIssues,
|
|
77
|
-
searchIssues
|
|
78
|
-
} from "./chunk-JAKMZI5S.js";
|
|
79
|
-
import "./chunk-UHMMANC2.js";
|
|
80
|
-
import "./chunk-WS6OA7H6.js";
|
|
75
|
+
import "./chunk-6EP2VTHC.js";
|
|
81
76
|
import "./chunk-F4NJ4CBP.js";
|
|
82
77
|
import "./chunk-IXO4G4D3.js";
|
|
83
78
|
import "./chunk-6NLHFIYA.js";
|
|
@@ -87,13 +82,19 @@ import {
|
|
|
87
82
|
import {
|
|
88
83
|
ContextGraph
|
|
89
84
|
} from "./chunk-55CBWOEZ.js";
|
|
90
|
-
import {
|
|
91
|
-
getSkillRegistry
|
|
92
|
-
} from "./chunk-G76DYVGX.js";
|
|
93
85
|
import {
|
|
94
86
|
getOutputManager
|
|
95
|
-
} from "./chunk-
|
|
96
|
-
import
|
|
87
|
+
} from "./chunk-TIMIKBY2.js";
|
|
88
|
+
import {
|
|
89
|
+
findSimilarIssues,
|
|
90
|
+
getMemoryStats,
|
|
91
|
+
getRecentIssues,
|
|
92
|
+
markIssueResolved,
|
|
93
|
+
purgeIssues,
|
|
94
|
+
searchIssues,
|
|
95
|
+
storeIssues
|
|
96
|
+
} from "./chunk-R3WZI6QZ.js";
|
|
97
|
+
import "./chunk-4MJ52WBH.js";
|
|
97
98
|
import "./chunk-43X6JBEM.js";
|
|
98
99
|
import {
|
|
99
100
|
getTrieDirectory,
|
|
@@ -1342,6 +1343,8 @@ Your Trie agent is now autonomously watching and learning from your codebase.
|
|
|
1342
1343
|
if (!isInteractiveMode()) {
|
|
1343
1344
|
console.error(`[!] Watcher error: ${err.message}`);
|
|
1344
1345
|
}
|
|
1346
|
+
watcher.close();
|
|
1347
|
+
this.watchers.delete(dir);
|
|
1345
1348
|
});
|
|
1346
1349
|
this.watchers.set(dir, watcher);
|
|
1347
1350
|
if (this.streamingManager) {
|
|
@@ -1414,7 +1417,9 @@ ${f.content.slice(0, 1e3)}`
|
|
|
1414
1417
|
}
|
|
1415
1418
|
}
|
|
1416
1419
|
}
|
|
1417
|
-
this.autoScanFiles(files)
|
|
1420
|
+
void this.autoScanFiles(files).catch((err) => {
|
|
1421
|
+
getOutputManager().log("warn", `Auto scan failed: ${err}`);
|
|
1422
|
+
});
|
|
1418
1423
|
await this.discoverPatternsFromIssues(projectPath);
|
|
1419
1424
|
const now = Date.now();
|
|
1420
1425
|
if (now - this.lastHypothesisCheck > _TrieWatchTool.HYPOTHESIS_CHECK_INTERVAL_MS) {
|
|
@@ -1465,8 +1470,8 @@ ${f.content.slice(0, 1e3)}`
|
|
|
1465
1470
|
async checkAndGenerateHypotheses(projectPath) {
|
|
1466
1471
|
if (!isAIAvailable()) return;
|
|
1467
1472
|
try {
|
|
1468
|
-
const { getHypothesisEngine } = await import("./hypothesis-
|
|
1469
|
-
const { getOutputManager: getOutputManager2 } = await import("./output-manager-
|
|
1473
|
+
const { getHypothesisEngine } = await import("./hypothesis-W37VG6DA.js");
|
|
1474
|
+
const { getOutputManager: getOutputManager2 } = await import("./output-manager-DZO5LGSG.js");
|
|
1470
1475
|
const hypothesisEngine = getHypothesisEngine(projectPath);
|
|
1471
1476
|
const recentIssues = Array.from(this.state.issueCache.values()).flat();
|
|
1472
1477
|
const patterns = [];
|
|
@@ -1656,87 +1661,87 @@ ${f.content.slice(0, 1e3)}`
|
|
|
1656
1661
|
if (this.state.autoScanInProgress) return;
|
|
1657
1662
|
const now = Date.now();
|
|
1658
1663
|
if (now - this.state.lastAutoScan < this.aiWatcherCooldownMs) return;
|
|
1659
|
-
const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
|
|
1660
|
-
try {
|
|
1661
|
-
const config = await getAutonomyConfig(projectPath);
|
|
1662
|
-
const wc = config.aiWatcher;
|
|
1663
|
-
if (!wc.enabled) return;
|
|
1664
|
-
this.state.tokenBudget.hourlyLimit = wc.hourlyTokenLimit;
|
|
1665
|
-
this.aiWatcherCooldownMs = wc.scanCooldownSec * 1e3;
|
|
1666
|
-
this.cleanFileCooldownMs = wc.cleanFileCooldownSec * 1e3;
|
|
1667
|
-
this.maxFilesPerScan = wc.maxFilesPerScan;
|
|
1668
|
-
this.maxCharsPerFile = wc.maxCharsPerFile;
|
|
1669
|
-
} catch {
|
|
1670
|
-
}
|
|
1671
|
-
const remaining = this.getRemainingBudget();
|
|
1672
|
-
if (remaining < 500) return;
|
|
1673
1664
|
this.state.autoScanInProgress = true;
|
|
1674
1665
|
this.state.lastAutoScan = now;
|
|
1666
|
+
const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
|
|
1675
1667
|
try {
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
});
|
|
1687
|
-
if (this.isQuiet() && !hasGoals) return;
|
|
1688
|
-
const scored = [];
|
|
1689
|
-
for (const file of files) {
|
|
1690
|
-
const relativePath = file.replace(projectPath + "/", "");
|
|
1691
|
-
const score = await this.scoreScanPriority(relativePath, graph, projectPath);
|
|
1692
|
-
if (hasGoals || score > 0) {
|
|
1693
|
-
scored.push({ file, relativePath, score: Math.max(score, hasGoals ? 1 : 0) });
|
|
1694
|
-
} else {
|
|
1695
|
-
this.state.tokenBudget.scansSaved++;
|
|
1696
|
-
}
|
|
1668
|
+
try {
|
|
1669
|
+
const config = await getAutonomyConfig(projectPath);
|
|
1670
|
+
const wc = config.aiWatcher;
|
|
1671
|
+
if (!wc.enabled) return;
|
|
1672
|
+
this.state.tokenBudget.hourlyLimit = wc.hourlyTokenLimit;
|
|
1673
|
+
this.aiWatcherCooldownMs = wc.scanCooldownSec * 1e3;
|
|
1674
|
+
this.cleanFileCooldownMs = wc.cleanFileCooldownSec * 1e3;
|
|
1675
|
+
this.maxFilesPerScan = wc.maxFilesPerScan;
|
|
1676
|
+
this.maxCharsPerFile = wc.maxCharsPerFile;
|
|
1677
|
+
} catch {
|
|
1697
1678
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1679
|
+
const remaining = this.getRemainingBudget();
|
|
1680
|
+
if (remaining < 500) return;
|
|
1681
|
+
try {
|
|
1682
|
+
const graph = new ContextGraph(projectPath);
|
|
1683
|
+
const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-HPPBSDXD.js");
|
|
1684
|
+
console.debug("[AI Watcher] Loading active goals...");
|
|
1685
|
+
const activeGoals = await getActiveGoals(projectPath);
|
|
1686
|
+
const hasGoals = activeGoals.length > 0;
|
|
1687
|
+
console.debug("[AI Watcher] Goals loaded:", {
|
|
1688
|
+
totalGoals: activeGoals.length,
|
|
1689
|
+
hasGoals,
|
|
1690
|
+
goals: activeGoals.map((g) => ({ id: g.id, description: g.description, status: g.status }))
|
|
1691
|
+
});
|
|
1692
|
+
if (this.isQuiet() && !hasGoals) return;
|
|
1693
|
+
const scored = [];
|
|
1694
|
+
for (const file of files) {
|
|
1695
|
+
const relativePath = file.replace(projectPath + "/", "");
|
|
1696
|
+
const score = await this.scoreScanPriority(relativePath, graph, projectPath);
|
|
1697
|
+
if (hasGoals || score > 0) {
|
|
1698
|
+
scored.push({ file, relativePath, score: Math.max(score, hasGoals ? 1 : 0) });
|
|
1699
|
+
} else {
|
|
1700
|
+
this.state.tokenBudget.scansSaved++;
|
|
1711
1701
|
}
|
|
1712
|
-
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1702
|
+
}
|
|
1703
|
+
if (scored.length === 0) return;
|
|
1704
|
+
scored.sort((a, b) => b.score - a.score);
|
|
1705
|
+
const budgetScale = remaining > 2e4 ? 1 : remaining > 1e4 ? 0.6 : 0.4;
|
|
1706
|
+
const maxFiles = Math.max(1, Math.round(this.maxFilesPerScan * budgetScale));
|
|
1707
|
+
const filesToScan = scored.slice(0, maxFiles);
|
|
1708
|
+
const charLimit = Math.round(this.maxCharsPerFile * (remaining > 15e3 ? 1 : 0.5));
|
|
1709
|
+
const fileContents = await Promise.all(
|
|
1710
|
+
filesToScan.map(async ({ file, relativePath }) => {
|
|
1711
|
+
try {
|
|
1712
|
+
const content = await readFile3(file, "utf-8");
|
|
1713
|
+
return { path: relativePath, content: content.slice(0, charLimit) };
|
|
1714
|
+
} catch {
|
|
1715
|
+
return null;
|
|
1716
|
+
}
|
|
1717
|
+
})
|
|
1718
|
+
);
|
|
1719
|
+
const valid = fileContents.filter(Boolean);
|
|
1720
|
+
if (valid.length === 0) return;
|
|
1721
|
+
const filesBlock = valid.map(
|
|
1722
|
+
(f) => `### ${f.path}
|
|
1718
1723
|
\`\`\`
|
|
1719
1724
|
${f.content}
|
|
1720
1725
|
\`\`\``
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1726
|
+
).join("\n\n");
|
|
1727
|
+
let goalsSection = "";
|
|
1728
|
+
if (hasGoals) {
|
|
1729
|
+
goalsSection = `
|
|
1725
1730
|
USER-DEFINED GOALS (IMPORTANT - check EVERY file against ALL goals):
|
|
1726
1731
|
${activeGoals.map((g, i) => ` ${i + 1}. "${g.description}"`).join("\n")}
|
|
1727
1732
|
|
|
1728
1733
|
Goal violations are HIGH PRIORITY. If a file violates any goal, you MUST report it.
|
|
1729
1734
|
`;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1735
|
+
}
|
|
1736
|
+
console.debug("[AI Watcher] Sending files to AI analysis:", {
|
|
1737
|
+
fileCount: valid.length,
|
|
1738
|
+
hasGoals,
|
|
1739
|
+
goalsIncluded: hasGoals,
|
|
1740
|
+
filePaths: valid.map((f) => f.path),
|
|
1741
|
+
goalsSection: goalsSection.slice(0, 200) + (goalsSection.length > 200 ? "..." : "")
|
|
1742
|
+
});
|
|
1743
|
+
const result = await runAIAnalysis({
|
|
1744
|
+
systemPrompt: `You are a code quality watcher. You review code for two things:
|
|
1740
1745
|
|
|
1741
1746
|
1. CODE ISSUES: bugs, security vulnerabilities, logic errors, risky patterns
|
|
1742
1747
|
2. GOAL VIOLATIONS: check every file against the user's quality goals
|
|
@@ -1754,163 +1759,161 @@ Be thorough with goal checking. If a goal says "no emojis" and you see an emoji
|
|
|
1754
1759
|
|
|
1755
1760
|
If no issues or violations found, reply with: []
|
|
1756
1761
|
Output ONLY the JSON array, no markdown fences, no commentary.`,
|
|
1757
|
-
|
|
1762
|
+
userPrompt: `Review these changed files:
|
|
1758
1763
|
|
|
1759
1764
|
${filesBlock}`,
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
});
|
|
1763
|
-
if (result.tokensUsed) {
|
|
1764
|
-
this.recordTokenUsage(result.tokensUsed.input + result.tokensUsed.output);
|
|
1765
|
-
}
|
|
1766
|
-
console.debug("[AI Watcher] AI analysis result:", {
|
|
1767
|
-
success: result.success,
|
|
1768
|
-
contentLength: result.content ? result.content.length : 0,
|
|
1769
|
-
tokensUsed: result.tokensUsed,
|
|
1770
|
-
contentPreview: result.content ? result.content.slice(0, 500) : "null"
|
|
1771
|
-
});
|
|
1772
|
-
if (!result.success || !result.content.trim()) {
|
|
1773
|
-
console.debug("[AI Watcher] AI analysis failed or returned empty content");
|
|
1774
|
-
return;
|
|
1775
|
-
}
|
|
1776
|
-
let issues = [];
|
|
1777
|
-
try {
|
|
1778
|
-
const cleaned = result.content.replace(/```json?\n?|\n?```/g, "").trim();
|
|
1779
|
-
console.debug("[AI Watcher] Parsing AI response:", { cleanedContent: cleaned.slice(0, 300) });
|
|
1780
|
-
issues = JSON.parse(cleaned);
|
|
1781
|
-
if (!Array.isArray(issues)) issues = [];
|
|
1782
|
-
console.debug("[AI Watcher] Parsed issues:", {
|
|
1783
|
-
totalIssues: issues.length,
|
|
1784
|
-
goalViolations: issues.filter((i) => i.isGoalViolation).length,
|
|
1785
|
-
issueTypes: issues.map((i) => ({ file: i.file, isGoalViolation: i.isGoalViolation, goalIndex: i.goalIndex }))
|
|
1765
|
+
maxTokens: 2048,
|
|
1766
|
+
temperature: 0.1
|
|
1786
1767
|
});
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
return;
|
|
1790
|
-
}
|
|
1791
|
-
const issuedFiles = new Set(issues.map((i) => i.file));
|
|
1792
|
-
for (const { relativePath } of filesToScan) {
|
|
1793
|
-
if (!issuedFiles.has(relativePath)) {
|
|
1794
|
-
this.state.cleanFiles.set(relativePath, Date.now());
|
|
1768
|
+
if (result.tokensUsed) {
|
|
1769
|
+
this.recordTokenUsage(result.tokensUsed.input + result.tokensUsed.output);
|
|
1795
1770
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
file:
|
|
1816
|
-
line: void 0,
|
|
1817
|
-
agent: "ai-watcher",
|
|
1818
|
-
severity: severity === "critical" ? "critical" : severity === "major" ? "high" : "medium",
|
|
1819
|
-
issue: `Goal "${goal.description}" violated: ${issue.description}`,
|
|
1820
|
-
fix: issue.suggestedFix || "Review and fix",
|
|
1821
|
-
category: "goal-violation",
|
|
1822
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1823
|
-
project: basename2(projectPath),
|
|
1824
|
-
resolved: false,
|
|
1825
|
-
resolvedAt: void 0
|
|
1826
|
-
};
|
|
1827
|
-
await appendIssuesToLedger([ledgerIssue], projectPath);
|
|
1828
|
-
await recordGoalViolationCaught(goal, issue.file, projectPath);
|
|
1829
|
-
const confidenceStr = `${confidence}%`;
|
|
1830
|
-
const nudgeMsg = `Goal "${goal.description}" violated in ${issue.file}: ${issue.description} [${confidenceStr} confidence]`;
|
|
1831
|
-
console.debug("[AI Watcher] Sending nudge:", {
|
|
1832
|
-
message: nudgeMsg,
|
|
1833
|
-
file: issue.file,
|
|
1834
|
-
severity: "warning"
|
|
1835
|
-
});
|
|
1836
|
-
getOutputManager().nudge(nudgeMsg, "warning", issue.file);
|
|
1837
|
-
await this.persistNudge({
|
|
1838
|
-
message: nudgeMsg,
|
|
1839
|
-
severity: "warning",
|
|
1840
|
-
file: issue.file,
|
|
1841
|
-
category: "quality",
|
|
1842
|
-
goalId: goal.id,
|
|
1843
|
-
priority: 7,
|
|
1844
|
-
suggestedAction: issue.suggestedFix || "Review and fix manually",
|
|
1845
|
-
relatedIssues: [fixId]
|
|
1771
|
+
console.debug("[AI Watcher] AI analysis result:", {
|
|
1772
|
+
success: result.success,
|
|
1773
|
+
contentLength: result.content ? result.content.length : 0,
|
|
1774
|
+
tokensUsed: result.tokensUsed,
|
|
1775
|
+
contentPreview: result.content ? result.content.slice(0, 500) : "null"
|
|
1776
|
+
});
|
|
1777
|
+
if (!result.success || !result.content.trim()) {
|
|
1778
|
+
console.debug("[AI Watcher] AI analysis failed or returned empty content");
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
let issues = [];
|
|
1782
|
+
try {
|
|
1783
|
+
const cleaned = result.content.replace(/```json?\n?|\n?```/g, "").trim();
|
|
1784
|
+
console.debug("[AI Watcher] Parsing AI response:", { cleanedContent: cleaned.slice(0, 300) });
|
|
1785
|
+
issues = JSON.parse(cleaned);
|
|
1786
|
+
if (!Array.isArray(issues)) issues = [];
|
|
1787
|
+
console.debug("[AI Watcher] Parsed issues:", {
|
|
1788
|
+
totalIssues: issues.length,
|
|
1789
|
+
goalViolations: issues.filter((i) => i.isGoalViolation).length,
|
|
1790
|
+
issueTypes: issues.map((i) => ({ file: i.file, isGoalViolation: i.isGoalViolation, goalIndex: i.goalIndex }))
|
|
1846
1791
|
});
|
|
1847
|
-
|
|
1848
|
-
|
|
1792
|
+
} catch (error) {
|
|
1793
|
+
console.debug("[AI Watcher] Failed to parse AI response:", error);
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
const issuedFiles = new Set(issues.map((i) => i.file));
|
|
1797
|
+
for (const { relativePath } of filesToScan) {
|
|
1798
|
+
if (!issuedFiles.has(relativePath)) {
|
|
1799
|
+
this.state.cleanFiles.set(relativePath, Date.now());
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
if (issues.length === 0) return;
|
|
1803
|
+
for (const issue of issues.slice(0, 10)) {
|
|
1804
|
+
const severity = issue.severity === "critical" ? "critical" : issue.severity === "major" ? "major" : "minor";
|
|
1805
|
+
if (issue.isGoalViolation && issue.goalIndex != null && issue.goalIndex >= 0 && issue.goalIndex < activeGoals.length) {
|
|
1806
|
+
const goal = activeGoals[issue.goalIndex];
|
|
1807
|
+
if (!goal) continue;
|
|
1808
|
+
const confidence = Math.min(100, Math.max(0, issue.confidence ?? 80));
|
|
1809
|
+
const fixId = `fix-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1810
|
+
console.debug("[AI Watcher] Goal violation detected:", {
|
|
1811
|
+
goalDescription: goal.description,
|
|
1812
|
+
file: issue.file,
|
|
1813
|
+
violation: issue.description,
|
|
1814
|
+
confidence,
|
|
1815
|
+
goalIndex: issue.goalIndex,
|
|
1816
|
+
totalActiveGoals: activeGoals.length
|
|
1817
|
+
});
|
|
1818
|
+
const goalViolationIssue = {
|
|
1849
1819
|
id: fixId,
|
|
1850
1820
|
file: issue.file,
|
|
1851
|
-
|
|
1852
|
-
|
|
1821
|
+
agent: "goal-violation",
|
|
1822
|
+
severity: severity === "critical" ? "critical" : severity === "major" ? "serious" : "moderate",
|
|
1823
|
+
issue: `Goal "${goal.description}" violated: ${issue.description}`,
|
|
1824
|
+
fix: issue.suggestedFix || "Review and fix",
|
|
1825
|
+
category: "goal-violation",
|
|
1853
1826
|
confidence,
|
|
1854
|
-
|
|
1855
|
-
|
|
1827
|
+
autoFixable: true
|
|
1828
|
+
};
|
|
1829
|
+
await storeIssues([goalViolationIssue], basename2(projectPath), projectPath);
|
|
1830
|
+
await recordGoalViolationCaught(goal, issue.file, projectPath);
|
|
1831
|
+
const confidenceStr = `${confidence}%`;
|
|
1832
|
+
const nudgeMsg = `Goal "${goal.description}" violated in ${issue.file}: ${issue.description} [${confidenceStr} confidence]`;
|
|
1833
|
+
console.debug("[AI Watcher] Sending nudge:", {
|
|
1834
|
+
message: nudgeMsg,
|
|
1835
|
+
file: issue.file,
|
|
1836
|
+
severity: "warning"
|
|
1856
1837
|
});
|
|
1838
|
+
getOutputManager().nudge(nudgeMsg, "warning", issue.file);
|
|
1839
|
+
await this.persistNudge({
|
|
1840
|
+
message: nudgeMsg,
|
|
1841
|
+
severity: "warning",
|
|
1842
|
+
file: issue.file,
|
|
1843
|
+
category: "quality",
|
|
1844
|
+
goalId: goal.id,
|
|
1845
|
+
priority: 7,
|
|
1846
|
+
suggestedAction: issue.suggestedFix || "Review and fix manually",
|
|
1847
|
+
relatedIssues: [fixId]
|
|
1848
|
+
});
|
|
1849
|
+
if (this.streamingManager) {
|
|
1850
|
+
this.streamingManager.reportPendingFix({
|
|
1851
|
+
id: fixId,
|
|
1852
|
+
file: issue.file,
|
|
1853
|
+
description: issue.description,
|
|
1854
|
+
goalDescription: goal.description,
|
|
1855
|
+
confidence,
|
|
1856
|
+
severity: issue.severity,
|
|
1857
|
+
suggestedFix: issue.suggestedFix || "Remove the violating code"
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
if (!isInteractiveMode()) {
|
|
1861
|
+
console.error(` [!] Goal violation (${confidenceStr}): ${issue.description}`);
|
|
1862
|
+
console.error(` Fix: ${issue.suggestedFix || "Review and fix manually"}`);
|
|
1863
|
+
}
|
|
1864
|
+
continue;
|
|
1857
1865
|
}
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
duration: null,
|
|
1869
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1870
|
-
resolved: false,
|
|
1871
|
-
resolution: null,
|
|
1872
|
-
fixChangeId: null,
|
|
1873
|
-
reportedVia: "detected"
|
|
1874
|
-
});
|
|
1875
|
-
const filePath = join2(projectPath, issue.file);
|
|
1876
|
-
const fileNode = await graph.getNode("file", filePath);
|
|
1877
|
-
if (fileNode) {
|
|
1878
|
-
await graph.addEdge(fileNode.id, incident.id, "affects");
|
|
1879
|
-
const data = fileNode.data;
|
|
1880
|
-
const newRisk = severity === "critical" ? "critical" : severity === "major" ? "high" : data.riskLevel === "low" ? "medium" : data.riskLevel;
|
|
1881
|
-
await graph.updateNode("file", fileNode.id, {
|
|
1882
|
-
incidentCount: (data.incidentCount ?? 0) + 1,
|
|
1883
|
-
riskLevel: newRisk
|
|
1866
|
+
const incident = await graph.addNode("incident", {
|
|
1867
|
+
description: issue.description,
|
|
1868
|
+
severity,
|
|
1869
|
+
affectedUsers: null,
|
|
1870
|
+
duration: null,
|
|
1871
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1872
|
+
resolved: false,
|
|
1873
|
+
resolution: null,
|
|
1874
|
+
fixChangeId: null,
|
|
1875
|
+
reportedVia: "detected"
|
|
1884
1876
|
});
|
|
1877
|
+
const filePath = join2(projectPath, issue.file);
|
|
1878
|
+
const fileNode = await graph.getNode("file", filePath);
|
|
1879
|
+
if (fileNode) {
|
|
1880
|
+
await graph.addEdge(fileNode.id, incident.id, "affects");
|
|
1881
|
+
const data = fileNode.data;
|
|
1882
|
+
const newRisk = severity === "critical" ? "critical" : severity === "major" ? "high" : data.riskLevel === "low" ? "medium" : data.riskLevel;
|
|
1883
|
+
await graph.updateNode("file", fileNode.id, {
|
|
1884
|
+
incidentCount: (data.incidentCount ?? 0) + 1,
|
|
1885
|
+
riskLevel: newRisk
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
this.state.totalIssuesFound++;
|
|
1889
|
+
if (severity !== "minor") {
|
|
1890
|
+
getOutputManager().nudge(
|
|
1891
|
+
`${issue.description}`,
|
|
1892
|
+
severity === "critical" ? "critical" : "warning",
|
|
1893
|
+
issue.file,
|
|
1894
|
+
severity === "critical" ? void 0 : 15e3
|
|
1895
|
+
);
|
|
1896
|
+
await this.persistNudge({
|
|
1897
|
+
message: issue.description,
|
|
1898
|
+
severity: severity === "critical" ? "critical" : "warning",
|
|
1899
|
+
file: issue.file,
|
|
1900
|
+
category: "quality",
|
|
1901
|
+
priority: severity === "critical" ? 9 : 6,
|
|
1902
|
+
...issue.suggestedFix && { suggestedAction: issue.suggestedFix }
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1885
1905
|
}
|
|
1886
|
-
this.
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
severity === "critical" ? void 0 : 15e3
|
|
1893
|
-
);
|
|
1894
|
-
await this.persistNudge({
|
|
1895
|
-
message: issue.description,
|
|
1896
|
-
severity: severity === "critical" ? "critical" : "warning",
|
|
1897
|
-
file: issue.file,
|
|
1898
|
-
category: "quality",
|
|
1899
|
-
priority: severity === "critical" ? 9 : 6,
|
|
1900
|
-
...issue.suggestedFix && { suggestedAction: issue.suggestedFix }
|
|
1906
|
+
if (this.streamingManager && issues.length > 0) {
|
|
1907
|
+
this.streamingManager.reportSignalExtraction({
|
|
1908
|
+
decisions: 0,
|
|
1909
|
+
facts: 0,
|
|
1910
|
+
blockers: issues.length,
|
|
1911
|
+
questions: 0
|
|
1901
1912
|
});
|
|
1902
1913
|
}
|
|
1914
|
+
} catch (error) {
|
|
1915
|
+
getOutputManager().log("warn", `AI watcher error: ${error}`);
|
|
1903
1916
|
}
|
|
1904
|
-
if (this.streamingManager && issues.length > 0) {
|
|
1905
|
-
this.streamingManager.reportSignalExtraction({
|
|
1906
|
-
decisions: 0,
|
|
1907
|
-
facts: 0,
|
|
1908
|
-
blockers: issues.length,
|
|
1909
|
-
questions: 0
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
|
-
} catch (error) {
|
|
1913
|
-
getOutputManager().log("warn", `AI watcher error: ${error}`);
|
|
1914
1917
|
} finally {
|
|
1915
1918
|
this.state.autoScanInProgress = false;
|
|
1916
1919
|
}
|
|
@@ -1929,7 +1932,7 @@ ${filesBlock}`,
|
|
|
1929
1932
|
const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
|
|
1930
1933
|
console.debug("[Initial Hypothesis] Starting initial hypothesis generation", { projectPath });
|
|
1931
1934
|
try {
|
|
1932
|
-
const { getHypothesisEngine } = await import("./hypothesis-
|
|
1935
|
+
const { getHypothesisEngine } = await import("./hypothesis-W37VG6DA.js");
|
|
1933
1936
|
const hypothesisEngine = getHypothesisEngine(projectPath);
|
|
1934
1937
|
console.debug("[Initial Hypothesis] Running AI-powered hypothesis generation...");
|
|
1935
1938
|
const generated = await hypothesisEngine.generateHypothesesWithAI({
|
|
@@ -1943,7 +1946,7 @@ ${filesBlock}`,
|
|
|
1943
1946
|
hypotheses: generated.map((h) => ({ statement: h.statement, confidence: h.confidence }))
|
|
1944
1947
|
});
|
|
1945
1948
|
if (generated.length > 0) {
|
|
1946
|
-
const { getOutputManager: getOutputManager2 } = await import("./output-manager-
|
|
1949
|
+
const { getOutputManager: getOutputManager2 } = await import("./output-manager-DZO5LGSG.js");
|
|
1947
1950
|
const outputManager = getOutputManager2();
|
|
1948
1951
|
for (const hypothesis of generated.slice(0, 2)) {
|
|
1949
1952
|
const message = `[Initial Hypothesis] "${hypothesis.statement}" (${Math.round(hypothesis.confidence * 100)}% confidence)`;
|
|
@@ -1987,7 +1990,7 @@ ${filesBlock}`,
|
|
|
1987
1990
|
const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
|
|
1988
1991
|
console.debug("[Initial Scan] Starting initial goal compliance scan", { projectPath });
|
|
1989
1992
|
try {
|
|
1990
|
-
const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-
|
|
1993
|
+
const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-HPPBSDXD.js");
|
|
1991
1994
|
const activeGoals = await getActiveGoals(projectPath);
|
|
1992
1995
|
console.debug("[Initial Scan] Loaded goals for initial scan:", {
|
|
1993
1996
|
goalCount: activeGoals.length,
|
|
@@ -2089,22 +2092,26 @@ ${filesBlock}`,
|
|
|
2089
2092
|
} catch {
|
|
2090
2093
|
return;
|
|
2091
2094
|
}
|
|
2092
|
-
const
|
|
2093
|
-
const issuesForLedger = [];
|
|
2095
|
+
const issuesToStore = [];
|
|
2094
2096
|
let violationsFound = 0;
|
|
2095
2097
|
for (const issue of issues) {
|
|
2096
2098
|
if (!issue.isGoalViolation || issue.confidence < 40) continue;
|
|
2097
2099
|
violationsFound++;
|
|
2098
|
-
issuesForLedger.push({
|
|
2099
|
-
file: issue.file,
|
|
2100
|
-
message: issue.description,
|
|
2101
|
-
severity: issue.severity,
|
|
2102
|
-
confidence: issue.confidence,
|
|
2103
|
-
category: "goal-violation",
|
|
2104
|
-
suggestedFix: issue.suggestedFix
|
|
2105
|
-
});
|
|
2106
2100
|
if (issue.goalIndex != null && issue.goalIndex >= 0 && issue.goalIndex < activeGoals.length) {
|
|
2107
2101
|
const goal = activeGoals[issue.goalIndex];
|
|
2102
|
+
if (!goal) continue;
|
|
2103
|
+
const fixId = `fix-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2104
|
+
issuesToStore.push({
|
|
2105
|
+
id: fixId,
|
|
2106
|
+
file: issue.file,
|
|
2107
|
+
agent: "goal-violation",
|
|
2108
|
+
severity: issue.severity === "critical" ? "critical" : issue.severity === "major" ? "serious" : "moderate",
|
|
2109
|
+
issue: `Goal "${goal.description}" violated: ${issue.description}`,
|
|
2110
|
+
fix: issue.suggestedFix || "Review and fix",
|
|
2111
|
+
category: "goal-violation",
|
|
2112
|
+
confidence: issue.confidence,
|
|
2113
|
+
autoFixable: true
|
|
2114
|
+
});
|
|
2108
2115
|
await recordGoalViolationCaught(goal, issue.file, projectPath);
|
|
2109
2116
|
const confidenceStr = issue.confidence >= 80 ? "high" : issue.confidence >= 60 ? "medium" : "low";
|
|
2110
2117
|
const nudgeMsg = `Goal "${goal.description}" violated in ${issue.file}: ${issue.description} [${confidenceStr} confidence]`;
|
|
@@ -2120,8 +2127,8 @@ ${filesBlock}`,
|
|
|
2120
2127
|
});
|
|
2121
2128
|
}
|
|
2122
2129
|
}
|
|
2123
|
-
if (
|
|
2124
|
-
await
|
|
2130
|
+
if (issuesToStore.length > 0) {
|
|
2131
|
+
await storeIssues(issuesToStore, basename2(projectPath), projectPath);
|
|
2125
2132
|
}
|
|
2126
2133
|
if (!isInteractiveMode()) {
|
|
2127
2134
|
if (violationsFound > 0) {
|
|
@@ -2145,7 +2152,7 @@ ${filesBlock}`,
|
|
|
2145
2152
|
}]
|
|
2146
2153
|
};
|
|
2147
2154
|
}
|
|
2148
|
-
for (const
|
|
2155
|
+
for (const watcher of this.watchers.values()) {
|
|
2149
2156
|
watcher.close();
|
|
2150
2157
|
}
|
|
2151
2158
|
this.watchers.clear();
|
|
@@ -2212,8 +2219,8 @@ Use \`trie_watch start\` to begin autonomous scanning.`
|
|
|
2212
2219
|
).join("\n");
|
|
2213
2220
|
let agencyStatus = "";
|
|
2214
2221
|
try {
|
|
2215
|
-
const {
|
|
2216
|
-
const trieAgent =
|
|
2222
|
+
const { getTrieAgent } = await import("./guardian-agent-YKG5XURG.js");
|
|
2223
|
+
const trieAgent = getTrieAgent(this.watchedDirectory || getWorkingDirectory(void 0, true));
|
|
2217
2224
|
await trieAgent.initialize();
|
|
2218
2225
|
const status = await trieAgent.getAgencyStatus();
|
|
2219
2226
|
agencyStatus = `
|
|
@@ -3313,9 +3320,9 @@ var TrieMemorySearchTool = class {
|
|
|
3313
3320
|
}
|
|
3314
3321
|
}
|
|
3315
3322
|
if (projects.length > 0) {
|
|
3316
|
-
lines.push("## Recent Projects", "", "| Project |
|
|
3323
|
+
lines.push("## Recent Projects", "", "| Project | Issues |", "|---------|--------|");
|
|
3317
3324
|
for (const p of projects.slice(0, 5)) {
|
|
3318
|
-
lines.push(`| ${p.name} | ${p.
|
|
3325
|
+
lines.push(`| ${p.name} | ${p.totalIssues} |`);
|
|
3319
3326
|
}
|
|
3320
3327
|
}
|
|
3321
3328
|
return lines.join("\n");
|
|
@@ -4251,7 +4258,7 @@ var ResourceManager = class {
|
|
|
4251
4258
|
{
|
|
4252
4259
|
uri: "trie://skills/installed",
|
|
4253
4260
|
name: "Installed Skills",
|
|
4254
|
-
description: "External skills installed from skills.sh that
|
|
4261
|
+
description: "External skills installed from skills.sh that Trie can apply",
|
|
4255
4262
|
mimeType: "application/json"
|
|
4256
4263
|
},
|
|
4257
4264
|
{
|
|
@@ -4524,7 +4531,6 @@ var ResourceManager = class {
|
|
|
4524
4531
|
"",
|
|
4525
4532
|
`| Metric | Value |`,
|
|
4526
4533
|
`|--------|-------|`,
|
|
4527
|
-
`| Health Score | ${state.healthScore}% |`,
|
|
4528
4534
|
`| Last Scan | ${state.lastScan ? new Date(state.lastScan.timestamp).toLocaleDateString() : "Never"} |`,
|
|
4529
4535
|
`| Critical Issues | ${state.lastScan?.issues.critical ?? 0} |`,
|
|
4530
4536
|
`| Total Issues | ${state.lastScan?.issues.total ?? 0} |`,
|
|
@@ -5558,7 +5564,7 @@ var MCPServer = class {
|
|
|
5558
5564
|
\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D
|
|
5559
5565
|
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
5560
5566
|
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
5561
|
-
Your central registry for
|
|
5567
|
+
Your central registry for Trie and its skills
|
|
5562
5568
|
|
|
5563
5569
|
by Louis Kishfy
|
|
5564
5570
|
|