@triedotdev/mcp 1.0.162 → 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.
@@ -4,6 +4,9 @@ import {
4
4
  import {
5
5
  getTrieAgent
6
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
@@ -38,9 +44,6 @@ import {
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,
@@ -693,9 +696,11 @@ function dashboardReducer(state, action) {
693
696
  const blocks = action.ledgerBlocks ?? state.memoryTree.ledgerBlocks;
694
697
  const gotchas = action.storageGotchas ?? state.memoryTree.storageGotchas;
695
698
  const facts = action.storageFacts ?? state.memoryTree.storageFacts;
699
+ const nudges = action.storageNudges ?? state.memoryTree.storageNudges;
696
700
  const expanded = new Set(state.memoryTree.expandedNodes);
697
701
  if (blocks.length > 0) expanded.add("ledger-chain");
698
702
  if (gotchas.length > 0) expanded.add("gotchas");
703
+ if (nudges.length > 0) expanded.add("patterns");
699
704
  return {
700
705
  ...state,
701
706
  memoryTree: {
@@ -706,6 +711,7 @@ function dashboardReducer(state, action) {
706
711
  storageGovernance: action.storageGovernance ?? state.memoryTree.storageGovernance,
707
712
  storageFacts: facts,
708
713
  storageGotchas: gotchas,
714
+ storageNudges: nudges,
709
715
  ledgerBlocks: blocks,
710
716
  expandedNodes: expanded
711
717
  }
@@ -970,7 +976,7 @@ function createInitialState() {
970
976
  },
971
977
  goalsPanel: { goals: [], selectedIndex: 0, selectedAchievedIndex: 0, inputMode: "browse", inputBuffer: "", lastRefresh: 0, scanningGoalId: null, scanningProgress: "" },
972
978
  hypothesesPanel: { hypotheses: [], selectedIndex: 0, selectedCompletedIndex: 0, inputMode: "browse", inputBuffer: "", lastRefresh: 0, scanningHypothesisId: null, scanningProgress: "" },
973
- memoryTree: { loaded: false, snapshot: null, globalPatterns: [], storageGovernance: [], storageFacts: [], 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 },
974
980
  agentBrain: { loaded: false, governance: [], patterns: [], ledgerHash: null, selectedIndex: 0, expandedIndex: null },
975
981
  chatState: { messages: [], inputBuffer: "", loading: false, progress: null, messageQueue: [], currentSessionId: null, currentSessionTitle: null },
976
982
  chatArchivePanel: { sessions: [], selectedIndex: 0, showArchived: false, loading: false, inputMode: "browse", inputBuffer: "" },
@@ -1041,18 +1047,6 @@ function Header() {
1041
1047
  // src/cli/dashboard/components/Footer.tsx
1042
1048
  import React2 from "react";
1043
1049
  import { Box as Box2, Text as Text2, useStdout as useStdout2 } from "ink";
1044
-
1045
- // src/cli/dashboard/parse-goal-violation.ts
1046
- function parseGoalViolation(message) {
1047
- const match = message.match(/Goal "([^"]+)" violated in ([^:]+): (.+)/);
1048
- if (!match) return null;
1049
- const [, goal, file, violation] = match;
1050
- if (!goal || !file || !violation) return null;
1051
- const cleanViolation = violation.replace(/\s*\[\d+%\s*confidence\]\s*$/i, "").trim();
1052
- return { file: file.trim(), goal: goal.trim(), violation: cleanViolation };
1053
- }
1054
-
1055
- // src/cli/dashboard/components/Footer.tsx
1056
1050
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1057
1051
  var VIEW_LABELS = {
1058
1052
  overview: "Overview",
@@ -1188,7 +1182,7 @@ function Notification() {
1188
1182
  /* @__PURE__ */ jsx4(Text3, { color, bold: true, children: "\u25CF " }),
1189
1183
  notification.message
1190
1184
  ] }),
1191
- notification.file && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
1185
+ notification.file && /* @__PURE__ */ jsxs3(Text3, { wrap: "wrap", dimColor: true, children: [
1192
1186
  " \u2192 ",
1193
1187
  notification.file
1194
1188
  ] })
@@ -2819,7 +2813,7 @@ function timeAgo2(iso) {
2819
2813
  function MemoryTreeView() {
2820
2814
  const { state, dispatch } = useDashboard();
2821
2815
  const { memoryTree } = state;
2822
- const { snapshot, globalPatterns, storageGovernance, storageFacts, storageGotchas, ledgerBlocks, expandedNodes, expandedItemId, selectedNode, loaded } = memoryTree;
2816
+ const { snapshot, globalPatterns, storageGovernance, storageFacts, storageGotchas, storageNudges, ledgerBlocks, expandedNodes, expandedItemId, selectedNode, loaded } = memoryTree;
2823
2817
  const { stdout } = useStdout8();
2824
2818
  const cols = stdout?.columns || 80;
2825
2819
  const narrow = cols < 60;
@@ -2829,15 +2823,16 @@ function MemoryTreeView() {
2829
2823
  const workDir = getWorkingDirectory(void 0, true);
2830
2824
  const graph = new ContextGraph(workDir);
2831
2825
  const storage = new TieredStorage(workDir);
2832
- const [snap, patterns, governance2, facts, gotchas, blocks] = await Promise.all([
2826
+ const [snap, patterns, governance2, facts, gotchas, nudges, blocks] = await Promise.all([
2833
2827
  graph.getSnapshot(),
2834
2828
  findCrossProjectPatterns(2),
2835
2829
  storage.queryGovernance({ limit: 20 }).catch(() => []),
2836
2830
  storage.queryFacts({ limit: 20 }).catch(() => []),
2837
2831
  storage.queryGotchas({ limit: 20, resolved: false }).catch(() => []),
2832
+ storage.queryNudges({ limit: 20, resolved: false }).catch(() => []),
2838
2833
  getLedgerBlocks(workDir).catch(() => [])
2839
2834
  ]);
2840
- dispatch({ type: "SET_MEMORY_TREE", snapshot: snap, patterns, storageGovernance: governance2, storageFacts: facts, storageGotchas: gotchas, ledgerBlocks: blocks });
2835
+ dispatch({ type: "SET_MEMORY_TREE", snapshot: snap, patterns, storageGovernance: governance2, storageFacts: facts, storageGotchas: gotchas, storageNudges: nudges, ledgerBlocks: blocks });
2841
2836
  } catch (err) {
2842
2837
  dispatch({ type: "ADD_ACTIVITY", message: "Context graph load error" });
2843
2838
  }
@@ -2914,7 +2909,7 @@ function MemoryTreeView() {
2914
2909
  const order = { critical: 0, high: 1 };
2915
2910
  return (order[a.data.riskLevel] ?? 2) - (order[b.data.riskLevel] ?? 2);
2916
2911
  });
2917
- const totalEntries = productGovernance.length + learnedSignals.length + (storageFacts?.length ?? 0) + 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;
2918
2913
  const expandedGovernance = expandedItemId?.startsWith("decision-") ? governance.find((g) => `decision-${g.id}` === expandedItemId) : null;
2919
2914
  const expandedIncident = expandedItemId?.startsWith("incident-") ? incidentNodes.find((n) => `incident-${n.id}` === expandedItemId) : null;
2920
2915
  const expandedGotcha = expandedItemId?.startsWith("gotcha-") ? storageGotchas.find((g) => `gotcha-${g.id}` === expandedItemId) ?? null : null;
@@ -3180,9 +3175,31 @@ function MemoryTreeView() {
3180
3175
  ] })
3181
3176
  ] }, g.id);
3182
3177
  }),
3183
- renderHeader("patterns", "Learned Signals", learnedSignals.length + (storageFacts?.length ?? 0) + patternNodes.length, learnedSignals.length === 0 && (storageFacts?.length ?? 0) === 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),
3184
3179
  expandedNodes.has("patterns") && /* @__PURE__ */ jsxs10(Fragment6, { children: [
3185
- learnedSignals.length > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
3180
+ (storageNudges?.length ?? 0) > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
3181
+ /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3182
+ " ",
3183
+ " ",
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: [
3186
3203
  /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3187
3204
  " ",
3188
3205
  " ",
@@ -3203,7 +3220,7 @@ function MemoryTreeView() {
3203
3220
  ] }, g.id);
3204
3221
  })
3205
3222
  ] }),
3206
- (storageFacts?.length ?? 0) > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: learnedSignals.length > 0 ? 1 : 0, children: [
3223
+ (storageFacts?.length ?? 0) > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: (storageNudges?.length ?? 0) > 0 || learnedSignals.length > 0 ? 1 : 0, children: [
3207
3224
  /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
3208
3225
  " ",
3209
3226
  " ",
@@ -3224,8 +3241,8 @@ function MemoryTreeView() {
3224
3241
  ] }, f.id);
3225
3242
  })
3226
3243
  ] }),
3227
- patternNodes.length > 0 && /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", marginTop: learnedSignals.length > 0 || (storageFacts?.length ?? 0) > 0 ? 1 : 0, children: [
3228
- (learnedSignals.length > 0 || (storageFacts?.length ?? 0) > 0) && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
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: [
3229
3246
  " ",
3230
3247
  " ",
3231
3248
  "Patterns"
@@ -3236,7 +3253,7 @@ function MemoryTreeView() {
3236
3253
  const confColor = conf > 70 ? "green" : conf > 40 ? "yellow" : void 0;
3237
3254
  const descWidth = Math.max(30, contentWidth - 15);
3238
3255
  const desc = n.data.description.length > descWidth ? n.data.description.slice(0, descWidth - 3) + "..." : n.data.description;
3239
- const hasPreceding = learnedSignals.length > 0 || (storageFacts?.length ?? 0) > 0;
3256
+ const hasPreceding = (storageNudges?.length ?? 0) > 0 || learnedSignals.length > 0 || (storageFacts?.length ?? 0) > 0;
3240
3257
  return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
3241
3258
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : hasPreceding ? " " : " ",
3242
3259
  !hasPreceding && " ",
@@ -3256,7 +3273,7 @@ function MemoryTreeView() {
3256
3273
  ] }, n.id);
3257
3274
  })
3258
3275
  ] }),
3259
- patternNodes.length === 0 && learnedSignals.length === 0 && (storageFacts?.length ?? 0) === 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: [
3260
3277
  " ",
3261
3278
  " ",
3262
3279
  "No signals learned yet. Trie will extract insights as you work."
@@ -6889,7 +6906,7 @@ var TrieGetBlockersTool = class {
6889
6906
  const emoji = blocker.impact === "critical" ? "\u{1F534}" : blocker.impact === "high" ? "\u{1F7E0}" : blocker.impact === "medium" ? "\u{1F7E1}" : "\u{1F7E2}";
6890
6907
  output += `${emoji} [${impact}] ${blocker.blocker}
6891
6908
  `;
6892
- if (blocker.affectedAreas.length > 0) {
6909
+ if ((blocker.affectedAreas?.length ?? 0) > 0) {
6893
6910
  output += ` Affects: ${blocker.affectedAreas.join(", ")}
6894
6911
  `;
6895
6912
  }
@@ -6976,6 +6993,48 @@ function formatNudges(nudges) {
6976
6993
  }
6977
6994
  return out;
6978
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
+ };
6979
7038
  function formatIncidents(incidents) {
6980
7039
  if (incidents.length === 0) return "No incidents found.";
6981
7040
  let out = `Found ${incidents.length} incident(s):
@@ -7932,6 +7991,18 @@ var CHAT_TOOLS = [
7932
7991
  }
7933
7992
  }
7934
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
+ },
7935
8006
  {
7936
8007
  name: "trie_query_ledger_blocks",
7937
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.',
@@ -8212,6 +8283,11 @@ async function executeTool(name, input, onProgress) {
8212
8283
  const result = await tool.execute(withDir);
8213
8284
  return textFromResult(result);
8214
8285
  }
8286
+ case "trie_get_nudges": {
8287
+ const tool = new TrieGetNudgesTool();
8288
+ const result = await tool.execute(withDir);
8289
+ return textFromResult(result);
8290
+ }
8215
8291
  case "trie_query_ledger_blocks": {
8216
8292
  const tool = new TrieQueryLedgerBlocksTool();
8217
8293
  const result = await tool.execute(withDir);
@@ -8791,9 +8867,9 @@ var SYSTEM_PROMPT = `You are Trie, a code assistant embedded in a terminal TUI.
8791
8867
  3. NEVER use numeric IDs like 1, 2, 3 - always use the full ID like "hyp-1771957097120-bogco0"
8792
8868
  4. If hypothesis IDs aren't in the context, first call trie_query_context with type="hypotheses" to fetch them
8793
8869
 
8794
- **When user asks to fix violations:**
8795
- 1. Look in "Recent goal violations (nudges)" section of project context
8796
- 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
8797
8873
  3. If multiple violations: Call trie_propose_fixes_batch ONCE with all fixes
8798
8874
  4. If single violation: Call trie_propose_fix once
8799
8875
  5. AFTER the tool call completes, the system will ask for user confirmation - do NOT add your own confirmation message
@@ -11356,6 +11432,7 @@ export {
11356
11432
  TrieGetBlockersTool,
11357
11433
  TrieGetRelatedGovernanceTool,
11358
11434
  TrieGetRelatedDecisionsTool,
11435
+ TrieGetNudgesTool,
11359
11436
  TrieQueryContextTool,
11360
11437
  TrieQueryLedgerBlocksTool,
11361
11438
  handleCheckpointTool,
@@ -11364,4 +11441,4 @@ export {
11364
11441
  InteractiveDashboard,
11365
11442
  TrieWatchTool
11366
11443
  };
11367
- //# sourceMappingURL=chunk-Q4K7CFCK.js.map
11444
+ //# sourceMappingURL=chunk-XSKLOBD2.js.map