little-coder 1.0.0

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 (76) hide show
  1. package/.pi/extensions/benchmark-profiles/index.ts +159 -0
  2. package/.pi/extensions/benchmark-profiles/profiles.test.ts +78 -0
  3. package/.pi/extensions/browser/index.ts +304 -0
  4. package/.pi/extensions/browser-extract-retention/index.ts +170 -0
  5. package/.pi/extensions/browser-extract-retention/live-integration.test.ts +176 -0
  6. package/.pi/extensions/browser-extract-retention/retention.test.ts +195 -0
  7. package/.pi/extensions/checkpoint/index.ts +66 -0
  8. package/.pi/extensions/evidence/evidence.test.ts +30 -0
  9. package/.pi/extensions/evidence/index.ts +119 -0
  10. package/.pi/extensions/evidence-compact/bridge.test.ts +25 -0
  11. package/.pi/extensions/evidence-compact/index.ts +32 -0
  12. package/.pi/extensions/extra-tools/index.ts +139 -0
  13. package/.pi/extensions/finalize-warn/index.ts +73 -0
  14. package/.pi/extensions/hello/index.ts +7 -0
  15. package/.pi/extensions/knowledge-inject/index.ts +149 -0
  16. package/.pi/extensions/knowledge-inject/scoring.test.ts +81 -0
  17. package/.pi/extensions/llama-cpp-provider/index.ts +58 -0
  18. package/.pi/extensions/output-parser/index.ts +56 -0
  19. package/.pi/extensions/output-parser/parser.test.ts +90 -0
  20. package/.pi/extensions/output-parser/parser.ts +126 -0
  21. package/.pi/extensions/permission-gate/index.ts +53 -0
  22. package/.pi/extensions/permission-gate/permission.test.ts +26 -0
  23. package/.pi/extensions/quality-monitor/index.ts +70 -0
  24. package/.pi/extensions/quality-monitor/quality.test.ts +75 -0
  25. package/.pi/extensions/quality-monitor/quality.ts +84 -0
  26. package/.pi/extensions/shell-session/helpers.test.ts +62 -0
  27. package/.pi/extensions/shell-session/helpers.ts +58 -0
  28. package/.pi/extensions/shell-session/index.ts +139 -0
  29. package/.pi/extensions/skill-inject/frontmatter.test.ts +72 -0
  30. package/.pi/extensions/skill-inject/frontmatter.ts +39 -0
  31. package/.pi/extensions/skill-inject/index.ts +256 -0
  32. package/.pi/extensions/skill-inject/selector.test.ts +91 -0
  33. package/.pi/extensions/thinking-budget/budget.test.ts +182 -0
  34. package/.pi/extensions/thinking-budget/index.ts +105 -0
  35. package/.pi/extensions/tool-gating/index.ts +38 -0
  36. package/.pi/extensions/turn-cap/index.ts +37 -0
  37. package/.pi/extensions/write-guard/index.ts +61 -0
  38. package/.pi/settings.json +76 -0
  39. package/AGENTS.md +61 -0
  40. package/CHANGELOG.md +618 -0
  41. package/LICENSE +201 -0
  42. package/NOTICE +22 -0
  43. package/README.md +245 -0
  44. package/bin/little-coder.mjs +99 -0
  45. package/models.json +45 -0
  46. package/package.json +46 -0
  47. package/skills/knowledge/bfs_state_space.md +9 -0
  48. package/skills/knowledge/binary_search.md +9 -0
  49. package/skills/knowledge/dfs_vs_bfs.md +9 -0
  50. package/skills/knowledge/dynamic_programming.md +9 -0
  51. package/skills/knowledge/hash_vs_tree.md +9 -0
  52. package/skills/knowledge/io_wrapper.md +9 -0
  53. package/skills/knowledge/recursion_backtracking.md +9 -0
  54. package/skills/knowledge/rule_string_transform.md +9 -0
  55. package/skills/knowledge/sorting_choice.md +9 -0
  56. package/skills/knowledge/tree_rerooting.md +9 -0
  57. package/skills/knowledge/tree_zipper.md +9 -0
  58. package/skills/knowledge/two_pointers.md +9 -0
  59. package/skills/knowledge/workspace_docs.md +10 -0
  60. package/skills/protocols/cite_before_answer.md +19 -0
  61. package/skills/protocols/research_protocol.md +20 -0
  62. package/skills/protocols/task_decomposition.md +24 -0
  63. package/skills/tools/agent.md +24 -0
  64. package/skills/tools/bash.md +29 -0
  65. package/skills/tools/browser_click.md +25 -0
  66. package/skills/tools/browser_extract.md +24 -0
  67. package/skills/tools/browser_navigate.md +22 -0
  68. package/skills/tools/browser_type.md +22 -0
  69. package/skills/tools/edit.md +30 -0
  70. package/skills/tools/evidence_add.md +23 -0
  71. package/skills/tools/glob.md +28 -0
  72. package/skills/tools/grep.md +29 -0
  73. package/skills/tools/read.md +28 -0
  74. package/skills/tools/shell_session.md +31 -0
  75. package/skills/tools/webfetch.md +22 -0
  76. package/skills/tools/write.md +29 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,22 @@
1
+ little-coder
2
+ Copyright 2026 Itay Inbar
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License"); see the
5
+ accompanying LICENSE file for the full text.
6
+
7
+ --------------------------------------------------------------------------
8
+ Attribution to upstream project
9
+ --------------------------------------------------------------------------
10
+
11
+ This product is a derivative work based on CheetahClaws / ClawSpring
12
+ (https://github.com/SafeRL-Lab/clawspring), Copyright SafeRL-Lab,
13
+ licensed under the Apache License, Version 2.0.
14
+
15
+ The upstream project provided the foundational agent architecture, tool
16
+ system, multi-provider support, and REPL interface. little-coder has
17
+ been substantially modified: skill-augmented tool use, domain-knowledge
18
+ injection, workspace awareness, thinking-budget enforcement with
19
+ reasoning reuse, the Write-vs-Edit tool invariant, a multi-language
20
+ Aider Polyglot benchmark harness, per-model profiles for small local
21
+ LLMs, and a complete UI refresh have been added. Many upstream features
22
+ that did not fit the small-model focus have been removed.
package/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # little-coder
2
+
3
+ **A coding agent tuned for small local models, built on top of [pi](https://pi.dev).**
4
+
5
+ The research story behind all this — why scaffold–model fit matters, how a 9.7 B Qwen beat frontier entries on Aider Polyglot, and what the load-bearing mechanisms actually do — is written up on Substack: **[*Honey, I Shrunk the Coding Agent*](https://open.substack.com/pub/itayinbarr/p/honey-i-shrunk-the-coding-agent)**. Start there if you want the "why"; stay here for the "how".
6
+
7
+ ## How it relates to pi
8
+
9
+ [pi](https://pi.dev) is the minimal substrate — agent loop, multi-provider API, TUI, session tree, compaction, extension model. Four built-in tools (read / write / edit / bash) and a ~1000-token system prompt.
10
+
11
+ little-coder is **pi + 20 extensions + 30 skill markdown files + a Python benchmark harness**. It doesn't fork pi or shadow its CLI — pi is a plain dependency in `package.json`, and everything little-coder-specific lives under `.pi/extensions/`, `skills/`, and `benchmarks/`. You can mix little-coder with pi packages from anyone else, add your own extensions, or disable ours per-project via `.pi/settings.json`.
12
+
13
+ If you've never used pi, it's useful to skim [pi.dev](https://pi.dev) first — the rest of this doc assumes pi's model of `--agent-import-path`, `--mode rpc`, and `.pi/extensions/` auto-discovery.
14
+
15
+ ## Paper / benchmark results
16
+
17
+ | Release | Model | Benchmark | Result |
18
+ |---|---|---|---|
19
+ | [**v0.0.2**](https://github.com/itayinbarr/little-coder/releases/tag/v0.0.2) (commit `1d62bde`) — the paper | Qwen3.5-9B via Ollama | Aider Polyglot (225 exercises) | **45.56 %** mean of two runs; matched-model vanilla Aider baseline 19.11 %. Paper: [*Honey, I Shrunk the Coding Agent* on Substack](https://open.substack.com/pub/itayinbarr/p/honey-i-shrunk-the-coding-agent). |
20
+ | [**v0.0.5**](https://github.com/itayinbarr/little-coder/releases/tag/v0.0.5) — pre-pi Python | Qwen3.6-35B-A3B via llama.cpp | Aider Polyglot | **78.67 %**. [Full narrative](docs/benchmark-qwen3.6-35b-a3b.md). |
21
+ | [**v0.1.4**](https://github.com/itayinbarr/little-coder/releases/tag/v0.1.4) — on pi | Qwen3.6-35B-A3B via llama.cpp | Terminal-Bench-Core v0.1.1 (80 tasks) | **40.0 %** in 6 h 50 min. [Write-up](docs/benchmark-terminal-bench-v0.1.1.md). |
22
+ | [**v0.1.13**](https://github.com/itayinbarr/little-coder/releases/tag/v0.1.13) — on pi, TB 2.0 leaderboard | Qwen3.6-35B-A3B via llama.cpp | Terminal-Bench 2.0 (89 tasks × 5 trials = 445) | **23.82 %** (106 / 445). [PR #158](https://huggingface.co/datasets/harborframework/terminal-bench-2-leaderboard/discussions/158) — awaiting maintainer merge. |
23
+ | [**v0.1.24**](https://github.com/itayinbarr/little-coder/releases/tag/v0.1.24) — on pi, TB 2.0 leaderboard, smaller model | Qwen3.5-9B (Q4_K_M) via llama.cpp (5.3 GB on GPU, 2× faster per-token than the 35B-A3B) | Terminal-Bench 2.0 (89 tasks × 5 trials = 445) | **9.21 %** (41 / 445). [PR #163](https://huggingface.co/datasets/harborframework/terminal-bench-2-leaderboard/discussions/163) — awaiting maintainer merge. |
24
+ | [**v0.1.27**](https://github.com/itayinbarr/little-coder/releases/tag/v0.1.27) — on pi, GAIA validation | Qwen3.6-35B-A3B via llama.cpp | GAIA validation set (165 tasks) | **40.00 %** (66 / 165). L1 60.4 % / L2 37.2 % / L3 7.7 %. Test-split run pending. |
25
+
26
+ All runs used a consumer laptop: i9-14900HX, 32 GB RAM, **8 GB VRAM** on RTX 5070 Laptop (Blackwell). No cloud inference at any point.
27
+
28
+ ---
29
+
30
+ ## Roadmap
31
+
32
+ The near-term focus is **benchmarking**, not new features. The paper established that scaffold–model fit moves a 9.7 B model from 19 % to 45 % on Aider Polyglot. The open question is: **how wide is the impact radius?** Does the same set of adaptations — Write-vs-Edit invariant, per-turn skill injection, thinking-budget cap, output-repair, quality monitor — help on tasks that *aren't* self-contained coding exercises? What breaks? What compounds?
33
+
34
+ The plan is to establish a wide baseline before any further scaffolding changes:
35
+
36
+ 1. **Aider Polyglot** — done. 45.56 % (paper, Qwen3.5-9B) and 78.67 % (v0.0.5, Qwen3.6-35B-A3B).
37
+ 2. **Terminal-Bench-Core v0.1.1** — done. 40.0 % (v0.1.4).
38
+ 3. **Terminal-Bench 2.0** — done. Qwen3.6-35B-A3B at **23.82 %** ([PR #158](https://huggingface.co/datasets/harborframework/terminal-bench-2-leaderboard/discussions/158)) and Qwen3.5-9B at **9.21 %** ([PR #163](https://huggingface.co/datasets/harborframework/terminal-bench-2-leaderboard/discussions/163)), both awaiting maintainer merge. The v0.1.24 prompt-repetition fix (re-add tool descriptions + concision guideline, validated by a 4 / 4 pilot on the previously-regressing `prove-plus-comm` task) was the prompt for both submissions.
39
+ 4. **GAIA** — validation set done at v0.1.27: **40.00 %** (66 / 165) on Qwen3.6-35B-A3B. Per-level L1 60.4 % / L2 37.2 % / L3 7.7 %. Test-split run (301 tasks) pending → leaderboard submission to follow.
40
+ 5. **SWE-bench Verified** — after GAIA. Multi-file real-world patches; the longest-horizon test of whether the scaffolding generalizes past exercise-scale tasks.
41
+
42
+ **After that baseline is in place**, the next phase starts: improvement experiments targeted at the specific failure patterns we've seen (thinking-budget / quality-monitor behavior on long-horizon tasks, deliberate.py-style parallel branches on failure, better shell-session recovery for interactive-process traps). No scaffold changes until the data says which ones are worth running.
43
+
44
+ ---
45
+
46
+ ## Install
47
+
48
+ One-line install (Node.js 20.6+ required):
49
+
50
+ ```bash
51
+ curl -fsSL https://raw.githubusercontent.com/itayinbarr/little-coder/main/install.sh | bash
52
+ ```
53
+
54
+ Or with npm directly:
55
+
56
+ ```bash
57
+ npm install -g little-coder
58
+ ```
59
+
60
+ That's the whole install. No clone, no `npm install` in a workspace, no PATH fiddling. `little-coder` is now on your PATH and works from any directory.
61
+
62
+ ## Run
63
+
64
+ ```bash
65
+ cd ~/your-project
66
+ little-coder --model anthropic/claude-haiku-4-5
67
+ ```
68
+
69
+ Other models work the same way:
70
+
71
+ ```bash
72
+ little-coder --model openai/gpt-4o-mini "What does this codebase do?"
73
+ little-coder --model llamacpp/qwen3.6-35b-a3b # local llama.cpp server
74
+ little-coder --model ollama/qwen3.5 # local Ollama
75
+ little-coder --list-models # see everything pi knows about
76
+ ```
77
+
78
+ The agent uses the directory you launched it from as its working directory — `Read` / `Write` / `Edit` / `Bash` operate on your project, not on little-coder's install path.
79
+
80
+ For local providers (llama.cpp, Ollama) pi expects *some* value in the API-key env even though local servers ignore it:
81
+
82
+ ```bash
83
+ export LLAMACPP_API_KEY=noop
84
+ export OLLAMA_API_KEY=noop
85
+ ```
86
+
87
+ `LLAMACPP_BASE_URL` and `OLLAMA_BASE_URL` override the defaults (`http://127.0.0.1:8888/v1`, `http://127.0.0.1:11434/v1`).
88
+
89
+ For cloud providers, set the standard env (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, etc.) and pi will discover it.
90
+
91
+ ## Local model setup (optional)
92
+
93
+ Skip this section if you're using a cloud model.
94
+
95
+ **Option A — llama.cpp** (fastest for local; supports Qwen3.6-35B-A3B MoE):
96
+
97
+ ```bash
98
+ # One-time: build llama.cpp with CUDA (sm_XXX = your GPU arch; Blackwell = 120)
99
+ git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp
100
+ cmake -B build -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=120 -DLLAMA_CURL=ON
101
+ cmake --build build --config Release -j
102
+
103
+ # Fetch a GGUF
104
+ pip install -U "huggingface_hub[cli]"
105
+ hf download unsloth/Qwen3.6-35B-A3B-GGUF Qwen3.6-35B-A3B-UD-Q4_K_M.gguf --local-dir ~/models
106
+
107
+ # Serve it (MoE trick: experts in RAM, attention on GPU → 22 GB model on 8 GB VRAM)
108
+ build/bin/llama-server -m ~/models/Qwen3.6-35B-A3B-UD-Q4_K_M.gguf \
109
+ --host 127.0.0.1 --port 8888 --jinja \
110
+ -c 16384 -ngl 99 --n-cpu-moe 999 --flash-attn on
111
+ ```
112
+
113
+ **Option B — Ollama** (simpler, but slower on MoE):
114
+
115
+ ```bash
116
+ curl -fsSL https://ollama.com/install.sh | sh
117
+ ollama pull qwen3.5 # 9.7B — the paper's model
118
+ # or: ollama pull qwen3.6-35b-a3b
119
+ ```
120
+
121
+ All small-model-specific extensions auto-disable for large/cloud models so they don't interfere.
122
+
123
+ ---
124
+
125
+ ## Troubleshooting
126
+
127
+ **`little-coder: command not found`** — npm's global bin directory isn't on your PATH. Run `npm config get prefix` to see where it installed; add `<prefix>/bin` to your PATH. Or reinstall with `sudo` if your prefix needs root.
128
+
129
+ **`ECONNREFUSED 127.0.0.1:8888`** — llama.cpp isn't running. Start `llama-server` first, or switch `--model` to an Ollama/cloud ID.
130
+
131
+ **No API key env var warning** — pi expects *some* key even for local providers. Export `LLAMACPP_API_KEY=noop` (or `OLLAMA_API_KEY=noop`) before launching.
132
+
133
+ **Extension load failures on startup** — run `little-coder --list-models --verbose`; extension errors surface there. If the install looks corrupt: `npm uninstall -g little-coder && npm install -g little-coder`.
134
+
135
+ **Node version too old** — little-coder needs Node ≥ 20.6.0. Check with `node --version`. Easiest fix: `nvm install 20 && nvm use 20`.
136
+
137
+ ---
138
+
139
+ ## Developing little-coder locally
140
+
141
+ If you want to hack on the extensions or skills:
142
+
143
+ ```bash
144
+ git clone https://github.com/itayinbarr/little-coder.git
145
+ cd little-coder
146
+ npm install
147
+ npm link # makes the local checkout available as `little-coder`
148
+ little-coder --model anthropic/claude-haiku-4-5
149
+ ```
150
+
151
+ To unlink: `npm unlink -g little-coder`.
152
+
153
+ The benchmarks harness (`benchmarks/`) is dev-only and not shipped with the npm package. Run it from a clone with `python3 benchmarks/aider_polyglot.py …` etc.
154
+
155
+ ---
156
+
157
+ ## Architecture
158
+
159
+ ```
160
+ little-coder/
161
+ ├── .pi/
162
+ │ ├── settings.json # per-model profiles + benchmark_overrides (terminal_bench, gaia)
163
+ │ └── extensions/ # 20 TypeScript extensions, auto-discovered by pi
164
+ │ ├── llama-cpp-provider/ # registers llamacpp/* and ollama/* as OpenAI-compat providers
165
+ │ ├── write-guard/ # Write refuses on existing files — the whitepaper invariant
166
+ │ ├── extra-tools/ # glob, webfetch, websearch (pi ships grep/find)
167
+ │ ├── skill-inject/ # per-turn tool-skill selection (error > recency > intent)
168
+ │ ├── knowledge-inject/ # algorithm cheat-sheet scoring (word=1.0, bigram=2.0, threshold=2.0)
169
+ │ ├── output-parser/ # repair malformed ```tool, <tool_call>, bare JSON
170
+ │ ├── quality-monitor/ # empty / hallucinated / loop detection + correction follow-up
171
+ │ ├── thinking-budget/ # cap thinking tokens per turn, retry with thinking off
172
+ │ ├── permission-gate/ # bash whitelist (ls, cat, git log/status/diff, etc.)
173
+ │ ├── checkpoint/ # snapshot files before Write/Edit
174
+ │ ├── tool-gating/ # enforces _allowed_tools at exec + schema levels
175
+ │ ├── turn-cap/ # max_turns abort (Polyglot unbounded, TB 40, GAIA 30)
176
+ │ ├── benchmark-profiles/ # reads settings.json → systemPromptOptions + sets temperature
177
+ │ ├── shell-session/ # ShellSession[Cwd|Reset] — tmux-proxy + subprocess backends
178
+ │ ├── browser/ # Playwright BrowserNavigate/Click/Type/Scroll/Extract/Back/History
179
+ │ ├── evidence/ # EvidenceAdd/Get/List — per-session store, 1 KB snippet cap
180
+ │ └── evidence-compact/ # preserves evidence across pi's auto-compaction
181
+ ├── skills/ # 30 markdown files the extensions inject on demand
182
+ │ ├── tools/*.md # 14 tool-usage cards
183
+ │ ├── knowledge/*.md # 13 algorithm cheat sheets
184
+ │ └── protocols/*.md # 3 research/cite/decomposition workflows
185
+ ├── benchmarks/
186
+ │ ├── rpc_client.py # PiRpc — spawns `pi --mode rpc`, demuxes events + UI requests
187
+ │ ├── aider_polyglot.py # Polyglot driver with per-language transforms
188
+ │ ├── tb_adapter/ # Terminal-Bench 1.0 BaseAgent (tmux-proxy)
189
+ │ ├── harbor_adapter/ # Terminal-Bench 2.0 BaseAgent (async env.exec proxy)
190
+ │ ├── tb_pilot.sh / harbor_pilot.sh
191
+ │ ├── tb_status.sh / harbor_status.sh
192
+ │ └── test_rpc_client.py
193
+ ├── AGENTS.md # project system prompt (pi discovers it automatically)
194
+ ├── models.json # documented provider registration (extension is canonical)
195
+ └── docs/
196
+ ├── benchmark-*.md # per-benchmark narratives
197
+ └── architecture.md # v0.0.5-era Python architecture (historical)
198
+ ```
199
+
200
+ **Key invariant.** pi is a minimal base by design. Every little-coder mechanism ships as a pi extension that hooks pi's lifecycle events (`before_agent_start`, `context`, `before_provider_request`, `tool_call`, `tool_result`, `turn_end`, `session_compact`). Extensions are independent and can be enabled/disabled per deployment via `.pi/settings.json`. If you don't want one, delete its directory or disable it in settings; if you want to add another, drop it next to the existing ones.
201
+
202
+ ---
203
+
204
+ ## Reproducing the paper (v0.0.2)
205
+
206
+ ```bash
207
+ git clone https://github.com/itayinbarr/little-coder.git
208
+ cd little-coder
209
+ git checkout v0.0.2
210
+ # Follow that version's README for its Python setup (pip install -e .)
211
+ ```
212
+
213
+ The paper ran `ollama/qwen3.5` through the Python little-coder at commit **`1d62bde`** (tag [`v0.0.2`](https://github.com/itayinbarr/little-coder/releases/tag/v0.0.2)). The 45.56 % mean figure is the average of two full 225-exercise runs on that exact codebase. For the 78.67 % headline, check out tag [`v0.0.5`](https://github.com/itayinbarr/little-coder/releases/tag/v0.0.5) — both are pre-pi Python and follow the pre-pi setup.
214
+
215
+ ---
216
+
217
+ ## Citation
218
+
219
+ ```bibtex
220
+ @misc{inbar2026littlecoder,
221
+ title = {little-coder: A Coding Agent Optimized for Small Local Language Models},
222
+ subtitle = {Architectural Adaptation Lets a 9.7B Model Outperform Frontier Models on Aider Polyglot},
223
+ author = {Inbar, Itay},
224
+ year = {2026},
225
+ month = apr,
226
+ howpublished = {\url{https://open.substack.com/pub/itayinbarr/p/honey-i-shrunk-the-coding-agent}},
227
+ note = {White paper}
228
+ }
229
+ ```
230
+
231
+ ---
232
+
233
+ ## Attribution
234
+
235
+ little-coder v0.0.x was a derivative work of [CheetahClaws / ClawSpring](https://github.com/SafeRL-Lab/clawspring) by SafeRL-Lab, Apache 2.0. That upstream provided the Python agent substrate, tool system, multi-provider support, and REPL.
236
+
237
+ little-coder v0.1.0+ replaces that substrate with **[pi](https://github.com/badlogic/pi-mono)** (`@mariozechner/pi-coding-agent`) by Mario Zechner — Apache 2.0 / MIT. pi provides the agent loop, provider abstraction, TUI, and extension model. little-coder rebuilds its small-model adaptations on top of pi as extensions.
238
+
239
+ All little-coder-specific mechanisms — Write-vs-Edit invariant, skill / knowledge injection, thinking-budget cap, output-parser, quality-monitor, per-model profiles, per-benchmark overrides, ShellSession / Browser / Evidence tool families, evidence-aware compaction — are preserved across versions.
240
+
241
+ ---
242
+
243
+ ## License
244
+
245
+ Apache 2.0 — see [LICENSE](LICENSE) for details. NOTICE tracks upstream attribution.
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ // little-coder launcher.
3
+ // Spawns the bundled pi runtime with our AGENTS.md, skills, and every
4
+ // custom extension wired in — works from any working directory.
5
+
6
+ import { spawn } from "node:child_process";
7
+ import { existsSync, readdirSync, statSync } from "node:fs";
8
+ import { dirname, join, resolve } from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+
11
+ // ---- 1. Node version preflight (>= 20.6.0, matching pi.dev) ----
12
+ const MIN_NODE = [20, 6, 0];
13
+ const cur = process.versions.node.split(".").map((n) => parseInt(n, 10));
14
+ const tooOld =
15
+ cur[0] < MIN_NODE[0] ||
16
+ (cur[0] === MIN_NODE[0] && cur[1] < MIN_NODE[1]) ||
17
+ (cur[0] === MIN_NODE[0] && cur[1] === MIN_NODE[1] && cur[2] < MIN_NODE[2]);
18
+ if (tooOld) {
19
+ console.error(
20
+ `little-coder requires Node.js >= ${MIN_NODE.join(".")} (you have ${process.versions.node}).\n` +
21
+ `Install a newer Node from https://nodejs.org or via nvm: 'nvm install 20'.`,
22
+ );
23
+ process.exit(1);
24
+ }
25
+
26
+ // ---- 2. Resolve package install root ----
27
+ const here = dirname(fileURLToPath(import.meta.url));
28
+ const pkgRoot = resolve(here, "..");
29
+
30
+ // ---- 3. Resolve the bundled pi binary ----
31
+ const piBin = join(pkgRoot, "node_modules", ".bin", "pi");
32
+ if (!existsSync(piBin)) {
33
+ console.error(
34
+ `little-coder: cannot find pi at ${piBin}.\n` +
35
+ `Try reinstalling: npm install -g little-coder`,
36
+ );
37
+ process.exit(1);
38
+ }
39
+
40
+ // ---- 4. Auto-discover bundled extensions ----
41
+ const extDir = join(pkgRoot, ".pi", "extensions");
42
+ const extArgs = [];
43
+ if (existsSync(extDir)) {
44
+ for (const name of readdirSync(extDir).sort()) {
45
+ const subdir = join(extDir, name);
46
+ const idx = join(subdir, "index.ts");
47
+ try {
48
+ if (statSync(subdir).isDirectory() && existsSync(idx)) {
49
+ extArgs.push("--extension", idx);
50
+ }
51
+ } catch {
52
+ // skip unreadable entries
53
+ }
54
+ }
55
+ }
56
+
57
+ // ---- 5. Compose pi argv ----
58
+ // --no-context-files : ignore the user's AGENTS.md / CLAUDE.md so OURS wins
59
+ // --no-extensions : skip pi's auto-discovery from cwd; explicit -e flags still load
60
+ // --system-prompt : load <pkgRoot>/AGENTS.md regardless of cwd
61
+ const agentsMd = join(pkgRoot, "AGENTS.md");
62
+ const piArgs = [
63
+ "--no-context-files",
64
+ "--no-extensions",
65
+ ...(existsSync(agentsMd) ? ["--system-prompt", agentsMd] : []),
66
+ ...extArgs,
67
+ ...process.argv.slice(2),
68
+ ];
69
+
70
+ // ---- 6. Spawn pi in the user's cwd ----
71
+ const child = spawn(piBin, piArgs, {
72
+ stdio: "inherit",
73
+ cwd: process.cwd(),
74
+ env: process.env,
75
+ });
76
+
77
+ const forward = (sig) => () => {
78
+ try {
79
+ child.kill(sig);
80
+ } catch {
81
+ // child already gone
82
+ }
83
+ };
84
+ process.on("SIGINT", forward("SIGINT"));
85
+ process.on("SIGTERM", forward("SIGTERM"));
86
+ process.on("SIGHUP", forward("SIGHUP"));
87
+
88
+ child.on("error", (err) => {
89
+ console.error("little-coder: failed to start pi:", err.message);
90
+ process.exit(1);
91
+ });
92
+
93
+ child.on("exit", (code, signal) => {
94
+ if (signal) {
95
+ process.kill(process.pid, signal);
96
+ } else {
97
+ process.exit(code ?? 0);
98
+ }
99
+ });
package/models.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "providers": {
3
+ "llamacpp": {
4
+ "api": "openai-completions",
5
+ "baseUrl": "http://127.0.0.1:8888/v1",
6
+ "apiKey": "LLAMACPP_API_KEY",
7
+ "models": [
8
+ {
9
+ "id": "qwen3.6-35b-a3b",
10
+ "name": "Qwen3.6-35B-A3B (local llama.cpp)",
11
+ "reasoning": true,
12
+ "input": ["text"],
13
+ "contextWindow": 32768,
14
+ "maxTokens": 4096,
15
+ "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
16
+ },
17
+ {
18
+ "id": "qwen3.5-9b",
19
+ "name": "Qwen3.5-9B (local llama.cpp)",
20
+ "reasoning": true,
21
+ "input": ["text"],
22
+ "contextWindow": 32768,
23
+ "maxTokens": 4096,
24
+ "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
25
+ }
26
+ ]
27
+ },
28
+ "ollama": {
29
+ "api": "openai-completions",
30
+ "baseUrl": "http://127.0.0.1:11434/v1",
31
+ "apiKey": "OLLAMA_API_KEY",
32
+ "models": [
33
+ {
34
+ "id": "qwen3.5",
35
+ "name": "Qwen3.5 (ollama)",
36
+ "reasoning": true,
37
+ "input": ["text"],
38
+ "contextWindow": 32768,
39
+ "maxTokens": 4096,
40
+ "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "little-coder",
3
+ "version": "1.0.0",
4
+ "description": "A pi-based coding agent optimized for small local language models. Reproduces the whitepaper's scaffold-model-fit adaptations as pi extensions.",
5
+ "homepage": "https://github.com/itayinbarr/little-coder",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/itayinbarr/little-coder.git"
9
+ },
10
+ "license": "Apache-2.0",
11
+ "author": "Itay Inbar",
12
+ "type": "module",
13
+ "bin": {
14
+ "little-coder": "bin/little-coder.mjs"
15
+ },
16
+ "engines": {
17
+ "node": ">=20.6.0"
18
+ },
19
+ "files": [
20
+ "bin/",
21
+ "AGENTS.md",
22
+ "skills/",
23
+ ".pi/extensions/",
24
+ ".pi/settings.json",
25
+ "models.json",
26
+ "LICENSE",
27
+ "NOTICE",
28
+ "README.md",
29
+ "CHANGELOG.md"
30
+ ],
31
+ "scripts": {
32
+ "pi": "pi",
33
+ "test": "vitest run",
34
+ "test:py": "python3 -m pytest benchmarks/test_rpc_client.py -q",
35
+ "typecheck": "tsc --noEmit"
36
+ },
37
+ "dependencies": {
38
+ "@mariozechner/pi-coding-agent": "^0.68.1",
39
+ "@sinclair/typebox": "^0.34.49",
40
+ "playwright": "^1.59.1"
41
+ },
42
+ "devDependencies": {
43
+ "typescript": "^5.6.0",
44
+ "vitest": "^2.1.0"
45
+ }
46
+ }