@aiready/cli 0.3.7 → 0.4.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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.3.7 build /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.4.0 build /Users/pengcao/projects/aiready/packages/cli
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm --dts
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,16 +9,16 @@
9
9
  CLI Target: es2020
10
10
  CJS Build start
11
11
  ESM Build start
12
- CJS dist/index.js 2.57 KB
13
- CJS dist/cli.js 10.77 KB
14
- CJS ⚡️ Build success in 58ms
12
+ CJS dist/index.js 3.15 KB
13
+ CJS dist/cli.js 15.94 KB
14
+ CJS ⚡️ Build success in 60ms
15
+ ESM dist/chunk-VOB7SA3E.mjs 2.02 KB
16
+ ESM dist/cli.mjs 12.36 KB
15
17
  ESM dist/index.mjs 138.00 B
16
- ESM dist/cli.mjs 7.92 KB
17
- ESM dist/chunk-KZKXZKES.mjs 1.45 KB
18
- ESM ⚡️ Build success in 58ms
18
+ ESM ⚡️ Build success in 60ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 534ms
20
+ DTS ⚡️ Build success in 485ms
21
21
  DTS dist/cli.d.ts 20.00 B
22
- DTS dist/index.d.ts 880.00 B
22
+ DTS dist/index.d.ts 991.00 B
23
23
  DTS dist/cli.d.mts 20.00 B
24
- DTS dist/index.d.mts 880.00 B
24
+ DTS dist/index.d.mts 991.00 B
@@ -0,0 +1,71 @@
1
+ // src/index.ts
2
+ import { analyzePatterns } from "@aiready/pattern-detect";
3
+ import { analyzeContext } from "@aiready/context-analyzer";
4
+ import { analyzeConsistency } from "@aiready/consistency";
5
+ async function analyzeUnified(options) {
6
+ const startTime = Date.now();
7
+ const tools = options.tools || ["patterns", "context", "consistency"];
8
+ const result = {
9
+ summary: {
10
+ totalIssues: 0,
11
+ toolsRun: tools,
12
+ executionTime: 0
13
+ }
14
+ };
15
+ if (tools.includes("patterns")) {
16
+ const patternResult = await analyzePatterns(options);
17
+ result.patterns = patternResult.results;
18
+ result.summary.totalIssues += patternResult.results.length;
19
+ }
20
+ if (tools.includes("context")) {
21
+ result.context = await analyzeContext(options);
22
+ result.summary.totalIssues += result.context?.length || 0;
23
+ }
24
+ if (tools.includes("consistency")) {
25
+ const report = await analyzeConsistency({
26
+ rootDir: options.rootDir,
27
+ include: options.include,
28
+ exclude: options.exclude,
29
+ checkNaming: true,
30
+ checkPatterns: true,
31
+ minSeverity: "info"
32
+ });
33
+ result.consistency = report;
34
+ result.summary.totalIssues += report.summary.totalIssues;
35
+ }
36
+ result.summary.executionTime = Date.now() - startTime;
37
+ return result;
38
+ }
39
+ function generateUnifiedSummary(result) {
40
+ const { summary } = result;
41
+ let output = `\u{1F680} AIReady Analysis Complete
42
+
43
+ `;
44
+ output += `\u{1F4CA} Summary:
45
+ `;
46
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
47
+ `;
48
+ output += ` Total issues found: ${summary.totalIssues}
49
+ `;
50
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
51
+
52
+ `;
53
+ if (result.patterns?.length) {
54
+ output += `\u{1F50D} Pattern Analysis: ${result.patterns.length} issues
55
+ `;
56
+ }
57
+ if (result.context?.length) {
58
+ output += `\u{1F9E0} Context Analysis: ${result.context.length} issues
59
+ `;
60
+ }
61
+ if (result.consistency) {
62
+ output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
63
+ `;
64
+ }
65
+ return output;
66
+ }
67
+
68
+ export {
69
+ analyzeUnified,
70
+ generateUnifiedSummary
71
+ };
package/dist/cli.js CHANGED
@@ -29,9 +29,10 @@ var import_commander = require("commander");
29
29
  // src/index.ts
30
30
  var import_pattern_detect = require("@aiready/pattern-detect");
31
31
  var import_context_analyzer = require("@aiready/context-analyzer");
32
+ var import_consistency = require("@aiready/consistency");
32
33
  async function analyzeUnified(options) {
33
34
  const startTime = Date.now();
34
- const tools = options.tools || ["patterns", "context"];
35
+ const tools = options.tools || ["patterns", "context", "consistency"];
35
36
  const result = {
36
37
  summary: {
37
38
  totalIssues: 0,
@@ -48,6 +49,18 @@ async function analyzeUnified(options) {
48
49
  result.context = await (0, import_context_analyzer.analyzeContext)(options);
49
50
  result.summary.totalIssues += result.context?.length || 0;
50
51
  }
52
+ if (tools.includes("consistency")) {
53
+ const report = await (0, import_consistency.analyzeConsistency)({
54
+ rootDir: options.rootDir,
55
+ include: options.include,
56
+ exclude: options.exclude,
57
+ checkNaming: true,
58
+ checkPatterns: true,
59
+ minSeverity: "info"
60
+ });
61
+ result.consistency = report;
62
+ result.summary.totalIssues += report.summary.totalIssues;
63
+ }
51
64
  result.summary.executionTime = Date.now() - startTime;
52
65
  return result;
53
66
  }
@@ -71,6 +84,10 @@ function generateUnifiedSummary(result) {
71
84
  }
72
85
  if (result.context?.length) {
73
86
  output += `\u{1F9E0} Context Analysis: ${result.context.length} issues
87
+ `;
88
+ }
89
+ if (result.consistency) {
90
+ output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
74
91
  `;
75
92
  }
76
93
  return output;
@@ -78,18 +95,19 @@ function generateUnifiedSummary(result) {
78
95
 
79
96
  // src/cli.ts
80
97
  var import_chalk = __toESM(require("chalk"));
98
+ var import_fs = require("fs");
81
99
  var import_path = require("path");
82
100
  var import_core = require("@aiready/core");
83
- var import_fs = require("fs");
84
- var packageJson = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(__dirname, "../package.json"), "utf8"));
101
+ var import_fs2 = require("fs");
102
+ var packageJson = JSON.parse((0, import_fs2.readFileSync)((0, import_path.join)(__dirname, "../package.json"), "utf8"));
85
103
  var program = new import_commander.Command();
86
104
  program.name("aiready").description("AIReady - Unified AI-readiness analysis tools").version(packageJson.version).addHelpText("after", "\nCONFIGURATION:\n Supports config files: aiready.json, aiready.config.json, .aiready.json, .aireadyrc.json, aiready.config.js, .aireadyrc.js\n CLI options override config file settings");
87
- program.command("scan").description("Run unified analysis on a codebase").argument("<directory>", "Directory to analyze").option("-t, --tools <tools>", "Tools to run (comma-separated: patterns,context)", "patterns,context").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option("-o, --output <format>", "Output format: console, json", "console").option("--output-file <path>", "Output file path (for json)").action(async (directory, options) => {
105
+ program.command("scan").description("Run unified analysis on a codebase").argument("<directory>", "Directory to analyze").option("-t, --tools <tools>", "Tools to run (comma-separated: patterns,context,consistency)", "patterns,context,consistency").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option("-o, --output <format>", "Output format: console, json", "console").option("--output-file <path>", "Output file path (for json)").action(async (directory, options) => {
88
106
  console.log(import_chalk.default.blue("\u{1F680} Starting AIReady unified analysis...\n"));
89
107
  const startTime = Date.now();
90
108
  try {
91
109
  const defaults = {
92
- tools: ["patterns", "context"],
110
+ tools: ["patterns", "context", "consistency"],
93
111
  include: void 0,
94
112
  exclude: void 0,
95
113
  output: {
@@ -195,12 +213,23 @@ program.command("context").description("Run context window cost analysis").argum
195
213
  file: void 0
196
214
  }
197
215
  };
198
- const finalOptions = (0, import_core.loadMergedConfig)(directory, defaults, {
216
+ let baseOptions = (0, import_core.loadMergedConfig)(directory, defaults, {
199
217
  maxDepth: options.maxDepth ? parseInt(options.maxDepth) : void 0,
200
218
  maxContextBudget: options.maxContext ? parseInt(options.maxContext) : void 0,
201
219
  include: options.include?.split(","),
202
220
  exclude: options.exclude?.split(",")
203
221
  });
222
+ let finalOptions = { ...baseOptions };
223
+ const { getSmartDefaults } = await import("@aiready/context-analyzer");
224
+ const contextSmartDefaults = await getSmartDefaults(directory, baseOptions);
225
+ finalOptions = { ...contextSmartDefaults, ...finalOptions };
226
+ console.log("\u{1F4CB} Configuration:");
227
+ console.log(` Max depth: ${finalOptions.maxDepth}`);
228
+ console.log(` Max context budget: ${finalOptions.maxContextBudget}`);
229
+ console.log(` Min cohesion: ${(finalOptions.minCohesion * 100).toFixed(1)}%`);
230
+ console.log(` Max fragmentation: ${(finalOptions.maxFragmentation * 100).toFixed(1)}%`);
231
+ console.log(` Analysis focus: ${finalOptions.focus}`);
232
+ console.log("");
204
233
  const { analyzeContext: analyzeContext2, generateSummary } = await import("@aiready/context-analyzer");
205
234
  const results = await analyzeContext2(finalOptions);
206
235
  const elapsedTime = (0, import_core.getElapsedTime)(startTime);
@@ -224,4 +253,97 @@ program.command("context").description("Run context window cost analysis").argum
224
253
  (0, import_core.handleCLIError)(error, "Context analysis");
225
254
  }
226
255
  });
256
+ program.command("consistency").description("Check naming, patterns, and architecture consistency").argument("<directory>", "Directory to analyze").option("--naming", "Check naming conventions (default: true)").option("--no-naming", "Skip naming analysis").option("--patterns", "Check code patterns (default: true)").option("--no-patterns", "Skip pattern analysis").option("--min-severity <level>", "Minimum severity: info|minor|major|critical", "info").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option("-o, --output <format>", "Output format: console, json, markdown", "console").option("--output-file <path>", "Output file path (for json/markdown)").action(async (directory, options) => {
257
+ console.log(import_chalk.default.blue("\u{1F50D} Analyzing consistency...\n"));
258
+ const startTime = Date.now();
259
+ try {
260
+ const defaults = {
261
+ checkNaming: true,
262
+ checkPatterns: true,
263
+ minSeverity: "info",
264
+ include: void 0,
265
+ exclude: void 0,
266
+ output: {
267
+ format: "console",
268
+ file: void 0
269
+ }
270
+ };
271
+ const finalOptions = (0, import_core.loadMergedConfig)(directory, defaults, {
272
+ checkNaming: options.naming !== false,
273
+ checkPatterns: options.patterns !== false,
274
+ minSeverity: options.minSeverity,
275
+ include: options.include?.split(","),
276
+ exclude: options.exclude?.split(",")
277
+ });
278
+ const { analyzeConsistency: analyzeConsistency2 } = await import("@aiready/consistency");
279
+ const report = await analyzeConsistency2(finalOptions);
280
+ const elapsedTime = (0, import_core.getElapsedTime)(startTime);
281
+ const outputFormat = options.output || finalOptions.output?.format || "console";
282
+ const outputFile = options.outputFile || finalOptions.output?.file;
283
+ if (outputFormat === "json") {
284
+ const outputData = {
285
+ ...report,
286
+ summary: {
287
+ ...report.summary,
288
+ executionTime: parseFloat(elapsedTime)
289
+ }
290
+ };
291
+ (0, import_core.handleJSONOutput)(outputData, outputFile, `\u2705 Results saved to ${outputFile}`);
292
+ } else if (outputFormat === "markdown") {
293
+ const markdown = generateMarkdownReport(report, elapsedTime);
294
+ if (outputFile) {
295
+ (0, import_fs.writeFileSync)(outputFile, markdown);
296
+ console.log(import_chalk.default.green(`\u2705 Report saved to ${outputFile}`));
297
+ } else {
298
+ console.log(markdown);
299
+ }
300
+ } else {
301
+ console.log(`Consistency Analysis Complete (${elapsedTime}s)`);
302
+ console.log(`Files analyzed: ${report.summary.filesAnalyzed}`);
303
+ console.log(`Total issues: ${report.summary.totalIssues}`);
304
+ console.log(` Naming: ${report.summary.namingIssues}`);
305
+ console.log(` Patterns: ${report.summary.patternIssues}`);
306
+ if (report.recommendations.length > 0) {
307
+ console.log(import_chalk.default.bold("\n\u{1F4A1} Recommendations:"));
308
+ report.recommendations.forEach((rec, i) => {
309
+ console.log(`${i + 1}. ${rec}`);
310
+ });
311
+ }
312
+ }
313
+ } catch (error) {
314
+ (0, import_core.handleCLIError)(error, "Consistency analysis");
315
+ }
316
+ });
317
+ function generateMarkdownReport(report, elapsedTime) {
318
+ let markdown = `# Consistency Analysis Report
319
+
320
+ `;
321
+ markdown += `**Generated:** ${(/* @__PURE__ */ new Date()).toISOString()}
322
+ `;
323
+ markdown += `**Analysis Time:** ${elapsedTime}s
324
+
325
+ `;
326
+ markdown += `## Summary
327
+
328
+ `;
329
+ markdown += `- **Files Analyzed:** ${report.summary.filesAnalyzed}
330
+ `;
331
+ markdown += `- **Total Issues:** ${report.summary.totalIssues}
332
+ `;
333
+ markdown += ` - Naming: ${report.summary.namingIssues}
334
+ `;
335
+ markdown += ` - Patterns: ${report.summary.patternIssues}
336
+
337
+ `;
338
+ if (report.recommendations.length > 0) {
339
+ markdown += `## Recommendations
340
+
341
+ `;
342
+ report.recommendations.forEach((rec, i) => {
343
+ markdown += `${i + 1}. ${rec}
344
+ `;
345
+ });
346
+ }
347
+ return markdown;
348
+ }
227
349
  program.parse();
package/dist/cli.mjs CHANGED
@@ -2,23 +2,24 @@
2
2
  import {
3
3
  analyzeUnified,
4
4
  generateUnifiedSummary
5
- } from "./chunk-KZKXZKES.mjs";
5
+ } from "./chunk-VOB7SA3E.mjs";
6
6
 
7
7
  // src/cli.ts
8
8
  import { Command } from "commander";
9
9
  import chalk from "chalk";
10
+ import { writeFileSync } from "fs";
10
11
  import { join } from "path";
11
12
  import { loadMergedConfig, handleJSONOutput, handleCLIError, getElapsedTime } from "@aiready/core";
12
13
  import { readFileSync } from "fs";
13
14
  var packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf8"));
14
15
  var program = new Command();
15
16
  program.name("aiready").description("AIReady - Unified AI-readiness analysis tools").version(packageJson.version).addHelpText("after", "\nCONFIGURATION:\n Supports config files: aiready.json, aiready.config.json, .aiready.json, .aireadyrc.json, aiready.config.js, .aireadyrc.js\n CLI options override config file settings");
16
- program.command("scan").description("Run unified analysis on a codebase").argument("<directory>", "Directory to analyze").option("-t, --tools <tools>", "Tools to run (comma-separated: patterns,context)", "patterns,context").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option("-o, --output <format>", "Output format: console, json", "console").option("--output-file <path>", "Output file path (for json)").action(async (directory, options) => {
17
+ program.command("scan").description("Run unified analysis on a codebase").argument("<directory>", "Directory to analyze").option("-t, --tools <tools>", "Tools to run (comma-separated: patterns,context,consistency)", "patterns,context,consistency").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option("-o, --output <format>", "Output format: console, json", "console").option("--output-file <path>", "Output file path (for json)").action(async (directory, options) => {
17
18
  console.log(chalk.blue("\u{1F680} Starting AIReady unified analysis...\n"));
18
19
  const startTime = Date.now();
19
20
  try {
20
21
  const defaults = {
21
- tools: ["patterns", "context"],
22
+ tools: ["patterns", "context", "consistency"],
22
23
  include: void 0,
23
24
  exclude: void 0,
24
25
  output: {
@@ -124,12 +125,23 @@ program.command("context").description("Run context window cost analysis").argum
124
125
  file: void 0
125
126
  }
126
127
  };
127
- const finalOptions = loadMergedConfig(directory, defaults, {
128
+ let baseOptions = loadMergedConfig(directory, defaults, {
128
129
  maxDepth: options.maxDepth ? parseInt(options.maxDepth) : void 0,
129
130
  maxContextBudget: options.maxContext ? parseInt(options.maxContext) : void 0,
130
131
  include: options.include?.split(","),
131
132
  exclude: options.exclude?.split(",")
132
133
  });
134
+ let finalOptions = { ...baseOptions };
135
+ const { getSmartDefaults } = await import("@aiready/context-analyzer");
136
+ const contextSmartDefaults = await getSmartDefaults(directory, baseOptions);
137
+ finalOptions = { ...contextSmartDefaults, ...finalOptions };
138
+ console.log("\u{1F4CB} Configuration:");
139
+ console.log(` Max depth: ${finalOptions.maxDepth}`);
140
+ console.log(` Max context budget: ${finalOptions.maxContextBudget}`);
141
+ console.log(` Min cohesion: ${(finalOptions.minCohesion * 100).toFixed(1)}%`);
142
+ console.log(` Max fragmentation: ${(finalOptions.maxFragmentation * 100).toFixed(1)}%`);
143
+ console.log(` Analysis focus: ${finalOptions.focus}`);
144
+ console.log("");
133
145
  const { analyzeContext, generateSummary } = await import("@aiready/context-analyzer");
134
146
  const results = await analyzeContext(finalOptions);
135
147
  const elapsedTime = getElapsedTime(startTime);
@@ -153,4 +165,97 @@ program.command("context").description("Run context window cost analysis").argum
153
165
  handleCLIError(error, "Context analysis");
154
166
  }
155
167
  });
168
+ program.command("consistency").description("Check naming, patterns, and architecture consistency").argument("<directory>", "Directory to analyze").option("--naming", "Check naming conventions (default: true)").option("--no-naming", "Skip naming analysis").option("--patterns", "Check code patterns (default: true)").option("--no-patterns", "Skip pattern analysis").option("--min-severity <level>", "Minimum severity: info|minor|major|critical", "info").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option("-o, --output <format>", "Output format: console, json, markdown", "console").option("--output-file <path>", "Output file path (for json/markdown)").action(async (directory, options) => {
169
+ console.log(chalk.blue("\u{1F50D} Analyzing consistency...\n"));
170
+ const startTime = Date.now();
171
+ try {
172
+ const defaults = {
173
+ checkNaming: true,
174
+ checkPatterns: true,
175
+ minSeverity: "info",
176
+ include: void 0,
177
+ exclude: void 0,
178
+ output: {
179
+ format: "console",
180
+ file: void 0
181
+ }
182
+ };
183
+ const finalOptions = loadMergedConfig(directory, defaults, {
184
+ checkNaming: options.naming !== false,
185
+ checkPatterns: options.patterns !== false,
186
+ minSeverity: options.minSeverity,
187
+ include: options.include?.split(","),
188
+ exclude: options.exclude?.split(",")
189
+ });
190
+ const { analyzeConsistency } = await import("@aiready/consistency");
191
+ const report = await analyzeConsistency(finalOptions);
192
+ const elapsedTime = getElapsedTime(startTime);
193
+ const outputFormat = options.output || finalOptions.output?.format || "console";
194
+ const outputFile = options.outputFile || finalOptions.output?.file;
195
+ if (outputFormat === "json") {
196
+ const outputData = {
197
+ ...report,
198
+ summary: {
199
+ ...report.summary,
200
+ executionTime: parseFloat(elapsedTime)
201
+ }
202
+ };
203
+ handleJSONOutput(outputData, outputFile, `\u2705 Results saved to ${outputFile}`);
204
+ } else if (outputFormat === "markdown") {
205
+ const markdown = generateMarkdownReport(report, elapsedTime);
206
+ if (outputFile) {
207
+ writeFileSync(outputFile, markdown);
208
+ console.log(chalk.green(`\u2705 Report saved to ${outputFile}`));
209
+ } else {
210
+ console.log(markdown);
211
+ }
212
+ } else {
213
+ console.log(`Consistency Analysis Complete (${elapsedTime}s)`);
214
+ console.log(`Files analyzed: ${report.summary.filesAnalyzed}`);
215
+ console.log(`Total issues: ${report.summary.totalIssues}`);
216
+ console.log(` Naming: ${report.summary.namingIssues}`);
217
+ console.log(` Patterns: ${report.summary.patternIssues}`);
218
+ if (report.recommendations.length > 0) {
219
+ console.log(chalk.bold("\n\u{1F4A1} Recommendations:"));
220
+ report.recommendations.forEach((rec, i) => {
221
+ console.log(`${i + 1}. ${rec}`);
222
+ });
223
+ }
224
+ }
225
+ } catch (error) {
226
+ handleCLIError(error, "Consistency analysis");
227
+ }
228
+ });
229
+ function generateMarkdownReport(report, elapsedTime) {
230
+ let markdown = `# Consistency Analysis Report
231
+
232
+ `;
233
+ markdown += `**Generated:** ${(/* @__PURE__ */ new Date()).toISOString()}
234
+ `;
235
+ markdown += `**Analysis Time:** ${elapsedTime}s
236
+
237
+ `;
238
+ markdown += `## Summary
239
+
240
+ `;
241
+ markdown += `- **Files Analyzed:** ${report.summary.filesAnalyzed}
242
+ `;
243
+ markdown += `- **Total Issues:** ${report.summary.totalIssues}
244
+ `;
245
+ markdown += ` - Naming: ${report.summary.namingIssues}
246
+ `;
247
+ markdown += ` - Patterns: ${report.summary.patternIssues}
248
+
249
+ `;
250
+ if (report.recommendations.length > 0) {
251
+ markdown += `## Recommendations
252
+
253
+ `;
254
+ report.recommendations.forEach((rec, i) => {
255
+ markdown += `${i + 1}. ${rec}
256
+ `;
257
+ });
258
+ }
259
+ return markdown;
260
+ }
156
261
  program.parse();
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { ScanOptions, AnalysisResult } from '@aiready/core';
2
2
  import { ContextAnalysisResult } from '@aiready/context-analyzer';
3
+ import { ConsistencyReport } from '@aiready/consistency';
3
4
 
4
5
  interface UnifiedAnalysisOptions extends ScanOptions {
5
- tools?: ('patterns' | 'context')[];
6
+ tools?: ('patterns' | 'context' | 'consistency')[];
6
7
  minSimilarity?: number;
7
8
  minLines?: number;
8
9
  maxCandidatesPerBlock?: number;
@@ -12,6 +13,7 @@ interface UnifiedAnalysisOptions extends ScanOptions {
12
13
  interface UnifiedAnalysisResult {
13
14
  patterns?: AnalysisResult[];
14
15
  context?: ContextAnalysisResult[];
16
+ consistency?: ConsistencyReport;
15
17
  summary: {
16
18
  totalIssues: number;
17
19
  toolsRun: string[];
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { ScanOptions, AnalysisResult } from '@aiready/core';
2
2
  import { ContextAnalysisResult } from '@aiready/context-analyzer';
3
+ import { ConsistencyReport } from '@aiready/consistency';
3
4
 
4
5
  interface UnifiedAnalysisOptions extends ScanOptions {
5
- tools?: ('patterns' | 'context')[];
6
+ tools?: ('patterns' | 'context' | 'consistency')[];
6
7
  minSimilarity?: number;
7
8
  minLines?: number;
8
9
  maxCandidatesPerBlock?: number;
@@ -12,6 +13,7 @@ interface UnifiedAnalysisOptions extends ScanOptions {
12
13
  interface UnifiedAnalysisResult {
13
14
  patterns?: AnalysisResult[];
14
15
  context?: ContextAnalysisResult[];
16
+ consistency?: ConsistencyReport;
15
17
  summary: {
16
18
  totalIssues: number;
17
19
  toolsRun: string[];
package/dist/index.js CHANGED
@@ -26,9 +26,10 @@ __export(index_exports, {
26
26
  module.exports = __toCommonJS(index_exports);
27
27
  var import_pattern_detect = require("@aiready/pattern-detect");
28
28
  var import_context_analyzer = require("@aiready/context-analyzer");
29
+ var import_consistency = require("@aiready/consistency");
29
30
  async function analyzeUnified(options) {
30
31
  const startTime = Date.now();
31
- const tools = options.tools || ["patterns", "context"];
32
+ const tools = options.tools || ["patterns", "context", "consistency"];
32
33
  const result = {
33
34
  summary: {
34
35
  totalIssues: 0,
@@ -45,6 +46,18 @@ async function analyzeUnified(options) {
45
46
  result.context = await (0, import_context_analyzer.analyzeContext)(options);
46
47
  result.summary.totalIssues += result.context?.length || 0;
47
48
  }
49
+ if (tools.includes("consistency")) {
50
+ const report = await (0, import_consistency.analyzeConsistency)({
51
+ rootDir: options.rootDir,
52
+ include: options.include,
53
+ exclude: options.exclude,
54
+ checkNaming: true,
55
+ checkPatterns: true,
56
+ minSeverity: "info"
57
+ });
58
+ result.consistency = report;
59
+ result.summary.totalIssues += report.summary.totalIssues;
60
+ }
48
61
  result.summary.executionTime = Date.now() - startTime;
49
62
  return result;
50
63
  }
@@ -68,6 +81,10 @@ function generateUnifiedSummary(result) {
68
81
  }
69
82
  if (result.context?.length) {
70
83
  output += `\u{1F9E0} Context Analysis: ${result.context.length} issues
84
+ `;
85
+ }
86
+ if (result.consistency) {
87
+ output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
71
88
  `;
72
89
  }
73
90
  return output;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  analyzeUnified,
3
3
  generateUnifiedSummary
4
- } from "./chunk-KZKXZKES.mjs";
4
+ } from "./chunk-VOB7SA3E.mjs";
5
5
  export {
6
6
  analyzeUnified,
7
7
  generateUnifiedSummary
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/cli",
3
- "version": "0.3.7",
3
+ "version": "0.4.0",
4
4
  "description": "Unified CLI for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -11,9 +11,10 @@
11
11
  "dependencies": {
12
12
  "commander": "^12.1.0",
13
13
  "chalk": "^5.3.0",
14
- "@aiready/core": "0.3.6",
15
- "@aiready/context-analyzer": "0.3.7",
16
- "@aiready/pattern-detect": "0.7.11"
14
+ "@aiready/pattern-detect": "0.8.0",
15
+ "@aiready/context-analyzer": "0.4.0",
16
+ "@aiready/consistency": "0.2.0",
17
+ "@aiready/core": "0.5.0"
17
18
  },
18
19
  "devDependencies": {
19
20
  "tsup": "^8.3.5",
package/src/cli.ts CHANGED
@@ -22,7 +22,7 @@ program
22
22
  .command('scan')
23
23
  .description('Run unified analysis on a codebase')
24
24
  .argument('<directory>', 'Directory to analyze')
25
- .option('-t, --tools <tools>', 'Tools to run (comma-separated: patterns,context)', 'patterns,context')
25
+ .option('-t, --tools <tools>', 'Tools to run (comma-separated: patterns,context,consistency)', 'patterns,context,consistency')
26
26
  .option('--include <patterns>', 'File patterns to include (comma-separated)')
27
27
  .option('--exclude <patterns>', 'File patterns to exclude (comma-separated)')
28
28
  .option('-o, --output <format>', 'Output format: console, json', 'console')
@@ -35,7 +35,7 @@ program
35
35
  try {
36
36
  // Define defaults
37
37
  const defaults = {
38
- tools: ['patterns', 'context'],
38
+ tools: ['patterns', 'context', 'consistency'],
39
39
  include: undefined,
40
40
  exclude: undefined,
41
41
  output: {
@@ -46,7 +46,7 @@ program
46
46
 
47
47
  // Load and merge config with CLI options
48
48
  const baseOptions = loadMergedConfig(directory, defaults, {
49
- tools: options.tools ? options.tools.split(',').map((t: string) => t.trim()) as ('patterns' | 'context')[] : undefined,
49
+ tools: options.tools ? options.tools.split(',').map((t: string) => t.trim()) as ('patterns' | 'context' | 'consistency')[] : undefined,
50
50
  include: options.include?.split(','),
51
51
  exclude: options.exclude?.split(','),
52
52
  }) as any;
@@ -200,13 +200,28 @@ program
200
200
  };
201
201
 
202
202
  // Load and merge config with CLI options
203
- const finalOptions = loadMergedConfig(directory, defaults, {
203
+ let baseOptions = loadMergedConfig(directory, defaults, {
204
204
  maxDepth: options.maxDepth ? parseInt(options.maxDepth) : undefined,
205
205
  maxContextBudget: options.maxContext ? parseInt(options.maxContext) : undefined,
206
206
  include: options.include?.split(','),
207
207
  exclude: options.exclude?.split(','),
208
208
  });
209
209
 
210
+ // Apply smart defaults for context analysis (always for individual context command)
211
+ let finalOptions: any = { ...baseOptions };
212
+ const { getSmartDefaults } = await import('@aiready/context-analyzer');
213
+ const contextSmartDefaults = await getSmartDefaults(directory, baseOptions);
214
+ finalOptions = { ...contextSmartDefaults, ...finalOptions };
215
+
216
+ // Display configuration
217
+ console.log('📋 Configuration:');
218
+ console.log(` Max depth: ${finalOptions.maxDepth}`);
219
+ console.log(` Max context budget: ${finalOptions.maxContextBudget}`);
220
+ console.log(` Min cohesion: ${(finalOptions.minCohesion * 100).toFixed(1)}%`);
221
+ console.log(` Max fragmentation: ${(finalOptions.maxFragmentation * 100).toFixed(1)}%`);
222
+ console.log(` Analysis focus: ${finalOptions.focus}`);
223
+ console.log('');
224
+
210
225
  const { analyzeContext, generateSummary } = await import('@aiready/context-analyzer');
211
226
 
212
227
  const results = await analyzeContext(finalOptions);
@@ -236,4 +251,113 @@ program
236
251
  }
237
252
  });
238
253
 
254
+ program
255
+ .command('consistency')
256
+ .description('Check naming, patterns, and architecture consistency')
257
+ .argument('<directory>', 'Directory to analyze')
258
+ .option('--naming', 'Check naming conventions (default: true)')
259
+ .option('--no-naming', 'Skip naming analysis')
260
+ .option('--patterns', 'Check code patterns (default: true)')
261
+ .option('--no-patterns', 'Skip pattern analysis')
262
+ .option('--min-severity <level>', 'Minimum severity: info|minor|major|critical', 'info')
263
+ .option('--include <patterns>', 'File patterns to include (comma-separated)')
264
+ .option('--exclude <patterns>', 'File patterns to exclude (comma-separated)')
265
+ .option('-o, --output <format>', 'Output format: console, json, markdown', 'console')
266
+ .option('--output-file <path>', 'Output file path (for json/markdown)')
267
+ .action(async (directory, options) => {
268
+ console.log(chalk.blue('🔍 Analyzing consistency...\n'));
269
+
270
+ const startTime = Date.now();
271
+
272
+ try {
273
+ // Define defaults
274
+ const defaults = {
275
+ checkNaming: true,
276
+ checkPatterns: true,
277
+ minSeverity: 'info' as const,
278
+ include: undefined,
279
+ exclude: undefined,
280
+ output: {
281
+ format: 'console',
282
+ file: undefined,
283
+ },
284
+ };
285
+
286
+ // Load and merge config with CLI options
287
+ const finalOptions = loadMergedConfig(directory, defaults, {
288
+ checkNaming: options.naming !== false,
289
+ checkPatterns: options.patterns !== false,
290
+ minSeverity: options.minSeverity,
291
+ include: options.include?.split(','),
292
+ exclude: options.exclude?.split(','),
293
+ });
294
+
295
+ const { analyzeConsistency } = await import('@aiready/consistency');
296
+
297
+ const report = await analyzeConsistency(finalOptions);
298
+
299
+ const elapsedTime = getElapsedTime(startTime);
300
+
301
+ const outputFormat = options.output || finalOptions.output?.format || 'console';
302
+ const outputFile = options.outputFile || finalOptions.output?.file;
303
+
304
+ if (outputFormat === 'json') {
305
+ const outputData = {
306
+ ...report,
307
+ summary: {
308
+ ...report.summary,
309
+ executionTime: parseFloat(elapsedTime),
310
+ },
311
+ };
312
+
313
+ handleJSONOutput(outputData, outputFile, `✅ Results saved to ${outputFile}`);
314
+ } else if (outputFormat === 'markdown') {
315
+ // Markdown output
316
+ const markdown = generateMarkdownReport(report, elapsedTime);
317
+ if (outputFile) {
318
+ writeFileSync(outputFile, markdown);
319
+ console.log(chalk.green(`✅ Report saved to ${outputFile}`));
320
+ } else {
321
+ console.log(markdown);
322
+ }
323
+ } else {
324
+ console.log(`Consistency Analysis Complete (${elapsedTime}s)`);
325
+ console.log(`Files analyzed: ${report.summary.filesAnalyzed}`);
326
+ console.log(`Total issues: ${report.summary.totalIssues}`);
327
+ console.log(` Naming: ${report.summary.namingIssues}`);
328
+ console.log(` Patterns: ${report.summary.patternIssues}`);
329
+
330
+ if (report.recommendations.length > 0) {
331
+ console.log(chalk.bold('\n💡 Recommendations:'));
332
+ report.recommendations.forEach((rec, i) => {
333
+ console.log(`${i + 1}. ${rec}`);
334
+ });
335
+ }
336
+ }
337
+ } catch (error) {
338
+ handleCLIError(error, 'Consistency analysis');
339
+ }
340
+ });
341
+
342
+ function generateMarkdownReport(report: any, elapsedTime: string): string {
343
+ let markdown = `# Consistency Analysis Report\n\n`;
344
+ markdown += `**Generated:** ${new Date().toISOString()}\n`;
345
+ markdown += `**Analysis Time:** ${elapsedTime}s\n\n`;
346
+
347
+ markdown += `## Summary\n\n`;
348
+ markdown += `- **Files Analyzed:** ${report.summary.filesAnalyzed}\n`;
349
+ markdown += `- **Total Issues:** ${report.summary.totalIssues}\n`;
350
+ markdown += ` - Naming: ${report.summary.namingIssues}\n`;
351
+ markdown += ` - Patterns: ${report.summary.patternIssues}\n\n`;
352
+
353
+ if (report.recommendations.length > 0) {
354
+ markdown += `## Recommendations\n\n`;
355
+ report.recommendations.forEach((rec: string, i: number) => {
356
+ markdown += `${i + 1}. ${rec}\n`;
357
+ });
358
+ }
359
+
360
+ return markdown;
361
+ }
362
+
239
363
  program.parse();
package/src/index.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { analyzePatterns } from '@aiready/pattern-detect';
2
2
  import { analyzeContext } from '@aiready/context-analyzer';
3
+ import { analyzeConsistency } from '@aiready/consistency';
3
4
  import type { AnalysisResult, ScanOptions } from '@aiready/core';
4
5
  import type { ContextAnalysisResult } from '@aiready/context-analyzer';
5
6
  import type { PatternDetectOptions } from '@aiready/pattern-detect';
7
+ import type { ConsistencyReport } from '@aiready/consistency';
6
8
 
7
9
  export interface UnifiedAnalysisOptions extends ScanOptions {
8
- tools?: ('patterns' | 'context')[];
10
+ tools?: ('patterns' | 'context' | 'consistency')[];
9
11
  minSimilarity?: number;
10
12
  minLines?: number;
11
13
  maxCandidatesPerBlock?: number;
@@ -16,6 +18,7 @@ export interface UnifiedAnalysisOptions extends ScanOptions {
16
18
  export interface UnifiedAnalysisResult {
17
19
  patterns?: AnalysisResult[];
18
20
  context?: ContextAnalysisResult[];
21
+ consistency?: ConsistencyReport;
19
22
  summary: {
20
23
  totalIssues: number;
21
24
  toolsRun: string[];
@@ -27,7 +30,7 @@ export async function analyzeUnified(
27
30
  options: UnifiedAnalysisOptions
28
31
  ): Promise<UnifiedAnalysisResult> {
29
32
  const startTime = Date.now();
30
- const tools = options.tools || ['patterns', 'context'];
33
+ const tools = options.tools || ['patterns', 'context', 'consistency'];
31
34
  const result: UnifiedAnalysisResult = {
32
35
  summary: {
33
36
  totalIssues: 0,
@@ -49,6 +52,20 @@ export async function analyzeUnified(
49
52
  result.summary.totalIssues += result.context?.length || 0;
50
53
  }
51
54
 
55
+ // Run consistency analysis
56
+ if (tools.includes('consistency')) {
57
+ const report = await analyzeConsistency({
58
+ rootDir: options.rootDir,
59
+ include: options.include,
60
+ exclude: options.exclude,
61
+ checkNaming: true,
62
+ checkPatterns: true,
63
+ minSeverity: 'info',
64
+ });
65
+ result.consistency = report;
66
+ result.summary.totalIssues += report.summary.totalIssues;
67
+ }
68
+
52
69
  result.summary.executionTime = Date.now() - startTime;
53
70
  return result;
54
71
  }
@@ -69,5 +86,9 @@ export function generateUnifiedSummary(result: UnifiedAnalysisResult): string {
69
86
  output += `🧠 Context Analysis: ${result.context.length} issues\n`;
70
87
  }
71
88
 
89
+ if (result.consistency) {
90
+ output += `🏷️ Consistency Analysis: ${result.consistency.summary.totalIssues} issues\n`;
91
+ }
92
+
72
93
  return output;
73
94
  }