Summary
The history, config, and batch command handlers call loadConfig()/loadRawConfig()/countEntries() outside any try/catch, and src/index.ts action handlers don't wrap them. A corrupted config.json (which loadConfig deliberately surfaces as an error) or an unreadable history file triggers an unhandled promise rejection that prints a raw Node stack trace — instead of the friendly outro(pc.red(...)) error UI used elsewhere (e.g. suggest.ts).
Location
src/commands/history.ts:23 (in getHistoryJsonOutput), :50 (in historyCommand) — loadConfig() unguardedsrc/commands/config.ts:192 (loadConfig()), :230 (loadRawConfig()) — unguardedsrc/commands/batch.ts — loadOrPromptConfig() unguardedsrc/index.ts:105-185 — action handlers have no shared error boundary
Code snippet
// src/commands/history.tsconstconfig=awaitloadConfig();// throws on invalid JSON in config.json → unhandled rejectionconsttotal=awaitcountEntries();
Suggested fix
Add a shared error boundary for command handlers, e.g. a runCli(fn) helper in src/index.ts that catches and renders outro(pc.red(message)) and sets process.exitCode = 1 — or register a process.on('unhandledRejection') handler that renders the friendly error consistently.
Impact
- Expected error conditions (corrupted config/history files) crash with full stack traces, which look like bugs to end users.
- UX is inconsistent: the same corrupted-config error is friendly in
suggest but a raw trace in history/config.
Summary
The
history,config, andbatchcommand handlers callloadConfig()/loadRawConfig()/countEntries()outside any try/catch, andsrc/index.tsaction handlers don't wrap them. A corruptedconfig.json(whichloadConfigdeliberately surfaces as an error) or an unreadable history file triggers an unhandled promise rejection that prints a raw Node stack trace — instead of the friendlyoutro(pc.red(...))error UI used elsewhere (e.g.suggest.ts).Location
src/commands/history.ts:23(ingetHistoryJsonOutput),:50(inhistoryCommand) —loadConfig()unguardedsrc/commands/config.ts:192(loadConfig()),:230(loadRawConfig()) — unguardedsrc/commands/batch.ts—loadOrPromptConfig()unguardedsrc/index.ts:105-185— action handlers have no shared error boundaryCode snippet
Suggested fix
Add a shared error boundary for command handlers, e.g. a
runCli(fn)helper insrc/index.tsthat catches and rendersoutro(pc.red(message))and setsprocess.exitCode = 1— or register aprocess.on('unhandledRejection')handler that renders the friendly error consistently.Impact
suggestbut a raw trace inhistory/config.