Fixes#118 - Users can now initialize databases outside project directory
Changes:
- Check BEADS_DB env var in init command (PersistentPreRun skipped for init)
- Use global dbPath from --db flag or BEADS_DB, else default to .beads/{prefix}.db
- Use canonical path comparison (filepath.Abs + Clean) instead of strings.Contains
- Only create .beads/ directory when database is actually local
- Ensure parent directory exists for custom database paths
- Add comprehensive tests for --db flag, BEADS_DB env var, and edge cases
- Fix test isolation by resetting global dbPath in test setup
Tests:
- Custom path with --db flag
- Custom path with BEADS_DB env var
- Custom path containing ".beads" substring (prevents false positive)
- Flag precedence over env var
- All existing tests still pass
Amp-Thread-ID: https://ampcode.com/threads/T-04e2c94f-894a-4b49-8132-980450b2300d
Co-authored-by: Amp <amp@ampcode.com>