-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
cli-rearchitectCLI rearchitecture workCLI rearchitecture work
Description
Summary
Migrate the db-status command to use CommandContext as a proof-of-concept. Fix the singleton database import. Write integration tests.
Parent Epic: #172
Phase: 0
Priority: 2
Depends On: Story 1: Core Infrastructure Types
Agent Instructions
Before You Start
- Read
packages/cli/PROGRESS.mdfor status of prior stories in this chain - Read
docs/CONTEXT.mdfor project bootstrap - Read the parent epic Epic: Rearchitect CLI as Agent-First Compiled Binary #172 for full architecture context
- Read
docs/CONVENTIONS.mdanddocs/TESTING.mdfor code standards - Run
bun run check-types && bun run testto verify clean baseline
Task
Migrate the db-status command to use CommandContext as a proof-of-concept, demonstrating the pattern all other commands will follow.
-
createTestContext() helper:
- Returns a CommandContext with captured stdout/stderr as string buffers
- Allows inspection:
testCtx.getStdout(),testCtx.getStderr() - Uses a no-op AbortController
- Mock secrets provider that returns env vars
-
Migrate db-status:
- Current: imports
databasesingleton directly, usesconsole.log - Target: receives CommandContext, uses
ctx.stdout.write(), gets db via lazygetDb() - Add error handling: connection failure → DatabaseError with suggestion
- Add timeout handling: use ctx.signal for AbortController timeout
- Current: imports
-
Integration tests:
- Table-driven tests: success case, connection failure, timeout
- Use createTestContext() to capture output
- Assert exit codes and output content
TDD Approach (Mandatory)
- Write the failing test FIRST
- Implement the minimum code to make it pass
- Refactor for clarity
- Run validation:
bun run check-types && bun run test - Repeat for each acceptance criterion
Files to Create/Modify
packages/cli/src/commands/db-status.ts— Rewrite to accept CommandContextpackages/cli/src/index.ts— Wire db-status to use createContext()packages/cli/tests/integration/commands/db-status.test.tspackages/cli/tests/helpers/test-context.ts— createTestContext() helper that captures stdout/stderr
Acceptance Criteria
- db-status uses CommandContext (no direct console.log or database singleton)
- db-status handles connection failure with DatabaseError + suggestion
- createTestContext() helper works for capturing command output
- Table-driven integration tests cover happy + error paths
- All new code has corresponding tests
-
bun run check-typespasses with zero errors -
bun run testpasses with zero failures - No regressions in existing tests
Progress Tracking
- Update
packages/cli/PROGRESS.mdafter each major milestone within this story - Format:
## Story 2: db-status Migration PoC\n- [x] completed step\n- [ ] pending step - Commit progress regularly with descriptive messages:
feat(cli): [what changed]
On Completion
- Ensure all acceptance criteria are checked off
- Run final validation:
bun run check-types && bun run test - Write a completion summary at the bottom of
packages/cli/PROGRESS.md - Commit with message:
feat(cli): complete story 2 - db-status migration PoC
Ralph Loop Config
- Validation Command:
bun run check-types && bun run test - Priority: 2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
cli-rearchitectCLI rearchitecture workCLI rearchitecture work