feat(tui): /model and /setup slash commands with in-place CLI handoff

- hermes-ink: export `withInkSuspended()` + `useExternalProcess()` that
  pause/resume Ink around an arbitrary external process (built on the
  existing enterAlternateScreen/exitAlternateScreen plumbing)
- tui: `launchHermesCommand(args)` spawns the `hermes` binary with
  inherited stdio, with `HERMES_BIN` override for non-standard launches
- tui: `/model` and `/setup` slash commands invoke the CLI wizards
  in-place, then re-preflight `setup.status` and auto-start a session on
  success — no more exit-and-relaunch to finish first-run setup
- setup panel now advertises those slashes instead of only pointing
  users back at the shell
This commit is contained in:
Brooklyn Nicholson 2026-04-17 10:58:18 -05:00
parent 0dd5055d59
commit a82097e7a2
8 changed files with 141 additions and 7 deletions

View file

@ -1,3 +1,4 @@
export { default as TextInput, UncontrolledTextInput } from 'ink-text-input'
export { default as useStderr } from './hooks/use-stderr.js'
export { default as useStdout } from './hooks/use-stdout.js'
export { Ansi } from './ink/Ansi.js'
@ -12,6 +13,7 @@ export { default as Spacer } from './ink/components/Spacer.js'
export { default as Text } from './ink/components/Text.js'
export { default as useApp } from './ink/hooks/use-app.js'
export { useDeclaredCursor } from './ink/hooks/use-declared-cursor.js'
export { useExternalProcess, withInkSuspended, type RunExternalProcess } from './ink/hooks/use-external-process.js'
export { default as useInput } from './ink/hooks/use-input.js'
export { useHasSelection, useSelection } from './ink/hooks/use-selection.js'
export { default as useStdin } from './ink/hooks/use-stdin.js'
@ -22,4 +24,3 @@ export { useTerminalViewport } from './ink/hooks/use-terminal-viewport.js'
export { default as measureElement } from './ink/measure-element.js'
export { createRoot, default as render, renderSync } from './ink/root.js'
export { stringWidth } from './ink/stringWidth.js'
export { default as TextInput, UncontrolledTextInput } from 'ink-text-input'

View file

@ -0,0 +1,27 @@
import { useCallback } from 'react'
import instances from '../instances.js'
export type RunExternalProcess = () => Promise<void>
export async function withInkSuspended(run: RunExternalProcess): Promise<void> {
const ink = instances.get(process.stdout)
if (!ink) {
await run()
return
}
ink.enterAlternateScreen()
try {
await run()
} finally {
ink.exitAlternateScreen()
}
}
export function useExternalProcess(): (run: RunExternalProcess) => Promise<void> {
return useCallback((run: RunExternalProcess) => withInkSuspended(run), [])
}