@triedotdev/mcp 1.0.166 → 1.0.167
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/README.md +337 -801
- package/dist/chunk-2HF65EHQ.js +311 -0
- package/dist/chunk-2HF65EHQ.js.map +1 -0
- package/dist/{chunk-JNUOW2JS.js → chunk-4MXH2ZPT.js} +12 -12
- package/dist/chunk-4MXH2ZPT.js.map +1 -0
- package/dist/{chunk-LR5M4RTN.js → chunk-575YT2SD.js} +1 -1
- package/dist/chunk-575YT2SD.js.map +1 -0
- package/dist/{chunk-ZKKKLRZZ.js → chunk-5BRRRTN6.js} +4 -4
- package/dist/{chunk-TQOO6A4G.js → chunk-7WITSO22.js} +3 -3
- package/dist/{chunk-ACU2RJUJ.js → chunk-F6WFNUAY.js} +2 -2
- package/dist/{chunk-VR4VWXXU.js → chunk-G2TGF6TR.js} +9 -2
- package/dist/chunk-G2TGF6TR.js.map +1 -0
- package/dist/{chunk-ZBXW244P.js → chunk-HVCDY3AK.js} +3 -3
- package/dist/chunk-HVCDY3AK.js.map +1 -0
- package/dist/{chunk-HOGKPDZA.js → chunk-LQIMKE3P.js} +678 -151
- package/dist/chunk-LQIMKE3P.js.map +1 -0
- package/dist/{chunk-2Z3TQNNK.js → chunk-MRHKX5M5.js} +3 -3
- package/dist/{chunk-OLNZJ3XV.js → chunk-Q63FFI6D.js} +2 -2
- package/dist/{chunk-S36IO3EE.js → chunk-XE6KQRKZ.js} +9 -8
- package/dist/chunk-XE6KQRKZ.js.map +1 -0
- package/dist/{chunk-GDWA3CH3.js → chunk-XPZZFPBZ.js} +30 -6
- package/dist/chunk-XPZZFPBZ.js.map +1 -0
- package/dist/{chunk-JEZ7XJQN.js → chunk-XTFWT2XM.js} +2 -2
- package/dist/{chunk-UXRW2YSP.js → chunk-YDHUCDHM.js} +18 -112
- package/dist/chunk-YDHUCDHM.js.map +1 -0
- package/dist/{chunk-LG5CBK6A.js → chunk-YZ6Y2H3P.js} +21 -196
- package/dist/chunk-YZ6Y2H3P.js.map +1 -0
- package/dist/{chunk-MVVPJ73K.js → chunk-ZJF5FTBX.js} +126 -358
- package/dist/chunk-ZJF5FTBX.js.map +1 -0
- package/dist/cli/create-agent.js +1 -1
- package/dist/cli/create-agent.js.map +1 -1
- package/dist/cli/main.js +194 -849
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +15 -14
- package/dist/cli/yolo-daemon.js.map +1 -1
- package/dist/{fast-analyzer-NJQO3TFD.js → fast-analyzer-XXYMOXRK.js} +3 -3
- package/dist/git-EO5SRFMN.js +28 -0
- package/dist/{github-ingester-TFBDUDIY.js → github-ingester-ZOKK6GRS.js} +3 -3
- package/dist/{goal-manager-DVX24UPZ.js → goal-manager-YOB7VWK7.js} +5 -4
- package/dist/{goal-validator-6Y5CDEMJ.js → goal-validator-ULKIBDPX.js} +5 -4
- package/dist/{hypothesis-UKPGOYY2.js → hypothesis-7BFFT5JY.js} +5 -4
- package/dist/index.js +19 -18
- package/dist/index.js.map +1 -1
- package/dist/{issue-store-UZAPI5DU.js → issue-store-ZIRP23EP.js} +4 -3
- package/dist/{ledger-CNFCJKHX.js → ledger-TWZTGDFA.js} +3 -2
- package/dist/{linear-ingester-PLES2BRS.js → linear-ingester-XXPAZZRW.js} +3 -3
- package/dist/{output-manager-JNMEAXFO.js → output-manager-RVJ37XKA.js} +2 -2
- package/dist/server/mcp-server.js +19 -18
- package/dist/{tiered-storage-OP74NPJY.js → tiered-storage-Z3YCR465.js} +2 -2
- package/dist/{trie-agent-6SWUHCVO.js → trie-agent-3YDPEGHJ.js} +9 -8
- package/dist/trie-agent-3YDPEGHJ.js.map +1 -0
- package/package.json +3 -2
- package/dist/chunk-GDWA3CH3.js.map +0 -1
- package/dist/chunk-HOGKPDZA.js.map +0 -1
- package/dist/chunk-JNUOW2JS.js.map +0 -1
- package/dist/chunk-LG5CBK6A.js.map +0 -1
- package/dist/chunk-LR5M4RTN.js.map +0 -1
- package/dist/chunk-MVVPJ73K.js.map +0 -1
- package/dist/chunk-S36IO3EE.js.map +0 -1
- package/dist/chunk-UXRW2YSP.js.map +0 -1
- package/dist/chunk-VR4VWXXU.js.map +0 -1
- package/dist/chunk-ZBXW244P.js.map +0 -1
- /package/dist/{chunk-ZKKKLRZZ.js.map → chunk-5BRRRTN6.js.map} +0 -0
- /package/dist/{chunk-TQOO6A4G.js.map → chunk-7WITSO22.js.map} +0 -0
- /package/dist/{chunk-ACU2RJUJ.js.map → chunk-F6WFNUAY.js.map} +0 -0
- /package/dist/{chunk-2Z3TQNNK.js.map → chunk-MRHKX5M5.js.map} +0 -0
- /package/dist/{chunk-OLNZJ3XV.js.map → chunk-Q63FFI6D.js.map} +0 -0
- /package/dist/{chunk-JEZ7XJQN.js.map → chunk-XTFWT2XM.js.map} +0 -0
- /package/dist/{fast-analyzer-NJQO3TFD.js.map → fast-analyzer-XXYMOXRK.js.map} +0 -0
- /package/dist/{github-ingester-TFBDUDIY.js.map → git-EO5SRFMN.js.map} +0 -0
- /package/dist/{goal-manager-DVX24UPZ.js.map → github-ingester-ZOKK6GRS.js.map} +0 -0
- /package/dist/{goal-validator-6Y5CDEMJ.js.map → goal-manager-YOB7VWK7.js.map} +0 -0
- /package/dist/{hypothesis-UKPGOYY2.js.map → goal-validator-ULKIBDPX.js.map} +0 -0
- /package/dist/{issue-store-UZAPI5DU.js.map → hypothesis-7BFFT5JY.js.map} +0 -0
- /package/dist/{ledger-CNFCJKHX.js.map → issue-store-ZIRP23EP.js.map} +0 -0
- /package/dist/{linear-ingester-PLES2BRS.js.map → ledger-TWZTGDFA.js.map} +0 -0
- /package/dist/{output-manager-JNMEAXFO.js.map → linear-ingester-XXPAZZRW.js.map} +0 -0
- /package/dist/{tiered-storage-OP74NPJY.js.map → output-manager-RVJ37XKA.js.map} +0 -0
- /package/dist/{trie-agent-6SWUHCVO.js.map → tiered-storage-Z3YCR465.js.map} +0 -0
|
@@ -1,54 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodebaseIndex
|
|
3
|
+
} from "./chunk-Q5EKA5YA.js";
|
|
1
4
|
import {
|
|
2
5
|
getChatStore
|
|
3
6
|
} from "./chunk-JVMBCWKS.js";
|
|
4
7
|
import {
|
|
5
8
|
getTrieAgent
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4MXH2ZPT.js";
|
|
7
10
|
import {
|
|
8
11
|
parseGoalViolation
|
|
9
12
|
} from "./chunk-WCN7S3EI.js";
|
|
10
|
-
import {
|
|
11
|
-
CodebaseIndex
|
|
12
|
-
} from "./chunk-Q5EKA5YA.js";
|
|
13
13
|
import {
|
|
14
14
|
getOutputManager
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-G2TGF6TR.js";
|
|
16
16
|
import {
|
|
17
17
|
getInsightStore
|
|
18
18
|
} from "./chunk-T63OHG4Q.js";
|
|
19
19
|
import {
|
|
20
20
|
LearningEngine,
|
|
21
21
|
formatFriendlyError,
|
|
22
|
-
getLastCheckpoint,
|
|
23
22
|
isTrieInitialized,
|
|
24
|
-
listCheckpoints,
|
|
25
23
|
perceiveCurrentChanges,
|
|
26
|
-
reasonAboutChangesHumanReadable
|
|
27
|
-
|
|
28
|
-
} from "./chunk-LG5CBK6A.js";
|
|
24
|
+
reasonAboutChangesHumanReadable
|
|
25
|
+
} from "./chunk-YZ6Y2H3P.js";
|
|
29
26
|
import {
|
|
30
27
|
measureInitialGoalValue
|
|
31
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-5BRRRTN6.js";
|
|
32
29
|
import {
|
|
33
30
|
exportToJson
|
|
34
31
|
} from "./chunk-OBQ74FOU.js";
|
|
35
32
|
import {
|
|
36
33
|
loadConfig,
|
|
37
34
|
saveConfig
|
|
38
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XPZZFPBZ.js";
|
|
39
36
|
import {
|
|
40
37
|
IncidentIndex
|
|
41
38
|
} from "./chunk-TN5WEKWI.js";
|
|
42
39
|
import {
|
|
43
40
|
findCrossProjectPatterns
|
|
44
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-7WITSO22.js";
|
|
45
42
|
import {
|
|
46
43
|
ContextGraph
|
|
47
44
|
} from "./chunk-VUL52BQL.js";
|
|
48
45
|
import {
|
|
49
46
|
TieredStorage,
|
|
50
47
|
getStorage
|
|
51
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-575YT2SD.js";
|
|
52
49
|
import {
|
|
53
50
|
getKeyFromKeychain,
|
|
54
51
|
isAIAvailable,
|
|
@@ -57,25 +54,27 @@ import {
|
|
|
57
54
|
setAPIKey
|
|
58
55
|
} from "./chunk-FQ45QP5A.js";
|
|
59
56
|
import {
|
|
57
|
+
getRecentIssues,
|
|
60
58
|
storeIssues
|
|
61
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-XE6KQRKZ.js";
|
|
60
|
+
import {
|
|
61
|
+
generateKeyPair,
|
|
62
|
+
getLedgerBlocks,
|
|
63
|
+
getPublicKey,
|
|
64
|
+
hasSigningKey,
|
|
65
|
+
saveKeyPair
|
|
66
|
+
} from "./chunk-ZJF5FTBX.js";
|
|
62
67
|
import {
|
|
63
68
|
getProjectState
|
|
64
69
|
} from "./chunk-GTKYBOXL.js";
|
|
70
|
+
import {
|
|
71
|
+
atomicWriteJSON
|
|
72
|
+
} from "./chunk-43X6JBEM.js";
|
|
65
73
|
import {
|
|
66
74
|
getAutonomyConfig,
|
|
67
75
|
loadAutonomyConfig,
|
|
68
76
|
saveAutonomyConfig
|
|
69
77
|
} from "./chunk-ME2OERF5.js";
|
|
70
|
-
import {
|
|
71
|
-
generateKeyPair,
|
|
72
|
-
getChangedFilesSinceTimestamp,
|
|
73
|
-
getGitChangedFiles,
|
|
74
|
-
getLedgerBlocks,
|
|
75
|
-
getPublicKey,
|
|
76
|
-
hasSigningKey,
|
|
77
|
-
saveKeyPair
|
|
78
|
-
} from "./chunk-MVVPJ73K.js";
|
|
79
78
|
import {
|
|
80
79
|
getTrieDirectory,
|
|
81
80
|
getWorkingDirectory
|
|
@@ -83,6 +82,10 @@ import {
|
|
|
83
82
|
import {
|
|
84
83
|
isInteractiveMode
|
|
85
84
|
} from "./chunk-KDHN2ZQE.js";
|
|
85
|
+
import {
|
|
86
|
+
getChangedFilesSinceTimestamp,
|
|
87
|
+
getGitChangedFiles
|
|
88
|
+
} from "./chunk-2HF65EHQ.js";
|
|
86
89
|
|
|
87
90
|
// src/utils/streaming.ts
|
|
88
91
|
var shouldSuppressConsole = () => isInteractiveMode();
|
|
@@ -2060,7 +2063,7 @@ function AgentView() {
|
|
|
2060
2063
|
const { getInsightStore: getInsightStore2 } = await import("./insight-store-EC4PLSAW.js");
|
|
2061
2064
|
const store = getInsightStore2(workDir);
|
|
2062
2065
|
await store.dismissInsight(insight.id);
|
|
2063
|
-
const { getStorage: getStorage2 } = await import("./tiered-storage-
|
|
2066
|
+
const { getStorage: getStorage2 } = await import("./tiered-storage-Z3YCR465.js");
|
|
2064
2067
|
const storage = getStorage2(workDir);
|
|
2065
2068
|
await storage.dismissNudge(insight.id).catch(() => {
|
|
2066
2069
|
});
|
|
@@ -2072,7 +2075,7 @@ function AgentView() {
|
|
|
2072
2075
|
const clearAllNudges = useCallback(async () => {
|
|
2073
2076
|
try {
|
|
2074
2077
|
const workDir = getWorkingDirectory(void 0, true);
|
|
2075
|
-
const { getStorage: getStorage2 } = await import("./tiered-storage-
|
|
2078
|
+
const { getStorage: getStorage2 } = await import("./tiered-storage-Z3YCR465.js");
|
|
2076
2079
|
const storage = getStorage2(workDir);
|
|
2077
2080
|
await storage.clearAllNudges();
|
|
2078
2081
|
dispatch({ type: "CLEAR_ALL_INSIGHTS" });
|
|
@@ -2446,7 +2449,7 @@ function GoalsView() {
|
|
|
2446
2449
|
dispatch({ type: "SET_GOAL_SCANNING", goalId, progress: "Starting scan..." });
|
|
2447
2450
|
dispatch({ type: "ADD_ACTIVITY", message: `Scanning goal: ${goalSummary.description}...` });
|
|
2448
2451
|
dispatch({ type: "SET_GOAL_SCANNING", goalId, progress: "Loading goal configuration..." });
|
|
2449
|
-
const { checkFilesForGoalViolations } = await import("./goal-validator-
|
|
2452
|
+
const { checkFilesForGoalViolations } = await import("./goal-validator-ULKIBDPX.js");
|
|
2450
2453
|
const agentState = getProjectState(workDir);
|
|
2451
2454
|
await agentState.load();
|
|
2452
2455
|
const fullGoal = agentState.getAllGoals().find((g) => g.id === goalId);
|
|
@@ -2721,7 +2724,7 @@ function HypothesesView() {
|
|
|
2721
2724
|
dispatch({ type: "SET_HYPOTHESIS_SCANNING", hypothesisId: hypoId, progress: "Gathering evidence..." });
|
|
2722
2725
|
dispatch({ type: "ADD_ACTIVITY", message: `Testing hypothesis: ${hypo.statement}` });
|
|
2723
2726
|
dispatch({ type: "SHOW_NOTIFICATION", message: `Gathering evidence for hypothesis...`, severity: "info", autoHideMs: 3e3 });
|
|
2724
|
-
const { gatherEvidenceForHypothesis } = await import("./hypothesis-
|
|
2727
|
+
const { gatherEvidenceForHypothesis } = await import("./hypothesis-7BFFT5JY.js");
|
|
2725
2728
|
const evidence = await gatherEvidenceForHypothesis(hypoId, workDir, signal);
|
|
2726
2729
|
scanAbortRef.current = null;
|
|
2727
2730
|
dispatch({ type: "SET_HYPOTHESIS_SCANNING", hypothesisId: null, progress: "" });
|
|
@@ -6477,7 +6480,7 @@ ${"\u2501".repeat(60)}
|
|
|
6477
6480
|
|
|
6478
6481
|
`;
|
|
6479
6482
|
if (pendingFixes.size === 0) {
|
|
6480
|
-
output += `No pending fixes. Run \`
|
|
6483
|
+
output += `No pending fixes. Run \`trie watch\` or \`trie check\` first to detect issues.
|
|
6481
6484
|
`;
|
|
6482
6485
|
return { content: [{ type: "text", text: output }] };
|
|
6483
6486
|
}
|
|
@@ -6602,9 +6605,9 @@ function getPendingFixes() {
|
|
|
6602
6605
|
}
|
|
6603
6606
|
async function loadPendingFixesFromMemory() {
|
|
6604
6607
|
try {
|
|
6605
|
-
const { getRecentIssues } = await import("./issue-store-
|
|
6608
|
+
const { getRecentIssues: getRecentIssues2 } = await import("./issue-store-ZIRP23EP.js");
|
|
6606
6609
|
pendingFixes.clear();
|
|
6607
|
-
const recentIssues = await
|
|
6610
|
+
const recentIssues = await getRecentIssues2({ limit: 50, includeResolved: false });
|
|
6608
6611
|
for (const storedIssue of recentIssues) {
|
|
6609
6612
|
const fix = {
|
|
6610
6613
|
id: storedIssue.id,
|
|
@@ -6905,8 +6908,8 @@ var TrieCloudFixTool = class {
|
|
|
6905
6908
|
if (pending.length === 0) {
|
|
6906
6909
|
try {
|
|
6907
6910
|
console.log("Loading issues from memory...");
|
|
6908
|
-
const { getRecentIssues } = await import("./issue-store-
|
|
6909
|
-
const recentIssues = await
|
|
6911
|
+
const { getRecentIssues: getRecentIssues2 } = await import("./issue-store-ZIRP23EP.js");
|
|
6912
|
+
const recentIssues = await getRecentIssues2({ limit: 50, includeResolved: false });
|
|
6910
6913
|
console.log(`Found ${recentIssues.length} recent issues in memory`);
|
|
6911
6914
|
const memoryIssues = recentIssues.map((storedIssue) => ({
|
|
6912
6915
|
id: storedIssue.id,
|
|
@@ -7211,7 +7214,7 @@ var TrieGetNudgesTool = class {
|
|
|
7211
7214
|
return {
|
|
7212
7215
|
content: [{
|
|
7213
7216
|
type: "text",
|
|
7214
|
-
text: "No unresolved nudges (goal violations) found. Run trie
|
|
7217
|
+
text: "No unresolved nudges (goal violations) found. Run `trie watch` to detect issues as you code."
|
|
7215
7218
|
}]
|
|
7216
7219
|
};
|
|
7217
7220
|
}
|
|
@@ -7505,64 +7508,6 @@ var TrieQueryLedgerBlocksTool = class {
|
|
|
7505
7508
|
}
|
|
7506
7509
|
};
|
|
7507
7510
|
|
|
7508
|
-
// src/tools/checkpoint.ts
|
|
7509
|
-
async function handleCheckpointTool(input) {
|
|
7510
|
-
const workDir = getWorkingDirectory(void 0, true);
|
|
7511
|
-
switch (input.action) {
|
|
7512
|
-
case "save": {
|
|
7513
|
-
const saveOptions = {
|
|
7514
|
-
files: input.files || [],
|
|
7515
|
-
workDir,
|
|
7516
|
-
createdBy: "mcp"
|
|
7517
|
-
};
|
|
7518
|
-
if (input.message !== void 0) {
|
|
7519
|
-
saveOptions.message = input.message;
|
|
7520
|
-
}
|
|
7521
|
-
if (input.notes !== void 0) {
|
|
7522
|
-
saveOptions.notes = input.notes;
|
|
7523
|
-
}
|
|
7524
|
-
const checkpoint = await saveCheckpoint(saveOptions);
|
|
7525
|
-
return `# Checkpoint Saved
|
|
7526
|
-
|
|
7527
|
-
**ID:** ${checkpoint.id}
|
|
7528
|
-
**Time:** ${checkpoint.timestamp}
|
|
7529
|
-
${checkpoint.message ? `**Message:** ${checkpoint.message}` : ""}
|
|
7530
|
-
${checkpoint.notes ? `**Notes:** ${checkpoint.notes}` : ""}
|
|
7531
|
-
${checkpoint.files.length > 0 ? `**Files:** ${checkpoint.files.join(", ")}` : ""}
|
|
7532
|
-
|
|
7533
|
-
Context saved to \`.trie/\`. This checkpoint will be visible in other tools (Cursor, Claude Code, CLI).`;
|
|
7534
|
-
}
|
|
7535
|
-
case "list": {
|
|
7536
|
-
const checkpoints = await listCheckpoints(workDir);
|
|
7537
|
-
if (checkpoints.length === 0) {
|
|
7538
|
-
return 'No checkpoints yet. Use `trie_checkpoint action="save"` to create one.';
|
|
7539
|
-
}
|
|
7540
|
-
const lines = ["# Recent Checkpoints", ""];
|
|
7541
|
-
for (const cp of checkpoints.slice(-10).reverse()) {
|
|
7542
|
-
const date = new Date(cp.timestamp).toLocaleString();
|
|
7543
|
-
lines.push(`- **${cp.id}** (${date}): ${cp.message || "(no message)"}`);
|
|
7544
|
-
}
|
|
7545
|
-
return lines.join("\n");
|
|
7546
|
-
}
|
|
7547
|
-
case "last": {
|
|
7548
|
-
const checkpoint = await getLastCheckpoint(workDir);
|
|
7549
|
-
if (!checkpoint) {
|
|
7550
|
-
return 'No checkpoints yet. Use `trie_checkpoint action="save"` to create one.';
|
|
7551
|
-
}
|
|
7552
|
-
return `# Last Checkpoint
|
|
7553
|
-
|
|
7554
|
-
**ID:** ${checkpoint.id}
|
|
7555
|
-
**Time:** ${new Date(checkpoint.timestamp).toLocaleString()}
|
|
7556
|
-
${checkpoint.message ? `**Message:** ${checkpoint.message}` : ""}
|
|
7557
|
-
${checkpoint.notes ? `**Notes:** ${checkpoint.notes}` : ""}
|
|
7558
|
-
${checkpoint.files.length > 0 ? `**Files:** ${checkpoint.files.join(", ")}` : ""}
|
|
7559
|
-
**Created by:** ${checkpoint.createdBy}`;
|
|
7560
|
-
}
|
|
7561
|
-
default:
|
|
7562
|
-
return "Unknown action. Use: save, list, or last";
|
|
7563
|
-
}
|
|
7564
|
-
}
|
|
7565
|
-
|
|
7566
7511
|
// src/tools/pipeline.ts
|
|
7567
7512
|
var TriePipelineTool = class {
|
|
7568
7513
|
async execute(input) {
|
|
@@ -8245,7 +8190,7 @@ var CHAT_TOOLS = [
|
|
|
8245
8190
|
},
|
|
8246
8191
|
{
|
|
8247
8192
|
name: "trie_get_pipeline",
|
|
8248
|
-
description: "Get current pipeline status: open PRs, active Linear tickets, open GitHub issues, and Trie
|
|
8193
|
+
description: "Get current pipeline status: open PRs, active Linear tickets, open GitHub issues, and Trie issues not yet tracked in any ticket or PR. Use when the user asks about the status of work, what PRs are open, or what tickets are in progress.",
|
|
8249
8194
|
input_schema: {
|
|
8250
8195
|
type: "object",
|
|
8251
8196
|
properties: {
|
|
@@ -8258,20 +8203,6 @@ var CHAT_TOOLS = [
|
|
|
8258
8203
|
}
|
|
8259
8204
|
}
|
|
8260
8205
|
},
|
|
8261
|
-
{
|
|
8262
|
-
name: "trie_checkpoint",
|
|
8263
|
-
description: "Save a work checkpoint, list recent checkpoints, or get the last one.",
|
|
8264
|
-
input_schema: {
|
|
8265
|
-
type: "object",
|
|
8266
|
-
properties: {
|
|
8267
|
-
action: { type: "string", enum: ["save", "list", "last"], description: "What to do" },
|
|
8268
|
-
message: { type: "string", description: "Checkpoint message (for save)" },
|
|
8269
|
-
notes: { type: "string", description: "Additional notes (for save)" },
|
|
8270
|
-
files: { type: "array", items: { type: "string" }, description: "Files to associate (for save)" }
|
|
8271
|
-
},
|
|
8272
|
-
required: ["action"]
|
|
8273
|
-
}
|
|
8274
|
-
},
|
|
8275
8206
|
{
|
|
8276
8207
|
name: "trie_add_goal",
|
|
8277
8208
|
description: "Create a new goal for the user to track. Use when the user asks to set, add, or create a goal.",
|
|
@@ -8518,10 +8449,6 @@ async function executeTool(name, input, onProgress) {
|
|
|
8518
8449
|
const result = await pipelineTool.execute(pipelineArgs);
|
|
8519
8450
|
return textFromResult(result);
|
|
8520
8451
|
}
|
|
8521
|
-
case "trie_checkpoint": {
|
|
8522
|
-
const result = await handleCheckpointTool(input);
|
|
8523
|
-
return result;
|
|
8524
|
-
}
|
|
8525
8452
|
case "trie_add_goal": {
|
|
8526
8453
|
const desc = String(input.description || "").trim();
|
|
8527
8454
|
if (!desc) return "Goal description is required.";
|
|
@@ -8760,7 +8687,7 @@ ${truncated}`;
|
|
|
8760
8687
|
const goalId = input.goalId ? String(input.goalId).trim() : void 0;
|
|
8761
8688
|
try {
|
|
8762
8689
|
onProgress?.("Loading goals...");
|
|
8763
|
-
const { getActiveGoals } = await import("./goal-validator-
|
|
8690
|
+
const { getActiveGoals } = await import("./goal-validator-ULKIBDPX.js");
|
|
8764
8691
|
const agentState = getProjectState(directory);
|
|
8765
8692
|
await agentState.load();
|
|
8766
8693
|
const allGoals = await getActiveGoals(directory);
|
|
@@ -8769,7 +8696,7 @@ ${truncated}`;
|
|
|
8769
8696
|
return goalId ? `No active goal found with ID: ${goalId}` : "No active goals to check. Add goals in the Goals view first.";
|
|
8770
8697
|
}
|
|
8771
8698
|
onProgress?.("Scanning codebase for violations...");
|
|
8772
|
-
const { analyzeFilesRapidly } = await import("./fast-analyzer-
|
|
8699
|
+
const { analyzeFilesRapidly } = await import("./fast-analyzer-XXYMOXRK.js");
|
|
8773
8700
|
const analysisOptions = {
|
|
8774
8701
|
maxFiles: 50,
|
|
8775
8702
|
enableSmartBatching: true
|
|
@@ -8783,7 +8710,7 @@ ${truncated}`;
|
|
|
8783
8710
|
const cacheInfo2 = analysisResult.cacheHitRatio > 0 ? ` (${Math.round(analysisResult.cacheHitRatio * 100)}% cache hit, ${analysisResult.timeMs}ms)` : ` (${analysisResult.timeMs}ms)`;
|
|
8784
8711
|
return `\u2713 Scan complete! No violations found for ${goalsToCheck.length} goal(s).${cacheInfo2}`;
|
|
8785
8712
|
}
|
|
8786
|
-
const { storeIssues: storeIssues2 } = await import("./issue-store-
|
|
8713
|
+
const { storeIssues: storeIssues2 } = await import("./issue-store-ZIRP23EP.js");
|
|
8787
8714
|
const { basename: basename2 } = await import("path");
|
|
8788
8715
|
const issuesToStore = violations.map((v, i) => ({
|
|
8789
8716
|
id: `goal-violation-${Date.now()}-${i}`,
|
|
@@ -8862,7 +8789,7 @@ ${truncated}`;
|
|
|
8862
8789
|
}
|
|
8863
8790
|
try {
|
|
8864
8791
|
onProgress?.("Gathering evidence for hypothesis...");
|
|
8865
|
-
const { gatherEvidenceForHypothesis } = await import("./hypothesis-
|
|
8792
|
+
const { gatherEvidenceForHypothesis } = await import("./hypothesis-7BFFT5JY.js");
|
|
8866
8793
|
const evidence = await gatherEvidenceForHypothesis(hypothesisId, directory);
|
|
8867
8794
|
if (evidence.length === 0) {
|
|
8868
8795
|
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.`;
|
|
@@ -8953,7 +8880,7 @@ async function buildContext(workDir, dashboardState) {
|
|
|
8953
8880
|
console.error("Failed to load project state:", error);
|
|
8954
8881
|
}
|
|
8955
8882
|
try {
|
|
8956
|
-
const { getLedgerBlocks: getLedgerBlocks2 } = await import("./ledger-
|
|
8883
|
+
const { getLedgerBlocks: getLedgerBlocks2 } = await import("./ledger-TWZTGDFA.js");
|
|
8957
8884
|
const blocks = await getLedgerBlocks2(workDir);
|
|
8958
8885
|
const allEntries = blocks.flatMap((b) => b.entries);
|
|
8959
8886
|
const recentEntries = allEntries.filter((e) => e.status !== "false-positive" && e.issue).slice(-20);
|
|
@@ -9052,7 +8979,6 @@ var SYSTEM_PROMPT = `You are Trie, a code assistant embedded in a terminal TUI.
|
|
|
9052
8979
|
- Create and manage goals and hypotheses
|
|
9053
8980
|
- Propose fixes for goal violations (requires user confirmation before spawning Claude Code)
|
|
9054
8981
|
- Run AI-powered scans to detect goal violations across the entire codebase
|
|
9055
|
-
- Save work checkpoints
|
|
9056
8982
|
|
|
9057
8983
|
**AUTONOMOUS AWARENESS:**
|
|
9058
8984
|
- The project context includes "Recent issues from ledger" \u2014 these are patterns you should AVOID in new code
|
|
@@ -9823,7 +9749,7 @@ ${content}
|
|
|
9823
9749
|
fixedContent = fixedContent.replace(/^```\w*\n?/, "").replace(/\n?```$/, "");
|
|
9824
9750
|
}
|
|
9825
9751
|
await writeFile2(fullPath, fixedContent, "utf-8");
|
|
9826
|
-
const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-
|
|
9752
|
+
const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-ULKIBDPX.js");
|
|
9827
9753
|
const goals = await getActiveGoals(projectPath);
|
|
9828
9754
|
const matchedGoal = goals.find((g) => g.description === fix.goalDescription);
|
|
9829
9755
|
if (matchedGoal) {
|
|
@@ -9939,7 +9865,7 @@ function DashboardApp({ onReady }) {
|
|
|
9939
9865
|
const loadPersistedNudges = useCallback7(async () => {
|
|
9940
9866
|
try {
|
|
9941
9867
|
const workDir = getWorkingDirectory(void 0, true);
|
|
9942
|
-
const { getStorage: getStorage2 } = await import("./tiered-storage-
|
|
9868
|
+
const { getStorage: getStorage2 } = await import("./tiered-storage-Z3YCR465.js");
|
|
9943
9869
|
const storage = getStorage2(workDir);
|
|
9944
9870
|
await storage.initialize();
|
|
9945
9871
|
const nudges = await storage.queryNudges({ resolved: false, limit: 50 });
|
|
@@ -10208,9 +10134,9 @@ var InteractiveDashboard = class {
|
|
|
10208
10134
|
};
|
|
10209
10135
|
|
|
10210
10136
|
// src/tools/watch.ts
|
|
10211
|
-
import { watch, existsSync as
|
|
10212
|
-
import { stat, readFile as
|
|
10213
|
-
import { join as
|
|
10137
|
+
import { watch, existsSync as existsSync7, readFileSync as readFileSync2 } from "fs";
|
|
10138
|
+
import { stat, readFile as readFile6 } from "fs/promises";
|
|
10139
|
+
import { join as join5, extname as extname3, basename } from "path";
|
|
10214
10140
|
import { createHash as createHash3 } from "crypto";
|
|
10215
10141
|
|
|
10216
10142
|
// src/agent/signal-summarizer.ts
|
|
@@ -10452,6 +10378,528 @@ function getSignalSummarizer(projectPath) {
|
|
|
10452
10378
|
return summarizer;
|
|
10453
10379
|
}
|
|
10454
10380
|
|
|
10381
|
+
// src/compliance/false-negative-detector.ts
|
|
10382
|
+
import { join as join4 } from "path";
|
|
10383
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
10384
|
+
import { existsSync as existsSync6 } from "fs";
|
|
10385
|
+
var FalseNegativeDetector = class {
|
|
10386
|
+
workDir;
|
|
10387
|
+
alertsPath;
|
|
10388
|
+
coveragePath;
|
|
10389
|
+
constructor(workDir) {
|
|
10390
|
+
this.workDir = workDir || getWorkingDirectory(void 0, true);
|
|
10391
|
+
const memoryDir = join4(getTrieDirectory(this.workDir), "memory");
|
|
10392
|
+
this.alertsPath = join4(memoryDir, "false-negative-alerts.json");
|
|
10393
|
+
this.coveragePath = join4(memoryDir, "compliance-coverage.json");
|
|
10394
|
+
}
|
|
10395
|
+
/**
|
|
10396
|
+
* Run continuous validation checks
|
|
10397
|
+
*/
|
|
10398
|
+
async runValidation(complianceFrameworks) {
|
|
10399
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
10400
|
+
const alerts = [];
|
|
10401
|
+
const coverageGaps = [];
|
|
10402
|
+
const recommendations = [];
|
|
10403
|
+
try {
|
|
10404
|
+
const crossValidationAlerts = await this.performCrossValidation(complianceFrameworks);
|
|
10405
|
+
alerts.push(...crossValidationAlerts);
|
|
10406
|
+
const patternDriftAlerts = await this.detectPatternDrift();
|
|
10407
|
+
alerts.push(...patternDriftAlerts);
|
|
10408
|
+
const coverageAnalysis = await this.analyzeCoverageGaps(complianceFrameworks);
|
|
10409
|
+
coverageGaps.push(...coverageAnalysis.gaps);
|
|
10410
|
+
alerts.push(...coverageAnalysis.alerts);
|
|
10411
|
+
const auditTrailAlerts = await this.validateAuditTrails(complianceFrameworks);
|
|
10412
|
+
alerts.push(...auditTrailAlerts);
|
|
10413
|
+
recommendations.push(...await this.generateRecommendations(alerts, coverageGaps));
|
|
10414
|
+
await this.storeAlerts(alerts);
|
|
10415
|
+
return {
|
|
10416
|
+
valid: alerts.filter((a) => a.severity === "critical" || a.severity === "high").length === 0,
|
|
10417
|
+
alerts,
|
|
10418
|
+
coverageGaps,
|
|
10419
|
+
recommendations,
|
|
10420
|
+
validationTimestamp: timestamp
|
|
10421
|
+
};
|
|
10422
|
+
} catch (error) {
|
|
10423
|
+
const criticalAlert = {
|
|
10424
|
+
id: `validation-failure-${Date.now()}`,
|
|
10425
|
+
timestamp,
|
|
10426
|
+
type: "compliance_gap",
|
|
10427
|
+
severity: "critical",
|
|
10428
|
+
description: `False negative validation failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
10429
|
+
affectedFiles: [],
|
|
10430
|
+
complianceFrameworks,
|
|
10431
|
+
suggestedAction: "Investigate validation system failure and restore monitoring",
|
|
10432
|
+
confidence: 100,
|
|
10433
|
+
context: { riskScore: 100 }
|
|
10434
|
+
};
|
|
10435
|
+
return {
|
|
10436
|
+
valid: false,
|
|
10437
|
+
alerts: [criticalAlert],
|
|
10438
|
+
coverageGaps: ["validation-system"],
|
|
10439
|
+
recommendations: ["Fix validation system immediately"],
|
|
10440
|
+
validationTimestamp: timestamp
|
|
10441
|
+
};
|
|
10442
|
+
}
|
|
10443
|
+
}
|
|
10444
|
+
/**
|
|
10445
|
+
* Cross-validate current detections against historical patterns
|
|
10446
|
+
*/
|
|
10447
|
+
async performCrossValidation(frameworks) {
|
|
10448
|
+
const alerts = [];
|
|
10449
|
+
const blocks = await getLedgerBlocks(this.workDir);
|
|
10450
|
+
const recentIssues = await getRecentIssues({ workDir: this.workDir, limit: 100 });
|
|
10451
|
+
const historicalDetectionRates = this.calculateHistoricalDetectionRates(blocks, frameworks);
|
|
10452
|
+
const currentDetectionRate = this.calculateCurrentDetectionRate(recentIssues, frameworks);
|
|
10453
|
+
for (const framework of frameworks) {
|
|
10454
|
+
const historical = historicalDetectionRates.get(framework) || 0;
|
|
10455
|
+
const current = currentDetectionRate.get(framework) || 0;
|
|
10456
|
+
const dropThreshold = 0.3;
|
|
10457
|
+
if (historical > 0 && (historical - current) / historical > dropThreshold) {
|
|
10458
|
+
alerts.push({
|
|
10459
|
+
id: `detection-drop-${framework}-${Date.now()}`,
|
|
10460
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10461
|
+
type: "missing_detection",
|
|
10462
|
+
severity: current === 0 ? "critical" : "high",
|
|
10463
|
+
description: `${framework} detection rate dropped ${Math.round((historical - current) / historical * 100)}% from historical average`,
|
|
10464
|
+
affectedFiles: [],
|
|
10465
|
+
complianceFrameworks: [framework],
|
|
10466
|
+
suggestedAction: "Review detection rules and validate scanning coverage",
|
|
10467
|
+
confidence: 85,
|
|
10468
|
+
context: {
|
|
10469
|
+
expectedDetection: `${historical.toFixed(2)} issues per scan`,
|
|
10470
|
+
actualDetection: `${current.toFixed(2)} issues per scan`,
|
|
10471
|
+
riskScore: current === 0 ? 100 : 70
|
|
10472
|
+
}
|
|
10473
|
+
});
|
|
10474
|
+
}
|
|
10475
|
+
}
|
|
10476
|
+
return alerts;
|
|
10477
|
+
}
|
|
10478
|
+
/**
|
|
10479
|
+
* Detect if detection patterns are drifting unexpectedly
|
|
10480
|
+
*/
|
|
10481
|
+
async detectPatternDrift() {
|
|
10482
|
+
const alerts = [];
|
|
10483
|
+
const blocks = await getLedgerBlocks(this.workDir);
|
|
10484
|
+
const patternStability = this.analyzePatternStability(blocks);
|
|
10485
|
+
for (const [pattern, stability] of Array.from(patternStability.entries())) {
|
|
10486
|
+
if (stability < 0.7) {
|
|
10487
|
+
alerts.push({
|
|
10488
|
+
id: `pattern-drift-${pattern.replace(/[^a-zA-Z0-9]/g, "-")}-${Date.now()}`,
|
|
10489
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10490
|
+
type: "pattern_drift",
|
|
10491
|
+
severity: stability < 0.5 ? "high" : "medium",
|
|
10492
|
+
description: `Detection pattern '${pattern}' showing instability (${Math.round(stability * 100)}% stable)`,
|
|
10493
|
+
affectedFiles: [],
|
|
10494
|
+
complianceFrameworks: this.inferComplianceFrameworks(pattern),
|
|
10495
|
+
suggestedAction: "Review and stabilize detection pattern or investigate environmental changes",
|
|
10496
|
+
confidence: Math.round((1 - stability) * 100),
|
|
10497
|
+
context: {
|
|
10498
|
+
riskScore: Math.round((1 - stability) * 80),
|
|
10499
|
+
lastValidated: this.getLastPatternValidation(pattern)
|
|
10500
|
+
}
|
|
10501
|
+
});
|
|
10502
|
+
}
|
|
10503
|
+
}
|
|
10504
|
+
return alerts;
|
|
10505
|
+
}
|
|
10506
|
+
/**
|
|
10507
|
+
* Analyze coverage gaps in compliance monitoring
|
|
10508
|
+
*/
|
|
10509
|
+
async analyzeCoverageGaps(frameworks) {
|
|
10510
|
+
const gaps = [];
|
|
10511
|
+
const alerts = [];
|
|
10512
|
+
const requiredControls = this.getRequiredControls(frameworks);
|
|
10513
|
+
const currentCoverage = await this.getCurrentCoverage();
|
|
10514
|
+
for (const [framework, controls] of Array.from(requiredControls.entries())) {
|
|
10515
|
+
const coveredControls = currentCoverage.get(framework) || /* @__PURE__ */ new Set();
|
|
10516
|
+
const missingControls = controls.filter((control) => !coveredControls.has(control));
|
|
10517
|
+
if (missingControls.length > 0) {
|
|
10518
|
+
gaps.push(...missingControls.map((c) => `${framework}:${c}`));
|
|
10519
|
+
const criticalControls = this.getCriticalControls(framework, missingControls);
|
|
10520
|
+
if (criticalControls.length > 0) {
|
|
10521
|
+
alerts.push({
|
|
10522
|
+
id: `coverage-gap-${framework}-${Date.now()}`,
|
|
10523
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10524
|
+
type: "coverage_hole",
|
|
10525
|
+
severity: "critical",
|
|
10526
|
+
description: `Missing critical ${framework} controls: ${criticalControls.join(", ")}`,
|
|
10527
|
+
affectedFiles: [],
|
|
10528
|
+
complianceFrameworks: [framework],
|
|
10529
|
+
suggestedAction: "Implement monitoring for missing critical controls immediately",
|
|
10530
|
+
confidence: 100,
|
|
10531
|
+
context: {
|
|
10532
|
+
riskScore: 95,
|
|
10533
|
+
expectedDetection: `Controls: ${controls.join(", ")}`,
|
|
10534
|
+
actualDetection: `Missing: ${criticalControls.join(", ")}`
|
|
10535
|
+
}
|
|
10536
|
+
});
|
|
10537
|
+
}
|
|
10538
|
+
}
|
|
10539
|
+
}
|
|
10540
|
+
return { gaps, alerts };
|
|
10541
|
+
}
|
|
10542
|
+
/**
|
|
10543
|
+
* Validate that audit trails are complete and tamper-evident
|
|
10544
|
+
*/
|
|
10545
|
+
async validateAuditTrails(frameworks) {
|
|
10546
|
+
const alerts = [];
|
|
10547
|
+
const blocks = await getLedgerBlocks(this.workDir);
|
|
10548
|
+
const auditGaps = this.findAuditTrailGaps(blocks, frameworks);
|
|
10549
|
+
for (const gap of auditGaps) {
|
|
10550
|
+
alerts.push({
|
|
10551
|
+
id: `audit-gap-${gap.type}-${Date.now()}`,
|
|
10552
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10553
|
+
type: "compliance_gap",
|
|
10554
|
+
severity: gap.critical ? "critical" : "high",
|
|
10555
|
+
description: `Audit trail gap: ${gap.description}`,
|
|
10556
|
+
affectedFiles: gap.affectedFiles,
|
|
10557
|
+
complianceFrameworks: gap.frameworks,
|
|
10558
|
+
suggestedAction: gap.remediation,
|
|
10559
|
+
confidence: 95,
|
|
10560
|
+
context: {
|
|
10561
|
+
riskScore: gap.critical ? 90 : 60,
|
|
10562
|
+
lastValidated: gap.lastSeen
|
|
10563
|
+
}
|
|
10564
|
+
});
|
|
10565
|
+
}
|
|
10566
|
+
const integrityIssues = await this.validateCryptographicIntegrity(blocks);
|
|
10567
|
+
for (const issue of integrityIssues) {
|
|
10568
|
+
alerts.push({
|
|
10569
|
+
id: `integrity-${issue.type}-${Date.now()}`,
|
|
10570
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10571
|
+
type: "compliance_gap",
|
|
10572
|
+
severity: "critical",
|
|
10573
|
+
description: `Audit trail integrity compromised: ${issue.description}`,
|
|
10574
|
+
affectedFiles: [],
|
|
10575
|
+
complianceFrameworks: frameworks,
|
|
10576
|
+
suggestedAction: "Investigate potential tampering and restore audit trail integrity",
|
|
10577
|
+
confidence: 100,
|
|
10578
|
+
context: { riskScore: 100 }
|
|
10579
|
+
});
|
|
10580
|
+
}
|
|
10581
|
+
return alerts;
|
|
10582
|
+
}
|
|
10583
|
+
/**
|
|
10584
|
+
* Generate actionable recommendations based on findings
|
|
10585
|
+
*/
|
|
10586
|
+
async generateRecommendations(alerts, gaps) {
|
|
10587
|
+
const recommendations = [];
|
|
10588
|
+
const alertsByType = alerts.reduce((acc, alert) => {
|
|
10589
|
+
if (!acc[alert.type]) acc[alert.type] = [];
|
|
10590
|
+
acc[alert.type].push(alert);
|
|
10591
|
+
return acc;
|
|
10592
|
+
}, {});
|
|
10593
|
+
if (alertsByType.missing_detection?.length > 0) {
|
|
10594
|
+
recommendations.push("Increase detection frequency and review agent configurations");
|
|
10595
|
+
recommendations.push("Implement additional cross-validation mechanisms");
|
|
10596
|
+
}
|
|
10597
|
+
if (alertsByType.pattern_drift?.length > 0) {
|
|
10598
|
+
recommendations.push("Stabilize detection patterns through improved training data");
|
|
10599
|
+
recommendations.push("Implement pattern validation checkpoints");
|
|
10600
|
+
}
|
|
10601
|
+
if (alertsByType.coverage_hole?.length > 0) {
|
|
10602
|
+
recommendations.push("Expand compliance monitoring coverage to include missing controls");
|
|
10603
|
+
recommendations.push("Implement automated compliance mapping validation");
|
|
10604
|
+
}
|
|
10605
|
+
if (alertsByType.compliance_gap?.length > 0) {
|
|
10606
|
+
recommendations.push("Strengthen audit trail generation and validation processes");
|
|
10607
|
+
recommendations.push("Implement real-time compliance monitoring dashboards");
|
|
10608
|
+
}
|
|
10609
|
+
if (gaps.length > 0) {
|
|
10610
|
+
recommendations.push(`Address ${gaps.length} compliance coverage gaps immediately`);
|
|
10611
|
+
recommendations.push("Implement automated gap detection and remediation");
|
|
10612
|
+
}
|
|
10613
|
+
const criticalAlerts = alerts.filter((a) => a.severity === "critical");
|
|
10614
|
+
if (criticalAlerts.length > 0) {
|
|
10615
|
+
recommendations.push(`URGENT: ${criticalAlerts.length} critical compliance issues require immediate attention`);
|
|
10616
|
+
}
|
|
10617
|
+
return recommendations;
|
|
10618
|
+
}
|
|
10619
|
+
/**
|
|
10620
|
+
* Store alerts for trending and historical analysis
|
|
10621
|
+
*/
|
|
10622
|
+
async storeAlerts(alerts) {
|
|
10623
|
+
if (alerts.length === 0) return;
|
|
10624
|
+
try {
|
|
10625
|
+
let existingAlerts = [];
|
|
10626
|
+
if (existsSync6(this.alertsPath)) {
|
|
10627
|
+
const content = await readFile5(this.alertsPath, "utf-8");
|
|
10628
|
+
existingAlerts = JSON.parse(content);
|
|
10629
|
+
}
|
|
10630
|
+
const ninetyDaysAgo = /* @__PURE__ */ new Date();
|
|
10631
|
+
ninetyDaysAgo.setDate(ninetyDaysAgo.getDate() - 90);
|
|
10632
|
+
const recentAlerts = existingAlerts.filter(
|
|
10633
|
+
(alert) => new Date(alert.timestamp) > ninetyDaysAgo
|
|
10634
|
+
);
|
|
10635
|
+
const allAlerts = [...recentAlerts, ...alerts];
|
|
10636
|
+
await atomicWriteJSON(this.alertsPath, allAlerts);
|
|
10637
|
+
} catch (error) {
|
|
10638
|
+
console.error("Failed to store false negative alerts:", error);
|
|
10639
|
+
}
|
|
10640
|
+
}
|
|
10641
|
+
// Helper methods for calculations and analysis
|
|
10642
|
+
calculateHistoricalDetectionRates(blocks, frameworks) {
|
|
10643
|
+
const rates = /* @__PURE__ */ new Map();
|
|
10644
|
+
const thirtyDaysAgo = /* @__PURE__ */ new Date();
|
|
10645
|
+
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
|
|
10646
|
+
const recentBlocks = blocks.filter(
|
|
10647
|
+
(block) => new Date(block.date) > thirtyDaysAgo
|
|
10648
|
+
);
|
|
10649
|
+
for (const framework of frameworks) {
|
|
10650
|
+
let totalDetections = 0;
|
|
10651
|
+
let blockCount = 0;
|
|
10652
|
+
for (const block of recentBlocks) {
|
|
10653
|
+
const frameworkDetections = block.entries.filter(
|
|
10654
|
+
(entry) => entry.context?.complianceViolations?.includes(framework) || this.inferFrameworkFromEntry(entry) === framework
|
|
10655
|
+
).length;
|
|
10656
|
+
totalDetections += frameworkDetections;
|
|
10657
|
+
blockCount++;
|
|
10658
|
+
}
|
|
10659
|
+
rates.set(framework, blockCount > 0 ? totalDetections / blockCount : 0);
|
|
10660
|
+
}
|
|
10661
|
+
return rates;
|
|
10662
|
+
}
|
|
10663
|
+
calculateCurrentDetectionRate(issues, frameworks) {
|
|
10664
|
+
const rates = /* @__PURE__ */ new Map();
|
|
10665
|
+
const oneDayAgo = /* @__PURE__ */ new Date();
|
|
10666
|
+
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
|
|
10667
|
+
const recentIssues = issues.filter(
|
|
10668
|
+
(issue) => new Date(issue.timestamp) > oneDayAgo
|
|
10669
|
+
);
|
|
10670
|
+
for (const framework of frameworks) {
|
|
10671
|
+
const frameworkIssues = recentIssues.filter(
|
|
10672
|
+
(issue) => this.inferFrameworkFromIssue(issue) === framework
|
|
10673
|
+
);
|
|
10674
|
+
rates.set(framework, frameworkIssues.length);
|
|
10675
|
+
}
|
|
10676
|
+
return rates;
|
|
10677
|
+
}
|
|
10678
|
+
analyzePatternStability(blocks) {
|
|
10679
|
+
const stability = /* @__PURE__ */ new Map();
|
|
10680
|
+
const patterns = this.extractDetectionPatterns(blocks);
|
|
10681
|
+
for (const [pattern, occurrences] of Array.from(patterns.entries())) {
|
|
10682
|
+
const mean = occurrences.reduce((a, b) => a + b, 0) / occurrences.length;
|
|
10683
|
+
const variance = occurrences.reduce((acc, val) => acc + Math.pow(val - mean, 2), 0) / occurrences.length;
|
|
10684
|
+
const stdDev = Math.sqrt(variance);
|
|
10685
|
+
const cv = mean > 0 ? stdDev / mean : 1;
|
|
10686
|
+
stability.set(pattern, Math.max(0, 1 - cv));
|
|
10687
|
+
}
|
|
10688
|
+
return stability;
|
|
10689
|
+
}
|
|
10690
|
+
extractDetectionPatterns(blocks) {
|
|
10691
|
+
const patterns = /* @__PURE__ */ new Map();
|
|
10692
|
+
const weeklyData = /* @__PURE__ */ new Map();
|
|
10693
|
+
for (const block of blocks) {
|
|
10694
|
+
const weekKey = this.getWeekKey(new Date(block.date));
|
|
10695
|
+
if (!weeklyData.has(weekKey)) {
|
|
10696
|
+
weeklyData.set(weekKey, /* @__PURE__ */ new Map());
|
|
10697
|
+
}
|
|
10698
|
+
const weekData = weeklyData.get(weekKey);
|
|
10699
|
+
for (const entry of block.entries) {
|
|
10700
|
+
const pattern = `${entry.agent}:${entry.severity}`;
|
|
10701
|
+
weekData.set(pattern, (weekData.get(pattern) || 0) + 1);
|
|
10702
|
+
}
|
|
10703
|
+
}
|
|
10704
|
+
const allWeeks = Array.from(weeklyData.keys()).sort();
|
|
10705
|
+
const allPatterns = /* @__PURE__ */ new Set();
|
|
10706
|
+
for (const weekData of Array.from(weeklyData.values())) {
|
|
10707
|
+
for (const pattern of Array.from(weekData.keys())) {
|
|
10708
|
+
allPatterns.add(pattern);
|
|
10709
|
+
}
|
|
10710
|
+
}
|
|
10711
|
+
for (const pattern of Array.from(allPatterns)) {
|
|
10712
|
+
const timeSeries = [];
|
|
10713
|
+
for (const week of allWeeks) {
|
|
10714
|
+
const weekData = weeklyData.get(week);
|
|
10715
|
+
timeSeries.push(weekData.get(pattern) || 0);
|
|
10716
|
+
}
|
|
10717
|
+
patterns.set(pattern, timeSeries);
|
|
10718
|
+
}
|
|
10719
|
+
return patterns;
|
|
10720
|
+
}
|
|
10721
|
+
getWeekKey(date) {
|
|
10722
|
+
const year = date.getFullYear();
|
|
10723
|
+
const week = Math.floor((date.getTime() - new Date(year, 0, 1).getTime()) / (7 * 24 * 60 * 60 * 1e3));
|
|
10724
|
+
return `${year}-W${week.toString().padStart(2, "0")}`;
|
|
10725
|
+
}
|
|
10726
|
+
getRequiredControls(frameworks) {
|
|
10727
|
+
const controls = /* @__PURE__ */ new Map();
|
|
10728
|
+
const frameworkControls = {
|
|
10729
|
+
SOC2: ["access-control", "data-encryption", "audit-logging", "incident-response"],
|
|
10730
|
+
GDPR: ["data-protection", "consent-management", "data-breach-notification", "privacy-by-design"],
|
|
10731
|
+
HIPAA: ["phi-protection", "access-controls", "audit-controls", "transmission-security"],
|
|
10732
|
+
"ISO27001": ["information-security-policy", "risk-management", "access-control", "cryptography"],
|
|
10733
|
+
"PCI-DSS": ["cardholder-data-protection", "secure-networks", "vulnerability-management", "access-control"],
|
|
10734
|
+
SOX: ["financial-reporting-controls", "segregation-of-duties", "audit-trail", "change-management"],
|
|
10735
|
+
ICFR: ["control-environment", "risk-assessment", "control-activities", "monitoring"],
|
|
10736
|
+
"FDA21CFR11": ["electronic-records", "electronic-signatures", "audit-trail", "system-validation"],
|
|
10737
|
+
GLBA: ["customer-information-protection", "access-control", "disposal-procedures", "incident-response"],
|
|
10738
|
+
FFIEC: ["authentication", "access-control", "encryption", "incident-response"],
|
|
10739
|
+
FINRA: ["recordkeeping", "supervision", "reporting", "compliance-monitoring"]
|
|
10740
|
+
};
|
|
10741
|
+
for (const framework of frameworks) {
|
|
10742
|
+
const frameworkKey = framework;
|
|
10743
|
+
if (frameworkControls[frameworkKey]) {
|
|
10744
|
+
controls.set(framework, frameworkControls[frameworkKey]);
|
|
10745
|
+
}
|
|
10746
|
+
}
|
|
10747
|
+
return controls;
|
|
10748
|
+
}
|
|
10749
|
+
async getCurrentCoverage() {
|
|
10750
|
+
const coverage = /* @__PURE__ */ new Map();
|
|
10751
|
+
try {
|
|
10752
|
+
const blocks = await getLedgerBlocks(this.workDir);
|
|
10753
|
+
for (const block of blocks) {
|
|
10754
|
+
for (const entry of block.entries) {
|
|
10755
|
+
const frameworks = entry.context?.complianceViolations || [this.inferFrameworkFromEntry(entry)].filter(Boolean);
|
|
10756
|
+
for (const framework of frameworks) {
|
|
10757
|
+
if (!coverage.has(framework)) {
|
|
10758
|
+
coverage.set(framework, /* @__PURE__ */ new Set());
|
|
10759
|
+
}
|
|
10760
|
+
const control = this.inferControlFromEntry(entry);
|
|
10761
|
+
if (control) {
|
|
10762
|
+
coverage.get(framework).add(control);
|
|
10763
|
+
}
|
|
10764
|
+
}
|
|
10765
|
+
}
|
|
10766
|
+
}
|
|
10767
|
+
} catch (error) {
|
|
10768
|
+
console.error("Failed to calculate current coverage:", error);
|
|
10769
|
+
}
|
|
10770
|
+
return coverage;
|
|
10771
|
+
}
|
|
10772
|
+
getCriticalControls(framework, missingControls) {
|
|
10773
|
+
const criticalControlsByFramework = {
|
|
10774
|
+
SOC2: /* @__PURE__ */ new Set(["access-control", "audit-logging"]),
|
|
10775
|
+
GDPR: /* @__PURE__ */ new Set(["data-protection", "consent-management"]),
|
|
10776
|
+
HIPAA: /* @__PURE__ */ new Set(["phi-protection", "access-controls"]),
|
|
10777
|
+
"ISO27001": /* @__PURE__ */ new Set(["information-security-policy", "access-control"]),
|
|
10778
|
+
"PCI-DSS": /* @__PURE__ */ new Set(["cardholder-data-protection", "secure-networks"]),
|
|
10779
|
+
SOX: /* @__PURE__ */ new Set(["financial-reporting-controls", "audit-trail"]),
|
|
10780
|
+
ICFR: /* @__PURE__ */ new Set(["control-environment", "monitoring"]),
|
|
10781
|
+
"FDA21CFR11": /* @__PURE__ */ new Set(["electronic-records", "audit-trail"]),
|
|
10782
|
+
GLBA: /* @__PURE__ */ new Set(["customer-information-protection"]),
|
|
10783
|
+
FFIEC: /* @__PURE__ */ new Set(["authentication", "encryption"]),
|
|
10784
|
+
FINRA: /* @__PURE__ */ new Set(["recordkeeping", "compliance-monitoring"])
|
|
10785
|
+
};
|
|
10786
|
+
const criticalControls = criticalControlsByFramework[framework] || /* @__PURE__ */ new Set();
|
|
10787
|
+
return missingControls.filter((control) => criticalControls.has(control));
|
|
10788
|
+
}
|
|
10789
|
+
findAuditTrailGaps(blocks, frameworks) {
|
|
10790
|
+
const gaps = [];
|
|
10791
|
+
const unsignedEntries = blocks.flatMap(
|
|
10792
|
+
(block) => block.entries.filter((entry) => !entry.signature)
|
|
10793
|
+
);
|
|
10794
|
+
if (unsignedEntries.length > 0) {
|
|
10795
|
+
gaps.push({
|
|
10796
|
+
type: "missing-signatures",
|
|
10797
|
+
description: `${unsignedEntries.length} audit entries lack cryptographic signatures`,
|
|
10798
|
+
critical: true,
|
|
10799
|
+
affectedFiles: Array.from(new Set(unsignedEntries.map((e) => e.file))),
|
|
10800
|
+
frameworks,
|
|
10801
|
+
remediation: "Enable cryptographic signing for all audit entries"
|
|
10802
|
+
});
|
|
10803
|
+
}
|
|
10804
|
+
const sortedBlocks = blocks.sort((a, b) => a.date.localeCompare(b.date));
|
|
10805
|
+
for (let i = 1; i < sortedBlocks.length; i++) {
|
|
10806
|
+
const prevDate = new Date(sortedBlocks[i - 1].date);
|
|
10807
|
+
const currDate = new Date(sortedBlocks[i].date);
|
|
10808
|
+
const daysDiff = (currDate.getTime() - prevDate.getTime()) / (1e3 * 60 * 60 * 24);
|
|
10809
|
+
if (daysDiff > 7) {
|
|
10810
|
+
gaps.push({
|
|
10811
|
+
type: "temporal-gap",
|
|
10812
|
+
description: `${Math.floor(daysDiff)} day gap in audit trail between ${prevDate.toISOString().slice(0, 10)} and ${currDate.toISOString().slice(0, 10)}`,
|
|
10813
|
+
critical: daysDiff > 30,
|
|
10814
|
+
affectedFiles: [],
|
|
10815
|
+
frameworks,
|
|
10816
|
+
remediation: "Investigate cause of audit trail gap and ensure continuous monitoring",
|
|
10817
|
+
lastSeen: prevDate.toISOString()
|
|
10818
|
+
});
|
|
10819
|
+
}
|
|
10820
|
+
}
|
|
10821
|
+
return gaps;
|
|
10822
|
+
}
|
|
10823
|
+
async validateCryptographicIntegrity(blocks) {
|
|
10824
|
+
const issues = [];
|
|
10825
|
+
for (let i = 1; i < blocks.length; i++) {
|
|
10826
|
+
const prevBlock = blocks[i - 1];
|
|
10827
|
+
const currBlock = blocks[i];
|
|
10828
|
+
if (currBlock.previousHash !== prevBlock.blockHash) {
|
|
10829
|
+
issues.push({
|
|
10830
|
+
type: "chain-break",
|
|
10831
|
+
description: `Block chain integrity compromised at block ${i}: expected ${prevBlock.blockHash}, got ${currBlock.previousHash}`
|
|
10832
|
+
});
|
|
10833
|
+
}
|
|
10834
|
+
}
|
|
10835
|
+
for (const block of blocks) {
|
|
10836
|
+
if (block.entries.length > 0 && !block.merkleRoot) {
|
|
10837
|
+
issues.push({
|
|
10838
|
+
type: "missing-merkle",
|
|
10839
|
+
description: `Block ${block.date} missing merkle root for ${block.entries.length} entries`
|
|
10840
|
+
});
|
|
10841
|
+
}
|
|
10842
|
+
}
|
|
10843
|
+
return issues;
|
|
10844
|
+
}
|
|
10845
|
+
// Framework inference helpers
|
|
10846
|
+
inferComplianceFrameworks(pattern) {
|
|
10847
|
+
const frameworks = [];
|
|
10848
|
+
if (pattern.includes("security") || pattern.includes("auth")) {
|
|
10849
|
+
frameworks.push("SOC2", "ISO27001");
|
|
10850
|
+
}
|
|
10851
|
+
if (pattern.includes("privacy") || pattern.includes("pii")) {
|
|
10852
|
+
frameworks.push("GDPR", "CCPA");
|
|
10853
|
+
}
|
|
10854
|
+
if (pattern.includes("health") || pattern.includes("phi")) {
|
|
10855
|
+
frameworks.push("HIPAA");
|
|
10856
|
+
}
|
|
10857
|
+
if (pattern.includes("payment") || pattern.includes("card")) {
|
|
10858
|
+
frameworks.push("PCI-DSS");
|
|
10859
|
+
}
|
|
10860
|
+
if (pattern.includes("financial") || pattern.includes("audit")) {
|
|
10861
|
+
frameworks.push("SOX", "ICFR");
|
|
10862
|
+
}
|
|
10863
|
+
return frameworks.length > 0 ? frameworks : ["SOC2"];
|
|
10864
|
+
}
|
|
10865
|
+
inferFrameworkFromEntry(entry) {
|
|
10866
|
+
if (entry.context?.complianceViolations?.length) {
|
|
10867
|
+
return entry.context.complianceViolations[0];
|
|
10868
|
+
}
|
|
10869
|
+
const content = `${entry.issue} ${entry.fix} ${entry.file}`.toLowerCase();
|
|
10870
|
+
if (content.includes("phi") || content.includes("health")) return "HIPAA";
|
|
10871
|
+
if (content.includes("pii") || content.includes("personal")) return "GDPR";
|
|
10872
|
+
if (content.includes("payment") || content.includes("card")) return "PCI-DSS";
|
|
10873
|
+
if (content.includes("financial")) return "SOX";
|
|
10874
|
+
return "SOC2";
|
|
10875
|
+
}
|
|
10876
|
+
inferFrameworkFromIssue(issue) {
|
|
10877
|
+
const content = `${issue.issue} ${issue.fix} ${issue.file}`.toLowerCase();
|
|
10878
|
+
if (content.includes("phi") || content.includes("health")) return "HIPAA";
|
|
10879
|
+
if (content.includes("pii") || content.includes("personal")) return "GDPR";
|
|
10880
|
+
if (content.includes("payment") || content.includes("card")) return "PCI-DSS";
|
|
10881
|
+
if (content.includes("financial")) return "SOX";
|
|
10882
|
+
return "SOC2";
|
|
10883
|
+
}
|
|
10884
|
+
inferControlFromEntry(entry) {
|
|
10885
|
+
const content = `${entry.issue} ${entry.fix} ${entry.agent}`.toLowerCase();
|
|
10886
|
+
if (content.includes("access") || content.includes("auth")) return "access-control";
|
|
10887
|
+
if (content.includes("encrypt") || content.includes("crypto")) return "data-encryption";
|
|
10888
|
+
if (content.includes("audit") || content.includes("log")) return "audit-logging";
|
|
10889
|
+
if (content.includes("incident") || content.includes("response")) return "incident-response";
|
|
10890
|
+
if (content.includes("privacy") || content.includes("consent")) return "consent-management";
|
|
10891
|
+
if (content.includes("protection") || content.includes("security")) return "data-protection";
|
|
10892
|
+
return null;
|
|
10893
|
+
}
|
|
10894
|
+
getLastPatternValidation(pattern) {
|
|
10895
|
+
return new Date(Date.now() - 24 * 60 * 60 * 1e3).toISOString();
|
|
10896
|
+
}
|
|
10897
|
+
};
|
|
10898
|
+
async function runFalseNegativeValidation(complianceFrameworks, workDir) {
|
|
10899
|
+
const detector = new FalseNegativeDetector(workDir);
|
|
10900
|
+
return detector.runValidation(complianceFrameworks);
|
|
10901
|
+
}
|
|
10902
|
+
|
|
10455
10903
|
// src/tools/watch.ts
|
|
10456
10904
|
var WATCH_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
10457
10905
|
".ts",
|
|
@@ -10714,7 +11162,7 @@ Your Trie agent is now autonomously watching and learning from your codebase.
|
|
|
10714
11162
|
return parts.some((p) => SKIP_DIRS.has(p) || p.startsWith(".") && p !== ".");
|
|
10715
11163
|
}
|
|
10716
11164
|
async watchDirectory(dir, debounceMs) {
|
|
10717
|
-
if (!
|
|
11165
|
+
if (!existsSync7(dir)) return;
|
|
10718
11166
|
try {
|
|
10719
11167
|
const dirStat = await stat(dir);
|
|
10720
11168
|
if (!dirStat.isDirectory()) return;
|
|
@@ -10723,8 +11171,8 @@ Your Trie agent is now autonomously watching and learning from your codebase.
|
|
|
10723
11171
|
if (this.shouldSkipPath(filename)) return;
|
|
10724
11172
|
const ext = extname3(filename).toLowerCase();
|
|
10725
11173
|
if (!WATCH_EXTENSIONS.has(ext)) return;
|
|
10726
|
-
const fullPath =
|
|
10727
|
-
if (!
|
|
11174
|
+
const fullPath = join5(dir, filename);
|
|
11175
|
+
if (!existsSync7(fullPath)) return;
|
|
10728
11176
|
this.state.pendingFiles.add(fullPath);
|
|
10729
11177
|
if (this.state.scanDebounceTimer) {
|
|
10730
11178
|
clearTimeout(this.state.scanDebounceTimer);
|
|
@@ -10755,8 +11203,8 @@ Your Trie agent is now autonomously watching and learning from your codebase.
|
|
|
10755
11203
|
* Watch .trie/context.json for incident changes
|
|
10756
11204
|
*/
|
|
10757
11205
|
async watchContextGraph(directory) {
|
|
10758
|
-
const contextPath =
|
|
10759
|
-
if (!
|
|
11206
|
+
const contextPath = join5(getTrieDirectory(directory), "context.json");
|
|
11207
|
+
if (!existsSync7(contextPath)) {
|
|
10760
11208
|
console.debug("[Watch] No context.json found, skipping incident watcher");
|
|
10761
11209
|
return;
|
|
10762
11210
|
}
|
|
@@ -10837,7 +11285,7 @@ Detected changes in ${files.length} file(s):`);
|
|
|
10837
11285
|
const fileContents = await Promise.all(
|
|
10838
11286
|
files.map(async (file) => {
|
|
10839
11287
|
try {
|
|
10840
|
-
const content = await
|
|
11288
|
+
const content = await readFile6(file, "utf-8");
|
|
10841
11289
|
return { file, content };
|
|
10842
11290
|
} catch {
|
|
10843
11291
|
return null;
|
|
@@ -10919,7 +11367,7 @@ ${f.content.slice(0, 1e3)}`
|
|
|
10919
11367
|
}
|
|
10920
11368
|
isQuiet() {
|
|
10921
11369
|
const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
|
|
10922
|
-
const quietPath =
|
|
11370
|
+
const quietPath = join5(getTrieDirectory(projectPath), "quiet.json");
|
|
10923
11371
|
try {
|
|
10924
11372
|
const raw = readFileSync2(quietPath, "utf-8");
|
|
10925
11373
|
const data = JSON.parse(raw);
|
|
@@ -10936,8 +11384,8 @@ ${f.content.slice(0, 1e3)}`
|
|
|
10936
11384
|
async checkAndGenerateHypotheses(projectPath) {
|
|
10937
11385
|
if (!isAIAvailable()) return;
|
|
10938
11386
|
try {
|
|
10939
|
-
const { getHypothesisEngine } = await import("./hypothesis-
|
|
10940
|
-
const { getOutputManager: getOutputManager2 } = await import("./output-manager-
|
|
11387
|
+
const { getHypothesisEngine } = await import("./hypothesis-7BFFT5JY.js");
|
|
11388
|
+
const { getOutputManager: getOutputManager2 } = await import("./output-manager-RVJ37XKA.js");
|
|
10941
11389
|
const hypothesisEngine = getHypothesisEngine(projectPath);
|
|
10942
11390
|
const recentIssues = Array.from(this.state.issueCache.values()).flat();
|
|
10943
11391
|
const patterns = [];
|
|
@@ -11001,7 +11449,7 @@ ${f.content.slice(0, 1e3)}`
|
|
|
11001
11449
|
*/
|
|
11002
11450
|
async discoverPatternsFromIssues(projectPath) {
|
|
11003
11451
|
try {
|
|
11004
|
-
const { searchIssues } = await import("./issue-store-
|
|
11452
|
+
const { searchIssues } = await import("./issue-store-ZIRP23EP.js");
|
|
11005
11453
|
const allIssues = await searchIssues("", {
|
|
11006
11454
|
workDir: projectPath,
|
|
11007
11455
|
limit: 1e3,
|
|
@@ -11103,7 +11551,7 @@ ${f.content.slice(0, 1e3)}`
|
|
|
11103
11551
|
if (lastClean && Date.now() - lastClean < this.cleanFileCooldownMs) {
|
|
11104
11552
|
return 0;
|
|
11105
11553
|
}
|
|
11106
|
-
const fileNode = await graph.getNode("file",
|
|
11554
|
+
const fileNode = await graph.getNode("file", join5(projectPath, file));
|
|
11107
11555
|
if (!fileNode) return score;
|
|
11108
11556
|
const data = fileNode.data;
|
|
11109
11557
|
const riskScores = { critical: 10, high: 6, medium: 2, low: 1 };
|
|
@@ -11162,7 +11610,7 @@ ${f.content.slice(0, 1e3)}`
|
|
|
11162
11610
|
if (remaining < 500) return;
|
|
11163
11611
|
try {
|
|
11164
11612
|
const graph = new ContextGraph(projectPath);
|
|
11165
|
-
const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-
|
|
11613
|
+
const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-ULKIBDPX.js");
|
|
11166
11614
|
console.debug("[AI Watcher] Loading active goals...");
|
|
11167
11615
|
const activeGoals = await getActiveGoals(projectPath);
|
|
11168
11616
|
const hasGoals = activeGoals.length > 0;
|
|
@@ -11191,7 +11639,7 @@ ${f.content.slice(0, 1e3)}`
|
|
|
11191
11639
|
const fileContents = await Promise.all(
|
|
11192
11640
|
filesToScan.map(async ({ file, relativePath }) => {
|
|
11193
11641
|
try {
|
|
11194
|
-
const content = await
|
|
11642
|
+
const content = await readFile6(file, "utf-8");
|
|
11195
11643
|
return { path: relativePath, content: content.slice(0, charLimit) };
|
|
11196
11644
|
} catch {
|
|
11197
11645
|
return null;
|
|
@@ -11359,7 +11807,7 @@ ${filesBlock}`,
|
|
|
11359
11807
|
fixChangeId: null,
|
|
11360
11808
|
reportedVia: "detected"
|
|
11361
11809
|
});
|
|
11362
|
-
const filePath =
|
|
11810
|
+
const filePath = join5(projectPath, issue.file);
|
|
11363
11811
|
const fileNode = await graph.getNode("file", filePath);
|
|
11364
11812
|
if (fileNode) {
|
|
11365
11813
|
await graph.addEdge(fileNode.id, incident.id, "affects");
|
|
@@ -11417,7 +11865,7 @@ ${filesBlock}`,
|
|
|
11417
11865
|
const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
|
|
11418
11866
|
console.debug("[Initial Hypothesis] Starting initial hypothesis generation", { projectPath });
|
|
11419
11867
|
try {
|
|
11420
|
-
const { getHypothesisEngine } = await import("./hypothesis-
|
|
11868
|
+
const { getHypothesisEngine } = await import("./hypothesis-7BFFT5JY.js");
|
|
11421
11869
|
const hypothesisEngine = getHypothesisEngine(projectPath);
|
|
11422
11870
|
console.debug("[Initial Hypothesis] Running AI-powered hypothesis generation...");
|
|
11423
11871
|
const generated = await hypothesisEngine.generateHypothesesWithAI({
|
|
@@ -11431,7 +11879,7 @@ ${filesBlock}`,
|
|
|
11431
11879
|
hypotheses: generated.map((h) => ({ statement: h.statement, confidence: h.confidence }))
|
|
11432
11880
|
});
|
|
11433
11881
|
if (generated.length > 0) {
|
|
11434
|
-
const { getOutputManager: getOutputManager2 } = await import("./output-manager-
|
|
11882
|
+
const { getOutputManager: getOutputManager2 } = await import("./output-manager-RVJ37XKA.js");
|
|
11435
11883
|
const outputManager = getOutputManager2();
|
|
11436
11884
|
for (const hypothesis of generated.slice(0, 2)) {
|
|
11437
11885
|
const message = `[Initial Hypothesis] "${hypothesis.statement}" (${Math.round(hypothesis.confidence * 100)}% confidence)`;
|
|
@@ -11475,7 +11923,7 @@ ${filesBlock}`,
|
|
|
11475
11923
|
const projectPath = this.watchedDirectory || getWorkingDirectory(void 0, true);
|
|
11476
11924
|
console.debug("[Initial Scan] Starting initial goal compliance scan", { projectPath });
|
|
11477
11925
|
try {
|
|
11478
|
-
const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-
|
|
11926
|
+
const { getActiveGoals, recordGoalViolationCaught } = await import("./goal-validator-ULKIBDPX.js");
|
|
11479
11927
|
const activeGoals = await getActiveGoals(projectPath);
|
|
11480
11928
|
console.debug("[Initial Scan] Loaded goals for initial scan:", {
|
|
11481
11929
|
goalCount: activeGoals.length,
|
|
@@ -11491,7 +11939,7 @@ ${filesBlock}`,
|
|
|
11491
11939
|
const recentFiles = /* @__PURE__ */ new Set();
|
|
11492
11940
|
const uncommittedFiles = await getGitChangedFiles(projectPath);
|
|
11493
11941
|
if (uncommittedFiles) {
|
|
11494
|
-
uncommittedFiles.forEach((f) => recentFiles.add(
|
|
11942
|
+
uncommittedFiles.forEach((f) => recentFiles.add(join5(projectPath, f)));
|
|
11495
11943
|
}
|
|
11496
11944
|
const oneDayAgo = Date.now() - 24 * 60 * 60 * 1e3;
|
|
11497
11945
|
const recentChanges = await getChangedFilesSinceTimestamp(projectPath, oneDayAgo);
|
|
@@ -11500,7 +11948,7 @@ ${filesBlock}`,
|
|
|
11500
11948
|
}
|
|
11501
11949
|
const filesToCheck = Array.from(recentFiles).filter((file) => {
|
|
11502
11950
|
const ext = extname3(file).toLowerCase();
|
|
11503
|
-
return WATCH_EXTENSIONS.has(ext) &&
|
|
11951
|
+
return WATCH_EXTENSIONS.has(ext) && existsSync7(file);
|
|
11504
11952
|
});
|
|
11505
11953
|
console.debug("[Initial Scan] Files discovered for initial scan:", {
|
|
11506
11954
|
totalRecentFiles: recentFiles.size,
|
|
@@ -11522,7 +11970,7 @@ ${filesBlock}`,
|
|
|
11522
11970
|
const fileContents = await Promise.all(
|
|
11523
11971
|
filesToScan.map(async (file) => {
|
|
11524
11972
|
try {
|
|
11525
|
-
const content = await
|
|
11973
|
+
const content = await readFile6(file, "utf-8");
|
|
11526
11974
|
const relativePath = file.replace(projectPath + "/", "");
|
|
11527
11975
|
return { path: relativePath, content: content.slice(0, maxCharsPerFile) };
|
|
11528
11976
|
} catch {
|
|
@@ -11618,11 +12066,12 @@ ${filesBlock}`,
|
|
|
11618
12066
|
this.streamingManager.reportLedgerUpdate(issuesToStore.length, "goal-violation");
|
|
11619
12067
|
}
|
|
11620
12068
|
}
|
|
11621
|
-
|
|
11622
|
-
const {
|
|
12069
|
+
await this.runComplianceValidation(projectPath);
|
|
12070
|
+
const { resolveGoalViolation } = await import("./issue-store-ZIRP23EP.js");
|
|
12071
|
+
const { recordGoalViolationFixed } = await import("./goal-validator-ULKIBDPX.js");
|
|
11623
12072
|
const scannedFiles = new Set(valid.map((f) => f.path));
|
|
11624
12073
|
const filesWithViolations = new Set(issuesToStore.map((i) => i.file));
|
|
11625
|
-
for (const scannedFile of scannedFiles) {
|
|
12074
|
+
for (const scannedFile of Array.from(scannedFiles)) {
|
|
11626
12075
|
if (!filesWithViolations.has(scannedFile)) {
|
|
11627
12076
|
for (const goal of activeGoals) {
|
|
11628
12077
|
const resolvedCount = await resolveGoalViolation(scannedFile, goal.description, projectPath);
|
|
@@ -11658,7 +12107,7 @@ ${filesBlock}`,
|
|
|
11658
12107
|
const graph = new ContextGraph(projectPath);
|
|
11659
12108
|
if (hasLinear) {
|
|
11660
12109
|
try {
|
|
11661
|
-
const { LinearIngester } = await import("./linear-ingester-
|
|
12110
|
+
const { LinearIngester } = await import("./linear-ingester-XXPAZZRW.js");
|
|
11662
12111
|
const ingester = new LinearIngester(projectPath, graph);
|
|
11663
12112
|
await ingester.syncTickets();
|
|
11664
12113
|
if (!isInteractiveMode()) {
|
|
@@ -11672,7 +12121,7 @@ ${filesBlock}`,
|
|
|
11672
12121
|
}
|
|
11673
12122
|
if (hasGithub) {
|
|
11674
12123
|
try {
|
|
11675
|
-
const { GitHubIngester } = await import("./github-ingester-
|
|
12124
|
+
const { GitHubIngester } = await import("./github-ingester-ZOKK6GRS.js");
|
|
11676
12125
|
const ingester = new GitHubIngester(graph);
|
|
11677
12126
|
const token = await ingester.getApiToken();
|
|
11678
12127
|
const repoInfo = ingester.getRepoInfo(projectPath);
|
|
@@ -11772,7 +12221,7 @@ Use \`trie_watch start\` to begin autonomous scanning.`
|
|
|
11772
12221
|
).join("\n");
|
|
11773
12222
|
let agencyStatus = "";
|
|
11774
12223
|
try {
|
|
11775
|
-
const { getTrieAgent: getTrieAgent2 } = await import("./trie-agent-
|
|
12224
|
+
const { getTrieAgent: getTrieAgent2 } = await import("./trie-agent-3YDPEGHJ.js");
|
|
11776
12225
|
const trieAgent = getTrieAgent2(this.watchedDirectory || getWorkingDirectory(void 0, true));
|
|
11777
12226
|
await trieAgent.initialize();
|
|
11778
12227
|
const status = await trieAgent.getAgencyStatus();
|
|
@@ -11945,7 +12394,7 @@ To get a full report, run \`trie watch\` on your codebase.`
|
|
|
11945
12394
|
console.debug("[Watch] resolveNudgesForMissingFiles failed:", e);
|
|
11946
12395
|
}
|
|
11947
12396
|
try {
|
|
11948
|
-
const { getActiveGoals } = await import("./goal-validator-
|
|
12397
|
+
const { getActiveGoals } = await import("./goal-validator-ULKIBDPX.js");
|
|
11949
12398
|
const { getProjectState: getProjectState2 } = await import("./project-state-AHPA77SM.js");
|
|
11950
12399
|
const projectState = getProjectState2(directory);
|
|
11951
12400
|
await projectState.load();
|
|
@@ -11968,6 +12417,85 @@ To get a full report, run \`trie watch\` on your codebase.`
|
|
|
11968
12417
|
console.log(`[Watch] \u2713 Cleaned up ${totalResolved} stale nudge(s)`);
|
|
11969
12418
|
}
|
|
11970
12419
|
}
|
|
12420
|
+
/**
|
|
12421
|
+
* Run compliance validation to detect false negatives
|
|
12422
|
+
*/
|
|
12423
|
+
async runComplianceValidation(projectPath) {
|
|
12424
|
+
try {
|
|
12425
|
+
const config = await loadConfig(projectPath);
|
|
12426
|
+
const complianceFrameworks = config?.compliance?.standards || ["SOC2"];
|
|
12427
|
+
if (!config?.compliance?.falseNegativeDetection?.enabled) {
|
|
12428
|
+
return;
|
|
12429
|
+
}
|
|
12430
|
+
const samplingRate = config?.compliance?.falseNegativeDetection?.samplingRate || 0.1;
|
|
12431
|
+
if (Math.random() > samplingRate) {
|
|
12432
|
+
return;
|
|
12433
|
+
}
|
|
12434
|
+
console.log(`[Watch] Running compliance validation for frameworks: ${complianceFrameworks.join(", ")}`);
|
|
12435
|
+
const validation = await runFalseNegativeValidation(complianceFrameworks, projectPath);
|
|
12436
|
+
const criticalAlerts = validation.alerts.filter((a) => a.severity === "critical");
|
|
12437
|
+
if (criticalAlerts.length > 0) {
|
|
12438
|
+
console.error(`[Watch] \u26A0\uFE0F ${criticalAlerts.length} critical compliance alert(s) detected:`);
|
|
12439
|
+
for (const alert of criticalAlerts) {
|
|
12440
|
+
console.error(` - ${alert.type}: ${alert.description}`);
|
|
12441
|
+
console.error(` Action: ${alert.suggestedAction}`);
|
|
12442
|
+
}
|
|
12443
|
+
const complianceIssues = criticalAlerts.map((alert) => ({
|
|
12444
|
+
id: alert.id,
|
|
12445
|
+
hash: createHash3("sha256").update(`${alert.id}-${alert.timestamp}`).digest("hex"),
|
|
12446
|
+
file: "compliance-validation",
|
|
12447
|
+
line: 1,
|
|
12448
|
+
agent: "compliance-validator",
|
|
12449
|
+
issue: alert.description,
|
|
12450
|
+
fix: alert.suggestedAction,
|
|
12451
|
+
severity: alert.severity,
|
|
12452
|
+
timestamp: alert.timestamp,
|
|
12453
|
+
category: "compliance",
|
|
12454
|
+
confidence: alert.confidence,
|
|
12455
|
+
autoFixable: false
|
|
12456
|
+
}));
|
|
12457
|
+
await storeIssues(complianceIssues, basename(projectPath), projectPath);
|
|
12458
|
+
if (this.streamingManager) {
|
|
12459
|
+
this.streamingManager.reportLedgerUpdate(complianceIssues.length, "incident");
|
|
12460
|
+
}
|
|
12461
|
+
}
|
|
12462
|
+
const highAlerts = validation.alerts.filter((a) => a.severity === "high");
|
|
12463
|
+
if (highAlerts.length > 0) {
|
|
12464
|
+
console.warn(`[Watch] \u26A0\uFE0F ${highAlerts.length} high-priority compliance alert(s) detected`);
|
|
12465
|
+
}
|
|
12466
|
+
if (validation.coverageGaps.length > 0) {
|
|
12467
|
+
console.warn(`[Watch] \u26A0\uFE0F ${validation.coverageGaps.length} compliance coverage gap(s) detected`);
|
|
12468
|
+
}
|
|
12469
|
+
if (validation.recommendations.length > 0 && criticalAlerts.length === 0) {
|
|
12470
|
+
console.log(`[Watch] \u{1F4A1} ${validation.recommendations.length} compliance recommendation(s) available`);
|
|
12471
|
+
}
|
|
12472
|
+
if (validation.valid) {
|
|
12473
|
+
console.log("[Watch] \u2713 Compliance validation passed");
|
|
12474
|
+
}
|
|
12475
|
+
} catch (error) {
|
|
12476
|
+
console.error("[Watch] Compliance validation failed:", error);
|
|
12477
|
+
if (error instanceof Error) {
|
|
12478
|
+
const validationFailure = [{
|
|
12479
|
+
id: `compliance-validation-error-${Date.now()}`,
|
|
12480
|
+
hash: createHash3("sha256").update(`validation-error-${Date.now()}`).digest("hex"),
|
|
12481
|
+
file: "compliance-validation",
|
|
12482
|
+
line: 1,
|
|
12483
|
+
agent: "compliance-validator",
|
|
12484
|
+
issue: `Compliance validation system failure: ${error.message}`,
|
|
12485
|
+
fix: "Investigate and restore compliance validation system",
|
|
12486
|
+
severity: "critical",
|
|
12487
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12488
|
+
category: "compliance",
|
|
12489
|
+
confidence: 100,
|
|
12490
|
+
autoFixable: false
|
|
12491
|
+
}];
|
|
12492
|
+
await storeIssues(validationFailure, basename(projectPath), projectPath);
|
|
12493
|
+
if (this.streamingManager) {
|
|
12494
|
+
this.streamingManager.reportLedgerUpdate(1, "incident");
|
|
12495
|
+
}
|
|
12496
|
+
}
|
|
12497
|
+
}
|
|
12498
|
+
}
|
|
11971
12499
|
};
|
|
11972
12500
|
|
|
11973
12501
|
export {
|
|
@@ -11988,10 +12516,9 @@ export {
|
|
|
11988
12516
|
TrieGetNudgesTool,
|
|
11989
12517
|
TrieQueryContextTool,
|
|
11990
12518
|
TrieQueryLedgerBlocksTool,
|
|
11991
|
-
handleCheckpointTool,
|
|
11992
12519
|
TriePipelineTool,
|
|
11993
12520
|
GitHubBranchesTool,
|
|
11994
12521
|
InteractiveDashboard,
|
|
11995
12522
|
TrieWatchTool
|
|
11996
12523
|
};
|
|
11997
|
-
//# sourceMappingURL=chunk-
|
|
12524
|
+
//# sourceMappingURL=chunk-LQIMKE3P.js.map
|