@triedotdev/mcp 1.0.148 → 1.0.151

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +225 -78
  3. package/dist/{autonomy-config-ZCOSTMPD.js → autonomy-config-3APNC6QF.js} +3 -3
  4. package/dist/{chat-store-OJLJCJFI.js → chat-store-HMTDL7I2.js} +3 -3
  5. package/dist/{chunk-LD7ZEFNY.js → chunk-3KZBC3RJ.js} +2 -2
  6. package/dist/{chunk-SH7H3WRU.js → chunk-4TQQP7JD.js} +3 -3
  7. package/dist/{chunk-SH7H3WRU.js.map → chunk-4TQQP7JD.js.map} +1 -1
  8. package/dist/{chunk-N2EDZTKG.js → chunk-4UDBGYI3.js} +13 -13
  9. package/dist/{chunk-XTTZAQWJ.js → chunk-74R4XSFB.js} +5 -5
  10. package/dist/{chunk-T6PS3MXJ.js → chunk-7HYOJ4Q7.js} +8 -8
  11. package/dist/{chunk-T6PS3MXJ.js.map → chunk-7HYOJ4Q7.js.map} +1 -1
  12. package/dist/{chunk-3MUCUZ46.js → chunk-ABY2R7OK.js} +3 -3
  13. package/dist/chunk-ED7PLRQA.js +782 -0
  14. package/dist/chunk-ED7PLRQA.js.map +1 -0
  15. package/dist/{chunk-4MJ52WBH.js → chunk-EFWVF6TI.js} +4 -2
  16. package/dist/chunk-EFWVF6TI.js.map +1 -0
  17. package/dist/{chunk-23RJT5WT.js → chunk-F7BMFOZ6.js} +2 -2
  18. package/dist/{chunk-4PAAGLKO.js → chunk-G7Q23IGF.js} +36 -9
  19. package/dist/{chunk-4PAAGLKO.js.map → chunk-G7Q23IGF.js.map} +1 -1
  20. package/dist/{chunk-LT6VUZG2.js → chunk-GLY76TSI.js} +3 -3
  21. package/dist/{chunk-WMDFK7LI.js → chunk-IFBEAOHH.js} +5 -5
  22. package/dist/{chunk-YEIJW6X6.js → chunk-JIS2OCZR.js} +4 -4
  23. package/dist/{chunk-FG467PDD.js → chunk-LNUMECBJ.js} +2 -2
  24. package/dist/{chunk-FPEMP54L.js → chunk-OJXFQRUE.js} +2 -2
  25. package/dist/{chunk-5KJ4UJOY.js → chunk-QQG42HCI.js} +2 -2
  26. package/dist/{chunk-7OJ6JIPL.js → chunk-REHKDCI6.js} +7 -150
  27. package/dist/chunk-REHKDCI6.js.map +1 -0
  28. package/dist/{chunk-J7CEBSEB.js → chunk-SU3WCAC4.js} +102 -163
  29. package/dist/chunk-SU3WCAC4.js.map +1 -0
  30. package/dist/{chunk-4C67GV3O.js → chunk-TCNCNWGV.js} +2 -2
  31. package/dist/{chunk-NKHO34UZ.js → chunk-TU7D5DEW.js} +2 -2
  32. package/dist/{chunk-62POBLFC.js → chunk-TWPX6PHF.js} +453 -986
  33. package/dist/chunk-TWPX6PHF.js.map +1 -0
  34. package/dist/{chunk-FH335WL5.js → chunk-TWQPOVRA.js} +2 -2
  35. package/dist/{chunk-YOJGSRZK.js → chunk-V3O7C2LY.js} +2 -2
  36. package/dist/{chunk-V7AY2EJO.js → chunk-WOTLY5NA.js} +2 -2
  37. package/dist/cli/create-agent.js +8 -40
  38. package/dist/cli/create-agent.js.map +1 -1
  39. package/dist/cli/main.js +121 -164
  40. package/dist/cli/main.js.map +1 -1
  41. package/dist/cli/yolo-daemon.js +31 -155
  42. package/dist/cli/yolo-daemon.js.map +1 -1
  43. package/dist/{client-INNE2GGZ.js → client-5L64D5SQ.js} +3 -3
  44. package/dist/{codebase-index-FMIULFZQ.js → codebase-index-OOE7OAHP.js} +3 -3
  45. package/dist/{fast-analyzer-MWKCDRGD.js → fast-analyzer-FMU3X4AZ.js} +5 -5
  46. package/dist/github-ingester-C66ZRUYC.js +11 -0
  47. package/dist/{goal-manager-ZBWKWEML.js → goal-manager-VTBFFYN4.js} +8 -7
  48. package/dist/{goal-validator-DA3JQ6JN.js → goal-validator-EM5XVWVC.js} +7 -6
  49. package/dist/{graph-J4OGTYCO.js → graph-26JPZ3DF.js} +3 -3
  50. package/dist/{hypothesis-JCUMZKTG.js → hypothesis-4UPE7KXU.js} +8 -7
  51. package/dist/{incident-index-BWW2UEY7.js → incident-index-H6APJ4S3.js} +3 -3
  52. package/dist/index.js +116 -397
  53. package/dist/index.js.map +1 -1
  54. package/dist/{insight-store-A5XXMFD6.js → insight-store-QEEUQR5L.js} +4 -4
  55. package/dist/{issue-store-LZWZIGM7.js → issue-store-C6XYENE5.js} +7 -4
  56. package/dist/ledger-VNA4DX3Z.js +51 -0
  57. package/dist/linear-ingester-WIUBWF55.js +11 -0
  58. package/dist/{tiered-storage-VZL7KK64.js → tiered-storage-P6Z3NV2Q.js} +3 -3
  59. package/dist/trie-agent-GJJJCL6P.js +27 -0
  60. package/dist/trie-agent-GJJJCL6P.js.map +1 -0
  61. package/package.json +8 -6
  62. package/dist/chunk-4MJ52WBH.js.map +0 -1
  63. package/dist/chunk-62POBLFC.js.map +0 -1
  64. package/dist/chunk-7OJ6JIPL.js.map +0 -1
  65. package/dist/chunk-G76DYVGX.js +0 -136
  66. package/dist/chunk-G76DYVGX.js.map +0 -1
  67. package/dist/chunk-J7CEBSEB.js.map +0 -1
  68. package/dist/comprehension-46F7ZNKL.js +0 -821
  69. package/dist/comprehension-46F7ZNKL.js.map +0 -1
  70. package/dist/github-ingester-J2ZFYXVE.js +0 -11
  71. package/dist/linear-ingester-JRDQAIAA.js +0 -11
  72. package/dist/trie-agent-6A7YBNTQ.js +0 -26
  73. package/dist/workers/agent-worker.d.ts +0 -2
  74. package/dist/workers/agent-worker.js +0 -28
  75. package/dist/workers/agent-worker.js.map +0 -1
  76. /package/dist/{autonomy-config-ZCOSTMPD.js.map → autonomy-config-3APNC6QF.js.map} +0 -0
  77. /package/dist/{chat-store-OJLJCJFI.js.map → chat-store-HMTDL7I2.js.map} +0 -0
  78. /package/dist/{chunk-LD7ZEFNY.js.map → chunk-3KZBC3RJ.js.map} +0 -0
  79. /package/dist/{chunk-N2EDZTKG.js.map → chunk-4UDBGYI3.js.map} +0 -0
  80. /package/dist/{chunk-XTTZAQWJ.js.map → chunk-74R4XSFB.js.map} +0 -0
  81. /package/dist/{chunk-3MUCUZ46.js.map → chunk-ABY2R7OK.js.map} +0 -0
  82. /package/dist/{chunk-23RJT5WT.js.map → chunk-F7BMFOZ6.js.map} +0 -0
  83. /package/dist/{chunk-LT6VUZG2.js.map → chunk-GLY76TSI.js.map} +0 -0
  84. /package/dist/{chunk-WMDFK7LI.js.map → chunk-IFBEAOHH.js.map} +0 -0
  85. /package/dist/{chunk-YEIJW6X6.js.map → chunk-JIS2OCZR.js.map} +0 -0
  86. /package/dist/{chunk-FG467PDD.js.map → chunk-LNUMECBJ.js.map} +0 -0
  87. /package/dist/{chunk-FPEMP54L.js.map → chunk-OJXFQRUE.js.map} +0 -0
  88. /package/dist/{chunk-5KJ4UJOY.js.map → chunk-QQG42HCI.js.map} +0 -0
  89. /package/dist/{chunk-4C67GV3O.js.map → chunk-TCNCNWGV.js.map} +0 -0
  90. /package/dist/{chunk-NKHO34UZ.js.map → chunk-TU7D5DEW.js.map} +0 -0
  91. /package/dist/{chunk-FH335WL5.js.map → chunk-TWQPOVRA.js.map} +0 -0
  92. /package/dist/{chunk-YOJGSRZK.js.map → chunk-V3O7C2LY.js.map} +0 -0
  93. /package/dist/{chunk-V7AY2EJO.js.map → chunk-WOTLY5NA.js.map} +0 -0
  94. /package/dist/{client-INNE2GGZ.js.map → client-5L64D5SQ.js.map} +0 -0
  95. /package/dist/{codebase-index-FMIULFZQ.js.map → codebase-index-OOE7OAHP.js.map} +0 -0
  96. /package/dist/{fast-analyzer-MWKCDRGD.js.map → fast-analyzer-FMU3X4AZ.js.map} +0 -0
  97. /package/dist/{github-ingester-J2ZFYXVE.js.map → github-ingester-C66ZRUYC.js.map} +0 -0
  98. /package/dist/{goal-manager-ZBWKWEML.js.map → goal-manager-VTBFFYN4.js.map} +0 -0
  99. /package/dist/{goal-validator-DA3JQ6JN.js.map → goal-validator-EM5XVWVC.js.map} +0 -0
  100. /package/dist/{graph-J4OGTYCO.js.map → graph-26JPZ3DF.js.map} +0 -0
  101. /package/dist/{hypothesis-JCUMZKTG.js.map → hypothesis-4UPE7KXU.js.map} +0 -0
  102. /package/dist/{incident-index-BWW2UEY7.js.map → incident-index-H6APJ4S3.js.map} +0 -0
  103. /package/dist/{insight-store-A5XXMFD6.js.map → insight-store-QEEUQR5L.js.map} +0 -0
  104. /package/dist/{issue-store-LZWZIGM7.js.map → issue-store-C6XYENE5.js.map} +0 -0
  105. /package/dist/{linear-ingester-JRDQAIAA.js.map → ledger-VNA4DX3Z.js.map} +0 -0
  106. /package/dist/{tiered-storage-VZL7KK64.js.map → linear-ingester-WIUBWF55.js.map} +0 -0
  107. /package/dist/{trie-agent-6A7YBNTQ.js.map → tiered-storage-P6Z3NV2Q.js.map} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Trie Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,48 +1,59 @@
1
- # Trie: A trainable AI agent with cryptographic governance and portable context
1
+ # Trie: A trainable AI agent with a cryptographic governance ledger and portable context
2
2
 
3
3
 
4
- **The ledger that keeps your work compliant when agents and humans ship together.**
4
+ **The ledger that keeps agents and humans aligned when shipping together.**
5
5
 
6
6
  [![Download Workspace](https://img.shields.io/badge/Download-Trie%20Workspace-blue)](https://www.trie.dev) [![Follow on X](https://img.shields.io/badge/Follow-@louiskishfy-1DA1F2?logo=x)](https://x.com/louiskishfy)
7
7
 
8
8
  ## What Trie Does
9
9
 
10
- Trie is a trainable AI agent that maintains a ledger that governs work across agents and humans:
10
+ Trie is governance for teams where agents and humans ship together. Every decision, direction change, and tradeoff gets recorded in a governance ledger that every contributor—human or agent—reads from and writes to, across every tool in the stack.
11
11
 
12
12
  - **Autonomous Operation**: Run `trie watch` and the agent monitors your codebase 24/7
13
13
  - **Intelligent Extraction**: Automatically extracts decisions, facts, blockers from every change
14
- - **Cryptographic governance ledger**: Stores decisions, incidents, and fixes in a tamper-evident chain—the shared memory that travels from Cursor/Claude Code → CLI → CI/CD, solving the context-across-tools problem
14
+ - **Governance ledger**: Tamper-evident chain with digital signatures—the shared memory that travels from Cursor/Claude Code → CLI → CI/CD
15
15
  - **Predictive Intelligence**: `trie gotcha` queries the ledger to predict problems before they happen
16
16
  - **Continuous Learning**: Feed it incidents with `trie tell`, teach it patterns with your history
17
17
 
18
- The ledger learns from every incident, decision, and fix. When you ship, Trie remembers. When something breaks, Trie learns. Over time, everyone on the team—human and agent—gets better at predicting what will go wrong before it does.
18
+ The work stays coherent not because someone held it together, but because the ledger did. When any contributor flags a direction change, the ledger surfaces the relevant history instantly. When an agent acts, it does so with full context of what was decided before and why.
19
19
 
20
- ### The Context-Across-Tools Problem (and How the Ledger Solves It)
20
+ ### The Agent Coordination Problem
21
21
 
22
- **The problem**: When work happens across Cursor, Claude Code, VS Code, the terminal, and CI/CD, context fragments. An agent makes a decision in one tool; a human forgets it in another. Each environment has its own memory—or none at all. You burn tokens re-explaining the same constraints, or worse, ship code that violates decisions made elsewhere.
22
+ **The problem**: When agents and humans ship code together across Cursor, Claude Code, VS Code, and CI/CD, who's accountable for what? An agent makes a decision in one tool; a human modifies it in another; a second agent undoes both. Without a shared record, coordination becomes chaos.
23
23
 
24
- **The solution**: Trie stores important information in a cryptographic governance ledger—a tamper-evident, append-only chain of blocks. Every decision, incident, fix, and tradeoff gets written to the ledger. Because the ledger lives in your `.trie/` folder and syncs across your team, every tool reads from the same source of truth. Cursor, Claude, the CLI, and CI/CD all query the same blocks. No more context loss. No more conflicting memories. The ledger is the shared brain that keeps agents and humans aligned across every tool you use.
24
+ **The solution**: Trie's governance ledger provides a shared source of truth that both agents and humans can trust. Every decision, every incident, every fix gets recorded with cryptographic signatures proving who (or what) made each change. When an agent queries the ledger, it gets the full context. When you review changes, you see the reasoning. When something breaks, the ledger shows you exactly what led there.
25
25
 
26
- ## Goal
26
+ Think of it as **double-entry bookkeeping for code decisions**—not blockchain-level immutability, but tamper-evident accountability that works with Git and your existing workflow.
27
27
 
28
- **Trie is the governance layer for teams where agents and humans ship together.**
28
+ ## Why It Matters for Agent Collaboration
29
29
 
30
- Every bug you fix teaches the ledger a pattern that protects all your projects. Every incident you report becomes institutional knowledge that travels with your code. Every decision you make—and the tradeoffs you considered—gets extracted and stored automatically. The ledger keeps work compliant so you ship the right thing every time.
30
+ When agents can ship production changes, you need governance that works for both humans and AI:
31
31
 
32
- Instead of burning tokens on the same questions across different repos or forgetting why you architected something a certain way six months ago, the ledger remembers for everyone. Instead of agents and humans stepping on each other's decisions, the ledger maintains system coherence.
32
+ **Traditional tools fall short:**
33
+ - Linear tracks tasks, not decisions or reasoning
34
+ - GitHub shows changes, not why they were made
35
+ - Slack/Discord: context vanishes in chat history
36
+ - No tool tells you if an agent's change conflicts with yesterday's decision
33
37
 
34
- The result: faster development with fewer production fires, because the ledger gets smarter every time something breaks—and every agent and human on the team benefits.
38
+ **Trie's ledger provides:**
39
+ - **Tamper-evident history**: Ed25519 signatures detect if entries are modified
40
+ - **Automatic recording**: Agents and humans write to the same ledger
41
+ - **Cross-tool context**: Works in Cursor, CLI, CI/CD, MCP servers
42
+ - **Accountability**: See who (human or agent) made each decision and when
43
+ - **Pattern learning**: Every incident makes the system smarter
44
+
45
+ The ledger ensures nothing is lost. When an agent queries it, answers come with full provenance. When you review changes, you see the reasoning trail. When something breaks, the audit trail is already there.
35
46
 
36
47
  ### How the Agent Works
37
48
 
38
49
  1. **`trie watch`** - Start the agent, it monitors your codebase autonomously
39
50
  2. **Agent Extracts** - Every file change → extract decisions, facts, blockers
40
- 3. **Agent Stores** - Builds decision ledger with rich metadata and tag expansion
51
+ 3. **Agent Stores** - Builds decision ledger with signatures and metadata
41
52
  4. **`trie gotcha`** - Agent queries ledger to predict problems in your current changes
42
53
  5. **`trie tell`** - Feed agent incidents to improve its predictions
43
54
  6. **Agent Learns** - Gets better at predicting what matters in YOUR codebase
44
55
 
45
- Your decisions persist across tools. Your edge cases don't get forgotten. The ledger keeps agents and humans compliant—so you ship the right thing every time.
56
+ Your decisions persist across tools. Your edge cases don't get forgotten. The ledger keeps agents and humans aligned—so you ship the right thing every time.
46
57
 
47
58
  ## Quick Start
48
59
 
@@ -91,54 +102,75 @@ Tools like Cursor Bugbot flag issues—but flagging doesn't help you avoid simil
91
102
 
92
103
  ## Key Features
93
104
 
94
- ### Smart Memory
105
+ ### Built for Agent + Human Collaboration
95
106
 
96
- - Git-based storage - Your project's memory travels with your code in `.trie/` folder.
97
- - Cross-project learning - Patterns discovered in one project help prevent bugs in others.
98
- - Incident tracking - Build a searchable history of what went wrong and why.
99
- - Decision memory - Remembers architectural choices and tradeoffs across Cursor, Claude, VS Code, CLI, and CI/CD.
100
- - Cryptographic governance ledger - Chain-of-blocks, append-only, tamper-evident; solves the context-across-tools problem; every tool reads from the same source of truth.
101
- - Governance that travels - The ledger keeps agents and humans compliant across all your tools.
107
+ - **Shared governance ledger** - Single source of truth that agents and humans both read from and write to
108
+ - **Digital signatures** - Ed25519 signatures prove who (human or agent) created each entry, automatic and zero-config
109
+ - **Accountability trail** - See exactly what decisions agents made and when, verify authenticity
110
+ - **Cross-tool context** - Works in Cursor, Claude Code, CLI, CI/CD—same ledger everywhere
111
+ - **Tamper detection** - Signatures and Git history make modifications visible
112
+ - **No coordination needed** - Agents and humans write concurrently; Git handles conflicts
102
113
 
103
- ### Intelligent Analysis
114
+ ### Governance That Scales
104
115
 
105
- - Risk scoring - Intelligent priority ranking based on your actual incident history.
106
- - Edge case detection - Identifies recurring issues and patterns you've hit before.
107
- - System coherence - Tracks relationships between files, changes, incidents, fixes, and decisions.
116
+ - **Tamper-evident ledger** - Append-only chain with cryptographic signatures (not blockchain, think double-entry bookkeeping)
117
+ - **Correction pattern** - Entries never deleted, only marked as corrected with full audit trail
118
+ - **Decision memory** - Captures architectural choices, tradeoffs, and context across all tools
119
+ - **Judgment artifacts** - Not just what shipped, but why, what was considered, and who (or what) decided
120
+ - **Git integration** - Auto-commits ledger changes; distributed backup via Git history
108
121
 
109
- ### Development Integration
122
+ ### Intelligence That Compounds
110
123
 
111
- - Git hooks - Automatic checks before commits and pushes.
112
- - Watch mode - Real-time monitoring while you code.
113
- - Fast performance - Sub-500ms checks, won't slow down your workflow.
124
+ - **Predictive analysis** - `trie gotcha` queries the ledger to predict problems before they happen
125
+ - **Pattern recognition** - Identifies recurring issues and edge cases from your actual incident history
126
+ - **Cross-project learning** - Patterns discovered in one project help prevent bugs in others
127
+ - **System coherence** - Tracks relationships between files, changes, incidents, fixes, and decisions
128
+ - **Continuous learning** - Gets better at predicting what matters in YOUR codebase over time
114
129
 
115
- ### Developer Experience
130
+ ### Integration Built for Speed
116
131
 
117
- - Plain English warnings - "This payment flow broke twice before" instead of cryptic codes.
118
- - Multiple interfaces - CLI, MCP tools for Claude/Cursor, visual dashboards.
119
- - Flexible workflow - Works with any editor, any git workflow, any deployment setup.
132
+ - **Multiple interfaces** - CLI, MCP tools for Claude/Cursor, visual dashboards
133
+ - **Git hooks** - Automatic checks before commits and pushes
134
+ - **Watch mode** - Real-time monitoring while you code
135
+ - **Fast performance** - Sub-500ms checks, won't slow down your workflow
136
+ - **Flexible workflow** - Works with any editor, any git workflow, any deployment setup
120
137
 
121
138
  ## How It Works
122
139
 
123
- ### The Trie Agent
140
+ ### Memory Architecture
141
+
142
+ Trie maintains two complementary memory systems that work together to provide both fast queries and tamper-evident governance:
143
+
144
+ **1. Governance Ledger** (`.trie/memory/ledger.json`)
145
+ - **Purpose**: Cryptographic chain of what was detected and when
146
+ - **Properties**: Append-only, tamper-evident, never deleted
147
+ - **Used for**: Audit trail, compliance, historical analysis, gotcha predictions
148
+ - **Immutability**: Entries are marked as corrected, not deleted (see [Ledger Corrections](./docs/LEDGER_CORRECTIONS.md))
149
+
150
+ **2. Issue Memory** (`.trie/memory/issues/`)
151
+ - **Purpose**: Fast searchable cache of detected issues
152
+ - **Properties**: Queryable, can be compacted and purged
153
+ - **Used for**: `trie memory search`, pattern recognition, recent issue queries
154
+ - **Lifecycle**: Subject to capacity limits; cleaned up via `trie memory purge` strategies
124
155
 
125
- Trie uses a proactive agent architecture:
156
+ Both systems sync across your team and travel with your codebase. The `.trie/` folder commits with your code, so your project's intelligence is preserved and shared across:
126
157
 
127
- - Analyzes your code for potential issues based on your incident history.
128
- - The agent decides what matters based on your history.
129
- - Memory Tree stores incident patterns using a trie data structure for fast lookups.
130
- - Learning Loop improves predictions based on your feedback.
158
+ Local development
159
+ CI/CD pipelines
160
+ Team members
161
+ Cursor/Claude/VS Code
162
+ Git hooks
131
163
 
132
- ### Memory That Travels
164
+ ### File Structure
133
165
 
134
166
  ```
135
167
  your-project/
136
168
  ├── .trie/
137
169
  │ ├── hot/ # In-memory current session
138
- │ ├── warm/ # Queryable decisions DB
170
+ │ ├── warm/ # Queryable governance DB
139
171
  │ │ └── decisions.db # SQLite database
140
172
  │ ├── cold/ # Archived history
141
- │ ├── memory/ # Incident history + ledger.json (cryptographic ledger)
173
+ │ ├── memory/ # Issue cache + ledger.json (cryptographic ledger)
142
174
  │ ├── patterns/ # Learned patterns
143
175
  │ ├── context.json # Project knowledge graph
144
176
  │ └── config.json # Settings
@@ -148,14 +180,7 @@ your-project/
148
180
  │ └── ledger-manifest.json
149
181
  ├── src/
150
182
  └── .git/
151
- ```
152
-
153
- The .trie/ folder commits with your code, so your project's intelligence is preserved and shared across:
154
-
155
- Local development
156
- CI/CD pipelines
157
- Team members
158
- Different machines
183
+ ```
159
184
 
160
185
  ### Decision Memory Across Tools
161
186
 
@@ -503,7 +528,7 @@ Git repository
503
528
  npm install -g trie
504
529
 
505
530
  # Or use npx for one-time runs
506
- npx trie scan
531
+ npx trie watch
507
532
  ```
508
533
 
509
534
  ### Project Setup
@@ -752,6 +777,44 @@ Or manually add to `.trie/config.json`:
752
777
  - Critical decision changes
753
778
  - Auto-escalation notifications
754
779
 
780
+ ### Ledger Corrections (Immutable Audit Trail)
781
+
782
+ The ledger is **append-only** - entries are never deleted. When mistakes happen, use corrections instead:
783
+
784
+ **Mark entries as corrected:**
785
+ ```bash
786
+ # Correct a false positive
787
+ trie ledger correct <entry-id> -r "Expected behavior, not a bug" -t false-positive
788
+
789
+ # Mark as fixed
790
+ trie ledger correct <entry-id> -r "Fixed in commit abc123"
791
+
792
+ # Batch corrections
793
+ trie ledger correct entry1 entry2 entry3 -r "Duplicate detections"
794
+ ```
795
+
796
+ **View correction stats:**
797
+ ```bash
798
+ # Show correction statistics
799
+ trie ledger corrections
800
+
801
+ # View history for specific entries
802
+ trie ledger corrections --entries <entry-id1> <entry-id2>
803
+ ```
804
+
805
+ **What happens:**
806
+ - Original entry preserved for audit trail
807
+ - Entry marked with status (`corrected` or `false-positive`)
808
+ - Correction metadata added (timestamp, reason, who)
809
+ - New correction entry appended to ledger
810
+ - Queries automatically filter out corrected entries
811
+
812
+ **Why immutability matters:**
813
+ - Full audit trail for compliance and trust
814
+ - Tamper-evidence through cryptographic chain
815
+ - Learn from false positives to improve detection
816
+ - Track correction rates over time
817
+
755
818
  ## CI/CD Integration
756
819
 
757
820
  ### GitHub Actions
@@ -772,45 +835,84 @@ trie ci github
772
835
  # In your CI pipeline
773
836
  npm install -g trie
774
837
  # Query decision ledger for risks
775
- trie gotcha
776
- # Check memory for related incidents
777
- trie memory search "deployment"
778
- ```
779
838
 
780
- ## Memory System
839
+ ## Memory Architecture
781
840
 
782
- ### Local Memory
841
+ Trie maintains two complementary memory systems that work together:
783
842
 
784
- Each project stores its own memory in .trie/memory/:
843
+ ### 1. Governance Ledger (Primary Product)
785
844
 
786
- Incident reports and patterns
787
- Risk scores and confidence levels
788
- Performance over time
845
+ **Location:** `.trie/memory/ledger.json`
846
+ **Purpose:** Tamper-evident record of decisions, incidents, and fixes
847
+ **Architecture:** Append-only chain of blocks with Ed25519 signatures
789
848
 
790
- ### Cross-Project Memory
849
+ This is the **core governance layer** that:
850
+ - Powers `trie gotcha` predictions
851
+ - Provides accountability for agent and human decisions
852
+ - Uses digital signatures to detect tampering
853
+ - Never deleted, only corrected (see [Ledger Corrections](./docs/LEDGER_CORRECTIONS.md))
854
+ - Auto-commits to Git for distributed backup
791
855
 
792
- Global patterns stored in ~/.trie/memory/:
856
+ **How it works:**
857
+ - Every entry gets signed with Ed25519 (automatic, zero config)
858
+ - Signatures prove who created each entry and detect modifications
859
+ - Git integration provides distributed backup and history
860
+ - Think: **double-entry bookkeeping**, not blockchain
793
861
 
794
- Patterns that apply across projects
795
- Your personal coding patterns
862
+ **Security model:**
863
+ - **Tamper-evident**: Signatures detect if entries are modified
864
+ - ✅ **Accountability**: See who (human or agent) made each decision
865
+ - ✅ **Git backup**: Distributed history via automatic commits
866
+ - ✅ **Verification**: `trie ledger verify` checks integrity
867
+ - ⚠️ **Not encrypted**: Ledger is plaintext (can add encryption if needed)
868
+ - ⚠️ **Not access-controlled**: Standard file permissions apply
869
+ - ⚠️ **Not deletion-proof**: Can still `rm .trie/` (but Git history remains)
796
870
 
797
- ### Memory Management
871
+ **Real protection comes from:** Git history + Team workflow + PR reviews
798
872
 
799
- ```bash
800
- # View capacity (default: 10,000 issues)
801
- trie memory stats
873
+ Perfect for agent collaboration because:
874
+ - Agents can trust ledger contents (signatures verify authenticity)
875
+ - Humans can audit agent decisions (full provenance trail)
876
+ - Cross-tool context works (same ledger in Cursor, CLI, CI/CD)
877
+ - Conflicts are visible (Git shows competing changes)
878
+
879
+ Learn more: [Signatures & Git Integration](./docs/SIGNATURES_AND_GIT.md)
880
+
881
+ ### 2. Issue Memory (Query Cache)
882
+
883
+ **Location:** `.trie/memory/issues.json`
884
+ **Purpose:** Fast searchable cache for pattern queries
885
+ **Complementary to:** The ledger
886
+
887
+ Issue memory caches:
888
+ - **Goal violations** caught by watch mode
889
+ - **Learning extractions** from `trie learn` (git history analysis)
890
+ - **Manual reports** via `trie tell` or chat
891
+ - **Working state** - tracks resolved/open/fixed status
892
+ - **Cross-project patterns** in `~/.trie/memory/`
802
893
 
803
- # Smart cleanup (removes resolved + old low-priority)
804
- trie memory purge smart
894
+ **Each issue links back to the ledger** via `ledgerBlockHash` for full audit trail.
805
895
 
806
- # Remove all resolved issues
807
- trie memory purge resolved
896
+ **Why both systems?**
897
+ - **Ledger** = immutable historical record (what was detected, when)
898
+ - **Issue memory** = mutable working state (resolved, open, metrics)
808
899
 
809
- # Remove issues older than 90 days
810
- trie memory purge old --days=90
900
+ The ledger ensures nothing is lost. Issue memory tracks current state and makes queries fast.
901
+
902
+ ### Query Issue Memory
903
+
904
+ ```bash
905
+ # Search for patterns
906
+ trie memory search "authentication"
907
+
908
+ # View statistics
909
+ trie memory stats
910
+
911
+ # See recent detections
912
+ trie memory recent
811
913
  ```
812
914
 
813
- What happens at the 10,000 issue cap: Trie will deduplicate new repeats, compact older issues into summaries, and if it still exceeds the cap it will prune the oldest/lowest-value issues (it does not “overwrite” in place).
915
+ **Note:** Issue memory can be cleaned up (`trie memory purge smart`) without affecting the immutable ledger. The ledger remains the source of truth.
814
916
 
815
917
  ## Troubleshooting
816
918
 
@@ -836,6 +938,51 @@ trie goal list
836
938
  ### Getting Help
837
939
  - Issues: [Report bugs and request features](https://x.com/louiskishfy)
838
940
 
941
+ ## Contributing
942
+
943
+ We welcome contributions from the community! Whether you're fixing bugs, adding features, improving documentation, or sharing feedback, your contributions help make Trie better for everyone.
944
+
945
+ ### Quick Start for Contributors
946
+
947
+ 1. **Fork and clone** the repository
948
+ 2. **Install dependencies**: `npm install`
949
+ 3. **Set up environment**: Copy `.env.example` to `.env.local` and add your API keys
950
+ 4. **Build the project**: `npm run build`
951
+ 5. **Run tests**: `npm test`
952
+
953
+ ### Before Submitting
954
+
955
+ - Ensure all tests pass (`npm test`)
956
+ - Run type checking (`npm run typecheck`)
957
+ - Follow our code style (`npm run lint`)
958
+ - Update documentation for new features
959
+ - Never commit secrets or API keys
960
+
961
+ **Read our full [Contributing Guide](CONTRIBUTING.md) for detailed guidelines.**
962
+
963
+ ### Ways to Contribute
964
+
965
+ - 🐛 **Report bugs** - Open an issue with reproduction steps
966
+ - 💡 **Suggest features** - Share ideas for improvements
967
+ - 📝 **Improve docs** - Fix typos, add examples, clarify instructions
968
+ - 🔧 **Submit PRs** - Fix bugs or implement features
969
+ - 🧪 **Add tests** - Improve test coverage
970
+ - 🔐 **Security** - Report vulnerabilities privately (see [SECURITY.md](SECURITY.md))
971
+
972
+ ### Code of Conduct
973
+
974
+ Be respectful, inclusive, and professional. We're building this together.
975
+
976
+ ## Security
977
+
978
+ Please report security vulnerabilities privately. See [SECURITY.md](SECURITY.md) for details.
979
+
980
+ **Never commit:**
981
+ - API keys or secrets
982
+ - `.env.local` or `.env` files
983
+ - Private signing keys (`.trie/keys/`)
984
+ - Personal configuration
985
+
839
986
  ## License
840
987
 
841
- MIT License
988
+ MIT License - See [LICENSE](LICENSE) for details.
@@ -10,8 +10,8 @@ import {
10
10
  shouldAutoFix,
11
11
  shouldBlockPush,
12
12
  trackIssueOccurrence
13
- } from "./chunk-5KJ4UJOY.js";
14
- import "./chunk-SH7H3WRU.js";
13
+ } from "./chunk-QQG42HCI.js";
14
+ import "./chunk-4TQQP7JD.js";
15
15
  import "./chunk-APMV77PU.js";
16
16
  import "./chunk-DGUM43GV.js";
17
17
  export {
@@ -27,4 +27,4 @@ export {
27
27
  shouldBlockPush,
28
28
  trackIssueOccurrence
29
29
  };
30
- //# sourceMappingURL=autonomy-config-ZCOSTMPD.js.map
30
+ //# sourceMappingURL=autonomy-config-3APNC6QF.js.map
@@ -2,9 +2,9 @@ import {
2
2
  ChatStore,
3
3
  clearChatStores,
4
4
  getChatStore
5
- } from "./chunk-23RJT5WT.js";
5
+ } from "./chunk-F7BMFOZ6.js";
6
6
  import "./chunk-43X6JBEM.js";
7
- import "./chunk-SH7H3WRU.js";
7
+ import "./chunk-4TQQP7JD.js";
8
8
  import "./chunk-APMV77PU.js";
9
9
  import "./chunk-DGUM43GV.js";
10
10
  export {
@@ -12,4 +12,4 @@ export {
12
12
  clearChatStores,
13
13
  getChatStore
14
14
  };
15
- //# sourceMappingURL=chat-store-OJLJCJFI.js.map
15
+ //# sourceMappingURL=chat-store-HMTDL7I2.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadConfig
3
- } from "./chunk-NKHO34UZ.js";
3
+ } from "./chunk-TU7D5DEW.js";
4
4
 
5
5
  // src/ingest/linear-ingester.ts
6
6
  import path from "path";
@@ -129,4 +129,4 @@ var LinearIngester = class {
129
129
  export {
130
130
  LinearIngester
131
131
  };
132
- //# sourceMappingURL=chunk-LD7ZEFNY.js.map
132
+ //# sourceMappingURL=chunk-3KZBC3RJ.js.map
@@ -176,8 +176,8 @@ function getWorkingDirectory(explicitDir, silent = false) {
176
176
  console.error(" Or set DEBUG_TRIE_WORKSPACE=1 to debug workspace detection");
177
177
  console.error(` Current working directory: ${cwd}`);
178
178
  console.error(" Examples:");
179
- console.error(' Use trie_security with directory: "/path/to/your/project"');
180
- console.error(' Use trie_scan with directory: "./your-project"');
179
+ console.error(' Use trie_fix with directory: "/path/to/your/project"');
180
+ console.error(' Use trie watch with directory: "./your-project"');
181
181
  }
182
182
  return cwd;
183
183
  }
@@ -186,4 +186,4 @@ export {
186
186
  getTrieDirectory,
187
187
  getWorkingDirectory
188
188
  };
189
- //# sourceMappingURL=chunk-SH7H3WRU.js.map
189
+ //# sourceMappingURL=chunk-4TQQP7JD.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/workspace.ts"],"sourcesContent":["/**\n * Workspace detection utilities\n * \n * MCP servers run as separate processes where process.cwd() may not be\n * the user's workspace. These utilities detect the actual project root\n * by looking for common project indicators.\n */\n\nimport { execSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'fs';\nimport { basename, dirname, join, resolve } from 'path';\nimport { isInteractiveMode } from './progress.js';\n\n// Project root indicators - files/directories that indicate a project root\n// Ordered by strength: primary indicators first\nconst PROJECT_ROOT_INDICATORS = [\n 'package.json', // Node.js/npm projects\n '.git', // Git repository root\n 'Cargo.toml', // Rust projects\n 'go.mod', // Go modules\n 'pyproject.toml', // Python projects (modern)\n 'pom.xml', // Maven (Java)\n 'build.gradle', // Gradle (Java/Kotlin)\n 'deno.json', // Deno projects\n // Note: .trie/config.json would be a better indicator, but empty .trie dirs exist\n // tsconfig.json is secondary as it can exist in subdirectories\n];\n\n// Directories that indicate we're in an npm package, not a user workspace\nconst NPM_PACKAGE_INDICATORS = [\n 'node_modules/@', // Scoped packages\n 'node_modules/', // Regular packages\n '.npm/', // npm cache\n '.nvm/', // nvm\n 'lib/node_modules/', // Global npm\n];\n\nfunction getGitCommonDir(startDir: string): string | null {\n try {\n const output = execSync('git rev-parse --git-common-dir', {\n cwd: startDir,\n stdio: ['ignore', 'pipe', 'ignore'],\n })\n .toString()\n .trim();\n if (!output) return null;\n return resolve(startDir, output);\n } catch {\n return null;\n }\n}\n\nfunction getSharedWorktreeRoot(startDir: string): string | null {\n const commonDir = getGitCommonDir(startDir);\n if (!commonDir) return null;\n if (basename(commonDir) !== '.git') return null;\n return dirname(commonDir);\n}\n\nexport function getTrieDirectory(workDir: string): string {\n const mode = process.env.TRIE_WORKTREE_MODE?.toLowerCase();\n if (mode === 'isolated') {\n return join(workDir, '.trie');\n }\n const sharedRoot = getSharedWorktreeRoot(workDir);\n if (sharedRoot) {\n return join(sharedRoot, '.trie');\n }\n return join(workDir, '.trie');\n}\n\n/**\n * Find the nearest project root by walking up from a starting directory\n * Returns the directory containing a project root indicator, or null if none found\n */\nexport function findProjectRoot(startDir: string, maxLevels: number = 10): string | null {\n let currentDir = resolve(startDir);\n let levels = 0;\n \n while (levels < maxLevels) {\n // Check if any project root indicator exists in this directory\n for (const indicator of PROJECT_ROOT_INDICATORS) {\n const indicatorPath = join(currentDir, indicator);\n if (existsSync(indicatorPath)) {\n return currentDir;\n }\n }\n \n // Move up one directory\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) {\n // Reached filesystem root\n break;\n }\n currentDir = parentDir;\n levels++;\n }\n \n return null;\n}\n\n/**\n * Check if a path looks like it's inside an npm package installation\n */\nfunction isInsideNpmPackage(dir: string): boolean {\n const normalizedPath = dir.replace(/\\\\/g, '/');\n return NPM_PACKAGE_INDICATORS.some(indicator => normalizedPath.includes(indicator));\n}\n\n/**\n * Try to get workspace from environment variables\n * Various tools set these when invoking MCP servers\n */\nfunction getWorkspaceFromEnv(): string | null {\n // Common environment variables that might contain workspace path\n const envVars = [\n 'CURSOR_WORKSPACE', // Cursor IDE\n 'CURSOR_WORKSPACE_ROOT', // Alternative Cursor env var\n 'VSCODE_WORKSPACE', // VS Code\n 'VSCODE_CWD', // VS Code working directory\n 'WORKSPACE_FOLDER', // Generic workspace\n 'PROJECT_ROOT', // Generic project root\n 'INIT_CWD', // npm's original directory\n 'PWD', // Original shell directory\n ];\n \n for (const envVar of envVars) {\n const value = process.env[envVar];\n if (value && existsSync(value)) {\n // Verify it looks like a project\n const hasProjectIndicator = PROJECT_ROOT_INDICATORS.some(\n indicator => existsSync(join(value, indicator))\n );\n if (hasProjectIndicator) {\n return value;\n }\n }\n }\n \n return null;\n}\n\n/**\n * Get the best working directory for scanning/operations\n * Priority: \n * 1. Explicit directory arg\n * 2. Environment variable (CURSOR_WORKSPACE, etc.)\n * 3. Detected project root from cwd (if not inside npm package)\n * 4. process.cwd() with warning\n * \n * @param explicitDir - Optional explicit directory from user\n * @param silent - If true, don't log warnings when falling back to cwd\n */\nexport function getWorkingDirectory(explicitDir?: string, silent: boolean = false): string {\n // If explicitly provided, use it\n if (explicitDir) {\n return resolve(explicitDir);\n }\n\n // Suppress all logs in interactive mode (TUI handles its own display)\n const shouldLog = !silent && !isInteractiveMode();\n\n // Debug: Log all relevant environment variables\n if (shouldLog && process.env.DEBUG_TRIE_WORKSPACE) {\n console.error('Debug: Environment variables:');\n console.error(` CURSOR_WORKSPACE: ${process.env.CURSOR_WORKSPACE || 'not set'}`);\n console.error(` CURSOR_WORKSPACE_ROOT: ${process.env.CURSOR_WORKSPACE_ROOT || 'not set'}`);\n console.error(` VSCODE_CWD: ${process.env.VSCODE_CWD || 'not set'}`);\n console.error(` INIT_CWD: ${process.env.INIT_CWD || 'not set'}`);\n console.error(` PWD: ${process.env.PWD || 'not set'}`);\n console.error(` process.cwd(): ${process.cwd()}`);\n }\n\n // Try environment variables first\n const envWorkspace = getWorkspaceFromEnv();\n if (envWorkspace) {\n if (shouldLog) {\n console.error(`Using workspace from environment: ${envWorkspace}`);\n }\n return envWorkspace;\n }\n \n // Try to find a project root from cwd\n const cwd = process.cwd();\n \n // Check if we're running from inside an npm package (common for MCP servers)\n if (isInsideNpmPackage(cwd)) {\n if (shouldLog) {\n console.error('Warning: MCP server running from npm package directory.');\n console.error(' Please pass the \"directory\" parameter with your project path.');\n console.error(` Current directory: ${cwd}`);\n }\n // Still return cwd, but we've warned\n return cwd;\n }\n \n const projectRoot = findProjectRoot(cwd);\n \n if (projectRoot) {\n // Extra check: make sure we're not returning the Trie package itself\n const packageJsonPath = join(projectRoot, 'package.json');\n if (existsSync(packageJsonPath)) {\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\n if (pkg.name === '@triedotdev/mcp' || pkg.name === 'trie-mcp-agent') {\n if (shouldLog) {\n console.error('Warning: Detected Trie package directory, not user workspace.');\n console.error(' Please pass the \"directory\" parameter with your project path.');\n }\n return cwd;\n }\n } catch {\n // Ignore parse errors\n }\n }\n return projectRoot;\n }\n \n // Fallback to cwd, but warn\n if (shouldLog) {\n console.error('Warning: Could not detect project root. Operating from:', cwd);\n console.error(' Tip: Pass directory parameter or run from a directory with package.json/.git');\n console.error(' Or set DEBUG_TRIE_WORKSPACE=1 to debug workspace detection');\n console.error(` Current working directory: ${cwd}`);\n\n // Show how to properly call with directory\n console.error(' Examples:');\n console.error(' Use trie_security with directory: \"/path/to/your/project\"');\n console.error(' Use trie_scan with directory: \"./your-project\"');\n }\n\n return cwd;\n}\n"],"mappings":";;;;;AAQA,SAAS,gBAAgB;AACzB,SAAS,YAAY,oBAAoB;AACzC,SAAS,UAAU,SAAS,MAAM,eAAe;AAKjD,IAAM,0BAA0B;AAAA,EAC9B;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA;AAAA;AAGF;AAGA,IAAM,yBAAyB;AAAA,EAC7B;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAEA,SAAS,gBAAgB,UAAiC;AACxD,MAAI;AACF,UAAM,SAAS,SAAS,kCAAkC;AAAA,MACxD,KAAK;AAAA,MACL,OAAO,CAAC,UAAU,QAAQ,QAAQ;AAAA,IACpC,CAAC,EACE,SAAS,EACT,KAAK;AACR,QAAI,CAAC,OAAQ,QAAO;AACpB,WAAO,QAAQ,UAAU,MAAM;AAAA,EACjC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,sBAAsB,UAAi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BAAiB,OAAO,CAAC;AAC7D,YAAI,IAAI,SAAS,qBAAqB,IAAI,SAAS,kBAAkB;AACnE,cAAI,WAAW;AACb,oBAAQ,MAAM,+DAA+D;AAC7E,oBAAQ,MAAM,kEAAkE;AAAA,UAClF;AACA,iBAAO;AAAA,QACT;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAGA,MAAI,WAAW;AACb,YAAQ,MAAM,2DAA2D,GAAG;AAC5E,YAAQ,MAAM,iFAAiF;AAC/F,YAAQ,MAAM,+DAA+D;AAC7E,YAAQ,MAAM,iCAAiC,GAAG,EAAE;AAGpD,YAAQ,MAAM,cAAc;AAC5B,YAAQ,MAAM,gEAAgE;AAC9E,YAAQ,MAAM,qDAAqD;AAAA,EACrE;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/utils/workspace.ts"],"sourcesContent":["/**\n * Workspace detection utilities\n * \n * MCP servers run as separate processes where process.cwd() may not be\n * the user's workspace. These utilities detect the actual project root\n * by looking for common project indicators.\n */\n\nimport { execSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'fs';\nimport { basename, dirname, join, resolve } from 'path';\nimport { isInteractiveMode } from './progress.js';\n\n// Project root indicators - files/directories that indicate a project root\n// Ordered by strength: primary indicators first\nconst PROJECT_ROOT_INDICATORS = [\n 'package.json', // Node.js/npm projects\n '.git', // Git repository root\n 'Cargo.toml', // Rust projects\n 'go.mod', // Go modules\n 'pyproject.toml', // Python projects (modern)\n 'pom.xml', // Maven (Java)\n 'build.gradle', // Gradle (Java/Kotlin)\n 'deno.json', // Deno projects\n // Note: .trie/config.json would be a better indicator, but empty .trie dirs exist\n // tsconfig.json is secondary as it can exist in subdirectories\n];\n\n// Directories that indicate we're in an npm package, not a user workspace\nconst NPM_PACKAGE_INDICATORS = [\n 'node_modules/@', // Scoped packages\n 'node_modules/', // Regular packages\n '.npm/', // npm cache\n '.nvm/', // nvm\n 'lib/node_modules/', // Global npm\n];\n\nfunction getGitCommonDir(startDir: string): string | null {\n try {\n const output = execSync('git rev-parse --git-common-dir', {\n cwd: startDir,\n stdio: ['ignore', 'pipe', 'ignore'],\n })\n .toString()\n .trim();\n if (!output) return null;\n return resolve(startDir, output);\n } catch {\n return null;\n }\n}\n\nfunction getSharedWorktreeRoot(startDir: string): string | null {\n const commonDir = getGitCommonDir(startDir);\n if (!commonDir) return null;\n if (basename(commonDir) !== '.git') return null;\n return dirname(commonDir);\n}\n\nexport function getTrieDirectory(workDir: string): string {\n const mode = process.env.TRIE_WORKTREE_MODE?.toLowerCase();\n if (mode === 'isolated') {\n return join(workDir, '.trie');\n }\n const sharedRoot = getSharedWorktreeRoot(workDir);\n if (sharedRoot) {\n return join(sharedRoot, '.trie');\n }\n return join(workDir, '.trie');\n}\n\n/**\n * Find the nearest project root by walking up from a starting directory\n * Returns the directory containing a project root indicator, or null if none found\n */\nexport function findProjectRoot(startDir: string, maxLevels: number = 10): string | null {\n let currentDir = resolve(startDir);\n let levels = 0;\n \n while (levels < maxLevels) {\n // Check if any project root indicator exists in this directory\n for (const indicator of PROJECT_ROOT_INDICATORS) {\n const indicatorPath = join(currentDir, indicator);\n if (existsSync(indicatorPath)) {\n return currentDir;\n }\n }\n \n // Move up one directory\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) {\n // Reached filesystem root\n break;\n }\n currentDir = parentDir;\n levels++;\n }\n \n return null;\n}\n\n/**\n * Check if a path looks like it's inside an npm package installation\n */\nfunction isInsideNpmPackage(dir: string): boolean {\n const normalizedPath = dir.replace(/\\\\/g, '/');\n return NPM_PACKAGE_INDICATORS.some(indicator => normalizedPath.includes(indicator));\n}\n\n/**\n * Try to get workspace from environment variables\n * Various tools set these when invoking MCP servers\n */\nfunction getWorkspaceFromEnv(): string | null {\n // Common environment variables that might contain workspace path\n const envVars = [\n 'CURSOR_WORKSPACE', // Cursor IDE\n 'CURSOR_WORKSPACE_ROOT', // Alternative Cursor env var\n 'VSCODE_WORKSPACE', // VS Code\n 'VSCODE_CWD', // VS Code working directory\n 'WORKSPACE_FOLDER', // Generic workspace\n 'PROJECT_ROOT', // Generic project root\n 'INIT_CWD', // npm's original directory\n 'PWD', // Original shell directory\n ];\n \n for (const envVar of envVars) {\n const value = process.env[envVar];\n if (value && existsSync(value)) {\n // Verify it looks like a project\n const hasProjectIndicator = PROJECT_ROOT_INDICATORS.some(\n indicator => existsSync(join(value, indicator))\n );\n if (hasProjectIndicator) {\n return value;\n }\n }\n }\n \n return null;\n}\n\n/**\n * Get the best working directory for scanning/operations\n * Priority: \n * 1. Explicit directory arg\n * 2. Environment variable (CURSOR_WORKSPACE, etc.)\n * 3. Detected project root from cwd (if not inside npm package)\n * 4. process.cwd() with warning\n * \n * @param explicitDir - Optional explicit directory from user\n * @param silent - If true, don't log warnings when falling back to cwd\n */\nexport function getWorkingDirectory(explicitDir?: string, silent: boolean = false): string {\n // If explicitly provided, use it\n if (explicitDir) {\n return resolve(explicitDir);\n }\n\n // Suppress all logs in interactive mode (TUI handles its own display)\n const shouldLog = !silent && !isInteractiveMode();\n\n // Debug: Log all relevant environment variables\n if (shouldLog && process.env.DEBUG_TRIE_WORKSPACE) {\n console.error('Debug: Environment variables:');\n console.error(` CURSOR_WORKSPACE: ${process.env.CURSOR_WORKSPACE || 'not set'}`);\n console.error(` CURSOR_WORKSPACE_ROOT: ${process.env.CURSOR_WORKSPACE_ROOT || 'not set'}`);\n console.error(` VSCODE_CWD: ${process.env.VSCODE_CWD || 'not set'}`);\n console.error(` INIT_CWD: ${process.env.INIT_CWD || 'not set'}`);\n console.error(` PWD: ${process.env.PWD || 'not set'}`);\n console.error(` process.cwd(): ${process.cwd()}`);\n }\n\n // Try environment variables first\n const envWorkspace = getWorkspaceFromEnv();\n if (envWorkspace) {\n if (shouldLog) {\n console.error(`Using workspace from environment: ${envWorkspace}`);\n }\n return envWorkspace;\n }\n \n // Try to find a project root from cwd\n const cwd = process.cwd();\n \n // Check if we're running from inside an npm package (common for MCP servers)\n if (isInsideNpmPackage(cwd)) {\n if (shouldLog) {\n console.error('Warning: MCP server running from npm package directory.');\n console.error(' Please pass the \"directory\" parameter with your project path.');\n console.error(` Current directory: ${cwd}`);\n }\n // Still return cwd, but we've warned\n return cwd;\n }\n \n const projectRoot = findProjectRoot(cwd);\n \n if (projectRoot) {\n // Extra check: make sure we're not returning the Trie package itself\n const packageJsonPath = join(projectRoot, 'package.json');\n if (existsSync(packageJsonPath)) {\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\n if (pkg.name === '@triedotdev/mcp' || pkg.name === 'trie-mcp-agent') {\n if (shouldLog) {\n console.error('Warning: Detected Trie package directory, not user workspace.');\n console.error(' Please pass the \"directory\" parameter with your project path.');\n }\n return cwd;\n }\n } catch {\n // Ignore parse errors\n }\n }\n return projectRoot;\n }\n \n // Fallback to cwd, but warn\n if (shouldLog) {\n console.error('Warning: Could not detect project root. Operating from:', cwd);\n console.error(' Tip: Pass directory parameter or run from a directory with package.json/.git');\n console.error(' Or set DEBUG_TRIE_WORKSPACE=1 to debug workspace detection');\n console.error(` Current working directory: ${cwd}`);\n\n // Show how to properly call with directory\n console.error(' Examples:');\n console.error(' Use trie_fix with directory: \"/path/to/your/project\"');\n console.error(' Use trie watch with directory: \"./your-project\"');\n }\n\n return cwd;\n}\n"],"mappings":";;;;;AAQA,SAAS,gBAAgB;AACzB,SAAS,YAAY,oBAAoB;AACzC,SAAS,UAAU,SAAS,MAAM,eAAe;AAKjD,IAAM,0BAA0B;AAAA,EAC9B;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA;AAAA;AAGF;AAGA,IAAM,yBAAyB;AAAA,EAC7B;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAEA,SAAS,gBAAgB,UAAiC;AACxD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ACvE,cAAQ,MAAM,kEAAkE;AAChF,cAAQ,MAAM,yBAAyB,GAAG,EAAE;AAAA,IAC9C;AAEA,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,gBAAgB,GAAG;AAEvC,MAAI,aAAa;AAEf,UAAM,kBAAkB,KAAK,aAAa,cAAc;AACxD,QAAI,WAAW,eAAe,GAAG;AAC/B,UAAI;AACF,cAAM,MAAM,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;AAC7D,YAAI,IAAI,SAAS,qBAAqB,IAAI,SAAS,kBAAkB;AACnE,cAAI,WAAW;AACb,oBAAQ,MAAM,+DAA+D;AAC7E,oBAAQ,MAAM,kEAAkE;AAAA,UAClF;AACA,iBAAO;AAAA,QACT;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAGA,MAAI,WAAW;AACb,YAAQ,MAAM,2DAA2D,GAAG;AAC5E,YAAQ,MAAM,iFAAiF;AAC/F,YAAQ,MAAM,+DAA+D;AAC7E,YAAQ,MAAM,iCAAiC,GAAG,EAAE;AAGpD,YAAQ,MAAM,cAAc;AAC5B,YAAQ,MAAM,2DAA2D;AACzE,YAAQ,MAAM,sDAAsD;AAAA,EACtE;AAEA,SAAO;AACT;","names":[]}
@@ -1,38 +1,38 @@
1
1
  import {
2
2
  getGoalManager
3
- } from "./chunk-YEIJW6X6.js";
3
+ } from "./chunk-JIS2OCZR.js";
4
4
  import {
5
5
  getHypothesisEngine
6
- } from "./chunk-XTTZAQWJ.js";
6
+ } from "./chunk-74R4XSFB.js";
7
7
  import {
8
8
  getInsightStore
9
- } from "./chunk-3MUCUZ46.js";
9
+ } from "./chunk-ABY2R7OK.js";
10
10
  import {
11
11
  GotchaPredictor,
12
12
  SlackIntegration,
13
13
  findCrossProjectPatterns,
14
14
  recordToGlobalMemory
15
- } from "./chunk-WMDFK7LI.js";
15
+ } from "./chunk-IFBEAOHH.js";
16
16
  import {
17
17
  ContextGraph
18
- } from "./chunk-FH335WL5.js";
18
+ } from "./chunk-TWQPOVRA.js";
19
19
  import {
20
20
  isAIAvailable,
21
21
  runAIAnalysis
22
- } from "./chunk-FPEMP54L.js";
22
+ } from "./chunk-OJXFQRUE.js";
23
23
  import {
24
24
  getProjectState
25
- } from "./chunk-LT6VUZG2.js";
25
+ } from "./chunk-GLY76TSI.js";
26
26
  import {
27
27
  getStorage
28
- } from "./chunk-FG467PDD.js";
28
+ } from "./chunk-LNUMECBJ.js";
29
29
  import {
30
30
  autoResolveIssues,
31
31
  getHistoricalInsights,
32
32
  getIssueHash,
33
33
  searchIssues,
34
34
  storeIssues
35
- } from "./chunk-62POBLFC.js";
35
+ } from "./chunk-ED7PLRQA.js";
36
36
 
37
37
  // src/agent/trie-agent.ts
38
38
  import { basename as basename2 } from "path";
@@ -1322,9 +1322,9 @@ var TrieAgent = class {
1322
1322
  }
1323
1323
  if (issues.length >= 5 && this.canCreateInsight("pattern-discovery")) {
1324
1324
  try {
1325
- const { IncidentIndex } = await import("./incident-index-BWW2UEY7.js");
1325
+ const { IncidentIndex } = await import("./incident-index-H6APJ4S3.js");
1326
1326
  const { TriePatternDiscovery } = await import("./pattern-discovery-F7LU5K6E.js");
1327
- const { ContextGraph: ContextGraph2 } = await import("./graph-J4OGTYCO.js");
1327
+ const { ContextGraph: ContextGraph2 } = await import("./graph-26JPZ3DF.js");
1328
1328
  const graph = new ContextGraph2(this.projectPath);
1329
1329
  const incidentIndex = await IncidentIndex.build(graph, this.projectPath);
1330
1330
  const discovery = new TriePatternDiscovery(graph, incidentIndex);
@@ -1581,7 +1581,7 @@ var TrieAgent = class {
1581
1581
  await this.projectState.recordScan();
1582
1582
  try {
1583
1583
  const riskLevel = issues.filter((i) => i.severity === "critical").length > 0 ? "critical" : issues.filter((i) => i.severity === "serious").length >= 3 ? "high" : issues.length > 10 ? "medium" : "low";
1584
- const { calculateAdaptiveScanFrequency } = await import("./goal-manager-ZBWKWEML.js");
1584
+ const { calculateAdaptiveScanFrequency } = await import("./goal-manager-VTBFFYN4.js");
1585
1585
  const result = await calculateAdaptiveScanFrequency(riskLevel);
1586
1586
  await this.projectState.setScanFrequency(result.frequencyMs);
1587
1587
  } catch {
@@ -1810,4 +1810,4 @@ export {
1810
1810
  TrieAgent,
1811
1811
  getTrieAgent
1812
1812
  };
1813
- //# sourceMappingURL=chunk-N2EDZTKG.js.map
1813
+ //# sourceMappingURL=chunk-4UDBGYI3.js.map