Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Overview

editordiscovery.go implements D-14/D-15's startup-time editor discovery: the third rung of resolveEditorLink's precedence chain (internal/cli/editorurl.go), consulted only when neither --editor-url nor CODEGRAPH_EDITOR_URL configured a template.

Discovery is a PROBE, never a launch (SRV-03): it only asks the operating system "is this on PATH?" or "does this application directory exist?" via exec.LookPath and os.Stat — it never spawns a process. discoverEditorWith runs the probe order once, at codegraph ui's startup, before the server binds a port; it is never re-run per request. Finding nothing is a normal outcome, not a failure: the server still starts and GetEditorLink answers NO_TEMPLATE, exactly as it does when no source configured a template at all (D-15).

The probe order (editorLaunchers below) is a committed fact: VS Code, then Cursor, then the JetBrains family in a fixed order. Changing it is a deliberate, tested decision, not an incidental refactor.

Native Windows app-directory probing is deliberately absent: native Windows support was dropped at v0.4.0 (WSL2 only, per quick task 260807-gho) — there is no host left for such a probe to run on. Any platform other than macOS or Linux falls back to PATH probing only.

editorurl.go resolves codegraph ui's editor-link configuration ONCE at startup (D-14/D-15/D-16), before uiserver.Listen ever binds a port. This is the CLI's operator boundary counterpart to internal/uiserver/editorlink.go's per-request handler: both call the SAME uiserver.ValidateEditorTemplate — this package declares no second validator.

Package cli implements the codegraph command-line interface: the Cobra root command "codegraph" and its init/index/uninit subcommands, wired directly to the internal/indexer pipeline (D-01). Commands contain no extraction/resolution logic of their own — they resolve paths, manage the .codegraph/ directory layout (D-01b), and delegate all indexing work to indexer.Run. sync/daemon (D-01/D-05) extend the surface with incremental update and the shared watch/index server, delegating to indexer.Sync and internal/daemon respectively. search is the one lexical-search verb (Phase 3 VERB-01/VERB-03): its --full flag selects the full-node-record shape the now-removed `query` verb used to render, and daemon start|stop|unlock (Phase 3 VERB-04) is the complete daemon lifecycle, unlock included — `daemon unlock` clears a stale daemon lock left behind by a crash. The one-release `query` and `unlock` rename stubs were removed in v0.15.0 (VERB-09); invoking either name is now cobra's unknown-command error. githooks (phase 05) manages marker-fenced git sync hooks, and man (Phase 3 D-01/D-02) is the hidden man-page generator the Homebrew cask's post-install hook invokes — both are documented Go-only surface extensions. ui (Phase 1 SRV-01) runs a local, read-only Connect RPC server (internal/uiserver) over the repository's own index, foreground until Ctrl-C like serve/daemon start, sharing neither's lifecycle.

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyInitialized = errors.New("cli: already initialized")

ErrAlreadyInitialized is returned by `init` when .codegraph/ already exists at the target root (D-01a) — init never clobbers an existing store; the caller must run `codegraph index --force` to rebuild.

View Source
var ErrHomeDirectoryTarget = errors.New("the home directory cannot be a codegraph project")

ErrHomeDirectoryTarget is returned by targetRoot when the directory a command would create, rebuild or remove an index in is the user's home directory. The home directory can never be a codegraph project: the query engine never resolves it as an index root (query.ResolveCodegraphDir), so an index there would be unreachable, and older releases kept per-user state in ~/.codegraph.

View Source
var ErrNotInitialized = errors.New("cli: not initialized")

ErrNotInitialized is returned by `index` when no .codegraph/ exists yet at the target root (D-01a) — the caller must run `codegraph init` first.

Functions

func Execute

func Execute() error

Execute runs the codegraph root command against os.Args, returning any error for the caller (cmd/codegraph/main.go) to report and exit non-zero on.

func NewRootCmd added in v0.13.0

func NewRootCmd() *cobra.Command

NewRootCmd returns a freshly built root command tree, identical to what Execute() runs. It exists so tools/clidoc (DOCS-05's out-of-package CLI reference generator) can obtain the same command tree without this package importing cobra/doc or anything new; it changes no behavior of the shipped binary. newRootCmd itself is not renamed — every existing intra-package and cmd/codegraph call site keeps working untouched.

Types

This section is empty.

Directories

Path Synopsis
Package present is the sole home for charm.land/lipgloss/v2 styling (D-01).
Package present is the sole home for charm.land/lipgloss/v2 styling (D-01).
Package tui hosts the ONLY code in this module that imports charm.land/bubbletea/v2 and charm.land/bubbles/v2 (D-09/D-11).
Package tui hosts the ONLY code in this module that imports charm.land/bubbletea/v2 and charm.land/bubbles/v2 (D-09/D-11).

Jump to

Keyboard shortcuts

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