Implements bd-caa9: migration tool for existing users to enable
separate branch workflow.
Features:
- bd migrate --to-separate-branch <branch> sets sync.branch config
- Validates branch names (no whitespace/empty)
- Dry-run support with --dry-run flag
- Idempotent (safe to run multiple times)
- JSON output support
- Clear next steps for users
Closes bd-caa9, bd-a101
Amp-Thread-ID: https://ampcode.com/threads/T-93c3427d-12a1-4d9a-8690-1d0cfe22188f
Co-authored-by: Amp <amp@ampcode.com>
- Switched from modernc.org/sqlite to ncruces/go-sqlite3 for WASM support
- Added WASM-specific stubs for daemon process management
- Created wasm/ directory with build.sh and Node.js runner
- WASM build succeeds (32MB bd.wasm)
- Node.js can load and execute the WASM module
- Next: Need to bridge Go file I/O to Node.js fs module
Related: bd-44d0, bd-8534, bd-c7eb
- Renamed config.json to metadata.json to clarify purpose (database metadata)
- Fixed config.yaml/config.json conflict by making Viper explicitly load only config.yaml
- Added automatic migration from config.json to metadata.json on first read
- Fixed jsonOutput variable shadowing across 22 command files
- Updated bd init to create both metadata.json and config.yaml template
- Fixed 5 failing JSON output tests
- All tests passing
Resolves config file confusion and makes config.yaml work correctly.
Closes#178 (global flags), addresses config issues from #193
Amp-Thread-ID: https://ampcode.com/threads/T-e6ac8192-e18f-4ed7-83bc-4a5986718bb7
Co-authored-by: Amp <amp@ampcode.com>
- Fixes GH #201
- bd migrate now detects prefix from existing issues
- Sets issue_prefix config before schema version update
- Prevents 'no issue found' errors after migration
- Prevents incorrect prefix in hash ID migrations
When migrating pre-0.17.5 databases, the issue_prefix config
(required since bd-166) was not being set. This caused commands
like 'bd show' to fail with 'no issue found' errors.
The fix queries for existing issues after migration and extracts
the prefix using utils.ExtractIssuePrefix(), then sets the config
before continuing with version updates.
Amp-Thread-ID: https://ampcode.com/threads/T-ba0c6c5c-8812-4ecf-8576-c0870fdbefff
Co-authored-by: Amp <amp@ampcode.com>
Fixes#204
Multiple critical bugs in bd migrate:
1. **Respects config.json database name**: migrate now loads config.json
and uses the configured database name instead of hardcoding beads.db.
Users with custom database names (e.g., beady.db) will no longer
have their databases renamed.
2. **Fixes disk I/O error (522)**: Clean up orphaned WAL files before
reopening database to update schema version. This prevents SQLite
error 522 (disk I/O error) when WAL files exist from previous
database sessions.
3. **Creates backup before migration**: First migration now creates
a timestamped backup (*.backup-pre-migrate-*.db) before renaming
database, consistent with hash-id migration behavior.
4. **Cleans up orphaned WAL files**: Removes .db-wal and .db-shm
files after migrating old database to prevent stale files.
Changes:
- Load config.json in migrate command to get target database name
- Use cfg.Database instead of hardcoded beads.CanonicalDatabaseName
- Add loadOrCreateConfig() helper function
- Add cleanupWALFiles() to remove orphaned WAL/SHM files
- Create backup before first migration
- Clean up WAL files before version update and after migration
- Add TestMigrateRespectsConfigJSON test
All migration tests passing.
Amp-Thread-ID: https://ampcode.com/threads/T-e5b9ddd0-621b-418b-bc52-ba9462975c39
Co-authored-by: Amp <amp@ampcode.com>
- Removed nextSequentialID() and getIDMode() functions
- Removed issue_counters table from schema
- Made SyncAllCounters() a no-op for backward compatibility
- Simplified ID generation to hash-only (adaptive length)
- Removed id_mode config setting
- Removed sequential ID tests and migration code
- Updated CONFIG.md and AGENTS.md to remove sequential ID references
Follow-up bd-2a70 will remove obsolete test files and renumber command.
- Changed generateHashID to start with 6 chars (3 bytes), expand to 7/8 on collision
- Updated both CreateIssue and CreateIssues (batch) to use progressive length fallback
- Updated tests to accept 9-11 char IDs (bd- + 6-8 hex chars)
- All new issues now generate with shorter, more readable IDs
- Existing 8-char IDs preserved (no migration needed)
Amp-Thread-ID: https://ampcode.com/threads/T-8a6058af-9f42-4bff-be02-8c8bce41eeb5
Co-authored-by: Amp <amp@ampcode.com>
- Add id_mode config (sequential|hash), defaults to sequential
- Update CreateIssue/CreateIssues to check id_mode and generate appropriate IDs
- Implement lazy counter initialization from existing issues
- Update migrate --to-hash-ids to set id_mode=hash after migration
- Fix hash ID tests to set id_mode=hash
- Fix renumber test to use explicit IDs
- All 183 test packages pass
This makes hash IDs backward-compatible opt-in rather than forced default.
- Added CanonicalDatabaseName constant (beads.db) and LegacyDatabaseNames list
- Updated bd init to use canonical name via constant
- Added daemon validation to reject non-canonical database names
- Updated bd migrate to use canonical name constant
- Enhanced FindDatabasePath to warn when using legacy database names
- All database discovery now prefers beads.db with backward compatibility
Closes bd-165
- Implement bd migrate command with detection, version checking, and cleanup
- Update daemon to suggest bd migrate for version mismatches
- Enhance CLI version warnings to recommend bd migrate
- Add comprehensive tests for migration scenarios
- Document migration workflow in QUICKSTART.md and AGENTS.md
Completes bd-164 and epic bd-159
Amp-Thread-ID: https://ampcode.com/threads/T-34ea4682-8c48-44c2-8421-dc40f867773b
Co-authored-by: Amp <amp@ampcode.com>