Skip to content

Commit 2297cb8

Browse files
committed
tweaks
1 parent 018ba60 commit 2297cb8

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

npm-app/src/shell-dispatcher.ts

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ export function installShims(
189189
return
190190
}
191191

192-
const shimsDir = getShimsDirectory()
193192
let installed = 0
194193
let errors = 0
195194

@@ -209,51 +208,47 @@ export function installShims(
209208
const commandName = customCommand || defaultCommandName
210209

211210
createShim(agentId, commandName, force)
212-
console.log(green(`✓ ${commandName}${agentId}`))
213211
installed++
212+
// Only show command name, not full agent ID
213+
console.log(
214+
green(
215+
`✓ ${commandName} saved as a shim for "codebuff --agent ${agentId}"`,
216+
),
217+
)
214218
} catch (error) {
215219
console.error(red(`Error creating shim for '${agentSpec}': ${error}`))
216220
errors++
217221
}
218222
}
219-
220-
console.log(
221-
green(
222-
`\n✓ Installed ${installed} shim${installed !== 1 ? 's' : ''} in ${shimsDir}`,
223-
),
224-
)
225223
if (errors > 0) {
226224
console.log(
227225
red(`✗ Failed to install ${errors} shim${errors !== 1 ? 's' : ''}`),
228226
)
229-
} // Always add to PATH after successful installation
227+
}
228+
229+
// Always add to PATH after successful installation
230230
if (installed > 0) {
231-
console.log('\n' + bold('Adding shims to PATH...'))
232231
const success = addToPath()
233232

234233
if (success) {
235-
console.log(
236-
'\n' +
237-
green(
238-
'🎉 Setup complete! Shims will persist after terminal restart.',
239-
),
240-
)
241-
console.log('\n' + cyan('For immediate use in this session, run:'))
242-
console.log(cyan(` eval "$(codebuff shims env)"`))
243-
console.log('\n' + cyan('Then try:'))
244-
// Show the first installed command as an example
234+
console.log('\nRun this for immediate use:')
235+
if (success !== 'ALREADY_IN_PATH') {
236+
console.log(cyan(`eval "$(codebuff shims env)"`))
237+
}
238+
239+
// Show example command
245240
const firstCommand = agentSpecs[0]
246241
const [agentId, customCommand] = firstCommand.split(':')
247242
const defaultCommandName = parseAgentId(agentId)
248243
const exampleCommand = customCommand || defaultCommandName
249244
if (exampleCommand) {
250-
console.log(cyan(` ${exampleCommand} "your prompt here"`))
245+
console.log(cyan(`${exampleCommand} "your prompt"`))
251246
}
252247
} else {
253-
console.log(
254-
'\n' + yellow('Profile setup failed. Use manual instructions below:'),
255-
)
256-
showPathInstructions(shimsDir)
248+
console.log(yellow('\nCould not auto-configure PATH. Run manually:'))
249+
const { evalCommand } = detectShell()
250+
const sessionCmd = evalCommand.replace('{dir}', getShimsDirectory())
251+
console.log(cyan(sessionCmd))
257252
}
258253
}
259254
}
@@ -655,7 +650,9 @@ function isShimsDirInPath(): boolean {
655650
/**
656651
* Add shims directory to shell profile with idempotency
657652
*/
658-
export function addToPath(options: { force?: boolean } = {}): boolean {
653+
export function addToPath(
654+
options: { force?: boolean } = {},
655+
): boolean | 'ALREADY_IN_PATH' {
659656
const { force = false } = options
660657
const shimsDir = getShimsDirectory()
661658
const { shell, profileFile } = detectShell()
@@ -667,10 +664,9 @@ export function addToPath(options: { force?: boolean } = {}): boolean {
667664
return false
668665
}
669666

670-
// Check if already in PATH
667+
// Check if already in PATH (silent check)
671668
if (isShimsDirInPath() && !force) {
672-
console.log(green('✓ Shims directory is already in PATH'))
673-
return true
669+
return 'ALREADY_IN_PATH'
674670
}
675671

676672
try {
@@ -681,10 +677,9 @@ export function addToPath(options: { force?: boolean } = {}): boolean {
681677
if (existsSync(profilePath)) {
682678
profileContent = readFileSync(profilePath, 'utf8')
683679

684-
// Check if our entry already exists
680+
// Check if our entry already exists (silent check)
685681
if (profileContent.includes('# >>> codebuff shims >>>') && !force) {
686-
console.log(green('✓ Shims already configured in profile'))
687-
return true
682+
return 'ALREADY_IN_PATH'
688683
}
689684
} else {
690685
// Create profile directory if it doesn't exist
@@ -713,7 +708,6 @@ export function addToPath(options: { force?: boolean } = {}): boolean {
713708
const newContent = cleanContent + addition
714709
writeFileSync(profilePath, newContent, 'utf8')
715710

716-
console.log(green(`✓ Added shims to PATH in ${profilePath}`))
717711
return true
718712
} catch (error) {
719713
console.error(red(`Failed to update profile: ${error}`))
@@ -771,6 +765,7 @@ function getPowerShellProfile(): string {
771765
try {
772766
const result = execSync('powershell -Command "$PROFILE"', {
773767
encoding: 'utf8',
768+
stdio: ['ignore', 'pipe', 'ignore'], // Suppress stderr
774769
})
775770
return result.trim()
776771
} catch {

0 commit comments

Comments
 (0)