cli

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUser = errors.New("user error")

ErrUser is the sentinel that marks errors caused by bad user input. main.go maps errors.Is(err, ErrUser) to exit code 1; anything else becomes exit code 2.

Functions

func NewAddCmd

func NewAddCmd() *cobra.Command

NewAddCmd returns the `brag add` subcommand. Three modes:

  • json mode: --json set; reads a single JSON entry from stdin (DEC-012 schema) and inserts it. Mutually exclusive with the six entry-field flags.
  • flag mode: any of the six entry-field flags set; --title is required (DEC-007).
  • editor mode: no entry-field flag set; opens $EDITOR on a hint template (DEC-009 buffer format), parses + persists on save.

func NewCompletionCmd added in v0.2.0

func NewCompletionCmd(root *cobra.Command) *cobra.Command

NewCompletionCmd returns a subcommand that generates shell completion scripts using cobra's built-in generators. root must be the root brag command so the generated scripts include all registered subcommands, not just this one.

func NewCoverageCmd added in v0.4.0

func NewCoverageCmd() *cobra.Command

NewCoverageCmd returns the `brag coverage` subcommand (SPEC-045), the sixth DEC-014 consumer: a rule-based, calendar-windowed digest of the agent- vs human-authored provenance share over time (DEC-024/DEC-033). It reuses the shared calendar-window core (DEC-028) and the --previous modifier (DEC-032), classifies via aggregate.IsAgentAuthored (single-sourced with storage's SQL clause, SPEC-045 LD2), and renders a per-month agent-share sparkline (DEC-031).

func NewDeleteCmd

func NewDeleteCmd() *cobra.Command

NewDeleteCmd returns the `brag delete <id>` subcommand. Prompts for y/N confirmation on stdin unless --yes/-y is passed; on decline the command exits 0 cleanly (a deliberate user choice, not an error). Positional-arg validation lives inline in runDelete per DEC-007.

func NewEditCmd

func NewEditCmd() *cobra.Command

NewEditCmd returns the `brag edit <id>` subcommand. This is the primary update mechanism for PROJ-001 (DEC-009 pins the buffer format; flag-based update is a deferred polish spec).

func NewExportCmd

func NewExportCmd() *cobra.Command

NewExportCmd returns the `brag export` subcommand. STAGE-003 introduced it with --format json (SPEC-014); SPEC-015 added --format markdown and the markdown-only --flat modifier. Filter flags mirror `brag list` verbatim (SPEC-007's ListFilter).

func NewImpactCmd added in v0.4.0

func NewImpactCmd() *cobra.Command

NewImpactCmd returns the `brag impact` subcommand (SPEC-048), the fourth DEC-014 consumer: a rule-based, calendar-windowed, initiative- grouped digest of entries carrying an impact statement.

func NewListCmd

func NewListCmd() *cobra.Command

NewListCmd returns the `brag list` subcommand. It prints every entry matching the filter flags (or all entries when none are set) to stdout, one per line, as `<id>\t<created_at>\t<title>` in the order returned by Store.List (created_at DESC, id DESC tie-break).

func NewMCPCmd added in v0.3.0

func NewMCPCmd() *cobra.Command

NewMCPCmd returns the `brag mcp` parent command, with `serve` and `install` as its children.

func NewMemoryCmd added in v0.6.0

func NewMemoryCmd() *cobra.Command

NewMemoryCmd returns the `brag memory` subcommand (SPEC-073), the eighth DEC-014 consumer: a ranked, token-budgeted slice of the corpus — the corpus read back as working memory, blended by reciprocal-rank fusion (DEC-043) and trimmed to a token budget (DEC-044).

func NewProjectCmd added in v0.2.0

func NewProjectCmd() *cobra.Command

NewProjectCmd returns the `brag project` parent command with new, list, show, status, edit, archive, delete, and here subcommands. A bare `brag project` prints help (cobra default for a command with subcommands and no RunE).

func NewReviewCmd

func NewReviewCmd() *cobra.Command

NewReviewCmd returns the `brag review` subcommand. SPEC-019 emits it as the second DEC-014 consumer: a reflection-prompt digest of recent entries grouped by project, followed by three hard-coded reflection questions designed to be pasted into an external AI session for guided self-review. No LLM ships in the binary.

func NewRootCmd

func NewRootCmd(version string) *cobra.Command

NewRootCmd creates the root cobra command for the brag CLI.

func NewSearchCmd

func NewSearchCmd() *cobra.Command

NewSearchCmd returns the `brag search <query>` subcommand. It runs a full-text search over entries via FTS5 (see SPEC-011's entries_fts index) and prints matching rows to stdout in the same tab-separated shape as `brag list`. Query semantics are per DEC-010.

func NewShowCmd

func NewShowCmd() *cobra.Command

NewShowCmd returns the `brag show <id>` subcommand. Prints the matched entry as markdown to stdout. Missing, non-numeric, or non- positive IDs surface as ErrUser (exit 1) via runShow; positional-arg validation lives inline here rather than in a cobra.Args validator because cobra's built-ins return unwrappable plain errors (DEC-007 extension).

func NewSparkCmd added in v0.5.0

func NewSparkCmd() *cobra.Command

NewSparkCmd returns the `brag spark` subcommand (SPEC-059), the seventh DEC-014 consumer: a sparklines-only "pulse" of recent activity — a Total row plus up to the top-8 by-project rows, each a per-row min→max sparkline over a ROLLING recent window (DEC-037). Windows are rolling, not calendar (--week/--month/--quarter, mutually exclusive, default --month); --project is a row SELECTOR, not a corpus filter. Reuses the spark.Line primitive (DEC-031) and the shared lookupSparkEnv escape.

func NewStatsCmd

func NewStatsCmd() *cobra.Command

NewStatsCmd returns the `brag stats` subcommand. SPEC-020 ships it as the third (and final) DEC-014 consumer in STAGE-004: six lifetime aggregations over the entire corpus, rendered as markdown (default) or the DEC-014 JSON envelope. No filter flags, no --range, no --out.

func NewStoryCmd added in v0.4.0

func NewStoryCmd() *cobra.Command

NewStoryCmd returns the `brag story` subcommand (SPEC-049): the first narrative surface. It coalesces the in-window corpus into deterministic threads, assembles a throughline skeleton, shapes selection/altitude per a data-driven audience profile, and emits an arc-aware bundle (markdown default / JSON envelope) with a per-audience framing directive appended. No model, no network in the binary — the bundle is a complete artifact standalone; the LLM (already in the caller) is the optional upgrade.

func NewSummaryCmd

func NewSummaryCmd() *cobra.Command

NewSummaryCmd returns the `brag summary` subcommand. SPEC-018 emits it as the first DEC-014 consumer: a rule-based digest of entries in a rolling 7- or 30-day window, rendered as markdown (default) or the DEC-014 JSON envelope.

func NewTagCmd added in v0.2.0

func NewTagCmd() *cobra.Command

NewTagCmd returns the `brag tag` parent command with rename and merge subcommands. A bare `brag tag` prints help (cobra default for a command with subcommands and no RunE).

func NewTagsCmd added in v0.2.0

func NewTagsCmd() *cobra.Command

NewTagsCmd returns the `brag tags` subcommand. Lists every in-use tag with its usage count. Data goes to stdout; errors to stderr.

func NewWrappedCmd added in v0.4.0

func NewWrappedCmd() *cobra.Command

NewWrappedCmd returns the `brag wrapped` subcommand (SPEC-051), the fifth DEC-014 consumer: a shareable, celebratory year- or quarter-in- review digest over a named calendar period. It curates the existing internal/aggregate toolbox into a retrospective highlight reel.

func UserErrorf

func UserErrorf(format string, args ...any) error

UserErrorf returns an error that wraps ErrUser with a formatted message. Use it at call sites instead of hand-rolling fmt.Errorf so downstream errors.Is(err, ErrUser) keeps working.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL