cli

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 61 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeDesktopConfigPathForTest added in v0.11.2

func ClaudeDesktopConfigPathForTest(goos, home, appData string) string

ClaudeDesktopConfigPathForTest exposes claudeDesktopConfigPathFor to the external tests package. Test-only surface.

func DaemonChildHandshakeEnvForTest added in v0.10.0

func DaemonChildHandshakeEnvForTest(stateDir string) ([]string, func(), error)

DaemonChildHandshakeEnvForTest prepares a real parent-side handshake in stateDir and returns the environment entries a spawned child receives, plus a cleanup that removes the handshake file. It lets external tests reproduce the launch handshake exactly, rather than assert that a long-enough marker selects daemon-child mode. Test-only surface; not used by production code.

func DaemonReadinessTimeout added in v0.8.0

func DaemonReadinessTimeout() time.Duration

DaemonReadinessTimeout exposes the readiness window so external tests can assert it stays above the document-extractor probe ceiling (ingest.DoclingProbeTimeout). Read-only accessor.

func ExtractPortFromAddress

func ExtractPortFromAddress(addr string) string

ExtractPortFromAddress extracts a numeric trailing port token from a host:port address or malformed best-effort address string.

func IsDaemonStillStarting added in v0.8.0

func IsDaemonStillStarting(err error) bool

IsDaemonStillStarting reports whether err indicates the daemon child was still alive but had not yet written connection.json when the readiness deadline expired (as opposed to having crashed). Exported so the readiness classification — still-starting vs crashed vs ready — can be unit-tested from the external tests package without exposing waitForConnectionFile.

func ProcessStartTokenForTest added in v0.10.0

func ProcessStartTokenForTest(pid int) (string, bool)

ProcessStartTokenForTest exposes processStartToken so external lifecycle tests can tell whether pid-reuse protection is active on this platform (ok) and obtain a real token to build a deliberately-mismatching pid record. Test-only surface; not used by production code.

func PublicURLAddress

func PublicURLAddress(configuredListenAddr, resolvedListenAddr string) string

PublicURLAddress derives the public-facing address using the configured listen host and the resolved runtime port.

func ServiceUnsupportedMessageForTest added in v0.11.2

func ServiceUnsupportedMessageForTest(goos string) string

ServiceUnsupportedMessageForTest exposes serviceUnsupportedMessage to the external tests package. Test-only surface.

func WaitForConnectionReady added in v0.8.0

func WaitForConnectionReady(path string, childPid int, timeout time.Duration) (bool, error)

WaitForConnectionReady is a thin exported wrapper over waitForConnectionFile so the readiness classification — ready vs still-starting vs crashed — can be exercised from the external tests package (waitForConnectionFile itself stays unexported). It returns whether the connection became ready and the classifying error; pair it with IsDaemonStillStarting to distinguish the healthy-but-slow case from a child that exited before binding.

func WritePIDRecordForTest added in v0.10.0

func WritePIDRecordForTest(path string, pid int, startToken string) error

WritePIDRecordForTest writes a pid file carrying an arbitrary start-time token so external tests can simulate a recycled pid (a live pid whose recorded token no longer matches the live process). Test-only surface.

Types

type App

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

func NewApp

func NewApp() *App

NewApp constructs an App wired to os.Stdout and os.Stderr.

func NewAppWithIO

func NewAppWithIO(stdout, stderr io.Writer) *App

NewAppWithIO constructs an App with the given output writers and the default ingestor/store constructors.

func NewAppWithIOAndHooks

func NewAppWithIOAndHooks(stdout, stderr io.Writer, hooks RuntimeHooks) *App

NewAppWithIOAndHooks constructs an App with the given writers, overriding the default ingestor/store/retriever constructors with any non-nil hooks (used by tests to inject fakes).

func (*App) RenderDaemonReadyForTest added in v0.10.0

func (a *App) RenderDaemonReadyForTest(ctx context.Context, cfg config.Config)

RenderDaemonReadyForTest renders the daemon PARENT's ready banner for cfg to the app's stdout, for the external tests package.

It drives printDaemonReady end to end rather than printDaemonCoverage alone, because the defect in #981 was not that the sections rendered wrongly: it was that nothing on the daemon path ever asked for them. A test over the renderer in isolation would keep passing with the call deleted again.

func (*App) RenderTranscriptCoverageSectionForTest added in v0.10.0

func (a *App) RenderTranscriptCoverageSectionForTest(ctx context.Context, st interface{}, cfg config.Config) string

RenderTranscriptCoverageSectionForTest runs the banner's ACTUAL path for the corpus behind st — compute the verdict, then render the section — and returns exactly what the banner would have written.

It exists because asserting the probe's count is not the same claim as asserting what the banner prints, and the README documents the latter. A test over the count alone would keep passing if the section started rendering for a verdict that is not partial.

func (*App) ReportDaemonStillStartingForTest added in v0.10.0

func (a *App) ReportDaemonStillStartingForTest(pid int, logPath string)

ReportDaemonStillStartingForTest exposes the still-starting notice to the external tests package, so the §7.7 pairing can assert that this path emits no coverage rather than leaving that to a comment.

func (*App) Run

func (a *App) Run(args []string) int

Run is the process entrypoint: it installs a signal-cancelled context, dispatches args, and maps a clean exit after interruption to the signal-interrupt exit code.

func (*App) RunWithContext

func (a *App) RunWithContext(ctx context.Context, args []string) int

RunWithContext parses global flags and dispatches the remaining command under ctx, printing usage when no command is given.

func (*App) StartupExtractionCoverageForTest added in v0.10.0

func (a *App) StartupExtractionCoverageForTest(ctx context.Context, st interface{}, cfg config.Config, jsonOutput, quiet bool, stderr io.Writer) []string

StartupExtractionCoverageForTest exposes the banner's coverage probe to the external `tests/cli` package, which cannot call an unexported method. It returns the uncovered extensions of the verdict; an empty result means the probe was skipped or found nothing. Whether the store was queried at all is observable on the caller's counter, which is the point for the daemon-child case (#949 review).

func (*App) StartupTranscriptCoverageForTest added in v0.10.0

func (a *App) StartupTranscriptCoverageForTest(ctx context.Context, st interface{}, cfg config.Config, jsonOutput, quiet bool, stderr io.Writer) int64

StartupTranscriptCoverageForTest exposes the banner's probe to the external `tests/cli` package, which cannot call an unexported method. It returns how many partial transcripts the verdict found; 0 means the probe was skipped or found nothing, and whether the store was queried at all is observable on the caller's counter.

type RuntimeHooks

type RuntimeHooks struct {
	NewIngestor  func(config.Config, model.Store) (model.Ingestor, error)
	NewStore     func(config.Config) model.Store
	NewRetriever func(config.Config, model.Store) model.Retriever
	// NewIndex replaces the local index.backend dispatch, returning the index
	// for one kind ("text" or "code") and the path it persists to. It exists so
	// tests can inject an instrumented index (the concurrent startup load of
	// issue #429 F6 is otherwise unobservable from outside the package, and
	// AGENTS.md keeps new tests under tests/). When set it also bypasses the
	// networked qdrant/pgvector branches. It is called once per kind, from two
	// goroutines at once, so an implementation must be safe for concurrent use.
	NewIndex func(config.Config, string) (model.Index, string)
}

type SyncWriter added in v0.10.0

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

SyncWriter serializes concurrent writes to an underlying io.Writer with a mutex. The server runs several long-lived goroutines (embed workers, the corpus writer, the watch worker) plus the main event loop, and they all log diagnostics to the same process stderr sink. A *log.Logger guards its own Output calls, but direct writef(stderr, ...) writes bypass that lock, so two goroutines writing to one unsynchronized sink (e.g. a bytes.Buffer in tests) is a data race (issue #419). Routing every concurrent-phase writer through a single SyncWriter gives them one shared lock.

It is exported (with NewSyncWriter) only so the concurrency regression guard can live in tests/ per AGENTS.md rather than as an internal *_test.go file; there is no external consumer (internal/cli is not importable outside the module).

func NewSyncWriter added in v0.10.0

func NewSyncWriter(w io.Writer) *SyncWriter

NewSyncWriter wraps w so concurrent Write calls are serialized. If w is already a *SyncWriter it is returned unchanged to avoid nesting locks.

func (*SyncWriter) Write added in v0.10.0

func (s *SyncWriter) Write(p []byte) (int, error)

Write serializes concurrent writes to the wrapped io.Writer under a mutex.

Jump to

Keyboard shortcuts

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