@aiready/cli 0.13.8 → 0.14.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.
@@ -0,0 +1,230 @@
1
+ {
2
+ "summary": {
3
+ "totalIssues": 0,
4
+ "criticalIssues": 0,
5
+ "majorIssues": 0,
6
+ "totalFiles": 0,
7
+ "toolsRun": [
8
+ "pattern-detect"
9
+ ],
10
+ "executionTime": 7,
11
+ "config": {
12
+ "scan": {
13
+ "tools": [
14
+ "patterns"
15
+ ]
16
+ },
17
+ "tools": {
18
+ "pattern-detect": {
19
+ "minSimilarity": 0.5,
20
+ "minLines": 6,
21
+ "approx": true,
22
+ "minSharedTokens": 10,
23
+ "maxCandidatesPerBlock": 100,
24
+ "severity": "all"
25
+ }
26
+ }
27
+ },
28
+ "toolConfigs": {
29
+ "pattern-detect": {
30
+ "minSimilarity": 0.5,
31
+ "minLines": 6,
32
+ "approx": true,
33
+ "minSharedTokens": 10,
34
+ "maxCandidatesPerBlock": 100,
35
+ "severity": "all"
36
+ }
37
+ }
38
+ },
39
+ "pattern-detect": {
40
+ "results": [],
41
+ "summary": {
42
+ "totalFiles": 0,
43
+ "totalIssues": 0,
44
+ "duplicates": [],
45
+ "clusters": [],
46
+ "config": {
47
+ "rootDir": "/Users/pengcao/projects/aiready/packages/cli/packages/pattern-detect/src",
48
+ "minSimilarity": 0.5,
49
+ "minLines": 6,
50
+ "approx": true,
51
+ "minSharedTokens": 10,
52
+ "maxCandidatesPerBlock": 100,
53
+ "severity": "all"
54
+ }
55
+ },
56
+ "metadata": {
57
+ "toolName": "pattern-detect",
58
+ "version": "0.12.5",
59
+ "timestamp": "2026-03-14T05:11:39.972Z",
60
+ "config": {
61
+ "minSimilarity": 0.5,
62
+ "minLines": 6,
63
+ "approx": true,
64
+ "minSharedTokens": 10,
65
+ "maxCandidatesPerBlock": 100,
66
+ "severity": "all",
67
+ "includeTests": false
68
+ }
69
+ }
70
+ },
71
+ "patterns": {
72
+ "results": [],
73
+ "summary": {
74
+ "totalFiles": 0,
75
+ "totalIssues": 0,
76
+ "duplicates": [],
77
+ "clusters": [],
78
+ "config": {
79
+ "rootDir": "/Users/pengcao/projects/aiready/packages/cli/packages/pattern-detect/src",
80
+ "minSimilarity": 0.5,
81
+ "minLines": 6,
82
+ "approx": true,
83
+ "minSharedTokens": 10,
84
+ "maxCandidatesPerBlock": 100,
85
+ "severity": "all"
86
+ }
87
+ },
88
+ "metadata": {
89
+ "toolName": "pattern-detect",
90
+ "version": "0.12.5",
91
+ "timestamp": "2026-03-14T05:11:39.972Z",
92
+ "config": {
93
+ "minSimilarity": 0.5,
94
+ "minLines": 6,
95
+ "approx": true,
96
+ "minSharedTokens": 10,
97
+ "maxCandidatesPerBlock": 100,
98
+ "severity": "all",
99
+ "includeTests": false
100
+ }
101
+ }
102
+ },
103
+ "duplicates": {
104
+ "results": [],
105
+ "summary": {
106
+ "totalFiles": 0,
107
+ "totalIssues": 0,
108
+ "duplicates": [],
109
+ "clusters": [],
110
+ "config": {
111
+ "rootDir": "/Users/pengcao/projects/aiready/packages/cli/packages/pattern-detect/src",
112
+ "minSimilarity": 0.5,
113
+ "minLines": 6,
114
+ "approx": true,
115
+ "minSharedTokens": 10,
116
+ "maxCandidatesPerBlock": 100,
117
+ "severity": "all"
118
+ }
119
+ },
120
+ "metadata": {
121
+ "toolName": "pattern-detect",
122
+ "version": "0.12.5",
123
+ "timestamp": "2026-03-14T05:11:39.972Z",
124
+ "config": {
125
+ "minSimilarity": 0.5,
126
+ "minLines": 6,
127
+ "approx": true,
128
+ "minSharedTokens": 10,
129
+ "maxCandidatesPerBlock": 100,
130
+ "severity": "all",
131
+ "includeTests": false
132
+ }
133
+ }
134
+ },
135
+ "duplication": {
136
+ "results": [],
137
+ "summary": {
138
+ "totalFiles": 0,
139
+ "totalIssues": 0,
140
+ "duplicates": [],
141
+ "clusters": [],
142
+ "config": {
143
+ "rootDir": "/Users/pengcao/projects/aiready/packages/cli/packages/pattern-detect/src",
144
+ "minSimilarity": 0.5,
145
+ "minLines": 6,
146
+ "approx": true,
147
+ "minSharedTokens": 10,
148
+ "maxCandidatesPerBlock": 100,
149
+ "severity": "all"
150
+ }
151
+ },
152
+ "metadata": {
153
+ "toolName": "pattern-detect",
154
+ "version": "0.12.5",
155
+ "timestamp": "2026-03-14T05:11:39.972Z",
156
+ "config": {
157
+ "minSimilarity": 0.5,
158
+ "minLines": 6,
159
+ "approx": true,
160
+ "minSharedTokens": 10,
161
+ "maxCandidatesPerBlock": 100,
162
+ "severity": "all",
163
+ "includeTests": false
164
+ }
165
+ }
166
+ },
167
+ "patternDetect": {
168
+ "results": [],
169
+ "summary": {
170
+ "totalFiles": 0,
171
+ "totalIssues": 0,
172
+ "duplicates": [],
173
+ "clusters": [],
174
+ "config": {
175
+ "rootDir": "/Users/pengcao/projects/aiready/packages/cli/packages/pattern-detect/src",
176
+ "minSimilarity": 0.5,
177
+ "minLines": 6,
178
+ "approx": true,
179
+ "minSharedTokens": 10,
180
+ "maxCandidatesPerBlock": 100,
181
+ "severity": "all"
182
+ }
183
+ },
184
+ "metadata": {
185
+ "toolName": "pattern-detect",
186
+ "version": "0.12.5",
187
+ "timestamp": "2026-03-14T05:11:39.972Z",
188
+ "config": {
189
+ "minSimilarity": 0.5,
190
+ "minLines": 6,
191
+ "approx": true,
192
+ "minSharedTokens": 10,
193
+ "maxCandidatesPerBlock": 100,
194
+ "severity": "all",
195
+ "includeTests": false
196
+ }
197
+ }
198
+ },
199
+ "results": [],
200
+ "scoring": {
201
+ "overall": 100,
202
+ "rating": "Excellent",
203
+ "timestamp": "2026-03-14T05:11:39.975Z",
204
+ "toolsUsed": [
205
+ "pattern-detect"
206
+ ],
207
+ "breakdown": [
208
+ {
209
+ "toolName": "pattern-detect",
210
+ "score": 100,
211
+ "rawMetrics": {
212
+ "totalDuplicates": 0,
213
+ "totalTokenCost": 0,
214
+ "highImpactDuplicates": 0,
215
+ "totalFilesAnalyzed": 0
216
+ },
217
+ "factors": [],
218
+ "recommendations": []
219
+ }
220
+ ],
221
+ "calculation": {
222
+ "formula": "[(100 × 22)] / 22 = 100",
223
+ "weights": {
224
+ "pattern-detect": 22
225
+ },
226
+ "normalized": "[(100 × 22)] / 22 = 100"
227
+ }
228
+ },
229
+ "repository": {}
230
+ }
package/src/cli.ts CHANGED
@@ -8,6 +8,7 @@ import { fileURLToPath } from 'url';
8
8
  import {
9
9
  scanAction,
10
10
  scanHelpText,
11
+ initAction,
11
12
  patternsAction,
12
13
  patternsHelpText,
13
14
  contextAction,
@@ -122,6 +123,20 @@ program
122
123
  await scanAction(directory, options);
123
124
  });
124
125
 
126
+ // Init command - Generate default configuration
127
+ program
128
+ .command('init')
129
+ .description('Generate a default configuration (aiready.json)')
130
+ .option('-f, --force', 'Overwrite existing configuration file')
131
+ .option(
132
+ '--js',
133
+ 'Generate configuration as a JavaScript file (aiready.config.js)'
134
+ )
135
+ .action(async (options) => {
136
+ const format = options.js ? 'js' : 'json';
137
+ await initAction({ force: options.force, format });
138
+ });
139
+
125
140
  // Patterns command - Detect duplicate code patterns
126
141
  program
127
142
  .command('patterns')
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  export { scanAction, scanHelpText } from './scan';
6
+ export { initAction } from './init';
6
7
  export { patternsAction, patternsHelpText } from './patterns';
7
8
  export { contextAction } from './context';
8
9
  export { consistencyAction } from './consistency';
@@ -0,0 +1,97 @@
1
+ import { writeFileSync, existsSync } from 'fs';
2
+ import { join } from 'path';
3
+ import chalk from 'chalk';
4
+ import { ToolName } from '@aiready/core';
5
+
6
+ export async function initAction(options: {
7
+ force?: boolean;
8
+ format?: 'json' | 'js';
9
+ }) {
10
+ const fileExt = options.format === 'js' ? 'js' : 'json';
11
+ const fileName = fileExt === 'js' ? 'aiready.config.js' : 'aiready.json';
12
+ const filePath = join(process.cwd(), fileName);
13
+
14
+ if (existsSync(filePath) && !options.force) {
15
+ console.error(
16
+ chalk.red(`Error: ${fileName} already exists. Use --force to overwrite.`)
17
+ );
18
+ process.exit(1);
19
+ }
20
+
21
+ const defaultConfig = {
22
+ scan: {
23
+ include: [
24
+ 'src/**/*.ts',
25
+ 'src/**/*.js',
26
+ 'lib/**/*.ts',
27
+ 'packages/*/src/**/*.ts',
28
+ ],
29
+ exclude: [
30
+ '**/node_modules/**',
31
+ '**/dist/**',
32
+ '**/build/**',
33
+ '**/*.test.ts',
34
+ '**/*.spec.ts',
35
+ ],
36
+ tools: [
37
+ ToolName.PatternDetect,
38
+ ToolName.ContextAnalyzer,
39
+ ToolName.NamingConsistency,
40
+ ToolName.AiSignalClarity,
41
+ ToolName.AgentGrounding,
42
+ ToolName.TestabilityIndex,
43
+ ToolName.DocDrift,
44
+ ToolName.DependencyHealth,
45
+ ToolName.ChangeAmplification,
46
+ ],
47
+ },
48
+ tools: {
49
+ [ToolName.PatternDetect]: {
50
+ minSimilarity: 0.8,
51
+ minLines: 5,
52
+ },
53
+ [ToolName.ContextAnalyzer]: {
54
+ maxContextBudget: 128000,
55
+ minCohesion: 0.6,
56
+ },
57
+ [ToolName.NamingConsistency]: {
58
+ shortWords: ['id', 'db', 'ui', 'ai'],
59
+ },
60
+ [ToolName.AiSignalClarity]: {
61
+ checkMagicLiterals: true,
62
+ checkBooleanTraps: true,
63
+ checkAmbiguousNames: true,
64
+ checkUndocumentedExports: true,
65
+ },
66
+ },
67
+ scoring: {
68
+ threshold: 70,
69
+ showBreakdown: true,
70
+ },
71
+ };
72
+
73
+ let content = '';
74
+ if (fileExt === 'js') {
75
+ content = `/** @type {import('@aiready/core').AIReadyConfig} */\nmodule.exports = ${JSON.stringify(
76
+ defaultConfig,
77
+ null,
78
+ 2
79
+ )};\n`;
80
+ } else {
81
+ content = JSON.stringify(defaultConfig, null, 2);
82
+ }
83
+
84
+ try {
85
+ writeFileSync(filePath, content, 'utf8');
86
+ console.log(
87
+ chalk.green(`\n✅ Created default configuration: ${chalk.bold(fileName)}`)
88
+ );
89
+ console.log(
90
+ chalk.cyan('You can now fine-tune your settings and run AIReady with:')
91
+ );
92
+ console.log(chalk.white(` $ aiready scan\n`));
93
+ } catch (error) {
94
+ console.error(chalk.red(`Failed to write configuration file: ${error}`));
95
+ process.exit(1);
96
+ }
97
+ }