@triedotdev/mcp 1.0.135 → 1.0.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{chunk-DFHMB44X.js → chunk-4JQ6W7LW.js} +3 -4
  2. package/dist/chunk-4JQ6W7LW.js.map +1 -0
  3. package/dist/{chunk-WS6OA7H6.js → chunk-4MJ52WBH.js} +2 -3
  4. package/dist/chunk-4MJ52WBH.js.map +1 -0
  5. package/dist/{chunk-UHMMANC2.js → chunk-6EP2VTHC.js} +15 -15
  6. package/dist/chunk-6EP2VTHC.js.map +1 -0
  7. package/dist/{chunk-T4THB2OR.js → chunk-A6PWS6ZV.js} +38 -27
  8. package/dist/chunk-A6PWS6ZV.js.map +1 -0
  9. package/dist/{chunk-TFGNTSMH.js → chunk-AXYNWBME.js} +319 -208
  10. package/dist/chunk-AXYNWBME.js.map +1 -0
  11. package/dist/{chunk-LRQV7SGQ.js → chunk-DPZLABUC.js} +33 -33
  12. package/dist/chunk-DPZLABUC.js.map +1 -0
  13. package/dist/{chunk-3DPVJQNM.js → chunk-G74XEI7K.js} +14 -15
  14. package/dist/chunk-G74XEI7K.js.map +1 -0
  15. package/dist/{goal-validator-KLAK5TZN.js → chunk-HUR67JXG.js} +72 -34
  16. package/dist/chunk-HUR67JXG.js.map +1 -0
  17. package/dist/{chunk-6OUWNVLX.js → chunk-K6NTRSDF.js} +4 -4
  18. package/dist/{chunk-JCU6REX7.js → chunk-O6OTJI3W.js} +16 -5
  19. package/dist/{chunk-JCU6REX7.js.map → chunk-O6OTJI3W.js.map} +1 -1
  20. package/dist/{chunk-T62V4H5O.js → chunk-QM5VIDFN.js} +76 -72
  21. package/dist/chunk-QM5VIDFN.js.map +1 -0
  22. package/dist/{chunk-4YJ6KLGI.js → chunk-QNKBXOIQ.js} +7 -5
  23. package/dist/chunk-QNKBXOIQ.js.map +1 -0
  24. package/dist/{chunk-JAKMZI5S.js → chunk-R3WZI6QZ.js} +290 -179
  25. package/dist/chunk-R3WZI6QZ.js.map +1 -0
  26. package/dist/{chunk-VRLMTOB6.js → chunk-TIMIKBY2.js} +1 -1
  27. package/dist/chunk-TIMIKBY2.js.map +1 -0
  28. package/dist/cli/main.js +104 -100
  29. package/dist/cli/main.js.map +1 -1
  30. package/dist/cli/yolo-daemon.js +14 -14
  31. package/dist/cli/yolo-daemon.js.map +1 -1
  32. package/dist/{client-OVI6TBX7.js → client-BZHI675W.js} +2 -2
  33. package/dist/{goal-manager-FAK7H4RR.js → goal-manager-62IL6WGY.js} +6 -7
  34. package/dist/goal-validator-HPPBSDXD.js +22 -0
  35. package/dist/guardian-agent-YKG5XURG.js +30 -0
  36. package/dist/{hypothesis-I276JIDW.js → hypothesis-W37VG6DA.js} +6 -7
  37. package/dist/index.js +263 -257
  38. package/dist/index.js.map +1 -1
  39. package/dist/{insight-store-F5KDBY5Y.js → insight-store-U3NYTOJE.js} +5 -3
  40. package/dist/issue-store-EZMBHOVN.js +32 -0
  41. package/dist/{output-manager-BOTMXSND.js → output-manager-DZO5LGSG.js} +2 -2
  42. package/dist/output-manager-DZO5LGSG.js.map +1 -0
  43. package/dist/ui/chat.html +1 -1
  44. package/package.json +1 -1
  45. package/dist/chunk-3DPVJQNM.js.map +0 -1
  46. package/dist/chunk-4YJ6KLGI.js.map +0 -1
  47. package/dist/chunk-DFHMB44X.js.map +0 -1
  48. package/dist/chunk-JAKMZI5S.js.map +0 -1
  49. package/dist/chunk-LRQV7SGQ.js.map +0 -1
  50. package/dist/chunk-PEJEYWVR.js +0 -135
  51. package/dist/chunk-PEJEYWVR.js.map +0 -1
  52. package/dist/chunk-T4THB2OR.js.map +0 -1
  53. package/dist/chunk-T62V4H5O.js.map +0 -1
  54. package/dist/chunk-TFGNTSMH.js.map +0 -1
  55. package/dist/chunk-UHMMANC2.js.map +0 -1
  56. package/dist/chunk-VRLMTOB6.js.map +0 -1
  57. package/dist/chunk-WS6OA7H6.js.map +0 -1
  58. package/dist/goal-validator-KLAK5TZN.js.map +0 -1
  59. package/dist/guardian-agent-3EUJUAJ2.js +0 -27
  60. package/dist/ledger-WKVJWHBX.js +0 -17
  61. /package/dist/{chunk-6OUWNVLX.js.map → chunk-K6NTRSDF.js.map} +0 -0
  62. /package/dist/{client-OVI6TBX7.js.map → client-BZHI675W.js.map} +0 -0
  63. /package/dist/{goal-manager-FAK7H4RR.js.map → goal-manager-62IL6WGY.js.map} +0 -0
  64. /package/dist/{guardian-agent-3EUJUAJ2.js.map → goal-validator-HPPBSDXD.js.map} +0 -0
  65. /package/dist/{hypothesis-I276JIDW.js.map → guardian-agent-YKG5XURG.js.map} +0 -0
  66. /package/dist/{insight-store-F5KDBY5Y.js.map → hypothesis-W37VG6DA.js.map} +0 -0
  67. /package/dist/{ledger-WKVJWHBX.js.map → insight-store-U3NYTOJE.js.map} +0 -0
  68. /package/dist/{output-manager-BOTMXSND.js.map → issue-store-EZMBHOVN.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
- getGuardian
3
- } from "./chunk-T62V4H5O.js";
2
+ getTrieAgent
3
+ } from "./chunk-QM5VIDFN.js";
4
4
  import {
5
5
  getChatStore
6
6
  } from "./chunk-DFPVUMVE.js";
@@ -13,22 +13,25 @@ import {
13
13
  perceiveCurrentChanges,
14
14
  reasonAboutChangesHumanReadable,
15
15
  saveCheckpoint
16
- } from "./chunk-6OUWNVLX.js";
16
+ } from "./chunk-K6NTRSDF.js";
17
17
  import {
18
18
  IncidentIndex
19
19
  } from "./chunk-WHIQAGB7.js";
20
20
  import {
21
21
  findCrossProjectPatterns
22
- } from "./chunk-3DPVJQNM.js";
22
+ } from "./chunk-G74XEI7K.js";
23
+ import {
24
+ measureInitialGoalValue
25
+ } from "./chunk-HUR67JXG.js";
23
26
  import {
24
27
  getKeyFromKeychain,
25
28
  isAIAvailable,
26
29
  runAIWithTools,
27
30
  setAPIKey
28
- } from "./chunk-JCU6REX7.js";
31
+ } from "./chunk-O6OTJI3W.js";
29
32
  import {
30
- getGuardianState
31
- } from "./chunk-UHMMANC2.js";
33
+ getProjectState
34
+ } from "./chunk-6EP2VTHC.js";
32
35
  import {
33
36
  TieredStorage,
34
37
  getStorage
@@ -38,10 +41,10 @@ import {
38
41
  } from "./chunk-55CBWOEZ.js";
39
42
  import {
40
43
  getOutputManager
41
- } from "./chunk-VRLMTOB6.js";
44
+ } from "./chunk-TIMIKBY2.js";
42
45
  import {
43
46
  getLedgerBlocks
44
- } from "./chunk-PEJEYWVR.js";
47
+ } from "./chunk-R3WZI6QZ.js";
45
48
  import {
46
49
  getTrieDirectory,
47
50
  getWorkingDirectory
@@ -1478,7 +1481,7 @@ function ConfigDialog({ onClose }) {
1478
1481
  }
1479
1482
 
1480
1483
  // src/cli/dashboard/components/HelpDialog.tsx
1481
- import { Box as Box5, Text as Text5 } from "ink";
1484
+ import { Box as Box5, Text as Text5, useStdout as useStdout4 } from "ink";
1482
1485
  import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1483
1486
  var VIEW_HELP = {
1484
1487
  overview: [
@@ -1495,8 +1498,8 @@ var VIEW_HELP = {
1495
1498
  agent: [
1496
1499
  { key: "j / \u2193", description: "Move down" },
1497
1500
  { key: "k / \u2191", description: "Move up" },
1498
- { key: "enter", description: "Expand selected nudge" },
1499
- { key: "f", description: "Spawn Claude Code to fix selected goal violation" },
1501
+ { key: "enter", description: "Fix goal violation (or expand if not a violation)" },
1502
+ { key: "f", description: "Force spawn Claude Code fix" },
1500
1503
  { key: "d", description: "Dismiss selected nudge" },
1501
1504
  { key: "tab", description: "Navigate between views" },
1502
1505
  { key: "s", description: "Open Settings" },
@@ -1568,34 +1571,36 @@ var VIEW_HELP = {
1568
1571
  function HelpDialog({ view }) {
1569
1572
  const shortcuts = VIEW_HELP[view] || VIEW_HELP.overview;
1570
1573
  const viewName = view.charAt(0).toUpperCase() + view.slice(1);
1574
+ const { stdout } = useStdout4();
1575
+ const cols = stdout?.columns || 80;
1576
+ const narrow = cols < 70;
1577
+ const dialogWidth = narrow ? "95%" : "80%";
1578
+ const keyWidth = narrow ? 10 : 12;
1571
1579
  return /* @__PURE__ */ jsxs5(
1572
1580
  Box5,
1573
1581
  {
1574
1582
  flexDirection: "column",
1575
1583
  borderStyle: "round",
1576
1584
  borderColor: "cyan",
1577
- paddingX: 2,
1585
+ paddingX: narrow ? 1 : 2,
1578
1586
  paddingY: 1,
1579
- width: "80%",
1587
+ width: dialogWidth,
1580
1588
  alignSelf: "center",
1581
- marginTop: 2,
1589
+ marginTop: narrow ? 1 : 2,
1582
1590
  children: [
1583
- /* @__PURE__ */ jsxs5(Text5, { bold: true, color: "cyan", children: [
1584
- viewName,
1585
- " View - Keyboard Shortcuts"
1586
- ] }),
1587
- /* @__PURE__ */ jsx6(Box5, { marginTop: 1, flexDirection: "column", gap: 0, children: shortcuts.map(({ key, description }, idx) => /* @__PURE__ */ jsxs5(Box5, { gap: 2, children: [
1588
- /* @__PURE__ */ jsx6(Box5, { width: 12, children: /* @__PURE__ */ jsx6(Text5, { color: "yellow", children: key }) }),
1591
+ /* @__PURE__ */ jsx6(Text5, { bold: true, color: "cyan", children: narrow ? `${viewName} Keys` : `${viewName} View - Keyboard Shortcuts` }),
1592
+ /* @__PURE__ */ jsx6(Box5, { marginTop: 1, flexDirection: "column", gap: 0, children: shortcuts.map(({ key, description }, idx) => /* @__PURE__ */ jsxs5(Box5, { gap: narrow ? 1 : 2, children: [
1593
+ /* @__PURE__ */ jsx6(Box5, { width: keyWidth, children: /* @__PURE__ */ jsx6(Text5, { color: "yellow", children: key }) }),
1589
1594
  /* @__PURE__ */ jsx6(Text5, { children: description })
1590
1595
  ] }, idx)) }),
1591
- /* @__PURE__ */ jsx6(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx6(Text5, { dimColor: true, children: "Press / or ? again to close" }) })
1596
+ /* @__PURE__ */ jsx6(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx6(Text5, { dimColor: true, children: narrow ? "/ or ? to close" : "Press / or ? again to close" }) })
1592
1597
  ]
1593
1598
  }
1594
1599
  );
1595
1600
  }
1596
1601
 
1597
1602
  // src/cli/dashboard/views/OverviewView.tsx
1598
- import { Box as Box6, Text as Text6, useInput as useInput2, useStdout as useStdout4 } from "ink";
1603
+ import { Box as Box6, Text as Text6, useInput as useInput2, useStdout as useStdout5 } from "ink";
1599
1604
  import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1600
1605
  function truncate(str, max) {
1601
1606
  return str.length > max ? str.slice(0, max - 1) + "..." : str;
@@ -1604,7 +1609,7 @@ function OverviewView() {
1604
1609
  const { state, dispatch } = useDashboard();
1605
1610
  const { progress, signalExtraction, watch, issues, activityLog, activityPage, pendingFixes, selectedFixIndex } = state;
1606
1611
  const { totalIssues } = progress;
1607
- const { stdout } = useStdout4();
1612
+ const { stdout } = useStdout5();
1608
1613
  const cols = stdout?.columns || 80;
1609
1614
  const narrow = cols < 60;
1610
1615
  const contentWidth = Math.max(20, cols - 4);
@@ -1721,7 +1726,7 @@ function OverviewView() {
1721
1726
 
1722
1727
  // src/cli/dashboard/views/AgentView.tsx
1723
1728
  import { useEffect, useCallback } from "react";
1724
- import { Box as Box7, Text as Text7, useInput as useInput3, useStdout as useStdout5 } from "ink";
1729
+ import { Box as Box7, Text as Text7, useInput as useInput3, useStdout as useStdout6 } from "ink";
1725
1730
 
1726
1731
  // src/cli/dashboard/theme.ts
1727
1732
  import pc from "picocolors";
@@ -1760,7 +1765,7 @@ function progressBar(current, total, width = 10) {
1760
1765
  }
1761
1766
 
1762
1767
  // src/cli/dashboard/views/AgentView.tsx
1763
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1768
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1764
1769
  function timeAgo(iso) {
1765
1770
  const ms = Date.now() - new Date(iso).getTime();
1766
1771
  const mins = Math.floor(ms / 6e4);
@@ -1772,8 +1777,9 @@ function timeAgo(iso) {
1772
1777
  function AgentView() {
1773
1778
  const { state, dispatch } = useDashboard();
1774
1779
  const { agentInsights, agentBrain, selectedInsight, expandedInsight } = state;
1775
- const { stdout } = useStdout5();
1780
+ const { stdout } = useStdout6();
1776
1781
  const cols = stdout?.columns || 80;
1782
+ const narrow = cols < 60;
1777
1783
  const msgLen = Math.max(20, cols - 25);
1778
1784
  const visibleInsights = getVisibleInsights(state);
1779
1785
  const alerts = visibleInsights.filter((i) => i.type === "warning");
@@ -1809,7 +1815,7 @@ function AgentView() {
1809
1815
  if (!insight) return;
1810
1816
  try {
1811
1817
  const workDir = getWorkingDirectory(void 0, true);
1812
- const { getInsightStore } = await import("./insight-store-F5KDBY5Y.js");
1818
+ const { getInsightStore } = await import("./insight-store-U3NYTOJE.js");
1813
1819
  const store = getInsightStore(workDir);
1814
1820
  await store.dismissInsight(insight.id);
1815
1821
  const { getStorage: getStorage2 } = await import("./tiered-storage-QW2G7GSG.js");
@@ -1849,8 +1855,18 @@ function AgentView() {
1849
1855
  useInput3((input, key) => {
1850
1856
  if (key.upArrow || input === "k") dispatch({ type: "NAVIGATE_UP" });
1851
1857
  else if (key.downArrow || input === "j") dispatch({ type: "NAVIGATE_DOWN" });
1852
- else if (key.return) dispatch({ type: "TOGGLE_INSIGHT", index: selectedInsight });
1853
- else if (input === "d") void dismissInsight();
1858
+ else if (key.return) {
1859
+ const visible = getVisibleInsights(state);
1860
+ const insight = visible[selectedInsight];
1861
+ if (insight) {
1862
+ const parsed = parseGoalViolation(insight.message);
1863
+ if (parsed) {
1864
+ void spawnFixForInsight();
1865
+ } else {
1866
+ dispatch({ type: "TOGGLE_INSIGHT", index: selectedInsight });
1867
+ }
1868
+ }
1869
+ } else if (input === "d") void dismissInsight();
1854
1870
  else if (input === "f") void spawnFixForInsight();
1855
1871
  });
1856
1872
  const alertCount = alerts.length;
@@ -1871,7 +1887,10 @@ function AgentView() {
1871
1887
  return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 1, children: [
1872
1888
  /* @__PURE__ */ jsxs7(Text7, { children: [
1873
1889
  /* @__PURE__ */ jsx8(Text7, { bold: true, children: "Nudges" }),
1874
- /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1890
+ narrow ? /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1891
+ " ",
1892
+ alertCount
1893
+ ] }) : /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1875
1894
  " ",
1876
1895
  alertCount,
1877
1896
  " alerts \xB7 ",
@@ -1893,7 +1912,7 @@ function AgentView() {
1893
1912
  riskColor ? /* @__PURE__ */ jsx8(Text7, { color: riskColor, children: "\u25CF" }) : /* @__PURE__ */ jsx8(Text7, { dimColor: true, children: "\u25CB" }),
1894
1913
  " ",
1895
1914
  isSelected ? /* @__PURE__ */ jsx8(Text7, { bold: true, children: msg }) : /* @__PURE__ */ jsx8(Text7, { children: msg }),
1896
- /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1915
+ narrow ? null : /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1897
1916
  " ",
1898
1917
  insight.category,
1899
1918
  " \xB7 ",
@@ -1915,13 +1934,14 @@ function AgentView() {
1915
1934
  decisions.slice(0, 10).map((dec) => {
1916
1935
  const ago = timeAgo(dec.when);
1917
1936
  const active = dec.status === "active";
1918
- return /* @__PURE__ */ jsxs7(Text7, { children: [
1937
+ const decWidth = Math.max(20, cols - 18);
1938
+ return /* @__PURE__ */ jsxs7(Text7, { wrap: "truncate", children: [
1919
1939
  " ",
1920
1940
  active ? /* @__PURE__ */ jsx8(Text7, { color: "green", children: "\u25CF" }) : /* @__PURE__ */ jsx8(Text7, { dimColor: true, children: "\u25CB" }),
1921
1941
  " ",
1922
- dec.decision.slice(0, msgLen),
1923
- dec.decision.length > msgLen ? "..." : "",
1924
- /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1942
+ dec.decision.slice(0, decWidth),
1943
+ dec.decision.length > decWidth ? "..." : "",
1944
+ narrow ? null : /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1925
1945
  " ",
1926
1946
  ago
1927
1947
  ] })
@@ -1933,19 +1953,22 @@ function AgentView() {
1933
1953
  patterns.slice(0, 8).map((pat, idx) => {
1934
1954
  const conf = Math.round(pat.confidence * 100);
1935
1955
  const confColor = conf > 70 ? "green" : conf > 40 ? "yellow" : void 0;
1936
- return /* @__PURE__ */ jsxs7(Text7, { children: [
1956
+ const patWidth = Math.max(20, cols - 18);
1957
+ return /* @__PURE__ */ jsxs7(Text7, { wrap: "truncate", children: [
1937
1958
  " ",
1938
1959
  pat.isAntiPattern ? /* @__PURE__ */ jsx8(Text7, { color: "red", children: "\u25CF" }) : /* @__PURE__ */ jsx8(Text7, { dimColor: true, children: "\u25CB" }),
1939
1960
  " ",
1940
- pat.description.slice(0, msgLen),
1941
- pat.description.length > msgLen ? "..." : "",
1942
- " ",
1943
- confColor ? /* @__PURE__ */ jsxs7(Text7, { color: confColor, children: [
1944
- conf,
1945
- "%"
1946
- ] }) : /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1947
- conf,
1948
- "%"
1961
+ pat.description.slice(0, patWidth),
1962
+ pat.description.length > patWidth ? "..." : "",
1963
+ narrow ? null : /* @__PURE__ */ jsxs7(Fragment3, { children: [
1964
+ " ",
1965
+ confColor ? /* @__PURE__ */ jsxs7(Text7, { color: confColor, children: [
1966
+ conf,
1967
+ "%"
1968
+ ] }) : /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
1969
+ conf,
1970
+ "%"
1971
+ ] })
1949
1972
  ] })
1950
1973
  ] }, idx);
1951
1974
  })
@@ -1970,13 +1993,14 @@ function AgentView() {
1970
1993
 
1971
1994
  // src/cli/dashboard/views/GoalsView.tsx
1972
1995
  import { useCallback as useCallback2 } from "react";
1973
- import { Box as Box8, Text as Text8, useInput as useInput4 } from "ink";
1974
- import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
1996
+ import { Box as Box8, Text as Text8, useInput as useInput4, useStdout as useStdout7 } from "ink";
1997
+ import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
1975
1998
  function calculateGoalProgress(goal) {
1976
1999
  if (goal.target <= 0) return 0;
1977
2000
  const startValue = goal.startValue ?? goal.currentValue;
1978
2001
  if (startValue > goal.target) {
1979
2002
  const totalReduction = startValue - goal.target;
2003
+ if (totalReduction === 0) return 100;
1980
2004
  const actualReduction = startValue - goal.currentValue;
1981
2005
  return Math.round(actualReduction / totalReduction * 100);
1982
2006
  }
@@ -1985,13 +2009,17 @@ function calculateGoalProgress(goal) {
1985
2009
  function GoalsView() {
1986
2010
  const { state, dispatch } = useDashboard();
1987
2011
  const { goalsPanel } = state;
2012
+ const { stdout } = useStdout7();
2013
+ const cols = stdout?.columns || 80;
2014
+ const narrow = cols < 60;
2015
+ const contentWidth = Math.max(20, cols - 4);
1988
2016
  const activeGoals = goalsPanel.goals.filter((g) => g.status === "active");
1989
2017
  const achievedGoals = goalsPanel.goals.filter((g) => g.status === "achieved");
1990
2018
  const otherGoals = goalsPanel.goals.filter((g) => g.status !== "active" && g.status !== "achieved" && g.status !== "rejected");
1991
2019
  const refreshGoals = useCallback2(async () => {
1992
2020
  try {
1993
2021
  const workDir = getWorkingDirectory(void 0, true);
1994
- const agentState = getGuardianState(workDir);
2022
+ const agentState = getProjectState(workDir);
1995
2023
  await agentState.load();
1996
2024
  const goals = agentState.getAllGoals();
1997
2025
  dispatch({
@@ -2001,23 +2029,25 @@ function GoalsView() {
2001
2029
  return g.category ? { ...base, category: g.category } : base;
2002
2030
  })
2003
2031
  });
2004
- } catch {
2032
+ } catch (err) {
2033
+ console.debug("[GoalsView] refreshGoals failed:", err);
2005
2034
  }
2006
2035
  }, [dispatch]);
2007
2036
  const addGoal = useCallback2(async (description) => {
2008
2037
  if (!description.trim()) return;
2009
2038
  try {
2010
2039
  const workDir = getWorkingDirectory(void 0, true);
2011
- const agentState = getGuardianState(workDir);
2040
+ const agentState = getProjectState(workDir);
2012
2041
  await agentState.load();
2042
+ const initialValue = await measureInitialGoalValue(description.trim(), workDir);
2013
2043
  const goal = {
2014
2044
  id: `goal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
2015
2045
  description: description.trim(),
2016
2046
  type: "reduction",
2017
2047
  metric: "semantic",
2018
2048
  target: 0,
2019
- currentValue: 0,
2020
- startValue: 0,
2049
+ currentValue: initialValue,
2050
+ startValue: initialValue,
2021
2051
  status: "active",
2022
2052
  autoGenerated: false,
2023
2053
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -2027,13 +2057,14 @@ function GoalsView() {
2027
2057
  await agentState.addGoal(goal);
2028
2058
  dispatch({ type: "ADD_ACTIVITY", message: `Goal added: ${description.slice(0, 40)}` });
2029
2059
  await refreshGoals();
2030
- } catch {
2060
+ } catch (err) {
2061
+ console.debug("[GoalsView] addGoal failed:", err);
2031
2062
  }
2032
2063
  }, [dispatch, refreshGoals]);
2033
2064
  const completeGoal = useCallback2(async (goalId) => {
2034
2065
  try {
2035
2066
  const workDir = getWorkingDirectory(void 0, true);
2036
- const agentState = getGuardianState(workDir);
2067
+ const agentState = getProjectState(workDir);
2037
2068
  await agentState.load();
2038
2069
  const goals = agentState.getAllGoals();
2039
2070
  const goal = goals.find((g) => g.id === goalId);
@@ -2042,35 +2073,38 @@ function GoalsView() {
2042
2073
  dispatch({ type: "ADD_ACTIVITY", message: `Goal achieved: ${goal.description.slice(0, 30)}` });
2043
2074
  await refreshGoals();
2044
2075
  }
2045
- } catch {
2076
+ } catch (err) {
2077
+ console.debug("[GoalsView] completeGoal failed:", err);
2046
2078
  }
2047
2079
  }, [dispatch, refreshGoals]);
2048
2080
  const deleteGoal = useCallback2(async (goalId) => {
2049
2081
  try {
2050
2082
  const workDir = getWorkingDirectory(void 0, true);
2051
- const agentState = getGuardianState(workDir);
2083
+ const agentState = getProjectState(workDir);
2052
2084
  await agentState.load();
2053
2085
  await agentState.updateGoal(goalId, { status: "rejected" });
2054
2086
  dispatch({ type: "ADD_ACTIVITY", message: "Goal removed" });
2055
2087
  await refreshGoals();
2056
- } catch {
2088
+ } catch (err) {
2089
+ console.debug("[GoalsView] deleteGoal failed:", err);
2057
2090
  }
2058
2091
  }, [dispatch, refreshGoals]);
2059
2092
  const reactivateGoal = useCallback2(async (goalId) => {
2060
2093
  try {
2061
2094
  const workDir = getWorkingDirectory(void 0, true);
2062
- const agentState = getGuardianState(workDir);
2095
+ const agentState = getProjectState(workDir);
2063
2096
  await agentState.load();
2064
2097
  await agentState.updateGoal(goalId, { status: "active", achievedAt: void 0 });
2065
2098
  dispatch({ type: "ADD_ACTIVITY", message: "Goal reactivated" });
2066
2099
  await refreshGoals();
2067
- } catch {
2100
+ } catch (err) {
2101
+ console.debug("[GoalsView] reactivateGoal failed:", err);
2068
2102
  }
2069
2103
  }, [dispatch, refreshGoals]);
2070
2104
  const clearAchievedGoals = useCallback2(async () => {
2071
2105
  try {
2072
2106
  const workDir = getWorkingDirectory(void 0, true);
2073
- const agentState = getGuardianState(workDir);
2107
+ const agentState = getProjectState(workDir);
2074
2108
  await agentState.load();
2075
2109
  const achieved = goalsPanel.goals.filter((g) => g.status === "achieved");
2076
2110
  if (achieved.length === 0) {
@@ -2092,14 +2126,21 @@ function GoalsView() {
2092
2126
  const checkGoalNow = useCallback2(async (goalId) => {
2093
2127
  try {
2094
2128
  const workDir = getWorkingDirectory(void 0, true);
2095
- const goal = goalsPanel.goals.find((g) => g.id === goalId);
2096
- if (!goal) return;
2097
- dispatch({ type: "ADD_ACTIVITY", message: `Checking goal: ${goal.description.slice(0, 30)}...` });
2129
+ const goalSummary = goalsPanel.goals.find((g) => g.id === goalId);
2130
+ if (!goalSummary) return;
2131
+ dispatch({ type: "ADD_ACTIVITY", message: `Checking goal: ${goalSummary.description.slice(0, 30)}...` });
2098
2132
  dispatch({ type: "SHOW_NOTIFICATION", message: `Scanning files...`, severity: "info", autoHideMs: 5e3 });
2099
- const { checkFilesForGoalViolations } = await import("./goal-validator-KLAK5TZN.js");
2100
- const violations = await checkFilesForGoalViolations([goal], workDir);
2133
+ const { checkFilesForGoalViolations } = await import("./goal-validator-HPPBSDXD.js");
2134
+ const agentState = getProjectState(workDir);
2135
+ await agentState.load();
2136
+ const fullGoal = agentState.getAllGoals().find((g) => g.id === goalId);
2137
+ if (!fullGoal) {
2138
+ dispatch({ type: "SHOW_NOTIFICATION", message: `Goal not found: ${goalId}`, severity: "warning", autoHideMs: 5e3 });
2139
+ return;
2140
+ }
2141
+ const violations = await checkFilesForGoalViolations([fullGoal], workDir);
2101
2142
  if (violations.length === 0) {
2102
- dispatch({ type: "SHOW_NOTIFICATION", message: `\u2713 No violations found for: ${goal.description.slice(0, 40)}`, severity: "info", autoHideMs: 5e3 });
2143
+ dispatch({ type: "SHOW_NOTIFICATION", message: `\u2713 No violations found for: ${goalSummary.description.slice(0, 40)}`, severity: "info", autoHideMs: 5e3 });
2103
2144
  dispatch({ type: "ADD_ACTIVITY", message: `No violations found` });
2104
2145
  } else {
2105
2146
  dispatch({ type: "SHOW_NOTIFICATION", message: `Found ${violations.length} violation(s) - check Nudges tab`, severity: "warning", autoHideMs: 5e3 });
@@ -2164,7 +2205,7 @@ function GoalsView() {
2164
2205
  /* @__PURE__ */ jsx9(Text8, { bold: true, color: "green", children: "|" })
2165
2206
  ] }) }),
2166
2207
  /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: " enter save \xB7 esc cancel" })
2167
- ] }) : /* @__PURE__ */ jsx9(Fragment3, { children: goalsPanel.goals.length === 0 ? /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: " No goals yet. Press a to add one." }) : /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
2208
+ ] }) : /* @__PURE__ */ jsx9(Fragment4, { children: goalsPanel.goals.length === 0 ? /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: " No goals yet. Press a to add one." }) : /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
2168
2209
  activeGoals.length === 0 && goalsPanel.goals.length > 0 && /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginBottom: 1, paddingX: 1, borderStyle: "round", borderColor: "yellow", children: [
2169
2210
  /* @__PURE__ */ jsx9(Text8, { color: "yellow", bold: true, children: "\u26A0 No Active Goals" }),
2170
2211
  /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "Goals exist but none are active. Violations won't be detected." }),
@@ -2173,13 +2214,15 @@ function GoalsView() {
2173
2214
  activeGoals.map((goal, idx) => {
2174
2215
  const isSelected = goalsPanel.selectedIndex === idx;
2175
2216
  const progress = calculateGoalProgress(goal);
2176
- const bar = progressBar(progress, 100, 8);
2217
+ const barWidth = narrow ? 6 : Math.min(12, Math.floor(contentWidth / 8));
2218
+ const bar = progressBar(progress, 100, barWidth);
2177
2219
  const source = goal.autoGenerated ? "auto" : "";
2178
- return /* @__PURE__ */ jsxs8(Text8, { children: [
2220
+ const descWidth = Math.max(20, contentWidth - barWidth - 20);
2221
+ return /* @__PURE__ */ jsxs8(Text8, { wrap: "truncate", children: [
2179
2222
  isSelected ? /* @__PURE__ */ jsx9(Text8, { bold: true, color: "green", children: "> " }) : " ",
2180
2223
  /* @__PURE__ */ jsx9(Text8, { color: "green", children: "\u25CB" }),
2181
2224
  " ",
2182
- goal.description.slice(0, 45),
2225
+ goal.description.slice(0, descWidth),
2183
2226
  /* @__PURE__ */ jsxs8(Text8, { dimColor: true, children: [
2184
2227
  " ",
2185
2228
  bar,
@@ -2192,12 +2235,15 @@ function GoalsView() {
2192
2235
  }),
2193
2236
  achievedGoals.length > 0 && /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginTop: 1, children: [
2194
2237
  /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: " Achieved" }),
2195
- achievedGoals.slice(0, 5).map((g) => /* @__PURE__ */ jsxs8(Text8, { children: [
2196
- " ",
2197
- /* @__PURE__ */ jsx9(Text8, { color: "green", children: "\u25CF" }),
2198
- " ",
2199
- g.description.slice(0, 50)
2200
- ] }, g.id)),
2238
+ achievedGoals.slice(0, 5).map((g) => {
2239
+ const goalWidth = Math.max(30, contentWidth - 4);
2240
+ return /* @__PURE__ */ jsxs8(Text8, { wrap: "truncate", children: [
2241
+ " ",
2242
+ /* @__PURE__ */ jsx9(Text8, { color: "green", children: "\u25CF" }),
2243
+ " ",
2244
+ g.description.slice(0, goalWidth)
2245
+ ] }, g.id);
2246
+ }),
2201
2247
  achievedGoals.length > 5 && /* @__PURE__ */ jsxs8(Text8, { dimColor: true, children: [
2202
2248
  " +",
2203
2249
  achievedGoals.length - 5,
@@ -2206,14 +2252,17 @@ function GoalsView() {
2206
2252
  ] }),
2207
2253
  otherGoals.length > 0 && /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginTop: 1, children: [
2208
2254
  /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: " Other" }),
2209
- otherGoals.slice(0, 2).map((g) => /* @__PURE__ */ jsxs8(Text8, { children: [
2210
- " ",
2211
- /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "\u25CB" }),
2212
- " ",
2213
- g.description.slice(0, 50),
2214
- " ",
2215
- /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: g.status })
2216
- ] }, g.id))
2255
+ otherGoals.slice(0, 2).map((g) => {
2256
+ const goalWidth = Math.max(30, contentWidth - 15);
2257
+ return /* @__PURE__ */ jsxs8(Text8, { wrap: "truncate", children: [
2258
+ " ",
2259
+ /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "\u25CB" }),
2260
+ " ",
2261
+ g.description.slice(0, goalWidth),
2262
+ " ",
2263
+ /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: g.status })
2264
+ ] }, g.id);
2265
+ })
2217
2266
  ] })
2218
2267
  ] }) })
2219
2268
  ] });
@@ -2221,18 +2270,22 @@ function GoalsView() {
2221
2270
 
2222
2271
  // src/cli/dashboard/views/HypothesesView.tsx
2223
2272
  import { useCallback as useCallback3 } from "react";
2224
- import { Box as Box9, Text as Text9, useInput as useInput5 } from "ink";
2225
- import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
2273
+ import { Box as Box9, Text as Text9, useInput as useInput5, useStdout as useStdout8 } from "ink";
2274
+ import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
2226
2275
  function HypothesesView() {
2227
2276
  const { state, dispatch } = useDashboard();
2228
2277
  const { hypothesesPanel } = state;
2278
+ const { stdout } = useStdout8();
2279
+ const cols = stdout?.columns || 80;
2280
+ const narrow = cols < 60;
2281
+ const contentWidth = Math.max(20, cols - 4);
2229
2282
  const testing = hypothesesPanel.hypotheses.filter((h) => h.status === "testing");
2230
2283
  const validated = hypothesesPanel.hypotheses.filter((h) => h.status === "validated");
2231
2284
  const invalidated = hypothesesPanel.hypotheses.filter((h) => h.status === "invalidated");
2232
2285
  const refreshHypotheses = useCallback3(async () => {
2233
2286
  try {
2234
2287
  const workDir = getWorkingDirectory(void 0, true);
2235
- const agentState = getGuardianState(workDir);
2288
+ const agentState = getProjectState(workDir);
2236
2289
  await agentState.load();
2237
2290
  const hypotheses = agentState.getAllHypotheses();
2238
2291
  dispatch({
@@ -2242,14 +2295,15 @@ function HypothesesView() {
2242
2295
  return h.category ? { ...base, category: h.category } : base;
2243
2296
  })
2244
2297
  });
2245
- } catch {
2298
+ } catch (err) {
2299
+ console.debug("[HypothesesView] refreshHypotheses failed:", err);
2246
2300
  }
2247
2301
  }, [dispatch]);
2248
2302
  const addHypothesis = useCallback3(async (statement) => {
2249
2303
  if (!statement.trim()) return;
2250
2304
  try {
2251
2305
  const workDir = getWorkingDirectory(void 0, true);
2252
- const agentState = getGuardianState(workDir);
2306
+ const agentState = getProjectState(workDir);
2253
2307
  await agentState.load();
2254
2308
  const hypothesis = {
2255
2309
  id: `hypo-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
@@ -2264,31 +2318,34 @@ function HypothesesView() {
2264
2318
  await agentState.addHypothesis(hypothesis);
2265
2319
  dispatch({ type: "ADD_ACTIVITY", message: `Hypothesis added: ${statement.slice(0, 40)}` });
2266
2320
  await refreshHypotheses();
2267
- } catch {
2321
+ } catch (err) {
2322
+ console.debug("[HypothesesView] addHypothesis failed:", err);
2268
2323
  }
2269
2324
  }, [dispatch, refreshHypotheses]);
2270
2325
  const updateHypothesis = useCallback3(async (hypoId, action) => {
2271
2326
  try {
2272
2327
  const workDir = getWorkingDirectory(void 0, true);
2273
- const agentState = getGuardianState(workDir);
2328
+ const agentState = getProjectState(workDir);
2274
2329
  await agentState.load();
2275
2330
  if (action === "validate") await agentState.updateHypothesis(hypoId, { status: "validated", confidence: 0.9 });
2276
2331
  else if (action === "invalidate") await agentState.updateHypothesis(hypoId, { status: "invalidated", confidence: 0.1 });
2277
2332
  else await agentState.updateHypothesis(hypoId, { status: "retired" });
2278
2333
  dispatch({ type: "ADD_ACTIVITY", message: `Hypothesis ${action === "validate" ? "validated" : action === "invalidate" ? "invalidated" : "removed"}` });
2279
2334
  await refreshHypotheses();
2280
- } catch {
2335
+ } catch (err) {
2336
+ console.debug("[HypothesesView] updateHypothesis failed:", err);
2281
2337
  }
2282
2338
  }, [dispatch, refreshHypotheses]);
2283
2339
  const reactivateHypothesis = useCallback3(async (hypoId) => {
2284
2340
  try {
2285
2341
  const workDir = getWorkingDirectory(void 0, true);
2286
- const agentState = getGuardianState(workDir);
2342
+ const agentState = getProjectState(workDir);
2287
2343
  await agentState.load();
2288
2344
  await agentState.updateHypothesis(hypoId, { status: "testing", confidence: 0.5, validatedAt: void 0 });
2289
2345
  dispatch({ type: "ADD_ACTIVITY", message: "Hypothesis reactivated" });
2290
2346
  await refreshHypotheses();
2291
- } catch {
2347
+ } catch (err) {
2348
+ console.debug("[HypothesesView] reactivateHypothesis failed:", err);
2292
2349
  }
2293
2350
  }, [dispatch, refreshHypotheses]);
2294
2351
  const checkHypothesisNow = useCallback3(async (hypoId) => {
@@ -2298,7 +2355,7 @@ function HypothesesView() {
2298
2355
  if (!hypo) return;
2299
2356
  dispatch({ type: "ADD_ACTIVITY", message: `Testing hypothesis: ${hypo.statement.slice(0, 30)}...` });
2300
2357
  dispatch({ type: "SHOW_NOTIFICATION", message: `Gathering evidence for hypothesis...`, severity: "info", autoHideMs: 3e3 });
2301
- const { gatherEvidenceForHypothesis } = await import("./hypothesis-I276JIDW.js");
2358
+ const { gatherEvidenceForHypothesis } = await import("./hypothesis-W37VG6DA.js");
2302
2359
  const evidence = await gatherEvidenceForHypothesis(hypoId, workDir);
2303
2360
  if (evidence.length === 0) {
2304
2361
  dispatch({ type: "SHOW_NOTIFICATION", message: `No evidence found for: ${hypo.statement.slice(0, 40)}`, severity: "info", autoHideMs: 5e3 });
@@ -2343,7 +2400,7 @@ function HypothesesView() {
2343
2400
  } else if (_input === "d") {
2344
2401
  const selected = testing[hypothesesPanel.selectedIndex];
2345
2402
  if (selected) void updateHypothesis(selected.id, "delete");
2346
- } else if (_input === "r") {
2403
+ } else if (_input === "c") {
2347
2404
  const completed = hypothesesPanel.hypotheses.filter((h) => h.status === "validated" || h.status === "invalidated");
2348
2405
  if (completed[0]) void updateHypothesis(completed[0].id, "delete");
2349
2406
  } else if (_input === "u") {
@@ -2359,32 +2416,40 @@ function HypothesesView() {
2359
2416
  /* @__PURE__ */ jsx10(Text9, { bold: true, color: "green", children: "|" })
2360
2417
  ] }) }),
2361
2418
  /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: " enter save \xB7 esc cancel" })
2362
- ] }) : /* @__PURE__ */ jsx10(Fragment4, { children: hypothesesPanel.hypotheses.length === 0 ? /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: " No hypotheses yet. Press a to add one." }) : /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
2419
+ ] }) : /* @__PURE__ */ jsx10(Fragment5, { children: hypothesesPanel.hypotheses.length === 0 ? /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: " No hypotheses yet. Press a to add one." }) : /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
2420
+ testing.length === 0 && hypothesesPanel.hypotheses.length > 0 && /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", marginBottom: 1, paddingX: 1, borderStyle: "round", borderColor: "yellow", children: [
2421
+ /* @__PURE__ */ jsx10(Text9, { color: "yellow", bold: true, children: "\u26A0 No Active Hypotheses" }),
2422
+ /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: "Hypotheses exist but none are being tested. Evidence won't be gathered." }),
2423
+ /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: 'Press a to add a new hypothesis, or run: trie hypothesis add "your hypothesis"' })
2424
+ ] }),
2363
2425
  testing.map((hypo, idx) => {
2364
2426
  const isSelected = hypothesesPanel.selectedIndex === idx;
2365
2427
  const conf = Math.round(hypo.confidence * 100);
2366
- return /* @__PURE__ */ jsxs9(Text9, { children: [
2428
+ const statementWidth = Math.max(25, contentWidth - 20);
2429
+ return /* @__PURE__ */ jsxs9(Text9, { wrap: "truncate", children: [
2367
2430
  isSelected ? /* @__PURE__ */ jsx10(Text9, { bold: true, color: "green", children: "> " }) : " ",
2368
2431
  /* @__PURE__ */ jsx10(Text9, { color: "yellow", children: "\u25CB" }),
2369
2432
  " ",
2370
- hypo.statement.slice(0, 50),
2433
+ hypo.statement.slice(0, statementWidth),
2371
2434
  /* @__PURE__ */ jsxs9(Text9, { dimColor: true, children: [
2372
2435
  " ",
2373
2436
  conf,
2374
- "% \xB7 ",
2375
- hypo.evidenceCount,
2376
- " evidence"
2437
+ "%",
2438
+ narrow ? "" : ` \xB7 ${hypo.evidenceCount} evidence`
2377
2439
  ] })
2378
2440
  ] }, hypo.id);
2379
2441
  }),
2380
2442
  validated.length > 0 && /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", marginTop: 1, children: [
2381
2443
  /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: " Validated" }),
2382
- validated.slice(0, 3).map((h) => /* @__PURE__ */ jsxs9(Text9, { children: [
2383
- " ",
2384
- /* @__PURE__ */ jsx10(Text9, { color: "green", children: "\u25CF" }),
2385
- " ",
2386
- h.statement.slice(0, 50)
2387
- ] }, h.id)),
2444
+ validated.slice(0, 3).map((h) => {
2445
+ const statementWidth = Math.max(30, contentWidth - 4);
2446
+ return /* @__PURE__ */ jsxs9(Text9, { wrap: "truncate", children: [
2447
+ " ",
2448
+ /* @__PURE__ */ jsx10(Text9, { color: "green", children: "\u25CF" }),
2449
+ " ",
2450
+ h.statement.slice(0, statementWidth)
2451
+ ] }, h.id);
2452
+ }),
2388
2453
  validated.length > 3 && /* @__PURE__ */ jsxs9(Text9, { dimColor: true, children: [
2389
2454
  " +",
2390
2455
  validated.length - 3,
@@ -2393,12 +2458,15 @@ function HypothesesView() {
2393
2458
  ] }),
2394
2459
  invalidated.length > 0 && /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", marginTop: 1, children: [
2395
2460
  /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: " Invalidated" }),
2396
- invalidated.slice(0, 2).map((h) => /* @__PURE__ */ jsxs9(Text9, { children: [
2397
- " ",
2398
- /* @__PURE__ */ jsx10(Text9, { color: "red", children: "\u25CF" }),
2399
- " ",
2400
- /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: h.statement.slice(0, 50) })
2401
- ] }, h.id)),
2461
+ invalidated.slice(0, 2).map((h) => {
2462
+ const statementWidth = Math.max(30, contentWidth - 4);
2463
+ return /* @__PURE__ */ jsxs9(Text9, { wrap: "truncate", children: [
2464
+ " ",
2465
+ /* @__PURE__ */ jsx10(Text9, { color: "red", children: "\u25CF" }),
2466
+ " ",
2467
+ /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: h.statement.slice(0, statementWidth) })
2468
+ ] }, h.id);
2469
+ }),
2402
2470
  invalidated.length > 2 && /* @__PURE__ */ jsxs9(Text9, { dimColor: true, children: [
2403
2471
  " +",
2404
2472
  invalidated.length - 2,
@@ -2411,8 +2479,8 @@ function HypothesesView() {
2411
2479
 
2412
2480
  // src/cli/dashboard/views/MemoryTreeView.tsx
2413
2481
  import { useEffect as useEffect2, useCallback as useCallback4 } from "react";
2414
- import { Box as Box10, Text as Text10, useInput as useInput6 } from "ink";
2415
- import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
2482
+ import { Box as Box10, Text as Text10, useInput as useInput6, useStdout as useStdout9 } from "ink";
2483
+ import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
2416
2484
  function timeAgo2(iso) {
2417
2485
  const ms = Date.now() - new Date(iso).getTime();
2418
2486
  const mins = Math.floor(ms / 6e4);
@@ -2425,6 +2493,10 @@ function MemoryTreeView() {
2425
2493
  const { state, dispatch } = useDashboard();
2426
2494
  const { memoryTree } = state;
2427
2495
  const { snapshot, globalPatterns, storageDecisions, ledgerBlocks, expandedNodes, expandedItemId, selectedNode, loaded } = memoryTree;
2496
+ const { stdout } = useStdout9();
2497
+ const cols = stdout?.columns || 80;
2498
+ const narrow = cols < 60;
2499
+ const contentWidth = Math.max(20, cols - 4);
2428
2500
  const loadData = useCallback4(async () => {
2429
2501
  try {
2430
2502
  const workDir = getWorkingDirectory(void 0, true);
@@ -2437,7 +2509,8 @@ function MemoryTreeView() {
2437
2509
  getLedgerBlocks(workDir).catch(() => [])
2438
2510
  ]);
2439
2511
  dispatch({ type: "SET_MEMORY_TREE", snapshot: snap, patterns, storageDecisions: decisions2, ledgerBlocks: blocks });
2440
- } catch {
2512
+ } catch (err) {
2513
+ console.debug("[MemoryTreeView] loadData failed:", err);
2441
2514
  dispatch({ type: "ADD_ACTIVITY", message: "Context graph load error" });
2442
2515
  }
2443
2516
  }, [dispatch]);
@@ -2545,24 +2618,25 @@ function MemoryTreeView() {
2545
2618
  renderHeader("decisions", "Decisions", decisions.length, "-- use trie tell or chat"),
2546
2619
  expandedNodes.has("decisions") && decisions.slice(0, 10).map((d) => {
2547
2620
  const nodeId = `decision-${d.id}`;
2548
- const dec = d.decision.length > 50 ? d.decision.slice(0, 47) + "..." : d.decision;
2621
+ const decWidth = Math.max(30, contentWidth - 25);
2622
+ const dec = d.decision.length > decWidth ? d.decision.slice(0, decWidth - 3) + "..." : d.decision;
2549
2623
  const outcomeColor = d.outcome === "good" ? "green" : d.outcome === "bad" ? "red" : void 0;
2550
- return /* @__PURE__ */ jsxs10(Text10, { children: [
2624
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
2551
2625
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : " ",
2552
2626
  " ",
2553
2627
  outcomeColor ? /* @__PURE__ */ jsx11(Text10, { color: outcomeColor, children: "\u25CF" }) : /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "\u25CB" }),
2554
2628
  " ",
2555
2629
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: dec }) : /* @__PURE__ */ jsx11(Text10, { children: dec }),
2556
- d.hash ? /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2630
+ !narrow && d.hash ? /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2557
2631
  " [",
2558
2632
  d.hash.slice(0, 8),
2559
2633
  "]"
2560
2634
  ] }) : null,
2561
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2635
+ narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2562
2636
  " ",
2563
2637
  timeAgo2(d.when)
2564
2638
  ] }),
2565
- outcomeColor ? /* @__PURE__ */ jsxs10(Text10, { color: outcomeColor, children: [
2639
+ outcomeColor && !narrow ? /* @__PURE__ */ jsxs10(Text10, { color: outcomeColor, children: [
2566
2640
  " ",
2567
2641
  d.outcome
2568
2642
  ] }) : null
@@ -2573,19 +2647,22 @@ function MemoryTreeView() {
2573
2647
  expandedNodes.has("incidents") && incidentNodes.slice(0, 10).map((n) => {
2574
2648
  const nodeId = `incident-${n.id}`;
2575
2649
  const sevColor = n.data.severity === "critical" ? "red" : n.data.severity === "major" ? "yellow" : void 0;
2576
- const desc = n.data.description.length > 55 ? n.data.description.slice(0, 52) + "..." : n.data.description;
2577
- return /* @__PURE__ */ jsxs10(Text10, { children: [
2650
+ const descWidth = Math.max(30, contentWidth - 20);
2651
+ const desc = n.data.description.length > descWidth ? n.data.description.slice(0, descWidth - 3) + "..." : n.data.description;
2652
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
2578
2653
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : " ",
2579
2654
  " ",
2580
2655
  sevColor ? /* @__PURE__ */ jsx11(Text10, { color: sevColor, children: "\u25CF" }) : /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "\u25CB" }),
2581
2656
  " ",
2582
2657
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: desc }) : /* @__PURE__ */ jsx11(Text10, { children: desc }),
2583
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2658
+ narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2584
2659
  " ",
2585
2660
  timeAgo2(n.data.timestamp)
2586
2661
  ] }),
2587
- " ",
2588
- n.data.resolved ? /* @__PURE__ */ jsx11(Text10, { color: "green", children: "resolved" }) : /* @__PURE__ */ jsx11(Text10, { color: "yellow", children: "open" })
2662
+ narrow ? null : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2663
+ " ",
2664
+ n.data.resolved ? /* @__PURE__ */ jsx11(Text10, { color: "green", children: "resolved" }) : /* @__PURE__ */ jsx11(Text10, { color: "yellow", children: "open" })
2665
+ ] })
2589
2666
  ] }, n.id);
2590
2667
  }),
2591
2668
  renderHeader("patterns", "Learned Patterns", patternNodes.length, "-- Trie learns as you work"),
@@ -2593,57 +2670,65 @@ function MemoryTreeView() {
2593
2670
  const nodeId = `pattern-${n.id}`;
2594
2671
  const conf = Math.round(n.data.confidence * 100);
2595
2672
  const confColor = conf > 70 ? "green" : conf > 40 ? "yellow" : void 0;
2596
- const desc = n.data.description.length > 50 ? n.data.description.slice(0, 47) + "..." : n.data.description;
2597
- return /* @__PURE__ */ jsxs10(Text10, { children: [
2673
+ const descWidth = Math.max(30, contentWidth - 15);
2674
+ const desc = n.data.description.length > descWidth ? n.data.description.slice(0, descWidth - 3) + "..." : n.data.description;
2675
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
2598
2676
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : " ",
2599
2677
  " ",
2600
2678
  n.data.isAntiPattern ? /* @__PURE__ */ jsx11(Text10, { color: "red", children: "!" }) : /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "\u25CB" }),
2601
2679
  " ",
2602
2680
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: desc }) : /* @__PURE__ */ jsx11(Text10, { children: desc }),
2603
- " ",
2604
- confColor ? /* @__PURE__ */ jsxs10(Text10, { color: confColor, children: [
2605
- conf,
2606
- "%"
2607
- ] }) : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2608
- conf,
2609
- "%"
2681
+ narrow ? null : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2682
+ " ",
2683
+ confColor ? /* @__PURE__ */ jsxs10(Text10, { color: confColor, children: [
2684
+ conf,
2685
+ "%"
2686
+ ] }) : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2687
+ conf,
2688
+ "%"
2689
+ ] })
2610
2690
  ] })
2611
2691
  ] }, n.id);
2612
2692
  }),
2613
2693
  renderHeader("cross-project", "Cross-Project", globalPatterns.length),
2614
2694
  expandedNodes.has("cross-project") && globalPatterns.slice(0, 8).map((pattern) => {
2615
2695
  const patternId = `global-${pattern.id}`;
2616
- const desc = pattern.pattern.length > 45 ? pattern.pattern.slice(0, 42) + "..." : pattern.pattern;
2617
- return /* @__PURE__ */ jsxs10(Text10, { children: [
2696
+ const descWidth = Math.max(25, contentWidth - 35);
2697
+ const desc = pattern.pattern.length > descWidth ? pattern.pattern.slice(0, descWidth - 3) + "..." : pattern.pattern;
2698
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
2618
2699
  sel(patternId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : " ",
2619
2700
  " ",
2620
2701
  /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "\u25CB" }),
2621
2702
  " ",
2622
2703
  sel(patternId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: desc }) : /* @__PURE__ */ jsx11(Text10, { children: desc }),
2623
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2704
+ narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2624
2705
  " ",
2625
2706
  pattern.projects.length,
2626
- " projects \xB7 ",
2707
+ "p \xB7 ",
2627
2708
  pattern.occurrences,
2628
- " hits"
2709
+ "x"
2629
2710
  ] })
2630
2711
  ] }, pattern.id);
2631
2712
  }),
2632
- hotspots.length > 0 && /* @__PURE__ */ jsxs10(Fragment5, { children: [
2713
+ hotspots.length > 0 && /* @__PURE__ */ jsxs10(Fragment6, { children: [
2633
2714
  renderHeader("hotspots", "Risk Hotspots", hotspots.length),
2634
2715
  expandedNodes.has("hotspots") && hotspots.slice(0, 10).map((n) => {
2635
2716
  const nodeId = `file-${n.id}`;
2636
2717
  const path2 = n.data.path.split("/").slice(-2).join("/");
2637
2718
  const isCritical = n.data.riskLevel === "critical";
2638
- return /* @__PURE__ */ jsxs10(Text10, { children: [
2719
+ const pathWidth = Math.max(20, contentWidth - 30);
2720
+ const displayPath = path2.length > pathWidth ? path2.slice(-pathWidth) : path2;
2721
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
2639
2722
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : " ",
2640
2723
  " ",
2641
2724
  /* @__PURE__ */ jsx11(Text10, { color: isCritical ? "red" : "yellow", children: "\u25CF" }),
2642
2725
  " ",
2643
- sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: path2 }) : /* @__PURE__ */ jsx11(Text10, { children: path2 }),
2644
- " ",
2645
- /* @__PURE__ */ jsx11(Text10, { color: isCritical ? "red" : "yellow", children: n.data.riskLevel }),
2646
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2726
+ sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: displayPath }) : /* @__PURE__ */ jsx11(Text10, { children: displayPath }),
2727
+ narrow ? null : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2728
+ " ",
2729
+ /* @__PURE__ */ jsx11(Text10, { color: isCritical ? "red" : "yellow", children: n.data.riskLevel })
2730
+ ] }),
2731
+ narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2647
2732
  " ",
2648
2733
  n.data.changeCount,
2649
2734
  " changes"
@@ -2651,11 +2736,11 @@ function MemoryTreeView() {
2651
2736
  ] }, n.id);
2652
2737
  })
2653
2738
  ] }),
2654
- ledgerBlocks.length > 0 && /* @__PURE__ */ jsxs10(Fragment5, { children: [
2739
+ ledgerBlocks.length > 0 && /* @__PURE__ */ jsxs10(Fragment6, { children: [
2655
2740
  renderHeader("ledger-chain", "Ledger Chain (hashes)", ledgerBlocks.length),
2656
2741
  expandedNodes.has("ledger-chain") && ledgerBlocks.map((block, i) => {
2657
2742
  const nodeId = `ledger-block-${i}`;
2658
- return /* @__PURE__ */ jsxs10(Text10, { children: [
2743
+ return /* @__PURE__ */ jsxs10(Text10, { wrap: "truncate", children: [
2659
2744
  sel(nodeId) ? /* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "> " }) : " ",
2660
2745
  " ",
2661
2746
  /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "\u25CF" }),
@@ -2667,27 +2752,32 @@ function MemoryTreeView() {
2667
2752
  "Block ",
2668
2753
  i + 1
2669
2754
  ] }),
2670
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2755
+ narrow ? null : /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2671
2756
  " ",
2672
2757
  block.date
2673
2758
  ] }),
2674
- " ",
2675
- " ",
2676
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2677
- "block: ",
2678
- (block.blockHash || "-").slice(0, 12),
2679
- "\u2026"
2759
+ narrow ? null : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2760
+ " ",
2761
+ /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2762
+ "blk:",
2763
+ (block.blockHash || "-").slice(0, 8),
2764
+ "\u2026"
2765
+ ] })
2680
2766
  ] }),
2681
- " ",
2682
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2683
- "merkle: ",
2684
- (block.merkleRoot || "-").slice(0, 8),
2685
- "\u2026"
2767
+ narrow ? null : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2768
+ " ",
2769
+ /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2770
+ "mk:",
2771
+ (block.merkleRoot || "-").slice(0, 6),
2772
+ "\u2026"
2773
+ ] })
2686
2774
  ] }),
2687
- " ",
2688
- /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2689
- block.entries.length,
2690
- " entries"
2775
+ narrow ? null : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2776
+ " ",
2777
+ /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
2778
+ block.entries.length,
2779
+ " entries"
2780
+ ] })
2691
2781
  ] })
2692
2782
  ] }, nodeId);
2693
2783
  })
@@ -2696,11 +2786,14 @@ function MemoryTreeView() {
2696
2786
  }
2697
2787
 
2698
2788
  // src/cli/dashboard/views/RawLogView.tsx
2699
- import { Box as Box11, Text as Text11, useInput as useInput7 } from "ink";
2789
+ import { Box as Box11, Text as Text11, useInput as useInput7, useStdout as useStdout10 } from "ink";
2700
2790
  import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
2701
2791
  function RawLogView() {
2702
2792
  const { state, dispatch } = useDashboard();
2703
2793
  const { rawLog, rawLogPage } = state;
2794
+ const { stdout } = useStdout10();
2795
+ const cols = stdout?.columns || 80;
2796
+ const msgWidth = Math.max(30, cols - 18);
2704
2797
  const pageSize = Math.max(10, (process.stdout.rows || 40) - 10);
2705
2798
  const totalPages = Math.max(1, Math.ceil(rawLog.length / pageSize));
2706
2799
  useInput7((input, _key) => {
@@ -2723,13 +2816,14 @@ function RawLogView() {
2723
2816
  ] }),
2724
2817
  rawLog.length === 0 ? /* @__PURE__ */ jsx12(Text11, { dimColor: true, children: " No log entries yet" }) : logs.map((entry, i) => {
2725
2818
  const dot = entry.level === "error" ? /* @__PURE__ */ jsx12(Text11, { color: "red", children: "\u25CF" }) : entry.level === "warn" ? /* @__PURE__ */ jsx12(Text11, { color: "yellow", children: "\u25CF" }) : entry.level === "info" ? /* @__PURE__ */ jsx12(Text11, { color: "green", children: "\u25CF" }) : /* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "\u25CB" });
2726
- return /* @__PURE__ */ jsxs11(Text11, { children: [
2819
+ const msg = entry.message.length > msgWidth ? entry.message.slice(0, msgWidth - 3) + "..." : entry.message;
2820
+ return /* @__PURE__ */ jsxs11(Text11, { wrap: "truncate", children: [
2727
2821
  " ",
2728
2822
  /* @__PURE__ */ jsx12(Text11, { dimColor: true, children: entry.time }),
2729
2823
  " ",
2730
2824
  dot,
2731
2825
  " ",
2732
- entry.message.slice(0, 70)
2826
+ msg
2733
2827
  ] }, i);
2734
2828
  })
2735
2829
  ] });
@@ -5374,16 +5468,17 @@ async function executeTool(name, input, onProgress) {
5374
5468
  const desc = String(input.description || "").trim();
5375
5469
  if (!desc) return "Goal description is required.";
5376
5470
  const category = input.category || "general";
5377
- const agentState = getGuardianState(directory);
5471
+ const agentState = getProjectState(directory);
5378
5472
  await agentState.load();
5473
+ const initialValue = await measureInitialGoalValue(desc, directory);
5379
5474
  const goal = {
5380
5475
  id: `goal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
5381
5476
  description: desc,
5382
5477
  type: "custom",
5383
5478
  metric: "progress",
5384
5479
  target: 100,
5385
- currentValue: 0,
5386
- startValue: 0,
5480
+ currentValue: initialValue,
5481
+ startValue: initialValue,
5387
5482
  status: "active",
5388
5483
  autoGenerated: false,
5389
5484
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -5392,13 +5487,13 @@ async function executeTool(name, input, onProgress) {
5392
5487
  category
5393
5488
  };
5394
5489
  await agentState.addGoal(goal);
5395
- return `Goal created: "${desc}" [${category}]`;
5490
+ return `Goal created: "${desc}" [${category}]${initialValue > 0 ? ` (starting at ${initialValue} issues)` : ""}`;
5396
5491
  }
5397
5492
  case "trie_add_hypothesis": {
5398
5493
  const stmt = String(input.statement || "").trim();
5399
5494
  if (!stmt) return "Hypothesis statement is required.";
5400
5495
  const category = input.category || "general";
5401
- const agentState = getGuardianState(directory);
5496
+ const agentState = getProjectState(directory);
5402
5497
  await agentState.load();
5403
5498
  const hypothesis = {
5404
5499
  id: `hyp-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
@@ -5605,8 +5700,8 @@ ${truncated}`;
5605
5700
  const goalId = input.goalId ? String(input.goalId).trim() : void 0;
5606
5701
  try {
5607
5702
  onProgress?.("Loading goals...");
5608
- const { checkFilesForGoalViolations, getActiveGoals } = await import("./goal-validator-KLAK5TZN.js");
5609
- const agentState = getGuardianState(directory);
5703
+ const { checkFilesForGoalViolations, getActiveGoals } = await import("./goal-validator-HPPBSDXD.js");
5704
+ const agentState = getProjectState(directory);
5610
5705
  await agentState.load();
5611
5706
  const allGoals = await getActiveGoals(directory);
5612
5707
  const goalsToCheck = goalId ? allGoals.filter((g) => g.id === goalId) : allGoals;
@@ -5644,7 +5739,7 @@ ${truncated}`;
5644
5739
  }
5645
5740
 
5646
5741
  // src/cli/dashboard/views/ChatView.tsx
5647
- import { Fragment as Fragment6, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
5742
+ import { Fragment as Fragment7, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
5648
5743
  var VISIBLE_MESSAGES = 8;
5649
5744
  async function buildContext(workDir, dashboardState) {
5650
5745
  const parts = [];
@@ -5663,9 +5758,9 @@ async function buildContext(workDir, dashboardState) {
5663
5758
  }
5664
5759
  }
5665
5760
  try {
5666
- const guardianState = getGuardianState(workDir);
5667
- await guardianState.load();
5668
- const activeGoals = guardianState.getAllGoals().filter((g) => g.status === "active");
5761
+ const projectState = getProjectState(workDir);
5762
+ await projectState.load();
5763
+ const activeGoals = projectState.getAllGoals().filter((g) => g.status === "active");
5669
5764
  if (activeGoals.length > 0) {
5670
5765
  parts.push("Active goals:\n" + activeGoals.map((g) => {
5671
5766
  const metadata = g.metadata || {};
@@ -5924,22 +6019,15 @@ ${contextBlock}`;
5924
6019
  ...messages,
5925
6020
  { role: "user", content: question, timestamp: Date.now() }
5926
6021
  ]);
5927
- const CHAT_TIMEOUT_MS = 18e4;
5928
- const timeoutPromise = new Promise((_, reject) => {
5929
- setTimeout(() => reject(new Error("Request timed out. Large scans (e.g. emoji removal) can take a few minutes. Try again or run the scan from the Goals view.")), CHAT_TIMEOUT_MS);
6022
+ const result = await runAIWithTools({
6023
+ systemPrompt: fullSystem,
6024
+ messages: history,
6025
+ tools: CHAT_TOOLS,
6026
+ executeTool,
6027
+ maxTokens: 4096,
6028
+ maxToolRounds: 8,
6029
+ onProgress: (msg) => dispatch({ type: "SET_CHAT_PROGRESS", message: msg })
5930
6030
  });
5931
- const result = await Promise.race([
5932
- runAIWithTools({
5933
- systemPrompt: fullSystem,
5934
- messages: history,
5935
- tools: CHAT_TOOLS,
5936
- executeTool,
5937
- maxTokens: 4096,
5938
- maxToolRounds: 8,
5939
- onProgress: (msg) => dispatch({ type: "SET_CHAT_PROGRESS", message: msg })
5940
- }),
5941
- timeoutPromise
5942
- ]);
5943
6031
  if (result.success) {
5944
6032
  const action = {
5945
6033
  type: "ADD_CHAT_MESSAGE",
@@ -5959,6 +6047,24 @@ ${contextBlock}`;
5959
6047
  } catch {
5960
6048
  }
5961
6049
  }
6050
+ if (result.toolResults && result.toolResults.length > 0) {
6051
+ for (const toolResult of result.toolResults) {
6052
+ const toolRegex = /\[PENDING_FIX:(.+?)\]/g;
6053
+ let toolMatch;
6054
+ while ((toolMatch = toolRegex.exec(toolResult)) !== null) {
6055
+ try {
6056
+ const jsonStr = toolMatch[1];
6057
+ if (jsonStr) {
6058
+ const fixData = JSON.parse(jsonStr);
6059
+ if (!pendingFixes.some((f) => f.file === fixData.file)) {
6060
+ pendingFixes.push(fixData);
6061
+ }
6062
+ }
6063
+ } catch {
6064
+ }
6065
+ }
6066
+ }
6067
+ }
5962
6068
  if (pendingFixes.length > 0) {
5963
6069
  action.content = result.content.replace(/\[PENDING_FIX:.+?\]/g, "").trim();
5964
6070
  const firstFix = pendingFixes[0];
@@ -5973,7 +6079,7 @@ ${contextBlock}`;
5973
6079
  const toolNames = new Set(result.toolCalls.map((tc) => tc.name));
5974
6080
  if (toolNames.has("trie_add_goal") || toolNames.has("trie_add_hypothesis")) {
5975
6081
  try {
5976
- const agentState = getGuardianState(workDir);
6082
+ const agentState = getProjectState(workDir);
5977
6083
  await agentState.load();
5978
6084
  if (toolNames.has("trie_add_goal")) {
5979
6085
  const goals = agentState.getAllGoals();
@@ -6129,10 +6235,10 @@ ${contextBlock}`;
6129
6235
  /* @__PURE__ */ jsx13(Text12, { dimColor: true, children: " (Esc to cancel)" })
6130
6236
  ] })
6131
6237
  ] }),
6132
- /* @__PURE__ */ jsx13(Box12, { borderStyle: "single", borderColor: "green", paddingX: 1, flexShrink: 0, flexGrow: 0, children: /* @__PURE__ */ jsx13(Text12, { children: inputBuffer ? /* @__PURE__ */ jsxs12(Fragment6, { children: [
6238
+ /* @__PURE__ */ jsx13(Box12, { borderStyle: "single", borderColor: "green", paddingX: 1, flexShrink: 0, flexGrow: 0, children: /* @__PURE__ */ jsx13(Text12, { children: inputBuffer ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
6133
6239
  inputBuffer,
6134
6240
  /* @__PURE__ */ jsx13(Text12, { bold: true, color: "green", children: cursor })
6135
- ] }) : /* @__PURE__ */ jsxs12(Fragment6, { children: [
6241
+ ] }) : /* @__PURE__ */ jsxs12(Fragment7, { children: [
6136
6242
  /* @__PURE__ */ jsx13(Text12, { bold: true, color: "green", children: cursor }),
6137
6243
  /* @__PURE__ */ jsx13(Text12, { dimColor: true, children: "Ask a question..." })
6138
6244
  ] }) }) })
@@ -6159,7 +6265,7 @@ function formatToolInput(input) {
6159
6265
 
6160
6266
  // src/cli/dashboard/views/ChatArchiveView.tsx
6161
6267
  import { useEffect as useEffect4, useCallback as useCallback6 } from "react";
6162
- import { Box as Box13, Text as Text13, useInput as useInput9 } from "ink";
6268
+ import { Box as Box13, Text as Text13, useInput as useInput9, useStdout as useStdout11 } from "ink";
6163
6269
  import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
6164
6270
  function formatTimeAgo2(timestamp) {
6165
6271
  const seconds = Math.floor((Date.now() - timestamp) / 1e3);
@@ -6274,6 +6380,10 @@ function ChatArchiveView() {
6274
6380
  dispatch({ type: "SHOW_NOTIFICATION", message: `Failed to export: ${error instanceof Error ? error.message : "unknown"}`, severity: "warning", autoHideMs: 3e3 });
6275
6381
  }
6276
6382
  }, [sessions, selectedIndex, dispatch]);
6383
+ const { stdout } = useStdout11();
6384
+ const cols = stdout?.columns || 80;
6385
+ const narrow = cols < 60;
6386
+ const contentWidth = Math.max(20, cols - 4);
6277
6387
  useInput9((input, key) => {
6278
6388
  if (inputMode === "rename") {
6279
6389
  if (key.return) {
@@ -6353,11 +6463,12 @@ function ChatArchiveView() {
6353
6463
  /* @__PURE__ */ jsx14(Box13, { flexDirection: "column", marginTop: 1, children: sessions.map((session, idx) => {
6354
6464
  const isSelected = idx === selectedIndex;
6355
6465
  const ago = formatTimeAgo2(session.updatedAt);
6356
- const titleDisplay = session.title.length > 60 ? session.title.slice(0, 60) + "..." : session.title;
6357
- return /* @__PURE__ */ jsx14(Box13, { flexDirection: "column", children: /* @__PURE__ */ jsxs13(Text13, { children: [
6466
+ const titleWidth = Math.max(30, contentWidth - 20);
6467
+ const titleDisplay = session.title.length > titleWidth ? session.title.slice(0, titleWidth) + "..." : session.title;
6468
+ return /* @__PURE__ */ jsx14(Box13, { flexDirection: "column", children: /* @__PURE__ */ jsxs13(Text13, { wrap: "truncate", children: [
6358
6469
  isSelected ? /* @__PURE__ */ jsx14(Text13, { bold: true, color: "green", children: "> " }) : " ",
6359
6470
  isSelected ? /* @__PURE__ */ jsx14(Text13, { bold: true, children: titleDisplay }) : /* @__PURE__ */ jsx14(Text13, { children: titleDisplay }),
6360
- /* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
6471
+ narrow ? null : /* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
6361
6472
  " ",
6362
6473
  session.messageCount,
6363
6474
  " msgs \xB7 ",
@@ -6373,7 +6484,7 @@ import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
6373
6484
  var MAIN_VIEWS = ["overview", "memory", "goals", "hypotheses", "agent", "chat"];
6374
6485
  async function applyGoalFix(fix, dispatch) {
6375
6486
  try {
6376
- const { runAIAnalysis, isAIAvailable: isAIAvailable2 } = await import("./client-OVI6TBX7.js");
6487
+ const { runAIAnalysis, isAIAvailable: isAIAvailable2 } = await import("./client-BZHI675W.js");
6377
6488
  if (!isAIAvailable2()) {
6378
6489
  dispatch({ type: "DISMISS_FIX", id: fix.id });
6379
6490
  getOutputManager().nudge("AI not available for fix", "warning");
@@ -6408,7 +6519,7 @@ ${content}
6408
6519
  fixedContent = fixedContent.replace(/^```\w*\n?/, "").replace(/\n?```$/, "");
6409
6520
  }
6410
6521
  await writeFile(fullPath, fixedContent, "utf-8");
6411
- const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-KLAK5TZN.js");
6522
+ const { recordGoalViolationFixed, getActiveGoals } = await import("./goal-validator-HPPBSDXD.js");
6412
6523
  const goals = await getActiveGoals(projectPath);
6413
6524
  const matchedGoal = goals.find((g) => g.description === fix.goalDescription);
6414
6525
  if (matchedGoal) {
@@ -6455,7 +6566,7 @@ function DashboardApp({ onReady }) {
6455
6566
  const processInsights = useCallback7(async (issues) => {
6456
6567
  try {
6457
6568
  const workDir = getWorkingDirectory(void 0, true);
6458
- const trieAgent = getGuardian(workDir);
6569
+ const trieAgent = getTrieAgent(workDir);
6459
6570
  if (!stateRef.current.agentInitialized) {
6460
6571
  await trieAgent.initialize();
6461
6572
  dispatchRef.current({ type: "SET_AGENT_INITIALIZED", initialized: true });
@@ -6481,7 +6592,7 @@ function DashboardApp({ onReady }) {
6481
6592
  const refreshGoals = useCallback7(async () => {
6482
6593
  try {
6483
6594
  const workDir = getWorkingDirectory(void 0, true);
6484
- const agentState = getGuardianState(workDir);
6595
+ const agentState = getProjectState(workDir);
6485
6596
  await agentState.load();
6486
6597
  const goals = agentState.getAllGoals();
6487
6598
  dispatchRef.current({
@@ -6497,7 +6608,7 @@ function DashboardApp({ onReady }) {
6497
6608
  const refreshHypotheses = useCallback7(async () => {
6498
6609
  try {
6499
6610
  const workDir = getWorkingDirectory(void 0, true);
6500
- const agentState = getGuardianState(workDir);
6611
+ const agentState = getProjectState(workDir);
6501
6612
  await agentState.load();
6502
6613
  const hypotheses = agentState.getAllHypotheses();
6503
6614
  dispatchRef.current({
@@ -6795,4 +6906,4 @@ export {
6795
6906
  handleCheckpointTool,
6796
6907
  InteractiveDashboard
6797
6908
  };
6798
- //# sourceMappingURL=chunk-TFGNTSMH.js.map
6909
+ //# sourceMappingURL=chunk-AXYNWBME.js.map