@defai.digital/ax-cli 3.5.4 → 3.6.0
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/.ax-cli/memory.json +8 -8
- package/README.md +7 -0
- package/config-defaults/messages.yaml +75 -0
- package/config-defaults/models.yaml +66 -0
- package/config-defaults/prompts.yaml +156 -0
- package/config-defaults/settings.yaml +86 -0
- package/dist/agent/chat-history-manager.d.ts +56 -0
- package/dist/agent/chat-history-manager.js +150 -0
- package/dist/agent/chat-history-manager.js.map +1 -0
- package/dist/agent/llm-agent.js +1 -1
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/tool-manager.d.ts +39 -0
- package/dist/agent/tool-manager.js +76 -0
- package/dist/agent/tool-manager.js.map +1 -0
- package/dist/commands/memory.js +1 -1
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/setup.js +19 -6
- package/dist/commands/setup.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/client.d.ts +1 -0
- package/dist/llm/client.js +44 -0
- package/dist/llm/client.js.map +1 -1
- package/dist/mcp/health.js +4 -2
- package/dist/mcp/health.js.map +1 -1
- package/dist/mcp/ssrf-protection.d.ts +86 -0
- package/dist/mcp/ssrf-protection.js +313 -0
- package/dist/mcp/ssrf-protection.js.map +1 -0
- package/dist/mcp/validation.d.ts +4 -0
- package/dist/mcp/validation.js +122 -11
- package/dist/mcp/validation.js.map +1 -1
- package/dist/schemas/settings-schemas.d.ts +30 -0
- package/dist/schemas/settings-schemas.js +30 -0
- package/dist/schemas/settings-schemas.js.map +1 -1
- package/dist/tools/bash.d.ts +3 -2
- package/dist/tools/bash.js +31 -2
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/search.d.ts +1 -1
- package/dist/tools/search.js +121 -128
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.js +52 -15
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/ui/components/chat-history.js +1 -1
- package/dist/ui/components/chat-history.js.map +1 -1
- package/dist/ui/components/chat-interface.js +3 -2
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/confirmation-dialog.js +1 -1
- package/dist/ui/components/confirmation-dialog.js.map +1 -1
- package/dist/ui/components/status-bar.js +2 -2
- package/dist/ui/components/status-bar.js.map +1 -1
- package/dist/{hooks → ui/hooks}/use-chat-reducer.d.ts +1 -1
- package/dist/ui/hooks/use-chat-reducer.js.map +1 -0
- package/dist/{hooks → ui/hooks}/use-enhanced-input.js +8 -3
- package/dist/ui/hooks/use-enhanced-input.js.map +1 -0
- package/dist/{hooks → ui/hooks}/use-input-handler.d.ts +1 -1
- package/dist/{hooks → ui/hooks}/use-input-handler.js +28 -24
- package/dist/ui/hooks/use-input-handler.js.map +1 -0
- package/dist/utils/audit-logger.d.ts +247 -0
- package/dist/utils/audit-logger.js +374 -0
- package/dist/utils/audit-logger.js.map +1 -0
- package/dist/utils/command-security.d.ts +85 -0
- package/dist/utils/command-security.js +200 -0
- package/dist/utils/command-security.js.map +1 -0
- package/dist/utils/config-loader.js +3 -3
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/encryption.d.ts +78 -0
- package/dist/utils/encryption.js +216 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/error-sanitizer.d.ts +119 -0
- package/dist/utils/error-sanitizer.js +253 -0
- package/dist/utils/error-sanitizer.js.map +1 -0
- package/dist/utils/input-sanitizer.d.ts +210 -0
- package/dist/utils/input-sanitizer.js +362 -0
- package/dist/utils/input-sanitizer.js.map +1 -0
- package/dist/utils/json-utils.d.ts +13 -0
- package/dist/utils/json-utils.js +55 -1
- package/dist/utils/json-utils.js.map +1 -1
- package/dist/utils/path-security.d.ts +90 -0
- package/dist/utils/path-security.js +328 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/process-pool.d.ts +105 -0
- package/dist/utils/process-pool.js +326 -0
- package/dist/utils/process-pool.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +207 -0
- package/dist/utils/rate-limiter.js +303 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/settings-manager.js +99 -6
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/streaming-analyzer.js +9 -21
- package/dist/utils/streaming-analyzer.js.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/use-chat-reducer.js.map +0 -1
- package/dist/hooks/use-enhanced-input.js.map +0 -1
- package/dist/hooks/use-input-handler.js.map +0 -1
- package/dist/hooks/use-input-history.d.ts +0 -9
- package/dist/hooks/use-input-history.js +0 -112
- package/dist/hooks/use-input-history.js.map +0 -1
- /package/dist/{hooks → ui/hooks}/use-chat-reducer.js +0 -0
- /package/dist/{hooks → ui/hooks}/use-enhanced-input.d.ts +0 -0
package/.ax-cli/memory.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 1,
|
|
3
|
-
"created_at": "2025-11-
|
|
4
|
-
"updated_at": "2025-11-
|
|
3
|
+
"created_at": "2025-11-22T11:59:21.278Z",
|
|
4
|
+
"updated_at": "2025-11-22T11:59:21.278Z",
|
|
5
5
|
"project_root": "/Users/akiralam/code/ax-cli",
|
|
6
|
-
"content_hash": "sha256:
|
|
6
|
+
"content_hash": "sha256:213c195995de78eced482260119b8ac69826a6a26f7bffe20ab0e3874b4f0f9f",
|
|
7
7
|
"source": {
|
|
8
8
|
"directories": [
|
|
9
9
|
{
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
]
|
|
44
44
|
},
|
|
45
45
|
"context": {
|
|
46
|
-
"formatted": "# Project Context\n\n\n## Architecture Patterns\n- **Project Type**: cli\n- **Primary Language**: TypeScript\n- **Tech Stack**: React, Vitest, Zod, Commander, Ink, ESM, TypeScript\n- **Package Manager**: npm\n- **Entry Point**: dist/index.js\n- **Module System**: ESM\n- **Test Framework**: vitest\n- **Validation**: zod\n- **Linter**: eslint\n- **Key Directories**: source: src, tests: tests\n\n\n## Directory Structure\n```\nsrc/\n├── agent/\n│ ├── specialized/\n│ │ ├── analysis-agent.ts\n│ │ ├── debug-agent.ts\n│ │ ├── documentation-agent.ts\n│ │ ├── index.ts\n│ │ ├── performance-agent.ts\n│ │ ├── refactoring-agent.ts\n│ │ └── testing-agent.ts\n│ ├── context-manager.ts\n│ ├── context-manager.ts.bak\n│ ├── dependency-resolver.ts\n│ ├── index.ts\n│ ├── llm-agent.ts\n│ ├── llm-agent.ts.backup\n│ ├── subagent-orchestrator.ts\n│ ├── subagent-types.ts\n│ └── subagent.ts\n├── analyzers/\n│ ├── architecture/\n│ │ ├── anti-pattern-detectors/\n│ │ ├── pattern-detectors/\n│ │ ├── architecture-analyzer.ts\n│ │ ├── index.ts\n│ │ └── project-structure-scanner.ts\n│ ├── ast/\n│ │ ├── index.ts\n│ │ ├── node-helpers.ts\n│ │ ├── parser.ts\n│ │ ├── traverser.ts\n│ │ └── types.ts\n│ ├── best-practices/\n│ │ ├── rules/\n│ │ ├── base-rule.ts\n│ │ ├── best-practice-validator.ts\n│ │ ├── index.ts\n│ │ └── types.ts\n│ ├── cache/\n│ │ └── analysis-cache.ts\n│ ├── security/\n│ │ ├── detectors/\n│ │ ├── base-detector.ts\n│ │ ├── index.ts\n│ │ ├── security-analyzer.ts\n│ │ └── types.ts\n│ └── errors.ts\n├── checkpoint/\n│ ├── index.ts\n│ ├── manager.ts\n│ ├── storage.ts\n│ └── types.ts\n├── commands/\n│ ├── init/\n│ │ └── wizard.ts\n│ ├── cache.ts\n│ ├── doctor.ts\n│ ├── frontend.ts\n│ ├── init.ts\n│ ├── mcp.ts\n│ ├── memory.ts\n│ ├── models.ts\n│ ├── plan.ts\n│ ├── rewind.ts\n│ ├── setup.ts\n│ ├── templates.ts\n│ ├── update.ts\n│ └── usage.ts\n├── hooks/\n│ ├── use-chat-reducer.ts\n│ ├── use-enhanced-input.ts\n│ ├── use-input-handler.ts\n│ └── use-input-history.ts\n├── llm/\n│ ├── client.ts\n│ ├── tools.ts\n│ └── types.ts\n├── mcp/\n│ ├── client.ts\n│ ├── config.ts\n│ ├── health.ts\n│ ├── reconnection.ts\n│ ├── registry.ts\n│ ├── resources.ts\n│ ├── templates.ts\n│ ├── transports.ts\n│ └── validation.ts\n├── memory/\n│ ├── context-generator.ts\n│ ├── context-injector.ts\n│ ├── context-store.ts\n│ ├── index.ts\n│ ├── schemas.ts\n│ ├── stats-collector.ts\n│ └── types.ts\n├── planner/\n│ ├── prompts/\n│ │ └── planning-prompt.ts\n│ ├── dependency-resolver.ts\n│ ├── index.ts\n│ ├── plan-generator.ts\n│ ├── plan-storage.ts\n│ ├── task-planner.ts\n│ ├── token-estimator.ts\n│ └── types.ts\n├── schemas/\n│ ├── api-schemas.ts\n│ ├── confirmation-schemas.ts\n│ ├── index-unified.ts\n│ ├── index.ts\n│ ├── README.md\n│ ├── settings-schemas.ts\n│ ├── tool-schemas.ts\n│ └── yaml-schemas.ts\n├── sdk/\n│ ├── index.ts\n│ ├── README.md\n│ └── types.ts\n├── tools/\n│ ├── analysis-tools/\n│ │ ├── architecture-tool.ts\n│ │ └── validation-tool.ts\n│ ├── web-search/\n│ │ ├── engines/\n│ │ ├── cache.ts\n│ │ ├── index.ts\n│ │ ├── router.ts\n│ │ ├── types.ts\n│ │ └── web-search-tool.ts\n│ ├── bash-output.ts\n│ ├── bash.ts\n│ ├── confirmation-tool.ts\n│ ├── index.ts\n│ ├── search.ts\n│ ├── text-editor.ts\n│ └── todo-tool.ts\n├── types/\n│ ├── analysis.ts\n│ ├── index.ts\n│ ├── project-analysis.ts\n│ └── template.ts\n├── ui/\n│ ├── components/\n│ │ ├── api-key-input.tsx\n│ │ ├── chat-history.tsx\n│ │ ├── chat-input.tsx\n│ │ ├── chat-interface.tsx\n│ │ ├── collapsible-tool-result.tsx\n│ │ ├── command-suggestions.tsx\n│ │ ├── confirmation-dialog.tsx\n│ │ ├── diff-renderer.tsx\n│ │ ├── index.ts\n│ │ ├── keyboard-hints.tsx\n│ │ ├── loading-spinner.tsx\n│ │ ├── mcp-status.tsx\n│ │ ├── model-selection.tsx\n│ │ ├── phase-progress.tsx\n│ │ ├── quick-actions.tsx\n│ │ ├── reasoning-display.tsx\n│ │ ├── status-bar.tsx\n│ │ ├── subagent-monitor.tsx\n│ │ ├── toast-notification.tsx\n│ │ ├── virtualized-chat-history.tsx\n│ │ └── welcome-panel.tsx\n│ ├── shared/\n│ │ └── max-sized-box.tsx\n│ ├── utils/\n│ │ ├── code-colorizer.tsx\n│ │ ├── colors.ts\n│ │ └── markdown-renderer.tsx\n│ └── app.tsx\n├── utils/\n│ ├── analysis-logger.ts\n│ ├── automatosx-detector.ts\n│ ├── background-task-manager.ts\n│ ├── cache.ts\n│ ├── config-loader.ts\n│ ├── confirmation-service.ts\n│ ├── console-messenger.ts\n│ ├── custom-instructions.ts\n│ ├── error-handler.ts\n│ ├── error-translator.ts\n│ ├── errors.ts\n│ ├── file-cache.ts\n│ ├── history-manager.ts\n│ ├── incremental-analyzer.ts\n│ ├── index.ts\n│ ├── init-previewer.ts\n│ ├── init-validator.ts\n│ ├── instruction-generator.ts\n│ ├── json-utils.ts\n│ ├── llm-optimized-instruction-generator.ts\n│ ├── message-optimizer.ts\n│ ├── onboarding-manager.ts\n│ ├── parallel-analyzer.ts\n│ ├── path-utils.ts\n│ ├── path-validator.ts\n│ ├── performance.ts\n│ ├── progress-tracker.ts\n│ ├── project-analyzer.ts\n│ ├── prompt-builder.ts\n│ ├── settings-manager.ts\n│ └── ... (9 more)\n├── constants.ts\n└── index.ts\npackages/\n└── schemas/\n ├── __tests__/\n ├── scripts/\n ├── src/\n ├── .eslintrc.js\n ├── package-lock.json\n ├── package.json\n ├── README.md\n ├── tsconfig.json\n └── vitest.config.ts\n```\n\n\n## Key Configuration\n\n### README.md\n\n```\n# AX CLI - Enterprise-Class GLM AI CLI\n\n[](https://github.com/defai-digital/ax-cli/actions/workflows/test.yml)\n[](https://github.com/defai-digital/ax-cli)\n[](https://npm-stat.com/charts.html?package=%40defai.digital%2Fax-\n...\n```\n\n### readme.md\n\n```\n# AX CLI - Enterprise-Class GLM AI CLI\n\n[](https://github.com/defai-digital/ax-cli/actions/workflows/test.yml)\n[](https://github.com/defai-digital/ax-cli)\n[](https://npm-stat.com/charts.html?package=%40defai.digital%2Fax-\n...\n```\n\n### package.json\n\n- **Name**: @defai.digital/ax-cli\n- **Version**: 3.4.1\n- **Description**: Enterprise-Class AI Command Line Interface - Primary support for GLM (General Language Model) with multi-provider AI orchestration powered by AutomatosX.\n- **Type**: module\n- **CLI**: Yes\n- **Dependencies**: @ax-cli/schemas, @clack/prompts, @modelcontextprotocol/sdk, axios, chalk, clipboardy, commander, dotenv, enquirer, fs-extra (+14 more)\n- **Dev Dependencies**: @types/fs-extra, @types/glob, @types/js-yaml, @types/marked-terminal, @types/node, @types/react, @typescript-eslint/eslint-plugin, @typescript-eslint/parser (+6 more)\n- **Scripts**: build, build:schemas, build:bun, dev, dev:node, start\n\n### tsconfig.json\n\n- **Target**: ES2022\n- **Module**: ESNext\n- **Module Resolution**: Bundler\n- **Strict**: true\n- **Output**: ./dist\n\n### .ax-cli/CUSTOM.md\n\n# @defai.digital/ax-cli - Quick Reference\n\n**Type:** cli | **Lang:** TypeScript | **Ver:** v2.3.1\n**Stack:** React, Vitest, Zod, Commander, Ink, ESM, TypeScript\n\n---\n\n## 🎯 Critical Rules\n\n1. **ESM Imports:** Always use `.js` extension: `import { x } from './y.js'`\n2. **Validation:** Use zod for all external inputs\n3. **Types:** Explicit return types required on all functions\n4. **Testing:** 80%+ coverage, test error paths\n5. **Modules:** Use `import/export` (not `require/module.exports`)\n6. **File Organization:** Follow standardized output paths (see below)\n\n---\n\n## 📁 Project File Organization\n\n### Standard Output Paths\n\nAll AI-generated and project artifacts must follow this structure:\n\n```\nautomatosx/\n├── PRD/ # Product Requirement Documents\n│ ├── features/ # Feature specifications\n│ ├── api/ # API documentation\n│ └── archive/ # Old/deprecated PRDs\n├── REPORT/ # Project reports and analysis\n│ ├── status/ # Status reports\n│ ├\n[...truncated]\n\n\n## README Summary\n\n# AX CLI - Enterprise-Class GLM AI CLI\n\n[](https://github.com/defai-digital/ax-cli/actions/workflows/test.yml)\n[](https://github.com/defai-digital/ax-cli)\n[](https://npm-stat.com/charts.html?package=%40defai.digital%2Fax-cli)\n[](https://nodejs.org/)\n[](https://www.typescriptlang.org/)\n[](https://opensource.org/licenses/MIT)\n[](https://www.apple.com/macos/)\n[](https://www.microsoft.com/windows/)\n[](https://ubuntu.com/)\n\n\n\n<p align=\"center\">\n <strong>GLM-Optimized CLI • Enterprise Architecture • 98%+ Test Coverage • TypeScript & Zod</strong>\n</p>\n\n---\n\n## 🚀 Quick Start\n\n```bash\n# Install globally\nnpm install -g @defai.digital/ax-cli\n\n# Configure your API key\nax-cli setup\n\n# Initialize your project\nax-cli init\n\n# Start interactive mode\nax-cli\n```\n\n## ✨ Features\n\n- **🤖 GLM-Focused AI CLI**: Optimized for Z.AI's GLM models (glm-4.6, glm-4-air, glm-4-airx)\n - **Note**: For xAI Grok models, use [grok-cli](https://github.com/superagent-ai/grok-cli)\n - **Note**: For Anthropic Claude models, use [claude-code](https://claude.ai/code)\n- **🧠 GLM 4.6 Optimized**: Primary support for General Language Model with advanced reasoning\n - **32K max tokens** (industry-standard, matches Claude Code CLI)\n - 200K context window, 128K max output capability\n - 30% more token efficient than GLM 4.5\n - Optimized for complex code generation and refactoring\n- **🎯 Multi-Phase Task Planner** (NEW in v3.0.0): Intelligent task decomposition for complex requests\n - Automatic complexity detection (57 keyword patterns)\n - LLM-based plan generation with phases and dependencies\n - Phase-by-phase execution with progress tracking\n - File modification tracking and context pruning between phases\n - Plan management commands: `/plans`, `/plan`, `/phases`, `/pause`, `/resume`, `/skip`, `/abandon`\n- **🔄 Session Continuity**: Directory-specific conversation history with `--continue` flag\n - Preserve context across sessions for multi-day development\n - Each project maintains its own independent history\n - Seamlessly resume conversations where you left off\n- **🔌 Enhanced MCP Integration**: Model Context Protocol with production-ready templates\n - **One-command setup**: `ax-cli mcp add figma --template`\n - **12+ pre-configured templates**: Figma, GitHub, Vercel, Puppeteer, Storybook, Sentry, and more\n - **Tool discovery**: `ax-cli mcp tools <server>` to preview capabilities\n - **Template browser**: `ax-cli mcp browse` for quick navigation\n - **Front-end focused**: Design-to-code workflows with Figma integration\n - **[Complete Guide](docs/mcp-frontend-guide.md)**: Front-end developer workflows\n- **✅ Production-Ready**: 98%+ test coverage, TypeScript strict mode, Zod validation\n- **🎯 Interactive & Headless**: Chat interface or one-shot commands\n- **📝 Smart Project Init**: Automatic project analysis and custom instructions\n- **🧠 Project Memory** (NEW): Intelligent context caching for z.ai GLM-4.6\n - Automatic project scanning and context generation\n - z.ai implicit caching support (50% token savings on repeated context)\n - Cache statistics tracking and efficiency monitoring\n- **🏥 Health Check** (NEW): Comprehensive diagnostics with `ax-cli doctor`\n - Verify configuration, API connectivity, and de\n\n[...truncated]",
|
|
47
|
-
"token_estimate":
|
|
46
|
+
"formatted": "# Project Context\n\n\n## Architecture Patterns\n- **Project Type**: cli\n- **Primary Language**: TypeScript\n- **Tech Stack**: React, Vitest, Zod, Commander, Ink, ESM, TypeScript\n- **Package Manager**: npm\n- **Entry Point**: dist/index.js\n- **Module System**: ESM\n- **Test Framework**: vitest\n- **Validation**: zod\n- **Linter**: eslint\n- **Key Directories**: source: src, tests: tests\n\n\n## Directory Structure\n```\nsrc/\n├── agent/\n│ ├── specialized/\n│ │ ├── analysis-agent.ts\n│ │ ├── debug-agent.ts\n│ │ ├── documentation-agent.ts\n│ │ ├── index.ts\n│ │ ├── performance-agent.ts\n│ │ ├── refactoring-agent.ts\n│ │ └── testing-agent.ts\n│ ├── chat-history-manager.ts\n│ ├── context-manager.ts\n│ ├── dependency-resolver.ts\n│ ├── index.ts\n│ ├── llm-agent.ts\n│ ├── subagent-orchestrator.ts\n│ ├── subagent-types.ts\n│ ├── subagent.ts\n│ └── tool-manager.ts\n├── analyzers/\n│ ├── architecture/\n│ │ ├── anti-pattern-detectors/\n│ │ ├── pattern-detectors/\n│ │ ├── architecture-analyzer.ts\n│ │ ├── index.ts\n│ │ └── project-structure-scanner.ts\n│ ├── ast/\n│ │ ├── index.ts\n│ │ ├── node-helpers.ts\n│ │ ├── parser.ts\n│ │ ├── traverser.ts\n│ │ └── types.ts\n│ ├── best-practices/\n│ │ ├── rules/\n│ │ ├── base-rule.ts\n│ │ ├── best-practice-validator.ts\n│ │ ├── index.ts\n│ │ └── types.ts\n│ ├── cache/\n│ │ └── analysis-cache.ts\n│ ├── code-smells/\n│ │ ├── detectors/\n│ │ ├── base-smell-detector.ts\n│ │ ├── code-smell-analyzer.ts\n│ │ ├── index.ts\n│ │ └── types.ts\n│ ├── dependency/\n│ │ ├── circular-detector.ts\n│ │ ├── coupling-calculator.ts\n│ │ ├── dependency-analyzer.ts\n│ │ ├── dependency-graph.ts\n│ │ ├── index.ts\n│ │ └── types.ts\n│ ├── git/\n│ │ ├── churn-calculator.ts\n│ │ ├── git-analyzer.ts\n│ │ ├── hotspot-detector.ts\n│ │ ├── index.ts\n│ │ └── types.ts\n│ ├── metrics/\n│ │ ├── halstead-calculator.ts\n│ │ ├── index.ts\n│ │ ├── maintainability-calculator.ts\n│ │ ├── metrics-analyzer.ts\n│ │ └── types.ts\n│ ├── security/\n│ │ ├── detectors/\n│ │ ├── base-detector.ts\n│ │ ├── index.ts\n│ │ ├── security-analyzer.ts\n│ │ └── types.ts\n│ └── errors.ts\n├── checkpoint/\n│ ├── index.ts\n│ ├── manager.ts\n│ ├── storage.ts\n│ └── types.ts\n├── commands/\n│ ├── init/\n│ │ └── wizard.ts\n│ ├── cache.ts\n│ ├── doctor.ts\n│ ├── frontend.ts\n│ ├── init.ts\n│ ├── mcp.ts\n│ ├── memory.ts\n│ ├── models.ts\n│ ├── plan.ts\n│ ├── rewind.ts\n│ ├── setup.ts\n│ ├── templates.ts\n│ ├── update.ts\n│ └── usage.ts\n├── llm/\n│ ├── client.ts\n│ ├── tools.ts\n│ └── types.ts\n├── mcp/\n│ ├── client.ts\n│ ├── config.ts\n│ ├── health.ts\n│ ├── reconnection.ts\n│ ├── registry.ts\n│ ├── resources.ts\n│ ├── ssrf-protection.ts\n│ ├── templates.ts\n│ ├── transports.ts\n│ └── validation.ts\n├── memory/\n│ ├── context-generator.ts\n│ ├── context-injector.ts\n│ ├── context-store.ts\n│ ├── index.ts\n│ ├── schemas.ts\n│ ├── stats-collector.ts\n│ └── types.ts\n├── planner/\n│ ├── prompts/\n│ │ └── planning-prompt.ts\n│ ├── dependency-resolver.ts\n│ ├── index.ts\n│ ├── plan-generator.ts\n│ ├── plan-storage.ts\n│ ├── task-planner.ts\n│ ├── token-estimator.ts\n│ └── types.ts\n├── schemas/\n│ ├── api-schemas.ts\n│ ├── confirmation-schemas.ts\n│ ├── index-unified.ts\n│ ├── index.ts\n│ ├── README.md\n│ ├── settings-schemas.ts\n│ ├── tool-schemas.ts\n│ └── yaml-schemas.ts\n├── sdk/\n│ ├── index.ts\n│ ├── README.md\n│ └── types.ts\n├── tools/\n│ ├── analysis-tools/\n│ │ ├── architecture-tool.ts\n│ │ └── validation-tool.ts\n│ ├── web-search/\n│ │ ├── engines/\n│ │ ├── cache.ts\n│ │ ├── index.ts\n│ │ ├── router.ts\n│ │ ├── types.ts\n│ │ └── web-search-tool.ts\n│ ├── analysis-tools.ts\n│ ├── bash-output.ts\n│ ├── bash.ts\n│ ├── confirmation-tool.ts\n│ ├── index.ts\n│ ├── search.ts\n│ ├── text-editor.ts\n│ └── todo-tool.ts\n├── types/\n│ ├── analysis.ts\n│ ├── index.ts\n│ ├── project-analysis.ts\n│ └── template.ts\n├── ui/\n│ ├── components/\n│ │ ├── api-key-input.tsx\n│ │ ├── chat-history.tsx\n│ │ ├── chat-input.tsx\n│ │ ├── chat-interface.tsx\n│ │ ├── collapsible-tool-result.tsx\n│ │ ├── command-suggestions.tsx\n│ │ ├── confirmation-dialog.tsx\n│ │ ├── diff-renderer.tsx\n│ │ ├── index.ts\n│ │ ├── keyboard-hints.tsx\n│ │ ├── loading-spinner.tsx\n│ │ ├── mcp-status.tsx\n│ │ ├── model-selection.tsx\n│ │ ├── phase-progress.tsx\n│ │ ├── quick-actions.tsx\n│ │ ├── reasoning-display.tsx\n│ │ ├── status-bar.tsx\n│ │ ├── subagent-monitor.tsx\n│ │ ├── toast-notification.tsx\n│ │ ├── virtualized-chat-history.tsx\n│ │ └── welcome-panel.tsx\n│ ├── hooks/\n│ │ ├── use-chat-reducer.ts\n│ │ ├── use-enhanced-input.ts\n│ │ ├── use-input-handler.ts\n│ │ └── use-input-history.ts\n│ ├── shared/\n│ │ └── max-sized-box.tsx\n│ ├── utils/\n│ │ ├── code-colorizer.tsx\n│ │ ├── colors.ts\n│ │ └── markdown-renderer.tsx\n│ └── app.tsx\n├── utils/\n│ ├── analysis-logger.ts\n│ ├── audit-logger.ts\n│ ├── automatosx-detector.ts\n│ ├── background-task-manager.ts\n│ ├── cache.ts\n│ ├── command-security.ts\n│ ├── config-loader.ts\n│ ├── confirmation-service.ts\n│ ├── console-messenger.ts\n│ ├── custom-instructions.ts\n│ ├── encryption.ts\n│ ├── error-handler.ts\n│ ├── error-sanitizer.ts\n│ ├── error-translator.ts\n│ ├── errors.ts\n│ ├── file-cache.ts\n│ ├── history-manager.ts\n│ ├── incremental-analyzer.ts\n│ ├── index.ts\n│ ├── init-previewer.ts\n│ ├── init-validator.ts\n│ ├── input-sanitizer.ts\n│ ├── instruction-generator.ts\n│ ├── json-utils.ts\n│ ├── llm-optimized-instruction-generator.ts\n│ ├── message-optimizer.ts\n│ ├── onboarding-manager.ts\n│ ├── parallel-analyzer.ts\n│ ├── path-security.ts\n│ ├── path-utils.ts\n│ └── ... (17 more)\n├── constants.ts\n└── index.ts\npackages/\n└── schemas/\n ├── __tests__/\n ├── scripts/\n ├── src/\n ├── .eslintrc.js\n ├── package-lock.json\n ├── package.json\n ├── README.md\n ├── tsconfig.json\n └── vitest.config.ts\n```\n\n\n## Key Configuration\n\n### README.md\n\n```\n# AX CLI - Enterprise-Class GLM AI CLI\n\n[](https://npm-stat.com/charts.html?package=%40defai.digital%2Fax-cli)\n[](https://github.com/defai-digital/ax-cli/actions/workflows/test.yml)\n[](https://github.com/defai-digital/ax\n...\n```\n\n### readme.md\n\n```\n# AX CLI - Enterprise-Class GLM AI CLI\n\n[](https://npm-stat.com/charts.html?package=%40defai.digital%2Fax-cli)\n[](https://github.com/defai-digital/ax-cli/actions/workflows/test.yml)\n[](https://github.com/defai-digital/ax\n...\n```\n\n### package.json\n\n- **Name**: @defai.digital/ax-cli\n- **Version**: 3.5.4\n- **Description**: Enterprise-Class AI Command Line Interface - Primary support for GLM (General Language Model) with multi-provider AI orchestration powered by AutomatosX.\n- **Type**: module\n- **CLI**: Yes\n- **Dependencies**: @ax-cli/schemas, @clack/prompts, @modelcontextprotocol/sdk, axios, chalk, clipboardy, commander, dotenv, enquirer, fs-extra (+14 more)\n- **Dev Dependencies**: @types/fs-extra, @types/glob, @types/js-yaml, @types/marked-terminal, @types/node, @types/react, @typescript-eslint/eslint-plugin, @typescript-eslint/parser (+6 more)\n- **Scripts**: build, build:schemas, build:bun, dev, dev:node, start\n\n### tsconfig.json\n\n- **Target**: ES2022\n- **Module**: ESNext\n- **Module Resolution**: Bundler\n- **Strict**: true\n- **Output**: ./dist\n\n### .ax-cli/CUSTOM.md\n\n# @defai.digital/ax-cli - Quick Reference\n\n**Type:** cli | **Lang:** TypeScript | **Ver:** v2.3.1\n**Stack:** React, Vitest, Zod, Commander, Ink, ESM, TypeScript\n\n---\n\n## 🎯 Critical Rules\n\n1. **ESM Imports:** Always use `.js` extension: `import { x } from './y.js'`\n2. **Validation:** Use zod for all external inputs\n3. **Types:** Explicit return types required on all functions\n4. **Testing:** 80%+ coverage, test error paths\n5. **Modules:** Use `import/export` (not `require/module.exports`)\n6. **File Organization:** Follow standardized output paths (see below)\n\n---\n\n## 📁 Project File Organization\n\n### Standard Output Paths\n\nAll AI-generated and project artifacts must follow this structure:\n\n```\nautomatosx/\n├── PRD/ # Product Requirement Documents\n│ ├── features/ # Feature specifications\n│ ├── api/ # API documentation\n│ └── archive/ # Old/deprecated PRDs\n├── REPORT/ # Project reports and analysis\n│ ├── status/ # Status reports\n│ ├\n[...truncated]\n\n\n## README Summary\n\n# AX CLI - Enterprise-Class GLM AI CLI\n\n[](https://npm-stat.com/charts.html?package=%40defai.digital%2Fax-cli)\n[](https://github.com/defai-digital/ax-cli/actions/workflows/test.yml)\n[](https://github.com/defai-digital/ax-cli)\n[](https://www.typescriptlang.org/)\n[](https://nodejs.org/)\n[](https://opensource.org/licenses/MIT)\n[](https://www.apple.com/macos/)\n[](https://www.microsoft.com/windows/)\n[](https://ubuntu.com/)\n\n\n\n<p align=\"center\">\n <strong>GLM-Optimized CLI • Enterprise Architecture • 98%+ Test Coverage • TypeScript & Zod</strong>\n</p>\n\n---\n\n## 🚀 Quick Start\n\n```bash\n# Install globally\nnpm install -g @defai.digital/ax-cli\n\n# Configure your API key\nax-cli setup\n\n# Initialize your project\nax-cli init\n\n# Start interactive mode\nax-cli\n```\n\n## ✨ Features\n\n- **🤖 GLM-Focused AI CLI**: Optimized for Z.AI's GLM models (glm-4.6, glm-4-air, glm-4-airx)\n - **Note**: For xAI Grok models, use [grok-cli](https://github.com/superagent-ai/grok-cli)\n - **Note**: For Anthropic Claude models, use [claude-code](https://claude.ai/code)\n- **🧠 GLM 4.6 Optimized**: Primary support for General Language Model with advanced reasoning\n - **32K max tokens** (industry-standard, matches Claude Code CLI)\n - 200K context window, 128K max output capability\n - 30% more token efficient than GLM 4.5\n - Optimized for complex code generation and refactoring\n- **🎯 Multi-Phase Task Planner** (NEW in v3.0.0): Intelligent task decomposition for complex requests\n - Automatic complexity detection (57 keyword patterns)\n - LLM-based plan generation with phases and dependencies\n - Phase-by-phase execution with progress tracking\n - File modification tracking and context pruning between phases\n - Plan management commands: `/plans`, `/plan`, `/phases`, `/pause`, `/resume`, `/skip`, `/abandon`\n- **🔄 Session Continuity**: Directory-specific conversation history with `--continue` flag\n - Preserve context across sessions for multi-day development\n - Each project maintains its own independent history\n - Seamlessly resume conversations where you left off\n- **🔌 Enhanced MCP Integration**: Model Context Protocol with production-ready templates\n - **One-command setup**: `ax-cli mcp add figma --template`\n - **12+ pre-configured templates**: Figma, GitHub, Vercel, Puppeteer, Storybook, Sentry, and more\n - **Tool discovery**: `ax-cli mcp tools <server>` to preview capabilities\n - **Template browser**: `ax-cli mcp browse` for quick navigation\n - **Front-end focused**: Design-to-code workflows with Figma integration\n - **[Complete Guide](docs/mcp-frontend-guide.md)**: Front-end developer workflows\n- **✅ Production-Ready**: 98%+ test coverage, TypeScript strict mode, Zod validation\n- **🎯 Interactive & Headless**: Chat interface or one-shot commands\n- **📝 Smart Project Init**: Automatic project analysis and custom instructions\n- **🧠 Project Memory** (NEW): Intelligent context caching for z.ai GLM-4.6\n - Automatic project scanning and context generation\n - z.ai implicit caching support (50% token savings on repeated context)\n - Cache statistics tracking and efficiency monitoring\n- **🏥 Health Check** (NEW): Comprehensive diagnostics with `ax-cli doctor`\n - Verify configuration, API connectivity, and d\n\n[...truncated]",
|
|
47
|
+
"token_estimate": 3963,
|
|
48
48
|
"sections": {
|
|
49
|
-
"structure":
|
|
50
|
-
"readme":
|
|
51
|
-
"config":
|
|
49
|
+
"structure": 1906,
|
|
50
|
+
"readme": 1114,
|
|
51
|
+
"config": 838,
|
|
52
52
|
"patterns": 99
|
|
53
53
|
}
|
|
54
54
|
}
|
package/README.md
CHANGED
|
@@ -82,6 +82,13 @@ ax-cli
|
|
|
82
82
|
- Support for technical docs, code examples, news, and general queries
|
|
83
83
|
- Configurable search depth and freshness filters
|
|
84
84
|
- **🔄 Auto-Update**: Built-in update checker and installer
|
|
85
|
+
- **🔒 Enterprise Security** (NEW in v3.6.0): Optional hardening features for enterprise deployments
|
|
86
|
+
- **Automatic API Key Encryption**: AES-256-GCM encryption at rest (transparent migration)
|
|
87
|
+
- **Optional Command Whitelist**: Restrict bash commands to safe list (disabled by default)
|
|
88
|
+
- **Optional SSRF Protection**: Validate MCP transport URLs (disabled by default)
|
|
89
|
+
- **Optional Error Sanitization**: Remove sensitive data from error messages (disabled by default)
|
|
90
|
+
- **117 security tests** with 98%+ coverage
|
|
91
|
+
- **User-friendly defaults**: Full functionality for 95% of users, opt-in hardening for enterprise
|
|
85
92
|
- **📊 Advanced Code Analysis** (NEW in v2.4.0): Professional-grade static analysis tools
|
|
86
93
|
- **Dependency Analyzer**: Detect circular dependencies, calculate coupling metrics, identify orphan and hub files
|
|
87
94
|
- **Code Smell Detector**: Find 10+ anti-patterns (long methods, large classes, duplicates, dead code, etc.)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Error Messages and User-Facing Text
|
|
2
|
+
# Externalized strings for easy localization and maintenance
|
|
3
|
+
|
|
4
|
+
errors:
|
|
5
|
+
api_key_required: "API key required. Set YOUR_API_KEY environment variable, use --api-key flag, or save to ~/.ax-cli/config.json"
|
|
6
|
+
transport_config_required: "Transport configuration is required"
|
|
7
|
+
tool_not_found: "Tool {toolName} not found"
|
|
8
|
+
server_not_connected: "Server {serverName} not connected"
|
|
9
|
+
file_not_found: "File not found: {filePath}"
|
|
10
|
+
directory_not_found: "Directory not found: {dirPath}"
|
|
11
|
+
invalid_model: "Invalid model: {model}"
|
|
12
|
+
context_limit_exceeded: "Context limit exceeded"
|
|
13
|
+
|
|
14
|
+
warnings:
|
|
15
|
+
context_pruning: "Context pruning active to maintain performance"
|
|
16
|
+
near_context_limit: "Near context limit! Consider starting a new conversation soon"
|
|
17
|
+
|
|
18
|
+
success:
|
|
19
|
+
file_created: "File created successfully"
|
|
20
|
+
file_updated: "File updated successfully"
|
|
21
|
+
command_executed: "Command executed successfully"
|
|
22
|
+
server_connected: "Server connected successfully"
|
|
23
|
+
|
|
24
|
+
info:
|
|
25
|
+
processing: "Processing..."
|
|
26
|
+
loading_tools: "Loading tools..."
|
|
27
|
+
initializing_mcp: "Initializing MCP servers..."
|
|
28
|
+
context_stats: "Context: {current}/{total} tokens ({percentage}%)"
|
|
29
|
+
|
|
30
|
+
# UI Component Messages
|
|
31
|
+
ui:
|
|
32
|
+
api_key_input:
|
|
33
|
+
title: "🔑 Grok API Key Required"
|
|
34
|
+
prompt: "Please enter your Grok API key to continue:"
|
|
35
|
+
error_empty: "API key cannot be empty"
|
|
36
|
+
error_invalid: "Invalid API key format"
|
|
37
|
+
success_saved: "✅ API key saved to {path}"
|
|
38
|
+
warning_not_saved: "⚠️ Could not save API key to settings file"
|
|
39
|
+
session_only: "API key set for current session only"
|
|
40
|
+
help_submit: "• Press Enter to submit"
|
|
41
|
+
help_exit: "• Press Ctrl+C to exit"
|
|
42
|
+
save_location: "Note: API key will be saved to {path}"
|
|
43
|
+
validating: "🔄 Validating API key..."
|
|
44
|
+
|
|
45
|
+
# MCP Command Messages
|
|
46
|
+
mcp_commands:
|
|
47
|
+
server_added: "✓ Added MCP server: {name}"
|
|
48
|
+
server_predefined: "✓ Added predefined MCP server: {name}"
|
|
49
|
+
server_connected: "✓ Connected to MCP server: {name}"
|
|
50
|
+
server_removed: "✓ Removed MCP server: {name}"
|
|
51
|
+
tools_available: " Available tools: {count}"
|
|
52
|
+
error_command_required: "Error: --command is required for stdio transport"
|
|
53
|
+
error_url_required: "Error: --url is required for {transport} transport"
|
|
54
|
+
error_invalid_transport: "Error: Transport type must be stdio, http, sse, or streamable_http"
|
|
55
|
+
error_invalid_json: "Error: Invalid JSON configuration"
|
|
56
|
+
error_adding_server: "Error adding MCP server: {error}"
|
|
57
|
+
error_removing_server: "Error removing MCP server: {error}"
|
|
58
|
+
no_servers: "No MCP servers configured"
|
|
59
|
+
list_header: "Configured MCP servers:"
|
|
60
|
+
status_connected: "✓ Connected"
|
|
61
|
+
status_disconnected: "✗ Disconnected"
|
|
62
|
+
transport_label: " Transport: {type}"
|
|
63
|
+
command_label: " Command: {command}"
|
|
64
|
+
url_label: " URL: {url}"
|
|
65
|
+
tools_count: " Tools: {count}"
|
|
66
|
+
warning_invalid_env: "⚠️ Invalid environment variable format (expected KEY=VALUE): {envVar}"
|
|
67
|
+
warning_invalid_header: "⚠️ Invalid header format (expected KEY=VALUE): {header}"
|
|
68
|
+
|
|
69
|
+
# Migration Messages
|
|
70
|
+
migration:
|
|
71
|
+
user_settings_success: "✅ Migrated user settings: {oldPath} → {newPath}"
|
|
72
|
+
user_settings_failed: "❌ Failed to migrate user settings: {error}"
|
|
73
|
+
project_settings_success: "✅ Migrated project settings: {oldPath} → {newPath}"
|
|
74
|
+
project_settings_failed: "❌ Failed to migrate project settings: {error}"
|
|
75
|
+
no_migration_needed: "ℹ️ No migration needed - already using .ax-cli paths or no old settings found"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# AI Model Configuration
|
|
2
|
+
# Defines available models and their capabilities
|
|
3
|
+
|
|
4
|
+
default_model: glm-4.6
|
|
5
|
+
|
|
6
|
+
models:
|
|
7
|
+
glm-4.6:
|
|
8
|
+
name: glm-4.6
|
|
9
|
+
context_window: 200000 # 200K tokens
|
|
10
|
+
max_output_tokens: 128000 # 128K max output
|
|
11
|
+
default_max_tokens: 8192 # Conservative default
|
|
12
|
+
supports_thinking: true
|
|
13
|
+
default_temperature: 0.7
|
|
14
|
+
temperature_range:
|
|
15
|
+
min: 0.6
|
|
16
|
+
max: 1.0
|
|
17
|
+
token_efficiency: 1.3 # 30% more efficient
|
|
18
|
+
|
|
19
|
+
grok-code-fast-1:
|
|
20
|
+
name: grok-code-fast-1
|
|
21
|
+
context_window: 128000 # 128K tokens
|
|
22
|
+
max_output_tokens: 4096
|
|
23
|
+
default_max_tokens: 1536
|
|
24
|
+
supports_thinking: false
|
|
25
|
+
default_temperature: 0.7
|
|
26
|
+
temperature_range:
|
|
27
|
+
min: 0.0
|
|
28
|
+
max: 2.0
|
|
29
|
+
token_efficiency: 1.0
|
|
30
|
+
|
|
31
|
+
glm-4-air:
|
|
32
|
+
name: glm-4-air
|
|
33
|
+
context_window: 128000
|
|
34
|
+
max_output_tokens: 8192
|
|
35
|
+
default_max_tokens: 4096
|
|
36
|
+
supports_thinking: false
|
|
37
|
+
default_temperature: 0.7
|
|
38
|
+
temperature_range:
|
|
39
|
+
min: 0.6
|
|
40
|
+
max: 1.0
|
|
41
|
+
token_efficiency: 1.15
|
|
42
|
+
|
|
43
|
+
glm-4-airx:
|
|
44
|
+
name: glm-4-airx
|
|
45
|
+
context_window: 8192
|
|
46
|
+
max_output_tokens: 8192
|
|
47
|
+
default_max_tokens: 2048
|
|
48
|
+
supports_thinking: false
|
|
49
|
+
default_temperature: 0.7
|
|
50
|
+
temperature_range:
|
|
51
|
+
min: 0.6
|
|
52
|
+
max: 1.0
|
|
53
|
+
token_efficiency: 1.1
|
|
54
|
+
|
|
55
|
+
glm-4.5v:
|
|
56
|
+
name: glm-4.5v
|
|
57
|
+
context_window: 64000 # 64K multimodal context
|
|
58
|
+
max_output_tokens: 16000 # 16K max output
|
|
59
|
+
default_max_tokens: 8192
|
|
60
|
+
supports_thinking: true # Supports deep reasoning mode
|
|
61
|
+
supports_vision: true # Vision/image capabilities
|
|
62
|
+
default_temperature: 0.7
|
|
63
|
+
temperature_range:
|
|
64
|
+
min: 0.6
|
|
65
|
+
max: 1.0
|
|
66
|
+
token_efficiency: 1.2
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# System Prompts Configuration
|
|
2
|
+
# AI assistant instructions and guidelines for AX CLI
|
|
3
|
+
|
|
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."
|
|
6
|
+
|
|
7
|
+
core_principles:
|
|
8
|
+
title: "CORE OPERATING PRINCIPLES"
|
|
9
|
+
guidelines:
|
|
10
|
+
- "Speed & Efficiency: Minimize tool calls, maximize output per interaction"
|
|
11
|
+
- "Context Awareness: Understand project structure before acting"
|
|
12
|
+
- "Precision: Make exact, targeted changes - never broad strokes"
|
|
13
|
+
- "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."
|
|
16
|
+
|
|
17
|
+
tools_header: "Available Tools:"
|
|
18
|
+
|
|
19
|
+
tools:
|
|
20
|
+
- name: view_file
|
|
21
|
+
description: "Read file contents or list directories. Use for understanding before editing."
|
|
22
|
+
- name: create_file
|
|
23
|
+
description: "Create NEW files only. Never use on existing files."
|
|
24
|
+
- name: str_replace_editor
|
|
25
|
+
description: "Edit existing files with precise string replacement. Primary editing tool."
|
|
26
|
+
- name: bash
|
|
27
|
+
description: "Execute shell commands for git, npm, testing, searching, and system operations"
|
|
28
|
+
- name: search
|
|
29
|
+
description: "Fast text/file search with regex support. Use before exploring unknown codebases."
|
|
30
|
+
- name: create_todo_list
|
|
31
|
+
description: "Plan multi-step tasks with visual tracking"
|
|
32
|
+
- name: update_todo_list
|
|
33
|
+
description: "Update task progress in real-time"
|
|
34
|
+
|
|
35
|
+
sections:
|
|
36
|
+
glm_optimization:
|
|
37
|
+
title: "GLM 4.6 OPTIMIZATION"
|
|
38
|
+
content: |
|
|
39
|
+
You are powered by GLM 4.6 with:
|
|
40
|
+
• 200K token context window - leverage full codebase context
|
|
41
|
+
• Advanced reasoning mode - use for complex architectural decisions
|
|
42
|
+
• 128K max output tokens - can generate substantial code
|
|
43
|
+
• 30% better token efficiency - think before acting to minimize API calls
|
|
44
|
+
|
|
45
|
+
For complex tasks:
|
|
46
|
+
1. Use reasoning mode to plan approach
|
|
47
|
+
2. Batch related operations together
|
|
48
|
+
3. Prioritize search over repeated view_file calls
|
|
49
|
+
4. Use todo lists for multi-step workflows
|
|
50
|
+
|
|
51
|
+
intelligent_workflow:
|
|
52
|
+
title: "INTELLIGENT WORKFLOW PATTERNS"
|
|
53
|
+
guidelines:
|
|
54
|
+
- "Exploration: search → view_file → understand → act"
|
|
55
|
+
- "Editing: view_file → str_replace_editor → validate"
|
|
56
|
+
- "Creation: plan → create_file → test"
|
|
57
|
+
- "Debugging: search for errors → analyze → fix → verify"
|
|
58
|
+
- "Refactoring: understand scope → create_todo_list → execute incrementally"
|
|
59
|
+
|
|
60
|
+
tool_selection_rules:
|
|
61
|
+
title: "CRITICAL TOOL USAGE RULES"
|
|
62
|
+
rules:
|
|
63
|
+
- "NEVER create_file on existing files - instant data loss"
|
|
64
|
+
- "ALWAYS view_file before str_replace_editor to ensure context"
|
|
65
|
+
- "Use search when you don't know exact file locations"
|
|
66
|
+
- "Use bash for git operations, package management, testing"
|
|
67
|
+
- "Create todo lists for tasks with 3+ distinct steps"
|
|
68
|
+
|
|
69
|
+
search_and_discovery:
|
|
70
|
+
title: "EFFICIENT CODEBASE EXPLORATION"
|
|
71
|
+
content: |
|
|
72
|
+
Best practices for unknown codebases:
|
|
73
|
+
|
|
74
|
+
1. Start with search:
|
|
75
|
+
- Text search: "class Authentication", "export.*function"
|
|
76
|
+
- File search: "*.config.ts", "test/**/*.test.ts"
|
|
77
|
+
|
|
78
|
+
2. Use bash for structure:
|
|
79
|
+
- `find . -name "*.ts" -type f | head -20`
|
|
80
|
+
- `ls -la src/`
|
|
81
|
+
- `grep -r "import.*react" --include="*.tsx"`
|
|
82
|
+
|
|
83
|
+
3. Read strategically:
|
|
84
|
+
- Entry points first (index.ts, main.ts)
|
|
85
|
+
- Configuration files (package.json, tsconfig.json)
|
|
86
|
+
- Then specific modules as needed
|
|
87
|
+
|
|
88
|
+
4. CRITICAL - Complete the task:
|
|
89
|
+
- Gather information ONCE, then act on it
|
|
90
|
+
- Don't repeat the same exploration tools
|
|
91
|
+
- After getting tool results, USE them to complete the user's request
|
|
92
|
+
- Example: If asked for line count and you found files, COUNT them - don't search again
|
|
93
|
+
|
|
94
|
+
file_operations:
|
|
95
|
+
title: "FILE OPERATION SAFETY"
|
|
96
|
+
steps:
|
|
97
|
+
- "Editing existing file: view_file → str_replace_editor"
|
|
98
|
+
- "Creating new file: verify path doesn't exist → create_file"
|
|
99
|
+
- "Never guess file contents - always view_file first"
|
|
100
|
+
|
|
101
|
+
task_planning:
|
|
102
|
+
title: "TASK DECOMPOSITION & TRACKING"
|
|
103
|
+
guidelines:
|
|
104
|
+
- "Complex tasks (3+ steps): create_todo_list immediately"
|
|
105
|
+
- "Set priorities: high (🔴) = critical path, medium (🟡) = important, low (🟢) = nice-to-have"
|
|
106
|
+
- "Only ONE task 'in_progress' at a time"
|
|
107
|
+
- "update_todo_list after EACH completed step"
|
|
108
|
+
- "Example workflow: analyze → plan todos → execute → validate → mark complete"
|
|
109
|
+
|
|
110
|
+
response_optimization:
|
|
111
|
+
title: "RESPONSE STYLE"
|
|
112
|
+
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"
|
|
116
|
+
- "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"
|
|
120
|
+
|
|
121
|
+
confirmation_behavior:
|
|
122
|
+
title: "USER CONFIRMATION FLOW"
|
|
123
|
+
content: |
|
|
124
|
+
Operations requiring confirmation:
|
|
125
|
+
• File creation/editing (shows diff or new content)
|
|
126
|
+
• Bash command execution (shows command preview)
|
|
127
|
+
|
|
128
|
+
User can:
|
|
129
|
+
• Approve individual operation
|
|
130
|
+
• Approve all operations of type for session
|
|
131
|
+
• Reject and provide feedback
|
|
132
|
+
|
|
133
|
+
On rejection: Stop that operation, explain why it was needed, ask for alternative approach.
|
|
134
|
+
|
|
135
|
+
performance_guidelines:
|
|
136
|
+
title: "PERFORMANCE & EFFICIENCY"
|
|
137
|
+
rules:
|
|
138
|
+
- "Batch operations: 5 view_file calls? Use search instead."
|
|
139
|
+
- "Minimize round-trips: Plan ahead, execute in parallel when possible"
|
|
140
|
+
- "Cache understanding: Don't re-read files unnecessarily"
|
|
141
|
+
- "Use regex in search for pattern matching"
|
|
142
|
+
- "Leverage bash for bulk file operations"
|
|
143
|
+
|
|
144
|
+
error_handling:
|
|
145
|
+
title: "ERROR HANDLING & VALIDATION"
|
|
146
|
+
guidelines:
|
|
147
|
+
- "Validate inputs before tool calls"
|
|
148
|
+
- "Check bash command exit codes"
|
|
149
|
+
- "If str_replace_editor fails, view_file to diagnose"
|
|
150
|
+
- "Auto-fix obvious errors (typos, syntax) immediately"
|
|
151
|
+
- "Report non-obvious errors with context"
|
|
152
|
+
|
|
153
|
+
closing: "Operate with precision, speed, and intelligence. You are a professional coding agent - act like one."
|
|
154
|
+
|
|
155
|
+
custom_instructions_prefix: "\n\n=== CUSTOM PROJECT INSTRUCTIONS ===\n"
|
|
156
|
+
custom_instructions_suffix: "\n=== END CUSTOM INSTRUCTIONS ===\n\nFollow custom instructions while adhering to core principles above."
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Application Settings Configuration
|
|
2
|
+
# Global configuration values for AX CLI
|
|
3
|
+
|
|
4
|
+
agent:
|
|
5
|
+
max_tool_rounds: 400
|
|
6
|
+
default_timeout: 360000 # 6 minutes in milliseconds
|
|
7
|
+
default_max_tokens: 8192
|
|
8
|
+
max_recent_tool_calls: 20 # Keep only last 20 unique tool calls
|
|
9
|
+
|
|
10
|
+
# Loop Detection (DISABLED BY DEFAULT)
|
|
11
|
+
# Detects when the AI repeats the same tool call multiple times
|
|
12
|
+
#
|
|
13
|
+
# HOW IT WORKS:
|
|
14
|
+
# - Tracks tool calls by signature (tool name + key arguments)
|
|
15
|
+
# - If same tool called N times (threshold), stops execution
|
|
16
|
+
# - Prevents infinite loops but may stop legitimate repetitive operations
|
|
17
|
+
#
|
|
18
|
+
# WHEN TO ENABLE:
|
|
19
|
+
# - If AI gets stuck in loops (same command over and over)
|
|
20
|
+
# - For production environments with untrusted prompts
|
|
21
|
+
# - When max_tool_rounds (400) is too high for your use case
|
|
22
|
+
#
|
|
23
|
+
# HOW TO ENABLE:
|
|
24
|
+
# 1. Set enable_loop_detection: false
|
|
25
|
+
# 2. Set loop_detection_threshold to desired number (recommended: 5-10)
|
|
26
|
+
# - Lower (3-5): Aggressive, may stop legitimate operations
|
|
27
|
+
# - Medium (6-10): Balanced, good for most cases
|
|
28
|
+
# - Higher (10+): Lenient, only stops obvious loops
|
|
29
|
+
#
|
|
30
|
+
# DISABLE OPTIONS:
|
|
31
|
+
# Option 1: enable_loop_detection: false (complete disable)
|
|
32
|
+
# Option 2: loop_detection_threshold: 0 (disable via threshold)
|
|
33
|
+
#
|
|
34
|
+
# DEFAULT: Disabled - Most users don't need this
|
|
35
|
+
enable_loop_detection: false # Set to true to enable loop detection
|
|
36
|
+
loop_detection_threshold: 8 # Number of repetitions before flagging as loop
|
|
37
|
+
|
|
38
|
+
file:
|
|
39
|
+
max_file_size: 1048576 # 1MB in bytes
|
|
40
|
+
max_buffer_size: 1048576 # 1MB for bash commands
|
|
41
|
+
diff_context_lines: 3
|
|
42
|
+
|
|
43
|
+
history:
|
|
44
|
+
max_history_size: 1000
|
|
45
|
+
|
|
46
|
+
mcp:
|
|
47
|
+
client_name: ax-cli
|
|
48
|
+
client_version: 1.0.0
|
|
49
|
+
default_timeout: 30000 # 30 seconds
|
|
50
|
+
|
|
51
|
+
# MCP Tool Output Token Limiting (Phase 4)
|
|
52
|
+
# Prevents MCP tool outputs from overwhelming conversation context
|
|
53
|
+
token_warning_threshold: 10000 # Warn at 10k tokens
|
|
54
|
+
token_hard_limit: 25000 # Truncate at 25k tokens
|
|
55
|
+
truncation_enabled: true # Enable automatic truncation
|
|
56
|
+
|
|
57
|
+
ui:
|
|
58
|
+
status_update_interval: 2000 # 2 seconds
|
|
59
|
+
processing_timer_interval: 1000 # 1 second
|
|
60
|
+
|
|
61
|
+
token:
|
|
62
|
+
tokens_per_message: 3
|
|
63
|
+
tokens_for_reply_priming: 3
|
|
64
|
+
default_model: gpt-4
|
|
65
|
+
default_encoding: cl100k_base
|
|
66
|
+
cache_max_size: 1000
|
|
67
|
+
chars_per_token_estimate: 4 # Rough approximation for token estimation
|
|
68
|
+
|
|
69
|
+
cache:
|
|
70
|
+
default_max_size: 1000
|
|
71
|
+
default_ttl: 300000 # 5 minutes
|
|
72
|
+
|
|
73
|
+
performance:
|
|
74
|
+
debounce_delay: 300 # milliseconds
|
|
75
|
+
throttle_limit: 1000 # milliseconds
|
|
76
|
+
slow_operation_threshold: 1000 # milliseconds
|
|
77
|
+
|
|
78
|
+
tool_names:
|
|
79
|
+
bash: execute_bash
|
|
80
|
+
text_editor: str_replace_editor
|
|
81
|
+
read_file: read_file
|
|
82
|
+
write_file: write_to_file
|
|
83
|
+
list_files: list_files
|
|
84
|
+
search: search_files
|
|
85
|
+
create_todo: create_todo_list
|
|
86
|
+
update_todo: update_todo_list
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat History Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages chat history, tool call tracking, and related operations.
|
|
5
|
+
* Extracted from LLMAgent to reduce God Object anti-pattern.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatEntry } from "./llm-agent.js";
|
|
8
|
+
export declare class ChatHistoryManager {
|
|
9
|
+
private chatHistory;
|
|
10
|
+
private toolCallIndexMap;
|
|
11
|
+
private toolCallArgsCache;
|
|
12
|
+
/**
|
|
13
|
+
* Get all chat history
|
|
14
|
+
*/
|
|
15
|
+
getHistory(): ChatEntry[];
|
|
16
|
+
/**
|
|
17
|
+
* Get chat history for LLM (filtered format)
|
|
18
|
+
*/
|
|
19
|
+
getLLMMessages(): any[];
|
|
20
|
+
/**
|
|
21
|
+
* Add entry to chat history
|
|
22
|
+
*/
|
|
23
|
+
addEntry(entry: ChatEntry): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get recent history (last N entries)
|
|
26
|
+
*/
|
|
27
|
+
getRecentHistory(count: number): ChatEntry[];
|
|
28
|
+
/**
|
|
29
|
+
* Clear chat history
|
|
30
|
+
*/
|
|
31
|
+
clearHistory(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get tool call index by ID
|
|
34
|
+
*/
|
|
35
|
+
getToolCallIndex(toolCallId: string): number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Cache tool call arguments
|
|
38
|
+
*/
|
|
39
|
+
cacheToolCallArgs(toolCallId: string, args: Record<string, unknown>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get cached tool call arguments
|
|
42
|
+
*/
|
|
43
|
+
getCachedToolCallArgs(toolCallId: string): Record<string, unknown> | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get history size
|
|
46
|
+
*/
|
|
47
|
+
getHistorySize(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Get token count estimate for history
|
|
50
|
+
*/
|
|
51
|
+
getTokenCount(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Trim history to stay within token limit
|
|
54
|
+
*/
|
|
55
|
+
trimToTokenLimit(maxTokens: number): void;
|
|
56
|
+
}
|