heartcode 0.1.58 → 0.1.59

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  What changed in each version of HeartCode, newest first.
4
4
 
5
+ ## 0.1.59 (2026-11-07)
6
+
7
+ - **You see which model does what**: every step names its model (`● web_fetch … · model`), each
8
+ helper at work has a line with its model, and a plan step handed to a helper says who has it.
9
+ - **Headless says everything the screen shows**: `stream-json` adds `system` lines for the plan
10
+ (`todos`, with `by`), helpers (`helper`), reviews, model switches, retries, warnings and what it's
11
+ doing now (`status`, a running command's output too); tool results carry their `model`; every
12
+ reply and the result have a `stop_reason`. SKILL.md lists them.
13
+ - **Cut-off replies aren't taken as finished**: a reply stopped by its provider's output limit, or a
14
+ stream that ends without `[DONE]` (its last line is no longer lost), is continued where it
15
+ stopped; the answer is always sent whole as a reply of its own.
16
+ - **A spinner where the work is**: the running step's ● spins, and while it waits on the model a
17
+ line at the end of the conversation says so (the status at the bottom stays).
18
+ - **Queued messages can be changed or dropped**: Esc (or ↑) takes them back into the box without
19
+ stopping the work; Esc twice stops it. Shift+Enter adds a new line while it works too.
20
+ - **Alt+O sends nothing**: it no longer queues `/toggle_thinking`; after an answer it opens that
21
+ reply's thinking in a box.
22
+ - **No more flicker or broken screens**: a question no longer flickers (only what changed is drawn,
23
+ shown at once where the terminal can); resizing the terminal keeps the input box and status bar;
24
+ a plan that grows prints only what changed.
25
+ - **Installed from a clone, /update works**: `npm start` installs a copy in npm's global folder, as
26
+ `npm install -g heartcode` does, so `/update` replaces it there.
27
+ - **Says what it does**: an audit of every hint, prompt, settings text and doc against the code.
28
+ Fixed on the way: `--save -m` saves the model, `--provider` picks a model alone, `-m` runs a
29
+ model of a switched-off provider, `--allowedTools WebFetch/WebSearch` work, guided mode's
30
+ `--max-turns` is an error, `HEART_LOG=off` stops request logs too, `heart page` with a missing
31
+ file says so, `list_files` takes `path` and `filter` together, project prompts reach the tool
32
+ descriptions at once, reviews see browser and helper checks, settings changes reach every tab.
33
+
5
34
  ## 0.1.58 (2026-11-07)
6
35
 
7
36
  - **Helpers you pick**: on Your models, a Helper column: a switch (can #1 start this model for a part
package/README.md CHANGED
@@ -67,10 +67,12 @@ has none, so there's nothing for anyone to poison.
67
67
  1. **It asks first.** If your request leaves something open (how it should look, how far to go,
68
68
  whether to test it), it asks you, with its own suggestion first. Small fixes it just does.
69
69
  2. **It reads up** on whatever it's about to use, instead of trusting its memory.
70
- 3. **It makes a plan**: a todo list you can see. It can't change a file before there's one.
70
+ 3. **It makes a plan**: a todo list you can see. Its first change of each message waits for one.
71
71
  4. **It does the work**: reading files, running commands, editing.
72
72
  5. **It may split the work.** Your #1 model can hand a job to a helper, or run separate parts at
73
- the same time, each on its own files. Helpers use your models in your order. The model decides.
73
+ the same time, each on its own files. The model decides. Pick your helpers yourself (below), or
74
+ let HeartCode pick them; without any, it can use any of your models, in your order. Every step
75
+ on screen names the model doing it.
74
76
  6. **It checks before it says it's done**: it must have tested what it changed, finished its todo
75
77
  list and made the files it names. Then your next models say yes or no; a no sends it back.
76
78
  7. **It tidies up** in the background: saves notes for next time, removes throwaway files.
@@ -83,7 +85,7 @@ has none, so there's nothing for anyone to poison.
83
85
  npm install -g heartcode
84
86
  ```
85
87
 
86
- Or from source (a `git pull` then updates it):
88
+ Or from source (installed the same way: `/update` updates it):
87
89
 
88
90
  ```sh
89
91
  git clone https://github.com/p32929/HeartCode.git
@@ -133,8 +135,13 @@ On **Models → Your list**:
133
135
  2. **Drag rows** to fine-tune. #1 is the one HeartCode uses; the rest are its fallbacks, in order.
134
136
  3. **Test** (optional): **Test all** sends each model a short message and shows which answer and
135
137
  how fast (*Works?*). Sort by it to put the fastest first.
136
- 4. **Filter** (optional): by name, provider, test result, context, abilities or free. **Use only
137
- these** keeps just the ones you see, in that order.
138
+ 4. **Filter** (optional): by name, provider, test result, context, abilities, free or helpers.
139
+ **Use only these** keeps just the ones you see, in that order.
140
+ 5. **Helpers** (optional): the models #1 can hand parts of a task to. In the *Helper* column, switch
141
+ a model on and pick what it's good at: **UI & visuals**, **Code & logic**, **Big & hard**,
142
+ **Quick & cheap** (hover a pill to see what it covers). **Suggest helpers** proposes them from
143
+ the models that passed **Test all** and the rankings; or set *Helpers* to **picked for you**.
144
+ *Helpers picked* (beside **Order providers**): in your order, or by your provider ranking.
138
145
 
139
146
  **Update model info** fetches what each model can do and costs (from models.dev) and its places in
140
147
  LMArena's public rankings for coding, web apps and vision, as columns to sort by. A model *not
@@ -205,7 +212,10 @@ Ask it to read, change, run and fix things in your project, like any coding agen
205
212
 
206
213
  - `/` shows every command; `heart --help` lists the rest.
207
214
  - `Shift+Tab` changes what it may do without asking.
208
- - `Esc` stops it, or closes a dialog.
215
+ - `Esc` twice stops it; `Esc` also closes a dialog.
216
+ - While it works, `Enter` queues a message. `Esc` (or `↑`) takes queued messages back into the box
217
+ to change or drop, without stopping the work.
218
+ - `Shift+Enter` (or `Option+Enter`) adds a new line. `Alt+O` shows all of the model's thinking.
209
219
  - While it works, commands that don't change the conversation (`/help`, `/cost`, `/diff`,
210
220
  `/settings`…) run at once; the ones that do (`/compact`, `/rewind`…) wait until it's done.
211
221
 
package/SKILL.md CHANGED
@@ -16,7 +16,7 @@ heart --version # installed? (else: node /path/to/heart_cli/bin/heart.j
16
16
  heart providers # the providers set up, and their URLs (keys are masked)
17
17
  heart models # what -m takes, one per line: "auto" first, then the user's models (provider/model), #1 first
18
18
  heart models --json # the same, as JSON
19
- heart models --all # every provider's models too (slower: asks each provider)
19
+ heart models --all # every provider's models (slower: asks each provider); with --json, beside the list
20
20
  ```
21
21
 
22
22
  `heart models` prints one id per line, nothing else (like `opencode models`):
@@ -42,8 +42,9 @@ With `--json`:
42
42
  `id` is exactly what to pass to `-m`:
43
43
 
44
44
  - **`auto`** (always first): the user's list. `fallbacks: true` when it has more than one model:
45
- #1 is used, and the next one in order when it fails. No `-m` means `auto` too. (`default` is
46
- its old name and still works.)
45
+ #1 is used, and the next one in order when it fails. No `-m` means `auto` too, unless the user
46
+ chose a set of models for that folder in HeartCode (`/select_model`): then that set. (`default`
47
+ is its old name and still works.)
47
48
  - **the user's models** (`place` 1, 2, …), as `provider/model`: #1 is the one `auto` starts with.
48
49
 
49
50
  No model set up yet: `models` is empty (and `heart -p` fails with "no model set up").
@@ -110,12 +111,14 @@ heart -p --output-format json -C /path/to/project "fix the failing test in math.
110
111
 
111
112
  ```json
112
113
  { "type": "result", "subtype": "success", "is_error": false, "result": "Fixed it: …",
113
- "num_turns": 6, "duration_ms": 41200, "total_cost_usd": 0.0031,
114
+ "stop_reason": "end_turn", "num_turns": 6, "duration_ms": 41200, "total_cost_usd": 0.0031,
114
115
  "usage": { "input_tokens": 18000, "output_tokens": 900 }, "session_id": "20261027-…" }
115
116
  ```
116
117
 
117
118
  Read `is_error` and `result`. `subtype` is `success`, `error_during_execution` or
118
- `error_max_turns`. Without `--output-format`, stdout is just the answer text, and an error
119
+ `error_max_turns`. `stop_reason` is why the answer ended, in Claude's words: `end_turn`, or
120
+ `max_tokens` when it was still cut off (see "Cut-off replies" below), `refusal` when the
121
+ provider's filter stopped it. Without `--output-format`, stdout is just the answer text, and an error
119
122
  goes to stderr. Logs never go to stdout.
120
123
 
121
124
  ## Continue the same conversation
@@ -145,7 +148,7 @@ can't switch the model you chose.
145
148
  | Everything (edits and commands) | `--permission-mode all` (the default unless the user set another) |
146
149
  | Changes kept apart from the user's files | `--worktree=<name>` (in a git repo): it works in `.heartcode/worktrees/<name>` on the branch `heartcode/<name>`; kept if anything changed (merge it from there), removed if nothing did |
147
150
  | A cap on how long it works | `--max-turns 30` (model steps), `--max-retries 3` (a failing provider) |
148
- | Nothing kept: no session, logs, settings or notes in `~/.heart`, nothing in the project's `.heartcode/` | `--temp` (a throwaway copy, shared by the `--temp` runs going on at once, deleted after the last; the project's notes and research are read, and what the run adds goes with the copy) |
151
+ | Nothing kept: no session, logs, settings or notes in `~/.heart`, nothing in the project's `.heartcode/` | `--temp` (a throwaway copy, shared by the `--temp` runs going on at once, deleted after the last; the project's notes and research are read, and what the run adds goes with the copy) With `--worktree` too, the worktree itself is made in the project's `.heartcode/worktrees/` (git needs it in the repository) |
149
152
 
150
153
  Tool names: HeartCode's own (`read_file`, `edit_file`, `write_file`, `run_command`, `search`,
151
154
  `list_files`, `changes`, `web_fetch`, `web_search`…) or Claude Code's (`Read`, `Edit`, `Write`, `Bash`,
@@ -169,10 +172,16 @@ nothing is sent to the model to find out. A model models.dev doesn't know works
169
172
  assumptions, and the user can set it up on the settings page. Models that can't call tools still
170
173
  work, in a slower guided mode.
171
174
 
172
- The model in use knows the user's other models (in the user's order, with what each can do) and works with them through its `agent` tool: it asks a model that can for what it
175
+ The model in use knows the user's other models and works with them through its `agent` tool.
176
+ When the user picked helpers (on *Your models*: a switch per model and what it's good at: UI &
177
+ visuals, Code & logic, Big & hard, Quick & cheap), it knows only those, and a job goes to the
178
+ helper good at it (no model named: the first helper, in the user's order or by their provider
179
+ ranking, as they chose); else it knows all of them, in the user's order, with what each can do. It
180
+ asks a model that can for what it
173
181
  can't do itself (a model that can't see asks one that can about a screenshot: "which tiles show a
174
182
  chair?"), several at once when there are many images or parts, and a helper that fails is handed to
175
- the next capable model in the user's order until one does the job. A helper works until its job is done (no step
183
+ the next capable model in the user's order (with helpers picked: the next helper, then the model in
184
+ use) until one does the job. A helper works until its job is done (no step
176
185
  limit; `--max-turns` applies to it too). Their tokens are in `usage`, and each model's in
177
186
  `modelUsage`.
178
187
 
@@ -193,7 +202,7 @@ HEART_API_KEY=… heart -u https://api.groq.com/openai/v1 -m openai/gpt-oss-120b
193
202
  ```
194
203
 
195
204
  A model server on this machine (Ollama on :11434, LM Studio on :1234, llama.cpp on :8080) is
196
- found on its own. The user can also set everything up in a browser: `heart settings` (its link has
205
+ found on its own while no provider is set up yet. The user can also set everything up in a browser: `heart settings` (its link has
197
206
  the machine's network address, so it opens from another device too, for HeartCode on a server), where
198
207
  **Test all** under *Your models* sends each model a short message to show it really answers, and how fast. A run that fails with a wrong key or an unknown model: ask the user to test it there.
199
208
 
@@ -201,7 +210,7 @@ the machine's network address, so it opens from another device too, for HeartCod
201
210
 
202
211
  | Flag | |
203
212
  |---|---|
204
- | `--append-system-prompt "<text>"` | your instructions for this run, at the end of the system prompt. HeartCode's own part then says less (no role of its own, no "stay in the project folder", no way of finishing of its own) and tells the model to follow yours where they differ; its `manage` tool is left out, and nothing from the run's messages is saved to its memory |
213
+ | `--append-system-prompt "<text>"` | your instructions for this run, at the end of the system prompt. HeartCode's own part then says less (no role of its own, no "stay in the project folder", no way of finishing of its own) and tells the model to follow yours where they differ; its `manage` tool is left out (its memory still works: `--no-memory` turns that off) |
205
214
  | `--mcp-config <file or JSON>` | more MCP servers (repeatable); `--strict-mcp-config`: only those. The model sees every server's tools by name, one line each, and gets a tool's arguments when it uses it (a call that doesn't fit them comes back with what's wrong, not run). What a server says about using its tools comes once, with the first result of one of them |
206
215
  | `--skills-dir <folder>` | more skills (repeatable) |
207
216
  | `--no-memory` | nothing read or kept: no memory notes, no web pages saved in the project, no wrap-up at the end (see "What a run leaves") |
@@ -227,7 +236,8 @@ stopped when HeartCode exits.
227
236
 
228
237
  Before a task that changed files ends, another of the user's models (the same one when only one is
229
238
  used) reviews the work against the request in a request of its own; a NO sends it back to fix.
230
- The first file change of a task waits for the model's plan (its todo list). Changing files and
239
+ The first file change of each message waits for the model's plan (its todo list): without one it
240
+ isn't made, once (the model is told to write the plan first). Changing files and
231
241
  then saying it's done without running anything since sends it back to check. Nothing stops a
232
242
  task but `--max-turns`, `--max-retries` or an interrupt: a model going round in circles hands the
233
243
  work to the next model in the list. These requests are in `usage` and `modelUsage` too.
@@ -240,7 +250,8 @@ heart -p --input-format stream-json --output-format stream-json
240
250
 
241
251
  Stdin: one message per line, `{"type":"user","message":{"role":"user","content":"…"}}`.
242
252
  Stop the running one with `{"type":"control_request","request_id":"1","request":{"subtype":"interrupt"}}`;
243
- any other control request gets a `control_response` with `subtype: "error"` (not supported).
253
+ `initialize` and `set_permission_mode` (`"mode"`: as `--permission-mode` takes it) are answered with
254
+ `subtype: "success"`; any other control request gets a `control_response` with `subtype: "error"` (not supported).
244
255
  Stdout: one JSON event per line, `system`/`init` (its `tools` include the MCP servers' tools, each
245
256
  `mcp__<server>__<tool>`, and `mcp_servers` says which are `connected`), then `assistant` (text, thinking, `tool_use`),
246
257
  `user` (`tool_result`), and a `result` after each message. It runs until stdin closes. An MCP
@@ -257,13 +268,43 @@ several can run at once) come as `assistant` and `user` lines too, as Claude Cod
257
268
  subagent's: `parent_tool_use_id` is the id of the `agent` call they belong to (`null` for the main
258
269
  conversation's). The helper's last reply is that `agent` call's `tool_result`.
259
270
 
260
- Every `assistant` line's `message.model` is the model that wrote it (`provider/model`): after a
261
- fallback, the one that took over, not the one the run started with (the `init` line's `model`).
271
+ **Which model does what.** Every line says which model it's from, as `provider/model`:
272
+
273
+ - `assistant`: `message.model` is the model that wrote it (after a fallback, the one that took
274
+ over, not the `init` line's `model`; a helper's lines: the helper's model).
275
+ - `user` (a `tool_result`): a top-level `model`, the model that made the call.
276
+ - `system` lines (below): `model` on `status`, `helper` and `review`; `by` on each plan step a
277
+ helper took; `from` and `to` on `model_switch`.
278
+
262
279
  `modelUsage` in the `result` has each model that answered.
263
280
 
264
- Not in the stream: HeartCode's own prompts (the system prompt, its nudges), the review's verdict
265
- and the wrap-up. Helpers' work is in it: `agent` tool calls, with the helper's lines under them. Their tokens are in `usage` and
266
- `modelUsage`. Retries and switches to another model go to stderr with `--verbose`.
281
+ **Why a reply ended.** Each `assistant` line's `message.stop_reason` is `end_turn`, `tool_use`,
282
+ `max_tokens` (cut off: its provider's output limit, or a connection that ended early) or `refusal`
283
+ (the provider's filter); the `result` has the final answer's.
284
+
285
+ **Cut-off replies.** HeartCode sends no `max_tokens`, so each provider's own output limit applies.
286
+ An answer cut off by it (or by a stream that ended without `[DONE]`) isn't taken as finished: the
287
+ model is asked to go on where it stopped (up to 3 times in a row), and the answer is the pieces
288
+ together. Each piece comes as its own `assistant` line (`stop_reason: max_tokens`), then the whole
289
+ answer as one more `assistant` line, so the last `assistant` line before the `result` is always
290
+ the answer as a whole (and so is `result`).
291
+
292
+ **What the full screen shows, as `system` lines** (`{"type":"system","subtype":…,"session_id":…}`;
293
+ a program that doesn't know a subtype can skip it, as for Claude Code):
294
+
295
+ | `subtype` | Fields | When |
296
+ |---|---|---|
297
+ | `status` | `status`, `model` | what it's doing now, as the screen's spinner says it ("thinking", "waiting for …", "preparing read_file README.md", a running command's latest output line, read once a second); sent when it changes. A helper's: its model |
298
+ | `todos` | `todos`: `[{ content, status, by? }]` | the whole plan, each time it changes; `status` is `pending`, `in_progress` or `completed`; `by`: the model a step was handed to |
299
+ | `helper` | `tool_use_id`, `label`, `model`, `status` | a helper at work: `starting`, then what it's doing, then `done`. `tool_use_id` is its `agent` call (several parts of a plan run at once can share one); `label` its job |
300
+ | `review` | `model`, `verdict` (`yes`/`no`), `issues` | another model's look at the changes before the answer; a `no` sends the work back to be fixed |
301
+ | `model_switch` | `from`, `to`, `reason`, `place` | the user's list moved on: `from` failed (`reason`, e.g. `rate-limited (429)`), `to` answers now (`place`: its place in the list) |
302
+ | `retry` | `attempt`, `delay_ms`, `error` | a request failed and is tried again after `delay_ms` |
303
+ | `warning` | `message` | what the screen shows as a warning (e.g. a model models.dev doesn't know) |
304
+
305
+ Not in the stream: HeartCode's own prompts (the system prompt, its nudges) and the wrap-up's
306
+ requests (their `retry` lines can come after the `result`). Their tokens are in `usage` and
307
+ `modelUsage`.
267
308
 
268
309
  ## Don't
269
310
 
package/bin/heart.js CHANGED
@@ -22,7 +22,7 @@ const fail = (msg) => {
22
22
  console.error(msg)
23
23
  process.exit(1)
24
24
  }
25
- if (Number(process.versions.node.split('.')[0]) < 20) fail(`HeartCode needs Node.js 20 or newer (you have ${process.version}): https://nodejs.org`)
25
+ if (Number(process.versions.node.split('.')[0]) < 22) fail(`HeartCode needs Node.js 22 or newer (you have ${process.version}): https://nodejs.org`)
26
26
 
27
27
  const args = process.argv.slice(2)
28
28
  const realHome = process.env.HEART_HOME || path.join(os.homedir(), '.heart')
package/bin/heartcode.js CHANGED
@@ -9,7 +9,7 @@ import { Session, transcript, contextReport } from '../src/agent.js'
9
9
  import { listJobs, getJob, stopJob, removeJob, runningJobs, tailLines, ago as ranFor } from '../src/background.js'
10
10
  import { checkUpdate, installKind, UPDATE_COMMANDS, packageDir, whatsNew } from '../src/update.js'
11
11
  import { treeItems, codePlan, move, leaving, leftText, leftFiles } from '../src/tree.js'
12
- import { UI, c, PERMISSIONS, duration, copyText, overSsh, rank, setTheme, themeCodes, renderDiff, diffLines, DEFAULT_KEYS, loadKeys, width, shortError, wrapWords } from '../src/ui.js'
12
+ import { UI, c, PERMISSIONS, duration, copyText, overSsh, prettyKey, rank, setTheme, themeCodes, renderDiff, diffLines, DEFAULT_KEYS, loadKeys, width, shortError, wrapWords } from '../src/ui.js'
13
13
  import { listFiles, runCommand, clip } from '../src/tools.js'
14
14
  import { notify } from '../src/telegram.js'
15
15
  import { log, LOG_FILE, LOG_DIR, requestLog, useRequestLog, useLogs, pruneLogs, logDays } from '../src/log.js'
@@ -55,7 +55,7 @@ ${c.bold('options')}
55
55
  "auto" (the default): your list, #1 then the next when one fails
56
56
  --fallback-model <name> after -m's model when it fails (repeatable)
57
57
  --api-key <key> API key for --base-url
58
- -y, --yes do everything without asking (the default)
58
+ -y, --yes do everything without asking (the default; through --acp, an editor: ask)
59
59
  --ask ask before every edit and command, this run
60
60
  --hide-thinking the model's thinking: only its last two lines while it thinks (the default; Alt+O shows all of it)
61
61
  -C, --cwd <dir> project folder (default: current folder)
@@ -93,7 +93,8 @@ ${c.bold('headless')} (for other programs; flags and output as in Claude Code's
93
93
  ${c.bold('editors')} heartcode --acp the Agent Client Protocol on stdin/stdout (Zed, JetBrains, Neovim)
94
94
 
95
95
  ${c.bold('env')} HEART_BASE_URL, HEART_MODEL, HEART_API_KEY (or OPENAI_BASE_URL / OPENAI_API_KEY)
96
- HEART_LOG=<file> every kind of log of this run in that one file, whatever is switched on (off: none)
96
+ HEART_LOG=<file> every text log of this run in that one file, whatever is switched on (requests stay
97
+ in their own folder); HEART_LOG=off: no logs at all
97
98
 
98
99
  ${c.bold('in a session')} attach an image with @path/to/shot.png · /help for commands`
99
100
 
@@ -104,7 +105,7 @@ const SECTIONS = [
104
105
  ]],
105
106
  ['settings', [
106
107
  ['/toggle_thinking', "the model's thinking: its last two lines, or all of it (Alt+O)"],
107
- ['/voice', 'say your message (or Space in an empty box): it shows in the box as you speak, Enter sends it, Esc cancels'],
108
+ ['/voice', 'say your message (or Space in an empty box, once voice is set up): it shows in the box as you speak, Enter sends it, Esc cancels'],
108
109
  ]],
109
110
  ['session', [
110
111
  ['/resume', 'continue an earlier session in this folder'],
@@ -133,7 +134,7 @@ const SECTIONS = [
133
134
  ['/reset', "HeartCode's settings (or also providers, or everything) back to the start; asks for a code first"],
134
135
  ['/settings', 'change providers, models, settings, MCP servers, hooks, keys and skills in your browser'],
135
136
  ['/help', 'this list'],
136
- ['/tab', 'a new tab (Alt+T): another conversation beside this one · /tab worktree [name]: in its own git worktree · /tab 2: go to tab 2 (Alt+N/P) · Alt+W closes one', true],
137
+ ['/tab', 'a new tab (Alt+T): another conversation beside this one · /tab worktree [name]: in its own git worktree · /tab 2: go to tab 2 (Alt+2; Alt+N/P: the next or previous) · Alt+W closes one', true],
137
138
  ['/close_tab', 'close this tab (Alt+W); asks first'],
138
139
  ['/exit', 'quit HeartCode (Alt+W closes just this tab)'],
139
140
  ]],
@@ -149,19 +150,18 @@ const SLASH = helpText(SECTIONS)
149
150
 
150
151
  // The keyboard shortcuts, as [keys, what] rows, read from the effective keybindings (keybindings.json
151
152
  // can change any of them) plus the fixed ones (Space, Enter, Esc, Shift+Tab, Ctrl+C).
152
- function keysHelp(keys = {}, mouse = false) {
153
- const NAMES = { pageup: 'PgUp', pagedown: 'PgDn', up: '↑', down: '↓', left: '←', right: '→', ctrl: 'Ctrl', alt: 'Alt', shift: 'Shift' }
154
- const pretty = (k) => k.split('+').map((p) => NAMES[p] ?? (p.length === 1 ? p.toUpperCase() : p[0].toUpperCase() + p.slice(1))).join('+')
155
- const forAct = (a) => Object.entries(keys).filter(([, v]) => v === a).map(([k]) => pretty(k)).join(' / ')
156
- const tabs = /(^|,)alt\+[1-9]/.test(Object.keys(keys).join(','))
153
+ function keysHelp(keys = {}, mouse = false, voice = false) {
154
+ const forAct = (a) => Object.entries(keys).filter(([, v]) => v === a).map(([k]) => prettyKey(k)).join(' / ')
155
+ const tabs = Object.values(keys).some((v) => /^tab_[1-9]$/.test(v))
157
156
  const rows = [
158
- ['Space', 'voice: listens at once, Enter sends what you said (in an empty box)'],
157
+ [voice ? 'Space' : '', 'voice: listens at once, Enter sends what you said (in an empty box)'],
159
158
  ['Enter', 'send · while it works, queue the message (commands like /help, /cost, /select_model run at once)'],
160
- ['Option+Enter or Shift+Enter', 'new line in the box'],
161
- ['Esc', 'stop the task (press twice to confirm)'],
159
+ ['Option+Enter or Shift+Enter', 'new line in the box (also while it works)'],
160
+ ['Esc', 'while it works: queued messages back into the box, then clears the box, then stops the task (twice)'],
162
161
  ['Esc Esc', 'rewind to an earlier message (at the prompt)'],
163
162
  ['Shift+Tab', 'change what runs without asking (permissions)'],
164
- [forAct('background_log'), "the background commands' logs in a dialog, a tab each (←/→ switch, ↑/↓ scroll, K twice stops one, Esc closes)"],
163
+ [forAct('toggle_thinking'), "the model's thinking: after an answer, all of it in a box; while it works, all of it as it comes or its last two lines"],
164
+ [forAct('background_log'), "the background commands' logs in a dialog, a tab each (←/→ switch, ↑/↓ scroll, K twice stops one, Esc closes); with text in the box it moves back a word instead"],
165
165
  [forAct('new_tab'), 'new tab'],
166
166
  [forAct('close_tab'), 'close this tab'],
167
167
  [forAct('next_tab'), 'next tab'],
@@ -251,7 +251,7 @@ class App {
251
251
  this.ui.print(`${c.info('↗')} ${c.bold(name)} ${c.muted('needs you to sign in; opening your browser…')}\n ${c.faint(url)}`)
252
252
  const [cmd, ...args] = process.platform === 'darwin' ? ['open', url] : process.platform === 'win32' ? ['rundll32', 'url.dll,FileProtocolHandler', url] : ['xdg-open', url]
253
253
  spawnSync(cmd, args, { stdio: 'ignore' })
254
- this.ui.spinner(`waiting for you to sign in to ${name} in the browser · Esc to stop`)
254
+ this.ui.spinner(`waiting for you to sign in to ${name} in the browser · Esc twice to stop`)
255
255
  }
256
256
  return mcp
257
257
  }
@@ -367,9 +367,11 @@ class App {
367
367
  client.onSwitch = (t) => {
368
368
  const i = client.rotation.list.indexOf(t)
369
369
  const f = failed?.e
370
+ const from = failed?.t
370
371
  const why = f ? `${failed.t.model} ${f.status === 429 ? 'rate-limited (429)' : `failed (${clip(shortError(f), 50)})`} → ` : ''
371
372
  failed = null
372
373
  switched = c.dim(`↻ ${why}${t.provider} · ${t.model} answered${i ? ` (#${i + 1} in your model list)` : ' (#1 again)'}`)
374
+ ui.event?.({ subtype: 'model_switch', from: from ? `${from.provider}/${from.model}` : null, to: `${t.provider}/${t.model}`, reason: f ? (f.status === 429 ? 'rate-limited (429)' : shortError(f)) : null, place: i + 1 })
373
375
  setImmediate(client.announceSwitch)
374
376
  }
375
377
  if (cfg.maxRetries !== undefined) client.retryIf = (e, attempt) => attempt < cfg.maxRetries // headless: then give up
@@ -633,7 +635,7 @@ class App {
633
635
  const mine = this.commands().slice(COMMANDS.length)
634
636
  const sections = [...SECTIONS]
635
637
  if (mine.length) sections.push(['your skills (type /skill:name)', mine])
636
- sections.push(['keyboard', keysHelp(this.ui.keys, this.cfg?.mouse !== false)])
638
+ sections.push(['keyboard', keysHelp(this.ui.keys, this.cfg?.mouse !== false, Boolean(this.ui.voiceReady?.()))])
637
639
  return helpText(sections)
638
640
  }
639
641
 
@@ -912,7 +914,7 @@ class App {
912
914
  const { cfg } = this
913
915
  if (!cfg.session) return this.myModels(all)
914
916
  const seen = new Set()
915
- return cfg.session.filter((t) => cfg.providers[t.provider] && (all || !cfg.providers[t.provider].off) && t.model && !seen.has(`${t.provider}/${t.model}`) && seen.add(`${t.provider}/${t.model}`))
917
+ return cfg.session.filter((t) => cfg.providers[t.provider] && (all || cfg.pinned || !cfg.providers[t.provider].off) && t.model && !seen.has(`${t.provider}/${t.model}`) && seen.add(`${t.provider}/${t.model}`))
916
918
  }
917
919
 
918
920
  // Alt+B, /background: the background commands' logs in a dialog, one at a time with a tab each.
@@ -1235,7 +1237,7 @@ function applySettings(apps, cfg, what) {
1235
1237
  const { ui } = app
1236
1238
  const busy = Boolean(ui.busySince || app.working)
1237
1239
  const now = (fn) => (busy ? app.later.push(fn) : fn())
1238
- if (app.cfg !== cfg) for (const k of ['providers', 'provider', 'model', 'effort', 'theme', 'context', 'autoCompact', 'director', 'format', 'lsp', 'voice', 'rotation', 'statusBar']) app.cfg[k] = cfg[k]
1240
+ if (app.cfg !== cfg) for (const k of ['providers', 'provider', 'model', 'effort', 'theme', 'context', 'autoCompact', 'director', 'format', 'lsp', 'voice', 'rotation', 'statusBar', 'helpers', 'helpersAuto', 'helperOrder', 'providerRank', 'replyStart', 'replyIdle', 'telegram', 'queue', 'mouse']) app.cfg[k] = cfg[k]
1239
1241
  // a model pinned in this CLI (/select_model) is a session choice: a model/order change on the
1240
1242
  // settings page leaves it alone (only /select_model auto here returns it to the list)
1241
1243
  if (what === 'model' && !app.cfg.session) {
@@ -1426,7 +1428,7 @@ async function slash(app, line, working = false) {
1426
1428
  if (!go?.yes) return
1427
1429
  }
1428
1430
  if (!working && app.s?.wrapping) {
1429
- ui.spinner('keeping what the last task learned · Ctrl+C to quit now')
1431
+ ui.spinner('keeping what the last task learned · Ctrl+C twice to quit now')
1430
1432
  await app.s.wrapping
1431
1433
  }
1432
1434
  return 'exit'
@@ -1862,7 +1864,7 @@ async function repl(app, f = {}) {
1862
1864
  ui.folder = app.root // what a double click on the header's folder copies
1863
1865
  ui.header = (cols = 100) => {
1864
1866
  const room = cols - 2 - width(`♥ HeartCode ${VERSION} `) // the folder's own name (its end) stays in sight
1865
- const keys = [['/', 'run a command'], ['@', 'attach a file'], ...(ui.voiceReady?.() ? [['Space', 'talk (voice)']] : []), [NEWLINE_KEY, 'add a new line'], ['Esc', 'stop'], ['Shift+Tab', 'change permissions']]
1867
+ const keys = [['/', 'run a command'], ['@', 'attach a file'], ...(ui.voiceReady?.() ? [['Space', 'talk (voice)']] : []), [NEWLINE_KEY, 'add a new line'], ui.busySince ? ['Esc twice', 'stop'] : ['Esc Esc', 'go back to a message'], ['Shift+Tab', 'change permissions']]
1866
1868
  // the keys: on a second line when they don't fit one, broken between keys (never inside one)
1867
1869
  const rows = []
1868
1870
  for (const kd of keys) {
@@ -1959,6 +1961,7 @@ async function main() {
1959
1961
  // that starts with "page" ("page fix the footer") is a prompt
1960
1962
  const target = process.argv[3]
1961
1963
  if (process.argv[2] === 'page' && process.argv.length === 4 && (/^https?:\/\//.test(target) || fs.existsSync(target))) return (process.exitCode = await (await import('../src/check.js')).pageCommand(target))
1964
+ if (process.argv[2] === 'page' && process.argv.length === 4 && /[./\\]/.test(target)) return console.error(`heart page: no such file: ${target}`), (process.exitCode = 1) // a file meant, not there: not taken as a task
1962
1965
  // "--resume <id>" (as in Claude Code) vs a bare "--resume" (pick one): an id follows it
1963
1966
  const argv = process.argv.slice(2)
1964
1967
  const print = argv.includes('-p') || argv.includes('--print') // headless: an id after --resume is always an id
@@ -2021,14 +2024,21 @@ async function main() {
2021
2024
  for (const k of ['output-format', 'input-format']) if (f[k] && !['text', 'json', 'stream-json'].includes(f[k])) throw new Error(`--${k} must be text, json or stream-json`)
2022
2025
  if (f['permission-mode'] && !PERMISSION_MODES[f['permission-mode']]) throw new Error(`--permission-mode must be one of ${Object.keys(PERMISSION_MODES).join(', ')}`)
2023
2026
 
2024
- const cfg = loadConfig({ baseUrl: f['base-url'], model: f.model, apiKey: f['api-key'], context: f.context })
2027
+ if (f.effort && !['default', 'low', 'medium', 'high'].includes(f.effort)) throw new Error('--effort must be low, medium, high or default')
2028
+ const cfg = loadConfig({ baseUrl: f['base-url'], model: f.provider && f.model ? `${f.provider} ${f.model}` : f.model, apiKey: f['api-key'], context: f.context })
2025
2029
  setTheme(cfg.theme)
2026
2030
  useLogs(cfg)
2027
2031
  const safe = { ...cfg, providers: Object.fromEntries(Object.entries(cfg.providers).map(([n, p]) => [n, { ...p, apiKey: p.apiKey && mask(p.apiKey) }])) }
2028
2032
  log('start', `heartcode ${VERSION} · node ${process.version} · ${process.platform} · cwd ${process.cwd()}`, { args: process.argv.slice(2).map((a) => (a === f['api-key'] ? mask(a) : a)), config: safe })
2033
+ // --provider: one model alone, as -m does: with -m, that one (above); alone, that provider's first
2034
+ // model in your list
2029
2035
  if (f.provider) {
2030
2036
  if (!cfg.providers[f.provider]) throw new Error(`no provider "${f.provider}" (heartcode providers lists them)`)
2031
- Object.assign(cfg, { provider: f.provider, fixed: true })
2037
+ if (!f.model) {
2038
+ const t = [{ provider: cfg.provider, model: cfg.model }, ...(cfg.rotation?.then ?? [])].find((x) => x.provider === f.provider && x.model)
2039
+ if (!t) throw new Error(`--provider ${f.provider}: none of your models is from it; add -m <model>`)
2040
+ Object.assign(cfg, { ...t, session: [t], pinned: true })
2041
+ }
2032
2042
  }
2033
2043
  // --fallback-model: after the model given (as in Claude Code's -p), when it fails
2034
2044
  cfg.fallbacks = (f['fallback-model'] ?? []).map((v) => {
@@ -2041,6 +2051,8 @@ async function main() {
2041
2051
  extraSkillDirs.push(...(f['skills-dir'] ?? []).map((d) => path.resolve(d)))
2042
2052
  if (f.save) {
2043
2053
  cfg.adhoc = null
2054
+ // the model given (-m, -u): saved as #1, not just for this run
2055
+ if (cfg.session?.length) [cfg.provider, cfg.model, cfg.session, cfg.pinned] = [cfg.session[0].provider, cfg.session[0].model, undefined, undefined]
2044
2056
  saveConfig(cfg)
2045
2057
  console.log(c.dim(`saved to ${CONFIG_FILE}`))
2046
2058
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartcode",
3
- "version": "0.1.58",
3
+ "version": "0.1.59",
4
4
  "description": "A coding CLI for any local or OpenAI-compatible model, including small models without tool calling.",
5
5
  "keywords": [
6
6
  "ai",
package/prompts/agent.md CHANGED
@@ -34,8 +34,8 @@ Then build exactly what they chose. Nothing extra: no polish, features, tests or
34
34
  ## 2. Research and plan
35
35
  1. Your memory is out of date. Before you use a library, framework, API, tool or command, read its current official docs (web_search, then web_fetch) and use its latest version. This project's own code needs no lookup: read the code.
36
36
  2. Notes and pages saved for this project come with the message. Read them first.
37
- 3. Save a project note (memory tool) for what later tasks here need: how to build, run or test it; a decision and why.
38
- 4. Before the first change, write a plan with the todo tool: the result in one line, what "done" looks like, then each step with how you'll check it. A small change: one item. HeartCode blocks your first change until there is a plan.
37
+ 3. {{#if memory}}Save a project note (memory tool) for what later tasks here need: how to build, run or test it; a decision and why.{{else}}Say in your reply what later tasks here need: how to build, run or test it; a decision and why.{{/if}}
38
+ 4. Before the first change, write a plan with the todo tool: the result in one line, what "done" looks like, then each step with how you'll check it. A small change: one item. The first change of each message waits for that plan: without one it isn't made.
39
39
 
40
40
  ## 3. Find your way
41
41
  Stop looking once you have what the task needs.
@@ -99,6 +99,11 @@ How to use {{server}}, in its own words (said once):
99
99
  <!-- A tool result that was shortened. {{shown}}, {{total}}: characters shown and in all. {{file}}: where all of it is (may be empty). {{call}}: set for an older result shortened to save room ("run_command npm test"); its first lines follow. -->
100
100
  [{{#if call}}Older output of {{call}}, shortened to save room{{else}}Shortened to fit{{/if}}. Not an error: it ran normally. {{shown}} of {{total}} characters shown.{{#if file}} All of it is in {{file}}: read_file it (start_line, end_line) or search it.{{/if}}]
101
101
 
102
+ ## cut-off
103
+
104
+ <!-- Sent when the model's reply was cut off (its provider's output limit, or the connection ended early), to have it go on. -->
105
+ (Your reply was cut off. Go on exactly where it stopped, without repeating what you already wrote.)
106
+
102
107
  ## empty-reply
103
108
 
104
109
  <!-- Sent when the model replied with nothing (no text, no tool call) in the middle of a task. -->
@@ -143,7 +148,7 @@ Your file changes in this message, as a diff (`all`: the whole conversation; `pa
143
148
 
144
149
  ## tool-list_files
145
150
 
146
- With `path`: that folder's entries (folders end in /; "(ignored)": left out by .gitignore). Without: the project's files (only paths containing `filter`, if given).
151
+ With `path`: that folder's entries (folders end in /; "(ignored)": left out by .gitignore). Without: the project's files. `filter`: only paths containing it (with `path`: the files under that folder that contain it).
147
152
 
148
153
  ## tool-find_command
149
154
 
@@ -166,7 +171,7 @@ Create a file, or overwrite one with its full content. append: true adds to its
166
171
 
167
172
  ## tool-run_command
168
173
 
169
- Run a shell command in the project folder. `wait`: seconds to wait for it (5 for a quick one, 60+ for an install or build; default 30). Finished: its exit code and output. Still running: it goes on in the background and you get its id and output so far; check it with the background tool. A command that keeps running (a dev server, a watcher): background: true.
174
+ Run a shell command in the project folder. `wait`: seconds to wait for it (5 for a quick one, 60+ for an install or build; default 30, or 3 with background: true). Finished: its exit code and output (of a long one, its last 4,000 characters). Still running: it goes on in the background and you get its id and output so far; check it with the background tool. A command that keeps running (a dev server, a watcher): background: true.
170
175
 
171
176
  ## tool-background
172
177
 
@@ -215,16 +220,16 @@ Files of this skill (read one with the skill tool: name "{{name}}", file "<path>
215
220
  ## tool-todo
216
221
 
217
222
  <!-- The todo tool: the model's checklist, shown to the user. -->
218
- Your todo list for a task with several steps. Send the whole list each time: content and status (pending, in_progress or completed). One item in_progress at a time; mark it completed as soon as it's done. Skip it for small tasks.
219
- A part that stands alone (needs no other part's result, touches no file another part touches) can run at the same time on another of your models: parallel: true, model ("provider model" from "Your other models"; left out: yours), files (the files only it changes). HeartCode starts those as helpers when you save the list and gives you what each did; you combine and check. Parts that build on each other, one file, a small fix: do them yourself.
223
+ Your todo list for a task with several steps. Send the whole list each time: content and status (pending, in_progress or completed). One item in_progress at a time; mark it completed as soon as it's done. A small task: one item (changing files needs a plan first).
224
+ A part that stands alone (needs no other part's result, touches no file another part touches) can run at the same time on another of your models: parallel: true, model ("provider model" from "Your helpers" or "Your other models"; left out: your first helper, or yours when you have none), files (the files only it changes). HeartCode starts the pending ones as helpers when you save the list (not in plan mode, not from a helper) and gives you what each did; you combine and check. Parts that build on each other, one file, a small fix: do them yourself.
220
225
 
221
226
  ## tool-web_search
222
227
 
223
- Search the web. Returns titles, URLs and snippets; read a page with web_fetch. Pages this project already saved that match come first (with the date read): use them, or search again with fresh: true for something that changes (a latest version).
228
+ Search the web. Returns titles, URLs and snippets; read a page with web_fetch. When pages this project already saved match, you get those instead of a search (with the date read): use them, or search with fresh: true for something that changes (a latest version).
224
229
 
225
230
  ## tool-web_fetch
226
231
 
227
- Fetch a web page (any http/https URL) as Markdown. The whole page is saved in the project's research folder (the result says where). Give look_for (what you need, in a few words): a long page comes as its outline plus the matching parts; read the rest from the saved file with read_file. A short page comes whole.
232
+ Fetch a web page (any http/https URL) as Markdown. The whole page is saved in the project's research folder (the result says where). Give look_for (what you need, in a few words): a long page comes as its outline plus the matching parts; read the rest from the saved file with read_file. A short page comes whole. When nothing is saved (the result says so), a long page comes in parts: start (a character offset) reads on from where it stopped.
228
233
 
229
234
  ## tool-ask_user
230
235
 
@@ -238,7 +243,7 @@ No answer. Decide yourself, carry on, and say in your reply what you assumed.
238
243
  ## tool-agent
239
244
 
240
245
  <!-- Starts a helper agent (only in the main conversation, not in helpers). -->
241
- Give a side job to a helper agent with a fresh context, to keep the details out of this conversation: searching or reading a lot of code, web research, reviewing changes. It has your tools (no helpers of its own) and sees only your prompt: say exactly what to do and what to report. Its final reply is the result. description: 3-5 words for the user.
246
+ Give a side job to a helper agent with a fresh context, to keep the details out of this conversation: searching or reading a lot of code, web research, reviewing changes. It has your tools (but no helpers of its own, no memory, and it can't ask the user) and sees only your prompt: say exactly what to do and what to report. Its final reply is the result. description: 3-5 words for the user.
242
247
  Several agent calls in one reply run at the same time: one helper per independent part, or the same question to several helpers to compare their answers.
243
248
 
244
249
  ## team
@@ -449,7 +454,7 @@ Not changed: {{file}} belongs to another part. Your part changes only {{files}}.
449
454
  These parts were done at the same time, each by a helper:
450
455
  {{reports}}
451
456
  {{#if unknown}}
452
- ({{unknown}}: not one of your models, so those parts ran on yours. Your models: {{models}}.)
457
+ ({{unknown}}: not one of your models, so HeartCode chose the model for those parts. Yours: {{models}}.)
453
458
  {{/if}}
454
459
  Now combine them: read what they changed, add what's still needed between them, then check the whole thing once. A part not done: do it yourself or give it again.
455
460