Documentation
¶
Overview ¶
Package cli wires up the cobra command tree for the agent-memory binary. M0 ships only the `version` subcommand; M1+ add `init`, `status`, `fetch`, `review`, `apply`, `reject`, `rebase`, `rebuild-index`, `doctor`, `mcp`, and `install <adapter>`.
Index ¶
- Constants
- Variables
- func NewApplyCmd() *cobra.Command
- func NewDoctorCmd() *cobra.Command
- func NewFetchCmd() *cobra.Command
- func NewInitCmd() *cobra.Command
- func NewInstallCmd() *cobra.Command
- func NewMCPCmd() *cobra.Command
- func NewMergeDriverCmd() *cobra.Command
- func NewProposeCmd() *cobra.Command
- func NewRebaseCmd() *cobra.Command
- func NewRebuildIndexCmd() *cobra.Command
- func NewRejectCmd() *cobra.Command
- func NewReviewCmd() *cobra.Command
- func NewRootCmd() *cobra.Command
- func NewStatusCmd() *cobra.Command
- func NewStoreCmd() *cobra.Command
- func NewSweepCmd() *cobra.Command
- func NewSyncCmd() *cobra.Command
- func NewVersionCmd() *cobra.Command
- func Version() string
- type Finding
- type InstallResult
- type ProposeReport
- type RebuildIndexResult
- type ReviewDetail
- type ReviewList
- type Severity
- type StatusReport
- type StoreStatus
Constants ¶
const DesignDocVersion = "v0.4.1"
DesignDocVersion is the spec revision this binary implements. Printed alongside ProgramVersion in `status --json` and useful for matching a binary's behaviour back to a written design. Hardcoded — the spec only moves with documented design-doc bumps, not per release.
const MemoryDirName = ".agent-memory"
MemoryDirName is the directory created inside a repo root that holds the agent-memory state. Centralised here so init/status/doctor agree.
Variables ¶
var ProgramVersion = "dev"
ProgramVersion is the user-visible version string for `agent-memory version`. Default value is "dev" so `go build ./cmd/agent-memory` produces a binary that clearly identifies itself as a development build. Release builds via goreleaser stamp the actual git tag in via -ldflags, e.g.:
go build -ldflags='-X github.com/xChuCx/agent-memory/internal/cli.ProgramVersion=v0.3.0' ./cmd/agent-memory
See .goreleaser.yml and .github/workflows/release.yml.
var, not const, so the linker can override it. The exported name is stable; only the value is configurable at build time.
Functions ¶
func NewApplyCmd ¶
NewApplyCmd returns the `agent-memory apply` subcommand.
func NewDoctorCmd ¶
NewDoctorCmd returns the `agent-memory doctor` subcommand.
func NewFetchCmd ¶
NewFetchCmd returns the `agent-memory fetch` subcommand.
func NewInitCmd ¶
NewInitCmd returns the `agent-memory init` subcommand.
func NewInstallCmd ¶
NewInstallCmd returns the `agent-memory install` subcommand.
func NewMCPCmd ¶
NewMCPCmd returns the `agent-memory mcp` subcommand. With --stdio (the default and only currently-supported transport) it starts a JSON-RPC MCP server on stdio and registers the agent-facing tools.
M2 registers memory.fetch_context. M3 will add memory.propose_update and memory.status.
func NewMergeDriverCmd ¶
NewMergeDriverCmd returns the `agent-memory merge-driver` subcommand. It has two modes:
- git driver: `agent-memory merge-driver <base> <ours> <theirs> [path]` performs a section-aware 3-way merge and writes the result to <ours> (the path git passes as %A). Exits non-zero if conflicts remain.
- setup: `agent-memory merge-driver --install` registers the driver in this repo (writes .agent-memory/.gitattributes + git config).
func NewProposeCmd ¶
NewProposeCmd returns the `agent-memory propose` subcommand: a human-facing front door to the same memory.ProposeUpdate pipeline the MCP memory.propose_update tool uses, so proposals can be created without an MCP server running.
func NewRebaseCmd ¶
NewRebaseCmd returns the `agent-memory rebase` subcommand.
func NewRebuildIndexCmd ¶
NewRebuildIndexCmd returns the `agent-memory rebuild-index` subcommand.
func NewRejectCmd ¶
NewRejectCmd returns the `agent-memory reject` subcommand.
func NewReviewCmd ¶
NewReviewCmd returns the `agent-memory review` subcommand.
func NewRootCmd ¶
NewRootCmd builds the agent-memory root command with all subcommands attached.
func NewStatusCmd ¶
NewStatusCmd returns the `agent-memory status` subcommand.
func NewStoreCmd ¶ added in v0.5.0
NewStoreCmd returns the `agent-memory store` command group: declare and inspect referenced "landscape" stores (federation; see docs/design/federated-memory.md). These edit the manifest's `stores` block. Fetching/using a store lands in later PRs (sync, multi-store fetch); `store` only manages the declaration here.
func NewSweepCmd ¶
NewSweepCmd returns the `agent-memory sweep` subcommand.
Removes every staged proposal whose age exceeds the manifest's `staging.ttl_seconds`. Each removal is logged to meta/rejection-log.jsonl with reason="ttl_expired".
--ttl overrides the manifest value for a one-off aggressive cleanup (e.g., `agent-memory sweep --ttl 1h` before a release). --dry-run previews without changing anything.
func NewSyncCmd ¶ added in v0.5.0
NewSyncCmd returns the `agent-memory sync` command: fetch & pin the referenced landscape stores (federation; see docs/design/federated-memory.md and docs/patterns/federation-stores.md).
func NewVersionCmd ¶
NewVersionCmd returns the `agent-memory version` subcommand. Output is a single line containing the resolved Version() (release tag, the `go install` module version, or "dev (<vcs-rev>)"), written to the cobra command's stdout (which can be redirected by callers in tests).
func Version ¶ added in v0.4.1
func Version() string
Version returns the version string shown by `agent-memory version`, sent in the MCP server handshake, and reported as memory.status.memory_version.
It resolves so a binary always identifies itself usefully in a bug report, in this order:
- ProgramVersion, if a release build stamped it via -ldflags (e.g. the goreleaser archives → "v0.4.0").
- else the module version from the build info — set when the binary was installed with `go install …@v0.4.0` / `@latest` → e.g. "v0.4.0". (This is the case `go install` users hit; without it they'd report "dev" and we couldn't tell which version they ran.)
- else "dev", enriched with the VCS revision (and a "dirty" marker) when built from a checkout → e.g. "dev (a5a4b0c9, dirty)".
Types ¶
type InstallResult ¶
type InstallResult struct {
Adapter string `json:"adapter"`
Files []string `json:"files,omitempty"`
Skipped []string `json:"skipped,omitempty"`
}
InstallResult is the structured shape returned by `agent-memory install`. Unified across adapters so consumers parse the same JSON regardless of which adapter was requested.
type ProposeReport ¶
type ProposeReport struct {
*memory.ProposeResponse
Applied *memory.ApplyResult `json:"applied,omitempty"`
}
ProposeReport is the JSON shape for `propose --json`: the orchestrator's response, plus the apply outcome when --apply landed a staged proposal.
type RebuildIndexResult ¶
type RebuildIndexResult struct {
FilesIndexed int `json:"files_indexed"`
SectionsIndexed int `json:"sections_indexed"`
DurationSeconds float64 `json:"duration_seconds"`
Clobbered bool `json:"clobbered,omitempty"`
AssignedIDs bool `json:"assigned_ids,omitempty"`
}
RebuildIndexResult is the structured shape returned by `agent-memory rebuild-index`. JSON-friendly. The numeric counts come from CountSections / CountFiles after the rebuild — they describe the final on-disk state, NOT a delta from before.
type ReviewDetail ¶
type ReviewDetail struct {
Proposal *memory.StagedProposal `json:"proposal"`
Targets []memory.OperationTarget `json:"targets"`
Files map[string]string `json:"files,omitempty"`
Diffs map[string]string `json:"diffs,omitempty"`
}
ReviewDetail is the structured output for `agent-memory review <id>`. Files is populated only when --show is set (otherwise the staged file contents are not echoed to keep output focused on metadata). Diffs is populated only when --diff is set: per-file unified diff of the staged post-state against the current on-disk file (what `apply` would change).
type ReviewList ¶
type ReviewList struct {
Proposals []memory.StagedProposal `json:"proposals"`
}
ReviewList is the structured output for `agent-memory review` with no id.
type StatusReport ¶
type StatusReport struct {
// §15.11 — every field the design spec lists, in the same shape.
*memory.MemoryStatus
// CLI-only extras: useful for human/script readers but not part of
// the design's memory.status contract.
Root string `json:"root"`
MemoryDir string `json:"memory_dir"`
ManifestPath string `json:"manifest_path"`
SchemaPath string `json:"schema_path"`
Categories map[string]int `json:"categories"`
Stores []StoreStatus `json:"stores,omitempty"`
}
StatusReport is the structured shape returned by `agent-memory status`. Wire format = design doc §15.11 (the same shape memory.status MCP tool returns) plus a few CLI-specific helpers (Root, MemoryDir, paths to manifest/schema, per-category counts). The shared §15.11 block is embedded so JSON output flattens to one object.
type StoreStatus ¶ added in v0.5.0
type StoreStatus struct {
Name string `json:"name"`
Source string `json:"source"`
Revision string `json:"revision,omitempty"`
Lock string `json:"lock"` // resolved commit, "unlocked", or "not synced"
}
StoreStatus summarises one referenced landscape store for `status`.