Skip to content

fix piped CLI output truncation - #249

Merged
nahiyankhan merged 1 commit into
mainfrom
fix/flush-piped-cli-output
Aug 4, 2026
Merged

fix piped CLI output truncation#249
nahiyankhan merged 1 commit into
mainfrom
fix/flush-piped-cli-output

Conversation

@nahiyankhan

Copy link
Copy Markdown
Collaborator

Category: fix

User Impact: Ghost commands now return complete output when consumed through pipes or subprocess capture.

Problem: Commands wrote to stdout and immediately called process.exit, allowing Node to terminate before asynchronous pipe buffers drained. Large pulls were silently cut off at the host pipe capacity, and JSON output could become invalid.

Solution: Centralize command termination behind a flush-before-exit helper, migrate every command exit path to it, and cover the behavior with real multi-megabyte subprocess tests plus an exit-discipline guardrail.

Validation:

  • pnpm build: passed
  • pnpm test: passed, 18 test files passed; 202 passed, 1 skipped (203 total)
  • pnpm check: passed

Changeset: added a patch changeset for @design-intelligence/ghost.

ghost Review:

  • ghost check --base main: not run because the current CLI has no check command and this change does not alter product-surface guidance.
  • ghost review --base main --include-memory: not run because this lifecycle fix does not change guidance, checks, or review packet behavior.
  • Read-only implementation review: approved, smell rating 2/10, no blocking findings.
File changes
  • .changeset/early-falcons-smile.md: patch changeset for the public Ghost package.
  • packages/ghost/src/commands/errors.ts: adds the shared flush-before-exit helper and routes fatal command exits through it.
  • packages/ghost/src/commands/checks-command.ts: migrates checks command exit paths to the shared helper.
  • packages/ghost/src/commands/export-command.ts: migrates export command exit paths to the shared helper.
  • packages/ghost/src/commands/fingerprint-commands.ts: migrates fingerprint command exit paths to the shared helper.
  • packages/ghost/src/commands/gather-command.ts: migrates gather command exit paths to the shared helper.
  • packages/ghost/src/commands/init-command.ts: migrates init command exit paths to the shared helper.
  • packages/ghost/src/commands/manifest-command.ts: migrates manifest command exit paths to the shared helper.
  • packages/ghost/src/commands/pull-command.ts: migrates pull command exit paths to the shared helper.
  • packages/ghost/src/commands/pulse-command.ts: migrates pulse command exit paths to the shared helper.
  • packages/ghost/src/commands/review-command.ts: migrates review command exit paths to the shared helper.
  • packages/ghost/src/commands/skill-command.ts: migrates skill command exit paths to the shared helper.
  • packages/ghost/test/cli-exit.test.ts: adds subprocess coverage for multi-megabyte piped output and a guardrail that rejects direct process.exit in command modules.

Screenshots/Demos: N/A

@nahiyankhan
nahiyankhan requested a review from chailandau August 4, 2026 16:42
@nahiyankhan
nahiyankhan marked this pull request as ready for review August 4, 2026 16:42
@nahiyankhan
nahiyankhan merged commit c103924 into main Aug 4, 2026
5 checks passed
@nahiyankhan
nahiyankhan deleted the fix/flush-piped-cli-output branch August 4, 2026 17:56
@github-actions github-actions Bot mentioned this pull request Aug 4, 2026
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.

2 participants