@triedotdev/mcp 1.0.169 → 1.0.170

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 (145) hide show
  1. package/README.md +54 -545
  2. package/dist/chunk-2YXOBNKW.js +619 -0
  3. package/dist/chunk-2YXOBNKW.js.map +1 -0
  4. package/dist/chunk-QR64Y5TI.js +363 -0
  5. package/dist/chunk-QR64Y5TI.js.map +1 -0
  6. package/dist/cli/main.d.ts +0 -15
  7. package/dist/cli/main.js +356 -3098
  8. package/dist/cli/main.js.map +1 -1
  9. package/dist/index.js +2 -34
  10. package/dist/index.js.map +1 -1
  11. package/dist/server/mcp-server.js +2 -34
  12. package/package.json +8 -31
  13. package/dist/autonomy-config-FSERX3O3.js +0 -30
  14. package/dist/autonomy-config-FSERX3O3.js.map +0 -1
  15. package/dist/chat-store-JNGNTDSN.js +0 -15
  16. package/dist/chat-store-JNGNTDSN.js.map +0 -1
  17. package/dist/chunk-2HF65EHQ.js +0 -311
  18. package/dist/chunk-2HF65EHQ.js.map +0 -1
  19. package/dist/chunk-3XR6WVAW.js +0 -4011
  20. package/dist/chunk-3XR6WVAW.js.map +0 -1
  21. package/dist/chunk-43X6JBEM.js +0 -36
  22. package/dist/chunk-43X6JBEM.js.map +0 -1
  23. package/dist/chunk-6NLHFIYA.js +0 -344
  24. package/dist/chunk-6NLHFIYA.js.map +0 -1
  25. package/dist/chunk-7IO4YUI3.js +0 -1827
  26. package/dist/chunk-7IO4YUI3.js.map +0 -1
  27. package/dist/chunk-AHD2CBQ7.js +0 -846
  28. package/dist/chunk-AHD2CBQ7.js.map +0 -1
  29. package/dist/chunk-BUTOP5EB.js +0 -931
  30. package/dist/chunk-BUTOP5EB.js.map +0 -1
  31. package/dist/chunk-DGUM43GV.js +0 -11
  32. package/dist/chunk-DGUM43GV.js.map +0 -1
  33. package/dist/chunk-EFWVF6TI.js +0 -267
  34. package/dist/chunk-EFWVF6TI.js.map +0 -1
  35. package/dist/chunk-F6WFNUAY.js +0 -216
  36. package/dist/chunk-F6WFNUAY.js.map +0 -1
  37. package/dist/chunk-FBNURWRY.js +0 -662
  38. package/dist/chunk-FBNURWRY.js.map +0 -1
  39. package/dist/chunk-FQ45QP5A.js +0 -361
  40. package/dist/chunk-FQ45QP5A.js.map +0 -1
  41. package/dist/chunk-FVRO5RN3.js +0 -1306
  42. package/dist/chunk-FVRO5RN3.js.map +0 -1
  43. package/dist/chunk-G2TGF6TR.js +0 -573
  44. package/dist/chunk-G2TGF6TR.js.map +0 -1
  45. package/dist/chunk-G3I7SZLW.js +0 -354
  46. package/dist/chunk-G3I7SZLW.js.map +0 -1
  47. package/dist/chunk-GTKYBOXL.js +0 -700
  48. package/dist/chunk-GTKYBOXL.js.map +0 -1
  49. package/dist/chunk-HVCDY3AK.js +0 -850
  50. package/dist/chunk-HVCDY3AK.js.map +0 -1
  51. package/dist/chunk-I2O5OYQT.js +0 -727
  52. package/dist/chunk-I2O5OYQT.js.map +0 -1
  53. package/dist/chunk-JVMBCWKS.js +0 -348
  54. package/dist/chunk-JVMBCWKS.js.map +0 -1
  55. package/dist/chunk-KCUOWRPX.js +0 -816
  56. package/dist/chunk-KCUOWRPX.js.map +0 -1
  57. package/dist/chunk-KDHN2ZQE.js +0 -313
  58. package/dist/chunk-KDHN2ZQE.js.map +0 -1
  59. package/dist/chunk-ME2OERF5.js +0 -345
  60. package/dist/chunk-ME2OERF5.js.map +0 -1
  61. package/dist/chunk-OBQ74FOU.js +0 -27
  62. package/dist/chunk-OBQ74FOU.js.map +0 -1
  63. package/dist/chunk-Q5EKA5YA.js +0 -254
  64. package/dist/chunk-Q5EKA5YA.js.map +0 -1
  65. package/dist/chunk-Q63FFI6D.js +0 -132
  66. package/dist/chunk-Q63FFI6D.js.map +0 -1
  67. package/dist/chunk-SASNMSB5.js +0 -12597
  68. package/dist/chunk-SASNMSB5.js.map +0 -1
  69. package/dist/chunk-T63OHG4Q.js +0 -440
  70. package/dist/chunk-T63OHG4Q.js.map +0 -1
  71. package/dist/chunk-TN5WEKWI.js +0 -173
  72. package/dist/chunk-TN5WEKWI.js.map +0 -1
  73. package/dist/chunk-VUL52BQL.js +0 -402
  74. package/dist/chunk-VUL52BQL.js.map +0 -1
  75. package/dist/chunk-VVITXIHN.js +0 -189
  76. package/dist/chunk-VVITXIHN.js.map +0 -1
  77. package/dist/chunk-WCN7S3EI.js +0 -14
  78. package/dist/chunk-WCN7S3EI.js.map +0 -1
  79. package/dist/chunk-XPZZFPBZ.js +0 -491
  80. package/dist/chunk-XPZZFPBZ.js.map +0 -1
  81. package/dist/chunk-ZJF5FTBX.js +0 -1396
  82. package/dist/chunk-ZJF5FTBX.js.map +0 -1
  83. package/dist/chunk-ZV2K6M7T.js +0 -74
  84. package/dist/chunk-ZV2K6M7T.js.map +0 -1
  85. package/dist/cli/create-agent.d.ts +0 -1
  86. package/dist/cli/create-agent.js +0 -1050
  87. package/dist/cli/create-agent.js.map +0 -1
  88. package/dist/cli/yolo-daemon.d.ts +0 -1
  89. package/dist/cli/yolo-daemon.js +0 -421
  90. package/dist/cli/yolo-daemon.js.map +0 -1
  91. package/dist/client-NJPZE5JT.js +0 -28
  92. package/dist/client-NJPZE5JT.js.map +0 -1
  93. package/dist/codebase-index-VAPF32XX.js +0 -12
  94. package/dist/codebase-index-VAPF32XX.js.map +0 -1
  95. package/dist/fast-analyzer-3GCCZMLK.js +0 -216
  96. package/dist/fast-analyzer-3GCCZMLK.js.map +0 -1
  97. package/dist/git-EO5SRFMN.js +0 -28
  98. package/dist/git-EO5SRFMN.js.map +0 -1
  99. package/dist/github-ingester-ZOKK6GRS.js +0 -11
  100. package/dist/github-ingester-ZOKK6GRS.js.map +0 -1
  101. package/dist/goal-manager-QUKX2W6C.js +0 -25
  102. package/dist/goal-manager-QUKX2W6C.js.map +0 -1
  103. package/dist/goal-validator-2SFSKKVU.js +0 -24
  104. package/dist/goal-validator-2SFSKKVU.js.map +0 -1
  105. package/dist/graph-B3NA4S7I.js +0 -10
  106. package/dist/graph-B3NA4S7I.js.map +0 -1
  107. package/dist/hypothesis-KCPBR652.js +0 -23
  108. package/dist/hypothesis-KCPBR652.js.map +0 -1
  109. package/dist/incident-index-EFNUSGWL.js +0 -11
  110. package/dist/incident-index-EFNUSGWL.js.map +0 -1
  111. package/dist/insight-store-EC4PLSAW.js +0 -22
  112. package/dist/insight-store-EC4PLSAW.js.map +0 -1
  113. package/dist/issue-store-YAXTNRRY.js +0 -36
  114. package/dist/issue-store-YAXTNRRY.js.map +0 -1
  115. package/dist/ledger-TWZTGDFA.js +0 -58
  116. package/dist/ledger-TWZTGDFA.js.map +0 -1
  117. package/dist/linear-ingester-XXPAZZRW.js +0 -11
  118. package/dist/linear-ingester-XXPAZZRW.js.map +0 -1
  119. package/dist/output-manager-RVJ37XKA.js +0 -13
  120. package/dist/output-manager-RVJ37XKA.js.map +0 -1
  121. package/dist/parse-goal-violation-SACGFG3C.js +0 -8
  122. package/dist/parse-goal-violation-SACGFG3C.js.map +0 -1
  123. package/dist/pattern-discovery-F7LU5K6E.js +0 -8
  124. package/dist/pattern-discovery-F7LU5K6E.js.map +0 -1
  125. package/dist/progress-SRQ2V3BP.js +0 -18
  126. package/dist/progress-SRQ2V3BP.js.map +0 -1
  127. package/dist/project-state-AHPA77SM.js +0 -28
  128. package/dist/project-state-AHPA77SM.js.map +0 -1
  129. package/dist/sync-M2FSWPBC.js +0 -12
  130. package/dist/sync-M2FSWPBC.js.map +0 -1
  131. package/dist/terminal-spawn-5YXDMUCF.js +0 -157
  132. package/dist/terminal-spawn-5YXDMUCF.js.map +0 -1
  133. package/dist/tiered-storage-DYNC5CQ6.js +0 -13
  134. package/dist/tiered-storage-DYNC5CQ6.js.map +0 -1
  135. package/dist/trie-agent-I3HAHY2G.js +0 -26
  136. package/dist/trie-agent-I3HAHY2G.js.map +0 -1
  137. package/dist/ui/chat.html +0 -1014
  138. package/dist/ui/goals.html +0 -967
  139. package/dist/ui/hypotheses.html +0 -1011
  140. package/dist/ui/ledger.html +0 -954
  141. package/dist/ui/nudges.html +0 -995
  142. package/dist/vibe-code-signatures-5ZULYP3D.js +0 -987
  143. package/dist/vibe-code-signatures-5ZULYP3D.js.map +0 -1
  144. package/dist/vulnerability-signatures-2URZSXAQ.js +0 -983
  145. package/dist/vulnerability-signatures-2URZSXAQ.js.map +0 -1
@@ -1,345 +0,0 @@
1
- import {
2
- getTrieDirectory
3
- } from "./chunk-VVITXIHN.js";
4
-
5
- // src/utils/autonomy-config.ts
6
- import { readFile, writeFile, mkdir } from "fs/promises";
7
- import { existsSync } from "fs";
8
- import { join } from "path";
9
-
10
- // src/types/autonomy.ts
11
- var DEFAULT_AUTONOMY_CONFIG = {
12
- level: "proactive",
13
- autoCheck: {
14
- enabled: true,
15
- threshold: 5,
16
- onCritical: true,
17
- cooldownMs: 3e4
18
- // 30 seconds
19
- },
20
- autoFix: {
21
- enabled: true,
22
- askFirst: true,
23
- // Always ask (human-in-the-loop)
24
- categories: ["trivial", "safe"],
25
- allowedFixTypes: [
26
- "remove-console-log",
27
- "remove-debugger",
28
- "remove-emoji",
29
- "remove-unused-import",
30
- "add-missing-await",
31
- "fix-typo"
32
- ]
33
- },
34
- pushBlocking: {
35
- enabled: true,
36
- allowBypass: true,
37
- blockOn: ["critical"],
38
- bypassMethods: ["env", "flag", "confirm"],
39
- logBypasses: true
40
- },
41
- progressiveEscalation: {
42
- enabled: true,
43
- thresholds: {
44
- suggest: 1,
45
- autoCheck: 3,
46
- escalate: 5,
47
- block: 10
48
- },
49
- windowMs: 24 * 60 * 60 * 1e3
50
- // 24 hours
51
- },
52
- aiWatcher: {
53
- enabled: true,
54
- hourlyTokenLimit: 5e4,
55
- scanCooldownSec: 30,
56
- cleanFileCooldownSec: 300,
57
- maxFilesPerScan: 5,
58
- maxCharsPerFile: 4e3
59
- },
60
- cloudAgentEnabled: false,
61
- cursorApiKey: void 0
62
- };
63
-
64
- // src/utils/autonomy-config.ts
65
- import { createHash } from "crypto";
66
- async function loadAutonomyConfig(projectPath) {
67
- const configPath = join(getTrieDirectory(projectPath), "config.json");
68
- try {
69
- if (!existsSync(configPath)) {
70
- return { ...DEFAULT_AUTONOMY_CONFIG };
71
- }
72
- const content = await readFile(configPath, "utf-8");
73
- const config = JSON.parse(content);
74
- return mergeWithDefaults(config.autonomy || {});
75
- } catch (error) {
76
- console.error("Failed to load autonomy config:", error);
77
- return { ...DEFAULT_AUTONOMY_CONFIG };
78
- }
79
- }
80
- async function saveAutonomyConfig(projectPath, autonomyConfig) {
81
- const configPath = join(getTrieDirectory(projectPath), "config.json");
82
- const trieDir = getTrieDirectory(projectPath);
83
- try {
84
- if (!existsSync(trieDir)) {
85
- await mkdir(trieDir, { recursive: true });
86
- }
87
- let fullConfig = {};
88
- if (existsSync(configPath)) {
89
- const content = await readFile(configPath, "utf-8");
90
- fullConfig = JSON.parse(content);
91
- }
92
- const existingAutonomy = fullConfig.autonomy || {};
93
- fullConfig.autonomy = mergeWithDefaults({ ...existingAutonomy, ...autonomyConfig });
94
- const tempPath = configPath + ".tmp";
95
- await writeFile(tempPath, JSON.stringify(fullConfig, null, 2));
96
- await writeFile(configPath, JSON.stringify(fullConfig, null, 2));
97
- } catch (error) {
98
- console.error("Failed to save autonomy config:", error);
99
- throw error;
100
- }
101
- }
102
- function mergeWithDefaults(partial) {
103
- return {
104
- level: partial.level ?? DEFAULT_AUTONOMY_CONFIG.level,
105
- autoCheck: {
106
- ...DEFAULT_AUTONOMY_CONFIG.autoCheck,
107
- ...partial.autoCheck || {}
108
- },
109
- autoFix: {
110
- ...DEFAULT_AUTONOMY_CONFIG.autoFix,
111
- ...partial.autoFix || {}
112
- },
113
- pushBlocking: {
114
- ...DEFAULT_AUTONOMY_CONFIG.pushBlocking,
115
- ...partial.pushBlocking || {}
116
- },
117
- progressiveEscalation: {
118
- ...DEFAULT_AUTONOMY_CONFIG.progressiveEscalation,
119
- ...partial.progressiveEscalation || {},
120
- thresholds: {
121
- ...DEFAULT_AUTONOMY_CONFIG.progressiveEscalation.thresholds,
122
- ...partial.progressiveEscalation?.thresholds || {}
123
- }
124
- },
125
- aiWatcher: {
126
- ...DEFAULT_AUTONOMY_CONFIG.aiWatcher,
127
- ...partial.aiWatcher || {}
128
- },
129
- cloudAgentEnabled: partial.cloudAgentEnabled ?? DEFAULT_AUTONOMY_CONFIG.cloudAgentEnabled,
130
- cursorApiKey: partial.cursorApiKey ?? DEFAULT_AUTONOMY_CONFIG.cursorApiKey
131
- };
132
- }
133
- var occurrenceCache = /* @__PURE__ */ new Map();
134
- async function getOccurrences(projectPath) {
135
- if (occurrenceCache.has(projectPath)) {
136
- return occurrenceCache.get(projectPath);
137
- }
138
- const occurrencesPath = join(getTrieDirectory(projectPath), "memory", "occurrences.json");
139
- const occurrences = /* @__PURE__ */ new Map();
140
- try {
141
- if (existsSync(occurrencesPath)) {
142
- const content = await readFile(occurrencesPath, "utf-8");
143
- const data = JSON.parse(content);
144
- for (const [hash, occ] of Object.entries(data)) {
145
- occurrences.set(hash, occ);
146
- }
147
- }
148
- } catch {
149
- }
150
- occurrenceCache.set(projectPath, occurrences);
151
- return occurrences;
152
- }
153
- async function saveOccurrences(projectPath) {
154
- const occurrences = occurrenceCache.get(projectPath);
155
- if (!occurrences) return;
156
- const occurrencesPath = join(getTrieDirectory(projectPath), "memory", "occurrences.json");
157
- const memoryDir = join(getTrieDirectory(projectPath), "memory");
158
- try {
159
- if (!existsSync(memoryDir)) {
160
- await mkdir(memoryDir, { recursive: true });
161
- }
162
- const data = {};
163
- for (const [hash, occ] of occurrences.entries()) {
164
- data[hash] = occ;
165
- }
166
- await writeFile(occurrencesPath, JSON.stringify(data, null, 2));
167
- } catch (error) {
168
- console.error("Failed to save occurrences:", error);
169
- }
170
- }
171
- function createIssueHash(file, line, issueType) {
172
- const input = `${file}:${line || 0}:${issueType}`;
173
- return createHash("md5").update(input).digest("hex").slice(0, 12);
174
- }
175
- async function trackIssueOccurrence(projectPath, file, line, issueType, config) {
176
- const occurrences = await getOccurrences(projectPath);
177
- const hash = createIssueHash(file, line, issueType);
178
- const now = Date.now();
179
- let occurrence = occurrences.get(hash);
180
- if (occurrence) {
181
- const windowMs = config.progressiveEscalation.windowMs;
182
- if (now - occurrence.firstSeen > windowMs) {
183
- occurrence = {
184
- hash,
185
- firstSeen: now,
186
- lastSeen: now,
187
- count: 1,
188
- escalationLevel: "suggest",
189
- notified: false,
190
- bypassed: false,
191
- bypassHistory: occurrence.bypassHistory
192
- // Keep bypass history
193
- };
194
- } else {
195
- occurrence.lastSeen = now;
196
- occurrence.count++;
197
- const thresholds = config.progressiveEscalation.thresholds;
198
- if (occurrence.count >= thresholds.block) {
199
- occurrence.escalationLevel = "block";
200
- } else if (occurrence.count >= thresholds.escalate) {
201
- occurrence.escalationLevel = "escalate";
202
- } else if (occurrence.count >= thresholds.autoCheck) {
203
- occurrence.escalationLevel = "autoCheck";
204
- }
205
- }
206
- } else {
207
- occurrence = {
208
- hash,
209
- firstSeen: now,
210
- lastSeen: now,
211
- count: 1,
212
- escalationLevel: "suggest",
213
- notified: false,
214
- bypassed: false,
215
- bypassHistory: []
216
- };
217
- }
218
- occurrences.set(hash, occurrence);
219
- await saveOccurrences(projectPath);
220
- return occurrence;
221
- }
222
- async function getEscalationLevel(projectPath, file, line, issueType) {
223
- const occurrences = await getOccurrences(projectPath);
224
- const hash = createIssueHash(file, line, issueType);
225
- const occurrence = occurrences.get(hash);
226
- return occurrence?.escalationLevel ?? "suggest";
227
- }
228
- async function recordBypass(projectPath, file, line, issueType, method, reason) {
229
- const occurrences = await getOccurrences(projectPath);
230
- const hash = createIssueHash(file, line, issueType);
231
- const occurrence = occurrences.get(hash);
232
- if (occurrence) {
233
- occurrence.bypassed = true;
234
- occurrence.bypassHistory.push({
235
- timestamp: Date.now(),
236
- method,
237
- ...reason !== void 0 ? { reason } : {}
238
- });
239
- await saveOccurrences(projectPath);
240
- }
241
- }
242
- function shouldAutoFix(fix, config) {
243
- if (!config.autoFix.enabled) {
244
- return false;
245
- }
246
- const allowedCategories = config.autoFix.categories;
247
- if (!allowedCategories.includes(fix.category) && !allowedCategories.includes("all")) {
248
- return false;
249
- }
250
- if (config.autoFix.allowedFixTypes.length > 0 && !config.autoFix.allowedFixTypes.includes(fix.type)) {
251
- return false;
252
- }
253
- if (fix.confidence < 0.9) {
254
- return false;
255
- }
256
- return true;
257
- }
258
- function groupFixesByFile(fixes) {
259
- const grouped = /* @__PURE__ */ new Map();
260
- for (const fix of fixes) {
261
- const existing = grouped.get(fix.file) || [];
262
- existing.push(fix);
263
- grouped.set(fix.file, existing);
264
- }
265
- return grouped;
266
- }
267
- function shouldBlockPush(issues, config) {
268
- if (!config.pushBlocking.enabled) {
269
- return {
270
- blocked: false,
271
- blockingIssues: [],
272
- bypassed: false
273
- };
274
- }
275
- const blockingIssues = issues.filter(
276
- (issue) => config.pushBlocking.blockOn.includes(issue.severity)
277
- );
278
- if (blockingIssues.length === 0) {
279
- return {
280
- blocked: false,
281
- blockingIssues: [],
282
- bypassed: false
283
- };
284
- }
285
- const envBypass = process.env.TRIE_BYPASS === "1" || process.env.TRIE_BYPASS === "true";
286
- if (envBypass && config.pushBlocking.allowBypass) {
287
- return {
288
- blocked: false,
289
- blockingIssues,
290
- bypassed: true,
291
- bypassMethod: "env"
292
- };
293
- }
294
- const bypassInstructions = buildBypassInstructions(config);
295
- return {
296
- blocked: true,
297
- reason: `${blockingIssues.length} ${blockingIssues[0]?.severity || "critical"} issue(s) must be fixed before pushing`,
298
- blockingIssues,
299
- bypassInstructions,
300
- bypassed: false
301
- };
302
- }
303
- function buildBypassInstructions(config) {
304
- const instructions = [];
305
- if (config.pushBlocking.bypassMethods.includes("env")) {
306
- instructions.push("\u2022 Set TRIE_BYPASS=1 to bypass: TRIE_BYPASS=1 git push");
307
- }
308
- if (config.pushBlocking.bypassMethods.includes("flag")) {
309
- instructions.push("\u2022 Use --no-verify flag: git push --no-verify");
310
- }
311
- if (config.pushBlocking.bypassMethods.includes("confirm")) {
312
- instructions.push("\u2022 Run: trie bypass --confirm to bypass this push");
313
- }
314
- return instructions.join("\n");
315
- }
316
- var configCache = /* @__PURE__ */ new Map();
317
- var CACHE_TTL = 6e4;
318
- async function getAutonomyConfig(projectPath) {
319
- const cached = configCache.get(projectPath);
320
- if (cached && Date.now() - cached.loadedAt < CACHE_TTL) {
321
- return cached.config;
322
- }
323
- const config = await loadAutonomyConfig(projectPath);
324
- configCache.set(projectPath, { config, loadedAt: Date.now() });
325
- return config;
326
- }
327
- function clearConfigCache() {
328
- configCache.clear();
329
- occurrenceCache.clear();
330
- }
331
-
332
- export {
333
- loadAutonomyConfig,
334
- saveAutonomyConfig,
335
- createIssueHash,
336
- trackIssueOccurrence,
337
- getEscalationLevel,
338
- recordBypass,
339
- shouldAutoFix,
340
- groupFixesByFile,
341
- shouldBlockPush,
342
- getAutonomyConfig,
343
- clearConfigCache
344
- };
345
- //# sourceMappingURL=chunk-ME2OERF5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/autonomy-config.ts","../src/types/autonomy.ts"],"sourcesContent":["/**\n * Autonomy Configuration Loader\n * \n * Loads, saves, and manages autonomy settings from .trie/config.json\n */\n\nimport { readFile, writeFile, mkdir } from 'fs/promises';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\nimport { getTrieDirectory } from './workspace.js';\nimport type { \n AutonomyConfig, \n IssueOccurrence,\n AutoFixAction,\n PushBlockResult \n} from '../types/autonomy.js';\nimport { DEFAULT_AUTONOMY_CONFIG } from '../types/autonomy.js';\nimport { createHash } from 'crypto';\n\n// ============================================================================\n// Config Loading/Saving\n// ============================================================================\n\n/**\n * Load autonomy config from .trie/config.json\n */\nexport async function loadAutonomyConfig(projectPath: string): Promise<AutonomyConfig> {\n const configPath = join(getTrieDirectory(projectPath), 'config.json');\n \n try {\n if (!existsSync(configPath)) {\n return { ...DEFAULT_AUTONOMY_CONFIG };\n }\n \n const content = await readFile(configPath, 'utf-8');\n const config = JSON.parse(content);\n \n // Merge with defaults to ensure all fields exist\n return mergeWithDefaults(config.autonomy || {});\n } catch (error) {\n console.error('Failed to load autonomy config:', error);\n return { ...DEFAULT_AUTONOMY_CONFIG };\n }\n}\n\n/**\n * Save autonomy config to .trie/config.json\n */\nexport async function saveAutonomyConfig(\n projectPath: string, \n autonomyConfig: Partial<AutonomyConfig>\n): Promise<void> {\n const configPath = join(getTrieDirectory(projectPath), 'config.json');\n const trieDir = getTrieDirectory(projectPath);\n \n try {\n // Ensure .trie directory exists\n if (!existsSync(trieDir)) {\n await mkdir(trieDir, { recursive: true });\n }\n \n // Load existing config (preserve apiKeys and other top-level keys)\n let fullConfig: Record<string, unknown> = {};\n if (existsSync(configPath)) {\n const content = await readFile(configPath, 'utf-8');\n fullConfig = JSON.parse(content);\n }\n \n // Merge autonomy config with existing autonomy (preserve cursorApiKey etc.)\n const existingAutonomy = (fullConfig.autonomy as Record<string, unknown>) || {};\n fullConfig.autonomy = mergeWithDefaults({ ...existingAutonomy, ...autonomyConfig } as Partial<AutonomyConfig>);\n \n // Save atomically\n const tempPath = configPath + '.tmp';\n await writeFile(tempPath, JSON.stringify(fullConfig, null, 2));\n await writeFile(configPath, JSON.stringify(fullConfig, null, 2));\n \n } catch (error) {\n console.error('Failed to save autonomy config:', error);\n throw error;\n }\n}\n\n/**\n * Merge partial config with defaults\n */\nfunction mergeWithDefaults(partial: Partial<AutonomyConfig>): AutonomyConfig {\n return {\n level: partial.level ?? DEFAULT_AUTONOMY_CONFIG.level,\n autoCheck: {\n ...DEFAULT_AUTONOMY_CONFIG.autoCheck,\n ...(partial.autoCheck || {}),\n },\n autoFix: {\n ...DEFAULT_AUTONOMY_CONFIG.autoFix,\n ...(partial.autoFix || {}),\n },\n pushBlocking: {\n ...DEFAULT_AUTONOMY_CONFIG.pushBlocking,\n ...(partial.pushBlocking || {}),\n },\n progressiveEscalation: {\n ...DEFAULT_AUTONOMY_CONFIG.progressiveEscalation,\n ...(partial.progressiveEscalation || {}),\n thresholds: {\n ...DEFAULT_AUTONOMY_CONFIG.progressiveEscalation.thresholds,\n ...(partial.progressiveEscalation?.thresholds || {}),\n },\n },\n aiWatcher: {\n ...DEFAULT_AUTONOMY_CONFIG.aiWatcher,\n ...(partial.aiWatcher || {}),\n },\n cloudAgentEnabled: partial.cloudAgentEnabled ?? DEFAULT_AUTONOMY_CONFIG.cloudAgentEnabled,\n cursorApiKey: partial.cursorApiKey ?? DEFAULT_AUTONOMY_CONFIG.cursorApiKey,\n };\n}\n\n// ============================================================================\n// Issue Occurrence Tracking (for progressive escalation)\n// ============================================================================\n\nconst occurrenceCache = new Map<string, Map<string, IssueOccurrence>>();\n\n/**\n * Get occurrence tracker for a project\n */\nasync function getOccurrences(projectPath: string): Promise<Map<string, IssueOccurrence>> {\n if (occurrenceCache.has(projectPath)) {\n return occurrenceCache.get(projectPath)!;\n }\n \n const occurrencesPath = join(getTrieDirectory(projectPath), 'memory', 'occurrences.json');\n const occurrences = new Map<string, IssueOccurrence>();\n \n try {\n if (existsSync(occurrencesPath)) {\n const content = await readFile(occurrencesPath, 'utf-8');\n const data = JSON.parse(content);\n for (const [hash, occ] of Object.entries(data)) {\n occurrences.set(hash, occ as IssueOccurrence);\n }\n }\n } catch {\n // Start fresh\n }\n \n occurrenceCache.set(projectPath, occurrences);\n return occurrences;\n}\n\n/**\n * Save occurrences to disk\n */\nasync function saveOccurrences(projectPath: string): Promise<void> {\n const occurrences = occurrenceCache.get(projectPath);\n if (!occurrences) return;\n \n const occurrencesPath = join(getTrieDirectory(projectPath), 'memory', 'occurrences.json');\n const memoryDir = join(getTrieDirectory(projectPath), 'memory');\n \n try {\n if (!existsSync(memoryDir)) {\n await mkdir(memoryDir, { recursive: true });\n }\n \n const data: Record<string, IssueOccurrence> = {};\n for (const [hash, occ] of occurrences.entries()) {\n data[hash] = occ;\n }\n \n await writeFile(occurrencesPath, JSON.stringify(data, null, 2));\n } catch (error) {\n console.error('Failed to save occurrences:', error);\n }\n}\n\n/**\n * Create a hash for an issue (for deduplication)\n */\nexport function createIssueHash(file: string, line: number | undefined, issueType: string): string {\n const input = `${file}:${line || 0}:${issueType}`;\n return createHash('md5').update(input).digest('hex').slice(0, 12);\n}\n\n/**\n * Track an issue occurrence\n */\nexport async function trackIssueOccurrence(\n projectPath: string,\n file: string,\n line: number | undefined,\n issueType: string,\n config: AutonomyConfig\n): Promise<IssueOccurrence> {\n const occurrences = await getOccurrences(projectPath);\n const hash = createIssueHash(file, line, issueType);\n const now = Date.now();\n \n let occurrence = occurrences.get(hash);\n \n if (occurrence) {\n // Check if within time window\n const windowMs = config.progressiveEscalation.windowMs;\n if (now - occurrence.firstSeen > windowMs) {\n // Reset if outside window\n occurrence = {\n hash,\n firstSeen: now,\n lastSeen: now,\n count: 1,\n escalationLevel: 'suggest',\n notified: false,\n bypassed: false,\n bypassHistory: occurrence.bypassHistory, // Keep bypass history\n };\n } else {\n // Increment within window\n occurrence.lastSeen = now;\n occurrence.count++;\n \n // Update escalation level\n const thresholds = config.progressiveEscalation.thresholds;\n if (occurrence.count >= thresholds.block) {\n occurrence.escalationLevel = 'block';\n } else if (occurrence.count >= thresholds.escalate) {\n occurrence.escalationLevel = 'escalate';\n } else if (occurrence.count >= thresholds.autoCheck) {\n occurrence.escalationLevel = 'autoCheck';\n }\n }\n } else {\n // New occurrence\n occurrence = {\n hash,\n firstSeen: now,\n lastSeen: now,\n count: 1,\n escalationLevel: 'suggest',\n notified: false,\n bypassed: false,\n bypassHistory: [],\n };\n }\n \n occurrences.set(hash, occurrence);\n await saveOccurrences(projectPath);\n \n return occurrence;\n}\n\n/**\n * Get escalation level for an issue\n */\nexport async function getEscalationLevel(\n projectPath: string,\n file: string,\n line: number | undefined,\n issueType: string\n): Promise<IssueOccurrence['escalationLevel']> {\n const occurrences = await getOccurrences(projectPath);\n const hash = createIssueHash(file, line, issueType);\n \n const occurrence = occurrences.get(hash);\n return occurrence?.escalationLevel ?? 'suggest';\n}\n\n/**\n * Record a bypass\n */\nexport async function recordBypass(\n projectPath: string,\n file: string,\n line: number | undefined,\n issueType: string,\n method: string,\n reason?: string\n): Promise<void> {\n const occurrences = await getOccurrences(projectPath);\n const hash = createIssueHash(file, line, issueType);\n \n const occurrence = occurrences.get(hash);\n if (occurrence) {\n occurrence.bypassed = true;\n occurrence.bypassHistory.push({\n timestamp: Date.now(),\n method,\n ...(reason !== undefined ? { reason } : {}),\n });\n await saveOccurrences(projectPath);\n }\n}\n\n// ============================================================================\n// Auto-fix Helpers\n// ============================================================================\n\n/**\n * Check if a fix should be auto-applied based on config\n */\nexport function shouldAutoFix(\n fix: AutoFixAction,\n config: AutonomyConfig\n): boolean {\n if (!config.autoFix.enabled) {\n return false;\n }\n \n // Check if category is allowed\n const allowedCategories = config.autoFix.categories as string[];\n if (!allowedCategories.includes(fix.category) && \n !allowedCategories.includes('all')) {\n return false;\n }\n \n // Check if specific fix type is allowed\n if (config.autoFix.allowedFixTypes.length > 0 &&\n !config.autoFix.allowedFixTypes.includes(fix.type)) {\n return false;\n }\n \n // Check confidence threshold (require high confidence for auto-fix)\n if (fix.confidence < 0.9) {\n return false;\n }\n \n return true;\n}\n\n/**\n * Group fixes by file for batch application\n */\nexport function groupFixesByFile(fixes: AutoFixAction[]): Map<string, AutoFixAction[]> {\n const grouped = new Map<string, AutoFixAction[]>();\n \n for (const fix of fixes) {\n const existing = grouped.get(fix.file) || [];\n existing.push(fix);\n grouped.set(fix.file, existing);\n }\n \n return grouped;\n}\n\n// ============================================================================\n// Push Blocking Helpers\n// ============================================================================\n\n/**\n * Check if push should be blocked\n */\nexport function shouldBlockPush(\n issues: Array<{ severity: string; file: string; line?: number; issue: string }>,\n config: AutonomyConfig\n): PushBlockResult {\n if (!config.pushBlocking.enabled) {\n return {\n blocked: false,\n blockingIssues: [],\n bypassed: false,\n };\n }\n \n // Find blocking issues\n const blockingIssues = issues.filter(issue => \n config.pushBlocking.blockOn.includes(issue.severity as 'critical' | 'serious' | 'moderate')\n );\n \n if (blockingIssues.length === 0) {\n return {\n blocked: false,\n blockingIssues: [],\n bypassed: false,\n };\n }\n \n // Check for bypass\n const envBypass = process.env.TRIE_BYPASS === '1' || process.env.TRIE_BYPASS === 'true';\n \n if (envBypass && config.pushBlocking.allowBypass) {\n return {\n blocked: false,\n blockingIssues,\n bypassed: true,\n bypassMethod: 'env',\n };\n }\n \n // Build bypass instructions\n const bypassInstructions = buildBypassInstructions(config);\n \n return {\n blocked: true,\n reason: `${blockingIssues.length} ${blockingIssues[0]?.severity || 'critical'} issue(s) must be fixed before pushing`,\n blockingIssues,\n bypassInstructions,\n bypassed: false,\n };\n}\n\n/**\n * Build bypass instructions based on config\n */\nfunction buildBypassInstructions(config: AutonomyConfig): string {\n const instructions: string[] = [];\n \n if (config.pushBlocking.bypassMethods.includes('env')) {\n instructions.push('• Set TRIE_BYPASS=1 to bypass: TRIE_BYPASS=1 git push');\n }\n \n if (config.pushBlocking.bypassMethods.includes('flag')) {\n instructions.push('• Use --no-verify flag: git push --no-verify');\n }\n \n if (config.pushBlocking.bypassMethods.includes('confirm')) {\n instructions.push('• Run: trie bypass --confirm to bypass this push');\n }\n \n return instructions.join('\\n');\n}\n\n// ============================================================================\n// Singleton Config Cache\n// ============================================================================\n\nconst configCache = new Map<string, { config: AutonomyConfig; loadedAt: number }>();\nconst CACHE_TTL = 60000; // 1 minute\n\n/**\n * Get autonomy config with caching\n */\nexport async function getAutonomyConfig(projectPath: string): Promise<AutonomyConfig> {\n const cached = configCache.get(projectPath);\n \n if (cached && Date.now() - cached.loadedAt < CACHE_TTL) {\n return cached.config;\n }\n \n const config = await loadAutonomyConfig(projectPath);\n configCache.set(projectPath, { config, loadedAt: Date.now() });\n \n return config;\n}\n\n/**\n * Clear config cache (for testing or after config changes)\n */\nexport function clearConfigCache(): void {\n configCache.clear();\n occurrenceCache.clear();\n}\n","/**\n * Autonomy Configuration Types\n * \n * Controls how autonomous Trie behaves:\n * - Auto-check: Run full checks when issues detected\n * - Auto-fix: Apply fixes with human confirmation\n * - Push blocking: Block git push on critical issues\n * - Progressive escalation: Escalate based on occurrence count\n */\n\n/**\n * Overall autonomy level\n */\nexport type AutonomyLevel = \n | 'passive' // Only report, never act\n | 'suggest' // Suggest actions, don't execute\n | 'proactive' // Auto-check, ask before fixing\n | 'aggressive'; // Auto-check, auto-fix trivial, block on critical\n\n/**\n * Auto-check configuration\n */\nexport interface AutoCheckConfig {\n /** Enable auto-running full checks */\n enabled: boolean;\n /** Issue count threshold to trigger auto-check */\n threshold: number;\n /** Always trigger on critical issues */\n onCritical: boolean;\n /** Cooldown between auto-checks (ms) */\n cooldownMs: number;\n}\n\n/**\n * Auto-fix configuration\n */\nexport interface AutoFixConfig {\n /** Enable auto-fix suggestions */\n enabled: boolean;\n /** Always ask user before applying fixes (human-in-the-loop) */\n askFirst: boolean;\n /** Categories of fixes to auto-apply */\n categories: ('trivial' | 'safe' | 'moderate' | 'all')[];\n /** Specific fix types to auto-apply */\n allowedFixTypes: string[];\n}\n\n/**\n * Push blocking configuration\n */\nexport interface PushBlockingConfig {\n /** Enable push blocking */\n enabled: boolean;\n /** Allow user to bypass with flag */\n allowBypass: boolean;\n /** Severities that trigger blocking */\n blockOn: ('critical' | 'serious' | 'moderate')[];\n /** Bypass methods */\n bypassMethods: ('env' | 'flag' | 'confirm')[];\n /** Log bypasses for audit */\n logBypasses: boolean;\n}\n\n/**\n * Progressive escalation thresholds\n */\nexport interface ProgressiveEscalationConfig {\n /** Enable progressive escalation */\n enabled: boolean;\n /** Thresholds for different actions */\n thresholds: {\n /** First occurrence: suggest fix */\n suggest: number;\n /** N occurrences: auto-run full check */\n autoCheck: number;\n /** N occurrences: escalate to Slack/email */\n escalate: number;\n /** N occurrences: block until fixed */\n block: number;\n };\n /** Time window for counting occurrences (ms) */\n windowMs: number;\n}\n\n/**\n * AI Watcher configuration -- controls the Claude-powered file watcher\n */\nexport interface AIWatcherConfig {\n /** Enable AI-powered file watching */\n enabled: boolean;\n /** Max tokens to spend per hour on AI scans */\n hourlyTokenLimit: number;\n /** Minimum seconds between AI scans */\n scanCooldownSec: number;\n /** Seconds before re-scanning a file that was clean */\n cleanFileCooldownSec: number;\n /** Max files to include in a single AI scan */\n maxFilesPerScan: number;\n /** Max characters to send per file */\n maxCharsPerFile: number;\n}\n\n/**\n * Full autonomy configuration\n */\nexport interface AutonomyConfig {\n /** Overall autonomy level (can be overridden by specific settings) */\n level: AutonomyLevel;\n /** Auto-check settings */\n autoCheck: AutoCheckConfig;\n /** Auto-fix settings */\n autoFix: AutoFixConfig;\n /** Push blocking settings */\n pushBlocking: PushBlockingConfig;\n /** Progressive escalation settings */\n progressiveEscalation: ProgressiveEscalationConfig;\n /** AI watcher settings (Claude-powered file scanning) */\n aiWatcher: AIWatcherConfig;\n /** Enable dispatching fixes to Cursor cloud agents */\n cloudAgentEnabled?: boolean | undefined;\n /** Cursor API key for cloud agent dispatch */\n cursorApiKey?: string | undefined;\n}\n\n/**\n * Default autonomy configuration - proactive but safe\n */\nexport const DEFAULT_AUTONOMY_CONFIG: AutonomyConfig = {\n level: 'proactive',\n autoCheck: {\n enabled: true,\n threshold: 5,\n onCritical: true,\n cooldownMs: 30000, // 30 seconds\n },\n autoFix: {\n enabled: true,\n askFirst: true, // Always ask (human-in-the-loop)\n categories: ['trivial', 'safe'],\n allowedFixTypes: [\n 'remove-console-log',\n 'remove-debugger',\n 'remove-emoji',\n 'remove-unused-import',\n 'add-missing-await',\n 'fix-typo',\n ],\n },\n pushBlocking: {\n enabled: true,\n allowBypass: true,\n blockOn: ['critical'],\n bypassMethods: ['env', 'flag', 'confirm'],\n logBypasses: true,\n },\n progressiveEscalation: {\n enabled: true,\n thresholds: {\n suggest: 1,\n autoCheck: 3,\n escalate: 5,\n block: 10,\n },\n windowMs: 24 * 60 * 60 * 1000, // 24 hours\n },\n aiWatcher: {\n enabled: true,\n hourlyTokenLimit: 50_000,\n scanCooldownSec: 30,\n cleanFileCooldownSec: 300,\n maxFilesPerScan: 5,\n maxCharsPerFile: 4000,\n },\n cloudAgentEnabled: false,\n cursorApiKey: undefined,\n};\n\n/**\n * Issue occurrence tracking for progressive escalation\n */\nexport interface IssueOccurrence {\n /** Issue hash (file + line + type) */\n hash: string;\n /** First seen timestamp */\n firstSeen: number;\n /** Last seen timestamp */\n lastSeen: number;\n /** Total occurrence count */\n count: number;\n /** Current escalation level */\n escalationLevel: 'suggest' | 'autoCheck' | 'escalate' | 'block';\n /** Whether user has been notified at current level */\n notified: boolean;\n /** Whether issue has been bypassed */\n bypassed: boolean;\n /** Bypass history */\n bypassHistory: Array<{\n timestamp: number;\n method: string;\n reason?: string;\n }>;\n}\n\n/**\n * Auto-fix action\n */\nexport interface AutoFixAction {\n /** Unique ID for this fix */\n id: string;\n /** File to fix */\n file: string;\n /** Line number */\n line?: number;\n /** Original code */\n original: string;\n /** Fixed code */\n fixed: string;\n /** Type of fix */\n type: 'remove-console-log' | 'remove-debugger' | 'remove-emoji' | 'remove-unused-import' | \n 'add-missing-await' | 'fix-typo' | 'goal-violation' | 'custom' | string;\n /** Category of fix */\n category: 'trivial' | 'safe' | 'moderate' | 'risky' | 'goal-violation';\n /** Description of what the fix does */\n description: string;\n /** Confidence in the fix (0-1) */\n confidence: number;\n}\n\n/**\n * Push block result\n */\nexport interface PushBlockResult {\n /** Whether push is blocked */\n blocked: boolean;\n /** Reason for blocking */\n reason?: string;\n /** Issues causing the block */\n blockingIssues: Array<{\n file: string;\n line?: number;\n severity: string;\n issue: string;\n }>;\n /** Bypass instructions */\n bypassInstructions?: string;\n /** Whether user chose to bypass */\n bypassed: boolean;\n /** Bypass method used */\n bypassMethod?: string;\n}\n"],"mappings":";;;;;AAMA,SAAS,UAAU,WAAW,aAAa;AAC3C,SAAS,kBAAkB;AAC3B,SAAS,YAAY;;;ACuHd,IAAM,0BAA0C;AAAA,EACrD,OAAO;AAAA,EACP,WAAW;AAAA,IACT,SAAS;AAAA,IACT,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAA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AAY,IAAI,WAAW;AAE1C,MAAI,UAAU,KAAK,IAAI,IAAI,OAAO,WAAW,WAAW;AACtD,WAAO,OAAO;AAAA,EAChB;AAEA,QAAM,SAAS,MAAM,mBAAmB,WAAW;AACnD,cAAY,IAAI,aAAa,EAAE,QAAQ,UAAU,KAAK,IAAI,EAAE,CAAC;AAE7D,SAAO;AACT;AAKO,SAAS,mBAAyB;AACvC,cAAY,MAAM;AAClB,kBAAgB,MAAM;AACxB;","names":[]}
@@ -1,27 +0,0 @@
1
- import {
2
- getTrieDirectory
3
- } from "./chunk-VVITXIHN.js";
4
-
5
- // src/context/sync.ts
6
- import fs from "fs/promises";
7
- import path from "path";
8
- var DEFAULT_JSON_NAME = "context.json";
9
- async function exportToJson(graph, targetPath) {
10
- const snapshot = await graph.getSnapshot();
11
- const json = JSON.stringify(snapshot, null, 2);
12
- const outputPath = targetPath ?? path.join(getTrieDirectory(graph.projectRoot), DEFAULT_JSON_NAME);
13
- await fs.mkdir(path.dirname(outputPath), { recursive: true });
14
- await fs.writeFile(outputPath, json, "utf8");
15
- return json;
16
- }
17
- async function importFromJson(graph, json, sourcePath) {
18
- const payload = json.trim().length > 0 ? json : await fs.readFile(sourcePath ?? path.join(getTrieDirectory(graph.projectRoot), DEFAULT_JSON_NAME), "utf8");
19
- const snapshot = JSON.parse(payload);
20
- await graph.applySnapshot(snapshot);
21
- }
22
-
23
- export {
24
- exportToJson,
25
- importFromJson
26
- };
27
- //# sourceMappingURL=chunk-OBQ74FOU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/context/sync.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { getTrieDirectory } from '../utils/workspace.js';\n\nimport { ContextGraph } from './graph.js';\nimport type { ContextSnapshot } from './types.js';\n\nconst DEFAULT_JSON_NAME = 'context.json';\n\nexport async function exportToJson(graph: ContextGraph, targetPath?: string): Promise<string> {\n const snapshot = await graph.getSnapshot();\n const json = JSON.stringify(snapshot, null, 2);\n\n const outputPath = targetPath ?? path.join(getTrieDirectory(graph.projectRoot), DEFAULT_JSON_NAME);\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, json, 'utf8');\n\n return json;\n}\n\nexport async function importFromJson(\n graph: ContextGraph,\n json: string,\n sourcePath?: string\n): Promise<void> {\n const payload =\n json.trim().length > 0\n ? json\n : await fs.readFile(sourcePath ?? path.join(getTrieDirectory(graph.projectRoot), DEFAULT_JSON_NAME), 'utf8');\n\n const snapshot = JSON.parse(payload) as ContextSnapshot;\n await graph.applySnapshot(snapshot);\n}\n"],"mappings":";;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAMjB,IAAM,oBAAoB;AAE1B,eAAsB,aAAa,OAAqB,YAAsC;AAC5F,QAAM,WAAW,MAAM,MAAM,YAAY;AACzC,QAAM,OAAO,KAAK,UAAU,UAAU,MAAM,CAAC;AAE7C,QAAM,aAAa,cAAc,KAAK,KAAK,iBAAiB,MAAM,WAAW,GAAG,iBAAiB;AACjG,QAAM,GAAG,MAAM,KAAK,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AAC5D,QAAM,GAAG,UAAU,YAAY,MAAM,MAAM;AAE3C,SAAO;AACT;AAEA,eAAsB,eACpB,OACA,MACA,YACe;AACf,QAAM,UACJ,KAAK,KAAK,EAAE,SAAS,IACjB,OACA,MAAM,GAAG,SAAS,cAAc,KAAK,KAAK,iBAAiB,MAAM,WAAW,GAAG,iBAAiB,GAAG,MAAM;AAE/G,QAAM,WAAW,KAAK,MAAM,OAAO;AACnC,QAAM,MAAM,cAAc,QAAQ;AACpC;","names":[]}