cli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 104 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli assembles GraphLume's command-line interface.

Index

Constants

View Source
const DefaultIndexMemoryLimit int64 = 768 << 20

DefaultIndexMemoryLimit is the soft heap limit `graphlume index` runs under when nothing else sets one and the repository is of ordinary size.

A soft limit (runtime/debug.SetMemoryLimit) does not stop the process at a size; it makes the collector work harder as the heap approaches it, so garbage that would have waited for the next cycle is returned sooner. An index run is a stream of parse trees that die young next to a graph that lives, which is the case it suits.

MEASURED, a full index of 561 C files (17.5 MiB of source, PostgreSQL's parser, 4 workers), median of three, on a 14-core Apple machine:

limit      wall     peak RSS
none       15.5 s   1,114 MB
1 GiB      15.5 s   1,029 MB   -8%
768 MiB    15.3 s     918 MB   -18%   (750 MiB measured)
500 MiB    16.1 s     844 MB   -24%   +4% wall

768 MiB is where the saving is still free: a fifth of the peak for no measurable time, where 500 MiB buys six points more for a few percent of wall clock.

View Source
const DefaultMemoryLimitMaxSource int64 = 64 << 20

DefaultMemoryLimitMaxSource is the most source a run may discover for the default limit to apply. Past it the live heap is bigger than the limit, and a limit below the live set only makes the collector run flat out: 14,000 files and 117 MiB of source took 283 s under 768 MiB against 254 s without (+11%), with no lower peak (1,818 MB against 1,414 MB, one run each). The cut is 64 MiB, between that and the 17.5 MiB that gained. An explicit limit is always applied.

View Source
const IndexDir = ".graphlume"

IndexDir is where GraphLume stores its registry inside a project.

View Source
const IndexFile = "index.db"

IndexFile is the SQLite registry filename.

Variables

View Source
var (
	Version   = "dev"
	Commit    = "none"
	BuildTime = "unknown"
)

Build metadata, injected via -ldflags at release time. Spec §64.

Functions

func Execute

func Execute(ctx context.Context) int

Execute runs the CLI, returning a process exit code.

func NewRoot

func NewRoot() *cobra.Command

NewRoot builds the root command tree.

func UninstallCommitHook

func UninstallCommitHook(root string) (bool, error)

UninstallCommitHook removes the managed block from post-commit, post-merge, and post-checkout, leaving any other hook content exactly as it was. Reports whether anything was removed.

Types

type Deeplink struct {
	Client      string
	Description string
	URI         string
}

Deeplink represents a 1-click installation URI for an AI coding agent or editor.

func AgentDeeplinks(root string, profile ...string) []Deeplink

AgentDeeplinks returns 1-click MCP install links for supported editors.

type ExitCodeError

type ExitCodeError struct {
	Code int
	// Silent is set when the command already printed its report. The code is
	// the message at that point, and an "error:" line beneath a rendered report
	// reads as a malfunction rather than a verdict.
	Silent bool
	Err    error
}

ExitCodeError is an error that carries the process exit code it wants.

It exists so a command whose exit code IS its output — `verify`, whose four dispositions a CI job branches on — can express that without calling os.Exit from inside RunE. A command that exits the process directly cannot be tested for the one behaviour that matters about it, and the codes would then be the only untested part of a gate whose entire job is to fail correctly.

func (*ExitCodeError) Error

func (e *ExitCodeError) Error() string

func (*ExitCodeError) Unwrap

func (e *ExitCodeError) Unwrap() error

type Global

type Global struct {
	JSON    bool
	Verbose bool
	Quiet   bool
	Project string
	// contains filtered or unexported fields
}

Global holds flags shared by every command.

func (*Global) Config

func (g *Global) Config() config.Config

Config returns the resolved configuration.

func (*Global) DBPath

func (g *Global) DBPath() string

DBPath returns the registry path for the resolved project root.

func (*Global) Log

func (g *Global) Log() *slog.Logger

Log returns the logger.

type HookState

type HookState struct {
	Path          string `json:"path"`
	AuxiliaryPath string `json:"auxiliary_path,omitempty"`
	// NeedsWiring is true when GraphLume wrote an auxiliary script beside a
	// hook it would not edit (not a shell script) and that hook does not call
	// it yet. Git never runs the auxiliary script by itself, so such a hook is
	// not Installed.
	NeedsWiring    bool `json:"needs_wiring,omitempty"`
	Installed      bool `json:"installed"`
	Appended       bool `json:"appended,omitempty"`
	AlreadyCurrent bool `json:"already_current,omitempty"`
}

HookState reports what an install actually did. Callers print it; the portal renders it.

func CommitHookStatus

func CommitHookStatus(root string) HookState

CommitHookStatus reports primary post-commit installation status.

func InstallCommitHook

func InstallCommitHook(root, binary string) (HookState, error)

InstallCommitHook writes (or updates) the managed block in post-commit, post-merge (on git pull/merge), and post-checkout (on branch switch).

type HooksReport

type HooksReport struct {
	PostCommit   HookState `json:"post_commit"`
	PostMerge    HookState `json:"post_merge"`
	PostCheckout HookState `json:"post_checkout"`
}

HooksReport reports status across all managed hooks.

func AllHooksStatus

func AllHooksStatus(root string) HooksReport

AllHooksStatus reports status across post-commit, post-merge, and post-checkout.

type IssueBundle

type IssueBundle struct {
	Timestamp        string         `json:"timestamp"`
	GraphLumeVersion string         `json:"graphlume_version"`
	Commit           string         `json:"commit"`
	BuildTime        string         `json:"build_time"`
	GoVersion        string         `json:"go_version"`
	OS               string         `json:"os"`
	Arch             string         `json:"arch"`
	NumCPU           int            `json:"num_cpu"`
	Project          string         `json:"project"`
	Checks           []check        `json:"doctor_checks"`
	Status           map[string]any `json:"index_status,omitempty"`
	SubmitInfo       SubmitDetails  `json:"submit_info"`
}

IssueBundle represents a sanitized diagnostic bundle ready for bug reports.

type ScopeTypeAnalysis

type ScopeTypeAnalysis struct {
	Type            string  `json:"type"`
	Files           int64   `json:"files"`
	FilesPercentage float64 `json:"files_percentage"`
	Symbols         int64   `json:"symbols"`
	ResolutionScope string  `json:"resolution_scope"`
}

ScopeTypeAnalysis breaks down files, symbols, and resolution provenance by architectural role.

type SubmitDetails

type SubmitDetails struct {
	GitHubIssuesURL string `json:"github_issues_url"`
	SupportEmail    string `json:"support_email"`
	Instructions    string `json:"instructions"`
}

SubmitDetails guides the user on where and how to submit their issue.

type UI

type UI struct {
	// contains filtered or unexported fields
}

UI provides styled terminal output.

func NewUI

func NewUI(w io.Writer) *UI

NewUI creates a UI writer targeting w.

func (*UI) Bold

func (u *UI) Bold(text string) string

Bold wraps text in bold if color is enabled.

func (*UI) Dim

func (u *UI) Dim(text string) string

Dim wraps text in dim color if color is enabled.

func (*UI) Header

func (u *UI) Header(title string)

Header prints a Homebrew-style stage header: ==> Title

func (*UI) Info

func (u *UI) Info(format string, args ...any)

Info prints a cyan info item: ℹ Text

func (*UI) NextSteps

func (u *UI) NextSteps(project string)

NextSteps prints an enterprise-grade next steps guide.

func (*UI) Success

func (u *UI) Success(format string, args ...any)

Success prints a green checkmark item: ✔ Text

func (*UI) Warn

func (u *UI) Warn(format string, args ...any)

Warn prints a yellow warning item: ▲ Text

Jump to

Keyboard shortcuts

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