Repository navigation
Closed
Labels
cliCLI commands and interfaceenhancementNew feature or requestplannedImplementation plan approvedready-for-reviewReady for code reviewstateState tracking and management
Milestone
Description
Summary
Provide a way to populate .sequant/state.json for worktrees that already exist but have no state tracking.
Problem
When state tracking is introduced, existing worktrees won't have entries in the state file. Need a way to:
- Detect existing worktrees
- Infer their current phase from logs or git state
- Populate state file with reasonable defaults
Proposed Commands
sequant state init
# → Scans for worktrees, creates state entries for any not tracked
sequant state rebuild
# → Rebuilds entire state file from git worktrees + logs
# → Use when state is corrupted or out of sync
sequant state clean
# → Removes entries for worktrees that no longer existDetection Logic
- Run
git worktree listto find all worktrees - For each worktree with
issue-*orfeature/*pattern:- Extract issue number from branch name
- Fetch issue title from GitHub
- Check
.sequant/logs/for any phase history - Infer current phase (last completed + 1, or
not_started)
- Write to state file
Edge Cases
- Worktree exists but issue was closed/deleted
- Multiple worktrees for same issue (shouldn't happen, but handle gracefully)
- Logs exist but worktree was deleted
- No logs, no worktree, but state entry exists (stale)
Acceptance Criteria
-
sequant state initpopulates state for untracked worktrees -
sequant state rebuildrecreates state from scratch -
sequant state cleanremoves orphaned entries - Commands are idempotent (safe to run multiple times)
- Clear output showing what was added/removed/updated
Dependencies
- Add persistent state tracking for workflow phases #115 - State tracking schema and utilities
Metadata
Metadata
Assignees
Labels
cliCLI commands and interfaceenhancementNew feature or requestplannedImplementation plan approvedready-for-reviewReady for code reviewstateState tracking and management
Activity
admarble commentedon Jan 19, 2026
Worktree Setup
Feature worktree already created from
feature/dashboardbranch:This is part of the dashboard feature integration - all dashboard work (#114, #116, #117, #118, #119, #120) branches from
feature/dashboardrather thanmain.Note:
sequant rundoesn't support custom base branches yet (see #122), so this worktree was created manually.admarble commentedon Jan 20, 2026
📋 Implementation Plan for State Bootstrapping
Acceptance Criteria with Verification
sequant state initpopulates state for untracked worktreessequant state rebuildrecreates state from scratchsequant state cleanremoves orphaned entriesImplementation Phases
Phase 1: CLI Infrastructure
/src/commands/state.tswith subcommand routingsequant statein CLI withinit,rebuild,cleansubcommandsPhase 2: Worktree Discovery & State Init
discoverUntrackedWorktrees()tostate-utils.tsfetchIssueTitle()helper usingghCLIstate initcommandPhase 3: Rebuild & Clean Enhancement
rebuildStateFromLogs()to include worktree scanningstate rebuildwith backup optionstate cleanwrapperPhase 4: Quality
Key Assumptions
feature/<issue>-*orissue-<issue>patterngh) available for title lookup (graceful fallback if not)Open Decisions
sequant status --rebuildas alias → Recommend: Yes--force→ Recommend: YesEffort Breakdown
Feature Branch
🤖 Generated by /spec workflow
feat(#117): add state bootstrapping for existing worktrees
admarble commentedon Jan 20, 2026
Implementation Complete
AC Coverage
sequant state initpopulates state for untracked worktreessequant state rebuildrecreates state from scratchsequant state cleanremoves orphaned entriesKey Files Changed
src/commands/state.ts- New CLI command with subcommand routingsrc/lib/workflow/state-utils.ts- AdddiscoverUntrackedWorktrees()functionbin/cli.ts- Register the newstatecommand and subcommandssrc/commands/state.test.ts- Tests for idempotency and output structuresrc/lib/workflow/state-utils.test.ts- Tests for worktree discoveryTest Results
npm test: 444 passing (2 unrelated failures in doctor tests due to version check)npm run build: ✅ PassesPR
Created: #134
Notes
The implementation supports:
feature/<N>-*,issue-<N>,<N>-*ghCLI (with fallback placeholder)--jsonflag)--dry-runflag)--forceflag)🤖 Generated by /exec workflow
admarble commentedon Jan 20, 2026
QA Review for Issue #117
AC Coverage
sequant state initpopulates state for untracked worktrees--jsonoutput.sequant state rebuildrecreates state from scratch--forceflag as safety measure.sequant state cleanremoves orphaned entries--dry-runand--max-ageoptions.--jsonflag for scripting.Coverage: 5/5 AC items fully met
Quality Metrics
any)Code Review
Strengths:
state.ts, core logic instate-utils.tsIssues:
Suggestions:
--backupoption torebuildto save existing state before overwritingSelf-Evaluation
init,rebuild,clean)Verdict: READY_FOR_MERGE
All acceptance criteria are met. The implementation is well-structured with proper error handling, comprehensive tests, and good developer experience (JSON output, dry-run modes, force flags for destructive operations).
Documentation
--help), and this is an internal workflow toolNext Steps
/docs 117to generate feature documentation if needed🤖 Generated by /qa workflow
docs(#117): add state command documentation
admarble commentedon Jan 20, 2026
Documentation Generated
File:
docs/state-command.mdSections Included:
init,rebuild,cleanDocumentation Highlights:
sequant state initsequant state rebuildsequant state cleanNext Steps:
🤖 Generated by /docs workflow
admarble commentedon Jan 20, 2026
Smoke Test Results ✅
state init(first run)state init(second run)state clean --dry-runstatus --issuesNote: Issues with multiple worktrees (e.g., #117, #119) are tracked by issue number as unique key - last worktree wins. This is expected behavior.
All tests pass. Merging PR #134.
feat(#117): add state bootstrapping for existing worktrees (#134)
admarble commentedon Jan 20, 2026
Merged via PR #134 (commit 6c85d2f)
docs: add state command to CHANGELOG