Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc05781

Browse files
PsiACEampcode-com
andcommitted
docs: polish README and docs with consistent voice and accurate content
- Rewrite README with project stance: 'A common shape for agents that live alongside people' - Align tagline across pyproject.toml, mkdocs.yml, and CLI help string - Fix stale config defaults (max_steps 8→50, timeout 90→None) - Remove references to deleted features (bub install, BUB_RUNTIME_ENABLED) - Add back source file pointers, AGENTS.md behavior, and plugin extensibility - Flatten doc layout: remove core/index.md and workflows/index.md hub pages - Move cli.md into channels/ alongside telegram.md - Reorder nav: Core → Channels → Skills → Deployment → Extension Guide → Posts - Fix cli.md command count (five → four main + two hidden) - Fix CONTRIBUTING.md misnumbered steps Amp-Thread-ID: https://ampcode.com/threads/T-019d01bc-cdc1-742c-9a6a-d11945bd793a Co-authored-by: Amp <[email protected]>
1 parent 856889d commit fc05781

12 files changed

Lines changed: 150 additions & 174 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Then, install and activate the environment with:
6868
uv sync
6969
```
7070

71-
1. Install prek to run linters/formatters at commit time:
71+
4. Install prek to run linters/formatters at commit time:
7272

7373
```bash
7474
uv run prek install
@@ -96,7 +96,7 @@ Now, validate that all unit tests are passing:
9696
just test
9797
```
9898

99-
9. Before raising a pull request you should also run tox.
99+
8. Before raising a pull request you should also run tox.
100100
This will run the tests across different versions of Python:
101101

102102
```bash

README.md

Lines changed: 85 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,135 @@
11
# Bub
22

3-
[Bub](https://github.com/bubbuild/bub) is a common shape for agents.
3+
**A common shape for agents that live alongside people.**
44

5-
It starts from a simple question: if there are many agents in the world, what kind of agent is a Bub?
5+
Bub started in group chats. Not as a demo or a personal assistant, but as a teammate that had to coexist with real humans and other agents in the same messy conversations — concurrent tasks, incomplete context, and nobody waiting.
66

7-
A Bub is an agent that can live inside shared operator environments with explicit boundaries, visible execution evidence, and safe handoff.
7+
It is hook-first, built on [pluggy](https://pluggy.readthedocs.io/), with a small core (~200 lines) and builtins that are just default plugins you can replace. Context comes from [tape](https://tape.systems), not session accumulation. The same pipeline runs across CLI, Telegram, and any channel you add.
88

9-
The point is not only to complete tasks, but to remain understandable, reviewable, and continuable when more humans and agents join the work.
9+
[Website](https://bub.build) · [GitHub](https://github.com/bubbuild/bub)
1010

11-
## Current Implementation
12-
13-
This repository is the current Python implementation of Bub.
14-
It is hook-first, built on `pluggy`, and keeps the core small while builtins and plugins provide behavior.
15-
In this implementation, Bub uses [Republic](https://github.com/bubbuild/republic) as its context runtime and [constructs context from tape](https://tape.systems).
11+
## Quick Start
1612

17-
- CLI bootstrap: `src/bub/__main__.py` (Typer app)
18-
- Turn orchestrator: `src/bub/framework.py`
19-
- Hook contract: `src/bub/hookspecs.py`
20-
- Builtin hooks/runtime: `src/bub/builtin/hook_impl.py` + `src/bub/builtin/engine.py`
21-
- Skill discovery and validation: `src/bub/skills.py`
13+
```bash
14+
pip install bub
15+
```
2216

23-
## Quick Start
17+
Or from source:
2418

2519
```bash
2620
git clone https://github.com/bubbuild/bub.git
2721
cd bub
2822
uv sync
29-
uv run bub --help
3023
```
3124

3225
```bash
33-
# Runtime off: falls back to model_output=prompt
34-
BUB_RUNTIME_ENABLED=0 uv run bub run "hello"
26+
uv run bub chat # interactive session
27+
uv run bub run "summarize this repo" # one-shot task
28+
uv run bub gateway # channel listener mode
3529
```
3630

37-
```bash
38-
# Internal command mode (line starts with ',')
39-
BUB_RUNTIME_ENABLED=0 uv run bub run ",help"
40-
```
31+
## How It Works
4132

42-
```bash
43-
# Model runtime (hosted providers usually require a key)
44-
BUB_API_KEY=your_key uv run bub run "Summarize this repository"
45-
```
33+
Every inbound message goes through one turn pipeline. Each stage is a hook.
4634

47-
```bash
48-
# OpenAI Codex OAuth (no provider API key required)
49-
uv run bub login openai
50-
BUB_MODEL=openai:gpt-5-codex uv run bub chat
5135
```
36+
resolve_session → load_state → build_prompt → run_model
37+
38+
dispatch_outbound ← render_outbound ← save_state
39+
```
40+
41+
Builtins are plugins registered first. Later plugins override earlier ones. No special cases.
5242

53-
## CLI Commands
43+
If `AGENTS.md` exists in the workspace, it is appended to the system prompt automatically.
5444

55-
- `bub run MESSAGE`: execute one inbound turn and print outbound messages
56-
- `bub login openai`: persist OpenAI Codex OAuth credentials for later runs
57-
- `bub hooks`: print hook-to-plugin bindings
58-
- `bub install PLUGIN_SPEC`: install plugin from PyPI or `owner/repo` (GitHub shorthand)
45+
Key source files:
5946

60-
## Runtime Behavior
47+
- Turn orchestrator: [`src/bub/framework.py`](src/bub/framework.py)
48+
- Hook contract: [`src/bub/hookspecs.py`](src/bub/hookspecs.py)
49+
- Builtin hooks: [`src/bub/builtin/hook_impl.py`](src/bub/builtin/hook_impl.py)
50+
- Skill discovery: [`src/bub/skills.py`](src/bub/skills.py)
6151

62-
- Regular text input: uses `run_model`; if runtime is unavailable, output falls back to the prompt text
63-
- Comma commands: `,help`, `,tools`, `,fs.read ...`, etc.
64-
- Unknown comma commands: executed as `bash -lc` in workspace
65-
- Session event log: `.bub/runtime/<session-hash>.jsonl`
66-
- `AGENTS.md`: if present in workspace, appended to runtime system prompt
52+
## What Sets It Apart
6753

68-
## Skills
54+
Bub grew up in multi-person chats with multiple agents running at the same time. Single-user flows hide structural problems; shared environments expose them fast. That shaped a few things:
6955

70-
- Discovery roots with deterministic override:
71-
1. `<workspace>/.agent/skills`
72-
2. `~/.agent/skills`
73-
3. `src/skills`
74-
- Each skill directory must include `SKILL.md`
75-
- Supported frontmatter fields:
76-
- required: `name`, `description`
77-
- optional: `license`, `compatibility`, `metadata`, `allowed-tools`
56+
- **Context from tape.** History is append-only facts. Anchors mark phase transitions. Context is assembled on demand — not accumulated, not compressed into lossy summaries.
57+
- **Hooks all the way down.** The turn pipeline *is* hooks. Override `build_prompt`, `run_model`, or `render_outbound` to change behavior. The core does not privilege its own builtins.
58+
- **One pipeline across channels.** CLI and Telegram share the same `process_inbound()` path. Hooks don't know which channel they're in.
59+
- **Skills as documents.** Skills are `SKILL.md` files with validated frontmatter, not code modules with magic registration.
7860

79-
## Plugin Development
61+
## Extend It
8062

81-
Plugins are loaded from Python entry points in `group="bub"`:
63+
```python
64+
from bub import hookimpl
65+
66+
class EchoPlugin:
67+
@hookimpl
68+
def build_prompt(self, message, session_id, state):
69+
return f"[echo] {message['content']}"
70+
71+
@hookimpl
72+
async def run_model(self, prompt, session_id, state):
73+
return prompt
74+
```
8275

8376
```toml
8477
[project.entry-points."bub"]
85-
my_plugin = "my_package.my_plugin"
78+
echo = "my_package.plugin:EchoPlugin"
8679
```
8780

88-
Implement hooks with `@hookimpl` following `BubHookSpecs`.
81+
See the [Extension Guide](https://bub.build/extension-guide/) for hook semantics and plugin packaging.
8982

90-
## Runtime Environment Variables
83+
## CLI
9184

92-
- `BUB_RUNTIME_ENABLED`: `auto` (default), `1`, `0`
93-
- `BUB_MODEL`: default `openrouter:qwen/qwen3-coder-next`
94-
- `BUB_API_KEY`: runtime provider key; optional when using `openai:*` models with `bub login openai`
95-
- `BUB_API_BASE`: optional provider base URL
96-
- `BUB_API_FORMAT`: upstream API shape; default `completion`
97-
Use `responses` for OpenAI Responses-compatible providers and `messages` for chat-completions-style providers.
98-
- `BUB_RUNTIME_MAX_STEPS`: default `8`
99-
- `BUB_RUNTIME_MAX_TOKENS`: default `1024`
100-
- `BUB_RUNTIME_MODEL_TIMEOUT_SECONDS`: default `90`
85+
| Command | Description |
86+
|---------|-------------|
87+
| `bub chat` | Interactive REPL |
88+
| `bub run MESSAGE` | One-shot turn |
89+
| `bub gateway` | Channel listener (Telegram, etc.) |
90+
| `bub login openai` | OpenAI Codex OAuth |
91+
| `bub hooks` | Print hook-to-plugin bindings |
10192

102-
```bash
103-
# Use a Responses-compatible upstream API.
104-
BUB_MODEL=openai:gpt-5-codex \
105-
BUB_API_FORMAT=responses \
106-
uv run bub chat
107-
```
93+
Lines starting with `,` enter internal command mode (`,help`, `,tools`, `,fs.read path=README.md`).
94+
95+
## Configuration
10896

109-
## Documentation
97+
| Variable | Default | Description |
98+
|----------|---------|-------------|
99+
| `BUB_MODEL` | `openrouter:qwen/qwen3-coder-next` | Model identifier |
100+
| `BUB_API_KEY` || Provider key (optional with `bub login openai`) |
101+
| `BUB_API_BASE` || Custom provider endpoint |
102+
| `BUB_API_FORMAT` | `completion` | `completion`, `responses`, or `messages` |
103+
| `BUB_RUNTIME_MAX_STEPS` | `50` | Max tool-use loop iterations |
104+
| `BUB_RUNTIME_MAX_TOKENS` | `1024` | Max tokens per model call |
105+
| `BUB_RUNTIME_MODEL_TIMEOUT_SECONDS` || Model call timeout (seconds) |
110106

111-
- `docs/index.md`: overview
112-
- `docs/architecture.md`: lifecycle, precedence, and failure isolation
113-
- `docs/skills.md`: skill discovery and frontmatter constraints
114-
- `docs/cli.md`: CLI usage and comma command mode
115-
- `docs/features.md`: implemented capabilities and limits
107+
## Background
116108

117-
## Development Checks
109+
We care less about whether an agent can finish a demo task, and more about whether it can coexist with real people under real conditions. Context is not baggage to carry forever — it is a working set, constructed when needed and let go when done.
110+
111+
Read more: [Context from Tape](https://tape.systems) · [Socialized Evaluation and Agent Partnership](https://bub.build/posts/2026-03-01-bub-socialized-evaluation-and-agent-partnership/)
112+
113+
## Docs
114+
115+
- [Architecture](https://bub.build/architecture/) — lifecycle, hook precedence, error handling
116+
- [Features](https://bub.build/features/) — what ships today and current boundaries
117+
- [CLI](https://bub.build/cli/) — commands and comma mode
118+
- [Skills](https://bub.build/skills/) — discovery and authoring
119+
- [Extension Guide](https://bub.build/extension-guide/) — hooks, tools, plugin packaging
120+
- [Channels](https://bub.build/channels/) — adapters and sessions
121+
- [Deployment](https://bub.build/deployment/) — Docker, Telegram, operations
122+
123+
## Development
118124

119125
```bash
120126
uv run ruff check .
121127
uv run mypy src
122128
uv run pytest -q
123129
```
124130

131+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
132+
125133
## License
126134

127135
[Apache-2.0](./LICENSE)

docs/cli.md renamed to docs/channels/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CLI
22

3-
`bub` currently exposes five builtin commands: `run`, `gateway`, `chat`, `login`, and the hidden compatibility command `message`.
3+
`bub` exposes four main commands (`run`, `gateway`, `chat`, `login`) plus two hidden ones (`hooks` for diagnostics, `message` as a compatibility alias for `gateway`).
44

55
## `bub run`
66

docs/channels/index.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# Channels
22

3-
Bub uses channel adapters to run the same agent pipeline across different I/O endpoints.
3+
Bub uses channel adapters to run the same pipeline across different I/O endpoints. Hooks don't know which channel they're in.
44

55
## Builtin Channels
66

7-
- `cli`: local interactive terminal channel (`uv run bub chat`)
8-
- `telegram`: Telegram bot channel (`uv run bub gateway`)
9-
10-
See [Telegram](telegram.md) for channel-specific configuration and runtime behavior.
7+
- `cli`: local interactive terminal — see [CLI](cli.md)
8+
- `telegram`: Telegram bot — see [Telegram](telegram.md)
119

1210
## Run Modes
1311

docs/core/index.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/features.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
# Key Features
22

3-
## Framework Core
3+
## Hook-First Runtime
44

5-
- Hook-first architecture powered by `pluggy`.
6-
- Deterministic turn pipeline in `BubFramework.process_inbound()`.
7-
- Safe fallback to prompt text when `run_model` returns no value (with `on_error` notification).
8-
- Automatic fallback outbound when `render_outbound` produces nothing.
5+
Every turn stage is a [pluggy](https://pluggy.readthedocs.io/) hook.
6+
Builtins are ordinary plugins — override any stage by registering your own.
7+
Both first-result hooks (override) and broadcast hooks (observer) are supported.
8+
Safe fallback to prompt text when `run_model` returns no value (with `on_error` notification).
9+
Automatic fallback outbound when `render_outbound` produces nothing.
910

10-
## Runtime And Commands
11+
## Tape-Based Context
1112

12-
- Builtin CLI commands: `run`, `hooks`, `message`, `chat`.
13-
- Builtin `RuntimeEngine`:
14-
- normal input goes through model + tool loop (Republic)
15-
- comma-prefixed input enters internal command mode (`,help`, `,tools`, `,fs.read`, etc.)
16-
- unknown internal commands fall back to shell execution via the `bash` tool
17-
- Runtime events are persisted to tapes (default under `~/.bub/tapes`).
13+
Runtime events are recorded to tapes (default under `~/.bub/tapes`).
14+
Context is reconstructed from tape records, not accumulated in session state.
1815

19-
## Channel Capability
16+
## Builtin Batteries
2017

21-
- Builtin channels: `cli` and `telegram`.
22-
- `message` mode runs the same framework pipeline for channel-driven traffic.
23-
- Outbound delivery is routed by `ChannelManager`, keeping business hooks channel-agnostic.
18+
- **CLI**: `run`, `chat`, `gateway`, `login`, `hooks` via Typer.
19+
- **Model runtime**: agent loop with tool use, backed by [Republic](https://github.com/bubbuild/republic).
20+
- **Comma commands**: `,help`, `,tools`, `,fs.read`, etc. Unknown commands fall back to shell.
21+
- **Channels**: `cli` and `telegram` ship as defaults.
22+
23+
All of these are hook implementations. Replace what you need.
24+
25+
## Channel-Agnostic Pipeline
26+
27+
CLI and Telegram use the same `process_inbound()` path.
28+
Hooks don't know which channel they're in.
29+
Outbound routing is handled by `ChannelManager`.
30+
31+
## Skills
32+
33+
Skills are `SKILL.md` files with validated frontmatter.
34+
Plugins can ship their own by including a `skills/` directory.
2435

2536
## Plugin Extensibility
2637

27-
- External plugins are loaded via Python entry points (`group="bub"`).
28-
- Later-registered plugins run first and can override builtin behavior.
29-
- Supports both first-result hooks (override style) and broadcast hooks (observer style).
38+
External plugins are loaded via Python entry points (`group="bub"`).
39+
Later-registered plugins run first and can override builtin behavior.
3040

3141
## Current Boundaries
3242

33-
- No strict envelope schema: `Envelope` is intentionally flexible.
43+
- `Envelope` is intentionally weakly typed (`Any` + accessor helpers).
3444
- No centralized key contract for shared plugin `state`.
35-
- Core repository does not currently ship a builtin Discord channel adapter.
45+
- No builtin Discord adapter — implement one via `provide_channels`.

0 commit comments

Comments
 (0)