1bcoder 0.1.0__tar.gz → 0.1.1__tar.gz

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 (74) hide show
  1. 1bcoder-0.1.1/1bcoder.egg-info/PKG-INFO +1189 -0
  2. {1bcoder-0.1.0 → 1bcoder-0.1.1}/1bcoder.egg-info/SOURCES.txt +1 -0
  3. 1bcoder-0.1.1/LICENSE +21 -0
  4. 1bcoder-0.1.1/PKG-INFO +1189 -0
  5. {1bcoder-0.1.0 → 1bcoder-0.1.1}/README.md +41 -25
  6. {1bcoder-0.1.0 → 1bcoder-0.1.1}/chat.py +1 -0
  7. {1bcoder-0.1.0 → 1bcoder-0.1.1}/pyproject.toml +2 -1
  8. 1bcoder-0.1.0/1bcoder.egg-info/PKG-INFO +0 -8
  9. 1bcoder-0.1.0/PKG-INFO +0 -8
  10. {1bcoder-0.1.0 → 1bcoder-0.1.1}/1bcoder.egg-info/dependency_links.txt +0 -0
  11. {1bcoder-0.1.0 → 1bcoder-0.1.1}/1bcoder.egg-info/entry_points.txt +0 -0
  12. {1bcoder-0.1.0 → 1bcoder-0.1.1}/1bcoder.egg-info/requires.txt +0 -0
  13. {1bcoder-0.1.0 → 1bcoder-0.1.1}/1bcoder.egg-info/top_level.txt +0 -0
  14. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/__init__.py +0 -0
  15. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/agents/advance.txt +0 -0
  16. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/agents/ask.txt +0 -0
  17. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/agents/fill.txt +0 -0
  18. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/agents/planning.txt +0 -0
  19. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/agents/sqlite.txt +0 -0
  20. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/aliases.txt +0 -0
  21. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/doc/MCP.md +0 -0
  22. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/doc/PARAM.md +0 -0
  23. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/doc/PROC.md +0 -0
  24. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/map.txt +0 -0
  25. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/add-save.py +0 -0
  26. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/collect-files.py +0 -0
  27. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/extract-code.py +0 -0
  28. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/extract-files.py +0 -0
  29. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/extract-list.py +0 -0
  30. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/grounding-check.py +0 -0
  31. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/md.py +0 -0
  32. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/mdx.py +0 -0
  33. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/proc/regexp-extract.py +0 -0
  34. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/profiles.txt +0 -0
  35. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/prompts/analysis.txt +0 -0
  36. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/prompts/sumarise.txt +0 -0
  37. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/prompts.txt +0 -0
  38. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/AddFunction.txt +0 -0
  39. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/AskProject.txt +0 -0
  40. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/CheckRequirements.txt +0 -0
  41. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/DockerMySQL.txt +0 -0
  42. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/DockerNginx.txt +0 -0
  43. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/DockerPython.txt +0 -0
  44. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/DockerStack.txt +0 -0
  45. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/DuckDuckGoInstant.txt +0 -0
  46. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/EnvTemplate.txt +0 -0
  47. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/Explain.txt +0 -0
  48. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/ExploreProjectStructure.txt +0 -0
  49. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/GitIgnorePython.txt +0 -0
  50. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/MySQLDump.txt +0 -0
  51. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/NewScript.txt +0 -0
  52. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/PipFreeze.txt +0 -0
  53. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/PyPI.txt +0 -0
  54. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/Refactor.txt +0 -0
  55. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/RunAndFix.txt +0 -0
  56. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/SQLiteSchema.txt +0 -0
  57. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/WikiPage.txt +0 -0
  58. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/WikiSearch.txt +0 -0
  59. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/parallel_call.txt +0 -0
  60. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/personal/content/create-regular-content.txt +0 -0
  61. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/personal/content/plan.txt +0 -0
  62. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/personal/test/collect-data-from-test-environment.txt +0 -0
  63. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/plan.txt +0 -0
  64. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/remote/create-content-on-remote-server.txt +0 -0
  65. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/set_ctx.txt +0 -0
  66. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/team-map-worker.txt +0 -0
  67. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/team-search-worker.txt +0 -0
  68. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/team-summarize.txt +0 -0
  69. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/team-tree-worker.txt +0 -0
  70. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/scripts/test.txt +0 -0
  71. {1bcoder-0.1.0 → 1bcoder-0.1.1}/_bcoder_data/teams/code-analysis.yaml +0 -0
  72. {1bcoder-0.1.0 → 1bcoder-0.1.1}/map_index.py +0 -0
  73. {1bcoder-0.1.0 → 1bcoder-0.1.1}/map_query.py +0 -0
  74. {1bcoder-0.1.0 → 1bcoder-0.1.1}/setup.cfg +0 -0
@@ -0,0 +1,1189 @@
1
+ Metadata-Version: 2.4
2
+ Name: 1bcoder
3
+ Version: 0.1.1
4
+ Requires-Python: >=3.10
5
+ Description-Content-Type: text/markdown
6
+ License-File: LICENSE
7
+ Requires-Dist: requests>=2.28
8
+ Requires-Dist: pyreadline3>=3.4; sys_platform == "win32"
9
+ Requires-Dist: tqdm>=4.64
10
+ Requires-Dist: rich>=13.0
11
+ Dynamic: license-file
12
+
13
+ # 1bcoder
14
+
15
+ AI-assisted code editor designed for small (1B parameter) language models running locally via [Ollama](https://ollama.com), [LMStudio](https://lmstudio.ai), or [LiteLLM](https://litellm.ai).
16
+
17
+ ---
18
+
19
+ **(c) 2026 Stanislav Zholobetskyi**
20
+ Institute for Information Recording, National Academy of Sciences of Ukraine, Kyiv
21
+
22
+ *Створено в рамках аспірантського дослідження на тему:
23
+ «Інтелектуальна технологія підтримки розробки та супроводу програмних продуктів»*
24
+
25
+ ---
26
+
27
+ **Core idea:** 1B models hallucinate badly when asked to rewrite large blocks of code. 1bcoder works around this by keeping changes small and structured — the model outputs a single-line fix (`LINE N: content`) or a minimal SEARCH/REPLACE block, which the tool then applies with a diff preview before writing to disk.
28
+
29
+ Planning and navigation are externalized: plans live in `.txt` files, project structure is indexed into a searchable map — so the model never has to hold the whole codebase in its head.
30
+
31
+ **Target:** programmers running `qwen2.5-coder:0.6b` or `llama3.2:1b` on a 4 GB machine — offline, no cloud, no subscription. The tool does the heavy lifting so the model doesn't have to.
32
+
33
+ ---
34
+
35
+ ## What 1B models are actually good at
36
+
37
+ 1B models fail at open-ended tasks. They excel at **bounded tasks** — where the answer is almost fully determined by the input you give them. The key is to use 1bcoder's navigation tools to narrow context to exactly what the model needs, then ask a specific question.
38
+
39
+ ### Generate
40
+
41
+ | Task | How |
42
+ |---|---|
43
+ | Dockerfile / docker-compose | Describe the stack, ask the model to write it |
44
+ | SQL script | Load schema with `/script apply SQLiteSchema.txt`, ask for INSERT / SELECT / migration |
45
+ | Simple algorithm | Bubble sort, binary search, Newton gradient — model knows these cold |
46
+ | Function stub → implementation | Write the signature + docstring, ask the model to fill the body |
47
+ | Unit test for one function | `/read` the function, ask for a test |
48
+ | Type annotations | `/read` a Python or TypeScript file, ask to add types |
49
+ | Regex pattern | Describe the pattern precisely, ask for the regex |
50
+ | Config file | nginx server block, systemd service, GitHub Actions single-job workflow |
51
+ | Shell script / Makefile | Repetitive structure the model handles reliably |
52
+ | argparse / click parser | Very formulaic — model knows these patterns exactly |
53
+ | Port a function to another language | Paste 10–20 lines of Python/Go/Java, ask for the equivalent |
54
+
55
+ ### Explain
56
+
57
+ | Task | How |
58
+ |---|---|
59
+ | What does this function do? | `/read file.py 10-30` → ask; works even for unfamiliar languages |
60
+ | What does this error mean? | `/run python main.py` → output injected automatically → ask |
61
+ | What is this project? | `/tree ctx` → injects directory tree → ask for overview |
62
+ | What does this module do? | `/find ClassName -c ctx` or `/map find \ClassName -y` → inject → ask |
63
+ | What changed after my edit? | `/map idiff` → inject diff → ask what the structural change means |
64
+ | Explain this SQL / regex / config | Paste the fragment, ask; no file context needed |
65
+
66
+ ### The rule behind the list
67
+
68
+ These tasks share one property: the model never needs to **search** for information. You deliver exactly the right context using `/read`, `/run`, `/find`, `/tree`, or `/map find` — then the model executes a single well-defined subtask. Context under 2K tokens, one clear question, deterministic output format: this is where 1B models are reliable.
69
+
70
+ Tasks that require the model to decide *what to look at* — refactoring across files, debugging a multi-file interaction, writing a new feature from scratch — need 32B+ models with `/agent advance`.
71
+
72
+ ---
73
+
74
+ ## Features
75
+
76
+ - Plain terminal REPL — works in any shell, IDE terminal, or SSH session; status line before each prompt shows active model, disk size, quantization, native context limit, and context fill %
77
+ - **`/read`** injects files without line numbers (clean text, ideal for `notes.txt` and structured data); **`/readln`** injects with line numbers (use before `/fix` or `/patch` when line references matter)
78
+ - **Command autocorrection** — typos in command names, file paths, and keywords are detected and fixed automatically before execution, for both human input and agent actions
79
+ - **`/tree [path]`** — display directory tree of the whole project or any subtree; ask to inject into context (or pass `ctx` to skip the prompt)
80
+ - **`/find <pattern>`** — search filenames and file content with regex; supports `-f`/`-c`/`-i`/`--ext` flags; highlights matches, asks to inject results into context
81
+ - AI proposes a **one-line fix** (`/fix`) or a **SEARCH/REPLACE patch** (`/patch`) — always shows a diff before applying
82
+ - **Apply AI code blocks directly** with `/edit <file> code` (new/full file) or `/patch <file> code` (SEARCH/REPLACE from reply, no line numbers needed) — preferred for agent mode
83
+ - **`<think>` tag support** — reasoning blocks shown in terminal by default; `/think hide` suppresses terminal display; `/think include` keeps reasoning in context for chained turns
84
+ - Run shell commands and inject their output with `/run`
85
+ - Save AI replies to files with `/save` (code-fence stripping, multiple files, append modes)
86
+ - **Session persistence** — `/ctx save` / `/ctx load` dump and restore full conversations; `/ctx compact` summarizes and compresses the context via AI; `/ctx savepoint` marks a position for rollback or selective compaction; `/ctx clear N` drops the last N messages
87
+ - **Scripts** — reusable sequences of commands stored as `.txt` files, run step-by-step or fully automated
88
+ - **Script from history** — `/script create ctx` captures this session's commands into a reusable script automatically
89
+ - **Project map** — scan any codebase into a searchable index (`/map index`), query it (`/map find`), trace call chains (`/map trace`), and diff changes (`/map idiff`) — now includes `ORPHAN_DRIFT` alert (dead code delta) and `GHOST ALERT` (deleted file that other files depended on)
90
+ - **Ask mode** — `/ask <question>` is an alias for `/agent ask`: a read-only research loop for 4B models that explores the project with tree/find/map tools, never edits files, auto-truncates large results to protect context
91
+ - **Agent mode** — `/agent <task>` runs an autonomous loop; stops when the model outputs plain text with no ACTION; after the loop a `[s]ummary / [a]ll / [n]one` prompt lets you pull agent results into main context
92
+ - **Named agents** — define custom agents in `.1bcoder/agents/<name>.txt` (system prompt, tools, max_turns, aliases, `on_done`); call with `/agent <name> task` or `/<name> task` directly; agent-scoped aliases active only during that run
93
+ - **`/plan <goal>`** — planning agent: researches the project, writes a natural-language step-by-step plan to `plan.txt`; run `/agent <task> plan plan.txt` to execute it step by step
94
+ - **`/fill`** — fill agent: reads NaN session variables, scans project for `.var` files and config files, sets each value automatically
95
+ - **Session variables** — `{{name}}` placeholders substituted in any command; save/load from `.var` files for offline reuse without loading files into context
96
+ - **Project config** — `/config save` persists session state (host, model, ctx, params, vars, procs) to `.1bcoder/config.yml`; auto-loaded on startup when `auto: true`
97
+ - **Aliases** — define command shortcuts with `/alias /name = expansion` (supports `{{args}}`); persisted in `aliases.txt`; loaded from global then project directory at startup and survive `/clear`
98
+ - **Backup/restore** — `/bkup save` rotates existing backups (`file.bkup` → `file.bkup(1)`, `file.bkup(2)`…) so no snapshot is ever overwritten; `/bkup restore` always restores the latest
99
+ - **MCP support** — connect external tool servers (filesystem, web, git, database, browser…) via the Model Context Protocol
100
+ - **Parallel queries** — send prompts to multiple models simultaneously with `/parallel`, with saved profiles
101
+ - Switch model or host at runtime without restarting (`/model gemma3:1b`, `/host openai://localhost:1234`)
102
+ - **Model parameters** — `/param temperature 0.2`, `/param enable_thinking false` — sent with every request, auto-cast to correct type
103
+ - **Multi-provider** — connect to Ollama, LMStudio, or LiteLLM using `ollama://` / `openai://` URL scheme; plain host defaults to Ollama
104
+
105
+ ---
106
+
107
+ ## Quick install
108
+
109
+ ### Option 1 — PyPI (recommended)
110
+
111
+ ```bash
112
+ pip install 1bcoder
113
+ ```
114
+
115
+ On first launch, default agents, procs, and scripts are copied to `~/.1bcoder/` automatically.
116
+
117
+ ### Option 2 — Clone and install locally
118
+
119
+ ```bash
120
+ git clone https://github.com/szholobetsky/1bcoder.git
121
+ cd 1bcoder
122
+ pip install -e .
123
+ ```
124
+
125
+ ### Option 3 — Install directly from GitHub
126
+
127
+ ```bash
128
+ pip install git+https://github.com/szholobetsky/1bcoder.git
129
+ ```
130
+
131
+ Then run anywhere:
132
+
133
+ ```bash
134
+ 1bcoder
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Requirements
140
+
141
+ | Dependency | Version |
142
+ |---|---|
143
+ | Python | ≥ 3.10 |
144
+ | [Ollama](https://ollama.com) | any recent version |
145
+ | requests | ≥ 2.28 |
146
+
147
+ Instead of Ollama, any OpenAI-compatible backend works: [LMStudio](https://lmstudio.ai), [LiteLLM](https://litellm.ai), or any `/v1/chat/completions` proxy.
148
+
149
+ Optional (for MCP servers):
150
+ - Node.js + npx (for `@modelcontextprotocol/*` servers)
151
+ - uv / uvx (for Python-based MCP servers)
152
+
153
+ ---
154
+
155
+ ## Installation
156
+
157
+ ### 1. Install Ollama and pull a model
158
+
159
+ ```bash
160
+ # Install Ollama from https://ollama.com, then:
161
+ ollama pull llama3.2:1b # fast, minimal RAM
162
+ ollama pull qwen2.5-coder:1b # good for code
163
+ ```
164
+
165
+ ### 2. Clone and install 1bcoder
166
+
167
+ ```bash
168
+ git clone <repo-url>
169
+ cd 1bcoder
170
+
171
+ # Install with pip (creates the `1bcoder` command)
172
+ pip install -e .
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Running
178
+
179
+ ```bash
180
+ # Using the installed command
181
+ 1bcoder
182
+
183
+ # Or run directly
184
+ python chat.py
185
+ ```
186
+
187
+ On startup a numbered list of available Ollama models is shown — type the number to select one. Use `--model` to skip the prompt.
188
+
189
+ ### CLI options
190
+
191
+ ```
192
+ 1bcoder [--host URL] [--model NAME] [--init] [--scriptapply SCRIPT] [--param KEY=VALUE]
193
+
194
+ --host URL Host URL — supports ollama:// and openai:// schemes (default: http://localhost:11434)
195
+ --model NAME Skip model selection, use this model directly
196
+ --init Create .1bcoder/ scaffold in the current directory
197
+ --scriptapply SCRIPT Run a script file non-interactively, then exit
198
+ --param KEY=VALUE Plan parameter substitution (repeatable)
199
+ ```
200
+
201
+ Examples:
202
+
203
+ ```bash
204
+ 1bcoder --host http://192.168.1.50:11434
205
+ 1bcoder --model qwen2.5-coder:1b
206
+ 1bcoder --scriptapply my-fixes.txt --param file=calc.py --param range=1-4
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Quick start
212
+
213
+ ```
214
+ ██╗██████╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗
215
+ ███║██╔══██╗ ██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗
216
+ ╚██║██████╔╝█████╗██║ ██║ ██║██║ ██║█████╗ ██████╔╝
217
+ ██║██╔══██╗╚════╝██║ ██║ ██║██║ ██║██╔══╝ ██╔══██╗
218
+ ██║██████╔╝ ╚██████╗╚██████╔╝██████╔╝███████╗██║ ██║
219
+ ╚═╝╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
220
+
221
+ model : gemma3:1b [815M Q4_K 32K]
222
+ host : http://localhost:11434
223
+ provider : ollama
224
+ dir : /home/user/myproject
225
+
226
+ /help for all commands /init to create .1bcoder/ folder
227
+ Ctrl+C interrupts stream /exit to quit
228
+
229
+ > /init
230
+ > /map index .
231
+ > /read main.py 1-20
232
+ > what does the divide() function do?
233
+ > /fix main.py 5-5 wrong operator
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Command Reference
239
+
240
+ ### File operations
241
+
242
+ | Command | Description |
243
+ |---|---|
244
+ | `/read <file> [file2 ...] [start-end]` | Inject file(s) into AI context **without line numbers** (clean text) |
245
+ | `/readln <file> [file2 ...] [start-end]` | Same as `/read` but **with line numbers** — use before `/fix` or `/patch` |
246
+ | `/insert <file> <line>` | Insert last AI reply before line N (full text) |
247
+ | `/insert <file> <line> code` | Insert extracted code block from last AI reply before line N |
248
+ | `/insert <file> <line> <text>` | Insert literal text directly, preserving indentation (e.g. `/insert main.py 14 x = 1`) |
249
+ | `/edit <file> <line>` | Manually replace a single line |
250
+ | `/edit <file> code` | Apply last AI reply (code block) to whole file — creates file if missing, diff before applying |
251
+ | `/edit <file> <line> code` | Apply code block starting at `<line>` — creates file if missing |
252
+ | `/edit <file> <start>-<end> code` | Apply code block replacing exactly lines `start`–`end` |
253
+ | `/save <file> [mode]` | Save last AI reply to a file |
254
+ | `/bkup save <file>` | Save a backup as `<file>.bkup`; rotates existing backup to `<file>.bkup(N)` |
255
+ | `/bkup restore <file>` | Replace `<file>` with its `.bkup` copy (always the latest) |
256
+ | `/diff <file_a> <file_b> [-y]` | Show colored unified diff between two files; `-y` auto-injects into context |
257
+
258
+ `/save` modes: `overwrite` (default), `append-above` / `-aa`, `append-below` / `-ab`, `add-suffix`, `code`
259
+
260
+ ```
261
+ /diff main.py main.py.bkup # colored diff, asks to inject into context
262
+ /diff v1/calc.py v2/calc.py -y # auto-inject without confirmation
263
+ ```
264
+
265
+ ```
266
+ /save out.txt
267
+ /save out.txt add-suffix # → out_1.txt, out_2.txt, …
268
+ /save main.py code # strips ```python…``` wrapper
269
+ /save index.html style.css code # block 1 → index.html, block 2 → style.css
270
+ ```
271
+
272
+ ---
273
+
274
+ ### AI edits
275
+
276
+ | Command | Description |
277
+ |---|---|
278
+ | `/fix <file> [start-end] [hint]` | AI proposes one-line fix, shows diff, asks to apply |
279
+ | `/patch <file> [start-end] [hint]` | AI proposes SEARCH/REPLACE block, shows unified diff |
280
+ | `/patch <file> code` | Apply SEARCH/REPLACE block from last AI reply (no new LLM call) |
281
+
282
+ `/fix` is designed for 1B models — output is strictly constrained to `LINE N: content`.
283
+ `/patch` works better with larger models (7B+) and can replace multiple consecutive lines.
284
+ `/patch <file> code` is the preferred agent mode edit — the agent writes the SEARCH/REPLACE block in its reply, then calls `/patch <file> code` to apply it without needing line numbers.
285
+
286
+ When `/patch` fails to find the SEARCH text it shows a diagnostic diff — the SEARCH lines vs the nearest matching lines in the file — so you can see immediately what doesn't match (e.g. trailing commas, wrong indentation). It also detects no-op patches where SEARCH and REPLACE are identical.
287
+
288
+ ```
289
+ /fix main.py
290
+ /fix main.py 2-2 wrong operator
291
+ /patch main.py 10-40 fix the loop logic
292
+ /patch main.py code
293
+ ```
294
+
295
+ ---
296
+
297
+ ### Shell
298
+
299
+ ```
300
+ /run <command>
301
+ ```
302
+ Runs any shell command and injects stdout + stderr into the AI context.
303
+
304
+ ```
305
+ /run python main.py
306
+ /run pytest tests/ -x
307
+ ```
308
+
309
+ ---
310
+
311
+ ### Codebase navigation
312
+
313
+ #### `/tree` — directory structure
314
+
315
+ ```
316
+ /tree whole project from current directory (depth 4)
317
+ /tree src subtree rooted at src/
318
+ /tree src/java/com -d 6 deep subtree, 6 levels
319
+ /tree static ctx show and auto-inject into context (no prompt)
320
+ ```
321
+
322
+ Displays a Unicode box-drawing tree. Skips `.git`, `node_modules`, `__pycache__`, `.venv`, and other noise automatically. When depth is cut, shows `… (N entries)` so you know something's there. After displaying results asks `Add tree to context? [Y/n]` — pass `ctx` to skip.
323
+
324
+ #### `/find` — search filenames and content
325
+
326
+ ```
327
+ /find <pattern> [-f] [-c] [-i] [--ext <ext>] [ctx]
328
+ ```
329
+
330
+ | Flag | Effect |
331
+ |---|---|
332
+ | *(none)* | search filenames **and** file content |
333
+ | `-f` | filenames only |
334
+ | `-c` | content only |
335
+ | `-i` | case-insensitive |
336
+ | `--ext py` | restrict to `.py` files |
337
+ | `ctx` | auto-inject results into context (no Y/n prompt) |
338
+
339
+ Pattern is a full **regex**. Matches highlighted in the terminal output.
340
+
341
+ ```
342
+ /find MyClass filenames + content
343
+ /find user_id -c -i content only, case-insensitive
344
+ /find config --ext py ctx .py files, inject automatically
345
+ /find \.connect\( regex: literal .connect(
346
+ ```
347
+
348
+ After showing results asks `Add results to context? [Y/n]` (suppressed when there are no matches).
349
+
350
+ ---
351
+
352
+ ### Project map
353
+
354
+ The map command scans your project with language-agnostic regex, extracts definitions (classes, functions, endpoints, tables…) and cross-references between files. No external dependencies — pure regex, works for Python, Java, SQL, HTML, Terraform, YAML, and anything else.
355
+
356
+ ```
357
+ /map index [path] [depth] — scan project, save to .1bcoder/map.txt
358
+ /map find [query] [-d N] [-y] — search the map and inject results into context
359
+ /map trace <id> [-d N] [-y] — BFS backwards: who depends on this identifier?
360
+ /map trace deps <id> [-d N] [-leaf] [-y] — forward: what does this identifier depend on?
361
+ /map trace <start> <end> [-y] — shortest dependency path between two points
362
+ /map idiff [path] [depth] — re-index then show diff vs previous snapshot
363
+ /map diff — show diff without re-indexing (safe to repeat)
364
+ /map keyword index — build keyword vocabulary from map.txt
365
+ /map keyword extract <text> [-f] [-a] [-n] [-c] — extract real identifiers from keyword.txt matching text/file
366
+ ```
367
+
368
+ **Partial / incremental indexing** — for large codebases where a full re-scan is slow:
369
+
370
+ ```
371
+ /map index sonar_core/src/main/java/org/sonar/core/util
372
+ ```
373
+
374
+ When `path` is a subfolder of the working directory, 1bcoder:
375
+ 1. Scans only that subtree (fast)
376
+ 2. Adjusts all paths to be relative to the project root
377
+ 3. Saves a named segment file: `.1bcoder/map_sonar_core_src_main_java_org_sonar_core_util.txt`
378
+ 4. Patches `map.txt` in-place — removes stale blocks for that subtree, appends the fresh ones
379
+ 5. Backs up the previous `map.txt` to `map.prev.txt` before patching
380
+
381
+ This lets you re-index a changed module in seconds instead of hours.
382
+
383
+ **`/map find` search syntax:**
384
+
385
+ | Token | Where | Effect |
386
+ |---|---|---|
387
+ | `term` | filename | include if filename contains term |
388
+ | `!term` | filename | exclude if filename contains term |
389
+ | `\term` | child lines | include block if any child line contains term |
390
+ | `\!term` | child lines | exclude entire block if any child contains term |
391
+ | `-term` | child lines | show ONLY child lines containing term |
392
+ | `-!term` | child lines | hide child lines containing term |
393
+ | `-d 1` | — | filenames only |
394
+ | `-d 2` | — | filenames + defines/vars (no links) |
395
+ | `-d 3` | — | full blocks (default) |
396
+ | `-y` | — | skip "add to context?" confirmation |
397
+
398
+ ```
399
+ /map find register — files named *register*
400
+ /map find \register — files that define/link "register"
401
+ /map find register \register — both: in name AND in children
402
+ /map find \register !mock — has "register" in children, skip mock files
403
+ /map find auth \UserService -!deprecated -y
404
+ /map find \py -!import — show only non-import lines in .py files
405
+ /map find password -d 1 — just filenames, no details
406
+ /map find models -d 2 — filenames + defines/vars only
407
+ ```
408
+
409
+ **`/map trace`** — three modes:
410
+
411
+ **1. Backwards BFS** (who depends on this?):
412
+ ```
413
+ /map trace register -d 2
414
+
415
+ auth/routes.py [defines register(ln:45)]
416
+ ← import:register app/__init__.py
417
+ ← call:register tests/test_auth.py
418
+ ```
419
+
420
+ **2. Forward deps** (what does this depend on?):
421
+ ```
422
+ /map trace deps UserService -leaf
423
+
424
+ deps (leaves): UserService(ln:5) [UserService.java]
425
+ UserEntity.java [firstName, lastName, accountNumber]
426
+ UserRepo.java [findById, findByEmail, save]
427
+ ```
428
+
429
+ **3. Path between two points** (shortest dependency chain):
430
+ ```
431
+ /map trace AccountNumber UserController
432
+
433
+ path 1: AccountNumber(ln:15) → UserController
434
+
435
+ AccountEntity.java
436
+ ↓ import:AccountNumber
437
+ UserDAO.java
438
+ ↓ import:UserDAO
439
+ UserController.java
440
+
441
+ [Y]es add + next / [s]kip next / [n]o stop:
442
+ ```
443
+
444
+ After each path:
445
+ - `Y` — add to context, find next alternative path
446
+ - `s` — skip (don't add), find next alternative path
447
+ - `l N` or `l` then enter N — auto-collect the next N paths without prompting (e.g. `l 10`)
448
+ - `n` — stop and inject everything collected so far
449
+
450
+ **`/map keyword`** — build and query a keyword vocabulary from the map:
451
+
452
+ ```
453
+ /map keyword index
454
+ ```
455
+
456
+ Scans `map.txt`, extracts all real code identifiers, saves to `.1bcoder/keyword.txt` as CSV (`word, count, line_numbers`). Run once after `/map index`.
457
+
458
+ ```
459
+ /map keyword extract <text or file> [-f] [-a] [-n] [-c]
460
+ ```
461
+
462
+ Finds identifiers from `keyword.txt` that match words in the given text or file. Output is always **real identifiers from keyword.txt** — never synthetic splits.
463
+
464
+ | Flag | Effect |
465
+ |---|---|
466
+ | *(none)* | Exact match: `rule` matches `rule` only, not `RuleIndex` |
467
+ | `-f` | Fuzzy subword match: splits both query and keyword into parts |
468
+ | `-a` | Alphabetical order (default: order of appearance in text) |
469
+ | `-n` | Show codebase count: `RuleIndex(25)` |
470
+ | `-c` | Comma-separated output |
471
+
472
+ **Fuzzy subword rules (`-f`):**
473
+ - `rule` → matches `RuleIndex`, `RuleName`, `RuleUpdater` (all contain subword `rule`)
474
+ - `RuleIndex` → matches `RuleIndex` only (requires both `rule` AND `index`)
475
+ - `RuleIndex` does **not** match `Rule` (missing `index`) or `Index` (missing `rule`)
476
+ - Combined identifiers are more specific — no false positives from their parts
477
+
478
+ Handles all naming conventions at match time: `camelCase`, `PascalCase`, `snake_case`, `UPPER_SNAKE_CASE`, `kebab-case`.
479
+
480
+ ```
481
+ /map keyword extract "fix rule search performance" -f -c
482
+ → RuleIndex, RuleSearch, RuleUpdater, SearchService
483
+
484
+ /map keyword extract notes.txt -f -n
485
+ → RuleIndex(47)
486
+ RuleName(23)
487
+ SearchService(18)
488
+ ```
489
+
490
+ **`/map idiff`** re-indexes and shows what changed — use after every edit:
491
+
492
+ ```
493
+ /map idiff
494
+
495
+ [map diff] map.prev.txt → map.txt
496
+
497
+ calc.py
498
+ - defines: subtract(ln:12)
499
+ ! WARNING: 1 identifier(s) removed
500
+
501
+ ORPHAN_DRIFT = +1 [DEGRADATION]
502
+ before: 3 orphans
503
+ after: 4 orphans
504
+ + subtract ← calc.py
505
+
506
+ ! GHOST ALERT — 1 deleted file(s) had active callers:
507
+ ! services/UserService.java
508
+ called: findUser, createUser
509
+ ```
510
+
511
+ `ORPHAN_DRIFT` catches dead code accumulation and deleted caller files. `GHOST ALERT` catches deleted callee files that other files still depend on — the blind spot that structural diff alone misses.
512
+
513
+ Standalone tools (usable without 1bcoder):
514
+ - `map_index.py` — scanner only: `python map_index.py [path] [depth]`
515
+ - `map_query.py` — query only: `python map_query.py find \register` / `python map_query.py trace register`
516
+
517
+ ---
518
+
519
+ ### Ask mode — read-only research for 4B models
520
+
521
+ `/ask` is an alias for `/agent ask` — it loads its system prompt, tools, and aliases from `.1bcoder/agents/ask.txt` (global install) or your project's local override. Designed for 4B models (nemotron, qwen3:4b, ministral3:3b). The model navigates the project using `tree`, `find`, `map find`, and `map keyword` — it never edits files. All actions are auto-executed without confirmation.
522
+
523
+ ```
524
+ /ask what does this project do
525
+ /ask -t 5 where is authentication handled
526
+ /ask how are books stored in the database
527
+ ```
528
+
529
+ Each tool result is truncated at ~1K tokens to protect the model's context window — if a result is too large, the model receives a specific hint on how to narrow the query (e.g. `use /tree <subfolder>` or `add more keywords to /map find`).
530
+
531
+ The system prompt guides the model from broad to narrow: tree → map find → map keyword → find → read. On a second `/ask` in the same session the model skips `/tree` if the project structure is already in context.
532
+
533
+ When the loop finishes you are prompted: **`[s]ummary / [a]ll / [n]one`** — choose how much of the agent's conversation to pull into your main context.
534
+
535
+ **What 4B models can do with `/ask`:** 10-step investigation, understand project structure, predict where relevant code is located — tasks that normally require 30B+ models in open-ended agent mode.
536
+
537
+ ---
538
+
539
+ ### Agent mode
540
+
541
+ `/agent` runs an autonomous loop: the model reads the task and decides which tool to use. The agent prompt instructs the model to emit one ACTION per turn; if it emits multiple, all are executed in order. Stops when the model outputs plain text with no ACTION.
542
+
543
+ ```
544
+ /agent [-t N] [-y] <task> [plan step1, step2, ...]
545
+ ```
546
+
547
+ - **`-t N`** — override `max_turns` for this run only (e.g. `-t 1` for a quick read+explain)
548
+ - **`-y`** — skip per-action confirmation (execute all actions automatically)
549
+ - Without `-y`: each proposed action pauses and asks `[Y/n/e/f/q]`:
550
+
551
+ | Key | Action |
552
+ |---|---|
553
+ | `Y` / Enter | Execute the action |
554
+ | `n` | Skip this action |
555
+ | `e` | Edit the command before executing (copies to clipboard on Windows) |
556
+ | `f` | Send feedback to the AI and skip the action (redirect the model mid-loop) |
557
+ | `q` | Stop the agent |
558
+
559
+ - **`plan step1, step2, ...`** — optional comma-separated list of items injected as hints one per turn
560
+ - **`plan <file.txt>`** — load steps from a `.txt` or `.md` file; numbered/bulleted list items become steps; `### Example` / `### Summary` sections are injected as context before step 1; `max_turns` is raised automatically if the file has more steps than the default limit
561
+
562
+ When the loop finishes you are prompted: **`[s]ummary / [a]ll / [n]one`** — choose how much of the agent's conversation to pull into your main context.
563
+
564
+ ```
565
+ /agent find and fix the divide by zero bug in calc.py
566
+ /agent -t 1 read models.py and explain the User class
567
+ /agent -y -t 5 refactor utils.py
568
+ /agent read file plan models.py, views.py, urls.py
569
+ /agent implement the changes plan plan.txt # load steps from plan.txt
570
+ ```
571
+
572
+ Configure the default agent in `.1bcoder/agent.txt`:
573
+
574
+ ```ini
575
+ max_turns = 10
576
+ auto_apply = true
577
+
578
+ tools =
579
+ read
580
+ insert
581
+ save
582
+ patch
583
+ ```
584
+
585
+ ---
586
+
587
+ ### Named agents
588
+
589
+ Custom agents are defined in `.1bcoder/agents/<name>.txt` (project-local) or `<install>/.1bcoder/agents/<name>.txt` (global). Local files override global ones. Call them with `/agent <name> task` or directly as `/<name> task`.
590
+
591
+ **Agent file format:**
592
+
593
+ ```ini
594
+ # .1bcoder/agents/myagent.txt
595
+ description = What this agent does
596
+ max_turns = 10
597
+ auto_exec = false
598
+ auto_apply = false
599
+
600
+ system =
601
+ You are a ... Complete the task using the available tools.
602
+
603
+ To call a tool, write ACTION: followed by the command.
604
+ ...
605
+
606
+ Available tools:
607
+ {tool_list}
608
+
609
+ tools =
610
+ read
611
+ find
612
+ run
613
+
614
+ aliases =
615
+ /search = /map find {{args}}
616
+ /sql = /run python db.py "{{args}}"
617
+ ```
618
+
619
+ - **`system =`** — inline multiline system prompt; indented lines continue the block; `{tool_list}` is substituted automatically from the `tools =` list
620
+ - **`tools =`** — one tool name per indented line; controls what the agent knows about and what gets shown in its system prompt
621
+ - **`aliases =`** — agent-scoped aliases; active only during this agent's run, restored to global state after; `{{args}}` is replaced by everything after the alias name
622
+ - **`on_done = <command>`** — slash command executed once when the agent finishes naturally (no more ACTIONs); use to save the agent's final reply to a file (e.g. `on_done = /save plan.txt -w`)
623
+
624
+ ```ini
625
+ # Example: planning agent saves its output automatically
626
+ on_done = /save plan.txt -w
627
+ ```
628
+
629
+ Built-in named agents (global install):
630
+
631
+ | Agent | Command | Description |
632
+ |---|---|---|
633
+ | `ask` | `/ask <question>` or `/agent ask` | Read-only research — tree, find, map, never edits |
634
+ | `advance` | `/advance <task>` or `/agent advance` | Full toolset for 7B+ models |
635
+ | `planning` | `/plan <goal>` | Researches project, writes natural-language plan to `plan.txt` |
636
+ | `fill` | `/fill` | Reads NaN vars, finds `.var` files, sets missing values from project files |
637
+
638
+ **`/agent advance`** — named agent from `agents/advance.txt`, full toolset for larger models (7B+), includes `run`, `diff`, `map`, `bkup`, and all edit tools. Shortcut: `/advance`:
639
+
640
+ ```
641
+ /agent advance refactor the auth module
642
+ /advance read and summarise plan models.py, views.py
643
+ ```
644
+
645
+ ---
646
+
647
+ ### Aliases
648
+
649
+ Define command shortcuts with `/alias`:
650
+
651
+ ```
652
+ /alias /name = expansion define an alias ({{args}} = everything after the name)
653
+ /alias list all active aliases
654
+ /alias clear /name remove an alias (session only)
655
+ /alias save /name persist to .1bcoder/aliases.txt
656
+ ```
657
+
658
+ Aliases are loaded at startup from the global `aliases.txt` then the project-local one and **survive `/clear`**. They are expanded before any command is dispatched, so aliases can expand to other aliases (up to 10 levels deep).
659
+
660
+ ```
661
+ /alias /grep = /find {{args}} -c
662
+ /alias /kw = /map keyword extract {{args}} -f -c
663
+ /alias save /grep
664
+ ```
665
+
666
+ **Agent-scoped aliases** — an agent's `aliases =` section is merged into the active alias table before the loop starts and fully restored after. The agent can use its own shorthand commands in `ACTION:` lines; they disappear when the agent finishes.
667
+
668
+ ---
669
+
670
+ ### Scripts
671
+
672
+ Scripts are `.txt` files containing one command per line, stored in `.1bcoder/scripts/`.
673
+ Lines starting with `[v]` are already done and skipped. Lines starting with `#` are comments and skipped.
674
+
675
+ | Command | Description |
676
+ |---|---|
677
+ | `/script list` | List all script files (`*` = current). Shows global scripts `(g:)` and project plans |
678
+ | `/script open` | Select and load a script (type number). Includes global and project scripts |
679
+ | `/script open <N>` | Load script by number directly — shows the list but skips the prompt |
680
+ | `/script create [path]` | Create a new empty script |
681
+ | `/script create ctx [path]` | **Create script from this session's command history** |
682
+ | `/script show` | Display steps of the current script |
683
+ | `/script add <command>` | Append a step to the current script |
684
+ | `/script clear` | Wipe current script completely |
685
+ | `/script reset` | Unmark all done steps |
686
+ | `/script reapply [key=value ...]` | Reset all done steps then apply automatically; prompts for any NaN `{{variables}}` before running |
687
+ | `/script refresh` | Reload script from disk and show contents |
688
+ | `/script apply [file] [key=value ...]` | Run steps one by one (Y/n/q per step) |
689
+ | `/script apply -y [file] [key=value ...]` | Run all pending steps automatically |
690
+
691
+ **`/script create ctx`** captures all work commands typed this session (`/read`, `/edit`, `/fix`, `/patch`, `/run`, `/save`, `/bkup`, `/map`, `/model`, `/host`) into a ready-to-run plan:
692
+
693
+ ```
694
+ > /host http://192.168.1.50:11434
695
+ > /model gemma3:1b
696
+ > /read calc.py
697
+ > /fix calc.py 11-11 divide by zero
698
+ > /run python calc.py
699
+
700
+ > /script create ctx fix-calc.txt
701
+ [script] created 'fix-calc.txt' from session history (5 step(s))
702
+ ```
703
+
704
+ Scripts support `{{key}}` placeholders:
705
+
706
+ ```
707
+ /read {{file}} {{range}}
708
+ what is wrong in lines {{range}}?
709
+ /fix {{file}} {{range}} {{hint}}
710
+ ```
711
+
712
+ ```
713
+ /script apply fix-fn.txt file=calc.py range=1-4 hint="wrong operator"
714
+ ```
715
+
716
+ Run a script non-interactively from the command line:
717
+
718
+ ```bash
719
+ 1bcoder --model llama3.2:1b --scriptapply my-fixes.txt --param file=calc.py
720
+ ```
721
+
722
+ ---
723
+
724
+ ### Session variables (`/var`)
725
+
726
+ Session variables store named values that are substituted as `{{name}}` in any command, script step, or agent plan. Useful for parameterizing scripts without hard-coding values.
727
+
728
+ ```
729
+ /var set port=5432 set directly (shorthand)
730
+ /var set port =5432 set directly (original form)
731
+ /var set port = 5432 set with spaces (same result)
732
+ /var set name =MyService literal value
733
+ /var def port db host declare multiple NaN variables (skips if already set)
734
+ /var get list all variables (NaN = unset)
735
+ /var del port remove a variable
736
+ ```
737
+
738
+ **Capture from proc output:**
739
+ ```
740
+ /proc run regexp-extract "\bclass (\w+)" -g 1
741
+ /var set classname first # grab first= key from proc stdout
742
+ ```
743
+
744
+ **Save and load `.var` files** — for reuse across sessions without loading files into context:
745
+ ```
746
+ /var set description=DB connection params for INVOICES project
747
+ /var set port=5432
748
+ /var set db=invoices.db
749
+ /var save invoices # creates invoices.var
750
+ ```
751
+
752
+ The first line of a `.var` file is always `# <description>` — an agent can read just that line (`/read invoices.var 1-1`) to decide relevance before loading the full file.
753
+
754
+ ```
755
+ /var load invoices.var # restore vars from file
756
+ ```
757
+
758
+ **Extract placeholders from script or file:**
759
+ ```
760
+ /var extract # scan current open script for {{placeholders}}
761
+ /var extract deploy.txt # scan any file
762
+ ```
763
+
764
+ Any `{{key}}` found but not yet set is registered as NaN — `/script reapply` will prompt for it before running.
765
+
766
+ **`/fill` agent** — for weak models that can't hold large files in context, use `/fill` to populate NaN variables automatically. The agent:
767
+ 1. Runs `/var get` to see what's missing
768
+ 2. Searches for `.var` files (`/find . -f --ext var`), reads only the first line (description) of each to decide relevance
769
+ 3. Loads relevant `.var` files
770
+ 4. Searches project config files for any remaining NaN values
771
+
772
+ ```
773
+ /var extract # register NaN vars
774
+ /fill # agent fills them from project files
775
+ /script reapply # runs with all values set
776
+ ```
777
+
778
+ ---
779
+
780
+ ### Output capture (`->` and `$`)
781
+
782
+ Any command — LLM reply, tool output, or proc result — can be captured into a session variable using the `->` suffix. The special token `$` expands to the last captured output anywhere in a command or message.
783
+
784
+ ```
785
+ /map keyword extract auth.py -> keywords # capture tool output into variable
786
+ /ask find files related to {{keywords}} # use it in next command
787
+
788
+ summarize this for me -> myplan # capture LLM reply
789
+ /agent planning $ # pass it as task to next command
790
+
791
+ /find . -f --ext py -> filelist # capture file listing
792
+ /agent ask "which of these handles auth? $" # inline expand into message
793
+
794
+ /proc run my-extractor -> result # capture proc stdout
795
+ /var set port result # also works: grab key from proc output
796
+ ```
797
+
798
+ `->` stores the full text (including ANSI-stripped terminal output) and also updates `$` for immediate reuse. Variables captured with `->` appear in `/var get` like any other session variable.
799
+
800
+ ---
801
+
802
+ ### Project config (`/config`)
803
+
804
+ Save and restore session state (host, model, ctx, params, vars, procs) to `.1bcoder/config.yml` in the current working directory. Useful for project-specific presets that are too large to fit in model context.
805
+
806
+ ```
807
+ /config save # save all current state
808
+ /config save host # save only host
809
+ /config save model # save only model
810
+ /config save vars # save only vars
811
+ /config load # restore from config.yml
812
+ /config show # print config.yml contents
813
+ /config auto on # auto-load on every startup in this directory
814
+ /config auto off # disable auto-load
815
+ ```
816
+
817
+ **Selective delete:**
818
+ ```
819
+ /config del model # remove model from config
820
+ /config del var project # remove one variable
821
+ /config del vars # remove entire vars section
822
+ /config del param num_ctx # remove one param
823
+ /config del procs # remove entire procs section
824
+ /config del proc collect-files # remove one proc
825
+ ```
826
+
827
+ **Config file format** (`.1bcoder/config.yml`):
828
+ ```yaml
829
+ auto: true
830
+ host: ollama://localhost:11434
831
+ model: qwen3:1.7b
832
+ ctx: 4096
833
+ params:
834
+ num_ctx: 4096
835
+ temperature: 0.7
836
+ vars:
837
+ project: bookcrossing
838
+ db: invoices.db
839
+ procs:
840
+ - collect-files output.txt
841
+ ```
842
+
843
+ When `auto: true`, the config is applied automatically after the startup banner — host, model, ctx, params, vars, and procs are restored without any command.
844
+
845
+ ---
846
+
847
+ ### MCP (Model Context Protocol)
848
+
849
+ Connect external tool servers to give the AI access to filesystems, databases, web pages, and more.
850
+
851
+ ```
852
+ /mcp connect <name> <command>
853
+ /mcp tools [name]
854
+ /mcp call <server/tool> [json_args]
855
+ /mcp disconnect <name>
856
+ ```
857
+
858
+ ```
859
+ /mcp connect fs npx -y @modelcontextprotocol/server-filesystem .
860
+ /mcp connect web uvx mcp-server-fetch
861
+ /mcp call web/fetch {"url": "https://docs.python.org/3/"}
862
+ /mcp tools
863
+ /mcp disconnect fs
864
+ ```
865
+
866
+ See [MCP.md](MCP.md) for a full list of ready-to-use servers.
867
+
868
+ ---
869
+
870
+ ### Parallel queries
871
+
872
+ Send prompts to multiple models at the same time. Each answer is saved to its own file.
873
+
874
+ ```
875
+ /parallel ["prompt"] [profile <name>] [host:port|model|file ...]
876
+ ```
877
+
878
+ ```
879
+ /parallel "review this for bugs" \
880
+ localhost:11434|llama3.2:1b|answers/llm1.txt \
881
+ localhost:11435|qwen2.5:1b|answers/llm2.txt
882
+ ```
883
+
884
+ **Profiles** — save a set of workers for reuse:
885
+
886
+ ```
887
+ /parallel profile create <name> host|model|file ... # inline — workers as space-separated specs
888
+ /parallel profile create <name> # interactive wizard
889
+ /parallel profile list # show all profiles (local + global)
890
+ /parallel profile show <name> # print raw profile string
891
+ /parallel profile add <name> # append current host+model to a profile
892
+ /parallel "explain this" profile review
893
+ ```
894
+
895
+ Profiles stored in `~/.1bcoder/profiles.txt` (global) or `.1bcoder/profiles.txt` (project-local):
896
+ ```
897
+ review: localhost:11434|ministral3:3b|ans/review.txt localhost:11435|cogito:3b|ans/tests.txt # code review + unit tests
898
+ fast: localhost:11434|qwen2.5-coder:0.6b|ans/q.txt # quick sanity check
899
+ ```
900
+
901
+ ---
902
+
903
+ ### Prompt templates
904
+
905
+ Save any useful message as a reusable template and load it later with `{{param}}` substitution.
906
+
907
+ ```
908
+ /prompt save ConvertJavaToPy # saves last user message as ConvertJavaToPy.txt
909
+ /prompt load # numbered list, select by number, fill {{params}} interactively
910
+ ```
911
+
912
+ Templates stored in `<install>/.1bcoder/prompts/`. Use `{{keyword}}` placeholders — values are prompted on load.
913
+
914
+ ---
915
+
916
+ ### Post-processors (`/proc`)
917
+
918
+ Run a Python script against the last LLM reply. Useful for extracting filenames, validating identifiers against `map.txt`, collecting data across turns, and more.
919
+
920
+ ```
921
+ /proc list # list available processors
922
+ /proc run <name> # one-shot: run against last reply
923
+ /proc run <name> -f <file> # run against an external file instead of last reply
924
+ /proc on grounding-check # persistent: run after every reply automatically
925
+ /proc off # stop persistent processor
926
+ /proc new my-proc # create a new processor from template
927
+ ```
928
+
929
+ **Processor protocol:** `stdin` = last LLM reply · `stdout` = result · `key=value` lines = extracted params · `ACTION: /command` = confirmed and executed (run mode only) · exit 1 = failure.
930
+
931
+ Built-in processors in `<install>/.1bcoder/proc/`:
932
+
933
+ | Processor | Purpose | Best mode |
934
+ |---|---|---|
935
+ | `extract-files` | Extract filenames, `ACTION: /read` if one found | one-shot |
936
+ | `extract-code` | Extract code blocks; `ACTION: /save <file>` if one block + filename detected | one-shot |
937
+ | `extract-list` | Convert first bullet/numbered list in reply to comma-separated line | one-shot |
938
+ | `grounding-check` | Score identifiers against `map.txt`, warn if <50% | persistent |
939
+ | `collect-files` | Accumulate filenames to `.1bcoder/collected-files.txt` | persistent |
940
+ | `md` | Render last reply as formatted Markdown in terminal (`pip install rich`) | one-shot |
941
+ | `mdx` | Render last reply as Markdown + LaTeX (KaTeX) + Mermaid diagrams in browser | one-shot |
942
+
943
+ See `/doc PROC` for the full protocol, built-in processor reference, and guide to writing your own.
944
+
945
+ ---
946
+
947
+ ### Team runs (`/team`)
948
+
949
+ Spawn multiple 1bcoder workers in parallel, each running a different plan against the same project. Each worker gets its own context (e.g. `/tree`, `/find`, `/map`) and saves results to `.1bcoder/results/`.
950
+
951
+ ```
952
+ /team list # list team definitions
953
+ /team show code-analysis # show workers in a team
954
+ /team new my-team # create team yaml from template
955
+ /team run code-analysis --param keyword=auth --param task="404 on login"
956
+ ```
957
+
958
+ Team definition (`.1bcoder/teams/<name>.yaml`):
959
+ ```yaml
960
+ workers:
961
+ - name: structure
962
+ host: localhost:11434
963
+ model: qwen2.5-coder:1.5b
964
+ script: team-tree-worker.txt
965
+ - name: search
966
+ host: openai://localhost:1234
967
+ model: qwen2.5-coder:1.5b
968
+ script: team-search-worker.txt
969
+ depends_on: structure
970
+ - name: summary
971
+ host: 192.168.0.10:11434
972
+ model: gemma3:4b
973
+ script: team-map-worker.txt
974
+ depends_on: structure, search
975
+ ```
976
+
977
+ `name` — optional worker label (auto-assigned 1, 2, 3… if omitted).
978
+ `depends_on` — comma-separated worker names; worker waits until all listed workers finish before starting. Workers without `depends_on` start in parallel immediately.
979
+
980
+ `--param` values are forwarded to every worker script as `{{placeholders}}`. Each worker log goes to `.1bcoder/team-logs/`. After all workers finish, aggregate with a summary script:
981
+
982
+ ```
983
+ /script apply team-summarize.txt --param keyword=auth --param task="404 on login"
984
+ ```
985
+
986
+ Built-in team scripts in `<install>/.1bcoder/scripts/`:
987
+
988
+ | Script | Worker role |
989
+ |---|---|
990
+ | `team-tree-worker.txt` | `/tree` → where does the keyword live structurally? |
991
+ | `team-search-worker.txt` | `/find` → which functions implement it? |
992
+ | `team-map-worker.txt` | `/map find` → what depends on it? |
993
+ | `team-summarize.txt` | reads all results, produces unified answer |
994
+
995
+ ---
996
+
997
+ ### Session controls
998
+
999
+ | Command | Description |
1000
+ |---|---|
1001
+ | `/model [-sc]` | Switch AI model interactively |
1002
+ | `/model <name> [-sc]` | Switch directly by name (e.g. `/model gemma3:1b`) |
1003
+ | `/host <url> [-sc]` | Switch host and provider (see below); `-sc` keeps context |
1004
+ | `/ctx <n>` | Set context window size in tokens (default 8192) |
1005
+ | `/ctx` | Show current usage vs limit |
1006
+ | `/ctx clear` | Clear all conversation messages (keeps `/param` and num_ctx) |
1007
+ | `/ctx clear <n>` | Remove last N messages from context |
1008
+ | `/ctx cut` | Remove oldest messages until context fits |
1009
+ | `/ctx compact` | Ask AI to summarize the conversation, replace context with summary |
1010
+ | `/ctx save <file>` | Save full conversation to file |
1011
+ | `/ctx load <file>` | Restore a saved conversation |
1012
+ | `/ctx savepoint set` | Mark current position as a savepoint |
1013
+ | `/ctx savepoint rollback` | Remove all messages added since the savepoint |
1014
+ | `/ctx savepoint compact` | Summarize messages since savepoint, replace with summary |
1015
+ | `/ctx savepoint show` | Show savepoint info and messages added since |
1016
+ | `/think exclude` | Strip `<think>` blocks from context (default) |
1017
+ | `/think include` | Keep `<think>` blocks in context (pass model reasoning to next turn) |
1018
+ | `/think show` | Show `<think>` blocks in terminal (default) |
1019
+ | `/think hide` | Hide `<think>` blocks in terminal |
1020
+ | `/param <key> <value>` | Set a model parameter for every request (e.g. `temperature`, `enable_thinking`) |
1021
+ | `/param timeout <seconds>` | Set HTTP read timeout — increase when models are slow on large contexts (default: 120s) |
1022
+ | `/param` | Show currently set params including timeout |
1023
+ | `/param clear` | Remove all params and reset timeout to 120s |
1024
+ | `/role <persona>` | Set a system persona for the AI (e.g. `/role You are a Linux kernel expert`) |
1025
+ | `/role show` | Show the active persona |
1026
+ | `/role clear` | Remove the active persona |
1027
+ | `/format <description>` | Inject a strict output format constraint and call the AI (e.g. `JSON array`, `one word`) |
1028
+ | `/format clear` | Remove the active format constraint from context |
1029
+ | `/clear` | Clear conversation context, reset params, and reload model metadata |
1030
+ | `/help` | Show full command reference |
1031
+ | `/help <command>` | Show help for one command (e.g. `/help map`) |
1032
+ | `/help <command> ctx` | Same, and inject into AI context |
1033
+ | `/init` | Create `.1bcoder/` scaffold in current directory |
1034
+ | `/exit` | Quit |
1035
+
1036
+ ### Providers
1037
+
1038
+ 1bcoder supports **Ollama** (default) and any **OpenAI-compatible** endpoint (LMStudio, LiteLLM, etc.).
1039
+ The provider is encoded in the URL scheme — no separate flag needed.
1040
+
1041
+ | URL | Provider |
1042
+ |---|---|
1043
+ | `localhost:11434` | Ollama (default, no scheme needed) |
1044
+ | `ollama://localhost:11434` | Ollama (explicit) |
1045
+ | `openai://localhost:1234` | LMStudio |
1046
+ | `openai://localhost:4000` | LiteLLM |
1047
+ | `openai://api.example.com` | Any OpenAI-compatible proxy |
1048
+
1049
+ ```
1050
+ /host openai://localhost:1234 # switch to LMStudio, clear context
1051
+ /host openai://localhost:4000 -sc # switch to LiteLLM, keep context
1052
+ /host localhost:11434 # back to Ollama
1053
+ ```
1054
+
1055
+ **`/parallel` with mixed providers** — each worker carries its own scheme:
1056
+
1057
+ ```
1058
+ /parallel "review this" \
1059
+ ollama://localhost:11434|llama3.2:1b|ans/ollama.txt \
1060
+ openai://localhost:1234|qwen2.5:7b|ans/lmstudio.txt \
1061
+ openai://localhost:4000|gpt-4o-mini|ans/litellm.txt
1062
+ ```
1063
+
1064
+ On startup the active provider is shown:
1065
+ ```
1066
+ model : llama3.2:1b [1.3G Q4_K 131K]
1067
+ host : http://localhost:11434
1068
+ provider : ollama
1069
+ ```
1070
+
1071
+ The status line before each `>` prompt shows the same info in compact form:
1072
+ ```
1073
+ llama3.2:1b [1.3G Q4_K 131K] │ ctx 245 / 8192 (3%)
1074
+ gpt-4o-mini [128K] │ ctx 1536 / 128000 (1%) ← OpenAI (no disk size)
1075
+ ```
1076
+
1077
+ ---
1078
+
1079
+ ## Project layout
1080
+
1081
+ ```
1082
+ 1bcoder/
1083
+ ├── chat.py # entire application — REPL, all commands
1084
+ ├── map_index.py # standalone project scanner (usable without 1bcoder)
1085
+ ├── map_query.py # standalone map query tool (find + trace)
1086
+ ├── map_query_help.txt # full map_query usage reference
1087
+ ├── requirements.txt # pip dependencies
1088
+ ├── pyproject.toml # build metadata
1089
+ ├── run.bat # Windows quick-launch
1090
+ ├── MCP.md # MCP server quick-reference
1091
+ └── _bcoder_data/ # wheel defaults (copied to ~/.1bcoder/ on first run)
1092
+ ├── agents/ # built-in named agent definitions (ask.txt, advance.txt, ...)
1093
+ ├── aliases.txt # global aliases loaded at startup
1094
+ ├── scripts/ # built-in plan .txt files (team workers, examples)
1095
+ ├── teams/ # /team yaml definitions
1096
+ ├── prompts/ # /prompt saved templates
1097
+ ├── proc/ # /proc post-processor scripts
1098
+ └── doc/ # /doc articles (PROC.md, ...)
1099
+
1100
+ ~/.1bcoder/ # user global dir (created on first run, edit freely)
1101
+ └── (same structure as above — overrides wheel defaults)
1102
+
1103
+ <project>/.1bcoder/ # project-local dir (created by /init)
1104
+ ├── agents/ # project-specific agent definitions (override global)
1105
+ ├── aliases.txt # project-local aliases (merged over global at startup)
1106
+ ├── scripts/ # project-specific plan .txt files
1107
+ ├── teams/ # project-specific team yamls (override global)
1108
+ ├── agent.txt # default agent config (max_turns, auto_apply, tools)
1109
+ ├── config.yml # /config save — host, model, ctx, params, vars, procs
1110
+ ├── profiles.txt # /parallel worker profiles (project-local)
1111
+ ├── map.txt # generated by /map index
1112
+ ├── map.prev.txt # previous snapshot (for /map diff)
1113
+ ├── results/ # worker output files (tree-analysis.txt, etc.)
1114
+ └── team-logs/ # per-worker logs from /team run
1115
+ ```
1116
+
1117
+ ---
1118
+
1119
+ ## Keyboard shortcuts
1120
+
1121
+ | Key | Action |
1122
+ |---|---|
1123
+ | `Enter` | Submit message |
1124
+ | `Shift+Enter` | Insert newline (requires Kitty keyboard protocol support) |
1125
+ | `Ctrl+N` | Insert newline (reliable fallback for all terminals) |
1126
+ | `ESC` | Interrupt AI response mid-stream |
1127
+ | `Ctrl+C` | Interrupt streaming or exit prompt |
1128
+
1129
+ On Windows: hold `Shift` and drag with the left mouse button to select and copy text from the terminal.
1130
+
1131
+ ---
1132
+
1133
+ ## Tips for 1B models
1134
+
1135
+ - **Start small.** Use `/read file.py 10-25` instead of loading the whole file. Short context = better focus.
1136
+ - **Use `/fix` not `/patch`.** The `LINE N: content` format is much more reliable at 1B scale than free-form generation.
1137
+ - **Build a map first.** Run `/map index .` at the start of a session, then use `/map find` to load only the relevant parts into context.
1138
+ - **Use scripts.** Scripts make multi-step work reproducible — the model only needs to handle one step at a time.
1139
+ - **Capture workflows.** After solving a task manually, run `/script create ctx` to save the exact steps as a reusable script.
1140
+ - **Use `.var` files instead of context.** Save project constants (`port`, `db`, `host`, `main_file`) to a `.var` file once with `/var save`. Future sessions reload them instantly with `/var load` — no tokens wasted reading config files.
1141
+ - **Let `/fill` do the research.** If you have NaN variables and a 4B+ model, just run `/fill` — the agent finds and loads `.var` files, reads config files, and sets everything without you having to specify where to look.
1142
+ - **Use `/plan` before `/agent`.** For complex tasks, run `/plan <goal>` first to get a structured step-by-step plan in `plan.txt`, then `/agent implement plan plan.txt` to execute it turn by turn.
1143
+ - **Agent mode needs a bigger model.** `/agent advance` works best with 32B+ models. For 1B–7B, use scripts instead.
1144
+ - **Ctrl+C** interrupts streaming if the model starts going off-track.
1145
+ - **Use `/readln` before `/patch`.** Reading with line numbers lets you reference exact locations; `/patch` then sends the file without line numbers so the model's SEARCH block matches the real content.
1146
+ - **Timeout errors?** If you see `Read timed out` with a large context, run `/param timeout 300` to extend the limit to 5 minutes.
1147
+ - **Model behaving oddly after a long session?** Run `/clear` — it clears context, resets all params, and reloads model metadata, equivalent to a restart.
1148
+
1149
+ ## Command autocorrection
1150
+
1151
+ 1bcoder automatically detects and fixes common typos in commands before executing them — for both human input and agent-generated `ACTION:` lines.
1152
+
1153
+ | Error type | Example | Fixed to |
1154
+ |---|---|---|
1155
+ | Command name typo | `/insrt models.py 14` | `/insert models.py 14` |
1156
+ | File path typo | `/read models.p` | `/read models.py` |
1157
+ | Keyword prefix | `/insert main.py 14 co` | `/insert main.py 14 code` |
1158
+ | Subcommand prefix | `/map fnd auth` | `/map find auth` |
1159
+ | Subcommand typo | `/bkup resore calc.py` | `/bkup restore calc.py` |
1160
+
1161
+ For human input, the corrected command is shown with `[fix?]` and you are asked to confirm. For agent actions (`auto` mode), the fix is applied silently with a `[fix]` warning. Prefix matching is used for keywords to avoid false positives on hint words.
1162
+
1163
+ ---
1164
+
1165
+ ## Tips for reasoning models (Qwen3, DeepSeek-R1, etc.)
1166
+
1167
+ - **Disable thinking for simple tasks.** `/param enable_thinking false` speeds up responses when reasoning isn't needed.
1168
+ - **Use `/think include` to chain reasoning.** Pass one model's `<think>` output as context to another model or the next turn.
1169
+ - **`/patch <file> code` over `/edit`.** Reasoning models write precise SEARCH/REPLACE blocks — no line numbers needed, no full-file rewrites.
1170
+ - **`/ctx compact` after long sessions.** Reasoning models produce verbose output; compact regularly to stay within context limits.
1171
+ - **Connect via LMStudio.** `/host openai://localhost:1234` — full parameter control including `enable_thinking`, `temperature`, `seed`.
1172
+
1173
+ ---
1174
+
1175
+ ## Compatible local inference backends
1176
+
1177
+ | Name | OS | Server | Default port | Connector | Description |
1178
+ |---|---|---|---|---|---|
1179
+ | Ollama | Win / Mac / Linux | built-in | 11434 | `ollama://` | Default backend, easiest setup, pulls models automatically |
1180
+ | LM Studio | Win / Mac / Linux | built-in | 1234 | `openai://` | Desktop GUI, model browser, OpenAI-compatible server |
1181
+ | llama.cpp | Win / Mac / Linux | `./llama-server` | 8080 | `openai://` | Minimal C++ server, CPU + GPU, no install needed |
1182
+ | LocalAI | Linux / Docker | Docker container | 8080 | `openai://` | Runs many formats in a container, drop-in OpenAI replacement |
1183
+ | Jan.ai | Win / Mac / Linux | built-in | 1337 | `openai://` | Desktop app, offline-first, OpenAI-compatible local server |
1184
+ | llamafile | Win / Mac / Linux | self-contained exe | 8080 | `openai://` | Single executable, no install, built-in server (Mozilla) |
1185
+ | GPT4All | Win / Mac / Linux | built-in | 4891 | `openai://` | Desktop app, CPU-friendly, targets non-technical users |
1186
+ | Kobold.cpp | Win / Mac / Linux | built-in | 5001 | `openai://` | Popular for creative use, OpenAI-compatible API endpoint |
1187
+ | text-generation-webui | Linux / Win | `--api` flag | 5000 | `openai://` | oobabooga UI, needs `--api` flag to expose OpenAI endpoint |
1188
+ | TabbyAPI | Linux / Win | built-in | 5000 | `openai://` | Focused on exl2/GPTQ quantized models, low VRAM |
1189
+ | vLLM | Linux | built-in | 8000 | `openai://` | Production server, high throughput, requires significant VRAM |