Scira
Architecture

System overview

How Scira's components fit together — agents, tools, storage, and the run lifecycle.

Scira is built around two cooperating agents, a structured run directory, and a tool set that covers search, file I/O, shell, and claims management. This page explains how the pieces connect.

Component map

CLI entry (src/cli/index.ts)

├── TUI  ──────────────────────────────────────┐
│   └── SciraApp.tsx                           │
│       ├── useSession        session lifecycle│
│       ├── useAgentTurn      drives agent     │
│       ├── useSubmit         sends messages   │
│       └── useKeyboard       slash commands   │
│                                              │
└── Headless (scira "question")                │

                              Agent layer (src/agent/)
                              ├── createOneShotAgent()   quick answers
                              └── createResearchAgent()  full harness

                                  ├── ToolLoopAgent (Vercel AI SDK)
                                  │   └── getLanguageModel(config)

                                  └── Tool sets
                                      ├── createResearchTools()   always
                                      ├── createCodingTools()     --workspace
                                      ├── createFileTools()       files: config
                                      └── MCP bridge              mcp: config

Two agent modes

One-shot (createOneShotAgent) handles most TUI interactions. It has access to web search, page reading, file I/O, and coding tools. If the question needs structured multi-source research — claims, verification, a written report — it calls requestFullResearch and hands off.

Research (createResearchAgent) runs the full harness: writes plan.md, gathers sources into sources.jsonl, records findings as claims in claims.jsonl, verifies each claim, and synthesizes report.md. It runs both in the TUI (after escalation) and headlessly.

Both agents are instances of ToolLoopAgent from the Vercel AI SDK. The loop continues until isLoopFinished() — a stop condition the model signals by ending a turn without calling any more tools.

Tool sets

Tools are assembled per-agent in src/tools/agent-tools.ts. Which set a session gets depends on how it was launched:

SetWhen presentSource
Research toolsAlwayscreateResearchTools()
Coding toolsscira --workspace <path> or code agent modecreateCodingTools()
File toolsfiles.dir set in configcreateFileTools()
MCP toolsmcp.servers or mcp.chromeDevtools.enabledcreateMcpBridge()
X searchXAI_API_KEY is setcreateXSearchTool()

See the Tools reference page for the full per-tool spec.

Run directory

Every session writes to a run directory under .scira/runs/<run-id>/ (configurable via runDirectory). The structure:

.scira/runs/<id>/
├── goal.md               original question
├── plan.md               agent research plan (written by agent)
├── notes.md              incremental findings (written by agent)
├── sources.jsonl         sources read and cited (JSONL)
├── claims.jsonl          extracted + verified claims (JSONL)
├── report.md             final synthesized output
├── todos.json            structured task list for the current run
├── background-tasks.json live process registry (coding mode)
├── convo.json            conversation history for TUI resume
├── run.log.jsonl         event log (tool calls, timings)
└── snapshots/            saved page extracts from readUrl

Path routing in writeFile/readFile/editFile is automatic: bare harness filenames (plan.md, report.md) resolve to the run directory; everything else resolves to the workspace root when running in code agent mode.

Approval system

Every tool call that has side effects passes through a gate before executing. The gate behaviour depends on approvalMode:

ModeBehaviour
manualEvery write, edit, and bash call prompts for approval
suggest (default)Report writes, workspace edits, and shell commands prompt; reading is free
autoAll tools run without prompting

The gate is an ApprovalCallback injected at agent creation time. In the TUI it opens an overlay; headless mode reads from stdin.

Configuration

Config merges ~/.scira/config.json (global) with .scira/config.json (project). Key fields that affect agent behaviour:

FieldEffect
llmProvider + modelWhich model drives the agent
approvalModeWhen side-effecting tools require user approval
citationPolicystrict: every claim needs a source; balanced: major claims cited
maxSourcesCap on sources gathered per run
search.providerWeb search backend
search.maxResultsResults per query
files.dirMount a local file directory into the agent
mcp.chromeDevtools.enabledEnable live browser research

On this page