Skip to content

Commit 72ab91a

Browse files
committed
style: apply Prettier formatting to all TypeScript files
- Fixed formatting issues in 36 files - All files now pass prettier --check - Maintains 0 ESLint errors and 0 warnings - Build successful
1 parent 54ed2d1 commit 72ab91a

36 files changed

+10140
-4085
lines changed

src/commands/agent-inspect.ts

Lines changed: 502 additions & 182 deletions
Large diffs are not rendered by default.

src/commands/analytics.ts

Lines changed: 177 additions & 72 deletions
Large diffs are not rendered by default.

src/commands/analyze.ts

Lines changed: 155 additions & 71 deletions
Large diffs are not rendered by default.

src/commands/audit-firewall.ts

Lines changed: 465 additions & 189 deletions
Large diffs are not rendered by default.

src/commands/budget.ts

Lines changed: 86 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,29 @@ async function getBudgetStatus(options: any) {
4040

4141
if (!baseUrl || !apiKey) {
4242
console.log(chalk.red.bold('\n❌ Configuration Missing'));
43-
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
44-
43+
console.log(
44+
chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
45+
);
46+
4547
if (!apiKey) {
4648
console.log(chalk.yellow('• API Key is not set'));
4749
}
4850
if (!baseUrl) {
4951
console.log(chalk.yellow('• Base URL is not set'));
5052
}
51-
52-
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
53+
54+
console.log(
55+
chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
56+
);
5357
console.log(chalk.cyan('To set up your configuration, run:'));
5458
console.log(chalk.white(' cost-katana init'));
55-
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
56-
57-
throw new Error('Configuration incomplete. Please run "cost-katana init" to set up your API key and base URL.');
59+
console.log(
60+
chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n')
61+
);
62+
63+
throw new Error(
64+
'Configuration incomplete. Please run "cost-katana init" to set up your API key and base URL.'
65+
);
5866
}
5967

6068
try {
@@ -65,7 +73,7 @@ async function getBudgetStatus(options: any) {
6573

6674
const response = await axios.get(`${baseUrl}/api/budget/status?${params}`, {
6775
headers: {
68-
'Authorization': `Bearer ${apiKey}`,
76+
Authorization: `Bearer ${apiKey}`,
6977
'Content-Type': 'application/json',
7078
},
7179
timeout: 30000,
@@ -82,7 +90,9 @@ async function getBudgetStatus(options: any) {
8290
}
8391
} catch (error: any) {
8492
if (error.response) {
85-
throw new Error(`API Error: ${error.response.status} - ${error.response.data?.message || 'Unknown error'}`);
93+
throw new Error(
94+
`API Error: ${error.response.status} - ${error.response.data?.message || 'Unknown error'}`
95+
);
8696
} else if (error.request) {
8797
throw new Error('No response received from API');
8898
} else {
@@ -93,7 +103,7 @@ async function getBudgetStatus(options: any) {
93103

94104
function displayBudgetStatus(budgetData: any, options: any) {
95105
const format = options.format || 'table';
96-
106+
97107
if (format === 'json') {
98108
displayBudgetJson(budgetData);
99109
return;
@@ -103,7 +113,9 @@ function displayBudgetStatus(budgetData: any, options: any) {
103113
}
104114

105115
console.log(chalk.cyan.bold('\n💸 Budget Status'));
106-
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
116+
console.log(
117+
chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
118+
);
107119

108120
// Overall Budget Status
109121
if (budgetData.overall) {
@@ -114,7 +126,7 @@ function displayBudgetStatus(budgetData: any, options: any) {
114126
if (budgetData.projects && budgetData.projects.length > 0) {
115127
console.log(chalk.yellow.bold('\n📊 Project Budgets'));
116128
console.log(chalk.gray('─'.repeat(50)));
117-
129+
118130
budgetData.projects.forEach((project: any, index: number) => {
119131
displayProjectBudget(project, index + 1);
120132
});
@@ -124,7 +136,7 @@ function displayBudgetStatus(budgetData: any, options: any) {
124136
if (budgetData.alerts && budgetData.alerts.length > 0) {
125137
console.log(chalk.yellow.bold('\n🚨 Budget Alerts'));
126138
console.log(chalk.gray('─'.repeat(50)));
127-
139+
128140
budgetData.alerts.forEach((alert: any, index: number) => {
129141
displayBudgetAlert(alert, index + 1);
130142
});
@@ -134,7 +146,7 @@ function displayBudgetStatus(budgetData: any, options: any) {
134146
if (budgetData.recommendations && budgetData.recommendations.length > 0) {
135147
console.log(chalk.yellow.bold('\n💡 Budget Recommendations'));
136148
console.log(chalk.gray('─'.repeat(50)));
137-
149+
138150
budgetData.recommendations.forEach((rec: any, index: number) => {
139151
displayBudgetRecommendation(rec, index + 1);
140152
});
@@ -145,7 +157,9 @@ function displayBudgetStatus(budgetData: any, options: any) {
145157
exportBudgetData(budgetData, options.export);
146158
}
147159

148-
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
160+
console.log(
161+
chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
162+
);
149163
}
150164

151165
function displayOverallBudget(overall: any) {
@@ -158,7 +172,7 @@ function displayOverallBudget(overall: any) {
158172
// Determine status color and icon
159173
let statusIcon = '🟢';
160174
let statusColor = chalk.green;
161-
175+
162176
if (usagePercentage >= 90) {
163177
statusIcon = '🔴';
164178
statusColor = chalk.red;
@@ -172,15 +186,21 @@ function displayOverallBudget(overall: any) {
172186

173187
console.log(chalk.yellow.bold('\n📈 Overall Budget Status'));
174188
console.log(chalk.gray('─'.repeat(50)));
175-
176-
console.log(`${statusIcon} ${statusColor(`You've used ${usagePercentage.toFixed(1)}% of your ${budget.toLocaleString()} token budget this month.`)}`);
189+
190+
console.log(
191+
`${statusIcon} ${statusColor(`You've used ${usagePercentage.toFixed(1)}% of your ${budget.toLocaleString()} token budget this month.`)}`
192+
);
177193
console.log(chalk.white(`📊 Tokens Used: ${used.toLocaleString()}`));
178194
console.log(chalk.white(`💰 Cost: $${cost.toFixed(2)}`));
179-
console.log(chalk.white(`📉 Remaining: ${remaining.toLocaleString()} tokens`));
180-
195+
console.log(
196+
chalk.white(`📉 Remaining: ${remaining.toLocaleString()} tokens`)
197+
);
198+
181199
// Progress bar
182200
const progressBar = generateProgressBar(usagePercentage);
183-
console.log(chalk.gray(`Progress: ${progressBar} ${usagePercentage.toFixed(1)}%`));
201+
console.log(
202+
chalk.gray(`Progress: ${progressBar} ${usagePercentage.toFixed(1)}%`)
203+
);
184204
}
185205

186206
function displayProjectBudget(project: any, index: number) {
@@ -200,8 +220,12 @@ function displayProjectBudget(project: any, index: number) {
200220
}
201221

202222
console.log(chalk.white(`${index}. ${name}`));
203-
console.log(chalk.gray(` Usage: ${statusColor(`${usagePercentage.toFixed(1)}%`)} | Tokens: ${used.toLocaleString()} | Cost: $${cost.toFixed(2)}`));
204-
223+
console.log(
224+
chalk.gray(
225+
` Usage: ${statusColor(`${usagePercentage.toFixed(1)}%`)} | Tokens: ${used.toLocaleString()} | Cost: $${cost.toFixed(2)}`
226+
)
227+
);
228+
205229
// Progress bar for project
206230
const progressBar = generateProgressBar(usagePercentage);
207231
console.log(chalk.gray(` ${progressBar} ${usagePercentage.toFixed(1)}%`));
@@ -216,7 +240,7 @@ function displayBudgetAlert(alert: any, index: number) {
216240

217241
let severityColor = chalk.yellow;
218242
let severityIcon = '⚠️';
219-
243+
220244
if (severity === 'high') {
221245
severityColor = chalk.red;
222246
severityIcon = '🚨';
@@ -225,7 +249,11 @@ function displayBudgetAlert(alert: any, index: number) {
225249
severityIcon = 'ℹ️';
226250
}
227251

228-
console.log(chalk.white(`${index}. ${severityIcon} ${severityColor(type.toUpperCase())}`));
252+
console.log(
253+
chalk.white(
254+
`${index}. ${severityIcon} ${severityColor(type.toUpperCase())}`
255+
)
256+
);
229257
console.log(chalk.gray(` ${message}`));
230258
if (timestamp) {
231259
console.log(chalk.gray(` Time: ${timestamp}`));
@@ -241,7 +269,7 @@ function displayBudgetRecommendation(rec: any, index: number) {
241269

242270
let impactColor = chalk.yellow;
243271
let impactIcon = '💡';
244-
272+
245273
if (impact === 'high') {
246274
impactColor = chalk.green;
247275
impactIcon = '💰';
@@ -250,7 +278,9 @@ function displayBudgetRecommendation(rec: any, index: number) {
250278
impactIcon = '💭';
251279
}
252280

253-
console.log(chalk.white(`${index}. ${impactIcon} ${impactColor(type.toUpperCase())}`));
281+
console.log(
282+
chalk.white(`${index}. ${impactIcon} ${impactColor(type.toUpperCase())}`)
283+
);
254284
console.log(chalk.gray(` ${message}`));
255285
if (savings > 0) {
256286
console.log(chalk.green(` Estimated Savings: $${savings.toFixed(2)}`));
@@ -263,10 +293,10 @@ function generateProgressBar(percentage: number): string {
263293
const clampedPercentage = Math.min(100, Math.max(0, percentage));
264294
const filled = Math.round((clampedPercentage / 100) * width);
265295
const empty = width - filled;
266-
296+
267297
const filledBar = '█'.repeat(filled);
268298
const emptyBar = '░'.repeat(empty);
269-
299+
270300
return filledBar + emptyBar;
271301
}
272302

@@ -276,23 +306,37 @@ function displayBudgetJson(budgetData: any) {
276306

277307
function displayBudgetCsv(budgetData: any) {
278308
console.log('Project,Usage %,Budget,Used,Cost,Remaining,Status');
279-
309+
280310
if (budgetData.overall) {
281311
const overall = budgetData.overall;
282-
const status = overall.usagePercentage >= 90 ? 'CRITICAL' :
283-
overall.usagePercentage >= 75 ? 'WARNING' :
284-
overall.usagePercentage >= 50 ? 'NOTICE' : 'GOOD';
285-
286-
console.log(`Overall,${overall.usagePercentage?.toFixed(1) || 0},${overall.budget || 0},${overall.used || 0},${overall.cost || 0},${overall.remaining || 0},"${status}"`);
312+
const status =
313+
overall.usagePercentage >= 90
314+
? 'CRITICAL'
315+
: overall.usagePercentage >= 75
316+
? 'WARNING'
317+
: overall.usagePercentage >= 50
318+
? 'NOTICE'
319+
: 'GOOD';
320+
321+
console.log(
322+
`Overall,${overall.usagePercentage?.toFixed(1) || 0},${overall.budget || 0},${overall.used || 0},${overall.cost || 0},${overall.remaining || 0},"${status}"`
323+
);
287324
}
288-
325+
289326
if (budgetData.projects) {
290327
budgetData.projects.forEach((project: any) => {
291-
const status = project.usagePercentage >= 90 ? 'CRITICAL' :
292-
project.usagePercentage >= 75 ? 'WARNING' :
293-
project.usagePercentage >= 50 ? 'NOTICE' : 'GOOD';
294-
295-
console.log(`"${project.name || 'Unknown'}",${project.usagePercentage?.toFixed(1) || 0},${project.budget || 0},${project.used || 0},${project.cost || 0},${project.remaining || 0},"${status}"`);
328+
const status =
329+
project.usagePercentage >= 90
330+
? 'CRITICAL'
331+
: project.usagePercentage >= 75
332+
? 'WARNING'
333+
: project.usagePercentage >= 50
334+
? 'NOTICE'
335+
: 'GOOD';
336+
337+
console.log(
338+
`"${project.name || 'Unknown'}",${project.usagePercentage?.toFixed(1) || 0},${project.budget || 0},${project.used || 0},${project.cost || 0},${project.remaining || 0},"${status}"`
339+
);
296340
});
297341
}
298342
}
@@ -302,7 +346,7 @@ function exportBudgetData(budgetData: any, filePath: string) {
302346
const fullPath = require('path').resolve(filePath);
303347
const fs = require('fs');
304348
const content = JSON.stringify(budgetData, null, 2);
305-
349+
306350
// Ensure directory exists
307351
const dir = require('path').dirname(fullPath);
308352
if (!fs.existsSync(dir)) {

0 commit comments

Comments
 (0)