Documentation
¶
Index ¶
- Constants
- Variables
- func CodeErr(code int) error
- func Commit(tmp, path string) error
- func Failf(format string, args ...any) error
- func FormatInt(n int64) string
- func OrUnknown(s string) string
- func ParseFlags(fs *flag.FlagSet, args []string) (pos []string, code int, done bool)
- func ProcessAlive(pid int) bool
- func ReadInputSource(a *App, path string) (string, error)
- func RedactRawJSON(r *redact.Redactor, raw json.RawMessage) (json.RawMessage, error)
- func RedactText(r *redact.Redactor, s string) (string, error)
- func SplitLines(s string) []string
- func Stage(path string, data []byte, perm os.FileMode) (string, error)
- func TextWidth(s string) int
- func Truthy(value string) bool
- func UnifiedDiff(fromName, toName, from, to string) string
- func UnwrapReason(err error) error
- func UsageCount(known int64, unknown int) string
- func Usagef(format string, args ...any) error
- func ValidModelName(model string) bool
- func WithUsageOrigin(ctx context.Context, origin, agent string) context.Context
- func WithUsageRun(ctx context.Context, runID string) context.Context
- func WriteAtomic(path string, data []byte, perm os.FileMode) error
- func WriteTable(w io.Writer, headers []string, rows [][]string)
- func WriteTableAligned(w io.Writer, headers []string, rows [][]string, right []bool)
- type App
- func (a *App) AuditPath() string
- func (a *App) Clock() time.Time
- func (a *App) ColorEnabled(w io.Writer) bool
- func (a *App) CompactionClient(ctx context.Context) (compact.Asker, *compact.Policy)
- func (a *App) CompactionPolicyPath(path string, project bool) string
- func (a *App) Errf(format string, args ...any)
- func (a *App) Getenv(key string) string
- func (a *App) Group(use, short string, subs ...*cobra.Command) *cobra.Command
- func (a *App) Heading(title string)
- func (a *App) HelpText(w io.Writer, body string) string
- func (a *App) JevClient(cfg jev.Config, key func() (string, error)) Asker
- func (a *App) JevConfig() (jev.Config, error)
- func (a *App) LayerName(file string) string
- func (a *App) LoadConfig(cmd string) (*config.Config, bool)
- func (a *App) LoadOptions() config.LoadOptions
- func (a *App) LookPathFunc() func(string) (string, error)
- func (a *App) ModelPath() string
- func (a *App) ModelSelection() (model, source string, err error)
- func (a *App) NewFlagSet(name string) *flag.FlagSet
- func (a *App) Outf(format string, args ...any)
- func (a *App) ProjectPath() string
- func (a *App) RecordJev(client Asker, cfg jev.Config) Asker
- func (a *App) ResolveBinary(flag string) string
- func (a *App) ReviewPath() string
- func (a *App) RootCmd(commands ...*cobra.Command) *cobra.Command
- func (a *App) Run(args []string, commands ...*cobra.Command) int
- func (a *App) RunContext(ctx context.Context, args []string, commands ...*cobra.Command) int
- func (a *App) SDLCRunsDir() string
- func (a *App) SecurityAsker(ctx context.Context) Asker
- func (a *App) SecurityLoadOptions() securityconfig.LoadOptions
- func (a *App) StateHome() string
- func (a *App) Store() *keystore.Store
- func (a *App) Styled(w io.Writer, code, value string) string
- func (a *App) Table(headers []string, rows [][]string)
- func (a *App) Target(project bool) (string, error)
- func (a *App) UserHome() string
- func (a *App) UserPath() string
- type Asker
- type ExitError
Constants ¶
const ( ExitOK = 0 ExitFail = 1 ExitUsage = 2 )
Exit codes.
const ( ANSIReset = "\x1b[0m" ANSIBold = "\x1b[1m" ANSIDim = "\x1b[2m" ANSICyan = "\x1b[1;36m" ANSIGreen = "\x1b[32m" ANSIRed = "\x1b[31m" ANSIYellow = "\x1b[33m" )
const DiffContext = 3
const MaxTestInput = 8 << 20
maxTestInput bounds what `redact test` reads.
Variables ¶
var ANSISGR = regexp.MustCompile(`\x1b\[[0-9;]*m`)
var RunIDPattern = regexp.MustCompile(`^[A-Za-z0-9_-]+$`)
Functions ¶
func ParseFlags ¶
parseFlags parses flags interleaved with positional arguments. done is true when the caller should return code immediately (help or a flag error).
func ProcessAlive ¶
func ReadInputSource ¶
readInputSource reads path (or stdin, for "-"), bounded by maxTestInput.
func RedactRawJSON ¶
func RedactRawJSON(r *redact.Redactor, raw json.RawMessage) (json.RawMessage, error)
func RedactText ¶
redactText redacts a State or Instructions value: literal JSON text (the same shapes wireText treats as literal) is redacted recursively while preserving its JSON shape; anything else is redacted as a plain string, matching how the value will actually reach the wire.
func SplitLines ¶
func UnifiedDiff ¶
unifiedDiff renders a unified diff of two texts with the same number of lines (redaction never adds or removes a line). It returns "" when the texts are equal.
func UnwrapReason ¶
unwrapReason prefers the wrapped config error, which names file and key.
func UsageCount ¶
func ValidModelName ¶
func WithUsageOrigin ¶
func WriteAtomic ¶
writeAtomic writes data to path through a same-directory temp file and a rename, so a reader never sees a partial file.
func WriteTable ¶
writeTable renders a small table; callers decide whether cells have color.
Types ¶
type App ¶
type App struct {
Stdin io.Reader
Stdout, Stderr io.Writer
// Environ is the process environment (KEY=value).
Environ []string
// WorkDir holds the project layer at .jevkit/redact.yaml.
WorkDir string
// ConfigDir holds the user layer at redact.yaml.
ConfigDir string
// StateDir holds the audit log and the review store.
StateDir string
// SecurityPolicy selects a named local security policy for this invocation.
SecurityPolicy string
// Yolo lifts the workspace guard; killswitch and Jev scoring still apply.
Yolo bool
// Now is the clock; nil means time.Now.
Now func() time.Time
Version string
// Keystore resolves and stores the API key; nil builds one from
// ConfigDir, WorkDir and Environ.
Keystore *keystore.Store
// Keyring is the OS keychain backend; nil means the real one.
Keyring keystore.Keyring
// NewJev builds the client `key test` uses; nil builds the real one.
NewJev func(cfg jev.Config, key func() (string, error)) Asker
// Breaker is the persisted circuit breaker; nil uses StateDir.
Breaker *breaker.Breaker
// Dial probes endpoint reachability for doctor; nil skips the probe.
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
// LookPath finds agent binaries for doctor/install; nil means not detected
// (tests) or exec.LookPath at the call site when doctor needs real PATH.
LookPath func(name string) (string, error)
// HomeDir is the user home for agent user-scope installs; empty uses
// os.UserHomeDir.
HomeDir string
// Binary is the jevkit path written into agent hooks; empty resolves to
// the running executable or "jevkit".
Binary string
// ReadSecret reads a key with echo off. ok is false when stdin is not a
// terminal; nil means the real terminal check on os.Stdin.
ReadSecret func() (secret []byte, ok bool, err error)
// NewRunID generates an sdlc run id; nil means a random one.
NewRunID func() string
// SdlcReach supplies fake runtime adapters in tests; nil probes CLI binaries.
SdlcReach func() enrollment.Reach
// SdlcExecutor replaces CLI invocation in tests and host integrations.
SdlcExecutor worker.Executor
// WorktreeCreator creates isolated Git worktrees for fan-out subtasks.
// Nil uses worker.GitWorktreeCreator.
WorktreeCreator worker.WorktreeCreator
// SdlcSpecialistNeed replaces the specialist-need router in tests or hosts.
// Nil uses Jev's registered specialist question set.
SdlcSpecialistNeed func(context.Context, string, string, string) (bool, error)
// Confirm prompts prompt and reports whether the user agreed; nil means
// non-interactive (no TTY to confirm on), so a caller offering a
// "gather"-confidence pick for confirmation must instead refuse.
Confirm func(prompt string) (bool, error)
// SuppressOutput silences Outf while a dashboard owns the terminal.
SuppressOutput bool
}
App is the CLI with every external dependency injected, so commands run in-process under test.
func (*App) AuditPath ¶
auditPath and reviewPath resolve through stateHome()+"jevkit" (the same resolver breaker.New, usage.Path, and registry.DecisionsPath use) rather than a.StateDir directly, so a JEVKIT_STATE_DIR override that doesn't itself end in "jevkit" still lands these files next to every other jevkit-owned state file instead of one directory up.
func (*App) CompactionClient ¶
func (*App) CompactionPolicyPath ¶
func (*App) HelpText ¶
helpText preserves Cobra's layout while making section labels and command names easier to scan on an interactive terminal.
func (*App) LoadConfig ¶
load resolves the layered config, reporting a failure to stderr.
func (*App) LoadOptions ¶
func (a *App) LoadOptions() config.LoadOptions
func (*App) ModelSelection ¶
modelSelection chooses the process override, user setting, then built-in default.
func (*App) NewFlagSet ¶
newFlagSet makes a FlagSet that reports to stderr and never exits.
func (*App) ProjectPath ¶
func (*App) ResolveBinary ¶
func (*App) ReviewPath ¶
func (*App) Run ¶
Run dispatches args (without the program name) and returns the exit code. Cobra's own errors (unknown command, bad flag, bad arguments) are usage errors.
func (*App) RunContext ¶
RunContext dispatches a command with a caller-owned cancellation context. commands are the top-level subcommands; the root owns global flags and help.
func (*App) SDLCRunsDir ¶
sdlcRunsDir is where run ledgers live under StateDir.
func (*App) SecurityLoadOptions ¶
func (a *App) SecurityLoadOptions() securityconfig.LoadOptions
func (*App) StateHome ¶
stateHome is the single resolver for the Jevkit state root, independent of how a.StateDir was set: the default (main.go's defaultStateDir, itself XDG/Windows/JEVKIT_STATE_DIR-aware) already ends in "jevkit", while an explicit JEVKIT_STATE_DIR override may or may not. Every caller below joins "jevkit" back on (or delegates to a package like breaker.New, usage.Path, or registry.DecisionsPath that does), so stateHome() always returns the same directory a "jevkit" segment is about to be appended to. Ownership under <stateHome()>/jevkit/:
- sdlc/runs/<runID>/run.json, nodes/, artifacts/, events.jsonl, decisions.jsonl, logs/ — internal/sdlc/ledger, one directory per run (see sdlcRunsDir).
- usage.jsonl — internal/usage, one shared append-only log for every run and every Jev call (see usage.Path).
- decisions.jsonl (top-level, not per-run) — internal/registry, routing decisions outside any run (see registry.DecisionsPath).
- breaker.json — internal/breaker, one shared circuit-breaker state.
- redaction-audit.jsonl, redaction-review.json — internal/redact/audit, shared audit/review records (see auditPath, reviewPath).
- jev-ask-audit.jsonl — internal/mcp, shared MCP audit trail.
External runtime sessions (Claude/Codex/Cursor/OpenCode/Antigravity session IDs used to resume a conversation) are not files under this root at all: they live in the owning CLI's own native session store and are only referenced by ID in ledger.Run.Sessions.