gitgram/aitimemachine/beads/cmd/bd/show_children.go
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

129 lines
3.4 KiB
Go

package main
import (
"context"
"fmt"
"os"
"strings"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/uimd"
)
// showIssueChildren displays only the children of the specified issue(s)
func showIssueChildren(ctx context.Context, args []string, jsonOut bool, shortMode bool) {
// Collect all children for all issues
allChildren := make(map[string][]*types.IssueWithDependencyMetadata)
// Process each issue to get its children
processIssue := func(issueID string, issueStore storage.DoltStorage) error {
// Initialize entry so "no children" message can be shown
if _, exists := allChildren[issueID]; !exists {
allChildren[issueID] = []*types.IssueWithDependencyMetadata{}
}
// Get all dependents with metadata so we can filter for children
refs, err := issueStore.GetDependentsWithMetadata(ctx, issueID)
if err != nil {
return err
}
// Filter for only parent-child relationships
for _, ref := range refs {
if ref.DependencyType == types.DepParentChild {
allChildren[issueID] = append(allChildren[issueID], ref)
}
}
return nil
}
// Process each arg via routing-aware resolution
for _, id := range args {
result, err := resolveAndGetIssueWithRouting(ctx, store, id)
if err != nil {
fmt.Fprintf(os.Stderr, "Error resolving %s: %v\n", id, err)
continue
}
if result == nil || result.Issue == nil {
if result != nil {
result.Close()
}
fmt.Fprintf(os.Stderr, "Issue %s not found\n", id)
continue
}
if err := processIssue(result.ResolvedID, result.Store); err != nil {
fmt.Fprintf(os.Stderr, "Error getting children for %s: %v\n", id, err)
}
result.Close()
}
// Output results
if jsonOut {
outputJSON(allChildren)
return
}
// Display children
for issueID, children := range allChildren {
if len(children) == 0 {
fmt.Printf("%s: No children found\n", ui.RenderAccent(issueID))
continue
}
fmt.Printf("%s Children of %s (%d):\n", ui.RenderAccent("↳"), issueID, len(children))
for _, child := range children {
if shortMode {
fmt.Printf(" %s\n", formatShortIssue(&child.Issue))
} else {
fmt.Println(formatDependencyLine("↳", child))
}
}
fmt.Println()
}
}
// showIssueAsOf displays issues as they existed at a specific commit or branch ref.
// This requires a versioned storage backend (e.g., Dolt).
func showIssueAsOf(ctx context.Context, args []string, ref string, shortMode bool) {
var allIssues []*types.Issue
for idx, id := range args {
issue, err := store.AsOf(ctx, id, ref)
if err != nil {
fmt.Fprintf(os.Stderr, "Error fetching %s as of %s: %v\n", id, ref, err)
continue
}
if issue == nil {
fmt.Fprintf(os.Stderr, "Issue %s did not exist at %s\n", id, ref)
continue
}
if shortMode {
fmt.Println(formatShortIssue(issue))
continue
}
if jsonOutput {
allIssues = append(allIssues, issue)
continue
}
if idx > 0 {
fmt.Println("\n" + ui.RenderMuted(strings.Repeat("-", 60)))
}
// Display header with ref indicator
fmt.Printf("\n%s (as of %s)\n", formatIssueHeader(issue), ui.RenderMuted(ref))
fmt.Println(formatIssueMetadata(issue))
if issue.Description != "" {
fmt.Printf("\n%s\n%s\n", ui.RenderBold("DESCRIPTION"), uimd.RenderMarkdown(issue.Description))
}
fmt.Println()
}
if jsonOutput && len(allIssues) > 0 {
outputJSON(allIssues)
}
}