Skip to content

Shell Commands

tcsenpai edited this page Nov 30, 2026 · 4 revisions

Shell Commands

Purpose

The ringzero shell on COM1 and PS/2: how a typed line is routed to the agent, to a machine command (!name) or to a session command (/name), and what every command takes and does. Baseline of the code as of the OpenSpec adoption; the command table is CMDS in kernel/src/shell.rs and /help prints it.

Requirements

Requirement: Line routing

The shell SHALL send a line that does not start with ! or / to the agent as one user turn, with a leading @ and the spaces after it removed, and SHALL treat a line starting with ! as a machine command and a line starting with / as a session command. Source: kernel/src/shell.rs run, pre_of

Scenario: Plain text goes to the agent

  • WHEN the user types how much free memory do I have
  • THEN agent::ask receives that text and no command runs

Scenario: The old @ prefix still works

  • WHEN the user types @ hello
  • THEN the agent receives hello

Requirement: Wrong prefix and unknown command

The shell MUST NOT run a command typed with the wrong prefix; it SHALL print that the name is a machine or a session command and suggest the other prefix, and for a name that is in neither table it SHALL print unknown command '<line>'. Type /help, or type without <prefix> to ask the agent. Source: kernel/src/shell.rs run

Scenario: Session command typed with !

  • WHEN the user types undo with the ! prefix
  • THEN the shell prints 'undo' is a session command: try /undo and nothing is undone

Scenario: Unknown name

  • WHEN the user types a slash and a name that is in neither table
  • THEN the shell prints the unknown command line and the agent is not called

Requirement: Bare prefix lists commands

A line that is only ! or / SHALL print commands: followed by every command of that prefix; at the prompt, a bare ! or / left alone for 400 ms SHALL print the same list as a suggestion. Source: kernel/src/shell.rs run, readline

Scenario: Bare slash

  • WHEN the user types / and Enter
  • THEN the shell prints every session command name with its / prefix

Requirement: Line history and limits

The line editor SHALL recall the last 16 distinct lines with up and down, SHALL accept lines up to 16384 bytes at the prompt (history keeps lines up to 1024 bytes), and SHALL cancel the line on Ctrl-C. Source: kernel/src/shell.rs HIST, HIST_N, readline, LINE

Scenario: Ctrl-C cancels the line

  • WHEN the user types half a line and presses Ctrl-C
  • THEN the shell prints ^C and nothing runs

Requirement: Tab completion

Tab SHALL complete command names and the first argument from the command table: the longest common prefix, a trailing space when one candidate is left, a list when several are. Source: kernel/src/shell.rs redraw, candidates, suggest, add

Scenario: Tab completes a unique command

  • WHEN the user types /hib (a prefix of hibernate) and Tab
  • THEN the line becomes /hibernate with a trailing space

Scenario: Tab completes an argument

  • WHEN the user types !kbd u and Tab
  • THEN the line becomes !kbd us

Requirement: Confirmation questions

A y/N question SHALL confirm only on an answer of y or yes (any case, spaces trimmed); every other answer, an empty line and Ctrl-C SHALL mean no, and each answer SHALL be recorded in the kernel log as confirmation: yes or confirmation: no. Source: kernel/src/shell.rs readline, confirm

Scenario: Enter means no

  • WHEN a command asks [y/N] and the user presses Enter
  • THEN the answer is no and the action does not run

Requirement: Hidden test commands

The shell SHALL accept two commands that are not in the table or in /help, with either prefix: toks prints the boot prefix token ids, and fault reads an unmapped address to test the page fault handler (the machine halts). Source: kernel/src/shell.rs run

Scenario: Prefix token dump

  • WHEN the user types /toks
  • THEN the boot prefix token ids are printed comma separated

Requirement: Help command

!help and /help SHALL print the introduction, every machine command under ! machine commands: and every session command under / session commands:, each with its help text from the command table, then the editing and snapshot notes. Source: kernel/src/shell.rs CMDS, help, run

Scenario: Help lists both tables

  • WHEN the user types /help
  • THEN every entry of CMDS is printed once per prefix it has, /stats and !stats included

Requirement: Machine information commands

!mem SHALL print total and free memory, the model and the engine arena; !cpu the CPU model, clock and features; !uptime the time since boot; !cores [N] the cores online after setting the inference cores to N when N is given; !log [N] the last N kernel log lines, 20 when N is missing or not a number. Source: kernel/src/shell.rs CMDS, run

Scenario: Default log length

  • WHEN the user types !log
  • THEN the last 20 kernel log lines are printed

Scenario: Cores with an argument

  • WHEN the user types !cores 2
  • THEN the cores setting is applied as !set cores 2 and the core list is printed

Requirement: Keyboard command

!kbd without an argument SHALL print the current layout and (available: us, it); !kbd us or !kbd it SHALL set the layout like !set keyboard. Source: kernel/src/shell.rs CMDS, run

Scenario: Show the layout

  • WHEN the user types !kbd
  • THEN the shell prints keyboard layout it (available: us, it) on a fresh boot

Requirement: Set command

!set <key> <value> SHALL apply one setting through the same function the agent's set_setting tool uses and print its result line; the keys are specified by the settings capability. Source: kernel/src/shell.rs SETTINGS, CMDS, run

Scenario: Set a key

  • WHEN the user types !set temperature 0.7
  • THEN the shell prints temperature = 0.7 (top-p 0.95 sampling)

Requirement: Park command

!park off|idle|<usec> SHALL set worker core parking to off (always spin), idle (spin during a generation, park between requests) or always with that spin window, and SHALL print the mode; without a valid argument it SHALL only print the current mode. The default is idle. Source: kernel/src/shell.rs CMDS, run; kernel/src/smp.rs PARK

Scenario: Query parking

  • WHEN the user types !park on a fresh boot
  • THEN the shell prints [park] idle (spin during a generation, park between requests)

Requirement: Stats command

!stats and /stats SHALL print one [stats] line with threads, parked cores, wake IPIs, arena and heap use, agent context fill against the maximum, KV type and keyboard layout. Source: kernel/src/shell.rs CMDS, run

Scenario: Stats line

  • WHEN the user types !stats
  • THEN one line starting with [stats] threads is printed

Requirement: File write commands

!write PATH TEXT SHALL create or replace the file with TEXT trimmed and \n turned into new lines, and queue it for the memory index; !mkdir PATH SHALL create the directory and missing parents; !sync SHALL flush the disk. Errors SHALL print as [fs] <cmd>: <error>. Source: kernel/src/shell.rs CMDS, fs_cmd

Scenario: Write with new lines

  • WHEN the user types !write /a.txt one\ntwo
  • THEN /a.txt holds two lines and the shell prints [fs] wrote 7 bytes to /a.txt

Requirement: File read commands

!ls [PATH] SHALL list a directory (default /, (empty) for none); !cat PATH SHALL print at most the first 64 KiB and say how many bytes were shown; !df SHALL print disk size and free space. Source: kernel/src/shell.rs CMDS, fs_cmd

Scenario: Long file

  • WHEN the user types !cat on a 100 KiB file
  • THEN 65536 bytes are printed and [fs] first 65536 of 102400 bytes shown

Requirement: Delete command asks

!rm PATH SHALL refuse a non-empty directory without -r (directory is not empty (use !rm -r)), SHALL ask y/N naming the file and its size or the directory and its entry count, and SHALL delete only on yes, dropping the file's memory index chunks; on no it SHALL print [fs] kept PATH. Source: kernel/src/shell.rs CMDS, fs_cmd

Scenario: Declined delete

  • WHEN the user types !rm /a.txt and answers n
  • THEN the file stays and the shell prints [fs] kept /a.txt

Requirement: Program commands

!py CODE and !py -f PATH SHALL run MicroPython; !wasm PATH|NAME [ARGS] [< FILE] SHALL run a WASI program, NAME meaning /bin/NAME.wasm, and !run SHALL be the same command as !wasm. Limits are specified by the programs capability. Source: kernel/src/shell.rs CMDS, run

Scenario: run is wasm

  • WHEN the user types !run wc -l /demo/notes.txt
  • THEN the same code path as !wasm wc -l /demo/notes.txt runs

Requirement: Power commands

!poweroff and !reboot SHALL act at once, without a question, when typed by the user at the shell; both SHALL shut agentd down and sync the disk first, and !poweroff SHALL also write the hibernation image unless /hibernate discard turned that off. Source: kernel/src/shell.rs CMDS, run; kernel/src/sys.rs poweroff, reboot

Scenario: Poweroff from the shell

  • WHEN the user types !poweroff
  • THEN the machine powers off without a y/N question

Requirement: Conversation commands

/clear SHALL clear the screen and start a new conversation from the boot prefix, keeping the old one in /tree; /ctx SHALL print the context fill out of the maximum; /compact SHALL summarize and rebuild the context now and then print the fill; /history [N] SHALL print the last N raw transcript lines, 40 by default, kept across compactions. Source: kernel/src/shell.rs CMDS, run; kernel/src/agent.rs floor_char, ctx_info

Scenario: Clear keeps the old line

  • WHEN the user types /clear
  • THEN the shell prints [agent] new conversation from the boot prefix (the old one stays in /tree)

Requirement: Session setting shortcuts

/think on|off SHALL set the think setting and /temp <0..2> SHALL set the temperature setting, both through the settings function. Source: kernel/src/shell.rs CMDS, run

Scenario: Greedy shortcut

  • WHEN the user types /temp 0
  • THEN the shell prints temperature = 0 (greedy)

Requirement: Snapshot commands

The shell SHALL offer /undo [N] and /redo [N] (N defaults to 1), /retry, /tree [all], /branch NAME, /switch NAME|#ID, /save NAME, /load NAME (the same code as /switch), /drop NAME|#ID, /snap and /hibernate [discard|status]; /branch, /switch, /save, /load and /drop without an argument SHALL print usage: /<cmd> NAME. Their behaviour is specified by the snapshots-hibernation capability. Source: kernel/src/shell.rs CMDS, run

Scenario: Missing name

  • WHEN the user types /save
  • THEN the shell prints usage: /save NAME

Requirement: Retry command

/retry SHALL undo the last turn and ask its question again, reseeding the sampler when the temperature is above 0; with no question at the current point it SHALL print [retry] nothing to retry here (no question at this point). Source: kernel/src/shell.rs CMDS; kernel/src/agent.rs resume, retry

Scenario: Retry at temperature 0

  • WHEN the temperature is 0 and the user types /retry
  • THEN the same question is asked again from the previous point

Requirement: Memory commands

The shell SHALL offer /agentd [log [N]] (status and the last 10 decisions, or the last N decisions, 30 by default), /facts, /remember KEY VALUE (source user), /forget KEY (asks y/N, prints [facts] kept on no), /consolidate, /embed [-q] [-v] TEXT, /index add [-d YYYY-MM-DD] TEXT|stats|clear|dim N and /search QUERY (top 5 of the ranked answer). Their behaviour is specified by the memory capability. Source: kernel/src/shell.rs CMDS, run, set_setting, index_cmd, search_cmd

Scenario: Forget asks

  • WHEN the user types /forget user_name and answers n
  • THEN the fact stays and the shell prints [facts] kept

Scenario: Remember without a value

  • WHEN the user types /remember name
  • THEN the shell prints usage: /remember KEY VALUE

Requirement: Manual command

/man [TOPIC|check] SHALL search the built-in manual; its behaviour is specified by the manual capability. Source: kernel/src/shell.rs CMDS, run

Scenario: Manual lookup

  • WHEN the user types /man undo
  • THEN agentd::man runs with the argument undo

Requirement: Benchmark and debug commands

/bench SHALL run a 64-token decode bench, /fill [tokens] a prefill and decode at that fill (1024 by default), /prefill [B] [avx2|vnni] a timed boot prefix prefill, /spec [N] a check of N speculative verifier positions (16 by default) and /gen <n> <text> greedy ids with logit margins. Source: kernel/src/shell.rs CMDS, run

Scenario: gen usage

  • WHEN the user types /gen 5
  • THEN the shell prints usage: /gen <max tokens> <prompt text>

Requirement: Benches restore the conversation

Each bench and debug command SHALL run from position 0 and put the conversation back afterwards. Source: kernel/src/shell.rs run; kernel/src/agent.rs note, resume

Scenario: Conversation restored after a bench

  • WHEN the user types /bench in the middle of a conversation
  • THEN after the bench the shell prints [snap] conversation restored (ctx N) with the same N as before

Requirement: Multi-stream check command

/multi [N] [T] SHALL run N streams (all streams by default) of T greedy tokens each (64 by default, EOS ignored), first every stream alone on the agent's context and then all of them together, one row per stream per pass, and SHALL print the tok/s of both and, per stream, whether the ids and every step's logits are the same. Source: kernel/src/shell.rs CMDS, run; kernel/src/multi.rs bench

Scenario: multi-stream check

  • WHEN the user types /multi 2
  • THEN the shell prints [multi] 2 streams: the agent's context + 1 slots of 4096 positions lent by the snapshot pool (M MiB each), [multi] 2 streams x 64 tokens: alone A tok/s per stream; together B tok/s aggregate (Rx), C tok/s per stream and one [multi] stream S: prompt P tok, ids same (fnv 0x...), logits same line per stream

Requirement: Command table

The shell SHALL have exactly the commands of the table below, in its order, with its prefixes, Tab completion arguments, usage and help; /help SHALL print each once per prefix as <prefix><name padded to 9> <usage> <help>, or the help alone without a usage. For !set the Tab arguments are the setting keys and the help is the /help column of the settings table joined with , . Source: kernel/src/shell.rs CMDS, help; tools/spec_gen.py

Scenario: A line of /help

  • WHEN the user types /help
  • THEN the !log entry prints as !log [N] last N kernel log lines (20)

Scenario: Generated table matches

  • WHEN a row of this table changes and tools/spec_gen.py has not been run
  • THEN tools/spec_check.py fails naming the generated block in kernel/src/shell.rs and INFO.md

Table

Command Tab arguments Usage Help
!help /help this help
!mem memory: total, free, model, engine arena
!cpu CPU model, clock, features
!cores [N] cores online; N = cores used for inference
!log [N] last N kernel log lines (20)
!uptime time since boot
!kbd us it [us|it] PS/2 keyboard layout
!set the setting keys <key> <value> the /help text of every setting key, comma separated (settings table)
!park off idle off|idle|<usec> worker core parking
!stats /stats threads, parking, arena, context
!ls [PATH] list a directory on the disk (default /)
!cat PATH print a file
!write PATH TEXT create or replace a file (\n in TEXT = new line)
!mkdir PATH create a directory (and missing parents)
!rm -r [-r] PATH delete a file, or a directory with -r (asks y/N)
!df disk size and free space
!sync flush the disk (poweroff and reboot do it too)
!py -f CODE | -f PATH run MicroPython (one line echoes values; 10 s budget, Ctrl-C stops it)
!wasm PATH|NAME [ARGS] [< FILE] run a WASI program (NAME = /bin/NAME.wasm, else a coreutils tool; 60 s budget, Ctrl-C stops it)
!run NAME [ARGS] [< FILE] same as !wasm
!poweroff power off now
!reboot reboot now
/clear clear the screen, new conversation
/ctx context fill (tokens in use / 32768)
/compact summarize the conversation and rebuild the context now
/history [N] raw transcript, kept across compactions (40)
/think on off on|off model thinking
/temp <0..2> sampling temperature, 0 = greedy
/undo [N] back N turns (the model's state only, not the machine)
/redo [N] forward again after an undo
/retry ask the last question again (temp 0: the same answer)
/tree all [all] points, branches and saves
/branch NAME start a branch here and switch to it
/switch NAME|#ID go to a branch, a save or a point
/save NAME keep this point (never evicted)
/load NAME go to a saved point
/drop NAME|#ID delete a branch, a save or a point
/snap snapshot status: point, pool, timings
/read clear PATH | clear put a text file (64 KiB at most) into the conversation; its engine state is cached in /var/lib/ringzero/cache/docs and loaded instead of a prefill next time (alone: the cache, clear: delete it)
/hibernate discard status [discard|status] save the conversation and its points to the disk (!poweroff does it too); the next boot resumes it
/agentd log merge-legacy [log [N] | merge-legacy [DIR]] memory subsystem: stores, index, queue, consolidation, decisions; merge-legacy merges what an older kernel wrote (/var/lib/ringzero/legacy)
/facts saved facts (key = value, source, time)
/remember KEY VALUE save a fact
/forget KEY delete a fact (asks y/N)
/consolidate & [&] summarize this session into an episode and facts now (&: on the background stream, next to the next answers)
/embed -q -v [-q] [-v] TEXT embed TEXT (-q: as a query, -v: print all values)
/judge -v [-v] STATE debug: the goal judge on a turn state (\n = new line): P of each choice, P(goal reached), verdict, tokens, time; -v also prints the prompt's token ids
/index add stats clear dim add TEXT | stats | clear (rebuild) | dim N the memory index
/search QUERY top 5 in the memory index (embedding + gated BM25)
/man [TOPIC|check] search the built-in manual (alone: list its sections; check: baked vectors vs a fresh embedding)
/bench 64-token decode bench (the conversation is restored after)
/fill <tokens> prefill + decode speed at that context fill
/gen <n> <text> debug: greedy ids + logit margins
/prefill avx2 vnni [B] [avx2|vnni] prompt block (1 = per token, 64 max) and matmul kernel: time the boot prefix + state hash
/spec [N] debug: speculative verifier logits for N positions (16) vs one transformer_forward each, and their times
/multi [N] [T] N streams decoded together vs alone: aggregate tok/s, ids and logits the same (T tokens each, 64)

Source of this page: openspec/specs/shell-commands/spec.md

Clone this wiki locally