Files
splinter/docs/CONFIG.md
T

211 lines
9.7 KiB
Markdown

# Configuration
Splinter reads one file, so that `splinter` alone is enough to start working.
```
~/.splinter/splinter.conf
```
next to the sessions. If that file does not exist, an older install's
`$XDG_CONFIG_HOME/splinter/config` (or `~/.config/splinter/config`) is read
instead.
`SPLINTER_CONFIG=/path` overrides the location, `--config PATH` does the same
for one run, `--no-config` ignores the file entirely, and `--init-config`
writes a commented example.
Format: one `key = value` per line, `#` starts a comment, blank lines are
ignored. Not JSON, on purpose — this file gets edited by hand, and a missing
comma must not be the reason the harness will not start.
## Not in the file: the goal
The session goal is set at runtime with `/goal <text>` — in the TUI, or in a
one-shot run (`splinter -p "/goal ship the config"`). It belongs to the
conversation in front of you, not to a file that outlives it.
## Precedence
Command line, then the file, then the built-in default. An unknown key is an
error with its line number: a typo that is silently ignored is a config that
lies about what it does.
## Keys
| key | meaning |
|-----|---------|
| `endpoint` | OpenAI-compatible URL, e.g. `http://127.0.0.1:8080/v1/chat/completions` |
| `model` | model name the endpoint expects |
| `api_key_env` | name of the env var holding the key (default `SPLINTER_API_KEY`) |
| `transport` | a transport a plugin provides, e.g. `cli` |
| `cli_cmd` | command for the `cli` transport, e.g. `claude -p` |
| `plugin` | a plugin to load, one line each; absolute paths survive a `cd` |
| `theme` | CDE palette name (`splinter --list-themes`) |
| `locale` | language code (`de`, `en`); catalogues live in `share/locale` |
| `autonomous` | `1` runs mutating/destructive tools without asking |
| `steps` | tool rounds per turn (default 150) |
| `max_bytes` | conversation budget in bytes, `0` = no limit |
| `session_dir` | where session logs go (default `~/.splinter`) |
| `system_prompt` | sent once at the start of a conversation |
| `telegram_allow` | user ids the gateway answers, comma-separated; empty means nobody |
| `memory_url` | base URL of a mem0 server (`memory_search`, `memory_add`) |
| `memory_key_env` | env var with the mem0 key, sent as `Authorization: Token <key>` |
| `skills_dir` | a directory of skills, one line each |
| `env_delegates` | `1` turns `CLAUDE_CODE_OAUTH_TOKEN(_N)` into delegates (default off) |
| `exit` | one way to reach a model for the exit ring, see below |
| `delegate` | another model the `delegate` tool can hand work to, see below |
Secrets never go into the file: every `*key_env` names a variable, and the
variable holds the key. Those variables are hidden from the `run` tool's shell.
## Exits and delegates
Both are one line each, `|`-separated, every field but the first named:
```
exit = groq | Groq free tier | endpoint=https://api.groq.com/openai/v1/chat/completions | model=llama-3.3-70b | key_env=GROQ_KEY
delegate = coder | C99, POSIX, kennt den Quellbaum | endpoint=http://127.0.0.1:8080/v1/chat/completions | model=qwen | tags=code,review | prio=5 | max_parallel=2
delegate = far | the same, on another machine | host=buildbox | endpoint=... | model=...
delegate = claude-cli | Claude Code | kind=cli | cmd=claude -p | tags=plan
delegate = claude-b | Claude Code, second account | kind=cli | cmd=claude -p | env=CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-...
```
`exit` fields: `endpoint`, `model`, `key_env`; the second field is the label.
`delegate` fields: `endpoint`, `model`, `key_env`, `tags`, `prio`,
`max_parallel`, `kind` (`openai` or `cli`), `cmd` (for `cli`), and `host` - an
ssh target: the child splinter runs there, with that machine's keys. An unnamed
field is the description the selection reads.
`env=NAME=VALUE` (repeatable, up to 8) sets a variable for the delegate's
child right before it starts, overwriting whatever the parent exported - so two
delegates can run the same CLI with two different accounts. With `host=` it is
sent in front of the remote command as `env 'NAME=VALUE'`. A value cannot
contain `|`. A literal token in the file is a secret in the file: `chmod 600`.
### Limits: bench and fall back
A delegate whose answer says it is at its limit - a 429, "rate limit", "usage
limit", claude's "You've hit your weekly limit · resets 3am (Europe/Lisbon)" -
is benched until that reset, and the same task goes to the next delegate that
fits (the request's tags plus the benched one's). The bench is a file,
`~/.splinter/cooldown/<id>` holding the epoch, so every splinter on the machine
skips it, even when it is asked for by name; delete the file to unbench early.
A reset that cannot be read benches for an hour. In `delegate_parallel` the
task moves to the next delegate in its own slot while the others keep running,
unless that one is already at its `max_parallel`. Only when nothing else fits
does the job wait (`waiting_quota`) for the reset.
## Example: local model
```
endpoint = http://127.0.0.1:8080/v1/chat/completions
model = /models/unsloth/Qwen3.6-35B-A3B-MTP-GGUF/Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
theme = Delphinium
autonomous = 1
plugin = /home/lotherk/src/splinter/plugins/lcm/lcm.so
plugin = /home/lotherk/src/splinter/plugins/cps/cps.so
plugin = /home/lotherk/src/splinter/plugins/clock/clock.so
session_dir = /home/lotherk/.splinter
```
## Example: Claude Code as the model
```
transport = cli
cli_cmd = claude -p
cli_timeout = 1800
plugin = /home/lotherk/src/splinter/plugins/cli/cli.so
theme = Delphinium
```
`cli_env = NAME=VALUE` (repeatable, up to 8) sets a variable for the cli
program, e.g. `cli_env = CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-...`. It
overwrites an exported variable of the same name.
### Sessions
A cli program keeps its own conversation across calls. splinter exports its
session id as `SPLINTER_CLI_SESSION`; a cli delegate extends it with its name
(`sess-...:claude0`), so every delegate has its own conversation per splinter
session, and `claude0` and `claude1` never share one. From that key:
- `claude`: a UUID derived from the key, `--session-id` on the first call,
`--resume` after that (remembered in `~/.splinter/cli/`, or
`$SPLINTER_CLI_STATE`). If claude disagrees - session moved or deleted - the
other form is tried once, which costs no model call.
- `opencode`: `--session ses_<derived>`, created by opencode if missing.
- anything else: `{session}` and `{uuid}` in the command expand to the key and
the UUID.
Consecutive calls stay in one conversation, so the provider's prompt cache
covers the history: measured with claude, the second call read 17.6k tokens
from cache and wrote 80. A command that already says `--session`, `--resume`
or `--continue` is left alone; an exported empty `SPLINTER_CLI_SESSION` turns
sessions off. Only the newest user message is sent - the program has the rest.
`cli_fallback = claude1, claude0` names cli delegates to use, in order, when
`cli_cmd` is at its limit: their `cmd` and `env=` replace the main ones for
that call. The main command is benched as `cli`, a fallback under its own id -
the same bench delegation uses, so an account at its limit is skipped
everywhere. The session key stays, so claude resumes the same conversation
under the next account. A fallback's `env=` reaches the program through a
0600 file the shell sources, never through a command line `ps` would show.
When every account is benched, the turn fails with the first reset time.
`cli_cmd` may contain `{file}` (the prompt temp-file path) or `{prompt}` (a
shell-quoted prompt). Without a placeholder the prompt is fed on stdin, which
works for `claude -p`, `ollama run`, and similar tools. For CLIs that take the
message as an argument, use e.g. `cli_cmd = opencode run --format default {file}`
or pass the prompt via a flag your CLI supports.
With both `endpoint` and `transport` set, `transport` wins — it is the more
specific instruction.
## Adding a provider from the chat
`/connect` — in the Telegram gateway and in the TUI (one answer per line) —
asks for a name, an endpoint, a model and the
variable that holds the key, then writes one `delegate` line to
`<config>.d/20-connect.conf` — the drop-in next to the file that is in use, so
`--config` works too. Adding the same name again replaces its line. The
provider is usable in that run at once: the delegate table in memory is the one
the running agent reads. `ollama` and `opencode` are accepted instead of a URL
and stand for `http://127.0.0.1:11434/v1/chat/completions` and
`https://opencode.ai/zen/go/v1/chat/completions` (the latter with
`OPENCODE_GO_API_KEY`).
`/model` offers the models the config names and switches the transport; the
choice is written to `<config>.d/90-model.conf` (`endpoint`, `model`,
`api_key_env`), so the next start has it. Picking `main` deletes that file and
the configuration speaks again. `/model probe` asks each endpoint `/v1/models`
and lists what it really serves; `/model <name>` takes another model from the
current endpoint. With a plugin `transport` nothing is written — that program
picks the model.
## Drop-ins
Next to the config file, a directory with the same name plus `.d` is read after
it, every `*.conf` in name order:
```
~/.splinter/splinter.conf
~/.splinter/splinter.conf.d/10-local.conf
~/.splinter/splinter.conf.d/20-delegates.conf
```
A later file overrides an earlier one, and an unknown key is still an error -
now with the file it came from. Proven in `test_config`.
## Installieren ohne root
make install PREFIX=$HOME/.local
Das installierte Binary traegt einen RPATH auf `$ORIGIN/../lib`, findet seine
`libsplinter.so` also neben sich. Kein Wrapper, kein `LD_LIBRARY_PATH`, keine
Umgebungsdatei: `~/.local/bin/splinter` ist das Programm.
Keys kommen aus der Umgebung, die du selbst exportierst — splinter liest keine
fremde Konfigurationsdatei mit. Ein Delegate nennt nur den Namen der Variablen
(`key_env=OPENCODE_GO_API_KEY`).