|
4 | 4 |
|
5 | 5 | <h1 align="center">OpenWar</h1> |
6 | 6 |
|
7 | | -<p align="center"><strong>The framework that ships in <a href="https://github.com/pythonluvr/war-room">War Room</a>. Use it anywhere.</strong></p> |
| 7 | +<p align="center"><strong>A framework and a runtime for agent behavior that doesn't go off the rails.</strong></p> |
8 | 8 |
|
9 | | -OpenWar is a system prompt that turns any LLM-based agent (Claude, GPT, Gemini, others) into something that behaves like a senior peer instead of a customer service rep. It confirms briefs before acting, breaks work into phases, asks before doing anything destructive, and writes like an adult who's busy. |
| 9 | +OpenWar replaces eager-customer-service-rep defaults with the behavior of a senior peer. It confirms briefs before acting, breaks work into phases, asks before doing anything destructive, and writes like an adult who's busy. |
10 | 10 |
|
11 | | -It's a single markdown file. Drop it into your agent's system prompt, Claude Code's `CLAUDE.md`, Cursor's settings, Hermes config, OpenClaw skills, anywhere, and your agent's behavior changes. |
| 11 | +You can use it two ways: |
12 | 12 |
|
13 | | -## What's in it |
| 13 | +1. **As a runtime** (new in v0.2). Install the package, point it at a brief, watch the phase machine enforce the framework against any BYOK LLM. The runtime is opinionated: no flag to disable Phase 3, no way to skip the Confirmation Summary. |
| 14 | +2. **As a system prompt** (v0.1, still supported). Paste [`openwar.md`](./openwar.md) into Claude Code's CLAUDE.md, Cursor's rules, Hermes, OpenClaw, or anywhere else. The agent's behavior changes; nothing else does. |
14 | 15 |
|
15 | | -- **Phase architecture**: every task moves through Brief Intake → Execution → (Blocker / Destructive Flag) → Completion. Operators can interrupt at any phase. |
16 | | -- **Confirmation Summary**: agent never starts work without acknowledging what it heard. |
17 | | -- **Per-step vs auto-pilot mode**: operators pick how much gating they want; agents respect it. |
18 | | -- **Hard rules against** invented next steps, hallucinated capabilities, unauthorized actions, blind retries past blockers. |
19 | | -- **Pre-mortem trigger** for strategic / problem-solving / creative / cost-spending work. |
20 | | -- **Voice rules**: banned filler phrases ("Certainly", "Absolutely", "leverage"...), peer-level tone. |
21 | | -- **"Best solution, not the fast one"**: agent leads with the gold-standard path by default, not stopgaps. |
| 16 | +The framework doc and the runtime are the same source of truth. The doc tells the model what to do. The runtime makes sure it actually does it. |
22 | 17 |
|
23 | | -Read the full framework: [`openwar.md`](./openwar.md). |
| 18 | +## Quick start (runtime) |
24 | 19 |
|
25 | | -## Install |
26 | | - |
27 | | -### Claude Code |
| 20 | +```bash |
| 21 | +npx pythonluvr/openwar run examples/creative-brief.md --adapter anthropic |
| 22 | +``` |
28 | 23 |
|
29 | | -Append OpenWar to your global CLAUDE.md so every Claude Code session loads it automatically: |
| 24 | +Or install: |
30 | 25 |
|
31 | 26 | ```bash |
32 | | -mkdir -p ~/.claude |
33 | | -curl -fsSL https://raw.githubusercontent.com/pythonluvr/openwar/main/openwar.md >> ~/.claude/CLAUDE.md |
| 27 | +npm install -g pythonluvr/openwar |
| 28 | +export ANTHROPIC_API_KEY=... |
| 29 | +openwar run examples/engineering-brief.md |
34 | 30 | ``` |
35 | 31 |
|
36 | | -Or for a single project: |
| 32 | +Provide an API key for whichever adapter you pick: |
| 33 | + |
| 34 | +| Adapter | Env var | Default model | |
| 35 | +|-----------------|--------------------------|-----------------------| |
| 36 | +| `anthropic` | `ANTHROPIC_API_KEY` | `claude-sonnet-4-6` | |
| 37 | +| `openai` | `OPENAI_API_KEY` | `gpt-4o` | |
| 38 | +| `gemini` | `GEMINI_API_KEY` | `gemini-2.0-flash` | |
| 39 | +| `grok` | `XAI_API_KEY` | `grok-2-latest` | |
| 40 | +| `openai-compat` | `OPENAI_COMPAT_API_KEY` | (specify with `--base-url`) | |
| 41 | + |
| 42 | +`openai-compat` covers OpenRouter, Groq, Together, Ollama, vLLM, llama.cpp, and anything else speaking OpenAI's chat-completions protocol. |
| 43 | + |
| 44 | +## What the runtime enforces |
| 45 | + |
| 46 | +| Phase | What happens | What blocks | |
| 47 | +|---------|--------------------------------------------------------------------------------------------------|-------------| |
| 48 | +| Phase 0 | Agent must produce a Confirmation Summary with Objective / Deliverables / Constraints / Tools / Unknowns. | No execution until the operator accepts. | |
| 49 | +| Phase 1 | Agent executes step by step. Gated mode pauses between steps; auto-pilot runs through clean ones. | Banned phrases warn. | |
| 50 | +| Phase 2 | If the agent declares it's blocked, the runtime halts the session and persists state. | Resume with `openwar resume <brief_id>`. | |
| 51 | +| Phase 3 | If the agent announces intent to do something destructive or out-of-directive, the runtime stops and asks for explicit yes. | Authorization can be pre-approved per category in the brief's `authorized_costs`. | |
| 52 | +| Phase 4 | Agent produces a concise completion report. | None. | |
| 53 | + |
| 54 | +The phase loop is enforced by deterministic pattern detectors. No second LLM, no judging. If the agent skips the Confirmation Summary, the runtime asks it to restate before letting execution start. |
| 55 | + |
| 56 | +## CLI |
| 57 | + |
| 58 | +```text |
| 59 | +openwar run <brief.md> [--adapter <id>] [--model <name>] [--mode gated|auto] |
| 60 | + [--resume] [--ephemeral] |
| 61 | +openwar resume <brief_id> |
| 62 | +openwar list |
| 63 | +openwar inspect <brief_id> [--transcript] |
| 64 | +openwar validate <brief.md> |
| 65 | +openwar adapters |
| 66 | +openwar version |
| 67 | +``` |
37 | 68 |
|
38 | | -```bash |
39 | | -curl -fsSL https://raw.githubusercontent.com/pythonluvr/openwar/main/openwar.md >> ./CLAUDE.md |
| 69 | +Sessions persist to `~/.openwar/sessions/` as JSON + JSONL transcript. Resume with `openwar resume <brief_id>`. `--ephemeral` skips persistence (used by tests and integrators). |
| 70 | + |
| 71 | +## Use as a library |
| 72 | + |
| 73 | +```ts |
| 74 | +import { run, MockAdapter, AnthropicAdapter } from "openwar"; |
| 75 | + |
| 76 | +const adapter = new AnthropicAdapter({ id: "anthropic", model: "claude-sonnet-4-6" }); |
| 77 | +const result = await run({ briefPath: "./brief.md", adapter }); |
| 78 | + |
| 79 | +if (!result.completed) { |
| 80 | + console.error(`Halted at ${result.final_phase}: ${result.halt_reason}`); |
| 81 | +} |
40 | 82 | ``` |
41 | 83 |
|
42 | | -### Cursor |
| 84 | +War Room and other integrators consume OpenWar this way; the runtime is the framework's enforcement surface. |
43 | 85 |
|
44 | | -Cursor → Settings → Rules for AI → paste the contents of [`openwar.md`](./openwar.md). |
| 86 | +## Brief format |
45 | 87 |
|
46 | | -### War Room |
| 88 | +Briefs are markdown with required frontmatter. A reference template ships at [`templates/brief.md`](./templates/brief.md). |
47 | 89 |
|
48 | | -War Room ships OpenWar as the bundled default framework. Toggle in `Settings → Agent → Framework`. Nothing to install, it's already there. |
| 90 | +```yaml |
| 91 | +--- |
| 92 | +project: <slug> # required, kebab-case |
| 93 | +brief_id: YYYY-MM-DD-NNN # optional; auto-generated if absent |
| 94 | +deadline: YYYY-MM-DD # optional |
| 95 | +scope_locked: true|false # if true, refuse out-of-scope additions |
| 96 | +mode: gated|auto # optional override of per-step-vs-auto |
| 97 | +authorized_costs: # pre-approves these destructive categories |
| 98 | + - filesystem_write |
| 99 | + - generation_credits |
| 100 | + - git_push |
| 101 | +--- |
| 102 | +``` |
49 | 103 |
|
50 | | -### Anything else (Hermes, OpenClaw, custom) |
| 104 | +Recognized `authorized_costs` categories include `filesystem_delete`, `git_history_rewrite`, `git_push`, `deploy`, `external_message`, `paid_api`, `package_change`, `ci_modify`, `process_kill`. Use `*` to authorize everything (rarely a good idea). |
51 | 105 |
|
52 | | -Whatever your runtime calls "system prompt" or "preamble", paste the contents of `openwar.md` in. |
| 106 | +Body sections: **Objective**, **Deliverables**, **Constraints**, **Tools required**, **Notes / unknowns**. |
53 | 107 |
|
54 | | -## Why does this exist |
| 108 | +Validate a brief without running it: |
55 | 109 |
|
56 | | -Default agent behavior (eager, sycophantic, prone to surprise actions) produces bad outcomes for serious work. You ship the wrong thing because the agent didn't confirm what you meant. You discover paid API spend you didn't authorize. You get "I'd be happy to help you with that!" instead of an actual answer. |
| 110 | +```bash |
| 111 | +openwar validate brief.md |
| 112 | +``` |
| 113 | + |
| 114 | +## Still want just the system prompt? |
| 115 | + |
| 116 | +Paste [`openwar.md`](./openwar.md) into your agent's system prompt. The framework remains a single markdown file. You lose enforcement (the model is on the honor system), but you keep the behavior overlay. |
| 117 | + |
| 118 | +### Claude Code |
| 119 | + |
| 120 | +```bash |
| 121 | +mkdir -p ~/.claude |
| 122 | +curl -fsSL https://raw.githubusercontent.com/pythonluvr/openwar/main/openwar.md >> ~/.claude/CLAUDE.md |
| 123 | +``` |
| 124 | + |
| 125 | +### Cursor |
| 126 | + |
| 127 | +Settings → Rules for AI → paste the contents of `openwar.md`. |
| 128 | + |
| 129 | +### War Room |
57 | 130 |
|
58 | | -OpenWar replaces those defaults with the behavior of a senior peer. The agent reads your brief, says "here's what I heard, confirm?", and waits. It writes like an adult. It stops when it hits something it can't resolve instead of guessing. It tells you when something is outside what you asked for. |
| 131 | +War Room ships OpenWar as its default framework. v0.5+ adopts the runtime; earlier versions used the system prompt only. |
59 | 132 |
|
60 | | -It's not magic. It's a system prompt. But it's a system prompt that's been battle-tested across thousands of real freelance / dev / creative tasks and refined to remove the failure modes that kept showing up. |
| 133 | +## Why both |
61 | 134 |
|
62 | | -## Variants |
| 135 | +Behavioral overlays are easy to ignore. A model that's been told "always produce a Confirmation Summary" will sometimes skip it under context pressure or specific phrasing. The runtime catches the skip and asks the model to restate. |
63 | 136 |
|
64 | | -The default is `openwar.md`, the full framework with all phases, hard rules, and triggers. Future variants will live in [`variants/`](./variants/): |
| 137 | +System prompts cost nothing to install and work with any runtime. The runtime is heavier, but it actually enforces the rules. |
65 | 138 |
|
66 | | -- `openwar-strict.md`: adds aggressive confirmation gating; useful for high-stakes / production work |
67 | | -- `openwar-light.md`: drops the pre-mortem trigger and brief format requirement; useful for casual chat / quick questions |
| 139 | +## Versioning |
68 | 140 |
|
69 | | -(Empty for now, ships when stable.) |
| 141 | +Current: **v0.2.0** (runtime + framework doc). |
70 | 142 |
|
71 | | -## Templates |
| 143 | +- v0.2: runtime, CLI, BYOK adapters for Anthropic / OpenAI / Gemini / Grok / OpenAI-compat. |
| 144 | +- v0.3: CLI-bridge adapters (claude-cli, codex-cli), MCP tool calling. |
| 145 | +- v0.4: multi-agent / boardroom orchestration. |
72 | 146 |
|
73 | | -[`templates/brief.md`](./templates/brief.md) is a reference brief in OpenWar's format. Copy it when starting new tasks; the frontmatter fields drive how the agent gates execution. |
| 147 | +Framework doc is versioned with the package. Drop-in upgrades preserve compatibility within a major version; major bumps may rename phases or change the brief format. |
74 | 148 |
|
75 | 149 | ## License |
76 | 150 |
|
77 | | -[MIT](./LICENSE). Use it, modify it, fork it, ship your own variants, paste it into commercial products. No obligations beyond keeping the copyright notice. |
| 151 | +[MIT](./LICENSE). |
78 | 152 |
|
79 | 153 | ## Authorship |
80 | 154 |
|
81 | | -OpenWar is the framework that ships inside [War Room](https://github.com/pythonluvr/war-room), authored over many iterations of running real agent work. This standalone repo exists so people who don't use War Room can still adopt the framework. |
| 155 | +OpenWar is the framework that ships inside [War Room](https://github.com/pythonluvr/war-room), authored across many iterations of running real agent work. This standalone repo exists so people who don't use War Room can still adopt the framework. |
82 | 156 |
|
83 | | -Issues + PRs welcome. |
| 157 | +Issues and PRs welcome. |
0 commit comments