@nanobpm/nano-coder 0.14.0 → 0.15.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 (2) hide show
  1. package/README.md +41 -5
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -102,8 +102,8 @@ instead of guessing from the stop reason: `blocked` means the model needs help (
102
102
  escalation). Redelivering the input returns the same outcome. See [Outcomes](#outcomes).
103
103
 
104
104
  **Slash commands work via ACP too:**
105
- - `/compact [focus]` - summarizes the conversation; the result has `compacted`, `before`,
106
- `after`, `tokensBefore`, `tokensAfter`, `summarized` and `fallback`
105
+ - `/compact [--smart|--standard] [focus]` - summarizes the conversation; the result has
106
+ `compacted`, `before`, `after`, `tokensBefore`, `tokensAfter`, `summarized`, `mode` and `fallback`
107
107
  - `/settings` - returns current settings as JSON
108
108
  - `/tools` - lists registered tools
109
109
  - `/plan` - returns `plan` (JSON) and `text` (the rendered plan)
@@ -273,8 +273,10 @@ argument set (`/model`, `/mode`, `/verbosity`) get the same treatment for their
273
273
  argument: a type-ahead list narrows as you type and Tab completes it.
274
274
 
275
275
  - `/help` - Show available commands
276
- - `/compact [focus]` - Summarize older messages with the current model, keeping the latest
277
- message. Optional text tells the summary what to focus on. Esc Esc or Ctrl-C cancels
276
+ - `/compact [--smart|--standard] [focus]` - Summarize older messages with the current model,
277
+ keeping the latest message. `--smart` / `--standard` override `compaction_mode` for this
278
+ compaction (see [Smart compaction](#smart-compaction-experimental)). Optional text tells the
279
+ summary what to focus on. Esc Esc or Ctrl-C cancels
278
280
  - `/verbosity [quiet|normal|verbose|debug]` - Show or set how much is printed (see below)
279
281
  - `/context` - Show context usage, window, session token totals, AI Credits (GitHub Copilot), auto-compaction state and the loaded instruction files
280
282
  - `/settings` - Interactive settings menu:
@@ -284,7 +286,7 @@ argument: a type-ahead list narrows as you type and Tab completes it.
284
286
  written with mode 0600) and default model
285
287
  - temperature, max tokens, system prompt
286
288
  - **Turn cap** (`max_iterations`): LLM calls per input; normal mode asks before stopping
287
- - **Context**: auto-compaction on/off, threshold, context-window override
289
+ - **Context**: auto-compaction on/off, threshold, compaction mode, context-window override
288
290
  - **Verbosity**
289
291
  - **Save to config file**: writes only the keys you changed into the config file
290
292
  (`--config` or `~/.config/nano-coder/config.toml`), keeping comments and
@@ -338,6 +340,7 @@ persist_sessions = true
338
340
  # session_dir = "/path/to/sessions" # default: <platform data dir>/nano-coder/sessions
339
341
  auto_compact = true # summarize automatically when the context fills up
340
342
  auto_compact_threshold = 0.8 # fraction of the context window
343
+ compaction_mode = "standard" # standard | smart (experimental, see Smart compaction)
341
344
  # context_window = 128000 # override the window (providers can set it too)
342
345
  verbosity = "normal" # quiet | normal | verbose | debug (or --verbosity)
343
346
  timestamps = true # prefix CLI messages with the local time (HH:MM:SS)
@@ -565,6 +568,37 @@ another 10% of the window, so a context that can't shrink isn't summarized on ev
565
568
  If summarizing fails, the older messages are dropped with a note. The session log records
566
569
  the new conversation, so `--resume` continues from it.
567
570
 
571
+ ### Smart compaction (experimental)
572
+
573
+ A summary is lossy: whatever it leaves out is gone for the agent, even though the session
574
+ log still has every original message. Smart compaction keeps the whole history reachable.
575
+ It is off by default (`compaction_mode = "standard"`); try it on one compaction with
576
+ `/compact --smart`, or set `compaction_mode = "smart"` to use it for auto-compaction too.
577
+ It needs a session log, and falls back to a standard summary when `persist_sessions` is off.
578
+
579
+ - **Message IDs.** A message's ID is the line of the session log where it was first
580
+ recorded, shown as `#N`. IDs are stable across compactions and `--resume`.
581
+ - **Citing summary.** The summarizer sees each message labelled `[#N]` and is asked to cite
582
+ `(#N)` for details whose exact text may matter (errors, commands, outputs, the user's
583
+ wording) instead of copying them. The summary ends with the range it covers and a note
584
+ that the originals can be retrieved. Tool results clipped at compaction point at their ID.
585
+ - **History tools.** Once a smart summary is in the context, the agent gets two tools
586
+ over the current session's log (and only that one):
587
+ - `history_search(pattern, role?, before?, after?, limit?)` - case-insensitive regex (or
588
+ plain text) search, newest first, one `#N role name (time): snippet` line per match.
589
+ Earlier history lookups are not searched.
590
+ - `history_read(id, max_output_length?)` - one message in full, bounded like other tool
591
+ output (the whole is spilled to a file when it is longer).
592
+ Before a smart compaction the tools are not offered, so they cost nothing.
593
+
594
+ To judge whether it helps, the log records each compaction's `mode`, `model` and the
595
+ `summarized` line range (on the `replace` record), and each turn's `history_calls` (on
596
+ `turn_end`). `/context` shows the mode and this session's history-tool use.
597
+ `scripts/compaction-report.py [SESSION_DIR]` tabulates compacted sessions by model and mode:
598
+ compactions, turns after the first compaction, turns that used the history tools, and
599
+ reported outcomes. `eval/compaction/` has a harness that compares the two modes across
600
+ providers and models on synthetic or forked real sessions (see its README). See [#29](https://github.com/nanobpm/nano-coder/issues/29) for the design.
601
+
568
602
  ## Project Instructions
569
603
 
570
604
  When a session starts, the harness looks for instruction files in every directory from the
@@ -682,6 +716,8 @@ Resume a session with `--resume <id>` or ACP `session/load`.
682
716
  Record times and each message's `timestamp` are RFC 3339 with the local UTC offset
683
717
  (for example `2026-09-24T13:02:12.44+12:00`). Older logs with UTC times still load.
684
718
 
719
+ - Truncated tool output is kept whole in `<session_dir>/<id>.spill/`, so the paths in the
720
+ log stay valid after the process exits (temporary directory when sessions are not persisted).
685
721
  - An unsupported format version is an explicit error on resume.
686
722
  - Only records ending in a newline count as committed. A half-written last line from a
687
723
  crash is discarded and truncated before the next write.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanobpm/nano-coder",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "A 6MB coding agent. Run a fleet on your laptop.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -31,9 +31,9 @@
31
31
  "node": ">=18"
32
32
  },
33
33
  "optionalDependencies": {
34
- "@nanobpm/nano-coder-darwin-arm64": "0.14.0",
35
- "@nanobpm/nano-coder-darwin-x64": "0.14.0",
36
- "@nanobpm/nano-coder-linux-arm64": "0.14.0",
37
- "@nanobpm/nano-coder-linux-x64": "0.14.0"
34
+ "@nanobpm/nano-coder-darwin-arm64": "0.15.0",
35
+ "@nanobpm/nano-coder-darwin-x64": "0.15.0",
36
+ "@nanobpm/nano-coder-linux-arm64": "0.15.0",
37
+ "@nanobpm/nano-coder-linux-x64": "0.15.0"
38
38
  }
39
39
  }