feat: add dynamic molecule bonding with --ref flag (bd-xo1o.1)

Implements the Christmas Ornament pattern for patrol molecules:
- Add CloneOptions struct with ParentID and ChildRef for dynamic bonding
- Add generateBondedID() to create custom IDs like "patrol-x7k.arm-ace"
- Add --ref flag to `bd mol bond` for custom child references
- Variable substitution in childRef (e.g., "arm-{{polecat_name}}")

This enables:
  bd mol bond mol-polecat-arm bd-patrol --ref arm-{{name}} --var name=ace
  # Creates: bd-patrol.arm-ace, bd-patrol.arm-ace.capture, etc.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-23 03:38:24 -08:00
parent 3c86144d26
commit ee04b1ea96
7 changed files with 525 additions and 38 deletions

View File

@@ -64,7 +64,19 @@ Commands:
// Wraps cloneSubgraph from template.go and returns InstantiateResult.
// If ephemeral is true, spawned issues are marked for bulk deletion when closed.
func spawnMolecule(ctx context.Context, s storage.Storage, subgraph *MoleculeSubgraph, vars map[string]string, assignee string, actorName string, ephemeral bool) (*InstantiateResult, error) {
return cloneSubgraph(ctx, s, subgraph, vars, assignee, actorName, ephemeral)
opts := CloneOptions{
Vars: vars,
Assignee: assignee,
Actor: actorName,
Wisp: ephemeral,
}
return cloneSubgraph(ctx, s, subgraph, opts)
}
// spawnMoleculeWithOptions creates new issues from the proto using CloneOptions.
// This allows full control over dynamic bonding, variable substitution, and wisp phase.
func spawnMoleculeWithOptions(ctx context.Context, s storage.Storage, subgraph *MoleculeSubgraph, opts CloneOptions) (*InstantiateResult, error) {
return cloneSubgraph(ctx, s, subgraph, opts)
}
// printMoleculeTree prints the molecule structure as a tree