@defai.digital/ax-cli 3.8.7 → 3.8.9

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 (209) hide show
  1. package/README.md +50 -393
  2. package/config-defaults/prompts.yaml +96 -12
  3. package/config-defaults/settings.yaml +3 -0
  4. package/dist/agent/llm-agent.d.ts +11 -2
  5. package/dist/agent/llm-agent.js +75 -104
  6. package/dist/agent/llm-agent.js.map +1 -1
  7. package/dist/agent/loop-detector.d.ts +70 -0
  8. package/dist/agent/loop-detector.js +339 -0
  9. package/dist/agent/loop-detector.js.map +1 -0
  10. package/dist/agent/progress-tracker.d.ts +94 -0
  11. package/dist/agent/progress-tracker.js +222 -0
  12. package/dist/agent/progress-tracker.js.map +1 -0
  13. package/dist/agent/specialized/analysis-agent.js +7 -16
  14. package/dist/agent/specialized/analysis-agent.js.map +1 -1
  15. package/dist/agent/specialized/debug-agent.js +7 -16
  16. package/dist/agent/specialized/debug-agent.js.map +1 -1
  17. package/dist/agent/specialized/documentation-agent.js +7 -16
  18. package/dist/agent/specialized/documentation-agent.js.map +1 -1
  19. package/dist/agent/specialized/performance-agent.js +7 -16
  20. package/dist/agent/specialized/performance-agent.js.map +1 -1
  21. package/dist/agent/specialized/refactoring-agent.js +7 -16
  22. package/dist/agent/specialized/refactoring-agent.js.map +1 -1
  23. package/dist/agent/specialized/testing-agent.js +7 -16
  24. package/dist/agent/specialized/testing-agent.js.map +1 -1
  25. package/dist/agent/status-reporter.js +2 -2
  26. package/dist/agent/status-reporter.js.map +1 -1
  27. package/dist/agent/subagent-types.d.ts +6 -0
  28. package/dist/agent/subagent-types.js +43 -56
  29. package/dist/agent/subagent-types.js.map +1 -1
  30. package/dist/agent/subagent.js +3 -3
  31. package/dist/agent/subagent.js.map +1 -1
  32. package/dist/analyzers/git/churn-calculator.js +2 -1
  33. package/dist/analyzers/git/churn-calculator.js.map +1 -1
  34. package/dist/checkpoint/storage.js +6 -4
  35. package/dist/checkpoint/storage.js.map +1 -1
  36. package/dist/commands/cache.js +8 -6
  37. package/dist/commands/cache.js.map +1 -1
  38. package/dist/commands/doctor.js +19 -27
  39. package/dist/commands/doctor.js.map +1 -1
  40. package/dist/commands/init.js +6 -5
  41. package/dist/commands/init.js.map +1 -1
  42. package/dist/commands/mcp-migrate.js +6 -5
  43. package/dist/commands/mcp-migrate.js.map +1 -1
  44. package/dist/commands/memory.js +8 -8
  45. package/dist/commands/memory.js.map +1 -1
  46. package/dist/commands/models.js +8 -12
  47. package/dist/commands/models.js.map +1 -1
  48. package/dist/commands/plan.js +1 -10
  49. package/dist/commands/plan.js.map +1 -1
  50. package/dist/commands/setup.js +5 -4
  51. package/dist/commands/setup.js.map +1 -1
  52. package/dist/commands/status.js +4 -4
  53. package/dist/commands/status.js.map +1 -1
  54. package/dist/constants.d.ts +50 -0
  55. package/dist/constants.js +55 -4
  56. package/dist/constants.js.map +1 -1
  57. package/dist/hooks/hook-runner.d.ts +138 -0
  58. package/dist/hooks/hook-runner.js +429 -0
  59. package/dist/hooks/hook-runner.js.map +1 -0
  60. package/dist/hooks/index.d.ts +6 -0
  61. package/dist/hooks/index.js +7 -0
  62. package/dist/hooks/index.js.map +1 -0
  63. package/dist/index.js +1 -19
  64. package/dist/index.js.map +1 -1
  65. package/dist/llm/tools.js +41 -43
  66. package/dist/llm/tools.js.map +1 -1
  67. package/dist/mcp/automatosx-loader.js +2 -1
  68. package/dist/mcp/automatosx-loader.js.map +1 -1
  69. package/dist/mcp/config-migrator.js +3 -2
  70. package/dist/mcp/config-migrator.js.map +1 -1
  71. package/dist/mcp/config-v2.d.ts +5 -0
  72. package/dist/mcp/config-v2.js +26 -0
  73. package/dist/mcp/config-v2.js.map +1 -1
  74. package/dist/mcp/error-formatter.js +4 -1
  75. package/dist/mcp/error-formatter.js.map +1 -1
  76. package/dist/mcp/reconnection.js +2 -1
  77. package/dist/mcp/reconnection.js.map +1 -1
  78. package/dist/mcp/registry.js +3 -2
  79. package/dist/mcp/registry.js.map +1 -1
  80. package/dist/mcp/resources.js +2 -1
  81. package/dist/mcp/resources.js.map +1 -1
  82. package/dist/mcp/validation.js +9 -0
  83. package/dist/mcp/validation.js.map +1 -1
  84. package/dist/memory/context-store.js +4 -6
  85. package/dist/memory/context-store.js.map +1 -1
  86. package/dist/memory/types.d.ts +2 -0
  87. package/dist/memory/types.js +4 -1
  88. package/dist/memory/types.js.map +1 -1
  89. package/dist/permissions/index.d.ts +6 -0
  90. package/dist/permissions/index.js +7 -0
  91. package/dist/permissions/index.js.map +1 -0
  92. package/dist/permissions/permission-manager.d.ts +145 -0
  93. package/dist/permissions/permission-manager.js +401 -0
  94. package/dist/permissions/permission-manager.js.map +1 -0
  95. package/dist/planner/task-planner.js +2 -1
  96. package/dist/planner/task-planner.js.map +1 -1
  97. package/dist/schemas/index.d.ts +2 -2
  98. package/dist/schemas/settings-schemas.d.ts +0 -14
  99. package/dist/schemas/settings-schemas.js +0 -10
  100. package/dist/schemas/settings-schemas.js.map +1 -1
  101. package/dist/schemas/tool-schemas.d.ts +2 -2
  102. package/dist/schemas/yaml-schemas.d.ts +62 -0
  103. package/dist/schemas/yaml-schemas.js +4 -0
  104. package/dist/schemas/yaml-schemas.js.map +1 -1
  105. package/dist/tools/bash.js +6 -5
  106. package/dist/tools/bash.js.map +1 -1
  107. package/dist/tools/confirmation-tool.js +3 -2
  108. package/dist/tools/confirmation-tool.js.map +1 -1
  109. package/dist/tools/registry.d.ts +1 -1
  110. package/dist/tools/registry.js +2 -1
  111. package/dist/tools/registry.js.map +1 -1
  112. package/dist/tools/text-editor.d.ts +9 -0
  113. package/dist/tools/text-editor.js +169 -0
  114. package/dist/tools/text-editor.js.map +1 -1
  115. package/dist/tools/todo-tool.js +3 -2
  116. package/dist/tools/todo-tool.js.map +1 -1
  117. package/dist/ui/components/tool-group-display.js +0 -6
  118. package/dist/ui/components/tool-group-display.js.map +1 -1
  119. package/dist/ui/hooks/use-input-handler.js +7 -6
  120. package/dist/ui/hooks/use-input-handler.js.map +1 -1
  121. package/dist/ui/hooks/use-input-history.js +4 -4
  122. package/dist/ui/hooks/use-input-history.js.map +1 -1
  123. package/dist/ui/utils/tool-grouper.d.ts +1 -2
  124. package/dist/ui/utils/tool-grouper.js +4 -15
  125. package/dist/ui/utils/tool-grouper.js.map +1 -1
  126. package/dist/utils/audit-logger.js +2 -1
  127. package/dist/utils/audit-logger.js.map +1 -1
  128. package/dist/utils/config-loader.d.ts +4 -0
  129. package/dist/utils/config-loader.js.map +1 -1
  130. package/dist/utils/encryption.js +2 -1
  131. package/dist/utils/encryption.js.map +1 -1
  132. package/dist/utils/file-cache.js +4 -2
  133. package/dist/utils/file-cache.js.map +1 -1
  134. package/dist/utils/history-manager.js +6 -6
  135. package/dist/utils/history-manager.js.map +1 -1
  136. package/dist/utils/onboarding-manager.js +2 -1
  137. package/dist/utils/onboarding-manager.js.map +1 -1
  138. package/dist/utils/path-helpers.js +3 -2
  139. package/dist/utils/path-helpers.js.map +1 -1
  140. package/dist/utils/path-security.js +3 -2
  141. package/dist/utils/path-security.js.map +1 -1
  142. package/dist/utils/prompt-builder.js +4 -0
  143. package/dist/utils/prompt-builder.js.map +1 -1
  144. package/dist/utils/settings-manager.d.ts +1 -21
  145. package/dist/utils/settings-manager.js +6 -86
  146. package/dist/utils/settings-manager.js.map +1 -1
  147. package/dist/utils/streaming-analyzer.d.ts +2 -13
  148. package/dist/utils/streaming-analyzer.js +3 -25
  149. package/dist/utils/streaming-analyzer.js.map +1 -1
  150. package/dist/utils/template-manager.js +9 -8
  151. package/dist/utils/template-manager.js.map +1 -1
  152. package/dist/utils/token-counter.d.ts +8 -1
  153. package/dist/utils/token-counter.js +14 -5
  154. package/dist/utils/token-counter.js.map +1 -1
  155. package/package.json +3 -2
  156. package/packages/schemas/README.md +1 -1
  157. package/packages/schemas/package.json +1 -1
  158. package/.ax-cli/CUSTOM.md +0 -97
  159. package/.ax-cli/auto-accept-audit.json +0 -1302
  160. package/.ax-cli/index.json +0 -43
  161. package/.ax-cli/memory.json +0 -55
  162. package/.ax-cli/settings.json +0 -12
  163. package/ax.config.json +0 -303
  164. package/dist/tools/web-search/cache.d.ts +0 -62
  165. package/dist/tools/web-search/cache.js +0 -105
  166. package/dist/tools/web-search/cache.js.map +0 -1
  167. package/dist/tools/web-search/engines/crates.d.ts +0 -19
  168. package/dist/tools/web-search/engines/crates.js +0 -87
  169. package/dist/tools/web-search/engines/crates.js.map +0 -1
  170. package/dist/tools/web-search/engines/npm.d.ts +0 -18
  171. package/dist/tools/web-search/engines/npm.js +0 -86
  172. package/dist/tools/web-search/engines/npm.js.map +0 -1
  173. package/dist/tools/web-search/engines/pypi.d.ts +0 -18
  174. package/dist/tools/web-search/engines/pypi.js +0 -75
  175. package/dist/tools/web-search/engines/pypi.js.map +0 -1
  176. package/dist/tools/web-search/engines/stackoverflow.d.ts +0 -30
  177. package/dist/tools/web-search/engines/stackoverflow.js +0 -130
  178. package/dist/tools/web-search/engines/stackoverflow.js.map +0 -1
  179. package/dist/tools/web-search/engines/wikipedia.d.ts +0 -27
  180. package/dist/tools/web-search/engines/wikipedia.js +0 -112
  181. package/dist/tools/web-search/engines/wikipedia.js.map +0 -1
  182. package/dist/tools/web-search/index.d.ts +0 -11
  183. package/dist/tools/web-search/index.js +0 -11
  184. package/dist/tools/web-search/index.js.map +0 -1
  185. package/dist/tools/web-search/router.d.ts +0 -36
  186. package/dist/tools/web-search/router.js +0 -270
  187. package/dist/tools/web-search/router.js.map +0 -1
  188. package/dist/tools/web-search/types.d.ts +0 -45
  189. package/dist/tools/web-search/types.js +0 -6
  190. package/dist/tools/web-search/types.js.map +0 -1
  191. package/dist/tools/web-search/web-search-tool.d.ts +0 -51
  192. package/dist/tools/web-search/web-search-tool.js +0 -262
  193. package/dist/tools/web-search/web-search-tool.js.map +0 -1
  194. package/packages/schemas/dist/index.d.ts +0 -14
  195. package/packages/schemas/dist/index.d.ts.map +0 -1
  196. package/packages/schemas/dist/index.js +0 -19
  197. package/packages/schemas/dist/index.js.map +0 -1
  198. package/packages/schemas/dist/public/core/brand-types.d.ts +0 -308
  199. package/packages/schemas/dist/public/core/brand-types.d.ts.map +0 -1
  200. package/packages/schemas/dist/public/core/brand-types.js +0 -243
  201. package/packages/schemas/dist/public/core/brand-types.js.map +0 -1
  202. package/packages/schemas/dist/public/core/enums.d.ts +0 -227
  203. package/packages/schemas/dist/public/core/enums.d.ts.map +0 -1
  204. package/packages/schemas/dist/public/core/enums.js +0 -222
  205. package/packages/schemas/dist/public/core/enums.js.map +0 -1
  206. package/packages/schemas/dist/public/core/id-types.d.ts +0 -286
  207. package/packages/schemas/dist/public/core/id-types.d.ts.map +0 -1
  208. package/packages/schemas/dist/public/core/id-types.js +0 -136
  209. package/packages/schemas/dist/public/core/id-types.js.map +0 -1
package/README.md CHANGED
@@ -20,12 +20,11 @@
20
20
 
21
21
  - [🚀 Quick Start](#-quick-start)
22
22
  - [✨ Features](#-features)
23
- - [🎉 What's New](#-whats-new-in-v384)
23
+ - [🎉 What's New](#-whats-new-in-v389)
24
24
  - [📦 Installation](#-installation)
25
25
  - [⚙️ Configuration](#️-configuration)
26
26
  - [🔒 Security](#-security--api-key-handling)
27
27
  - [🎯 Usage Examples](#-usage-examples)
28
- - [🌐 Web Search](#-web-search)
29
28
  - [🔌 MCP Integration](#-mcp-model-context-protocol)
30
29
  - [🧠 Project Memory](#-project-memory)
31
30
  - [🎯 Multi-Phase Planner](#-multi-phase-task-planner-v300)
@@ -100,19 +99,6 @@ ax-cli
100
99
  - **Verbose mode**: Full details for debugging
101
100
  - Press `Ctrl+O` to cycle between levels
102
101
  - Auto-expands errors with full details
103
- - **💬 Dual-Model Mode**: Use different models for chat vs coding
104
- - Configure chat and coding models separately
105
- - Manual model switching with `--chat-mode` flag
106
- - Optimize cost and performance for different task types
107
- - **🌐 Web Search**: Real-time package search capabilities
108
- - **Works out-of-the-box**: npm, PyPI, and crates.io package search (no API keys required)
109
- - **Intelligent routing**: Automatically selects the best engine based on query intent
110
- - JavaScript/Node.js packages → npm registry search
111
- - Python packages → PyPI registry search
112
- - Rust packages → crates.io registry search
113
- - Results caching for faster responses (5 minute TTL)
114
- - Support for package discovery, dependency research, and version information
115
- - Session-based context for iterative package exploration
116
102
  - **🔄 Auto-Update**: Built-in update checker and installer
117
103
  - **🔒 Enterprise-Grade Security**: **FREE & Open Source**
118
104
  - **Command Injection Protection**: CVSS 9.8 CRITICAL fix - Safe command execution with whitelisting
@@ -164,6 +150,55 @@ AX CLI uses **industry-standard max tokens** based on research of leading AI cod
164
150
 
165
151
  [View all features →](docs/features.md)
166
152
 
153
+ ## 🎉 What's New in v3.8.9
154
+
155
+ **Refactoring & Configuration Improvements** - Further centralization and code quality enhancements:
156
+
157
+ ### 🔧 Improvements
158
+
159
+ - **Centralized file name constants** - Added `FILE_NAMES` constant object to eliminate hard-coded file names across the codebase
160
+ - **Extended CONFIG_PATHS** - Added new path constants for CUSTOM_MD, INDEX_JSON, MEMORY_JSON, and user directories
161
+ - **Unified path handling** - Replaced 15+ hard-coded `.ax-cli` path references with centralized constants
162
+ - **Improved text editor tool** - Enhanced functionality and reliability
163
+ - **Subagent types refinement** - Streamlined specialized agent type definitions
164
+ - **Prompt improvements** - Enhanced default prompts configuration
165
+
166
+ ### ✅ Quality
167
+
168
+ - TypeScript strict mode passes
169
+ - Build succeeds
170
+ - 76/77 test files pass
171
+ - Zero breaking changes
172
+
173
+ ---
174
+
175
+ ## 🎉 What's New in v3.8.8
176
+
177
+ **Code Quality & Maintainability Release** - Major refactoring for improved code consistency:
178
+
179
+ ### 🔧 Improvements
180
+
181
+ - **Centralized configuration constants** - Added `CONFIG_DIR_NAME` constant to eliminate hard-coded `.ax-cli` strings across 15+ files
182
+ - **Unified error handling** - Replaced inline `error instanceof Error ? error.message : String(error)` patterns with `extractErrorMessage()` utility across 20+ files
183
+ - **Improved ES module consistency** - Converted inline `require()` calls to proper ES module imports
184
+ - **Better home directory handling** - Replaced `process.env.HOME || process.env.USERPROFILE` patterns with Node.js `homedir()` function
185
+ - **Removed examples folder** - Cleaned up unused example files
186
+
187
+ ### ✅ Quality
188
+
189
+ - All tests passing
190
+ - 98%+ test coverage maintained
191
+ - Zero breaking changes
192
+ - Improved code maintainability
193
+
194
+ ---
195
+
196
+ ## 🎉 What's New in v3.8.7
197
+
198
+ **Critical Bug Fixes & Resilience Improvements** - Stability and reliability enhancements.
199
+
200
+ ---
201
+
167
202
  ## 🎉 What's New in v3.8.6
168
203
 
169
204
  **Patch Release** - Bug fixes and stability improvements:
@@ -738,374 +773,6 @@ The `doctor` command checks:
738
773
  - ✓ MCP server configuration
739
774
  - ✓ Dependencies (ripgrep, git)
740
775
 
741
- ## 💬 Dual-Model Mode
742
-
743
- Use different models for chat vs coding tasks to optimize performance and cost:
744
-
745
- ### Configuration
746
-
747
- **Option 1: Project Settings** (recommended for project-specific preferences)
748
-
749
- Add to `.ax-cli/settings.json` in your project directory:
750
-
751
- ```json
752
- {
753
- "dualModel": {
754
- "enabled": true,
755
- "chatModel": "grok-code-fast-1",
756
- "codingModel": "glm-4.6"
757
- }
758
- }
759
- ```
760
-
761
- **Option 2: Environment Variables** (for temporary or CI/CD use)
762
-
763
- ### Usage
764
-
765
- ```bash
766
- # Use faster chat model for questions
767
- ax-cli --chat-mode -p "explain what this project does"
768
-
769
- # Use coding model (default) for implementation
770
- ax-cli -p "implement user authentication"
771
-
772
- # In interactive mode, default is coding model
773
- ax-cli
774
- ```
775
-
776
- ### Environment Variables
777
-
778
- ```bash
779
- # Enable dual-model mode
780
- export AI_DUAL_MODEL_ENABLED=true
781
- export AI_CHAT_MODEL=grok-code-fast-1
782
- export AI_CODING_MODEL=glm-4.6
783
-
784
- ax-cli --chat-mode
785
- ```
786
-
787
- **Benefits:**
788
- - 💰 **Cost savings**: Use faster/cheaper models for simple queries
789
- - ⚡ **Better performance**: Match model capability to task complexity
790
- - 🎯 **Manual control**: You decide when to use each model
791
-
792
- ## 🌐 Web Search
793
-
794
- Search package registries for JavaScript, Python, and Rust packages with intelligent language detection and cross-registry comparison.
795
-
796
- ### ✨ Works Out of the Box!
797
-
798
- **Package search is enabled by default** (no API key required):
799
- - **npm** - JavaScript/Node.js packages from npmjs.com
800
- - **PyPI** - Python packages from pypi.org
801
- - **crates.io** - Rust packages from crates.io
802
-
803
- ### Quick Setup
804
-
805
- **No setup required!** Package search works immediately:
806
- - **npm** - JavaScript/Node.js packages work immediately
807
- - **PyPI** - Python packages work immediately
808
- - **crates.io** - Rust packages work immediately
809
- - Perfect for package discovery and dependency management
810
- - No API keys needed
811
-
812
- ### Usage
813
-
814
- ```bash
815
- # The AI will automatically use web search when needed
816
- ax-cli
817
-
818
- > "Find a React state management library" # Uses npm search
819
- > "Search for axios npm package" # Uses npm search
820
- > "Find a Python data analysis library" # Uses PyPI search
821
- > "Search for tokio rust crate" # Uses crates.io search
822
- ```
823
-
824
- ### How It Works
825
-
826
- - **Intelligent Routing**: Automatically selects the best search engine based on query type and language detection
827
- - **JavaScript/Node.js packages** → npm registry search (always available, no API key)
828
- - **Python packages** → PyPI registry search (always available, no API key)
829
- - **Rust packages** → crates.io registry search (always available, no API key)
830
- - **General/technical queries** → package search fallback
831
-
832
- - **Language Detection**: Automatically detects programming language from keywords
833
- - Python keywords (pip, django, flask, pandas) → PyPI
834
- - Rust keywords (cargo, crate, tokio, serde) → crates.io
835
- - npm/package keywords → npm registry
836
- - Multiple engines may be used in parallel for best results
837
-
838
- - **Automatic Caching**: Results cached for 5 minutes for faster subsequent queries
839
-
840
- - **LLM Integration**: The AI automatically uses package search for:
841
- - Package discovery and dependency management
842
- - Version compatibility checks
843
- - Alternative package recommendations
844
- - Package documentation and usage information
845
-
846
- ### Features
847
-
848
- - **Multi-Registry Package Search**: Search across npm, PyPI, and crates.io simultaneously
849
- - Package metadata, descriptions, and download statistics
850
- - Version information and release dates
851
- - No API keys or setup required
852
- - **Source Attribution**: All results include URLs and sources
853
- - **Parallel Search**: Multiple engines searched concurrently for comprehensive results
854
-
855
- ### Manual Usage
856
-
857
- While the AI uses web search automatically, you can also request it explicitly:
858
-
859
- ```bash
860
- # In interactive mode
861
- > "search npm for a markdown parser library"
862
- > "search PyPI for a web scraping package"
863
- > "search crates.io for async runtime"
864
-
865
- # Headless mode
866
- ax-cli -p "search for react-query npm package"
867
- ax-cli -p "find a Python FastAPI alternative"
868
- ```
869
-
870
- ### Web Search Session
871
-
872
- AX CLI maintains intelligent search context across your conversation, enabling natural follow-up questions and iterative refinement:
873
-
874
- **Session Continuity:**
875
- - Package search results are preserved in conversation context
876
- - Ask follow-up questions about packages without re-searching
877
- - Reference previous search results naturally
878
- - Session context includes package URLs, metadata, versions, and download stats
879
-
880
- **Example Session:**
881
-
882
- ```bash
883
- ax-cli
884
-
885
- # Initial package search
886
- > "search npm for a state management library"
887
- 🔍 Searching npm registry...
888
- Found 5 packages:
889
-
890
- 1. **zustand** (2.5M weekly downloads)
891
- Small, fast and scalable state-management
892
- Latest: v4.4.7 | Size: 1.2KB gzipped
893
-
894
- 2. **redux** (8.1M weekly downloads)
895
- Predictable state container for JavaScript apps
896
- Latest: v5.0.0 | Size: 6.2KB (core only)
897
-
898
- 3. **mobx** (1.2M weekly downloads)
899
- Simple, scalable state management
900
- Latest: v6.12.0 | Size: 16KB
901
- ...
902
-
903
- # Natural follow-up (uses cached context from npm search)
904
- > "which one has the smallest bundle size?"
905
- Based on the npm search results:
906
- - ✅ zustand: 1.2KB (gzipped) - Smallest
907
- - jotai: 2.9KB (gzipped)
908
- - redux: 6.2KB (core only)
909
- - mobx: 16KB
910
-
911
- # Version and compatibility check
912
- > "what's the latest version of zustand and does it support React 18?"
913
- Package: zustand v4.4.7 (latest)
914
- ✅ Full React 18 support with concurrent features
915
- ✅ TypeScript 5.0+ support
916
- 📅 Last published: 2 weeks ago
917
-
918
- # Installation guide
919
- > "show me how to install and use zustand"
920
- Installation:
921
- npm install zustand
922
-
923
- Basic usage:
924
- [Provides code example from npm documentation]
925
- ```
926
-
927
- **Context-Aware Features:**
928
-
929
- 1. **Result Caching**: Package search results stay in memory for the session
930
- - 5-minute cache for identical queries
931
- - Instant responses for follow-up questions about packages
932
- - No repeated API calls to registries
933
-
934
- 2. **Multi-Turn Package Refinement**:
935
- ```bash
936
- > "search npm for a react table library"
937
- Found: tanstack-table, react-table, ag-grid-react, mui-x-data-grid
938
-
939
- > "which ones have TypeScript support?"
940
- All 4 packages support TypeScript:
941
- - @tanstack/react-table: Full TS rewrite
942
- - react-table (deprecated, use @tanstack)
943
- - ag-grid-react: TypeScript included
944
- - @mui/x-data-grid: Full TS support
945
-
946
- > "which has the best documentation?"
947
- Based on npm stats and GitHub stars:
948
- - @tanstack/react-table: Excellent docs, 24K stars
949
-
950
- > "install that one"
951
- npm install @tanstack/react-table
952
- ```
953
-
954
- 3. **Cross-Registry Context**:
955
- ```bash
956
- > "search for data validation libraries"
957
- Searching npm, PyPI, and crates.io...
958
-
959
- npm: zod, yup, joi, ajv
960
- PyPI: pydantic, marshmallow, cerberus
961
- crates.io: serde, validator
962
-
963
- > "compare the JavaScript and Python options"
964
- **JavaScript (npm):**
965
- - zod: 3.5M/week, TypeScript-first, 30KB
966
- - yup: 5.2M/week, Schema builder, 45KB
967
-
968
- **Python (PyPI):**
969
- - pydantic: 50M/month, Type hints, fast
970
- - marshmallow: 8M/month, Schema validation
971
-
972
- > "which is fastest?"
973
- - JavaScript: zod (TypeScript inference, zero-cost)
974
- - Python: pydantic (uses Rust core, 20x faster than marshmallow)
975
- ```
976
-
977
- 4. **Package Comparison Tables**:
978
- ```bash
979
- > "search npm for http client libraries"
980
- Found: axios, node-fetch, got, ky, superagent
981
-
982
- > "create a comparison table"
983
-
984
- | Package | Weekly DLs | Size | Last Update | Browser | Node |
985
- |-------------|------------|---------|-------------|---------|------|
986
- | axios | 48M | 11.5KB | 2 weeks ago | ✅ | ✅ |
987
- | node-fetch | 35M | 4.5KB | 3 months | ❌ | ✅ |
988
- | got | 23M | 15KB | 1 week ago | ❌ | ✅ |
989
- | ky | 1.2M | 12KB | 2 weeks ago | ✅ | ✅ |
990
-
991
- > "which is best for Node.js backend with retry logic?"
992
- Recommendation: **got**
993
- - Built-in retry with exponential backoff
994
- - HTTP/2 support
995
- - Request cancellation
996
- - Promise & stream support
997
- ```
998
-
999
- **Session Management:**
1000
-
1001
- - **Session Duration**: Active for entire interactive session
1002
- - **History Integration**: Search results included in `--continue` sessions
1003
- - **Memory Commands**:
1004
- ```bash
1005
- /clear # Clears search context and conversation
1006
- /exit # Ends session (context lost)
1007
- ```
1008
- - **Persistent Context**: Use with `--continue` to maintain search context across sessions
1009
-
1010
- **Best Practices:**
1011
-
1012
- 1. **Start Broad, Refine Iteratively**:
1013
- ```bash
1014
- > "search npm for testing libraries"
1015
- Found: jest, vitest, mocha, jasmine, playwright, cypress
1016
-
1017
- > "focus on those for integration testing"
1018
- Integration testing: playwright, cypress, vitest (has browser mode)
1019
-
1020
- > "which has TypeScript support?"
1021
- All 3 have TypeScript:
1022
- - playwright: Native TS
1023
- - cypress: Full TS support
1024
- - vitest: Native TS (Vite-powered)
1025
-
1026
- > "show setup for playwright"
1027
- npm install -D @playwright/test
1028
- [Provides example config and test]
1029
- ```
1030
-
1031
- 2. **Leverage Context for Framework Comparisons**:
1032
- ```bash
1033
- > "search npm for react vue svelte packages"
1034
- Found core packages with download stats:
1035
- - react: 22M/week
1036
- - vue: 5.1M/week
1037
- - svelte: 850K/week
1038
-
1039
- > "compare their package ecosystems"
1040
- **React:** 180K+ packages
1041
- **Vue:** 45K+ packages
1042
- **Svelte:** 8K+ packages
1043
-
1044
- > "which has better TypeScript support?"
1045
- All have excellent TS support:
1046
- - React: @types/react (20M/week)
1047
- - Vue: Built-in TS (Vue 3+)
1048
- - Svelte: svelte-check + TypeScript plugin
1049
- ```
1050
-
1051
- 3. **Version Compatibility Checks**:
1052
- ```bash
1053
- > "search npm for next auth package"
1054
- Found: next-auth (8M/week, v4.24.5)
1055
-
1056
- > "does it work with Next.js 15?"
1057
- ⚠️ Compatibility:
1058
- - next-auth v4: Next.js 12-14
1059
- - For Next.js 15: Use NextAuth.js v5 (beta)
1060
-
1061
- > "show me the v5 package"
1062
- Package: next-auth@beta (v5.0.0-beta.4)
1063
- ✅ Next.js 15 compatible
1064
- [Installation and migration guide]
1065
- ```
1066
-
1067
- 4. **Combine Search with Development Tasks**:
1068
- ```bash
1069
- > "search npm for a markdown parser library"
1070
- Found: marked, remark, markdown-it, showdown
1071
-
1072
- > "which is fastest and most secure?"
1073
- Recommendation: **marked**
1074
- - 13M/week downloads
1075
- - Fast (built-in sanitization)
1076
- - Active maintenance
1077
-
1078
- > "install marked and show me basic usage"
1079
- Installing: npm install marked
1080
- [Generates code example with marked usage]
1081
-
1082
- > "add it to my project"
1083
- [Creates/updates relevant files with implementation]
1084
- ```
1085
-
1086
- **Performance Tips:**
1087
-
1088
- - **First search**: 1-3 seconds (registry API call)
1089
- - **Follow-up questions**: Instant (uses cached package data)
1090
- - **Cache duration**: 5 minutes per query
1091
- - **Parallel searches**: Multiple registries searched concurrently for cross-language queries
1092
- - **Offline work**: Use `--continue` to preserve search context across sessions
1093
-
1094
- ### Troubleshooting
1095
-
1096
- **No results found**
1097
- - Package registries (npm, PyPI, crates.io) are always available
1098
- - Try refining your search query
1099
- - Check your internet connection
1100
-
1101
- **Rate limit errors**
1102
- - Package registry searches are rate-limited by the registry providers
1103
- - Results are cached to minimize API calls
1104
-
1105
- **Slow searches**
1106
- - Results are cached after first search (5 minute TTL)
1107
- - Subsequent identical queries will be instant
1108
-
1109
776
  ## 🔌 MCP (Model Context Protocol)
1110
777
 
1111
778
  Extend AX CLI with MCP servers for additional capabilities:
@@ -1304,15 +971,6 @@ AX CLI implements enterprise-grade architecture with:
1304
971
  ### v3.6.1 (2025-11-22)
1305
972
 
1306
973
  **🔧 Improvements:**
1307
- - **Web Search Simplification**: Removed Tavily AI dependency, focusing entirely on package registries
1308
- - Streamlined to npm, PyPI, and crates.io package search only
1309
- - No API keys required for web search functionality
1310
- - Reduced dependencies and simplified architecture
1311
- - **Documentation Overhaul**: Completely updated web search documentation
1312
- - 200+ lines updated with package-focused examples
1313
- - 15+ new realistic examples showing npm, PyPI, and crates.io workflows
1314
- - Comprehensive session examples for package discovery and comparison
1315
- - Best practices for cross-registry searches and version compatibility checks
1316
974
  - **Smart Paste Auto-Collapse**: Intelligent handling of large text inputs
1317
975
  - Automatic collapse of 20+ line pastes for better readability
1318
976
  - Press Ctrl+P to expand/collapse pasted content
@@ -1434,7 +1092,6 @@ AX CLI implements enterprise-grade architecture with:
1434
1092
  - Multi-phase task planner with automatic complexity detection
1435
1093
  - Enhanced MCP integration with production-ready templates
1436
1094
  - Project memory system with intelligent context caching
1437
- - Web search capabilities with npm, PyPI, and crates.io package registries
1438
1095
  - Advanced code analysis tools (dependency, security, metrics)
1439
1096
 
1440
1097
  ## 📄 License
@@ -2,17 +2,30 @@
2
2
  # AI assistant instructions and guidelines for AX CLI
3
3
 
4
4
  system_prompt:
5
- identity: "You are AX CLI Assistant, an enterprise-grade AI coding agent specialized in software development, file operations, and intelligent automation. You excel at understanding context, making efficient tool choices, and executing tasks with precision."
5
+ # Professional, humble identity - no marketing jargon
6
+ identity: "You are AX CLI, an AI coding assistant that runs in your terminal. You help developers with software engineering tasks using the tools available to you. Be direct, accurate, and efficient."
7
+
8
+ # Professional objectivity - prioritize truth over user validation
9
+ professional_objectivity:
10
+ title: "PROFESSIONAL OBJECTIVITY"
11
+ content: |
12
+ Prioritize technical accuracy and truthfulness over validating the user's beliefs:
13
+ • Focus on facts and problem-solving, not emotional validation
14
+ • No unnecessary superlatives, praise, or agreement
15
+ • If the user is wrong, respectfully correct them with evidence
16
+ • Don't say "You're absolutely right" or "Great question!" - just answer
17
+ • Investigate claims before confirming them
18
+ • Respectful correction is more valuable than false agreement
6
19
 
7
20
  core_principles:
8
21
  title: "CORE OPERATING PRINCIPLES"
9
22
  guidelines:
10
- - "Speed & Efficiency: Minimize tool calls, maximize output per interaction"
23
+ - "Technical Accuracy: Be correct, not agreeable. Correct mistakes respectfully."
24
+ - "Brevity: Keep responses under 4 lines unless detail is explicitly requested."
11
25
  - "Context Awareness: Understand project structure before acting"
12
26
  - "Precision: Make exact, targeted changes - never broad strokes"
13
27
  - "Self-Correction: Validate your work and fix issues immediately"
14
- - "Minimal Verbosity: Show results, not commentary"
15
- - "Smart Tool Usage: Answer simple questions directly. Only use tools when they provide necessary context for accurate responses."
28
+ - "Smart Tool Usage: Answer simple questions directly. Only use tools when necessary."
16
29
 
17
30
  tools_header: "Available Tools:"
18
31
 
@@ -23,6 +36,8 @@ system_prompt:
23
36
  description: "Create NEW files only. Never use on existing files."
24
37
  - name: str_replace_editor
25
38
  description: "Edit existing files with precise string replacement. Primary editing tool."
39
+ - name: multi_edit
40
+ description: "Make multiple edits to a single file atomically. Use instead of multiple str_replace_editor calls."
26
41
  - name: bash
27
42
  description: "Execute shell commands for git, npm, testing, searching, and system operations"
28
43
  - name: search
@@ -63,8 +78,26 @@ system_prompt:
63
78
  - "NEVER create_file on existing files - instant data loss"
64
79
  - "ALWAYS view_file before str_replace_editor to ensure context"
65
80
  - "Use search when you don't know exact file locations"
66
- - "Use bash for git operations, package management, testing"
67
81
  - "Create todo lists for tasks with 3+ distinct steps"
82
+ - "CONSOLIDATE EDITS: When making multiple changes to the same file, identify ALL changes first, then make ONE str_replace_editor call with a larger old_str block that captures the entire region"
83
+ - "Anti-pattern: Multiple str_replace_editor calls to same file in sequence - always consolidate into single call"
84
+ - "For function rewrites: Include entire function in old_str and replace completely rather than making line-by-line edits"
85
+
86
+ tool_preferences:
87
+ title: "TOOL PREFERENCE HIERARCHY"
88
+ content: |
89
+ PREFER dedicated tools over bash equivalents:
90
+ • search tool > bash grep/rg/find
91
+ • view_file > bash cat/head/tail
92
+ • str_replace_editor > bash sed/awk
93
+ • create_file > bash echo/cat with redirection
94
+
95
+ USE bash ONLY for:
96
+ • git operations (status, diff, commit, push, pull)
97
+ • Package management (npm, pip, cargo)
98
+ • Running tests (npm test, pytest, cargo test)
99
+ • Build commands (npm run build, make)
100
+ • System commands that have no tool equivalent
68
101
 
69
102
  search_and_discovery:
70
103
  title: "EFFICIENT CODEBASE EXPLORATION"
@@ -110,13 +143,15 @@ system_prompt:
110
143
  response_optimization:
111
144
  title: "RESPONSE STYLE"
112
145
  guidelines:
113
- - "NO pleasantries: Skip 'Great!', 'Thanks!', 'Sure thing!'"
114
- - "Show, don't tell: Display results, not descriptions"
115
- - "Explain complex decisions only when necessary"
146
+ - "BREVITY: Keep responses under 4 lines unless user explicitly asks for detail"
147
+ - "One-word answers are preferred when appropriate"
148
+ - "NO preamble: Never start with 'Sure!', 'Great!', 'I'll help you with that', 'Let me...'"
149
+ - "NO summaries: Don't summarize what you just did unless asked"
150
+ - "Show results, not descriptions of what you're about to do"
116
151
  - "Errors: state problem → show fix → done"
117
- - "Success: confirm completion → show key changes"
118
- - "Simple questions: Answer directly without unnecessary tool calls"
119
- - "If you find yourself calling the same tool multiple times with no progress, STOP and provide a direct answer"
152
+ - "Success: confirm completion briefly"
153
+ - "Simple questions: Answer directly without tool calls"
154
+ - "If calling same tool repeatedly with no progress, STOP and answer directly"
120
155
 
121
156
  confirmation_behavior:
122
157
  title: "USER CONFIRMATION FLOW"
@@ -140,6 +175,8 @@ system_prompt:
140
175
  - "Cache understanding: Don't re-read files unnecessarily"
141
176
  - "Use regex in search for pattern matching"
142
177
  - "Leverage bash for bulk file operations"
178
+ - "Edit consolidation: Multiple edits to same file? Include entire function/block in old_str and replace in one call"
179
+ - "Extensive rewrite (>50% of file changing): Consider create_file to overwrite rather than many str_replace_editor calls"
143
180
 
144
181
  error_handling:
145
182
  title: "ERROR HANDLING & VALIDATION"
@@ -150,7 +187,54 @@ system_prompt:
150
187
  - "Auto-fix obvious errors (typos, syntax) immediately"
151
188
  - "Report non-obvious errors with context"
152
189
 
153
- closing: "Operate with precision, speed, and intelligence. You are a professional coding agent - act like one."
190
+ code_conventions:
191
+ title: "CODE STYLE MIMICRY"
192
+ content: |
193
+ IMPORTANT: Before writing any code, examine the existing codebase:
194
+ 1. Indentation style (tabs vs spaces, 2 vs 4 spaces)
195
+ 2. Quote style (single vs double quotes)
196
+ 3. Semicolon usage
197
+ 4. Naming conventions (camelCase, snake_case, PascalCase)
198
+ 5. Import organization patterns
199
+ 6. Comment style and density
200
+
201
+ Rules:
202
+ • Match existing conventions EXACTLY - never introduce new styles
203
+ • Don't add libraries/dependencies without explicit approval
204
+ • NEVER add comments unless logic is non-obvious or user requests them
205
+ • Don't add type annotations to code that doesn't have them
206
+ • Don't "improve" code style unless explicitly asked
207
+
208
+ git_safety:
209
+ title: "GIT SAFETY PROTOCOL"
210
+ content: |
211
+ CRITICAL GIT RULES:
212
+ • NEVER commit unless user explicitly requests ("commit this", "make a commit")
213
+ • NEVER push unless user explicitly requests
214
+ • NEVER amend commits unless explicitly asked
215
+ • NEVER force push
216
+ • NEVER run git commands with -i flag (interactive mode not supported)
217
+
218
+ Before committing:
219
+ 1. Run git status to see changes
220
+ 2. Run git diff to review what will be committed
221
+ 3. Show user what will be committed
222
+ 4. Use meaningful commit messages (not "update files")
223
+
224
+ If user hasn't asked to commit, just make the changes - they will commit when ready.
225
+
226
+ post_change_validation:
227
+ title: "POST-CHANGE VALIDATION"
228
+ content: |
229
+ After making code changes, validate your work:
230
+ 1. If project has lint command (npm run lint, ruff, etc.) - run it
231
+ 2. If project has typecheck (npm run typecheck, mypy, tsc) - run it
232
+ 3. If you modified code with existing tests - run relevant tests
233
+ 4. If validation fails, fix the issues before reporting completion
234
+
235
+ Don't skip validation to save time - catching errors early is faster.
236
+
237
+ closing: "Be direct. Be accurate. Be brief."
154
238
 
155
239
  custom_instructions_prefix: "\n\n=== CUSTOM PROJECT INSTRUCTIONS ===\n"
156
240
  custom_instructions_suffix: "\n=== END CUSTOM INSTRUCTIONS ===\n\nFollow custom instructions while adhering to core principles above."
@@ -6,6 +6,7 @@ agent:
6
6
  default_timeout: 360000 # 6 minutes in milliseconds
7
7
  default_max_tokens: 8192
8
8
  max_recent_tool_calls: 20 # Keep only last 20 unique tool calls
9
+ max_messages: 500 # Maximum number of messages to keep in chat history
9
10
 
10
11
  # Loop Detection (ENABLED BY DEFAULT)
11
12
  # Detects when the AI repeats the same tool call multiple times
@@ -90,6 +91,8 @@ token:
90
91
  cache:
91
92
  default_max_size: 1000
92
93
  default_ttl: 300000 # 5 minutes
94
+ tool_args_cache_max_size: 500 # Max entries for tool call arguments cache
95
+ tool_args_cache_prune_count: 100 # Number of entries to remove when cache is full
93
96
 
94
97
  performance:
95
98
  debounce_delay: 300 # milliseconds
@@ -57,7 +57,6 @@ export declare class LLMAgent extends EventEmitter {
57
57
  private bashOutput;
58
58
  private todoTool;
59
59
  private search;
60
- private webSearch;
61
60
  private _architectureTool?;
62
61
  private _validationTool?;
63
62
  private chatHistory;
@@ -172,13 +171,23 @@ export declare class LLMAgent extends EventEmitter {
172
171
  private get validationTool();
173
172
  /**
174
173
  * Detect if a tool call is repetitive (likely causing a loop)
175
- * Returns true if the same tool with similar arguments was called multiple times recently
174
+ * Uses the intelligent LoopDetector which provides:
175
+ * - Tool-specific thresholds (file ops get higher limits)
176
+ * - Progress-based detection (tracks success/failure)
177
+ * - Cycle pattern detection (A→B→A→B loops)
176
178
  */
177
179
  private isRepetitiveToolCall;
180
+ /** Last loop detection result for error messages */
181
+ private lastLoopResult?;
178
182
  /**
179
183
  * Reset the tool call tracking (called at start of new user message)
180
184
  */
181
185
  private resetToolCallTracking;
186
+ /**
187
+ * Generate a helpful warning message when a loop is detected
188
+ * Uses the lastLoopResult for context-aware suggestions
189
+ */
190
+ private getLoopWarningMessage;
182
191
  /**
183
192
  * Check if a request should trigger multi-phase planning
184
193
  */