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>
138 lines
3.9 KiB
Go
138 lines
3.9 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/beads/internal/timeparsing"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
"github.com/steveyegge/beads/internal/ui"
|
|
"github.com/steveyegge/beads/internal/utils"
|
|
)
|
|
|
|
var deferCmd = &cobra.Command{
|
|
Use: "defer [id...]",
|
|
Short: "Defer one or more issues for later",
|
|
Long: `Defer issues to put them on ice for later.
|
|
|
|
Deferred issues are deliberately set aside - not blocked by anything specific,
|
|
just postponed for future consideration. Unlike blocked issues, there's no
|
|
dependency keeping them from being worked. Unlike closed issues, they will
|
|
be revisited.
|
|
|
|
Deferred issues don't show in 'bd ready' but remain visible in 'bd list'.
|
|
|
|
Examples:
|
|
bd defer bd-abc # Defer a single issue (status-based)
|
|
bd defer bd-abc --until=tomorrow # Defer until specific time
|
|
bd defer bd-abc --reason="waiting on API access"
|
|
bd defer bd-abc bd-def # Defer multiple issues`,
|
|
Args: cobra.MinimumNArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
CheckReadonly("defer")
|
|
|
|
// Parse --until flag (GH#820)
|
|
var deferUntil *time.Time
|
|
untilStr, _ := cmd.Flags().GetString("until")
|
|
if untilStr != "" {
|
|
t, err := timeparsing.ParseRelativeTime(untilStr, time.Now())
|
|
if err != nil {
|
|
FatalError("invalid --until format %q. Examples: +1h, tomorrow, next monday, 2025-01-15", untilStr)
|
|
}
|
|
// Warn if defer date is in the past (user probably meant future)
|
|
if t.Before(time.Now()) && !jsonOutput {
|
|
fmt.Fprintf(os.Stderr, "%s Defer date %q is in the past. Issue will appear in bd ready immediately.\n",
|
|
ui.RenderWarn("!"), t.Format("2006-01-02 15:04"))
|
|
fmt.Fprintf(os.Stderr, " Did you mean a future date? Use --until=+1h or --until=tomorrow\n")
|
|
}
|
|
deferUntil = &t
|
|
}
|
|
reason, _ := cmd.Flags().GetString("reason")
|
|
reason = strings.TrimSpace(reason)
|
|
if cmd.Flags().Changed("reason") && reason == "" {
|
|
FatalError("reason cannot be empty")
|
|
}
|
|
|
|
ctx := rootCtx
|
|
|
|
// Resolve partial IDs
|
|
_, err := utils.ResolvePartialIDs(ctx, store, args)
|
|
if err != nil {
|
|
FatalError("%v", err)
|
|
}
|
|
|
|
deferredIssues := []*types.Issue{}
|
|
|
|
// Direct storage access
|
|
if store == nil {
|
|
FatalErrorWithHint("database not initialized",
|
|
diagHint())
|
|
}
|
|
|
|
for _, id := range args {
|
|
fullID, err := utils.ResolvePartialID(ctx, store, id)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error resolving %s: %v\n", id, err)
|
|
continue
|
|
}
|
|
|
|
updates := map[string]interface{}{
|
|
"status": string(types.StatusDeferred),
|
|
}
|
|
// Add defer_until if --until specified (GH#820)
|
|
if deferUntil != nil {
|
|
updates["defer_until"] = *deferUntil
|
|
}
|
|
if reason != "" {
|
|
issue, err := store.GetIssue(ctx, fullID)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error loading %s: %v\n", fullID, err)
|
|
continue
|
|
}
|
|
if issue == nil {
|
|
fmt.Fprintf(os.Stderr, "Issue %s not found\n", fullID)
|
|
continue
|
|
}
|
|
notes := issue.Notes
|
|
if notes != "" {
|
|
notes += "\n"
|
|
}
|
|
updates["notes"] = notes + reason
|
|
}
|
|
|
|
if err := store.UpdateIssue(ctx, fullID, updates, actor); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error deferring %s: %v\n", fullID, err)
|
|
continue
|
|
}
|
|
|
|
if jsonOutput {
|
|
issue, _ := store.GetIssue(ctx, fullID)
|
|
if issue != nil {
|
|
deferredIssues = append(deferredIssues, issue)
|
|
}
|
|
} else {
|
|
fmt.Printf("%s Deferred %s\n", ui.RenderAccent("*"), fullID)
|
|
}
|
|
}
|
|
|
|
if jsonOutput && len(deferredIssues) > 0 {
|
|
outputJSON(deferredIssues)
|
|
}
|
|
|
|
if len(args) > 0 {
|
|
commandDidWrite.Store(true)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
// Time-based scheduling flag (GH#820)
|
|
deferCmd.Flags().String("until", "", "Defer until specific time (e.g., +1h, tomorrow, next monday)")
|
|
deferCmd.Flags().String("reason", "", "Record why this issue is being deferred (appended to notes)")
|
|
deferCmd.ValidArgsFunction = issueIDCompletion
|
|
rootCmd.AddCommand(deferCmd)
|
|
}
|