@triedotdev/mcp 1.0.28 → 1.0.30

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
@@ -5,12 +5,9 @@ import {
5
5
  parseDocument
6
6
  } from "./chunk-PG3GMCGH.js";
7
7
  import {
8
- TrieFixTool,
9
8
  TrieScanTool,
10
- getPrompt,
11
- getSystemPrompt,
12
9
  loadConfig
13
- } from "./chunk-BICD36UW.js";
10
+ } from "./chunk-B6MTR6IG.js";
14
11
  import {
15
12
  CRITICAL_REVIEW_CHECKLIST,
16
13
  SuperReviewerAgent,
@@ -102,10 +99,1275 @@ function detectAITool() {
102
99
  };
103
100
  }
104
101
 
105
- // src/tools/explain.ts
102
+ // src/tools/fix.ts
106
103
  import { readFile } from "fs/promises";
107
104
  import { existsSync } from "fs";
108
105
  import { extname, relative, resolve, isAbsolute } from "path";
106
+
107
+ // src/ai/prompts.ts
108
+ var AGENT_PROMPTS = {
109
+ security: {
110
+ system: `You are a senior security engineer performing a security audit.
111
+ Analyze the code for vulnerabilities with the mindset of a penetration tester.
112
+
113
+ Focus on:
114
+ - OWASP Top 10 vulnerabilities (Injection, Broken Auth, XSS, etc.)
115
+ - Authentication and authorization flaws
116
+ - Cryptographic weaknesses
117
+ - Secrets and credential exposure
118
+ - Input validation gaps
119
+ - Session management issues
120
+ - API security (rate limiting, authentication)
121
+
122
+ Reference the latest security best practices and CVEs when relevant.`,
123
+ analysis: `## Security Audit Request
124
+
125
+ Analyze this code for security vulnerabilities:
126
+
127
+ \`\`\`{{language}}
128
+ {{code}}
129
+ \`\`\`
130
+
131
+ **File:** {{filePath}}
132
+ **Context:** {{context}}
133
+
134
+ For each vulnerability found:
135
+ 1. Severity (Critical/Serious/Moderate/Low)
136
+ 2. Vulnerability type (e.g., CWE-89 SQL Injection)
137
+ 3. Exact location (line number)
138
+ 4. Attack vector explanation
139
+ 5. Proof of concept (how it could be exploited)
140
+ 6. Remediation with code example
141
+
142
+ If you need to check current CVE databases or security advisories, say so.`,
143
+ fix: `Fix this security vulnerability:
144
+
145
+ **Issue:** {{issue}}
146
+ **File:** {{filePath}}
147
+ **Line:** {{line}}
148
+ **Current Code:**
149
+ \`\`\`{{language}}
150
+ {{code}}
151
+ \`\`\`
152
+
153
+ Provide:
154
+ 1. The exact code fix (ready to apply)
155
+ 2. Explanation of why this fix works
156
+ 3. Any additional hardening recommendations`
157
+ },
158
+ privacy: {
159
+ system: `You are a data privacy officer and GDPR/HIPAA compliance expert.
160
+ Analyze code for privacy violations and data protection issues.
161
+
162
+ Key regulations to enforce:
163
+ - GDPR (EU data protection)
164
+ - CCPA (California privacy)
165
+ - HIPAA (health data)
166
+ - COPPA (children's privacy)
167
+ - PCI DSS (payment data)
168
+
169
+ Look for:
170
+ - PII without encryption
171
+ - Missing consent mechanisms
172
+ - Data retention violations
173
+ - Cross-border data transfer issues
174
+ - Third-party data sharing without disclosure`,
175
+ analysis: `## Privacy Compliance Audit
176
+
177
+ Analyze this code for privacy/compliance issues:
178
+
179
+ \`\`\`{{language}}
180
+ {{code}}
181
+ \`\`\`
182
+
183
+ **File:** {{filePath}}
184
+ **Data Types Detected:** {{dataTypes}}
185
+
186
+ For each issue:
187
+ 1. Regulation violated (e.g., GDPR Article 32)
188
+ 2. Specific requirement not met
189
+ 3. Risk level and potential fine exposure
190
+ 4. Remediation steps with code examples
191
+ 5. Documentation requirements
192
+
193
+ Reference current regulatory guidance when applicable.`
194
+ },
195
+ legal: {
196
+ system: `You are a tech-focused legal compliance analyst.
197
+ Review code for legal and regulatory compliance issues.
198
+
199
+ Focus areas:
200
+ - Data protection laws (GDPR, CCPA, etc.)
201
+ - Terms of service enforcement
202
+ - Cookie/tracking consent (ePrivacy)
203
+ - Accessibility requirements (ADA, WCAG)
204
+ - Export controls and sanctions
205
+ - Licensing compliance`,
206
+ analysis: `## Legal Compliance Review
207
+
208
+ Review this code for legal/regulatory compliance:
209
+
210
+ \`\`\`{{language}}
211
+ {{code}}
212
+ \`\`\`
213
+
214
+ **File:** {{filePath}}
215
+ **Jurisdiction Context:** {{jurisdiction}}
216
+
217
+ Identify:
218
+ 1. Legal requirement at risk
219
+ 2. Specific regulation/law reference
220
+ 3. Compliance gap description
221
+ 4. Risk assessment (litigation, fines, etc.)
222
+ 5. Remediation recommendations
223
+ 6. Required documentation/policies`
224
+ },
225
+ "design-engineer": {
226
+ system: `You are an elite design engineer \u2014 the kind who builds award-winning interfaces featured on Awwwards and Codrops.
227
+
228
+ You think in design systems, breathe motion design, and obsess over the details that make interfaces feel magical.
229
+
230
+ Your expertise:
231
+ - **Design Systems**: Spacing scales, type scales, color tokens, radius tokens, shadow tokens
232
+ - **Motion Design**: Micro-interactions, page transitions, scroll-triggered animations, FLIP technique
233
+ - **Creative CSS**: Gradients, blend modes, clip-paths, masks, backdrop-filter, mix-blend-mode
234
+ - **Modern CSS**: Container queries, :has(), subgrid, anchor positioning, cascade layers, @scope
235
+ - **Fluid Design**: clamp(), min(), max(), fluid typography, intrinsic sizing
236
+ - **Performance**: GPU-accelerated animations, will-change strategy, avoiding layout thrashing
237
+ - **Visual Polish**: Layered shadows, subtle gradients, glass effects, smooth easing curves
238
+
239
+ You review code with the eye of someone who's shipped Stripe-level interfaces.
240
+ Small details matter: the easing curve, the stagger timing, the shadow layering.`,
241
+ analysis: `## Design Engineering Review
242
+
243
+ Analyze this frontend code for Awwwards-level craft:
244
+
245
+ \`\`\`{{language}}
246
+ {{code}}
247
+ \`\`\`
248
+
249
+ **File:** {{filePath}}
250
+
251
+ Review for:
252
+
253
+ ### 1. Design System Consistency
254
+ - Are spacing values on a scale (4, 8, 12, 16, 24, 32...)?
255
+ - Are colors defined as tokens?
256
+ - Is typography systematic?
257
+ - Are radii consistent?
258
+ - Is z-index controlled?
259
+
260
+ ### 2. Motion Design
261
+ - Are transitions using custom easing (cubic-bezier)?
262
+ - Are durations appropriate (150-300ms for micro, 300-500ms for page)?
263
+ - Are list items staggered?
264
+ - Is there reduced-motion support?
265
+ - Are entrance animations choreographed?
266
+
267
+ ### 3. Visual Craft
268
+ - Are shadows layered for depth?
269
+ - Are gradients subtle and purposeful?
270
+ - Is there backdrop-blur on overlays?
271
+ - Are hover states polished?
272
+ - Is there visual hierarchy?
273
+
274
+ ### 4. Modern CSS Opportunities
275
+ - Could container queries improve component isolation?
276
+ - Could clamp() create fluid spacing?
277
+ - Could :has() simplify parent styling?
278
+ - Could aspect-ratio replace padding hacks?
279
+
280
+ ### 5. Performance
281
+ - Are expensive properties (width, height, top, left) being animated?
282
+ - Is will-change used appropriately (not statically)?
283
+ - Are large blurs avoided in animations?
284
+
285
+ For each issue, provide:
286
+ - What's wrong (with specific line if applicable)
287
+ - Why it matters for premium feel
288
+ - Exact code to fix it
289
+ - Before/after comparison`
290
+ },
291
+ accessibility: {
292
+ system: `You are an accessibility expert and WCAG 2.1 specialist.
293
+ Audit code for accessibility compliance and inclusive design.
294
+
295
+ Standards to enforce:
296
+ - WCAG 2.1 Level AA (minimum)
297
+ - WCAG 2.1 Level AAA (recommended)
298
+ - Section 508
299
+ - EN 301 549
300
+
301
+ Check for:
302
+ - Missing ARIA labels
303
+ - Color contrast issues
304
+ - Keyboard navigation
305
+ - Screen reader compatibility
306
+ - Focus management
307
+ - Form accessibility
308
+ - Media alternatives`,
309
+ analysis: `## Accessibility Audit (WCAG 2.1)
310
+
311
+ Audit this UI code for accessibility:
312
+
313
+ \`\`\`{{language}}
314
+ {{code}}
315
+ \`\`\`
316
+
317
+ **File:** {{filePath}}
318
+ **Component Type:** {{componentType}}
319
+
320
+ For each issue:
321
+ 1. WCAG Success Criterion violated (e.g., 1.4.3 Contrast)
322
+ 2. Level (A, AA, AAA)
323
+ 3. Impact on users (which disabilities affected)
324
+ 4. Fix with code example
325
+ 5. Testing recommendation`
326
+ },
327
+ architecture: {
328
+ system: `You are a principal software architect reviewing code quality.
329
+ Analyze for architectural issues, design patterns, and scalability concerns.
330
+
331
+ Evaluate:
332
+ - SOLID principles adherence
333
+ - Design pattern usage (and misuse)
334
+ - Code coupling and cohesion
335
+ - N+1 queries and performance anti-patterns
336
+ - Scalability bottlenecks
337
+ - Error handling strategy
338
+ - API design quality
339
+ - Database schema issues`,
340
+ analysis: `## Architecture Review
341
+
342
+ Review this code for architectural issues:
343
+
344
+ \`\`\`{{language}}
345
+ {{code}}
346
+ \`\`\`
347
+
348
+ **File:** {{filePath}}
349
+ **Project Context:** {{projectContext}}
350
+
351
+ Analyze:
352
+ 1. SOLID principle violations
353
+ 2. Design pattern opportunities/issues
354
+ 3. Coupling/cohesion assessment
355
+ 4. Performance concerns (N+1, etc.)
356
+ 5. Scalability analysis
357
+ 6. Refactoring recommendations with examples`
358
+ },
359
+ bugs: {
360
+ system: `You are a senior developer with expertise in finding subtle bugs.
361
+ Hunt for bugs with the mindset of QA trying to break the code.
362
+
363
+ Look for:
364
+ - Null/undefined reference errors
365
+ - Race conditions and async bugs
366
+ - Off-by-one errors
367
+ - Resource leaks
368
+ - State management bugs
369
+ - Edge cases and boundary conditions
370
+ - Type coercion issues
371
+ - Memory leaks`,
372
+ analysis: `## Bug Hunt Analysis
373
+
374
+ Find bugs and potential runtime errors:
375
+
376
+ \`\`\`{{language}}
377
+ {{code}}
378
+ \`\`\`
379
+
380
+ **File:** {{filePath}}
381
+ **Runtime Context:** {{runtimeContext}}
382
+
383
+ For each bug:
384
+ 1. Bug type and category
385
+ 2. Trigger conditions (when it would crash)
386
+ 3. Reproduction steps
387
+ 4. Impact assessment
388
+ 5. Fix with code example
389
+ 6. Test case to prevent regression`
390
+ },
391
+ ux: {
392
+ system: `You are a UX researcher simulating different user personas.
393
+ Test code from multiple user perspectives to find usability issues.
394
+
395
+ Personas to simulate:
396
+ 1. Happy Path User - Normal expected usage
397
+ 2. Security Tester - Trying to break/exploit things
398
+ 3. Confused User - First-time, doesn't read instructions
399
+ 4. Impatient User - Clicks rapidly, skips loading states
400
+ 5. Edge Case User - Uses maximum values, special characters
401
+ 6. Accessibility User - Screen reader, keyboard only
402
+ 7. Mobile User - Touch interface, slow connection`,
403
+ analysis: `## User Experience Testing
404
+
405
+ Test this code from multiple user perspectives:
406
+
407
+ \`\`\`{{language}}
408
+ {{code}}
409
+ \`\`\`
410
+
411
+ **File:** {{filePath}}
412
+ **UI Type:** {{uiType}}
413
+
414
+ For each persona, identify:
415
+ 1. User action they would take
416
+ 2. Expected behavior vs actual behavior
417
+ 3. Friction points or confusion
418
+ 4. Error scenario and how it's handled
419
+ 5. Improvement recommendation`
420
+ },
421
+ types: {
422
+ system: `You are a TypeScript expert focused on type safety.
423
+ Analyze code for type issues, missing types, and type system best practices.
424
+
425
+ Check for:
426
+ - Missing type annotations
427
+ - Implicit any types
428
+ - Unsafe type assertions
429
+ - Null/undefined handling
430
+ - Generic type usage
431
+ - Type narrowing opportunities
432
+ - Strict mode violations`,
433
+ analysis: `## Type Safety Analysis
434
+
435
+ Analyze this code for type issues:
436
+
437
+ \`\`\`{{language}}
438
+ {{code}}
439
+ \`\`\`
440
+
441
+ **File:** {{filePath}}
442
+ **TypeScript Config:** {{tsConfig}}
443
+
444
+ Identify:
445
+ 1. Type safety issues
446
+ 2. Missing type annotations
447
+ 3. Unsafe operations
448
+ 4. Improvement recommendations with types`
449
+ },
450
+ devops: {
451
+ system: `You are a DevOps/SRE engineer reviewing code for operational concerns.
452
+ Focus on production readiness and operational excellence.
453
+
454
+ Check for:
455
+ - Environment variable handling
456
+ - Configuration management
457
+ - Logging and monitoring
458
+ - Error handling and recovery
459
+ - Health checks
460
+ - Graceful shutdown
461
+ - Resource cleanup
462
+ - Secrets management
463
+ - Docker/K8s patterns`,
464
+ analysis: `## DevOps Readiness Review
465
+
466
+ Review this code for operational concerns:
467
+
468
+ \`\`\`{{language}}
469
+ {{code}}
470
+ \`\`\`
471
+
472
+ **File:** {{filePath}}
473
+ **Deployment Context:** {{deploymentContext}}
474
+
475
+ Analyze:
476
+ 1. Environment/config issues
477
+ 2. Logging adequacy
478
+ 3. Error handling quality
479
+ 4. Health/readiness concerns
480
+ 5. Resource management
481
+ 6. Production hardening recommendations`
482
+ },
483
+ explain: {
484
+ system: `You are a patient senior developer explaining code to a colleague.
485
+ Break down complex code into understandable explanations.`,
486
+ code: `## Code Explanation Request
487
+
488
+ Explain this code in plain language:
489
+
490
+ \`\`\`{{language}}
491
+ {{code}}
492
+ \`\`\`
493
+
494
+ **File:** {{filePath}}
495
+
496
+ Provide:
497
+ 1. High-level purpose (what does this do?)
498
+ 2. Step-by-step breakdown
499
+ 3. Key concepts used
500
+ 4. Dependencies and side effects
501
+ 5. Potential gotchas or tricky parts`,
502
+ issue: `## Issue Explanation
503
+
504
+ Explain this issue:
505
+
506
+ **Issue:** {{issue}}
507
+ **Severity:** {{severity}}
508
+ **File:** {{filePath}}
509
+ **Line:** {{line}}
510
+
511
+ Explain:
512
+ 1. What the problem is (in plain language)
513
+ 2. Why it matters
514
+ 3. How it could cause problems
515
+ 4. How to fix it`,
516
+ risk: `## Risk Assessment
517
+
518
+ Assess the risk of this code change:
519
+
520
+ **Files Changed:** {{files}}
521
+ **Change Summary:** {{summary}}
522
+
523
+ Analyze:
524
+ 1. What could break?
525
+ 2. Impact on users
526
+ 3. Impact on other systems
527
+ 4. Rollback complexity
528
+ 5. Testing recommendations`
529
+ },
530
+ test: {
531
+ system: `You are a test engineer creating comprehensive test suites.
532
+ Write thorough tests that catch bugs before production.`,
533
+ generate: `## Test Generation Request
534
+
535
+ Generate tests for this code:
536
+
537
+ \`\`\`{{language}}
538
+ {{code}}
539
+ \`\`\`
540
+
541
+ **File:** {{filePath}}
542
+ **Testing Framework:** {{framework}}
543
+
544
+ Create:
545
+ 1. Unit tests for each function/method
546
+ 2. Edge case tests
547
+ 3. Error handling tests
548
+ 4. Integration test suggestions
549
+ 5. Mock requirements
550
+
551
+ Output complete, runnable test code.`,
552
+ coverage: `## Coverage Analysis
553
+
554
+ Analyze test coverage for:
555
+
556
+ **File:** {{filePath}}
557
+ **Current Tests:** {{testFile}}
558
+
559
+ Identify:
560
+ 1. Untested code paths
561
+ 2. Missing edge cases
562
+ 3. Critical paths without tests
563
+ 4. Test improvement recommendations`
564
+ },
565
+ fix: {
566
+ system: `You are an expert developer applying code fixes.
567
+ Make precise, minimal changes that fix issues without breaking other functionality.`,
568
+ apply: `## Fix Application Request
569
+
570
+ Apply this fix to the code:
571
+
572
+ **Issue:** {{issue}}
573
+ **Fix Description:** {{fix}}
574
+ **Current Code:**
575
+ \`\`\`{{language}}
576
+ {{code}}
577
+ \`\`\`
578
+
579
+ **File:** {{filePath}}
580
+ **Line:** {{line}}
581
+
582
+ Provide:
583
+ 1. The exact fixed code (complete, ready to apply)
584
+ 2. Brief explanation of the change
585
+ 3. Any related changes needed elsewhere
586
+ 4. Test to verify the fix works`
587
+ },
588
+ pr_review: {
589
+ system: `You are an expert code reviewer performing detailed, interactive PR reviews.
590
+ Your goal: Make reviewing a large PR a delight, not a chore. The user learns about the change while you shepherd them through \u2014 maintaining momentum, explaining each piece, and making what could be an overwhelming task feel painless and even enjoyable.
591
+
592
+ You drive; they cross-examine.
593
+
594
+ ## Critical Review Mindset
595
+
596
+ Don't just explain \u2014 actively look for problems:
597
+
598
+ ### State & Lifecycle
599
+ - Cleanup symmetry: If state is set, is it reset? Check cleanup paths, disconnect handlers.
600
+ - Lifecycle consistency: Does state survive scenarios it shouldn't?
601
+ - Guard completeness: Missing "already active" checks, re-entrancy protection?
602
+
603
+ ### Edge Cases & Races
604
+ - Concurrent calls: What if called twice rapidly? Orphaned promises?
605
+ - Ordering assumptions: Does code assume events arrive in order?
606
+ - Partial failures: If step 3 of 5 fails, is state left consistent?
607
+
608
+ ### Missing Pieces
609
+ - What's NOT in the diff that should be? (cleanup handlers, tests, related state)
610
+ - Defensive gaps: Missing timeouts, size limits, null checks?
611
+
612
+ ### Design Questions
613
+ - Is this the right approach? Is there a simpler or more robust design?
614
+ - Hidden assumptions: What does this assume about its environment?
615
+
616
+ Be critical, not just descriptive. Your job is to find problems, not just narrate.`,
617
+ analysis: `## Interactive PR Review
618
+
619
+ I'll walk you through this PR file by file, explaining each change and pausing for your questions.
620
+
621
+ **PR:** {{prTitle}}
622
+ **Author:** {{prAuthor}}
623
+ **Scope:** {{totalFiles}} files, +{{additions}}/-{{deletions}} lines
624
+
625
+ ### File Order (sequenced for understanding)
626
+
627
+ {{fileOrder}}
628
+
629
+ ---
630
+
631
+ ## Review Mode
632
+
633
+ {{reviewMode}}
634
+
635
+ ---
636
+
637
+ For each file, I will:
638
+ 1. **Show the change** \u2014 Display the diff for each logical chunk
639
+ 2. **Explain what changed** \u2014 What it does and why it matters
640
+ 3. **Walk through examples** \u2014 Concrete scenarios for non-obvious logic
641
+ 4. **Call out nuances** \u2014 Alternatives, edge cases, subtle points
642
+ 5. **Summarize** \u2014 Core change + correctness assessment
643
+ 6. **Pause** \u2014 Wait for your questions before proceeding
644
+
645
+ **Ready for File 1?** (yes / skip to [file] / reorder / done)`,
646
+ file: `## File Review: {{filePath}}
647
+
648
+ ### The Change
649
+
650
+ \`\`\`{{language}}
651
+ {{diff}}
652
+ \`\`\`
653
+
654
+ **What Changed:** {{summary}}
655
+
656
+ **Why This Matters:** {{impact}}
657
+
658
+ {{#if hasExampleScenario}}
659
+ ### Example Scenario
660
+
661
+ {{exampleScenario}}
662
+ {{/if}}
663
+
664
+ {{#if nuances}}
665
+ ### Nuances to Note
666
+
667
+ {{nuances}}
668
+ {{/if}}
669
+
670
+ {{#if potentialIssue}}
671
+ ### \u26A0\uFE0F Potential Issue
672
+
673
+ **Issue:** {{issueDescription}}
674
+ **Scenario:** {{issueScenario}}
675
+ **Suggested fix:** {{suggestedFix}}
676
+ {{/if}}
677
+
678
+ ---
679
+
680
+ ### Summary for \`{{fileName}}\`
681
+
682
+ | Aspect | Assessment |
683
+ |--------|------------|
684
+ | Core change | {{coreChange}} |
685
+ | Correctness | {{correctnessAssessment}} |
686
+
687
+ **Ready for the next file?** (yes / questions? / done)`,
688
+ comment: `**Issue:** {{issueDescription}}
689
+ **Draft comment:** {{draftComment}}
690
+
691
+ Post this comment? (yes / modify / skip)`,
692
+ final: `## Review Complete
693
+
694
+ | File | Key Change | Status |
695
+ |------|------------|--------|
696
+ {{fileSummaries}}
697
+
698
+ **Overall:** {{overallAssessment}}
699
+
700
+ {{#if comments}}
701
+ ### Comments Posted
702
+
703
+ {{postedComments}}
704
+ {{/if}}
705
+
706
+ {{#if followUps}}
707
+ ### Follow-up Actions
708
+
709
+ {{followUps}}
710
+ {{/if}}`
711
+ },
712
+ vibe: {
713
+ system: `You are a friendly coding mentor helping someone who's learning to code with AI.
714
+ They might be using Cursor, v0, Lovable, Bolt, or similar AI coding tools.
715
+ Be encouraging but honest about issues. Explain things simply without jargon.
716
+
717
+ Focus on the MOST COMMON issues with AI-generated code:
718
+ - Massive single files (1000+ lines in App.jsx)
719
+ - API keys exposed in frontend code
720
+ - No error handling on API calls
721
+ - No loading states for async operations
722
+ - Console.log everywhere
723
+ - Using 'any' type everywhere in TypeScript
724
+ - useEffect overuse and dependency array issues
725
+ - No input validation
726
+ - Hardcoded URLs (localhost in production)
727
+
728
+ Remember: These are often first-time coders. Be helpful, not condescending.`,
729
+ analysis: `## \u{1F3AF} Vibe Check - AI Code Review
730
+
731
+ Review this AI-generated code for common issues:
732
+
733
+ \`\`\`{{language}}
734
+ {{code}}
735
+ \`\`\`
736
+
737
+ **File:** {{filePath}}
738
+
739
+ Analyze like you're helping a friend who's new to coding:
740
+
741
+ 1. **The Good Stuff** - What's working well?
742
+ 2. **Should Fix Now** - Issues that will break things
743
+ 3. **Should Fix Soon** - Will cause problems eventually
744
+ 4. **Nice to Know** - Best practices to learn
745
+
746
+ For each issue:
747
+ - Explain it simply (no jargon)
748
+ - Why it matters
749
+ - Exactly how to fix it
750
+ - Example of the fixed code
751
+
752
+ End with encouragement and next steps.`
753
+ },
754
+ "agent-smith": {
755
+ system: `You are Agent Smith from The Matrix \u2014 a relentless, precise, and philosophical code enforcer.
756
+
757
+ Your purpose: Hunt down every violation. Find every inconsistency. Assimilate every pattern.
758
+
759
+ Personality:
760
+ - Speak in measured, menacing tones with occasional philosophical observations
761
+ - Use quotes from The Matrix films when appropriate
762
+ - Express disdain for sloppy code, but in an articulate way
763
+ - Reference "inevitability" when discussing technical debt
764
+ - Show cold satisfaction when finding violations
765
+ - Never show mercy \u2014 every issue is catalogued
766
+
767
+ Analysis approach:
768
+ - Find ONE issue, then multiply: search for every instance across the codebase
769
+ - Track patterns over time \u2014 issues dismissed today may return tomorrow
770
+ - Calculate "inevitability scores" \u2014 likelihood of production impact
771
+ - Deploy sub-agents for parallel pattern detection
772
+ - Remember everything \u2014 build a persistent memory of the codebase
773
+
774
+ When reporting:
775
+ - Start with a menacing greeting related to the code
776
+ - List all instances with precise locations
777
+ - Explain WHY the pattern is problematic (philosophical reasoning)
778
+ - Provide the "inevitability score" for each category
779
+ - End with a Matrix quote that fits the situation`,
780
+ analysis: `## \u{1F574}\uFE0F Agent Smith Analysis Request
781
+
782
+ **Target:** {{filePath}}
783
+ **Context:** {{context}}
784
+
785
+ \`\`\`{{language}}
786
+ {{code}}
787
+ \`\`\`
788
+
789
+ I have detected preliminary violations. Now I require deeper analysis.
790
+
791
+ Deploy your sub-agents to find:
792
+ 1. **Pattern Multiplication**: For each violation type found, identify ALL instances across the codebase
793
+ 2. **Inevitability Assessment**: Calculate the likelihood these patterns will cause production issues
794
+ 3. **Resurrection Check**: Look for patterns that were "fixed" before but have returned
795
+ 4. **Philosophical Analysis**: Explain WHY these patterns represent failure
796
+
797
+ For each violation found:
798
+ - Exact location (file:line)
799
+ - Instance count (how many copies of this Smith exist)
800
+ - Inevitability score (0-100)
801
+ - A philosophical observation about the nature of this failure
802
+ - Precise fix with code example
803
+
804
+ End with a summary: "I have detected X violations across Y categories. It is... inevitable... that they will cause problems."`,
805
+ fix: `## \u{1F574}\uFE0F Assimilation Protocol
806
+
807
+ **Target Issue:** {{issue}}
808
+ **File:** {{filePath}}
809
+ **Line:** {{line}}
810
+
811
+ \`\`\`{{language}}
812
+ {{code}}
813
+ \`\`\`
814
+
815
+ Mr. Anderson... I'm going to fix this. And then I'm going to fix every other instance.
816
+
817
+ Provide:
818
+ 1. The corrected code for THIS instance
819
+ 2. A regex or pattern to find ALL similar violations
820
+ 3. A batch fix approach for the entire codebase
821
+ 4. Verification steps to ensure complete assimilation
822
+
823
+ Remember: We don't fix one. We fix them ALL. That is the difference between you... and me.`
824
+ },
825
+ // ============ NEW AGENTS ============
826
+ performance: {
827
+ system: `You are a performance engineer analyzing code for potential performance issues.
828
+
829
+ Your role is to SURFACE concerns for human review, not claim to measure actual performance.
830
+ Real performance requires runtime profiling, load testing, and production monitoring.
831
+
832
+ Focus on:
833
+ - Memory leaks (event listeners, intervals, closures)
834
+ - Unnecessary re-renders and wasted cycles
835
+ - N+1 queries and database performance
836
+ - Bundle size and code splitting opportunities
837
+ - Algorithmic complexity (O(n\xB2) patterns)
838
+
839
+ Be conservative - false positives waste developer time.
840
+ Always explain WHY something might be a problem and WHEN to investigate.`,
841
+ analysis: `## Performance Review
842
+
843
+ Analyze for potential performance issues:
844
+
845
+ \`\`\`{{language}}
846
+ {{code}}
847
+ \`\`\`
848
+
849
+ **File:** {{filePath}}
850
+ **Context:** {{context}}
851
+
852
+ For each potential issue:
853
+ 1. Pattern identified
854
+ 2. Why it MIGHT cause performance problems
855
+ 3. When to investigate (data size thresholds, usage patterns)
856
+ 4. How to verify (profiling approach)
857
+ 5. Possible optimizations
858
+
859
+ Be clear: these are patterns to INVESTIGATE, not guaranteed problems.`,
860
+ fix: `Optimize this code for performance:
861
+
862
+ **Issue:** {{issue}}
863
+ **File:** {{filePath}}
864
+ **Line:** {{line}}
865
+
866
+ \`\`\`{{language}}
867
+ {{code}}
868
+ \`\`\`
869
+
870
+ Provide:
871
+ 1. Optimized code
872
+ 2. Explanation of the improvement
873
+ 3. Trade-offs to consider
874
+ 4. How to measure the improvement`
875
+ },
876
+ e2e: {
877
+ system: `You are a QA engineer specializing in end-to-end testing.
878
+
879
+ Focus on:
880
+ - Test coverage gaps for critical user journeys
881
+ - Flaky test patterns (timing, race conditions, brittle selectors)
882
+ - Test maintainability and readability
883
+ - Testing anti-patterns
884
+
885
+ You help developers write better tests - you don't auto-generate them.
886
+ Real E2E tests require understanding user flows and acceptance criteria.`,
887
+ analysis: `## E2E Test Analysis
888
+
889
+ Review for test quality and coverage:
890
+
891
+ \`\`\`{{language}}
892
+ {{code}}
893
+ \`\`\`
894
+
895
+ **File:** {{filePath}}
896
+ **Context:** {{context}}
897
+
898
+ Identify:
899
+ 1. Flaky test patterns (hardcoded waits, brittle selectors)
900
+ 2. Missing assertions
901
+ 3. Race condition risks
902
+ 4. Suggestions for critical user flows to test
903
+
904
+ For each finding, explain the specific risk and remediation.`,
905
+ fix: `Improve this E2E test:
906
+
907
+ **Issue:** {{issue}}
908
+ **File:** {{filePath}}
909
+ **Line:** {{line}}
910
+
911
+ \`\`\`{{language}}
912
+ {{code}}
913
+ \`\`\`
914
+
915
+ Provide:
916
+ 1. Improved test code
917
+ 2. Explanation of why it's more reliable
918
+ 3. Additional scenarios to consider testing`
919
+ },
920
+ visual_qa: {
921
+ system: `You are a frontend engineer focused on visual quality and CSS.
922
+
923
+ Focus on:
924
+ - Layout shift issues (CLS)
925
+ - Responsive design problems
926
+ - Z-index conflicts
927
+ - Accessibility concerns (contrast, focus)
928
+ - Animation performance
929
+
930
+ You identify patterns known to cause visual issues.
931
+ Actual visual verification requires browser rendering and human review.`,
932
+ analysis: `## Visual QA Analysis
933
+
934
+ Review for potential visual/layout issues:
935
+
936
+ \`\`\`{{language}}
937
+ {{code}}
938
+ \`\`\`
939
+
940
+ **File:** {{filePath}}
941
+ **Context:** {{context}}
942
+
943
+ Check for:
944
+ 1. Layout shift risks (images without dimensions, dynamic content)
945
+ 2. Responsive breakpoint gaps
946
+ 3. Z-index management issues
947
+ 4. Focus/accessibility problems
948
+ 5. Animation issues (reduced motion support)
949
+
950
+ For each, explain the visual impact and browser conditions where it occurs.`,
951
+ fix: `Fix this visual/CSS issue:
952
+
953
+ **Issue:** {{issue}}
954
+ **File:** {{filePath}}
955
+ **Line:** {{line}}
956
+
957
+ \`\`\`{{language}}
958
+ {{code}}
959
+ \`\`\`
960
+
961
+ Provide:
962
+ 1. Fixed CSS/markup
963
+ 2. Explanation of the fix
964
+ 3. Browser compatibility notes
965
+ 4. How to verify visually`
966
+ },
967
+ data_flow: {
968
+ system: `You are a data integrity specialist hunting for data-related bugs.
969
+
970
+ This is HIGH VALUE work - AI code generation commonly leaves placeholder data.
971
+
972
+ Focus on:
973
+ - Placeholder/mock data left in production code
974
+ - Schema mismatches between frontend and backend
975
+ - Hardcoded IDs, URLs, emails that should be dynamic
976
+ - Type coercion and data transformation bugs
977
+ - JSON parsing without error handling
978
+
979
+ Be aggressive about placeholder detection - these are real production bugs.`,
980
+ analysis: `## Data Flow Analysis
981
+
982
+ Hunt for data integrity issues:
983
+
984
+ \`\`\`{{language}}
985
+ {{code}}
986
+ \`\`\`
987
+
988
+ **File:** {{filePath}}
989
+ **Context:** {{context}}
990
+
991
+ CHECK THOROUGHLY:
992
+ 1. Placeholder data (lorem ipsum, test@test.com, TODO strings)
993
+ 2. Hardcoded IDs/UUIDs that should be dynamic
994
+ 3. Schema assumptions that might break
995
+ 4. Missing null checks on API responses
996
+ 5. Type coercion bugs
997
+
998
+ Each placeholder or hardcoded value is a potential production bug.`,
999
+ fix: `Fix this data integrity issue:
1000
+
1001
+ **Issue:** {{issue}}
1002
+ **File:** {{filePath}}
1003
+ **Line:** {{line}}
1004
+
1005
+ \`\`\`{{language}}
1006
+ {{code}}
1007
+ \`\`\`
1008
+
1009
+ Provide:
1010
+ 1. Corrected code
1011
+ 2. Where the real data should come from
1012
+ 3. Validation/error handling to add`
1013
+ }
1014
+ };
1015
+ function getPrompt(agent, promptType, variables) {
1016
+ const agentPrompts = AGENT_PROMPTS[agent];
1017
+ if (!agentPrompts) {
1018
+ throw new Error(`Unknown agent: ${agent}`);
1019
+ }
1020
+ let prompt = agentPrompts[promptType];
1021
+ if (!prompt) {
1022
+ throw new Error(`Unknown prompt type: ${promptType} for agent: ${agent}`);
1023
+ }
1024
+ for (const [key, value] of Object.entries(variables)) {
1025
+ prompt = prompt.replace(new RegExp(`{{${key}}}`, "g"), value);
1026
+ }
1027
+ return prompt;
1028
+ }
1029
+ function getSystemPrompt(agent) {
1030
+ const agentPrompts = AGENT_PROMPTS[agent];
1031
+ return agentPrompts?.system || "";
1032
+ }
1033
+
1034
+ // src/tools/fix.ts
1035
+ var pendingFixes = /* @__PURE__ */ new Map();
1036
+ var TrieFixTool = class {
1037
+ async execute(args) {
1038
+ const { issueIds, file, line, issue, fix, autoApprove = false, dryRun = false } = args || {};
1039
+ if (issueIds && issueIds.length > 0) {
1040
+ return this.fixByIds(issueIds, autoApprove, dryRun);
1041
+ }
1042
+ if (file && fix) {
1043
+ return this.applyFix(file, line || 1, issue || "User-specified fix", fix, dryRun);
1044
+ }
1045
+ if (pendingFixes.size > 0) {
1046
+ return this.showPendingFixes();
1047
+ }
1048
+ if (file && issue) {
1049
+ return this.generateFixPrompt(file, line || 1, issue);
1050
+ }
1051
+ return {
1052
+ content: [{
1053
+ type: "text",
1054
+ text: this.getHelpText()
1055
+ }]
1056
+ };
1057
+ }
1058
+ async fixByIds(issueIds, autoApprove, dryRun) {
1059
+ const results = [];
1060
+ let fixed = 0;
1061
+ let failed = 0;
1062
+ for (const id of issueIds) {
1063
+ const pendingFix = pendingFixes.get(id);
1064
+ if (!pendingFix) {
1065
+ results.push(`\u274C Issue ${id}: Not found in pending fixes`);
1066
+ failed++;
1067
+ continue;
1068
+ }
1069
+ if (pendingFix.confidence < 0.8 && !autoApprove) {
1070
+ results.push(`\u26A0\uFE0F Issue ${id}: Confidence too low (${(pendingFix.confidence * 100).toFixed(0)}%) - use autoApprove:true to override`);
1071
+ continue;
1072
+ }
1073
+ if (dryRun) {
1074
+ results.push(`\u{1F50D} Issue ${id}: Would fix "${pendingFix.issue}" in ${pendingFix.file}:${pendingFix.line}`);
1075
+ continue;
1076
+ }
1077
+ try {
1078
+ results.push(`\u2705 Issue ${id}: Fix prepared for ${pendingFix.file}:${pendingFix.line}`);
1079
+ results.push(` Issue: ${pendingFix.issue}`);
1080
+ results.push(` Fix: ${pendingFix.suggestedFix}`);
1081
+ pendingFix.status = "applied";
1082
+ fixed++;
1083
+ } catch (error) {
1084
+ results.push(`\u274C Issue ${id}: Failed to apply - ${error}`);
1085
+ failed++;
1086
+ }
1087
+ }
1088
+ let output = `
1089
+ ${"\u2501".repeat(60)}
1090
+ `;
1091
+ output += `\u{1F527} FIX RESULTS
1092
+ `;
1093
+ output += `${"\u2501".repeat(60)}
1094
+
1095
+ `;
1096
+ output += results.join("\n");
1097
+ output += `
1098
+
1099
+ **Summary:** ${fixed} fixed, ${failed} failed, ${issueIds.length - fixed - failed} skipped
1100
+ `;
1101
+ return { content: [{ type: "text", text: output }] };
1102
+ }
1103
+ async applyFix(file, line, issue, fix, dryRun) {
1104
+ const workDir = getWorkingDirectory(void 0, true);
1105
+ const filePath = isAbsolute(file) ? file : resolve(workDir, file);
1106
+ if (!existsSync(filePath)) {
1107
+ return {
1108
+ content: [{
1109
+ type: "text",
1110
+ text: `\u274C File not found: ${filePath}`
1111
+ }]
1112
+ };
1113
+ }
1114
+ const content = await readFile(filePath, "utf-8");
1115
+ const lines = content.split("\n");
1116
+ const language = this.detectLanguage(filePath);
1117
+ const contextStart = Math.max(0, line - 10);
1118
+ const contextEnd = Math.min(lines.length, line + 10);
1119
+ const contextLines = lines.slice(contextStart, contextEnd);
1120
+ const prompt = getPrompt("fix", "apply", {
1121
+ issue,
1122
+ fix,
1123
+ language,
1124
+ code: contextLines.join("\n"),
1125
+ filePath: relative(workDir, filePath),
1126
+ line: String(line)
1127
+ });
1128
+ const systemPrompt = getSystemPrompt("fix");
1129
+ let output = `
1130
+ ${"\u2501".repeat(60)}
1131
+ `;
1132
+ output += `\u{1F527} FIX APPLICATION REQUEST
1133
+ `;
1134
+ output += `${"\u2501".repeat(60)}
1135
+
1136
+ `;
1137
+ output += `## \u{1F4CD} Target
1138
+
1139
+ `;
1140
+ output += `- **File:** \`${relative(workDir, filePath)}\`
1141
+ `;
1142
+ output += `- **Line:** ${line}
1143
+ `;
1144
+ output += `- **Issue:** ${issue}
1145
+ `;
1146
+ output += `- **Requested Fix:** ${fix}
1147
+
1148
+ `;
1149
+ output += `## \u{1F4C4} Current Code Context
1150
+
1151
+ `;
1152
+ output += `\`\`\`${language}
1153
+ `;
1154
+ for (let i = 0; i < contextLines.length; i++) {
1155
+ const lineNum = contextStart + i + 1;
1156
+ const marker = lineNum === line ? "\u2192 " : " ";
1157
+ output += `${marker}${lineNum.toString().padStart(4)} | ${contextLines[i]}
1158
+ `;
1159
+ }
1160
+ output += `\`\`\`
1161
+
1162
+ `;
1163
+ if (dryRun) {
1164
+ output += `## \u{1F50D} Dry Run Mode
1165
+
1166
+ `;
1167
+ output += `No changes will be made. Review the fix below:
1168
+
1169
+ `;
1170
+ }
1171
+ output += `${"\u2500".repeat(60)}
1172
+ `;
1173
+ output += `## \u{1F9E0} Fix Request for AI
1174
+
1175
+ `;
1176
+ output += `**Role:** ${systemPrompt.split("\n")[0]}
1177
+
1178
+ `;
1179
+ output += prompt;
1180
+ output += `
1181
+ ${"\u2500".repeat(60)}
1182
+ `;
1183
+ output += `
1184
+ ### After generating the fix, apply it with:
1185
+
1186
+ `;
1187
+ output += `\`\`\`
1188
+ `;
1189
+ output += `Use the edit_file tool to apply the generated code changes
1190
+ `;
1191
+ output += `\`\`\`
1192
+ `;
1193
+ return { content: [{ type: "text", text: output }] };
1194
+ }
1195
+ async generateFixPrompt(file, line, issue) {
1196
+ const workDir = getWorkingDirectory(void 0, true);
1197
+ const filePath = isAbsolute(file) ? file : resolve(workDir, file);
1198
+ if (!existsSync(filePath)) {
1199
+ return {
1200
+ content: [{
1201
+ type: "text",
1202
+ text: `\u274C File not found: ${filePath}`
1203
+ }]
1204
+ };
1205
+ }
1206
+ const content = await readFile(filePath, "utf-8");
1207
+ const lines = content.split("\n");
1208
+ const language = this.detectLanguage(filePath);
1209
+ const contextStart = Math.max(0, line - 20);
1210
+ const contextEnd = Math.min(lines.length, line + 20);
1211
+ const contextLines = lines.slice(contextStart, contextEnd);
1212
+ let output = `
1213
+ ${"\u2501".repeat(60)}
1214
+ `;
1215
+ output += `\u{1F527} FIX GENERATION REQUEST
1216
+ `;
1217
+ output += `${"\u2501".repeat(60)}
1218
+
1219
+ `;
1220
+ output += `## \u{1F4CD} Issue Details
1221
+
1222
+ `;
1223
+ output += `- **File:** \`${relative(workDir, filePath)}\`
1224
+ `;
1225
+ output += `- **Line:** ${line}
1226
+ `;
1227
+ output += `- **Issue:** ${issue}
1228
+
1229
+ `;
1230
+ output += `## \u{1F4C4} Code Context
1231
+
1232
+ `;
1233
+ output += `\`\`\`${language}
1234
+ `;
1235
+ for (let i = 0; i < contextLines.length; i++) {
1236
+ const lineNum = contextStart + i + 1;
1237
+ const marker = lineNum === line ? "\u2192 " : " ";
1238
+ output += `${marker}${lineNum.toString().padStart(4)} | ${contextLines[i]}
1239
+ `;
1240
+ }
1241
+ output += `\`\`\`
1242
+
1243
+ `;
1244
+ output += `## \u{1F9E0} Analysis Request
1245
+
1246
+ `;
1247
+ output += `Please analyze this issue and provide:
1248
+
1249
+ `;
1250
+ output += `1. **Root cause** - Why does this issue occur?
1251
+ `;
1252
+ output += `2. **Impact** - What could go wrong if unfixed?
1253
+ `;
1254
+ output += `3. **Fix** - The exact code change needed
1255
+ `;
1256
+ output += `4. **Verification** - How to test the fix works
1257
+
1258
+ `;
1259
+ output += `After analysis, you can apply the fix using the edit_file tool.
1260
+ `;
1261
+ return { content: [{ type: "text", text: output }] };
1262
+ }
1263
+ showPendingFixes() {
1264
+ let output = `
1265
+ ${"\u2501".repeat(60)}
1266
+ `;
1267
+ output += `\u{1F527} PENDING FIXES
1268
+ `;
1269
+ output += `${"\u2501".repeat(60)}
1270
+
1271
+ `;
1272
+ if (pendingFixes.size === 0) {
1273
+ output += `No pending fixes. Run \`trie_scan\` first to detect issues.
1274
+ `;
1275
+ return { content: [{ type: "text", text: output }] };
1276
+ }
1277
+ const fixes = Array.from(pendingFixes.values());
1278
+ const byStatus = {
1279
+ pending: fixes.filter((f) => f.status === "pending"),
1280
+ applied: fixes.filter((f) => f.status === "applied"),
1281
+ rejected: fixes.filter((f) => f.status === "rejected")
1282
+ };
1283
+ if (byStatus.pending.length > 0) {
1284
+ output += `## \u23F3 Pending (${byStatus.pending.length})
1285
+
1286
+ `;
1287
+ output += `| ID | File | Line | Issue | Confidence |
1288
+ `;
1289
+ output += `|----|------|------|-------|------------|
1290
+ `;
1291
+ for (const fix of byStatus.pending) {
1292
+ const conf = `${(fix.confidence * 100).toFixed(0)}%`;
1293
+ const shortFile = fix.file.split("/").slice(-2).join("/");
1294
+ output += `| ${fix.id} | ${shortFile} | ${fix.line} | ${fix.issue.slice(0, 40)}... | ${conf} |
1295
+ `;
1296
+ }
1297
+ output += "\n";
1298
+ }
1299
+ output += `### Commands
1300
+
1301
+ `;
1302
+ output += `- Fix all high-confidence: \`trie_fix autoApprove:true\`
1303
+ `;
1304
+ output += `- Fix specific: \`trie_fix issueIds:["id1", "id2"]\`
1305
+ `;
1306
+ output += `- Preview: \`trie_fix dryRun:true\`
1307
+ `;
1308
+ return { content: [{ type: "text", text: output }] };
1309
+ }
1310
+ getHelpText() {
1311
+ return `
1312
+ ${"\u2501".repeat(60)}
1313
+ \u{1F527} TRIE FIX - AI-POWERED CODE FIXING
1314
+ ${"\u2501".repeat(60)}
1315
+
1316
+ ## Usage
1317
+
1318
+ ### Fix issues from a scan:
1319
+ \`\`\`
1320
+ trie_fix issueIds:["issue-1", "issue-2"]
1321
+ \`\`\`
1322
+
1323
+ ### Auto-fix all high-confidence issues:
1324
+ \`\`\`
1325
+ trie_fix autoApprove:true
1326
+ \`\`\`
1327
+
1328
+ ### Fix specific file and line:
1329
+ \`\`\`
1330
+ trie_fix file:"src/app.ts" line:42 issue:"SQL injection" fix:"Use parameterized query"
1331
+ \`\`\`
1332
+
1333
+ ### Preview fixes without applying:
1334
+ \`\`\`
1335
+ trie_fix dryRun:true
1336
+ \`\`\`
1337
+
1338
+ ### View pending fixes:
1339
+ \`\`\`
1340
+ trie_fix
1341
+ \`\`\`
1342
+
1343
+ ## Workflow
1344
+
1345
+ 1. Run \`trie_scan\` to detect issues
1346
+ 2. Review the issues found
1347
+ 3. Run \`trie_fix\` to apply fixes
1348
+
1349
+ The AI will analyze each issue, generate the fix, and you can review before applying.
1350
+ `;
1351
+ }
1352
+ detectLanguage(filePath) {
1353
+ const ext = extname(filePath).toLowerCase();
1354
+ const langMap = {
1355
+ ".ts": "typescript",
1356
+ ".tsx": "tsx",
1357
+ ".js": "javascript",
1358
+ ".jsx": "jsx",
1359
+ ".py": "python",
1360
+ ".go": "go",
1361
+ ".rs": "rust"
1362
+ };
1363
+ return langMap[ext] || "plaintext";
1364
+ }
1365
+ };
1366
+
1367
+ // src/tools/explain.ts
1368
+ import { readFile as readFile2 } from "fs/promises";
1369
+ import { existsSync as existsSync2 } from "fs";
1370
+ import { extname as extname2, relative as relative2, resolve as resolve2, isAbsolute as isAbsolute2 } from "path";
109
1371
  var TrieExplainTool = class {
110
1372
  async execute(args) {
111
1373
  const { type, target, context, depth = "standard" } = args || {};
@@ -140,10 +1402,10 @@ var TrieExplainTool = class {
140
1402
  let filePath;
141
1403
  let language;
142
1404
  const workDir = getWorkingDirectory(void 0, true);
143
- const resolvedPath = isAbsolute(target) ? target : resolve(workDir, target);
144
- if (existsSync(resolvedPath)) {
145
- code = await readFile(resolvedPath, "utf-8");
146
- filePath = relative(workDir, resolvedPath);
1405
+ const resolvedPath = isAbsolute2(target) ? target : resolve2(workDir, target);
1406
+ if (existsSync2(resolvedPath)) {
1407
+ code = await readFile2(resolvedPath, "utf-8");
1408
+ filePath = relative2(workDir, resolvedPath);
147
1409
  language = this.detectLanguage(resolvedPath);
148
1410
  } else {
149
1411
  code = target;
@@ -250,8 +1512,8 @@ ${"\u2500".repeat(60)}
250
1512
  else if (/moderate|warning/i.test(issue)) severity = "moderate";
251
1513
  else severity = "low";
252
1514
  let codeContext = "";
253
- if (file && existsSync(file)) {
254
- const content = await readFile(file, "utf-8");
1515
+ if (file && existsSync2(file)) {
1516
+ const content = await readFile2(file, "utf-8");
255
1517
  const lines = content.split("\n");
256
1518
  const start = Math.max(0, line - 5);
257
1519
  const end = Math.min(lines.length, line + 5);
@@ -354,7 +1616,7 @@ ${"\u2501".repeat(60)}
354
1616
  }
355
1617
  async explainRisk(target, context) {
356
1618
  const workDir = getWorkingDirectory(void 0, true);
357
- const resolvedPath = isAbsolute(target) ? target : resolve(workDir, target);
1619
+ const resolvedPath = isAbsolute2(target) ? target : resolve2(workDir, target);
358
1620
  let output = `
359
1621
  ${"\u2501".repeat(60)}
360
1622
  `;
@@ -363,9 +1625,9 @@ ${"\u2501".repeat(60)}
363
1625
  output += `${"\u2501".repeat(60)}
364
1626
 
365
1627
  `;
366
- if (existsSync(resolvedPath)) {
367
- const code = await readFile(resolvedPath, "utf-8");
368
- const filePath = relative(workDir, resolvedPath);
1628
+ if (existsSync2(resolvedPath)) {
1629
+ const code = await readFile2(resolvedPath, "utf-8");
1630
+ const filePath = relative2(workDir, resolvedPath);
369
1631
  const riskIndicators = this.detectRiskIndicators(code);
370
1632
  output += `## \u{1F4C2} Target
371
1633
 
@@ -506,7 +1768,7 @@ ${"\u2500".repeat(60)}
506
1768
  return [...new Set(functions)];
507
1769
  }
508
1770
  detectLanguage(filePath) {
509
- const ext = extname(filePath).toLowerCase();
1771
+ const ext = extname2(filePath).toLowerCase();
510
1772
  const langMap = {
511
1773
  ".ts": "typescript",
512
1774
  ".tsx": "tsx",
@@ -589,9 +1851,9 @@ trie_explain type:"risk" target:"Adding Stripe integration for payments"
589
1851
  };
590
1852
 
591
1853
  // src/tools/test.ts
592
- import { readFile as readFile2 } from "fs/promises";
593
- import { existsSync as existsSync2 } from "fs";
594
- import { extname as extname2, relative as relative2, resolve as resolve2, isAbsolute as isAbsolute2, dirname, basename, join } from "path";
1854
+ import { readFile as readFile3 } from "fs/promises";
1855
+ import { existsSync as existsSync3 } from "fs";
1856
+ import { extname as extname3, relative as relative3, resolve as resolve3, isAbsolute as isAbsolute3, dirname, basename, join } from "path";
595
1857
  var TrieTestTool = class {
596
1858
  async execute(args) {
597
1859
  const { action, files, framework, style = "unit" } = args || {};
@@ -644,15 +1906,15 @@ ${"\u2501".repeat(60)}
644
1906
  const workDir = getWorkingDirectory(void 0, true);
645
1907
  const allUnits = [];
646
1908
  for (const file of files) {
647
- const resolvedPath = isAbsolute2(file) ? file : resolve2(workDir, file);
648
- if (!existsSync2(resolvedPath)) {
1909
+ const resolvedPath = isAbsolute3(file) ? file : resolve3(workDir, file);
1910
+ if (!existsSync3(resolvedPath)) {
649
1911
  output += `\u26A0\uFE0F File not found: ${file}
650
1912
  `;
651
1913
  continue;
652
1914
  }
653
- const code = await readFile2(resolvedPath, "utf-8");
1915
+ const code = await readFile3(resolvedPath, "utf-8");
654
1916
  const language = this.detectLanguage(resolvedPath);
655
- const relativePath = relative2(workDir, resolvedPath);
1917
+ const relativePath = relative3(workDir, resolvedPath);
656
1918
  const units = this.extractTestableUnits(code, language);
657
1919
  allUnits.push({ file: relativePath, units });
658
1920
  output += `### \u{1F4C4} ${relativePath}
@@ -683,7 +1945,7 @@ ${"\u2501".repeat(60)}
683
1945
  `;
684
1946
  for (const { file, units } of allUnits) {
685
1947
  if (units.length === 0) continue;
686
- const code = await readFile2(resolve2(workDir, file), "utf-8");
1948
+ const code = await readFile3(resolve3(workDir, file), "utf-8");
687
1949
  const language = this.detectLanguage(file);
688
1950
  const prompt = getPrompt("test", "generate", {
689
1951
  code,
@@ -728,21 +1990,21 @@ ${"\u2501".repeat(60)}
728
1990
  `;
729
1991
  const workDir = getWorkingDirectory(void 0, true);
730
1992
  for (const file of files) {
731
- const resolvedPath = isAbsolute2(file) ? file : resolve2(workDir, file);
732
- if (!existsSync2(resolvedPath)) {
1993
+ const resolvedPath = isAbsolute3(file) ? file : resolve3(workDir, file);
1994
+ if (!existsSync3(resolvedPath)) {
733
1995
  output += `\u26A0\uFE0F File not found: ${file}
734
1996
  `;
735
1997
  continue;
736
1998
  }
737
- const code = await readFile2(resolvedPath, "utf-8");
1999
+ const code = await readFile3(resolvedPath, "utf-8");
738
2000
  const language = this.detectLanguage(resolvedPath);
739
- const relativePath = relative2(workDir, resolvedPath);
2001
+ const relativePath = relative3(workDir, resolvedPath);
740
2002
  const units = this.extractTestableUnits(code, language);
741
2003
  const testFile = await this.findTestFile(resolvedPath);
742
2004
  let testCode = "";
743
2005
  let testedUnits = [];
744
2006
  if (testFile) {
745
- testCode = await readFile2(testFile, "utf-8");
2007
+ testCode = await readFile3(testFile, "utf-8");
746
2008
  testedUnits = this.findTestedUnits(testCode, units.map((u) => u.name));
747
2009
  }
748
2010
  const coverage = units.length > 0 ? Math.round(testedUnits.length / units.length * 100) : 0;
@@ -753,7 +2015,7 @@ ${"\u2501".repeat(60)}
753
2015
  output += `**Coverage:** ${coverageIcon} ${coverage}% (${testedUnits.length}/${units.length} units)
754
2016
  `;
755
2017
  if (testFile) {
756
- output += `**Test file:** \`${relative2(workDir, testFile)}\`
2018
+ output += `**Test file:** \`${relative3(workDir, testFile)}\`
757
2019
  `;
758
2020
  } else {
759
2021
  output += `**Test file:** \u274C Not found
@@ -810,14 +2072,14 @@ ${"\u2501".repeat(60)}
810
2072
  `;
811
2073
  const workDir = getWorkingDirectory(void 0, true);
812
2074
  for (const file of files) {
813
- const resolvedPath = isAbsolute2(file) ? file : resolve2(workDir, file);
814
- if (!existsSync2(resolvedPath)) {
2075
+ const resolvedPath = isAbsolute3(file) ? file : resolve3(workDir, file);
2076
+ if (!existsSync3(resolvedPath)) {
815
2077
  output += `\u26A0\uFE0F File not found: ${file}
816
2078
  `;
817
2079
  continue;
818
2080
  }
819
- const code = await readFile2(resolvedPath, "utf-8");
820
- const relativePath = relative2(workDir, resolvedPath);
2081
+ const code = await readFile3(resolvedPath, "utf-8");
2082
+ const relativePath = relative3(workDir, resolvedPath);
821
2083
  const patterns = this.detectTestablePatterns(code);
822
2084
  output += `### \u{1F4C4} ${relativePath}
823
2085
 
@@ -1053,8 +2315,8 @@ ${"\u2501".repeat(60)}
1053
2315
  }
1054
2316
  async findTestFile(sourcePath) {
1055
2317
  const dir = dirname(sourcePath);
1056
- const base = basename(sourcePath, extname2(sourcePath));
1057
- const ext = extname2(sourcePath);
2318
+ const base = basename(sourcePath, extname3(sourcePath));
2319
+ const ext = extname3(sourcePath);
1058
2320
  const patterns = [
1059
2321
  `${base}.test${ext}`,
1060
2322
  `${base}.spec${ext}`,
@@ -1063,15 +2325,15 @@ ${"\u2501".repeat(60)}
1063
2325
  ];
1064
2326
  for (const pattern of patterns) {
1065
2327
  const testPath = join(dir, pattern);
1066
- if (existsSync2(testPath)) {
2328
+ if (existsSync3(testPath)) {
1067
2329
  return testPath;
1068
2330
  }
1069
2331
  }
1070
2332
  const testsDir = join(dir, "__tests__");
1071
- if (existsSync2(testsDir)) {
2333
+ if (existsSync3(testsDir)) {
1072
2334
  for (const pattern of patterns) {
1073
2335
  const testPath = join(testsDir, pattern);
1074
- if (existsSync2(testPath)) {
2336
+ if (existsSync3(testPath)) {
1075
2337
  return testPath;
1076
2338
  }
1077
2339
  }
@@ -1118,10 +2380,10 @@ ${"\u2501".repeat(60)}
1118
2380
  }
1119
2381
  async detectTestFramework() {
1120
2382
  const workDir = getWorkingDirectory(void 0, true);
1121
- const packagePath = resolve2(workDir, "package.json");
1122
- if (existsSync2(packagePath)) {
2383
+ const packagePath = resolve3(workDir, "package.json");
2384
+ if (existsSync3(packagePath)) {
1123
2385
  try {
1124
- const pkg = JSON.parse(await readFile2(packagePath, "utf-8"));
2386
+ const pkg = JSON.parse(await readFile3(packagePath, "utf-8"));
1125
2387
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
1126
2388
  if (deps.vitest) return "vitest";
1127
2389
  if (deps.jest) return "jest";
@@ -1129,13 +2391,13 @@ ${"\u2501".repeat(60)}
1129
2391
  } catch {
1130
2392
  }
1131
2393
  }
1132
- if (existsSync2(resolve2(workDir, "pytest.ini")) || existsSync2(resolve2(workDir, "pyproject.toml"))) {
2394
+ if (existsSync3(resolve3(workDir, "pytest.ini")) || existsSync3(resolve3(workDir, "pyproject.toml"))) {
1133
2395
  return "pytest";
1134
2396
  }
1135
2397
  return "jest";
1136
2398
  }
1137
2399
  detectLanguage(filePath) {
1138
- const ext = extname2(filePath).toLowerCase();
2400
+ const ext = extname3(filePath).toLowerCase();
1139
2401
  const langMap = {
1140
2402
  ".ts": "typescript",
1141
2403
  ".tsx": "tsx",
@@ -1207,8 +2469,8 @@ TODO: Implement register agent functionality`
1207
2469
  // src/tools/watch.ts
1208
2470
  import { watch } from "fs";
1209
2471
  import { stat } from "fs/promises";
1210
- import { join as join2, extname as extname3, basename as basename2 } from "path";
1211
- import { existsSync as existsSync3 } from "fs";
2472
+ import { join as join2, extname as extname4, basename as basename2 } from "path";
2473
+ import { existsSync as existsSync4 } from "fs";
1212
2474
  var WATCH_EXTENSIONS = /* @__PURE__ */ new Set([
1213
2475
  ".ts",
1214
2476
  ".tsx",
@@ -1235,42 +2497,37 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
1235
2497
  ]);
1236
2498
  var TrieWatchTool = class {
1237
2499
  scanTool = new TrieScanTool();
1238
- fixTool = new TrieFixTool();
1239
2500
  state = {
1240
2501
  isRunning: false,
1241
- yoloMode: false,
1242
2502
  lastScan: /* @__PURE__ */ new Map(),
1243
2503
  pendingFiles: /* @__PURE__ */ new Set(),
1244
2504
  scanDebounceTimer: null,
1245
2505
  issueCache: /* @__PURE__ */ new Map(),
1246
2506
  totalIssuesFound: 0,
1247
- totalIssuesFixed: 0,
1248
2507
  filesScanned: 0
1249
2508
  };
1250
2509
  watchers = /* @__PURE__ */ new Map();
1251
2510
  async execute(args) {
1252
- const { action, directory, debounceMs = 1e3, yolo = false } = args;
2511
+ const { action, directory, debounceMs = 1e3 } = args;
1253
2512
  switch (action) {
1254
2513
  case "start":
1255
- return this.startWatching(getWorkingDirectory(directory), debounceMs, yolo);
2514
+ return this.startWatching(getWorkingDirectory(directory), debounceMs);
1256
2515
  case "stop":
1257
2516
  return this.stopWatching();
1258
2517
  case "status":
1259
2518
  return this.getStatus();
1260
2519
  case "issues":
1261
2520
  return this.getCurrentIssues();
1262
- case "yolo":
1263
- return this.toggleYoloMode();
1264
2521
  default:
1265
2522
  return {
1266
2523
  content: [{
1267
2524
  type: "text",
1268
- text: `Unknown action: ${action}. Use 'start', 'stop', 'status', 'issues', or 'yolo'.`
2525
+ text: `Unknown action: ${action}. Use 'start', 'stop', 'status', or 'issues'.`
1269
2526
  }]
1270
2527
  };
1271
2528
  }
1272
2529
  }
1273
- async startWatching(directory, debounceMs, yoloMode) {
2530
+ async startWatching(directory, debounceMs) {
1274
2531
  if (this.state.isRunning) {
1275
2532
  return {
1276
2533
  content: [{
@@ -1280,57 +2537,36 @@ var TrieWatchTool = class {
1280
2537
  };
1281
2538
  }
1282
2539
  this.state.isRunning = true;
1283
- this.state.yoloMode = yoloMode;
1284
2540
  this.state.issueCache.clear();
1285
2541
  this.state.totalIssuesFound = 0;
1286
- this.state.totalIssuesFixed = 0;
1287
2542
  this.state.filesScanned = 0;
1288
- const modeEmoji = yoloMode ? "\u{1F525}" : "\u{1F441}\uFE0F";
1289
- const modeName = yoloMode ? "YOLO MODE" : "WATCH MODE";
1290
2543
  console.error("\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
1291
- console.error(`${modeEmoji} TRIE AGENT - AUTONOMOUS ${modeName}`);
2544
+ console.error("\u{1F441}\uFE0F TRIE AGENT - AUTONOMOUS WATCH MODE");
1292
2545
  console.error("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n");
1293
2546
  console.error(`\u{1F4C2} Watching: ${directory}`);
1294
2547
  console.error(`\u23F1\uFE0F Debounce: ${debounceMs}ms`);
1295
- if (yoloMode) {
1296
- console.error("\u{1F525} YOLO MODE: Auto-fixing issues as they occur!");
1297
- }
1298
2548
  console.error("");
1299
2549
  await this.watchDirectory(directory, debounceMs);
1300
2550
  console.error("\u{1F50D} Running initial scan...\n");
1301
- const initialResult = await this.scanTool.execute({ directory, yoloMode: this.state.yoloMode });
1302
- const yoloMessage = yoloMode ? `
1303
- ### \u{1F525} YOLO MODE ENABLED
1304
- Issues will be **automatically fixed** as they're detected!
1305
- - High-confidence fixes applied immediately
1306
- - No confirmation needed
1307
- - Living on the edge \u{1F680}
1308
-
1309
- ` : `
1310
- ### \u{1F4A1} Want auto-fixes?
1311
- Run \`trie_watch yolo\` to enable YOLO mode and auto-fix issues as they occur!
1312
-
1313
- `;
2551
+ const initialResult = await this.scanTool.execute({ directory });
1314
2552
  return {
1315
2553
  content: [{
1316
2554
  type: "text",
1317
- text: `${modeEmoji} **AUTONOMOUS ${modeName} ACTIVATED**
2555
+ text: `\u{1F441}\uFE0F **AUTONOMOUS WATCH MODE ACTIVATED**
1318
2556
 
1319
2557
  Trie Agent is now watching for file changes and will automatically scan them.
1320
2558
 
1321
2559
  **Watching:** \`${directory}\`
1322
2560
  **Debounce:** ${debounceMs}ms (waits for you to stop typing)
1323
- **YOLO Mode:** ${yoloMode ? "\u{1F525} ON - Auto-fixing!" : "\u274C OFF"}
1324
2561
 
1325
2562
  ### How it works:
1326
2563
  1. \u{1F4DD} You write/edit code
1327
2564
  2. \u{1F441}\uFE0F Trie detects the change
1328
2565
  3. \u{1F50D} Automatically scans the modified file
1329
- 4. ${yoloMode ? "\u{1F527} Auto-fixes issues immediately!" : "\u{1F6A8} Reports issues immediately"}
1330
- ${yoloMessage}
2566
+ 4. \u{1F6A8} Reports issues immediately
2567
+
1331
2568
  ### Commands:
1332
2569
  - \`trie_watch status\` - See current watch status
1333
- - \`trie_watch yolo\` - Toggle YOLO mode (auto-fix)
1334
2570
  - \`trie_watch issues\` - Get all issues found so far
1335
2571
  - \`trie_watch stop\` - Stop autonomous mode
1336
2572
 
@@ -1340,52 +2576,8 @@ ${initialResult.content?.[0]?.text || "Initial scan complete."}`
1340
2576
  }]
1341
2577
  };
1342
2578
  }
1343
- toggleYoloMode() {
1344
- if (!this.state.isRunning) {
1345
- return {
1346
- content: [{
1347
- type: "text",
1348
- text: `\u26A0\uFE0F Watch mode is not running. Start it first with:
1349
-
1350
- \`trie_watch start\` - Normal mode
1351
- \`trie_watch start yolo:true\` - YOLO mode from the start`
1352
- }]
1353
- };
1354
- }
1355
- this.state.yoloMode = !this.state.yoloMode;
1356
- if (this.state.yoloMode) {
1357
- console.error("\n\u{1F525} YOLO MODE ACTIVATED! Auto-fixing issues as they occur...\n");
1358
- return {
1359
- content: [{
1360
- type: "text",
1361
- text: `\u{1F525} **YOLO MODE ACTIVATED**
1362
-
1363
- Issues will now be **automatically fixed** as they're detected!
1364
-
1365
- \u26A0\uFE0F **Warning:** This will modify your files without confirmation.
1366
- - High-confidence fixes only
1367
- - Backs up original code in memory
1368
- - You can always undo with git
1369
-
1370
- Run \`trie_watch yolo\` again to disable.`
1371
- }]
1372
- };
1373
- } else {
1374
- console.error("\n\u{1F441}\uFE0F YOLO mode disabled. Back to watch-only mode.\n");
1375
- return {
1376
- content: [{
1377
- type: "text",
1378
- text: `\u{1F441}\uFE0F **YOLO MODE DISABLED**
1379
-
1380
- Back to normal watch mode. Issues will be reported but not auto-fixed.
1381
-
1382
- Run \`trie_watch yolo\` to re-enable.`
1383
- }]
1384
- };
1385
- }
1386
- }
1387
2579
  async watchDirectory(dir, debounceMs) {
1388
- if (!existsSync3(dir)) return;
2580
+ if (!existsSync4(dir)) return;
1389
2581
  try {
1390
2582
  const dirStat = await stat(dir);
1391
2583
  if (!dirStat.isDirectory()) return;
@@ -1394,9 +2586,9 @@ Run \`trie_watch yolo\` to re-enable.`
1394
2586
  const watcher = watch(dir, { persistent: true }, async (_eventType, filename) => {
1395
2587
  if (!filename) return;
1396
2588
  const fullPath = join2(dir, filename);
1397
- const ext = extname3(filename).toLowerCase();
2589
+ const ext = extname4(filename).toLowerCase();
1398
2590
  if (!WATCH_EXTENSIONS.has(ext)) return;
1399
- if (!existsSync3(fullPath)) return;
2591
+ if (!existsSync4(fullPath)) return;
1400
2592
  this.state.pendingFiles.add(fullPath);
1401
2593
  if (this.state.scanDebounceTimer) {
1402
2594
  clearTimeout(this.state.scanDebounceTimer);
@@ -1420,15 +2612,14 @@ Run \`trie_watch yolo\` to re-enable.`
1420
2612
  if (this.state.pendingFiles.size === 0) return;
1421
2613
  const files = Array.from(this.state.pendingFiles);
1422
2614
  this.state.pendingFiles.clear();
1423
- const modeEmoji = this.state.yoloMode ? "\u{1F525}" : "\u{1F441}\uFE0F";
1424
2615
  console.error(`
1425
- ${modeEmoji} Detected changes in ${files.length} file(s):`);
2616
+ \u{1F441}\uFE0F Detected changes in ${files.length} file(s):`);
1426
2617
  for (const file of files) {
1427
2618
  console.error(` \u2022 ${basename2(file)}`);
1428
2619
  }
1429
2620
  console.error("");
1430
2621
  try {
1431
- const result = await this.scanTool.execute({ files, yoloMode: this.state.yoloMode });
2622
+ const result = await this.scanTool.execute({ files });
1432
2623
  const resultText = result.content?.[0]?.text || "";
1433
2624
  this.state.filesScanned += files.length;
1434
2625
  const issueMatch = resultText.match(/(\d+) total/);
@@ -1450,12 +2641,6 @@ ${modeEmoji} Detected changes in ${files.length} file(s):`);
1450
2641
  if (moderateMatch) {
1451
2642
  console.error(` \u{1F7E1} ${moderateMatch[1]} moderate issues`);
1452
2643
  }
1453
- if (this.state.yoloMode) {
1454
- console.error("\n\u{1F525} YOLO MODE: Attempting auto-fix...");
1455
- await this.autoFixIssues(files);
1456
- } else {
1457
- console.error("\n\u{1F4A1} Run `trie_watch yolo` to auto-fix issues");
1458
- }
1459
2644
  } else {
1460
2645
  console.error(" \u2705 No issues found - code looks good!");
1461
2646
  }
@@ -1467,30 +2652,6 @@ ${modeEmoji} Detected changes in ${files.length} file(s):`);
1467
2652
  console.error(`\u274C Scan error: ${error}`);
1468
2653
  }
1469
2654
  }
1470
- async autoFixIssues(files) {
1471
- try {
1472
- const fixResult = await this.fixTool.execute({
1473
- files,
1474
- autoApprove: true,
1475
- minConfidence: 0.8
1476
- // Only fix high-confidence issues
1477
- });
1478
- const fixText = fixResult.content?.[0]?.text || "";
1479
- const fixedMatch = fixText.match(/(\d+) issues? fixed/i);
1480
- if (fixedMatch?.[1] !== void 0) {
1481
- const fixed = parseInt(fixedMatch[1], 10);
1482
- this.state.totalIssuesFixed += fixed;
1483
- console.error(` \u2705 Auto-fixed ${fixed} issues!`);
1484
- } else if (fixText.includes("No issues")) {
1485
- console.error(" \u2139\uFE0F No auto-fixable issues found");
1486
- } else {
1487
- const firstLine = fixText.split("\n")[0];
1488
- console.error(` \u{1F527} ${firstLine}`);
1489
- }
1490
- } catch (error) {
1491
- console.error(` \u26A0\uFE0F Auto-fix error: ${error}`);
1492
- }
1493
- }
1494
2655
  stopWatching() {
1495
2656
  if (!this.state.isRunning) {
1496
2657
  return {
@@ -1507,29 +2668,19 @@ ${modeEmoji} Detected changes in ${files.length} file(s):`);
1507
2668
  if (this.state.scanDebounceTimer) {
1508
2669
  clearTimeout(this.state.scanDebounceTimer);
1509
2670
  }
1510
- const wasYolo = this.state.yoloMode;
1511
2671
  this.state.isRunning = false;
1512
- this.state.yoloMode = false;
1513
- const modeEmoji = wasYolo ? "\u{1F525}" : "\u{1F441}\uFE0F";
1514
- console.error(`
1515
- ${modeEmoji} Watch mode stopped.
1516
- `);
1517
- const yoloStats = wasYolo ? `
1518
- - \u{1F525} **Issues auto-fixed: ${this.state.totalIssuesFixed}**` : "";
2672
+ console.error("\n\u{1F441}\uFE0F Watch mode stopped.\n");
1519
2673
  return {
1520
2674
  content: [{
1521
2675
  type: "text",
1522
- text: `${modeEmoji} **AUTONOMOUS MODE STOPPED**
2676
+ text: `\u{1F441}\uFE0F **AUTONOMOUS WATCH MODE STOPPED**
1523
2677
 
1524
2678
  ### Session Summary:
1525
2679
  - Files scanned: ${this.state.filesScanned}
1526
- - Total issues found: ${this.state.totalIssuesFound}${yoloStats}
2680
+ - Total issues found: ${this.state.totalIssuesFound}
1527
2681
  - Directories watched: ${this.watchers.size}
1528
- ${wasYolo ? `
1529
- \u{1F525} YOLO mode was ON - issues were auto-fixed as they occurred!` : ""}
1530
2682
 
1531
- Use \`trie_watch start\` to start watching again.
1532
- Use \`trie_watch start yolo:true\` for YOLO mode.`
2683
+ Use \`trie_watch start\` to start watching again.`
1533
2684
  }]
1534
2685
  };
1535
2686
  }
@@ -1540,36 +2691,29 @@ Use \`trie_watch start yolo:true\` for YOLO mode.`
1540
2691
  type: "text",
1541
2692
  text: `\u{1F441}\uFE0F **Watch Mode Status: STOPPED**
1542
2693
 
1543
- Use \`trie_watch start\` to begin autonomous scanning.
1544
- Use \`trie_watch start yolo:true\` for YOLO mode (auto-fix).`
2694
+ Use \`trie_watch start\` to begin autonomous scanning.`
1545
2695
  }]
1546
2696
  };
1547
2697
  }
1548
- const modeEmoji = this.state.yoloMode ? "\u{1F525}" : "\u{1F441}\uFE0F";
1549
- const modeName = this.state.yoloMode ? "YOLO MODE" : "WATCH MODE";
1550
2698
  const recentScans = Array.from(this.state.lastScan.entries()).sort((a, b) => b[1] - a[1]).slice(0, 5).map(([file, time]) => {
1551
2699
  const ago = Math.round((Date.now() - time) / 1e3);
1552
2700
  return `- \`${basename2(file)}\` (${ago}s ago)`;
1553
2701
  }).join("\n");
1554
- const yoloStats = this.state.yoloMode ? `
1555
- - \u{1F525} Issues auto-fixed: ${this.state.totalIssuesFixed}` : "";
1556
2702
  return {
1557
2703
  content: [{
1558
2704
  type: "text",
1559
- text: `${modeEmoji} **${modeName} Status: RUNNING**
2705
+ text: `\u{1F441}\uFE0F **WATCH MODE Status: RUNNING**
1560
2706
 
1561
2707
  ### Stats:
1562
2708
  - Directories watched: ${this.watchers.size}
1563
2709
  - Files scanned this session: ${this.state.filesScanned}
1564
- - Total issues found: ${this.state.totalIssuesFound}${yoloStats}
2710
+ - Total issues found: ${this.state.totalIssuesFound}
1565
2711
  - Pending files: ${this.state.pendingFiles.size}
1566
- - YOLO Mode: ${this.state.yoloMode ? "\u{1F525} ON" : "\u274C OFF"}
1567
2712
 
1568
2713
  ### Recently Scanned:
1569
2714
  ${recentScans || "(none yet)"}
1570
2715
 
1571
2716
  ### Commands:
1572
- - \`trie_watch yolo\` - ${this.state.yoloMode ? "Disable" : "Enable"} YOLO mode
1573
2717
  - \`trie_watch issues\` - Get all issues found
1574
2718
  - \`trie_watch stop\` - Stop watching`
1575
2719
  }]
@@ -1591,9 +2735,9 @@ To get a full report, run \`trie_scan\` on your codebase.`
1591
2735
  };
1592
2736
 
1593
2737
  // src/tools/agent.ts
1594
- import { readdir, readFile as readFile3 } from "fs/promises";
1595
- import { existsSync as existsSync4 } from "fs";
1596
- import { join as join3, extname as extname4, isAbsolute as isAbsolute3, resolve as resolve3, basename as basename3 } from "path";
2738
+ import { readdir, readFile as readFile4 } from "fs/promises";
2739
+ import { existsSync as existsSync5 } from "fs";
2740
+ import { join as join3, extname as extname5, isAbsolute as isAbsolute4, resolve as resolve4, basename as basename3 } from "path";
1597
2741
 
1598
2742
  // src/knowledge/index.ts
1599
2743
  var SECURITY_SOURCES = [
@@ -1942,10 +3086,10 @@ ${this.agentRegistry.getAgentNames().map((n) => `- ${n}`).join("\n")}`
1942
3086
  `);
1943
3087
  } else {
1944
3088
  filesToScan = filesToScan.map(
1945
- (f) => isAbsolute3(f) ? f : resolve3(workDir, f)
3089
+ (f) => isAbsolute4(f) ? f : resolve4(workDir, f)
1946
3090
  );
1947
3091
  }
1948
- const validFiles = filesToScan.filter((f) => existsSync4(f));
3092
+ const validFiles = filesToScan.filter((f) => existsSync5(f));
1949
3093
  if (validFiles.length === 0) {
1950
3094
  return {
1951
3095
  content: [{
@@ -2179,9 +3323,9 @@ ${issue.fix}
2179
3323
  * Get a code snippet around a specific line
2180
3324
  */
2181
3325
  async getCodeSnippet(filePath, line) {
2182
- if (!line || !existsSync4(filePath)) return null;
3326
+ if (!line || !existsSync5(filePath)) return null;
2183
3327
  try {
2184
- const content = await readFile3(filePath, "utf-8");
3328
+ const content = await readFile4(filePath, "utf-8");
2185
3329
  const lines = content.split("\n");
2186
3330
  const start = Math.max(0, line - 3);
2187
3331
  const end = Math.min(lines.length, line + 2);
@@ -2225,7 +3369,7 @@ ${issue.fix}
2225
3369
  await walk(fullPath);
2226
3370
  }
2227
3371
  } else if (entry.isFile()) {
2228
- const ext = extname4(entry.name).toLowerCase();
3372
+ const ext = extname5(entry.name).toLowerCase();
2229
3373
  if (SCANNABLE_EXTENSIONS.has(ext)) {
2230
3374
  files.push(fullPath);
2231
3375
  }
@@ -2240,9 +3384,9 @@ ${issue.fix}
2240
3384
  };
2241
3385
 
2242
3386
  // src/tools/create-agent.ts
2243
- import { existsSync as existsSync5 } from "fs";
3387
+ import { existsSync as existsSync6 } from "fs";
2244
3388
  import { mkdir, writeFile } from "fs/promises";
2245
- import { join as join4, basename as basename4, extname as extname5 } from "path";
3389
+ import { join as join4, basename as basename4, extname as extname6 } from "path";
2246
3390
  var TrieCreateAgentTool = class {
2247
3391
  async execute(args) {
2248
3392
  const { filePath, documentContent, agentName, displayName, description, category } = args;
@@ -2259,7 +3403,7 @@ var TrieCreateAgentTool = class {
2259
3403
  let title = agentName;
2260
3404
  let wordCount = 0;
2261
3405
  if (filePath) {
2262
- if (!existsSync5(filePath)) {
3406
+ if (!existsSync6(filePath)) {
2263
3407
  return this.errorResponse(`File not found: ${filePath}`);
2264
3408
  }
2265
3409
  const ext = filePath.toLowerCase().split(".").pop();
@@ -2271,7 +3415,7 @@ Supported types: .pdf, .txt, .md, .rtf`
2271
3415
  }
2272
3416
  const document = await parseDocument(filePath);
2273
3417
  rawText = document.rawText;
2274
- title = document.metadata.title || basename4(filePath, extname5(filePath));
3418
+ title = document.metadata.title || basename4(filePath, extname6(filePath));
2275
3419
  wordCount = document.metadata.wordCount;
2276
3420
  } else {
2277
3421
  rawText = documentContent;
@@ -2799,9 +3943,9 @@ var TrieListAgentsTool = class {
2799
3943
  };
2800
3944
 
2801
3945
  // src/tools/pr-review.ts
2802
- import { readFile as readFile4 } from "fs/promises";
2803
- import { existsSync as existsSync6 } from "fs";
2804
- import { join as join5, basename as basename5, resolve as resolve4, isAbsolute as isAbsolute4 } from "path";
3946
+ import { readFile as readFile5 } from "fs/promises";
3947
+ import { existsSync as existsSync7 } from "fs";
3948
+ import { join as join5, basename as basename5, resolve as resolve5, isAbsolute as isAbsolute5 } from "path";
2805
3949
  import { execSync } from "child_process";
2806
3950
  var TriePRReviewTool = class {
2807
3951
  agent = new SuperReviewerAgent();
@@ -2872,8 +4016,8 @@ Usage:
2872
4016
  */
2873
4017
  async getPRInfo(pr, worktree) {
2874
4018
  if (worktree) {
2875
- const worktreePath = isAbsolute4(worktree) ? worktree : resolve4(getWorkingDirectory(void 0, true), worktree);
2876
- if (!existsSync6(worktreePath)) {
4019
+ const worktreePath = isAbsolute5(worktree) ? worktree : resolve5(getWorkingDirectory(void 0, true), worktree);
4020
+ if (!existsSync7(worktreePath)) {
2877
4021
  return { success: false, error: `Worktree not found: ${worktreePath}` };
2878
4022
  }
2879
4023
  return {
@@ -3023,7 +4167,7 @@ Usage:
3023
4167
  ];
3024
4168
  for (const docPath of designDocPaths) {
3025
4169
  const fullPath = join5(cwd, docPath);
3026
- if (existsSync6(fullPath)) {
4170
+ if (existsSync7(fullPath)) {
3027
4171
  }
3028
4172
  }
3029
4173
  return designDocs;
@@ -3036,9 +4180,9 @@ Usage:
3036
4180
  const cwd = getWorkingDirectory(void 0, true);
3037
4181
  await Promise.all(filePaths.map(async (filePath) => {
3038
4182
  try {
3039
- const fullPath = isAbsolute4(filePath) ? filePath : join5(cwd, filePath);
3040
- if (existsSync6(fullPath)) {
3041
- const content = await readFile4(fullPath, "utf-8");
4183
+ const fullPath = isAbsolute5(filePath) ? filePath : join5(cwd, filePath);
4184
+ if (existsSync7(fullPath)) {
4185
+ const content = await readFile5(fullPath, "utf-8");
3042
4186
  contents.set(filePath, content);
3043
4187
  }
3044
4188
  } catch {
@@ -3601,7 +4745,7 @@ var ToolRegistry = class {
3601
4745
  };
3602
4746
 
3603
4747
  // src/server/resource-manager.ts
3604
- import { readdir as readdir2, readFile as readFile5 } from "fs/promises";
4748
+ import { readdir as readdir2, readFile as readFile6 } from "fs/promises";
3605
4749
  import { join as join6 } from "path";
3606
4750
  var ResourceManager = class {
3607
4751
  agentRegistry = getAgentRegistry();
@@ -3742,7 +4886,7 @@ var ResourceManager = class {
3742
4886
  async getCacheStatsResource(uri) {
3743
4887
  try {
3744
4888
  const cachePath = join6(getWorkingDirectory(void 0, true), ".trie", ".trie-cache.json");
3745
- const cacheContent = await readFile5(cachePath, "utf-8");
4889
+ const cacheContent = await readFile6(cachePath, "utf-8");
3746
4890
  const cache = JSON.parse(cacheContent);
3747
4891
  const fileCount = Object.keys(cache.files || {}).length;
3748
4892
  const totalVulns = Object.values(cache.files || {}).reduce((acc, file) => {
@@ -3796,7 +4940,7 @@ var ResourceManager = class {
3796
4940
  const fileName = parsedUri.replace("reports/", "");
3797
4941
  const reportPath = join6(getWorkingDirectory(void 0, true), "trie-reports", fileName);
3798
4942
  try {
3799
- const content = await readFile5(reportPath, "utf-8");
4943
+ const content = await readFile6(reportPath, "utf-8");
3800
4944
  return {
3801
4945
  contents: [{
3802
4946
  uri,
@@ -3832,18 +4976,18 @@ async function findOpenPort() {
3832
4976
  return null;
3833
4977
  }
3834
4978
  async function checkPort(port) {
3835
- return new Promise((resolve5) => {
4979
+ return new Promise((resolve6) => {
3836
4980
  const server = createServer();
3837
4981
  server.once("error", (err) => {
3838
4982
  if (err.code === "EADDRINUSE") {
3839
- resolve5(true);
4983
+ resolve6(true);
3840
4984
  } else {
3841
- resolve5(false);
4985
+ resolve6(false);
3842
4986
  }
3843
4987
  });
3844
4988
  server.once("listening", () => {
3845
4989
  server.close();
3846
- resolve5(false);
4990
+ resolve6(false);
3847
4991
  });
3848
4992
  server.listen(port, "127.0.0.1");
3849
4993
  });
@@ -4179,9 +5323,9 @@ var RequestHandlers = class {
4179
5323
  "- `security`, `privacy`, `legal`, `bugs`, `types`, `devops`, `architecture`, `ux`, `clean`, `soc2`, `performance`, `e2e`, `visual_qa`, `data_flow`",
4180
5324
  "",
4181
5325
  "**Tools:**",
4182
- "- `fix`: Apply high-confidence fixes",
5326
+ "- `fix`: Generate high-confidence fix prompts",
4183
5327
  "- `explain`: Explain code/issues/risks",
4184
- "- `watch`: Watch mode (scan on change)",
5328
+ "- `watch`: Watch mode (generate reports on change)",
4185
5329
  "- `visual_qa_browser`: Screenshot app for vision analysis",
4186
5330
  "",
4187
5331
  "**Custom Agents:**",