|
| 1 | +--- |
| 2 | +sidebar_position: 7 |
| 3 | +--- |
| 4 | + |
| 5 | +# Context |
| 6 | + |
| 7 | +Print a condensed snapshot of the active workspace — the profile, environment, and per-repository git state. Designed to be terse enough to paste into a chat agent or pipe into another tool. |
| 8 | + |
| 9 | +```bash |
| 10 | +raid context # pretty-printed for humans |
| 11 | +raid context --json # machine-readable JSON |
| 12 | +``` |
| 13 | + |
| 14 | +## What it emits |
| 15 | + |
| 16 | +Every snapshot is **self-describing** so an agent that picks it up out of context can identify the producer: |
| 17 | + |
| 18 | +- **Name** — always `raid` |
| 19 | +- **Title** — the human-readable display name, `Raid` |
| 20 | +- **Version** — the raid binary version, useful for feature/schema detection |
| 21 | +- **Website URL** — canonical GitHub URL the agent can follow for additional documentation, source code search, or issue reporting |
| 22 | +- **Generated at** — UTC timestamp of when the snapshot was produced |
| 23 | + |
| 24 | +Followed by the workspace data: |
| 25 | + |
| 26 | +- **Tools** — name and short description of every built-in `raid` subcommand (`install`, `env`, `doctor`, `profile`, `context`). Lets an agent discover what raid itself can do without having to invoke `raid --help`. |
| 27 | +- **Active profile name** |
| 28 | +- **Active environment** (if one is set) |
| 29 | +- **Repositories** — name, configured path, current git branch, dirty status (uncommitted changes), and whether the repo has been cloned to disk |
| 30 | +- **Commands** — name and short description of every user-defined `raid <cmd>` available in the active profile. Script bodies are intentionally excluded so the snapshot stays token-efficient and free of inlined secrets. If any of a command's tasks have a `name` field set, those names also surface as a `steps` array — letting an agent see the outline of what the command does without exposing the underlying scripts. Built-in subcommands are listed under **Tools** above and are not duplicated here. |
| 31 | +- **Recent runs** — exit status, duration, and relative time of the most recent `raid <cmd>` invocations (capped at 10, persisted in `~/.raid/recent.json`). A run that was killed mid-execution (Ctrl+C, SIGTERM, etc.) is recorded as `interrupted` so you don't lose visibility into terminated commands. |
| 32 | + |
| 33 | +JSON keys use camelCase and the workspace data is grouped under a single `workspace` object. This shape aligns with the [Model Context Protocol](https://modelcontextprotocol.io) so a future `raid context serve` mode (a stdio MCP server) can lift these structures directly into JSON-RPC responses without translation. |
| 34 | + |
| 35 | +Output is intentionally bounded — task script bodies are excluded so the snapshot stays token-efficient for AI agents. |
| 36 | + |
| 37 | +## Pretty output |
| 38 | + |
| 39 | +Default invocation produces a fixed-width table for human reading: |
| 40 | + |
| 41 | +``` |
| 42 | +# raid v1.2.3 workspace context (2026-04-27T18:00:00Z) |
| 43 | +# https://github.com/8bitalex/raid |
| 44 | +
|
| 45 | +Profile: my-project |
| 46 | +Env: dev |
| 47 | +
|
| 48 | +Repos (3): |
| 49 | + api ~/dev/my-project/api main clean |
| 50 | + frontend ~/dev/my-project/frontend develop dirty |
| 51 | + worker ~/dev/my-project/worker not cloned |
| 52 | +
|
| 53 | +Tools (5): |
| 54 | + context Print a condensed summary of the active workspace |
| 55 | + doctor Check the raid configuration and report any issues |
| 56 | + env Execute an environment |
| 57 | + install Install the active profile |
| 58 | + profile Manage raid profiles |
| 59 | +
|
| 60 | +Commands (3): |
| 61 | + deploy Deploy to production |
| 62 | + 1. Build artifact |
| 63 | + 2. Push to registry |
| 64 | + 3. Apply migrations |
| 65 | + test Run tests |
| 66 | + reset-db Reset local database |
| 67 | +
|
| 68 | +Recent (3): |
| 69 | + ✓ deploy ok 12.3s 2m ago |
| 70 | + ✗ test failed 4.5s 5m ago |
| 71 | + ⊘ migrate interrupted — 18m ago |
| 72 | +``` |
| 73 | + |
| 74 | +Each row shows a status glyph, the command name, a status word, the duration, and a relative timestamp. |
| 75 | + |
| 76 | +| Glyph | Status word | Meaning | |
| 77 | +|---|---|---| |
| 78 | +| `✓` | `ok` | Command completed with exit code 0 | |
| 79 | +| `✗` | `failed` | Command completed with a non-zero exit code | |
| 80 | +| `⊘` | `interrupted` | Command was killed before completing (SIGINT, SIGTERM, etc.). Duration is unknown and shown as `—`. | |
| 81 | + |
| 82 | +Status values: |
| 83 | + |
| 84 | +| Status | Meaning | |
| 85 | +|---|---| |
| 86 | +| `clean` | Repository is cloned and has no uncommitted changes | |
| 87 | +| `dirty` | Repository is cloned and has uncommitted changes (per `git status --porcelain`) | |
| 88 | +| `not cloned` | Path from the profile does not exist on disk, or is not a git repository | |
| 89 | + |
| 90 | +## JSON output |
| 91 | + |
| 92 | +`raid context --json` emits a stable, agent-friendly schema: |
| 93 | + |
| 94 | +```json |
| 95 | +{ |
| 96 | + "name": "raid", |
| 97 | + "title": "Raid", |
| 98 | + "version": "1.2.3", |
| 99 | + "websiteUrl": "https://github.com/8bitalex/raid", |
| 100 | + "generatedAt": "2026-04-27T18:00:00Z", |
| 101 | + "tools": [ |
| 102 | + { "name": "context", "description": "Print a condensed summary of the active workspace" }, |
| 103 | + { "name": "doctor", "description": "Check the raid configuration and report any issues" }, |
| 104 | + { "name": "env", "description": "Execute an environment" }, |
| 105 | + { "name": "install", "description": "Install the active profile" }, |
| 106 | + { "name": "profile", "description": "Manage raid profiles" } |
| 107 | + ], |
| 108 | + "workspace": { |
| 109 | + "profile": "my-project", |
| 110 | + "env": "dev", |
| 111 | + "repos": [ |
| 112 | + { |
| 113 | + "name": "api", |
| 114 | + "path": "~/dev/my-project/api", |
| 115 | + "cloned": true, |
| 116 | + "branch": "main", |
| 117 | + "dirty": false |
| 118 | + }, |
| 119 | + { |
| 120 | + "name": "worker", |
| 121 | + "path": "~/dev/my-project/worker", |
| 122 | + "cloned": false |
| 123 | + } |
| 124 | + ], |
| 125 | + "commands": [ |
| 126 | + { |
| 127 | + "name": "deploy", |
| 128 | + "description": "Deploy to production", |
| 129 | + "steps": [ |
| 130 | + { "name": "Build artifact" }, |
| 131 | + { "name": "Push to registry" }, |
| 132 | + { "name": "Apply migrations" } |
| 133 | + ] |
| 134 | + }, |
| 135 | + { "name": "test", "description": "Run tests" } |
| 136 | + ], |
| 137 | + "recent": [ |
| 138 | + { |
| 139 | + "command": "deploy", |
| 140 | + "status": "completed", |
| 141 | + "exitCode": 0, |
| 142 | + "startedAt": "2026-04-27T12:00:00Z", |
| 143 | + "durationMs": 12300 |
| 144 | + }, |
| 145 | + { |
| 146 | + "command": "migrate", |
| 147 | + "status": "interrupted", |
| 148 | + "exitCode": 0, |
| 149 | + "startedAt": "2026-04-27T11:42:00Z" |
| 150 | + } |
| 151 | + ] |
| 152 | + } |
| 153 | +} |
| 154 | +``` |
| 155 | + |
| 156 | +When a repository is not cloned, `branch` and `dirty` are omitted. The `workspace.recent` array is omitted entirely when no commands have been run yet. |
| 157 | + |
| 158 | +## Common uses |
| 159 | + |
| 160 | +```bash |
| 161 | +# Drop the current workspace state into a chat agent |
| 162 | +raid context | pbcopy |
| 163 | + |
| 164 | +# Feed JSON into another tool |
| 165 | +raid context --json | jq '.workspace.repos[] | select(.dirty)' |
| 166 | +``` |
0 commit comments