@aiready/cli 0.9.40 → 0.9.41

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,237 @@
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 { analyzePatterns } from "@aiready/pattern-detect";
10
+ import { analyzeContext } from "@aiready/context-analyzer";
11
+ import { analyzeConsistency } from "@aiready/consistency";
12
+ var severityOrder = {
13
+ critical: 4,
14
+ major: 3,
15
+ minor: 2,
16
+ info: 1
17
+ };
18
+ function sortBySeverity(results) {
19
+ return results.map((file) => {
20
+ const sortedIssues = [...file.issues].sort((a, b) => {
21
+ const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
22
+ if (severityDiff !== 0) return severityDiff;
23
+ return (a.location?.line || 0) - (b.location?.line || 0);
24
+ });
25
+ return { ...file, issues: sortedIssues };
26
+ }).sort((a, b) => {
27
+ const aMaxSeverity = Math.max(
28
+ ...a.issues.map((i) => severityOrder[i.severity] || 0),
29
+ 0
30
+ );
31
+ const bMaxSeverity = Math.max(
32
+ ...b.issues.map((i) => severityOrder[i.severity] || 0),
33
+ 0
34
+ );
35
+ if (aMaxSeverity !== bMaxSeverity) {
36
+ return bMaxSeverity - aMaxSeverity;
37
+ }
38
+ if (a.issues.length !== b.issues.length) {
39
+ return b.issues.length - a.issues.length;
40
+ }
41
+ return a.fileName.localeCompare(b.fileName);
42
+ });
43
+ }
44
+ async function analyzeUnified(options) {
45
+ const startTime = Date.now();
46
+ const tools = options.tools || ["patterns", "context", "consistency"];
47
+ const result = {
48
+ summary: {
49
+ totalIssues: 0,
50
+ toolsRun: tools,
51
+ executionTime: 0
52
+ }
53
+ };
54
+ if (tools.includes("patterns")) {
55
+ const patternResult = await analyzePatterns(options);
56
+ if (options.progressCallback) {
57
+ options.progressCallback({ tool: "patterns", data: patternResult });
58
+ }
59
+ result.patterns = sortBySeverity(patternResult.results);
60
+ result.duplicates = patternResult.duplicates;
61
+ result.summary.totalIssues += patternResult.results.reduce(
62
+ (sum, file) => sum + file.issues.length,
63
+ 0
64
+ );
65
+ }
66
+ if (tools.includes("context")) {
67
+ const contextResults = await analyzeContext(options);
68
+ if (options.progressCallback) {
69
+ options.progressCallback({ tool: "context", data: contextResults });
70
+ }
71
+ result.context = contextResults.sort((a, b) => {
72
+ const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
73
+ if (severityDiff !== 0) return severityDiff;
74
+ if (a.tokenCost !== b.tokenCost) return b.tokenCost - a.tokenCost;
75
+ return b.fragmentationScore - a.fragmentationScore;
76
+ });
77
+ result.summary.totalIssues += result.context?.length || 0;
78
+ }
79
+ if (tools.includes("consistency")) {
80
+ const consistencyOptions = {
81
+ rootDir: options.rootDir,
82
+ include: options.include,
83
+ exclude: options.exclude,
84
+ ...options.consistency || {}
85
+ };
86
+ const report = await analyzeConsistency(consistencyOptions);
87
+ if (options.progressCallback) {
88
+ options.progressCallback({ tool: "consistency", data: report });
89
+ }
90
+ if (report.results) {
91
+ report.results = sortBySeverity(report.results);
92
+ }
93
+ result.consistency = report;
94
+ result.summary.totalIssues += report.summary.totalIssues;
95
+ }
96
+ if (tools.includes("doc-drift")) {
97
+ const { analyzeDocDrift } = await import("@aiready/doc-drift");
98
+ const report = await analyzeDocDrift({
99
+ rootDir: options.rootDir,
100
+ include: options.include,
101
+ exclude: options.exclude
102
+ });
103
+ if (options.progressCallback) {
104
+ options.progressCallback({ tool: "doc-drift", data: report });
105
+ }
106
+ result.docDrift = report;
107
+ result.summary.totalIssues += report.issues?.length || 0;
108
+ }
109
+ if (tools.includes("deps-health")) {
110
+ const { analyzeDeps } = await import("@aiready/deps");
111
+ const report = await analyzeDeps({
112
+ rootDir: options.rootDir,
113
+ include: options.include,
114
+ exclude: options.exclude
115
+ });
116
+ if (options.progressCallback) {
117
+ options.progressCallback({ tool: "deps-health", data: report });
118
+ }
119
+ result.deps = report;
120
+ result.summary.totalIssues += report.issues?.length || 0;
121
+ }
122
+ if (tools.includes("aiSignalClarity")) {
123
+ const { analyzeAiSignalClarity } = await import("@aiready/ai-signal-clarity");
124
+ const report = await analyzeAiSignalClarity({
125
+ rootDir: options.rootDir,
126
+ include: options.include,
127
+ exclude: options.exclude
128
+ });
129
+ if (options.progressCallback) {
130
+ options.progressCallback({ tool: "aiSignalClarity", data: report });
131
+ }
132
+ result.aiSignalClarity = report;
133
+ result.summary.totalIssues += report.results?.reduce(
134
+ (sum, r) => sum + (r.issues?.length || 0),
135
+ 0
136
+ ) || 0;
137
+ }
138
+ if (tools.includes("grounding")) {
139
+ const { analyzeAgentGrounding } = await import("@aiready/agent-grounding");
140
+ const report = await analyzeAgentGrounding({
141
+ rootDir: options.rootDir,
142
+ include: options.include,
143
+ exclude: options.exclude
144
+ });
145
+ if (options.progressCallback) {
146
+ options.progressCallback({ tool: "grounding", data: report });
147
+ }
148
+ result.grounding = report;
149
+ result.summary.totalIssues += report.issues?.length || 0;
150
+ }
151
+ if (tools.includes("testability")) {
152
+ const { analyzeTestability } = await import("@aiready/testability");
153
+ const report = await analyzeTestability({
154
+ rootDir: options.rootDir,
155
+ include: options.include,
156
+ exclude: options.exclude
157
+ });
158
+ if (options.progressCallback) {
159
+ options.progressCallback({ tool: "testability", data: report });
160
+ }
161
+ result.testability = report;
162
+ result.summary.totalIssues += report.issues?.length || 0;
163
+ }
164
+ if (tools.includes("changeAmplification")) {
165
+ const { analyzeChangeAmplification } = await import("@aiready/change-amplification");
166
+ const report = await analyzeChangeAmplification({
167
+ rootDir: options.rootDir,
168
+ include: options.include,
169
+ exclude: options.exclude
170
+ });
171
+ if (options.progressCallback) {
172
+ options.progressCallback({ tool: "changeAmplification", data: report });
173
+ }
174
+ result.changeAmplification = report;
175
+ result.summary.totalIssues += report.summary?.totalIssues || 0;
176
+ }
177
+ result.summary.executionTime = Date.now() - startTime;
178
+ return result;
179
+ }
180
+ function generateUnifiedSummary(result) {
181
+ const { summary } = result;
182
+ let output = `\u{1F680} AIReady Analysis Complete
183
+
184
+ `;
185
+ output += `\u{1F4CA} Summary:
186
+ `;
187
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
188
+ `;
189
+ output += ` Total issues found: ${summary.totalIssues}
190
+ `;
191
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
192
+
193
+ `;
194
+ if (result.patterns) {
195
+ output += `\u{1F50D} Pattern Analysis: ${result.patterns.length} issues
196
+ `;
197
+ }
198
+ if (result.context) {
199
+ output += `\u{1F9E0} Context Analysis: ${result.context.length} issues
200
+ `;
201
+ }
202
+ if (result.consistency) {
203
+ output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
204
+ `;
205
+ }
206
+ if (result.docDrift) {
207
+ output += `\u{1F4DD} Doc Drift Analysis: ${result.docDrift.issues?.length || 0} issues
208
+ `;
209
+ }
210
+ if (result.deps) {
211
+ output += `\u{1F4E6} Dependency Health: ${result.deps.issues?.length || 0} issues
212
+ `;
213
+ }
214
+ if (result.aiSignalClarity) {
215
+ output += `\u{1F9E0} AI Signal Clarity: ${result.aiSignalClarity.summary?.totalSignals || 0} signals
216
+ `;
217
+ }
218
+ if (result.grounding) {
219
+ output += `\u{1F9ED} Agent Grounding: ${result.grounding.issues?.length || 0} issues
220
+ `;
221
+ }
222
+ if (result.testability) {
223
+ output += `\u{1F9EA} Testability Index: ${result.testability.issues?.length || 0} issues
224
+ `;
225
+ }
226
+ if (result.changeAmplification) {
227
+ output += `\u{1F4A5} Change Amplification: ${result.changeAmplification.summary?.totalIssues || 0} cascading risks
228
+ `;
229
+ }
230
+ return output;
231
+ }
232
+
233
+ export {
234
+ __require,
235
+ analyzeUnified,
236
+ generateUnifiedSummary
237
+ };