@aiready/cli 0.12.12 → 0.12.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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.12.11 build /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.12.15 build /Users/pengcao/projects/aiready/packages/cli
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -10,7 +10,7 @@
10
10
  CJS Build start
11
11
  ESM Build start
12
12
 
13
- [4:21:51 PM]  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
13
+ [12:05:08 am]  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
14
14
 
15
15
  src/cli.ts:25:31:
16
16
   25 │ return dirname(fileURLToPath(import.meta.url));
@@ -20,10 +20,10 @@
20
20
 
21
21
 
22
22
 
23
- CJS dist/index.js 9.79 KB
24
- CJS dist/cli.js 68.56 KB
25
- CJS ⚡️ Build success in 27ms
26
23
  ESM dist/index.mjs 170.00 B
27
- ESM dist/chunk-OOQTTRPG.mjs 8.68 KB
28
- ESM dist/cli.mjs 56.77 KB
29
- ESM ⚡️ Build success in 27ms
24
+ ESM dist/chunk-VOKP7FGM.mjs 9.52 KB
25
+ ESM dist/cli.mjs 56.89 KB
26
+ ESM ⚡️ Build success in 26ms
27
+ CJS dist/index.js 10.62 KB
28
+ CJS dist/cli.js 69.52 KB
29
+ CJS ⚡️ Build success in 26ms
@@ -1,55 +1,110 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.12.11 test /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.12.15 test /Users/pengcao/projects/aiready/packages/cli
4
4
  > vitest run
5
5
 
6
6
  [?25l
7
7
   RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/cli
8
8
 
9
+ stdout | src/__tests__/config-shape.test.ts
10
+ [ToolRegistry#0.36469398534514474] Registering tool: pattern-detect (patterns, duplicates, duplication)
11
+
9
12
  stdout | src/__tests__/cli.test.ts
10
- [ToolRegistry#0.9613653982612667] Registering tool: pattern-detect (patterns, duplicates, duplication)
13
+ [ToolRegistry#0.630029442852271] Registering tool: pattern-detect (patterns, duplicates, duplication)
11
14
 
12
15
  stdout | src/__tests__/cli.test.ts
13
- [ToolRegistry#0.9613653982612667] Registering tool: context-analyzer (context, fragmentation, budget)
16
+ [ToolRegistry#0.630029442852271] Registering tool: context-analyzer (context, fragmentation, budget)
17
+
18
+ stdout | src/__tests__/config-shape.test.ts
19
+ [ToolRegistry#0.36469398534514474] Registering tool: context-analyzer (context, fragmentation, budget)
14
20
 
15
21
  stdout | src/__tests__/cli.test.ts
16
- [ToolRegistry#0.9613653982612667] Registering tool: naming-consistency (consistency, naming, standards)
22
+ [ToolRegistry#0.630029442852271] Registering tool: naming-consistency (consistency, naming, standards)
23
+
24
+ stdout | src/__tests__/config-shape.test.ts
25
+ [ToolRegistry#0.36469398534514474] Registering tool: naming-consistency (consistency, naming, standards)
26
+
27
+ stdout | src/__tests__/config-shape.test.ts
28
+ [ToolRegistry#0.36469398534514474] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
17
29
 
18
30
  stdout | src/__tests__/cli.test.ts
19
- [ToolRegistry#0.9613653982612667] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
31
+ [ToolRegistry#0.630029442852271] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
32
+
33
+ stdout | src/__tests__/config-shape.test.ts
34
+ [ToolRegistry#0.36469398534514474] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
20
35
 
21
36
  stdout | src/__tests__/cli.test.ts
22
- [ToolRegistry#0.9613653982612667] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
37
+ [ToolRegistry#0.630029442852271] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
38
+
39
+ stdout | src/__tests__/config-shape.test.ts
40
+ [ToolRegistry#0.36469398534514474] Registering tool: testability-index (testability, tests, verification)
23
41
 
24
42
  stdout | src/__tests__/cli.test.ts
25
- [ToolRegistry#0.9613653982612667] Registering tool: testability-index (testability, tests, verification)
43
+ [ToolRegistry#0.630029442852271] Registering tool: testability-index (testability, tests, verification)
44
+
45
+ stdout | src/__tests__/config-shape.test.ts
46
+ [ToolRegistry#0.36469398534514474] Registering tool: doc-drift (doc-drift, docs, jsdoc)
26
47
 
27
48
  stdout | src/__tests__/cli.test.ts
28
- [ToolRegistry#0.9613653982612667] Registering tool: doc-drift (doc-drift, docs, jsdoc)
49
+ [ToolRegistry#0.630029442852271] Registering tool: doc-drift (doc-drift, docs, jsdoc)
50
+
51
+ stdout | src/__tests__/config-shape.test.ts
52
+ [ToolRegistry#0.36469398534514474] Registering tool: dependency-health (deps, deps-health, packages)
29
53
 
30
54
  stdout | src/__tests__/cli.test.ts
31
- [ToolRegistry#0.9613653982612667] Registering tool: dependency-health (deps, deps-health, packages)
55
+ [ToolRegistry#0.630029442852271] Registering tool: dependency-health (deps, deps-health, packages)
56
+
57
+ stdout | src/__tests__/config-shape.test.ts
58
+ [ToolRegistry#0.36469398534514474] Registering tool: change-amplification (change-amp, change-amplification, coupling)
32
59
 
33
60
  stdout | src/__tests__/cli.test.ts
34
- [ToolRegistry#0.9613653982612667] Registering tool: change-amplification (change-amp, change-amplification, coupling)
61
+ [ToolRegistry#0.630029442852271] Registering tool: change-amplification (change-amp, change-amplification, coupling)
62
+
63
+ stdout | src/__tests__/config-shape.test.ts > CLI Configuration Shape > should generate a strictly portable AIReadyConfig in summary
64
+ [ToolRegistry#0.36469398534514474] Registering tool: pattern-detect (patterns)
35
65
 
36
66
  stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run unified analysis with both tools
37
- [ToolRegistry#0.9613653982612667] Registering tool: pattern-detect (patterns)
38
- [ToolRegistry#0.9613653982612667] Registering tool: context-analyzer (context)
67
+ [ToolRegistry#0.630029442852271] Registering tool: pattern-detect (patterns)
68
+ [ToolRegistry#0.630029442852271] Registering tool: context-analyzer (context)
69
+
70
+ stderr | src/__tests__/config-shape.test.ts > CLI Configuration Shape > should generate a strictly portable AIReadyConfig in summary
71
+ Python WASM not found in common locations, attempting fallback regex parser
72
+
73
+ stderr | src/__tests__/cli.test.ts > CLI Unified Analysis > should run unified analysis with both tools
74
+ Python WASM not found in common locations, attempting fallback regex parser
39
75
 
40
76
  stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only patterns tool
41
- [ToolRegistry#0.9613653982612667] Registering tool: pattern-detect (patterns)
42
- [ToolRegistry#0.9613653982612667] Registering tool: context-analyzer (context)
77
+ [ToolRegistry#0.630029442852271] Registering tool: pattern-detect (patterns)
78
+ [ToolRegistry#0.630029442852271] Registering tool: context-analyzer (context)
79
+
80
+ stderr | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only patterns tool
81
+ Python WASM not found in common locations, attempting fallback regex parser
43
82
 
44
83
  stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only context tool
45
- [ToolRegistry#0.9613653982612667] Registering tool: pattern-detect (patterns)
46
- [ToolRegistry#0.9613653982612667] Registering tool: context-analyzer (context)
84
+ [ToolRegistry#0.630029442852271] Registering tool: pattern-detect (patterns)
85
+ [ToolRegistry#0.630029442852271] Registering tool: context-analyzer (context)
86
+
87
+ stdout | src/__tests__/config-shape.test.ts > CLI Configuration Shape > should strip internal keys like useSmartDefaults and batchSize
88
+ [ToolRegistry#0.36469398534514474] Registering tool: pattern-detect (patterns)
89
+
90
+ stderr | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only context tool
91
+ Python WASM not found in common locations, attempting fallback regex parser
92
+
93
+ stderr | src/__tests__/config-shape.test.ts > CLI Configuration Shape > should strip internal keys like useSmartDefaults and batchSize
94
+ Python WASM not found in common locations, attempting fallback regex parser
95
+
96
+ stdout | src/__tests__/config-shape.test.ts > CLI Configuration Shape > should produce a config that is compatible with tool specific collection
97
+ [ToolRegistry#0.36469398534514474] Registering tool: pattern-detect (patterns)
98
+
99
+ stderr | src/__tests__/config-shape.test.ts > CLI Configuration Shape > should produce a config that is compatible with tool specific collection
100
+ Python WASM not found in common locations, attempting fallback regex parser
47
101
 
48
- ✓ src/__tests__/cli.test.ts (3 tests) 3ms
102
+ ✓ src/__tests__/cli.test.ts (3 tests) 7ms
103
+ ✓ src/__tests__/config-shape.test.ts (3 tests) 7ms
49
104
 
50
-  Test Files  1 passed (1)
51
-  Tests  3 passed (3)
52
-  Start at  15:53:25
53
-  Duration  377ms (transform 110ms, setup 0ms, import 299ms, tests 3ms, environment 0ms)
105
+  Test Files  2 passed (2)
106
+  Tests  6 passed (6)
107
+  Start at  00:05:20
108
+  Duration  456ms (transform 229ms, setup 0ms, import 664ms, tests 14ms, environment 0ms)
54
109
 
55
110
  [?25h
@@ -0,0 +1,301 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/index.ts
9
+ import {
10
+ ToolRegistry,
11
+ ToolName,
12
+ calculateOverallScore,
13
+ calculateTokenBudget,
14
+ GLOBAL_INFRA_OPTIONS,
15
+ COMMON_FINE_TUNING_OPTIONS
16
+ } from "@aiready/core";
17
+ import "@aiready/pattern-detect";
18
+ import "@aiready/context-analyzer";
19
+ import "@aiready/consistency";
20
+ import "@aiready/ai-signal-clarity";
21
+ import "@aiready/agent-grounding";
22
+ import "@aiready/testability";
23
+ import "@aiready/doc-drift";
24
+ import "@aiready/deps";
25
+ import "@aiready/change-amplification";
26
+ var TOOL_PACKAGE_MAP = {
27
+ [ToolName.PatternDetect]: "@aiready/pattern-detect",
28
+ [ToolName.ContextAnalyzer]: "@aiready/context-analyzer",
29
+ [ToolName.NamingConsistency]: "@aiready/consistency",
30
+ [ToolName.AiSignalClarity]: "@aiready/ai-signal-clarity",
31
+ [ToolName.AgentGrounding]: "@aiready/agent-grounding",
32
+ [ToolName.TestabilityIndex]: "@aiready/testability",
33
+ [ToolName.DocDrift]: "@aiready/doc-drift",
34
+ [ToolName.DependencyHealth]: "@aiready/deps",
35
+ [ToolName.ChangeAmplification]: "@aiready/change-amplification",
36
+ // Aliases handled by registry
37
+ patterns: "@aiready/pattern-detect",
38
+ duplicates: "@aiready/pattern-detect",
39
+ context: "@aiready/context-analyzer",
40
+ fragmentation: "@aiready/context-analyzer",
41
+ consistency: "@aiready/consistency",
42
+ "ai-signal": "@aiready/ai-signal-clarity",
43
+ grounding: "@aiready/agent-grounding",
44
+ testability: "@aiready/testability",
45
+ "deps-health": "@aiready/deps",
46
+ "change-amp": "@aiready/change-amplification"
47
+ };
48
+ function sanitizeConfigRecursive(obj) {
49
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj;
50
+ const sanitized = {};
51
+ const infraToStrip = [
52
+ "rootDir",
53
+ "onProgress",
54
+ "progressCallback",
55
+ "streamResults",
56
+ "batchSize",
57
+ "useSmartDefaults"
58
+ ];
59
+ for (const [key, value] of Object.entries(obj)) {
60
+ if (infraToStrip.includes(key)) continue;
61
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
62
+ sanitized[key] = sanitizeConfigRecursive(value);
63
+ } else {
64
+ sanitized[key] = value;
65
+ }
66
+ }
67
+ return sanitized;
68
+ }
69
+ function sanitizeToolConfig(config) {
70
+ return sanitizeConfigRecursive(config);
71
+ }
72
+ async function analyzeUnified(options) {
73
+ const startTime = Date.now();
74
+ const requestedTools = options.tools || [
75
+ "patterns",
76
+ "context",
77
+ "consistency"
78
+ ];
79
+ const result = {
80
+ summary: {
81
+ totalIssues: 0,
82
+ criticalIssues: 0,
83
+ // Added as per instruction
84
+ majorIssues: 0,
85
+ // Added as per instruction
86
+ totalFiles: 0,
87
+ toolsRun: [],
88
+ executionTime: 0,
89
+ config: options,
90
+ toolConfigs: {}
91
+ }
92
+ };
93
+ for (const toolName of requestedTools) {
94
+ let provider = ToolRegistry.find(toolName);
95
+ if (!provider) {
96
+ const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
97
+ try {
98
+ await import(packageName);
99
+ provider = ToolRegistry.find(toolName);
100
+ if (provider) {
101
+ console.log(
102
+ `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
103
+ );
104
+ } else {
105
+ console.log(
106
+ `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
107
+ );
108
+ }
109
+ } catch (err) {
110
+ console.log(
111
+ `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
112
+ err.message
113
+ );
114
+ }
115
+ }
116
+ if (!provider) {
117
+ console.warn(
118
+ `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
119
+ );
120
+ continue;
121
+ }
122
+ try {
123
+ const sanitizedOptions = { ...options };
124
+ delete sanitizedOptions.onProgress;
125
+ delete sanitizedOptions.progressCallback;
126
+ const toolOptions = {
127
+ rootDir: options.rootDir
128
+ // Always include rootDir
129
+ };
130
+ [...GLOBAL_INFRA_OPTIONS, ...COMMON_FINE_TUNING_OPTIONS].forEach(
131
+ (key) => {
132
+ if (key in options && key !== "toolConfigs" && key !== "tools") {
133
+ toolOptions[key] = options[key];
134
+ }
135
+ }
136
+ );
137
+ if (options.toolConfigs?.[provider.id]) {
138
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
139
+ } else if (options.tools && !Array.isArray(options.tools) && typeof options.tools === "object" && options.tools[provider.id]) {
140
+ Object.assign(toolOptions, options.tools[provider.id]);
141
+ } else if (options[provider.id]) {
142
+ Object.assign(toolOptions, options[provider.id]);
143
+ }
144
+ toolOptions.onProgress = (processed, total, message) => {
145
+ if (options.progressCallback) {
146
+ options.progressCallback({
147
+ tool: provider.id,
148
+ processed,
149
+ total,
150
+ message
151
+ });
152
+ }
153
+ };
154
+ const output = await provider.analyze(toolOptions);
155
+ if (output.metadata) {
156
+ output.metadata.config = sanitizeToolConfig(toolOptions);
157
+ }
158
+ if (options.progressCallback) {
159
+ options.progressCallback({ tool: provider.id, data: output });
160
+ }
161
+ result[provider.id] = output;
162
+ result.summary.toolsRun.push(provider.id);
163
+ if (output.summary?.config) {
164
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
165
+ output.summary.config
166
+ );
167
+ } else if (output.metadata?.config) {
168
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
169
+ output.metadata.config
170
+ );
171
+ } else {
172
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
173
+ }
174
+ const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
175
+ if (toolFiles > result.summary.totalFiles) {
176
+ result.summary.totalFiles = toolFiles;
177
+ }
178
+ const issueCount = output.results.reduce(
179
+ (sum, file) => sum + (file.issues?.length || 0),
180
+ 0
181
+ );
182
+ result.summary.totalIssues += issueCount;
183
+ if (provider.alias && Array.isArray(provider.alias)) {
184
+ for (const alias of provider.alias) {
185
+ if (!result[alias]) {
186
+ result[alias] = output;
187
+ }
188
+ }
189
+ }
190
+ const camelCaseId = provider.id.replace(
191
+ /-([a-z])/g,
192
+ (g) => g[1].toUpperCase()
193
+ );
194
+ if (camelCaseId !== provider.id && !result[camelCaseId]) {
195
+ result[camelCaseId] = output;
196
+ }
197
+ } catch (err) {
198
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
199
+ }
200
+ }
201
+ result.summary.config = sanitizeConfigRecursive({
202
+ scan: {
203
+ tools: requestedTools,
204
+ include: options.include,
205
+ exclude: options.exclude
206
+ },
207
+ // Use 'tools' for tool-specific configurations to match AIReadyConfig
208
+ tools: result.summary.toolConfigs
209
+ });
210
+ result.summary.executionTime = Date.now() - startTime;
211
+ return result;
212
+ }
213
+ async function scoreUnified(results, options) {
214
+ const toolScores = /* @__PURE__ */ new Map();
215
+ for (const toolId of results.summary.toolsRun) {
216
+ const provider = ToolRegistry.get(toolId);
217
+ if (!provider) continue;
218
+ const output = results[toolId];
219
+ if (!output) continue;
220
+ try {
221
+ const toolScore = provider.score(output, options);
222
+ if (!toolScore.tokenBudget) {
223
+ if (toolId === ToolName.PatternDetect && output.duplicates) {
224
+ const wastedTokens = output.duplicates.reduce(
225
+ (sum, d) => sum + (d.tokenCost || 0),
226
+ 0
227
+ );
228
+ toolScore.tokenBudget = calculateTokenBudget({
229
+ totalContextTokens: wastedTokens * 2,
230
+ wastedTokens: {
231
+ duplication: wastedTokens,
232
+ fragmentation: 0,
233
+ chattiness: 0
234
+ }
235
+ });
236
+ } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
237
+ toolScore.tokenBudget = calculateTokenBudget({
238
+ totalContextTokens: output.summary.totalTokens,
239
+ wastedTokens: {
240
+ duplication: 0,
241
+ fragmentation: output.summary.totalPotentialSavings || 0,
242
+ chattiness: 0
243
+ }
244
+ });
245
+ }
246
+ }
247
+ toolScores.set(toolId, toolScore);
248
+ } catch (err) {
249
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
250
+ }
251
+ }
252
+ if (toolScores.size === 0) {
253
+ return {
254
+ overall: 0,
255
+ rating: "Critical",
256
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
257
+ toolsUsed: [],
258
+ breakdown: [],
259
+ calculation: {
260
+ formula: "0 / 0 = 0",
261
+ weights: {},
262
+ normalized: "0 / 0 = 0"
263
+ }
264
+ };
265
+ }
266
+ return calculateOverallScore(toolScores, options, void 0);
267
+ }
268
+ function generateUnifiedSummary(result) {
269
+ const { summary } = result;
270
+ let output = `\u{1F680} AIReady Analysis Complete
271
+
272
+ `;
273
+ output += `\u{1F4CA} Summary:
274
+ `;
275
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
276
+ `;
277
+ output += ` Total issues found: ${summary.totalIssues}
278
+ `;
279
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
280
+
281
+ `;
282
+ for (const provider of ToolRegistry.getAll()) {
283
+ const toolResult = result[provider.id];
284
+ if (toolResult) {
285
+ const issueCount = toolResult.results.reduce(
286
+ (sum, r) => sum + (r.issues?.length || 0),
287
+ 0
288
+ );
289
+ output += `\u2022 ${provider.id}: ${issueCount} issues
290
+ `;
291
+ }
292
+ }
293
+ return output;
294
+ }
295
+
296
+ export {
297
+ __require,
298
+ analyzeUnified,
299
+ scoreUnified,
300
+ generateUnifiedSummary
301
+ };