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

102 lines
3.0 KiB
Go

package main
import (
"fmt"
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
)
var linkCmd = &cobra.Command{
Use: "link <id1> <id2>",
GroupID: "issues",
Short: "Link two issues with a dependency",
Long: `Link two issues with a dependency.
Shorthand for 'bd dep add <id1> <id2>'. By default creates a "blocks"
dependency (id2 blocks id1). Use --type to specify a different relationship.
Examples:
bd link bd-123 bd-456 # bd-456 blocks bd-123
bd link bd-123 bd-456 --type related # bd-123 related to bd-456
bd link bd-123 bd-456 --type parent-child`,
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
CheckReadonly("link")
id1 := args[0]
id2 := args[1]
depType, _ := cmd.Flags().GetString("type")
ctx := rootCtx
// Resolve partial IDs with routing support. The source issue's store
// is mutated by AddDependency below, so resolve it write-intent
// (#4141); the dependency target is only resolved by ID and stays
// read-only (bd-6dnrw.32, GH#3231).
fromID, fromStore, fromCleanup, err := resolveIDForMutation(ctx, store, id1)
if err != nil {
FatalErrorRespectJSON("%v", err)
}
defer fromCleanup()
toID, _, toCleanup, err := resolveIDWithRouting(ctx, store, id2)
if err != nil {
FatalErrorRespectJSON("%v", err)
}
defer toCleanup()
// Check for child→parent dependency anti-pattern
if isChildOf(fromID, toID) {
FatalErrorRespectJSON("cannot add dependency: %s is already a child of %s. Children inherit dependency on parent completion via hierarchy. Adding an explicit dependency would create a deadlock", fromID, toID)
}
// Validate dependency type
dt := types.DependencyType(depType)
if !dt.IsValid() {
FatalErrorRespectJSON("invalid dependency type %q: must be non-empty and at most 50 characters", depType)
}
dep := &types.Dependency{
IssueID: fromID,
DependsOnID: toID,
Type: dt,
}
if err := fromStore.AddDependency(ctx, dep, actor); err != nil {
FatalErrorRespectJSON("%v", err)
}
// Check for cycles after adding dependency
warnIfCyclesExist(fromStore)
if err := commitPendingIfEmbedded(ctx, fromStore, actor, doltAutoCommitParams{
Command: "link",
IssueIDs: []string{fromID, toID},
}); err != nil {
FatalErrorRespectJSON("failed to commit: %v", err)
}
SetLastTouchedID(fromID)
if jsonOutput {
outputJSON(map[string]interface{}{
"status": "added",
"issue_id": fromID,
"depends_on_id": toID,
"type": depType,
})
} else {
fmt.Printf("%s Linked: %s depends on %s (%s)\n",
ui.RenderPass("✓"), formatFeedbackIDParen(fromID, lookupTitle(fromID)), formatFeedbackIDParen(toID, lookupTitle(toID)), depType)
}
},
}
func init() {
linkCmd.Flags().StringP("type", "t", "blocks", "Dependency type (blocks|tracks|related|parent-child|discovered-from)")
linkCmd.ValidArgsFunction = issueIDCompletion
rootCmd.AddCommand(linkCmd)
}