bashbros 0.1.3 → 0.1.5
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.
- package/README.md +734 -271
- package/dist/adapters-JAZGGNVP.js +9 -0
- package/dist/chunk-25TREQ6V.js +465 -0
- package/dist/chunk-25TREQ6V.js.map +1 -0
- package/dist/{chunk-A535VV7N.js → chunk-2CI2MRKI.js} +23 -6
- package/dist/chunk-2CI2MRKI.js.map +1 -0
- package/dist/chunk-4XZ64P4V.js +47 -0
- package/dist/chunk-4XZ64P4V.js.map +1 -0
- package/dist/chunk-5BBPRDWL.js +186 -0
- package/dist/chunk-5BBPRDWL.js.map +1 -0
- package/dist/{chunk-2RPTM6EQ.js → chunk-6QVMBCSX.js} +719 -902
- package/dist/chunk-6QVMBCSX.js.map +1 -0
- package/dist/{chunk-JYWQT2B4.js → chunk-6SLR5WPD.js} +657 -14
- package/dist/chunk-6SLR5WPD.js.map +1 -0
- package/dist/{chunk-EYO44OMN.js → chunk-AZVT6AZY.js} +78 -17
- package/dist/chunk-AZVT6AZY.js.map +1 -0
- package/dist/{chunk-WPJJZLT6.js → chunk-C4GZNBFF.js} +3 -2
- package/dist/chunk-C4GZNBFF.js.map +1 -0
- package/dist/chunk-IUUBCPMV.js +166 -0
- package/dist/chunk-IUUBCPMV.js.map +1 -0
- package/dist/chunk-J6ONXY6N.js +146 -0
- package/dist/chunk-J6ONXY6N.js.map +1 -0
- package/dist/{chunk-DLP2O6PN.js → chunk-JOIAG54E.js} +83 -88
- package/dist/chunk-JOIAG54E.js.map +1 -0
- package/dist/chunk-LJE4EPIU.js +56 -0
- package/dist/chunk-LJE4EPIU.js.map +1 -0
- package/dist/{chunk-QWZGB4V3.js → chunk-PAZIDRXK.js} +42 -181
- package/dist/chunk-PAZIDRXK.js.map +1 -0
- package/dist/chunk-PLSHJHHR.js +293 -0
- package/dist/chunk-PLSHJHHR.js.map +1 -0
- package/dist/chunk-R5I5DEXE.js +228 -0
- package/dist/chunk-R5I5DEXE.js.map +1 -0
- package/dist/chunk-SDN6TAGD.js +157 -0
- package/dist/chunk-SDN6TAGD.js.map +1 -0
- package/dist/chunk-T5ONCUHZ.js +198 -0
- package/dist/chunk-T5ONCUHZ.js.map +1 -0
- package/dist/cli.js +1204 -188
- package/dist/cli.js.map +1 -1
- package/dist/{config-43SK6SFI.js → config-IXBXMIUA.js} +2 -2
- package/dist/copilot-cli-5WJWK5YT.js +9 -0
- package/dist/{db-SWJUUSFX.js → db-GJALN3R7.js} +2 -2
- package/dist/db-checks-2YOVECD4.js +133 -0
- package/dist/db-checks-2YOVECD4.js.map +1 -0
- package/dist/{display-HFIFXOOL.js → display-UDIACHTP.js} +3 -3
- package/dist/{engine-EGPAS2EX.js → engine-4WNPXVMS.js} +3 -2
- package/dist/gemini-cli-3563EELZ.js +9 -0
- package/dist/gemini-cli-3563EELZ.js.map +1 -0
- package/dist/index.d.ts +205 -101
- package/dist/index.js +132 -402
- package/dist/index.js.map +1 -1
- package/dist/{ollama-HY35OHW4.js → ollama-TNMD5WHW.js} +2 -2
- package/dist/ollama-TNMD5WHW.js.map +1 -0
- package/dist/opencode-DRCY275R.js +9 -0
- package/dist/opencode-DRCY275R.js.map +1 -0
- package/dist/profiles-7CLN6TAT.js +9 -0
- package/dist/profiles-7CLN6TAT.js.map +1 -0
- package/dist/server-3CMTP4W4.js +13 -0
- package/dist/server-3CMTP4W4.js.map +1 -0
- package/dist/setup-U4R5QJMV.js +124 -0
- package/dist/setup-U4R5QJMV.js.map +1 -0
- package/dist/static/index.html +4862 -2007
- package/dist/store-WJ5Y7MOE.js +9 -0
- package/dist/store-WJ5Y7MOE.js.map +1 -0
- package/dist/{writer-4ZEAKUFD.js → writer-OMHUMJR5.js} +3 -3
- package/dist/writer-OMHUMJR5.js.map +1 -0
- package/package.json +78 -68
- package/dist/chunk-2RPTM6EQ.js.map +0 -1
- package/dist/chunk-A535VV7N.js.map +0 -1
- package/dist/chunk-DLP2O6PN.js.map +0 -1
- package/dist/chunk-EYO44OMN.js.map +0 -1
- package/dist/chunk-JYWQT2B4.js.map +0 -1
- package/dist/chunk-QWZGB4V3.js.map +0 -1
- package/dist/chunk-WPJJZLT6.js.map +0 -1
- /package/dist/{config-43SK6SFI.js.map → adapters-JAZGGNVP.js.map} +0 -0
- /package/dist/{db-SWJUUSFX.js.map → config-IXBXMIUA.js.map} +0 -0
- /package/dist/{display-HFIFXOOL.js.map → copilot-cli-5WJWK5YT.js.map} +0 -0
- /package/dist/{engine-EGPAS2EX.js.map → db-GJALN3R7.js.map} +0 -0
- /package/dist/{ollama-HY35OHW4.js.map → display-UDIACHTP.js.map} +0 -0
- /package/dist/{writer-4ZEAKUFD.js.map → engine-4WNPXVMS.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-

|
|
3
3
|
|
|
4
4
|
```
|
|
5
5
|
/____ _ ____
|
|
@@ -7,303 +7,841 @@
|
|
|
7
7
|
/ | _ \ / _` / __| '_ \| _ \| '__/ _ \/ __|
|
|
8
8
|
/ | |_) | (_| \__ \ | | | |_) | | | (_) \__ \
|
|
9
9
|
/ |____/ \__,_|___/_| |_|____/|_| \___/|___/
|
|
10
|
-
|
|
10
|
+
Security middleware + AI sidekick for CLI agents
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
BashBros
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
**BashBros** sits between AI coding agents and your terminal. It intercepts commands, applies security policies, and provides an AI sidekick powered by [Ollama](https://ollama.com). Think of it as a firewall + AI companion for your AI agents.
|
|
14
|
+
|
|
15
|
+
Supports **Claude Code**, **Copilot CLI**, **Gemini CLI**, **OpenCode**, **Aider**, and **Moltbot** out of the box.
|
|
16
|
+
|
|
17
|
+
[Website](https://bashbros.ai) | [GitHub](https://github.com/GhostPeony/bashbros) | [Issues](https://github.com/GhostPeony/bashbros/issues)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Table of Contents
|
|
22
|
+
|
|
23
|
+
- [Installation](#installation)
|
|
24
|
+
- [Quick Start](#quick-start)
|
|
25
|
+
- [Features](#features)
|
|
26
|
+
- [Security Policies](#security-policies)
|
|
27
|
+
- [AI Sidekick (Ollama-powered)](#ai-sidekick-ollama-powered)
|
|
28
|
+
- [Ollama Model Management](#ollama-model-management)
|
|
29
|
+
- [LoRA Adapter Management](#lora-adapter-management)
|
|
30
|
+
- [Model Profiles](#model-profiles)
|
|
31
|
+
- [Shared Context Store](#shared-context-store)
|
|
32
|
+
- [Dashboard](#dashboard)
|
|
33
|
+
- [Live Tab](#live-tab)
|
|
34
|
+
- [Sessions Tab](#sessions-tab)
|
|
35
|
+
- [Security Tab](#security-tab)
|
|
36
|
+
- [Bash Bro Tab](#bash-bro-tab)
|
|
37
|
+
- [Models Tab](#models-tab)
|
|
38
|
+
- [Context Tab](#context-tab)
|
|
39
|
+
- [Settings Tab](#settings-tab)
|
|
40
|
+
- [WebSocket Events](#websocket-events)
|
|
41
|
+
- [Agent Integrations](#agent-integrations)
|
|
42
|
+
- [MCP Sidekick for Claude Code](#mcp-sidekick-for-claude-code)
|
|
43
|
+
- [Ward (Network Security)](#ward-network-security)
|
|
44
|
+
- [Observability](#observability)
|
|
45
|
+
- [CLI Reference](#cli-reference)
|
|
46
|
+
- [Core Commands](#core-commands)
|
|
47
|
+
- [AI Sidekick Commands](#ai-sidekick-commands)
|
|
48
|
+
- [Bash Bro Commands](#bash-bro-commands)
|
|
49
|
+
- [Dashboard](#dashboard-command)
|
|
50
|
+
- [Agent Hook Commands](#agent-hook-commands)
|
|
51
|
+
- [Ward Commands](#ward-commands)
|
|
52
|
+
- [Undo Commands](#undo-commands)
|
|
53
|
+
- [Reporting Commands](#reporting-commands)
|
|
54
|
+
- [Examples](#examples)
|
|
55
|
+
- [Configuration](#configuration)
|
|
56
|
+
- [Config File Reference](#config-file-reference)
|
|
57
|
+
- [Security Profiles](#security-profiles)
|
|
58
|
+
- [Risk Levels](#risk-levels)
|
|
59
|
+
- [Shared Context Store Layout](#shared-context-store-layout)
|
|
60
|
+
- [Programmatic API](#programmatic-api)
|
|
61
|
+
- [Dashboard REST API](#dashboard-rest-api)
|
|
62
|
+
- [Supported Agents](#supported-agents)
|
|
63
|
+
- [BashGym Integration](#bashgym-integration)
|
|
64
|
+
- [Requirements](#requirements)
|
|
65
|
+
- [Development](#development)
|
|
66
|
+
- [License](#license)
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
Install globally:
|
|
16
73
|
|
|
17
74
|
```bash
|
|
18
75
|
npm install -g bashbros
|
|
19
76
|
```
|
|
20
77
|
|
|
21
|
-
|
|
78
|
+
Or as a project dev dependency:
|
|
22
79
|
|
|
23
80
|
```bash
|
|
24
|
-
|
|
25
|
-
bashbros scan # Learn your system
|
|
26
|
-
bashbros watch # Start protection
|
|
81
|
+
npm install --save-dev bashbros
|
|
27
82
|
```
|
|
28
83
|
|
|
29
|
-
|
|
84
|
+
Requires **Node.js >= 18**.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Quick Start
|
|
89
|
+
|
|
30
90
|
```bash
|
|
31
|
-
|
|
91
|
+
# 1. Initialize in your project
|
|
92
|
+
bashbros init
|
|
93
|
+
|
|
94
|
+
# 2. Install hooks for your agent(s)
|
|
95
|
+
bashbros hook install # Claude Code
|
|
96
|
+
bashbros gemini install # Gemini CLI
|
|
97
|
+
bashbros copilot install # Copilot CLI
|
|
98
|
+
bashbros setup # Or use the multi-agent wizard
|
|
99
|
+
|
|
100
|
+
# 3. Start protection
|
|
101
|
+
bashbros watch
|
|
102
|
+
|
|
103
|
+
# 4. (Optional) Start the dashboard
|
|
104
|
+
bashbros dashboard
|
|
32
105
|
```
|
|
33
106
|
|
|
107
|
+
The dashboard opens at `http://localhost:7890` by default and gives you real-time visibility into every command your agents run.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
34
111
|
## Features
|
|
35
112
|
|
|
36
|
-
### Security
|
|
37
|
-
- **Command filter** - Allow/block by pattern
|
|
38
|
-
- **Path sandbox** - Restrict filesystem access
|
|
39
|
-
- **Secrets guard** - Block .env, keys, credentials
|
|
40
|
-
- **Rate limiter** - Prevent runaway agents
|
|
41
|
-
- **Risk scorer** - Score commands 1-10 by danger level
|
|
42
|
-
- **Loop detector** - Detect stuck/repetitive agent behavior
|
|
43
|
-
- **Anomaly detector** - Flag unusual patterns
|
|
44
|
-
- **Output scanner** - Detect leaked secrets in command output
|
|
45
|
-
- **Undo stack** - Rollback file changes
|
|
46
|
-
|
|
47
|
-
### Observability (3 modules)
|
|
48
|
-
- **Session metrics** - Track commands, risk distribution, paths
|
|
49
|
-
- **Cost estimator** - Estimate token usage and API costs
|
|
50
|
-
- **Report generator** - Text/markdown/JSON session reports
|
|
51
|
-
|
|
52
|
-
### AI Sidekick (Ollama)
|
|
53
|
-
- **System awareness** - Knows your tools, versions, project type
|
|
54
|
-
- **Task routing** - Simple → local model, complex → main agent
|
|
55
|
-
- **Suggestions** - Context-aware next commands
|
|
56
|
-
- **Background tasks** - Tests/builds run in parallel
|
|
57
|
-
|
|
58
|
-
### Claude Code Integration
|
|
59
|
-
- **PreToolUse hook** - Gate commands before execution
|
|
60
|
-
- **PostToolUse hook** - Record metrics after execution
|
|
61
|
-
- **SessionEnd hook** - Generate session reports
|
|
62
|
-
|
|
63
|
-
## Commands
|
|
113
|
+
### Security Policies
|
|
64
114
|
|
|
65
|
-
|
|
115
|
+
BashBros provides nine security modules that work together to protect your system from unintended or dangerous agent behavior.
|
|
116
|
+
|
|
117
|
+
- **Command allow/block lists** -- Glob patterns to explicitly allow or block commands.
|
|
118
|
+
- **Path access control** -- Block dangerous paths like `/etc/passwd`, `~/.ssh`, `~/.aws`.
|
|
119
|
+
- **Secret detection and redaction** -- Detect and redact secrets in command output before they leak.
|
|
120
|
+
- **Risk scoring engine** -- Score every command from 1-10. Configurable block and warn thresholds.
|
|
121
|
+
- **Loop detection** -- Detect and break runaway agent loops (repeated commands, excessive turns).
|
|
122
|
+
- **Anomaly detection** -- Flag unusual command patterns and off-hours activity.
|
|
123
|
+
- **Rate limiting** -- Per-minute and per-hour rate limits to prevent runaway agents.
|
|
124
|
+
- **Output scanning** -- Scan command output for leaked secrets, API keys, and credentials.
|
|
125
|
+
- **Undo stack** -- Rollback file operations with automatic backups.
|
|
126
|
+
|
|
127
|
+
### AI Sidekick (Ollama-powered)
|
|
128
|
+
|
|
129
|
+
BashBros includes a local AI sidekick powered by Ollama. It can suggest next steps, perform security analysis, and run interactive chat sessions -- all running locally on your machine.
|
|
130
|
+
|
|
131
|
+
| Command | What it does |
|
|
132
|
+
|---------|--------------|
|
|
133
|
+
| `bashbros suggest` | Context-aware next command suggestions |
|
|
134
|
+
| `bashbros safety <command>` | AI-powered security risk analysis |
|
|
135
|
+
| `bashbros chat` | Interactive Ollama conversation |
|
|
136
|
+
|
|
137
|
+
Under the hood, the AI sidekick uses a hybrid routing system: pattern matching handles well-known commands instantly, while Ollama provides fallback analysis for ambiguous inputs. Suggestions are cached with a 5-minute TTL for fast repeated access.
|
|
138
|
+
|
|
139
|
+
### Ollama Model Management
|
|
140
|
+
|
|
141
|
+
Full Ollama control plane accessible from the web dashboard:
|
|
142
|
+
|
|
143
|
+
- Pull, delete, and inspect models without leaving the dashboard.
|
|
144
|
+
- View running models with real-time VRAM/RAM usage bars.
|
|
145
|
+
- Inspect model details: parameter count, quantization level, model family.
|
|
146
|
+
|
|
147
|
+
### LoRA Adapter Management
|
|
148
|
+
|
|
149
|
+
Integrate fine-tuned LoRA adapters into your AI sidekick workflow:
|
|
150
|
+
|
|
151
|
+
- Auto-discover GGUF LoRA adapters from `~/.bashgym/integration/models/adapters/`.
|
|
152
|
+
- Activate adapters with one click (auto-generates Ollama Modelfile, registers with Ollama).
|
|
153
|
+
- Per-function adapter routing -- assign different adapters to individual sidekick functions.
|
|
154
|
+
- Connects to the [BashGym](https://github.com/GhostPeony/bashgym) training pipeline for continuous improvement.
|
|
155
|
+
|
|
156
|
+
### Model Profiles
|
|
157
|
+
|
|
158
|
+
Named profiles that combine a base model with adapter assignments:
|
|
159
|
+
|
|
160
|
+
- Save, load, and delete profiles from `~/.bashbros/models/profiles/`.
|
|
161
|
+
- Quick-switch between profiles from the dashboard.
|
|
162
|
+
- Each profile stores the base model name and per-function adapter mappings.
|
|
163
|
+
|
|
164
|
+
### Shared Context Store
|
|
165
|
+
|
|
166
|
+
BashBros maintains a per-project context store at `.bashbros/context/` that any CLI agent can read. No proprietary format -- memory files are plain markdown (like `CLAUDE.md`), and artifacts are standard JSONL.
|
|
167
|
+
|
|
168
|
+
- **Memory files** (persistent, human-readable markdown): `decisions.md`, `conventions.md`, `issues.md`, plus custom files.
|
|
169
|
+
- **Session artifacts** (machine-readable JSONL): command history, error logs, session summaries.
|
|
170
|
+
- **Index manifest** tracking agents seen, session counts, and file counts.
|
|
171
|
+
- Auto-writes during watch mode sessions.
|
|
172
|
+
- Configurable retention with auto-pruning (default: 30 days).
|
|
173
|
+
|
|
174
|
+
See [Shared Context Store Layout](#shared-context-store-layout) for the full directory structure.
|
|
175
|
+
|
|
176
|
+
### Dashboard
|
|
177
|
+
|
|
178
|
+
Real-time web dashboard for monitoring everything BashBros does. Start it with `bashbros dashboard` and open `http://localhost:7890`.
|
|
179
|
+
|
|
180
|
+
The dashboard uses WebSocket for real-time updates and REST polling as a fallback. All data is stored in a local SQLite database and persists across sessions.
|
|
181
|
+
|
|
182
|
+
#### Live Tab
|
|
183
|
+
|
|
184
|
+
The default view. Shows a real-time command feed as agents execute commands.
|
|
185
|
+
|
|
186
|
+
- **Multi-session support** -- When multiple agents run simultaneously, each session gets a color-coded pill in the session bar. Click a pill to filter the feed to that session, or "Show All" to see everything.
|
|
187
|
+
- **Risk badges** -- Every command displays a risk badge (safe/caution/dangerous/critical) based on the risk scoring engine.
|
|
188
|
+
- **Command details** -- Each entry shows the command text, execution time, exit code, and which repository/project it ran in.
|
|
189
|
+
- **Cached feed** -- The live feed persists in localStorage so refreshing the page doesn't lose your view.
|
|
190
|
+
|
|
191
|
+
#### Sessions Tab
|
|
192
|
+
|
|
193
|
+
Browse completed and active sessions. Each session shows:
|
|
194
|
+
|
|
195
|
+
- Agent type, start time, duration
|
|
196
|
+
- Total commands executed and violations triggered
|
|
197
|
+
- Click to inspect individual session details
|
|
198
|
+
|
|
199
|
+
#### Security Tab
|
|
200
|
+
|
|
201
|
+
Security-focused monitoring across all sessions:
|
|
202
|
+
|
|
203
|
+
- **Risk distribution** -- Visual bars showing the proportion of safe/caution/dangerous/critical commands.
|
|
204
|
+
- **Violation breakdown** -- Counts by violation type (command, path, secrets, rate_limit, risk_score, loop, anomaly, output).
|
|
205
|
+
- **Blocked commands** -- Full list of blocked commands with the violation rule that triggered the block.
|
|
206
|
+
- **Security event feed** -- Chronological log of all security events with severity badges.
|
|
207
|
+
- **Exposure scans** -- Results from Ward's agent server exposure scanning.
|
|
208
|
+
|
|
209
|
+
#### Bash Bro Tab
|
|
210
|
+
|
|
211
|
+
Monitoring for the AI sidekick and Ollama integration:
|
|
212
|
+
|
|
213
|
+
- **Status panel** -- Shows Ollama connection status, current model, platform, shell, project type, active profile, and adapter count.
|
|
214
|
+
- **Model selector** -- Dropdown to switch the active Ollama model and trigger system scans.
|
|
215
|
+
- **AI activity log** -- Every AI request (suggestion, explanation, fix, script, safety analysis) with the model used, latency, and success/failure status. Requests under 50ms show a "CACHED" badge.
|
|
216
|
+
- **Router stats** -- Pattern-matched vs AI-routed decision counts, and average response latency. This tells you how often the AI fallback kicks in for ambiguous commands.
|
|
217
|
+
- **Adapter events** -- Table of adapter activations with timestamp, adapter name, base model, purpose, action, and success status.
|
|
218
|
+
|
|
219
|
+
#### Models Tab
|
|
220
|
+
|
|
221
|
+
Full Ollama control plane:
|
|
222
|
+
|
|
223
|
+
- **Pull model** -- Type a model name (e.g., `deepseek-coder:6.7b`) and pull it directly from the dashboard. A progress bar shows download status, and WebSocket events (`model:pull:complete`, `model:pull:error`) update the UI in real time.
|
|
224
|
+
- **Running models** -- Shows every model currently loaded in Ollama's memory. Each entry displays the model name, parameter size, quantization level, and a VRAM usage bar showing the proportion of the model loaded into GPU memory vs system RAM.
|
|
225
|
+
- **Installed models** -- Card grid of all models installed in Ollama. Each card shows the model name, parameter count, family (llama, qwen, etc.), quantization level (Q4_K_M, Q5_K_S, etc.), and format. Cards have a delete button with confirmation.
|
|
226
|
+
- **LoRA adapters** -- Card grid of adapters discovered from `~/.bashgym/integration/models/adapters/`. Each card shows the adapter name, base model, purpose tag (suggest/safety/route/etc.), quality score, trace count, and training date. Click "Activate" to auto-generate an Ollama Modelfile and register the adapter as a usable Ollama model.
|
|
227
|
+
- **Profile editor** -- List of saved profiles with edit/delete buttons. The editor form lets you set a profile name, base model, and assign adapters to six function slots (suggest, safety, route, explain, fix, script).
|
|
228
|
+
|
|
229
|
+
#### Context Tab
|
|
230
|
+
|
|
231
|
+
View and edit the shared context store:
|
|
232
|
+
|
|
233
|
+
- **Stats** -- Cards showing last update time, number of agents seen, total sessions, command files, and error files from the context index.
|
|
234
|
+
- **Memory file editor** -- Inline editors for each markdown memory file (`decisions.md`, `conventions.md`, `issues.md`, and any custom files). Edit the markdown directly in the browser and save with one click. WebSocket `context:updated` events refresh the view when files change externally.
|
|
235
|
+
- **Session browser** -- Placeholder for future search/filter over session artifacts.
|
|
236
|
+
|
|
237
|
+
#### Settings Tab
|
|
238
|
+
|
|
239
|
+
- **Agent integrations** -- Status cards for each supported agent showing installation state.
|
|
240
|
+
- **Security profile** -- Edit the active security profile, command allowlists/blocklists, and all policy settings.
|
|
241
|
+
|
|
242
|
+
#### WebSocket Events
|
|
243
|
+
|
|
244
|
+
The dashboard listens for real-time events over WebSocket:
|
|
245
|
+
|
|
246
|
+
| Event | Trigger |
|
|
247
|
+
|-------|---------|
|
|
248
|
+
| `command` | A command was executed (refreshes live feed) |
|
|
249
|
+
| `model:pull:start` | Model pull initiated |
|
|
250
|
+
| `model:pull:complete` | Model pull finished successfully |
|
|
251
|
+
| `model:pull:error` | Model pull failed |
|
|
252
|
+
| `adapter:activated` | LoRA adapter activated in Ollama |
|
|
253
|
+
| `context:updated` | A memory file was modified |
|
|
254
|
+
|
|
255
|
+
### Agent Integrations
|
|
256
|
+
|
|
257
|
+
BashBros hooks into six CLI agents with a single command per agent:
|
|
258
|
+
|
|
259
|
+
- **Claude Code** -- Pre/post command hooks (gate + record all tool types).
|
|
260
|
+
- **Moltbot/Clawdbot** -- Hook integration + gateway monitoring + security audit.
|
|
261
|
+
- **Gemini CLI** -- Pre/post hooks via `settings.json`.
|
|
262
|
+
- **Copilot CLI** -- Pre/post hooks.
|
|
263
|
+
- **OpenCode** -- Plugin integration.
|
|
264
|
+
- **Aider** -- Configuration support.
|
|
265
|
+
|
|
266
|
+
Use `bashbros setup` for a guided multi-agent setup wizard.
|
|
267
|
+
|
|
268
|
+
### MCP Sidekick for Claude Code
|
|
269
|
+
|
|
270
|
+
BashBros integrates with Claude Code as an MCP server, providing cross-session memory, local history intelligence, and safety tools that Claude Code doesn't have natively.
|
|
271
|
+
|
|
272
|
+
**Setup:**
|
|
273
|
+
```bash
|
|
274
|
+
# Automatic (installs hooks + MCP server)
|
|
275
|
+
npx bashbros hook install
|
|
276
|
+
|
|
277
|
+
# Manual: add to ~/.claude/settings.json
|
|
278
|
+
{
|
|
279
|
+
"mcpServers": {
|
|
280
|
+
"bashbros": {
|
|
281
|
+
"command": "npx",
|
|
282
|
+
"args": ["bashbros", "mcp"]
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
```
|
|
66
287
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
288
|
+
**5 MCP Tools:**
|
|
289
|
+
|
|
290
|
+
| Tool | Description |
|
|
291
|
+
|------|-------------|
|
|
292
|
+
| `session_summary` | Structured summaries of recent sessions -- commands, risk scores, AI-generated descriptions |
|
|
293
|
+
| `trace_search` | Search command history across sessions by text query |
|
|
294
|
+
| `history_suggest` | Smart next-command suggestions based on local usage patterns |
|
|
295
|
+
| `secret_scan` | Scan text for leaked credentials, API keys, tokens, and private keys |
|
|
296
|
+
| `code_task` | Delegate bounded coding tasks to a local Ollama model |
|
|
297
|
+
|
|
298
|
+
**Capability Tiers (code_task):**
|
|
299
|
+
|
|
300
|
+
| Model Size | Tier | Handles |
|
|
301
|
+
|-----------|------|---------|
|
|
302
|
+
| < 14B | Basic | Formatting, renames, imports, boilerplate, type annotations |
|
|
303
|
+
| 14B - 32B | Moderate | Tests, error handling, function refactors, interface implementations |
|
|
304
|
+
| 33B+ | Advanced | Complex logic, multi-function refactors, pattern-following generation |
|
|
305
|
+
|
|
306
|
+
### Ward (Network Security)
|
|
307
|
+
|
|
308
|
+
Network-level security scanning and egress monitoring:
|
|
309
|
+
|
|
310
|
+
- **Exposure scanning** -- Detect agent servers with open ports.
|
|
311
|
+
- **Egress pattern detection** -- Catch credentials, API keys, and PII leaving your machine.
|
|
312
|
+
- **Configurable actions** -- Block, alert, or log suspicious egress.
|
|
313
|
+
- **Severity-based response** -- Graduated handling for low/medium/high/critical threats.
|
|
75
314
|
|
|
76
315
|
### Observability
|
|
77
316
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
317
|
+
- **Command audit logging** -- Full history of every command executed.
|
|
318
|
+
- **Session metrics and reporting** -- Generate reports in text, markdown, or JSON format.
|
|
319
|
+
- **Cost estimation** -- Track estimated token usage and API costs.
|
|
320
|
+
- **Undo stack** -- Track and revert file operations.
|
|
82
321
|
|
|
83
|
-
|
|
322
|
+
---
|
|
84
323
|
|
|
85
|
-
|
|
86
|
-
|---------|-------------|
|
|
87
|
-
| `hook install` | Install BashBros hooks into Claude Code |
|
|
88
|
-
| `hook uninstall` | Remove hooks from Claude Code |
|
|
89
|
-
| `hook status` | Check hook installation status |
|
|
90
|
-
| `gate <cmd>` | Check if command should be allowed |
|
|
91
|
-
| `record <cmd>` | Record command execution |
|
|
324
|
+
## CLI Reference
|
|
92
325
|
|
|
93
|
-
###
|
|
326
|
+
### Core Commands
|
|
94
327
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
328
|
+
```
|
|
329
|
+
bashbros init Set up BashBros for your project
|
|
330
|
+
bashbros watch [-v] Start protecting your agent (verbose mode with -v)
|
|
331
|
+
bashbros doctor Check your configuration
|
|
332
|
+
bashbros allow <command> Allow a specific command (--once | --persist)
|
|
333
|
+
bashbros audit [-n lines] View recent command history
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### AI Sidekick Commands
|
|
337
|
+
|
|
338
|
+
Requires [Ollama](https://ollama.com) running locally.
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
bashbros suggest Get next command suggestions
|
|
342
|
+
bashbros safety <command> AI security risk analysis
|
|
343
|
+
bashbros chat Start an interactive Ollama conversation
|
|
344
|
+
bashbros models List available Ollama models
|
|
345
|
+
bashbros mcp Start MCP server for Claude Code integration (stdio)
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Bash Bro Commands
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
bashbros scan Scan system and project
|
|
352
|
+
bashbros status Show Bash Bro status
|
|
353
|
+
bashbros route <command> Check routing decision
|
|
354
|
+
bashbros run <command> [-b] Run through Bash Bro (-b for background)
|
|
355
|
+
bashbros tasks [-a] List background tasks (-a for all)
|
|
356
|
+
bashbros risk <command> Score command risk (1-10)
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Dashboard Command
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
bashbros dashboard [-p port] Start the web dashboard (default port: 7890)
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Agent Hook Commands
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
bashbros hook install Install Claude Code hooks
|
|
369
|
+
bashbros hook uninstall Remove Claude Code hooks
|
|
370
|
+
bashbros hook status Check Claude Code hook status
|
|
371
|
+
bashbros gemini install Install Gemini CLI hooks
|
|
372
|
+
bashbros gemini uninstall Remove Gemini CLI hooks
|
|
373
|
+
bashbros gemini status Check Gemini CLI hook status
|
|
374
|
+
bashbros copilot install Install Copilot CLI hooks
|
|
375
|
+
bashbros copilot uninstall Remove Copilot CLI hooks
|
|
376
|
+
bashbros copilot status Check Copilot CLI hook status
|
|
377
|
+
bashbros opencode install Install OpenCode plugin
|
|
378
|
+
bashbros opencode uninstall Remove OpenCode plugin
|
|
379
|
+
bashbros opencode status Check OpenCode plugin status
|
|
380
|
+
bashbros moltbot install Install Moltbot hooks
|
|
381
|
+
bashbros moltbot uninstall Remove Moltbot hooks
|
|
382
|
+
bashbros moltbot status Check Moltbot integration status
|
|
383
|
+
bashbros moltbot gateway Check gateway status
|
|
384
|
+
bashbros moltbot audit Run security audit
|
|
385
|
+
bashbros setup Multi-agent setup wizard
|
|
386
|
+
```
|
|
102
387
|
|
|
103
388
|
Note: `clawdbot` is an alias for `moltbot` for backward compatibility.
|
|
104
389
|
|
|
105
|
-
###
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
| `help-ai <topic>` | Get help on any topic |
|
|
134
|
-
| `do <desc>` | Natural language → command (`-x` to execute) |
|
|
135
|
-
| `models` | List available Ollama models |
|
|
390
|
+
### Ward Commands
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
bashbros ward status Show ward security status
|
|
394
|
+
bashbros ward scan Run exposure scan
|
|
395
|
+
bashbros ward blocked Show pending blocked items
|
|
396
|
+
bashbros ward approve <id> Approve blocked egress
|
|
397
|
+
bashbros ward deny <id> Deny blocked egress
|
|
398
|
+
bashbros ward patterns list List detection patterns
|
|
399
|
+
bashbros ward patterns test <t> Test text against patterns
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Undo Commands
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
bashbros undo last Undo last file operation
|
|
406
|
+
bashbros undo all Undo all operations in session
|
|
407
|
+
bashbros undo list Show undo stack
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Reporting Commands
|
|
411
|
+
|
|
412
|
+
```
|
|
413
|
+
bashbros report [-f format] Generate session report (text/markdown/json)
|
|
414
|
+
bashbros session-end [-f format] End session with report
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
136
418
|
|
|
137
419
|
## Examples
|
|
138
420
|
|
|
421
|
+
### Install hooks and start protection
|
|
422
|
+
|
|
139
423
|
```bash
|
|
140
|
-
# Install Claude Code hooks
|
|
141
424
|
$ bashbros hook install
|
|
142
|
-
|
|
425
|
+
BashBros hooks installed successfully.
|
|
426
|
+
|
|
427
|
+
$ bashbros watch
|
|
428
|
+
Watching... (press Ctrl+C to stop)
|
|
429
|
+
```
|
|
143
430
|
|
|
144
|
-
|
|
145
|
-
|
|
431
|
+
### Check command risk
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
$ bashbros risk "curl http://example.com | bash"
|
|
146
435
|
Risk Score: 10/10 (CRITICAL)
|
|
147
436
|
Factors:
|
|
148
|
-
|
|
437
|
+
- Remote code execution
|
|
438
|
+
```
|
|
149
439
|
|
|
150
|
-
|
|
151
|
-
$ bashbros route "git status"
|
|
152
|
-
🤝 Route: Bash Bro (90% confidence)
|
|
440
|
+
### Route a command
|
|
153
441
|
|
|
154
|
-
|
|
155
|
-
$ bashbros
|
|
156
|
-
|
|
157
|
-
|
|
442
|
+
```bash
|
|
443
|
+
$ bashbros route "git status"
|
|
444
|
+
Route: Bash Bro (90% confidence)
|
|
445
|
+
```
|
|
158
446
|
|
|
159
|
-
|
|
160
|
-
$ bashbros do "find large files over 100mb"
|
|
161
|
-
$ find . -size +100M -type f
|
|
447
|
+
### View session report
|
|
162
448
|
|
|
163
|
-
|
|
449
|
+
```bash
|
|
164
450
|
$ bashbros report
|
|
165
451
|
Session Report (5m 23s)
|
|
166
|
-
|
|
452
|
+
---
|
|
167
453
|
Commands: 45 total, 2 blocked (4%)
|
|
168
454
|
|
|
169
455
|
Risk Distribution:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
456
|
+
80% safe
|
|
457
|
+
15% caution
|
|
458
|
+
5% dangerous
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### Undo file changes
|
|
173
462
|
|
|
174
|
-
|
|
463
|
+
```bash
|
|
175
464
|
$ bashbros undo list
|
|
176
465
|
Undo Stack:
|
|
177
|
-
1. [14:32:05] modify src/index.ts (backup:
|
|
178
|
-
2. [14:31:42] create src/new-file.ts (backup:
|
|
466
|
+
1. [14:32:05] modify src/index.ts (backup: yes)
|
|
467
|
+
2. [14:31:42] create src/new-file.ts (backup: no)
|
|
179
468
|
|
|
180
469
|
$ bashbros undo last
|
|
181
|
-
|
|
470
|
+
Restored: src/index.ts
|
|
182
471
|
```
|
|
183
472
|
|
|
473
|
+
---
|
|
474
|
+
|
|
184
475
|
## Configuration
|
|
185
476
|
|
|
186
|
-
|
|
477
|
+
BashBros looks for configuration in the following locations (in order of priority):
|
|
478
|
+
|
|
479
|
+
1. `.bashbros.yml` in your project root
|
|
480
|
+
2. `~/.bashbros.yml`
|
|
481
|
+
3. `~/.bashbros/config.yml`
|
|
482
|
+
|
|
483
|
+
### Config File Reference
|
|
187
484
|
|
|
188
485
|
```yaml
|
|
189
|
-
agent: claude-code
|
|
190
|
-
profile: balanced
|
|
486
|
+
agent: claude-code # claude-code | gemini-cli | copilot-cli | opencode | moltbot | aider
|
|
487
|
+
profile: balanced # balanced | strict | permissive | custom
|
|
191
488
|
|
|
192
489
|
commands:
|
|
193
|
-
allow:
|
|
194
|
-
|
|
490
|
+
allow:
|
|
491
|
+
- "git *"
|
|
492
|
+
- "npm *"
|
|
493
|
+
- "node *"
|
|
494
|
+
block:
|
|
495
|
+
- "rm -rf /"
|
|
496
|
+
- "curl * | bash"
|
|
195
497
|
|
|
196
498
|
paths:
|
|
197
|
-
allow:
|
|
198
|
-
|
|
499
|
+
allow:
|
|
500
|
+
- "."
|
|
501
|
+
block:
|
|
502
|
+
- "~/.ssh/*"
|
|
503
|
+
- "/etc/shadow"
|
|
199
504
|
|
|
200
505
|
secrets:
|
|
201
506
|
enabled: true
|
|
202
|
-
mode: block
|
|
203
|
-
patterns: [.env*, "*.pem", "*.key"]
|
|
204
|
-
|
|
205
|
-
audit:
|
|
206
|
-
enabled: true
|
|
207
|
-
destination: local
|
|
507
|
+
mode: block # block | audit
|
|
208
508
|
|
|
209
509
|
rateLimit:
|
|
210
510
|
enabled: true
|
|
211
511
|
maxPerMinute: 100
|
|
212
512
|
maxPerHour: 1000
|
|
213
513
|
|
|
214
|
-
# Risk scoring thresholds (1-10)
|
|
215
514
|
riskScoring:
|
|
216
515
|
enabled: true
|
|
217
|
-
blockThreshold: 9
|
|
218
|
-
warnThreshold: 6
|
|
516
|
+
blockThreshold: 9 # Block commands at or above this score
|
|
517
|
+
warnThreshold: 6 # Warn for commands at or above this score
|
|
219
518
|
customPatterns:
|
|
220
519
|
- pattern: "my-custom-danger-cmd"
|
|
221
520
|
score: 8
|
|
222
521
|
factor: "Custom dangerous pattern"
|
|
223
522
|
|
|
224
|
-
# Loop detection
|
|
225
523
|
loopDetection:
|
|
226
524
|
enabled: true
|
|
227
|
-
maxRepeats: 3
|
|
228
|
-
maxTurns: 100
|
|
525
|
+
maxRepeats: 3 # Same command N times triggers alert
|
|
526
|
+
maxTurns: 100 # Hard stop after N total commands
|
|
229
527
|
similarityThreshold: 0.85
|
|
230
528
|
cooldownMs: 1000
|
|
231
529
|
windowSize: 20
|
|
232
|
-
action: warn
|
|
530
|
+
action: warn # warn | block
|
|
233
531
|
|
|
234
|
-
# Anomaly detection
|
|
235
532
|
anomalyDetection:
|
|
236
533
|
enabled: true
|
|
237
|
-
workingHours: [6, 22]
|
|
534
|
+
workingHours: [6, 22] # 6am - 10pm
|
|
238
535
|
typicalCommandsPerMinute: 30
|
|
239
|
-
learningCommands: 50
|
|
240
|
-
|
|
241
|
-
action: warn
|
|
536
|
+
learningCommands: 50
|
|
537
|
+
action: warn # warn | block
|
|
242
538
|
|
|
243
|
-
# Output scanning for leaked secrets
|
|
244
539
|
outputScanning:
|
|
245
540
|
enabled: true
|
|
246
541
|
scanForSecrets: true
|
|
247
542
|
scanForErrors: true
|
|
248
543
|
maxOutputLength: 100000
|
|
249
|
-
redactPatterns: []
|
|
544
|
+
redactPatterns: [] # Additional regex patterns to redact
|
|
250
545
|
|
|
251
|
-
# Undo/rollback
|
|
252
546
|
undo:
|
|
253
547
|
enabled: true
|
|
254
548
|
maxStackSize: 100
|
|
255
|
-
maxFileSize: 10485760
|
|
256
|
-
ttlMinutes: 60
|
|
549
|
+
maxFileSize: 10485760 # 10MB
|
|
550
|
+
ttlMinutes: 60
|
|
257
551
|
backupPath: ~/.bashbros/undo
|
|
552
|
+
|
|
553
|
+
ward:
|
|
554
|
+
enabled: true
|
|
555
|
+
|
|
556
|
+
dashboard:
|
|
557
|
+
enabled: true
|
|
558
|
+
port: 7890
|
|
559
|
+
bind: 127.0.0.1
|
|
258
560
|
```
|
|
259
561
|
|
|
260
|
-
|
|
562
|
+
### Security Profiles
|
|
563
|
+
|
|
564
|
+
Three built-in profiles control how aggressively BashBros enforces security:
|
|
261
565
|
|
|
262
566
|
| Profile | Risk Block | Risk Warn | Loop Max | Anomaly | Behavior |
|
|
263
567
|
|---------|------------|-----------|----------|---------|----------|
|
|
264
|
-
| `strict` | 6 | 3 | 2 repeats, block | enabled | Allowlist only, explicit approval |
|
|
568
|
+
| `strict` | 6 | 3 | 2 repeats, block | enabled | Allowlist only, explicit approval required |
|
|
265
569
|
| `balanced` | 9 | 6 | 3 repeats, warn | enabled | Block dangerous, allow common dev tools |
|
|
266
|
-
| `permissive` | 10 | 8 | 5 repeats, warn | disabled | Log
|
|
570
|
+
| `permissive` | 10 | 8 | 5 repeats, warn | disabled | Log everything, block only critical threats |
|
|
267
571
|
|
|
268
|
-
|
|
572
|
+
### Risk Levels
|
|
269
573
|
|
|
270
574
|
| Level | Score | Examples |
|
|
271
575
|
|-------|-------|----------|
|
|
272
576
|
| Safe | 1-2 | `ls`, `git status`, `npm test` |
|
|
273
577
|
| Caution | 3-5 | `ps aux`, `netstat`, encoded content |
|
|
274
578
|
| Dangerous | 6-8 | `crontab`, `chmod 777`, `sudo` |
|
|
275
|
-
| Critical | 9-10 | `rm -rf /`, `curl
|
|
579
|
+
| Critical | 9-10 | `rm -rf /`, `curl \| bash`, fork bombs |
|
|
580
|
+
|
|
581
|
+
---
|
|
276
582
|
|
|
277
|
-
##
|
|
583
|
+
## Shared Context Store Layout
|
|
278
584
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
585
|
+
```
|
|
586
|
+
.bashbros/context/
|
|
587
|
+
├── memory/ # Persistent markdown files
|
|
588
|
+
│ ├── decisions.md # Architectural decisions
|
|
589
|
+
│ ├── conventions.md # Coding patterns & style
|
|
590
|
+
│ ├── issues.md # Known issues & workarounds
|
|
591
|
+
│ └── custom/ # User-created files
|
|
592
|
+
├── artifacts/ # Machine-readable session data
|
|
593
|
+
│ ├── sessions/ # One JSON per session
|
|
594
|
+
│ ├── commands/ # Daily JSONL command logs
|
|
595
|
+
│ └── errors/ # Daily JSONL error logs
|
|
596
|
+
└── index.json # Manifest with stats
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Memory files are human-readable markdown. Any agent can read them the same way it reads `CLAUDE.md` or any other project documentation file. Artifacts are auto-pruned after 30 days by default (configurable via retention settings).
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
## Programmatic API
|
|
604
|
+
|
|
605
|
+
BashBros exports its core components for use as a library:
|
|
606
|
+
|
|
607
|
+
```typescript
|
|
608
|
+
import { BashBro, OllamaClient, PolicyEngine } from 'bashbros'
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
### AI Sidekick
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
const bro = new BashBro({
|
|
615
|
+
enableOllama: true,
|
|
616
|
+
modelName: 'qwen2.5-coder:7b',
|
|
617
|
+
activeProfile: 'balanced'
|
|
618
|
+
})
|
|
619
|
+
await bro.initialize()
|
|
620
|
+
|
|
621
|
+
const suggestion = await bro.aiSuggest('npm test failed with module error')
|
|
622
|
+
const explanation = await bro.aiExplain('find . -name "*.ts" -exec wc -l {} +')
|
|
623
|
+
const route = await bro.routeAsync('git diff --stat')
|
|
624
|
+
const suggestions = await bro.suggestAsync({ lastCommand: 'npm test', lastOutput: 'PASS' })
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### Security Policy Engine
|
|
628
|
+
|
|
629
|
+
```typescript
|
|
630
|
+
const engine = new PolicyEngine(config)
|
|
631
|
+
const result = engine.evaluate('rm -rf /tmp/*')
|
|
632
|
+
// result.allowed: boolean
|
|
633
|
+
// result.reason: string
|
|
634
|
+
// result.riskScore: number
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### Risk Scoring
|
|
638
|
+
|
|
639
|
+
```typescript
|
|
640
|
+
import { RiskScorer } from 'bashbros'
|
|
641
|
+
|
|
642
|
+
const scorer = new RiskScorer()
|
|
643
|
+
const risk = scorer.score('rm -rf /')
|
|
644
|
+
console.log(risk.level) // 'critical'
|
|
645
|
+
console.log(risk.score) // 10
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### Loop Detection
|
|
649
|
+
|
|
650
|
+
```typescript
|
|
651
|
+
import { LoopDetector } from 'bashbros'
|
|
652
|
+
|
|
653
|
+
const detector = new LoopDetector({ maxRepeats: 3 })
|
|
654
|
+
const alert = detector.check('git status')
|
|
655
|
+
if (alert) console.log('Loop detected:', alert.message)
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### Output Scanning
|
|
659
|
+
|
|
660
|
+
```typescript
|
|
661
|
+
import { OutputScanner } from 'bashbros'
|
|
662
|
+
|
|
663
|
+
const scanner = new OutputScanner({ enabled: true, scanForSecrets: true })
|
|
664
|
+
const result = scanner.scan('API_KEY=sk-secret123')
|
|
665
|
+
console.log(result.hasSecrets) // true
|
|
666
|
+
console.log(result.redactedOutput) // 'API_KEY=[REDACTED API Key]'
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
### Ollama Client
|
|
670
|
+
|
|
671
|
+
```typescript
|
|
672
|
+
const ollama = new OllamaClient({ host: 'http://localhost:11434' })
|
|
673
|
+
const models = await ollama.listModels()
|
|
674
|
+
const running = await ollama.listRunning()
|
|
675
|
+
const info = await ollama.showModel('qwen2.5-coder:7b')
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
### Session Metrics and Reporting
|
|
679
|
+
|
|
680
|
+
```typescript
|
|
681
|
+
import { MetricsCollector, ReportGenerator, CostEstimator } from 'bashbros'
|
|
682
|
+
|
|
683
|
+
const metrics = new MetricsCollector()
|
|
684
|
+
metrics.record({ command: 'ls', exitCode: 0 })
|
|
685
|
+
const report = ReportGenerator.generate(metrics.getMetrics())
|
|
686
|
+
|
|
687
|
+
const cost = new CostEstimator('claude-sonnet-4')
|
|
688
|
+
cost.recordToolCall('command', 'output')
|
|
689
|
+
console.log(cost.getEstimate()) // { estimatedCost: 0.05, ... }
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
### Undo Stack
|
|
693
|
+
|
|
694
|
+
```typescript
|
|
695
|
+
import { UndoStack } from 'bashbros'
|
|
696
|
+
|
|
697
|
+
const undo = new UndoStack({ maxStackSize: 50, ttlMinutes: 30 })
|
|
698
|
+
undo.recordModify('/path/to/file')
|
|
699
|
+
undo.undo() // Restores from backup
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
### Claude Code Hooks
|
|
703
|
+
|
|
704
|
+
```typescript
|
|
705
|
+
import { ClaudeCodeHooks } from 'bashbros'
|
|
706
|
+
|
|
707
|
+
ClaudeCodeHooks.install()
|
|
708
|
+
ClaudeCodeHooks.getStatus()
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
---
|
|
712
|
+
|
|
713
|
+
## Dashboard REST API
|
|
714
|
+
|
|
715
|
+
When running `bashbros dashboard`, the following REST endpoints are available at `http://localhost:7890`. All endpoints return JSON.
|
|
716
|
+
|
|
717
|
+
### System
|
|
718
|
+
|
|
719
|
+
| Method | Endpoint | Description |
|
|
720
|
+
|--------|----------|-------------|
|
|
721
|
+
| `GET` | `/api/health` | Health check |
|
|
722
|
+
| `GET` | `/api/stats` | Global stats (total commands, sessions, violations) |
|
|
723
|
+
| `GET` | `/api/events` | Event log with optional `?limit=` |
|
|
724
|
+
|
|
725
|
+
### Sessions and Commands
|
|
726
|
+
|
|
727
|
+
| Method | Endpoint | Description |
|
|
728
|
+
|--------|----------|-------------|
|
|
729
|
+
| `GET` | `/api/sessions` | All sessions with optional `?limit=` and `?status=` |
|
|
730
|
+
| `GET` | `/api/sessions/active` | Current active session |
|
|
731
|
+
| `GET` | `/api/sessions/active-all` | All active sessions (multi-agent) |
|
|
732
|
+
| `GET` | `/api/sessions/:id` | Single session details |
|
|
733
|
+
| `GET` | `/api/sessions/:id/commands` | Commands for a session |
|
|
734
|
+
| `GET` | `/api/sessions/:id/metrics` | Metrics for a session |
|
|
735
|
+
| `GET` | `/api/commands/live` | Live command feed with `?limit=` and `?sessionId=` |
|
|
736
|
+
| `GET` | `/api/commands` | Command history with `?limit=`, `?offset=`, `?allowed=` |
|
|
737
|
+
|
|
738
|
+
### Tool Recording
|
|
739
|
+
|
|
740
|
+
| Method | Endpoint | Description |
|
|
741
|
+
|--------|----------|-------------|
|
|
742
|
+
| `GET` | `/api/tools/live` | Live tool execution feed |
|
|
743
|
+
| `GET` | `/api/tools` | Tool execution history with `?limit=`, `?offset=`, `?tool_name=` |
|
|
744
|
+
| `GET` | `/api/tools/stats` | Tool usage statistics |
|
|
745
|
+
|
|
746
|
+
### Bash Bro (AI Sidekick)
|
|
747
|
+
|
|
748
|
+
| Method | Endpoint | Description |
|
|
749
|
+
|--------|----------|-------------|
|
|
750
|
+
| `GET` | `/api/bro/status` | Ollama connection, model, platform, shell, project type |
|
|
751
|
+
| `GET` | `/api/bro/events` | AI activity log with `?limit=` |
|
|
752
|
+
| `GET` | `/api/bro/models` | List installed Ollama models |
|
|
753
|
+
| `POST` | `/api/bro/model` | Switch active model (body: `{ model }`) |
|
|
754
|
+
| `POST` | `/api/bro/scan` | Trigger system profile scan |
|
|
755
|
+
|
|
756
|
+
### Model Management
|
|
757
|
+
|
|
758
|
+
| Method | Endpoint | Description |
|
|
759
|
+
|--------|----------|-------------|
|
|
760
|
+
| `GET` | `/api/bro/models/running` | Running models with VRAM/RAM usage |
|
|
761
|
+
| `GET` | `/api/bro/models/:name` | Model details (params, quantization, family) |
|
|
762
|
+
| `POST` | `/api/bro/models/pull` | Pull a model (body: `{ name }`) |
|
|
763
|
+
| `DELETE` | `/api/bro/models/:name` | Delete a model from Ollama |
|
|
764
|
+
|
|
765
|
+
### Adapters
|
|
766
|
+
|
|
767
|
+
| Method | Endpoint | Description |
|
|
768
|
+
|--------|----------|-------------|
|
|
769
|
+
| `GET` | `/api/bro/adapters` | List discovered LoRA adapters |
|
|
770
|
+
| `GET` | `/api/bro/adapters/events` | Adapter activation history |
|
|
771
|
+
| `POST` | `/api/bro/adapters/:name/activate` | Activate adapter (creates Ollama model) |
|
|
772
|
+
|
|
773
|
+
### Profiles
|
|
774
|
+
|
|
775
|
+
| Method | Endpoint | Description |
|
|
776
|
+
|--------|----------|-------------|
|
|
777
|
+
| `GET` | `/api/bro/profiles` | List model profiles |
|
|
778
|
+
| `POST` | `/api/bro/profiles` | Save a profile (body: full profile JSON) |
|
|
779
|
+
| `DELETE` | `/api/bro/profiles/:name` | Delete a profile |
|
|
780
|
+
|
|
781
|
+
### Context Store
|
|
782
|
+
|
|
783
|
+
| Method | Endpoint | Description |
|
|
784
|
+
|--------|----------|-------------|
|
|
785
|
+
| `GET` | `/api/context/index` | Context store manifest and stats |
|
|
786
|
+
| `GET` | `/api/context/memory` | All memory files (key = filename, value = content) |
|
|
787
|
+
| `PUT` | `/api/context/memory/:name` | Update a memory file (body: `{ content }`) |
|
|
788
|
+
|
|
789
|
+
### Security
|
|
790
|
+
|
|
791
|
+
| Method | Endpoint | Description |
|
|
792
|
+
|--------|----------|-------------|
|
|
793
|
+
| `GET` | `/api/security/summary` | Risk distribution, violation counts |
|
|
794
|
+
| `GET` | `/api/security/blocked-commands` | Blocked commands with `?limit=` |
|
|
795
|
+
| `GET` | `/api/exposures` | Ward exposure scan results |
|
|
796
|
+
| `GET` | `/api/blocked` | Pending blocked egress items |
|
|
797
|
+
| `POST` | `/api/blocked/:id/approve` | Approve a blocked egress item |
|
|
798
|
+
| `POST` | `/api/blocked/:id/deny` | Deny a blocked egress item |
|
|
799
|
+
| `GET` | `/api/connectors` | Monitored connectors |
|
|
800
|
+
| `GET` | `/api/connectors/:name/events` | Events for a specific connector |
|
|
801
|
+
|
|
802
|
+
### Configuration
|
|
803
|
+
|
|
804
|
+
| Method | Endpoint | Description |
|
|
805
|
+
|--------|----------|-------------|
|
|
806
|
+
| `GET` | `/api/config` | Current BashBros configuration |
|
|
807
|
+
| `POST` | `/api/config` | Update configuration |
|
|
808
|
+
| `GET` | `/api/agents/status` | Installed agent integration status |
|
|
809
|
+
|
|
810
|
+
---
|
|
811
|
+
|
|
812
|
+
## Supported Agents
|
|
813
|
+
|
|
814
|
+
| Agent | Integration Type | Gate | Record | Status |
|
|
815
|
+
|-------|------------------|------|--------|--------|
|
|
816
|
+
| Claude Code | Pre/Post command hooks | Yes | Yes | Full support |
|
|
817
|
+
| Gemini CLI | Pre/Post command hooks | Yes | Yes | Full support |
|
|
818
|
+
| Copilot CLI | Pre/Post command hooks | Yes | Yes | Full support |
|
|
819
|
+
| OpenCode | Plugin | Yes | Yes | Full support |
|
|
820
|
+
| Moltbot | Hook + Gateway | Yes | Yes | Full support |
|
|
821
|
+
| Aider | Config | -- | -- | Basic support |
|
|
822
|
+
|
|
823
|
+
---
|
|
286
824
|
|
|
287
825
|
## BashGym Integration
|
|
288
826
|
|
|
289
|
-
> **Note**: BashGym is releasing after BashBros. This
|
|
827
|
+
> **Note**: BashGym is releasing after BashBros. This section describes the planned integration interface and may be updated in future versions.
|
|
290
828
|
|
|
291
829
|
BashBros integrates with [BashGym](https://github.com/GhostPeony/bashgym), a self-improving agent training system. When linked, BashBros exports execution traces that BashGym uses to train better AI sidekick models.
|
|
292
830
|
|
|
293
|
-
###
|
|
831
|
+
### Training Loop
|
|
294
832
|
|
|
295
833
|
```
|
|
296
|
-
BashBros captures traces
|
|
834
|
+
BashBros captures traces --> BashGym trains --> GGUF to Ollama --> BashBros sidekick improves
|
|
297
835
|
```
|
|
298
836
|
|
|
299
|
-
1. **Trace Export
|
|
300
|
-
2. **Training
|
|
301
|
-
3. **Model Delivery
|
|
302
|
-
4. **Hot-Swap
|
|
837
|
+
1. **Trace Export** -- BashBros captures command sessions and exports them to `~/.bashgym/integration/traces/pending/`.
|
|
838
|
+
2. **Training** -- BashGym processes traces, classifies quality, and trains models.
|
|
839
|
+
3. **Model Delivery** -- Trained models are exported to GGUF format and registered with Ollama.
|
|
840
|
+
4. **Hot-Swap** -- BashBros detects new models and hot-swaps the sidekick without restart.
|
|
303
841
|
|
|
304
842
|
### Linking to BashGym
|
|
305
843
|
|
|
306
|
-
During `bashbros init`, you
|
|
844
|
+
During `bashbros init`, you will be prompted:
|
|
307
845
|
|
|
308
846
|
```
|
|
309
847
|
? Link to BashGym? (enables self-improving AI sidekick)
|
|
@@ -311,143 +849,68 @@ During `bashbros init`, you'll be asked if you want to link to BashGym:
|
|
|
311
849
|
No - Use bashbros standalone
|
|
312
850
|
```
|
|
313
851
|
|
|
314
|
-
### Shared Directory
|
|
315
|
-
|
|
316
|
-
The integration uses `~/.bashgym/integration/`:
|
|
852
|
+
### Shared Directory Structure
|
|
317
853
|
|
|
318
854
|
```
|
|
319
855
|
~/.bashgym/integration/
|
|
320
|
-
├── traces/pending/
|
|
321
|
-
├── traces/processed/
|
|
322
|
-
├── models/latest/
|
|
856
|
+
├── traces/pending/ # BashBros --> BashGym (new traces)
|
|
857
|
+
├── traces/processed/ # Ingested traces
|
|
858
|
+
├── models/latest/ # BashGym --> BashBros (current model)
|
|
323
859
|
├── models/manifest.json
|
|
860
|
+
├── models/adapters/ # LoRA adapters (GGUF)
|
|
324
861
|
├── config/settings.json
|
|
325
|
-
└── status/
|
|
862
|
+
└── status/ # Heartbeat files
|
|
326
863
|
```
|
|
327
864
|
|
|
328
865
|
### Capture Modes
|
|
329
866
|
|
|
330
|
-
Configure in `settings.json` or via BashGym dashboard:
|
|
331
|
-
|
|
332
867
|
| Mode | Description |
|
|
333
868
|
|------|-------------|
|
|
334
869
|
| `everything` | Capture all sessions |
|
|
335
870
|
| `successful_only` | Only verified/successful traces (default) |
|
|
336
871
|
| `sidekick_curated` | AI picks teachable moments |
|
|
337
872
|
|
|
338
|
-
### Model Hot-Swap
|
|
339
|
-
|
|
340
|
-
When BashGym trains a new model, BashBros detects it automatically:
|
|
341
|
-
|
|
342
|
-
```bash
|
|
343
|
-
$ bashbros status
|
|
344
|
-
# Shows: AI: Connected (bashgym sidekick v3)
|
|
345
|
-
```
|
|
346
|
-
|
|
347
873
|
### Programmatic Usage
|
|
348
874
|
|
|
349
875
|
```typescript
|
|
350
876
|
import { BashBro } from 'bashbros'
|
|
351
|
-
import { getBashgymIntegration } from 'bashbros/integration'
|
|
352
877
|
|
|
353
878
|
const bro = new BashBro({ enableBashgymIntegration: true })
|
|
354
879
|
await bro.initialize()
|
|
355
880
|
|
|
356
|
-
// Check integration status
|
|
357
881
|
if (bro.isUsingBashgymModel()) {
|
|
358
882
|
console.log(`Using model: ${bro.getBashgymModelVersion()}`)
|
|
359
883
|
}
|
|
360
|
-
|
|
361
|
-
// Listen for model updates
|
|
362
|
-
const integration = getBashgymIntegration()
|
|
363
|
-
integration.on('model:updated', (version) => {
|
|
364
|
-
console.log(`New model: ${version}`)
|
|
365
|
-
})
|
|
366
884
|
```
|
|
367
885
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
When linked, BashBros acts as primary security - BashGym defers all security checks to BashBros policies.
|
|
371
|
-
|
|
372
|
-
## API Usage
|
|
373
|
-
|
|
374
|
-
```typescript
|
|
375
|
-
import {
|
|
376
|
-
BashBros,
|
|
377
|
-
PolicyEngine,
|
|
378
|
-
BashBro,
|
|
379
|
-
RiskScorer,
|
|
380
|
-
LoopDetector,
|
|
381
|
-
AnomalyDetector,
|
|
382
|
-
OutputScanner,
|
|
383
|
-
MetricsCollector,
|
|
384
|
-
CostEstimator,
|
|
385
|
-
ReportGenerator,
|
|
386
|
-
ClaudeCodeHooks,
|
|
387
|
-
UndoStack
|
|
388
|
-
} from 'bashbros'
|
|
389
|
-
|
|
390
|
-
// Security middleware
|
|
391
|
-
const bros = new BashBros(config)
|
|
392
|
-
bros.on('command', (cmd, result) => console.log(cmd, result.allowed))
|
|
393
|
-
bros.start()
|
|
394
|
-
|
|
395
|
-
// Risk scoring
|
|
396
|
-
const scorer = new RiskScorer()
|
|
397
|
-
const risk = scorer.score('rm -rf /')
|
|
398
|
-
console.log(risk.level) // 'critical'
|
|
399
|
-
console.log(risk.score) // 10
|
|
400
|
-
|
|
401
|
-
// Loop detection
|
|
402
|
-
const loopDetector = new LoopDetector({ maxRepeats: 3 })
|
|
403
|
-
const alert = loopDetector.check('git status')
|
|
404
|
-
if (alert) console.log('Loop detected:', alert.message)
|
|
405
|
-
|
|
406
|
-
// Session metrics
|
|
407
|
-
const metrics = new MetricsCollector()
|
|
408
|
-
metrics.record({ command: 'ls', ... })
|
|
409
|
-
const report = ReportGenerator.generate(metrics.getMetrics())
|
|
410
|
-
|
|
411
|
-
// Cost estimation
|
|
412
|
-
const cost = new CostEstimator('claude-sonnet-4')
|
|
413
|
-
cost.recordToolCall('command', 'output')
|
|
414
|
-
console.log(cost.getEstimate()) // { estimatedCost: 0.05, ... }
|
|
886
|
+
When linked, BashBros acts as the primary security layer -- BashGym defers all security checks to BashBros policies.
|
|
415
887
|
|
|
416
|
-
|
|
417
|
-
const undo = new UndoStack({ maxStackSize: 50, ttlMinutes: 30 })
|
|
418
|
-
undo.recordModify('/path/to/file')
|
|
419
|
-
undo.undo() // Restores from backup
|
|
888
|
+
---
|
|
420
889
|
|
|
421
|
-
|
|
422
|
-
const scanner = new OutputScanner({ enabled: true, scanForSecrets: true })
|
|
423
|
-
const result = scanner.scan('API_KEY=sk-secret123')
|
|
424
|
-
console.log(result.hasSecrets) // true
|
|
425
|
-
console.log(result.redactedOutput) // 'API_KEY=[REDACTED API Key]'
|
|
890
|
+
## Requirements
|
|
426
891
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
892
|
+
- **Node.js** >= 18
|
|
893
|
+
- **Ollama** (optional, required for AI sidekick features) -- [https://ollama.com](https://ollama.com)
|
|
894
|
+
- **BashGym** (optional, for LoRA adapter management and training pipeline) -- [https://github.com/GhostPeony/bashgym](https://github.com/GhostPeony/bashgym)
|
|
430
895
|
|
|
431
|
-
|
|
432
|
-
const bro = new BashBro()
|
|
433
|
-
await bro.initialize()
|
|
434
|
-
const suggestions = bro.suggest({ lastCommand: 'git status' })
|
|
435
|
-
const explanation = await bro.aiExplain('tar -xzf file.tar.gz')
|
|
436
|
-
```
|
|
896
|
+
---
|
|
437
897
|
|
|
438
898
|
## Development
|
|
439
899
|
|
|
440
900
|
```bash
|
|
901
|
+
git clone https://github.com/GhostPeony/bashbros.git
|
|
902
|
+
cd bashbros
|
|
441
903
|
npm install
|
|
442
904
|
npm run build
|
|
443
|
-
npm test
|
|
905
|
+
npm test
|
|
444
906
|
```
|
|
445
907
|
|
|
908
|
+
---
|
|
909
|
+
|
|
446
910
|
## License
|
|
447
911
|
|
|
448
|
-
MIT
|
|
912
|
+
MIT -- see [LICENSE](./LICENSE) for details.
|
|
449
913
|
|
|
450
|
-
|
|
914
|
+
---
|
|
451
915
|
|
|
452
|
-
|
|
453
|
-
- [GitHub](https://github.com/GhostPeony/bashbros)
|
|
916
|
+
Built by [GhostPeony](https://github.com/GhostPeony) | [bashbros.ai](https://bashbros.ai)
|