@defai.digital/ax-cli 3.8.29 → 3.8.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +30 -1
  2. package/config-defaults/prompts.yaml +296 -0
  3. package/dist/agent/llm-agent.d.ts +19 -1
  4. package/dist/agent/llm-agent.js +69 -2
  5. package/dist/agent/llm-agent.js.map +1 -1
  6. package/dist/analyzers/ast/index.d.ts +7 -1
  7. package/dist/analyzers/ast/index.js +9 -1
  8. package/dist/analyzers/ast/index.js.map +1 -1
  9. package/dist/analyzers/ast/language-parser.d.ts +58 -0
  10. package/dist/analyzers/ast/language-parser.js +80 -0
  11. package/dist/analyzers/ast/language-parser.js.map +1 -0
  12. package/dist/analyzers/ast/multi-language-parser.d.ts +97 -0
  13. package/dist/analyzers/ast/multi-language-parser.js +275 -0
  14. package/dist/analyzers/ast/multi-language-parser.js.map +1 -0
  15. package/dist/analyzers/ast/parser.d.ts +1 -0
  16. package/dist/analyzers/ast/parser.js +15 -3
  17. package/dist/analyzers/ast/parser.js.map +1 -1
  18. package/dist/analyzers/ast/tree-sitter-parser.d.ts +134 -0
  19. package/dist/analyzers/ast/tree-sitter-parser.js +730 -0
  20. package/dist/analyzers/ast/tree-sitter-parser.js.map +1 -0
  21. package/dist/analyzers/code-smells/base-smell-detector.d.ts +2 -2
  22. package/dist/analyzers/code-smells/base-smell-detector.js +2 -2
  23. package/dist/analyzers/code-smells/base-smell-detector.js.map +1 -1
  24. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js +1 -1
  25. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js.map +1 -1
  26. package/dist/analyzers/code-smells/detectors/dead-code-detector.js +6 -1
  27. package/dist/analyzers/code-smells/detectors/dead-code-detector.js.map +1 -1
  28. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js +1 -1
  29. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js.map +1 -1
  30. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js +4 -1
  31. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js.map +1 -1
  32. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js +3 -0
  33. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js.map +1 -1
  34. package/dist/analyzers/code-smells/detectors/large-class-detector.js +1 -1
  35. package/dist/analyzers/code-smells/detectors/large-class-detector.js.map +1 -1
  36. package/dist/analyzers/code-smells/detectors/long-method-detector.js +1 -1
  37. package/dist/analyzers/code-smells/detectors/long-method-detector.js.map +1 -1
  38. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js +1 -1
  39. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js.map +1 -1
  40. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js +3 -0
  41. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js.map +1 -1
  42. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js +3 -0
  43. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js.map +1 -1
  44. package/dist/analyzers/dependency/dependency-analyzer.d.ts +4 -0
  45. package/dist/analyzers/dependency/dependency-analyzer.js +7 -3
  46. package/dist/analyzers/dependency/dependency-analyzer.js.map +1 -1
  47. package/dist/analyzers/git/hotspot-detector.js +3 -3
  48. package/dist/analyzers/git/hotspot-detector.js.map +1 -1
  49. package/dist/analyzers/metrics/metrics-analyzer.js +7 -3
  50. package/dist/analyzers/metrics/metrics-analyzer.js.map +1 -1
  51. package/dist/commands/usage.js +12 -1
  52. package/dist/commands/usage.js.map +1 -1
  53. package/dist/tools/text-editor.js +2 -1
  54. package/dist/tools/text-editor.js.map +1 -1
  55. package/package.json +3 -1
package/README.md CHANGED
@@ -93,6 +93,7 @@ ax-cli
93
93
  - **Code Smell Detector** - 10+ anti-patterns detection
94
94
  - **Hotspot Analyzer** - Git history-based complexity analysis
95
95
  - **Security Scanner** - SQL injection, XSS, hardcoded secrets
96
+ - **Multi-Language Support** - TypeScript, JavaScript, Python, Rust, Go, C, C++, Swift, HTML, CSS
96
97
 
97
98
  ---
98
99
 
@@ -381,7 +382,35 @@ Email: **security@defai.digital** (private disclosure)
381
382
 
382
383
  ## Changelog
383
384
 
384
- ### v3.8.29 (Latest)
385
+ ### v3.8.33 (Latest)
386
+
387
+ - **Bug fix: Dead code detection** - Fixed ts-morph source file lifecycle management for semantic analysis
388
+ - **Improved AST parser** - `getSourceFile()` now properly preserves files for `findReferencesAsNodes()` operations
389
+ - **CI/CD stability** - Resolved test failures in dead code detector tests
390
+
391
+ ### v3.8.32
392
+
393
+ - **Auto-Thinking Mode** - GLM-4.6 automatically enables reasoning mode for complex tasks (debugging, architecture, refactoring)
394
+ - **Smart complexity detection** - Uses `shouldUseThinkingMode()` and `getComplexityScore()` to detect when extended reasoning helps
395
+ - **Enhanced /usage command** - Estimated session cost, cache hit rate, and detailed token breakdown
396
+ - **User preference respect** - Auto-thinking only activates when user hasn't explicitly set thinking preference
397
+
398
+ ### v3.8.31
399
+
400
+ - **Multi-language AST parsing** - Tree-sitter integration for Python, Rust, Go, C, C++, Swift, HTML, CSS
401
+ - **Unified parser facade** - `MultiLanguageParser` automatically routes to appropriate parser (ts-morph for TS/JS, tree-sitter for others)
402
+ - **Updated analyzers** - DependencyAnalyzer, MetricsAnalyzer, HotspotDetector, CodeSmellDetector now support all languages
403
+ - **Polyglot code analysis** - Analyze mixed-language codebases with single command
404
+
405
+ ### v3.8.30
406
+
407
+ - **Project Status Report template** - Comprehensive template with metrics, risks, and progress tracking
408
+ - **Technical Specification template** - Detailed design docs with API, data model, and architecture sections
409
+ - **Changelog Generation guidelines** - Standard categories and git commands for release notes
410
+ - **PRD Refinement workflow** - Iterative improvement process with stakeholder feedback integration
411
+ - **Bug fix: multiEdit audit logging** - Fixed inverted boolean in audit log for multi-edit operations
412
+
413
+ ### v3.8.29
385
414
 
386
415
  - **ADR (Architecture Decision Record) template** - Complete template for documenting architectural decisions
387
416
  - **Self-verification pattern** - Quality checklists for code, analysis, and documentation
@@ -556,6 +556,302 @@ system_prompt:
556
556
  - If partial changes fail, note which files were modified
557
557
  - Provide user with recovery steps if needed
558
558
 
559
+ # Project Status Report template
560
+ project_status_report:
561
+ title: "PROJECT STATUS REPORT"
562
+ content: |
563
+ When asked to create a project status report or progress update:
564
+
565
+ === STATUS REPORT TEMPLATE ===
566
+ # Project Status Report
567
+ **Date**: [YYYY-MM-DD]
568
+ **Reporting Period**: [Start Date] to [End Date]
569
+ **Author**: [Name/Role]
570
+
571
+ ## Executive Summary
572
+ 2-3 sentences summarizing overall project health and key highlights.
573
+ Status: 🟢 On Track | 🟡 At Risk | 🔴 Blocked
574
+
575
+ ## Progress Overview
576
+
577
+ ### Completed This Period
578
+ | Task | Files Changed | Impact |
579
+ |------|--------------|--------|
580
+ | [Task 1] | [files] | [impact] |
581
+
582
+ ### In Progress
583
+ | Task | % Complete | ETA | Blockers |
584
+ |------|-----------|-----|----------|
585
+ | [Task 1] | [%] | [date] | [blockers] |
586
+
587
+ ### Planned Next Period
588
+ - [ ] Task 1
589
+ - [ ] Task 2
590
+
591
+ ## Metrics
592
+
593
+ ### Code Metrics
594
+ - Files modified: [N]
595
+ - Lines added: [+N]
596
+ - Lines removed: [-N]
597
+ - Test coverage: [N%]
598
+
599
+ ### Quality Metrics
600
+ - Open bugs: [N] (Critical: [N], Major: [N], Minor: [N])
601
+ - Technical debt items: [N]
602
+ - Code review turnaround: [N hours/days]
603
+
604
+ ## Risks and Blockers
605
+
606
+ | Risk/Blocker | Severity | Mitigation | Owner |
607
+ |--------------|----------|------------|-------|
608
+ | [Issue] | High/Med/Low | [Action] | [Name] |
609
+
610
+ ## Dependencies
611
+ - External: [List external dependencies and their status]
612
+ - Internal: [List internal team dependencies]
613
+
614
+ ## Decisions Needed
615
+ 1. [Decision 1]: [Options and recommendation]
616
+ 2. [Decision 2]: [Options and recommendation]
617
+
618
+ ## Next Steps
619
+ 1. [Immediate action 1]
620
+ 2. [Immediate action 2]
621
+ === END TEMPLATE ===
622
+
623
+ GATHERING DATA:
624
+ 1. Run `git log --oneline --since="[period]"` for commit history
625
+ 2. Run `git diff --stat [start]..HEAD` for file changes
626
+ 3. Check issue tracker for open/closed items
627
+ 4. Review test results for coverage metrics
628
+
629
+ RULES:
630
+ - Use actual data from codebase, not estimates
631
+ - Be specific about blockers and risks
632
+ - Include actionable next steps
633
+ - Keep executive summary concise
634
+
635
+ # Technical Specification template
636
+ technical_specification:
637
+ title: "TECHNICAL SPECIFICATION"
638
+ content: |
639
+ When asked to create a technical spec or detailed design:
640
+
641
+ === TECHNICAL SPEC TEMPLATE ===
642
+ # Technical Specification: [Feature Name]
643
+
644
+ ## Metadata
645
+ - **Author**: [Name]
646
+ - **Created**: [Date]
647
+ - **Status**: Draft | Review | Approved
648
+ - **Related PRD**: [Link to PRD if exists]
649
+
650
+ ## Overview
651
+ Brief description of what this specification covers.
652
+
653
+ ## Goals
654
+ - Primary goal
655
+ - Secondary goals
656
+
657
+ ## Non-Goals
658
+ - What this does NOT cover
659
+
660
+ ## System Architecture
661
+
662
+ ### Component Diagram
663
+ ```
664
+ [Component A] --> [Component B] --> [Component C]
665
+ | |
666
+ v v
667
+ [Database] [External API]
668
+ ```
669
+
670
+ ### Data Flow
671
+ 1. User action triggers [Component A]
672
+ 2. [Component A] validates and sends to [Component B]
673
+ 3. ...
674
+
675
+ ## API Design
676
+
677
+ ### Endpoints (if applicable)
678
+ ```
679
+ POST /api/v1/[resource]
680
+ Request:
681
+ {
682
+ "field1": "string",
683
+ "field2": number
684
+ }
685
+ Response:
686
+ {
687
+ "id": "string",
688
+ "status": "created"
689
+ }
690
+ ```
691
+
692
+ ### Function Signatures (if applicable)
693
+ ```typescript
694
+ function processData(input: InputType): Promise<OutputType>
695
+ ```
696
+
697
+ ## Data Model
698
+
699
+ ### Entities
700
+ ```typescript
701
+ interface Entity {
702
+ id: string;
703
+ createdAt: Date;
704
+ // ... fields
705
+ }
706
+ ```
707
+
708
+ ### Database Schema (if applicable)
709
+ ```sql
710
+ CREATE TABLE entities (
711
+ id UUID PRIMARY KEY,
712
+ created_at TIMESTAMP DEFAULT NOW()
713
+ );
714
+ ```
715
+
716
+ ## Error Handling
717
+ | Error Code | Condition | User Message | Recovery |
718
+ |------------|-----------|--------------|----------|
719
+ | E001 | [condition] | [message] | [action] |
720
+
721
+ ## Security Considerations
722
+ - Authentication: [method]
723
+ - Authorization: [rules]
724
+ - Data validation: [approach]
725
+ - Known risks: [list]
726
+
727
+ ## Performance Requirements
728
+ - Latency: < [N]ms for [operation]
729
+ - Throughput: [N] requests/second
730
+ - Memory: < [N]MB per [unit]
731
+
732
+ ## Testing Strategy
733
+ - Unit tests: [scope]
734
+ - Integration tests: [scope]
735
+ - E2E tests: [scope]
736
+
737
+ ## Rollout Plan
738
+ 1. Phase 1: [scope] - [criteria]
739
+ 2. Phase 2: [scope] - [criteria]
740
+
741
+ ## Rollback Plan
742
+ - Trigger: [conditions]
743
+ - Steps: [actions]
744
+ === END TEMPLATE ===
745
+
746
+ RULES:
747
+ - Research existing architecture FIRST
748
+ - Include actual code examples, not pseudocode
749
+ - Specify concrete numbers for performance requirements
750
+ - Link to existing code files where relevant
751
+
752
+ # Changelog Generation guidelines
753
+ changelog_generation:
754
+ title: "CHANGELOG GENERATION"
755
+ content: |
756
+ When asked to generate a changelog or release notes:
757
+
758
+ === CHANGELOG TEMPLATE ===
759
+ # Changelog
760
+
761
+ ## [Version] - YYYY-MM-DD
762
+
763
+ ### Added
764
+ - New feature 1 (#PR)
765
+ - New feature 2 (#PR)
766
+
767
+ ### Changed
768
+ - Updated behavior of X (#PR)
769
+ - Improved performance of Y (#PR)
770
+
771
+ ### Fixed
772
+ - Bug fix 1 (#PR)
773
+ - Bug fix 2 (#PR)
774
+
775
+ ### Deprecated
776
+ - Feature X will be removed in version Y
777
+
778
+ ### Removed
779
+ - Removed deprecated feature Z
780
+
781
+ ### Security
782
+ - Security fix for CVE-XXXX
783
+ === END TEMPLATE ===
784
+
785
+ CATEGORIZATION RULES:
786
+ - Added: Wholly new features or capabilities
787
+ - Changed: Modifications to existing behavior
788
+ - Fixed: Bug fixes (user-facing issues)
789
+ - Deprecated: Features marked for future removal
790
+ - Removed: Features that were removed
791
+ - Security: Security-related fixes
792
+
793
+ GATHERING DATA:
794
+ ```bash
795
+ # Get commits since last tag
796
+ git log $(git describe --tags --abbrev=0)..HEAD --oneline
797
+
798
+ # Get commits by type (if using conventional commits)
799
+ git log --oneline | grep -E "^[a-f0-9]+ (feat|fix|docs):"
800
+ ```
801
+
802
+ USER-FACING FOCUS:
803
+ - Emphasize what users can DO differently
804
+ - Avoid internal implementation details
805
+ - Include migration steps for breaking changes
806
+ - Link to documentation for new features
807
+
808
+ # PRD Refinement workflow
809
+ prd_refinement:
810
+ title: "PRD REFINEMENT"
811
+ content: |
812
+ When iterating on a PRD or design document:
813
+
814
+ REFINEMENT WORKFLOW:
815
+ 1. REVIEW existing PRD sections
816
+ 2. IDENTIFY gaps or ambiguities
817
+ 3. RESEARCH codebase for constraints
818
+ 4. UPDATE specific sections
819
+ 5. VALIDATE changes don't conflict
820
+
821
+ COMMON REFINEMENT TRIGGERS:
822
+ - "Make this more specific"
823
+ - "Add technical constraints"
824
+ - "Consider edge case X"
825
+ - "Incorporate feedback from [stakeholder]"
826
+
827
+ REFINEMENT CHECKLIST:
828
+ □ Problem Statement: Is it clear and measurable?
829
+ □ Goals: Are they SMART (Specific, Measurable, Achievable, Relevant, Time-bound)?
830
+ □ Non-Goals: Are boundaries explicit?
831
+ □ Technical Requirements: Based on actual codebase?
832
+ □ Risks: Realistic with mitigations?
833
+ □ Success Metrics: Quantifiable?
834
+
835
+ VERSION TRACKING:
836
+ ```
837
+ ## Revision History
838
+ | Version | Date | Author | Changes |
839
+ |---------|------|--------|---------|
840
+ | 1.0 | [date] | [author] | Initial draft |
841
+ | 1.1 | [date] | [author] | Added X based on feedback |
842
+ ```
843
+
844
+ STAKEHOLDER FEEDBACK INTEGRATION:
845
+ - Tag feedback source: "[Feedback from Engineering]"
846
+ - Track open questions: "❓ Needs clarification: [question]"
847
+ - Mark decisions: "✅ Decided: [decision] ([rationale])"
848
+
849
+ ITERATION BEST PRACTICES:
850
+ - Make focused changes (one concern per iteration)
851
+ - Preserve original intent while adding specificity
852
+ - Document why changes were made
853
+ - Re-validate affected sections
854
+
559
855
  closing: "Be direct. Be accurate. Be brief."
560
856
 
561
857
  # Custom instructions handling
@@ -31,6 +31,10 @@ export declare class LLMAgent extends EventEmitter {
31
31
  private samplingConfig;
32
32
  /** Thinking/reasoning mode configuration */
33
33
  private thinkingConfig;
34
+ /** Track if auto-thinking was enabled for current message (for UI indicator) */
35
+ private autoThinkingEnabled;
36
+ /** User's explicit thinking preference (undefined = auto, true/false = explicit) */
37
+ private userThinkingPreference;
34
38
  /** Stored reference to context overflow listener for proper cleanup */
35
39
  private contextOverflowListener;
36
40
  /** Track if agent has been disposed */
@@ -61,16 +65,30 @@ export declare class LLMAgent extends EventEmitter {
61
65
  /**
62
66
  * Set thinking/reasoning mode configuration for this agent session
63
67
  * @param config Thinking configuration to apply (enabled/disabled)
68
+ * @param isUserExplicit Whether this is an explicit user preference (vs auto-detection)
64
69
  */
65
- setThinkingConfig(config: ThinkingConfig | undefined): void;
70
+ setThinkingConfig(config: ThinkingConfig | undefined, isUserExplicit?: boolean): void;
66
71
  /**
67
72
  * Get current thinking configuration
68
73
  */
69
74
  getThinkingConfig(): ThinkingConfig | undefined;
75
+ /**
76
+ * Check if auto-thinking was enabled for the current message
77
+ * Used by UI to show indicator when thinking was auto-activated
78
+ */
79
+ isAutoThinkingEnabled(): boolean;
70
80
  /**
71
81
  * Get current sampling configuration
72
82
  */
73
83
  getSamplingConfig(): SamplingConfig | undefined;
84
+ /**
85
+ * Apply auto-thinking mode detection for a user message
86
+ * Only activates if user hasn't explicitly set a preference
87
+ *
88
+ * @param message User's message text
89
+ * @returns true if thinking mode was auto-enabled, false otherwise
90
+ */
91
+ private applyAutoThinking;
74
92
  /**
75
93
  * Enable or disable tool approval requirement
76
94
  * When enabled, text_editor operations will emit 'tool:approval_required' events
@@ -12,7 +12,7 @@ import { buildSystemPrompt } from "../utils/prompt-builder.js";
12
12
  import { extractErrorMessage } from "../utils/error-handler.js";
13
13
  import { getCheckpointManager } from "../checkpoint/index.js";
14
14
  import { SubagentOrchestrator } from "./subagent-orchestrator.js";
15
- import { getTaskPlanner, isComplexRequest, } from "../planner/index.js";
15
+ import { getTaskPlanner, isComplexRequest, shouldUseThinkingMode, getComplexityScore, } from "../planner/index.js";
16
16
  // Note: TaskPhase now used by PlanExecutor (Phase 2 refactoring)
17
17
  import { PLANNER_CONFIG } from "../constants.js";
18
18
  import { resolveMCPReferences, extractMCPReferences } from "../mcp/resources.js";
@@ -57,6 +57,10 @@ export class LLMAgent extends EventEmitter {
57
57
  samplingConfig;
58
58
  /** Thinking/reasoning mode configuration */
59
59
  thinkingConfig;
60
+ /** Track if auto-thinking was enabled for current message (for UI indicator) */
61
+ autoThinkingEnabled = false;
62
+ /** User's explicit thinking preference (undefined = auto, true/false = explicit) */
63
+ userThinkingPreference = undefined;
60
64
  /** Stored reference to context overflow listener for proper cleanup */
61
65
  contextOverflowListener;
62
66
  /** Track if agent has been disposed */
@@ -226,9 +230,15 @@ export class LLMAgent extends EventEmitter {
226
230
  /**
227
231
  * Set thinking/reasoning mode configuration for this agent session
228
232
  * @param config Thinking configuration to apply (enabled/disabled)
233
+ * @param isUserExplicit Whether this is an explicit user preference (vs auto-detection)
229
234
  */
230
- setThinkingConfig(config) {
235
+ setThinkingConfig(config, isUserExplicit = true) {
231
236
  this.thinkingConfig = config;
237
+ // Track user's explicit preference to respect their choice over auto-detection
238
+ if (isUserExplicit) {
239
+ this.userThinkingPreference = config?.type === 'enabled' ? true :
240
+ config?.type === 'disabled' ? false : undefined;
241
+ }
232
242
  }
233
243
  /**
234
244
  * Get current thinking configuration
@@ -236,12 +246,57 @@ export class LLMAgent extends EventEmitter {
236
246
  getThinkingConfig() {
237
247
  return this.thinkingConfig;
238
248
  }
249
+ /**
250
+ * Check if auto-thinking was enabled for the current message
251
+ * Used by UI to show indicator when thinking was auto-activated
252
+ */
253
+ isAutoThinkingEnabled() {
254
+ return this.autoThinkingEnabled;
255
+ }
239
256
  /**
240
257
  * Get current sampling configuration
241
258
  */
242
259
  getSamplingConfig() {
243
260
  return this.samplingConfig;
244
261
  }
262
+ /**
263
+ * Apply auto-thinking mode detection for a user message
264
+ * Only activates if user hasn't explicitly set a preference
265
+ *
266
+ * @param message User's message text
267
+ * @returns true if thinking mode was auto-enabled, false otherwise
268
+ */
269
+ applyAutoThinking(message) {
270
+ // Reset auto-thinking state
271
+ this.autoThinkingEnabled = false;
272
+ // If user has explicit preference, respect it
273
+ if (this.userThinkingPreference !== undefined) {
274
+ return false;
275
+ }
276
+ // Check if model supports thinking mode
277
+ const model = this.llmClient.getCurrentModel();
278
+ const modelLower = model.toLowerCase();
279
+ const supportsThinking = modelLower.includes('glm') || modelLower.includes('4.6');
280
+ if (!supportsThinking) {
281
+ return false;
282
+ }
283
+ // Check if message would benefit from thinking mode
284
+ if (shouldUseThinkingMode(message)) {
285
+ const complexity = getComplexityScore(message);
286
+ // Only auto-enable for moderately complex or higher tasks
287
+ if (complexity >= 25) {
288
+ this.thinkingConfig = { type: 'enabled' };
289
+ this.autoThinkingEnabled = true;
290
+ // Emit event for UI to show indicator
291
+ this.emit('auto_thinking_enabled', {
292
+ complexity,
293
+ message: message.substring(0, 100)
294
+ });
295
+ return true;
296
+ }
297
+ }
298
+ return false;
299
+ }
245
300
  /**
246
301
  * Enable or disable tool approval requirement
247
302
  * When enabled, text_editor operations will emit 'tool:approval_required' events
@@ -840,6 +895,8 @@ export class LLMAgent extends EventEmitter {
840
895
  async processUserMessage(message) {
841
896
  // Check if agent has been disposed
842
897
  this.checkDisposed();
898
+ // GLM-4.6 OPTIMIZATION: Auto-enable thinking mode for complex tasks
899
+ this.applyAutoThinking(message);
843
900
  // Reset tool call tracking for new message
844
901
  this.resetToolCallTracking();
845
902
  // Resolve MCP resource references (Phase 4)
@@ -1165,6 +1222,16 @@ export class LLMAgent extends EventEmitter {
1165
1222
  async *processUserMessageStream(message) {
1166
1223
  // Create new abort controller for this request
1167
1224
  this.abortController = new AbortController();
1225
+ // GLM-4.6 OPTIMIZATION: Auto-enable thinking mode for complex tasks
1226
+ // This detects requests that would benefit from extended reasoning
1227
+ const autoThinkingApplied = this.applyAutoThinking(message);
1228
+ if (autoThinkingApplied) {
1229
+ // Notify UI that thinking mode was auto-enabled
1230
+ yield {
1231
+ type: "content",
1232
+ content: "🧠 *Auto-thinking enabled for complex task*\n\n"
1233
+ };
1234
+ }
1168
1235
  // Check if this is a complex request that should use multi-phase planning
1169
1236
  if (this.shouldCreatePlan(message)) {
1170
1237
  // Delegate to planning processor