Commit Graph

571 Commits

Author SHA1 Message Date
Steve Yegge
bbfedb060a Refactor: extract duplicated validation and flag logic (bd-g5p7)
- Created internal/validation package for centralized validation logic
- Created cmd/bd/flags.go for shared flag registration
- Updated create and update commands to use shared logic
- Added support for 'P1' style priority to update command
- Added tests for validation logic

Amp-Thread-ID: https://ampcode.com/threads/T-c8d369a3-32f0-42a0-96d1-fd589e89bd6b
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:11:27 -05:00
Steve Yegge
6a25f5eaa6 fix: resolve remaining hyphenated ID issues in memory store and doctor 2025-11-20 19:01:30 -05:00
Zachary Rosen
408244ed73 fix: isHashID matches for hyphenated application names
Fixes `isHashID` checks for hyphenated application names

When a user calls bd init inside an application that has a "-" for
example my-first-application without any options than ids will follow a
pattern of my-first-application-{ID}. When using SplitN on the "-"
separator it would result in the split parts returning as [my,
first-application-{ID}] which is incorrectly pulling out the {ID}
resulting in the `isHashID` returning false when it could be a hash id.

Instead of using SplitN, this changes to find the last index of the
separator resulting in the suffix becoming the actual {ID}.
2025-11-20 19:01:30 -05:00
Steve Yegge
7b865eb541 Remove legacy issues.jsonl and update defaults to beads.jsonl
Amp-Thread-ID: https://ampcode.com/threads/T-ae11b392-24b5-4060-b431-606dd81c1763
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:00:36 -05:00
Steve Yegge
e5428abbb7 Merge branch 'main' into fix-monitor
Amp-Thread-ID: https://ampcode.com/threads/T-7bbd9558-2eb4-483a-bf7b-c61ea9c22092
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 12:34:30 -05:00
Steve Yegge
d933d98d47 Merge pull request #338 from cpdata/fix-daemon-lifetime
Fixes issue #278: Prevent daemon from exiting when launcher process dies
2025-11-20 09:15:51 -08:00
Steve Yegge
78a893d17d Merge pull request #337 from cpdata/fix-resolve-partial-id
Fix: Restore JSON unmarshaling in ResolveID for fixing failed bd show/update/close operations
2025-11-20 09:15:08 -08:00
Steve Yegge
0041efdf45 Merge pull request #333 from cpdata/cpdata-issue-322
Fix doctor incorrectly diagnosing hash IDs as sequential (#322)
2025-11-20 09:12:15 -08:00
Ryan
fb65163692 fix: address critical resource leaks and error handling issues (#327)
* fix: address critical resource leaks and error handling issues

Fixes 5 critical and high-priority issues identified in codebase analysis:

1. bd-vavh: Fix row iterator resource leak in recursive dependency queries
   - Move defer rows.Close() to execute on all code paths
   - Previously leaked connections on scan errors
   - Location: internal/storage/sqlite/sqlite.go:1121-1145

2. bd-qhws: Configure database connection pool limits for daemon mode
   - Set MaxOpenConns to runtime.NumCPU() + 1 for file-based databases
   - Prevents connection exhaustion under concurrent RPC load
   - Only affects daemon mode (long-running server)
   - Location: internal/storage/sqlite/sqlite.go:108-125

3. bd-jo38: Add WaitGroup tracking to FileWatcher goroutines
   - Track goroutines with sync.WaitGroup for graceful shutdown
   - Wait for goroutines to finish before cleanup in Close()
   - Prevents race condition on debouncer access during shutdown
   - Location: cmd/bd/daemon_watcher.go (Start, startPolling, Close)

4. bd-2d5r: Fix silent error handling in RPC response writing
   - writeResponse now returns errors instead of ignoring them
   - Prevents sending partial JSON and client hangs
   - Closes connection on marshal/write errors
   - Location: internal/rpc/server_lifecycle_conn.go:227-246

5. bd-zqmb: Fix goroutine leak in daemon restart
   - Add 10-second timeout to daemon Wait() goroutine
   - Kill process if it doesn't fork within timeout
   - Prevents goroutine accumulation on restart failures
   - Location: cmd/bd/daemons.go:250-268

All changes follow Go best practices and maintain backward compatibility.

* Add feature request for .beads/README.md generation during init

Created bd-m7ge to automatically generate a promotional/documentation
README in the .beads directory when running 'bd init'. This will help
advertise Beads in open source repositories and provide quick reference
documentation for developers using AI coding agents.

The README will include:
- Brief explanation of Beads (AI-native issue tracking)
- Link to steveyegge/beads repository
- Quick reference of essential commands
- Compelling messaging to encourage adoption
2025-11-20 08:13:06 -08:00
Matt Wilkie
4985a6803c Merge branch 'fix-ci-issue-328' into fix-monitor 2025-11-19 15:15:30 -07:00
Matt Wilkie
e538dbdee2 Merge show-rev-in-dev commit 'c922dc1ec32d5e3a470c22036891e239f4ab1350' into stable-fixes 2025-11-19 09:25:08 -07:00
Matt Wilkie
d72e57854b Merge branch 'pr-338' into stable-fixes 2025-11-19 09:15:35 -07:00
Charles P. Cross
4432af0aa4 fix: improve ResolvePartialID / ResolveID handling for bd show (issue #336)
- Add fast path for exact ID matches in ResolvePartialID
- Properly unmarshal ResolveID RPC responses used by `bd show`

Summary:
--------
Fixes regression introduced after v0.23.1 where `bd show <issue_id>`,
`bd update <issue_id>`, and `bd close <issue_id>` commands failed with
"operation failed: issue not found" errors even when the issue existed
in the database.

Root Cause:
-----------
The daemon's ResolveID RPC handler (handleResolveID in
internal/rpc/server_issues_epics.go) returns a JSON-encoded string
containing the resolved issue ID. For example, when resolving "ao-izl",
the RPC response contains the JSON string: "ao-izl" (with quotes).

After v0.23.1, the show/update/close commands in cmd/bd/show.go were
changed to use string(resp.Data) to extract the resolved ID, which
treats the raw bytes as a string without decoding the JSON. This caused
the resolved ID to literally be "ao-izl" (including the quotes),
which then failed to match the actual issue ID ao-izl (without quotes)
when passed to subsequent Show/Update/Close RPC calls.

In v0.23.1 (commit 77dcf55), the code correctly unmarshaled the JSON:
  var resolvedID string
  if err := json.Unmarshal(resp.Data, &resolvedID); err != nil {
      // handle error
  }

This unmarshal step was removed in later commits, causing the regression.

Fix:
----
Restored the JSON unmarshaling step in three places in cmd/bd/show.go:
1. showCmd - line 37-42
2. updateCmd - line 400-405
3. closeCmd - line 723-728

Each now properly decodes the JSON string response before using the
resolved ID in subsequent RPC calls.

Testing:
--------
- Verified `bd show <issue-id-with-prefix>` works correctly in both daemon and direct modes
- Tested with newly created issues to ensure the fix works for all IDs
- All Go tests pass (go test ./... -short)
- Confirmed behavior matches v0.23.1 working binary

The fix ensures that issue ID resolution works correctly regardless of
whether the ID prefix matches the configured issue_prefix.
2025-11-19 05:54:28 -05:00
Charles P. Cross
68f9bef98c fix: prevent daemon from exiting when launcher process exits (issue #278) 2025-11-19 05:07:16 -05:00
Charles P. Cross
04a1996fd9 fix: Fix daemon export leaving JSONL newer than database (issues #301, #321)
After daemon auto-export, JSONL mtime could be newer than database mtime
due to SQLite WAL mode not updating beads.db until checkpoint. This caused
validatePreExport to incorrectly block subsequent exports with "JSONL is
newer than database" error, leading to daemon shutdown.

Solution: Call TouchDatabaseFile after all export operations to ensure
database mtime >= JSONL mtime. This prevents false positives in validation
2025-11-19 05:06:12 -05:00
Charles P. Cross
8c1f865e23 Fix doctor incorrectly diagnosing hash IDs as sequential (issue #322)
- Enhanced checkIDFormat to sample multiple issues instead of just one
- Added detectHashBasedIDs function with robust multi-heuristic detection:
  * Checks for child_counters table (hash ID schema indicator)
  * Detects letters in IDs (base36 encoding)
  * Identifies leading zeros (common in hash IDs, rare in sequential)
  * Analyzes variable length patterns (adaptive hash IDs)
  * Checks for non-sequential numeric ordering
- Added comprehensive test coverage (16 new test cases)
- Fixes false positives for numeric-only hash IDs like 'pf-0088'

Closes #322
2025-11-18 05:20:11 -05:00
Codex Agent
070107caee Handle formatting errors in onboard renderer 2025-11-17 11:32:37 -07:00
Codex Agent
4e222145ac Fix onboard test deadlock on Windows 2025-11-17 11:26:59 -07:00
Codex Agent
bf9b2c83fb Annotate gosec-safe file accesses 2025-11-17 10:12:46 -07:00
Codex Agent
7b63b5a30b Fix CI regressions and stabilize tests 2025-11-17 10:06:35 -07:00
matt wilkie
12dfa0b555 also report branch in dev version 2025-11-16 18:10:46 -07:00
matt wilkie
6d390f7728 Merge branch 'main' into show-rev-in-dev
# Conflicts:
#	.beads/beads.jsonl
2025-11-16 15:50:09 -07:00
Steve Yegge
b9919fe031 Fix: --parent flag now creates parent-child dependency
When using 'bd create --parent <id>', the system now automatically
creates a parent-child dependency linking the child to the parent.
This fixes epic status reporting which was showing zero children.

Fixes #318 (bd-jijf)

Changes:
- cmd/bd/create.go: Add parent-child dependency after issue creation
- internal/rpc/server_issues_epics.go: Add same fix for daemon mode

Tested:
- Created epic with children, verified epic status shows correct count
- Verified closing all children makes epic eligible for closure
- All tests pass

Amp-Thread-ID: https://ampcode.com/threads/T-f1a1aee1-03bd-4e62-a63c-c1d339f8300b
Co-authored-by: Amp <amp@ampcode.com>
2025-11-15 13:20:02 -08:00
Steve Yegge
6f7e7fa930 Fix lint errors: handle error return values 2025-11-15 12:52:34 -08:00
Ryan
690c73fc31 Performance Improvements (#319)
* feat: add performance testing framework foundation

Implements foundation for comprehensive performance testing and user
diagnostics for beads databases at 10K-20K scale.

Components added:
- Fixture generator (internal/testutil/fixtures/) for realistic test data
  * LargeSQLite/XLargeSQLite: 10K/20K issues with epic hierarchies
  * LargeFromJSONL/XLargeFromJSONL: test JSONL import path
  * Realistic cross-linked dependencies, labels, assignees
  * Reproducible with seeded RNG

- User diagnostics (bd doctor --perf) for field performance data
  * Collects platform info (OS, arch, Go/SQLite versions)
  * Measures key operation timings (ready, list, show, search)
  * Generates CPU profiles for bug reports
  * Clean separation in cmd/bd/doctor/perf.go

Test data characteristics:
- 10% epics, 30% features, 60% tasks
- 4-level hierarchies (Epic → Feature → Task → Subtask)
- 20% cross-epic blocking dependencies
- Realistic status/priority/label distributions

Supports bd-l954 (Performance Testing Framework epic)
Closes bd-6ed8, bd-q59i

* perf: optimize GetReadyWork with compound index (20x speedup)

Add compound index on dependencies(depends_on_id, type, issue_id) to
eliminate performance bottleneck in GetReadyWork recursive CTE query.

Performance improvements (10K issue database):
- GetReadyWork: 752ms → 36.6ms (20.5x faster)
- Target: <50ms ✓ ACHIEVED
- 20K database: ~1500ms → 79.4ms (19x faster)

Benchmark infrastructure enhancements:
- Add dataset caching in /tmp/beads-bench-cache/ to avoid regenerating
  10K-20K issues on every benchmark run (first run: ~2min, subsequent: <5s)
- Add progress logging during fixture generation (shows 10%, 20%... completion)
- Add database size logging (17.5 MB for 10K, 35.1 MB for 20K)
- Document rationale for only benchmarking large datasets (>10K issues)
- Add CPU/trace profiling with --profile flag for performance debugging

Schema changes:
- internal/storage/sqlite/schema.go: Add idx_dependencies_depends_on_type_issue

New files:
- internal/storage/sqlite/bench_helpers_test.go: Reusable benchmark setup with caching
- internal/storage/sqlite/sqlite_bench_test.go: Comprehensive benchmarks for critical operations
- Makefile: Convenient benchmark execution (make bench-quick, make bench)

Related:
- Resolves bd-5qim (optimize GetReadyWork performance)
- Builds on bd-6ed8 (fixture generator), bd-q59i (bd doctor --perf)

* perf: add WASM compilation cache to eliminate cold-start overhead

Configure wazero compilation cache for ncruces/go-sqlite3 to avoid
~220ms JIT compilation on every process start.

Cache configuration:
- Location: ~/.cache/beads/wasm/ (platform-specific via os.UserCacheDir)
- Automatic version management: wazero keys entries by its version
- Fallback: in-memory cache if directory creation fails
- No cleanup needed: old versions are harmless (~5-10MB each)

Performance impact:
- First run: ~220ms (populate cache)
- Subsequent runs: ~20ms (load from cache)
- Savings: ~200ms per cold start

Cache invalidation:
- Automatic when wazero version changes (upgrades use new cache dir)
- Manual cleanup: rm -rf ~/.cache/beads/wasm/ (safe to delete anytime)

This complements daemon mode:
- Daemon mode: eliminates startup cost by keeping process alive
- WASM cache: reduces startup cost for one-off commands or daemon restarts

Changes:
- internal/storage/sqlite/sqlite.go: Add init() with cache setup

* refactor: improve maintainability of performance testing code

Extract common patterns and eliminate duplication across benchmarks, fixture generation, and performance diagnostics. Replace magic numbers with explicit configuration to improve readability and make it easier to tune test parameters.

* docs: clarify profiling behavior and add missing documentation

Add explanatory comments for profiling setup to clarify why --profile
forces direct mode (captures actual database operations instead of RPC
overhead) and document the stopCPUProfile function's role in flushing
profile data to disk. Also fix gosec G104 linter warning by explicitly
ignoring Close() error during cleanup.

* fix: prevent bench-quick from running indefinitely

Added //go:build bench tags and skipped timeout-prone benchmarks to
prevent make bench-quick from running for hours.

Changes:
- Add //go:build bench tag to cycle_bench_test.go and compact_bench_test.go
- Skip Dense graph benchmarks (documented to timeout >120s)
- Fix compact benchmark prefix: bd- → bd (validation expects prefix without trailing dash)

Before: make bench-quick ran for 3.5+ hours (12,699s) before manual interrupt
After: make bench-quick completes in ~25 seconds

The Dense graph benchmarks are known to timeout and represent rare edge
cases that don't need optimization for typical workflows.
2025-11-15 12:46:13 -08:00
Steve Yegge
bd6dca507d Remove orphaned TestFormatDependencyType test
The formatDependencyType function was removed in commit 57b6ea6 when
the dependency display UI was simplified. The test was left behind
and is now failing CI.

This completes the cleanup that was partially done in PR #309.
2025-11-15 11:55:15 -08:00
Peter Loron
92f3af56c5 fix: Improve missing git hook message (#306)
Install hooks with 'bd hooks install' message added to bd doctor output.

Co-authored-by: Peter Loron <ploron@protonmail.com>
2025-11-15 11:53:38 -08:00
Codex Agent
7c96142432 Add commit hash to bd version output (bd-hpt5) 2025-11-13 13:45:52 -07:00
David Laing
57b6ea606b fix: add external_ref support to daemon mode RPC (fixes #303) (#304)
Add external_ref field to CreateArgs and UpdateArgs RPC protocol
structs to enable linking issues to external systems (GitHub, Jira,
Shortcut, etc.) when using daemon mode.

Changes:
- Add ExternalRef field to rpc.CreateArgs and rpc.UpdateArgs
- Update bd create/update commands to pass external_ref via RPC
- Update daemon handlers to process external_ref field
- Add integration tests for create and update operations

The --external-ref flag now works correctly in both daemon and direct modes.

Fixes https://github.com/steveyegge/beads/issues/303

Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Happy <yesreply@happy.engineering>
2025-11-13 12:01:27 -08:00
Steve Yegge
f4a2f87aff Fix #274: Add automatic .beads/.gitignore upgrade (#300)
* Fix #274: Add automatic .beads/.gitignore upgrade

Implements three mechanisms to ensure users get updated gitignore:

1. bd doctor --fix: Manually upgrade gitignore
2. Daemon auto-upgrade: Upgrades on startup if outdated
3. bd init idempotent: Safe to re-run, always updates gitignore

The gitignore template now lives in cmd/bd/doctor/gitignore.go
for consistent updates across all three mechanisms.

Fixes: #274

* Remove test binary

Amp-Thread-ID: https://ampcode.com/threads/T-7042cfcc-ac97-43d7-a40f-3fa1bb4e1c2b
Co-authored-by: Amp <amp@ampcode.com>

* Fix critical issues: remove merge artifact and apply gitignore template

- Remove .beads/beads.left.jsonl (merge artifact that shouldn't be committed)
- Apply new gitignore template to .beads/.gitignore (was missing patterns)

Amp-Thread-ID: https://ampcode.com/threads/T-7042cfcc-ac97-43d7-a40f-3fa1bb4e1c2b
Co-authored-by: Amp <amp@ampcode.com>

* bd sync: 2025-11-12 11:09:30

* Retrigger CI

Amp-Thread-ID: https://ampcode.com/threads/T-8d532264-6d5e-4b68-88e9-e4511851b64a
Co-authored-by: Amp <amp@ampcode.com>

* Fix duplicate DoctorCheck type definition

* Trigger CI after fixing type conflict

Amp-Thread-ID: https://ampcode.com/threads/T-8d532264-6d5e-4b68-88e9-e4511851b64a
Co-authored-by: Amp <amp@ampcode.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
2025-11-12 12:46:27 -08:00
Ryan
f7e80dd80c feat: add context optimization features for AI agents (#297)
* feat: add bd prime and setup commands for AI agent integration

This commit consolidates context optimization features for AI agents:

## New Commands

**bd prime** - AI-optimized workflow context injection
- Outputs ~1-2k tokens of workflow context
- Context-aware: adapts to MCP vs CLI mode
- MCP mode: minimal reminders (~500 tokens)
- CLI mode: full command reference (~1-2k tokens)
- Warns against TodoWrite tool and markdown TODOs
- Designed for SessionStart/PreCompact hooks

**bd setup claude** - Claude Code integration installer
- Installs hooks via JSON configuration (not file scripts)
- Supports --project for project-only installation
- Supports --check to verify installation
- Supports --remove to uninstall hooks
- Idempotent (safe to run multiple times)
- Merges with existing settings

**bd setup cursor** - Cursor IDE integration installer
- Creates .cursor/rules/beads.mdc with workflow rules
- Simplified implementation (just overwrites file)

## bd doctor Enhancements

- New: CheckClaude() verifies Claude Code integration
- Detects plugin, MCP server, and hooks installation
- Provides actionable fix suggestions
- Extracted legacy pattern detection to doctor/legacy.go
- Detects JSONL-only mode and warns about legacy issues.jsonl

## Core Improvements

- FindBeadsDir() utility for cross-platform .beads/ discovery
- Works in JSONL-only mode (no database required)
- Sorted noDbCommands alphabetically (one per line for easy diffs)

## Testing

- Unit tests for setup command hook manipulation
- Tests for idempotency, adding/removing hooks
- All tests passing

## Documentation

- cmd/bd/doctor/claude.md - Documents why beads doesn't use Claude Skills
- commands/prime.md - Slash command for bd prime
- Fixed G304 gosec warnings with nosec comments

## Token Efficiency

The bd prime approach reduces AI context usage dramatically:
- MCP mode: ~500 tokens (vs ~10.5k for full MCP tool scan)
- CLI mode: ~1-2k tokens
- 80-99% reduction in standing context overhead

* fix: resolve linting errors in setup utils and remove obsolete test

- Add error check for tmpFile.Close() in setup/utils.go to fix golangci-lint G104
- Remove TestCheckMultipleJSONLFiles test that referenced deleted checkMultipleJSONLFiles function

Fixes golangci-lint errcheck violations introduced in the bd prime/setup feature.
2025-11-12 10:48:36 -08:00
dezer32
d9904a8830 Fix compact command failing with 'SQLite DB needed' error when daemon is running by removing premature store check and using ensureDirectMode for analyze/apply modes (closes beads-vlo) (#294) 2025-11-12 10:37:54 -08:00
Matteo Landi
9dff345e7a Fix: Update DB mtime after import even with 0 changes (#296)
When bd import finds no changes (0 created, 0 updated), it now updates
the database modification timestamp to signal sync validation passed.

This fixes 'bd sync' refusing to export with 'JSONL is newer than database'
error that occurs after git pull updates JSONL mtime without content changes.

Root cause: Import validated DB/JSONL are in sync but didn't update DB mtime,
causing timestamp-based sync validation to perpetually fail.

Amp-Thread-ID: https://ampcode.com/threads/T-560b9c11-e368-45e6-b1e3-512b6d6010a1

Co-authored-by: Amp <amp@ampcode.com>
2025-11-12 10:37:32 -08:00
Steve Yegge
1deaad124f Fix bd sync Windows upstream detection (#281)
Use git config instead of @{u} symbolic ref for better
compatibility with Git for Windows.

Fixes #281
2025-11-10 10:59:46 -08:00
Steve Yegge
9e9db62954 Fix daemon exiting after 5s on macOS due to PID 1 parent monitoring (GH #278)
Amp-Thread-ID: https://ampcode.com/threads/T-87e6732c-f7bf-4e8d-9ebc-f778ac6f0c40
Co-authored-by: Amp <amp@ampcode.com>
2025-11-10 10:22:03 -08:00
Steve Yegge
4de9f015d6 Support local-only git repos without remote origin (bd-biwp)
- Add hasGitRemote() helper to detect if any remote exists
- Gracefully skip git pull/push when no remote configured
- Daemon now works in local-only mode (RPC, auto-flush, JSONL export)
- Add comprehensive test coverage for local-only workflows
- Fixes GH#279: daemon crash on repos without origin remote

Amp-Thread-ID: https://ampcode.com/threads/T-5dad0ca8-ac77-4ae0-8de6-208b23ea47af
Co-authored-by: Amp <amp@ampcode.com>
2025-11-09 16:16:45 -08:00
Steve Yegge
23fce6ea49 fix: add version marker to post-checkout hook and include in CheckGitHooks
The post-checkout hook was missing the bd-hooks-version marker that the other
hooks have, and it wasn't being checked by CheckGitHooks(). This caused
version mismatch issues during hook status checks.

Changes:
- Added 'bd-hooks-version: 0.23.1' marker to post-checkout hook
- Updated CheckGitHooks() to include post-checkout in the list of hooks to check

This ensures all four git hooks (pre-commit, post-merge, pre-push, post-checkout)
have consistent version tracking.

Fixes bd-kb4g

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 14:58:03 -08:00
Steve Yegge
83472aca3d bd sync: 2025-11-09 14:53:59 2025-11-09 14:53:59 -08:00
Steve Yegge
d482d9ea6e bd sync: 2025-11-09 14:13:48 2025-11-09 14:13:48 -08:00
Steve Yegge
1fc9bf629f Fix parallel test deadlock by removing t.Parallel() from TestCLI_* tests
Tests now complete successfully without -short flag.

Also updated git hook templates to version 0.23.1.

Fixes bd-82dv
2025-11-09 12:55:14 -08:00
Yashwanth Reddy
8f37904c9c Add auto-detection of issue prefix from git history (#277)
- Check existing JSONL issues before falling back to directory name on initialization
- Implement readFirstIssueFromJSONL() to extract prefix from first issue
- Added tests for readFirstIssueFromJSONL
2025-11-09 11:22:12 -08:00
Steve Yegge
b02743c5ba chore: Bump version to 0.23.1
Updated all component versions:
- bd CLI: 0.23.0 → 0.23.1
- Plugin: 0.23.0 → 0.23.1
- MCP server: 0.23.0 → 0.23.1
- npm package: 0.23.0 → 0.23.1
- Documentation: 0.23.0 → 0.23.1

Generated by scripts/bump-version.sh
2025-11-08 22:59:00 -08:00
Steve Yegge
9a280e0f60 Clean up snapshot files after successful merge (bd-auf1)
Amp-Thread-ID: https://ampcode.com/threads/T-15e8dbc1-4706-4640-883e-6830a8e79fe8
Co-authored-by: Amp <amp@ampcode.com>
2025-11-08 22:45:36 -08:00
Steve Yegge
0131eda09d Optimize CLI tests with in-process testing (bd-ky74)
- Convert exec.Command() tests to in-process rootCmd.Execute()
- Achieve ~10x speedup (3.8s vs 40s for 17 tests)
- Add mutex serialization for thread safety
- Implement manual temp dir cleanup with retries
- Reset global state between tests to prevent contamination
- Keep TestCLI_EndToEnd for binary validation
2025-11-08 22:42:02 -08:00
Steve Yegge
6ca26ed71b Improve cmd/bd test coverage from 20.2% to 23.3%
- Fixed TestCLI_Create to handle warning messages before JSON output
- Added tests for formatDependencyType (show.go)
- Added tests for truncateForBox and gitRevParse (worktree.go)
- Added comprehensive CLI tests for labels, priority formats, and reopen
- All tests passing in short mode

Addresses bd-6221bdcd
2025-11-08 18:22:28 -08:00
Steve Yegge
734579b1a2 Remove version field from metadata.json
- Removes noisy version mismatch warnings on every bd upgrade
- Version field in metadata.json was redundant with daemon version checking via RPC
- Daemon version mismatches still detected via HealthResponse
- Removes checkVersionMismatch() function and related test file
- Updates .beads/.gitignore to properly ignore merge artifacts

Amp-Thread-ID: https://ampcode.com/threads/T-7ba8aff2-97a0-4d0c-9008-e858bdfadd61
Co-authored-by: Amp <amp@ampcode.com>
2025-11-08 18:16:39 -08:00
Steve Yegge
f027de93b6 Add schema compatibility probe to prevent silent migration failures (bd-ckvw)
- Implement comprehensive schema probe in sqlite.New() that verifies all
  expected tables and columns after migrations
- Add retry logic: if probe fails, retry migrations once
- Return clear fatal error with missing schema elements if probe still fails
- Enhance daemon version gating: refuse RPC if client has newer minor version
- Improve checkVersionMismatch messaging: verify schema before claiming upgrade
- Add schema compatibility check to bd doctor command
- Add comprehensive tests for schema probing

This prevents the silent migration failure bug where:
1. Migrations fail silently
2. Database queries fail with 'no such column' errors
3. Import logic misinterprets as 'not found' and tries INSERT
4. Results in cryptic UNIQUE constraint errors

Fixes #262

Amp-Thread-ID: https://ampcode.com/threads/T-0d7ae2c0-9f12-4f9b-85d1-1291488af150
Co-authored-by: Amp <amp@ampcode.com>
2025-11-08 15:40:19 -08:00
Steve Yegge
54702b59a2 Fix #264 and #262: Remove stale --resolve-collisions references
- Update examples/git-hooks README to use 'bd hooks install' instead of non-existent install.sh
- Fix post-merge hook error message to not suggest --resolve-collisions flag (removed in v0.20)
- Clean up all doc references to --resolve-collisions (flag removed, hash IDs prevent collisions)

Fixes #264 (git hooks installer missing)
Fixes #262 (misleading error message)

Amp-Thread-ID: https://ampcode.com/threads/T-c9f0e4cb-fba2-4db2-a3d5-36dc1892be9d
Co-authored-by: Amp <amp@ampcode.com>
2025-11-08 13:18:50 -08:00
Steve Yegge
c3a701fe8e Implement message system improvements (bd-6uix)
- Add 30s HTTP client timeout to prevent hangs (bd-de0h)
- Implement full message reading with body display (bd-8mfn)
- Add validation for --importance flag (bd-bdhn)
- Refactor duplicated error messages into constant (bd-s1xn)
- Fix inefficient client-side filtering, use server-side (bd-ri6d)
- Improve type safety with typed Message struct (bd-p0zr)

Amp-Thread-ID: https://ampcode.com/threads/T-ee20cc86-a866-4789-9d4d-4d14e1a6d6f4
Co-authored-by: Amp <amp@ampcode.com>
2025-11-08 13:16:53 -08:00
Steve Yegge
0b28bfec7a Fix bd-17d5: conflict marker false positives on JSON-encoded content
- import.go: Check raw bytes before JSON decoding using bytes.HasPrefix
- validate.go: Use bytes.Split and bytes.HasPrefix on raw data
- Added regression test TestAutoImportConflictMarkerFalsePositive
- Verified with vc-85 issue that triggered the bug

Amp-Thread-ID: https://ampcode.com/threads/T-3f81e22a-14b9-435b-8932-5641aadb7d31
Co-authored-by: Amp <amp@ampcode.com>
2025-11-08 13:09:42 -08:00