Commit Graph

4397 Commits

Author SHA1 Message Date
Steve Yegge
eefeb1a5bc refactor: dedupe error classification, fix --force+--source=db conflict
Post-merge cleanup of PR #805:

1. Extract duplicate error classification logic into classifyDatabaseError()
   helper function (was duplicated in two places in database.go)

2. Fix semantic conflict between --force and --source=db flags:
   - --force implies "database is broken, rebuild from JSONL"
   - --source=db implies "use database as source of truth"
   - These are contradictory; now errors with clear message
   - --force with --source=auto or --source=jsonl works as expected

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

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

Executed-By: beads/crew/dave
Rig: beads
Role: crew
2025-12-30 10:37:53 -08:00
Steve Yegge
c86bffc045 Merge pull request #805 from kraitsura/feature/bd-doctor-enhancements
feat: Enhance bd doctor with force repair and source selection
2025-12-30 10:34:41 -08:00
Steve Yegge
f6f9ef260d feat: auto-detect non-TTY and adjust output (bd-xrwy)
Add TTY detection to automatically disable ANSI colors when stdout is
piped or redirected. Respects standard conventions:
- NO_COLOR environment variable (no-color.org)
- CLICOLOR=0 disables color
- CLICOLOR_FORCE enables color even in non-TTY

Also adds ShouldUseEmoji() helper controlled by BD_NO_EMOJI.
Pager already disabled non-TTY in previous work (bd-jdz3).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:19:44 -08:00
Steve Yegge
06c8855873 feat: add daemon RPC endpoints for config and mol stale (bd-ag35)
Add two new RPC endpoints to allow CLI commands to work in daemon mode:

1. GetConfig (OpGetConfig) - Retrieves config values from the daemon database.
   Used by bd create to validate issue prefix in daemon mode.

2. MolStale (OpMolStale) - Finds stale molecules (complete-but-unclosed
   epics). Used by bd mol stale command in daemon mode.

Changes:
- internal/rpc/protocol.go: Add operation constants and request/response types
- internal/rpc/client.go: Add client methods GetConfig() and MolStale()
- internal/rpc/server_issues_epics.go: Add handler implementations
- internal/rpc/server_routing_validation_diagnostics.go: Register handlers
- cmd/bd/create.go: Use GetConfig RPC instead of skipping validation
- cmd/bd/mol_stale.go: Use MolStale RPC instead of requiring --no-daemon
- internal/rpc/coverage_test.go: Add tests for new endpoints

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 06:59:51 -08:00
Steve Yegge
7f5378ba26 bd sync: 2025-12-30 00:55:05 2025-12-30 00:55:05 -08:00
kraitsura
3e453cdc3a fix: Enhance error classification for PRAGMA integrity check failures
Apply the same enhanced error classification to PRAGMA integrity_check
failures as we do for database open failures.

This ensures users see detailed, actionable recovery steps regardless of
which stage the corruption is detected (open vs integrity check).

Tested with real corruption scenarios - all error paths now provide
specific recovery guidance with exact commands.
2025-12-30 00:43:54 -08:00
Steve Yegge
553544f6ac bd sync: 2025-12-30 00:42:19 2025-12-30 00:42:25 -08:00
Steve Yegge
8f07b619ac bd sync: 2025-12-30 00:42:11 2025-12-30 00:42:25 -08:00
Steve Yegge
7216109284 feat: add pager support to bd list (bd-jdz3)
Add pager support following gh cli conventions:

Flags:
- --no-pager: disable pager for this command

Environment variables:
- BD_PAGER / PAGER: pager program (default: less)
- BD_NO_PAGER: disable pager globally

Behavior:
- Auto-enable pager when output exceeds terminal height
- Respect LESS env var for pager options
- Disable pager when stdout is not a TTY (pipes/scripts)

Implementation:
- New internal/ui/pager.go with ToPager() function
- Added formatIssueLong/formatIssueCompact helper functions
- Buffer output before displaying to support pager

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:41:11 -08:00
Steve Yegge
ebd5c1b72a fix: rename BondRef.ProtoID to SourceID for clarity (bd-ia3g)
The ProtoID field in BondRef was misleading as it could hold both proto
IDs (from proto+proto bonds) and molecule IDs (from mol+mol bonds).
Rename to SourceID with updated JSON tag to better reflect its purpose.

Changes:
- Rename BondRef.ProtoID to SourceID in types.go
- Update JSON tag from proto_id to source_id
- Update all usages in mol_bond.go and tests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:40:16 -08:00
Steve Yegge
b273465966 chore: remove stale TODOs for implemented Expand/ExpandVars (bd-qe7j)
- Step.Expand and Step.ExpandVars are implemented in ApplyInlineExpansions
  (expand.go), but had stale TODO comments claiming they were not
- Updated doc comments to reference the implementation
- Updated bd-7zka to reflect which features are still not implemented
  (Step.Condition and Step.Gate remain as future work)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:39:16 -08:00
Steve Yegge
6561c9fa98 docs: add CHANGELOG.md documenting breaking changes in v0.24.0 (bd-pdr2)
Created CHANGELOG.md for beads-mcp documenting:
- Breaking change: ready() and list() now return list[IssueMinimal] | CompactedResult
- Migration guide for clients expecting list[Issue]
- Context engineering optimization details (~80% context reduction)

Assessment complete: Current approach is correct:
- Type "mismatch" is intentional two-layer architecture
- Client layer returns List[Issue], MCP layer converts to minimal
- Adding full=True would defeat context optimization purpose
- CONTEXT_ENGINEERING.md already has migration guide

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:35:46 -08:00
Steve Yegge
7f16c9d68c bd sync: 2025-12-30 00:28:24 2025-12-30 00:28:51 -08:00
Steve Yegge
973696c640 chore: remove deprecated setupDaemonLoggerLegacy function (bd-2dwo)
The function was marked for removal once all callers migrated to the new
setupDaemonLogger signature with jsonFormat and level parameters.
Audit confirmed no remaining callers - safe to remove.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:27:12 -08:00
Steve Yegge
0f8d7093b2 fix: add missing mockStorage methods for Storage interface compliance
Added GetDependenciesWithMetadata and GetDependentsWithMetadata to mockStorage
to match the Storage interface definition.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:26:56 -08:00
Steve Yegge
99e205868e bd sync: 2025-12-30 00:07:05 2025-12-30 00:07:29 -08:00
Steve Yegge
fb5fd88722 feat: integrate migration detection into bd doctor (bd-7l27)
Add a consolidated "Pending Migrations" check to bd doctor that:
- Detects sequential ID usage (suggests bd migrate hash-ids)
- Detects legacy deletions.jsonl (suggests bd migrate tombstones)
- Detects missing sync-branch config (suggests bd migrate sync)
- Detects database version mismatches (suggests bd migrate)

Also updates existing checks to use correct modern commands:
- CheckIDFormat: bd migrate hash-ids (was bd migrate --to-hash-ids)
- CheckDeletionsManifest: bd migrate tombstones (was bd migrate-tombstones)
- CheckSyncBranchConfig: bd migrate sync beads-sync (was config.yaml edit)

Removes TODO(bd-7l27) comments from migrate_*.go files.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:06:42 -08:00
Steve Yegge
0597d66275 bd sync: close bd-7t9a (MCP redirect fix) 2025-12-30 00:06:17 -08:00
Steve Yegge
e20de54cb2 fix: MCP plugin follows .beads/redirect files (bd-7t9a, gt-tnw)
The _find_beads_db_in_tree() function now follows .beads/redirect files
to find shared beads databases. This is essential for polecat/crew
directories that use redirect files to share a central database.

Changes:
- Added _resolve_beads_redirect() helper function
- Updated _find_beads_db_in_tree() to check for redirect files before
  looking for local .db files
- Added comprehensive tests for redirect functionality

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:06:17 -08:00
Steve Yegge
99692b52f0 bd sync: 2025-12-30 00:00:49 2025-12-30 00:06:17 -08:00
Steve Yegge
b63df91230 feat: add 'convoy' issue type with reactive completion (bd-hj0s)
- Add TypeConvoy to issue types for cross-project tracking
- Implement reactive completion: when all tracked issues close,
  convoy auto-closes with reason "All tracked issues completed"
- Uses 'tracks' dependency type (non-blocking, cross-prefix capable)
- Update help text for --type flag in list/create commands
- Add test for convoy reactive completion behavior

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

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

Executed-By: beads/crew/dave
Rig: beads
Role: crew
2025-12-30 00:04:43 -08:00
Steve Yegge
160feb95ea fix: bd admin compact --older-than=0 now expires all tombstones
Previously, --older-than=0 was indistinguishable from "flag not set"
because both resulted in compactOlderThan==0. The check `> 0` treated
both as "use default 30 days".

Fix:
- Change flag default to -1 (sentinel for "use default")
- Treat 0 as "expire all tombstones" by passing 1ns TTL
- Explicit positive values work as before (N days)

Closes bd-gigi

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:00:25 -08:00
Steve Yegge
cb69f1c154 feat: Show actor on pinned/status change events (gt-1ydd9)
- Add Actor field to MutationEvent struct
- Use new assignee from update args instead of old issue state
- Include actor (who performed the action) in mutation events
- Display actor in bd activity output, falling back to assignee

When pinning/updating status, the activity feed now shows who performed
the action (e.g., "@gastown/crew/jack") instead of showing nothing.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 23:42:20 -08:00
Steve Yegge
e5cf9b3199 bd sync: 2025-12-29 21:26:41 2025-12-29 23:42:20 -08:00
Steve Yegge
48cca7f73d bd sync: 2025-12-29 21:16:05 2025-12-29 23:42:20 -08:00
kraitsura
602c59eb48 feat: Enhance bd doctor with force repair and source selection
Add comprehensive database corruption recovery capabilities to bd doctor.

## Changes

### New Command Flags

- --force: Force repair mode that bypasses database validation
- --source: Choose source of truth (auto/jsonl/db) for recovery

### Enhanced Error Classification

Improved CheckDatabaseIntegrity() to detect and classify:
- Database locked errors (suggests killing processes, removing locks)
- Invalid SQLite files (suggests JSONL recovery with exact commands)
- Migration/validation failures (orphaned dependencies, etc.)
- Generic database errors (context-aware suggestions)

Each error type provides:
- Specific diagnosis
- Step-by-step recovery instructions
- Appropriate command examples with new flags

### Force Recovery Implementation

New DatabaseCorruptionRecoveryWithOptions() function:
- Bypasses database validation when --force is used
- Supports explicit source of truth selection
- Auto-detects best recovery path when source=auto
- Comprehensive rollback on failure
- Uses --force --no-git-history in import during force mode

### Integration

Updated fix orchestration to pass force and source flags to recovery.

## Usage Examples

```bash
# Unopenable database with validation errors
bd doctor --fix --force --source=jsonl

# Choose specific source of truth
bd doctor --fix --source=jsonl  # Trust JSONL
bd doctor --fix --source=db     # Trust database
bd doctor --fix --source=auto   # Auto-detect (default)

# Force recovery with auto-detection
bd doctor --fix --force
```

## Problem Solved

Before: When database had validation errors (orphaned dependencies,
foreign key violations), all bd commands failed in a catch-22 situation.
Could not open database to fix database. Users had to manually delete
database files and reinit.

After: bd doctor --fix --force detects unopenable databases, provides
clear recovery steps, and forces rebuild from JSONL even when database
validation fails.

## Backward Compatibility

- All new flags are optional with safe defaults
- --source defaults to 'auto' (existing behavior)
- --force is opt-in only
- Existing bd doctor behavior unchanged when flags not used
- DatabaseCorruptionRecovery() still exists for compatibility

Fixes: bd-pgza
2025-12-29 22:59:48 -08:00
Steve Yegge
3c6354c051 fix: prevent label accumulation when updating agent role_type/rig
When updating role_type or rig on an agent bead, remove existing
role_type:* or rig:* labels before adding the new one. This prevents
label accumulation that would break filtering.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:41:14 -08:00
Steve Yegge
1b9c0e145e feat: add prepare-commit-msg hook for agent identity trailers (bd-luso)
Automatically adds trailers to commits when running in Gas Town agent context:
- Executed-By: agent identity (e.g., beads/crew/dave)
- Rig: the rig name
- Role: crew, polecat, witness, etc.
- Molecule: pinned molecule ID (if any)

Detection sources:
1. GT_ROLE environment variable (set by Gas Town sessions)
2. cwd path patterns (crew/, polecats/, witness/, refinery/)

Trailers are skipped for:
- Human commits (no agent context detected)
- Merge commits (have their own format)
- Commits that already have Executed-By trailer (avoid duplicates)

Executed-By: beads/crew/dave
Rig: beads
Role: crew
2025-12-29 21:26:32 -08:00
Steve Yegge
a8748936e4 feat: add structured labels for agent beads (bd-g7eq)
Add role_type and rig labels to agent beads for filtering queries.

Changes:
- Add RoleType/Rig to CreateArgs and UpdateArgs in RPC protocol
- Auto-add role_type:<value> and rig:<value> labels when creating/updating agents
- Add --role-type and --agent-rig flags to bd create (requires --type=agent)
- Add bd agent backfill-labels command to update existing agent beads

This enables queries like:
  bd list --type=agent --label=role_type:witness
  bd list --type=agent --label=rig:gastown

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:15:46 -08:00
Steve Yegge
22fb3ff56b fix: improve --town mode robustness from code review
- resolveBeadsRedirect now verifies target exists before returning
- Added failure tracking to runTownActivityFollow (warns on rig disconnect)
- Created fetchTownMutationsWithStatus for tracking daemon availability
- Shows reconnection message when rigs come back online

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:13:37 -08:00
Steve Yegge
5f5a341624 bd sync: 2025-12-29 21:13:11 2025-12-29 21:13:11 -08:00
Steve Yegge
6b12efbb2b bd sync: 2025-12-29 21:10:00 2025-12-29 21:10:10 -08:00
Steve Yegge
26e491d7d4 feat: add --town flag to bd activity for aggregated cross-rig feed (bd-dx6e)
Adds --town flag that:
- Discovers all rigs via routes.jsonl
- Connects to each rig daemon
- Aggregates mutations from all daemons
- Sorts by timestamp for unified feed
- Works with --follow for real-time streaming

Usage:
  bd activity --town              # Aggregated feed from all rigs
  bd activity --follow --town     # Stream all rig activity

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:09:53 -08:00
Steve Yegge
35ffeea804 bd sync: 2025-12-29 21:09:05 2025-12-29 21:09:05 -08:00
Steve Yegge
b8a5ee162b feat: Add tracks relation type for convoy tracking (bd-3roq)
Adds non-blocking tracks dependency type for convoy to issue relationships:
- Non-blocking: does not affect ready work calculation
- Cross-prefix capable: convoys in hq-* can track issues in gt-*, bd-*
- Reverse lookup: bd dep list <id> --direction=up -t tracks

Also adds bd dep list command with direction and type filtering for
querying dependencies/dependents.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:04:45 -08:00
Steve Yegge
2b90f51d0c feat: add doctor check for issues.jsonl git tracking (GH#796)
Safeguard for users with global gitignore patterns like *.jsonl that
could cause issues.jsonl to be ignored, breaking bd sync.

The check runs git check-ignore and warns if issues.jsonl would be
ignored by any gitignore rule (global, parent directory, etc).
2025-12-29 20:58:30 -08:00
Steve Yegge
61edfafe4c bd sync: 2025-12-29 20:49:22 2025-12-29 20:49:22 -08:00
Steve Yegge
447fe84bf0 bd sync: 2025-12-29 20:47:42 2025-12-29 20:47:55 -08:00
Steve Yegge
fd781cee5b bd sync: 2025-12-29 18:30:11 2025-12-29 20:47:55 -08:00
Steve Yegge
aa759c06aa fix: improve jira sync error when Python script not found (GH#803)
- Add BD_JIRA_SCRIPT env var to let users specify script location
- Improve error message with clear instructions for binary users
- Show all locations that were searched
2025-12-29 18:44:03 -08:00
Steve Yegge
34e2548c86 feat: bd list defaults to non-closed issues with 50 limit (GH#788)
Changes:
- Default to excluding closed issues (use --all to include)
- Default limit of 50 issues (use --limit 0 for unlimited)
- --all flag now overrides the closed filter

This addresses agent context blowout from seeing hundreds of closed issues.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 17:54:56 -08:00
Steve Yegge
a7f34d8f89 bd sync: 2025-12-29 17:54:03 2025-12-29 17:54:03 -08:00
Steve Yegge
6e9004bb94 bd sync: 2025-12-29 17:52:01 2025-12-29 17:52:18 -08:00
Steve Yegge
5c1cd2b9fa feat: add default limit of 50 to bd list (bd-v5fn, GH#788)
Changes:
- Default --limit changed from 0 (unlimited) to 50
- --limit 0 explicitly means unlimited (override default)
- Show truncation hint when results are limited:
  "Showing N issues (use --limit 0 for all)"

This protects agents and humans from overwhelming output.
Follows precedent from gh cli (30) and jira-cli (50).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-29 17:52:10 -08:00
Steve Yegge
4c16895c29 feat: add 'rm' as alias for 'dep remove' (bd-oehv) 2025-12-29 17:50:29 -08:00
Steve Yegge
a6b37796d1 bd sync: 2025-12-29 17:50:18 2025-12-29 17:50:18 -08:00
Steve Yegge
f5ec63df8f bd sync: 2025-12-29 17:49:07 2025-12-29 17:49:07 -08:00
Steve Yegge
2ca76dcae8 bd sync: 2025-12-29 17:10:34 2025-12-29 17:10:40 -08:00
Steve Yegge
7f62ae2630 feat: bd mol burn now works on mols, not just wisps (bd-l6yk)
Previously mol burn only worked on wisps (Ephemeral=true), erroring
on persistent mols. Now it works on both:
- Wisps: direct delete without tombstones (original behavior)
- Mols: cascade delete with tombstones (syncs to remotes)

This makes the 'burn' metaphor consistent: burn = destroy a molecule,
regardless of phase.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 17:10:26 -08:00
Steve Yegge
de239e09f9 bd sync: 2025-12-29 17:05:12 2025-12-29 17:05:12 -08:00