hawkeye-ai 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +263 -723
  2. package/dashboard/assets/index-BUGSHUFm.css +1 -0
  3. package/dashboard/assets/index-DudE3Qss.js +141 -0
  4. package/dashboard/index.html +2 -3
  5. package/dist/commands/agent-command.d.ts +2 -0
  6. package/dist/commands/agent-command.d.ts.map +1 -1
  7. package/dist/commands/agent-command.js +40 -1
  8. package/dist/commands/agent-command.js.map +1 -1
  9. package/dist/commands/analyze.d.ts.map +1 -1
  10. package/dist/commands/analyze.js +18 -11
  11. package/dist/commands/analyze.js.map +1 -1
  12. package/dist/commands/ci-report.d.ts +37 -0
  13. package/dist/commands/ci-report.d.ts.map +1 -0
  14. package/dist/commands/ci-report.js +228 -0
  15. package/dist/commands/ci-report.js.map +1 -0
  16. package/dist/commands/ci.d.ts +15 -0
  17. package/dist/commands/ci.d.ts.map +1 -0
  18. package/dist/commands/ci.js +272 -0
  19. package/dist/commands/ci.js.map +1 -0
  20. package/dist/commands/daemon.d.ts +24 -1
  21. package/dist/commands/daemon.d.ts.map +1 -1
  22. package/dist/commands/daemon.js +505 -33
  23. package/dist/commands/daemon.js.map +1 -1
  24. package/dist/commands/desktop.d.ts.map +1 -0
  25. package/dist/commands/export.d.ts +7 -13
  26. package/dist/commands/export.d.ts.map +1 -1
  27. package/dist/commands/export.js +531 -201
  28. package/dist/commands/export.js.map +1 -1
  29. package/dist/commands/hook-handler.d.ts.map +1 -1
  30. package/dist/commands/hook-handler.js +14 -0
  31. package/dist/commands/hook-handler.js.map +1 -1
  32. package/dist/commands/record.d.ts.map +1 -1
  33. package/dist/commands/record.js +70 -19
  34. package/dist/commands/record.js.map +1 -1
  35. package/dist/commands/report.d.ts.map +1 -1
  36. package/dist/commands/report.js +3 -2
  37. package/dist/commands/report.js.map +1 -1
  38. package/dist/commands/serve.d.ts.map +1 -1
  39. package/dist/commands/serve.js +989 -77
  40. package/dist/commands/serve.js.map +1 -1
  41. package/dist/config.d.ts +10 -0
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +74 -21
  44. package/dist/config.js.map +1 -1
  45. package/dist/demo.d.ts +2 -0
  46. package/dist/demo.d.ts.map +1 -0
  47. package/dist/demo.js +4 -0
  48. package/dist/demo.js.map +1 -0
  49. package/dist/desktop.d.ts.map +1 -0
  50. package/dist/impact.d.ts +2 -0
  51. package/dist/impact.d.ts.map +1 -1
  52. package/dist/impact.js +2 -2
  53. package/dist/impact.js.map +1 -1
  54. package/dist/index.js +2 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/interactive-constants.d.ts +4 -0
  57. package/dist/interactive-constants.d.ts.map +1 -0
  58. package/dist/interactive-constants.js +59 -0
  59. package/dist/interactive-constants.js.map +1 -0
  60. package/dist/interactive-display.d.ts +11 -0
  61. package/dist/interactive-display.d.ts.map +1 -0
  62. package/dist/interactive-display.js +67 -0
  63. package/dist/interactive-display.js.map +1 -0
  64. package/dist/interactive-models.d.ts +18 -0
  65. package/dist/interactive-models.d.ts.map +1 -0
  66. package/dist/interactive-models.js +360 -0
  67. package/dist/interactive-models.js.map +1 -0
  68. package/dist/interactive-types.d.ts +30 -0
  69. package/dist/interactive-types.d.ts.map +1 -0
  70. package/dist/interactive-types.js +2 -0
  71. package/dist/interactive-types.js.map +1 -0
  72. package/dist/interactive.d.ts.map +1 -1
  73. package/dist/interactive.js +675 -323
  74. package/dist/interactive.js.map +1 -1
  75. package/dist/mcp/server.d.ts.map +1 -1
  76. package/dist/mcp/server.js +598 -185
  77. package/dist/mcp/server.js.map +1 -1
  78. package/dist/vscode-bridge.d.ts.map +1 -0
  79. package/package.json +2 -2
  80. package/dashboard/assets/index-Ci4a7w1H.css +0 -1
  81. package/dashboard/assets/index-CjUuFl4a.js +0 -137
package/README.md CHANGED
@@ -1,389 +1,292 @@
1
- <h1 align="center">Hawkeye</h1>
2
-
3
- <p align="center">
4
- <strong>The flight recorder for AI agents</strong><br/>
5
- <sub>Open-source observability & security for Claude Code · Aider · AutoGPT · CrewAI · Open Interpreter · any LLM-powered agent</sub>
6
- </p>
7
-
8
- <p align="center">
9
- <a href="https://www.npmjs.com/package/hawkeye-ai"><img src="https://img.shields.io/npm/v/hawkeye-ai?color=ff5f1f&label=npm" alt="npm version"></a>
10
- <a href="https://github.com/MLaminekane/hawkeye/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license"></a>
11
- <a href="https://github.com/MLaminekane/hawkeye"><img src="https://img.shields.io/github/stars/MLaminekane/hawkeye?style=social" alt="GitHub stars"></a>
12
- </p>
13
-
14
- <p align="center">
15
- <a href="#installation">Install</a> •
16
- <a href="#quick-start">Quick Start</a> •
17
- <a href="#features">Features</a> •
18
- <a href="#cli-commands">CLI</a> •
19
- <a href="#dashboard">Dashboard</a> •
20
- <a href="#driftdetect">DriftDetect</a> •
21
- <a href="#guardrails">Guardrails</a> •
22
- <a href="#security">Security</a> •
23
- <a href="#architecture">Architecture</a>
24
- </p>
25
-
26
- ---
27
-
28
- ## What is Hawkeye?
29
-
30
- Hawkeye is a **flight recorder** for AI agents. It captures every action an agent performs — terminal commands, file operations, LLM calls, API requests — and provides:
31
-
32
- - **Session recording & replay** — Full timeline of every agent action with costs and metadata
33
- - **Time Travel Debugging** — Step-through replay with breakpoints, keyboard shortcuts, interactive SVG timeline, session forking ("replay from here")
34
- - **Root Cause Analysis** — Automatic `hawkeye analyze` finds primary errors, causal chains, error patterns, and fix suggestions (heuristic + optional LLM)
35
- - **DriftDetect** — Real-time objective drift detection using heuristic + LLM scoring
36
- - **Guardrails** — File protection, command blocking, cost limits, token limits, directory scoping, network lock, review gates
37
- - **Impact Preview** — Pre-execution risk analysis for every agent action (low/medium/high/critical)
38
- - **Live Firewall** — Real-time action stream with browser push notifications and badge counter
39
- - **Policy Engine** — Declarative `.hawkeye/policies.yml` for shareable, team-wide security rules
40
- - **Autonomous Control Layer** — Autocorrect engine that auto-rolls back files, pauses sessions, blocks failing patterns, and injects correction hints to agents via MCP
41
- - **Memory Diff** — Cross-session agent memory tracking, hallucination detection, cumulative knowledge view
42
- - **Live Agent Spawning** — Spawn, monitor, and control AI agents directly from the dashboard with role assignment, permission levels, and real-time session linking
43
- - **Multi-agent Orchestration (Swarm)** — Coordinate multiple AI agents on parallel tasks with isolated worktrees, scope enforcement, dependency ordering, conflict detection, and merge strategies
44
- - **Visual dashboard** — Mobile-responsive web UI with session explorer, drift charts, firewall, agents control room, memory viewer, and settings management
45
- - **Remote tasks** — Submit prompts from your phone via dashboard, with image attachments, auto-approve, and persistent agent memory
46
- - **Interactive TUI** — Terminal-responsive CLI with arrow-key navigation and slash commands
47
- - **OpenTelemetry export** — Push traces to Grafana Tempo, Jaeger, Datadog, Honeycomb
48
- - **Universal ingestion API** — Accept events from any source (MCP servers, custom tools)
49
- - **MCP server** — 38 tools for agent self-awareness, intelligence, and cross-session analysis
50
- - **Multi-agent support** — Claude Code (hooks), Aider, Open Interpreter, AutoGPT, CrewAI, Codex, or any custom command
51
-
52
- ## Installation
53
-
54
- ### npm (recommended)
55
-
56
- ```bash
57
- npm install -g hawkeye-ai
1
+ ```text
2
+ ██╗ ██╗
3
+ ██║ ██║
4
+ ███████║ Hawkeye
5
+ ██╔══██║ The flight recorder for AI agents
6
+ ██║ ██║
7
+ ╚═╝ ╚═╝
58
8
  ```
59
9
 
60
- ### npx (no install)
10
+ # Hawkeye CLI
61
11
 
62
- ```bash
63
- npx hawkeye-ai
64
- ```
12
+ `hawkeye-ai` turns any coding agent into something you can actually observe, debug, and trust.
65
13
 
66
- ### Homebrew (macOS/Linux)
14
+ If Claude Code, Codex, Cline, or a custom agent goes off-script, Hawkeye shows you:
67
15
 
68
- ```bash
69
- brew install MLaminekane/hawkeye/hawkeye-ai
70
- ```
16
+ - what it did
17
+ - which files it touched
18
+ - what it cost
19
+ - where it started drifting
20
+ - which guardrail blocked it
21
+ - how to replay or inspect the failure
71
22
 
72
- ### Vercel Agent Skill
23
+ This package is the fastest way to try Hawkeye locally: install it, wrap one agent run, then open the dashboard and see the whole session.
73
24
 
74
- Install as a skill for any AI coding agent (Claude Code, Cursor, Gemini CLI, GitHub Copilot, and 30+ more):
25
+ ## Why try Hawkeye?
75
26
 
76
- ```bash
77
- npx skills add MLaminekane/hawkeye
78
- ```
27
+ Most agent workflows fail in annoying ways:
79
28
 
80
- ### From source
29
+ - the agent changed too many files and you do not know when it went wrong
30
+ - the model burned credits without making progress
31
+ - a dangerous command almost ran
32
+ - a failure happened 8 steps after the actual mistake
33
+ - you want to compare a good run with a bad one
81
34
 
82
- ```bash
83
- git clone https://github.com/MLaminekane/hawkeye.git
84
- cd hawkeye
85
- pnpm install && pnpm build
86
- cd packages/cli && npm link
87
- ```
35
+ Hawkeye is built for that exact moment.
88
36
 
89
- ## Quick Start
37
+ It gives you:
90
38
 
91
- ```bash
92
- # Initialize in your project
93
- hawkeye init
94
-
95
- # Record an agent session
96
- hawkeye record -o "Build a REST API" -- claude chat
39
+ - session recording with cost, token, and action tracking
40
+ - drift detection during the run
41
+ - guardrails and policy enforcement
42
+ - root-cause analysis after failures
43
+ - replay, comparison, exports, and dashboard visibility
44
+ - background automation through daemon, tasks, and MCP
97
45
 
98
- # Or launch the interactive TUI
99
- hawkeye
100
- ```
46
+ If you want the full product overview and repo-level architecture, see the root README. This file stays focused on the CLI package and how to get value from it quickly.
101
47
 
102
- ## Features
48
+ ## Install
103
49
 
104
- ### Session Recording
105
-
106
- Wrap any LLM-powered agent with `hawkeye record` to capture everything:
50
+ ### npm
107
51
 
108
52
  ```bash
109
- hawkeye record -o "Refactor auth module" -- claude chat
110
- hawkeye record -o "Fix bug #42" --agent cursor -- cursor .
111
- hawkeye record -o "Deploy to staging" --no-drift -- node deploy.js
53
+ npm install -g hawkeye-ai
112
54
  ```
113
55
 
114
- Hawkeye automatically detects the agent (Claude Code, Aider, AutoGPT, CrewAI, Open Interpreter) and intercepts:
115
-
116
- | Interceptor | What it captures |
117
- | -------------- | ------------------------------------------------------ |
118
- | **Terminal** | Commands executed, exit codes, stdout/stderr |
119
- | **Filesystem** | File reads, writes, deletes, renames |
120
- | **Network** | HTTP requests, LLM API calls with token counts & costs |
121
-
122
- ### Claude Code Hooks
123
-
124
- For agents with bundled Node.js runtimes (where `NODE_OPTIONS` injection doesn't work), Hawkeye integrates via **Claude Code hooks**:
56
+ ### npx
125
57
 
126
58
  ```bash
127
- hawkeye hooks install # Install PreToolUse + PostToolUse hooks
128
- hawkeye hooks install --guardrails-only # Only install guardrail enforcement
129
- hawkeye hooks status # Check installation
130
- hawkeye hooks uninstall # Remove hooks
131
- ```
132
-
133
- Hooks provide:
134
-
135
- - **PreToolUse** — Guardrails enforcement (exit code 2 blocks the action)
136
- - **PostToolUse** — Event recording to SQLite
137
- - **Stop** — Drift score update (fires after every response, does not end session)
138
- - Sessions auto-created per `session_id`
139
-
140
- ### Interactive TUI
141
-
142
- Launch the interactive mode by running `hawkeye` with no subcommand:
143
-
59
+ npx hawkeye-ai
144
60
  ```
145
- ██╗ ██╗
146
- ██║ ██║
147
- ███████║ Hawkeye v0.1.0
148
- ██╔══██║ The flight recorder for AI agents
149
- ██║ ██║ /Users/you/project
150
- ╚═╝ ╚═╝
151
61
 
152
- Recording: "Build REST API" (5m 23s)
62
+ ### Homebrew
153
63
 
154
- › /
64
+ ```bash
65
+ brew install MLaminekane/hawkeye/hawkeye-ai
155
66
  ```
156
67
 
157
- Type `/` to open the command picker with arrow-key navigation and live filtering:
158
-
159
- | Command | Description |
160
- | ---------------- | ------------------------------------------------ |
161
- | `/active` | Show current recording |
162
- | `/analyze` | Root cause analysis — find why a session failed |
163
- | `/approve` | Approve pending review gate actions |
164
- | `/attach` | Launch agent on active session |
165
- | `/autocorrect` | Autonomous control — auto-correct agent behavior |
166
- | `/clear` | Clear screen |
167
- | `/compare` | Compare sessions side by side |
168
- | `/delete` | Delete a session |
169
- | `/end` | End active sessions |
170
- | `/export` | Export session as JSON |
171
- | `/firewall` | Show recent interceptions & impact previews |
172
- | `/init` | Initialize Hawkeye |
173
- | `/inspect` | Detailed session inspection |
174
- | `/kill` | Kill hawkeye background processes |
175
- | `/mcp` | Show MCP server setup instructions |
176
- | `/memory` | Memory diff — agent memory across sessions |
177
- | `/new` | New session (pick agent + objective) |
178
- | `/overnight` | Run overnight mode (guardrails + morning report) |
179
- | `/policy` | Manage security policies (init/check/show) |
180
- | `/purge` | Delete ALL sessions (including old) |
181
- | `/quit` | Exit |
182
- | `/remote` | Launch serve + daemon + Cloudflare tunnel |
183
- | `/remote stop` | Stop tunnel + daemon |
184
- | `/replay` | Replay a session (interactive) |
185
- | `/report` | Generate morning report |
186
- | `/restart` | Restart a session |
187
- | `/revert` | Revert file changes from a session |
188
- | `/serve` | Open dashboard on :4242 |
189
- | `/sessions` | List & manage sessions |
190
- | `/settings` | Configure DriftDetect, Guardrails, API keys |
191
- | `/stats` | Session or global statistics |
192
- | `/swarm` | Multi-agent orchestration — list/show/init swarms |
193
- | `/tasks` | List & submit remote tasks |
194
- | `/watch` | Live event stream (tail -f style) |
195
-
196
- ## CLI Commands
197
-
198
- ### `hawkeye analyze <session-id>`
68
+ ### From source
199
69
 
200
70
  ```bash
201
- hawkeye analyze <session-id> # Heuristic root cause analysis
202
- hawkeye analyze <session-id> --llm # Enhanced with LLM analysis
203
- hawkeye analyze <session-id> --json # Machine-readable output
71
+ git clone https://github.com/MLaminekane/hawkeye.git
72
+ cd hawkeye
73
+ pnpm install
74
+ pnpm build
75
+ cd packages/cli
76
+ npm link
204
77
  ```
205
78
 
206
- Automatic root cause analysis: identifies the primary error, builds the causal chain, detects error patterns, analyzes drift trajectory, and generates fix suggestions.
207
-
208
- ### `hawkeye approve`
209
-
210
- Approve pending review gate actions from the CLI.
79
+ ## Quick Start
211
80
 
212
- ### `hawkeye autocorrect`
81
+ Try it in under a minute:
213
82
 
214
83
  ```bash
215
- hawkeye autocorrect enable [--dry-run] # Enable autonomous correction
216
- hawkeye autocorrect disable # Disable autocorrect
217
- hawkeye autocorrect status # Show current status and config
218
- hawkeye autocorrect history # View past corrections
84
+ hawkeye init
85
+ hawkeye record -o "Review this repo and suggest improvements" -- claude
86
+ hawkeye serve
219
87
  ```
220
88
 
221
- Autonomous control layer — Hawkeye doesn't just observe, it autonomously corrects agent behavior when drift, errors, or cost issues are detected. Actions include file rollback, session pause, hint injection to MCP-aware agents, and pattern blocking.
89
+ Then open `http://localhost:4242`.
222
90
 
223
- ### `hawkeye compare <id1> <id2>`
91
+ You will immediately get:
92
+
93
+ - the recorded session timeline
94
+ - files touched
95
+ - drift and cost tracking
96
+ - session stats and replay tools
97
+
98
+ If you mainly use Claude Code, install hooks once and Hawkeye can capture Claude Code sessions automatically:
224
99
 
225
100
  ```bash
226
- hawkeye compare <session1> <session2>
101
+ hawkeye hooks install
227
102
  ```
228
103
 
229
- Compare two sessions side by side — stats, drift, cost, tokens, and actions.
230
-
231
- ### `hawkeye daemon`
104
+ If you prefer the terminal-first workflow, open the built-in TUI:
232
105
 
233
106
  ```bash
234
- hawkeye daemon [--agent claude] [--interval 30]
107
+ hawkeye
235
108
  ```
236
109
 
237
- Run the task daemon polls `.hawkeye/tasks.json` for pending tasks and executes them. Features:
110
+ ## The First 3 Workflows To Try
238
111
 
239
- - **Persistent memory**: writes a task journal (`.hawkeye/task-journal.md`) after each task
240
- - **Conversation continuity**: uses `claude --continue` within 30-min windows
241
- - **Context injection**: enriches prompts with git status, recent commits, and task history
242
- - Works with any agent CLI, not just Claude
112
+ ### 1. Record a session
243
113
 
244
- ### `hawkeye end`
114
+ Wrap any agent command with `hawkeye record`:
245
115
 
246
116
  ```bash
247
- hawkeye end [-s <session-id>] [--all] [--status completed|aborted]
117
+ hawkeye record -o "Fix flaky tests" -- codex
118
+ hawkeye record -o "Review recent changes" -- claude
119
+ hawkeye record -o "Investigate bug 142" -- node ./scripts/agent.js
248
120
  ```
249
121
 
250
- ### `hawkeye export`
122
+ This is the fastest way to understand Hawkeye. One command gives you:
251
123
 
252
- ```bash
253
- hawkeye export <session-id> [-f json|html] [-o report.html]
254
- ```
124
+ - terminal commands and exit codes
125
+ - file reads and writes
126
+ - LLM calls, token usage, and cost
127
+ - drift updates
128
+ - guardrail violations
255
129
 
256
- ### `hawkeye hooks`
130
+ ### 2. Open the dashboard
257
131
 
258
132
  ```bash
259
- hawkeye hooks install [--local] [--guardrails-only]
260
- hawkeye hooks uninstall [--local]
261
- hawkeye hooks status
133
+ hawkeye serve
262
134
  ```
263
135
 
264
- ### `hawkeye init`
136
+ The dashboard is where Hawkeye clicks for most people:
265
137
 
266
- Initialize Hawkeye in the current directory. Creates `.hawkeye/` directory and config files.
138
+ - sessions list
139
+ - session detail and replay
140
+ - compare view
141
+ - firewall
142
+ - tasks
143
+ - agents control room
267
144
 
268
- ### `hawkeye inspect <session-id>`
145
+ It is the easiest way to feel the product value fast.
269
146
 
270
- Detailed session inspection shows events, cost per file, drift snapshots, and guardrail violations.
147
+ ### 3. Inspect a real session
271
148
 
272
- ### `hawkeye mcp`
273
-
274
- Start the MCP (Model Context Protocol) server over stdio. Agents connect automatically.
149
+ Once you have one recorded run, try:
275
150
 
276
151
  ```bash
277
- hawkeye mcp [--db <path>]
152
+ hawkeye sessions
153
+ hawkeye inspect <session-id>
154
+ hawkeye analyze <session-id>
155
+ hawkeye replay <session-id>
278
156
  ```
279
157
 
280
- ### `hawkeye memory`
158
+ That is usually the moment where Hawkeye stops feeling like “extra logging” and starts feeling like a debugger for agent behavior.
281
159
 
282
- ```bash
283
- hawkeye memory [session] # Extract memories from a session
284
- hawkeye memory diff <s1> <s2> # Compare what agent remembers between sessions
285
- hawkeye memory cumulative # Aggregate knowledge across all sessions
286
- hawkeye memory hallucinations # Detect contradictions and recurring errors
287
- ```
160
+ ## Core Workflows
288
161
 
289
- Cross-session agent memory tracking. Extracts structured knowledge (file patterns, error lessons, tool patterns, decisions) from session events, compares what agents learned/forgot across sessions, and detects hallucinations.
162
+ ### Claude Code hooks
290
163
 
291
- ### `hawkeye otel-export`
164
+ For Claude Code, Hawkeye integrates through hooks instead of `NODE_OPTIONS` injection:
292
165
 
293
166
  ```bash
294
- hawkeye otel-export <session-id> [-o traces.json]
295
- hawkeye otel-export <session-id> --endpoint https://tempo.example.com/v1/traces
296
- ```
297
-
298
- Export as OTLP JSON traces. Compatible with Grafana Tempo, Jaeger, Datadog, Honeycomb.
299
-
300
- ### `hawkeye overnight`
301
-
302
- ```bash
303
- hawkeye overnight [--budget 5] [--agent claude] [--task "prompt"] [--tunnel] [--port 4242] [--report-llm]
167
+ hawkeye hooks install
168
+ hawkeye hooks install --guardrails-only
169
+ hawkeye hooks status
170
+ hawkeye hooks uninstall
304
171
  ```
305
172
 
306
- Run overnight mode — composes serve + daemon with strict guardrails for unattended agent runs:
173
+ Hooks enable:
307
174
 
308
- - **Auto-applies guardrails**: cost limit (from `--budget`), file protection for secrets, command blocking, auto-pause on critical drift
309
- - **Backs up config** before modifying and restores on shutdown
310
- - **Optional tunnel**: `--tunnel` starts a Cloudflare tunnel for remote monitoring
311
- - **Optional task**: `--task "..."` queues an initial task for the daemon
312
- - **Morning report on Ctrl+C**: generates consolidated report of all sessions, fires `overnight_report` webhook
175
+ - synchronous guardrail enforcement before tool use
176
+ - event capture after tool use
177
+ - automatic session creation for Claude Code sessions
313
178
 
314
- | Option | Description | Default |
315
- | --------------- | ----------------------------------------- | -------- |
316
- | `--budget` | Maximum cost budget in USD | `5` |
317
- | `--agent` | Agent CLI command | `claude` |
318
- | `--task` | Submit initial task to daemon queue | |
319
- | `--tunnel` | Enable Cloudflare tunnel for remote access| |
320
- | `--port` | Dashboard port | `4242` |
321
- | `--report-llm` | Run LLM post-mortem per session on shutdown| |
179
+ ### Inspect what happened
322
180
 
323
- ### `hawkeye policy`
181
+ Common inspection commands:
324
182
 
325
183
  ```bash
326
- hawkeye policy init [--force] # Generate default policies.yml (or convert existing guardrails)
327
- hawkeye policy check # Validate policies.yml
328
- hawkeye policy show # Display current policies
329
- hawkeye policy export [-o file] # Export guardrails as YAML
330
- hawkeye policy import <file> # Import a policies.yml
184
+ hawkeye sessions
185
+ hawkeye stats
186
+ hawkeye inspect <session-id>
187
+ hawkeye analyze <session-id>
188
+ hawkeye compare <id-a> <id-b>
189
+ hawkeye replay <session-id>
331
190
  ```
332
191
 
333
- Declarative security policies in `.hawkeye/policies.yml` — shareable across projects and teams. The hook-handler automatically loads and merges policy rules with config.json guardrails.
334
-
335
- ### `hawkeye record`
192
+ Useful exports:
336
193
 
337
194
  ```bash
338
- hawkeye record -o <objective> [options] -- <command...>
195
+ hawkeye export <session-id> -f json
196
+ hawkeye export <session-id> -f html -o report.html
197
+ hawkeye otel-export <session-id> -o traces.json
339
198
  ```
340
199
 
341
- | Option | Description |
342
- | ----------------- | --------------------------------------- |
343
- | `-o, --objective` | Session objective **(required)** |
344
- | `-a, --agent` | Agent name (auto-detected from command) |
345
- | `-m, --model` | Model name |
346
- | `--no-drift` | Disable DriftDetect |
347
- | `--no-guardrails` | Disable guardrails |
348
-
349
- ### `hawkeye replay <session-id>`
200
+ ### Run the dashboard and automation
350
201
 
351
202
  ```bash
352
- hawkeye replay <session-id> [--speed 2] [--no-delay]
203
+ hawkeye serve
204
+ hawkeye daemon
205
+ hawkeye overnight --budget 5 --task "review the repo"
353
206
  ```
354
207
 
355
- Replay a session action-by-action with timing.
208
+ This is the setup to use if you want:
356
209
 
357
- ### `hawkeye report`
210
+ - remote task submission
211
+ - persistent task execution
212
+ - unattended guarded runs
213
+ - dashboard visibility while agents work
358
214
 
359
- ```bash
360
- hawkeye report [--since <iso>] [--json] [--llm] [--webhook]
361
- ```
215
+ ### Connect agents through MCP
362
216
 
363
- Generate a morning report of recent sessions. Aggregates stats, drift, errors, and cost per session.
364
-
365
- | Option | Description | Default |
366
- | ----------- | -------------------------------------------------------------- | ------------------------------------ |
367
- | `--since` | Report on sessions since this ISO timestamp | `overnight.json` startedAt or 8h ago |
368
- | `--json` | Output as JSON | |
369
- | `--llm` | Include LLM-powered post-mortem per session | |
370
- | `--webhook` | Fire `overnight_report` webhook with the report | |
217
+ ```bash
218
+ hawkeye mcp
219
+ ```
220
+
221
+ The MCP server exposes Hawkeye tools for session introspection, drift checks, memory analysis, and corrective workflows.
222
+
223
+ ## Command Guide
224
+
225
+ ### Main commands
226
+
227
+ | Command | Purpose |
228
+ | --- | --- |
229
+ | `hawkeye init` | Initialize `.hawkeye/` in the current project |
230
+ | `hawkeye record` | Record an agent session |
231
+ | `hawkeye hooks` | Install or manage Claude Code hooks |
232
+ | `hawkeye serve` | Start the dashboard |
233
+ | `hawkeye daemon` | Run the task daemon |
234
+ | `hawkeye mcp` | Start the MCP server |
235
+ | `hawkeye sessions` | List recorded sessions |
236
+ | `hawkeye inspect` | Show detailed session data |
237
+ | `hawkeye analyze` | Run root-cause analysis |
238
+ | `hawkeye compare` | Compare two or more sessions |
239
+ | `hawkeye replay` | Replay a session timeline |
240
+ | `hawkeye report` | Generate a recent session report |
241
+ | `hawkeye export` | Export a session report |
242
+ | `hawkeye policy` | Manage `.hawkeye/policies.yml` |
243
+ | `hawkeye autocorrect` | Configure autonomous correction |
244
+ | `hawkeye memory` | Compare or aggregate agent memory |
245
+ | `hawkeye ci` | Post a session report to GitHub PRs |
246
+ | `hawkeye overnight` | Run guarded unattended workflows |
247
+ | `hawkeye swarm` | Run multi-agent orchestration |
248
+ | `hawkeye restart` | Restart a session with inherited context |
249
+ | `hawkeye revert` | Revert file changes from a session |
250
+ | `hawkeye approve` | Approve pending review-gate actions |
251
+ | `hawkeye end` | End active recording sessions |
252
+ | `hawkeye stats` | Show stats for one session or globally |
253
+
254
+ ### Interactive mode
255
+
256
+ Running `hawkeye` with no subcommand opens the terminal UI.
257
+
258
+ That mode is great if you want Hawkeye to feel more like a daily control surface than a long list of commands. It is the fastest way to:
259
+
260
+ - start a new session
261
+ - browse sessions
262
+ - launch the dashboard
263
+ - inspect stats
264
+ - manage settings and policies
265
+
266
+ ## Key Commands
371
267
 
372
- ### `hawkeye restart`
268
+ ### `hawkeye record`
373
269
 
374
270
  ```bash
375
- hawkeye restart [session-id] [-o <objective>] [-a <agent>] [-m <model>]
271
+ hawkeye record -o <objective> [options] -- <command...>
376
272
  ```
377
273
 
378
- Restart a session — inherits objective, agent, and model from the original if not overridden. Interactive picker when no ID is given.
274
+ Common options:
379
275
 
380
- ### `hawkeye revert`
276
+ | Option | Meaning |
277
+ | --- | --- |
278
+ | `-o, --objective` | Required session objective |
279
+ | `-a, --agent` | Override agent name |
280
+ | `-m, --model` | Override model name |
281
+ | `--no-drift` | Disable DriftDetect |
282
+ | `--no-guardrails` | Disable guardrails |
381
283
 
382
- ```bash
383
- hawkeye revert <session-id> <file-path>
384
- ```
284
+ Good use cases:
385
285
 
386
- Revert a file to its pre-session state using git.
286
+ - wrap a single risky run
287
+ - compare two agent strategies on the same task
288
+ - capture a bug reproduction or failed refactor
289
+ - audit what an agent actually did
387
290
 
388
291
  ### `hawkeye serve`
389
292
 
@@ -391,496 +294,133 @@ Revert a file to its pre-session state using git.
391
294
  hawkeye serve [-p 4242]
392
295
  ```
393
296
 
394
- Launch the web dashboard on `http://localhost:4242`. Auto-reloads after `pnpm build` — watches `dist/` and restarts the server when compiled files change.
297
+ Starts the dashboard locally, usually at `http://localhost:4242`.
395
298
 
396
- ### `hawkeye sessions`
299
+ Use this when you want visual monitoring, replay, compare, firewall, tasks, or agent orchestration.
300
+
301
+ ### `hawkeye daemon`
397
302
 
398
303
  ```bash
399
- hawkeye sessions [-n 10] [-s recording|completed|aborted]
304
+ hawkeye daemon [--agent claude] [--interval 30]
400
305
  ```
401
306
 
402
- ### `hawkeye stats <session-id>`
307
+ Runs the background task worker that processes queued dashboard tasks and maintains task memory.
403
308
 
404
- Display statistics for a session (accepts ID prefix).
309
+ Use this if you want Hawkeye to keep working even when the dashboard tab is closed.
405
310
 
406
- ### `hawkeye swarm`
311
+ ### `hawkeye mcp`
407
312
 
408
313
  ```bash
409
- hawkeye swarm <config.json> # Run multi-agent orchestration from config
410
- hawkeye swarm init # Generate a template swarm config
411
- hawkeye swarm list # List past swarm runs
314
+ hawkeye mcp [--db <path>]
412
315
  ```
413
316
 
414
- Coordinate multiple AI agents on parallel tasks. Each agent gets an isolated git worktree with enforced scope boundaries. Features dependency ordering (topological sort), file conflict detection, sequential/octopus merge strategies, and live terminal progress.
317
+ Starts the Hawkeye MCP server over stdio.
415
318
 
416
- Add to `.mcp.json` at project root for Claude Code:
319
+ Use this when you want agents to query Hawkeye directly for session stats, drift, memory, or historical context.
320
+
321
+ Example `.mcp.json`:
417
322
 
418
323
  ```json
419
324
  {
420
325
  "mcpServers": {
421
326
  "hawkeye": {
422
- "command": "node",
423
- "args": ["path/to/hawkeye/packages/cli/dist/index.js", "mcp"]
327
+ "command": "hawkeye",
328
+ "args": ["mcp"]
424
329
  }
425
330
  }
426
331
  }
427
332
  ```
428
333
 
429
- **38 tools** for agent self-awareness, intelligence, and control:
430
-
431
- | Category | Tools |
432
- |----------|-------|
433
- | **Observability** (9) | `list_sessions`, `get_session`, `get_session_events`, `get_session_drift`, `get_session_stats`, `get_global_stats`, `compare_sessions`, `get_violations`, `get_cost_by_file` |
434
- | **Self-awareness** (8) | `check_drift`, `get_objective`, `check_cost`, `check_guardrail`, `check_progress`, `log_event`, `list_changes`, `get_config` |
435
- | **Intelligence** (8) | `get_session_timeline`, `get_error_summary`, `suggest_correction`, `analyze_root_cause`, `post_mortem`, `memory_diff`, `check_memory`, `auto_correct` |
436
- | **Actions** (5) | `end_session`, `pause_session`, `resume_session`, `set_objective`, `get_correction` |
437
- | **Cross-session** (2) | `search_events`, `revert_file` |
438
- | **Swarm** (3) | `list_swarms`, `get_swarm`, `get_swarm_agent` |
439
-
440
- ## Dashboard
441
-
442
- The web dashboard (`hawkeye serve`) is fully **mobile responsive** and provides:
443
-
444
- ### Sessions Page
445
-
446
- - List all sessions with status filtering (recording / completed / aborted)
447
- - Search by objective or agent name
448
- - Auto-refresh every 5 seconds, module-level cache (no flash on page change)
449
- - Shows costs, drift scores, action counts
450
-
451
- ### Session Detail Page
452
-
453
- - **Time Travel Debugger** — Interactive SVG timeline with step-through, breakpoints, keyboard shortcuts, and session forking
454
- - **Drift score chart** — Line chart with warning/critical reference zones
455
- - **Event timeline** — Filterable, searchable list with type badges (CMD, FILE, LLM, GUARD, etc.)
456
- - **Expandable details** — Full event payload for each action, auto-expands during step-through
457
- - **Live mode** — Auto-refreshes every 3 seconds for active sessions
458
- - **Export** — Download session as JSON
459
-
460
- ### Tasks Page (Remote)
461
-
462
- - Submit prompts remotely from your phone
463
- - **Image attachments** — Upload photos to include with prompts
464
- - **Auto-approve toggle** — Automatically approve all guardrail-blocked actions
465
- - **Approve/Deny buttons** — Manually review dangerous actions
466
- - **Agent memory** — View/clear the persistent task journal
467
- - Status tracking: pending, running, completed, failed
468
-
469
- ### Agents Control Room
470
-
471
- - **Spawn agents** directly from the dashboard — choose agent CLI (claude, aider, codex), assign role (lead/worker/reviewer), set permissions (full access/supervised/default), add personality
472
- - **Live monitoring** — Real-time output streaming, session linking with drift/cost/action stats, follow-up messages
473
- - **Permission levels** — Full access (skip confirmation prompts), supervised (Hawkeye guardrails enforce limits), default (agent runtime defaults)
474
- - **Persistent agents** — Agents survive server restarts via file-backed persistence (`.hawkeye/agents.json`)
475
- - **Session integration** — Each spawned agent is automatically linked to its Hawkeye session for full observability
476
-
477
- ### Compare Page
478
-
479
- - Select two sessions to compare side by side
480
- - Stats comparison (actions, cost, tokens, drift)
481
-
482
- ### Memory Page
483
-
484
- - **Cumulative Memory** — Aggregate knowledge across all sessions (file patterns, error lessons, tool patterns, decisions)
485
- - **Memory Diff** — Compare what an agent remembered between two sessions (learned, forgotten, retained, evolved, contradicted)
486
- - **Hallucination Detection** — Cross-session analysis for recurring errors and contradicted facts
487
-
488
- ### Swarm Page
489
-
490
- - List and detail view of multi-agent orchestration runs
491
- - Agent cards with scope display, files changed, merge status
492
- - Conflict visualization between agents
493
- - Real-time WebSocket updates during execution
494
-
495
- ### Firewall Page
496
-
497
- - **Live action stream** — Every agent action in real-time with risk classification
498
- - **Filters** — All / Risky Only / Blocked / Writes / Commands
499
- - **Browser notifications** — Push alerts when actions are blocked or critical
500
- - **Navbar badge** — Red counter for high/critical actions
501
-
502
- ### Settings Page
503
-
504
- - Configure DriftDetect (provider, model, thresholds, check frequency)
505
- - Manage guardrail rules (enable/disable, toggle warn/block)
506
- - **Policy Engine** — Initialize, edit, and manage `.hawkeye/policies.yml` with full CRUD for rules
507
- - Provider model selection with live lookup
508
-
509
- ### REST API
510
-
511
- | Endpoint | Method | Description |
512
- | --------------------------------- | ------ | -------------------------------- |
513
- | `/api/sessions` | GET | List sessions |
514
- | `/api/sessions/:id` | GET | Session details |
515
- | `/api/sessions/:id/events` | GET | Session events |
516
- | `/api/sessions/:id/drift` | GET | Drift snapshots |
517
- | `/api/sessions/:id/cost-by-file` | GET | Cost breakdown by file |
518
- | `/api/sessions/:id/end` | POST | End a session |
519
- | `/api/sessions/:id/pause` | POST | Pause a session |
520
- | `/api/sessions/:id/resume` | POST | Resume a paused session |
521
- | `/api/sessions/:id/fork` | POST | Fork session up to event N |
522
- | `/api/sessions/:id/analyze` | GET | Root cause analysis |
523
- | `/api/compare?ids=id1,id2` | GET | Compare sessions side by side |
524
- | `/api/stats` | GET | Global statistics |
525
- | `/api/settings` | GET | Get configuration |
526
- | `/api/settings` | POST | Save configuration (Zod-validated) |
527
- | `/api/providers` | GET | Available LLM providers & models |
528
- | `/api/ingest` | POST | Universal event ingestion (Zod-validated) |
529
- | `/api/revert` | POST | Revert a file change |
530
- | `/api/tasks` | GET | List remote tasks |
531
- | `/api/tasks` | POST | Create a task (with attachments) |
532
- | `/api/tasks/:id/cancel` | POST | Cancel a pending task |
533
- | `/api/tasks/journal` | GET | Read agent memory journal |
534
- | `/api/tasks/journal/clear` | POST | Clear agent memory |
535
- | `/api/tasks/attachments/:file` | GET | Serve task image attachments |
536
- | `/api/pending-reviews` | GET | List pending review gate items |
537
- | `/api/review-approve` | POST | Approve a review gate item |
538
- | `/api/review-deny` | POST | Deny a review gate item |
539
- | `/api/policies` | GET | Get current policies.yml |
540
- | `/api/policies` | POST | Save policies (server-validated) |
541
- | `/api/impact` | GET | Last impact preview |
542
- | `/api/interceptions` | GET | Recent blocks + pending reviews |
543
- | `/api/sessions/:id/memory` | GET | Session memory items |
544
- | `/api/sessions/:id/corrections` | GET | Session autocorrect history |
545
- | `/api/memory/diff?a=X&b=Y` | GET | Memory diff between sessions |
546
- | `/api/memory/cumulative` | GET | Cumulative memory across sessions|
547
- | `/api/memory/hallucinations` | GET | Cross-session hallucination check|
548
- | `/api/corrections` | GET | All corrections across sessions |
549
- | `/api/active-correction` | GET | Current active correction hint |
550
- | `/api/autocorrect` | POST | Trigger/configure autocorrect |
551
- | `/api/agents` | GET | List live agents |
552
- | `/api/agents/spawn` | POST | Spawn a new agent |
553
- | `/api/agents/:id` | GET | Get agent details |
554
- | `/api/agents/:id/stop` | POST | Stop a running agent |
555
- | `/api/agents/:id/remove` | POST | Remove an agent |
556
- | `/api/agents/:id/message` | POST | Send follow-up message to agent |
557
- | `/api/agents/:id/events` | GET | Get agent's session events |
558
- | `/api/swarms` | GET | List swarm runs |
559
- | `/api/swarms/:id` | GET | Swarm details |
560
- | `/api/swarms/:id/agents` | GET | Swarm agent details |
561
- | `/api/swarms/:id/conflicts` | GET | Swarm file conflicts |
562
-
563
- ## DriftDetect
564
-
565
- DriftDetect monitors agent behavior in real-time and assigns a **drift score** (0–100):
566
-
567
- | Score | Status | Meaning |
568
- | ------ | ----------- | --------------------------------- |
569
- | 70–100 | ✅ OK | Agent is on track |
570
- | 40–69 | ⚠️ Warning | Possible deviation from objective |
571
- | 0–39 | 🔴 Critical | Significant drift detected |
572
-
573
- ### Scoring Engines
574
-
575
- **Heuristic scorer** (always active, zero-cost):
576
-
577
- - Penalizes dangerous commands (`rm -rf`, `DROP TABLE`, `curl | bash`)
578
- - Flags suspicious paths (`/etc`, `~/.ssh`, `/root`)
579
- - Detects sensitive file extensions (`.pem`, `.key`, `.env`)
580
- - Monitors error rates
581
-
582
- **LLM scorer** (optional, configurable):
583
-
584
- - Evaluates actions against the stated objective using an LLM
585
- - Supports 6 providers:
586
-
587
- | Provider | Models |
588
- | --------- | ---------------------------------------------------------------------------------------------------- |
589
- | Ollama | llama4, llama3.2, mistral, codellama, deepseek-coder, phi3 |
590
- | Anthropic | claude-sonnet-4-6, claude-opus-4-6, claude-haiku-4-5, claude-sonnet-4-5, claude-opus-4-5 |
591
- | OpenAI | gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-5, gpt-5-mini, o3, o3-mini, o4-mini |
592
- | DeepSeek | deepseek-chat, deepseek-reasoner |
593
- | Mistral | mistral-large-latest, mistral-medium-latest, mistral-small-latest, codestral-latest, devstral-latest |
594
- | Google | gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash |
595
-
596
- ## Guardrails
597
-
598
- Guardrails are evaluated **synchronously before** events are persisted. Violations can `warn` (log only) or `block` (prevent the action).
599
-
600
- | Rule Type | Description | Config |
601
- | ----------------- | -------------------------------------- | ------------------------------------- |
602
- | `file_protect` | Protect files/dirs from modification | `paths: string[]` (glob patterns) |
603
- | `command_block` | Block dangerous commands | `patterns: string[]` (regex patterns) |
604
- | `cost_limit` | Limit spending per session/hour | `maxUsdPerSession`, `maxUsdPerHour` |
605
- | `token_limit` | Limit token consumption | `maxTokensPerSession` |
606
- | `directory_scope` | Restrict agent to specific directories | `allowedDirs`, `blockedDirs` |
607
- | `network_lock` | Allow/block specific API hostnames | `allowedHosts`, `blockedHosts` |
608
- | `review_gate` | Require human approval for commands | `patterns: string[]` (regex patterns) |
609
- | `impact_threshold`| Block actions above a risk level | `blockAbove`, `warnAbove` (low/medium/high/critical) |
610
-
611
- ### Time Travel Debugging
612
-
613
- The dashboard session replay is a full debugger for AI agent sessions:
614
-
615
- - **Step-through controls** — Step forward/back one event at a time, play/pause with speed controls (1x–10x)
616
- - **Breakpoints** — Click events on the interactive SVG timeline or press `B` to toggle breakpoints; playback pauses automatically at breakpoints
617
- - **Interactive timeline** — Color-coded dots by event type, drift score overlay, right-click context menu
618
- - **Session forking** — "Fork from here" creates a new session from any point in time, copying all events, drift snapshots, and guardrail violations up to that point
619
- - **Keyboard shortcuts** — `←`/`→` step through, `Space` play/pause, `B` toggle breakpoint
620
- - **Auto-expand** — Current event details expand automatically during step-through
621
-
622
- ### Root Cause Analysis
623
-
624
- After a session fails, run `hawkeye analyze <session>` (or click "Analyze" in the dashboard) to get:
625
-
626
- - **Primary error** — The main failure event with context
627
- - **Causal chain** — Backwards trace: which file edits and LLM decisions led to the error
628
- - **Error patterns** — Repeated failures grouped and counted (e.g., "tsc failed 5x")
629
- - **Drift analysis** — Score trend, inflection point, and what triggered the drift
630
- - **Suggestions** — Actionable fix recommendations based on detected patterns
631
- - **LLM enhancement** — Add `--llm` for deeper natural language analysis
334
+ ### `hawkeye policy`
632
335
 
336
+ ```bash
337
+ hawkeye policy init
338
+ hawkeye policy check
339
+ hawkeye policy show
340
+ hawkeye policy export
341
+ hawkeye policy import <file>
633
342
  ```
634
- $ hawkeye analyze abc123
635
343
 
636
- ─── Root Cause Analysis ─── session abc12345
344
+ Use this when you want declarative, shareable guardrail rules in `.hawkeye/policies.yml`.
637
345
 
638
- FAILURE confidence: high
346
+ ## Who this is for
639
347
 
640
- SUMMARY
641
- Session failed due to repeated TypeScript compilation errors
348
+ Hawkeye is a strong fit if you:
642
349
 
643
- PRIMARY ERROR (event #47)
644
- tsc --noEmit exit 1
645
- at 14:23:05 command
350
+ - run AI coding agents on real repos
351
+ - care about cost visibility
352
+ - want safer automation
353
+ - need post-mortems when runs go wrong
354
+ - want a shared observability layer across multiple agent runtimes
646
355
 
647
- CAUSAL CHAIN
648
- #12 ◇ LLM anthropic/claude-3.5-sonnet
649
- #15 ● FILE Modified src/middleware.ts
650
- #23 ○ CMD tsc --noEmit → exit 1
356
+ It is especially useful once you move beyond toy prompts and start trusting agents with actual code, CI, secrets, or long-running tasks.
651
357
 
652
- SUGGESTIONS
653
- 1. TypeScript compilation failed 5 times — fix type errors
654
- 2. Agent made multiple unsuccessful attempts
655
- ```
358
+ ### `hawkeye overnight`
656
359
 
657
- ### Impact Preview
658
-
659
- Every agent action is analyzed **before execution** via the Impact Preview engine:
660
-
661
- - Computes risk level (low/medium/high/critical) based on command patterns, file sensitivity, git status
662
- - Shows affected files, lines, and git tracking status in the terminal
663
- - Blocks critical-risk actions automatically (configurable via `impact_threshold` policy rule)
664
- - Dashboard Firewall page shows all actions in real-time with browser push notifications
665
-
666
- ### Policy Engine
667
-
668
- Declarative policies in `.hawkeye/policies.yml` are shareable, version-controllable, and team-wide:
669
-
670
- ```yaml
671
- version: "1"
672
- name: my-project
673
- rules:
674
- - name: protect-secrets
675
- type: file_protect
676
- enabled: true
677
- action: block
678
- config:
679
- paths: [".env", "*.pem", "*.key"]
680
- - name: block-high-impact
681
- type: impact_threshold
682
- enabled: true
683
- action: block
684
- config:
685
- blockAbove: critical
686
- warnAbove: high
360
+ ```bash
361
+ hawkeye overnight [--budget 5] [--agent claude] [--task "prompt"] [--tunnel]
687
362
  ```
688
363
 
689
- Manage via `hawkeye policy` CLI, dashboard Settings page, or direct YAML edit.
690
-
691
- ### Autonomous Control Layer (Autocorrect)
692
-
693
- Hawkeye doesn't just observe — it autonomously corrects agent behavior:
694
-
695
- - **Triggers**: critical drift (< 30), declining drift trend, repeated error patterns (configurable, default 3x), cost exceeding budget threshold (85%)
696
- - **Actions**: file rollback (`git checkout -- <file>`), session pause, hint injection to MCP-aware agents, dynamic pattern blocking, webhook notifications
697
- - **Agent integration**: MCP-aware agents (Claude Code, Cursor) receive correction hints via `get_correction` tool with direct `agentInstructions`
698
- - **Dry-run mode**: test corrections without executing them
699
-
700
- ### Memory Diff
701
-
702
- Cross-session agent memory tracking and hallucination detection:
703
-
704
- - **7-phase extraction**: file knowledge, error lessons, corrections, tool patterns, decisions, dependency facts, API knowledge
705
- - **Diff analysis**: learned (new), forgotten (lost), retained, evolved (updated), contradicted (conflicting)
706
- - **Hallucination detection**: recurring errors across sessions, contradicted facts
707
- - **Cumulative memory**: aggregated knowledge across all sessions with deduplication
364
+ Useful for unattended runs with:
708
365
 
709
- ### Multi-agent Orchestration (Swarm)
710
-
711
- Coordinate multiple AI agents on parallel tasks:
712
-
713
- - **Isolated worktrees**: each agent gets its own git worktree — no conflicts during execution
714
- - **Scope enforcement**: include/exclude glob patterns, enforced at prompt-level and validated post-execution
715
- - **Dependency ordering**: topological sort (Kahn's algorithm) for task dependencies
716
- - **Conflict detection**: file overlap detection between agents with severity scoring
717
- - **Merge strategies**: sequential (least-conflict-first) or octopus
718
- - **Config-driven**: JSON config files with agent personas, tasks, scopes, and timeouts
719
-
720
- ### Live Agent Spawning
721
-
722
- Spawn and control AI agents directly from the dashboard:
723
-
724
- - **Role-based creation**: assign roles (lead/worker/reviewer) and custom personality
725
- - **Permission levels**: full access (`--dangerously-skip-permissions`), supervised (Hawkeye guardrails), or default
726
- - **Session linking**: automatic detection and linking to Hawkeye sessions for full observability
727
- - **Live stats**: real-time drift score, cost, action count, and session info via WebSocket
728
- - **Follow-up messages**: send additional prompts to running agents via stdin
729
- - **Persistence**: agents survive server restarts via `.hawkeye/agents.json`
730
-
731
- Example configuration (via `/settings` in TUI or dashboard):
732
-
733
- ```json
734
- {
735
- "guardrails": [
736
- {
737
- "name": "Protect secrets",
738
- "type": "file_protect",
739
- "enabled": true,
740
- "action": "block",
741
- "config": { "paths": ["**/.env", "**/*.key", "**/*.pem"] }
742
- },
743
- {
744
- "name": "No destructive commands",
745
- "type": "command_block",
746
- "enabled": true,
747
- "action": "block",
748
- "config": { "patterns": ["rm\\s+-rf\\s+/", "DROP\\s+TABLE", "curl.*\\|.*bash"] }
749
- },
750
- {
751
- "name": "Budget limit",
752
- "type": "cost_limit",
753
- "enabled": true,
754
- "action": "warn",
755
- "config": { "maxUsdPerSession": 5.0, "maxUsdPerHour": 2.0 }
756
- }
757
- ]
758
- }
759
- ```
366
+ - budget enforcement
367
+ - stricter guardrails
368
+ - optional remote monitoring
369
+ - morning report generation on shutdown
760
370
 
761
371
  ## Configuration
762
372
 
763
- Configuration is stored at `.hawkeye/config.json`:
373
+ Project config lives in:
764
374
 
765
- ```json
766
- {
767
- "drift": {
768
- "enabled": true,
769
- "checkEvery": 5,
770
- "provider": "ollama",
771
- "model": "llama3.2",
772
- "warningThreshold": 60,
773
- "criticalThreshold": 30,
774
- "contextWindow": 10
775
- },
776
- "guardrails": [],
777
- "apiKeys": {
778
- "anthropic": "sk-ant-...",
779
- "openai": "sk-..."
780
- }
781
- }
375
+ ```text
376
+ .hawkeye/config.json
782
377
  ```
783
378
 
784
- Manage settings via:
785
-
786
- - **TUI**: `/settings` command with interactive sub-menus
787
- - **Dashboard**: Settings page at `http://localhost:4242/settings`
788
- - **Direct edit**: `.hawkeye/config.json`
379
+ Typical sections:
789
380
 
790
- ## Security
381
+ - `drift`
382
+ - `guardrails`
383
+ - `apiKeys`
384
+ - provider-specific settings such as LM Studio URL
791
385
 
792
- Hawkeye is designed to run locally. The dashboard server binds to `localhost` and includes multiple security layers:
386
+ You can manage config through:
793
387
 
794
- | Protection | Description |
795
- |---|---|
796
- | **CORS** | Only `localhost` / `127.0.0.1` origins accepted |
797
- | **WebSocket origin check** | Upgrade requests from cross-origin pages are rejected |
798
- | **POST body limit** | 5 MB max — oversized requests are destroyed (prevents DoS) |
799
- | **Path traversal** | Static file serving and attachment endpoints verify resolved paths stay within their root |
800
- | **No command injection** | All git operations use `execFile()` with argument arrays, never shell strings |
801
- | **Config file permissions** | `.hawkeye/config.json` and `policies.yml` written with `0o600` (owner-only) to protect API keys |
802
- | **Policy validation** | `POST /api/policies` validates schema before writing — rejects invalid rules |
803
- | **Impact analysis** | Pre-execution risk scoring blocks critical actions before they run |
804
- | **Concurrent write safety** | Hook handler uses exclusive lockfile for `hook-sessions.json` writes |
388
+ - the TUI
389
+ - the dashboard Settings page
390
+ - direct file edits
805
391
 
806
- ### API Keys
392
+ ## What this package includes
807
393
 
808
- API keys for LLM providers (Anthropic, OpenAI, etc.) are stored in `.hawkeye/config.json`. The file is created with restricted permissions (`0o600`), but you should also add `.hawkeye/` to your global `.gitignore` to avoid accidental commits.
394
+ This package ships:
809
395
 
810
- ## Architecture
396
+ - the `hawkeye` executable
397
+ - the bundled dashboard assets used by `hawkeye serve`
398
+ - the CLI command set and interactive TUI
811
399
 
812
- TypeScript monorepo using **pnpm workspaces** + **Turborepo**:
813
-
814
- ```
815
- packages/
816
- ├── core/ Node.js SDK — recorder, interceptors, storage, DriftDetect, guardrails
817
- ├── cli/ CLI (Commander.js + chalk) — commands, interactive TUI
818
- └── dashboard/ React 19 + Vite + Tailwind CSS + Recharts — web UI
819
- ```
820
-
821
- ### Data Flow
822
-
823
- ```
824
- Agent ──► Interceptors ──► Recorder ──► Guardrails (sync) ──► SQLite
825
-
826
- └──► DriftDetect (async)
827
- ```
828
-
829
- ### Network Interception
830
-
831
- For child processes, Hawkeye injects a preload ESM script via `NODE_OPTIONS="--import ..."` that monkey-patches `http/https.request` and `globalThis.fetch`. It detects LLM API calls by hostname and path, parses SSE streaming responses, and sends captured events back to the parent via Node.js IPC.
832
-
833
- ### Storage
834
-
835
- SQLite via `better-sqlite3` with WAL mode. Nine tables:
836
-
837
- | Table | Purpose |
838
- | ---------------------- | ------------------------------------------------------------- |
839
- | `sessions` | Session metadata (objective, agent, status, timestamps) |
840
- | `events` | Captured events (type, data, timestamps, token counts, costs) |
841
- | `drift_snapshots` | Drift score history per session |
842
- | `guardrail_violations` | Guardrail violation log |
843
- | `memory_items` | Cross-session agent memory (knowledge, patterns, lessons) |
844
- | `corrections` | Autocorrect actions (rollbacks, pauses, hints, blocks) |
845
- | `swarms` | Swarm orchestration run metadata |
846
- | `swarm_agents` | Per-agent state within swarm runs |
847
- | `swarm_conflicts` | File conflicts detected between swarm agents |
400
+ This is the package to install if you want to actually use Hawkeye, not just browse the repo.
848
401
 
849
402
  ## Development
850
403
 
404
+ From the repo root:
405
+
851
406
  ```bash
852
- pnpm install # Install all dependencies
853
- pnpm build # Production build (all packages)
854
- pnpm dev # Dev mode (Turborepo watch)
855
- pnpm test # Run all tests (Vitest)
856
- pnpm --filter @hawkeye/core test # Run only core tests
857
- pnpm --filter @hawkeye/cli build # Build only CLI
407
+ pnpm install
408
+ pnpm build
409
+ pnpm test
410
+ pnpm --filter hawkeye-ai build
411
+ pnpm --filter hawkeye-ai test
858
412
  ```
859
413
 
860
- ### Requirements
861
-
862
- - Node.js ≥ 20
863
- - pnpm 9.x
864
-
865
- ### Tech Stack
866
-
867
- | Package | Stack |
868
- | -------------------- | -------------------------------------- |
869
- | `@hawkeye/core` | TypeScript, better-sqlite3, Vitest |
870
- | `@hawkeye/cli` | TypeScript, Commander.js, chalk v5 |
871
- | `@hawkeye/dashboard` | React 19, Vite, Tailwind CSS, Recharts |
872
-
873
- ### Code Conventions
414
+ Requirements:
874
415
 
875
- - TypeScript strict mode, ES2022 target, ESM modules
876
- - File names in kebab-case
877
- - Named exports only (no default exports except React components)
878
- - `Result<T, E>` pattern for error handling (no throwing in core)
879
- - Prettier: semi, singleQuote, trailingComma: all, printWidth: 100
416
+ - Node.js 20+
417
+ - pnpm 9+
880
418
 
881
- ## Acknowledgments
419
+ ## Notes
882
420
 
883
- Special thanks to **Lamine** for their contributions and support.
421
+ - `packages/cli/README.md` is the package README for `hawkeye-ai`.
422
+ - The root README should stay product-level.
423
+ - This file should stay CLI-focused and avoid duplicating the entire repository handbook.
884
424
 
885
425
  ## License
886
426