@aiready/cli 0.13.7 → 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.
- package/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-test.log +32 -32
- package/dist/cli.js +290 -188
- package/dist/cli.mjs +239 -137
- package/package.json +12 -12
- package/packages/core/src/.aiready/aiready-report-20260314-161145.json +230 -0
- package/packages/core/src/.aiready/aiready-report-20260314-161152.json +253 -0
- package/packages/pattern-detect/src/.aiready/aiready-report-20260314-161139.json +230 -0
- package/src/.aiready/aiready-report-20260312-110843.json +28746 -0
- package/src/.aiready/aiready-report-20260312-110955.json +28746 -0
- package/src/cli.ts +15 -0
- package/src/commands/index.ts +1 -0
- package/src/commands/init.ts +97 -0
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')
|
package/src/commands/index.ts
CHANGED
|
@@ -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
|
+
}
|