Skip to content

refactor(cli): move process-exit lifecycle to the CLI boundary #2142

Description

@thymikee

Parent: #2129

Blocked by: none. Wave 1; this is CLI process lifecycle, not host process execution.

Scope — exact tracked files

Production:

  • src/utils/process-exit.ts

Tests:

  • src/utils/__tests__/process-exit.test.ts

Destination and importer edits

Move to:

  • src/cli/process-exit.ts
  • src/cli/process-exit.test.ts

Update exactly these production importers:

  • src/bin.ts
  • src/cli.ts
  • src/cli/process-entry.ts

Keep the implementation beside the existing CLI entry/process boundary. Do not move it into host-kit/process and do not add a generic process facade.

Behavior invariants

Preserve stdout/stderr drain ordering, the bounded drain timeout, flush behavior, exit-code propagation, and the distinction between normal command completion and process-entry failure. Preserve CLI startup and signal/error behavior; do not change daemon child-process ownership or host command execution.

Focused validation

Run:

  • pnpm vitest run src/cli/process-exit.test.ts
  • the existing CLI process-entry and CLI error tests
  • pnpm check:affected --run

Planted-red proof

No new structural rule is added. Temporarily remove the stdout/stderr drain await or shorten the bounded timeout in the moved test seam and observe the independent lifecycle assertion fail; restore the exact implementation before the final run.

Dependency order

Wave 1. The terminal child is blocked by this child. No other owner slice should import this module.

Shrink target

Delete the old utility module and test with no compatibility re-export. The CLI destination must be a physical move with no production LOC growth after discounting the move.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    项目

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions