Documentation
¶
Overview ¶
Package command holds domain command structs — write intent. Commands are dispatched to handlers for execution; results flow back through optional callback functions on the command struct (handlers themselves return only errors so write paths and read paths stay distinct).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
Source string // file path, or "-" for stdin
Target string // destination filename inside the attachment directory
Data []byte // populated when Source == "-"
}
Attachment describes a file to attach to a new entry. For stdin attachments the source is "-" and Data holds the already-read bytes — the CLI layer materializes stdin before constructing the command so the handler operates on a self-contained value.
type FinishWIPCmd ¶
type FinishWIPCmd struct {
MarkerID string
Force bool // when true, force-delete an unmerged branch (discard flow)
// OnRemoved fires after the marker file is removed and the deletion
// is committed.
OnRemoved func(markerID string)
// OnBranchDeleted fires after a git branch is deleted (merged or
// force-deleted).
OnBranchDeleted func(branch string, forced bool)
// OnBranchPreserved fires when the marker referenced a branch but the
// branch was unmerged and Force was not set — branch is preserved,
// callback informs the CLI to print guidance.
OnBranchPreserved func(branch string)
}
FinishWIPCmd captures intent to remove a WIP marker (and optionally clean up its git branch).
func (*FinishWIPCmd) Validate ¶
func (c *FinishWIPCmd) Validate() error
Validate checks required fields.
type InitCmd ¶
type InitCmd struct {
// RepoRoot is the absolute path to the repository root where .sdd/
// will be created.
RepoRoot string
// GraphDir is the graph directory path relative to RepoRoot.
// Empty defaults to model.DefaultGraphDir (".sdd/graph").
GraphDir string
// OnCreated fires after the .sdd/ directory, config.yaml, and graph
// dir are successfully created. Receives the absolute path to .sdd/
// and the absolute graph directory path.
OnCreated func(sddDir, absGraphDir string)
// OnMigrated fires after .sdd-tmp/ contents are migrated to .sdd/tmp/.
// Receives the count of migrated files.
OnMigrated func(count int)
// OnGitignoreUpdated fires after .gitignore is updated with .sdd/tmp/.
OnGitignoreUpdated func(gitignorePath string)
}
InitCmd captures intent to initialize the .sdd/ metadata directory at a repository root. The handler creates the directory structure, writes config.yaml, updates .gitignore, and optionally migrates legacy .sdd-tmp/ contents.
type LintFixCmd ¶
type LintFixCmd struct {
// OnFixed is invoked for each entry that was fixed, with the entry ID
// and a list of human-readable fix descriptions.
OnFixed func(id string, fixes []string)
}
LintFixCmd captures intent to apply mechanical fixes to graph entries. The handler loads the graph, applies all available fixers, writes patched files, and commits. OnFixed is invoked per entry with the fixes applied.
type NewEntryCmd ¶
type NewEntryCmd struct {
Type model.EntryType
Layer model.Layer
Kind model.Kind // only meaningful for decisions
Description string
Refs []string
Supersedes []string
Closes []string
Participants []string
Confidence string
Attachments []Attachment
SkipPreflight bool
DryRun bool
PreflightTimeout time.Duration
PreflightModel string
// OnNewEntry is invoked with the new entry's ID on successful creation.
// Not invoked on dry-run or any failure path. The callback receives
// only the ID — for richer data (path, content), the caller issues a
// query against the appropriate finder.
OnNewEntry func(id string)
}
NewEntryCmd captures intent to create a new graph entry. The handler is responsible for graph loading, validation, pre-flight, stdin persistence on rejection/dry-run, writing the entry file, copying attachments, and committing. On success the handler invokes OnNewEntry with the new entry's ID; the caller queries a finder for any richer data.
func (*NewEntryCmd) BuildEntry ¶
func (c *NewEntryCmd) BuildEntry(id string) (*model.Entry, error)
BuildEntry constructs a model.Entry from the command fields, applying defaults (Kind → directive for decisions) and resolving attachment paths and content links. The caller provides the generated entry ID.
func (*NewEntryCmd) StdinAttachment ¶
func (c *NewEntryCmd) StdinAttachment() *Attachment
StdinAttachment returns the single stdin attachment, or nil if none is present. (parseAttachFlags enforces at most one stdin attachment at the CLI layer.)
func (*NewEntryCmd) Validate ¶
func (c *NewEntryCmd) Validate() error
Validate checks that required fields are populated and internally consistent. Richer validation (refs exist in graph, type constraints on closes, etc.) is the handler's job against a loaded graph.
type StartWIPCmd ¶
type StartWIPCmd struct {
EntryID string
Description string
Participant string
Exclusive bool
Branch bool // when true, derive a branch name and create+checkout
// OnStarted fires after the marker file is written and committed.
// Callbacks receive only identifiers — the caller queries finders for
// richer data if needed (consistent with d-cpt-l3s).
OnStarted func(markerID, markerPath string)
// OnBranchCreated fires after the git branch is created and checked
// out. Only invoked when Branch is true.
OnBranchCreated func(branchName string)
// OnExclusiveCollision fires when an existing exclusive marker is
// found for the same entry. The handler doesn't block creation; the
// callback lets the CLI print a warning.
OnExclusiveCollision func(existing *model.WIPMarker)
}
StartWIPCmd captures intent to create a WIP marker for a graph entry, optionally creating and checking out a git branch in the same step.
func (*StartWIPCmd) Validate ¶
func (c *StartWIPCmd) Validate() error
Validate checks required fields.
type SummarizeCmd ¶
type SummarizeCmd struct {
// EntryIDs lists specific entries to summarize. Empty means --all.
EntryIDs []string
// Force regenerates summaries even if the hash matches.
Force bool
// Model is the LLM model to use for summary generation.
Model string
// Timeout per entry for the LLM call.
Timeout time.Duration
// OnSummarized is called for each entry that gets a new summary.
OnSummarized func(id, summary string)
// OnSkipped is called for each entry whose hash matched (skipped).
OnSkipped func(id string)
}
SummarizeCmd captures intent to generate or regenerate entry summaries.