Commit graph

20 commits

Author SHA1 Message Date
matt wilkie
e54bc625fd
fix: correct 'bd config' hints to 'bd config set' in error messages (#3141)
Ten error messages across github, gitlab, and ado commands recommend
'bd config {key} {value}' but the CLI requires the 'set' verb:
'bd config set {key} {value}'.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 10:11:00 -07:00
Harry Miller
d802687869
feat: add --issues flag, push pull subcommands, and --parent port (#2975)
Adds CLI layer for selective sync on top of #2957:
- --issues flag registered on all 6 tracker sync commands via shared helpers
- New push/pull subcommands with --dry-run support
- --parent flag ported from Linear-only to ADO, Jira, GitHub, GitLab

Co-authored-by: Harry <harry_miller@trimble.com>
2026-04-05 22:27:46 -07:00
beads/crew/emma
29531d2b68 feat: GitLab sync — dedup fixes, type filtering, epic→milestone mapping, work item hierarchy (#2889)
- Fix pull dedup: check wisps table and match work_items URLs
- Add type-based filtering to GitLab sync CLI
- Default-exclude molecule/message/event types from push
- Fix source_system update that breaks external_ref persistence
- Map all beads statuses to GitLab scoped labels for board columns
- Handle status::review and status::done labels on pull
- Map epic beads to GitLab milestones instead of issues
- Create task beads as GitLab Task work items with parent hierarchy
- Walk parent chain to find epic milestone, use API ID not IID

Co-authored-by: ktoulgaridis <ktoulg@gmail.com>

Executed-By: beads/crew/emma
2026-04-02 20:58:25 -07:00
Kyriakos Toulgaridis
9dc3264663
feat: add optional group-level GitLab issue sync (PR #2801)
* feat: add optional group-level GitLab issue sync (be-711)

When gitlab.group_id is configured, FetchIssues and FetchIssuesSince
use the /groups/:id/issues API endpoint to aggregate issues across all
projects in the group. Issue creation still uses the project endpoint
(via gitlab.project_id or gitlab.default_project_id).

New config keys:
- gitlab.group_id / GITLAB_GROUP_ID
- gitlab.default_project_id / GITLAB_DEFAULT_PROJECT_ID

Backward compatible: existing project-level sync is unchanged when
group_id is not set.

* feat: add filtering support to GitLab group sync (be-4js)

Add optional filters for labels, project, milestone, and assignee to
the GitLab issue sync. Filters work on both project and group endpoints.

Filters can be set via config (gitlab.filter_labels, etc.), environment
variables (GITLAB_FILTER_LABELS, etc.), or CLI flags (--label, --project,
--milestone, --assignee). CLI flags override config defaults.

Labels, milestone, and assignee are passed as GitLab API query params.
Project filtering within a group is done client-side since the GitLab
group issues API doesn't support it natively.
2026-03-26 19:31:45 -07:00
emma
3af3ea1505 fix(cmd/bd): preserve repo config when reopening stores by path (PR #2628)
Several helper paths (list, completions, github, gitlab, linear) reopen
Dolt with only a raw path when the global store is nil. This loses
repo-local metadata like custom dolt_database names and server ports,
falling back to the wrong database or port.

Add a shared openReadOnlyStoreForDBPath() helper that maps dbPath back
to its owning .beads dir and reopens with full metadata. Also fix port
resolution in applyConfigDefaults to use BeadsDir (the .beads/ config
directory) instead of Path (the dolt data directory).

Fixes #2627

Co-Authored-By: Gary <gary@algorune.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 13:57:10 -07:00
beads/crew/emma
8386380437 fix: YAML config prefix takes precedence over DB in shared-server mode (GH#2469)
In shared-server mode, the DB issue_prefix belongs to whichever project
initialized first. This caused all projects sharing a server to use the
wrong prefix for issue creation, ID generation, and imports.

Fix: YAML config.yaml issue-prefix now takes precedence over the DB value
in create.go, github.go, gitlab.go, linear.go, orphans.go, and merge_slot.go
(which already had the correct pattern).

Also: EnsureRunning() now calls KillStaleServers() before starting a new
server, cleaning up orphaned dolt sql-server processes that accumulate when
parent processes crash without graceful shutdown (GH#2372).

Also: add cross-project data isolation tests (5 tests covering read isolation,
port collision, same-prefix isolation, concurrent writes, and concurrent
read-write mix). Based on tests by @PabloLION (PR #2472).

Co-Authored-By: PabloLION <dev@pablolion.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:18:19 -07:00
beads/crew/lizzy
9abb7dd5d9 refactor(dolt): remove vestigial embedded-mode artifacts
- Remove Config.ServerMode and Config.OpenTimeout fields (dead since embedded removal)
- Rewrite doctor/dolt.go to use MySQL protocol instead of embedded dolthub/driver
- Rename openDoltDBWithLock to openDoltConn, remove closeDoltDB helpers
- Delete dolt_nocgo.go stubs (doctor + store_nocgo_test.go)
- Remove cgo build tags from doctor package
- Update lock error messages for server-only world
- Clean up unused lockTimeout parameter threading in list.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 17:33:59 -08:00
beads/crew/emma
5ffd625b40 refactor: Phase 8 CLI & config cleanup - remove SQLite/daemon remnants (dolt-1s40.8)
Remove all vestiges of the SQLite backend, daemon system, and JSONL auto-sync
from CLI flags, config keys, doctor checks, init flows, and the bd backend command.

Key changes:
- Delete bd backend command and tests (backend selection obsolete)
- Remove --backend, --skip-merge-driver flags from bd init
- Remove --lock-timeout flag from main; use fixed 30s default
- Remove deprecated config keys: no-daemon, no-auto-flush, no-auto-import,
  auto-start-daemon, lock-timeout, daemon.* keys
- Remove auto-sync daemon setup wizard (Step 4) from bd init --team
- Clean up doctor checks: remove SQLite mtime divergence check, SQLite-only
  migrations, obsolete boolean config validation
- Replace all "bd init --backend dolt" references with "bd init"
- Simplify storage/dolt/open.go to always create Dolt store
- Change configfile.GetBackend() default from SQLite to Dolt
- Fix pre-existing build errors: AsVersioned removal, duplicate imports,
  missing compact/dirty stubs, signature mismatches, undefined functions

Also adds bridge/stub files for functions removed in prior phases:
- sync_bridge.go: exportToJSONL, importFromJSONL, doSyncFromMain, etc.
- import_shared.go: ImportOptions, ImportResult, importIssuesCore
- stubs.go: findJSONLPath, clearAutoFlushState, readFromGitRef
- dolt/compact.go, dolt/dirty_issues.go: no-op method stubs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 15:43:11 -08:00
beads/crew/emma
12f9037d87 refactor: replace factory/memory imports with direct dolt calls (Phase 7 cleanup)
Phase 7 (a5da57e3) deleted internal/storage/factory/ and internal/storage/memory/
but left 30+ files still importing them. This commit fixes all broken references:

- Created internal/storage/dolt/open.go with NewFromConfig/NewFromConfigWithOptions
- Replaced all factory.New/NewFromConfig/NewWithOptions with dolt equivalents
- Broke import cycles in dolt/bootstrap.go (routing/utils/audit → local types)
- Removed dead storage.Config struct
- Converted all test files from memory.New() to dolt.New() test stores
- Removed tests that depended on deleted detectPrefix/LoadFromIssues/mockRemoteStore

46 files changed, 249 insertions(+), 851 deletions(-)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 13:22:06 -08:00
beads/crew/emma
5a5407fafe refactor: wire Linear/GitLab CLI through SyncEngine, delete duplicated sync code
Phase 4 of the tracker engine migration. Rewrites `bd linear sync` and
`bd gitlab sync` to use the shared tracker.Engine instead of bespoke
pull/push/conflict-detection functions.

- Rewrite runLinearSync: create tracker → set hooks → Engine.Sync()
- Add buildLinearPullHooks (hash-based ID generation with collision avoidance)
- Add buildLinearPushHooks (FormatDescription, ContentEqual, StateCache, ShouldPush)
- Add BuildStateCacheFromTracker to internal/linear for CLI hook access
- Rewrite runGitLabSync: create tracker → set hooks → Engine.Sync()
- Add buildGitLabPullHooks (timestamp-counter-random ID generation)
- Add conflict-aware pull to Engine (skip locally-modified issues when prefer-local)
- Delete linear_sync.go (419 lines), linear_conflict.go (191 lines), gitlab_sync.go (563 lines)
- Remove tests for deleted sync functions (covered by engine_test.go)
- Keep utility function tests (generateIssueID, parseGitLabSourceSystem, getConflictStrategy)

Net: -2077 lines. CLI is now thin: parse flags, create tracker, call Engine.Sync().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 17:29:05 -08:00
collins
237f47ba7e feat: delete SQLite storage backend (Phase 2 of Dolt transition)
Remove the entire internal/storage/sqlite/ package (~43K lines) and update
all 80+ files that imported it to use either the Dolt backend directly
(test files) or the storage factory (production files).

Key changes:
- Delete internal/storage/sqlite/ directory (150+ files)
- Update factory to make Dolt the sole backend, treating "sqlite" as alias for "dolt"
- Replace sqlite.New() calls with dolt.New() in tests, factory.New() in production
- Replace *sqlite.SQLiteStorage with storage.Storage interface throughout
- Replace :memory: SQLite URIs with t.TempDir() for Dolt compatibility
- Inline sqlite.GenerateIssueID() as SHA-256 content hashing where needed
- Fix import cycle in routing/routes.go (routing→factory→dolt→routing)
- Preserve backward-compatible beads.NewSQLiteStorage() wrapper in public API

228 files changed, 605 insertions, 43,821 deletions.
go vet ./... passes clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 12:23:15 -08:00
beads/crew/lizzy
2bb827facb style: run gofmt across entire codebase (bd-nmk12)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:35:20 -08:00
obsidian
ed71a9abc6 fix: remove unused source return value from getGitLabConfigValue (unparam)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
2026-02-02 18:16:21 -07:00
obsidian
c2f3d46eda fix: resolve errcheck violations in cmd/bd/gitlab.go and gitlab_sync.go
Add explicit `_, _ =` assignments to suppress golangci-lint errcheck
findings for fmt.Fprintln/Fprintf return values (status output to
cmd.OutOrStdout()) and crypto/rand.Read (always returns nil on
supported platforms).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
2026-02-02 10:29:39 -07:00
beads/crew/emma
96a28eefaa fix(gitlab): address PR review findings for merge readiness
- Add wrapper functions (doPullFromGitLab, doPushToGitLab,
  detectGitLabConflicts) so integration tests compile
- Change IssueConversion.Issue from interface{} to *types.Issue
  (new package, no backwards compat needed); remove GetIssue() helper
- Replace raw http.Client in runGitLabProjects with gitlab.Client
  method (ListProjects), getting retry/auth logic for free
- Add HTTPS validation on GitLab URL to prevent sending tokens
  in cleartext (allows localhost for dev/testing)
- Add io.LimitReader (50MB) to client.go doRequest to prevent OOM
- Improve token masking: show only first 4 chars, not first+last 4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:07:10 -08:00
Ramos
8604c5ec18 fix(gitlab): address code review round 3 feedback
Changes based on PR #1290 code review:

1. Wire up SyncContext in runGitLabSync - SyncContext was created
   but not actually used in the main entry point

2. Delete legacy non-WithContext functions - removes code duplication
   and eliminates dead code maintenance burden. All sync operations
   now use WithContext variants exclusively

3. Fix --prefer-local behavior - conflicting issues now go to
   forceUpdateIDs (to force push) instead of skipUpdateIDs. This
   ensures local changes actually win when that strategy is selected

4. Document conflict detection 1-second tolerance - explains the
   timestamp comparison window and its limitations for clock skew

5. Document UUID alternative for ID generation - notes that
   distributed deployments may need UUIDs instead of the current
   timestamp+counter+random approach

Test updates:
- All tests now use WithContext functions
- Removed global store manipulation from tests
- All 18 GitLab tests pass

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:48 -08:00
Ramos
a90720395f fix(gitlab): P0 - conflict detection before push and SyncContext
P0 #1: Conflict detection now happens BEFORE push to prevent data loss.
Previously: Pull -> Push -> Detect conflicts (wrong - conflicts overwritten)
Now: Pull -> Detect conflicts -> Push (skip conflicting issues)

P0 #2: Added SyncContext struct for thread-safe sync operations.
- SyncContext holds store, actor, dbPath, issueIDCounter
- WithContext variants of all sync functions
- globalContextIDCounter for cross-context uniqueness
- Enables concurrent sync operations without race conditions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:46 -08:00
Ramos
1f5cb9f8fc Implement conflict resolution strategies (Issue #8)
Add --prefer-local, --prefer-gitlab, and --prefer-newer flags to bd gitlab sync:
- --prefer-local: Always keep local beads version on conflict
- --prefer-gitlab: Always use GitLab version on conflict
- --prefer-newer: Use most recently updated version (default)

Features:
- Unified resolveGitLabConflicts() function with strategy parameter
- Flag validation (only one conflict strategy allowed)
- Automatic conflict detection and resolution in bidirectional sync
- 7 new tests for conflict resolution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:45 -08:00
Ramos
7af8153b43 Implement GitLab sync (Issue #7): pull, push, conflict detection
Added gitlab_sync.go with full sync implementation:
- doPullFromGitLab: imports GitLab issues to beads with incremental sync
- doPushToGitLab: creates/updates GitLab issues from local beads issues
- detectGitLabConflicts: finds issues modified on both sides since last sync
- resolveGitLabConflictsByTimestamp: resolves conflicts using newer-wins
- parseGitLabSourceSystem: parses "gitlab:projectID:iid" format

Updated gitlab.go:
- runGitLabSync now uses sync functions with --pull-only/--push-only flags
- Added proper error handling and progress output

8 new tests in gitlab_sync_test.go, all passing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:44 -08:00
Ramos
04b34b25a0 Add bd gitlab command with sync, status, projects subcommands
Implements Issue #7 from the beads GitLab backend epic.

Features:
- bd gitlab status: Show GitLab configuration and sync status
- bd gitlab sync: Sync issues with GitLab (--dry-run, --pull-only, --push-only)
- bd gitlab projects: List accessible GitLab projects

Configuration via bd config or environment variables:
- gitlab.url / GITLAB_URL
- gitlab.token / GITLAB_TOKEN
- gitlab.project_id / GITLAB_PROJECT_ID

Tests: 6 passing tests for config, validation, and command registration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:43 -08:00