refactor(mol): remove molecule.go (superseded by mol.go)
The simple single-issue instantiation in molecule.go is superseded by the full DAG-based mol commands. Use 'bd mol bond' for all molecule instantiation - it handles both single-issue and multi-issue molecules. Closes: bd-8b0x Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
{"id":"bd-7tuu","title":"Commit and push release","description":"git add -A \u0026\u0026 git commit \u0026\u0026 git push to trigger CI","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-19T22:56:02.053382-08:00","updated_at":"2025-12-20T01:23:52.484043-08:00","closed_at":"2025-12-20T01:23:52.484043-08:00","close_reason":"Superseded by 0.30.7 release - already committed and pushed","dependencies":[{"issue_id":"bd-7tuu","depends_on_id":"bd-6s61","type":"parent-child","created_at":"2025-12-19T22:56:15.021087-08:00","created_by":"daemon"},{"issue_id":"bd-7tuu","depends_on_id":"bd-hw3w","type":"blocks","created_at":"2025-12-19T22:56:23.291591-08:00","created_by":"daemon"}]}
|
||||
{"id":"bd-7yg","title":"Git merge driver uses invalid placeholders (%L, %R instead of %A, %B)","description":"## Problem\n\nThe beads git merge driver is configured with invalid Git placeholders:\n\n```\ngit config merge.beads.driver \"bd merge %A %O %L %R\"\n```\n\nGit doesn't recognize `%L` or `%R` as valid merge driver placeholders. The valid placeholders are:\n- `%O` = base (common ancestor)\n- `%A` = current version (ours)\n- `%B` = other version (theirs)\n\n## Impact\n\n- Affects ALL users when they have `.beads/beads.jsonl` merge conflicts\n- Automatic JSONL merge fails with error: \"error reading left file: failed to open file: open 7: no such file or directory\"\n- Users must manually resolve conflicts instead of getting automatic merge\n\n## Root Cause\n\nThe `bd init` command (or wherever the merge driver is configured) is using non-standard placeholders. When Git encounters `%L` and `%R`, it either passes them literally or interprets them incorrectly.\n\n## Fix\n\nUpdate the merge driver configuration to:\n```\ngit config merge.beads.driver \"bd merge %A %O %A %B\"\n```\n\nWhere:\n- 1st `%A` = output file (current file, will be overwritten)\n- `%O` = base (common ancestor)\n- 2nd `%A` = left/current version\n- `%B` = right/other version\n\n## Action Items\n\n1. Fix `bd init` (or equivalent setup command) to use correct placeholders\n2. Add migration/warning for existing users with misconfigured merge driver\n3. Update documentation with correct merge driver setup\n4. Consider adding validation when `bd init` is run","status":"closed","priority":1,"issue_type":"bug","created_at":"2025-11-21T19:51:55.747608-05:00","updated_at":"2025-12-17T23:13:40.532368-08:00","closed_at":"2025-12-17T17:24:52.678668-08:00"}
|
||||
{"id":"bd-89f89fc0","title":"Remove unreachable RPC methods","description":"Several RPC server and client methods are unreachable and should be removed:\n\nServer methods (internal/rpc/server.go):\n- `Server.GetLastImportTime` (line 2116)\n- `Server.SetLastImportTime` (line 2123)\n- `Server.findJSONLPath` (line 2255)\n\nClient methods (internal/rpc/client.go):\n- `Client.Import` (line 311) - RPC import not used (daemon uses autoimport)\n\nEvidence:\n```bash\ngo run golang.org/x/tools/cmd/deadcode@latest -test ./...\n```\n\nImpact: Removes ~80 LOC of unused RPC code","status":"closed","priority":2,"issue_type":"task","created_at":"2025-10-28T16:20:02.432202-07:00","updated_at":"2025-12-17T22:58:34.564401-08:00","closed_at":"2025-12-17T22:58:34.564401-08:00","close_reason":"Closed"}
|
||||
{"id":"bd-8b0x","title":"Remove molecule.go (simple instantiation)","description":"molecule.go uses is_template field for simple single-issue cloning. This is too simple for what molecules should be - full DAG orchestration. The use case is covered by bd mol bond with a single-issue molecule. Delete molecule.go and its commands.","status":"open","priority":2,"issue_type":"task","created_at":"2025-12-20T23:52:15.041776-08:00","updated_at":"2025-12-20T23:52:15.041776-08:00","dependencies":[{"issue_id":"bd-8b0x","depends_on_id":"bd-ffjt","type":"blocks","created_at":"2025-12-20T23:52:25.807967-08:00","created_by":"daemon"}]}
|
||||
{"id":"bd-8b0x","title":"Remove molecule.go (simple instantiation)","description":"molecule.go uses is_template field for simple single-issue cloning. This is too simple for what molecules should be - full DAG orchestration. The use case is covered by bd mol bond with a single-issue molecule. Delete molecule.go and its commands.","status":"in_progress","priority":2,"issue_type":"task","created_at":"2025-12-20T23:52:15.041776-08:00","updated_at":"2025-12-21T00:03:59.388461-08:00","dependencies":[{"issue_id":"bd-8b0x","depends_on_id":"bd-ffjt","type":"blocks","created_at":"2025-12-20T23:52:25.807967-08:00","created_by":"daemon"}]}
|
||||
{"id":"bd-8e0q","title":"Merge: beads-ocs","description":"branch: polecat/valkyrie\ntarget: main\nsource_issue: beads-ocs\nrig: beads","status":"closed","priority":2,"issue_type":"merge-request","created_at":"2025-12-19T23:24:45.281478-08:00","updated_at":"2025-12-20T23:17:26.995706-08:00","closed_at":"2025-12-20T23:17:26.995706-08:00","close_reason":"Branches nuked, MRs obsolete"}
|
||||
{"id":"bd-8fgn","title":"test hash length","status":"tombstone","priority":2,"issue_type":"task","created_at":"2025-12-16T13:49:32.113843-08:00","updated_at":"2025-12-17T16:11:17.070763-08:00","deleted_at":"2025-12-17T16:11:17.070763-08:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"task"}
|
||||
{"id":"bd-8g8","title":"Fix G304 potential file inclusion in cmd/bd/tips.go:259","description":"Linting issue: G304: Potential file inclusion via variable (gosec) at cmd/bd/tips.go:259:18. Error: if data, err := os.ReadFile(settingsPath); err == nil {","status":"closed","issue_type":"bug","created_at":"2025-12-07T15:34:57.189730843-07:00","updated_at":"2025-12-17T23:13:40.534569-08:00","closed_at":"2025-12-17T16:46:11.029837-08:00"}
|
||||
@@ -148,7 +148,7 @@
|
||||
{"id":"bd-f3ll","title":"Merge: bd-ot0w","description":"branch: polecat/dementus\ntarget: main\nsource_issue: bd-ot0w\nrig: beads","status":"closed","priority":2,"issue_type":"merge-request","created_at":"2025-12-19T23:20:33.495772-08:00","updated_at":"2025-12-20T23:17:27.000252-08:00","closed_at":"2025-12-20T23:17:27.000252-08:00","close_reason":"Branches nuked, MRs obsolete"}
|
||||
{"id":"bd-f5cc","title":"Thread Test","description":"Testing the thread feature","status":"tombstone","priority":2,"issue_type":"message","created_at":"2025-12-16T18:21:01.244501-08:00","updated_at":"2025-12-17T16:11:17.070763-08:00","dependencies":[{"issue_id":"bd-f5cc","depends_on_id":"bd-x36g","type":"supersedes","created_at":"2025-12-18T13:45:31.137191-08:00","created_by":"migration"}],"deleted_at":"2025-12-17T16:11:17.070763-08:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"message"}
|
||||
{"id":"bd-fa2h","title":"🤝 HANDOFF: v0.31.0 released, molecules discussion","description":"Session completed 0.31.0 release and had important molecules discussion.\n\n## Completed\n- v0.31.0 released (deferred status, audit trail, directory labels, etc.)\n- Fixed lint issues, hook version markers, codesigning\n- All CI green, artifacts verified\n\n## Filed Issues\n- bd-usro: Rename template instantiate → bd mol bond\n- bd-y8bj: Auto-detect identity for bd mail (P1 bug)\n- gt-975: Molecule execution support for polecats/crew\n- gt-976: Crew lifecycle support in Deacon\n\n## Key Insight\nMolecules are the future - TodoWrite is ephemeral, molecules are persistent institutional memory on the world chain. I tried to use TodoWrite for version bump and missed steps (codesigning, MCP verification). Molecules would have caught this.\n\n## Next Steps\n- bd mol bond implementation is priority\n- Max has gt-976 for crew lifecycle (enables automated refresh mid-molecule)\n\nCheck bd ready and gt-975/976 status.","status":"open","priority":2,"issue_type":"message","assignee":"beads/crew/dave","created_at":"2025-12-20T17:23:09.889562-08:00","updated_at":"2025-12-20T17:23:09.889562-08:00","sender":"Steve Yegge","ephemeral":true}
|
||||
{"id":"bd-ffjt","title":"Unify template.go and mol.go under bd mol","description":"Consolidate the two DAG-template systems into one under the mol command. mol.go (on rictus branch) has the right UX (catalog/show/bond), template.go has the mechanics. Merge them, deprecate bd template commands.","status":"in_progress","priority":1,"issue_type":"task","created_at":"2025-12-20T23:52:13.208972-08:00","updated_at":"2025-12-20T23:55:11.522661-08:00"}
|
||||
{"id":"bd-ffjt","title":"Unify template.go and mol.go under bd mol","description":"Consolidate the two DAG-template systems into one under the mol command. mol.go (on rictus branch) has the right UX (catalog/show/bond), template.go has the mechanics. Merge them, deprecate bd template commands.","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-20T23:52:13.208972-08:00","updated_at":"2025-12-21T00:01:59.283765-08:00","closed_at":"2025-12-21T00:01:59.283765-08:00","close_reason":"Implemented mol commands with deprecation for template commands"}
|
||||
{"id":"bd-fgw3","title":"Update local installation","description":"Run install script or brew upgrade to get new version locally: curl -fsSL .../install.sh | bash","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-19T22:56:05.052016-08:00","updated_at":"2025-12-20T00:49:51.928221-08:00","closed_at":"2025-12-20T00:25:52.805029-08:00","dependencies":[{"issue_id":"bd-fgw3","depends_on_id":"bd-6s61","type":"parent-child","created_at":"2025-12-19T22:56:15.248427-08:00","created_by":"daemon"},{"issue_id":"bd-fgw3","depends_on_id":"bd-si4g","type":"blocks","created_at":"2025-12-19T22:56:23.497325-08:00","created_by":"daemon"}]}
|
||||
{"id":"bd-fi05","title":"bd sync fails with orphaned issues and duplicate ID conflict","description":"After fixing the deleted_at TEXT column scanning bug (commit 18b1eb2), bd sync still fails with two issues:\n\n1. Orphan Detection Warning: 12 orphaned child issues whose parents no longer exist (bd-cb64c226.* and bd-cbed9619.*)\n\n2. Import Failure: UNIQUE constraint failed for bd-360 - this tombstone exists in both DB and JSONL\n\nError: \"Import failed: error creating depth-0 issues: bulk insert issues: failed to insert issue bd-360: sqlite3: constraint failed: UNIQUE constraint failed: issues.id\"\n\nFix options:\n- Delete orphaned child issues with bd delete\n- Resolve bd-360 duplicate (in deletions.jsonl vs tombstone in DB)\n- Reset sync branch: git branch -f beads-sync main \u0026\u0026 git push --force-with-lease origin beads-sync","notes":"Fixed tombstone constraint violation bug. When deleting closed issues, the CHECK constraint (status = 'closed') = (closed_at IS NOT NULL) was violated because CreateTombstone didn't clear closed_at. Fix: set closed_at = NULL in tombstone creation SQL.\n\nThe sync data corruption (orphaned issues in beads-sync branch) requires manual cleanup: reset sync branch with 'git branch -f beads-sync main \u0026\u0026 git push --force-with-lease origin beads-sync'","status":"closed","priority":2,"issue_type":"bug","created_at":"2025-12-13T07:14:33.831346-08:00","updated_at":"2025-12-13T10:50:48.545465-08:00","closed_at":"2025-12-13T07:30:33.843986-08:00"}
|
||||
{"id":"bd-fom","title":"Remove all deletions.jsonl code except migration","description":"There's deletions manifest code spread across the entire codebase that should have been removed after tombstone migration:\n\nFiles with deletions code (non-migration):\n- internal/deletions/ - entire package\n- cmd/bd/sync.go - 25+ references, auto-compact, sanitize\n- cmd/bd/delete.go - dual-writes to deletions.jsonl\n- internal/importer/importer.go - checks deletions manifest\n- internal/syncbranch/worktree.go - merges deletions.jsonl\n- cmd/bd/doctor/fix/sync.go - cleanupDeletionsManifest\n- cmd/bd/doctor/fix/deletions.go - HydrateDeletionsManifest\n- cmd/bd/integrity.go - checks deletions for data loss\n- cmd/bd/deleted.go - entire command\n- cmd/bd/compact.go - pruneDeletionsManifest\n- cmd/bd/doctor.go - checkDeletionsManifest\n- Plus many more\n\nAction: Aggressively remove all non-migration deletions code. Tombstones are the only deletion mechanism now.","status":"tombstone","priority":1,"issue_type":"task","created_at":"2025-12-16T13:29:04.960863-08:00","updated_at":"2025-12-17T16:11:17.070763-08:00","deleted_at":"2025-12-17T16:11:17.070763-08:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"task"}
|
||||
|
||||
40
@AGENTS.md
Normal file
40
@AGENTS.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Agent Instructions
|
||||
|
||||
This project uses **bd** (beads) for issue tracking. Run `bd onboard` to get started.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
bd ready # Find available work
|
||||
bd show <id> # View issue details
|
||||
bd update <id> --status in_progress # Claim work
|
||||
bd close <id> # Complete work
|
||||
bd sync # Sync with git
|
||||
```
|
||||
|
||||
## Landing the Plane (Session Completion)
|
||||
|
||||
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
|
||||
|
||||
**MANDATORY WORKFLOW:**
|
||||
|
||||
1. **File issues for remaining work** - Create issues for anything that needs follow-up
|
||||
2. **Run quality gates** (if code changed) - Tests, linters, builds
|
||||
3. **Update issue status** - Close finished work, update in-progress items
|
||||
4. **PUSH TO REMOTE** - This is MANDATORY:
|
||||
```bash
|
||||
git pull --rebase
|
||||
bd sync
|
||||
git push
|
||||
git status # MUST show "up to date with origin"
|
||||
```
|
||||
5. **Clean up** - Clear stashes, prune remote branches
|
||||
6. **Verify** - All changes committed AND pushed
|
||||
7. **Hand off** - Provide context for next session
|
||||
|
||||
**CRITICAL RULES:**
|
||||
- Work is NOT complete until `git push` succeeds
|
||||
- NEVER stop before pushing - that leaves work stranded locally
|
||||
- NEVER say "ready to push when you are" - YOU must push
|
||||
- If push fails, resolve and retry until it succeeds
|
||||
|
||||
@@ -1,353 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads/internal/hooks"
|
||||
"github.com/steveyegge/beads/internal/rpc"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
)
|
||||
|
||||
var moleculeCmd = &cobra.Command{
|
||||
Use: "molecule",
|
||||
Short: "Manage template molecules",
|
||||
Long: `Manage template molecules for issue instantiation.
|
||||
|
||||
Molecules are template issues that can be instantiated to create work items.
|
||||
They are stored in molecules.jsonl and marked with is_template=true.
|
||||
|
||||
Examples:
|
||||
bd molecule list # List all available molecules
|
||||
bd molecule show mol-123 # Show details of a molecule
|
||||
`,
|
||||
}
|
||||
|
||||
var moleculeListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List available molecules",
|
||||
Long: `List all available template molecules.
|
||||
|
||||
Templates are read-only issues that can be instantiated to create work items.
|
||||
Use --all to include closed molecules.
|
||||
|
||||
Examples:
|
||||
bd molecule list # List open molecules
|
||||
bd molecule list --all # List all molecules including closed
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
showAll, _ := cmd.Flags().GetBool("all")
|
||||
|
||||
ctx := rootCtx
|
||||
if daemonClient == nil {
|
||||
if err := ensureDatabaseFresh(ctx); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Build filter for template molecules
|
||||
isTemplate := true
|
||||
filter := types.IssueFilter{
|
||||
IsTemplate: &isTemplate,
|
||||
}
|
||||
|
||||
if !showAll {
|
||||
// Default to non-closed
|
||||
status := types.StatusOpen
|
||||
filter.Status = &status
|
||||
}
|
||||
|
||||
// Direct mode only for now
|
||||
if store == nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: database not available\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
issues, err := store.SearchIssues(ctx, "", filter)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(issues) == 0 {
|
||||
fmt.Println("No molecules found")
|
||||
return
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
outputJSON(issues)
|
||||
return
|
||||
}
|
||||
|
||||
// Print molecule list
|
||||
for _, issue := range issues {
|
||||
priorityStr := fmt.Sprintf("P%d", issue.Priority)
|
||||
fmt.Printf("%s [%s] %s\n", issue.ID, priorityStr, issue.Title)
|
||||
}
|
||||
fmt.Printf("\n%d molecule(s)\n", len(issues))
|
||||
},
|
||||
}
|
||||
|
||||
var moleculeShowCmd = &cobra.Command{
|
||||
Use: "show <molecule-id>",
|
||||
Short: "Show molecule details",
|
||||
Long: `Show detailed information about a template molecule.
|
||||
|
||||
Examples:
|
||||
bd molecule show mol-123
|
||||
`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
moleculeID := args[0]
|
||||
|
||||
ctx := rootCtx
|
||||
if daemonClient == nil {
|
||||
if err := ensureDatabaseFresh(ctx); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if store == nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: database not available\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
issue, err := store.GetIssue(ctx, moleculeID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if issue == nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: molecule %s not found\n", moleculeID)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !issue.IsTemplate {
|
||||
fmt.Fprintf(os.Stderr, "Warning: %s is not a template molecule\n", moleculeID)
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
outputJSON(issue)
|
||||
return
|
||||
}
|
||||
|
||||
// Print molecule details
|
||||
fmt.Printf("%s: %s\n", issue.ID, issue.Title)
|
||||
fmt.Printf("Type: %s\n", issue.IssueType)
|
||||
fmt.Printf("Priority: P%d\n", issue.Priority)
|
||||
fmt.Printf("Status: %s\n", issue.Status)
|
||||
fmt.Printf("Template: %v\n", issue.IsTemplate)
|
||||
|
||||
if issue.Description != "" {
|
||||
fmt.Printf("\nDescription:\n%s\n", issue.Description)
|
||||
}
|
||||
|
||||
if issue.Design != "" {
|
||||
fmt.Printf("\nDesign:\n%s\n", issue.Design)
|
||||
}
|
||||
|
||||
if issue.AcceptanceCriteria != "" {
|
||||
fmt.Printf("\nAcceptance Criteria:\n%s\n", issue.AcceptanceCriteria)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var moleculeInstantiateCmd = &cobra.Command{
|
||||
Use: "instantiate <molecule-id>",
|
||||
Short: "Create a work item from a template molecule",
|
||||
Long: `Create a new work item based on a template molecule.
|
||||
|
||||
The new issue will inherit the template's title, description, design,
|
||||
acceptance criteria, priority, and issue type. The new issue will have
|
||||
is_template=false and will be linked to the template via a discovered-from
|
||||
dependency.
|
||||
|
||||
Examples:
|
||||
bd molecule instantiate mol-123 # Create work item from template
|
||||
bd molecule instantiate mol-123 --title "Custom title" # Override title
|
||||
`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
CheckReadonly("instantiate")
|
||||
moleculeID := args[0]
|
||||
|
||||
// Get flag overrides
|
||||
titleOverride, _ := cmd.Flags().GetString("title")
|
||||
assignee, _ := cmd.Flags().GetString("assignee")
|
||||
|
||||
ctx := rootCtx
|
||||
if daemonClient == nil {
|
||||
if err := ensureDatabaseFresh(ctx); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if store == nil && daemonClient == nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: database not available\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Get the template molecule
|
||||
var template *types.Issue
|
||||
var err error
|
||||
|
||||
if daemonClient != nil {
|
||||
showArgs := &rpc.ShowArgs{ID: moleculeID}
|
||||
resp, showErr := daemonClient.Show(showArgs)
|
||||
if showErr != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", showErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
template = &types.Issue{}
|
||||
if jsonErr := json.Unmarshal(resp.Data, template); jsonErr != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error parsing response: %v\n", jsonErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
template, err = store.GetIssue(ctx, moleculeID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if template == nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: molecule %s not found\n", moleculeID)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !template.IsTemplate {
|
||||
fmt.Fprintf(os.Stderr, "Warning: %s is not a template molecule (is_template=false)\n", moleculeID)
|
||||
}
|
||||
|
||||
// Build title (use override or template title)
|
||||
title := template.Title
|
||||
if titleOverride != "" {
|
||||
title = titleOverride
|
||||
}
|
||||
|
||||
// Create the new work item
|
||||
if daemonClient != nil {
|
||||
// Daemon mode
|
||||
createArgs := &rpc.CreateArgs{
|
||||
Title: title,
|
||||
Description: template.Description,
|
||||
IssueType: string(template.IssueType),
|
||||
Priority: template.Priority,
|
||||
Design: template.Design,
|
||||
AcceptanceCriteria: template.AcceptanceCriteria,
|
||||
Assignee: assignee,
|
||||
Dependencies: []string{"discovered-from:" + moleculeID},
|
||||
}
|
||||
|
||||
resp, createErr := daemonClient.Create(createArgs)
|
||||
if createErr != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", createErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var issue types.Issue
|
||||
if jsonErr := json.Unmarshal(resp.Data, &issue); jsonErr != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error parsing response: %v\n", jsonErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Run create hook
|
||||
if hookRunner != nil {
|
||||
hookRunner.Run(hooks.EventCreate, &issue)
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
outputJSON(&issue)
|
||||
} else {
|
||||
fmt.Printf("%s Created work item: %s (from template %s)\n", ui.RenderPass("✓"), issue.ID, moleculeID)
|
||||
fmt.Printf(" Title: %s\n", issue.Title)
|
||||
fmt.Printf(" Priority: P%d\n", issue.Priority)
|
||||
fmt.Printf(" Status: %s\n", issue.Status)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Direct mode
|
||||
now := time.Now()
|
||||
issue := &types.Issue{
|
||||
Title: title,
|
||||
Description: template.Description,
|
||||
Design: template.Design,
|
||||
AcceptanceCriteria: template.AcceptanceCriteria,
|
||||
Status: types.StatusOpen,
|
||||
Priority: template.Priority,
|
||||
IssueType: template.IssueType,
|
||||
Assignee: assignee,
|
||||
IsTemplate: false, // Work items are not templates
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := store.CreateIssue(ctx, issue, actor); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error creating issue: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Get the created issue (ID is set by CreateIssue)
|
||||
createdIssue, err := store.GetIssue(ctx, issue.ID)
|
||||
if err != nil || createdIssue == nil {
|
||||
fmt.Fprintf(os.Stderr, "Error getting created issue: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Add discovered-from dependency to template
|
||||
dep := &types.Dependency{
|
||||
IssueID: createdIssue.ID,
|
||||
DependsOnID: moleculeID,
|
||||
Type: types.DepDiscoveredFrom,
|
||||
CreatedAt: now,
|
||||
CreatedBy: actor,
|
||||
}
|
||||
if err := store.AddDependency(ctx, dep, actor); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to add dependency to template: %v\n", err)
|
||||
}
|
||||
|
||||
// Run create hook
|
||||
if hookRunner != nil {
|
||||
hookRunner.Run(hooks.EventCreate, createdIssue)
|
||||
}
|
||||
|
||||
// Schedule auto-flush
|
||||
markDirtyAndScheduleFlush()
|
||||
|
||||
if jsonOutput {
|
||||
outputJSON(createdIssue)
|
||||
} else {
|
||||
fmt.Printf("%s Created work item: %s (from template %s)\n", ui.RenderPass("✓"), createdIssue.ID, moleculeID)
|
||||
fmt.Printf(" Title: %s\n", createdIssue.Title)
|
||||
fmt.Printf(" Priority: P%d\n", createdIssue.Priority)
|
||||
fmt.Printf(" Status: %s\n", createdIssue.Status)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Add subcommands
|
||||
moleculeCmd.AddCommand(moleculeListCmd)
|
||||
moleculeCmd.AddCommand(moleculeShowCmd)
|
||||
moleculeCmd.AddCommand(moleculeInstantiateCmd)
|
||||
|
||||
// Flags for list command
|
||||
moleculeListCmd.Flags().Bool("all", false, "Include closed molecules")
|
||||
|
||||
// Flags for instantiate command
|
||||
moleculeInstantiateCmd.Flags().String("title", "", "Override the template title")
|
||||
moleculeInstantiateCmd.Flags().StringP("assignee", "a", "", "Assign the new work item")
|
||||
|
||||
// Add molecule command to root
|
||||
rootCmd.AddCommand(moleculeCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user