Replace fmt.Fprintf(os.Stderr, ...) + os.Exit(1) patterns with
FatalErrorRespectJSON() in updateCmd, closeCmd, and editCmd.
This ensures that when --json flag is set, errors are returned as
JSON objects ({"error": "message"}) instead of plain text.
Fixes: bd-28sq.1
Extends bd doctor to detect complete-but-unclosed molecules (epics where
all children are closed but root is still open).
- Added CheckStaleMolecules() to doctor/maintenance.go
- Added resolveBeadsDir() helper to follow Gas Town redirect files
- Check appears in Maintenance category with warning severity
- Shows example IDs and suggests 'bd mol stale' for review
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements formula management commands:
- bd formula list: Lists formulas from all search paths
- bd formula show <name>: Shows formula details, steps, composition rules
Search paths in priority order:
1. .beads/formulas/ (project)
2. ~/.beads/formulas/ (user)
3. ~/gt/.beads/formulas/ (town)
Features:
- Type filtering (--type workflow|expansion|aspect)
- JSON output support (--json)
- Shows variables, steps, advice, bond points, and aspects
- Formulas in earlier paths shadow later ones
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements command to find epics/molecules where all children are closed
but the root is still open. Helps identify work that's done but not
formally closed.
Flags:
--blocking Only show molecules blocking other work
--unassigned Only show unassigned molecules
--all Include molecules with 0 children
--json Machine-readable output
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ApplyAdvice now collects original step IDs before applying rules and
only matches steps in that set. This prevents advice patterns (like "*")
from matching their own inserted before/after steps.
Added test case demonstrating that a "*" pattern only adds advice to
original steps, not to inserted steps.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Aspects field to ComposeRules for listing aspect formulas
- Apply aspects during cooking after expansions
- Aspects are loaded by name and their advice rules are applied
Usage in formula:
"compose": {
"aspects": ["security-audit", "logging"]
}
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The map rule was only iterating over top-level steps, missing nested
children. Now uses buildStepMap to include all steps at any depth.
Added test case for map expansion over nested children.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
gitCommit() was adding the JSONL file but then committing ALL staged
changes (no pathspec). If other files were staged (e.g., deletions from
git add -A), they would be swept into the bd sync commit.
Fixed by adding pathspec to both gitCommit() and commitToExternalBeadsRepo()
so they only commit what they explicitly staged.
This was the root cause of PR #722 files being deleted - they were staged
for deletion in the working tree and got committed by bd sync.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Files from PR #722 were inadvertently removed by a bd sync commit.
Restoring: README.md, MOLECULES.md, PATTERNS.md, TROUBLESHOOTING.md,
INTEGRATION_PATTERNS.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The fix for GH#709 updated FindJSONLInDir to skip interactions.jsonl,
but the doctor check in CheckLegacyJSONLFilename was not updated.
This caused `bd doctor` to warn about multiple JSONL files when
both issues.jsonl and interactions.jsonl exist (which is normal
after `bd init`).
Also skip molecules.jsonl which is another system file that shouldn't
be counted as a duplicate issue database.
When a step is expanded (e.g., implement -> implement.draft, implement.refine-1,
etc.), any steps that depended on the original step should now depend on the
last step of the expansion.
Call UpdateDependenciesForExpansion after both expand and map operations.
Fixes gt-8tmz.3
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When bd cook encounters a circular extends chain (A extends B extends A),
the error message now shows the full chain: "cycle-a -> cycle-b -> cycle-a"
instead of just "circular extends detected: cycle-a".
This makes debugging circular dependencies much easier by showing exactly
which formulas are involved in the cycle.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add DefaultMaxExpansionDepth constant and depth tracking in expandStep
to prevent runaway nested expansions. The limit applies to template
children during expansion.
Changes:
- Add DefaultMaxExpansionDepth = 5 constant
- Update expandStep to track depth and return error when exceeded
- Update ApplyExpansions callers to handle errors
- Add TestExpandStepDepthLimit test for depth limiting
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Distilled protos (via `bd mol distill`) now get bd-proto-xxx IDs.
Summary of distinct prefixes:
- bd-proto-xxx: templates created via distill
- bd-mol-xxx: instances created via pour
- bd-wisp-xxx: ephemeral instances via wisp create
- bd-xxx: regular issues
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add expand and map operators that apply macro-style template expansion:
- expand(target, template) - replace a single step with expanded template
- map(select, template) - replace all matching steps with expanded template
The expansion formula type (e.g., rule-of-five) uses a template field with
{target} and {target.description} placeholders that are substituted when
applied to target steps.
Changes:
- Add Template field to Formula struct for expansion formulas
- Add ExpandRule and MapRule types to ComposeRules
- Implement ApplyExpansions in new expand.go
- Add LoadByName method to Parser for loading expansion formulas
- Integrate expansion into bd cook command
- Add comprehensive tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed prefix logic to combine the database prefix with the type prefix:
- bd-wisp-xxx (was: wisp-xxx)
- bd-mol-xxx (was: mol-xxx)
This ensures IDs like hq-wisp-xxx at town level and gt-mol-xxx for gastown,
maintaining database namespace while adding type recognition.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added type-specific ID prefixes for better visual recognition:
- `bd pour` now generates IDs with "mol-" prefix
- `bd wisp create` now generates IDs with "wisp-" prefix
- Regular issues continue using the configured prefix
Implementation:
- Added IDPrefix field to types.Issue (internal, not exported to JSONL)
- Added Prefix field to CloneOptions for spawning operations
- Added IDPrefix to RPC CreateArgs for daemon communication
- Updated storage layer to use issue.IDPrefix when generating IDs
- Updated pour.go and wisp.go to pass appropriate prefixes
This enables instant visual recognition of entity types and prevents
accidental modification of templates.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wisps are now just issues with Wisp=true flag in the main database,
not exported to JSONL. Removes all references to .beads-wisp/ directory.
- Update docs: CLAUDE.md, CLI_REFERENCE.md, MOLECULES.md, DELETIONS.md
- Update code comments: wisp.go
- Update changelog and info.go version notes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change file extension from .formula.yaml to .formula.json
- Replace gopkg.in/yaml.v3 with encoding/json in parser
- Remove yaml struct tags, keep json tags only
- Update all test cases to use JSON format
- Update documentation references
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bd should not assume specific orchestrator agents exist. Gates are just
data records - the orchestrator decides who processes them.
- Remove Assignee: deacon/ from gate creation
- Update help text to say orchestrator instead of Deacon patrol
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bd mol run was a convenience combo (pour + assign + pin + start) that
felt like orchestration but lived in the data layer. This blurred the
architectural boundary between bd (data) and gt (orchestration).
- Delete cmd/bd/mol_run.go entirely
- Update mol.go help text to remove run reference
- Update mol_current.go to suggest bd pour instead
gt spawn will implement the orchestration combo by calling the atomic
bd commands (pour, update, pin) directly.
Closes bd-00u3
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Two issues fixed:
1. bd-c8d5: mol run only created partial children from proto
- Root cause: children with missing/wrong dependencies were not loaded
- Fix: loadDescendants now uses two strategies:
- Strategy 1: Check dependency records for parent-child relationships
- Strategy 2: Find hierarchical children by ID pattern (parent.N)
- This catches children that may have broken dependency data
2. bd-drcx: mol run now supports proto lookup by title
- Can use: bd mol run mol-polecat-work --var issue=gt-xxx
- Or by ID: bd mol run gt-lwuu --var issue=gt-xxx
- Title matching is case-insensitive and supports partial matches
- Shows helpful error on ambiguous matches
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace fetchAndRebaseInWorktree with contentMergeRecovery in pushFromWorktree.
The problem: When push fails due to non-fast-forward, the old code used git
rebase to recover. But git rebase is text-level and does not invoke the JSONL
merge driver. This could resurrect tombstones - if remote had a tombstone and
local had closed, the rebase would overwrite the tombstone.
The fix: Use the same content-level merge algorithm that PullFromSyncBranch
uses. This respects tombstone semantics - recent tombstones always win over
live issues.
Changes:
- Add contentMergeRecovery() that does content-level merge instead of rebase
- Update pushFromWorktree to call contentMergeRecovery
- Mark fetchAndRebaseInWorktree as deprecated (kept for reference)
- Add tests for tombstone preservation during merge recovery
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wisps now use Wisp=true flag in the main database. The separate
.beads-wisp/ directory is no longer needed.
Removed:
- WispDirName constant
- FindWispDir()
- FindWispDatabasePath()
- NewWispStorage()
- EnsureWispGitignore()
- IsWispDatabase()
- All related tests
- .beads-wisp/ from .gitignore