Skip to content

Commit 7c55895

Browse files
committed
refactor(claude): split logger.log(colors...) into separate lines
- Break combined logger.log(colors.foo('bar')) into: - logger.log('') - logger.log(colors.foo('bar')) - Improves readability and follows logger pattern - Removes \n prefixes from colored messages
1 parent c375171 commit 7c55895

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

scripts/claude.mjs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ class CostTracker {
252252

253253
showSessionSummary() {
254254
const duration = Date.now() - this.startTime
255-
logger.log(colors.cyan('\n💰 Cost Summary:'))
255+
logger.log('')
256+
logger.log(colors.cyan('💰 Cost Summary:'))
256257
logger.log(` Input tokens: ${this.session.input.toLocaleString()}`)
257258
logger.log(` Output tokens: ${this.session.output.toLocaleString()}`)
258259
if (this.session.cacheWrite > 0) {
@@ -398,7 +399,8 @@ class ProgressTracker {
398399
const totalElapsed = Date.now() - this.startTime
399400
const eta = this.getTotalETA()
400401

401-
logger.log(colors.cyan('\n⏱️ Progress:'))
402+
logger.log('')
403+
logger.log(colors.cyan('⏱️ Progress:'))
402404
logger.log(` Elapsed: ${formatDuration(totalElapsed)}`)
403405
if (eta) {
404406
logger.log(` ETA: ${formatDuration(eta)}`)
@@ -415,6 +417,7 @@ class ProgressTracker {
415417

416418
// Show completed phases.
417419
if (this.phases.length > 0) {
420+
logger.log('')
418421
logger.log(colors.gray(' Completed:'))
419422
this.phases.forEach(p => {
420423
logger.log(
@@ -491,7 +494,8 @@ class SnapshotManager {
491494
}
492495

493496
listSnapshots() {
494-
logger.log(colors.cyan('\n📸 Available Snapshots:'))
497+
logger.log('')
498+
logger.log(colors.cyan('📸 Available Snapshots:'))
495499
this.snapshots.forEach((snap, i) => {
496500
const age = formatDuration(Date.now() - snap.timestamp)
497501
logger.log(
@@ -621,7 +625,8 @@ async function celebrateSuccess(costTracker, stats = {}) {
621625

622626
// Show fix details if available.
623627
if (stats.fixCount > 0) {
624-
logger.log(colors.cyan('\n📊 Session Stats:'))
628+
logger.log('')
629+
logger.log(colors.cyan('📊 Session Stats:'))
625630
logger.log(` Fixes applied: ${stats.fixCount}`)
626631
logger.log(` Retries: ${stats.retries || 0}`)
627632
}
@@ -649,7 +654,8 @@ async function celebrateSuccess(costTracker, stats = {}) {
649654

650655
await fs.writeFile(streakPath, JSON.stringify(streak, null, 2))
651656

652-
logger.log(colors.cyan('\n🔥 Success Streak:'))
657+
logger.log('')
658+
logger.log(colors.cyan('🔥 Success Streak:'))
653659
logger.log(` Current: ${streak.current}`)
654660
logger.log(` Best: ${streak.best}`)
655661
} catch {
@@ -854,7 +860,8 @@ function displayAnalysis(analysis) {
854860
return
855861
}
856862

857-
logger.log(colors.cyan('\n🔍 Root Cause Analysis:'))
863+
logger.log('')
864+
logger.log(colors.cyan('🔍 Root Cause Analysis:'))
858865
logger.log(
859866
` Cause: ${analysis.rootCause} ${colors.gray(`(${analysis.confidence}% confident)`)}`,
860867
)
@@ -867,6 +874,7 @@ function displayAnalysis(analysis) {
867874
),
868875
)
869876
if (analysis.environmentalFactors.length > 0) {
877+
logger.log('')
870878
logger.log(colors.yellow(' Factors to check:'))
871879
analysis.environmentalFactors.forEach(factor => {
872880
logger.log(colors.yellow(` - ${factor}`))
@@ -888,7 +896,9 @@ function displayAnalysis(analysis) {
888896
}
889897

890898
if (analysis.explanation) {
891-
logger.log(colors.cyan('\n📖 Explanation:'))
899+
logger.log('')
900+
logger.log(colors.cyan('📖 Explanation:'))
901+
logger.log('')
892902
logger.log(colors.gray(` ${analysis.explanation}`))
893903
}
894904
}
@@ -1249,7 +1259,8 @@ async function ensureClaudeAuthenticated(claudeCmd) {
12491259

12501260
// Not authenticated, provide instructions for manual authentication
12511261
log.warn('Claude Code login required')
1252-
logger.log(colors.yellow('\nClaude Code needs to be authenticated.'))
1262+
logger.log('')
1263+
logger.log(colors.yellow('Claude Code needs to be authenticated.'))
12531264
logger.log('\nTo authenticate:')
12541265
logger.log(' 1. Open a new terminal')
12551266
logger.log(` 2. Run: ${colors.green('claude')}`)
@@ -1300,7 +1311,8 @@ async function ensureGitHubAuthenticated() {
13001311

13011312
// Not authenticated, prompt for login
13021313
log.warn('GitHub authentication required')
1303-
logger.log(colors.yellow('\nYou need to authenticate with GitHub.'))
1314+
logger.log('')
1315+
logger.log(colors.yellow('You need to authenticate with GitHub.'))
13041316
logger.log('Follow the prompts to complete authentication.\n')
13051317

13061318
// Run gh auth login interactively
@@ -1315,10 +1327,12 @@ async function ensureGitHubAuthenticated() {
13151327
await new Promise(resolve => setTimeout(resolve, 2000))
13161328
} else {
13171329
log.failed('Login process failed')
1318-
logger.log(colors.red('\nLogin failed. Please try again.'))
1330+
logger.log('')
1331+
logger.log(colors.red('Login failed. Please try again.'))
13191332

13201333
if (attempts < maxAttempts) {
1321-
logger.log(colors.yellow(`\nAttempt ${attempts + 1} of ${maxAttempts}`))
1334+
logger.log('')
1335+
logger.log(colors.yellow(`Attempt ${attempts + 1} of ${maxAttempts}`))
13221336
await new Promise(resolve => setTimeout(resolve, 1000))
13231337
}
13241338
}
@@ -4412,12 +4426,14 @@ Let's work through this together to get CI passing.`
44124426

44134427
// Provide debugging information
44144428
if (runsResult.stderr) {
4415-
logger.log(colors.red('\nError details:'))
4429+
logger.log('')
4430+
logger.log(colors.red('Error details:'))
44164431
logger.log(runsResult.stderr)
44174432
}
44184433

44194434
// Common troubleshooting steps
4420-
logger.log(colors.yellow('\nTroubleshooting:'))
4435+
logger.log('')
4436+
logger.log(colors.yellow('Troubleshooting:'))
44214437
logger.log('1. Check GitHub CLI authentication:')
44224438
logger.log(` ${colors.green('gh auth status')}`)
44234439
logger.log('\n2. If not authenticated, login:')
@@ -4543,13 +4559,15 @@ Let's work through this together to get CI passing.`
45434559
// Show available snapshots for reference.
45444560
const snapshotList = snapshots.listSnapshots()
45454561
if (snapshotList.length > 0) {
4546-
logger.log(colors.cyan('\n📸 Available Snapshots:'))
4562+
logger.log('')
4563+
logger.log(colors.cyan('📸 Available Snapshots:'))
45474564
snapshotList.slice(0, 5).forEach(snap => {
45484565
logger.log(
45494566
` ${snap.label} ${colors.gray(`(${formatDuration(Date.now() - snap.timestamp)} ago)`)}`,
45504567
)
45514568
})
45524569
if (snapshotList.length > 5) {
4570+
logger.log('')
45534571
logger.log(colors.gray(` ... and ${snapshotList.length - 5} more`))
45544572
}
45554573
}

0 commit comments

Comments
 (0)