contenoxcli

package
v0.28.7 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 67 Imported by: 0

Documentation

Overview

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

cache_cmd.go implements `contenox cache` — managing data Contenox caches between runs (currently the per-backend model-list cache).

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

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

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.

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

Index

Constants

View Source
const DefaultWorkspaceID = "00000000-0000-0000-0000-000000000002"

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},
	{"hitl-policy-acp.json", hitlPolicyACP},
	{"hitl-policy-acpx.json", hitlPolicyACPX},
}

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/runtime/runtime/contenoxcli.Version=…" (e.g. distro packagers). When empty, CLIVersion uses runtime/version/version.txt.

Functions

func AgentsMDMessage

func AgentsMDMessage(content, path string) taskengine.Message

func CLIVersion

func CLIVersion() string

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

func ComputeReadiness

func ComputeReadiness(ctx context.Context, db libdbexec.DBManager, opts chatOpts) (setupcheck.Result, error)

ComputeReadiness builds the engine — which runs a read-only backend sync, NOT a model completion — and returns the evaluated setup readiness. It is the shared path behind `contenox doctor` and the setup wizard's final check, so readiness is verified without ever sending a prompt (which would run a chain, spend tokens, and could touch tools/audit trails). opts.EffectiveNoDeleteModels is honored by BuildEngine, so a readiness check never prunes models.

func LoadAgentsMD

func LoadAgentsMD(startDir string) (string, string, bool)

func Main

func Main()

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

func NewCLIAskApproval

func NewCLIAskApproval(w io.Writer) localtools.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

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

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

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

func PrintBackendChecks

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

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

func PrintSetupIssues

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

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 ResolveWorkspaceID

func ResolveWorkspaceID(contenoxDir string) string

func RunGlobalInit

func RunGlobalInit(out io.Writer) error

RunGlobalInit ensures ~/.contenox/ has chain files, HITL policies, and a local backend. Unlike RunInit it does NOT create a workspace-scoped .contenox/ directory.

func RunInit

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

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

func WithTransaction

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 = enginesvc.Engine

func BuildEngine

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

Jump to

Keyboard shortcuts

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