Skip to content

Commit 374d8fb

Browse files
author
Евгений Балякин
committed
Prepare 0.2.0 release
1 parent d9a960b commit 374d8fb

57 files changed

Lines changed: 3118 additions & 421 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
## 0.2.0
4+
5+
- Repositioned codebone as a context engine for AI coding agents.
6+
- Added reproducible token-savings benchmark.
7+
- Improved task-focused context packs.
8+
- Added impact analysis via CLI and MCP.
9+
- Added `.codeboneignore`, `.codebonerc.json`, resource limits, pagination, and MCP in-memory cache.
10+
- Added docs for Claude Code, Codex CLI, Cline, and OpenCode.
11+
- Strengthened MCP schema contract tests.

LICENSE

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

3-
Copyright (c) Evgeny Balyakin
3+
Copyright (c) 2026 Evgeny Balyakin
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 269 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,324 @@
11
# codebone
22

3-
Agent-native CLI and MCP server for compact, read-only code context.
3+
**Stop AI coding agents from wasting tokens on grep.**
44

5-
## Quick Start
5+
`codebone` is a local, read-only CLI and MCP server that gives AI coding agents compact, symbol-aware context from your real checkout. It is meant for Claude Code, Codex CLI, Cline, OpenCode, and any other client that can use stdio MCP servers.
6+
7+
Agents usually edit better than they search. `codebone` handles the boring part first: map the project, find the symbols, read only the relevant bodies, and check likely impact before the agent starts changing files.
8+
9+
![codebone terminal screenshot](docs/assets/codebone-terminal.svg)
10+
11+
## What You Get
12+
13+
- a compact project map with languages, entrypoints, imports, exports, and suggested first reads
14+
- file and directory skeletons instead of full-file dumps
15+
- symbol search for definitions, references, imports, and exports
16+
- exact reads by symbol, symbol id, or line range
17+
- task-focused context packs with a fixed token budget
18+
- impact analysis for likely references, related files, and tests
19+
- stable JSON responses for MCP clients
20+
- local-only analysis with no telemetry, no LLM calls, and no source upload
21+
22+
The short version: use `codebone` before an agent opens half the repository.
23+
24+
## Install
25+
26+
```bash
27+
npm install -g codebone
28+
codebone doctor --root /absolute/path/to/repo
29+
```
30+
31+
Requires Node.js 18 or newer.
32+
33+
Runtime analysis does not call LLM APIs, upload source code, or shell out to `grep`, `rg`, `git`, language toolchains, or package managers. The explicit `codebone index` command is the only command in the normal workflow that writes a local `.codebone/index.v1` cache.
34+
35+
## 60-Second Demo
36+
37+
Run this inside any repository:
38+
39+
```bash
40+
codebone doctor
41+
codebone map . --format json --limit 20
42+
codebone skeleton src/index.ts --signatures
43+
codebone context --goal "understand MCP server implementation" --budget 8000 --format json
44+
codebone impact src/mcp-server.ts --format md
45+
```
46+
47+
Local development works the same way:
648

749
```bash
850
npm install
951
npm run build
10-
npx codebone doctor
11-
npx codebone skeleton src --format json
12-
npx codebone mcp --root .
52+
node dist/index.js doctor
53+
```
54+
55+
## The Agent Workflow
56+
57+
Without `codebone`, a coding agent often does this:
58+
59+
1. search for a vague term
60+
2. open a long list of files
61+
3. read unrelated code
62+
4. spend the context window on setup instead of the actual change
63+
5. ask for more context
64+
65+
With `codebone`, the same agent can start with:
66+
67+
1. `codebone_map` to understand the repository shape
68+
2. `codebone_symbols` to locate the real symbols
69+
3. `codebone_read` to read exact function or class bodies
70+
4. `codebone_context` to build a compact task pack
71+
5. `codebone_impact` to see likely affected files and tests
72+
73+
That does not replace judgment. It just gives the agent a smaller, cleaner first pass.
74+
75+
## MCP Setup
76+
77+
Use stdio transport and pass an absolute `--root`.
78+
79+
```bash
80+
codebone mcp --root /absolute/path/to/repo
1381
```
1482

15-
## MCP Configuration
83+
### Claude Code
84+
85+
Checked against Anthropic Claude Code MCP docs on 2026-05-17.
86+
87+
```bash
88+
claude mcp add codebone -- codebone mcp --root /absolute/path/to/repo
89+
```
1690

17-
Claude Code `.claude/mcp.json`:
91+
Project `.mcp.json`:
1892

1993
```json
2094
{
2195
"mcpServers": {
2296
"codebone": {
23-
"command": "npx",
24-
"args": ["-y", "codebone", "mcp", "--root", "."]
97+
"command": "codebone",
98+
"args": ["mcp", "--root", "/absolute/path/to/repo"]
2599
}
26100
}
27101
}
28102
```
29103

30-
Cline settings:
104+
### Codex CLI
105+
106+
Checked against OpenAI Codex CLI MCP configuration docs on 2026-05-17.
107+
108+
Add this to `~/.codex/config.toml`:
109+
110+
```toml
111+
[mcp_servers.codebone]
112+
command = "codebone"
113+
args = ["mcp", "--root", "/absolute/path/to/repo"]
114+
enabled = true
115+
startup_timeout_sec = 20
116+
tool_timeout_sec = 120
117+
```
118+
119+
### Cline
120+
121+
Checked against Cline MCP configuration docs on 2026-05-17.
122+
123+
```bash
124+
cline mcp add codebone -- codebone mcp --root /absolute/path/to/repo
125+
```
126+
127+
Or edit `cline_mcp_settings.json`:
31128

32129
```json
33130
{
34-
"cline.mcpServers": {
131+
"mcpServers": {
35132
"codebone": {
36-
"command": "npx",
37-
"args": ["-y", "codebone", "mcp", "--root", "."]
133+
"command": "codebone",
134+
"args": ["mcp", "--root", "/absolute/path/to/repo"],
135+
"disabled": false,
136+
"alwaysAllow": []
38137
}
39138
}
40139
}
41140
```
42141

43-
OpenCode example:
142+
### OpenCode
143+
144+
Checked against OpenCode MCP server docs on 2026-05-17.
145+
146+
`opencode.json`:
44147

45148
```json
46149
{
150+
"$schema": "https://opencode.ai/config.json",
47151
"mcp": {
48152
"codebone": {
49-
"command": "npx",
50-
"args": ["-y", "codebone", "mcp", "--root", "."]
153+
"type": "local",
154+
"command": ["codebone", "mcp", "--root", "/absolute/path/to/repo"],
155+
"enabled": true
51156
}
52157
}
53158
}
54159
```
55160

56-
Codex CLI `~/.codex/config.toml`:
161+
More client notes live in [docs/mcp-clients.md](docs/mcp-clients.md).
57162

58-
```toml
59-
[mcp_servers.codebone]
60-
command = "npx"
61-
args = ["-y", "codebone", "mcp", "--root", "."]
163+
## CLI Commands
164+
165+
```bash
166+
codebone map . --limit 100 --offset 0
167+
codebone skeleton src/index.ts --signatures
168+
codebone symbols src --query createServer --limit 20
169+
codebone read src/mcp-server.ts --symbol createSdkServer
170+
codebone context --goal "add MCP impact tool" --symbols "createSdkServer" --budget 8000
171+
codebone impact src/mcp-server.ts --symbol createSdkServer --format md
172+
codebone index .
173+
codebone doctor
174+
```
175+
176+
## MCP Tools
177+
178+
- `codebone_map` - compact project overview
179+
- `codebone_skeleton` - file or directory structure without full bodies
180+
- `codebone_symbols` - definitions, references, imports, and exports
181+
- `codebone_read` - exact symbol, line range, or small-file reads
182+
- `codebone_context` - task-focused context pack
183+
- `codebone_impact` - likely affected files, references, relationships, and tests
184+
- `codebone_index` - optional local index for repeated lookups
185+
- `codebone_batch` - multiple operations in one MCP call
186+
- `codebone_doctor` - parser, config, cache, limit, and setup diagnostics
187+
188+
Every successful MCP call returns structured data, a human-readable text payload, `schemaVersion: "codebone.v1"`, `warnings`, `truncated`, `tokenEstimate`, and `tokenEstimator: "char-div-4"` where token estimates apply.
189+
190+
See [docs/tools.md](docs/tools.md) for schemas and examples.
191+
192+
## Why Not Just Use Grep?
193+
194+
`grep` and `ripgrep` are excellent human tools. They are a poor first interface for agents because they return lines, not decisions. An agent still has to guess which files matter, open too much code, and spend context on discovery.
195+
196+
`codebone` gives an agent a higher-level shape first: project map, skeletons, symbols, exact reads, context packs, and impact hints.
197+
198+
## Why Not LSP or RAG?
199+
200+
LSP is great inside an IDE. `codebone` is different: it exposes agent-native CLI and MCP tools with stable JSON, budgeted output, and no IDE requirement. It can complement LSP rather than replace it.
201+
202+
RAG and embeddings can help with documentation and semantic search, but they are often stale, remote, or expensive to refresh. `codebone` reads the live local checkout and keeps the default runtime path simple.
203+
204+
## Language Support
205+
206+
Gold support:
207+
208+
- TypeScript
209+
- Python
210+
- Go
211+
- Rust
212+
213+
Gold means parser smoke coverage exists and symbol extraction is syntax-aware.
214+
215+
Fallback support:
216+
217+
- JavaScript
218+
- Java
219+
- C / C++
220+
- C#
221+
- Ruby
222+
- PHP
223+
- Swift
224+
- Kotlin
225+
- Lua
226+
227+
Fallback means `codebone` uses lightweight syntax rules and text fallback. It is useful for maps and rough context, but it is not promised to match Gold precision.
228+
229+
## Security model
230+
231+
`codebone` is safe to expose to coding agents by default:
232+
233+
- read-only source analysis
234+
- no source-code upload
235+
- no telemetry
236+
- no LLM API calls
237+
- no runtime shell-outs to external code tools
238+
- root path confinement
239+
- stable MCP error shapes instead of uncaught crashes
240+
- ignored, generated, binary, and oversized files skipped before expensive reads
241+
242+
The explicit `codebone index` command writes an optional local `.codebone/index.v1` index. Other runtime analysis commands are local read-only.
243+
244+
## Configuration
245+
246+
Config precedence:
247+
248+
1. CLI flags
249+
2. `.codebonerc.json`
250+
3. `package.json#codebone`
251+
4. defaults
252+
253+
Example:
254+
255+
```json
256+
{
257+
"defaultBudget": 8000,
258+
"maxBudget": 50000,
259+
"batchBudget": 50000,
260+
"maxFiles": 10000,
261+
"maxFileBytes": 1048576,
262+
"timeoutMs": 30000,
263+
"cache": { "enabled": true, "maxFiles": 5000, "maxBytes": 67108864 },
264+
"ignore": ["dist/**", "*.generated.*"],
265+
"testPatterns": ["**/*.test.*", "**/*.spec.*", "tests/**"],
266+
"entrypoints": ["src/index.ts"]
267+
}
62268
```
63269

64-
## Commands
270+
Token estimates use:
65271

66-
- `codebone map [directory]`
67-
- `codebone skeleton <path>`
68-
- `codebone symbols <path> --query <name>`
69-
- `codebone read <path> --symbol-id <id>`
70-
- `codebone read <path> --symbol <name>`
71-
- `codebone read <path> --lines 10:30`
72-
- `codebone context --goal "task"`
73-
- `codebone index [directory]`
74-
- `codebone batch`
75-
- `codebone doctor`
76-
- `codebone mcp`
272+
```text
273+
estimatedTokens = ceil(charCount / 4)
274+
```
77275

78-
The current implementation is read-only and zero external CLI. It supports TypeScript, JavaScript, Python, Go, Rust, Java, C/C++, C#, Ruby, PHP, Swift, Kotlin, and Lua with syntax-aware extraction rules.
276+
Responses that report estimates also identify the estimator as `char-div-4`. This is a deterministic budget estimate, not a model-specific tokenizer.
79277

80-
## Language Tiers
278+
See [docs/configuration.md](docs/configuration.md).
81279

82-
- Gold: TypeScript, Python, Go, Rust tree-sitter WASM parser smoke coverage.
83-
- Fallback: JavaScript, Java, C/C++, C#, Ruby, PHP, Swift, Kotlin, Lua syntax-rule extraction.
84-
- References are AST-first where queries expose `@reference`, with text fallback otherwise.
280+
## Token savings benchmark
85281

86-
## Release Check
282+
Run:
87283

88284
```bash
89-
npm run release:check
285+
npm run bench:tokens
90286
```
91287

92-
## MCP Inspector
288+
The benchmark compares a naive full-file exploration baseline with a `codebone` context pack on the current repository. It is intentionally local and simple; treat it as a reproducible context-size comparison, not as a scientific LLM evaluation.
289+
290+
## Documentation
93291

94-
After `npm run build`, run:
292+
- [Quickstart](docs/quickstart.md)
293+
- [MCP clients](docs/mcp-clients.md)
294+
- [MCP tools](docs/tools.md)
295+
- [Agent instructions](docs/agent-instructions.md)
296+
- [Configuration](docs/configuration.md)
297+
298+
## Development
299+
300+
```bash
301+
npm install
302+
npm run typecheck
303+
npm test
304+
npm run build
305+
npm run bench:tokens
306+
npm run docs:check
307+
```
308+
309+
Release checks:
95310

96311
```bash
97-
npm run mcp:inspector
312+
npm run release:check
98313
```
314+
315+
## Roadmap
316+
317+
- deeper syntax-aware relationship extraction
318+
- optional LSP interop without making LSP a runtime dependency
319+
- more contract fixtures for fallback languages
320+
- IDE extension, TUI, HTTP server, and package-manager integrations in future releases
321+
322+
## License
323+
324+
MIT

0 commit comments

Comments
 (0)