Commit graph

37 commits

Author SHA1 Message Date
Jozef Izso
42064c46fe
Sync Linear milestones as local epics (#3528) 2026-05-05 07:45:30 -07:00
matt wilkie
890950f388
Merge pull request #3661 from kevglynn/pr3-oauth-client-credentials
feat(linear): OAuth client-credentials support for service identity
2026-05-02 19:31:14 -07:00
maphew
425ae20683 Merge main into OAuth client credentials branch 2026-05-02 19:14:05 -07:00
maphew
f4a1a211df Merge main into staleness signal branch 2026-05-02 19:09:01 -07:00
matt wilkie
9c41669cf4
Merge pull request #3657 from kevglynn/feat/linear-sync-concurrency-lock
feat(linear): add per-workspace concurrency lock on sync
2026-05-02 19:05:23 -07:00
maphew
cb1a0700b0 fix(linear): clean sync lock lint 2026-05-02 18:38:36 -07:00
maphew
dc4cd8b649 fix(linear): clean rate-limit lint 2026-05-02 18:38:36 -07:00
kev
6584ff8f8f feat(linear): add ambient staleness signal for auto-fresh data
Add staleness detection so agents and devs automatically get fresh
Linear data without retry infrastructure.

- New staleness library (internal/linear/staleness.go): WriteLastPull,
  ReadLastPull, IsPullStale, IsWithinDebounce, GetStalenessInfo
- --pull-if-stale flag on bd linear sync with configurable --threshold
  (default 20m) and 5-minute debounce to prevent agent loops
- bd prime auto-pulls when stale and LINEAR_API_KEY is set
- Per-session stderr warning on any bd command when data is stale
- 14 new tests covering all staleness functions

Design validated by three adversarial reviewers (architecture,
performance, agent-native). Morning storm (50 devs) = 1% of rate
limits. Scales to 500 devs safely.

Refs: PLAN.md d16, btl-seo
2026-05-02 20:08:33 -04:00
kev
46584d8222 fix(linear): address maintainer feedback on OAuth client-credentials PR
OAuth-only sync path (no LINEAR_API_KEY required):
- Tracker.Init() now checks for OAuth credentials first
  (LINEAR_OAUTH_CLIENT_ID + LINEAR_OAUTH_CLIENT_SECRET), constructs
  NewOAuthClient per team when present, and only falls back to API key
  when OAuth is absent. Missing both is a clear error naming both options.

Lint fixes:
- oauth.go: add //nolint:gosec on DefaultOAuthTokenURL (G101 false
  positive — URL path component, not a credential)
- oauth.go: change defer resp.Body.Close() to
  defer func() { _ = resp.Body.Close() }() to satisfy errcheck
- .golangci.yml: add unparam exclusion for getLinearConfig (ctx param
  kept for context propagation)

Docs/code precedence alignment:
- getLinearConfig: env vars now take precedence over config.yaml for
  yaml-only keys (was reversed). Matches documented precedence:
  OAuth > LINEAR_API_KEY > config file.

Tests:
- TestTrackerInitOAuthOnly: validates OAuth client construction without
  API key
- TestTrackerInitNoAuthFails: validates error message when no auth
  configured
2026-05-02 19:04:20 -04:00
kev
3e804cd39f fix(linear): address maintainer feedback on PR #3655
- Format types.go (struct field alignment was off by one space)
- parseRetryAfter: use http.ParseTime for HTTP-date form (RFC 1123 /
  RFC 850 / ANSI C) instead of time.Parse(time.RFC1123) — the latter
  requires an exact timezone abbreviation while http.ParseTime accepts
  the canonical GMT form mandated by RFC 9110 §10.2.3
- Add MaxRetryAfterDelay (300s) cap on server-provided Retry-After
  delays; log a warning to stderr and clamp when the hint exceeds the cap
- Wire linear.rate_limit_floor / LINEAR_RATE_LIMIT_FLOOR through both
  Tracker.Init() and getLinearClient() so the config key is functional
  via `bd config set linear.rate_limit_floor <n>` and the env var
- ErrRateLimitExhausted now implements RateLimitExhausted() bool;
  engine.go uses an interface check (no import cycle) to abort the
  push loop immediately on quota exhaustion instead of cascading the
  error across every remaining issue
- Tests: extend TestParseRetryAfter with HTTP-date future/past cases;
  add TestExecute_RetryAfterCapApplied to confirm the cap path is taken
2026-05-02 19:00:25 -04:00
kev
097ed1cf16 feat(linear): add OAuth client-credentials support
Add OAuthTokenManager for machine-to-machine authentication using
Linear's client_credentials grant. This enables CI workers to use a
service identity (actor=application) instead of personal API keys.

Key changes:
- New OAuthTokenManager with lazy acquisition, caching, thread-safe
  refresh (5-min buffer before expiry), and Invalidate() for 401 retry
- AuthMode enum (APIKey vs OAuth) on Client with appropriate header
  format: API keys use "Authorization: <key>", OAuth uses "Bearer"
- NewOAuthClient() constructor and WithOAuth() option
- 401 auto-retry: invalidate token and re-acquire on first 401
- Auth precedence: LINEAR_OAUTH_CLIENT_ID/SECRET env vars >
  LINEAR_API_KEY env var > bd config
- Mark oauth_client_secret as secret key (uses IsSecretKey from PR-1)
- 12 new tests covering acquisition, caching, refresh, invalidation,
  error handling, thread safety, and header format

Validated against Linear sandbox: client_credentials grant works with
scope=read,write, actor=application gives bot identity, 30-day TTL.

Refs: gastownhall/beads integration charter, PLAN.md §6 PR-3
2026-05-02 09:35:08 -04:00
kev
989d0f9496 feat(linear): add per-workspace concurrency lock on sync
Acquires .beads/.linear-sync.lock at start of bd linear sync to
serialize concurrent invocations. Stale lock detection via PID
check. Clean release on SIGTERM via defer. Prevents duplicate
creates and conflict thrash from overlapping sync runs.
2026-05-02 01:02:55 -04:00
matt wilkie
3e56f0b214
Document Linear external_ref pre-linking (#3517)
* Document Linear external ref prelinking (bd-ly3)
* Fix Linear sync dependency graph handling
* Fix init remote clone routing
* Fix stale gate help text
* Fix init remote cherry-pick integration
* Fix init remote flag handling
* Fix Linear prelink hydration blockers
* Fix Linear relation dependency gating
* Fix ready list parent filtering
* Deduplicate dry-run dependency previews by stored identity
2026-04-27 06:05:30 -07:00
matt wilkie
2f60a10fc5
Import Linear relations as dependencies (#3519)
* Fix gate and cook regressions (bd-r2l)

* Import Linear relations as dependencies (bd-ly3)
2026-04-26 20:30:02 -07:00
matt wilkie
c446a2ef09
fix(linear): harden push against data clobbering (#3328)
Closes #3289, #3309, #3252, #3253 — hardens Linear push: requires explicit linear.state_map.* config, rejects ambiguous state resolution, narrows push dedup to pushable fields, blocks unscoped project-filtered push from creating unlinked beads, and adds regression test for the orphan-ownership rule (parent-filtered push must not update external issues Beads hasn't claimed via external_ref).
2026-04-18 08:36:13 -07:00
matt wilkie
64678bcb34
fix: show diverged-history guidance on auto-push failure (#3138)
* fix: show diverged-history guidance on auto-push failure

When dolt auto-push fails with a 'no common ancestor' error, the user
only sees a cryptic warning. The explicit 'bd dolt push' and 'bd dolt
pull' commands already detect this and print recovery guidance via
printDivergedHistoryGuidance(), but the auto-push path did not.

Now auto-push also calls isDivergedHistoryErr() and prints the same
actionable recovery options (bootstrap, force-push, or re-init).

Amp-Thread-ID: https://ampcode.com/threads/T-019d6ee7-e46d-74f8-8b6e-2a0fc1b2d4d7
Co-authored-by: Amp <amp@ampcode.com>

* fix: store secret config keys in config.yaml, not Dolt DB

Keys like github.token and linear.api_key were stored in the Dolt
database's config table. When auto-push sends that data to a GitHub
remote, GitHub's push protection blocks the push because it detects
embedded secrets in the Dolt data files.

Fix: add github.token and linear.api_key to YamlOnlyKeys so they're
written to .beads/config.yaml (local-only, gitignored) instead of
the Dolt database. Update the read paths in getGitHubConfigValue()
and getLinearConfig() to check YAML config first for these keys.

Amp-Thread-ID: https://ampcode.com/threads/T-019d6ee7-e46d-74f8-8b6e-2a0fc1b2d4d7
Co-authored-by: Amp <amp@ampcode.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
2026-04-08 15:55:37 -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
Harry
3ae2ef3a5a feat: multi-project/team support for Linear, Jira, and ADO
Add support for syncing issues across multiple projects/teams in all
three tracker integrations, with shared infrastructure to avoid
duplicating logic.

Shared infrastructure (internal/tracker/multiproject.go):
- ParseCommaSeparated: splits comma-separated config values
- DeduplicateStrings: removes duplicates preserving order
- ResolveProjectIDs: config precedence (CLI > plural > singular)

Linear (closes #2791):
- Tracker: map[string]*Client with per-team routing
- FetchIssues iterates all teams, deduplicates by issue ID
- UpdateIssue routes to owning team via FetchIssueByIdentifier
- Config: linear.team_ids / LINEAR_TEAM_IDS + --team flag

Jira:
- projectKey string → projectKeys []string
- FetchIssues uses JQL IN clause (single query, no iteration)
- Config: jira.projects / JIRA_PROJECTS + --project flag

ADO:
- project string → projects []string
- WIQL uses TeamProject IN clause (single query)
- Config: ado.projects / AZURE_DEVOPS_PROJECTS + --project flag

All singular config keys remain supported for backward compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-28 13:40:39 -07:00
gregorycollins-usmobile
5297286bb2
feat(linear): add --parent flag to limit sync push to a ticket tree (PR #2853)
* feat(linear): add --parent flag to limit sync push to a ticket tree

Adds --parent=TICKET to bd linear sync --push, restricting the push
to the named beads ticket and all its transitive descendants via
parent-child dependencies.

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

* test(tracker): add tests for ParentID push filter

Six cases: basic parent+children, deep transitive descendants,
leaf with no children, non-parent-child edges not followed,
empty ParentID pushes all, dry-run with parent filter.

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 19:30:42 -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/wickham
4102096666 refactor: standardize error handling with FatalError wrappers (bd-qioh)
Convert ~250 instances of direct fmt.Fprintf(os.Stderr)+os.Exit(1)
to FatalError/FatalErrorWithHint/FatalErrorRespectJSON across 54 files.

Complex multi-line messages, warnings, loop-internal errors, and
JSON-branching patterns intentionally preserved where the helpers
do not fit cleanly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 16:27:09 -08:00
beads/crew/emma
ff0b469154 chore: Clean up stale daemon references in code comments and doctor messages
Update comments and user-facing messages across 17 production files to
reflect the current Dolt-native architecture (no daemon):

- Gitignore template: reorganized, daemon/SQLite entries moved to legacy section
- Doctor fix messages: removed references to non-existent bd daemon commands
- Doctor federation: updated fix suggestions to use gt dolt start / server mode
- Doctor integrity: removed "daemon won't start" messaging
- Code comments: replaced daemon mode references with current architecture terms
- Lock handling: marked daemon.lock as legacy cleanup

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-16 19:25:17 -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
7eed8b8a1e refactor: remove tombstone/soft-delete system (Phase 4)
Remove the tombstone soft-delete mechanism across the codebase. Dolt handles
delete propagation natively, making tombstones obsolete.

Key changes:
- Remove StatusTombstone constant and all status checks
- Remove DeletedAt/DeletedBy/DeleteReason/OriginalType fields from Issue struct
- Remove resurrection mechanism (JSONL parent recovery), replace with existence checks
- Simplify schema CHECK constraint (2 clauses instead of 3)
- Remove compact_tombstone.go, resurrection.go, migrate_tombstones.go
- Remove tombstone-specific tests (resurrection, expired tombstones, migration)
- Update doctor/fix validation to skip tombstone-specific checks
- Preserve migration files for backward compatibility with existing databases
- 104 files changed, 6117 deletions, 422 insertions

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 21:22:24 -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
jasper
619f34a441 chore: add explanatory comments to silently ignored errors across codebase
Code health review found 30+ instances of error suppression using blank
identifier without explanation. Added comments to 82 files explaining WHY
each error is safely ignored (best-effort cleanup, advisory operations,
safe defaults, etc.) to improve code maintainability.

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

Executed-By: beads/polecats/jasper
Rig: beads
Role: polecats
2026-02-14 17:16:43 -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
chrismilleruk
d8f5e1f1fc
fix(linear): exclude ephemeral issues from sync push by default (#1397)
Related to #1204, #1205. Linear sync was including local-only ephemeral beads (wisps, etc.), causing noise. We now exclude them by default using the `ephemeral` field.

- Exclude ephemeral issues from push to Linear by default.
- Add `--include-ephemeral` flag to override when needed.
2026-01-30 22:18:48 -08:00
Zachary Piazza
ee44498659
feat(linear): add --type and --exclude-type flags for sync filtering (#1205)
* feat(linear): add --type and --exclude-type flags for sync filtering

Add type filtering support to `bd linear sync --push` to allow users to
control which issue types are synced to Linear.

New flags:
- --type: Only sync issues matching these types (e.g., --type=task,feature)
- --exclude-type: Exclude issues of these types (e.g., --exclude-type=wisp)

Use cases:
- Sync only work items (tasks, features, bugs) while excluding internal
  telemetry (wisps, messages)
- Push only specific issue types to Linear

Fixes #1204

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

* fix(linear): update test to match new doPushToLinear signature

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 14:05:48 -08:00
Paddo
5254ade346
feat(linear): add project_id filter for sync (#938)
Add project_id filter for Linear sync

When linear.project_id is configured, bd linear sync will only fetch issues
belonging to that project instead of all team issues.

Closes #937
2026-01-07 20:45:00 -08:00
Steve Yegge
6c14fd2225 refactor: Split large cmd/bd files to meet 800-line limit (bd-xtf5)
Split 6 files exceeding 800 lines by extracting cohesive function groups:

- show.go (1592→578): extracted show_thread.go, close.go, edit.go, update.go
- doctor.go (1295→690): extracted doctor_fix.go, doctor_health.go, doctor_pollution.go
- sync.go (1201→749): extracted sync_git.go
- compact.go (1199→775): extracted compact_tombstone.go, compact_rpc.go
- linear.go (1190→641): extracted linear_sync.go, linear_conflict.go
- main.go (1148→800): extracted main_help.go, main_errors.go, main_daemon.go

All files now under 800-line acceptance criteria.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 18:43:09 -08:00
Ryan Snodgrass
acfdcebc0f
fix: misc improvements and dependency updates
- Update nix vendorHash after fatih/color removal
- Bump version to 0.30.7
- Add GroupID to remaining commands for proper cobra grouping
- Apply semantic color rendering to list and stale commands
- Update pre-commit hook template
2025-12-20 17:09:50 -08:00
Justin Williams
df5ceb5d82
feat: Linear Integration (#655)
* Add Linear integration CLI with sync and status commands

- Add `bd linear sync` for bidirectional issue sync with Linear
- Add `bd linear status` to show configuration and sync state
- Stub pull/push functions pending GraphQL client (bd-b6b.2)

* Implement Linear GraphQL client with full sync support

- Add LinearClient with auth, fetch, create, update methods
- Implement pull/push operations with Beads type mapping
- Clean up redundant comments and remove unused code

* Add configurable data mapping and dependency sync for Linear

- Add LinearMappingConfig with configurable priority/state/label/relation maps
- Import parent-child and issue relations as Beads dependencies
- Support custom workflow states via linear.state_map.* config

* Add incremental sync support for Linear integration

- Add FetchIssuesSince() method using updatedAt filter in GraphQL
- Check linear.last_sync config to enable incremental pulls
- Track sync mode (incremental vs full) in LinearPullStats

* feat(linear): implement push updates for existing Linear issues

Add FetchIssueByIdentifier method to retrieve single issues by identifier
(e.g., "TEAM-123") for timestamp comparison during push.

Update doPushToLinear to:
- Fetch Linear issue to get internal ID and UpdatedAt timestamp
- Compare timestamps: only update if local is newer
- Build update payload with title, description, priority, and state
- Call UpdateIssue for issues where local has newer changes

Closes bd-b6b.5

* Implement Linear conflict resolution strategies

- Add true conflict detection by fetching Linear timestamps via API
- Implement --prefer-linear resolution (re-import from Linear)
- Implement timestamp-based resolution (newer wins as default)
- Fix linter issues: handle resp.Body.Close() and remove unused error return

* Add Linear integration tests and documentation

- Add comprehensive unit tests for Linear mapping (priority, state, labels, relations)
- Update docs/CONFIG.md with Linear configuration reference
- Add examples/linear-workflow guide for bidirectional sync
- Remove AI section header comments from tests

* Fix Linear GraphQL filter construction and improve test coverage

- Refactor filter handling to combine team ID into main filter object
- Add test for duplicate issue relation mapping
- Add HTTP round-trip helper for testing request payload validation

* Refactor Linear queries to use shared constant and add UUID validation

- Extract linearIssuesQuery to deduplicate FetchIssues/FetchIssuesSince
- Add linearMaxPageSize constant and UUID validation with regex
- Expand test coverage for new functionality

* Refactor Linear integration into internal/linear package

- Extract types, client, and mapping logic from cmd/bd/linear.go
- Create internal/linear/ package for better code organization
- Update tests to work with new package structure

* Add linear teams command to list available teams

- Add FetchTeams GraphQL query to Linear client
- Refactor config reading to support daemon mode
- Add tests for teams listing functionality

* Refactor Linear config to use getLinearConfig helper

- Consolidate config/env var lookup using getLinearConfig function
- Add LINEAR_TEAM_ID environment variable support
- Update error messages to include env var configuration options

* Add hash ID generation and improve Linear conflict detection

- Add configurable hash ID mode for Linear imports (matches bd/Jira)
- Improve conflict detection with content hash comparison
- Enhance conflict resolution with skip/force update tracking

* Fix test for updated doPushToLinear signature

- Add missing skipUpdateIDs parameter to test call
2025-12-19 17:58:24 -08:00