@nanobpm/nano-coder 1.0.0 → 1.2.1

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 +57 -3
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -488,14 +488,56 @@ Flags: `--login github-copilot|muse`, `--list-models PROVIDER`, `--trajectory SE
488
488
  `--config PATH`, `--verbosity LEVEL` (`-v`), `--sandbox off|workspace|read-only` (or `NANO_CODER_SANDBOX`),
489
489
  `--allow RULE` and `--deny RULE` (repeatable; added to the config's rules), `--version` (`-V`).
490
490
 
491
- Before opening a PR, run `dub build` and `dub test` (both run `scripts/check-safe.sh`
492
- first) and D-Scanner (`dub run dscanner -- --styleCheck --config dscanner.ini source`); CI
493
- checks all three. All code is `@safe`: every module starts with `@safe:`, and calls the
491
+ CI runs `scripts/ci.sh`, and so can you: `scripts/ci.sh` runs everything CI does (lint,
492
+ unit tests, release build, typecheck of both the release and unittest builds, smoke checks);
493
+ `scripts/ci.sh quick` is the fast subset. With `git config core.hooksPath .githooks`, the
494
+ pre-push hook runs `quick` before every push. Test-only imports go inside the unittest or
495
+ test helper that uses them, never in a file-level `version (unittest)` block, where non-test
496
+ code could use them and pass `dub test` but fail the release build. All code is `@safe`: every module starts with `@safe:`, and calls the
494
497
  compiler can't check are wrapped in small, commented `@trusted` functions (shared ones in
495
498
  `source/nano/safeio.d`). `check-safe.sh` fails the build on a module without `@safe:`, an
496
499
  uncommented `@trusted`, raw threads or `__gshared` outside `safeio.d`, or more `@trusted` than
497
500
  the budgets in `scripts/` allow. The build uses `-preview=dip1000` and `-preview=nosharedaccess`.
498
501
 
502
+ Time goes through `nano.clock`: `wallNow`, `monoNow`, `since` and `sleepFor` instead of
503
+ `Clock.currTime`, `MonoTime.currTime`, `StopWatch` and `Thread.sleep`, which check-safe bans
504
+ elsewhere. A test can then install a `FakeClock` (per thread) to pick "now" and make sleeps
505
+ instant. Timeouts and grace periods that tests run into are parameters, so a test passes a
506
+ short one rather than waiting out the production value. The test runner
507
+ (`source/nano/testenv_test.d`) fails a module whose tests take over 1 s, unless
508
+ `scripts/slow-tests` gives it a higher limit and a reason; `NANO_TEST_TIMES=N dub test` lists the
509
+ N slowest modules. `NANO_TEST_JOBS=N` runs modules in parallel (`scripts/ci.sh` uses 4); modules
510
+ that change process-wide state (the cancel flag, environment variables) are listed in
511
+ `scripts/serial-tests` and run alone first.
512
+
513
+ Functions are `pure` wherever they can be: the result depends only on the arguments, with no
514
+ clock, environment, files or global state. Modules that start with `pure:` (parsing, markdown,
515
+ plans, context arithmetic, the status line and others) make up a pure core, and the I/O stays
516
+ in their callers. `pure:` doesn't reach member functions, so `source/nano/pure_core_test.d`
517
+ runs a compile-time audit (`nano.pureaudit`) over those modules. check-safe keeps that list in
518
+ step with the `pure:` modules, and the `pure` count and the number of pure modules can only
519
+ grow (`scripts/pure-floor`, `scripts/pure-module-floor`).
520
+
521
+ The pure core is also strongly pure: no public function takes a `ref`, `out` or other mutable
522
+ argument (the audit fails the build on one), so a call can't change what its caller passed.
523
+ Results come back as values, and so do errors: a function that can fail returns
524
+ `nano.result.Result!(T, E)` (`ok`/`err`, `match`, `map`, `andThen`, `toOption`, and
525
+ `orThrow!(e => new X(e))` for the code that still reports errors by throwing). A missing value is
526
+ `Option!T`. Inside the core, only the shell and TOML parsers throw, to unwind to their own entry
527
+ point, which returns the error. Their exception classes are private, and check-safe caps those
528
+ `throw`s (`scripts/pure-throw-budget`).
529
+
530
+ The agent loop is part of that core too. `nano.turn` is a state machine: `step(state, event)`
531
+ returns the next state and a list of effects. Events are what happened (a call is due, the model
532
+ replied, a call failed, tools ran, a Stop hook ran, compaction finished); effects are what to do
533
+ next (call the model, run the tools, continue a cut-off reply, run the Stop hook, finish). Every
534
+ decision in a turn is made in `step`: the turn cap, stream restarts, the output cap, compacting on
535
+ overflow, continuations, steers, Stop hook blocks and reported outcomes. `Agent.runTurn` only
536
+ carries effects out and feeds the results back in. `source/nano/turn_replay_test.d` replays
537
+ session logs through `step` and checks that each turn asks for what the log shows next and ends
538
+ with the recorded answer. Point `NANO_REPLAY_DIR` at a sessions directory to replay all of its
539
+ turns.
540
+
499
541
  ## Configuration
500
542
 
501
543
  Create `~/.config/nano-coder/config.toml` (every field is optional). Directories from before the rename (`agentic-harness`, for config and for data such as sessions) are moved to `nano-coder` at startup when the new ones don't exist yet. A symlink is left at the old path so an older nano-coder still finds them. If that compatibility symlink can't be created, a warning is printed and the link is retried on later starts; if the move itself fails, the old directory is used:
@@ -508,6 +550,7 @@ max_tokens = 4096
508
550
  max_iterations = 0 # LLM calls per user input (0 = unbounded; headless runs get a 300-call safety cap)
509
551
  system_prompt = "You are a helpful assistant with access to tools."
510
552
  bash_timeout_secs = 600
553
+ # bash_heartbeat_secs = 60 # supervisor-visible "still running" note interval (or NANO_CODER_BASH_HEARTBEAT_SECS)
511
554
  persist_sessions = true
512
555
  # session_dir = "/path/to/sessions" # default: <platform data dir>/nano-coder/sessions
513
556
  session_titles = false # ask the model for a few-word title per session (--resume picker)
@@ -1031,6 +1074,17 @@ makes any change, without having to decide to read them. Block-level `<!-- ... -
1031
1074
  are removed first. Each file is capped at 32 KiB and the total at 64 KiB; a file over the
1032
1075
  limit is named, with a note to read it with `read_file`.
1033
1076
 
1077
+ **Edits take effect at the next turn.** Before each prompt the files are read again. If what
1078
+ they add to the system prompt has changed (a file was edited, added or removed), the system
1079
+ prompt is rebuilt and a dim `[instruction files changed: ...]` line says so, so there's no
1080
+ need to restart and lose the conversation. Resuming a session (`--resume`) also rebuilds it
1081
+ from the current files. The provider's prompt cache misses once, on the turn after a change.
1082
+ Edits to rules scoped with `paths:` and the files they import are picked up too, as are edits
1083
+ to nested directories' files that already attached (including a file added there). After any
1084
+ change, rules and nested files attach afresh the next time a matching file is touched, so one
1085
+ already in the conversation may appear once more, but never in an old version.
1086
+ ACP sessions (`--acp`) still read the files once, when the session starts.
1087
+
1034
1088
  **Imports.** `CLAUDE.md`, `CLAUDE.local.md`, rules and imported files can pull in other files
1035
1089
  with `@path`, as in Claude Code: relative to the importing file, `~/` allowed, up to four
1036
1090
  levels deep, each file once. Code spans and fenced code blocks are skipped, `\ ` escapes a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanobpm/nano-coder",
3
- "version": "1.0.0",
3
+ "version": "1.2.1",
4
4
  "description": "A 4MB coding agent. Run a fleet on your laptop.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -28,9 +28,9 @@
28
28
  "node": ">=18"
29
29
  },
30
30
  "optionalDependencies": {
31
- "@nanobpm/nano-coder-darwin-arm64": "1.0.0",
32
- "@nanobpm/nano-coder-darwin-x64": "1.0.0",
33
- "@nanobpm/nano-coder-linux-arm64": "1.0.0",
34
- "@nanobpm/nano-coder-linux-x64": "1.0.0"
31
+ "@nanobpm/nano-coder-darwin-arm64": "1.2.1",
32
+ "@nanobpm/nano-coder-darwin-x64": "1.2.1",
33
+ "@nanobpm/nano-coder-linux-arm64": "1.2.1",
34
+ "@nanobpm/nano-coder-linux-x64": "1.2.1"
35
35
  }
36
36
  }