Skip to content

feat(commands): deterministic [commands] reflex — drive skills without the LLM - #7

Open
ceounittt wants to merge 2 commits into
mainfrom
feature/reflex-commands
Open

feat(commands): deterministic [commands] reflex — drive skills without the LLM#7
ceounittt wants to merge 2 commits into
mainfrom
feature/reflex-commands

Conversation

@ceounittt

@ceounittt ceounittt commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

What & why

A user with no LLM turn can't drive Albert at all. This PR adds deterministic /commands: a config-declared [commands] table binds a /name to a skill script, runs it via forkd, and renders the JSON output through a template — as a reflex, before and instead of the LLM. It's the deterministic counterpart to the owner-only ACL commands (/allow /deny /allowed). Fast, cheap, predictable: no model call, no agent turn.

Covers both code and config in a single PR.

How it works

[commands."/status"]
skill_path = "your-skill/scripts/run.py"   # relative to the skills dir (forkd skill_path)
args       = ["status"]                     # the script's subcommand + flags
reply      = "Status: {state} (uptime {uptime})."
help       = "service status"

[commands."/echo"]                            # /echo hello
skill_path   = "your-skill/scripts/run.py"
args         = ["echo", "{arg}"]              # a trailing {arg} takes the user's text
reply        = "You said: {text}"
owner_only   = true
  • /name arg → forkd forkd.run {skill_path, interpreter, args, timeout_secs} → renders {field} / {nested.field} from the script's JSON stdout.
  • A single trailing {arg} in args receives the text after the command word; calling it with no text returns a short usage hint (never a stray empty argv token).
  • reply template: an unresolved path renders as , non-JSON stdout is echoed as-is, and the reply is capped to Telegram's message limit.
  • /help is auto-composed: the built-in help plus the listing of configured commands.

Security

  • owner_only is enforced before any forkd dispatch (reuses acl::is_owner).
  • forkd runs argv with no shell — argument injection is inert; {arg} is substituted only into args, never into skill_path/interpreter (both config-only).
  • The command branch does not log the message text or output at INFO; no secret/PII leaks to the log.
  • Load-time validation: command names must start with /; a collision with a built-in reflex is warned about.

Tests

19 unit tests over build_args / fill / resolve / render / capped / help_listing (edge cases: empty {arg}, unbalanced braces, a value containing {...} is not re-expanded, timeout vs non-zero exit, oversized-reply truncation). cargo test and cargo build --release are green.

Files

  • src/commands.rs — the dispatcher (new); src/config.rsCommandSpec + validation; src/cogitator.rs — reflex wiring + /help.
  • albert.toml, README.md, docs/configuration.md, docs/structure.md — example + reference.

Ivan Vaskovsky added 2 commits August 7, 2026 23:00
Add [commands] to albert.toml: a /name -> {skill_path, args, reply
template, owner_only, timeout} map, parsed into Config.commands. The
dispatcher (next commit) runs the script via forkd and renders its JSON
stdout through the template as a reflex, before the LLM.
…out the LLM

A config-declared `[commands]` table maps a `/name` to a skill script run via
forkd and renders its JSON stdout through a `{field}` template, answered as a
reflex before the LLM — the deterministic counterpart to the owner-only ACL
admin commands. Lets a user drive Albert's existing skills fast, cheap, and
predictably: no model call, no agent turn.

- src/commands.rs: the dispatcher — owner_only gate (reuses acl::is_owner),
  {arg} substitution guarded by a usage hint, forkd.run round-trip, template
  render (missing path → —, non-JSON echoed raw), reply capped to Telegram's
  limit, timeout clamped to forkd's max. help_listing feeds /help.
- cogitator.rs: wire the reflex after the ACL check; /help now composes the
  built-in help with the configured command listing (so [commands] are
  discoverable and can't be shadowed by a "/help" entry).
- config.rs: load-time validation — command names must start with '/', warn on
  collision with a built-in reflex.
- albert.toml / README / docs: a documented example + a reference section.
- 19 unit tests over build_args/fill/resolve/render/capped/help_listing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant