Skip to content

feat(#117): add state bootstrapping for existing worktrees - #134

Merged
admarble merged 2 commits into
feature/dashboardfrom
feature/117-add-state-bootstrapping-for-existing-worktrees
Jan 20, 2026
Merged

admarble merged 2 commits into
feature/dashboardfrom
feature/117-add-state-bootstrapping-for-existing-worktrees

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Add new sequant state command with init, rebuild, and clean subcommands
  • Enables state tracking for worktrees created before state tracking was introduced
  • Auto-discovers worktrees with feature/<N>-* or issue-<N> branch patterns
  • Fetches issue titles from GitHub and infers current phase from logs

Changes

  • src/commands/state.ts - New CLI command with subcommand routing
  • src/lib/workflow/state-utils.ts - Add discoverUntrackedWorktrees() function
  • bin/cli.ts - Register the new state command and subcommands
  • src/commands/state.test.ts - Tests for idempotency and output structure
  • src/lib/workflow/state-utils.test.ts - Tests for worktree discovery

Acceptance Criteria

  • sequant state init populates state for untracked worktrees
  • sequant state rebuild recreates state from scratch
  • sequant state clean removes orphaned entries
  • Commands are idempotent (safe to run multiple times)
  • Clear output showing what was added/removed/updated

Test plan

  • Run npm test - all new tests pass
  • Run npm run build - compiles successfully
  • Manual testing of sequant state init - discovers worktrees correctly
  • Manual testing of sequant state init twice - idempotent (no changes second time)
  • Manual testing of sequant state clean --dry-run - shows preview
  • Manual testing of sequant state rebuild - requires --force flag

Closes #117

🤖 Generated with Claude Code

Add new `sequant state` command with three subcommands:
- `init`: Populate state for untracked worktrees
- `rebuild`: Recreate state from logs and worktrees
- `clean`: Remove entries for deleted worktrees

Implementation:
- Add discoverUntrackedWorktrees() to detect worktrees with
  feature/<N>-slug or issue-<N> branch patterns
- Auto-fetch issue titles from GitHub via `gh` CLI
- Infer current phase from existing run logs
- Commands are idempotent (safe to run multiple times)
- Clear output showing what was added/removed/updated
- JSON output mode for scripting

Closes #117

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Document the new `sequant state` command with subcommands:
- init: Populate state for untracked worktrees
- rebuild: Recreate state from logs + worktrees
- clean: Remove orphaned entries

Includes usage examples, options reference, common workflows,
and troubleshooting guide.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@admarble
admarble merged commit 6c85d2f into feature/dashboard Jan 20, 2026
@admarble
admarble deleted the feature/117-add-state-bootstrapping-for-existing-worktrees branch January 20, 2026 15:38
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