Commit Graph

3467 Commits

Author SHA1 Message Date
Steve Yegge
f6930eb399 feat(list): add --pinned and --no-pinned filter flags
Add ability to filter issues by their pinned status in bd list command.

- Add pinned column to issues table via migration 023
- Add Pinned field to Issue struct and IssueFilter
- Update all storage layer queries to include pinned column
- Add --pinned flag to show only pinned issues
- Add --no-pinned flag to exclude pinned issues
- Update RPC layer to forward pinned filter to daemon mode
- Add pinned to allowedUpdateFields for bd update support

Resolves: beads-p8e

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 00:46:46 -08:00
Steve Yegge
9dc34da64a fix(storage): add batch ID conflict detection and fix schema indexes
- Add checkForExistingIDs function to detect duplicate IDs within batch
  and conflicts with existing database entries before insert
- Remove thread_id index creation from schema.go since thread_id column
  is added by migration 020_edge_consolidation.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 19:11:50 -08:00
Steve Yegge
2ea1b74f43 Merge beads-sync into main 2025-12-18 18:58:35 -08:00
Steve Yegge
f7c746adb9 feat: auto-protect forks from committing upstream issue database
When bd detects it's running in a fork (origin != steveyegge/beads),
automatically add .beads/issues.jsonl to .git/info/exclude.

This prevents contributors from accidentally including issue database
changes in their PRs. The exclusion is:
- Per-clone (doesn't modify tracked files
- One-time setup (checks if already excluded)
- Silent (only logs in debug mode)

Maintainers (origin = steveyegge/beads) are not affected.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)
2025-12-18 18:56:59 -08:00
Steve Yegge
d2b9554651 bd sync: 2025-12-18 18:33:29 2025-12-18 18:33:29 -08:00
Aarya Reddy
efdfbac504 feat(mcp): consolidate admin tools to reduce token overhead (#634)
Consolidate 6 admin MCP tools into single 'admin' tool with action parameter for 79% token reduction.
2025-12-18 18:32:54 -08:00
Steve Yegge
1f4b55dacb Merge main into fix/ci-errors, resolve graph.go conflict 2025-12-18 18:30:47 -08:00
Andrei Onel
9382aa34fa Update CLI reference with new --body-file options (#627)
Documentation update for --body-file option
2025-12-18 18:25:09 -08:00
Steve Yegge
e0872ebbd0 fix(test): remove incorrect duplicate ID rollback test
The test expected CreateIssues to error on duplicate IDs, but the
implementation uses INSERT OR IGNORE which silently skips duplicates.
This is intentional behavior needed for JSONL import scenarios.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 18:24:28 -08:00
matt wilkie
fb16e504e6 Fix tests (bd-6ss and sub-issues) (#626)
Test coverage improvements for bd-6ss. Fixing failing test assumption in follow-up commit.
2025-12-18 18:23:30 -08:00
Charles P. Cross
5316559cf6 test(graph): add tests for graph utility functions
Add comprehensive tests for the new graph.go functions to meet
coverage threshold after rebase introduced 405 new lines:

- TestTruncateTitle: tests rune-safe title truncation
- TestPadRight: tests rune-safe string padding
- TestRenderNodeBox: tests ASCII box rendering for all status types
- TestComputeLayout: tests topological layout computation with
  dependencies

These tests cover the pure utility functions and basic graph layout
logic, bringing coverage from 44.7% to 45.1%.
2025-12-18 17:56:24 -05:00
Charles P. Cross
2b0a8cecdb fix(lint): mark unused subgraph parameter in renderGraph
The subgraph parameter was passed to renderGraph but not used in the
function body, causing an unparam lint error. Replace with _ to
indicate intentional non-use.
2025-12-18 17:47:03 -05:00
Charles P. Cross
ba8beb53b3 test(coverage): add tests to meet 45% CI threshold
Add comprehensive test coverage for previously untested functions:

internal/debug/debug_test.go:
- TestSetVerbose: tests SetVerbose() and its effect on Enabled()
- TestSetQuietAndIsQuiet: tests SetQuiet() and IsQuiet() functions
- TestPrintNormal: tests quiet mode suppression of normal output
- TestPrintlnNormal: tests quiet mode suppression of println output

internal/export/config_test.go (new file):
- TestLoadConfig: comprehensive tests for LoadConfig() including:
  - Default values when no config exists
  - Loading custom policies (both regular and auto-export)
  - Loading retry attempts, backoff, skip encoding errors, write manifest
  - Handling invalid/malformed config values gracefully

internal/export/policy_test.go:
- TestErrorPolicyString: tests String() method on ErrorPolicy
- TestNewManifest: tests manifest creation with proper defaults
- TestWriteManifest: tests manifest file writing and error handling

These tests bring coverage from 44.8% to 45.0%, meeting the CI threshold.
2025-12-18 17:45:49 -05:00
Charles P. Cross
cb59bb3ec8 fix(ci): resolve lint and test failures
Fix two CI failures that were blocking main:

1. Lint error in cmd/bd/onboard.go:126
   - Unchecked fmt.Fprintf return value
   - Fixed by explicitly ignoring with _, _

2. Test failures in internal/storage/sqlite
   - TestCreateIssues/duplicate_ID_error was passing but
     TestCreateIssuesRollback/rollback_on_conflict_with_existing_ID failed
   - Root cause: CreateIssues used INSERT OR IGNORE which silently
     ignored duplicate IDs instead of returning an error
   - Fixed by adding duplicate ID detection in EnsureIDs():
     a) Check for duplicates within the batch
     b) Check for conflicts with existing database IDs

Both fixes are minimal and targeted to unblock CI.
2025-12-18 17:45:49 -05:00
Steve Yegge
7f9ee3d1c4 fix(graph): traverse all dependency types, not just parent-child
The graph command now shows issues connected via any dependency type
(blocks, parent-child, etc.), not just parent-child relationships.

This makes bd graph useful for epics where children are connected via
blocks dependencies rather than hierarchical parent-child.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 13:51:26 -08:00
Steve Yegge
736389b6b7 bd sync: 2025-12-18 13:47:56 2025-12-18 13:47:56 -08:00
Steve Yegge
a89de1ac8b feat(graph): add bd graph command for ASCII DAG visualization
New command to visualize issue dependency graphs:
- Layered layout (Sugiyama-style) shows execution order
- Status coloring (open/in_progress/blocked/closed)
- Works with epics to show full subgraph
- Layer 0 = ready tasks (no blockers)

Usage: bd graph <issue-id>

Part of bd-r6a workflow system redesign.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 13:47:45 -08:00
Steve Yegge
125e36d529 refactor(onboard): simplify to minimal snippet pointing to bd prime
bd onboard now outputs a ~10 line snippet for AGENTS.md that points to
"bd prime" for full workflow context. This replaces the previous ~200
line static content that:

- Bloated AGENTS.md with instructions that loaded every session
- Got stale when bd was upgraded
- Wasted tokens when beads was not actively being used

The new approach:
- AGENTS.md gets minimal pointer (~20 tokens vs ~2000)
- bd prime provides dynamic, always-current workflow details
- Hooks auto-inject bd prime at session start

Also removes the --output flag for BD_GUIDE.md generation (obsolete).

Closes bd-gxq
Addresses GH#604

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 11:48:02 -08:00
Steve Yegge
acb3bbf7b6 bd sync: 2025-12-18 11:47:46 2025-12-18 11:47:46 -08:00
Steve Yegge
ecd46a6d6e Add tests for Decision 004 Phase 4 thread traversal functions
Tests findRepliesTo() and findReplies() helper functions in cmd/bd/show.go
that traverse message threads via dependencies. Covers:
- 3-message linear thread chain traversal (up and down)
- Thread root finding via repeated findRepliesTo() calls
- Branching threads (one message with multiple replies)
- Empty/standalone messages
- Nonexistent issue IDs
- Verification that only replies-to deps are followed

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 11:30:26 -08:00
Steve Yegge
8b581d6de3 bd sync: 2025-12-18 11:29:45 2025-12-18 11:29:45 -08:00
Steve Yegge
1951a2c5fe bd sync: 2025-12-18 11:28:36 2025-12-18 11:28:36 -08:00
Steve Yegge
6087cd438b fix(storage): race condition when reconnect closes db mid-query (GH#607)
Change reconnectMu from sync.Mutex to sync.RWMutex so read operations
can hold RLock during database access. This prevents reconnect() from
closing the connection while queries are in progress.

- GetIssue and SearchIssues now hold RLock during database operations
- Close() acquires write lock to coordinate with reconnect
- Add TestConcurrentReadsWithReconnect to verify the fix

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 11:28:13 -08:00
Steve Yegge
e0d8abe8c3 Add tests for Decision 004 Phase 4 edge schema consolidation
Tests added:
- TestTransactionAddDependency_RelatesTo: bidirectional relates-to in txn
- TestTransactionAddDependency_RepliesTo: thread_id preserved in txn
- TestRelateCommand: bd relate/unrelate CLI commands
- TestRelateCommandInit: command registration

Provides regression coverage for transaction.go fixes and relates-to behavior.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 11:25:17 -08:00
Steve Yegge
4981e84e86 Fix transaction.go AddDependency to match dependencies.go (Decision 004)
Code review found three issues where transaction.go diverged from the
main dependencies.go implementation:

1. Add relates-to exemption from cycle detection - bidirectional
   relationships are valid and should not trigger cycle errors

2. Add metadata and thread_id fields to INSERT - required for
   replies-to threading to work in transaction context

3. Update error message to match dependencies.go wording

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 11:15:16 -08:00
Steve Yegge
ee3d51fc21 Merge pull request #624 from marcodelpin/fix/schema-probe-dependencies-columns
fix(schema): add metadata and thread_id to dependencies expectedSchema
2025-12-18 11:15:04 -08:00
Steve Yegge
1b332ad10e Merge pull request #620 from qmx/fix-nix-vendor-hash
fix: update nix vendorHash for Go dependencies
2025-12-18 11:15:01 -08:00
Steve Yegge
332c9b9b8f Merge pull request #619 from qmx/add-push-configuration
feat: add no-push config to disable automatic git push
2025-12-18 11:14:56 -08:00
Steve Yegge
5981e6e752 bd sync: 2025-12-18 11:13:50 2025-12-18 11:13:50 -08:00
Steve Yegge
001ae4473f bd sync: 2025-12-18 11:09:54 2025-12-18 11:09:54 -08:00
Steve Yegge
8b0cd1ec66 refactor(import): remove redundant pre-batch deduplication layer
The early ID deduplication in the main loop (seenIDs check) already
prevents duplicate IDs from reaching newIssues. The pre-batch
deduplication was dead code that could never fire.

Keeping two layers:
1. Early dedup in main loop - catches duplicates in JSONL input
2. INSERT OR IGNORE at DB level - safety net for all code paths

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 11:09:26 -08:00
Steve Yegge
075a60f2b4 Merge pull request #625 from marcodelpin/fix/import-dedupe-by-id
fix(import): handle duplicate issue IDs in JSONL files gracefully
2025-12-18 11:08:32 -08:00
Marco Del Pin
973ecfc9e6 fix(lint): resolve golangci-lint errors for clean CI
Fixes 5 linting issues to allow PR checks to pass:
1. hooks.go: Explicitly ignore error in async goroutine
2. 022_drop_edge_columns.go: Handle deferred PRAGMA error
3. flags.go: Add nosec comment for validated file path
4. create_form.go: Fix American spelling (canceled vs cancelled)
5. create_form.go: Explicitly mark cmd parameter as required by cobra
These are pre-existing issues in the codebase, fixed here to
enable clean CI for the import deduplication fix.
🤖 Generated with Claude Code
2025-12-18 20:06:41 +01:00
Marco Del Pin
ef99f0700c fix(lint): resolve golangci-lint errors for clean CI
Fixes 5 linting issues to allow PR checks to pass:
1. hooks.go: Explicitly ignore error in async goroutine
2. 022_drop_edge_columns.go: Handle deferred PRAGMA error
3. flags.go: Add nosec comment for validated file path
4. create_form.go: Fix American spelling (canceled vs cancelled)
5. create_form.go: Explicitly mark cmd parameter as required by cobra
These are pre-existing issues in the codebase, fixed here to
enable clean CI for the schema probe fix.
🤖 Generated with Claude Code
2025-12-18 20:05:13 +01:00
Marco Del Pin
d5e569443d fix(schema): add metadata and thread_id to dependencies expectedSchema
**Problem:**
Schema compatibility probe was failing with "no such column: thread_id"
error when opening databases created before v0.30.5, even after running
migrations. This caused database initialization to fail.
**Root Cause:**
The migration 020_edge_consolidation.go correctly adds the metadata and
thread_id columns to the dependencies table, but schema_probe.go's
expectedSchema map was missing these columns in its validation list.
This caused verifySchemaCompatibility() to fail even though:
1. The columns existed in the actual schema (schema.go:51-52)
2. Migration 020 would add them if missing
3. The database was otherwise valid
**Solution:**
Updated expectedSchema in schema_probe.go to include "metadata" and
"thread_id" in the dependencies table column list. This aligns the schema
probe expectations with the actual schema definition and migration 020
behavior.
**Testing:**
 Tested on 5 databases across version range pre-0.17.5 → v0.30.5
   - All migrations completed successfully
   - Schema probe passes after migration
   - All bd commands work correctly
 No regressions in fresh database initialization
**Impact:**
- Fixes database initialization errors for users upgrading from v0.30.3
- No breaking changes or data migrations required
- Compatible with all existing databases
- Enables smooth migration path for all database versions
Fixes database migration issues reported in v0.30.5 upgrade path.
🤖 Generated with Claude Code
2025-12-18 19:32:26 +01:00
Marco Del Pin
dba9bb91c3 fix(import): handle duplicate issue IDs in JSONL files gracefully
Implements three-layer deduplication strategy to prevent UNIQUE
constraint errors during import:
1. Early deduplication during processing (importer.go)
2. Pre-batch deduplication (importer.go)
3. INSERT OR IGNORE with explicit error handling (issues.go)
**Problem:**
JSONL files with duplicate issue IDs caused import failures:
  Import failed: UNIQUE constraint failed: issues.id
**Root Cause:**
- Go SQLite driver returns errors even with INSERT OR IGNORE
- Only content hash was deduplicated, not IDs
- Multiple code paths affected (insertIssue, insertIssues)
**Solution:**
Layer 1: Early deduplication by ID in upsertIssues (lines 489-502)
Layer 2: Pre-batch deduplication (lines 713-726)
Layer 3: INSERT OR IGNORE + isUniqueConstraintError() helper
**Testing:**
- Multiple production databases tested
- 9 duplicates handled successfully
- 100% success rate on v0.30.5 databases
- Zero UNIQUE constraint errors
**Impact:**
- Enables importing JSONL with duplicate IDs
- Duplicate count shown in import statistics
- No breaking changes, backward compatible
🤖 Generated with Claude Code
2025-12-18 19:26:29 +01:00
Steve Yegge
d5a115a347 bd sync: 2025-12-18 02:49:16 2025-12-18 02:49:16 -08:00
Steve Yegge
51b3d3975f bd sync: 2025-12-18 02:48:19 2025-12-18 02:48:19 -08:00
Steve Yegge
7c8b69f5b3 Phase 4: Remove deprecated edge fields from Issue struct (Decision 004)
This is the final phase of the Edge Schema Consolidation. It removes
the deprecated edge fields (RepliesTo, RelatesTo, DuplicateOf, SupersededBy)
from the Issue struct and all related code.

Changes:
- Remove edge fields from types.Issue struct
- Remove edge field scanning from queries.go and transaction.go
- Update graph_links_test.go to use dependency API exclusively
- Update relate.go to use AddDependency/RemoveDependency
- Update show.go with helper functions for thread traversal via deps
- Update mail_test.go to verify thread links via dependencies
- Add migration 022 to drop columns from issues table
- Fix cycle detection to allow bidirectional relates-to links
- Fix migration 022 to disable foreign keys before table recreation

All edge relationships now use the dependencies table exclusively.
The old Issue fields are fully removed.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 02:48:13 -08:00
Steve Yegge
558bf9da34 bd sync: 2025-12-18 02:01:53 2025-12-18 02:01:53 -08:00
Steve Yegge
eaa8b89f04 bd sync: 2025-12-18 01:45:02 2025-12-18 01:45:03 -08:00
Steve Yegge
a3bad7890a bd sync: 2025-12-18 01:42:06 2025-12-18 01:42:06 -08:00
Steve Yegge
f541785457 bd sync: 2025-12-18 01:39:34 2025-12-18 01:39:34 -08:00
Steve Yegge
3ec517cc1b Fix daemon/direct mode inconsistency in graph commands (bd-fu83)
Commands relate, unrelate, duplicate, and supersede now properly
use RPC Update when daemonClient is available, instead of always
calling store.UpdateIssue() directly and bypassing the daemon.

Added RelatesTo, DuplicateOf, and SupersededBy fields to UpdateArgs
in the RPC protocol, and updated server_issues_epics.go to handle them.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 01:34:14 -08:00
Steve Yegge
5d7187f29b Phase 3: Migrate existing edge fields to dependencies (Decision 004)
Add migration to convert existing issue fields to dependency edges:
- replies_to -> replies-to dependency with thread_id
- relates_to -> relates-to dependencies (JSON array)
- duplicate_of -> duplicates dependency
- superseded_by -> supersedes dependency

The migration is idempotent (INSERT OR IGNORE) so it does not duplicate
edges that were already created by Phase 2 dual-write.

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 01:22:34 -08:00
Steve Yegge
1d40b8f970 Phase 2: Dual-write for edge schema consolidation (Decision 004)
When issue fields (replies_to, relates_to, duplicate_of, superseded_by)
are set during CreateIssue or UpdateIssue, we now ALSO create the
corresponding dependency edges. This enables gradual migration to
edge-based storage while maintaining backward compatibility.

Changes:
- createGraphEdgesFromIssueFields: handles CreateIssue dual-write
- createGraphEdgesFromUpdates: handles UpdateIssue dual-write
- Replies-to edges include thread_id for efficient thread queries
- Uses INSERT OR IGNORE to handle idempotency

The dual-write ensures both field and dependency stay in sync during
the migration period.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 01:21:15 -08:00
Steve Yegge
d390aa8834 Phase 1: Edge schema consolidation infrastructure (Decision 004)
Add metadata and thread_id columns to dependencies table to support:
- Edge metadata: JSON blob for type-specific data (similarity scores, etc.)
- Thread queries: O(1) conversation threading via thread_id

Changes:
- New migration 020_edge_consolidation.go
- Updated Dependency struct with Metadata and ThreadID fields
- Added new entity types: authored-by, assigned-to, approved-by
- Relaxed DependencyType validation (any non-empty string ≤50 chars)
- Added IsWellKnown() and AffectsReadyWork() methods
- Updated SQL queries to include new columns
- Updated tests for new behavior

This enables HOP knowledge graph requirements and Reddit-style threading.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 01:17:57 -08:00
Steve Yegge
b4a6ee4f5f fix: Include tombstones in DB count for stale check (bd-53c)
The countDBIssuesFast() fallback path used SearchIssues without
IncludeTombstones, returning only live issues (161). Meanwhile
countIssuesInJSONL counts all lines including tombstones (221).

This mismatch caused false "stale DB detected" warnings on every
sync, even when DB and JSONL were in sync.

Fix: Set IncludeTombstones: true in the fallback SearchIssues call.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 00:41:49 -08:00
Steve Yegge
bee04ef389 bd sync: 2025-12-18 00:41:18 2025-12-18 00:41:18 -08:00
Steve Yegge
6394033f72 chore: Bump version to 0.30.5
Updated all component versions:
- bd CLI: 0.30.4 → 0.30.5
- Plugin: 0.30.4 → 0.30.5
- MCP server: 0.30.4 → 0.30.5
- npm package: 0.30.4 → 0.30.5

Changes in 0.30.5:
- Removed YAML simple template system (--from-template flag)
- Removed embedded templates (bug.yaml, epic.yaml, feature.yaml)
- Templates are now purely Beads-based

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 00:27:59 -08:00