bandicot
Bandicot Docs
Chapter VReference · Available now

Command line

Drive the running Bandicot app from Terminal with `bandicot rpc`, list every method, search past chats, apply setup files and read the exit codes.

Available now. A current user-facing path exists within the stated scope.

Where the command is

The bandicot command is inside the app, at /Applications/Bandicot.app/Contents/MacOS/bandicot.

Call it by that full path, or make an alias for it. A bandicot already on your PATH may be an older build without rpc. bandicot version prints the build, and bandicot --help prints every command.

Commands
CommandWhat it does
bandicot rpc <method> [json]Calls one method on the running app and prints the result as JSON.
bandicot methods [--pretty]Lists every method with its params and its effect. Needs no running app.
bandicot history search|read|sessionsSearches and reads this folder's past chats, even with the app closed.
bandicot setup check|plan|apply|undo|export|receiptsChecks, previews, applies and undoes a setup file.
bandicot brain context|recall|remember|forgetReads and writes memory notes for the current folder; --global for every project.
bandicot versionPrints the build version.

Call the app with bandicot rpc

bandicot rpc <method> '<json params>' sends one call to the running Bandicot and prints its answer as JSON.

Bandicot must be open. Every method is listed by bandicot methods, with an effect: read looks, write changes Bandicot's state, spends starts model work, and outside reaches the network, a browser, the Mac or Team members. Anything but a read needs --yes, and so does reading a path outside the project.

A result that grants access prints its tokens redacted unless you pass --reveal. --events <s> keeps printing that connection's events for that many seconds after the answer.

--timeout and --events take seconds, and a decimal such as 2.5 is accepted. A number outside the range in the table, or a word, is a usage error (exit 2). If Bandicot is not up yet, rpc retries the connection for up to ten seconds before it gives up with exit 3.

  1. Open Bandicot.
  2. List what you can call: bandicot methods --pretty.
  3. Read something: bandicot rpc session_list --pretty.
  4. Change something only with --yes, for example bandicot rpc session_rename '{"session_id":"…","title":"Draft"}' --yes.
  5. Read the state back with a read method to confirm the change.
Options for bandicot rpc
OptionMeaning
--yesAllows a call that is not a read, or a read outside the project.
--prettyIndents the JSON.
--timeout <s>Seconds to wait for the answer, from 0 to 86400; 30 by default.
--events <s>Keeps printing event frames for that many seconds, from 0 to 86400.
--betaTalks to Bandicot Beta instead of Bandicot.
--channel <name>Talks to another channel's app, such as production or beta.
--socket <path>Talks to one engine exactly.
--revealPrints access tokens instead of redacting them.

Exit codes

bandicot rpc exits 0 when the app answered, 1 when it refused, and 2 to 7 for problems before or around the call.

After exit 4 to 7, a call that is not a read may already have run. The message names a read method to check with: read the state before you call it again.

What each exit code means
ExitMeaningWhat to do
0Answered.Read the JSON on stdout.
1The engine refused; {"error_code","error_message"} is on stderr.Look the code up in Troubleshooting.
2Usage error, or refused before sending (for example a write without --yes).Fix the command.
3Bandicot is not running.Open Bandicot and try again.
4No answer within --timeout.Check with the read the message names before retrying.
5The connection was lost before the answer.Check with a read, then retry.
6The answer was over 64 MiB.Ask for less, for example a smaller page.
7Failed on this side.Read the message; retry once.

If it goes wrong

Bandicot is not running; open it first
Open the app. rpc waits up to ten seconds for an app that is starting.
… changes Bandicot's state; pass --yes to call it
Add --yes if you meant to change it.
no production app answers; these other engines do
Pick one with --channel or --socket, as the message lists.
Bandicot stayed busy until the timeout
The app was finishing a step. Raise --timeout or try again.

Search past chats with bandicot history

bandicot history search <query> searches this folder's conversations for the active profile and prints JSON; it works with the app closed.

bandicot history read <session-id> reads one conversation and bandicot history sessions [query] lists them. The project is the folder you run it in. It never asks the running app, so it cannot change which chat is open.

Errors are one JSON line on stderr with a code: exit 1 means refused and exit 2 means a usage problem, including invalid_args.

Options for bandicot history
OptionUsed withMeaning
--session <id>searchSearch one conversation instead of the whole project.
--toolssearchAlso search tool calls and their output; secrets are masked.
--regexsearchTreat the query as a regular expression without groups.
--limit <n>search, readResults per page: 1 to 50 for search, 1 to 20 for read.
--cursor <c>search, readContinue from the cursor the previous page printed.
--around <message-id>readCentre the page on one message.
--prettyallIndent the JSON.
--profile <id>allRead another of your profiles instead of the active one.

If it goes wrong

signed_out
Sign in to the app on this Mac, then run it again.
secrets_unavailable
Unlock the Keychain; past tool output cannot be masked without the saved keys.
no_such_session
Run it from the project folder the chat belongs to, with the right profile.
no_home
HOME is unset or not an absolute path, so the conversations cannot be found. Run it from a normal shell.
no_such_profile
No profile of yours has that id on this Mac. Check the id given to --profile.
invalid_cursor
The cursor is not from this search. Use the one the last page printed, or start again without --cursor.
invalid_args
Check --limit is in range and the query is a valid expression without groups when you use --regex. This one exits 2.
read_failed
Something could not be read; the message names the cause. Try again.

Apply a setup file from Terminal

bandicot setup plan FILE shows what a setup file would change, and bandicot setup apply FILE applies it after you consent.

In a terminal, apply asks for each key the file needs; pass --credential PROVIDER=stdin or env:NAME to supply one without typing it. Sensitive changes need --allow ID or --allow-sensitive after reviewing the plan. bandicot setup undo reverses the last apply, and bandicot setup export --out DIR writes your setup to a folder.

Exit codes for bandicot setup
ExitMeaning
0Done, or nothing to do.
1Failed.
2Invalid file or usage.
3Consent missing for a sensitive change.
4The machine changed since the plan, or the undo was refused.
5The running app could not be reached.
6A required key is missing.

Options for bandicot setup

check validates a file, plan previews it, apply writes it, undo reverses an apply, export writes your setup out and receipts lists past applies.

check FILE validates the file alone and reads none of your settings. plan FILE prints each change with a mark (+ to create, ~ to change, - to remove) and flags the sensitive ones. apply FILE writes after consent. undo [RECEIPT] restores what an apply changed, the last one by default. export --out DIR writes a setup folder. receipts lists every apply on this Mac.

Every command takes --json for one JSON result instead of text. Keys are never read from arguments: a value for --credential must be stdin or env:NAME, so it never shows in a process list.

Options for bandicot setup
OptionUsed withMeaning
--jsonallPrint JSON.
--allplanAlso list items that are already set.
--yes, -yapplyDo not ask; apply without the review questions.
--allow <id>applyConsent to one sensitive change by its id. Repeat for more.
--allow-sensitiveapplyConsent to every sensitive change, after you read the plan.
--credential PROVIDER=stdin|env:NAMEapplySupply a key from standard input or an environment variable. Repeat for more.
--overwriteplan, apply, undoChange items you edited by hand since the last apply, or restore files that changed since the apply being undone.
--pruneplan, applyRemove items an earlier apply installed that the file no longer names; items you edited are kept.
--out <dir>exportThe folder to write the setup file into.

If it goes wrong

nothing applied; these sensitive changes need consent
Review the plan, then pass --allow <id> for each listed change, or --allow-sensitive for all. This exits 3.
nothing undone; changed since the apply
Files changed after the apply. Pass --overwrite to restore them anyway. This exits 4.
--credential takes PROVIDER=stdin or PROVIDER=env:NAME
Give the source of the key, never the key itself.

Read and write memory with bandicot brain

bandicot brain runs the agent's memory tool from Terminal on the folder you are in, or on notes kept everywhere with --global.

context <query> finds the few notes that fit a question, recall [query] lists or searches notes, remember <name> <text> saves one and forget <name> deletes one. Put --global last to use the notes kept everywhere; for recall it may come right after the command. A name or query must not start with a dash.

It exits 0 when it worked, 1 when the memory tool refused (the message says why, for example a note that is too large or no note by that name), and 2 for a usage mistake such as a missing name or an unknown option. See Memory for where the notes live.

Questions

Can I script Bandicot?

Yes. bandicot rpc calls any of the app's methods from Terminal or another program and prints JSON.

Why does bandicot rpc ask for --yes?

Anything that changes state, spends model time or reaches outside Bandicot needs it, so a script cannot change things by accident.