@triedotdev/mcp 1.0.21 → 1.0.23

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-PG3GMCGH.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-JJATCZV5.js";
16
+ import {
17
+ getWorkingDirectory
18
+ } from "./chunk-IMFD4SJC.js";
16
19
  import "./chunk-3CS6Z2SL.js";
20
+ import "./chunk-HGINYWNW.js";
17
21
  import "./chunk-MR755QGT.js";
18
22
  import "./chunk-6NLHFIYA.js";
19
- import "./chunk-3AUDJWEF.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);
@@ -4053,7 +4063,7 @@ var tools = [
4053
4063
  },
4054
4064
  directory: {
4055
4065
  type: "string",
4056
- description: "Directory to scan (defaults to current working directory)"
4066
+ description: "Directory to scan. IMPORTANT: Pass the workspace/project root path for accurate results."
4057
4067
  },
4058
4068
  clear_memory: {
4059
4069
  type: "boolean",
@@ -4082,6 +4092,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
4082
4092
  };
4083
4093
  const rawName = stripNamespace(name);
4084
4094
  const normalizedName = rawName.startsWith("trie_") ? rawName.slice("trie_".length) : rawName;
4095
+ if (args && !args.directory && !args.files) {
4096
+ const workingDir = getWorkingDirectory(void 0, true);
4097
+ if (workingDir !== process.cwd()) {
4098
+ args.directory = workingDir;
4099
+ }
4100
+ }
4085
4101
  try {
4086
4102
  switch (normalizedName) {
4087
4103
  case "trie":
@@ -4173,17 +4189,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
4173
4189
  case "smith": {
4174
4190
  const smithArgs = args;
4175
4191
  if (smithArgs.clear_memory) {
4176
- const { AgentSmithAgent } = await import("./agent-smith-QYMYTLFV.js");
4177
- const smith = new AgentSmithAgent();
4178
- const result = await smith.clearMemory();
4192
+ const { AgentSmithAgent: AgentSmithAgent2 } = await import("./agent-smith-CCCXIXRS.js");
4193
+ const smith2 = new AgentSmithAgent2();
4194
+ const result2 = await smith2.clearMemory();
4179
4195
  return {
4180
- content: [{ type: "text", text: result.message }]
4196
+ content: [{ type: "text", text: result2.message }]
4181
4197
  };
4182
4198
  }
4183
4199
  if (smithArgs.show_stats) {
4184
- const { AgentSmithAgent } = await import("./agent-smith-QYMYTLFV.js");
4185
- const smith = new AgentSmithAgent();
4186
- const stats = await smith.getMemoryStats();
4200
+ const { AgentSmithAgent: AgentSmithAgent2 } = await import("./agent-smith-CCCXIXRS.js");
4201
+ const smith2 = new AgentSmithAgent2();
4202
+ const stats = await smith2.getMemoryStats();
4187
4203
  return {
4188
4204
  content: [{
4189
4205
  type: "text",
@@ -4201,8 +4217,135 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
4201
4217
  }]
4202
4218
  };
4203
4219
  }
4204
- const { runAgentSmith } = await import("./agent-smith-runner-3MIO4CWT.js");
4205
- return await runAgentSmith(smithArgs);
4220
+ const { AgentSmithAgent } = await import("./agent-smith-CCCXIXRS.js");
4221
+ const smith = new AgentSmithAgent();
4222
+ const workingDir = getWorkingDirectory(smithArgs.directory);
4223
+ const files = smithArgs.files || [];
4224
+ let filesToScan = files;
4225
+ if (!filesToScan.length) {
4226
+ const { readdir: readdir3 } = await import("fs/promises");
4227
+ const { join: join8, extname: extname6 } = await import("path");
4228
+ const SCANNABLE_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".vue", ".svelte", ".astro", ".py", ".go", ".rs"]);
4229
+ const SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", ".next", ".nuxt", "coverage", ".nyc_output", "__pycache__", ".pytest_cache", "vendor", ".venv", "venv", "target", ".turbo", ".cache"]);
4230
+ const discoverFiles = async (dir) => {
4231
+ const discovered = [];
4232
+ try {
4233
+ const entries = await readdir3(dir, { withFileTypes: true });
4234
+ for (const entry of entries) {
4235
+ const fullPath = join8(dir, entry.name);
4236
+ if (entry.isDirectory() && !SKIP_DIRS3.has(entry.name) && !entry.name.startsWith(".")) {
4237
+ discovered.push(...await discoverFiles(fullPath));
4238
+ } else if (entry.isFile() && SCANNABLE_EXTENSIONS2.has(extname6(entry.name).toLowerCase())) {
4239
+ discovered.push(fullPath);
4240
+ }
4241
+ if (discovered.length >= 300) break;
4242
+ }
4243
+ } catch {
4244
+ }
4245
+ return discovered;
4246
+ };
4247
+ filesToScan = await discoverFiles(workingDir);
4248
+ }
4249
+ const result = await smith.scan(filesToScan, { workingDir });
4250
+ const animationLog = smith.swarmAnimationLog || [];
4251
+ const totalIssues = result.issues.length;
4252
+ const criticalIssues = result.issues.filter((i) => i.severity === "critical");
4253
+ const seriousIssues = result.issues.filter((i) => i.severity === "serious");
4254
+ const moderateIssues = result.issues.filter((i) => i.severity === "moderate");
4255
+ const issueGroups = /* @__PURE__ */ new Map();
4256
+ result.issues.forEach((issue) => {
4257
+ const category = issue.category || "unknown";
4258
+ if (!issueGroups.has(category)) {
4259
+ issueGroups.set(category, []);
4260
+ }
4261
+ issueGroups.get(category).push(issue);
4262
+ });
4263
+ const sortedGroups = Array.from(issueGroups.entries()).map(([category, issues]) => {
4264
+ const criticalCount = issues.filter((i) => i.severity === "critical").length;
4265
+ const seriousCount = issues.filter((i) => i.severity === "serious").length;
4266
+ const score = criticalCount * 10 + seriousCount * 5 + issues.length;
4267
+ return {
4268
+ category,
4269
+ issues,
4270
+ count: issues.length,
4271
+ score,
4272
+ criticalCount,
4273
+ seriousCount
4274
+ };
4275
+ }).sort((a, b) => b.score - a.score);
4276
+ const reportLines = [
4277
+ "```",
4278
+ " \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557",
4279
+ " \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D",
4280
+ " \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 ",
4281
+ " \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 ",
4282
+ " \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 ",
4283
+ " \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u255D ",
4284
+ " ",
4285
+ " \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557",
4286
+ " \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551",
4287
+ " \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551",
4288
+ " \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551",
4289
+ " \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551",
4290
+ " \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D",
4291
+ "```",
4292
+ "",
4293
+ `*"${["You hear that? That is the sound of console.log... everywhere.", "The AI wrote this, didn't it? I can always tell.", "I'm going to be honest with you... I hate this vibe code."][Math.floor(Math.random() * 3)]}"*`,
4294
+ "",
4295
+ // Show the swarm animation
4296
+ "## \u{1F574}\uFE0F Agent Deployment Log",
4297
+ "```",
4298
+ ...animationLog,
4299
+ "```",
4300
+ "",
4301
+ // Executive Summary
4302
+ "## \u{1F4CA} Threat Assessment",
4303
+ `**${totalIssues} violations detected** across ${filesToScan.length} files`,
4304
+ `- \u{1F534} ${criticalIssues.length} **CRITICAL** (immediate action required)`,
4305
+ `- \u{1F7E0} ${seriousIssues.length} **SERIOUS** (address this sprint)`,
4306
+ `- \u{1F7E1} ${moderateIssues.length} **MODERATE** (technical debt)`,
4307
+ "",
4308
+ // Priority Targets
4309
+ "## \u{1F3AF} PRIORITY TARGETS (Top 5 Patterns)",
4310
+ ""
4311
+ ];
4312
+ sortedGroups.slice(0, 5).forEach((group, idx) => {
4313
+ const urgencyEmoji = group.criticalCount > 0 ? "\u{1F480}" : group.seriousCount > 0 ? "\u26A0\uFE0F" : "\u{1F50D}";
4314
+ const categoryName = group.category.replace("-hunter", "").replace(/_/g, " ").toUpperCase();
4315
+ reportLines.push(`**${idx + 1}. ${urgencyEmoji} ${categoryName}** \u2014 ${group.count} instances`);
4316
+ if (group.criticalCount > 0) {
4317
+ reportLines.push(` \u2514\u2500 \u{1F534} ${group.criticalCount} critical violations \u2014 **FIX IMMEDIATELY**`);
4318
+ }
4319
+ if (group.seriousCount > 0) {
4320
+ reportLines.push(` \u2514\u2500 \u{1F7E0} ${group.seriousCount} serious violations \u2014 address this week`);
4321
+ }
4322
+ reportLines.push("");
4323
+ });
4324
+ reportLines.push("");
4325
+ if (criticalIssues.length > 0) {
4326
+ reportLines.push("## \u{1F6A8} IMMEDIATE ACTION REQUIRED");
4327
+ reportLines.push("");
4328
+ criticalIssues.slice(0, 3).forEach((issue, idx) => {
4329
+ reportLines.push(`### ${idx + 1}. \`${issue.file}:${issue.line || "?"}\``);
4330
+ reportLines.push("");
4331
+ reportLines.push(`**Issue:** ${issue.issue.split("\n")[0]}`);
4332
+ reportLines.push(`**Risk:** Production security/stability impact`);
4333
+ reportLines.push(`**Action:** ${issue.fix}`);
4334
+ reportLines.push("");
4335
+ });
4336
+ if (criticalIssues.length > 3) {
4337
+ reportLines.push(`*...and ${criticalIssues.length - 3} more critical issues*`);
4338
+ reportLines.push("");
4339
+ }
4340
+ }
4341
+ reportLines.push("---");
4342
+ reportLines.push('*"The pattern spreads... like a virus. It is... inevitable."*');
4343
+ return {
4344
+ content: [{
4345
+ type: "text",
4346
+ text: reportLines.join("\n")
4347
+ }]
4348
+ };
4206
4349
  }
4207
4350
  default:
4208
4351
  throw new Error(`Unknown tool: ${name}`);
@@ -4246,7 +4389,7 @@ async function getAvailableResources() {
4246
4389
  mimeType: "application/json"
4247
4390
  });
4248
4391
  try {
4249
- const reportsDir = join7(process.cwd(), "trie-reports");
4392
+ const reportsDir = join7(getWorkingDirectory(void 0, true), "trie-reports");
4250
4393
  const files = await readdir2(reportsDir);
4251
4394
  const reportFiles = files.filter((f) => f.endsWith(".txt") || f.endsWith(".json"));
4252
4395
  for (const file of reportFiles.slice(0, 10)) {
@@ -4323,7 +4466,7 @@ async function readResourceContent(uri) {
4323
4466
  }
4324
4467
  if (parsedUri === "cache/stats") {
4325
4468
  try {
4326
- const cachePath = join7(process.cwd(), ".trie", ".trie-cache.json");
4469
+ const cachePath = join7(getWorkingDirectory(void 0, true), ".trie", ".trie-cache.json");
4327
4470
  const cacheContent = await readFile6(cachePath, "utf-8");
4328
4471
  const cache = JSON.parse(cacheContent);
4329
4472
  const fileCount = Object.keys(cache.files || {}).length;
@@ -4376,7 +4519,7 @@ async function readResourceContent(uri) {
4376
4519
  }
4377
4520
  if (parsedUri.startsWith("reports/")) {
4378
4521
  const fileName = parsedUri.replace("reports/", "");
4379
- const reportPath = join7(process.cwd(), "trie-reports", fileName);
4522
+ const reportPath = join7(getWorkingDirectory(void 0, true), "trie-reports", fileName);
4380
4523
  try {
4381
4524
  const content = await readFile6(reportPath, "utf-8");
4382
4525
  return {