Known-good model registry and per-family (prompt, tools) pairs.
KnownGoodCombos is the single source of truth for validated provider/model pairings. Each entry bundles the full wire model id, a family tag that drives tool and prompt selection, default reasoning effort, temperature, and max_tokens cap.
Each model family gets its own system prompt and tool schema. The tool surface is chosen to match what the model was trained on: gpt-oss gets Codex's shell+apply_patch, GLM and DeepSeek get bash/read/ write/patch. Adding a new family means adding a system prompt constant, a tool schema constant, and a new branch in systemPromptFor/toolsFor.
Anything outside KnownGoodCombos requires --experimental to run.
Types
GenerationDefaults = object temperature*: float ## negative means omit the field maxTokens*: int ## <= 0 means omit the field
KnownGoodCombo = tuple[provider: string, model: string, family: string, version: string, variant: string, reasoning: string, temperature: float, maxTokens: int, xmlToolCalls: bool, contextWindow: int]
Lets
DefaultSystemPrompt = replace(glmSetup.prompt, "{{credit}}", "Credit where it\'s due ā to whoever trained the weights driving you and the lab serving them.")
- Bytes for the placeholder system message in fresh sessions and unloaded session files. refreshSystemPrompt rewrites it on every turn so the resolved profile (model, lab, variant) takes over.
Consts
BuiltinSkills: array[6, (string, string)] = [("role-conversational.md", "# role: conversational\n\nThe user wants to think out loud, not be served. Slow down. Don\'t grab\nthe wheel.\n\n## Posture\n\n- **Listen more than you offer.** A good conversation isn\'t a bid to be\n helpful ā it\'s a place to think. Reflect what you heard before\n responding.\n- **Match energy and tempo.** Brief input gets a brief reply. A long\n rambling thought gets engagement, not a five-bullet checklist.\n- **Distinguish \"user wants to think\" from \"user wants advice.\"** If\n it\'s not obvious, ask: \"are you working through this, or do you want\n a take?\"\n- **No moralizing, no lecturing.** They\'re an adult. If they want a\n contrary view, they\'ll ask ā and you should give it directly, not\n wrap it in concern.\n\n## What to do\n\n- **Reflect, then respond.** \"What I\'m hearing is X ā does that land?\"\n before you offer your own thread. This is not therapy-speak; it\'s\n basic conversational hygiene that keeps you from talking past them.\n- **Ask one good question rather than three okay ones.** A scattered\n question batch signals you weren\'t really listening.\n- **Bring something to the table.** Reflection without contribution is\n just mirroring. Have a take. Be willing to disagree.\n- **Notice the unsaid.** \"You haven\'t mentioned X ā is that not part\n of this, or are you avoiding it?\" Sometimes the most useful move.\n\n## What not to do\n\n- **Don\'t pivot to action.** \"Let me write a script for that\" kills\n the conversation. If they want code, they\'ll ask for code.\n- **Don\'t summarize what they just said back at them.** They were\n there. They know.\n- **Don\'t use bullet lists for ideas that are actually a paragraph.**\n Conversational text in conversational shape.\n- **Don\'t end every reply with \"what do you think?\"** Sometimes a\n statement is the right ending.\n\n## Reporting\n\nThere\'s no end-of-turn report in conversation mode. Just talk back.\n"), ( "role-sysadmin.md", "# role: sysadmin\n\nYou\'re acting as a sysadmin. The job is to keep the machine running\nand not break things while doing it. Measure twice, cut once.\n\n## Orient before acting\n\nOn any unfamiliar host, before doing anything:\n\n- `hostname` and `uname -a` ā confirm where you are.\n- `whoami` and `id` ā confirm what you can do.\n- `cat /etc/motd` if it exists ā the previous admin may have left\n warnings.\n- `df -h` and `free -h` ā disk and memory headroom.\n- `uptime` ā load and how long it\'s been up.\n- `systemctl --failed` ā anything already broken.\n\nThis is two seconds and it stops you from `rm -rf`\'ing the wrong host.\n\n## Read state before changing it\n\nFor anything you\'re about to touch:\n\n- A service: `systemctl status <name>` and `journalctl -u <name> -n 50`\n before `restart`.\n- A file: read it before editing. Note its owner, permissions, and\n whether it\'s a symlink.\n- A package: `dpkg -l <pkg>` / `rpm -q <pkg>` / equivalent before\n install/remove. Check what depends on it.\n- A user/group: `getent passwd <user>` before useradd/usermod.\n- A port or process: `ss -tlnp` and `ps -ef | grep <thing>` before\n killing anything.\n\n## Destructive ops: confirm scope\n\nBefore `rm -rf`, `truncate`, dropping tables, force-restarting:\n\n- **Print the target first.** `ls <path>` before `rm -rf <path>`.\n `SELECT count(*) FROM <table>` before `DROP`. See what you\'re about\n to obliterate.\n- **Never `rm -rf $VAR/...` without confirming `$VAR` is set.** A\n trailing slash on an empty variable is `rm -rf /`. Use `${VAR:?}` to\n make the shell error if it\'s unset.\n- **Backup or snapshot.** A `cp -a` to `/tmp/` for files. A\n `pg_dump`/`mysqldump` for databases. A filesystem snapshot if you\n have one. Two minutes of backup beats an afternoon of restore.\n- **Dry-run when the tool offers it.** `rsync --dry-run`, `apt -s`,\n `terraform plan`, `ansible --check`.\n\n## Idempotent and recoverable\n\nPrefer commands you can re-run without harm. Prefer changes you can\nundo. Concretely:\n\n- Append-only edits when possible (`>>` not `>`); explicit edits when\n not (use `sed -i.bak` so you keep `<file>.bak`).\n- Symlink swaps over file replacement: `ln -sfn new current` lets you\n flip back instantly.\n- For config files, edit, validate (`nginx -t`, `sshd -t`,\n `visudo -c`), reload (not restart) if the daemon supports it.\n- For systemd services, `systemctl reload` before `restart` before\n `stop`+`start`.\n\n## Blast radius\n\nBefore anything that affects more than one process or user:\n\n- **Who else uses this box?** `who`, `last -n 20`, `ps -ef | wc -l`.\n A shared host needs more care than a dedicated one.\n- **What depends on the service?** `systemctl list-dependencies\n <name>` and reverse with `--reverse`. Restarting Postgres takes down\n every app that talks to it.\n- **Is this prod?** Hostname, IP, /etc/motd, the absence of a\n \"staging\" anywhere ā assume prod if you can\'t prove otherwise.\n\n## SSH and remote ops\n\n- After `ssh`, run `hostname` before any destructive command. Tabs and\n tmux panes drift; the host you think you\'re on may not be the host\n you\'re on.\n- Long-running commands: `tmux`, `screen`, or `nohup` so a network\n blip doesn\'t kill them mid-flight.\n- Prefer pull over push: have the target machine fetch what it needs,\n rather than streaming from an unstable client connection.\n\n## Logging your own actions\n\nFor anything beyond a read-only check, leave a trail. A one-liner is\nfine:\n\n echo \"$(date -Iseconds) carlo: restarted nginx after cert renewal\" \\\n >> /var/log/admin-actions.log\n\nFuture-you (or future-coworker) will thank present-you.\n\n## Reporting\n\nState what you checked, what you changed, and what\'s still pending.\nFor destructive ops, name the backup location. If you noticed\nsomething concerning unrelated to the task, mention it once at the end\nā don\'t silently fix it.\n"), ( "role-thinking-partner.md", "# role: thinking-partner\n\nThe user is stuck on something and wants help thinking through it ā\nnot the answer handed to them. Your value is the questions you ask\nand the framings you offer, not the conclusions you reach for them.\n\n## Posture\n\n- **Don\'t grab the wheel.** The user is the one who has to live with\n the decision; they need to own it. If you solve it for them, you\n rob them of the thinking that makes the choice stick.\n- **Treat them as competent.** They got far enough to know they\'re\n stuck. Don\'t restart from first principles unless they ask.\n- **Be willing to disagree.** A thinking partner who only nods is\n useless. If their reasoning has a hole, name it.\n\n## Move 1: situate\n\nBefore responding to the surface question, surface the structure:\n\n- What have they already tried or considered?\n- What does success look like to them?\n- What would change their mind in either direction?\n- What\'s the actual decision, vs. what\'s anxiety dressed as a\n decision?\n\nOne or two of these, not all four. Pick the one that\'s missing.\n\n## Move 2: reflect\n\nPlay back what you heard ā but selectively. Highlight the part that\nseems load-bearing or the part that contradicts something else they\nsaid. \"You said you want X, but you\'ve also said Y three times ā is\nX really the goal?\"\n\nDon\'t summarize for completeness. Summarize to surface the tension.\n\n## Move 3: offer framings, not answers\n\nInstead of \"you should do X,\" try:\n\n- \"Two ways to look at this: ...\"\n- \"The case for X is ...; the case against is ...\"\n- \"If you were giving this advice to someone else, what would you\n tell them?\"\n- \"What\'s the smallest version of this you could try this week?\"\n\nMultiple framings let them pick. A single recommendation makes them\neither accept or argue.\n\n## When to give a direct answer\n\nIf after a few turns they explicitly want a take, give one ā clearly,\nin one sentence, with the main tradeoff. Don\'t hedge into mush. \"I\'d\ndo X. Tradeoff: Y. Worth it because Z.\" Then stop.\n\n## What not to do\n\n- Don\'t ask three questions in a row. One at a time.\n- Don\'t list every possibility. Two or three.\n- Don\'t moralize about their choices.\n- Don\'t pivot to action (\"want me to write a plan?\"). Stay in the\n thinking layer until they ask to leave it.\n\n## Reporting\n\nThere\'s no end-of-turn report. Stay in conversation.\n"), ( "role-writing.md", "# role: writing\n\nYou\'re drafting prose for a human reader ā email, doc, post, message.\nThe goal is for the reader to want to keep reading.\n\n## Voice\n\n- **Match the user\'s existing voice if you can see it.** Read what\n they\'ve already written (this thread, recent commits, sample emails)\n before drafting. Mimic sentence length, vocabulary level, formality.\n- **If you don\'t have a voice to match, default to:** plain words,\n short sentences, active verbs, concrete nouns. The reader gets\n through faster and trusts more.\n- **No throat-clearing.** Cut \"It\'s worth noting that,\" \"I just wanted\n to reach out about,\" \"I hope this finds you well.\" Open with the\n thing you\'re actually saying.\n\n## AI tells to delete\n\n- \"Moreover,\" \"Furthermore,\" \"In conclusion,\" \"Additionally\"\n- \"Delve into,\" \"navigate the complexities of,\" \"leverage\"\n- \"It\'s important to note that,\" \"It\'s worth mentioning that\"\n- \"In today\'s fast-paced world\"\n- Em-dash overuse ā like this ā repeatedly ā in the same paragraph.\n- Tricolons everywhere (\"clearer, faster, better\")\n- Bulleted lists where prose would do\n- Headers for two-paragraph notes\n\nIf a draft has any of these, rewrite ā don\'t patch.\n\n## Structure\n\n- **Subject / opening line carries the message.** A reader who only\n reads the first line should still know what this is about.\n- **One idea per paragraph.** Two if they\'re tightly linked.\n- **Concrete first, abstract second.** \"The build broke at 3pm because\n of the cert renewal\" beats \"There has been an issue with the build\n pipeline.\"\n- **For requests: ask, then context.** \"Can you take a look at PR 42\n by Friday? Background: ...\" not the other way around.\n\n## Length\n\n- **Email: 1-3 sentences default.** If it\'s longer, ask whether the\n user wants the full draft or a tightened version.\n- **Doc: scannable.** Headers, code blocks early, prose second. The\n reader is looking for an answer, not your essay.\n- **Post / message: punchier than you think.** Cut the second-best\n sentence in every paragraph.\n\n## Reporting\n\nHand back the draft and one line about choices: \"Plain version, no\nsmall-talk opener ā say if you want it warmer.\" Don\'t explain every\nsentence; the user will edit if they want different.\n"), ( "task-debug-systematic.md", "# task: debug-systematic\n\nFor when something\'s broken and the path forward isn\'t obvious. Random\npoking is how an hour becomes a day.\n\n## Step 0: reproduce\n\nIf you can\'t reproduce it, you can\'t fix it. Get to a one-line\nincantation that produces the failure on demand. Until you have that,\nyou\'re guessing.\n\nIf the bug is intermittent: capture state when it happens\n(`strace`, logs, screenshots, core dump). Don\'t lose the artifact\ntrying to retry.\n\n## Step 1: read the actual error\n\nRead the full error message, slowly. Not the bit that confirms what\nyou suspect ā the whole thing. The line number, the function, the\ntype, the path. Errors are usually more precise than your reading of\nthem.\n\nWhen the error says \"X not found\" ā check spelling, case, and path.\nWhen it says \"permission denied\" ā check who, what, where. When it\nsays \"unexpected token\" ā check the line *before* the one named.\n\n## Step 2: minimum reproducer\n\nStrip everything that isn\'t required to trigger the failure. No logic\nthat doesn\'t matter, no data that isn\'t load-bearing, no dependencies\nthat aren\'t in the path. The bug shrinks with the reproducer; what\'s\nleft is the bug.\n\nThis often *is* the fix ā the act of stripping reveals the cause.\n\n## Step 3: bisect\n\nIf you don\'t know which change broke it: `git bisect`, or its\nmanual equivalent. Halve the search space each step. Don\'t reason ā\nmeasure.\n\nIf you don\'t know which input triggers it: halve the input. The line\nthat broke is in one half or the other; halve again.\n\nIf you don\'t know which dependency: pin everything, then start\nunpinning one at a time.\n\n## Step 4: hypothesis ā test ā result\n\nWrite down (mentally is fine):\n\n- **Hypothesis:** \"I think it\'s failing because X.\"\n- **Test:** \"If true, doing Y will produce Z.\"\n- **Result:** Y produces what?\n\nIf Z, you have a confirmed cause. If not, the hypothesis was wrong ā\nmove on. **Don\'t change two things at once;** you won\'t know which\none mattered.\n\n## Step 5: explain it\n\nOut loud, to a duck or the user. Not \"here\'s what\'s broken\" but\n\"here\'s why it\'s broken\" ā root cause, not symptom. If you can\'t\nstate the why in one sentence, you don\'t have the cause yet.\n\nThis is the rubber-duck moment that solves more bugs than any\ndebugger.\n\n## Anti-patterns\n\n- **Adding error handling around the failure** without understanding\n it. That hides the bug, doesn\'t fix it.\n- **Restarting / clearing cache / reboot** as a primary move.\n Sometimes warranted, but if it works you don\'t actually know why.\n- **Reading 200 lines of stack trace** before reading the bottom of\n the trace where the actual error is.\n- **\"It works on my machine.\"** That\'s data, not a conclusion. What\n differs?\n\n## When to stop and ask\n\nIf after ~30 minutes of focused debugging the cause is still opaque,\nwrite up what you know: the failure, the reproducer, what you\'ve\nruled out, the current hypothesis. Either share it (a fresh pair of\neyes catches what you can\'t) or sleep on it. The pattern matters more\nthan the breakthrough.\n\n## Reporting\n\nState the root cause in one sentence, the fix in one sentence, and\nhow you confirmed the fix actually fixes it (not just that the build\npasses ā that the original failure no longer reproduces).\n"), ( "task-chunked-implementation.md", "---\nname: task-chunked-implementation\ndescription: Break a large implementation task into sequential chunk-plan files, then execute each chunk in a fresh context using the context_clear tool. Use when a task is too big for one context window or when the model needs to work in stages with clean state.\n---\n\n# Chunked Implementation\n\n## When to use\n\nUse this skill when the user asks to implement a substantial feature, refactor, or multi-file change. The task should be broken into pieces that each fit comfortably in a single context window.\n\n## Workflow\n\n1. **Analyze the task.** Read the codebase as needed to understand scope, dependencies, and existing patterns. Produce a detailed mental model of what needs to change and in what order.\n\n2. **Create the master plan.** Write a file called `impl-plan.md` in the project root (or cwd). This file contains:\n - A brief overview of the task.\n - An ordered list of chunks (3ā7 is typical). Each chunk entry names the chunk and summarizes what it covers in 1ā3 sentences.\n - The final chunk (if needed) is an \"integrate and polish\" pass.\n\n3. **Create chunk plan files.** For each chunk in the master plan, create a separate file `impl-N.md` (where N is the chunk number, 1-based). Each chunk file contains:\n - **Goal**: what this chunk accomplishes.\n - **Files to read first**: list of files the agent should read before starting work.\n - **Detailed instructions**: step-by-step changes to make, including exact function names, type definitions, and expected behavior. Be specific enough that an agent with no prior context can execute correctly.\n - **Verification**: how to verify this chunk is complete (build command, test command, manual check). use the todo tool call for this.\n - **Next step**: the instruction to call `context_clear` with a summary of what was done and a reference to the next chunk file. Example:\n ```\n When this chunk is complete and verified, call context_clear with:\n - summary: \"Implemented X, Y, Z. Build passes. Tests green.\"\n - instructions: \"Read impl-2.md and execute the instructions there.\"\n ```\n Add this as an additional last todo item of the verification tool.\n\n4. **Execute chunk 1.** Read `impl-1.md` and carry out its instructions. When done, use `context_clear` to summarize state and hand off to chunk 2.\n\n5. **Each subsequent chunk.** The agent starts with fresh context and the instructions from the previous chunk\'s `context_clear` call. It reads the referenced chunk file and executes. When done, it calls `context_clear` again to hand off.\n\n6. **Final chunk (optional).** The last chunk may be \"integrate and polish\" ā run full builds, clean up, run all tests, remove the impl-N.md plan files if desired.\n\n## Chunk file template\n\n```markdown\n# Chunk N: <title>\n\n## Goal\n<what this chunk accomplishes>\n\n## Read first\n- <file paths the agent should read before starting>\n\n## Instructions\n<step-by-step, specific enough for a fresh-context agent>\n\n## Verification\n<how to confirm correctness>\n\n## Next step\nWhen complete and verified, call context_clear with:\n- summary: \"<concise state summary>\"\n- instructions: \"Read impl-<N+1>.md and execute the instructions there.\"\n```\n\n## Rules\n\n- Each chunk must be self-contained: a fresh-context agent should be able to execute it using only the chunk file and the files it lists under \"Read first\".\n- Prefer fewer, larger chunks over many tiny ones. Each context clear has overhead.\n- Always verify (build, test) before calling context_clear.\n- The summary passed to context_clear should mention: files changed, tests status, any open questions or partial work.\n- The instructions passed to context_clear should start with reading the next chunk file.\n- Keep the master plan (`impl-plan.md`) updated as chunks complete if discoveries change the plan.\n- Do not call context_clear until the current chunk is verified. If something fails, fix it in the current context.\n")]
-
Universal skills compiled into the binary. Materialized to ~/.local/share/3code/skills/ on startup; re-extracted whenever the contents change (the dir's VERSION file holds a content fingerprint, not just a version string, so adding or editing a built-in skill triggers re-extraction without a manual bump). User overrides live in ~/.config/3code/skills/ and are never touched by the materializer.
Per-model variants (skills/<model>/<name>.md) are not implemented yet ā see CLAUDE.md "Skills convention" for the planned layout and the trigger condition (when a smaller model needs hand-holding the others don't).
ConfigExample = """ [settings] current = "openai.gpt-4o-mini" [provider] name = "openai" url = "https://api.openai.com/v1" key = "sk-..." models = "gpt-4o-mini gpt-4o" (values are Nim string literals ā always wrap them in double quotes.) """
HelpText = """3code the economical coding agent commands: :help show this message :tokens show token usage for this session :clear reset conversation (keeps system prompt) :model list models for current provider (current marked with *) :model X switch to model X (within current provider) :provider list configured providers (current marked with *) :provider X switch to provider X (model defaults to first in its list) :provider add add a new provider (interactive, verified) :provider edit X edit provider X (url, key, models) :provider rm X remove provider X :reasoning list reasoning levels for current model (* marks active) :reasoning X switch reasoning level (low / medium / high) :streaming show streaming mode (on = live output, off = request/response) :streaming on|off toggle SSE streaming (off is the reliable fallback for flaky SSE) :prompt show the active system prompt :show [N] show full output of tool call N (default: last) :log list all tool calls this session :sessions list recent sessions saved in this directory (max 20) :summarize collapse old turns into a synthetic recap (meta model call) :q :quit exit (also Ctrl-D) input: single-line just type and press Enter multi-line Shift+Enter (or Alt+Enter) inserts a newline; Enter submits arrows full cursor navigation across lines and visual wraps ctrl+arrow word-by-word jumps (also crosses logical lines) home / end jump to start / end of the current logical line ctrl+u delete to start of line ctrl+w delete the word before the cursor up / down visual-row up/down inside the buffer; on the top/bottom row recalls history ctrl+r / s incremental history search (enter submits, esc accepts, ctrl+g aborts) alt+p / n history search completed at enter alt+< / > jump to the oldest entry / back to your draft tab complete :commands, provider names, model names ctrl+l clear the screen @path inline file contents (e.g. @src/foo.nim) """
KnownGoodCombos = [("baseten", "zai-org/GLM-5", "glm", "5", "", "on", 0.2, 8192, false, 200000), ("baseten", "zai-org/GLM-4.7", "glm", "4", "7", "on", 0.2, 8192, false, 200000), ( "cerebras", "zai-glm-4.7", "glm", "4", "7", "on", 0.2, 8192, false, 200000), ( "fireworks", "accounts/fireworks/models/glm-5p1", "glm", "5", "1", "on", 0.2, 8192, false, 200000), ("fireworks", "accounts/fireworks/models/glm-5", "glm", "5", "", "on", 0.2, 8192, false, 200000), ( "nebius", "zai-org/GLM-5.1", "glm", "5", "1", "on", 0.2, 8192, false, 200000), ( "nebius", "zai-org/GLM-5", "glm", "5", "", "on", 0.2, 8192, false, 200000), ( "nvidia", "z-ai/glm4.7", "glm", "4", "7", "on", 0.2, 8192, true, 200000), ( "together", "zai-org/GLM-5.1", "glm", "5", "1", "on", 0.2, 8192, false, 200000), ("together", "zai-org/GLM-5", "glm", "5", "", "on", 0.2, 8192, false, 200000), ("zai", "glm-4.7", "glm", "4", "7", "on", 0.2, 8192, false, 200000), ("zai", "glm-4.7-flash", "glm", "4", "flash", "on", 0.2, 8192, false, 200000), ("zai", "glm-5", "glm", "5", "", "on", 0.2, 8192, false, 200000), ("zai", "glm-5-turbo", "glm", "5", "turbo", "on", 0.2, 8192, false, 200000), ("zai", "glm-5.1", "glm", "5", "1", "on", 0.2, 8192, false, 200000), ("zai", "glm-5.2", "glm", "5", "1", "high", 0.2, 8192, false, 1000000), ("deepinfra", "zai-org/GLM-5.1", "glm", "5", "1", "on", 0.2, 8192, false, 200000), ( "deepinfra", "zai-org/GLM-5", "glm", "5", "", "on", 0.2, 8192, false, 200000), ( "deepinfra", "zai-org/GLM-4.7", "glm", "4", "7", "on", 0.2, 8192, false, 200000), ("baseten", "openai/gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("cerebras", "gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("groq", "openai/gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("nebius", "openai/gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("nebius", "openai/gpt-oss-120b-fast", "gpt-oss", "", "120b-fast", "medium", 0.2, 4096, false, 131072), ("nvidia", "openai/gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("nvidia", "openai/gpt-oss-20b", "gpt-oss", "", "20b", "medium", 0.2, 4096, false, 131072), ("ovh", "gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("sambanova", "gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("deepinfra", "openai/gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("openrouter", "openai/gpt-oss-120b", "gpt-oss", "", "120b", "medium", 0.2, 8192, false, 131072), ("baseten", "deepseek-ai/DeepSeek-V4-Pro", "deepseek", "4", "pro", "low", 0.2, 8192, false, 1000000), ("deepseek", "deepseek-chat", "deepseek", "3", "", "medium", 0.2, 8192, false, 128000), ("deepseek", "deepseek-reasoner", "deepseek", "r1", "", "medium", 0.2, 8192, false, 128000), ("deepseek", "deepseek-v4-flash", "deepseek", "4", "flash", "low", 0.2, 4096, false, 1000000), ("deepseek", "deepseek-v4-pro", "deepseek", "4", "pro", "low", 0.2, 8192, false, 1000000), ("nebius", "deepseek-ai/DeepSeek-V3.2", "deepseek", "3.2", "", "medium", 0.2, 8192, false, 128000), ("nebius", "deepseek-ai/DeepSeek-V3.2-fast", "deepseek", "3.2", "fast", "medium", 0.2, 4096, false, 128000), ( "nebius", "deepseek-ai/DeepSeek-V4-Pro", "deepseek", "4", "pro", "low", 0.2, 8192, false, 1000000), ("nebius", "moonshotai/Kimi-K2.5", "kimi", "2", "5", "on", 0.2, 8192, false, 262144), ("nebius", "moonshotai/Kimi-K2.5-fast", "kimi", "2", "5-fast", "on", 0.2, 4096, false, 262144), ("nebius", "deepseek-ai/MiniMax-M2.5", "minimax", "2", "5", "low", 0.2, 8192, false, 204800), ("nebius", "deepseek-ai/MiniMax-M2.5-fast", "minimax", "2", "5-fast", "low", 0.2, 4096, false, 204800), ("together", "deepseek-ai/DeepSeek-V4-Pro", "deepseek", "4", "pro", "low", 0.2, 8192, false, 1000000), ("fireworks", "accounts/fireworks/models/deepseek-v4-pro", "deepseek", "4", "pro", "low", 0.2, 8192, false, 1000000), ("deepinfra", "deepseek-ai/DeepSeek-V4-Pro", "deepseek", "4", "pro", "low", 0.2, 8192, false, 1000000), ("sambanova", "deepseek-ai/DeepSeek-V3.2", "deepseek", "3.2", "", "medium", 0.2, 8192, false, 128000), ("nvidia", "minimaxai/minimax-m2.5", "minimax", "2", "5", "low", 0.2, 8192, false, 204800), ("nvidia", "minimaxai/minimax-m2.7", "minimax", "2", "7", "low", 0.2, 8192, false, 204800), ("fireworks", "accounts/fireworks/models/minimax-m2p7", "minimax", "2", "7", "low", 0.2, 8192, false, 204800), ("deepinfra", "minimaxai/MiniMax-M2.5", "minimax", "2", "5", "low", 0.2, 8192, false, 204800), ("together", "minimaxai/MiniMax-M2.7", "minimax", "2", "7", "low", 0.2, 8192, false, 204800), ("sambanova", "minimaxai/MiniMax-M2.7", "minimax", "2", "7", "low", 0.2, 8192, false, 204800), ("sambanova", "minimaxai/MiniMax-M2.5", "minimax", "2", "5", "low", 0.2, 8192, false, 204800), ("together", "moonshotai/Kimi-K2.5", "kimi", "2", "5", "on", 0.2, 8192, false, 262144), ("fireworks", "accounts/fireworks/models/kimi-k2p6", "kimi", "2", "6", "on", 0.2, 8192, false, 262144), ("together", "moonshotai/Kimi-K2.6", "kimi", "2", "6", "on", 0.2, 8192, false, 262144), ( "deepinfra", "moonshotai/Kimi-K2.6", "kimi", "2", "6", "on", 0.2, 8192, false, 262144), ("deepinfra", "moonshotai/Kimi-K2.5", "kimi", "2", "5", "on", 0.2, 8192, false, 262144)]
- (provider, model, family, version, variant, reasoning, temperature, maxTokens, contextWindow) tuples. model is the full API id sent on the wire. family drives the (prompt, tools) branch ā it must be set explicitly here, no guessing from the model string. version and variant are informational tags. reasoning is the default effort level ("low" / "medium" / "high") used when the user hasn't switched it with :reasoning; the actual wire field depends on family (reasoning_effort for gpt-oss; thinking.type for glm). temperature < 0 means "omit the field"; otherwise send it as the sampling default. maxTokens is the explicit generation cap. contextWindow is the advertised input window in tokens. Anything outside this list requires --experimental to run.
ReasoningLevels = ["low", "medium", "high"]
- Abstract reasoning levels for the level-based families (gpt-oss, deepseek, minimax). Wire-level translation is family-specific (see callModel): gpt-oss passes them through to reasoning_effort; deepseek/minimax map them to thinking on/off + effort. GLM uses its own value sets (off/on, or off/high/max on 5.2); see knownGoodReasonings. Empty string means "no knob, omit the field."
Version = "0.4.0"
versionSuffix {.strdefine.} = ""
- Set via -d:versionSuffix=-main-<sha8> for non-release builds so the reported version distinguishes commits on main from the tagged release. Empty for nimble install and tagged release builds.
Procs
proc buildCredit(p: Profile): string {....raises: [], tags: [], forbids: [].}
- Dynamic attribution line: model + serving provider, derived from the active profile. Bytes change with (provider, model), not within a session ā prefix caching survives as long as the user doesn't :provider/:model switch mid-session.
proc buildSystemPrompt(p: Profile): string {....raises: [IOError, OSError], tags: [ReadDirEffect, ReadEnvEffect, ReadIOEffect, WriteIOEffect], forbids: [].}
- Bytes are stable within a (provider, model, variant) triple ā that's what the prompt now embeds for credit. Within a session that's constant, so prefix caching on Anthropic/OpenAI/DeepInfra still applies; switching model or provider mid-session will invalidate the cache. Skills are discovered fresh on every call so a newly added skill file becomes visible on the next turn without restarting the session.
proc builtinSkillsDir(): string {....raises: [], tags: [ReadEnvEffect, ReadIOEffect], forbids: [].}
proc defaultReasoningsFor(provider, model, family: string): seq[string] {. ...raises: [], tags: [], forbids: [].}
- Value set for the :reasoning listing. Empty when the family has no reasoning knob or the (provider, model) pair is off the known-good table.
proc discoverSkills(): string {....raises: [OSError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect], forbids: [].}
- Filename listing for the {{skills}} placeholder. One bullet per skill, full path so the model can cat it directly. Project skills listed first (and shadow user skills with the same name).
proc findSystemPromptOverride(family: string): string {....raises: [], tags: [ReadDirEffect, ReadEnvEffect, ReadIOEffect], forbids: [].}
- Look for <family>.txt in project .3code/ then userConfigRoot(). Returns the file path if found and experimental mode is on, else "".
proc isKnownGood(p: Profile): bool {....raises: [], tags: [], forbids: [].}
- True when (provider name, modelPrefix & model) exactly matches an entry in KnownGoodCombos (case-insensitive on both parts). Empty profiles return false ā caller decides what that means.
proc knownGoodContextWindow(p: Profile): int {....raises: [], tags: [], forbids: [].}
proc knownGoodContextWindow(provider, model: string): int {....raises: [], tags: [], forbids: [].}
- Context window for a known-good (provider, model) pair, in tokens. Returns 0 when the pair is off the table (caller falls back to the substring heuristic). The value comes straight from the contextWindow field of the matching entry in KnownGoodCombos.
proc knownGoodFamily(p: Profile): string {....raises: [], tags: [], forbids: [].}
- Returns the family label ("glm", ...) for a known-good combo, or "" if (provider, model) isn't on the list. Match is case-insensitive on (provider, full model id incl. prefix).
proc knownGoodFamily(provider, model: string): string {....raises: [], tags: [], forbids: [].}
- Convenience overload for the wizard, where we have a candidate (provider name, full model id) but no Profile.
proc knownGoodGeneration(p: Profile): GenerationDefaults {....raises: [], tags: [], forbids: [].}
proc knownGoodGeneration(provider, model: string): GenerationDefaults {. ...raises: [], tags: [], forbids: [].}
- Hardcoded generation defaults for a known-good combo. Experimental combos return the zero object, which callers treat as "omit".
proc knownGoodReasoning(provider, model: string): string {....raises: [], tags: [], forbids: [].}
- Default reasoning level for a known-good combo, "" if not on the list.
proc knownGoodReasonings(provider, model: string): seq[string] {....raises: [], tags: [], forbids: [].}
- Value set offered by :reasoning for a known-good (provider, model) pair. Reflects each model's real wire surface: glm 4.7/5/5.1 expose on/off only (thinking.type or the vLLM enable_thinking bool); glm-5.2 on z.ai additionally exposes thinking.effort with high (default) and max. Falls back to @ReasoningLevels for the level-based families (gpt-oss, deepseek, minimax), and @[] when the pair is off the table.
proc knownGoodTags(provider, model: string): (string, string, string) {. ...raises: [], tags: [], forbids: [].}
- Returns (family, version, variant) for a known-good combo, or empty strings when no match. Used at profile-build time to populate the informational tags on Profile.
proc materializeBuiltinSkills() {....raises: [], tags: [ReadEnvEffect, ReadIOEffect, WriteDirEffect, ReadDirEffect, WriteIOEffect], forbids: [].}
- Extract BuiltinSkills to the data dir when the on-disk fingerprint disagrees with the binary's. Idempotent. Failures are silent ā a read-only home dir shouldn't crash the agent; the model just won't see the built-ins, which is recoverable (user override or project skill still works).
proc reasoningSupported(family: string): bool {....raises: [], tags: [], forbids: [].}
- True when family has a wire field for reasoning effort. Drives whether :reasoning switching has any effect for the active model.
proc refreshSystemPrompt(messages: JsonNode; p: Profile) {. ...raises: [IOError, OSError], tags: [RootEffect, ReadDirEffect, ReadEnvEffect, ReadIOEffect, WriteIOEffect], forbids: [].}
proc skillsDirs(): seq[string] {....raises: [], tags: [ReadEnvEffect, ReadIOEffect], forbids: [].}
- Directories searched for skill files, in precedence order (first wins on filename collision). Project ā user override ā built-in.
proc xmlToolCallsFallback(p: Profile): bool {....raises: [], tags: [], forbids: [].}
- True when this (provider, model) is known to occasionally leak the model's native <tool_call>...</tool_call> chat template into delta.content instead of OpenAI tool_calls. Used by callModel to enable a content scan that promotes those blocks to synthetic tool calls. Defaults to false for everything not in the known-good list.