@triedotdev/mcp 1.0.161 → 1.0.163

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,10 @@ import {
3
3
  } from "./chunk-JVMBCWKS.js";
4
4
  import {
5
5
  getTrieAgent
6
- } from "./chunk-ZGVPZZFM.js";
6
+ } from "./chunk-ERMLZJTK.js";
7
+ import {
8
+ parseGoalViolation
9
+ } from "./chunk-WCN7S3EI.js";
7
10
  import {
8
11
  CodebaseIndex
9
12
  } from "./chunk-Q5EKA5YA.js";
@@ -21,6 +24,9 @@ import {
21
24
  reasonAboutChangesHumanReadable,
22
25
  saveCheckpoint
23
26
  } from "./chunk-62JD7MIS.js";
27
+ import {
28
+ measureInitialGoalValue
29
+ } from "./chunk-ACU3IXZG.js";
24
30
  import {
25
31
  loadConfig,
26
32
  saveConfig
@@ -30,17 +36,14 @@ import {
30
36
  } from "./chunk-TN5WEKWI.js";
31
37
  import {
32
38
  findCrossProjectPatterns
33
- } from "./chunk-OWYOC5DX.js";
39
+ } from "./chunk-HFVPHQL3.js";
34
40
  import {
35
41
  TieredStorage,
36
42
  getStorage
37
- } from "./chunk-XMW2WTZB.js";
43
+ } from "./chunk-LLDZDU2Y.js";
38
44
  import {
39
45
  ContextGraph
40
46
  } from "./chunk-VUL52BQL.js";
41
- import {
42
- measureInitialGoalValue
43
- } from "./chunk-ACU3IXZG.js";
44
47
  import {
45
48
  getKeyFromKeychain,
46
49
  isAIAvailable,
@@ -457,6 +460,7 @@ function handleStreamUpdate(state, update) {
457
460
  const total = (update.data.governance || 0) + (update.data.facts || 0) + (update.data.blockers || 0) + (update.data.questions || 0);
458
461
  if (total > 0) {
459
462
  s = addActivity(s, `[+] Extracted ${total} signals (${update.data.governance}g, ${update.data.facts}f, ${update.data.blockers}b)`);
463
+ s.memoryTree = { ...s.memoryTree, loaded: false };
460
464
  }
461
465
  break;
462
466
  }
@@ -691,9 +695,12 @@ function dashboardReducer(state, action) {
691
695
  case "SET_MEMORY_TREE": {
692
696
  const blocks = action.ledgerBlocks ?? state.memoryTree.ledgerBlocks;
693
697
  const gotchas = action.storageGotchas ?? state.memoryTree.storageGotchas;
698
+ const facts = action.storageFacts ?? state.memoryTree.storageFacts;
699
+ const nudges = action.storageNudges ?? state.memoryTree.storageNudges;
694
700
  const expanded = new Set(state.memoryTree.expandedNodes);
695
701
  if (blocks.length > 0) expanded.add("ledger-chain");
696
702
  if (gotchas.length > 0) expanded.add("gotchas");
703
+ if (nudges.length > 0) expanded.add("patterns");
697
704
  return {
698
705
  ...state,
699
706
  memoryTree: {
@@ -702,7 +709,9 @@ function dashboardReducer(state, action) {
702
709
  snapshot: action.snapshot,
703
710
  globalPatterns: action.patterns,
704
711
  storageGovernance: action.storageGovernance ?? state.memoryTree.storageGovernance,
712
+ storageFacts: facts,
705
713
  storageGotchas: gotchas,
714
+ storageNudges: nudges,
706
715
  ledgerBlocks: blocks,
707
716
  expandedNodes: expanded
708
717
  }
@@ -967,7 +976,7 @@ function createInitialState() {
967
976
  },
968
977
  goalsPanel: { goals: [], selectedIndex: 0, selectedAchievedIndex: 0, inputMode: "browse", inputBuffer: "", lastRefresh: 0, scanningGoalId: null, scanningProgress: "" },
969
978
  hypothesesPanel: { hypotheses: [], selectedIndex: 0, selectedCompletedIndex: 0, inputMode: "browse", inputBuffer: "", lastRefresh: 0, scanningHypothesisId: null, scanningProgress: "" },
970
- memoryTree: { loaded: false, snapshot: null, globalPatterns: [], storageGovernance: [], storageGotchas: [], ledgerBlocks: [], expandedNodes: /* @__PURE__ */ new Set(["decisions"]), expandedItemId: null, selectedNode: "decisions", scrollPosition: 0, lastRefresh: 0 },
979
+ memoryTree: { loaded: false, snapshot: null, globalPatterns: [], storageGovernance: [], storageFacts: [], storageGotchas: [], storageNudges: [], ledgerBlocks: [], expandedNodes: /* @__PURE__ */ new Set(["decisions"]), expandedItemId: null, selectedNode: "decisions", scrollPosition: 0, lastRefresh: 0 },
971
980
  agentBrain: { loaded: false, governance: [], patterns: [], ledgerHash: null, selectedIndex: 0, expandedIndex: null },
972
981
  chatState: { messages: [], inputBuffer: "", loading: false, progress: null, messageQueue: [], currentSessionId: null, currentSessionTitle: null },
973
982
  chatArchivePanel: { sessions: [], selectedIndex: 0, showArchived: false, loading: false, inputMode: "browse", inputBuffer: "" },
@@ -1038,18 +1047,6 @@ function Header() {
1038
1047
  // src/cli/dashboard/components/Footer.tsx
1039
1048
  import React2 from "react";
1040
1049
  import { Box as Box2, Text as Text2, useStdout as useStdout2 } from "ink";
1041
-
1042
- // src/cli/dashboard/parse-goal-violation.ts
1043
- function parseGoalViolation(message) {
1044
- const match = message.match(/Goal "([^"]+)" violated in ([^:]+): (.+)/);
1045
- if (!match) return null;
1046
- const [, goal, file, violation] = match;
1047
- if (!goal || !file || !violation) return null;
1048
- const cleanViolation = violation.replace(/\s*\[\d+%\s*confidence\]\s*$/i, "").trim();
1049
- return { file: file.trim(), goal: goal.trim(), violation: cleanViolation };
1050
- }
1051
-
1052
- // src/cli/dashboard/components/Footer.tsx
1053
1050
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1054
1051
  var VIEW_LABELS = {
1055
1052
  overview: "Overview",
@@ -1171,10 +1168,27 @@ function Notification() {
1171
1168
  if (!notification || !notification.active) return null;
1172
1169
  if (notification.autoHideAt && Date.now() > notification.autoHideAt) return null;
1173
1170
  const color = notification.severity === "critical" ? "red" : notification.severity === "warning" ? "yellow" : "blue";
1174
- return /* @__PURE__ */ jsxs3(Box3, { paddingX: 1, children: [
1175
- /* @__PURE__ */ jsx4(Text3, { color, bold: true, children: "\u25CF " }),
1176
- /* @__PURE__ */ jsx4(Text3, { wrap: "wrap", children: notification.message })
1177
- ] });
1171
+ const borderColor = notification.severity === "critical" ? "red" : notification.severity === "warning" ? "yellow" : "blue";
1172
+ return /* @__PURE__ */ jsx4(Box3, { marginY: 1, marginX: 1, children: /* @__PURE__ */ jsxs3(
1173
+ Box3,
1174
+ {
1175
+ borderStyle: "single",
1176
+ borderColor,
1177
+ paddingX: 2,
1178
+ paddingY: 1,
1179
+ flexDirection: "column",
1180
+ children: [
1181
+ /* @__PURE__ */ jsxs3(Text3, { wrap: "wrap", children: [
1182
+ /* @__PURE__ */ jsx4(Text3, { color, bold: true, children: "\u25CF " }),
1183
+ notification.message
1184
+ ] }),
1185
+ notification.file && /* @__PURE__ */ jsxs3(Text3, { wrap: "wrap", dimColor: true, children: [
1186
+ " \u2192 ",
1187
+ notification.file
1188
+ ] })
1189
+ ]
1190
+ }
1191
+ ) });
1178
1192
  }
1179
1193
 
1180
1194
  // src/cli/dashboard/components/ConfigDialog.tsx
@@ -1966,7 +1980,7 @@ function AgentView() {
1966
1980
  const { getInsightStore } = await import("./insight-store-EC4PLSAW.js");
1967
1981
  const store = getInsightStore(workDir);
1968
1982
  await store.dismissInsight(insight.id);
1969
- const { getStorage: getStorage2 } = await import("./tiered-storage-THHKROJF.js");
1983
+ const { getStorage: getStorage2 } = await import("./tiered-storage-FHHAJR4P.js");
1970
1984
  const storage = getStorage2(workDir);
1971
1985
  await storage.dismissNudge(insight.id).catch(() => {
1972
1986
  });
@@ -1978,7 +1992,7 @@ function AgentView() {
1978
1992
  const clearAllNudges = useCallback(async () => {
1979
1993
  try {
1980
1994
  const workDir = getWorkingDirectory(void 0, true);
1981
- const { getStorage: getStorage2 } = await import("./tiered-storage-THHKROJF.js");
1995
+ const { getStorage: getStorage2 } = await import("./tiered-storage-FHHAJR4P.js");
1982
1996
  const storage = getStorage2(workDir);
1983
1997
  await storage.clearAllNudges();
1984
1998
  dispatch({ type: "CLEAR_ALL_INSIGHTS" });
@@ -2799,7 +2813,7 @@ function timeAgo2(iso) {
2799
2813
  function MemoryTreeView() {
2800
2814
  const { state, dispatch } = useDashboard();
2801
2815
  const { memoryTree } = state;
2802
- const { snapshot, globalPatterns, storageGovernance, storageGotchas, ledgerBlocks, expandedNodes, expandedItemId, selectedNode, loaded } = memoryTree;
2816
+ const { snapshot, globalPatterns, storageGovernance, storageFacts, storageGotchas, storageNudges, ledgerBlocks, expandedNodes, expandedItemId, selectedNode, loaded } = memoryTree;
2803
2817
  const { stdout } = useStdout8();
2804
2818
  const cols = stdout?.columns || 80;
2805
2819
  const narrow = cols < 60;
@@ -2809,14 +2823,16 @@ function MemoryTreeView() {
2809
2823
  const workDir = getWorkingDirectory(void 0, true);
2810
2824
  const graph = new ContextGraph(workDir);
2811
2825
  const storage = new TieredStorage(workDir);
2812
- const [snap, patterns, governance2, gotchas, blocks] = await Promise.all([
2826
+ const [snap, patterns, governance2, facts, gotchas, nudges, blocks] = await Promise.all([
2813
2827
  graph.getSnapshot(),
2814
2828
  findCrossProjectPatterns(2),
2815
2829
  storage.queryGovernance({ limit: 20 }).catch(() => []),
2830
+ storage.queryFacts({ limit: 20 }).catch(() => []),
2816
2831
  storage.queryGotchas({ limit: 20, resolved: false }).catch(() => []),
2832
+ storage.queryNudges({ limit: 20, resolved: false }).catch(() => []),
2817
2833
  getLedgerBlocks(workDir).catch(() => [])
2818
2834
  ]);
2819
- dispatch({ type: "SET_MEMORY_TREE", snapshot: snap, patterns, storageGovernance: governance2, storageGotchas: gotchas, ledgerBlocks: blocks });
2835
+ dispatch({ type: "SET_MEMORY_TREE", snapshot: snap, patterns, storageGovernance: governance2, storageFacts: facts, storageGotchas: gotchas, storageNudges: nudges, ledgerBlocks: blocks });
2820
2836
  } catch (err) {
2821
2837
  dispatch({ type: "ADD_ACTIVITY", message: "Context graph load error" });
2822
2838
  }
@@ -2887,18 +2903,13 @@ function MemoryTreeView() {
2887
2903
  ...n.data.reasoning != null ? { reasoning: n.data.reasoning } : {},
2888
2904
  ...n.data.outcome != null ? { outcome: n.data.outcome } : {}
2889
2905
  }));
2890
- const productGovernance = governance.filter(
2891
- (g) => g.tags.includes("product") || g.tags.includes("decision") || g.context.includes("user") || g.context.includes("product") || g.decision.length > 100
2892
- // Longer decisions are likely product decisions
2893
- );
2894
- const learnedSignals = governance.filter(
2895
- (g) => !productGovernance.includes(g)
2896
- );
2906
+ const productGovernance = governance.filter((g) => g.who === "user");
2907
+ const learnedSignals = governance.filter((g) => g.who !== "user");
2897
2908
  const hotspots = fileNodes.filter((n) => n.data.riskLevel === "critical" || n.data.riskLevel === "high").sort((a, b) => {
2898
2909
  const order = { critical: 0, high: 1 };
2899
2910
  return (order[a.data.riskLevel] ?? 2) - (order[b.data.riskLevel] ?? 2);
2900
2911
  });
2901
- const totalEntries = productGovernance.length + learnedSignals.length + incidentNodes.length + patternNodes.length + globalPatterns.length + hotspots.length + ledgerBlocks.length;
2912
+ const totalEntries = productGovernance.length + learnedSignals.length + (storageFacts?.length ?? 0) + (storageNudges?.length ?? 0) + incidentNodes.length + patternNodes.length + globalPatterns.length + hotspots.length + ledgerBlocks.length;
2902
2913
  const expandedGovernance = expandedItemId?.startsWith("decision-") ? governance.find((g) => `decision-${g.id}` === expandedItemId) : null;
2903
2914
  const expandedIncident = expandedItemId?.startsWith("incident-") ? incidentNodes.find((n) => `incident-${n.id}` === expandedItemId) : null;
2904
2915
  const expandedGotcha = expandedItemId?.startsWith("gotcha-") ? storageGotchas.find((g) => `gotcha-${g.id}` === expandedItemId) ?? null : null;
@@ -3164,13 +3175,35 @@ function MemoryTreeView() {
3164
3175
  ] })
3165
3176
  ] }, g.id);
3166
3177
  }),
3167
- renderHeader("patterns", "Learned Signals", learnedSignals.length + patternNodes.length, learnedSignals.length === 0 && patternNodes.length === 0 ? "-- Trie learns as you work" : void 0),
3178
+ renderHeader("patterns", "Learned Signals", learnedSignals.length + (storageFacts?.length ?? 0) + (storageNudges?.length ?? 0) + patternNodes.length, learnedSignals.length === 0 && (storageFacts?.length ?? 0) === 0 && (storageNudges?.length ?? 0) === 0 && patternNodes.length === 0 ? "-- Trie learns as you work" : void 0),
3168
3179
  expandedNodes.has("patterns") && /* @__PURE__ */ jsxs10(Fragment6, { children: [
3169
- learnedSignals.length > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
3180
+ (storageNudges?.length ?? 0) > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
3170
3181
  /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3171
3182
  " ",
3172
3183
  " ",
3173
- "Governance & Facts"
3184
+ "AI Detections"
3185
+ ] }),
3186
+ storageNudges.slice(0, 5).map((n) => {
3187
+ const descWidth = Math.max(30, contentWidth - 15);
3188
+ const desc = n.message.length > descWidth ? n.message.slice(0, descWidth - 3) + "..." : n.message;
3189
+ const severityColor = n.severity === "critical" ? "red" : n.severity === "high" ? "yellow" : "cyan";
3190
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
3191
+ " ",
3192
+ /* @__PURE__ */ jsx11(Text10, { color: severityColor, children: "\u25CF" }),
3193
+ " ",
3194
+ /* @__PURE__ */ jsx11(Text10, { children: desc }),
3195
+ narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3196
+ " ",
3197
+ timeAgo2(n.timestamp)
3198
+ ] })
3199
+ ] }, n.id);
3200
+ })
3201
+ ] }),
3202
+ learnedSignals.length > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: (storageNudges?.length ?? 0) > 0 ? 1 : 0, children: [
3203
+ /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3204
+ " ",
3205
+ " ",
3206
+ "Governance"
3174
3207
  ] }),
3175
3208
  learnedSignals.slice(0, 5).map((g) => {
3176
3209
  const descWidth = Math.max(30, contentWidth - 15);
@@ -3182,13 +3215,34 @@ function MemoryTreeView() {
3182
3215
  /* @__PURE__ */ jsx11(Text10, { children: desc }),
3183
3216
  narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3184
3217
  " ",
3185
- timeAgo2(g.when)
3218
+ timeAgo2(g.when ?? "")
3186
3219
  ] })
3187
3220
  ] }, g.id);
3188
3221
  })
3189
3222
  ] }),
3190
- patternNodes.length > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: learnedSignals.length > 0 ? 1 : 0, children: [
3191
- learnedSignals.length > 0 && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3223
+ (storageFacts?.length ?? 0) > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: (storageNudges?.length ?? 0) > 0 || learnedSignals.length > 0 ? 1 : 0, children: [
3224
+ /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3225
+ " ",
3226
+ " ",
3227
+ "Facts"
3228
+ ] }),
3229
+ storageFacts.slice(0, 5).map((f) => {
3230
+ const descWidth = Math.max(30, contentWidth - 15);
3231
+ const desc = f.fact.length > descWidth ? f.fact.slice(0, descWidth - 3) + "..." : f.fact;
3232
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
3233
+ " ",
3234
+ /* @__PURE__ */ jsx11(Text10, { color: "green", children: "\u25CB" }),
3235
+ " ",
3236
+ /* @__PURE__ */ jsx11(Text10, { children: desc }),
3237
+ narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3238
+ " ",
3239
+ timeAgo2(f.when)
3240
+ ] })
3241
+ ] }, f.id);
3242
+ })
3243
+ ] }),
3244
+ patternNodes.length > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: (storageNudges?.length ?? 0) > 0 || learnedSignals.length > 0 || (storageFacts?.length ?? 0) > 0 ? 1 : 0, children: [
3245
+ ((storageNudges?.length ?? 0) > 0 || learnedSignals.length > 0 || (storageFacts?.length ?? 0) > 0) && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3192
3246
  " ",
3193
3247
  " ",
3194
3248
  "Patterns"
@@ -3199,9 +3253,10 @@ function MemoryTreeView() {
3199
3253
  const confColor = conf > 70 ? "green" : conf > 40 ? "yellow" : void 0;
3200
3254
  const descWidth = Math.max(30, contentWidth - 15);
3201
3255
  const desc = n.data.description.length > descWidth ? n.data.description.slice(0, descWidth - 3) + "..." : n.data.description;
3256
+ const hasPreceding = (storageNudges?.length ?? 0) > 0 || learnedSignals.length > 0 || (storageFacts?.length ?? 0) > 0;
3202
3257
  return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
3203
- sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : learnedSignals.length > 0 ? " " : " ",
3204
- learnedSignals.length === 0 && " ",
3258
+ sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : hasPreceding ? " " : " ",
3259
+ !hasPreceding && " ",
3205
3260
  n.data.isAntiPattern ? /* @__PURE__ */ jsx11(Text10, { color: "red", children: "!" }) : /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "\u25CB" }),
3206
3261
  " ",
3207
3262
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: desc }) : /* @__PURE__ */ jsx11(Text10, { children: desc }),
@@ -3218,7 +3273,7 @@ function MemoryTreeView() {
3218
3273
  ] }, n.id);
3219
3274
  })
3220
3275
  ] }),
3221
- patternNodes.length === 0 && learnedSignals.length === 0 && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3276
+ patternNodes.length === 0 && learnedSignals.length === 0 && (storageFacts?.length ?? 0) === 0 && (storageNudges?.length ?? 0) === 0 && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3222
3277
  " ",
3223
3278
  " ",
3224
3279
  "No signals learned yet. Trie will extract insights as you work."
@@ -6851,7 +6906,7 @@ var TrieGetBlockersTool = class {
6851
6906
  const emoji = blocker.impact === "critical" ? "\u{1F534}" : blocker.impact === "high" ? "\u{1F7E0}" : blocker.impact === "medium" ? "\u{1F7E1}" : "\u{1F7E2}";
6852
6907
  output += `${emoji} [${impact}] ${blocker.blocker}
6853
6908
  `;
6854
- if (blocker.affectedAreas.length > 0) {
6909
+ if ((blocker.affectedAreas?.length ?? 0) > 0) {
6855
6910
  output += ` Affects: ${blocker.affectedAreas.join(", ")}
6856
6911
  `;
6857
6912
  }
@@ -6938,6 +6993,48 @@ function formatNudges(nudges) {
6938
6993
  }
6939
6994
  return out;
6940
6995
  }
6996
+ var TrieGetNudgesTool = class {
6997
+ async execute(input) {
6998
+ const workDir = input.directory || getWorkingDirectory(void 0, true);
6999
+ const storage = getStorage(workDir);
7000
+ await storage.initialize();
7001
+ const limit = input.limit ?? 20;
7002
+ const nudges = await storage.queryNudges({
7003
+ resolved: false,
7004
+ severity: input.severity,
7005
+ file: input.file,
7006
+ limit
7007
+ });
7008
+ if (nudges.length === 0) {
7009
+ return {
7010
+ content: [{
7011
+ type: "text",
7012
+ text: "No unresolved nudges (goal violations) found. Run trie scan to detect new issues."
7013
+ }]
7014
+ };
7015
+ }
7016
+ const { parseGoalViolation: parseGoalViolation2 } = await import("./parse-goal-violation-SACGFG3C.js");
7017
+ let out = `Found ${nudges.length} nudge(s) / goal violation(s):
7018
+
7019
+ `;
7020
+ for (const n of nudges) {
7021
+ const parsed = parseGoalViolation2(n.message);
7022
+ out += `\u26A0\uFE0F [${n.severity}] ${n.message}
7023
+ `;
7024
+ out += ` File: ${n.file || parsed?.file || "unknown"}
7025
+ `;
7026
+ if (parsed) {
7027
+ out += ` \u2192 trie_propose_fix: file="${parsed.file}" goal="${parsed.goal}" violation="${parsed.violation.slice(0, 80)}${parsed.violation.length > 80 ? "..." : ""}"
7028
+ `;
7029
+ }
7030
+ if (n.suggestedAction) out += ` Suggested: ${n.suggestedAction}
7031
+ `;
7032
+ out += "\n";
7033
+ }
7034
+ out += "To fix: call trie_propose_fix or trie_propose_fixes_batch with file, goal, violation from above.\n";
7035
+ return { content: [{ type: "text", text: out }] };
7036
+ }
7037
+ };
6941
7038
  function formatIncidents(incidents) {
6942
7039
  if (incidents.length === 0) return "No incidents found.";
6943
7040
  let out = `Found ${incidents.length} incident(s):
@@ -7130,6 +7227,77 @@ var TrieQueryContextTool = class {
7130
7227
  };
7131
7228
  }
7132
7229
  };
7230
+ var TrieQueryLedgerBlocksTool = class {
7231
+ async execute(input) {
7232
+ const workDir = input.directory || getWorkingDirectory(void 0, true);
7233
+ const analysis = input.analysis || "issues";
7234
+ const limit = input.limit ?? 50;
7235
+ const blocks = await getLedgerBlocks(workDir);
7236
+ const limited = blocks.slice(-limit);
7237
+ if (blocks.length === 0) {
7238
+ return {
7239
+ content: [{
7240
+ type: "text",
7241
+ text: "No ledger blocks found. Ledger blocks are created when issues are recorded during watch mode or scans."
7242
+ }]
7243
+ };
7244
+ }
7245
+ let output = `Ledger Chain: ${blocks.length} block(s)
7246
+
7247
+ `;
7248
+ if (analysis === "summary" || analysis === "all") {
7249
+ output += "**Block summary:**\n";
7250
+ for (let i = 0; i < limited.length; i++) {
7251
+ const b = limited[i];
7252
+ const critical = b.entries.filter((e) => e.severity === "critical").length;
7253
+ output += ` Block ${blocks.length - limited.length + i + 1}: ${b.date} \u2014 ${b.entries.length} entries (${critical} critical)
7254
+ `;
7255
+ }
7256
+ output += "\n";
7257
+ }
7258
+ if (analysis === "issues" || analysis === "all") {
7259
+ const allEntries = limited.flatMap((b) => b.entries).filter((e) => e.status !== "false-positive");
7260
+ const total = allEntries.length;
7261
+ if (total === 0) {
7262
+ output += "No active entries in these blocks.\n";
7263
+ } else {
7264
+ const byFile = /* @__PURE__ */ new Map();
7265
+ const bySeverity = /* @__PURE__ */ new Map();
7266
+ const byAgent = /* @__PURE__ */ new Map();
7267
+ for (const e of allEntries) {
7268
+ byFile.set(e.file, (byFile.get(e.file) || 0) + 1);
7269
+ bySeverity.set(e.severity, (bySeverity.get(e.severity) || 0) + 1);
7270
+ byAgent.set(e.agent, (byAgent.get(e.agent) || 0) + 1);
7271
+ }
7272
+ const topFiles = [...byFile.entries()].sort((a, b) => b[1] - a[1]).slice(0, 10);
7273
+ const topSeverities = [...bySeverity.entries()].sort((a, b) => b[1] - a[1]);
7274
+ const topAgents = [...byAgent.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
7275
+ output += `**Most frequent issues across ${total} entries:**
7276
+
7277
+ `;
7278
+ output += "**By file:**\n";
7279
+ for (const [file, count] of topFiles) {
7280
+ const short = file.split("/").pop() || file;
7281
+ output += ` ${short}: ${count}
7282
+ `;
7283
+ }
7284
+ output += "\n**By severity:**\n";
7285
+ for (const [sev, count] of topSeverities) {
7286
+ output += ` ${sev}: ${count}
7287
+ `;
7288
+ }
7289
+ output += "\n**By agent:**\n";
7290
+ for (const [agent, count] of topAgents) {
7291
+ output += ` ${agent}: ${count}
7292
+ `;
7293
+ }
7294
+ }
7295
+ }
7296
+ return {
7297
+ content: [{ type: "text", text: output.trim() }]
7298
+ };
7299
+ }
7300
+ };
7133
7301
 
7134
7302
  // src/tools/checkpoint.ts
7135
7303
  async function handleCheckpointTool(input) {
@@ -7815,7 +7983,7 @@ var CHAT_TOOLS = [
7815
7983
  },
7816
7984
  {
7817
7985
  name: "trie_get_blockers",
7818
- description: "Query active blockers \u2014 known problems preventing progress.",
7986
+ description: 'Query active blockers \u2014 known problems preventing progress. NOT the same as "blocks" (ledger chain).',
7819
7987
  input_schema: {
7820
7988
  type: "object",
7821
7989
  properties: {
@@ -7823,6 +7991,29 @@ var CHAT_TOOLS = [
7823
7991
  }
7824
7992
  }
7825
7993
  },
7994
+ {
7995
+ name: "trie_get_nudges",
7996
+ description: "Get unresolved nudges (goal violations). Use when automating fixes: call trie_get_nudges, then trie_propose_fix or trie_propose_fixes_batch with file/goal/violation from results.",
7997
+ input_schema: {
7998
+ type: "object",
7999
+ properties: {
8000
+ limit: { type: "number", description: "Max results (default 20)" },
8001
+ severity: { type: "string", enum: ["critical", "high", "warning", "info"], description: "Filter by severity" },
8002
+ file: { type: "string", description: "Filter by file path" }
8003
+ }
8004
+ }
8005
+ },
8006
+ {
8007
+ name: "trie_query_ledger_blocks",
8008
+ description: 'Query the ledger chain blocks \u2014 the tamper-evident chain of recorded issues. Use when user asks about "blocks", "ledger chain", "what issues in my blocks", "most frequent issues in blocks", etc. Returns block summary and aggregation of issues by file, severity, and agent.',
8009
+ input_schema: {
8010
+ type: "object",
8011
+ properties: {
8012
+ analysis: { type: "string", enum: ["summary", "issues", "all"], description: "What to analyze: summary (block counts), issues (most frequent files/severities/agents), or all (default: issues)" },
8013
+ limit: { type: "number", description: "Max blocks to include (default: 50)" }
8014
+ }
8015
+ }
8016
+ },
7826
8017
  {
7827
8018
  name: "trie_query_context",
7828
8019
  description: 'Natural-language search across ALL Trie context: goals, hypotheses, nudges (goal violations), incidents, governance, blockers, facts, and questions. Use for "what are my goals", "show hypotheses", "any nudges", "show incidents", "recent governance", etc.',
@@ -8092,6 +8283,16 @@ async function executeTool(name, input, onProgress) {
8092
8283
  const result = await tool.execute(withDir);
8093
8284
  return textFromResult(result);
8094
8285
  }
8286
+ case "trie_get_nudges": {
8287
+ const tool = new TrieGetNudgesTool();
8288
+ const result = await tool.execute(withDir);
8289
+ return textFromResult(result);
8290
+ }
8291
+ case "trie_query_ledger_blocks": {
8292
+ const tool = new TrieQueryLedgerBlocksTool();
8293
+ const result = await tool.execute(withDir);
8294
+ return textFromResult(result);
8295
+ }
8095
8296
  case "trie_query_context": {
8096
8297
  const tool = new TrieQueryContextTool();
8097
8298
  const result = await tool.execute(withDir);
@@ -8624,6 +8825,7 @@ var SYSTEM_PROMPT = `You are Trie, a code assistant embedded in a terminal TUI.
8624
8825
  - Check recent goal violations (nudges) in the provided project context
8625
8826
  - Record incidents, decisions, and feedback about the codebase
8626
8827
  - Query ALL stored context: goals, hypotheses, nudges, decisions, blockers via trie_query_context
8828
+ - Query ledger chain blocks (issues recorded in blocks) via trie_query_ledger_blocks \u2014 use for "blocks", "ledger chain", "most frequent issues"
8627
8829
  - Create and manage goals and hypotheses
8628
8830
  - Propose fixes for goal violations (requires user confirmation before spawning Claude Code)
8629
8831
  - Run AI-powered scans to detect goal violations across the entire codebase
@@ -8635,6 +8837,10 @@ var SYSTEM_PROMPT = `You are Trie, a code assistant embedded in a terminal TUI.
8635
8837
  - It uses AI analysis and is much more reliable than regex pattern matching
8636
8838
  - You also have trie_search_files but it requires ripgrep (often not installed)
8637
8839
 
8840
+ **CRITICAL - "blocks" vs "blockers" (different concepts):**
8841
+ - **Blocks** = Ledger chain blocks (Memory \u2192 Ledger Chain). Each block has entries (recorded issues). Use trie_query_ledger_blocks when user asks about "blocks", "ledger chain", "what issues in my blocks", "most frequent issues in blocks", etc.
8842
+ - **Blockers** = Things preventing progress (from governance). Use trie_get_blockers when user asks about "blockers" or "what's blocking me".
8843
+
8638
8844
  **When user asks "what are my goals", "show hypotheses", "any nudges", "latest decisions", etc.:**
8639
8845
  - The project context block already includes goals, hypotheses, nudges, decisions, blockers
8640
8846
  - If the user wants more detail or the context seems stale: Call trie_query_context with the relevant query (e.g. query: "goals", type: "goals")
@@ -8661,9 +8867,9 @@ var SYSTEM_PROMPT = `You are Trie, a code assistant embedded in a terminal TUI.
8661
8867
  3. NEVER use numeric IDs like 1, 2, 3 - always use the full ID like "hyp-1771957097120-bogco0"
8662
8868
  4. If hypothesis IDs aren't in the context, first call trie_query_context with type="hypotheses" to fetch them
8663
8869
 
8664
- **When user asks to fix violations:**
8665
- 1. Look in "Recent goal violations (nudges)" section of project context
8666
- 2. Extract: file path, goal description, and violation details for ALL files
8870
+ **When user asks to fix violations (or automate fixes):**
8871
+ 1. Call trie_get_nudges for full list of unresolved nudges (or check "Recent goal violations" in trie://context)
8872
+ 2. Extract: file path, goal description, and violation details for ALL nudges
8667
8873
  3. If multiple violations: Call trie_propose_fixes_batch ONCE with all fixes
8668
8874
  4. If single violation: Call trie_propose_fix once
8669
8875
  5. AFTER the tool call completes, the system will ask for user confirmation - do NOT add your own confirmation message
@@ -9505,7 +9711,7 @@ function DashboardApp({ onReady }) {
9505
9711
  const loadPersistedNudges = useCallback7(async () => {
9506
9712
  try {
9507
9713
  const workDir = getWorkingDirectory(void 0, true);
9508
- const { getStorage: getStorage2 } = await import("./tiered-storage-THHKROJF.js");
9714
+ const { getStorage: getStorage2 } = await import("./tiered-storage-FHHAJR4P.js");
9509
9715
  const storage = getStorage2(workDir);
9510
9716
  await storage.initialize();
9511
9717
  const nudges = await storage.queryNudges({ resolved: false, limit: 50 });
@@ -11096,7 +11302,7 @@ Use \`trie_watch start\` to begin autonomous scanning.`
11096
11302
  ).join("\n");
11097
11303
  let agencyStatus = "";
11098
11304
  try {
11099
- const { getTrieAgent: getTrieAgent2 } = await import("./trie-agent-VRV6GKJP.js");
11305
+ const { getTrieAgent: getTrieAgent2 } = await import("./trie-agent-NYSPGZYS.js");
11100
11306
  const trieAgent = getTrieAgent2(this.watchedDirectory || getWorkingDirectory(void 0, true));
11101
11307
  await trieAgent.initialize();
11102
11308
  const status = await trieAgent.getAgencyStatus();
@@ -11226,11 +11432,13 @@ export {
11226
11432
  TrieGetBlockersTool,
11227
11433
  TrieGetRelatedGovernanceTool,
11228
11434
  TrieGetRelatedDecisionsTool,
11435
+ TrieGetNudgesTool,
11229
11436
  TrieQueryContextTool,
11437
+ TrieQueryLedgerBlocksTool,
11230
11438
  handleCheckpointTool,
11231
11439
  TriePipelineTool,
11232
11440
  GitHubBranchesTool,
11233
11441
  InteractiveDashboard,
11234
11442
  TrieWatchTool
11235
11443
  };
11236
- //# sourceMappingURL=chunk-MPHYM7M6.js.map
11444
+ //# sourceMappingURL=chunk-XSKLOBD2.js.map