Skip to content

feat: keep numeric exit codes for shell commands (#80) - #160

Merged
NehharShah merged 1 commit into
mainfrom
feat/exit-codes
Nov 21, 2026
Merged

NehharShah merged 1 commit into
mainfrom
feat/exit-codes

Conversation

@NehharShah

Copy link
Copy Markdown
Collaborator

What changed and why

Shell events carried only isError, which hides the difference between a failing test, a missing command (127) and an interrupt (130). They now keep exitCode?: number wherever the source reports one.

Per adapter:

  • Codex: exitFailed became exitCodeOf — the JSON metadata.exit_code path returns the number itself, and the text forms ("Exit code: 1", "Process exited with code 1") are parsed with a shared exitCodeFromText() in common.ts. Failure semantics unchanged: a code is failure only when it is non-zero.
  • Cursor: the app database's exit code rides along on the marked shell event (it is only written for non-zero codes, so isError stays as today).
  • Claude Code: tool results carry no structured code, so the failed result's output text is scanned with the same "exit code N" patterns — a test with Process exited with code 2 and exit code: 127 covers both wordings.

markResult grew an exitCode parameter; the field lives on shell events only (file and tool events keep isError/errorExcerpt).

Docs

docs/architecture.md (the "Failed tool calls keep an excerpt" paragraph gains the exit-code sentence).

Testing

pnpm lint, pnpm typecheck, pnpm build, pnpm test: 758 passed, 18 skipped.

  • One test per adapter that fills exitCode (the acceptance criterion): Claude (two wordings: code 2, exit code: 127), Codex (exit code: 2 from the text form), Cursor (the database's exitCode: 1).
  • A successful call keeps neither an excerpt nor an exit code.

Shell events carry exitCode when the source reports one: Codex's
metadata.exit_code and its text forms (refactored into exitCodeOf), Cursor's
database exit code, and an exit code the output text itself reports (Claude
Code). isError behaves as today.
@NehharShah
NehharShah merged commit 164d636 into main Nov 21, 2026
2 checks passed
@NehharShah
NehharShah deleted the feat/exit-codes branch November 21, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant