cli

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package cli is the thin composition root: the cobra command tree, flag wiring, the flat-output printers, and the JSON emitters. The engine lives in the sibling packages (parse, paths, index, query, retrieve, view, render, semantic, adapters, agentproto).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitJSON

func EmitJSON(w io.Writer, obj any) error

EmitJSON writes obj as indented JSON (machine output, --json): 2-space indent, with HTML escaping disabled so <, >, & are emitted literally rather than \u-escaped.

func Execute

func Execute(root *cobra.Command, args []string) error

Execute runs the command tree under the self-bounding watchdog. It resolves the effective deadline from --timeout / RAWCLAW_TIMEOUT (a lenient pre-parse, so the watchdog is armed BEFORE cobra dispatches — covering even a slow PreRun), arms the watchdog, then runs root.Execute. The disarm is deferred, so the watchdog goroutine is always torn down — on success, on a returned error, or on a panic — which keeps the goroutine-leak detector green. main calls this instead of root.Execute() directly.

func ListProjects

func ListProjects(w io.Writer)

ListProjects prints the searchable-projects table (with session counts). It enumerates the same Claude scopes search does — live project dirs PLUS orphaned index dbs whose source dir was purged (D8) — so a retained-but-purged project still shows, flagged so it doesn't read as a live source.

func NewRootCmd

func NewRootCmd(build BuildInfo) *cobra.Command

NewRootCmd builds the rawclaw cobra command tree (root + the `read`, `outline`, `archive`, `live`, `delete`, `setup`, `upgrade`, and `version` subcommands). The root RunE dispatches the shape (browse/discovery/stats/resume/reindex-vectors) per the parsed flags. The build stamp feeds `--version` (cobra-native) and the `version` subcommand.

func PrintResults

func PrintResults(w io.Writer, res []retrieve.Hit, nSessions int)

PrintResults renders flat one-line hits (the fallback shape). nSessions < 0 means "unknown" (rendered as '?').

Types

type BuildInfo

type BuildInfo struct {
	Version string
	Commit  string
	Date    string
}

BuildInfo carries the compile-time stamp (set in package main via ldflags) down into the command tree so `--version` and the `version` subcommand report the real release. The zero value is honest: an un-stamped build shows "dev".

type ExitError

type ExitError struct {
	Code int
	Msg  string
}

ExitError carries a non-zero process exit code (and an optional usage-style message) up to main, which surfaces it via os.Exit.

func (ExitError) Error

func (e ExitError) Error() string

type LiveSetupReceipt added in v0.9.0

type LiveSetupReceipt struct {
	Status       string `json:"status"`
	Machine      string `json:"machine"`
	Target       string `json:"target"`
	RemotePath   string `json:"remote_path"`
	RemoteArch   string `json:"remote_arch"`
	RemoteOS     string `json:"remote_os"`
	Upgraded     bool   `json:"upgraded"`
	PathRepaired bool   `json:"path_repaired"`
}

LiveSetupReceipt is the structured JSON receipt returned when setup live completes.

type Options

type Options struct {
	Limit            int
	Dir              string
	ThisProject      bool
	All              bool
	List             bool
	Role             string
	Source           string
	Sort             string
	IncludeTools     bool
	IncludeSubagents bool
	Reindex          bool
	JSON             bool
	Resume           string
	Stats            bool
	Since            string
	Before           string
	NoVector         bool
	ReindexVectors   bool
	IncludePath      string
	ExcludePath      string
	MinMessages      int
	DebugSearch      bool
	Timeout          time.Duration
	DirSet           bool // --dir explicitly passed (the arbitrary-folder opt-in)
	Oneline          bool
	Format           string

	// CurrentSession is the caller's own live session ("" = fall back to the
	// runtime's env, "off" = don't exclude anything). Resolved by currentSession.
	CurrentSession string
}

Options holds every parsed flag for one rawclaw invocation, bound to the cobra root command.

Jump to

Keyboard shortcuts

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