Skip to content

feat: enhance migration with Dolt support and comment mapping#4

Open
greghughespdx wants to merge 3 commits intojayminwest:mainfrom
greghughespdx:feat/migrate-dolt-comments
Open

feat: enhance migration with Dolt support and comment mapping#4
greghughespdx wants to merge 3 commits intojayminwest:mainfrom
greghughespdx:feat/migrate-dolt-comments

Conversation

@greghughespdx
Copy link
Copy Markdown

Summary

  • sd migrate-from-beads now supports Dolt-based beads installations (v0.55+) in addition to legacy JSONL
  • Comments are mapped during migration (beads text field to seeds body field)

Context

Beads v0.55+ moved from JSONL storage to Dolt, making the existing JSONL-only migration path unreachable for modern installations. This adds automatic detection: if .beads/issues.jsonl exists, it reads from that (legacy path). If only .beads/ directory exists and the bd CLI is available, it shells out to bd list --json and bd show --json to extract all issues with comments.

Changes

  • src/commands/migrate.ts: Added loadFromDolt() function, BeadsComment interface, comment mapping in mapBeadsIssue(), auto-detection of data source, source label in output

Dependencies

Depends on PR #3 (comment support) for the IssueComment type.

Test plan

  • Tested Dolt path against real beads data (37 issues, 8 comments migrated)
  • Tested JSONL path against exported data (37 issues, 8 comments migrated)
  • Cross-checked issue counts against beads (15 open, 22 closed match exactly)
  • Full test suite passes (209 tests, 0 failures)
  • Lint and typecheck clean

Adds issue comment management with add, list, and delete subcommands.
Comments are stored inline on the issue object in JSONL, keeping the
git-native single-file approach. Includes 15 integration tests covering
CRUD operations, error paths, and SEEDS_AUTHOR env var fallback.

- IssueComment type added to types.ts
- Comment rendering in sd show output
- Full Commander registration with --json and --author flags
- CLI reference updated in CLAUDE.md
@greghughespdx greghughespdx marked this pull request as ready for review March 2, 2026 04:00
@jayminwest
Copy link
Copy Markdown
Owner

Thanks for tackling the Dolt migration path! The auto-detection fallback (JSONL -> Dolt -> error) is a clean design. A few things to sort out:

Must fix:

  1. Overlapping commits with PR feat: add comment support (sd comment add/list/delete) #3 -- This PR includes the full comment feature as its first commit, which duplicates PR feat: add comment support (sd comment add/list/delete) #3. Please rebase so this PR only contains the migration/Dolt changes and targets the branch from PR feat: add comment support (sd comment add/list/delete) #3 (or main after feat: add comment support (sd comment add/list/delete) #3 merges). We'll merge feat: add comment support (sd comment add/list/delete) #3 first.

  2. Wrap bd output parsing in try/catch (migrate.ts:95-106) -- JSON.parse on bd list --json output will throw an unhelpful error if the output is malformed or if bd doesn't support --json. Add a try/catch with a descriptive message like "Failed to parse bd list output. Is your bd CLI up to date?"

  3. Validate issue IDs from bd before passing to Bun.spawn (migrate.ts:114-127) -- The IDs come from external CLI output. A quick regex check (e.g., confirm they match an expected ID pattern) before passing them as subprocess arguments would be good defensive practice.

Nice to have (non-blocking):

  • The Dolt migration path has no automated tests. Even a basic test with a mock bd script returning known JSON would catch regressions.
  • bd show calls are sequential per issue. For large installations this could be slow. Consider Promise.all with a concurrency limit as a follow-up.

The migrate-from-beads command now supports two data sources:

1. Legacy JSONL: reads .beads/issues.jsonl directly (existing behavior)
2. Dolt (bd CLI): when .beads/ exists but no JSONL file, shells out to
   bd list/show --json to extract issues including comments

Beads v0.55+ moved from JSONL to Dolt storage, making the JSONL path
unreachable for modern installations. The Dolt path auto-detects when
the bd CLI is available and extracts all open and closed issues with
full comment history.

Also maps beads comments (text field) to seeds comments (body field)
for both migration paths.
- Wrap JSON.parse calls on bd list --json output in try/catch with a
  descriptive error message prompting users to check their bd CLI version
- Validate issue IDs from bd CLI output against an alphanumeric+hyphen
  pattern before passing them as subprocess arguments to Bun.spawn;
  warn and skip any IDs that do not match
@greghughespdx greghughespdx force-pushed the feat/migrate-dolt-comments branch from bfbe963 to 06f1580 Compare March 4, 2026 21:27
@greghughespdx
Copy link
Copy Markdown
Author

greghughespdx commented Mar 4, 2026

Will watch for PR #3 merge and then complete rebase for #4.

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.

2 participants