# Changelog

## [2.1.0] - 2026-01-10

### Features

#### Continuity Module Integration
- **feat(continuity)**: Add integrated continuity tools for task tracking and workflow automation
  - New module: `src/continuity/` - Consolidated continuity functionality from shell scripts
  - Benefit: Unified MCP interface for all development workflow operations
  - Token-optimized outputs (~20-50 tokens per call)

### New Tools

#### dev_ledger (~50 tokens)
- Manage continuity ledgers for task tracking
- Actions: `status`, `list`, `create`, `update`, `archive`, `search`
- Replaces: `~/.claude/scripts/ledger-manager.sh`

```
dev_ledger(action="status")                    # Current ledger status
dev_ledger(action="list")                      # List active/archived ledgers
dev_ledger(action="create", taskId="TASK-123") # Create new ledger
dev_ledger(action="archive", taskId="TASK-123") # Archive ledger
dev_ledger(action="search", keyword="auth")    # Search ledgers
```

#### dev_reasoning (~30 tokens)
- Manage commit reasoning and decision history
- Actions: `generate`, `recall`, `aggregate`
- Replaces: `~/.claude/scripts/generate-reasoning.sh`, `recall-reasoning.sh`

```
dev_reasoning(action="generate", commitHash="abc123", commitMessage="feat: add auth")
dev_reasoning(action="recall", keyword="authentication")
dev_reasoning(action="aggregate", baseBranch="master")
```

#### dev_branch (~30 tokens)
- Branch lifecycle management with smart stash handling
- Actions: `cleanup`, `stale`, `switch`, `prune`, `merged`
- Replaces: `~/.claude/scripts/branch-lifecycle.sh`

```
dev_branch(action="cleanup", dryRun=true)     # Preview merged branches to delete
dev_branch(action="stale", days=30)           # List stale branches
dev_branch(action="switch", target="feature/xxx") # Smart switch with auto-stash
dev_branch(action="prune")                    # Prune remote tracking branches
```

#### dev_defaults (~20 tokens)
- Infer scope, labels, reviewers from code changes
- Actions: `scope`, `labels`, `reviewers`, `working-set`, `all`
- Replaces: `~/.claude/scripts/smart-defaults.sh`

```
dev_defaults(action="scope")      # Infer commit scope from file paths
dev_defaults(action="labels")     # Infer PR labels from branch type
dev_defaults(action="reviewers")  # Infer reviewers from CODEOWNERS/git history
dev_defaults(action="all")        # Get all inferred values
```

### Technical Details

**New Files**:
- `src/continuity/index.ts` - Module exports
- `src/continuity/ledger.ts` - Ledger management (359 lines)
- `src/continuity/reasoning.ts` - Reasoning management (285 lines)
- `src/continuity/branch.ts` - Branch lifecycle (240 lines)
- `src/continuity/defaults.ts` - Smart defaults inference (238 lines)

**Modified Files**:
- `src/index.ts` - Added 4 tool definitions and handlers
- `package.json` - Version bump to 2.1.0

**Scope Inference Rules** (from `defaults.ts`):
| File Pattern | Inferred Scope |
|-------------|----------------|
| `HouseSigma/UI/*` | ui |
| `HouseSigma/Network*` | network |
| `HouseSigma/Model/*` | model |
| `*Auth*`, `*Login*` | auth |
| `.github/*` | ci |
| `*.md` | docs |

**Label Inference Rules**:
| Branch Prefix | Labels |
|--------------|--------|
| `feature/*` | enhancement |
| `fix/*`, `bugfix/*` | bug |
| `hotfix/*` | bug, priority:high |
| `refactor/*` | refactor |
| `perf/*` | performance |
| `docs/*` | documentation |

### Migration Guide

**Before (Shell Scripts)**:
```bash
bash ~/.claude/scripts/ledger-manager.sh status
bash ~/.claude/scripts/branch-lifecycle.sh cleanup
bash ~/.claude/scripts/smart-defaults.sh scope
bash ~/.claude/scripts/generate-reasoning.sh <hash> "<msg>"
```

**After (MCP Tools)**:
```
dev_ledger(action="status")
dev_branch(action="cleanup")
dev_defaults(action="scope")
dev_reasoning(action="generate", commitHash="<hash>", commitMessage="<msg>")
```

### Benefits

1. **Unified Interface**: All workflow operations through MCP
2. **Token Efficiency**: Compact outputs (~20-50 tokens vs ~100+ from scripts)
3. **Type Safety**: TypeScript implementation with compile-time checks
4. **Reduced Dependencies**: No need for separate shell scripts
5. **Better Integration**: Seamless use with other dev_* tools

## [2.0.3] - 2025-12-31

### Improvements

#### iOS Version Detection Modernization
- **refactor(ios)**: Replace deprecated agvtool with xcodebuild for version reading
  - Previously: Used `agvtool what-marketing-version -terse1` (deprecated)
  - Now: Uses `xcodebuild -showBuildSettings | grep MARKETING_VERSION`
  - Benefit: Better compatibility with modern Xcode versions
  - Auto-detects `.xcworkspace` or `.xcodeproj` files
  - Falls back gracefully if neither is found

### Technical Details

**Files Modified**:
- `src/git/version.ts` - Updated `getVersionInfo()` to use xcodebuild
  - Changed signature from `getVersionInfo(projectType)` to `getVersionInfo(project)`
  - Updated `VersionInfo.source` type: `'agvtool'` → `'xcodebuild'`
- `src/platforms/ios.ts` - Updated `getPlatformConfig()` versionCmd
  - Dynamically constructs xcodebuild command based on project structure
- `src/index.ts` - Updated function call to pass full `project` object

**Compatibility**:
- ✅ Backward compatible - no breaking changes
- ✅ Same output format maintained
- ✅ Automatic project type detection (workspace vs project)

**Benefits**:
- Works with Xcode 15+ without warnings
- More reliable version detection
- Better alignment with official Apple tooling

## [2.0.2] - 2025-12-31

### Features

#### CLI Tool for Shell Integration
- **feat(cli)**: Add standalone CLI tool for shell script integration
  - New file: `src/cli.ts` - Provides command-line interface for shell scripts
  - Purpose: Enable StatusLine and other shell scripts to query dev-flow status without MCP connection
  - Commands: `dev_status`, `dev_flow`, `dev_check`, `dev_fix`, `dev_next`
  - Usage: Detects command from script name (e.g., `/usr/bin/dev_status` → runs `status` command)
  - Output: Lightweight status format (e.g., `DEVELOPING|✅0|commit`)

#### Smart Workflow Suggestions
- **feat(ios)**: Skip format/lint for documentation-only changes
  - New function: `hasCodeFileChanges()` - Detects if any `.swift` files are modified
  - Behavior:
    - Code changes detected → `make fix` → `git commit` → `git push`
    - Docs/config only → `git commit` → `git push` (docs/config only)
  - Impact: Saves time by avoiding unnecessary SwiftLint/SwiftFormat runs
  - File: `src/platforms/ios.ts:158-183`

- **feat(android)**: Skip format/lint for documentation-only changes
  - New function: `hasCodeFileChanges()` - Detects if any `.kt` or `.java` files are modified
  - Behavior:
    - Code changes detected → `./gradlew ktlintFormat` → `git commit` → `git push`
    - Docs/config only → `git commit` → `git push` (docs/config only)
  - Impact: Avoids unnecessary ktlint runs on docs-only commits
  - File: `src/platforms/android.ts:140-166`

### Package Updates

#### New Binary Commands
- **chore(package)**: Register CLI commands in package.json
  - Added 5 bin entries: `dev_status`, `dev_flow`, `dev_check`, `dev_fix`, `dev_next`
  - All point to: `dist/cli.js`
  - Installation: `npm link` creates global commands
  - Usage: Scripts can call `dev_status` directly instead of invoking MCP server

### Use Cases

#### StatusLine Integration
```bash
# Before: StatusLine couldn't query dev-flow (needed MCP connection)
# After: StatusLine can call dev_status directly
PHASE=$(dev_status 2>/dev/null | cut -d'|' -f1)
```

#### Documentation Commits
```bash
# Before: Make changes to CLAUDE.md
$ /dev flow verbose
# Output: `make fix` → `git commit` → `git push`
# Problem: Wastes time running SwiftLint on unchanged code

# After: Make changes to CLAUDE.md
$ /dev flow verbose
# Output: `git commit` → `git push` (docs/config only)
# Benefit: Skips unnecessary quality checks
```

### Technical Details

**Files Modified**:
- `src/cli.ts` (new) - 81 lines - Standalone CLI tool
- `src/platforms/ios.ts` - Added `hasCodeFileChanges()` function
- `src/platforms/android.ts` - Added `hasCodeFileChanges()` function
- `package.json` - Added 5 bin commands

**Testing**:
1. Test CLI: `dev_status` → should output `PHASE|STATUS|NEXT`
2. Test docs-only: Modify `.md` files → `/dev flow` → should skip `make fix`
3. Test code changes: Modify `.swift` files → `/dev flow` → should include `make fix`

## [2.0.1] - 2025-12-31

### Bug Fixes

#### Critical Workflow Phase Detection
- **fix(workflow)**: Phase detection now prioritizes uncommitted changes over PR status
  - Previously: Branch with PR open + uncommitted changes → `PR_OPEN` (incorrect)
  - Now: Branch with PR open + uncommitted changes → `DEVELOPING` (correct)
  - Impact: Prevents incorrect "wait" suggestions when active development ongoing
  - File: `src/git/workflow.ts:105-123`

#### Git Status Detection
- **fix(workflow)**: Handle `latestTag` null case to prevent git command failures
  - Added null check before executing `git log ${latestTag}..HEAD`
  - Prevents "git log null..HEAD" error when no tags exist
  - File: `src/git/workflow.ts:94-101`

- **fix(workflow)**: Detect unpushed commits correctly when branch has no upstream
  - Previously: New branch with commits but no upstream → `hasUnpushedCommits = false`
  - Now: Compares with origin/master or origin/main when no upstream exists
  - Impact: Properly suggests "push" for new feature branches
  - File: `src/git/workflow.ts:51-66`

- **fix(workflow)**: Recognize additional Git Flow branch patterns
  - Added: `hotfix/`, `release/`, `chore/`, `refactor/`, `bugfix/`, `docs/`, `test/`, `ci/`
  - Previously: Only `feature/`, `fix/`, `feat/` were recognized
  - Impact: All common branch types now properly tracked
  - File: `src/git/workflow.ts:85-86`

#### Build Control
- **fix(build-control)**: Prevent doc-only detection from overriding code change decisions
  - Previously: Could mark "should_build" as "skip" if many doc files present
  - Now: Only applies "doc-only skip" when `totalCodeFiles === 0`
  - Impact: More accurate build recommendations
  - File: `src/git/build-control.ts:193-199`

#### Status Display
- **fix(index)**: Show PR build info even when phase is DEVELOPING
  - Previously: PR info only shown when `phase === 'PR_OPEN'`
  - Now: PR info shown whenever PR exists, regardless of phase
  - Impact: Better visibility of PR state and build settings
  - File: `src/index.ts:338-356`

- **fix(index)**: Add missing PR_MERGED phase handling
  - Added: `PR_MERGED → 'checkout master'` in quick next suggestions
  - Added: Full command in detailed next command map
  - Impact: Proper guidance after PR merge
  - Files: `src/index.ts:316`, `src/index.ts:456`

### Technical Details

**Files Modified**:
- `src/git/workflow.ts` - 4 bug fixes
- `src/git/build-control.ts` - 1 bug fix
- `src/index.ts` - 2 bug fixes

**Testing Recommendations**:
1. Test with branch that has PR + uncommitted changes (should show DEVELOPING)
2. Test with new branch without upstream (should detect unpushed commits)
3. Test with hotfix/release/chore branches (should be recognized)
4. Test with no git tags (should not crash)

## [2.0.0] - 2025-12-30

### Breaking Changes

#### Build Control System
- **feat(build-control)**: Smart PR draft/ready toggle with CI build control
  - New tool: `dev_ready(action)` - Control PR draft/ready status
  - Auto-build disabled for draft PRs, enabled for ready PRs
  - Analyze code changes to recommend build timing
  - Saves CI resources by skipping builds during active development

#### Change Analysis
- **feat(build-control)**: Intelligent build recommendation engine
  - Analyzes: lines changed, file types, dependencies, project config
  - Recommendations: `should_build` / `skip` / `maybe`
  - Rules:
    - Dependencies changed → always build
    - >100 lines → build
    - <30 lines → skip
    - Only docs → skip
    - 30-100 lines → maybe

#### Enhanced Status Output
- **feat(index)**: Build control info in workflow status
  - Added to `dev_flow`: `|DRAFT/READY|builds:ON/OFF|✅BUILD/⏸️SKIP/⚠️MAYBE`
  - Shows PR draft state, build switch, and recommendation
  - Only shown when PR exists

### New Tools
- `dev_ready(action)` - Control PR ready/draft status (~20 tokens)
- `dev_changes(base, format)` - Analyze code changes (~50 tokens)

### Migration Notes
- Output format backward compatible - new fields appended only
- No changes required for existing consumers
- New features opt-in via new tool calls

## [1.3.0] - 2025-12-30

### Extended Data Output

**Breaking Change** (backward compatible):
- `dev_flow` output format extended from 4 to 8 fields
- **Old format**: `项目|分支|阶段|状态` (4 fields)
- **New format**: `项目|分支|任务ID|阶段|错误数|警告数|PR状态|PR_URL` (8 fields)

**New Data Included**:
- ✅ **TASK_ID**: Extracted from branch name (e.g., TASK-945)
- ✅ **Errors/Warnings**: Separated error and warning counts
- ✅ **PR Status**: OPEN|MERGED|CLOSED|NONE
- ✅ **PR URL**: Direct link to pull request (if exists)

**Benefits**:
- **-50% duplicate data collection**: /dev-flow no longer needs to collect TASK_ID, PR status
- **Better data consistency**: Single source of truth for all workflow data
- **Token savings**: Reduced bash script execution in /dev-flow command

**Backward Compatibility**:
- Old consumers can still parse first 4 fields
- New consumers get enhanced data automatically
- No breaking changes for existing integrations

### Technical Details

**Modified**: `src/index.ts` - `fullStatus()` function
- Added `workflow.git.taskId` to output
- Added separate `errors` and `warnings` counts
- Added `workflow.git.prState` and `workflow.git.prUrl`
- Updated version to 1.3.0

## [1.2.0] - 2025-12-30

### Token Optimization

- **60-70% token reduction** across all tools
- `dev_status`: 100 → 30 tokens (~70% reduction)
- `dev_flow`: 300 → 100 tokens (~67% reduction)
- `dev_fix`: 50 → 20 tokens (~60% reduction)
- `dev_check`: 30 → 10 tokens (~67% reduction)

### Automation Improvements

- **Added Prompts**: Enable Claude to proactively suggest workflow actions
  - `dev_workflow_check`: Check status before committing
  - `dev_auto_fix`: Auto-fix code quality issues
  - `dev_next_step`: Get next recommended action

- **Added Resources**: Subscribable project information
  - `dev://status`: Real-time workflow status
  - `dev://config`: Project configuration and tools

- **New Tool**: `dev_next` - Smart next command suggestion

### Standards Compliance

- **Conventional Commits**: All commit suggestions follow `type(scope): message` format
- **Git Flow**: Branch naming follows `feature/*`, `release/*`, `hotfix/*` patterns
- **PR Standards**: Structured PR templates with summary and testing checklists

### Technical Improvements

- **Smart Caching**: Per-tool caching with appropriate TTLs
  - Project info: 60s (rarely changes)
  - Git status: 5s (changes often)
  - Quality checks: 10s (moderate)
- **Optimized Output**: Ultra-compact formats using pipes and symbols
- **SDK Update**: Upgraded to @modelcontextprotocol/sdk@1.25.1 (security fix)

## [1.0.0] - 2025-12-30

### Initial Release

- Auto-detect iOS and Android projects
- Git workflow phase detection
- Code quality checks (SwiftLint, ktlint, detekt)
- Phase-specific guidance
