@triedotdev/mcp 1.0.21 → 1.0.22

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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  listCustomAgents,
4
4
  loadAgentConfig,
5
5
  parseDocument
6
- } from "./chunk-EYNAGEQK.js";
6
+ } from "./chunk-R5VBDDAD.js";
7
7
  import {
8
8
  CRITICAL_REVIEW_CHECKLIST,
9
9
  SuperReviewerAgent,
@@ -12,11 +12,14 @@ import {
12
12
  getAgentRegistry,
13
13
  getPrompt,
14
14
  getSystemPrompt
15
- } from "./chunk-52RPXHT6.js";
15
+ } from "./chunk-NETSKBGJ.js";
16
16
  import "./chunk-3CS6Z2SL.js";
17
17
  import "./chunk-MR755QGT.js";
18
18
  import "./chunk-6NLHFIYA.js";
19
- import "./chunk-3AUDJWEF.js";
19
+ import {
20
+ getWorkingDirectory
21
+ } from "./chunk-7QBNXROW.js";
22
+ import "./chunk-3MYJUGCZ.js";
20
23
  import "./chunk-DGUM43GV.js";
21
24
 
22
25
  // src/index.ts
@@ -68,10 +71,11 @@ var TrieExplainTool = class {
68
71
  let code;
69
72
  let filePath;
70
73
  let language;
71
- const resolvedPath = isAbsolute(target) ? target : resolve(process.cwd(), target);
74
+ const workDir = getWorkingDirectory(void 0, true);
75
+ const resolvedPath = isAbsolute(target) ? target : resolve(workDir, target);
72
76
  if (existsSync(resolvedPath)) {
73
77
  code = await readFile(resolvedPath, "utf-8");
74
- filePath = relative(process.cwd(), resolvedPath);
78
+ filePath = relative(workDir, resolvedPath);
75
79
  language = this.detectLanguage(resolvedPath);
76
80
  } else {
77
81
  code = target;
@@ -281,7 +285,8 @@ ${"\u2501".repeat(60)}
281
285
  return { content: [{ type: "text", text: output }] };
282
286
  }
283
287
  async explainRisk(target, context) {
284
- const resolvedPath = isAbsolute(target) ? target : resolve(process.cwd(), target);
288
+ const workDir = getWorkingDirectory(void 0, true);
289
+ const resolvedPath = isAbsolute(target) ? target : resolve(workDir, target);
285
290
  let output = `
286
291
  ${"\u2501".repeat(60)}
287
292
  `;
@@ -292,7 +297,7 @@ ${"\u2501".repeat(60)}
292
297
  `;
293
298
  if (existsSync(resolvedPath)) {
294
299
  const code = await readFile(resolvedPath, "utf-8");
295
- const filePath = relative(process.cwd(), resolvedPath);
300
+ const filePath = relative(workDir, resolvedPath);
296
301
  const riskIndicators = this.detectRiskIndicators(code);
297
302
  output += `## \u{1F4C2} Target
298
303
 
@@ -568,9 +573,10 @@ ${"\u2501".repeat(60)}
568
573
  output += `- **Files:** ${files.length}
569
574
 
570
575
  `;
576
+ const workDir = getWorkingDirectory(void 0, true);
571
577
  const allUnits = [];
572
578
  for (const file of files) {
573
- const resolvedPath = isAbsolute2(file) ? file : resolve2(process.cwd(), file);
579
+ const resolvedPath = isAbsolute2(file) ? file : resolve2(workDir, file);
574
580
  if (!existsSync2(resolvedPath)) {
575
581
  output += `\u26A0\uFE0F File not found: ${file}
576
582
  `;
@@ -578,7 +584,7 @@ ${"\u2501".repeat(60)}
578
584
  }
579
585
  const code = await readFile2(resolvedPath, "utf-8");
580
586
  const language = this.detectLanguage(resolvedPath);
581
- const relativePath = relative2(process.cwd(), resolvedPath);
587
+ const relativePath = relative2(workDir, resolvedPath);
582
588
  const units = this.extractTestableUnits(code, language);
583
589
  allUnits.push({ file: relativePath, units });
584
590
  output += `### \u{1F4C4} ${relativePath}
@@ -609,7 +615,7 @@ ${"\u2501".repeat(60)}
609
615
  `;
610
616
  for (const { file, units } of allUnits) {
611
617
  if (units.length === 0) continue;
612
- const code = await readFile2(resolve2(process.cwd(), file), "utf-8");
618
+ const code = await readFile2(resolve2(workDir, file), "utf-8");
613
619
  const language = this.detectLanguage(file);
614
620
  const prompt = getPrompt("test", "generate", {
615
621
  code,
@@ -652,8 +658,9 @@ ${"\u2501".repeat(60)}
652
658
  output += `${"\u2501".repeat(60)}
653
659
 
654
660
  `;
661
+ const workDir = getWorkingDirectory(void 0, true);
655
662
  for (const file of files) {
656
- const resolvedPath = isAbsolute2(file) ? file : resolve2(process.cwd(), file);
663
+ const resolvedPath = isAbsolute2(file) ? file : resolve2(workDir, file);
657
664
  if (!existsSync2(resolvedPath)) {
658
665
  output += `\u26A0\uFE0F File not found: ${file}
659
666
  `;
@@ -661,7 +668,7 @@ ${"\u2501".repeat(60)}
661
668
  }
662
669
  const code = await readFile2(resolvedPath, "utf-8");
663
670
  const language = this.detectLanguage(resolvedPath);
664
- const relativePath = relative2(process.cwd(), resolvedPath);
671
+ const relativePath = relative2(workDir, resolvedPath);
665
672
  const units = this.extractTestableUnits(code, language);
666
673
  const testFile = await this.findTestFile(resolvedPath);
667
674
  let testCode = "";
@@ -678,7 +685,7 @@ ${"\u2501".repeat(60)}
678
685
  output += `**Coverage:** ${coverageIcon} ${coverage}% (${testedUnits.length}/${units.length} units)
679
686
  `;
680
687
  if (testFile) {
681
- output += `**Test file:** \`${relative2(process.cwd(), testFile)}\`
688
+ output += `**Test file:** \`${relative2(workDir, testFile)}\`
682
689
  `;
683
690
  } else {
684
691
  output += `**Test file:** \u274C Not found
@@ -733,15 +740,16 @@ ${"\u2501".repeat(60)}
733
740
  output += `${"\u2501".repeat(60)}
734
741
 
735
742
  `;
743
+ const workDir = getWorkingDirectory(void 0, true);
736
744
  for (const file of files) {
737
- const resolvedPath = isAbsolute2(file) ? file : resolve2(process.cwd(), file);
745
+ const resolvedPath = isAbsolute2(file) ? file : resolve2(workDir, file);
738
746
  if (!existsSync2(resolvedPath)) {
739
747
  output += `\u26A0\uFE0F File not found: ${file}
740
748
  `;
741
749
  continue;
742
750
  }
743
751
  const code = await readFile2(resolvedPath, "utf-8");
744
- const relativePath = relative2(process.cwd(), resolvedPath);
752
+ const relativePath = relative2(workDir, resolvedPath);
745
753
  const patterns = this.detectTestablePatterns(code);
746
754
  output += `### \u{1F4C4} ${relativePath}
747
755
 
@@ -1041,7 +1049,8 @@ ${"\u2501".repeat(60)}
1041
1049
  return patterns;
1042
1050
  }
1043
1051
  async detectTestFramework() {
1044
- const packagePath = resolve2(process.cwd(), "package.json");
1052
+ const workDir = getWorkingDirectory(void 0, true);
1053
+ const packagePath = resolve2(workDir, "package.json");
1045
1054
  if (existsSync2(packagePath)) {
1046
1055
  try {
1047
1056
  const pkg = JSON.parse(await readFile2(packagePath, "utf-8"));
@@ -1052,7 +1061,7 @@ ${"\u2501".repeat(60)}
1052
1061
  } catch {
1053
1062
  }
1054
1063
  }
1055
- if (existsSync2(resolve2(process.cwd(), "pytest.ini")) || existsSync2(resolve2(process.cwd(), "pyproject.toml"))) {
1064
+ if (existsSync2(resolve2(workDir, "pytest.ini")) || existsSync2(resolve2(workDir, "pyproject.toml"))) {
1056
1065
  return "pytest";
1057
1066
  }
1058
1067
  return "jest";
@@ -1175,7 +1184,7 @@ var TrieWatchTool = class {
1175
1184
  const { action, directory, debounceMs = 1e3, yolo = false } = args;
1176
1185
  switch (action) {
1177
1186
  case "start":
1178
- return this.startWatching(directory || process.cwd(), debounceMs, yolo);
1187
+ return this.startWatching(getWorkingDirectory(directory), debounceMs, yolo);
1179
1188
  case "stop":
1180
1189
  return this.stopWatching();
1181
1190
  case "status":
@@ -1835,7 +1844,7 @@ var TrieAgentTool = class {
1835
1844
  }
1836
1845
  }
1837
1846
  async execute(args) {
1838
- const { agent, files, directory, depth = "standard", lookup, output = "full" } = args;
1847
+ const { agent, files, directory, depth: _depth = "standard", lookup, output = "full" } = args;
1839
1848
  if (lookup) {
1840
1849
  return this.handleKnowledgeLookup(lookup);
1841
1850
  }
@@ -1855,17 +1864,17 @@ ${this.agentRegistry.getAgentNames().map((n) => `- ${n}`).join("\n")}`
1855
1864
  }]
1856
1865
  };
1857
1866
  }
1867
+ const workDir = getWorkingDirectory(directory);
1858
1868
  let filesToScan = files || [];
1859
1869
  if (!filesToScan.length) {
1860
- const scanDir = directory || process.cwd();
1861
1870
  console.error(`
1862
- \u{1F50D} Discovering files in: ${scanDir}`);
1863
- filesToScan = await this.discoverFiles(scanDir);
1871
+ \u{1F50D} Discovering files in: ${workDir}`);
1872
+ filesToScan = await this.discoverFiles(workDir);
1864
1873
  console.error(` Found ${filesToScan.length} files
1865
1874
  `);
1866
1875
  } else {
1867
1876
  filesToScan = filesToScan.map(
1868
- (f) => isAbsolute3(f) ? f : resolve3(process.cwd(), f)
1877
+ (f) => isAbsolute3(f) ? f : resolve3(workDir, f)
1869
1878
  );
1870
1879
  }
1871
1880
  const validFiles = filesToScan.filter((f) => existsSync4(f));
@@ -1895,7 +1904,7 @@ ${this.agentRegistry.getAgentNames().map((n) => `- ${n}`).join("\n")}`
1895
1904
  console.error(` (Pattern detection + AI enhancement if API key is set)
1896
1905
  `);
1897
1906
  try {
1898
- const result = await agentInstance.scan(files, { workingDir: process.cwd() });
1907
+ const result = await agentInstance.scan(files, { workingDir: getWorkingDirectory(void 0, true) });
1899
1908
  const executionTime = Date.now() - startTime;
1900
1909
  return {
1901
1910
  content: [{
@@ -1912,7 +1921,8 @@ ${this.agentRegistry.getAgentNames().map((n) => `- ${n}`).join("\n")}`
1912
1921
  };
1913
1922
  }
1914
1923
  }
1915
- generateKnowledgeSuggestions(followUps, agentName) {
1924
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1925
+ _generateKnowledgeSuggestions(followUps, agentName) {
1916
1926
  if (followUps.length === 0) {
1917
1927
  return "";
1918
1928
  }
@@ -2559,7 +2569,7 @@ var TrieSaveAgentTool = class {
2559
2569
  };
2560
2570
  }
2561
2571
  async saveAgentConfig(config) {
2562
- const trieDir = join4(process.cwd(), ".trie", "agents");
2572
+ const trieDir = join4(getWorkingDirectory(void 0, true), ".trie", "agents");
2563
2573
  await mkdir(trieDir, { recursive: true });
2564
2574
  const configPath = join4(trieDir, `${config.name}.json`);
2565
2575
  await writeFile(configPath, JSON.stringify(config, null, 2));
@@ -2794,7 +2804,7 @@ Usage:
2794
2804
  */
2795
2805
  async getPRInfo(pr, worktree) {
2796
2806
  if (worktree) {
2797
- const worktreePath = isAbsolute4(worktree) ? worktree : resolve4(process.cwd(), worktree);
2807
+ const worktreePath = isAbsolute4(worktree) ? worktree : resolve4(getWorkingDirectory(void 0, true), worktree);
2798
2808
  if (!existsSync6(worktreePath)) {
2799
2809
  return { success: false, error: `Worktree not found: ${worktreePath}` };
2800
2810
  }
@@ -2931,7 +2941,7 @@ Usage:
2931
2941
  */
2932
2942
  async findDesignDocs(files, prInfo) {
2933
2943
  const designDocs = [];
2934
- const cwd = prInfo.path || process.cwd();
2944
+ const cwd = prInfo.path || getWorkingDirectory(void 0, true);
2935
2945
  for (const file of files) {
2936
2946
  if (file.path.includes("design_docs/") || file.path.includes("docs/design/") || file.path.includes("rfcs/")) {
2937
2947
  designDocs.push(file.path);
@@ -2955,7 +2965,7 @@ Usage:
2955
2965
  */
2956
2966
  async preloadFiles(filePaths) {
2957
2967
  const contents = /* @__PURE__ */ new Map();
2958
- const cwd = process.cwd();
2968
+ const cwd = getWorkingDirectory(void 0, true);
2959
2969
  await Promise.all(filePaths.map(async (filePath) => {
2960
2970
  try {
2961
2971
  const fullPath = isAbsolute4(filePath) ? filePath : join5(cwd, filePath);
@@ -3473,7 +3483,7 @@ var DEFAULT_CONFIG = {
3473
3483
  // src/config/loader.ts
3474
3484
  async function loadConfig() {
3475
3485
  try {
3476
- const configPath = join6(process.cwd(), ".trie", "config.json");
3486
+ const configPath = join6(getWorkingDirectory(void 0, true), ".trie", "config.json");
3477
3487
  const configFile = await readFile5(configPath, "utf-8");
3478
3488
  const userConfig = JSON.parse(configFile);
3479
3489
  return mergeConfig(DEFAULT_CONFIG, userConfig);
@@ -4173,7 +4183,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
4173
4183
  case "smith": {
4174
4184
  const smithArgs = args;
4175
4185
  if (smithArgs.clear_memory) {
4176
- const { AgentSmithAgent } = await import("./agent-smith-QYMYTLFV.js");
4186
+ const { AgentSmithAgent } = await import("./agent-smith-MAOXWVIS.js");
4177
4187
  const smith = new AgentSmithAgent();
4178
4188
  const result = await smith.clearMemory();
4179
4189
  return {
@@ -4181,7 +4191,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
4181
4191
  };
4182
4192
  }
4183
4193
  if (smithArgs.show_stats) {
4184
- const { AgentSmithAgent } = await import("./agent-smith-QYMYTLFV.js");
4194
+ const { AgentSmithAgent } = await import("./agent-smith-MAOXWVIS.js");
4185
4195
  const smith = new AgentSmithAgent();
4186
4196
  const stats = await smith.getMemoryStats();
4187
4197
  return {
@@ -4201,7 +4211,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
4201
4211
  }]
4202
4212
  };
4203
4213
  }
4204
- const { runAgentSmith } = await import("./agent-smith-runner-3MIO4CWT.js");
4214
+ const { runAgentSmith } = await import("./agent-smith-runner-KYOVKE6C.js");
4205
4215
  return await runAgentSmith(smithArgs);
4206
4216
  }
4207
4217
  default:
@@ -4246,7 +4256,7 @@ async function getAvailableResources() {
4246
4256
  mimeType: "application/json"
4247
4257
  });
4248
4258
  try {
4249
- const reportsDir = join7(process.cwd(), "trie-reports");
4259
+ const reportsDir = join7(getWorkingDirectory(void 0, true), "trie-reports");
4250
4260
  const files = await readdir2(reportsDir);
4251
4261
  const reportFiles = files.filter((f) => f.endsWith(".txt") || f.endsWith(".json"));
4252
4262
  for (const file of reportFiles.slice(0, 10)) {
@@ -4323,7 +4333,7 @@ async function readResourceContent(uri) {
4323
4333
  }
4324
4334
  if (parsedUri === "cache/stats") {
4325
4335
  try {
4326
- const cachePath = join7(process.cwd(), ".trie", ".trie-cache.json");
4336
+ const cachePath = join7(getWorkingDirectory(void 0, true), ".trie", ".trie-cache.json");
4327
4337
  const cacheContent = await readFile6(cachePath, "utf-8");
4328
4338
  const cache = JSON.parse(cacheContent);
4329
4339
  const fileCount = Object.keys(cache.files || {}).length;
@@ -4376,7 +4386,7 @@ async function readResourceContent(uri) {
4376
4386
  }
4377
4387
  if (parsedUri.startsWith("reports/")) {
4378
4388
  const fileName = parsedUri.replace("reports/", "");
4379
- const reportPath = join7(process.cwd(), "trie-reports", fileName);
4389
+ const reportPath = join7(getWorkingDirectory(void 0, true), "trie-reports", fileName);
4380
4390
  try {
4381
4391
  const content = await readFile6(reportPath, "utf-8");
4382
4392
  return {