1 # Headless execution
2
3 `sigit run` exposes the siGit Code agent runtime to scripts, CI, and siGit Factory clients.
4 It uses the same provider selection, project instructions, skills, tools, MCP servers, and
5 permission policy as the interactive and ACP surfaces.
6
7 ## Run and resume
8
9 ```sh
10 sigit run "Review this repository" --cwd /path/to/repository
11 ```
12
13 A new run receives a UUID session ID and saves its conversation under the siGit configuration
14 directory. Text mode prints the ID to stderr as `Session: <id>`. Resume it later with:
15
16 ```sh
17 sigit run "Continue with the fixes" --resume <id>
18 ```
19
20 The saved metadata includes the primary working directory, additional project roots, and model.
21 This makes the same session discoverable through ACP `session/list` and loadable by an editor.
22 Each run rewrites that metadata with its own `--cwd` and `--add-dir` values, so a resume records
23 where the session last ran. Pass the same `--add-dir` flags again to keep extra roots attached.
24
25 Use repeatable `--add-dir <path>` flags for multi-root workspaces. Mutating tools that would ask
26 for interactive permission are denied in headless mode unless granted with
27 `--allow-tool <name>`. A repeatable `--deny-tool <name>` takes precedence over grants and
28 settings.
29
30 ## JSONL output
31
32 Pass `--output jsonl` for a machine-readable stdout stream:
33
34 ```sh
35 sigit run "Run the focused tests" --output jsonl --allow-tool run_command
36 ```
37
38 Each line is one JSON object. Every event includes `type` and `session_id`. A run that gets as far
39 as inference starts with a `session` event. A run that fails before that, because no remote
40 provider is configured or the `--resume` session doesn't exist, emits a single `error` event and
41 nothing else.
42
43 | Type | Additional fields | Meaning |
44 |---|---|---|
45 | `session` | `resumed` | Identifies the run before inference starts. |
46 | `assistant_delta` | `text` | One visible streamed response fragment. |
47 | `tool_call` | `tool_call_id`, `name`, `arguments` | A tool requested by the model. `arguments` is the tool's JSON string. |
48 | `tool_result` | `tool_call_id`, `name`, `content` | The executed result or permission denial returned to the model. |
49 | `result` | `text`, `tool_rounds` | The completed turn and its final visible text. |
50 | `error` | `message` | A provider, session, or inference failure. |
51
52 Logs and diagnostics stay on stderr. `--quiet` applies only to text output and cannot be combined
53 with JSONL output.
54
55 ## Exit codes
56
57 | Code | Meaning |
58 |---|---|
59 | `0` | The turn completed, including turns where a tool was denied by policy. |
60 | `1` | Provider resolution, session restoration, inference, or tool-loop failure. |
61 | `2` | Invalid command-line arguments or working directories. |
62
63 The earlier `sigit -p "<prompt>"` syntax remains an alias for headless execution and accepts the
64 same flags.