@shuyhere/bb-agent 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 BB-Agent Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # BB-Agent
2
+
3
+ A Rust-native AI coding agent for the terminal — featuring a fullscreen TUI, multi-provider support, tool use, session persistence, branching, extensions, and skills.
4
+
5
+ ## Install
6
+
7
+ ### From source (all platforms — macOS, Linux)
8
+
9
+ Requires [Rust](https://rustup.rs). Install Rust first if you don't have it:
10
+
11
+ ```bash
12
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
13
+ source ~/.cargo/env
14
+ ```
15
+
16
+ Then build and install BB-Agent:
17
+
18
+ ```bash
19
+ git clone https://github.com/shuyhere/bb-agent.git
20
+ cd bb-agent
21
+ cargo install --path crates/cli
22
+ ```
23
+
24
+ This compiles the `bb` binary and installs it to `~/.cargo/bin/bb` (which Rust adds to your PATH).
25
+
26
+ ### npm (Linux x86_64 — prebuilt binary)
27
+
28
+ ```bash
29
+ npm install -g @shuyhere/bb-agent
30
+ ```
31
+
32
+ > **macOS / other platforms:** npm install will print instructions to build from source.
33
+ > Prebuilt binaries for macOS coming soon. After install, run `bb` to start.
34
+
35
+ ## Getting Started
36
+
37
+ ### 1. Login to a provider
38
+
39
+ ```bash
40
+ bb login # Interactive provider selection
41
+ bb login anthropic # Login to Anthropic (OAuth)
42
+ bb login openai-codex # Login to OpenAI (OAuth)
43
+ bb login google # Login to Google (API key)
44
+ ```
45
+
46
+ Or set environment variables: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GOOGLE_API_KEY`, etc.
47
+
48
+ ### 2. Start the TUI
49
+
50
+ ```bash
51
+ bb
52
+ ```
53
+
54
+ That's it! Run `bb` to launch the fullscreen interactive terminal UI. Type your prompt and press Enter.
55
+
56
+ ### More ways to use `bb`
57
+
58
+ ```bash
59
+ bb # Launch the fullscreen TUI
60
+ bb "Explain this codebase" # TUI with an initial prompt
61
+ bb -p "What is 2+2?" # Print mode (non-interactive, pipe-friendly)
62
+ bb -c # Continue your last session
63
+ bb -r # Resume: pick from previous sessions
64
+ bb --model sonnet # Use a specific model
65
+ bb --model sonnet:high # Model with extended thinking
66
+ bb --list-models # List all available models
67
+ ```
68
+
69
+ ## Features
70
+
71
+ - **Fullscreen TUI** — rich terminal interface with streaming output, markdown rendering, syntax highlighting
72
+ - **Multi-provider** — Anthropic (Claude), OpenAI, Google (Gemini), Groq, xAI, OpenRouter, and custom OpenAI-compatible endpoints
73
+ - **Built-in tools** — `read`, `write`, `edit`, `bash`, `find`, `grep`, `ls`, `web_search`, `web_fetch`, `browser_fetch`
74
+ - **Session persistence** — SQLite-backed sessions with branching, forking, and tree navigation
75
+ - **Extensions** — JS/TS plugin system for custom tools, commands, and hooks
76
+ - **Skills** — markdown-based instruction files that auto-load contextual knowledge
77
+ - **System prompt templates** — save and switch between named prompt configurations
78
+ - **OAuth login** — browser-based login for Anthropic and OpenAI
79
+
80
+ ## System Prompt Templates
81
+
82
+ Save prompt templates in `~/.bb-agent/system-prompts/` and switch between them:
83
+
84
+ ```bash
85
+ bb --list-templates # List available templates
86
+ bb -t coding # Start with "coding" template
87
+ bb -t research # Start with "research" template
88
+ bb --system-prompt @path/to/file.md # Load prompt from any file
89
+ ```
90
+
91
+ ## Extensions & Skills
92
+
93
+ ```bash
94
+ bb install npm:some-skill # Install a global package
95
+ bb install --local ./my-skill # Install project-local
96
+ bb list # List installed packages
97
+ bb update # Update packages
98
+ ```
99
+
100
+ ## Configuration
101
+
102
+ BB-Agent uses layered configuration:
103
+
104
+ | File | Scope |
105
+ |------|-------|
106
+ | `~/.bb-agent/settings.json` | Global settings |
107
+ | `<project>/.bb-agent/settings.json` | Project settings (overrides global) |
108
+ | `~/.bb-agent/AGENTS.md` or `AGENTS.md` | System prompt additions |
109
+ | `~/.bb-agent/system-prompts/<name>.md` | Named prompt templates |
110
+ | `~/.bb-agent/skills/` | Global skills |
111
+ | `~/.bb-agent/extensions/` | Global extensions |
112
+
113
+ ### Example `settings.json`
114
+
115
+ ```json
116
+ {
117
+ "default_model": "claude-sonnet-4-20250514",
118
+ "default_provider": "anthropic",
119
+ "default_thinking": "medium",
120
+ "models": [
121
+ {
122
+ "id": "my-local-model",
123
+ "provider": "ollama",
124
+ "api": "openai",
125
+ "base_url": "http://localhost:11434/v1",
126
+ "context_window": 32000,
127
+ "max_tokens": 4096
128
+ }
129
+ ]
130
+ }
131
+ ```
132
+
133
+ ## Keyboard Shortcuts
134
+
135
+ | Key | Action |
136
+ |-----|--------|
137
+ | `Enter` | Submit prompt |
138
+ | `Shift+Enter` | Insert newline |
139
+ | `Esc` | Clear input / cancel / exit prompt |
140
+ | `Ctrl+C` | Exit |
141
+ | `Ctrl+P` | Cycle models |
142
+ | `Ctrl+O` | Open settings menu |
143
+ | `Ctrl+Shift+O` | Expand/collapse tool calls |
144
+ | `/` | Slash commands menu |
145
+ | `@` | File mention autocomplete |
146
+
147
+ ## Workspace Crates
148
+
149
+ | Crate | Description |
150
+ |-------|-------------|
151
+ | `bb-core` | Core agent, session, config, and runtime types |
152
+ | `bb-session` | SQLite-backed session storage, branching, context building |
153
+ | `bb-tools` | Built-in tool implementations |
154
+ | `bb-provider` | Model/provider integrations and streaming |
155
+ | `bb-hooks` | Hook event types for extensions |
156
+ | `bb-plugin-host` | Plugin discovery and host runtime |
157
+ | `bb-tui` | Terminal UI components and fullscreen experience |
158
+ | `bb-cli` | The `bb` command-line application |
159
+
160
+ ## Documentation
161
+
162
+ - [Configuration Reference](docs/configuration.md) — settings.json, AGENTS.md, templates
163
+ - [Built-in Tools](docs/tools.md) — all 10 tools with parameters
164
+ - [Extensions & Skills](docs/extensions.md) — plugins, skills, prompts, packages
165
+ - [Providers & Models](docs/providers.md) — authentication, model selection, custom providers
166
+ - [Development Guide](docs/development.md) — build from source, dev workflow, project structure, debugging
167
+ - [Contributing](CONTRIBUTING.md) — code style, PR process
168
+ - [Changelog](CHANGELOG.md) — release history
169
+ - [Security](SECURITY.md) — vulnerability reporting, security model
170
+
171
+ ## Development
172
+
173
+ See the full [Development Guide](docs/development.md) for detailed instructions.
174
+
175
+ ```bash
176
+ git clone https://github.com/shuyhere/bb-agent.git
177
+ cd bb-agent
178
+ cargo install --path crates/cli # Build + install to ~/.cargo/bin/bb
179
+ bb # Run it
180
+ ```
181
+
182
+ Dev cycle:
183
+ ```bash
184
+ cargo run --bin bb # Run without installing
185
+ cargo test --workspace --release # Run all 435 tests
186
+ cargo fmt --all # Format
187
+ cargo clippy --workspace # Lint
188
+ ```
189
+
190
+ ## License
191
+
192
+ [MIT License](LICENSE)
package/bin/bb ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { execFileSync } = require("child_process");
6
+ const path = require("path");
7
+ const fs = require("fs");
8
+
9
+ function findBinary() {
10
+ // 1. Check native/ dir (downloaded by postinstall)
11
+ const nativeBin = path.join(__dirname, "..", "native", "bb");
12
+ if (fs.existsSync(nativeBin)) {
13
+ try { fs.accessSync(nativeBin, fs.constants.X_OK); return nativeBin; } catch {}
14
+ }
15
+
16
+ // 2. Check PATH (cargo install)
17
+ const dirs = (process.env.PATH || "").split(path.delimiter);
18
+ for (const dir of dirs) {
19
+ // Skip our own bin/ dir to avoid infinite recursion
20
+ if (path.resolve(dir) === path.resolve(__dirname)) continue;
21
+ const full = path.join(dir, "bb");
22
+ try { fs.accessSync(full, fs.constants.X_OK); return full; } catch {}
23
+ }
24
+
25
+ return null;
26
+ }
27
+
28
+ const binary = findBinary();
29
+
30
+ if (!binary) {
31
+ console.error(`
32
+ BB-Agent binary not found.
33
+
34
+ Install Rust (if needed):
35
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
36
+ source ~/.cargo/env
37
+
38
+ Then build BB-Agent:
39
+ git clone https://github.com/shuyhere/bb-agent.git
40
+ cd bb-agent && cargo install --path crates/cli
41
+
42
+ Then run:
43
+ bb
44
+ `;
45
+ process.exit(1);
46
+ }
47
+
48
+ try {
49
+ execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
50
+ } catch (err) {
51
+ process.exit(err.status || 1);
52
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@shuyhere/bb-agent",
3
+ "version": "0.0.1",
4
+ "description": "BB-Agent — a Rust-native AI coding agent for the terminal",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/shuyhere/bb-agent.git"
9
+ },
10
+ "homepage": "https://github.com/shuyhere/bb-agent",
11
+ "author": "shuyhere",
12
+ "keywords": [
13
+ "ai",
14
+ "coding-agent",
15
+ "cli",
16
+ "terminal",
17
+ "tui",
18
+ "llm",
19
+ "anthropic",
20
+ "claude",
21
+ "openai",
22
+ "rust"
23
+ ],
24
+ "bin": {
25
+ "bb": "bin/bb"
26
+ },
27
+ "files": [
28
+ "bin/",
29
+ "scripts/",
30
+ "README.md",
31
+ "LICENSE"
32
+ ],
33
+ "scripts": {
34
+ "postinstall": "node scripts/postinstall.js"
35
+ },
36
+ "os": [
37
+ "darwin",
38
+ "linux"
39
+ ],
40
+ "cpu": [
41
+ "x64",
42
+ "arm64"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "engines": {
48
+ "node": ">=16"
49
+ }
50
+ }
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { execSync } = require("child_process");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const os = require("os");
9
+ const https = require("https");
10
+
11
+ const VERSION = "0.0.1";
12
+ const REPO = "shuyhere/bb-agent";
13
+ const NATIVE_DIR = path.join(__dirname, "..", "native");
14
+ const DOWNLOAD_TIMEOUT_MS = 15_000;
15
+
16
+ function getTarget() {
17
+ const platform = os.platform();
18
+ const arch = os.arch();
19
+
20
+ const platformMap = { darwin: "apple-darwin", linux: "unknown-linux-gnu" };
21
+ const archMap = { x64: "x86_64", arm64: "aarch64" };
22
+
23
+ const p = platformMap[platform];
24
+ const a = archMap[arch];
25
+ if (!p || !a) return null;
26
+ return `${a}-${p}`;
27
+ }
28
+
29
+ function downloadBinary(url, dest, timeoutMs) {
30
+ return new Promise((resolve, reject) => {
31
+ const timer = setTimeout(() => reject(new Error("Download timed out")), timeoutMs);
32
+
33
+ const follow = (url, redirects = 0) => {
34
+ if (redirects > 5) { clearTimeout(timer); return reject(new Error("Too many redirects")); }
35
+
36
+ const mod = url.startsWith("https") ? https : require("http");
37
+ const req = mod.get(url, (res) => {
38
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
39
+ return follow(res.headers.location, redirects + 1);
40
+ }
41
+ if (res.statusCode !== 200) {
42
+ clearTimeout(timer);
43
+ return reject(new Error(`HTTP ${res.statusCode}`));
44
+ }
45
+ const file = fs.createWriteStream(dest);
46
+ res.pipe(file);
47
+ file.on("finish", () => { clearTimeout(timer); file.close(); resolve(); });
48
+ file.on("error", (e) => { clearTimeout(timer); reject(e); });
49
+ });
50
+ req.on("error", (e) => { clearTimeout(timer); reject(e); });
51
+ req.on("timeout", () => { req.destroy(); clearTimeout(timer); reject(new Error("Request timed out")); });
52
+ };
53
+ follow(url);
54
+ });
55
+ }
56
+
57
+ async function tryDownloadPrebuilt(target) {
58
+ const assetName = `bb-${target}`;
59
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`;
60
+
61
+ fs.mkdirSync(NATIVE_DIR, { recursive: true });
62
+ const dest = path.join(NATIVE_DIR, "bb");
63
+
64
+ try {
65
+ console.log(`Downloading BB-Agent v${VERSION} for ${target}...`);
66
+ await downloadBinary(url, dest, DOWNLOAD_TIMEOUT_MS);
67
+ fs.chmodSync(dest, 0o755);
68
+
69
+ // Verify the binary is executable
70
+ try {
71
+ execSync(`"${dest}" --version`, { stdio: "pipe", timeout: 5000 });
72
+ } catch {
73
+ // Binary may not run on this platform (e.g. wrong arch) — remove it
74
+ fs.unlinkSync(dest);
75
+ return false;
76
+ }
77
+
78
+ console.log("✓ BB-Agent binary installed successfully.");
79
+ return true;
80
+ } catch (err) {
81
+ // Clean up partial download
82
+ try { fs.unlinkSync(dest); } catch {}
83
+ return false;
84
+ }
85
+ }
86
+
87
+ function findInPath(name) {
88
+ const dirs = (process.env.PATH || "").split(path.delimiter);
89
+ for (const dir of dirs) {
90
+ const full = path.join(dir, name);
91
+ try {
92
+ fs.accessSync(full, fs.constants.X_OK);
93
+ return full;
94
+ } catch {}
95
+ }
96
+ return null;
97
+ }
98
+
99
+ function checkExistingInstall() {
100
+ const existing = findInPath("bb");
101
+ if (!existing) return false;
102
+
103
+ try {
104
+ const version = execSync(`"${existing}" --version`, { encoding: "utf8", timeout: 5000 }).trim();
105
+ console.log(`✓ BB-Agent already installed: ${version} (${existing})`);
106
+ return true;
107
+ } catch {
108
+ return false;
109
+ }
110
+ }
111
+
112
+ async function main() {
113
+ if (process.env.BB_SKIP_POSTINSTALL) {
114
+ return;
115
+ }
116
+
117
+ // Already installed via cargo install?
118
+ if (checkExistingInstall()) return;
119
+
120
+ const target = getTarget();
121
+
122
+ // Try prebuilt binary
123
+ if (target) {
124
+ const ok = await tryDownloadPrebuilt(target);
125
+ if (ok) return;
126
+ }
127
+
128
+ // No prebuilt available — print instructions instead of trying cargo build
129
+ // (cargo build takes 5+ minutes and would appear to hang)
130
+ const platform = `${os.platform()}-${os.arch()}`;
131
+ console.log("");
132
+ console.log("╔══════════════════════════════════════════════════════════════╗");
133
+ console.log("║ BB-Agent: no prebuilt binary for " + platform.padEnd(19) + " ║");
134
+ console.log("║ ║");
135
+ console.log("║ Install Rust (if needed): ║");
136
+ console.log("║ curl --proto '=https' --tlsv1.2 -sSf https://rustup.rs|sh ║");
137
+ console.log("║ source ~/.cargo/env ║");
138
+ console.log("║ ║");
139
+ console.log("║ Then build BB-Agent: ║");
140
+ console.log("║ git clone https://github.com/shuyhere/bb-agent.git ║");
141
+ console.log("║ cd bb-agent && cargo install --path crates/cli ║");
142
+ console.log("║ ║");
143
+ console.log("║ Then run: bb ║");
144
+ console.log("╚══════════════════════════════════════════════════════════════╝");
145
+ console.log("");
146
+ }
147
+
148
+ main().catch((err) => {
149
+ // Never fail npm install — just print instructions
150
+ console.error("BB-Agent postinstall notice:", err.message);
151
+ console.log("Install manually: git clone https://github.com/shuyhere/bb-agent.git && cd bb-agent && cargo install --path crates/cli");
152
+ });