contenoxcli

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Overview

backends.go contains helpers for LLM backend and provider config KV storage.

chat_cmd.go implements contenox chat (session-backed chain execution).

cli.go holds the contenox CLI entrypoint (Main), default constants, flags, and merge logic.

hook_cmd.go — contenox hook subcommand tree (add, list, show, remove, update). Each subcommand opens only the DB; no LLM stack is needed.

init.go implements the contenox init subcommand (scaffold .contenox/).

output.go holds CLI output helpers.

session.go — session-related constants and helpers for the contenoxcli package.

session_cmd.go — contenox session subcommand tree (new, list, switch, delete, show). Each subcommand opens only the DB via sessionservice; no LLM stack is needed.

Index

Constants

This section is empty.

Variables

View Source
var ErrPreflightBlocked = errors.New("LLM setup is not ready")

ErrPreflightBlocked is returned when LLM setup is not ready; instructions are already printed to w.

View Source
var HITLPolicyPresets = []struct {
	Name    string
	Content string
}{
	{"hitl-policy-default.json", hitlPolicyDefault},
	{"hitl-policy-strict.json", hitlPolicyStrict},
	{"hitl-policy-dev.json", hitlPolicyDev},
}

HITLPolicyPresets lists the names and content of all embedded HITL policy presets in the order they should be written to disk.

View Source
var Version string

Version is an optional link-time override via -ldflags "-X github.com/contenox/contenox/internal/contenoxcli.Version=…" (e.g. distro packagers). When empty, CLIVersion uses apiframework/version.txt embedded in package apiframework.

Functions

func CLIVersion added in v0.6.6

func CLIVersion() string

CLIVersion returns the effective CLI version string (embedded file or link override).

func Main

func Main()

Main runs the contenox CLI: init subcommand or run (default) with optional positional input.

func NewCLIAskApproval added in v0.7.3

func NewCLIAskApproval(w io.Writer) localhooks.AskApproval

NewCLIAskApproval returns an AskApproval callback suitable for interactive CLI use. It opens /dev/tty directly so it works even when stdin is piped (e.g. --auto runs or shell-piped input). Falls back to os.Stdin if /dev/tty is unavailable.

The callback prints the tool name, args, and diff (if any) to w (stderr), prompts "Approve? y/N:", and blocks until the user responds or ctx is cancelled. Only "y" or "yes" (case-insensitive) approves; everything else (including blank input and EOF) denies.

func OpenDBAt added in v0.6.6

func OpenDBAt(ctx context.Context, dbPath string) (libdb.DBManager, error)

OpenDBAt opens (and creates if needed) the SQLite database at the given path. It applies the application schema and the KV store schema so the kv_store table is always present for provider model-list caching.

func PreflightLLMSetup added in v0.6.6

func PreflightLLMSetup(w io.Writer, res setupcheck.Result) error

PreflightLLMSetup checks setup status before running chat, run, or plan. If the user must fix configuration first, it prints instructions and returns ErrPreflightBlocked. Otherwise it returns nil.

func PrintBackendChecks added in v0.6.6

func PrintBackendChecks(w io.Writer, res setupcheck.Result)

PrintBackendChecks prints one line per registered backend plus any runtime error hint.

func PrintSetupIssues added in v0.6.6

func PrintSetupIssues(w io.Writer, res setupcheck.Result)

PrintSetupIssues prints actionable setup issues after model resolution failures. Includes error and warning severities, ordered for readability.

func ResolveContenoxDir added in v0.6.0

func ResolveContenoxDir(cmd *cobra.Command) (string, error)

ResolveContenoxDir finds the closest .contenox directory by walking up from the current working directory. If cmd is non-nil and --data-dir is set, that value is returned directly. Otherwise it walks up from cwd; if it hits the root without finding one, it returns the .contenox directory in the current working directory as a fallback.

func RunInit

func RunInit(out, errOut io.Writer, force bool, provider string, contenoxDir string) error

RunInit scaffolds .contenox/ with default chain files. provider is "" (defaults to the already-configured provider or "ollama"), "ollama", "gemini", "openai", or "local". contenoxDir is the target data directory (e.g. from --data-dir or the default .contenox/).

func WithTransaction added in v0.5.0

func WithTransaction(ctx context.Context, db libdb.DBManager, fn func(tx libdb.Exec) error) error

WithTransaction is the exported version for use by sub-packages.

Types

type Engine

type Engine struct {
	TaskService execservice.TasksEnvService
	Tracker     libtracker.ActivityTracker
	Stop        func()
	Bus         libbus.Messenger
	MCPManager  *mcpworker.Manager
	// LocalHooks lists the names of all registered local hook handlers.
	LocalHooks []string
	// SetupCheck is the last SetupStatus evaluation after RunBackendCycle (for resolver-failure hints).
	SetupCheck setupcheck.Result
}

func BuildEngine

func BuildEngine(ctx context.Context, db libdbexec.DBManager, opts chatOpts) (*Engine, error)

BuildEngine scaffolds the complex dependency graph needed to run task chains.

func (*Engine) WatchTaskEvents added in v0.6.6

func (e *Engine) WatchTaskEvents(ctx context.Context, requestID string, ch chan<- taskengine.TaskEvent) (libbus.Subscription, error)

WatchTaskEvents subscribes to request-scoped taskengine events and decodes them into structured TaskEvent values for CLI consumers.

Jump to

Keyboard shortcuts

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