@defai.digital/ax-cli 3.14.13 → 3.14.16

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 (49) hide show
  1. package/.ax-cli/CUSTOM.md +97 -0
  2. package/.ax-cli/auto-accept-audit.json +1302 -0
  3. package/.ax-cli/index.json +43 -0
  4. package/.ax-cli/memory.json +62 -0
  5. package/.ax-cli/settings.json +39 -0
  6. package/README.md +54 -2
  7. package/ax.config.json +304 -0
  8. package/dist/analyzers/ast/tree-sitter-parser.d.ts +134 -0
  9. package/dist/analyzers/ast/tree-sitter-parser.js +730 -0
  10. package/dist/analyzers/ast/tree-sitter-parser.js.map +1 -0
  11. package/dist/commands/setup.js +108 -0
  12. package/dist/commands/setup.js.map +1 -1
  13. package/dist/commands/update.js +55 -2
  14. package/dist/commands/update.js.map +1 -1
  15. package/dist/mcp/config-detector-v2.d.ts +83 -0
  16. package/dist/mcp/config-detector-v2.js +328 -0
  17. package/dist/mcp/config-detector-v2.js.map +1 -0
  18. package/dist/mcp/config-migrator-v2.d.ts +89 -0
  19. package/dist/mcp/config-migrator-v2.js +288 -0
  20. package/dist/mcp/config-migrator-v2.js.map +1 -0
  21. package/dist/mcp/config-v2.d.ts +111 -0
  22. package/dist/mcp/config-v2.js +443 -0
  23. package/dist/mcp/config-v2.js.map +1 -0
  24. package/dist/mcp/transports-v2.d.ts +152 -0
  25. package/dist/mcp/transports-v2.js +481 -0
  26. package/dist/mcp/transports-v2.js.map +1 -0
  27. package/dist/mcp/transports.d.ts +6 -2
  28. package/dist/mcp/transports.js +57 -103
  29. package/dist/mcp/transports.js.map +1 -1
  30. package/dist/schemas/settings-schemas.d.ts +2 -2
  31. package/dist/utils/error-sanitizer.d.ts +119 -0
  32. package/dist/utils/error-sanitizer.js +253 -0
  33. package/dist/utils/error-sanitizer.js.map +1 -0
  34. package/dist/utils/errors.d.ts +74 -0
  35. package/dist/utils/errors.js +139 -0
  36. package/dist/utils/errors.js.map +1 -0
  37. package/dist/utils/incremental-analyzer.d.ts +134 -0
  38. package/dist/utils/incremental-analyzer.js +377 -0
  39. package/dist/utils/incremental-analyzer.js.map +1 -0
  40. package/dist/utils/math.d.ts +1 -0
  41. package/dist/utils/math.js +4 -0
  42. package/dist/utils/math.js.map +1 -0
  43. package/dist/utils/settings.d.ts +1 -0
  44. package/dist/utils/settings.js +4 -0
  45. package/dist/utils/settings.js.map +1 -0
  46. package/dist/utils/streaming-analyzer.d.ts +160 -0
  47. package/dist/utils/streaming-analyzer.js +214 -0
  48. package/dist/utils/streaming-analyzer.js.map +1 -0
  49. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Typed Error Classes
3
+ * Provides consistent, categorized error handling across the application
4
+ */
5
+ /**
6
+ * Base error class for AX CLI errors
7
+ */
8
+ export declare class AxCliError extends Error {
9
+ readonly category: string;
10
+ readonly details?: unknown | undefined;
11
+ constructor(message: string, category: string, details?: unknown | undefined);
12
+ }
13
+ /**
14
+ * Configuration-related errors (YAML, settings, etc.)
15
+ */
16
+ export declare class ConfigurationError extends AxCliError {
17
+ constructor(message: string, details?: unknown);
18
+ }
19
+ /**
20
+ * Validation errors (Zod, schema, input validation)
21
+ */
22
+ export declare class ValidationError extends AxCliError {
23
+ constructor(message: string, details?: unknown);
24
+ }
25
+ /**
26
+ * File system operation errors
27
+ */
28
+ export declare class FileSystemError extends AxCliError {
29
+ readonly filePath?: string | undefined;
30
+ constructor(message: string, filePath?: string | undefined, details?: unknown);
31
+ }
32
+ /**
33
+ * Network/API errors
34
+ */
35
+ export declare class NetworkError extends AxCliError {
36
+ readonly statusCode?: number | undefined;
37
+ constructor(message: string, statusCode?: number | undefined, details?: unknown);
38
+ }
39
+ /**
40
+ * MCP (Model Context Protocol) errors
41
+ */
42
+ export declare class MCPError extends AxCliError {
43
+ readonly serverName?: string | undefined;
44
+ constructor(message: string, serverName?: string | undefined, details?: unknown);
45
+ }
46
+ /**
47
+ * Tool execution errors
48
+ */
49
+ export declare class ToolExecutionError extends AxCliError {
50
+ readonly toolName?: string | undefined;
51
+ constructor(message: string, toolName?: string | undefined, details?: unknown);
52
+ }
53
+ /**
54
+ * Authentication/Authorization errors
55
+ */
56
+ export declare class AuthenticationError extends AxCliError {
57
+ constructor(message: string, details?: unknown);
58
+ }
59
+ /**
60
+ * Type guard to check if error is an AxCliError
61
+ */
62
+ export declare function isAxCliError(error: unknown): error is AxCliError;
63
+ /**
64
+ * Extract user-friendly error message from any error type
65
+ */
66
+ export declare function getErrorMessage(error: unknown): string;
67
+ /**
68
+ * Format error for logging with details
69
+ */
70
+ export declare function formatErrorForLogging(error: unknown): string;
71
+ /**
72
+ * Wrap any error in an appropriate AxCliError
73
+ */
74
+ export declare function wrapError(error: unknown, category: string, context?: string): AxCliError;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Typed Error Classes
3
+ * Provides consistent, categorized error handling across the application
4
+ */
5
+ /**
6
+ * Base error class for AX CLI errors
7
+ */
8
+ export class AxCliError extends Error {
9
+ category;
10
+ details;
11
+ constructor(message, category, details) {
12
+ super(message);
13
+ this.category = category;
14
+ this.details = details;
15
+ this.name = 'AxCliError';
16
+ Error.captureStackTrace(this, this.constructor);
17
+ }
18
+ }
19
+ /**
20
+ * Configuration-related errors (YAML, settings, etc.)
21
+ */
22
+ export class ConfigurationError extends AxCliError {
23
+ constructor(message, details) {
24
+ super(message, 'Configuration', details);
25
+ this.name = 'ConfigurationError';
26
+ }
27
+ }
28
+ /**
29
+ * Validation errors (Zod, schema, input validation)
30
+ */
31
+ export class ValidationError extends AxCliError {
32
+ constructor(message, details) {
33
+ super(message, 'Validation', details);
34
+ this.name = 'ValidationError';
35
+ }
36
+ }
37
+ /**
38
+ * File system operation errors
39
+ */
40
+ export class FileSystemError extends AxCliError {
41
+ filePath;
42
+ constructor(message, filePath, details) {
43
+ super(message, 'FileSystem', details);
44
+ this.filePath = filePath;
45
+ this.name = 'FileSystemError';
46
+ }
47
+ }
48
+ /**
49
+ * Network/API errors
50
+ */
51
+ export class NetworkError extends AxCliError {
52
+ statusCode;
53
+ constructor(message, statusCode, details) {
54
+ super(message, 'Network', details);
55
+ this.statusCode = statusCode;
56
+ this.name = 'NetworkError';
57
+ }
58
+ }
59
+ /**
60
+ * MCP (Model Context Protocol) errors
61
+ */
62
+ export class MCPError extends AxCliError {
63
+ serverName;
64
+ constructor(message, serverName, details) {
65
+ super(message, 'MCP', details);
66
+ this.serverName = serverName;
67
+ this.name = 'MCPError';
68
+ }
69
+ }
70
+ /**
71
+ * Tool execution errors
72
+ */
73
+ export class ToolExecutionError extends AxCliError {
74
+ toolName;
75
+ constructor(message, toolName, details) {
76
+ super(message, 'ToolExecution', details);
77
+ this.toolName = toolName;
78
+ this.name = 'ToolExecutionError';
79
+ }
80
+ }
81
+ /**
82
+ * Authentication/Authorization errors
83
+ */
84
+ export class AuthenticationError extends AxCliError {
85
+ constructor(message, details) {
86
+ super(message, 'Authentication', details);
87
+ this.name = 'AuthenticationError';
88
+ }
89
+ }
90
+ /**
91
+ * Type guard to check if error is an AxCliError
92
+ */
93
+ export function isAxCliError(error) {
94
+ return error instanceof AxCliError;
95
+ }
96
+ /**
97
+ * Extract user-friendly error message from any error type
98
+ */
99
+ export function getErrorMessage(error) {
100
+ if (error instanceof AxCliError) {
101
+ return error.message;
102
+ }
103
+ if (error instanceof Error) {
104
+ return error.message;
105
+ }
106
+ if (typeof error === 'string') {
107
+ return error;
108
+ }
109
+ return 'An unknown error occurred';
110
+ }
111
+ /**
112
+ * Format error for logging with details
113
+ */
114
+ export function formatErrorForLogging(error) {
115
+ if (error instanceof AxCliError) {
116
+ let message = `[${error.category}] ${error.message}`;
117
+ if (error.details) {
118
+ message += `\nDetails: ${JSON.stringify(error.details, null, 2)}`;
119
+ }
120
+ if (error.stack) {
121
+ message += `\nStack: ${error.stack}`;
122
+ }
123
+ return message;
124
+ }
125
+ if (error instanceof Error) {
126
+ return error.stack || error.message;
127
+ }
128
+ return String(error);
129
+ }
130
+ /**
131
+ * Wrap any error in an appropriate AxCliError
132
+ */
133
+ export function wrapError(error, category, context) {
134
+ const message = context
135
+ ? `${context}: ${getErrorMessage(error)}`
136
+ : getErrorMessage(error);
137
+ return new AxCliError(message, category, error);
138
+ }
139
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGjB;IACA;IAHlB,YACE,OAAe,EACC,QAAgB,EAChB,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAChD,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAG3B;IAFlB,YACE,OAAe,EACC,QAAiB,EACjC,OAAiB;QAEjB,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QAHtB,aAAQ,GAAR,QAAQ,CAAS;QAIjC,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analyzer
3
+ *
4
+ * Analyzes only changed files and their dependencies using git integration.
5
+ * Provides 10-50x speedup by avoiding analysis of unchanged files.
6
+ *
7
+ * Quick Win #2: Git-Based Incremental Analysis (Est. time: 1 hour)
8
+ * Impact: 10-50x reduction in files to analyze
9
+ */
10
+ /**
11
+ * Configuration for incremental analysis
12
+ */
13
+ export interface IncrementalConfig {
14
+ /** Base directory for git operations (default: cwd) */
15
+ baseDir?: string;
16
+ /** File patterns to include (default: all) */
17
+ include?: string[];
18
+ /** File patterns to exclude (default: none) */
19
+ exclude?: string[];
20
+ /** Compare against specific commit/branch (default: HEAD) */
21
+ compareWith?: string;
22
+ /** Include untracked files (default: true) */
23
+ includeUntracked?: boolean;
24
+ /** Build dependency graph (default: false, for future use) */
25
+ trackDependencies?: boolean;
26
+ }
27
+ /**
28
+ * Changed file info
29
+ */
30
+ export interface ChangedFile {
31
+ /** File path relative to base directory */
32
+ path: string;
33
+ /** Type of change */
34
+ status: 'modified' | 'added' | 'deleted' | 'renamed' | 'untracked';
35
+ /** Previous path (for renamed files) */
36
+ oldPath?: string;
37
+ }
38
+ /**
39
+ * Result of incremental analysis
40
+ */
41
+ export interface IncrementalResult {
42
+ /** Files that need analysis */
43
+ filesToAnalyze: string[];
44
+ /** Files that are cached */
45
+ cachedFiles: string[];
46
+ /** Changed files detected */
47
+ changedFiles: ChangedFile[];
48
+ /** Total files in project */
49
+ totalFiles: number;
50
+ /** Estimated speedup */
51
+ speedup: number;
52
+ }
53
+ /**
54
+ * Check if directory is a git repository
55
+ */
56
+ export declare function isGitRepo(dir?: string): boolean;
57
+ /**
58
+ * Get changed files from git
59
+ *
60
+ * @param config - Configuration options
61
+ * @returns Array of changed files
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const changed = await getChangedFiles({
66
+ * compareWith: 'main',
67
+ * include: ['*.ts', '*.tsx'],
68
+ * });
69
+ *
70
+ * console.log(`${changed.length} files changed`);
71
+ * ```
72
+ */
73
+ export declare function getChangedFiles(config?: IncrementalConfig): Promise<ChangedFile[]>;
74
+ /**
75
+ * Get files to analyze incrementally
76
+ *
77
+ * Returns only files that need analysis based on git changes.
78
+ *
79
+ * @param allFiles - All files in project
80
+ * @param config - Configuration options
81
+ * @returns Incremental analysis result
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const allFiles = await glob('src/** /*.ts');
86
+ * const result = await getFilesToAnalyze(allFiles);
87
+ *
88
+ * console.log(`Analyzing ${result.filesToAnalyze.length} of ${result.totalFiles} files`);
89
+ * console.log(`Speedup: ${result.speedup.toFixed(1)}x`);
90
+ * ```
91
+ */
92
+ export declare function getFilesToAnalyze(allFiles: string[], config?: IncrementalConfig): Promise<IncrementalResult>;
93
+ /**
94
+ * Get git repository info
95
+ *
96
+ * @param baseDir - Base directory (default: cwd)
97
+ * @returns Repository information
98
+ */
99
+ export declare function getGitInfo(baseDir?: string): {
100
+ branch: string;
101
+ commit: string;
102
+ isDirty: boolean;
103
+ ahead: number;
104
+ behind: number;
105
+ } | null;
106
+ /**
107
+ * Simple dependency tracker (for future use)
108
+ *
109
+ * Parses import/require statements to build a dependency graph.
110
+ */
111
+ export declare class DependencyTracker {
112
+ private graph;
113
+ private reverseGraph;
114
+ /**
115
+ * Add a file and its dependencies
116
+ */
117
+ addFile(filePath: string): Promise<void>;
118
+ /**
119
+ * Get files that depend on the given file
120
+ */
121
+ getDependents(filePath: string): string[];
122
+ /**
123
+ * Get all affected files (transitive dependencies)
124
+ */
125
+ getAffectedFiles(changedFiles: string[]): string[];
126
+ /**
127
+ * Parse import statements from file content
128
+ */
129
+ private parseImports;
130
+ /**
131
+ * Resolve import path to absolute path
132
+ */
133
+ private resolveImport;
134
+ }