Repository navigation
Description
Status
Approved for implementation.
Problem
Maka has an interactive maka TUI and a separate maka-headless evaluation harness, but no general non-interactive entrypoint comparable to codex exec, claude -p, or pi -p.
Two constraints from #31 and #45 remain:
- Headless execution is a runtime property, not an evaluation domain.
- A one-turn session and an autonomous verifier-driven task are different control loops.
The smallest useful outcome is one CLI and one shared runtime without merging those loops.
User outcomes
- Interactive users keep the existing
makaTUI behavior. - Scripts can run one deterministic text turn through
maka runormaka -p. - Automation receives stable stdout, stderr, permission, signal, and exit-code behavior.
- Users can continue or resume compatible sessions without changing stored session identity.
- Evaluation users get one
maka evaltree while the legacy bin remains compatible during migration.
Command tree
maka
maka run [PROMPT]
maka -p [PROMPT]
maka eval run <spec>
maka eval compare <results>
maka eval task-run run|inspect|resume|retry-failed|export
maka eval harbor ...
maka eval ahe ...
maka keeps launching the TUI. maka -p is an exact alias for maka run.
Architecture boundary
flowchart TB
Caller --> CLI[maka CLI]
CLI --> TUI[Interactive TUI]
CLI --> Run[maka run / -p]
CLI --> Eval[maka eval]
TUI --> SessionDriver[Interactive session driver]
Run --> RunAdapter[Non-interactive CLI adapter]
Eval --> TaskController[Autonomous task controller]
SessionDriver --> Runtime[Existing shared runtime]
RunAdapter --> Runtime
TaskController --> Runtime
Runtime --> Sessions[(Session store)]
TaskController --> Verifier[Verifier and result export]
The run adapter is CLI-local. It reuses the existing session/runtime path, consumes live events for fail-closed permissions, and reads the final InvocationResult. A public controller is deferred until a second caller proves the abstraction necessary. Evaluation retains verifier, retry, task-run, Harbor, AHE, matrix, and result-export behavior.
maka run contract
Input
maka run "explain this repository"
maka run - < prompt.txt
maka run "summarize this input" < document.txtrun -uses stdin as the complete prompt.- Positional prompt plus piped stdin uses the prompt as instruction and stdin as context.
- Non-TTY stdin without a positional prompt is equivalent to
run -. - Missing input is exit
2.
One invocation runs one model turn, including tool steps, then exits. It has no verifier or outer retry loop.
Result and exit codes
Text is the only initial format. stdout contains only the final answer; progress and diagnostics use stderr.
The existing runtime InvocationResult remains the single result source and gains finalOutput. RuntimeRunner sets it from the last non-partial model text event in the invocation only after a completed terminal event. Completed without non-empty final text becomes missing_final_output; the CLI never guesses from arbitrary stream text.
0: completed withfinalOutput1: permission denial, timeout, step/token cap, missing output, or runtime/provider/policy failure2: invalid input or pre-invocation configuration, including unknown connection/model, missing credentials, missing cwd, or incompatible session130: SIGINT
Auth rejection or transport failure after provider startup is runtime failure 1. Any permission denial remains failure, matching current RuntimeRunner.
Permissions
New sessions default to explore. The CLI exposes explore, execute, and bypass, not interactive ask.
Every permission prompt without a matching rule is resolved immediately as deny. Evaluation order is:
- matching
--deny: deny - matching
--allow: allow - otherwise apply the mode; any resulting prompt is deny
Rules apply only to this invocation. Project configuration cannot elevate them.
The initial grammar supports repeatable categories such as category:file_write and exact Bash rules such as Bash(npm test). Bash content uses exact string equality after CLI parsing, without whitespace rewriting, glob, regex, or prefix matching.
Sessions
A run creates and persists a new session by default. Canonical cwd means realpath(resolve(cwd)).
- New sessions store canonical cwd.
- Existing stored cwd is canonicalized at read/compare time without rewriting its header. A missing or inaccessible path is incompatible and exits
2. --resume <id>uses that session and stored canonical cwd. An explicit conflicting--cwdis exit2; implicit process cwd is ignored.--continueconsiders non-archivedactiveorabortedsessions with matching canonical cwd, a non-emptylastMessageAt, and a supported mode. It sorts bylastMessageAtdescending, then session id ascending. No match is exit2.- Resume keeps stored cwd, connection, model, thinking, and permission mode. Conflicting explicit
--connection,--model,--thinking, or--permission-modeis exit2. asksessions are incompatible rather than downgraded.--timeoutand--max-stepsare per invocation.
Legacy mapping
maka-headless eval <spec> ... -> maka eval run <spec> ...
maka-headless compare ... -> maka eval compare ...
maka-headless task <command> ... -> maka eval task-run <command> ...
maka-headless harbor ... -> maka eval harbor ...
maka-headless ahe ... -> maka eval ahe ...
The legacy bin uses the same eval router and adds only a stderr deprecation warning. Help/error text may use the invoked program name; functional output and exit codes otherwise match.
Implementation tracking
Implementation and merge order is strictly serial: slice 1 → 2 → 3 → 4. Each slice starts from the latest main after its blocker is squash-merged. Do not stack these PRs.
- Slice 1: route evaluation commands through
maka eval- Delivers the new eval tree and legacy forwarding shim without changing evaluation behavior.
- Acceptance: all five legacy mappings preserve functional output and exit codes; bare
makastill launches the TUI.
- Slice 2: add non-interactive text runs
- Blocked by slice 1.
- Delivers
maka run/maka -p, input handling, strict final output, fail-closed prompts, limits, signals, and exit codes.
- Slice 3: add non-interactive permission controls
- Blocked by slice 2.
- Delivers permission modes and exact allow/deny rules without weakening the default fail-closed policy.
- Slice 4: resume non-interactive sessions
- Blocked by slice 3.
- Delivers deterministic
--resumeand cwd-scoped--continue.
Testing decisions
- Exercise argv, stdin, stdout, stderr, signals, and exit codes at the CLI process boundary with deterministic fake backends.
- Test
InvocationResult.finalOutputand fail-closed permission outcomes at the runtime seam. - Run the legacy and unified eval entrypoints through the same router contract and compare functional output and exit codes.
- Test session selection, cwd canonicalization, compatibility rejection, and stable ordering independently of the TUI.
Non-goals
- autonomous verification or outer retries in
maka run - structured output, package renaming, protocol adapters, or sandbox integration
- ephemeral storage, bidirectional prompts, or fuzzy permission rules
Activity
[-]RFC: unify Maka CLI entrypoints for interactive, run, and eval[/-][+]feat(cli): unify interactive, run, and eval entrypoints[/+]likun666661 commentedon Jul 12, 2026
Implemented and validated across all four serial slices:
maka run/maka -p--resume/--continueAll four PRs are merged with green CI. A final isolated DeepSeek V4 Pro smoke also passed the run, alias, stdin, resume, continue, permission deny/allow, conflict, stdout, and exit-code paths. Closing as completed.