bdo-cli 0.44.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.
- package/CHANGELOG.md +1207 -0
- package/LICENSE +191 -0
- package/README.md +585 -0
- package/binary-install.js +348 -0
- package/binary.js +124 -0
- package/install.js +4 -0
- package/npm-shrinkwrap.json +52 -0
- package/package.json +99 -0
- package/run-bdo.js +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="logo.svg" alt="BDO (Bushido) Logo" width="600">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>High-performance CLI proxy that reduces LLM token consumption by 60-90%</strong>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/tedorigawa001/TokenReductionTool/actions"><img src="https://github.com/tedorigawa001/TokenReductionTool/workflows/Security%20Check/badge.svg" alt="CI"></a>
|
|
11
|
+
<a href="https://github.com/tedorigawa001/TokenReductionTool/releases"><img src="https://img.shields.io/github/v/release/tedorigawa001/TokenReductionTool" alt="Release"></a>
|
|
12
|
+
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License: Apache 2.0"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://github.com/tedorigawa001/TokenReductionTool">Website</a> •
|
|
17
|
+
<a href="#installation">Install</a> •
|
|
18
|
+
<a href="docs/guide/resources/troubleshooting.md">Troubleshooting</a> •
|
|
19
|
+
<a href="docs/contributing/ARCHITECTURE.md">Architecture</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<a href="README.md">English</a> •
|
|
24
|
+
<a href="README_ja.md">日本語</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
bdo filters and compresses command outputs before they reach your LLM context. Single Rust binary, 100+ supported commands, <10ms overhead.
|
|
30
|
+
|
|
31
|
+
## Token Savings (30-min Claude Code Session)
|
|
32
|
+
|
|
33
|
+
| Operation | Frequency | Standard | bdo | Savings |
|
|
34
|
+
|-----------|-----------|----------|-----|---------|
|
|
35
|
+
| `ls` / `tree` | 10x | 2,000 | 400 | -80% |
|
|
36
|
+
| `cat` / `read` | 20x | 40,000 | 12,000 | -70% |
|
|
37
|
+
| `grep` / `rg` | 8x | 16,000 | 3,200 | -80% |
|
|
38
|
+
| `git status` | 10x | 3,000 | 600 | -80% |
|
|
39
|
+
| `git diff` | 5x | 10,000 | 2,500 | -75% |
|
|
40
|
+
| `git log` | 5x | 2,500 | 500 | -80% |
|
|
41
|
+
| `git add/commit/push` | 8x | 1,600 | 120 | -92% |
|
|
42
|
+
| `cargo test` / `npm test` | 5x | 25,000 | 2,500 | -90% |
|
|
43
|
+
| `ruff check` | 3x | 3,000 | 600 | -80% |
|
|
44
|
+
| `pytest` | 4x | 8,000 | 800 | -90% |
|
|
45
|
+
| `go test` | 3x | 6,000 | 600 | -90% |
|
|
46
|
+
| `docker ps` | 3x | 900 | 180 | -80% |
|
|
47
|
+
| **Total** | | **~118,000** | **~23,900** | **-80%** |
|
|
48
|
+
|
|
49
|
+
> Estimates based on medium-sized TypeScript/Rust projects. Actual savings vary by project size.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
### Homebrew
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
brew tap tedorigawa001/tap && brew install bdo
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Quick Install (Linux/macOS)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
curl -fsSL https://raw.githubusercontent.com/tedorigawa001/TokenReductionTool/refs/heads/master/install.sh | sh
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
> Installs to `~/.local/bin`. Add to PATH if needed:
|
|
66
|
+
> ```bash
|
|
67
|
+
> echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # or ~/.zshrc
|
|
68
|
+
> ```
|
|
69
|
+
|
|
70
|
+
### Cargo
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cargo install --git https://github.com/tedorigawa001/TokenReductionTool
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Pre-built Binaries
|
|
77
|
+
|
|
78
|
+
Download from [releases](https://github.com/tedorigawa001/TokenReductionTool/releases):
|
|
79
|
+
- macOS: `bdo-x86_64-apple-darwin.tar.gz` / `bdo-aarch64-apple-darwin.tar.gz`
|
|
80
|
+
- Linux: `bdo-x86_64-unknown-linux-musl.tar.gz` / `bdo-aarch64-unknown-linux-gnu.tar.gz`
|
|
81
|
+
- Windows: `bdo-x86_64-pc-windows-msvc.zip`
|
|
82
|
+
|
|
83
|
+
> **Windows users**: Extract the zip and place `bdo.exe` somewhere in your PATH (e.g. `C:\Users\<you>\.local\bin`). Run Bushido from **Command Prompt**, **PowerShell**, or **Windows Terminal** — do not double-click the `.exe` (it will flash and close). For the best experience, use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) where the full hook system works natively. See [Windows setup](#windows) below for details.
|
|
84
|
+
|
|
85
|
+
### Verify Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
bdo --version # Should show "bdo 0.43.0"
|
|
89
|
+
bdo gain # Should show token savings stats
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Quick Start
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# 1. Install for your AI tool
|
|
96
|
+
bdo init -g # Claude Code / Copilot (default)
|
|
97
|
+
bdo init -g --gemini # Gemini CLI
|
|
98
|
+
bdo init -g --codex # Codex (OpenAI)
|
|
99
|
+
bdo init -g --agent cursor # Cursor
|
|
100
|
+
bdo init -g --agent windsurf # Windsurf
|
|
101
|
+
bdo init --agent cline # Cline / Roo Code
|
|
102
|
+
bdo init --agent kilocode # Kilo Code
|
|
103
|
+
bdo init --agent antigravity # Google Antigravity
|
|
104
|
+
bdo init -g --agent pi # Pi
|
|
105
|
+
bdo init --agent hermes # Hermes
|
|
106
|
+
|
|
107
|
+
# 2. Restart your AI tool, then test
|
|
108
|
+
git status # Automatically rewritten to bdo git status
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Hook-based agents rewrite Bash commands (e.g., `git status` -> `bdo git status`) before execution. Plugin-based agents, including Hermes, use their plugin API to rewrite commands before execution. The agent receives compact output without needing to call `bdo` explicitly.
|
|
112
|
+
|
|
113
|
+
**Important:** the hook only runs on Bash tool calls. Claude Code built-in tools like `Read`, `Grep`, and `Glob` do not pass through the Bash hook, so they are not auto-rewritten. To get Bushido's compact output for those workflows, use shell commands (`cat`/`head`/`tail`, `rg`/`grep`, `find`) or call `bdo read`, `bdo grep`, or `bdo find` directly.
|
|
114
|
+
|
|
115
|
+
## How It Works
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
Without bdo: With bdo:
|
|
119
|
+
|
|
120
|
+
Claude --git status--> shell --> git Claude --git status--> Bushido --> git
|
|
121
|
+
^ | ^ | |
|
|
122
|
+
| ~2,000 tokens (raw) | | ~200 tokens | filter |
|
|
123
|
+
+-----------------------------------+ +------- (filtered) ---+----------+
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Four strategies applied per command type:
|
|
127
|
+
|
|
128
|
+
1. **Smart Filtering** - Removes noise (comments, whitespace, boilerplate)
|
|
129
|
+
2. **Grouping** - Aggregates similar items (files by directory, errors by type)
|
|
130
|
+
3. **Truncation** - Keeps relevant context, cuts redundancy
|
|
131
|
+
4. **Deduplication** - Collapses repeated log lines with counts
|
|
132
|
+
|
|
133
|
+
## Commands
|
|
134
|
+
|
|
135
|
+
### Files
|
|
136
|
+
```bash
|
|
137
|
+
bdo ls . # Token-optimized directory tree
|
|
138
|
+
bdo read file.rs # Auto: light cleanup, smart truncation for large source files
|
|
139
|
+
bdo read file.rs -l none # Full content when exact text matters
|
|
140
|
+
bdo read file.rs -l aggressive # Heavier cleanup (drops more boilerplate)
|
|
141
|
+
bdo read file.rs -l outline # Signatures only — every fn/struct/trait, bodies elided
|
|
142
|
+
bdo map src/ # Repo map: top-level signatures of every file under a dir
|
|
143
|
+
bdo smart file.rs # 2-line heuristic code summary
|
|
144
|
+
bdo find "*.rs" . # Compact find results
|
|
145
|
+
bdo grep "pattern" . # Grouped search results
|
|
146
|
+
bdo diff file1 file2 # Condensed diff
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`find`/`grep` always print the true total and a `+N more — use --all …` line
|
|
150
|
+
when the display is capped, so matches are never dropped silently; `--all`
|
|
151
|
+
lifts every cap (the result count and grep's per-file cap).
|
|
152
|
+
|
|
153
|
+
#### Code map (`bdo map`)
|
|
154
|
+
|
|
155
|
+
Get the API surface of an entire directory in one shot — every file's top-level
|
|
156
|
+
declarations, function bodies elided. Ideal for onboarding an agent to a new
|
|
157
|
+
codebase without reading (and paying for) every file.
|
|
158
|
+
|
|
159
|
+
```console
|
|
160
|
+
$ bdo map src/core
|
|
161
|
+
runner.rs
|
|
162
|
+
pub fn run(cmd: Command, tool_name: &str, args_display: &str, mode: RunMode<'_>, opts: RunOptions<'_>) -> Result<i32> { … }
|
|
163
|
+
pub struct RunOptions<'a> { … }
|
|
164
|
+
pub enum RunMode<'a> { … }
|
|
165
|
+
stream.rs
|
|
166
|
+
pub trait StreamFilter { … }
|
|
167
|
+
pub fn run_streaming(cmd: &mut Command, stdin_mode: StdinMode, stdout_mode: FilterMode<'_>) -> Result<StreamResult> { … }
|
|
168
|
+
…
|
|
169
|
+
— 16 files, 245 signatures (full source: 9,188 lines)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
On this repo that's **~74,000 tokens of source rendered in ~3,500** (≈95%
|
|
173
|
+
reduction) with the complete top-level API intact. Supports Rust, Go, JS/TS, C,
|
|
174
|
+
C++, Java, and Python; respects `.gitignore`.
|
|
175
|
+
|
|
176
|
+
`bdo map --changed` narrows the map to the git change set (add
|
|
177
|
+
`--against origin/main` for the whole-branch diff) — the API surface you touched,
|
|
178
|
+
ideal alongside `bdo review`.
|
|
179
|
+
|
|
180
|
+
For Python, function bodies are elided with a `…` marker (the analogue of
|
|
181
|
+
`{ … }`), `async def` is handled like `def`, and multi-line signatures are
|
|
182
|
+
folded onto one line:
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
async def run(task: Task, retries: int = 3) -> Result: …
|
|
186
|
+
class Config: …
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### Change review (`bdo review`)
|
|
190
|
+
|
|
191
|
+
A one-shot summary of a change set for human + agent review — what you'd
|
|
192
|
+
otherwise assemble by hand from `git status`, `rg`, and `cargo test`:
|
|
193
|
+
|
|
194
|
+
```console
|
|
195
|
+
$ bdo review # working-tree changes (default)
|
|
196
|
+
$ bdo review --against origin/main # whole-branch diff vs a ref
|
|
197
|
+
|
|
198
|
+
bdo review — 3 changed file(s) (uncommitted)
|
|
199
|
+
|
|
200
|
+
CHANGED
|
|
201
|
+
M src/core/filter.rs
|
|
202
|
+
?? src/cmds/system/review.rs
|
|
203
|
+
|
|
204
|
+
⚠ ARTIFACTS (0)
|
|
205
|
+
✓ none
|
|
206
|
+
⚠ STALE MARKERS (1) — verify before commit
|
|
207
|
+
scripts/x.sh:27 broken install URL (blob serves HTML)
|
|
208
|
+
|
|
209
|
+
🧪 SUGGESTED TESTS
|
|
210
|
+
cargo test -- filter review
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
It flags stray build artifacts (`__pycache__`, `target/`, `.bak` …), high-signal
|
|
214
|
+
stale markers (legacy names, broken install URLs), and the inline test modules
|
|
215
|
+
worth running for the changed Rust files.
|
|
216
|
+
|
|
217
|
+
#### Residue audit (`bdo stale`)
|
|
218
|
+
|
|
219
|
+
Where `bdo review` checks the change set, `bdo stale` audits the **whole tracked
|
|
220
|
+
tree** for residue — generated artifacts that slipped into git and high-signal
|
|
221
|
+
stale strings (legacy names, broken install URLs) — and exits non-zero when any
|
|
222
|
+
are found, so it can gate CI:
|
|
223
|
+
|
|
224
|
+
```console
|
|
225
|
+
$ bdo stale # whole repo (or: bdo stale <path>)
|
|
226
|
+
bdo stale — scanned 312 tracked files
|
|
227
|
+
|
|
228
|
+
⚠ TRACKED ARTIFACTS (0)
|
|
229
|
+
✓ none
|
|
230
|
+
⚠ STALE MARKERS (1)
|
|
231
|
+
scripts/x.sh:27 broken install URL (blob serves HTML)
|
|
232
|
+
|
|
233
|
+
✗ 1 residue item(s) found
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Add a `.bdostaleignore` (gitignore-style globs) for files that legitimately
|
|
237
|
+
*document* residue — a changelog or rename ledger — so they aren't flagged.
|
|
238
|
+
|
|
239
|
+
### Git
|
|
240
|
+
```bash
|
|
241
|
+
bdo git status # Compact status
|
|
242
|
+
bdo git log -n 10 # One-line commits
|
|
243
|
+
bdo git diff # Condensed diff
|
|
244
|
+
bdo git add # -> "ok"
|
|
245
|
+
bdo git commit -m "msg" # -> "ok abc1234"
|
|
246
|
+
bdo git push # -> "ok main"
|
|
247
|
+
bdo git pull # -> "ok 3 files +10 -2"
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### GitHub CLI
|
|
251
|
+
```bash
|
|
252
|
+
bdo gh pr list # Compact PR listing
|
|
253
|
+
bdo gh pr view 42 # PR details + checks
|
|
254
|
+
bdo gh issue list # Compact issue listing
|
|
255
|
+
bdo gh run list # Workflow run status
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Test Runners
|
|
259
|
+
```bash
|
|
260
|
+
bdo jest # Jest compact (failures only)
|
|
261
|
+
bdo vitest # Vitest compact (failures only)
|
|
262
|
+
bdo playwright test # E2E results (failures only)
|
|
263
|
+
bdo pytest # Python tests (-90%)
|
|
264
|
+
bdo go test # Go tests (NDJSON, -90%)
|
|
265
|
+
bdo cargo test # Cargo tests (-90%)
|
|
266
|
+
bdo rake test # Ruby minitest (-90%)
|
|
267
|
+
bdo rspec # RSpec tests (JSON, -60%+)
|
|
268
|
+
bdo err <cmd> # Filter errors only from any command
|
|
269
|
+
bdo test <cmd> # Generic test wrapper - failures only (-90%)
|
|
270
|
+
bdo test --changed # Run only tests for changed Rust files (+ --against <ref>)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
`bdo test --changed` derives `cargo test -- <stems>` from the git change set
|
|
274
|
+
(file stem = inline test module, e.g. `src/core/outline.rs` → `outline`) and
|
|
275
|
+
runs just those, failures-only — pairs with `bdo review`/`bdo map --changed`.
|
|
276
|
+
|
|
277
|
+
### Build & Lint
|
|
278
|
+
```bash
|
|
279
|
+
bdo lint # ESLint grouped by rule/file
|
|
280
|
+
bdo lint biome # Supports other linters
|
|
281
|
+
bdo tsc # TypeScript errors grouped by file
|
|
282
|
+
bdo next build # Next.js build compact
|
|
283
|
+
bdo prettier --check . # Files needing formatting
|
|
284
|
+
bdo cargo build # Cargo build (-80%)
|
|
285
|
+
bdo cargo clippy # Cargo clippy (-80%)
|
|
286
|
+
bdo ruff check # Python linting (JSON, -80%)
|
|
287
|
+
bdo golangci-lint run # Go linting (JSON, -85%)
|
|
288
|
+
bdo rubocop # Ruby linting (JSON, -60%+)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Package Managers
|
|
292
|
+
```bash
|
|
293
|
+
bdo pnpm list # Compact dependency tree
|
|
294
|
+
bdo pip list # Python packages (auto-detect uv)
|
|
295
|
+
bdo pip outdated # Outdated packages
|
|
296
|
+
bdo bundle install # Ruby gems (strip Using lines)
|
|
297
|
+
bdo prisma generate # Schema generation (no ASCII art)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### AWS
|
|
301
|
+
```bash
|
|
302
|
+
bdo aws sts get-caller-identity # One-line identity
|
|
303
|
+
bdo aws ec2 describe-instances # Compact instance list
|
|
304
|
+
bdo aws lambda list-functions # Name/runtime/memory (strips secrets)
|
|
305
|
+
bdo aws logs get-log-events # Timestamped messages only
|
|
306
|
+
bdo aws cloudformation describe-stack-events # Failures first
|
|
307
|
+
bdo aws dynamodb scan # Unwraps type annotations
|
|
308
|
+
bdo aws iam list-roles # Strips policy documents
|
|
309
|
+
bdo aws s3 ls # Truncated with tee recovery
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Containers
|
|
313
|
+
```bash
|
|
314
|
+
bdo docker ps # Compact container list
|
|
315
|
+
bdo docker images # Compact image list
|
|
316
|
+
bdo docker logs <container> # Deduplicated logs
|
|
317
|
+
bdo docker compose ps # Compose services
|
|
318
|
+
bdo kubectl pods # Compact pod list
|
|
319
|
+
bdo kubectl logs <pod> # Deduplicated logs
|
|
320
|
+
bdo kubectl services # Compact service list
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Data & Analytics
|
|
324
|
+
```bash
|
|
325
|
+
bdo json config.json # Structure without values
|
|
326
|
+
bdo deps # Dependencies summary
|
|
327
|
+
bdo env -f AWS # Filtered env vars
|
|
328
|
+
bdo log app.log # Deduplicated logs
|
|
329
|
+
bdo curl <url> # Truncate + save full output
|
|
330
|
+
bdo wget <url> # Download, strip progress bars
|
|
331
|
+
bdo summary <long command> # Heuristic summary
|
|
332
|
+
bdo proxy <command> # Raw passthrough + tracking
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Token Savings Analytics
|
|
336
|
+
```bash
|
|
337
|
+
bdo gain # Summary stats
|
|
338
|
+
bdo gain --graph # ASCII graph (last 30 days)
|
|
339
|
+
bdo gain --history # Recent command history
|
|
340
|
+
bdo gain --daily # Day-by-day breakdown
|
|
341
|
+
bdo gain --by-agent # Savings split by AI agent (claude/gemini/copilot/…)
|
|
342
|
+
bdo gain --all --format json # JSON export for dashboards
|
|
343
|
+
|
|
344
|
+
bdo discover # Find missed savings opportunities
|
|
345
|
+
bdo discover --all --since 7 # All projects, last 7 days
|
|
346
|
+
|
|
347
|
+
bdo session # Show Bushido adoption across recent sessions
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
`--by-agent` attributes each command to the AI agent that ran it — auto-detected
|
|
351
|
+
from the agent's environment (Claude Code, Gemini CLI, Copilot, Cursor), or set
|
|
352
|
+
explicitly via `BDO_AGENT=<name>`. Commands with no detectable agent show as
|
|
353
|
+
`(other/direct)`.
|
|
354
|
+
|
|
355
|
+
## Global Flags
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
-u, --ultra-compact # ASCII icons, inline format (extra token savings)
|
|
359
|
+
-v, --verbose # Increase verbosity (-v, -vv, -vvv)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Examples
|
|
363
|
+
|
|
364
|
+
**Directory listing:**
|
|
365
|
+
```
|
|
366
|
+
# ls -la (45 lines, ~800 tokens) # bdo ls (12 lines, ~150 tokens)
|
|
367
|
+
drwxr-xr-x 15 user staff 480 ... my-project/
|
|
368
|
+
-rw-r--r-- 1 user staff 1234 ... +-- src/ (8 files)
|
|
369
|
+
... | +-- main.rs
|
|
370
|
+
+-- Cargo.toml
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Git operations:**
|
|
374
|
+
```
|
|
375
|
+
# git push (15 lines, ~200 tokens) # bdo git push (1 line, ~10 tokens)
|
|
376
|
+
Enumerating objects: 5, done. ok main
|
|
377
|
+
Counting objects: 100% (5/5), done.
|
|
378
|
+
Delta compression using up to 8 threads
|
|
379
|
+
...
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Test output:**
|
|
383
|
+
```
|
|
384
|
+
# cargo test (200+ lines on failure) # bdo test cargo test (~20 lines)
|
|
385
|
+
running 15 tests FAILED: 2/15 tests
|
|
386
|
+
test utils::test_parse ... ok test_edge_case: assertion failed
|
|
387
|
+
test utils::test_format ... ok test_overflow: panic at utils.rs:18
|
|
388
|
+
...
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## Auto-Rewrite Hook
|
|
392
|
+
|
|
393
|
+
The most effective way to use Bushido. The hook transparently intercepts Bash commands and rewrites them to bdo equivalents before execution.
|
|
394
|
+
|
|
395
|
+
**Result**: 100% bdo adoption across all conversations and subagents, zero token overhead.
|
|
396
|
+
|
|
397
|
+
**Scope note:** this only applies to Bash tool calls. Claude Code built-in tools such as `Read`, `Grep`, and `Glob` bypass the hook, so use shell commands or explicit `bdo` commands when you want Bushido filtering there.
|
|
398
|
+
|
|
399
|
+
### Setup
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
bdo init -g # Install hook + Bushido.md (recommended)
|
|
403
|
+
bdo init -g --opencode # OpenCode plugin (instead of Claude Code)
|
|
404
|
+
bdo init -g --auto-patch # Non-interactive (CI/CD)
|
|
405
|
+
bdo init -g --hook-only # Hook only, no Bushido.md
|
|
406
|
+
bdo init --show # Verify installation
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
After install, **restart Claude Code**.
|
|
410
|
+
|
|
411
|
+
## Windows
|
|
412
|
+
|
|
413
|
+
Bushido works on Windows with some limitations. The auto-rewrite hook (`bdo hook`) requires a Unix shell, so on native Windows Bushido falls back to **CLAUDE.md injection mode** — your AI assistant receives Bushido instructions but commands are not rewritten automatically.
|
|
414
|
+
|
|
415
|
+
### Recommended: WSL (full support)
|
|
416
|
+
|
|
417
|
+
For the best experience, use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) (Windows Subsystem for Linux). Inside WSL, Bushido works exactly like Linux — full hook support, auto-rewrite, everything:
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
# Inside WSL
|
|
421
|
+
curl -fsSL https://raw.githubusercontent.com/tedorigawa001/TokenReductionTool/refs/heads/master/install.sh | sh
|
|
422
|
+
bdo init -g
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Native Windows (limited support)
|
|
426
|
+
|
|
427
|
+
On native Windows (cmd.exe / PowerShell), Bushido filters work but the hook does not auto-rewrite commands:
|
|
428
|
+
|
|
429
|
+
```powershell
|
|
430
|
+
# 1. Download and extract bdo-x86_64-pc-windows-msvc.zip from releases
|
|
431
|
+
# 2. Add bdo.exe to your PATH
|
|
432
|
+
# 3. Initialize (falls back to CLAUDE.md injection)
|
|
433
|
+
bdo init -g
|
|
434
|
+
# 4. Use bdo explicitly
|
|
435
|
+
bdo cargo test
|
|
436
|
+
bdo git status
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**Important**: Do not double-click `bdo.exe` — it is a CLI tool that prints usage and exits immediately. Always run it from a terminal (Command Prompt, PowerShell, or Windows Terminal).
|
|
440
|
+
|
|
441
|
+
| Feature | WSL | Native Windows |
|
|
442
|
+
|---------|-----|----------------|
|
|
443
|
+
| Filters (cargo, git, etc.) | Full | Full |
|
|
444
|
+
| Auto-rewrite hook | Yes | No (CLAUDE.md fallback) |
|
|
445
|
+
| `bdo init -g` | Hook mode | CLAUDE.md mode |
|
|
446
|
+
| `bdo gain` / analytics | Full | Full |
|
|
447
|
+
|
|
448
|
+
## Supported AI Tools
|
|
449
|
+
|
|
450
|
+
Bushido supports 14 AI coding tools. Each integration rewrites shell commands to `bdo` equivalents for 60-90% token savings where the agent supports command interception.
|
|
451
|
+
|
|
452
|
+
| Tool | Install | Method |
|
|
453
|
+
|------|---------|--------|
|
|
454
|
+
| **Claude Code** | `bdo init -g` | PreToolUse hook (bash) |
|
|
455
|
+
| **GitHub Copilot (VS Code)** | `bdo init -g --copilot` | PreToolUse hook — transparent rewrite |
|
|
456
|
+
| **GitHub Copilot CLI** | `bdo init -g --copilot` | PreToolUse deny-with-suggestion (CLI limitation) |
|
|
457
|
+
| **Cursor** | `bdo init -g --agent cursor` | preToolUse hook (hooks.json) |
|
|
458
|
+
| **Gemini CLI** | `bdo init -g --gemini` | BeforeTool hook |
|
|
459
|
+
| **Codex** | `bdo init -g --codex` | AGENTS.md + Bushido.md instructions |
|
|
460
|
+
| **Windsurf** | `bdo init -g --agent windsurf` | .windsurfrules (project-scoped) |
|
|
461
|
+
| **Cline / Roo Code** | `bdo init --agent cline` | .clinerules (project-scoped) |
|
|
462
|
+
| **OpenCode** | `bdo init -g --opencode` | Plugin TS (tool.execute.before) |
|
|
463
|
+
| **OpenClaw** | `openclaw plugins install ./openclaw` | Plugin TS (before_tool_call) |
|
|
464
|
+
| **Pi** | `bdo init -g --agent pi` (global) | TypeScript extension (tool_call) |
|
|
465
|
+
| **Hermes** | `bdo init --agent hermes` | Python plugin adapter (terminal command mutation via `bdo rewrite`) |
|
|
466
|
+
| **Mistral Vibe** | Planned ([#800](https://github.com/tedorigawa001/TokenReductionTool/issues/800)) | Blocked on upstream |
|
|
467
|
+
| **Kilo Code** | `bdo init --agent kilocode` | .kilocode/rules/bdo-rules.md (project-scoped) |
|
|
468
|
+
| **Google Antigravity** | `bdo init --agent antigravity` | .agents/rules/antigravity-bdo-rules.md (project-scoped) |
|
|
469
|
+
|
|
470
|
+
For per-agent setup details, override controls, and graceful degradation, see the [Supported Agents guide](docs/guide/getting-started/supported-agents.md). The Hermes plugin source and tests live in `hooks/hermes/`; installed Hermes runtime files still live under `~/.hermes/plugins/bdo-rewrite/`.
|
|
471
|
+
|
|
472
|
+
## Configuration
|
|
473
|
+
|
|
474
|
+
`~/.config/bdo/config.toml` (macOS: `~/Library/Application Support/bdo/config.toml`):
|
|
475
|
+
|
|
476
|
+
```toml
|
|
477
|
+
[hooks]
|
|
478
|
+
exclude_commands = ["curl", "playwright"] # skip rewrite for these
|
|
479
|
+
|
|
480
|
+
[tee]
|
|
481
|
+
enabled = true # save raw output on failure (default: true)
|
|
482
|
+
mode = "failures" # "failures", "always", or "never"
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
When a command fails, Bushido saves the full unfiltered output so the LLM can read it without re-executing:
|
|
486
|
+
|
|
487
|
+
```
|
|
488
|
+
FAILED: 2/15 tests
|
|
489
|
+
[full output: ~/.local/share/bdo/tee/1707753600_cargo_test.log]
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
For the full config reference (all sections, env vars, per-project filters), see the [Configuration guide](docs/guide/getting-started/configuration.md).
|
|
493
|
+
|
|
494
|
+
### Uninstall
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
bdo init -g --uninstall # Remove hook, Bushido.md, settings.json entry
|
|
498
|
+
cargo uninstall bdo # Remove binary
|
|
499
|
+
brew uninstall bdo # If installed via Homebrew
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
## Documentation
|
|
503
|
+
|
|
504
|
+
- **[docs/guide](https://github.com/tedorigawa001/TokenReductionTool/tree/master/docs/guide)** — full user guide (installation, supported agents, what gets optimized, analytics, configuration, troubleshooting)
|
|
505
|
+
- **[INSTALL.md](INSTALL.md)** — detailed installation reference
|
|
506
|
+
- **[ARCHITECTURE.md](docs/contributing/ARCHITECTURE.md)** — system design and technical decisions
|
|
507
|
+
- **[CONTRIBUTING.md](CONTRIBUTING.md)** — contribution guide
|
|
508
|
+
- **[SECURITY.md](SECURITY.md)** — security policy
|
|
509
|
+
|
|
510
|
+
## Privacy & Telemetry
|
|
511
|
+
|
|
512
|
+
Bushido can collect **anonymous, aggregate usage metrics** once per day. Telemetry is **disabled by default** and requires **explicit opt-in consent** (GDPR Art. 6, 7) during `bdo init` or via `bdo telemetry enable`. This data helps us build a better product: identifying which commands need filters, which filters need improvement, and how much value Bushido delivers. For the full list of fields, data handling, and contributor guidelines, see **[docs/TELEMETRY.md](docs/TELEMETRY.md)**.
|
|
513
|
+
|
|
514
|
+
**What is collected and why:**
|
|
515
|
+
|
|
516
|
+
| Category | Data | Why |
|
|
517
|
+
|----------|------|-----|
|
|
518
|
+
| Identity | Salted device hash (SHA-256, not reversible) | Count unique installations without tracking individuals |
|
|
519
|
+
| Environment | Bushido version, OS, architecture, install method | Know which platforms to support and test |
|
|
520
|
+
| Usage volume | Command count (24h), total commands, tokens saved (24h/30d/total) | Measure adoption and value delivered |
|
|
521
|
+
| Quality | Top 5 passthrough commands (0% savings), parse failure count, commands with <30% savings | Identify missing filters and weak ones to improve |
|
|
522
|
+
| Ecosystem | Command category distribution (e.g. git 45%, cargo 20%, js 15%) | Prioritize filter development for popular ecosystems |
|
|
523
|
+
| Retention | Days since first use, active days in last 30 | Understand engagement and detect churn |
|
|
524
|
+
| Adoption | AI agent hook type (claude/gemini/codex), custom TOML filter count | Track integration coverage and DSL adoption |
|
|
525
|
+
| Configuration | Whether config.toml exists, number of excluded commands, project count | Understand user maturity and customization patterns |
|
|
526
|
+
| Features | Usage counts for meta-commands (gain, discover, proxy, verify) | Know which Bushido features are valued vs unused |
|
|
527
|
+
| Economics | Estimated USD savings (based on API token pricing) | Quantify the value Bushido provides to users |
|
|
528
|
+
|
|
529
|
+
All data is **aggregate counts or anonymized command names** (first 3 words, no arguments). Top commands report only tool names (e.g. "git", "cargo"), never full command lines.
|
|
530
|
+
|
|
531
|
+
**What is NOT collected:** source code, file paths, command arguments, secrets, environment variables, personal data, or repository contents.
|
|
532
|
+
|
|
533
|
+
**Manage telemetry:**
|
|
534
|
+
```bash
|
|
535
|
+
bdo telemetry status # Check current consent state
|
|
536
|
+
bdo telemetry enable # Give consent (interactive prompt)
|
|
537
|
+
bdo telemetry disable # Withdraw consent — stops all collection immediately
|
|
538
|
+
bdo telemetry forget # Withdraw consent + delete all local data + request server-side erasure
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
**Override via environment:**
|
|
542
|
+
```bash
|
|
543
|
+
export BDO_TELEMETRY_DISABLED=1 # Blocks telemetry regardless of consent
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
## Star History
|
|
547
|
+
|
|
548
|
+
<a href="https://www.star-history.com/?repos=tedorigawa001%2FTokenReductionTool&type=date&legend=top-left">
|
|
549
|
+
<picture>
|
|
550
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=tedorigawa001/TokenReductionTool&type=date&theme=dark&legend=top-left" />
|
|
551
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=tedorigawa001/TokenReductionTool&type=date&legend=top-left" />
|
|
552
|
+
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=tedorigawa001/TokenReductionTool&type=date&legend=top-left" />
|
|
553
|
+
</picture>
|
|
554
|
+
</a>
|
|
555
|
+
|
|
556
|
+
## StarMapper
|
|
557
|
+
|
|
558
|
+
<a href="https://starmapper.bruniaux.com/tedorigawa001/TokenReductionTool">
|
|
559
|
+
<picture>
|
|
560
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://starmapper.bruniaux.com/api/map-image/tedorigawa001/TokenReductionTool?theme=dark" />
|
|
561
|
+
<source media="(prefers-color-scheme: light)" srcset="https://starmapper.bruniaux.com/api/map-image/tedorigawa001/TokenReductionTool?theme=light" />
|
|
562
|
+
<img alt="StarMapper" src="https://starmapper.bruniaux.com/api/map-image/tedorigawa001/TokenReductionTool" />
|
|
563
|
+
</picture>
|
|
564
|
+
</a>
|
|
565
|
+
|
|
566
|
+
## Core team
|
|
567
|
+
|
|
568
|
+
- **Patrick Szymkowiak** — Founder
|
|
569
|
+
[GitHub](https://github.com/pszymkowiak) · [LinkedIn](https://www.linkedin.com/in/patrick-szymkowiak/)
|
|
570
|
+
- **Florian Bruniaux** — Core contributor
|
|
571
|
+
[GitHub](https://github.com/FlorianBruniaux) · [LinkedIn](https://www.linkedin.com/in/florian-bruniaux-43408b83/)
|
|
572
|
+
- **Adrien Eppling** — Core contributor
|
|
573
|
+
[GitHub](https://github.com/aeppling) · [LinkedIn](https://www.linkedin.com/in/adrien-eppling/)
|
|
574
|
+
|
|
575
|
+
## Contributing
|
|
576
|
+
|
|
577
|
+
Contributions welcome! Please open an issue or PR on [GitHub](https://github.com/tedorigawa001/TokenReductionTool).
|
|
578
|
+
|
|
579
|
+
## License
|
|
580
|
+
|
|
581
|
+
Apache License 2.0 - see [LICENSE](LICENSE) for details.
|
|
582
|
+
|
|
583
|
+
## Disclaimer
|
|
584
|
+
|
|
585
|
+
See [DISCLAIMER.md](DISCLAIMER.md).
|