@aiready/cli 0.14.2 → 0.14.4
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/.aiready/aiready-report-20260314-164626.json +2 -5
- package/.aiready/aiready-report-20260314-164741.json +2 -5
- package/.turbo/turbo-build.log +29 -28
- package/.turbo/turbo-lint.log +0 -32
- package/.turbo/turbo-test.log +35 -125
- package/aiready-report.json +30703 -0
- package/dist/cli.js +415 -378
- package/dist/cli.mjs +358 -320
- package/package.json +12 -12
- package/packages/core/src/.aiready/aiready-report-20260314-161145.json +4 -10
- package/packages/core/src/.aiready/aiready-report-20260314-161152.json +10 -28
- package/packages/pattern-detect/src/.aiready/aiready-report-20260314-161139.json +4 -10
- package/src/.aiready/aiready-report-20260312-103623.json +3 -9
- package/src/.aiready/aiready-report-20260312-110843.json +3 -9
- package/src/.aiready/aiready-report-20260312-110955.json +3 -9
- package/src/.aiready/aiready-report-20260314-203209.json +3 -9
- package/src/.aiready/aiready-report-20260314-203736.json +3 -9
- package/src/.aiready/aiready-report-20260314-203857.json +3 -9
- package/src/.aiready/aiready-report-20260314-204047.json +3 -9
- package/src/__tests__/cli.test.ts +1 -1
- package/src/__tests__/config-shape.test.ts +0 -1
- package/src/__tests__/unified.test.ts +1 -1
- package/src/cli.ts +2 -1
- package/src/commands/__tests__/consistency.test.ts +3 -0
- package/src/commands/__tests__/extra-commands.test.ts +29 -38
- package/src/commands/__tests__/init.test.ts +56 -0
- package/src/commands/__tests__/scan.test.ts +4 -2
- package/src/commands/__tests__/upload.test.ts +0 -1
- package/src/commands/__tests__/visualize.test.ts +3 -7
- package/src/commands/ai-signal-clarity.ts +1 -56
- package/src/commands/bug.ts +1 -2
- package/src/commands/deps-health.ts +1 -65
- package/src/commands/doc-drift.ts +1 -62
- package/src/commands/init.ts +58 -2
- package/src/commands/patterns.ts +3 -1
- package/src/commands/report-formatter.ts +128 -0
- package/src/commands/scan.ts +29 -120
- package/src/commands/shared/configured-tool-action.ts +35 -0
- package/src/commands/shared/standard-tool-actions.ts +126 -0
- package/src/commands/upload.ts +15 -13
- package/src/commands/visualize.ts +11 -4
- package/src/index.ts +18 -3
- package/src/utils/helpers.ts +86 -37
- package/vitest.config.ts +5 -12
package/src/utils/helpers.ts
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { resolve as resolvePath } from 'path';
|
|
6
|
-
import { existsSync,
|
|
6
|
+
import { existsSync, readFileSync } from 'fs';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
|
+
import { loadConfig, mergeConfigWithDefaults } from '@aiready/core';
|
|
9
|
+
import type { ToolScoringOutput } from '@aiready/core';
|
|
10
|
+
|
|
11
|
+
// Re-export findLatestReport from core for deduplication with visualizer
|
|
12
|
+
export { findLatestReport } from '@aiready/core';
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Generate timestamp for report filenames (YYYYMMDD-HHMMSS)
|
|
@@ -16,42 +21,6 @@ export function getReportTimestamp(): string {
|
|
|
16
21
|
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
/**
|
|
20
|
-
* Find the latest aiready report in the .aiready directory
|
|
21
|
-
* Searches for both new format (aiready-report-*) and legacy format (aiready-scan-*)
|
|
22
|
-
*/
|
|
23
|
-
export function findLatestScanReport(dirPath: string): string | null {
|
|
24
|
-
const aireadyDir = resolvePath(dirPath, '.aiready');
|
|
25
|
-
if (!existsSync(aireadyDir)) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Search for new format first, then legacy format
|
|
30
|
-
let files = readdirSync(aireadyDir).filter(
|
|
31
|
-
(f) => f.startsWith('aiready-report-') && f.endsWith('.json')
|
|
32
|
-
);
|
|
33
|
-
if (files.length === 0) {
|
|
34
|
-
files = readdirSync(aireadyDir).filter(
|
|
35
|
-
(f) => f.startsWith('aiready-scan-') && f.endsWith('.json')
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (files.length === 0) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Sort by modification time, most recent first
|
|
44
|
-
const sortedFiles = files
|
|
45
|
-
.map((f) => ({
|
|
46
|
-
name: f,
|
|
47
|
-
path: resolvePath(aireadyDir, f),
|
|
48
|
-
mtime: statSync(resolvePath(aireadyDir, f)).mtime,
|
|
49
|
-
}))
|
|
50
|
-
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
51
|
-
|
|
52
|
-
return sortedFiles[0].path;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
24
|
/**
|
|
56
25
|
* Warn if graph caps may be exceeded
|
|
57
26
|
*/
|
|
@@ -156,3 +125,83 @@ export function truncateArray(arr: any[] | undefined, cap = 8): string {
|
|
|
156
125
|
const more = arr.length - shown.length;
|
|
157
126
|
return shown.join(', ') + (more > 0 ? `, ... (+${more} more)` : '');
|
|
158
127
|
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Build a common ToolScoringOutput payload from a tool report.
|
|
131
|
+
*/
|
|
132
|
+
export function buildToolScoringOutput(
|
|
133
|
+
toolName: string,
|
|
134
|
+
report: {
|
|
135
|
+
summary: { score: number };
|
|
136
|
+
rawData?: Record<string, unknown>;
|
|
137
|
+
recommendations?: string[];
|
|
138
|
+
}
|
|
139
|
+
): ToolScoringOutput {
|
|
140
|
+
return {
|
|
141
|
+
toolName,
|
|
142
|
+
score: report.summary.score,
|
|
143
|
+
rawMetrics: report.rawData ?? {},
|
|
144
|
+
factors: [],
|
|
145
|
+
recommendations: (report.recommendations ?? []).map((action: string) => ({
|
|
146
|
+
action,
|
|
147
|
+
estimatedImpact: 5,
|
|
148
|
+
priority: 'medium',
|
|
149
|
+
})),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Load config and apply tool-level defaults.
|
|
155
|
+
*/
|
|
156
|
+
export async function loadMergedToolConfig<T extends Record<string, unknown>>(
|
|
157
|
+
directory: string,
|
|
158
|
+
defaults: T
|
|
159
|
+
): Promise<T & Record<string, unknown>> {
|
|
160
|
+
const config = await loadConfig(directory);
|
|
161
|
+
return mergeConfigWithDefaults(config, defaults) as T &
|
|
162
|
+
Record<string, unknown>;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Shared base scan options used by CLI tool commands.
|
|
167
|
+
*/
|
|
168
|
+
export function buildCommonScanOptions(
|
|
169
|
+
directory: string,
|
|
170
|
+
options: any,
|
|
171
|
+
extras: Record<string, unknown> = {}
|
|
172
|
+
): Record<string, unknown> {
|
|
173
|
+
return {
|
|
174
|
+
rootDir: directory,
|
|
175
|
+
include: options.include,
|
|
176
|
+
exclude: options.exclude,
|
|
177
|
+
...extras,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Execute a config-driven tool command with shared CLI plumbing.
|
|
183
|
+
*/
|
|
184
|
+
export async function runConfiguredToolCommand<TReport, TScoring>(params: {
|
|
185
|
+
directory: string;
|
|
186
|
+
options: any;
|
|
187
|
+
defaults: Record<string, unknown>;
|
|
188
|
+
analyze: (scanOptions: any) => Promise<TReport>;
|
|
189
|
+
getExtras: (
|
|
190
|
+
options: any,
|
|
191
|
+
merged: Record<string, unknown>
|
|
192
|
+
) => Record<string, unknown>;
|
|
193
|
+
score: (report: TReport) => TScoring;
|
|
194
|
+
}): Promise<{ report: TReport; scoring: TScoring }> {
|
|
195
|
+
const merged = await loadMergedToolConfig(params.directory, params.defaults);
|
|
196
|
+
const report = await params.analyze(
|
|
197
|
+
buildCommonScanOptions(
|
|
198
|
+
params.directory,
|
|
199
|
+
params.options,
|
|
200
|
+
params.getExtras(params.options, merged)
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
return {
|
|
204
|
+
report,
|
|
205
|
+
scoring: params.score(report),
|
|
206
|
+
};
|
|
207
|
+
}
|
package/vitest.config.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { defineConfig } from 'vitest/config';
|
|
2
|
-
import {
|
|
2
|
+
import { createAireadyVitestAliases } from '../../vitest-aliases';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
test: {
|
|
6
6
|
globals: true,
|
|
7
7
|
environment: 'node',
|
|
8
|
-
alias: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'../pattern-detect/src/index.ts'
|
|
13
|
-
),
|
|
14
|
-
'@aiready/context-analyzer': resolve(
|
|
15
|
-
__dirname,
|
|
16
|
-
'../context-analyzer/src/index.ts'
|
|
17
|
-
),
|
|
18
|
-
},
|
|
8
|
+
alias: createAireadyVitestAliases(__dirname, {
|
|
9
|
+
packagesRootRelative: '..',
|
|
10
|
+
useIndexEntrypoints: true,
|
|
11
|
+
}),
|
|
19
12
|
},
|
|
20
13
|
});
|