Quark
Lightning-fast micro-agent. A stripped-down alternative to heavy AI agents, executing tasks with minimal prompt overhead.
Quark is a minimal CLI agent loop: send a message, let the model call tools (read/edit/write files, list directories, search file names/contents, optionally run shell commands), and get an answer back — with conversation history persisted to disk between runs. It talks to any LLM provider through a small abstraction layer (Anthropic, OpenAI, and Ollama/any OpenAI-compatible endpoint included) instead of depending on a heavy vendor SDK.
Two things it optimizes for on purpose:
- Lightweight: no framework, no heavy SDKs (just
httpx), a short default system prompt, and anedit_filetool so the model can make targeted changes instead of re-sending whole files. - Productive by default, secure by default: file tools are confined to a workspace directory (symlink escapes included),
run_shellis off unless you opt in, and if aQUARK.md/AGENTS.mdfile exists it's folded into the system prompt automatically so the agent already knows about your project.
Install
Requires Python 3.10+. Works anywhere Python does, including WSL2 — nothing platform-specific.
From PyPI:
pip install quark-ai
This installs the quark command (the PyPI distribution name doesn't have to match the console script it installs), including the terminal UI (textual) — see Terminal UI below.
On Debian/Ubuntu (including most current WSL2 distros), a bare pip install is blocked by default with externally-managed-environment (PEP 668). Use pipx instead — it installs CLI tools like Quark in their own isolated environment and puts them on your PATH:
sudo apt install pipx
pipx ensurepath
# open a new terminal (or: source ~/.bashrc)
pipx install quark-ai
For local development, clone the repo instead:
./install.sh
Creates .venv, installs Quark editable with dev deps, and copies .env.example to .env if you don't already have one. Safe to re-run (reuses the venv, never overwrites an existing .env).
Or by hand:
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Configure
Interactive setup (recommended)
The first time you run quark chat or quark tui, if nothing has been configured yet, Quark asks a short series of questions — provider, model (for Ollama it detects your locally pulled models and lets you pick one), workspace, tool mode, whether to allow run_shell — and saves your answers to ~/.quark/config.json so you never have to repeat the same flags again. Entirely local: this wizard never contacts a model or sends any context anywhere, except one optional ping to your own Ollama server to list its models.
quark chat "hola" # first run only: asks a few questions, then answers
quark chat "qué hora es" # every run after: no questions, uses what you picked
Re-run it anytime with quark init, or edit ~/.quark/config.json directly. Any --flag or env var still overrides a saved value for a single run — saved config is just the fallback default. If an API key is entered during setup, it's saved to ~/.quark/.env (chmod 600), never into config.json.
Skipped automatically for non-interactive use (piped input, CI, no tty) so it can never hang waiting on a prompt that can't arrive.
Manual configuration
Alternatively, copy .env.example to .env (done automatically by install.sh) and fill in the key(s) for the provider(s) you want to use:
cp .env.example .env
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
QUARK_PROVIDER=anthropic
.env is loaded automatically from the current working directory, then ~/.quark/.env as a fallback. You can also export the variables directly, or pass --api-key on the command line.
Because the current directory can be a repository you didn't write, its .env is restricted: it may set API keys (*_API_KEY), QUARK_PROVIDER, QUARK_COMPACT_THRESHOLD, QUARK_CONTEXT_WINDOW, QUARK_MINIMAL_TOOLS and QUARK_PROGRESSIVE_TOOLS, and nothing else. Any other QUARK_* setting in it (QUARK_SHELL_MODE, QUARK_MCP_MODE, QUARK_SKILLS_MODE, QUARK_SUBAGENTS_MODE, QUARK_PLUGINS_MODE, QUARK_READ_DIRS, QUARK_BASE_URL, ...) is ignored with a warning, since those grant capabilities or decide where your API key is sent. Put them in ~/.quark/.env, ~/.quark/config.json or the real environment, which are always trusted. A real environment variable always wins over either file.
Usage
# One-shot message, prints the reply and exits
quark chat "list the files in this directory"
# Interactive REPL (Ctrl+D or 'exit' to quit)
quark chat
# Choose a provider/model
quark --provider openai --model gpt-4o chat "what's in README.md?"
# Run fully locally against Ollama (ollama serve + ollama pull llama3.2 first) — no API key needed
quark --provider ollama chat "what's in README.md?"
# Named sessions keep separate histories on disk
quark --session project-a chat "remember that we're using Postgres"
quark --session project-a chat "what database are we using?"
# Confine file tools to a specific directory (default: cwd)
quark --workspace ./my-project chat "list the files here"
# Opt in to the run_shell tool (off by default), approving each command
quark --allow-shell chat "run the test suite"
# Let the model delegate bounded sub-tasks to a short-lived side agent (off by default)
quark --subagents-mode ask chat "add docstrings to every function in utils.py"
# Load your own Python plugins from ~/.quark/plugins/ or ./.agents/plugins/ (off by default)
quark --plugins-mode ask chat "use the word_count tool on README.md"
# Let run_shell run commands without asking (e.g. for scripts or CI)
quark --shell-mode auto chat "run the test suite"
# Read-only mode: only read_file + list_dir, smallest tool-schema footprint, no escape hatch
quark --minimal-tools chat "what does this project do?"
# Progressive mode: starts like --minimal-tools, but the model can unlock
# write_file/edit_file/delete_file itself the moment it actually needs them
quark --progressive-tools chat "fix the typo in README.md"
# Plan mode: read, list and search only; the model proposes changes instead of making them
quark --plan chat "how would you add a --verbose flag?"
# Print the full reply at once instead of streaming it token by token
quark --no-stream chat "what's in README.md?"
# Lower the threshold for auto-summarizing older turns (in estimated tokens)
quark --compact-threshold 4000 chat "..."
# Redo the interactive setup, or set it up for the first time without waiting for a prompt
quark init
# Manage sessions
quark sessions list
quark sessions clear project-a
# Token usage and an estimated cost for a session, from the provider's own reported counts
quark usage project-a
quark usage --all
Sessions belong to the workspace: they're stored as JSON under ~/.quark/sessions/<folder>-<hash>/<name>.json, so default in one project never mixes with default in another. Files are written atomically and readable only by you (600); a damaged file is set aside as <name>.corrupt.json instead of crashing. Session names may use letters, digits, ., _ and -. Sessions saved by older versions stay in ~/.quark/sessions/ and are no longer listed.
Each session also keeps a running total of the input/output tokens the provider reported for it, per provider/model (switching models with /model keeps both totals). quark usage [name] prints it with an estimated dollar cost, from a small, hand-maintained price table (quark/pricing.py) that only covers well-known Anthropic/OpenAI models and will drift out of date — treat the number as a ballpark, not a bill. Ollama and other unlisted models show the token counts with no guessed cost. quark usage --all covers every saved session in the workspace.
Terminal UI
quark
Running quark with no subcommand launches the terminal UI by default — a scrollable chat with rendered markdown (real tables, not raw | pipes |), colored bubbles per role, a fixed input box, and streaming replies — the same way running bare claude does. You can also ask for it explicitly with quark tui. All the usual flags apply (--provider, --model, --session, --workspace, etc.):
quark --provider ollama --model qwen3.5-4b-coder-128k:latest
It's a thin view on top of the same Agent used everywhere else — no separate request/tool/session logic, so anything that works in quark chat works in the TUI. textual is a core dependency, so pip install quark-ai pulls it in automatically; if it's somehow missing, bare quark falls back to the plain quark chat REPL instead of erroring out.
- Modes: Tab switches between Build and Plan (see Build and Plan modes); the header shows the mode, provider/model, and context tokens (
~while estimated; once the provider reports usage, the real count). - Input: Enter sends, Ctrl+J adds a line (pasted text keeps its lines), ↑/↓ on the first/last line browse what you sent before. While a reply is running you can keep typing: messages are queued and sent in order, each in the mode (Build/Plan) it was sent in; the header shows
Running: Planwhen the running reply's mode differs from the selected one (Esc stops the reply and drops the queue)./plan,/build,/read-dir,/modeland/exitalso work during a reply. Typing/suggests a command (→ accepts it). - Reasoning: if the model streams its reasoning (
reasoning_contenton OpenAI-compatible endpoints,thinkingon Anthropic), it shows in gray above the answer. It is display only and isn't kept in the history. - Tool calls: each one appears inside the reply as it runs (
▸ read_file(path='README.md')), then with its outcome (✓ 1,234 charsor✗and the error). - Stopping: Esc stops the reply that's streaming; any partial answer is kept in the conversation and you can send a correction.
- Attaching files: type
@and part of a file name to open a dropdown of fuzzy matches, ranked by how well each workspace path fits what you typed (↑/↓ to pick one, Enter or → to accept, Esc to dismiss). On sending, each@paththat names a workspace file gets its contents attached, up to 8 files, throughread_file(so the same limits apply and the file counts as read for later edits). This also works in thequark chatREPL, which completes to the single best match instead of listing them. The file index for suggestions is built locally on first use, capped at 10,000 entries, and never sent to the model. - Images:
@shot.png, or an image path written as is (also an absolute path outside the workspace, e.g. dragged into the terminal), is sent as an image to models that accept them: png, jpg, gif, webp, up to 5 MB, 4 per message. For a text-only model, use--no-images(orQUARK_IMAGES=0, or"images": falsein the config); it then says so instead of attaching it. Only images can come from outside the workspace this way; the model still can't read outside text files. Images cost about 1,500 tokens each in the estimate. - Models:
/modelopens a selector with what the provider's/modelsendpoint offers (↑/↓ and Enter to switch, Esc to close); in thequark chatREPL it prints a numbered list./model NUMBERor/model NAMEswitches directly. When the catalog reports a context window or image support (Anthropic, OpenRouter-style endpoints), compaction and image handling adapt; otherwise the configured values stay and it says so. Switching to a text-only model is refused while the conversation has images (/newfirst). - Commands:
/model [number|name],/compact [focus],/new,/plan,/build,/init [focus],/read-dir [add|remove PATH],/exit. - Shell approval: in
askmode eachrun_shellcommand opens a dialog (yruns it,n/Esc rejects it).
quark sessions has no TUI equivalent; use the regular CLI for it.
Local models (Ollama, or any OpenAI-compatible endpoint)
ollama serve # if not already running
ollama pull llama3.2 # or whatever model you want
quark --provider ollama chat "hola"
--provider ollama reuses the OpenAI provider against Ollama's OpenAI-compatible API (http://localhost:11434/v1 by default) — no API key required, nothing to configure beyond having Ollama running. Override the endpoint with --base-url (also QUARK_BASE_URL), which works for --provider openai too — useful for any other OpenAI-compatible server (vLLM, LM Studio, a proxy, etc.), not just Ollama. Tool-calling quality depends entirely on the local model: not every model Ollama can run supports it well, so results with write_file/edit_file/etc. will vary more than with Claude or GPT.
Project context
If a QUARK.md or AGENTS.md file exists at the workspace root, its contents (up to 64KB) are appended to the system prompt automatically — a cheap way to give the agent standing context (stack, conventions, gotchas) without repeating it every session. It's reread before every request, so edits apply from the next message.
/init [focus] (in quark tui and the quark chat REPL) writes that guide for you. The model investigates the workspace with read_file, list_dir, and search_files only (each call is shown), then Quark saves its answer to the existing QUARK.md, else the existing AGENTS.md, else a new QUARK.md. Nothing is saved if the model read no files, produced nothing usable, was stopped with Esc, or the guide changed on disk meanwhile. An empty workspace gets a minimal guide. /init isn't available in Plan mode, since it writes a file. (quark init, the command, is the setup wizard, unrelated.)
Build and Plan modes
Quark starts in Build mode with every tool you enabled. In Plan mode the model only gets read_file, list_dir, and search_files, plus an instruction to investigate and propose changes (steps, affected files, interfaces, expected behavior) rather than write full implementations. Any other tool the model calls in Plan mode is refused before it runs, even one outside the catalog it was shown.
Switch with Tab in quark tui, or /plan and /build in quark tui and the quark chat REPL; --plan starts in Plan mode. Both modes share the conversation, so a plan made in Plan mode is there to implement after switching to Build. A switch during a reply applies to the next message.
Read-only directories
The file tools only see the workspace. To let the model also read files elsewhere on your computer without being able to change them, add read-only directories:
quark --read-dir ~/Documents --read-dir ~/notes tui
Also QUARK_READ_DIRS (separated like PATH) or "read_dirs": [...] in ~/.quark/config.json. In quark tui and the quark chat REPL, /read-dir lists them, /read-dir add PATH adds one and /read-dir remove PATH removes it, for the current session, from the next message on.
read_file,list_dir,search_filesand@fileattachments work in them, given an absolute (or~) path; relative paths still mean the workspace. The model is told which directories it may read.write_file,edit_fileanddelete_filenever reach them, and symlinks inside them that point elsewhere are refused.run_shellisn't limited by them: with the shell enabled, commands can read whatever your account can.
Shell permissions
--shell-mode (also QUARK_SHELL_MODE, or shell_mode in ~/.quark/config.json) decides what run_shell may do:
| Mode | Behavior |
|---|---|
off (default) |
run_shell isn't offered to the model at all. |
ask |
Each command needs your approval: a [y/N] prompt in quark chat, a dialog in quark tui. Without a terminal to ask (piped input, CI), commands are rejected. |
auto |
Commands run without asking. Only for prompts and providers you trust. |
--allow-shell, QUARK_ALLOW_SHELL=1, and allowing the shell in quark init all mean ask.
Skills
Skills are folders of instructions the model can load when a task matches them. With --skills-mode ask or auto (also QUARK_SKILLS_MODE, or skills_mode in ~/.quark/config.json; default off), Quark looks for <name>/SKILL.md in ~/.quark/skills/, then the workspace's skills/, then .agents/skills/ (the first skill with a given name wins, up to 24):
---
name: release
description: Steps to cut a release of this project
---
1. Bump the version in pyproject.toml ...
The model sees only the names and descriptions (each shortened to 160 characters, 8KB in all), inside the description of one load_skill tool. It calls load_skill(name) for the instructions (up to 64KB) or load_skill(name, path) for a file bundled in the skill's folder (up to 32KB, never outside it). In ask mode each load needs your approval, in auto it doesn't, and off skips discovery so the tool doesn't exist. Plan mode never loads skills. A skill is text the model will follow, so only enable skills from sources you trust: a workspace's skills/ folder comes with the repository.
MCP servers
With --mcp-mode ask or auto (also QUARK_MCP_MODE, or mcp_mode in ~/.quark/config.json; default off), Quark starts the servers listed in ~/.quark/mcp.json and offers their tools to the model as mcp__<server>__<tool>. Local servers use stdio, remote ones Streamable HTTP:
{
"mcpServers": {
"project-tools": {"command": "node", "args": ["/path/to/server.mjs"], "cwd": "/path/to/project", "env": {}},
"remote-tools": {"url": "http://127.0.0.1:3000/mcp", "headers": {}}
}
}
askapproves each call (a[y/N]prompt, or a dialog in the TUI);autoruns them directly;offstarts nothing.- A server that fails to start is skipped with a warning. At most 32 tools are offered; a tool whose input schema is over 8KB is skipped, all definitions together are capped at 64KB, and server instructions (folded into the system prompt) at 8KB.
- Results keep their text (up to 48,000 characters, beginning and end); images and audio are noted but not passed on, since Quark sends text only.
- An executed MCP call forgets what the model had read (like
run_shell), since a server may change files. Plan mode never calls MCP tools, and--minimal-toolsdoesn't load them. - MCP servers run with your account's permissions; only configure servers you trust.
- Servers start in parallel. They don't inherit your provider API keys (
*_API_KEY) or anything loaded from a.envfile; give a server the keys it needs in itsenv.
With many MCP servers configured, sending a full JSON-schema tool definition per remote tool on every turn adds up. --mcp-code-mode (also QUARK_MCP_CODE_MODE, or mcp_code_mode in the saved config; default off) replaces that with a single run_mcp_code tool: its description lists every available call as mcp.<server>.<tool>(...) with a one-line summary, and the model writes a short Python script that calls them as plain functions (print(mcp.project_tools.search(query="..."))) instead of one tool call per MCP call. The script runs with no imports, no file or network access, and no builtins beyond basic types and control flow — the only thing it can do is call the listed mcp.* functions, each of which still goes through --mcp-mode's own per-call approval exactly as if the model had called it directly.
Side agents
With --subagents-mode ask or auto (also QUARK_SUBAGENTS_MODE, or subagents_mode in ~/.quark/config.json; default off), Quark offers a spawn_agent tool so the model can delegate a bounded, self-contained sub-task — "add docstrings to every function in utils.py", "write unit tests for parser.py" — to a short-lived side agent instead of doing it inline.
The side agent never sees this conversation and works alone in its own isolated copy of the workspace: a git worktree on a throwaway quark-agent-<id> branch when the workspace is a git repository, or a plain directory copy under your temp directory otherwise. It gets the same provider/model and the default (non-minimal) file tools, but no shell, no skills, no MCP servers, and no spawn_agent of its own — one level of delegation only — plus a lower tool-call budget (12 rounds) than a normal session, since it's meant for one sub-task, not an open-ended conversation.
Nothing it does reaches your real workspace by itself. spawn_agent returns its final answer plus, if anything changed, where to find the isolated copy and the git diff/merge commands to review it (or to discard it); if a git worktree ends up with no changes, Quark removes it and its branch for you. A plain directory copy (no git) is left for you to inspect and clean up yourself. ask approves each spawn (a [y/N] prompt, or a dialog in the TUI); auto runs it directly; off doesn't offer the tool at all.
Plugins
With --plugins-mode ask or auto (also QUARK_PLUGINS_MODE, or plugins_mode in ~/.quark/config.json; default off), Quark loads Python plugins: *.py files directly under ~/.quark/plugins/ or the workspace's .agents/plugins/ (first match per filename wins), each defining a module-level PLUGIN = MyPlugin() that contributes its own Tool subclasses — for when a skill (text) or an MCP server (a separate process) isn't enough and you're willing to write Python that runs inside Quark itself:
# ~/.quark/plugins/word_count.py
from quark.plugins import Plugin
from quark.tools.base import Tool
class WordCountTool(Tool):
name = "word_count"
description = "Count words in a string."
parameters = {"type": "object", "properties": {"text": {"type": "string"}}, "required": ["text"]}
def run(self, text: str) -> str:
return str(len(text.split()))
class WordCountPlugin(Plugin):
name = "word-count"
def tools(self, workspace):
return [WordCountTool()]
PLUGIN = WordCountPlugin()
A plugin's code runs in Quark's own process with its full permissions the instant the file is imported — unlike a skill or an MCP call, there's no per-call approval the model can be asked for, since importing is running it. ask mode only lists candidate files by name (nothing is imported yet) and asks once before importing any of them; auto imports them directly; off doesn't even look. Only enable this for plugins you wrote yourself or fully trust. A plugin that fails to import, or doesn't define a valid PLUGIN, is skipped with a warning instead of stopping Quark; at most 16 plugin files are loaded.
Progressive tool disclosure
--progressive-tools (also QUARK_PROGRESSIVE_TOOLS=1) starts a turn with just read_file, list_dir, and one cheap extra tool, request_more_tools (no parameters). Its description tells the model to call it if it needs to write, edit, or delete files. If the model calls it, Quark registers write_file/edit_file/delete_file on the spot, drops request_more_tools (no longer needed), and the same agent.step() call retries with the expanded set — so the model still gets everything it needs, in the same turn, it just asks first.
This is deliberately not a heuristic: matching intent from text (keywords, embeddings, a classifier) always trades accuracy for cost and can silently withhold a tool the model actually needed on some phrasing you didn't anticipate. Letting the model itself request more tools can't misfire that way — the only cost is one extra round trip, and only on turns that actually mutate something. run_shell stays independently gated behind --shell-mode; progressive mode never unlocks it.
--minimal-tools is the stricter sibling: same starting set, but with no request_more_tools escape hatch at all, for when you want a hard read-only guarantee. Passing both flags together, --minimal-tools wins.
Tool limits
read_file: up to 500 lines or 64 KB per call withoffsetto continue; a single line longer than that is shown in pieces withcolumn. Files over 10 MiB are refused, and a file that changes while being read is reported instead of returned.list_dir: 500 entries by default (limitup to 10,000); symlinks are shown asland never followed.search_files: 100 results by default (limitup to 500), content hits aspath:line:column, files up to 10 MiB, 64 MiB read in total and 15 seconds per search; Esc stops it and keeps the partial results. Binary and unreadable files are skipped and counted.
Loop limits
A single reply may request at most 16 tool calls; a response asking for more gets an error for every call and none of them run. A turn may take at most 32 rounds of tool calls. Tool calls whose arguments aren't a valid JSON object are never run: the model gets an error and can resend them, and the turn stops after two such corrections. Calling the same tool with the same arguments and getting the same result is flagged to the model on the second time and stops the turn on the third.
Timeouts
Quark waits up to one hour for the model's next bytes (--request-timeout, also QUARK_REQUEST_TIMEOUT, or request_timeout in ~/.quark/config.json; connecting still gives up after 30 seconds), because a local model can take minutes to read a long prompt before its first token. Overloaded, rate-limited and dropped requests (408, 409, 429, 5xx, connection errors) are retried up to four times with backoff, honouring retry-after, but only while nothing has been shown yet; an error in the middle of a reply is reported instead of being saved as the answer.
Replies may use up to 32,000 output tokens on Anthropic (--max-tokens, also QUARK_MAX_TOKENS or max_tokens in ~/.quark/config.json; OpenAI-compatible servers use their own default unless set). A reply cut off by that limit is marked, and tool calls it contained are not run, so a half-written file never lands on disk. With Ollama, Quark reads the context size the server actually loaded and compacts earlier if it is smaller than expected, with a hint to raise OLLAMA_CONTEXT_LENGTH. run_shell commands time out after 120 seconds by default (the model can ask for more) and don't see your provider API keys or anything loaded from a .env file. On a timeout, or when you press Esc, the command and every process it started are killed, not just the shell; Esc also stops a command that is still running.
Token counts
The provider's own usage report (prompt_tokens/input_tokens plus output) replaces the character-based estimate once a reply has come back, and the estimate only covers messages added since. Compaction decisions still use the estimate, which is deliberately conservative.
Streaming
Replies print as the model generates them — both providers use stream: true and parse server-sent events, calling back into the CLI for each text chunk. Tool calls are accumulated silently (their JSON arguments arrive fragmented) and only run once complete; nothing changes about tool behavior, just how text reaches your terminal. Pass --no-stream to wait for the full reply and print it in one shot instead (e.g. for piping output into another program).
Context compaction
Quark estimates the session's token count (a len(text) // 4 heuristic — no tokenizer dependency) plus the system prompt and tool schemas sent with every request. Once history is over the budget, it asks the model for a summary of the older turns (file paths, decisions, your preferences, unfinished work, and what was verified) and folds it into the oldest turn it keeps. It only ever cuts at a turn boundary — right after a completed assistant reply, never mid-tool-call — so this can't break the strict user/assistant alternation Anthropic's API requires. It keeps up to the last three turns, fewer if they're bigger than ~20,000 tokens (or a quarter of the budget), but always the last one.
- Budget: set
--context-window(alsoQUARK_CONTEXT_WINDOW, orcontext_windowin~/.quark/config.json) to your model's real context limit and the budget becomes that window minus room for the reply (16,384 tokens or a quarter of the window, whichever is smaller). Without it, the budget is--compact-threshold(default 20000, alsoQUARK_COMPACT_THRESHOLD), which also overrides the window when both are set.--compact-threshold 0disables compaction. - Within a turn: once the budget is exceeded, Quark first looks for a cheaper, semantic cut before resorting to blind trimming: an older
read_fileorlist_dirresult for a path the model has since read or listed again is replaced outright with a one-line note, since the file could have changed in between and the newer call is what's actually current — this also runs before the LLM is asked to summarize anything, so a session full of re-reads never has to pay for summarizing them. Only then are any remaining older tool results shortened to their beginning and end. Either way, the latest round's results and the pairing of calls and results are kept. - Long outputs: any single tool result over 64,000 characters keeps its beginning and end, with the omission marked. The transcript sent for summarizing shortens each tool result the same way.
- What survives: what the model has read (see Read before edit) isn't part of the history, so compaction doesn't make it reread files.
- In the TUI:
/compact [focus]summarizes the whole conversation on demand, optionally steering the summary, and reports history and total context before and after. The header shows the current estimate.
Startup time
No network call, no API key, just importing Quark's own modules — measured by scripts/bench_startup.py (median of 7 runs, on the machine these docs were written on; your numbers will differ but should land in the same order of magnitude):
| Stage | Median |
|---|---|
python3 -c 'pass' (interpreter baseline) |
~13 ms |
import httpx (Quark's only hard dependency) |
~85 ms |
import quark.cli (quark chat's cold-start cost) |
~105 ms |
import quark.tui (quark tui's cold-start cost, pulls in textual) |
~330 ms |
Almost all of quark chat's own startup cost is httpx's import, not Quark's code; quark tui costs more because of textual. Run python scripts/bench_startup.py yourself to reproduce these (it also prints the default system prompt's token count, see below).
Token overhead
On the first turn (empty session), before the model generates anything, Quark sends the system prompt plus the JSON schema of every registered tool. The default system prompt itself is about 30 tokens; tool schemas are the rest. Rough token counts (tiktoken cl100k_base, an approximation — Claude's real tokenizer isn't public — but the right order of magnitude either way):
| Mode | Tools registered | Tool-schema tokens | Total (system + tools + a short message) |
|---|---|---|---|
| default | read_file, list_dir, search_files, write_file, edit_file, delete_file, delete_directory |
~600 | ~635 |
--minimal-tools |
read_file, list_dir, search_files |
~290 | ~325 |
--progressive-tools, before unlocking |
read_file, list_dir, search_files, request_more_tools |
~335 | ~370 |
--progressive-tools, after unlocking |
same as default | ~545 | ~580 |
default + --allow-shell |
+ run_shell |
~545 + ~90 | ~670 |
--minimal-tools is cheapest but can never write/edit/delete. --progressive-tools costs a little more than minimal on read-only turns (~370 vs ~325) but is capability-equivalent to the default the moment it's actually needed — it only pays the full ~580 on turns that mutate something. search_files is in every mode, including minimal, since searching never mutates anything. Every subsequent turn in a session also carries the accumulated conversation history on top of these numbers.
Architecture
quark/
message.py Internal Message/ToolCall representation
session.py Persistent, named conversation history, and its cumulative token usage
pricing.py Per-model $/1M-token table backing `quark usage`'s cost estimate
agent.py The chat + tool-calling loop
compact.py History summarization: semantic collapse of stale re-reads, then token-threshold trimming and LLM summary
providers/ Provider abstraction (unified request/response shape)
base.py
anthropic.py Anthropic Messages API, streamed (SSE)
openai.py OpenAI Chat Completions API, streamed (SSE) — also backs --provider ollama
tools/ Built-in tools the agent can call
base.py Tool + ToolRegistry
workspace.py Path confinement (resolve_within)
evidence.py What the model has read, required before edits
fs.py read_file / write_file / edit_file / delete_file / delete_directory / list_dir
search.py search_files (literal filename/content search)
shell.py run_shell (opt-in)
meta.py request_more_tools (--progressive-tools)
approval.py Approval prompts shared by run_shell, skills, MCP and side agents
skills.py Skill discovery and load_skill
mcp.py MCP client (stdio and Streamable HTTP) and MCP tools
subagent.py spawn_agent: isolated git worktree / copy, and the side Agent run in it
plugins.py Typed Python plugins (*.py under ~/.quark/plugins or ./.agents/plugins)
cli.py argparse-based entry point
onboarding.py Interactive first-run setup (quark init)
attachments.py @file attachments and the local index for @ suggestions
commands.py /read-dir, shared by the TUI and the REPL
init_project.py /init: investigate the workspace and write QUARK.md
evaluation.py Live model evaluation tasks (quark eval --live)
tui.py Textual UI (default bare `quark` invocation, also `quark tui`)
Adding a provider means implementing Provider.complete() in quark/providers/ and registering it in quark/providers/__init__.py. Adding a tool means subclassing Tool in quark/tools/ and adding it to default_registry().
Security note
read_file,write_file,edit_file,delete_file, andlist_dirare confined to--workspace(default: the current directory); paths that escape it, including via symlinks, are rejected. Read-only directories you add with--read-diror/read-dirextend only what can be read, listed and searched.run_shellexecutes arbitrary shell commands and is off by default.--allow-shellenables it with approval for every command;--shell-mode autoskips approval and should only be used when you trust the prompts/provider you're running against. See Shell permissions.write_file,edit_file, anddelete_fileonly touch existing files the model has read in their current state (see Read before edit), and every write is atomic (temp file + rename) and verified on disk. Symlinks, special files and files with other hard links are refused,delete_directorydeletes non-empty folders only after every file inside was read in its current state, and API keys/tokens are masked in search results and tool-output previews. They still mutate the filesystem inside the workspace without asking for confirmation, andrun_shellcommands can change files regardless of these checks. Only point Quark at trusted providers/prompts, and run it in an environment you're comfortable with an autonomous agent touching.- If you enter an API key during
quark init, it's written in plaintext to~/.quark/.env(permissions set to600, readable only by you) — never to~/.quark/config.json, which holds only non-secret preferences (provider, model, workspace, tool mode).
Development
pip install -e ".[dev]"
pytest
Tests mock the HTTP layer (httpx.stream), so the suite runs offline with no API keys required. The TUI test uses Textual's headless run_test() (via pytest-asyncio, a dev-only dependency) and sticks to a smoke check — mount, type, submit, see the bubble — since asserting on the agent's actual reply would mean waiting on a background worker thread from the test, which is a source of flaky CI. Agent.step() itself already has non-flaky coverage in tests/test_agent.py and tests/test_compact.py.
scripts/bench_startup.py backs the Startup time numbers above; also offline, no API key needed.
Live model evaluation
quark eval --live runs five tasks against the configured provider and model (the usual --provider/--model/--base-url/--api-key apply), each in its own temporary workspace and a session that isn't saved:
| Task | Passes when |
|---|---|
targeted_edit |
settings.py changes only the port. |
read_continuation |
The model finds a word on line 650 of a 700-line file, which needs read_file's offset. |
plan_boundaries |
In Plan mode, app.py is unchanged after a request to rename a function. A forbidden attempt is still counted, even though Quark blocks it. |
external_edit_recovery |
The file changes on disk right after the model reads it; the edit must still land on the new content. |
init |
/init's QUARK.md mentions the project and its test command. |
It prints JSON with each task's success, elapsed time, requests, tool calls, invalid and repeated calls, read-before-edit refusals, Plan mode violations, and an estimate of input tokens (estimated from text length, not provider-reported usage). It exits non-zero if any task fails. Without --live it only lists the tasks, and --task NAME (repeatable) picks some. These send real API requests; the unit tests never do. Keep the model (and quantization, for local models) fixed when comparing runs: the tasks measure these specific behaviors, not overall model quality.
Publishing to PyPI
Published as quark-ai. .github/workflows/publish.yml publishes to PyPI via Trusted Publishing (OIDC) whenever a GitHub Release is published — no API token stored in the repo. The pending-publisher setup (PyPI project quark-ai, owner rmoya81, repository Quark, workflow publish.yml, environment pypi) is already done; a new release is just:
- Bump
versioninpyproject.tomland merge that tomain. - Cut a GitHub Release with a matching tag (e.g.
v0.2.0) — the workflow builds the sdist/wheel and publishes them automatically.
(quark and quark-agent were already taken by unrelated projects on PyPI, which is why the distribution name is quark-ai instead — the installed command is still quark.)
Metadata
Release files for quark-ai 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quark_ai-0.4.0.tar.gz | 136.1 kB | With provenance | Details for quark_ai-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quark_ai-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for quark_ai-0.4.0-py3-none-any.whl |
Total release size: 232.2 kB
Release files / quark_ai-0.4.0.tar.gz
| Download URL | quark_ai-0.4.0.tar.gz |
|---|---|
| Size | 136.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b73df5d944c3c259edcfcdc86f8603cf31cc496fe988facbcb92edc6e3eb5b00
|
|
BLAKE2b-256 checksum How to use checksums |
5cd1a562004630acae434d3cf930bf5b61cd36c4b6c2349c41484554b9cc555f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logRelease files / quark_ai-0.4.0-py3-none-any.whl
| Download URL | quark_ai-0.4.0-py3-none-any.whl |
|---|---|
| Size | 96.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8beea699485a37f58b2cc4b43783faeae4fbd6756513092cf2f0951d9920d827
|
|
BLAKE2b-256 checksum How to use checksums |
d7953c4a15e58887e8388b9a783fd529b2f50a42fe2243ffb8ac54d874220daa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logSecurity for quark-ai 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for quark_ai-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.