feat: Support ephemeral protos: cook inline for pour/wisp/bond (bd-rciw)
Changes: - bd cook: outputs proto JSON to stdout by default, add --persist flag for legacy behavior (write to database) - bd pour: accepts formula names, cooks inline as ephemeral proto, spawns mol, then cleans up temporary proto - bd wisp create: accepts formula names, cooks inline as ephemeral proto, creates wisp, then cleans up temporary proto - bd mol bond: already supported ephemeral protos (gt-8tmz.25) The ephemeral proto pattern avoids persisting templates in the database. Protos are only needed temporarily during spawn operations - the spawned mol/wisp is what gets persisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
// - Proto (solid) -> pour -> Mol (liquid)
|
||||
// - Pour creates persistent, auditable work in .beads/
|
||||
var pourCmd = &cobra.Command{
|
||||
Use: "pour <proto-id>",
|
||||
Use: "pour <proto-id-or-formula>",
|
||||
Short: "Instantiate a proto as a persistent mol (solid -> liquid)",
|
||||
Long: `Pour a proto into a persistent mol - like pouring molten metal into a mold.
|
||||
|
||||
@@ -26,13 +26,20 @@ The resulting mol lives in .beads/ (permanent storage) and is synced with git.
|
||||
|
||||
Phase transition: Proto (solid) -> pour -> Mol (liquid)
|
||||
|
||||
The argument can be:
|
||||
- A proto ID (existing proto in database): bd pour mol-feature
|
||||
- A formula name (cooked inline): bd pour mol-feature --var name=auth
|
||||
|
||||
When given a formula name, pour cooks it inline as an ephemeral proto,
|
||||
spawns the mol, then cleans up the temporary proto (bd-rciw).
|
||||
|
||||
Use pour for:
|
||||
- Feature work that spans sessions
|
||||
- Important work needing audit trail
|
||||
- Anything you might need to reference later
|
||||
|
||||
Examples:
|
||||
bd pour mol-feature --var name=auth # Create persistent mol from proto
|
||||
bd pour mol-feature --var name=auth # Formula cooked inline
|
||||
bd pour mol-release --var version=1.0 # Release workflow
|
||||
bd pour mol-review --var pr=123 # Code review workflow`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
@@ -72,20 +79,28 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
vars[parts[0]] = parts[1]
|
||||
}
|
||||
|
||||
// Resolve proto ID
|
||||
protoID, err := utils.ResolvePartialID(ctx, store, args[0])
|
||||
// Resolve proto ID or cook formula inline (bd-rciw)
|
||||
// This accepts either:
|
||||
// - An existing proto ID: bd pour mol-feature
|
||||
// - A formula name: bd pour mol-feature (cooked inline as ephemeral proto)
|
||||
protoIssue, cookedProto, err := resolveOrCookFormula(ctx, store, args[0], actor)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error resolving proto ID %s: %v\n", args[0], err)
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Verify it's a proto
|
||||
protoIssue, err := store.GetIssue(ctx, protoID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error loading proto %s: %v\n", protoID, err)
|
||||
os.Exit(1)
|
||||
// Track cooked formula for cleanup
|
||||
cleanupCooked := func() {
|
||||
if cookedProto {
|
||||
_ = deleteProtoSubgraph(ctx, store, protoIssue.ID)
|
||||
}
|
||||
}
|
||||
|
||||
protoID := protoIssue.ID
|
||||
|
||||
// Verify it's a proto
|
||||
if !isProto(protoIssue) {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error: %s is not a proto (missing '%s' label)\n", protoID, MoleculeLabel)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -93,6 +108,7 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
// Load the proto subgraph
|
||||
subgraph, err := loadTemplateSubgraph(ctx, store, protoID)
|
||||
if err != nil {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error loading proto: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -107,20 +123,24 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
for _, attachArg := range attachFlags {
|
||||
attachID, err := utils.ResolvePartialID(ctx, store, attachArg)
|
||||
if err != nil {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error resolving attachment ID %s: %v\n", attachArg, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
attachIssue, err := store.GetIssue(ctx, attachID)
|
||||
if err != nil {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error loading attachment %s: %v\n", attachID, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !isProto(attachIssue) {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error: %s is not a proto (missing '%s' label)\n", attachID, MoleculeLabel)
|
||||
os.Exit(1)
|
||||
}
|
||||
attachSubgraph, err := loadTemplateSubgraph(ctx, store, attachID)
|
||||
if err != nil {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error loading attachment subgraph %s: %v\n", attachID, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -155,6 +175,7 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
}
|
||||
if len(missingVars) > 0 {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error: missing required variables: %s\n", strings.Join(missingVars, ", "))
|
||||
fmt.Fprintf(os.Stderr, "Provide them with: --var %s=<value>\n", missingVars[0])
|
||||
os.Exit(1)
|
||||
@@ -177,6 +198,10 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf(" + %s (%d issues)\n", attach.issue.Title, len(attach.subgraph.Issues))
|
||||
}
|
||||
}
|
||||
if cookedProto {
|
||||
fmt.Printf("\n Note: Formula cooked inline as ephemeral proto.\n")
|
||||
}
|
||||
cleanupCooked()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -184,6 +209,7 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
// bd-hobo: Use "mol" prefix for distinct visual recognition
|
||||
result, err := spawnMolecule(ctx, store, subgraph, vars, assignee, actor, false, "mol")
|
||||
if err != nil {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error pouring proto: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -193,6 +219,7 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
if len(attachments) > 0 {
|
||||
spawnedMol, err := store.GetIssue(ctx, result.NewEpicID)
|
||||
if err != nil {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error loading spawned mol: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -201,6 +228,7 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
// pour command always creates persistent (Wisp=false) issues
|
||||
bondResult, err := bondProtoMol(ctx, store, attach.issue, spawnedMol, attachType, vars, "", actor, false, true)
|
||||
if err != nil {
|
||||
cleanupCooked()
|
||||
fmt.Fprintf(os.Stderr, "Error attaching %s: %v\n", attach.id, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -208,16 +236,20 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up ephemeral proto after successful spawn (bd-rciw)
|
||||
cleanupCooked()
|
||||
|
||||
// Schedule auto-flush
|
||||
markDirtyAndScheduleFlush()
|
||||
|
||||
if jsonOutput {
|
||||
type pourResult struct {
|
||||
*InstantiateResult
|
||||
Attached int `json:"attached"`
|
||||
Phase string `json:"phase"`
|
||||
Attached int `json:"attached"`
|
||||
Phase string `json:"phase"`
|
||||
CookedInline bool `json:"cooked_inline,omitempty"`
|
||||
}
|
||||
outputJSON(pourResult{result, totalAttached, "liquid"})
|
||||
outputJSON(pourResult{result, totalAttached, "liquid", cookedProto})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -227,6 +259,9 @@ func runPour(cmd *cobra.Command, args []string) {
|
||||
if totalAttached > 0 {
|
||||
fmt.Printf(" Attached: %d issues from %d protos\n", totalAttached, len(attachments))
|
||||
}
|
||||
if cookedProto {
|
||||
fmt.Printf(" Ephemeral proto cleaned up after use.\n")
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user