bashbros 0.1.2 → 0.1.4

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