@defai.digital/ax-cli 3.15.26 → 4.0.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/README.md +56 -21
- package/dist/commands/init.d.ts +3 -3
- package/dist/commands/init.js +175 -25
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/setup.d.ts +0 -1
- package/dist/commands/setup.js +7 -139
- package/dist/commands/setup.js.map +1 -1
- package/dist/llm/tools.d.ts +14 -0
- package/dist/llm/tools.js +17 -4
- package/dist/llm/tools.js.map +1 -1
- package/dist/planner/types.d.ts +4 -4
- package/dist/tools/definitions/ask-user.d.ts +8 -0
- package/dist/tools/definitions/ask-user.js +168 -0
- package/dist/tools/definitions/ask-user.js.map +1 -0
- package/dist/tools/definitions/ax-agent.d.ts +7 -0
- package/dist/tools/definitions/ax-agent.js +149 -0
- package/dist/tools/definitions/ax-agent.js.map +1 -0
- package/dist/tools/definitions/bash-output.d.ts +7 -0
- package/dist/tools/definitions/bash-output.js +78 -0
- package/dist/tools/definitions/bash-output.js.map +1 -0
- package/dist/tools/definitions/bash.d.ts +8 -0
- package/dist/tools/definitions/bash.js +152 -0
- package/dist/tools/definitions/bash.js.map +1 -0
- package/dist/tools/definitions/create-file.d.ts +7 -0
- package/dist/tools/definitions/create-file.js +129 -0
- package/dist/tools/definitions/create-file.js.map +1 -0
- package/dist/tools/definitions/design.d.ts +12 -0
- package/dist/tools/definitions/design.js +368 -0
- package/dist/tools/definitions/design.js.map +1 -0
- package/dist/tools/definitions/index.d.ts +48 -0
- package/dist/tools/definitions/index.js +96 -0
- package/dist/tools/definitions/index.js.map +1 -0
- package/dist/tools/definitions/multi-edit.d.ts +7 -0
- package/dist/tools/definitions/multi-edit.js +123 -0
- package/dist/tools/definitions/multi-edit.js.map +1 -0
- package/dist/tools/definitions/search.d.ts +7 -0
- package/dist/tools/definitions/search.js +159 -0
- package/dist/tools/definitions/search.js.map +1 -0
- package/dist/tools/definitions/str-replace-editor.d.ts +7 -0
- package/dist/tools/definitions/str-replace-editor.js +145 -0
- package/dist/tools/definitions/str-replace-editor.js.map +1 -0
- package/dist/tools/definitions/todo.d.ts +8 -0
- package/dist/tools/definitions/todo.js +261 -0
- package/dist/tools/definitions/todo.js.map +1 -0
- package/dist/tools/definitions/view-file.d.ts +7 -0
- package/dist/tools/definitions/view-file.js +111 -0
- package/dist/tools/definitions/view-file.js.map +1 -0
- package/dist/tools/format-generators.d.ts +62 -0
- package/dist/tools/format-generators.js +291 -0
- package/dist/tools/format-generators.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/result-enhancer.d.ts +64 -0
- package/dist/tools/result-enhancer.js +215 -0
- package/dist/tools/result-enhancer.js.map +1 -0
- package/dist/tools/types.d.ts +249 -0
- package/dist/tools/types.js +11 -0
- package/dist/tools/types.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# AX CLI - Enterprise-Class CLI for Vibe Coding
|
|
2
2
|
|
|
3
|
-
[](https://github.com/defai-digital/ax-cli)
|
|
3
|
+
[](https://npm-stat.com/charts.html?package=%40defai.digital%2Fax-cli)
|
|
4
|
+
[](https://github.com/defai-digital/ax-cli/actions/workflows/test.yml)
|
|
6
5
|
[](https://www.apple.com/macos/)
|
|
7
6
|
[](https://www.microsoft.com/windows)
|
|
8
7
|
[](https://ubuntu.com/) [](https://opensource.org/licenses/MIT)
|
|
@@ -23,11 +22,14 @@
|
|
|
23
22
|
# Install globally
|
|
24
23
|
npm install -g @defai.digital/ax-cli
|
|
25
24
|
|
|
26
|
-
# Configure API credentials
|
|
25
|
+
# Configure API credentials (one-time setup)
|
|
27
26
|
ax-cli setup
|
|
28
27
|
|
|
29
28
|
# Start interactive mode
|
|
30
29
|
ax-cli
|
|
30
|
+
|
|
31
|
+
# Inside interactive mode, initialize your project
|
|
32
|
+
> /init
|
|
31
33
|
```
|
|
32
34
|
|
|
33
35
|
**That's it!** AX CLI is now ready to help you build, debug, and ship code faster.
|
|
@@ -47,7 +49,7 @@ ax-cli
|
|
|
47
49
|
- [Security](#security)
|
|
48
50
|
- [Architecture](#architecture)
|
|
49
51
|
- [Changelog](#changelog)
|
|
50
|
-
- [Recent Changes (
|
|
52
|
+
- [Recent Changes (v4.0.0)](#recent-changes-v400)
|
|
51
53
|
- [Documentation](#documentation)
|
|
52
54
|
|
|
53
55
|
---
|
|
@@ -134,7 +136,8 @@ This interactive wizard will:
|
|
|
134
136
|
2. Securely encrypt and store your API key (AES-256-GCM)
|
|
135
137
|
3. Configure default model and settings
|
|
136
138
|
4. Validate your configuration
|
|
137
|
-
|
|
139
|
+
|
|
140
|
+
Then start `ax-cli` and run `/init` to initialize your project and generate `.ax-cli/CUSTOM.md`.
|
|
138
141
|
|
|
139
142
|
### Environment Variable Override
|
|
140
143
|
|
|
@@ -434,31 +437,63 @@ Email: **security@defai.digital** (private disclosure)
|
|
|
434
437
|
|
|
435
438
|
- **SSOT Type System** via `@ax-cli/schemas`
|
|
436
439
|
- **TypeScript strict mode** with Zod validation
|
|
437
|
-
- **98%+ test coverage** (
|
|
440
|
+
- **98%+ test coverage** (2265+ tests)
|
|
438
441
|
- **Modular design** with clean separation
|
|
439
442
|
- **Enterprise security** with AES-256-GCM encryption
|
|
440
443
|
|
|
441
444
|
---
|
|
442
445
|
|
|
443
|
-
## Recent Changes (
|
|
446
|
+
## Recent Changes (v4.0.0)
|
|
444
447
|
|
|
445
|
-
###
|
|
448
|
+
### Tool System v3.0 - Major Architecture Upgrade
|
|
446
449
|
|
|
447
|
-
|
|
448
|
-
- **Deprecated `ax-cli init`**: The standalone `init` command is now deprecated and shows a migration notice pointing to `ax-cli setup`.
|
|
449
|
-
- **New options for setup**:
|
|
450
|
-
- `-v, --verbose`: Show detailed output during setup
|
|
451
|
-
- `-d, --directory <dir>`: Specify project directory to initialize
|
|
452
|
-
- `--skip-project-init`: Skip project initialization step if only API configuration is needed
|
|
450
|
+
This major release introduces a completely redesigned tool definition system inspired by Claude Code's quality standards:
|
|
453
451
|
|
|
454
|
-
|
|
452
|
+
#### Rich Tool Definitions (Single Source of Truth)
|
|
455
453
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
454
|
+
- **Comprehensive Metadata**: Each tool now has 500+ word descriptions, usage notes, constraints, anti-patterns, and concrete examples
|
|
455
|
+
- **Type-Safe Architecture**: New `ToolDefinition` interface with full TypeScript support
|
|
456
|
+
- **Format Generators**: OpenAI and Anthropic formats are now derived from rich definitions, not hand-written
|
|
457
|
+
|
|
458
|
+
#### New Tool Definition System
|
|
459
|
+
|
|
460
|
+
| Component | Purpose |
|
|
461
|
+
|-----------|---------|
|
|
462
|
+
| `src/tools/types.ts` | Core type definitions (ToolDefinition, ParameterDefinition, etc.) |
|
|
463
|
+
| `src/tools/format-generators.ts` | Converts rich definitions to OpenAI/Anthropic formats |
|
|
464
|
+
| `src/tools/result-enhancer.ts` | Adds security reminders and contextual guidance |
|
|
465
|
+
| `src/tools/definitions/*.ts` | 17 rich tool definitions with Claude Code quality |
|
|
466
|
+
|
|
467
|
+
#### Tool Categories
|
|
468
|
+
|
|
469
|
+
- **File Operations**: view_file, create_file, str_replace_editor, multi_edit
|
|
470
|
+
- **Command Execution**: bash, bash_output
|
|
471
|
+
- **Search**: search (unified text/file search)
|
|
472
|
+
- **Task Management**: create_todo_list, update_todo_list
|
|
473
|
+
- **User Interaction**: ask_user
|
|
474
|
+
- **Agent Delegation**: ax_agent
|
|
475
|
+
- **Design Tools**: figma_map, figma_tokens, figma_audit, figma_search, figma_alias_list, figma_alias_resolve
|
|
476
|
+
|
|
477
|
+
#### Result Enhancer Features
|
|
478
|
+
|
|
479
|
+
- **Malware Detection**: Warns about potentially malicious code patterns
|
|
480
|
+
- **Sensitive Data Detection**: Identifies exposed credentials, API keys, tokens
|
|
481
|
+
- **Failure Guidance**: Provides contextual help when tools fail
|
|
482
|
+
- **Format Reminders**: Handles truncated output and long lines
|
|
483
|
+
|
|
484
|
+
#### Benefits
|
|
485
|
+
|
|
486
|
+
- **Better LLM Behavior**: Rich descriptions guide correct tool usage
|
|
487
|
+
- **Reduced Errors**: Anti-patterns and constraints prevent common mistakes
|
|
488
|
+
- **Easier Maintenance**: Single source of truth for all tool metadata
|
|
489
|
+
- **Token Cost Tracking**: Each tool has estimated token cost for budget planning
|
|
490
|
+
|
|
491
|
+
## Previous Changes (v3.15.26)
|
|
492
|
+
|
|
493
|
+
### Command Separation Clarification
|
|
460
494
|
|
|
461
|
-
|
|
495
|
+
- **`ax-cli setup`**: Handles user-level API configuration (provider, API key, model) - stored in `~/.ax-cli/config.json`
|
|
496
|
+
- **`/init` in interactive mode**: Initializes the current project - stored in `.ax-cli/`
|
|
462
497
|
|
|
463
498
|
## Previous Changes (v3.15.25)
|
|
464
499
|
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Init command
|
|
2
|
+
* Init command for project setup and analysis
|
|
3
3
|
*
|
|
4
|
-
* This command
|
|
5
|
-
*
|
|
4
|
+
* This command initializes project-level configuration (.ax-cli/CUSTOM.md).
|
|
5
|
+
* For API configuration, use 'ax-cli setup'.
|
|
6
6
|
*/
|
|
7
7
|
import { Command } from 'commander';
|
|
8
8
|
export declare function createInitCommand(): Command;
|
package/dist/commands/init.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Init command
|
|
2
|
+
* Init command for project setup and analysis
|
|
3
3
|
*
|
|
4
|
-
* This command
|
|
5
|
-
*
|
|
4
|
+
* This command initializes project-level configuration (.ax-cli/CUSTOM.md).
|
|
5
|
+
* For API configuration, use 'ax-cli setup'.
|
|
6
6
|
*/
|
|
7
7
|
import { Command } from 'commander';
|
|
8
|
+
import { existsSync, mkdirSync, writeFileSync, renameSync, unlinkSync } from 'fs';
|
|
9
|
+
import { join, resolve } from 'path';
|
|
10
|
+
import * as prompts from '@clack/prompts';
|
|
8
11
|
import chalk from 'chalk';
|
|
12
|
+
import { ProjectAnalyzer } from '../utils/project-analyzer.js';
|
|
13
|
+
import { LLMOptimizedInstructionGenerator } from '../utils/llm-optimized-instruction-generator.js';
|
|
14
|
+
import { InitValidator } from '../utils/init-validator.js';
|
|
15
|
+
import { InitWizard } from './init/wizard.js';
|
|
16
|
+
import { extractErrorMessage } from '../utils/error-handler.js';
|
|
17
|
+
import { CONFIG_DIR_NAME, FILE_NAMES } from '../constants.js';
|
|
9
18
|
export function createInitCommand() {
|
|
10
19
|
const initCommand = new Command('init')
|
|
11
|
-
.description('Initialize
|
|
20
|
+
.description('Initialize AX CLI for your project with intelligent analysis')
|
|
12
21
|
.option('-f, --force', 'Force regeneration even if files exist', false)
|
|
13
22
|
.option('-v, --verbose', 'Verbose output showing analysis details', false)
|
|
14
23
|
.option('-d, --directory <dir>', 'Project directory to analyze')
|
|
@@ -19,28 +28,169 @@ export function createInitCommand() {
|
|
|
19
28
|
.option('--dry-run', 'Show what would be done without making changes', false)
|
|
20
29
|
.option('--validate', 'Run validation checks only', false)
|
|
21
30
|
.action(async (options) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
try {
|
|
32
|
+
prompts.intro(chalk.cyan('AX CLI Project Initialization'));
|
|
33
|
+
const projectRoot = options.directory ? resolve(options.directory) : process.cwd();
|
|
34
|
+
if (options.verbose) {
|
|
35
|
+
prompts.log.info(`Working directory: ${projectRoot}`);
|
|
36
|
+
}
|
|
37
|
+
// Run validation if requested
|
|
38
|
+
if (options.validate) {
|
|
39
|
+
const validator = new InitValidator(projectRoot);
|
|
40
|
+
const validationResult = validator.validate();
|
|
41
|
+
console.log('\n' + InitValidator.formatValidationResult(validationResult));
|
|
42
|
+
process.exit(validationResult.valid ? 0 : 1);
|
|
43
|
+
}
|
|
44
|
+
// Check if in a git repo or has package.json (reasonable project indicator)
|
|
45
|
+
const hasGit = existsSync(join(projectRoot, '.git'));
|
|
46
|
+
const hasPackageJson = existsSync(join(projectRoot, 'package.json'));
|
|
47
|
+
if (!hasGit && !hasPackageJson) {
|
|
48
|
+
prompts.log.warn('No project detected in current directory (no .git or package.json)');
|
|
49
|
+
prompts.log.info('Run from a project directory to initialize it.');
|
|
50
|
+
prompts.outro(chalk.yellow('Initialization skipped'));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Run validation
|
|
54
|
+
const validator = new InitValidator(projectRoot);
|
|
55
|
+
const validationResult = validator.validate();
|
|
56
|
+
if (!validationResult.valid) {
|
|
57
|
+
prompts.log.error('Project validation failed:');
|
|
58
|
+
console.log(InitValidator.formatValidationResult(validationResult));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
if (options.verbose && (validationResult.warnings.length > 0 || validationResult.suggestions.length > 0)) {
|
|
62
|
+
console.log(InitValidator.formatValidationResult(validationResult));
|
|
63
|
+
}
|
|
64
|
+
// Check if already initialized
|
|
65
|
+
const axCliDir = join(projectRoot, CONFIG_DIR_NAME);
|
|
66
|
+
const customMdPath = join(axCliDir, FILE_NAMES.CUSTOM_MD);
|
|
67
|
+
const indexPath = join(axCliDir, FILE_NAMES.INDEX_JSON);
|
|
68
|
+
if (!options.force && existsSync(customMdPath)) {
|
|
69
|
+
prompts.log.success('Project already initialized!');
|
|
70
|
+
prompts.log.info(`Custom instructions: ${customMdPath}`);
|
|
71
|
+
prompts.log.info(`Project index: ${indexPath}`);
|
|
72
|
+
prompts.log.info('Use --force to regenerate');
|
|
73
|
+
prompts.outro(chalk.green('Already configured'));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Run interactive wizard for template selection (unless --yes or --no-interaction)
|
|
77
|
+
let selectedTemplate = undefined;
|
|
78
|
+
if (!options.noInteraction && !options.yes) {
|
|
79
|
+
const wizard = new InitWizard({
|
|
80
|
+
nonInteractive: options.noInteraction,
|
|
81
|
+
yes: options.yes,
|
|
82
|
+
template: options.template,
|
|
83
|
+
});
|
|
84
|
+
const wizardResult = await wizard.run();
|
|
85
|
+
selectedTemplate = wizardResult.selectedTemplate;
|
|
86
|
+
}
|
|
87
|
+
// Create config directory
|
|
88
|
+
if (!existsSync(axCliDir)) {
|
|
89
|
+
mkdirSync(axCliDir, { recursive: true });
|
|
90
|
+
if (options.verbose) {
|
|
91
|
+
prompts.log.info(`Created ${CONFIG_DIR_NAME} directory`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Analyze project
|
|
95
|
+
const spinner = prompts.spinner();
|
|
96
|
+
spinner.start('Analyzing project...');
|
|
97
|
+
const analyzer = new ProjectAnalyzer(projectRoot);
|
|
98
|
+
const result = await analyzer.analyze();
|
|
99
|
+
if (!result.success || !result.projectInfo) {
|
|
100
|
+
spinner.stop('Analysis failed');
|
|
101
|
+
prompts.log.error(`Project analysis failed: ${result.error || 'Unknown error'}`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
const projectInfo = result.projectInfo;
|
|
105
|
+
spinner.stop('Analysis complete');
|
|
106
|
+
// Display analysis results
|
|
107
|
+
if (options.verbose) {
|
|
108
|
+
prompts.log.info(`Project: ${projectInfo.name} (${projectInfo.projectType})`);
|
|
109
|
+
prompts.log.info(`Language: ${projectInfo.primaryLanguage}`);
|
|
110
|
+
if (projectInfo.techStack.length > 0) {
|
|
111
|
+
prompts.log.info(`Stack: ${projectInfo.techStack.join(', ')}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Generate content (either from template or project analysis)
|
|
115
|
+
let instructions;
|
|
116
|
+
let index;
|
|
117
|
+
if (selectedTemplate) {
|
|
118
|
+
instructions = selectedTemplate.instructions;
|
|
119
|
+
const indexData = {
|
|
120
|
+
projectName: selectedTemplate.name,
|
|
121
|
+
version: selectedTemplate.version,
|
|
122
|
+
projectType: selectedTemplate.projectType,
|
|
123
|
+
...selectedTemplate.metadata,
|
|
124
|
+
templateId: selectedTemplate.id,
|
|
125
|
+
templateAppliedAt: new Date().toISOString(),
|
|
126
|
+
};
|
|
127
|
+
index = JSON.stringify(indexData, null, 2);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// Generate LLM-optimized instructions
|
|
131
|
+
const generator = new LLMOptimizedInstructionGenerator({
|
|
132
|
+
compressionLevel: 'moderate',
|
|
133
|
+
hierarchyEnabled: true,
|
|
134
|
+
criticalRulesCount: 5,
|
|
135
|
+
includeDODONT: true,
|
|
136
|
+
includeTroubleshooting: true,
|
|
137
|
+
});
|
|
138
|
+
instructions = generator.generateInstructions(projectInfo);
|
|
139
|
+
index = generator.generateIndex(projectInfo);
|
|
140
|
+
}
|
|
141
|
+
// Preview or dry-run mode
|
|
142
|
+
if (options.dryRun) {
|
|
143
|
+
prompts.log.info('Dry-run mode - no changes made');
|
|
144
|
+
prompts.log.info(`Would create: ${customMdPath}`);
|
|
145
|
+
prompts.log.info(`Would create: ${indexPath}`);
|
|
146
|
+
prompts.outro(chalk.green('Dry-run complete'));
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Write files using atomic operations
|
|
150
|
+
const tmpCustomPath = `${customMdPath}.tmp`;
|
|
151
|
+
const tmpIndexPath = `${indexPath}.tmp`;
|
|
152
|
+
try {
|
|
153
|
+
writeFileSync(tmpCustomPath, instructions, 'utf-8');
|
|
154
|
+
writeFileSync(tmpIndexPath, index, 'utf-8');
|
|
155
|
+
// Atomic rename
|
|
156
|
+
renameSync(tmpCustomPath, customMdPath);
|
|
157
|
+
renameSync(tmpIndexPath, indexPath);
|
|
158
|
+
prompts.log.success(`Generated custom instructions: ${customMdPath}`);
|
|
159
|
+
prompts.log.success(`Generated project index: ${indexPath}`);
|
|
160
|
+
}
|
|
161
|
+
catch (writeError) {
|
|
162
|
+
// Cleanup temp files on error
|
|
163
|
+
try {
|
|
164
|
+
if (existsSync(tmpCustomPath))
|
|
165
|
+
unlinkSync(tmpCustomPath);
|
|
166
|
+
if (existsSync(tmpIndexPath))
|
|
167
|
+
unlinkSync(tmpIndexPath);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Ignore cleanup errors
|
|
171
|
+
}
|
|
172
|
+
throw writeError;
|
|
173
|
+
}
|
|
174
|
+
// Show completion summary
|
|
175
|
+
await prompts.note(`Project: ${projectInfo.name} (${projectInfo.projectType})\n` +
|
|
176
|
+
`Language: ${projectInfo.primaryLanguage}\n` +
|
|
177
|
+
(projectInfo.techStack.length > 0 ? `Stack: ${projectInfo.techStack.join(', ')}\n` : '') +
|
|
178
|
+
`\nFiles created:\n` +
|
|
179
|
+
` ${customMdPath}\n` +
|
|
180
|
+
` ${indexPath}`, 'Project Summary');
|
|
181
|
+
await prompts.note('1. Review .ax-cli/CUSTOM.md and customize if needed\n' +
|
|
182
|
+
'2. Start chatting: ax-cli\n' +
|
|
183
|
+
'3. Use --force to regenerate after project changes', 'Next Steps');
|
|
184
|
+
prompts.outro(chalk.green('Project initialized successfully!'));
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
prompts.log.error(`Error during initialization: ${extractErrorMessage(error)}`);
|
|
188
|
+
if (options.verbose && error instanceof Error && error.stack) {
|
|
189
|
+
console.error('\nStack trace:');
|
|
190
|
+
console.error(error.stack);
|
|
191
|
+
}
|
|
192
|
+
process.exit(1);
|
|
39
193
|
}
|
|
40
|
-
console.log(chalk.cyan('Equivalent command:'));
|
|
41
|
-
console.log(chalk.cyan(` ax-cli ${args.join(' ')}\n`));
|
|
42
|
-
// Instead of running, just inform the user
|
|
43
|
-
console.log('Run the setup command to configure your project.\n');
|
|
44
194
|
});
|
|
45
195
|
return initCommand;
|
|
46
196
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,UAAU,iBAAiB;IAC/B,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;SACpC,WAAW,CAAC,8DAA8D,CAAC;SAC3E,MAAM,CAAC,aAAa,EAAE,wCAAwC,EAAE,KAAK,CAAC;SACtE,MAAM,CAAC,eAAe,EAAE,yCAAyC,EAAE,KAAK,CAAC;SACzE,MAAM,CAAC,uBAAuB,EAAE,8BAA8B,CAAC;SAC/D,MAAM,CAAC,WAAW,EAAE,2CAA2C,EAAE,KAAK,CAAC;SACvE,MAAM,CAAC,kBAA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AC,mCAAmC,CAAC,CAAC,CAAC;QAElE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,gCAAgC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAChF,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAC7D,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBAChC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/commands/setup.d.ts
CHANGED
package/dist/commands/setup.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { existsSync, mkdirSync
|
|
3
|
-
import { dirname
|
|
2
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
4
|
import { execSync, spawnSync } from 'child_process';
|
|
5
5
|
import * as prompts from '@clack/prompts';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import { validateProviderSetup } from '../utils/setup-validator.js';
|
|
8
8
|
import { getSettingsManager } from '../utils/settings-manager.js';
|
|
9
9
|
import { extractErrorMessage } from '../utils/error-handler.js';
|
|
10
|
-
import { CONFIG_PATHS
|
|
10
|
+
import { CONFIG_PATHS } from '../constants.js';
|
|
11
11
|
import { detectZAIServices, getRecommendedServers, generateZAIServerConfig, } from '../mcp/index.js';
|
|
12
12
|
import { addMCPServer, removeMCPServer } from '../mcp/config.js';
|
|
13
|
-
import { ProjectAnalyzer } from '../utils/project-analyzer.js';
|
|
14
|
-
import { LLMOptimizedInstructionGenerator } from '../utils/llm-optimized-instruction-generator.js';
|
|
15
|
-
import { InitValidator } from '../utils/init-validator.js';
|
|
16
13
|
/**
|
|
17
14
|
* Check if AutomatosX (ax) is installed
|
|
18
15
|
*/
|
|
@@ -138,123 +135,15 @@ function getProviderFromBaseURL(baseURL) {
|
|
|
138
135
|
}
|
|
139
136
|
return null;
|
|
140
137
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Initialize project with .ax-cli/CUSTOM.md and index.json
|
|
143
|
-
* This is the core logic from the old init command, now integrated into setup
|
|
144
|
-
*/
|
|
145
|
-
async function runProjectInit(options) {
|
|
146
|
-
const projectRoot = options.directory ? resolve(options.directory) : process.cwd();
|
|
147
|
-
// Check if in a git repo or has package.json (reasonable project indicator)
|
|
148
|
-
const hasGit = existsSync(join(projectRoot, '.git'));
|
|
149
|
-
const hasPackageJson = existsSync(join(projectRoot, 'package.json'));
|
|
150
|
-
if (!hasGit && !hasPackageJson) {
|
|
151
|
-
prompts.log.info('No project detected in current directory (no .git or package.json)');
|
|
152
|
-
prompts.log.info('Run "ax-cli setup" from a project directory to initialize it.');
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
// Run validation
|
|
156
|
-
const validator = new InitValidator(projectRoot);
|
|
157
|
-
const validationResult = validator.validate();
|
|
158
|
-
if (!validationResult.valid) {
|
|
159
|
-
if (options.verbose) {
|
|
160
|
-
prompts.log.warn('Project validation failed:');
|
|
161
|
-
prompts.log.warn(InitValidator.formatValidationResult(validationResult));
|
|
162
|
-
}
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
// Check if already initialized
|
|
166
|
-
const axCliDir = join(projectRoot, CONFIG_DIR_NAME);
|
|
167
|
-
const customMdPath = join(axCliDir, FILE_NAMES.CUSTOM_MD);
|
|
168
|
-
const indexPath = join(axCliDir, FILE_NAMES.INDEX_JSON);
|
|
169
|
-
if (!options.force && existsSync(customMdPath)) {
|
|
170
|
-
prompts.log.success('Project already initialized!');
|
|
171
|
-
prompts.log.info(`Custom instructions: ${customMdPath}`);
|
|
172
|
-
if (options.verbose) {
|
|
173
|
-
prompts.log.info(`Project index: ${indexPath}`);
|
|
174
|
-
prompts.log.info('Use --force to regenerate');
|
|
175
|
-
}
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
// Create config directory
|
|
179
|
-
if (!existsSync(axCliDir)) {
|
|
180
|
-
mkdirSync(axCliDir, { recursive: true });
|
|
181
|
-
if (options.verbose) {
|
|
182
|
-
prompts.log.info(`Created ${CONFIG_DIR_NAME} directory`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// Analyze project
|
|
186
|
-
const analyzer = new ProjectAnalyzer(projectRoot);
|
|
187
|
-
const result = await analyzer.analyze();
|
|
188
|
-
if (!result.success || !result.projectInfo) {
|
|
189
|
-
if (options.verbose) {
|
|
190
|
-
prompts.log.warn(`Project analysis failed: ${result.error || 'Unknown error'}`);
|
|
191
|
-
}
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
const projectInfo = result.projectInfo;
|
|
195
|
-
// Display analysis results if verbose
|
|
196
|
-
if (options.verbose) {
|
|
197
|
-
prompts.log.info(`Project: ${projectInfo.name} (${projectInfo.projectType})`);
|
|
198
|
-
prompts.log.info(`Language: ${projectInfo.primaryLanguage}`);
|
|
199
|
-
if (projectInfo.techStack.length > 0) {
|
|
200
|
-
prompts.log.info(`Stack: ${projectInfo.techStack.join(', ')}`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
// Generate LLM-optimized instructions
|
|
204
|
-
const generator = new LLMOptimizedInstructionGenerator({
|
|
205
|
-
compressionLevel: 'moderate',
|
|
206
|
-
hierarchyEnabled: true,
|
|
207
|
-
criticalRulesCount: 5,
|
|
208
|
-
includeDODONT: true,
|
|
209
|
-
includeTroubleshooting: true,
|
|
210
|
-
});
|
|
211
|
-
const instructions = generator.generateInstructions(projectInfo);
|
|
212
|
-
const index = generator.generateIndex(projectInfo);
|
|
213
|
-
// Write files using atomic operations
|
|
214
|
-
const tmpCustomPath = `${customMdPath}.tmp`;
|
|
215
|
-
const tmpIndexPath = `${indexPath}.tmp`;
|
|
216
|
-
try {
|
|
217
|
-
writeFileSync(tmpCustomPath, instructions, 'utf-8');
|
|
218
|
-
writeFileSync(tmpIndexPath, index, 'utf-8');
|
|
219
|
-
// Atomic rename
|
|
220
|
-
renameSync(tmpCustomPath, customMdPath);
|
|
221
|
-
renameSync(tmpIndexPath, indexPath);
|
|
222
|
-
prompts.log.success(`Generated custom instructions: ${customMdPath}`);
|
|
223
|
-
if (options.verbose) {
|
|
224
|
-
prompts.log.success(`Generated project index: ${indexPath}`);
|
|
225
|
-
}
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
catch (writeError) {
|
|
229
|
-
// Cleanup temp files on error
|
|
230
|
-
try {
|
|
231
|
-
if (existsSync(tmpCustomPath))
|
|
232
|
-
unlinkSync(tmpCustomPath);
|
|
233
|
-
if (existsSync(tmpIndexPath))
|
|
234
|
-
unlinkSync(tmpIndexPath);
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
// Ignore cleanup errors
|
|
238
|
-
}
|
|
239
|
-
if (options.verbose) {
|
|
240
|
-
prompts.log.warn(`Failed to write project files: ${extractErrorMessage(writeError)}`);
|
|
241
|
-
}
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
138
|
/**
|
|
246
139
|
* Setup command - Initialize ~/.ax-cli/config.json with provider selection
|
|
247
|
-
* Also initializes project-level configuration (.ax-cli/CUSTOM.md)
|
|
248
140
|
*/
|
|
249
141
|
export function createSetupCommand() {
|
|
250
142
|
const setupCommand = new Command('setup');
|
|
251
143
|
setupCommand
|
|
252
|
-
.description('Initialize AX CLI configuration with AI provider selection
|
|
144
|
+
.description('Initialize AX CLI configuration with AI provider selection')
|
|
253
145
|
.option('--force', 'Overwrite existing configuration')
|
|
254
146
|
.option('--no-validate', 'Skip validation of API endpoint and credentials')
|
|
255
|
-
.option('-v, --verbose', 'Verbose output showing details', false)
|
|
256
|
-
.option('-d, --directory <dir>', 'Project directory to initialize')
|
|
257
|
-
.option('--skip-project-init', 'Skip project initialization step', false)
|
|
258
147
|
.action(async (options) => {
|
|
259
148
|
try {
|
|
260
149
|
// Show intro
|
|
@@ -608,29 +497,6 @@ export function createSetupCommand() {
|
|
|
608
497
|
}
|
|
609
498
|
}
|
|
610
499
|
// ═══════════════════════════════════════════════════════════════════
|
|
611
|
-
// Project Initialization (integrated from init command)
|
|
612
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
613
|
-
if (!options.skipProjectInit) {
|
|
614
|
-
await prompts.note('Setting up project-level configuration:\n' +
|
|
615
|
-
'• Analyzes project structure and tech stack\n' +
|
|
616
|
-
'• Generates .ax-cli/CUSTOM.md with AI instructions\n' +
|
|
617
|
-
'• Creates project index for context awareness', 'Project Initialization');
|
|
618
|
-
const initSpinner = prompts.spinner();
|
|
619
|
-
initSpinner.start('Analyzing project...');
|
|
620
|
-
const initResult = await runProjectInit({
|
|
621
|
-
force: options.force,
|
|
622
|
-
verbose: options.verbose,
|
|
623
|
-
directory: options.directory,
|
|
624
|
-
});
|
|
625
|
-
if (initResult) {
|
|
626
|
-
initSpinner.stop('Project initialized successfully');
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
initSpinner.stop('Project initialization skipped');
|
|
630
|
-
prompts.log.info('You can initialize a project later with: ax-cli setup -d /path/to/project');
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
634
500
|
// Completion Summary
|
|
635
501
|
// ═══════════════════════════════════════════════════════════════════
|
|
636
502
|
await prompts.note(`Location: ${configPath}\n` +
|
|
@@ -641,7 +507,9 @@ export function createSetupCommand() {
|
|
|
641
507
|
`Temperature: ${mergedConfig.temperature ?? 0.7}`, 'Configuration Details');
|
|
642
508
|
await prompts.note('1. Start interactive mode:\n' +
|
|
643
509
|
' $ ax-cli\n\n' +
|
|
644
|
-
'2.
|
|
510
|
+
'2. Initialize your project (inside ax-cli):\n' +
|
|
511
|
+
' > /init\n\n' +
|
|
512
|
+
'3. Or run a quick test:\n' +
|
|
645
513
|
' $ ax-cli -p "Hello, introduce yourself"', 'Next Steps');
|
|
646
514
|
await prompts.note(`• Edit config manually: ${configPath}\n` +
|
|
647
515
|
'• See example configs: Check "_examples" in config file\n' +
|