Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
19b0d8d
reasoning_payload
hit9 May 17, 2026
908c6c7
Add provider-aware OpenAI SDK transport
hit9 May 17, 2026
094b119
Add in-flight model retry shortcut
hit9 May 17, 2026
62a9ce0
Prevent chat from ending active tasks early
hit9 May 17, 2026
20628b3
Allow CreateFile to create cwd-local parent dirs
hit9 May 17, 2026
0505737
Surface tool cancellation reasons in agent feedback
hit9 May 17, 2026
1946358
Confirm selector search before selecting
hit9 May 17, 2026
c406f4d
Relax ReplaceRange boundary context for replacements
hit9 May 17, 2026
dfa3511
Stream action frames during model responses
hit9 May 17, 2026
492a251
Adopt function tools for agent actions
hit9 May 17, 2026
7fbb3d1
fix openai tool loops and session cleanup
hit9 May 18, 2026
e4ab758
fix responses stream parsing and add api command
hit9 May 18, 2026
d5174c2
fix replace range insertion fingerprints
hit9 May 18, 2026
4e3dc4f
require verification before text completion
hit9 May 18, 2026
e52a0ad
add chat reasoning payload command
hit9 May 18, 2026
f901a92
fix nullable enum tool schemas
hit9 May 18, 2026
25bb1d6
Simplify provider reasoning configuration
hit9 May 18, 2026
cbf3f24
Clean up agent and toolcall compatibility code
hit9 May 18, 2026
f1e7bb5
Simplify agent runtime and state formatting
hit9 May 18, 2026
217649e
Relax observe coverage and lower pending result threshold
hit9 May 18, 2026
39c7606
Show current plan focus in act prompt
hit9 May 18, 2026
e39f37a
Add context budget profiles
hit9 May 18, 2026
140b704
Simplify agent context and gate helpers
hit9 May 18, 2026
49208fe
Remove knowledge command
hit9 May 18, 2026
21623ad
Remove unused agent constants
hit9 May 18, 2026
4ee4927
Derive command handlers from command specs
hit9 May 18, 2026
018cd51
Simplify agent state updater actions
hit9 May 18, 2026
850308e
Simplify state and choice formatting helpers
hit9 May 18, 2026
4420708
Fix choice filtering helper removal
hit9 May 18, 2026
32ebce1
Trim small agent control helpers
hit9 May 18, 2026
a2d6676
Reuse status bar fragments in selectors
hit9 May 18, 2026
026345c
Clarify agent phase prompts
hit9 May 18, 2026
34a46cc
Normalize direct repository tool actions
hit9 May 18, 2026
f45b0ad
format code
hit9 May 18, 2026
f98bf24
Trim runtime and tool duplication
hit9 May 18, 2026
2e1784a
Simplify state update output
hit9 May 18, 2026
3fbac4b
Remove verbose state update header
hit9 May 18, 2026
9850457
Support all matches in Edit tool
hit9 May 18, 2026
cbe4795
Show line numbers in Read output
hit9 May 18, 2026
a102984
Add PatchFile edit tool
hit9 May 18, 2026
cc911f6
Refine queued feedback and runtime CLI handling
hit9 May 18, 2026
64a2f4a
Enforce user language for assistant replies
hit9 May 18, 2026
e381ca2
Improve PatchFile mismatch diagnostics
hit9 May 18, 2026
84429a3
Move runtime status line above queued input
hit9 May 18, 2026
d038b37
Tolerate duplicate empty PatchFile hunk markers
hit9 May 18, 2026
9c70c60
Suppress empty queued input redraw artifacts
hit9 May 18, 2026
c0a879c
Emphasize user language for assistant text
hit9 May 18, 2026
84b5ac5
Make read output and PatchFile indentation less ambiguous
hit9 May 18, 2026
b707d21
print session id on exit
hit9 May 18, 2026
69a0250
Encourage Unix text tools in Bash guidance
hit9 May 18, 2026
cec301f
Restore Bash live preview with final frame history
hit9 May 18, 2026
aaa0f6b
Rename ListDir tool to List
hit9 May 18, 2026
6825e38
Prevent repeated recalls for consumed tool results
hit9 May 18, 2026
8b67418
Clarify git commit scope for tool usage
hit9 May 18, 2026
1cd791b
Prefer dedicated tools over bash for repository inspection
hit9 May 18, 2026
aa73061
Revert specialized bash inspection guidance
hit9 May 18, 2026
7cd257c
Generalize bash guidance and one-shot text completion
hit9 May 18, 2026
f4c3cd9
Simplify tool result handling and catch action format errors
hit9 May 18, 2026
60863ea
Clarify one-shot completion prompt rules
hit9 May 18, 2026
5024acf
Soften non-deterministic agent gates
hit9 May 19, 2026
5a2fde6
Clarify task shapes in agent prompt
hit9 May 19, 2026
c156d5a
add optional CodeGraph integration
hit9 May 19, 2026
dd62a80
prevent planless command loops
hit9 May 19, 2026
dc10ce8
split CodeGraph symbol and context tools
hit9 May 19, 2026
b88bfc2
add dynamic CodeGraph usage hint
hit9 May 19, 2026
2ca2961
accept case-insensitive tool names
hit9 May 19, 2026
16ef345
clarify gate feedback and finish goal-only text replies
hit9 May 19, 2026
a18ee54
clarify CodeGraph as static analysis index
hit9 May 19, 2026
f687010
refine CodeGraph tool descriptions
hit9 May 19, 2026
6a46d12
prioritize CodeGraph for structural lookup
hit9 May 19, 2026
a9a9950
release 0.4.0
hit9 May 19, 2026
32ccfc8
soften planless command result feedback
hit9 May 19, 2026
8d85e98
replace codegraph with cymbal code inspection tools
hit9 May 19, 2026
62849d1
bump version to 0.4.1
hit9 May 19, 2026
fd095a1
improve observe memory guidance
hit9 May 19, 2026
ff9079f
bump version to 0.4.2
hit9 May 19, 2026
b7ef190
refactor: remove thin wrappers and dead status helper
hit9 May 20, 2026
1b36468
refactor: remove more thin wrappers
hit9 May 20, 2026
7d12559
refactor: reduce agent and provider special cases
hit9 May 20, 2026
6df2bc8
refactor: remove stable knowledge state
hit9 May 20, 2026
5e67cce
refactor: trim tool helper code
hit9 May 20, 2026
a12505e
chore: release 0.4.3
hit9 May 20, 2026
fde5b88
replace cymbal with built-in code index
hit9 May 20, 2026
d6bb5e7
support force rebuilding code index
hit9 May 20, 2026
027d153
show code index progress without blocking startup
hit9 May 20, 2026
a8fee94
Sync existing code index before prompt
hit9 May 21, 2026
9a57528
Use async refresh for existing code index
hit9 May 21, 2026
2df7ca6
Release 0.4.5 with code index 0.1.7 support
hit9 May 22, 2026
f827c31
Replace legacy edit tools with anchored EditFile
hit9 May 22, 2026
0b2b9b5
Improve Search anchors and EditFile guidance
hit9 May 22, 2026
f8e81fb
Use code-symbol-index 0.1.8 anchors
hit9 May 22, 2026
5d9006e
Fix tool arg preservation and stale feedback cleanup
hit9 May 22, 2026
da949fe
Unify code index inspection tool
hit9 May 22, 2026
de06ac6
Tighten EditFile tool schema
hit9 May 22, 2026
d26126e
Preserve streamed tool result batches
hit9 May 22, 2026
5efa25a
Reduce redundant discovery before edits
hit9 May 22, 2026
e84f6a7
Clear stale function-tool feedback
hit9 May 22, 2026
b5e4ec8
Reduce anchor refresh bias before edits
hit9 May 22, 2026
1280e25
Clarify EditFile execution timing
hit9 May 22, 2026
69a755c
Reduce edit anchor reread bias
hit9 May 22, 2026
fff4772
Tighten edit progress guidance
hit9 May 22, 2026
4112fa6
Increase search tool output budget
hit9 May 22, 2026
a28a450
Clarify mechanical rename tool choice
hit9 May 22, 2026
216b0fe
List available shell tools dynamically
hit9 May 23, 2026
4aea58d
Add EditFile replace_all operation
hit9 May 23, 2026
0821ca1
Preserve raw bad function-call arguments
hit9 May 23, 2026
e6d00ed
minor fix
hit9 May 23, 2026
f6d82b9
Default Search context to match line only
hit9 May 23, 2026
429053c
Keep large Search results structured
hit9 May 23, 2026
e18e7a7
Support multiple tool signatures
hit9 May 23, 2026
0f4bb0a
Simplify visible agent state and remove plan mode
hit9 May 23, 2026
08d9df9
ignore .code-symbol-index
hit9 May 23, 2026
1ff0c40
Tune observe triggers around referenced tool results
hit9 May 23, 2026
dae9c1a
Remove unused agent locals
hit9 May 23, 2026
b700cc3
Make agent prompt concise and workflow-focused
hit9 May 23, 2026
14ed2dd
minor fix
hit9 May 23, 2026
ea208c1
Simplify observe prompts
hit9 May 23, 2026
e86c4b7
Replace verification state with checks
hit9 May 23, 2026
df4799c
Remove at-file path completion
hit9 May 23, 2026
eacc56b
Refactor agent state naming and trim formatting noise
hit9 May 23, 2026
beb3ebc
Normalize protocol action casing and bump version
hit9 May 23, 2026
e5917fe
Clarify plan as minimal correct path in prompt
hit9 May 23, 2026
e98435c
Add plan obligation closure fields
hit9 May 23, 2026
864be2f
Fix plan patching and completion gate feedback
hit9 May 23, 2026
b165c82
Remove plan obligation fields and clarify plan prompt
hit9 May 23, 2026
75f6b6c
Add plan follow-up status gate
hit9 May 23, 2026
82a223c
Require reasons for plan follow-up status
hit9 May 23, 2026
c73e432
Upgrade codex-symbol-index dependency from >=0.1.8 to >=0.1.13
hit9 May 23, 2026
3d502cd
Clarify available shell commands in prompt
hit9 May 23, 2026
c89e10d
Show indexed language breakdown in prompt
hit9 May 23, 2026
3690a48
Support reading multiple files with Read
hit9 May 23, 2026
c8c192d
Simplify tool descriptions for LLM use
hit9 May 23, 2026
6021e8d
Simplify session cleanup and bump version
hit9 May 23, 2026
80c739a
Add prompt cache key and cached token stats
hit9 May 23, 2026
741a190
Clarify reply language rule
hit9 May 23, 2026
b1241d7
language rule
hit9 May 23, 2026
bf05b1e
Record DeepSeek cached prompt tokens
hit9 May 23, 2026
fab9820
Compact cached token handling
hit9 May 23, 2026
926a8ba
Bump version to 0.4.8
hit9 May 23, 2026
1890ed6
Complete 0.3.35 changelog
hit9 May 23, 2026
2023c78
ignore .code-workflow-probe
hit9 May 23, 2026
36a16dd
Rename EditFile tool to Edit across codebase and tests
hit9 May 23, 2026
57eeb84
Update CHANGELOG for 0.4.8: rename EditFile to Edit
hit9 May 23, 2026
e4cf832
Update code index after task completion
hit9 May 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ __pycache__/
*.pyc
.env*
.nanocode
.codegraph/
.venv/
.mypy_cache/
.ruff_cache/
uv.lock
.python-version
.code-symbol-index/
.code-workflow-probe.json
61 changes: 60 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,74 @@
# Changelog

## 0.4.8 - 2026-05-23

### Changed
- Renamed the `EditFile` tool to `Edit` across the codebase and tests.

## 0.4.5 - 2026-05-21

### Changed
- Updated the built-in code index integration for `code-symbol-index` 0.1.7.
- Added indexed symbol filters for kind, path, and exact matching.
- Added file-local symbol outlines and bounded pending-index details in `/status`.

## 0.4.4 - 2026-05-20

### Added
- Added built-in indexed code navigation backed by project data and `/index` for manual init/sync.

### Changed
- Replaced the external code-navigation CLI integration with the bundled code index API.
- Hid code navigation tools until an index exists, while lightly updating existing indexes at startup.
- Updated status/docs to describe code index availability without exposing dependency-install wording.

## 0.4.3 - 2026-05-20

### Changed
- Removed stable knowledge state while keeping current-task known facts.
- Extracted shared numbered-content and line-range helpers for tool output/range handling.
- Trimmed thin helper wrappers in List and indexed code-inspection tools.

## 0.4.2 - 2026-05-19

### Added
- Added indexed code inspection tools for symbol lookup, symbol investigation, and file outlines when the local index is available.
- Added queued user feedback during long-running turns.
- Added `PatchFile` for multi-location file edits.

### Changed
- Moved model calls to the OpenAI SDK and function-tool protocol.
- Reworked task-shape prompts for chat, one-shot tasks, and tracked tasks.
- Prioritized indexed code inspection for structural lookup while keeping Search/Read for exact literals and edit ranges.
- Improved terminal UX with persistent status, queued-input handling, Bash live preview, and terminal-friendly assistant output rules.
- Renamed `ListDir` to `List`.
- Improved `Read`, `Edit`, `ReplaceRange`, `PatchFile`, `Bash`, and `Git` tool guidance.
- Simplified gate behavior so only deterministic, correctable model errors are refused.

### Fixed
- Fixed duplicate final replies for goal-only text answers.
- Fixed repeated recall loops and several format/tool-name compatibility issues.
- Fixed PatchFile diagnostics and empty-hunk handling.
- Fixed queued feedback delivery, Ctrl-C/Ctrl-D handling, and Bash interrupt reporting.

## 0.3.35 - 2026-05-16

### Added
- Added batched `ReplaceRange` edits for multiple independent ranges in the same file.
- Added a design document covering agent state, context construction, tool-result storage, observe policy, and verification.

### Changed
- Aligned tool-result context layout with the design document.
- Refined tool-result context reduction around unreduced raw results, retained results, and checkpoint-based pruning.
- Compressed ACT and OBSERVE system prompts.
- Reduced routine OBSERVE triggers by raising the pending-result threshold and keeping ordinary tool failures in ACT for repair.
- Simplified agent gate and feedback handling, including single active plan item normalization.
- Added soft feedback for state-update-only ACT turns so models continue with frontier tools, verification, or completion.
- Highlighted recognized slash commands and reported unknown slash commands directly.

### Fixed
- Accepted harmless model output variants including trailing progress text, action type casing, and `message` action aliases.
- Ignored pending verification requests instead of treating them as blocking model output.

## 0.3.34 - 2026-05-16

Expand Down Expand Up @@ -115,7 +174,7 @@

### Changed
- Tightened completion gates, verification blockers, and compact state update grouping.
- Simplified Search argument parsing and removed legacy `/knowledge update` behavior.
- Simplified Search argument parsing and removed legacy knowledge-update behavior.
- Made provider reasoning payload shape configurable.

## 0.3.20 - 2026-05-15
Expand Down
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A lightweight terminal-based AI coding assistant.

nanocode is used to help building itself, including features such as `@file` path completion.
nanocode is used to help building itself.

Pre-1.0 note: nanocode is still evolving quickly. Functionality, commands, configuration, and behavior may change incompatibly before a 1.0 release.

Expand All @@ -14,9 +14,9 @@ Pre-1.0 note: nanocode is still evolving quickly. Functionality, commands, confi

## Features

- **Constrained Output**: Force model replies into auditable action frames.
- **Function Tools**: Route model decisions through auditable tools.
- **Verified Edits**: Reject stale range edits before they touch files.
- **Autonomous Loop**: Chain reading, editing, running, and verification.
- **Autonomous Loop**: Chain reading, editing, running, and checks.
- **Live Telemetry**: Stream tool intent, token use, and status.

## Install
Expand Down Expand Up @@ -61,7 +61,6 @@ Ask a source-aware question about nanocode itself:
CLI arguments:

- `--yolo`: Skip tool execution confirmations.
- `--plan`: Plan changes without editing files or running commands.
- `--debug`: Write request prompts to the current session directory under `~/.nanocode/sessions/`.
- `--config <path>`: Path to config file (default: `~/.nanocode/config.toml`).
- `--init-config`: Create a default config file.
Expand All @@ -75,34 +74,42 @@ If you do not fully trust the model, tools, prompts, or workspace, run nanocode

USE AT YOUR OWN RISK.

nanocode currently targets macOS and Linux. Windows is not supported.

## Tools

- File: `Read`, `LineCount`, `ListDir`, `Search`.
- Edit: `Edit`, `ReplaceRange`.
- File: `Read`, `LineCount`, `List`, `Search`.
- Code navigation: `InspectCode` after `/index` builds the project index.
- Edit: `CreateFile`, `EditFile`.
- Shell: `Bash`, `Git`.
- Memory: `Recall` reads stored tool results by key.

`Search`, `Read`, and `InspectCode` mode=inspect return 0-based `line:hash|code` lines that can be used as edit anchors. For broad mechanical text replacement, shell text pipelines are acceptable when followed by a focused diff or test.

## Commands

- Info: `/help [question]`, `/status`, `/rules`, `/knowledge`, `/compact`.
- Config: `/config`, `/set <key> <value>`, `/model [model_name]`, `/reason`, `/provider [name]`, `/plan [on|off|question]`, `/yolo`.
- Maintenance: `/clean`.
- Info: `/help [question]`, `/status`, `/rules`, `/compact`.
- Config: `/config`, `/set <key> <value>`, `/api [auto|chat|responses]`, `/model [model_name]`, `/reason`, `/reason-payload [value]`, `/provider [name]`, `/yolo`.
- Maintenance: `/index [force]`, `/clean`.
- Exit: `/exit`, `/quit`.

Selectors support `j`/`k`, arrows, `/keyword`, Enter, and Esc. `/model` lists configured models before discovered ones, then prompts for reasoning; `/model <name>` and `/reason` are direct shortcuts.
Selectors support `j`/`k`, arrows, `/keyword`, Enter, and Esc. `/api responses` switches the current provider to Responses format. `/reason` sets `provider.reasoning` to `off` or an effort value; `/reason-payload` controls the Chat-only reasoning payload shape. `/model` lists configured models before discovered ones, then prompts for reasoning.
During a slow model request, press `Ctrl-G` to cancel that request and resend the same prompt.

## Configuration

Run `nanocode --init-config` to create `~/.nanocode/config.toml`.

- Provider config: `[provider] active = "<name>"` plus `[provider.<name>]` url, key, model, `available_models`, and model options. `reasoning_payload` controls whether effort is sent as `reasoning`, `reasoning_effort`, or not sent.
- Provider config: `[provider] active = "<name>"` plus `[provider.<name>]` url, key, model, `available_models`, and model options. `api` selects `chat`, `responses`, or `auto`; auto uses exact-host profiles. Responses uses standard `reasoning.effort`; Chat reasoning is mapped by provider/model profile when known.
- Provider auto-detection covers common providers: OpenAI/OpenRouter prefer Responses API; DeepSeek, selected OpenCode models, and DashScope models use their matching Chat reasoning payload shapes.
- Path config: `[paths] data_dir = "~/.nanocode"`.
- Runtime config: `[runtime]`.
- `/context [low|medium|high]` shows or switches tool-result context budgets; lower budgets reduce token usage and observe overhead.
- Session data: debug prompts and tool-result logs are stored under `~/.nanocode/sessions/<session_id>/`.
- Tool-result logs from inactive sessions are auto-cleaned after `runtime.auto_clean_recent` (default `3d`; use `off` to disable). `/clean` removes inactive session logs immediately.
- Project data: user rules are stored under `~/.nanocode/projects/<project_key>/`.
- Old inactive session directories are auto-cleaned after `runtime.auto_clean_recent` (default `1d`; use `off` to disable). `/clean` removes inactive sessions immediately.
- Project data: user rules and code indexes are stored under `~/.nanocode/projects/<project_key>/`.

## Status

- Status bar: active model, reasoning, active yolo/plan modes, conversation context, current-turn tool calls, tokens, elapsed time, and active model-call time.
- `/status`: active provider, model state, session id, runtime state, conversation/tool counters, per-model calls/tokens, task, goal, and verification.
- Status bar: active model, reasoning, active yolo mode, conversation context, current-turn tool calls, tokens, elapsed time, and active model-call time.
- `/status`: active provider, model state, session id, runtime state, conversation/tool counters, per-model calls/tokens, goal, and checks.
33 changes: 25 additions & 8 deletions design.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ The agent has a work path and a cleanup path:

Conversation compaction is a background maintenance path. It summarizes old conversation history when the conversation list grows too large.

## Model Output Protocol

Model decisions use function tools:

- state tools update goal, plan, hypotheses, known facts, verification, and result retention
- repository tools read, search, edit, run commands, and recall stored results
- compaction uses a dedicated `compact` function tool

Assistant text is optional user-facing text. It must not replace the next useful
function tool. Completing work still requires a `goal` function tool call with
`complete=true`.

## Task State

The main task state lives in the blackboard:
Expand All @@ -27,55 +39,61 @@ The main task state lives in the blackboard:
- plan
- hypotheses
- known facts: settled facts for the current task
- stable knowledge: rare reusable codebase facts
- verification state
- recent edits

New user input keeps the previous task state available for follow-ups like "continue".

Old task state is cleared only when the model explicitly starts a different goal. When that happens, transient investigation state such as hypotheses and selected tool-result context is reset, while durable knowledge is kept.
Old task state is cleared only when the model explicitly sets a different goal. When that happens, transient investigation state such as hypotheses and selected tool-result context is reset, while durable knowledge is kept.

## New Goal Handling

New user input does not immediately clear the previous task. This keeps short
follow-ups such as "continue" usable.

When the model outputs `start` with a different goal:
When the model outputs `goal` with a different current-task goal:

- goal and plan are replaced
- hypotheses are cleared
- verification is reset
- kept tool results are cleared
- visible raw tool results are compacted into summaries
- full tool logs remain available through `Recall tr.N`
- known and stable knowledge remain available
- known facts remain available

## Context Construction

ACT mode receives a working context:

- goal, plan, hypotheses, verification
- environment, including whether local symbol inspection is available
- Tool Result Index
- Kept Tool Results
- Unreduced Tool Results
- Latest Tool Results
- errors
- recent edits
- known and stable knowledge
- known facts
- conversation history
- latest user request

OBSERVE receives a smaller cleanup context:

- latest user request
- goal, plan, hypotheses
- known and stable knowledge
- known facts
- kept tool results
- observe errors
- unreduced raw tool results selected from recent/latest storage

OBSERVE reduces tool-result noise before ACT continues.

The code navigation tool is environment-gated. `InspectCode` is shown only when
the built-in code index is available. It supports `find`, `inspect`, and
`outline` modes for symbol queries or file paths, not natural-language
questions. The index is created explicitly with `/index`, rebuilt with
`/index force`, and lightly updated at startup when it already exists.

Context layout:

Layout rules:
Expand All @@ -93,7 +111,6 @@ ACT user prompt, top -> bottom
+--------------------------------------------------+------------------------------+
| Background | compact_at |
| - Environment | |
| - Stable Knowledge | |
| - User Rules | |
| - Conversation History | |
+--------------------------------------------------+------------------------------+
Expand All @@ -113,7 +130,7 @@ ACT user prompt, top -> bottom
| Current Decision | section-local limits |
| - Recent Edits | |
| - Known | |
| - Task Code / Work Mode | |
| - Current Phase / Work Mode | |
| - Goal / Plan / Hypotheses / Verify | |
| - Errors | |
| - Latest User Request | |
Expand Down
Loading
Loading