Commit Graph

4033 Commits

Author SHA1 Message Date
Steve Yegge
47cc84de3a fix(docs): standardize sync branch name and daemon syntax (GH#376)
- Replace beads-metadata with beads-sync throughout docs
  (matches code default and internal examples)
- Fix bd daemon start → bd daemon --start (correct flag syntax)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:22:09 -08:00
Steve Yegge
3034fc392e fix(doctor): handle installed_plugins.json v2 format (GH#741)
Claude Code's installed_plugins.json changed from v1 (plugins as structs)
to v2 (plugins as arrays). Update GetClaudePluginVersion() to handle both.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:20:02 -08:00
Steve Yegge
a42fac8cb9 feat: Add on_complete/for-each runtime expansion types (gt-8tmz.8)
Implements the schema and validation for runtime dynamic expansion:

- Add OnCompleteSpec type for step completion triggers
- Add on_complete field to Step struct
- Validate for_each path format (must start with "output.")
- Validate bond is required with for_each (and vice versa)
- Validate parallel and sequential are mutually exclusive
- Add cloneOnComplete for proper step cloning
- Add comprehensive tests for parsing and validation

The runtime executor (in gastown) will interpret these fields to:
- Bond N molecules when step completes based on output.collection
- Run bonded molecules in parallel or sequential order
- Pass item/index context via vars substitution

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:07:57 -08:00
Steve Yegge
8b5168f1a3 fix: Control flow review fixes (gt-8tmz.4)
Critical bug fixes identified during code review:

1. External dependency rewriting: Dependencies on steps OUTSIDE the loop
   are now preserved as-is instead of being incorrectly prefixed.

2. Children dependency rewriting: Child step dependencies are now properly
   rewritten with iteration context.

3. Missing fields: Added Expand, ExpandVars, Gate fields to loop expansion.

4. Condition validation: Loop `until` conditions are now validated with
   ParseCondition to catch syntax errors early.

5. Label format: Changed gate and loop labels from colon-delimited to
   JSON format for unambiguous parsing:
   - gate:{"condition":"expr"}
   - loop:{"until":"expr","max":N}

Added TestApplyLoops_ExternalDependencies 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-25 15:02:07 -08:00
Steve Yegge
4f065024b5 feat: Implement control flow operators (gt-8tmz.4)
Add loop, branch, and gate operators for formula step transformation:

- LoopSpec: Fixed-count loops expand body N times with chained iterations.
  Conditional loops expand once with runtime metadata labels.
- BranchRule: Fork-join patterns wire dependencies for parallel paths.
- GateRule: Adds condition labels for runtime evaluation before steps.

Types added to types.go:
- LoopSpec (count/until/max/body)
- BranchRule (from/steps/join)
- GateRule (before/condition)
- Loop field on Step
- Branch/Gate arrays on ComposeRules

New controlflow.go with ApplyLoops, ApplyBranches, ApplyGates, and
ApplyControlFlow convenience function. Wired into cook.go before
advice and expansion operators.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:52:21 -08:00
Steve Yegge
2ff17686d0 feat(prime): add no-git-ops config to disable git ops in session close (GH#593)
Users who want manual control over git commits can now set:

  bd config set no-git-ops true

This makes `bd prime` output the stealth-mode session close protocol
(just `bd sync --flush-only`) instead of the full git add/commit/push
workflow. Useful when:

- You want to verify work before committing
- Claude tries to auto-commit after context compaction
- You have a custom git workflow

The --stealth flag still works as before for one-off use.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:25:45 -08:00
Steve Yegge
6d23689736 fix(init): guard git.IsWorktree() with isGitRepo() check (GH#727)
On Windows, running `bd init` outside a git repository could hang
indefinitely because git.IsWorktree() runs `git rev-parse --git-dir`
which may hang on Windows when not in a git repo.

The fix adds an isGitRepo() check before calling git.IsWorktree() in
both the main init flow and the checkExistingBeadsData helper.

Regression introduced in e01b7412 (Git worktree compatibility).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:13:59 -08:00
Steve Yegge
d2b1656c5d fix: Make child→parent dep fix opt-in with --fix-child-parent (bd-cuek)
GH#740: bd doctor --fix was auto-removing child→parent dependencies,
calling them an 'anti-pattern'. While these often indicate modeling
mistakes (deadlock), they may be intentional in some workflows.

Changes:
- Add --fix-child-parent flag (required to remove child→parent deps)
- Remove ChildParentDependencies from default --fix set
- Update warning message to reference new flag
- Update comments to reflect more nuanced understanding

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:05:55 -08:00
Steve Yegge
c9aa755ddc fix: Address code review issues in condition evaluator
- Empty set 'all' returns false (avoids premature gate passing)
- Add proper error handling for Atoi in count comparisons
- Extract inline regex to package-level var (performance)
- Handle == and != in compareString function
- Add nil/bool value handling in compare function
- Add tests for edge cases: empty children, nil output, bool values

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:00:56 -08:00
Steve Yegge
efdaa93789 fix: Use FatalErrorRespectJSON across all commands (bd-28sq)
Convert all fmt.Fprintf(os.Stderr, ...) + os.Exit(1) patterns to use
FatalErrorRespectJSON for consistent JSON error output:
- dep.go: dependency commands (add, remove, tree, cycles)
- label.go: label commands (add, remove, list, list-all)
- comments.go: comment commands (list, add)
- epic.go: epic commands (status, close-eligible)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 13:56:19 -08:00
Steve Yegge
f56f3615e8 feat: Add condition evaluator for gates and loops (gt-8tmz.7)
Implements mechanical condition evaluation for formula control flow:
- Step status checks: step.status == 'complete'
- Step output access: step.output.approved == true
- Aggregates: children(step).all(status == 'complete'), steps.complete >= 3
- External checks: file.exists('go.mod'), env.CI == 'true'

Conditions are intentionally limited to keep evaluation decidable.
No arbitrary code execution allowed.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 13:54:21 -08:00
Steve Yegge
d9bf695791 fix: Use FatalErrorRespectJSON for JSON-consistent error output (bd-28sq.1)
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
2025-12-25 13:41:06 -08:00
Steve Yegge
6da9610ba6 bd sync: 2025-12-25 13:40:56 2025-12-25 13:40:56 -08:00
Steve Yegge
e7735f0083 bd sync: 2025-12-25 13:32:48 2025-12-25 13:32:57 -08:00
Steve Yegge
29501c7aeb feat: Add stale molecules check to bd doctor (bd-6a5z)
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>
2025-12-25 12:42:55 -08:00
Steve Yegge
df3a6bff43 bd sync: 2025-12-25 12:42:51 2025-12-25 12:42:51 -08:00
Steve Yegge
09d053233e feat: Add bd formula list/show commands (gt-8tmz.14)
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>
2025-12-25 12:38:00 -08:00
Steve Yegge
92e99c8201 feat: Add bd mol stale command to detect complete-but-unclosed molecules (bd-anv2)
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>
2025-12-25 12:31:24 -08:00
Steve Yegge
fe661887ae bd sync: 2025-12-25 12:31:14 2025-12-25 12:31:14 -08:00
Steve Yegge
fd57f61f34 fix: Prevent aspect self-matching infinite recursion (gt-8tmz.16)
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>
2025-12-25 12:21:23 -08:00
Steve Yegge
6311fbaebf bd sync: 2025-12-25 12:18:37 2025-12-25 12:18:37 -08:00
Steve Yegge
71dc671dd6 bd sync: 2025-12-25 12:18:21 2025-12-25 12:18:21 -08:00
Steve Yegge
516c62e543 feat: Add aspect composition support (gt-8tmz.5)
- 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>
2025-12-25 12:15:12 -08:00
Steve Yegge
de1a9559fa fix: Map expansion now matches nested child steps (gt-8tmz.33)
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>
2025-12-25 12:08:05 -08:00
Steve Yegge
2f9d423ac8 fix: Prevent bd sync from committing non-.beads files (bd-trgb)
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>
2025-12-25 12:05:46 -08:00
Steve Yegge
2392496b0c bd sync: 2025-12-25 12:05:37 2025-12-25 12:05:37 -08:00
Steve Yegge
451c9e4630 bd sync: 2025-12-25 11:56:39 2025-12-25 11:56:47 -08:00
Steve Yegge
257ed9bdae fix: Restore skill files accidentally deleted by bd sync (GH#738)
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>
2025-12-25 11:56:30 -08:00
Dirceu Pereira Tiegs
939ade731f fix: doctor check skips interactions.jsonl and molecules.jsonl (GH#709) (#739)
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.
2025-12-25 11:52:43 -08:00
Steve Yegge
acb4aeee55 Fix misleading comment in replaceStep 2025-12-25 11:51:03 -08:00
Steve Yegge
b82d0e7c0f Fix expansion operators: update dependencies after expansion
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>
2025-12-25 11:44:28 -08:00
Steve Yegge
127a36dd5f Formula cycle detection: show full extends chain in error message (gt-8tmz.15)
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>
2025-12-25 02:33:22 -08:00
Steve Yegge
84c124fc3d Implement max expansion depth limit (default 5) (gt-8tmz.17)
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>
2025-12-25 02:23:20 -08:00
Steve Yegge
9451eeca03 bd sync: 2025-12-25 02:05:15 2025-12-25 02:18:33 -08:00
Steve Yegge
fca9e540a3 bd sync: 2025-12-25 01:50:05 2025-12-25 02:18:33 -08:00
Steve Yegge
c7bc8e6ca7 feat: Add proto prefix for distilled molecules (bd-hobo)
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>
2025-12-25 02:11:52 -08:00
Steve Yegge
cfb1196044 Implement expansion operators for formula composition (gt-8tmz.3)
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>
2025-12-25 02:11:03 -08:00
Steve Yegge
9c1bf7d4ea fix: Combine db prefix with type prefix for mol/wisp IDs (bd-hobo)
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>
2025-12-25 02:10:08 -08:00
Steve Yegge
f78fe883d0 feat: Distinct prefixes for protos, molecules, wisps (bd-hobo)
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>
2025-12-25 02:05:25 -08:00
Steve Yegge
a643b9ab67 Implement advice operators for formula composition (gt-8tmz.2)
Add Lisp-style advice operators to the formula DSL:
- before(target, step) - insert step before target
- after(target, step) - insert step after target
- around(target, wrapper) - wrap target with before/after

Features:
- Glob pattern matching for targets (*.implement, shiny.*, etc)
- Pointcut matching by type or label
- Step reference substitution ({step.id}, {step.title})
- Automatic dependency chaining

New types: AdviceRule, AdviceStep, AroundAdvice, Pointcut
New functions: ApplyAdvice, MatchGlob, MatchPointcut

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 01:53:43 -08:00
Steve Yegge
e068ac574f refactor: Simplify wisp architecture - badges not separate storage
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>
2025-12-25 01:49:57 -08:00
Steve Yegge
e6ce0d6365 refactor: Switch formula format from YAML to JSON
- 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>
2025-12-25 01:37:22 -08:00
Steve Yegge
a8ec1d6483 bd sync: 2025-12-25 01:21:15 2025-12-25 01:21:15 -08:00
Steve Yegge
9314f20092 Remove hardcoded deacon assignee from gate.go
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>
2025-12-25 01:14:53 -08:00
Steve Yegge
dd0fb7ce90 Remove bd mol run - orchestration belongs in gt
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>
2025-12-25 01:05:16 -08:00
Steve Yegge
812832496c bd sync: 2025-12-25 01:05:06 2025-12-25 01:05:06 -08:00
Steve Yegge
8b6a8cf8f8 bd sync: 2025-12-25 00:59:25 2025-12-25 00:59:37 -08:00
Steve Yegge
c429405e0d fix: mol run loads all hierarchical children + supports title lookup (bd-c8d5, bd-drcx)
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>
2025-12-24 23:33:34 -08:00
Steve Yegge
81171ff237 bd sync: 2025-12-24 23:32:27 2025-12-24 23:32:27 -08:00
Steve Yegge
fecbc5be76 bd sync: 2025-12-24 23:12:58 2025-12-24 23:12:58 -08:00