@triedotdev/mcp 1.0.113 → 1.0.114

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 (75) hide show
  1. package/dist/auto-fix-apply-PCAHWLXF.js +10 -0
  2. package/dist/autonomy-config-O4H3Z7YV.js +30 -0
  3. package/dist/chunk-2GIAROBF.js +173 -0
  4. package/dist/chunk-2GIAROBF.js.map +1 -0
  5. package/dist/{chunk-33WL3D7A.js → chunk-2SIFK7OW.js} +7 -419
  6. package/dist/chunk-2SIFK7OW.js.map +1 -0
  7. package/dist/chunk-43X6JBEM.js +36 -0
  8. package/dist/chunk-43X6JBEM.js.map +1 -0
  9. package/dist/{chunk-2764KZZQ.js → chunk-4SBZXIMG.js} +133 -595
  10. package/dist/chunk-4SBZXIMG.js.map +1 -0
  11. package/dist/chunk-55DOQNHJ.js +772 -0
  12. package/dist/chunk-55DOQNHJ.js.map +1 -0
  13. package/dist/chunk-6LXSA2OZ.js +425 -0
  14. package/dist/chunk-6LXSA2OZ.js.map +1 -0
  15. package/dist/{chunk-SDS3UVFY.js → chunk-AOFYU6T3.js} +113 -559
  16. package/dist/chunk-AOFYU6T3.js.map +1 -0
  17. package/dist/{chunk-6QR6QZIX.js → chunk-D3EXBJE2.js} +25 -658
  18. package/dist/chunk-D3EXBJE2.js.map +1 -0
  19. package/dist/chunk-DJ2YAGHK.js +50 -0
  20. package/dist/chunk-DJ2YAGHK.js.map +1 -0
  21. package/dist/chunk-DRDEEF6G.js +328 -0
  22. package/dist/chunk-DRDEEF6G.js.map +1 -0
  23. package/dist/chunk-DZREHOGW.js +706 -0
  24. package/dist/chunk-DZREHOGW.js.map +1 -0
  25. package/dist/chunk-KRH642MT.js +947 -0
  26. package/dist/chunk-KRH642MT.js.map +1 -0
  27. package/dist/{chunk-QYOACM2C.js → chunk-MVNJPJBK.js} +22 -252
  28. package/dist/chunk-MVNJPJBK.js.map +1 -0
  29. package/dist/chunk-NS2MSZMB.js +394 -0
  30. package/dist/chunk-NS2MSZMB.js.map +1 -0
  31. package/dist/chunk-SWSK7ANT.js +340 -0
  32. package/dist/chunk-SWSK7ANT.js.map +1 -0
  33. package/dist/chunk-VRLMTOB6.js +566 -0
  34. package/dist/chunk-VRLMTOB6.js.map +1 -0
  35. package/dist/chunk-YR4BMGYO.js +130 -0
  36. package/dist/chunk-YR4BMGYO.js.map +1 -0
  37. package/dist/chunk-ZV2K6M7T.js +74 -0
  38. package/dist/chunk-ZV2K6M7T.js.map +1 -0
  39. package/dist/cli/main.js +107 -375
  40. package/dist/cli/main.js.map +1 -1
  41. package/dist/cli/yolo-daemon.js +18 -8
  42. package/dist/cli/yolo-daemon.js.map +1 -1
  43. package/dist/client-7XZHCMD3.js +28 -0
  44. package/dist/client-7XZHCMD3.js.map +1 -0
  45. package/dist/{goal-manager-AP4LTE6U.js → goal-manager-LMS6ZJB7.js} +7 -3
  46. package/dist/goal-manager-LMS6ZJB7.js.map +1 -0
  47. package/dist/goal-validator-7UPLOVAZ.js +184 -0
  48. package/dist/goal-validator-7UPLOVAZ.js.map +1 -0
  49. package/dist/graph-U5JWSAB5.js +10 -0
  50. package/dist/graph-U5JWSAB5.js.map +1 -0
  51. package/dist/guardian-agent-EXP7APLC.js +25 -0
  52. package/dist/guardian-agent-EXP7APLC.js.map +1 -0
  53. package/dist/hypothesis-KGC3P54C.js +19 -0
  54. package/dist/hypothesis-KGC3P54C.js.map +1 -0
  55. package/dist/incident-index-PNIVT47T.js +11 -0
  56. package/dist/incident-index-PNIVT47T.js.map +1 -0
  57. package/dist/index.js +285 -16
  58. package/dist/index.js.map +1 -1
  59. package/dist/ledger-SR6OEBLO.js +15 -0
  60. package/dist/ledger-SR6OEBLO.js.map +1 -0
  61. package/dist/output-manager-BOTMXSND.js +13 -0
  62. package/dist/output-manager-BOTMXSND.js.map +1 -0
  63. package/dist/pattern-discovery-F7LU5K6E.js +8 -0
  64. package/dist/pattern-discovery-F7LU5K6E.js.map +1 -0
  65. package/package.json +1 -1
  66. package/dist/chunk-2764KZZQ.js.map +0 -1
  67. package/dist/chunk-33WL3D7A.js.map +0 -1
  68. package/dist/chunk-6JPPYG7F.js +0 -1813
  69. package/dist/chunk-6JPPYG7F.js.map +0 -1
  70. package/dist/chunk-6QR6QZIX.js.map +0 -1
  71. package/dist/chunk-QYOACM2C.js.map +0 -1
  72. package/dist/chunk-SDS3UVFY.js.map +0 -1
  73. package/dist/guardian-agent-XEYNG7RH.js +0 -18
  74. /package/dist/{goal-manager-AP4LTE6U.js.map → auto-fix-apply-PCAHWLXF.js.map} +0 -0
  75. /package/dist/{guardian-agent-XEYNG7RH.js.map → autonomy-config-O4H3Z7YV.js.map} +0 -0
package/dist/cli/main.js CHANGED
@@ -1,4 +1,14 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ getAutonomyConfig,
4
+ recordBypass,
5
+ shouldAutoFix,
6
+ shouldBlockPush,
7
+ trackIssueOccurrence
8
+ } from "../chunk-DRDEEF6G.js";
9
+ import {
10
+ applyAutoFix
11
+ } from "../chunk-DJ2YAGHK.js";
2
12
  import {
3
13
  LinearIngester,
4
14
  completeBootstrap,
@@ -13,7 +23,6 @@ import {
13
23
  saveConfig
14
24
  } from "../chunk-TKMV7JKN.js";
15
25
  import {
16
- IncidentIndex,
17
26
  LearningEngine,
18
27
  exportToJson,
19
28
  formatAuditLog,
@@ -28,41 +37,53 @@ import {
28
37
  isTrieInitialized,
29
38
  perceiveCurrentChanges,
30
39
  reasonAboutChangesHumanReadable
31
- } from "../chunk-QYOACM2C.js";
40
+ } from "../chunk-MVNJPJBK.js";
32
41
  import {
33
- ContextGraph,
34
42
  GotchaPredictor,
35
43
  findCrossProjectPatterns,
36
44
  getGlobalMemoryStats,
37
45
  listTrackedProjects,
38
46
  searchGlobalPatterns,
39
47
  updateGlobalMemoryMd
40
- } from "../chunk-6QR6QZIX.js";
41
- import "../chunk-IXO4G4D3.js";
48
+ } from "../chunk-D3EXBJE2.js";
49
+ import "../chunk-SWSK7ANT.js";
42
50
  import {
43
51
  getDailyLogs,
44
- getGuardianState,
45
52
  getMemoryStats,
46
53
  getRecentIssues,
47
54
  markIssueResolved,
48
55
  purgeIssues,
49
56
  searchIssues
50
- } from "../chunk-6JPPYG7F.js";
57
+ } from "../chunk-55DOQNHJ.js";
58
+ import {
59
+ getGuardianState
60
+ } from "../chunk-KRH642MT.js";
61
+ import "../chunk-F4NJ4CBP.js";
62
+ import "../chunk-IXO4G4D3.js";
63
+ import {
64
+ ContextGraph
65
+ } from "../chunk-NS2MSZMB.js";
66
+ import {
67
+ IncidentIndex
68
+ } from "../chunk-2GIAROBF.js";
69
+ import "../chunk-6NLHFIYA.js";
70
+ import "../chunk-ZV2K6M7T.js";
71
+ import "../chunk-YR4BMGYO.js";
72
+ import "../chunk-43X6JBEM.js";
51
73
  import {
52
74
  getTrieDirectory,
53
75
  getWorkingDirectory
54
76
  } from "../chunk-R4AAPFXC.js";
55
- import "../chunk-F4NJ4CBP.js";
56
- import "../chunk-6NLHFIYA.js";
57
77
  import "../chunk-APMV77PU.js";
58
78
  import {
59
79
  __require
60
80
  } from "../chunk-DGUM43GV.js";
61
81
 
62
82
  // src/cli/main.ts
63
- import { resolve, join as join4, dirname } from "path";
83
+ import { resolve, join as join3, dirname } from "path";
64
84
  import { readFileSync } from "fs";
65
85
  import { fileURLToPath } from "url";
86
+ import pc5 from "picocolors";
66
87
 
67
88
  // src/hooks/install.ts
68
89
  import fs from "fs";
@@ -705,274 +726,6 @@ async function handleCheckCommand(args) {
705
726
  }
706
727
  }
707
728
 
708
- // src/utils/autonomy-config.ts
709
- import { readFile, writeFile, mkdir } from "fs/promises";
710
- import { existsSync } from "fs";
711
- import { join } from "path";
712
-
713
- // src/types/autonomy.ts
714
- var DEFAULT_AUTONOMY_CONFIG = {
715
- level: "proactive",
716
- autoCheck: {
717
- enabled: true,
718
- threshold: 5,
719
- onCritical: true,
720
- cooldownMs: 3e4
721
- // 30 seconds
722
- },
723
- autoFix: {
724
- enabled: true,
725
- askFirst: true,
726
- // Always ask (human-in-the-loop)
727
- categories: ["trivial", "safe"],
728
- allowedFixTypes: [
729
- "remove-console-log",
730
- "remove-unused-import",
731
- "add-missing-await",
732
- "fix-typo"
733
- ]
734
- },
735
- pushBlocking: {
736
- enabled: true,
737
- allowBypass: true,
738
- blockOn: ["critical"],
739
- bypassMethods: ["env", "flag", "confirm"],
740
- logBypasses: true
741
- },
742
- progressiveEscalation: {
743
- enabled: true,
744
- thresholds: {
745
- suggest: 1,
746
- autoCheck: 3,
747
- escalate: 5,
748
- block: 10
749
- },
750
- windowMs: 24 * 60 * 60 * 1e3
751
- // 24 hours
752
- }
753
- };
754
-
755
- // src/utils/autonomy-config.ts
756
- import { createHash } from "crypto";
757
- async function loadAutonomyConfig(projectPath) {
758
- const configPath = join(getTrieDirectory(projectPath), "config.json");
759
- try {
760
- if (!existsSync(configPath)) {
761
- return { ...DEFAULT_AUTONOMY_CONFIG };
762
- }
763
- const content = await readFile(configPath, "utf-8");
764
- const config = JSON.parse(content);
765
- return mergeWithDefaults(config.autonomy || {});
766
- } catch (error) {
767
- console.error("Failed to load autonomy config:", error);
768
- return { ...DEFAULT_AUTONOMY_CONFIG };
769
- }
770
- }
771
- function mergeWithDefaults(partial) {
772
- return {
773
- level: partial.level ?? DEFAULT_AUTONOMY_CONFIG.level,
774
- autoCheck: {
775
- ...DEFAULT_AUTONOMY_CONFIG.autoCheck,
776
- ...partial.autoCheck || {}
777
- },
778
- autoFix: {
779
- ...DEFAULT_AUTONOMY_CONFIG.autoFix,
780
- ...partial.autoFix || {}
781
- },
782
- pushBlocking: {
783
- ...DEFAULT_AUTONOMY_CONFIG.pushBlocking,
784
- ...partial.pushBlocking || {}
785
- },
786
- progressiveEscalation: {
787
- ...DEFAULT_AUTONOMY_CONFIG.progressiveEscalation,
788
- ...partial.progressiveEscalation || {},
789
- thresholds: {
790
- ...DEFAULT_AUTONOMY_CONFIG.progressiveEscalation.thresholds,
791
- ...partial.progressiveEscalation?.thresholds || {}
792
- }
793
- }
794
- };
795
- }
796
- var occurrenceCache = /* @__PURE__ */ new Map();
797
- async function getOccurrences(projectPath) {
798
- if (occurrenceCache.has(projectPath)) {
799
- return occurrenceCache.get(projectPath);
800
- }
801
- const occurrencesPath = join(getTrieDirectory(projectPath), "memory", "occurrences.json");
802
- const occurrences = /* @__PURE__ */ new Map();
803
- try {
804
- if (existsSync(occurrencesPath)) {
805
- const content = await readFile(occurrencesPath, "utf-8");
806
- const data = JSON.parse(content);
807
- for (const [hash, occ] of Object.entries(data)) {
808
- occurrences.set(hash, occ);
809
- }
810
- }
811
- } catch {
812
- }
813
- occurrenceCache.set(projectPath, occurrences);
814
- return occurrences;
815
- }
816
- async function saveOccurrences(projectPath) {
817
- const occurrences = occurrenceCache.get(projectPath);
818
- if (!occurrences) return;
819
- const occurrencesPath = join(getTrieDirectory(projectPath), "memory", "occurrences.json");
820
- const memoryDir = join(getTrieDirectory(projectPath), "memory");
821
- try {
822
- if (!existsSync(memoryDir)) {
823
- await mkdir(memoryDir, { recursive: true });
824
- }
825
- const data = {};
826
- for (const [hash, occ] of occurrences.entries()) {
827
- data[hash] = occ;
828
- }
829
- await writeFile(occurrencesPath, JSON.stringify(data, null, 2));
830
- } catch (error) {
831
- console.error("Failed to save occurrences:", error);
832
- }
833
- }
834
- function createIssueHash(file, line, issueType) {
835
- const input = `${file}:${line || 0}:${issueType}`;
836
- return createHash("md5").update(input).digest("hex").slice(0, 12);
837
- }
838
- async function trackIssueOccurrence(projectPath, file, line, issueType, config) {
839
- const occurrences = await getOccurrences(projectPath);
840
- const hash = createIssueHash(file, line, issueType);
841
- const now = Date.now();
842
- let occurrence = occurrences.get(hash);
843
- if (occurrence) {
844
- const windowMs = config.progressiveEscalation.windowMs;
845
- if (now - occurrence.firstSeen > windowMs) {
846
- occurrence = {
847
- hash,
848
- firstSeen: now,
849
- lastSeen: now,
850
- count: 1,
851
- escalationLevel: "suggest",
852
- notified: false,
853
- bypassed: false,
854
- bypassHistory: occurrence.bypassHistory
855
- // Keep bypass history
856
- };
857
- } else {
858
- occurrence.lastSeen = now;
859
- occurrence.count++;
860
- const thresholds = config.progressiveEscalation.thresholds;
861
- if (occurrence.count >= thresholds.block) {
862
- occurrence.escalationLevel = "block";
863
- } else if (occurrence.count >= thresholds.escalate) {
864
- occurrence.escalationLevel = "escalate";
865
- } else if (occurrence.count >= thresholds.autoCheck) {
866
- occurrence.escalationLevel = "autoCheck";
867
- }
868
- }
869
- } else {
870
- occurrence = {
871
- hash,
872
- firstSeen: now,
873
- lastSeen: now,
874
- count: 1,
875
- escalationLevel: "suggest",
876
- notified: false,
877
- bypassed: false,
878
- bypassHistory: []
879
- };
880
- }
881
- occurrences.set(hash, occurrence);
882
- await saveOccurrences(projectPath);
883
- return occurrence;
884
- }
885
- async function recordBypass(projectPath, file, line, issueType, method, reason) {
886
- const occurrences = await getOccurrences(projectPath);
887
- const hash = createIssueHash(file, line, issueType);
888
- const occurrence = occurrences.get(hash);
889
- if (occurrence) {
890
- occurrence.bypassed = true;
891
- occurrence.bypassHistory.push({
892
- timestamp: Date.now(),
893
- method,
894
- ...reason !== void 0 ? { reason } : {}
895
- });
896
- await saveOccurrences(projectPath);
897
- }
898
- }
899
- function shouldAutoFix(fix, config) {
900
- if (!config.autoFix.enabled) {
901
- return false;
902
- }
903
- const allowedCategories = config.autoFix.categories;
904
- if (!allowedCategories.includes(fix.category) && !allowedCategories.includes("all")) {
905
- return false;
906
- }
907
- if (config.autoFix.allowedFixTypes.length > 0 && !config.autoFix.allowedFixTypes.includes(fix.type)) {
908
- return false;
909
- }
910
- if (fix.confidence < 0.9) {
911
- return false;
912
- }
913
- return true;
914
- }
915
- function shouldBlockPush(issues, config) {
916
- if (!config.pushBlocking.enabled) {
917
- return {
918
- blocked: false,
919
- blockingIssues: [],
920
- bypassed: false
921
- };
922
- }
923
- const blockingIssues = issues.filter(
924
- (issue) => config.pushBlocking.blockOn.includes(issue.severity)
925
- );
926
- if (blockingIssues.length === 0) {
927
- return {
928
- blocked: false,
929
- blockingIssues: [],
930
- bypassed: false
931
- };
932
- }
933
- const envBypass = process.env.TRIE_BYPASS === "1" || process.env.TRIE_BYPASS === "true";
934
- if (envBypass && config.pushBlocking.allowBypass) {
935
- return {
936
- blocked: false,
937
- blockingIssues,
938
- bypassed: true,
939
- bypassMethod: "env"
940
- };
941
- }
942
- const bypassInstructions = buildBypassInstructions(config);
943
- return {
944
- blocked: true,
945
- reason: `${blockingIssues.length} ${blockingIssues[0]?.severity || "critical"} issue(s) must be fixed before pushing`,
946
- blockingIssues,
947
- bypassInstructions,
948
- bypassed: false
949
- };
950
- }
951
- function buildBypassInstructions(config) {
952
- const instructions = [];
953
- if (config.pushBlocking.bypassMethods.includes("env")) {
954
- instructions.push("\u2022 Set TRIE_BYPASS=1 to bypass: TRIE_BYPASS=1 git push");
955
- }
956
- if (config.pushBlocking.bypassMethods.includes("flag")) {
957
- instructions.push("\u2022 Use --no-verify flag: git push --no-verify");
958
- }
959
- if (config.pushBlocking.bypassMethods.includes("confirm")) {
960
- instructions.push("\u2022 Run: trie bypass --confirm to bypass this push");
961
- }
962
- return instructions.join("\n");
963
- }
964
- var configCache = /* @__PURE__ */ new Map();
965
- var CACHE_TTL = 6e4;
966
- async function getAutonomyConfig(projectPath) {
967
- const cached = configCache.get(projectPath);
968
- if (cached && Date.now() - cached.loadedAt < CACHE_TTL) {
969
- return cached.config;
970
- }
971
- const config = await loadAutonomyConfig(projectPath);
972
- configCache.set(projectPath, { config, loadedAt: Date.now() });
973
- return config;
974
- }
975
-
976
729
  // src/cli/pre-push.ts
977
730
  import pc from "picocolors";
978
731
  function parseArgs2(args) {
@@ -1106,8 +859,8 @@ function collectIssuesForBlocking(reasoning) {
1106
859
  }
1107
860
 
1108
861
  // src/cli/auto-fix.ts
1109
- import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
1110
- import { existsSync as existsSync2 } from "fs";
862
+ import { readFile } from "fs/promises";
863
+ import { existsSync } from "fs";
1111
864
  import { createInterface } from "readline";
1112
865
  import pc2 from "picocolors";
1113
866
  function detectAutoFixes(issues) {
@@ -1181,50 +934,14 @@ function displayFixPreview(fix, index, total) {
1181
934
  }
1182
935
  console.error("");
1183
936
  }
1184
- async function applyFix(fix) {
1185
- try {
1186
- if (!existsSync2(fix.file)) {
1187
- console.error(pc2.red(`File not found: ${fix.file}`));
1188
- return false;
1189
- }
1190
- const content = await readFile2(fix.file, "utf-8");
1191
- const lines = content.split("\n");
1192
- if (fix.line === void 0 || fix.line < 1 || fix.line > lines.length) {
1193
- console.error(pc2.red(`Invalid line number: ${fix.line}`));
1194
- return false;
1195
- }
1196
- const lineIndex = fix.line - 1;
1197
- const originalLine = lines[lineIndex];
1198
- let newContent;
1199
- if (fix.type === "remove-console-log" || fix.type === "remove-debugger") {
1200
- lines.splice(lineIndex, 1);
1201
- newContent = lines.join("\n");
1202
- } else if (fix.fixed) {
1203
- lines[lineIndex] = fix.fixed;
1204
- newContent = lines.join("\n");
1205
- } else {
1206
- console.error(pc2.red(`Unknown fix type: ${fix.type}`));
1207
- return false;
1208
- }
1209
- await writeFile2(fix.file, newContent);
1210
- console.error(pc2.green(`\u2713 Applied fix to ${fix.file}:${fix.line}`));
1211
- if (originalLine) {
1212
- console.error(pc2.dim(` Removed: ${originalLine.trim().slice(0, 60)}...`));
1213
- }
1214
- return true;
1215
- } catch (error) {
1216
- console.error(pc2.red(`Failed to apply fix: ${error}`));
1217
- return false;
1218
- }
1219
- }
1220
937
  async function loadFixContent(fixes) {
1221
938
  const enrichedFixes = [];
1222
939
  for (const fix of fixes) {
1223
- if (!fix.line || !existsSync2(fix.file)) {
940
+ if (!fix.line || !existsSync(fix.file)) {
1224
941
  continue;
1225
942
  }
1226
943
  try {
1227
- const content = await readFile2(fix.file, "utf-8");
944
+ const content = await readFile(fix.file, "utf-8");
1228
945
  const lines = content.split("\n");
1229
946
  const originalLine = lines[fix.line - 1];
1230
947
  if (originalLine) {
@@ -1313,8 +1030,13 @@ async function handleAutoFixCommand(args, issues) {
1313
1030
  break;
1314
1031
  }
1315
1032
  if (answer === "y" || answer === "yes") {
1316
- const success = await applyFix(fix);
1317
- if (success) applied2++;
1033
+ const success = await applyAutoFix(fix);
1034
+ if (success) {
1035
+ console.error(pc2.green(`\u2713 Applied fix to ${fix.file}:${fix.line}`));
1036
+ applied2++;
1037
+ } else {
1038
+ console.error(pc2.red(`\u2717 Failed to apply fix`));
1039
+ }
1318
1040
  } else {
1319
1041
  console.error(pc2.dim("Skipped."));
1320
1042
  skipped++;
@@ -1333,10 +1055,12 @@ async function handleAutoFixCommand(args, issues) {
1333
1055
  let applied = 0;
1334
1056
  let failed = 0;
1335
1057
  for (const fix of fixes) {
1336
- const success = await applyFix(fix);
1058
+ const success = await applyAutoFix(fix);
1337
1059
  if (success) {
1060
+ console.error(pc2.green(`\u2713 Applied fix to ${fix.file}:${fix.line}`));
1338
1061
  applied++;
1339
1062
  } else {
1063
+ console.error(pc2.red(`\u2717 Failed to apply fix to ${fix.file}:${fix.line}`));
1340
1064
  failed++;
1341
1065
  }
1342
1066
  }
@@ -1888,8 +1612,8 @@ async function handleQuietCommand() {
1888
1612
  }
1889
1613
 
1890
1614
  // src/cli/ci.ts
1891
- import { writeFileSync, existsSync as existsSync3, mkdirSync } from "fs";
1892
- import { join as join2 } from "path";
1615
+ import { writeFileSync, existsSync as existsSync2, mkdirSync } from "fs";
1616
+ import { join } from "path";
1893
1617
  import pc4 from "picocolors";
1894
1618
  var WORKFLOW_TEMPLATE = `# Trie Security Scan with Memory Persistence
1895
1619
  # Generated by: trie ci
@@ -1980,8 +1704,8 @@ jobs:
1980
1704
  `;
1981
1705
  function handleCISetupCommand(args) {
1982
1706
  const workDir = getWorkingDirectory(void 0, true);
1983
- const workflowsDir = join2(workDir, ".github", "workflows");
1984
- const workflowPath = join2(workflowsDir, "trie-scan.yml");
1707
+ const workflowsDir = join(workDir, ".github", "workflows");
1708
+ const workflowPath = join(workflowsDir, "trie-scan.yml");
1985
1709
  const isMinimal = args.includes("--minimal") || args.includes("-m");
1986
1710
  const isDryRun = args.includes("--dry-run") || args.includes("-n");
1987
1711
  const showHelp3 = args.includes("--help") || args.includes("-h");
@@ -2030,13 +1754,13 @@ ${pc4.bold("REQUIRED SECRETS:")}
2030
1754
  console.log(pc4.dim("\nRun without --dry-run to create the file."));
2031
1755
  return;
2032
1756
  }
2033
- if (existsSync3(workflowPath)) {
1757
+ if (existsSync2(workflowPath)) {
2034
1758
  console.log(pc4.yellow("Workflow already exists: .github/workflows/trie-scan.yml"));
2035
1759
  console.log(pc4.dim(" Run with --dry-run to preview what would be written."));
2036
1760
  console.log(pc4.dim(" Delete the existing file to regenerate."));
2037
1761
  return;
2038
1762
  }
2039
- if (!existsSync3(workflowsDir)) {
1763
+ if (!existsSync2(workflowsDir)) {
2040
1764
  mkdirSync(workflowsDir, { recursive: true });
2041
1765
  }
2042
1766
  writeFileSync(workflowPath, template);
@@ -2282,21 +2006,21 @@ async function handleLearnCommand(args) {
2282
2006
  }
2283
2007
 
2284
2008
  // src/cli/patterns.ts
2285
- import { readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
2286
- import { existsSync as existsSync5 } from "fs";
2009
+ import { readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
2010
+ import { existsSync as existsSync4 } from "fs";
2287
2011
  import { basename as basename2 } from "path";
2288
2012
  import picocolors3 from "picocolors";
2289
2013
 
2290
2014
  // src/patterns/saved-patterns.ts
2291
- import { createHash as createHash2 } from "crypto";
2292
- import { readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
2293
- import { existsSync as existsSync4 } from "fs";
2294
- import { join as join3, basename } from "path";
2015
+ import { createHash } from "crypto";
2016
+ import { readFile as readFile2, writeFile } from "fs/promises";
2017
+ import { existsSync as existsSync3 } from "fs";
2018
+ import { join as join2, basename } from "path";
2295
2019
  async function loadSavedPatterns(workDir) {
2296
- const patternsPath = join3(getTrieDirectory(workDir), "saved-patterns.json");
2020
+ const patternsPath = join2(getTrieDirectory(workDir), "saved-patterns.json");
2297
2021
  try {
2298
- if (existsSync4(patternsPath)) {
2299
- const content = await readFile3(patternsPath, "utf-8");
2022
+ if (existsSync3(patternsPath)) {
2023
+ const content = await readFile2(patternsPath, "utf-8");
2300
2024
  return JSON.parse(content);
2301
2025
  }
2302
2026
  } catch {
@@ -2304,10 +2028,10 @@ async function loadSavedPatterns(workDir) {
2304
2028
  return [];
2305
2029
  }
2306
2030
  async function savePatternsToProject(patterns, workDir) {
2307
- const { mkdir: mkdir2 } = await import("fs/promises");
2308
- const patternsPath = join3(getTrieDirectory(workDir), "saved-patterns.json");
2309
- await mkdir2(getTrieDirectory(workDir), { recursive: true });
2310
- await writeFile3(patternsPath, JSON.stringify(patterns, null, 2));
2031
+ const { mkdir } = await import("fs/promises");
2032
+ const patternsPath = join2(getTrieDirectory(workDir), "saved-patterns.json");
2033
+ await mkdir(getTrieDirectory(workDir), { recursive: true });
2034
+ await writeFile(patternsPath, JSON.stringify(patterns, null, 2));
2311
2035
  }
2312
2036
  async function savePatternToProject(pattern, workDir) {
2313
2037
  const patterns = await loadSavedPatterns(workDir);
@@ -2342,14 +2066,14 @@ function detectPatternType(target, workDir) {
2342
2066
  if (scoutNames.includes(target.toLowerCase())) {
2343
2067
  return "detection-rule";
2344
2068
  }
2345
- const fullPath = join3(workDir, target);
2346
- if (existsSync4(fullPath) || target.includes("/") || target.includes("*") || target.endsWith(".ts") || target.endsWith(".js")) {
2069
+ const fullPath = join2(workDir, target);
2070
+ if (existsSync3(fullPath) || target.includes("/") || target.includes("*") || target.endsWith(".ts") || target.endsWith(".js")) {
2347
2071
  return "file-structure";
2348
2072
  }
2349
2073
  return "code-pattern";
2350
2074
  }
2351
2075
  function generatePatternId(target, type) {
2352
- const hash = createHash2("sha256").update(`${type}:${target}`).digest("hex").slice(0, 12);
2076
+ const hash = createHash("sha256").update(`${type}:${target}`).digest("hex").slice(0, 12);
2353
2077
  return `${type}-${hash}`;
2354
2078
  }
2355
2079
  async function createSavedPattern(target, note, workDir) {
@@ -2501,7 +2225,7 @@ async function handleExportPatterns(args, workDir) {
2501
2225
  exportedFrom: basename2(workDir),
2502
2226
  patterns
2503
2227
  };
2504
- await writeFile4(outputPath, JSON.stringify(exportData, null, 2));
2228
+ await writeFile2(outputPath, JSON.stringify(exportData, null, 2));
2505
2229
  console.log(picocolors3.green(`\u2713 Exported ${patterns.length} patterns to ${outputPath}`));
2506
2230
  console.log(picocolors3.dim(` Import to another project with: trie patterns import ${outputPath}`));
2507
2231
  }
@@ -2511,11 +2235,11 @@ async function handleImportPatterns(args, workDir) {
2511
2235
  console.error(picocolors3.red("Usage: trie patterns import <path-to-patterns.json>"));
2512
2236
  process.exit(1);
2513
2237
  }
2514
- if (!existsSync5(inputPath)) {
2238
+ if (!existsSync4(inputPath)) {
2515
2239
  console.error(picocolors3.red(`File not found: ${inputPath}`));
2516
2240
  process.exit(1);
2517
2241
  }
2518
- const content = await readFile4(inputPath, "utf-8");
2242
+ const content = await readFile3(inputPath, "utf-8");
2519
2243
  const importData = JSON.parse(content);
2520
2244
  if (!importData.patterns || !Array.isArray(importData.patterns)) {
2521
2245
  console.error(picocolors3.red("Invalid pattern file format."));
@@ -2760,48 +2484,56 @@ async function handleStatusCommand() {
2760
2484
  const state = await loadContextState();
2761
2485
  const memoryStats = await getMemoryStats(workDir);
2762
2486
  console.log("\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
2763
- console.log("\u2551 \u{1F4CA} Project Status \u2551");
2487
+ console.log("\u2551 PROJECT STATUS \u2551");
2764
2488
  console.log("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n");
2765
- const healthEmoji = state.healthScore >= 80 ? "\u2705" : state.healthScore >= 60 ? "\u26A0\uFE0F" : "\u{1F534}";
2766
- console.log(`${healthEmoji} Health Score: ${state.healthScore}%`);
2489
+ const healthIndicator = state.healthScore >= 80 ? "\u25CF" : state.healthScore >= 60 ? "\u25C9" : "\u25CB";
2490
+ const healthColor = state.healthScore >= 80 ? pc5.green(healthIndicator) : state.healthScore >= 60 ? pc5.yellow(healthIndicator) : pc5.red(healthIndicator);
2491
+ console.log(`${healthColor} Health Score: ${pc5.bold(state.healthScore + "%")}`);
2767
2492
  if (state.lastScan) {
2768
2493
  const lastScanDate = new Date(state.lastScan.timestamp);
2769
2494
  const daysAgo = Math.floor((Date.now() - lastScanDate.getTime()) / (1e3 * 60 * 60 * 24));
2770
2495
  console.log(`
2771
- \u{1F4C5} Last Scan: ${lastScanDate.toLocaleDateString()} (${daysAgo === 0 ? "today" : daysAgo === 1 ? "yesterday" : `${daysAgo} days ago`})`);
2772
- console.log(` Files scanned: ${state.lastScan.filesScanned}`);
2773
- console.log(` Issues found: ${state.lastScan.issues.total} (${state.lastScan.issues.critical} critical, ${state.lastScan.issues.serious} serious)`);
2496
+ ${pc5.bold("Last Scan:")} ${lastScanDate.toLocaleDateString()} (${daysAgo === 0 ? "today" : daysAgo === 1 ? "yesterday" : `${daysAgo} days ago`})`);
2497
+ console.log(pc5.dim(` Files scanned: ${state.lastScan.filesScanned}`));
2498
+ console.log(pc5.dim(` Issues found: ${state.lastScan.issues.total} (${state.lastScan.issues.critical} critical, ${state.lastScan.issues.serious} serious)`));
2774
2499
  } else {
2775
- console.log("\n\u{1F4C5} Last Scan: Never (run `trie scan` to get started)");
2500
+ console.log(`
2501
+ ${pc5.bold("Last Scan:")} Never ${pc5.dim("(run `trie scan` to get started)")}`);
2776
2502
  }
2777
- console.log("\n\u{1F4BE} Memory Stats:");
2778
- console.log(` Active Issues: ${memoryStats.activeIssues}`);
2779
- console.log(` Resolved: ${memoryStats.resolvedCount}`);
2780
- console.log(` Total (all-time): ${memoryStats.totalIssues}`);
2503
+ console.log(`
2504
+ ${pc5.bold("Memory Stats:")}`);
2505
+ console.log(pc5.dim(` Active Issues: ${memoryStats.activeIssues}`));
2506
+ console.log(pc5.dim(` Resolved: ${memoryStats.resolvedCount}`));
2507
+ console.log(pc5.dim(` Total (all-time): ${memoryStats.totalIssues}`));
2781
2508
  const cap = memoryStats.capacityInfo;
2782
- const capEmoji = cap.isAtCap ? "\u{1F534}" : cap.percentFull >= 80 ? "\u26A0\uFE0F" : "\u2705";
2783
- console.log(` ${capEmoji} Memory Usage: ${cap.percentFull}% (${cap.current}/${cap.max})`);
2509
+ const capIndicator = cap.isAtCap ? pc5.red("\u25CB") : cap.percentFull >= 80 ? pc5.yellow("\u25C9") : pc5.green("\u25CF");
2510
+ console.log(` ${capIndicator} Memory Usage: ${pc5.bold(cap.percentFull + "%")} ${pc5.dim(`(${cap.current}/${cap.max})`)}`);
2784
2511
  if (memoryStats.activeIssues > 0) {
2785
- console.log("\n Active Issues by Severity:");
2512
+ console.log(`
2513
+ ${pc5.bold("Active Issues by Severity:")}`);
2786
2514
  const severityOrder = ["critical", "serious", "moderate", "low", "info"];
2787
2515
  for (const severity of severityOrder) {
2788
2516
  const count = memoryStats.activeIssuesBySeverity[severity] || 0;
2789
2517
  if (count > 0) {
2790
- console.log(` ${severity}: ${count}`);
2518
+ console.log(pc5.dim(` ${severity}: ${count}`));
2791
2519
  }
2792
2520
  }
2793
2521
  } else if (memoryStats.totalIssues > 0) {
2794
- console.log("\n \u2705 All issues have been resolved!");
2522
+ console.log(`
2523
+ ${pc5.green("\u25CF")} All issues have been resolved`);
2795
2524
  }
2796
2525
  if (cap.isAtCap) {
2797
- console.log("\n\u26A0\uFE0F Memory at capacity - consider running: trie memory purge smart");
2526
+ console.log(`
2527
+ ${pc5.yellow("\u2B22 Warning:")} Memory at capacity - consider running: ${pc5.bold("trie memory purge smart")}`);
2798
2528
  } else if (cap.percentFull >= 80) {
2799
- console.log("\n\u2139\uFE0F Memory usage high - consider running: trie memory purge smart");
2529
+ console.log(`
2530
+ ${pc5.yellow("\u2B22 Notice:")} Memory usage high - consider running: ${pc5.bold("trie memory purge smart")}`);
2800
2531
  }
2801
- console.log("\n\u{1F4A1} Quick Commands:");
2802
- console.log(" trie scan - Scan codebase now");
2803
- console.log(" trie memory stats - Detailed memory statistics");
2804
- console.log(" trie project - View project information");
2532
+ console.log(`
2533
+ ${pc5.bold("Quick Commands:")}`);
2534
+ console.log(pc5.dim(" trie scan - Scan codebase now"));
2535
+ console.log(pc5.dim(" trie memory stats - Detailed memory statistics"));
2536
+ console.log(pc5.dim(" trie project - View project information"));
2805
2537
  console.log("");
2806
2538
  } catch (error) {
2807
2539
  console.error("Error loading status:", error);
@@ -2816,10 +2548,10 @@ async function handleProject(args) {
2816
2548
  if (result.created) {
2817
2549
  console.log(`
2818
2550
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
2819
- \u2551 \u{1F4CB} PROJECT.md Created \u2551
2551
+ \u2551 PROJECT.md Created \u2551
2820
2552
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
2821
2553
 
2822
- Path: ${result.path}
2554
+ ${pc5.bold("Path:")} ${result.path}
2823
2555
 
2824
2556
  A template has been created with sections for:
2825
2557
  \u2022 Project Overview
@@ -2844,7 +2576,7 @@ Next steps:
2844
2576
  }
2845
2577
  if (subcommand === "edit") {
2846
2578
  const editor = process.env.EDITOR || process.env.VISUAL || "nano";
2847
- const projectPath = join4(getTrieDirectory(workDir), "PROJECT.md");
2579
+ const projectPath = join3(getTrieDirectory(workDir), "PROJECT.md");
2848
2580
  if (!projectInfoExists(workDir)) {
2849
2581
  console.log("No PROJECT.md found. Creating one first...");
2850
2582
  await initProjectInfo(workDir);
@@ -2859,10 +2591,10 @@ Next steps:
2859
2591
  if (!projectInfoExists(workDir)) {
2860
2592
  console.log(`
2861
2593
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
2862
- \u2551 \u{1F4CB} Project Information \u2551
2594
+ \u2551 Project Information \u2551
2863
2595
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
2864
2596
 
2865
- No PROJECT.md found in this project.
2597
+ ${pc5.bold("No PROJECT.md found in this project.")}
2866
2598
 
2867
2599
  COMMANDS:
2868
2600
  trie project init Create PROJECT.md from template
@@ -2887,10 +2619,10 @@ This info is available via trie://project MCP resource.
2887
2619
  const content = await loadProjectInfo(workDir);
2888
2620
  console.log(`
2889
2621
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
2890
- \u2551 \u{1F4CB} Project Information \u2551
2622
+ \u2551 Project Information \u2551
2891
2623
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
2892
2624
 
2893
- Path: ${join4(getTrieDirectory(workDir), "PROJECT.md")}
2625
+ ${pc5.bold("Path:")} ${join3(getTrieDirectory(workDir), "PROJECT.md")}
2894
2626
 
2895
2627
  ${"-".repeat(68)}
2896
2628
  `);