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