heartcode 0.1.45 → 0.1.54

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/SKILL.md CHANGED
@@ -58,7 +58,7 @@ reached has an `error` (in text: a line on stderr) and is skipped; the command s
58
58
 
59
59
  | `-m` | What runs |
60
60
  |---|---|
61
- | `auto`, or no `-m` | the user's list: #1, and the next one in order when it fails (with the user's orchestrator setting: an orchestrator model first, below). Use this unless you need one particular model. |
61
+ | `auto`, or no `-m` | the user's list: #1, and the next one in order when it fails. Use this unless you need one particular model. |
62
62
  | `provider/model` (`-m groq/openai/gpt-oss-120b`), or a model of #1's provider alone | that model alone: never another one, also when it fails (a rate limit or an outage is tried again, up to `--max-retries`) |
63
63
  | that, plus `--fallback-model provider/model` (repeatable) | that model, then the fallbacks in order when it fails (as `claude -p --fallback-model`) |
64
64
 
@@ -80,14 +80,9 @@ image, one that can't call tools gets the tool calls as text.
80
80
 
81
81
  `--provider <name>` and `-u <url>` (a server for this run) also mean one model, alone.
82
82
 
83
- **Orchestrator** (the user's setting "Pick: an orchestrator hands it out", on Your models in
84
- `heart settings`; `--model-choice fit` for one run): with `auto`, each message starts on one of the
85
- models the user chose as orchestrators (none chosen: their first that calls tools). It answers
86
- at once, streaming, when it can (a greeting, a question), and otherwise hands the work to the
87
- user's other models through its `agent` tool. It picks which one, knowing what each can do and
88
- its places in the public LMArena rankings. It has no other tool: the models it picks do the work. If no
89
- orchestrator answers, the list goes on to the next model. With "in your order" (the default), the list
90
- is the user's order, as is.
83
+ `heartcode page <file|url>` checks a web page in a headless browser (errors, a blank page, a click
84
+ that breaks it, text too faint to read, content hidden at load, icons that don't draw: exit 0 when it
85
+ passes) and saves screenshots to `.heartcode/page-shots/`.
91
86
 
92
87
  A run picks up settings the user changes meanwhile (`heart settings`, another HeartCode, or
93
88
  `~/.heart` by hand) without being restarted, from its next request: the model order, prompts,
@@ -95,7 +90,7 @@ hooks, skills, MCP servers. `--temp` runs share one throwaway folder, so a chang
95
90
  other `--temp` runs going on, never the real ones.
96
91
 
97
92
  `heart` is installed by `npm start` in the HeartCode folder. `heartcode` is the same command.
98
- Needs Node.js 20 or newer. No providers? See "Setting up a model" below.
93
+ Needs Node.js 22 or newer. No providers? See "Setting up a model" below.
99
94
 
100
95
  ## Run a task
101
96
 
@@ -125,7 +120,7 @@ goes to stderr. Logs never go to stdout.
125
120
 
126
121
  ## Continue the same conversation
127
122
 
128
- Every run is saved as a session in `~/.heart/sessions/` (and logged, for the kinds of logs the user
123
+ Every run is saved as a session in the project's `.heartcode/sessions/` (and logged, for the kinds of logs the user
129
124
  switched on), as when the user works in HeartCode; `--temp` keeps nothing. Pass the `session_id`
130
125
  from the last result:
131
126
 
@@ -166,7 +161,7 @@ heart -p -m auto "…" # the user's list, with its fa
166
161
  heart -p -m groq/openai/gpt-oss-120b "…" # that provider and model alone, for this run
167
162
  heart -p -m groq/openai/gpt-oss-120b --fallback-model openrouter/qwen/qwen3-coder "…" # and that one when it fails
168
163
  heart -p --provider ollama -m qwen3-coder "…" # the same, written apart
169
- heart -p --effort high "…" # how hard a thinking model thinks
164
+ heart -p --effort high "…" # how hard a thinking model thinks (low unless set)
170
165
  ```
171
166
 
172
167
  What a model can do (tool calls, context size, thinking, images) comes from models.dev, at once;
@@ -174,11 +169,10 @@ nothing is sent to the model to find out. A model models.dev doesn't know works
174
169
  assumptions, and the user can set it up on the settings page. Models that can't call tools still
175
170
  work, in a slower guided mode.
176
171
 
177
- The model in use knows the user's other models (what each can do, how often it failed this
178
- session, and with an orchestrator their ranks overall, for code, web apps and vision) and works with them through its `agent` tool: it asks a model that can for what it
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
179
173
  can't do itself (a model that can't see asks one that can about a screenshot: "which tiles show a
180
174
  chair?"), several at once when there are many images or parts, and a helper that fails is handed to
181
- the next capable model until one does the job. A helper works until its job is done (no step
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
182
176
  limit; `--max-turns` applies to it too). Their tokens are in `usage`, and each model's in
183
177
  `modelUsage`.
184
178
 
@@ -201,8 +195,7 @@ HEART_API_KEY=… heart -u https://api.groq.com/openai/v1 -m openai/gpt-oss-120b
201
195
  A model server on this machine (Ollama on :11434, LM Studio on :1234, llama.cpp on :8080) is
202
196
  found on its own. The user can also set everything up in a browser: `heart settings` (its link has
203
197
  the machine's network address, so it opens from another device too, for HeartCode on a server), where
204
- **Test** (or **Test all**) under *Your models* sends a model a short message to show it really
205
- answers. A run that fails with a wrong key or an unknown model: ask the user to test it there.
198
+ **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.
206
199
 
207
200
  ## More context for the task
208
201
 
@@ -254,6 +247,11 @@ Stdout: one JSON event per line, `system`/`init` (its `tools` include the MCP se
254
247
  call's `tool_use` is named as in Claude Code, `mcp__<server>__<tool>`, with the tool's own
255
248
  arguments as `input`.
256
249
 
250
+ With `--include-partial-messages`, each reply also comes as it's written, as Claude Code sends it:
251
+ `stream_event` lines (`message_start`, `content_block_start`, `content_block_delta` with a
252
+ `thinking_delta` or `text_delta`, `content_block_stop`, `message_stop`), before its whole
253
+ `assistant` line. Helpers' replies come whole only (their `assistant` lines, with their parent).
254
+
257
255
  A helper's steps (the `agent` tool: another of the user's models, or the same one, doing a job;
258
256
  several can run at once) come as `assistant` and `user` lines too, as Claude Code sends a
259
257
  subagent's: `parent_tool_use_id` is the id of the `agent` call they belong to (`null` for the main
@@ -264,7 +262,7 @@ fallback, the one that took over, not the one the run started with (the `init` l
264
262
  `modelUsage` in the `result` has each model that answered.
265
263
 
266
264
  Not in the stream: HeartCode's own prompts (the system prompt, its nudges), the review's verdict
267
- and the wrap-up. An orchestrator's handoffs are in it: `agent` tool calls, with the helper's lines under them. Their tokens are in `usage` and
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
268
266
  `modelUsage`. Retries and switches to another model go to stderr with `--verbose`.
269
267
 
270
268
  ## Don't
package/bin/heartcode.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import path from 'node:path'
3
3
  import { parseArgs } from 'node:util'
4
- import { Client } from '../src/client.js'
5
- import { loadConfig, saveConfig, readJson, writeJson, providerName, CONFIG_FILE, HOME, TEMP, AUTO_MODEL, isAuto, parseModel, takeIn, whatOf, VERSION } from '../src/config.js'
4
+ import { Client, limitSaid } from '../src/client.js'
5
+ import { loadConfig, saveConfig, readJson, writeJson, providerName, CONFIG_FILE, HOME, TEMP, AUTO_MODEL, isAuto, parseModel, takeIn, whatOf, VERSION, speedOf } from '../src/config.js'
6
6
  import { loadProfile, strategy, describe, profilePath, profileFrom } from '../src/probe.js'
7
- import { learnFromUsage, LIMIT_MS } from '../src/context.js'
7
+ import { learnFromUsage, LIMIT_MS, RATE_CAP_MS } from '../src/context.js'
8
8
  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'
@@ -57,7 +57,7 @@ ${c.bold('options')}
57
57
  --api-key <key> API key for --base-url
58
58
  -y, --yes do everything without asking (the default)
59
59
  --ask ask before every edit and command, this run
60
- --hide-thinking collapse the model's thinking to one line
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)
62
62
  --temp keep nothing: a throwaway settings folder (your providers, model info,
63
63
  prices and notes copied in), shared by the --temp runs going on at once
@@ -80,7 +80,6 @@ ${c.bold('headless')} (for other programs; flags and output as in Claude Code's
80
80
  --skills-dir <dir> more skills (repeatable)
81
81
  --allowedTools <list> only these tools (HeartCode's or Claude Code's names: Read, Edit, Bash…)
82
82
  --disallowedTools <list> never these tools
83
- --model-choice <order|fit> your models' order (#1, then the next), or fit: an orchestrator hands each task out
84
83
  --permission-mode <m> all, commands, ask, plan (or bypassPermissions, acceptEdits, default);
85
84
  --dangerously-skip-permissions = all. Nothing is asked: the rest is declined
86
85
  --session-id <id> start (or continue) the session with this id
@@ -104,7 +103,7 @@ const SECTIONS = [
104
103
  ['/select_model', 'pick the model(s) for this session: one pins it, several rotate among them, auto = your whole list', true],
105
104
  ]],
106
105
  ['settings', [
107
- ['/toggle_thinking', "show or collapse the model's thinking"],
106
+ ['/toggle_thinking', "the model's thinking: its last two lines, or all of it (Alt+O)"],
108
107
  ['/voice', 'say your message (or Space in an empty box): it shows in the box as you speak, Enter sends it, Esc cancels'],
109
108
  ]],
110
109
  ['session', [
@@ -158,7 +157,7 @@ function keysHelp(keys = {}, mouse = false) {
158
157
  const rows = [
159
158
  ['Space', 'voice: listens at once, Enter sends what you said (in an empty box)'],
160
159
  ['Enter', 'send · while it works, queue the message (commands like /help, /cost, /select_model run at once)'],
161
- ['Option/Shift/Ctrl+Enter', 'new line in the box'],
160
+ ['Option+Enter or Shift+Enter', 'new line in the box'],
162
161
  ['Esc', 'stop the task (press twice to confirm)'],
163
162
  ['Esc Esc', 'rewind to an earlier message (at the prompt)'],
164
163
  ['Shift+Tab', 'change what runs without asking (permissions)'],
@@ -178,7 +177,7 @@ function keysHelp(keys = {}, mouse = false) {
178
177
  [mouse ? 'Drag' : '', 'select and copy: the conversation, a dialog, the folder, the input, the status bar'],
179
178
  [mouse ? 'Double-click' : '', 'copy the word under it (an address, a path, a model)'],
180
179
  [mouse ? (process.platform === 'darwin' ? 'Option+drag' : 'Shift+drag') : '', "the terminal's own selection, past HeartCode's"],
181
- [mouse ? '' : 'Mouse', 'the terminal\'s own: select and copy as usual (HeartCode takes the mouse, for the wheel and drag to copy, with "mouse": true in config.json)'],
180
+ [mouse ? '' : 'Mouse', 'the terminal\'s own: select and copy as usual (switch "HeartCode takes the mouse" on in /settings → General for the wheel to scroll only the conversation)'],
182
181
  ].filter(([k]) => k)
183
182
  return rows
184
183
  }
@@ -194,7 +193,7 @@ const ALL_OFF = `${c.yellow('The providers of all your models are switched off.'
194
193
  // Choices for commands that take one (also offered in the "/" menu).
195
194
  const ARGS = {
196
195
  export: [['md', 'Markdown'], ['html', 'a web page'], ['json', 'the whole session file']],
197
- set_effort: [['default', "the model's own setting"], ['low', 'quick, less thinking'], ['medium', 'balanced'], ['high', 'thinks the longest']],
196
+ set_effort: [['default', 'low: a little thinking, shown as it comes'], ['low', 'quick, less thinking'], ['medium', 'balanced'], ['high', 'thinks the longest']],
198
197
  }
199
198
 
200
199
 
@@ -224,8 +223,6 @@ class App {
224
223
  this.memory = new Memory(root) // .heartcode/memory: notes linked with [[name]]
225
224
  this.director = new Director(this) // the manage tool: skills, MCP servers and settings by asking
226
225
  this.later = [] // setting changes that wait until the current message is done
227
- this.failures = {} // "provider model" → failed requests this session (engine: onFail)
228
- this.resting = {} // "provider model" → until when it's out of quota (the server said so: engine: onFail)
229
226
  this.loadProjectModels() // the model(s) you last chose for this folder (.heartcode/models.json)
230
227
  }
231
228
 
@@ -306,7 +303,7 @@ class App {
306
303
  case 'effort':
307
304
  if (!ARGS.set_effort.some(([o]) => o === v)) return bad('default, low, medium or high')
308
305
  cfg.effort = v === 'default' ? undefined : v
309
- if (this.s?.strat.thinking) this.s.client.effort = cfg.effort
306
+ if (this.s?.strat.thinking) this.s.client.effort = effortOf(cfg)
310
307
  return save(`effort: ${v}`)
311
308
  case 'auto_compact':
312
309
  case 'director':
@@ -328,7 +325,7 @@ class App {
328
325
  }
329
326
 
330
327
  // The model, its probe and strategy for a provider and model (probed once, then cached).
331
- // quiet: for a helper (orchestration): nothing printed about the model, the settings left alone.
328
+ // quiet: for a helper: nothing printed about the model, the settings left alone.
332
329
  async engine(provider, model, ui, signal, { quiet = false } = {}) {
333
330
  const { cfg } = this
334
331
  const client = this.client(provider, model)
@@ -337,18 +334,30 @@ class App {
337
334
  client.price = () => price
338
335
  client.onSpend = (u) => addUsage((this.chat.usage ??= {}), u, price)
339
336
  client.onRetry = (err, ms, attempt, next) => ui.retrying(err, ms, attempt, next) // keep trying until Esc (also while probing)
340
- // failures per model this session: the main model sees them (Your other models) and helpers
341
- // are tried in that order
337
+ // a failed request: what it says about the model's limits is learned
342
338
  client.onFail = (e, t) => {
343
339
  if (e.name === 'AbortError') return
344
- const k = `${t.provider} ${t.model}`
345
- this.failures[k] = (this.failures[k] ?? 0) + 1
346
- if (Number(e.retryAfter) > 60) this.resting[k] = Date.now() + Number(e.retryAfter) * 1000
340
+ // "too large" with the limit stated (Groq: "Limit 2000 … tokens per minute"): kept in its profile,
341
+ // so it isn't sent what it can't take
342
+ const said = limitSaid(e)
343
+ if (said) {
344
+ const cl = this.client(t.provider, t.model)
345
+ const p = loadProfile(cl) || profileFrom(cl, limitsOf(t.provider, cl.baseUrl, t.model))
346
+ if (said.rate) p.rateCap = { tokens: said.tokens, until: Date.now() + RATE_CAP_MS }
347
+ else Object.assign(p, { inputLimit: said.tokens, inputLimitAt: Date.now() })
348
+ writeJson(profilePath(cl), p)
349
+ log('context', `${k}: ${said.rate ? 'a per-minute cap' : 'a request limit'} of ${said.tokens} tokens, from its provider`)
350
+ }
347
351
  }
348
352
  // the model list (settings page): another model answered
353
+ // told once the reply that came is closed (it's known before the reply's last line ends: it'd go on
354
+ // that line): the agent says it then (announceSwitch), else right after
355
+ let switched = null
356
+ client.announceSwitch = () => switched && (ui.print(switched), (switched = null))
349
357
  client.onSwitch = (t) => {
350
358
  const i = client.rotation.list.indexOf(t)
351
- ui.print(c.dim(`↻ ${t.provider} · ${t.model} answered${i ? ` (#${i + 1} in your model list)` : ' (#1 again)'}`))
359
+ switched = c.dim(`↻ ${t.provider} · ${t.model} answered${i ? ` (#${i + 1} in your model list)` : ' (#1 again)'}`)
360
+ setImmediate(client.announceSwitch)
352
361
  }
353
362
  if (cfg.maxRetries !== undefined) client.retryIf = (e, attempt) => attempt < cfg.maxRetries // headless: then give up
354
363
  let profile = await getProfile(client, ui, quiet)
@@ -359,7 +368,7 @@ class App {
359
368
  const apply = () => {
360
369
  for (const k of Object.keys(strat)) delete strat[k]
361
370
  Object.assign(strat, strategy(profile, cfg))
362
- Object.assign(client, { tokenRatio: profile.tokenRatio ?? 1, knownGood: profile.largestAccepted ?? 0, can: strat, effort: strat.thinking ? cfg.effort : undefined })
371
+ Object.assign(client, { tokenRatio: profile.tokenRatio ?? 1, knownGood: profile.largestAccepted ?? 0, can: strat, effort: strat.thinking ? effortOf(cfg) : undefined })
363
372
  for (const [q, at] of Object.entries(profile.quirks ?? {})) if (Date.now() - at < LIMIT_MS) client.quirks[q] = true
364
373
  price = priceOf(client.provider, client.baseUrl, client.model)
365
374
  if (this.s?.client === client) this.s.profile = profile // /model_info, the settings page
@@ -379,7 +388,9 @@ class App {
379
388
  // to the window (a command can run for minutes). Nothing goes on with an old copy.
380
389
  client.refresh = () => {
381
390
  syncSettings()
382
- client.startMs = 1000 * (Number(this.cfg.replyStart) > 0 ? Number(this.cfg.replyStart) : 60) // a reply must start within this, else the next model
391
+ const speed = speedOf(this.cfg) // the settings page's seconds (config.js)
392
+ client.startMs = 1000 * speed.replyStart // a reply must start within this, else the next model
393
+ client.idleMs = 1000 * speed.replyIdle // a reply that stops sending for this long: stalled
383
394
  if (stampOf(profilePath(client)) !== stamp) client.onUse({ provider: client.provider, model: client.model })
384
395
  }
385
396
  // What this run learned about the model, onto its file as it is now: the rest (what you set up for
@@ -609,7 +620,7 @@ class App {
609
620
  const mine = this.commands().slice(COMMANDS.length)
610
621
  const sections = [...SECTIONS]
611
622
  if (mine.length) sections.push(['your skills (type /skill:name)', mine])
612
- sections.push(['keyboard', keysHelp(this.ui.keys, this.cfg?.mouse === true)])
623
+ sections.push(['keyboard', keysHelp(this.ui.keys, this.cfg?.mouse !== false)])
613
624
  return helpText(sections)
614
625
  }
615
626
 
@@ -680,7 +691,7 @@ class App {
680
691
  const rotated = rot && rot.at > 0
681
692
  const name = rotated ? c.yellow('↻ ' + now.model) : c.info(now.model)
682
693
  const model =
683
- count === 1 ? name : cfg.session ? `${name} ${c.faint(`(${count} chosen)`)}` : `${c.muted(fitMode(cfg) ? 'orchestrated' : 'auto')} ${c.faint('(')}${name}${c.faint(')')} ${c.faint(`(${count})`)}`
694
+ count === 1 ? name : cfg.session ? `${name} ${c.faint(`(${count} chosen)`)}` : `${c.muted('auto')} ${c.faint('(')}${name}${c.faint(')')} ${c.faint(`(${count})`)}`
684
695
  const key = `${now.provider}/${now.model}`
685
696
  if (this.profileKey !== key) [this.profileKey, this.profile] = [key, this.s?.profile ?? loadProfile(this.client(now.provider, now.model))]
686
697
  const profile = this.s?.profile ?? this.profile
@@ -690,7 +701,7 @@ class App {
690
701
  provider: `${c.brand('●')} ${c.muted(now.provider)} ${c.faint(`(${on})`)}`,
691
702
  model,
692
703
  mode: strat ? c.muted(strat.actions === 'tools' ? 'tools' : 'guided') : c.dim('not loaded yet'),
693
- thinking: strat?.thinking ? c.think(`thinking${cfg.effort ? ` · ${cfg.effort}` : ''}`) + (ui.showThinking ? '' : c.faint(' (collapsed)')) : null,
704
+ thinking: strat?.thinking ? c.think(`thinking · ${effortOf(cfg)}`) + (ui.showThinking ? c.faint(' (all)') : '') : null,
694
705
  images: strat?.vision ? c.muted('images') : null,
695
706
  ctx: null,
696
707
  tps: null,
@@ -779,8 +790,6 @@ class App {
779
790
  Object.assign(this.s, { noFormat: cfg.format === false, noLsp: cfg.lsp === false })
780
791
  Object.assign(this.s, { mcp: this.mcp, memory: this.memory, skills: this.skills, director: this.director })
781
792
  this.s.team = () => this.team() // your other models: a job this one can't do goes to one of them
782
- this.s.fitMode = () => fitMode(this.cfg) // an orchestrator hands each message's work out, not your list's order
783
- this.s.orchestrators = () => this.orchestrators()
784
793
  this.s.engineFor = (t) => this.engine(t.provider, t.model, ui, undefined, { quiet: true })
785
794
  // A model's context window, read from its saved profile (no probe, no network): so the agent can
786
795
  // see, before compacting, whether another model in the list has room for the whole conversation.
@@ -793,8 +802,6 @@ class App {
793
802
  return 0
794
803
  }
795
804
  }
796
- this.s.failures = this.failures
797
- this.s.resting = this.resting
798
805
  if (this.allowTools?.length) this.s.allowTools = toolNames(this.allowTools) // headless --allowedTools
799
806
  if (this.denyTools?.length) this.s.denyTools = toolNames(this.denyTools)
800
807
  if (this.cfg.maxTurns) this.s.maxTurns = this.cfg.maxTurns
@@ -811,7 +818,6 @@ class App {
811
818
  .filter((t) => cfg.providers[t.provider] && t.model && !seen.has(`${t.provider}/${t.model}`) && seen.add(`${t.provider}/${t.model}`))
812
819
  .map((t) => ({ ...t, baseUrl: cfg.providers[t.provider].baseUrl, apiKey: cfg.providers[t.provider].apiKey }))
813
820
  this.s?.client.setRotation(list, cfg.rotation ?? {})
814
- if (fitMode(cfg)) this.s?.client.orderBy(this.orchestrators().map((t) => `${t.provider} ${t.model}`)) // the first orchestrator answers first (and the status bar shows it)
815
821
  }
816
822
 
817
823
  async use(name, model) {
@@ -822,27 +828,17 @@ class App {
822
828
  await this.session()
823
829
  }
824
830
 
825
- // Your other models (not the one in use) and what each can do, from its saved profile or
826
- // models.dev: nothing is sent to them to find out.
831
+ // Your other models (not the one in use), in your order, and what each can do, from its saved
832
+ // profile or models.dev: nothing is sent to them to find out.
827
833
  team() {
828
834
  // helpers use this session's models (the set you chose, else your list), minus the one in use —
829
- // so a pinned single model gives no team, and a chosen set keeps helpers within it. While one
830
- // orchestrates: minus the orchestrators too (they only hand work out)
835
+ // so a pinned single model gives no team, and a chosen set keeps helpers within it
831
836
  const now = this.s?.client.rotation?.list[this.s.client.rotation.at] ?? this.sessionModels()[0]
832
- const lead = this.s?.orchestrating ? this.orchestrators() : []
833
837
  return this.sessionModels()
834
- .filter((t) => ![now, ...lead].some((o) => t.provider === o?.provider && t.model === o?.model))
838
+ .filter((t) => !(t.provider === now?.provider && t.model === now?.model))
835
839
  .map((t) => ({ ...t, ...this.abilities(t) }))
836
840
  }
837
841
 
838
- // The models that orchestrate (Pick: "an orchestrator hands it out"): those picked on Your models
839
- // that are in this session's set and call tools; none picked: your first that calls tools.
840
- orchestrators() {
841
- const mine = this.sessionModels().filter((t) => this.abilities(t).tools)
842
- const picked = mine.filter((t) => (this.cfg.orchestrators ?? []).some((o) => o.provider === t.provider && o.model === t.model))
843
- return picked.length ? picked : mine.slice(0, 1)
844
- }
845
-
846
842
  // What a model can do, from its saved profile or models.dev (guessed: neither knows it).
847
843
  abilities(t) {
848
844
  const cl = this.client(t.provider, t.model)
@@ -872,7 +868,7 @@ class App {
872
868
  const rot = this.s?.client.rotation
873
869
  if (rot) return rot.list[rot.at]
874
870
  if (this.s) return { provider: this.s.client.provider, model: this.s.client.model }
875
- return (fitMode(cfg) ? this.orchestrators()[0] : null) ?? this.sessionModels()[0] ?? null
871
+ return this.sessionModels()[0] ?? null
876
872
  }
877
873
 
878
874
  // your list has models, but the providers of all of them are switched off
@@ -1148,7 +1144,7 @@ function saveTabs(tabs) {
1148
1144
  // last session here.
1149
1145
  async function continueTabs(app, saved) {
1150
1146
  const { ui, tabs } = app
1151
- let open = (saved?.tabs ?? []).map((t, i) => ({ ...t, i, chat: loadChat(t.chat) })).filter((t) => t.chat?.turns?.length && (!t.worktree || fs.existsSync(t.chat.root)))
1147
+ let open = (saved?.tabs ?? []).map((t, i) => ({ ...t, i, chat: loadChat(t.chat, app.root) })).filter((t) => t.chat?.turns?.length && (!t.worktree || fs.existsSync(t.chat.root)))
1152
1148
  if (!saved) open = listChats(app.root).filter((c) => c.turns?.length).slice(0, 1).map((chat) => ({ chat, worktree: null }))
1153
1149
  if (!open.length) return
1154
1150
  const many = open.length > 1
@@ -1190,9 +1186,9 @@ let settingsPage = null
1190
1186
 
1191
1187
  // The browser, with a page. Windows: its URL handler (cmd's start mangles a URL whose arguments
1192
1188
  // it reads as its own, and wants a quoted empty title first).
1193
- // How HeartCode picks your models: "fit" (an orchestrator hands the work out) or your order; --model-choice for this run wins.
1194
- let modelChoiceFlag
1195
- const fitMode = (cfg) => (modelChoiceFlag ?? cfg.modelChoice) === 'fit'
1189
+ // The thinking effort asked of a model that thinks: yours, or low when you haven't chosen (many think
1190
+ // only when asked: then they think a little, and you see it)
1191
+ const effortOf = (cfg) => cfg.effort ?? 'low'
1196
1192
 
1197
1193
  function openBrowser(url) {
1198
1194
  if (process.env.HEART_NO_BROWSER) return
@@ -1214,7 +1210,7 @@ function applySettings(apps, cfg, what) {
1214
1210
  const { ui } = app
1215
1211
  const busy = Boolean(ui.busySince || app.working)
1216
1212
  const now = (fn) => (busy ? app.later.push(fn) : fn())
1217
- if (app.cfg !== cfg) for (const k of ['providers', 'provider', 'model', 'effort', 'theme', 'context', 'autoCompact', 'director', 'format', 'lsp', 'voice', 'rotation', 'statusBar', 'modelChoice', 'orchestrators']) app.cfg[k] = cfg[k]
1213
+ 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]
1218
1214
  // a model pinned in this CLI (/select_model) is a session choice: a model/order change on the
1219
1215
  // settings page leaves it alone (only /select_model auto here returns it to the list)
1220
1216
  if (what === 'model' && !app.cfg.session) {
@@ -1222,8 +1218,8 @@ function applySettings(apps, cfg, what) {
1222
1218
  if (app.s && !(cfg.providers[cfg.provider] && cfg.model)) now(() => ((app.s = null), ui.print(c.dim('settings: no model chosen'))))
1223
1219
  else if (app.s && !app.myModels().length) now(() => ((app.s = null), ui.print(c.dim('settings: the providers of all your models are switched off'))))
1224
1220
  }
1225
- // your model list: into the running session now, its next request goes to the new #1 (or orchestrator)
1226
- if (['model', 'setting:rotation', 'setting:modelChoice', 'setting:orchestrators'].includes(what) && !app.cfg.session && app.s && cfg.providers[cfg.provider] && cfg.model) {
1221
+ // your model list: into the running session now, its next request goes to the new #1
1222
+ if (['model', 'setting:rotation'].includes(what) && !app.cfg.session && app.s && cfg.providers[cfg.provider] && cfg.model) {
1227
1223
  const was = `${app.s.client.provider} · ${app.s.client.model}`
1228
1224
  app.useRotation()
1229
1225
  const is = `${app.s.client.provider} · ${app.s.client.model}`
@@ -1231,8 +1227,9 @@ function applySettings(apps, cfg, what) {
1231
1227
  }
1232
1228
  if (what === 'provider') app.lists = {} // its list switched on or off, a model added by name
1233
1229
  if (what === 'setting:permissions') ui.setPermission(cfg.permissions)
1230
+ if (what === 'setting:mouse') ui.setMouse(cfg.mouse !== false)
1234
1231
  if (what === 'setting:statusBar') ui.render?.() // the status bar's layout changed: redraw it now
1235
- if (what === 'setting:effort' && app.s?.strat.thinking) app.s.client.effort = cfg.effort
1232
+ if (what === 'setting:effort' && app.s?.strat.thinking) app.s.client.effort = effortOf(cfg)
1236
1233
  if (what === 'setting:autoCompact' && app.s) app.s.autoCompact = cfg.autoCompact !== false
1237
1234
  if (what === 'setting:format' && app.s) app.s.noFormat = cfg.format === false
1238
1235
  if (what === 'setting:lsp' && app.s) app.s.noLsp = cfg.lsp === false
@@ -1696,7 +1693,9 @@ async function slash(app, line, working = false) {
1696
1693
  }
1697
1694
  case 'toggle_thinking':
1698
1695
  ui.showThinking = !ui.showThinking
1699
- return ui.print(c.dim(`thinking ${ui.showThinking ? 'shown' : 'collapsed'}`))
1696
+ ui.print(c.dim(ui.showThinking ? 'thinking: all of it, as it comes (Alt+O: its last two lines)' : 'thinking: its last two lines while it thinks (Alt+O: all of it)'))
1697
+ if (ui.showThinking && !ui.thinkTail) ui.showLastThought() // the one just over: all of it now
1698
+ return
1700
1699
  }
1701
1700
  if (!['model_info', 'compact'].includes(cmd)) {
1702
1701
  app.skills = loadSkills(app.root) // edits to skill files apply right away
@@ -1751,7 +1750,7 @@ async function runTask(app, task, ctl) {
1751
1750
 
1752
1751
  async function repl(app, f = {}) {
1753
1752
  const { ui, cfg } = app
1754
- ui.fullscreen({ mouse: cfg.mouse === true }) // off: the terminal selects and copies text itself
1753
+ ui.fullscreen({ mouse: cfg.mouse !== false }) // HeartCode's wheel and selection ("mouse": false: the terminal's own: then its wheel scrolls the whole screen)
1755
1754
  ui.onDoubleEscape = () => '/rewind'
1756
1755
  let ctl = null
1757
1756
  ui.onEscape = () => ctl?.abort()
@@ -1819,7 +1818,7 @@ async function repl(app, f = {}) {
1819
1818
  return ui.clearInput()
1820
1819
  }
1821
1820
  if (again) return quit() // the second within 2s (also when the first stopped the work)
1822
- ui.notice(others() ? `Press Ctrl+C again to quit HeartCode (all ${others() + 1} tabs; Ctrl+Q closes just this one)` : 'Press Ctrl+C again to quit', 2000)
1821
+ ui.notice(others() ? `Press Ctrl+C again to quit HeartCode (all ${others() + 1} tabs; Alt+W closes just this one)` : 'Press Ctrl+C again to quit', 2000)
1823
1822
  }
1824
1823
  // Pinned to the top of the screen; /clear_chat and scrolling leave it alone.
1825
1824
  const home = process.env.HOME
@@ -1837,7 +1836,7 @@ async function repl(app, f = {}) {
1837
1836
  if (last) await app.resume(last)
1838
1837
  else ui.print(c.dim('No earlier session in this folder to continue.'))
1839
1838
  }
1840
- if (f['resume-id']) await app.resume(loadChat(f['resume-id']))
1839
+ if (f['resume-id']) await app.resume(loadChat(f['resume-id'], app.root))
1841
1840
  else if (f.resume) await app.resume()
1842
1841
  if (f.model) useModel(app, f.model) // a continued tab's own model
1843
1842
  // models this folder picked earlier (/select_model): said, with the way back to your whole list
@@ -1903,6 +1902,10 @@ async function repl(app, f = {}) {
1903
1902
  }
1904
1903
 
1905
1904
  async function main() {
1905
+ // "heartcode page <file|url>": a web page checked in a browser (src/check.js). Only that: a prompt
1906
+ // that starts with "page" ("page fix the footer") is a prompt
1907
+ const target = process.argv[3]
1908
+ 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))
1906
1909
  // "--resume <id>" (as in Claude Code) vs a bare "--resume" (pick one): an id follows it
1907
1910
  const argv = process.argv.slice(2)
1908
1911
  const print = argv.includes('-p') || argv.includes('--print') // headless: an id after --resume is always an id
@@ -1942,7 +1945,6 @@ async function main() {
1942
1945
  disallowedTools: { type: 'string', multiple: true },
1943
1946
  'disallowed-tools': { type: 'string', multiple: true },
1944
1947
  'permission-mode': { type: 'string' },
1945
- 'model-choice': { type: 'string' },
1946
1948
  'dangerously-skip-permissions': { type: 'boolean' },
1947
1949
  'session-id': { type: 'string' },
1948
1950
  effort: { type: 'string' },
@@ -1952,10 +1954,10 @@ async function main() {
1952
1954
  'max-turns': { type: 'string' },
1953
1955
  all: { type: 'boolean' }, // heart models --all
1954
1956
  json: { type: 'boolean' }, // heart models --json
1957
+ 'include-partial-messages': { type: 'boolean' }, // stream-json: the replies as they come (thinking too)
1955
1958
  // accepted for drop-in use where Claude Code is expected; nothing to do in HeartCode
1956
1959
  autocompact: { type: 'string' },
1957
1960
  'exclude-dynamic-system-prompt-sections': { type: 'boolean' },
1958
- 'include-partial-messages': { type: 'boolean' },
1959
1961
  help: { type: 'boolean', short: 'h' },
1960
1962
  version: { type: 'boolean', short: 'v' },
1961
1963
  },
@@ -1965,8 +1967,6 @@ async function main() {
1965
1967
  if (f.context && !(Number(f.context) > 0)) throw new Error('--context must be a number of tokens')
1966
1968
  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`)
1967
1969
  if (f['permission-mode'] && !PERMISSION_MODES[f['permission-mode']]) throw new Error(`--permission-mode must be one of ${Object.keys(PERMISSION_MODES).join(', ')}`)
1968
- if (f['model-choice'] && !['order', 'fit'].includes(f['model-choice'])) throw new Error('--model-choice must be order or fit')
1969
- modelChoiceFlag = f['model-choice']
1970
1970
 
1971
1971
  const cfg = loadConfig({ baseUrl: f['base-url'], model: f.model, apiKey: f['api-key'], context: f.context })
1972
1972
  setTheme(cfg.theme)
@@ -2035,7 +2035,7 @@ async function main() {
2035
2035
  saveConfig(cfg)
2036
2036
  }
2037
2037
  }
2038
- ui.showThinking = !f['hide-thinking']
2038
+ ui.showThinking = false // the thinking's last two lines while it thinks; Alt+O shows all of it (--hide-thinking: the same)
2039
2039
  const app = new App(cfg, ui, root)
2040
2040
  usePromptsFrom(app.root) // its .heartcode/prompts override the built-in sections
2041
2041
  ui.suggest = (line, cursor) => app.suggest(line, cursor)
@@ -2052,7 +2052,7 @@ async function main() {
2052
2052
  }
2053
2053
  // The full screen: in tabs (the first one is this folder; /tab and Alt+T open more).
2054
2054
  if (!headless && !sub && !positionals.length && process.stdin.isTTY && process.stdout.isTTY) {
2055
- if (f['resume-id'] && !loadChat(f['resume-id'])) throw new Error(`no session ${f['resume-id']}`)
2055
+ if (f['resume-id'] && !loadChat(f['resume-id'], root)) throw new Error(`no session ${f['resume-id']}`)
2056
2056
  const saved = readJson(TABS_FILE, {})[root] // before this run's first tab replaces it
2057
2057
  const asked = f.continue || f.resume || f['resume-id'] || f['session-id'] // a session was chosen already
2058
2058
  const tabs = new Tabs((tab, o) => {
@@ -2062,7 +2062,7 @@ async function main() {
2062
2062
  Object.assign(app, { tabs, tab, worktree: o.wt ?? null })
2063
2063
  if (o.first) {
2064
2064
  if (f['no-memory']) app.memory = null
2065
- if (f['session-id']) app.setChat(loadChat(f['session-id']) ?? { ...newChat(app.root), id: f['session-id'] })
2065
+ if (f['session-id']) app.setChat(loadChat(f['session-id'], app.root) ?? { ...newChat(app.root), id: f['session-id'] })
2066
2066
  }
2067
2067
  return (async () => {
2068
2068
  await repl(app, o.first ? { ...f, onStart: !asked && ((a) => continueTabs(a, saved)) } : o.chat ? { 'resume-id': o.chat.id, model: o.model } : {})
@@ -2090,14 +2090,14 @@ async function main() {
2090
2090
  if (sub === 'providers') return app.listProviders(), ui.close()
2091
2091
  if (sub === 'models') return await app.listModels(positionals[1] ?? '', { all: f.all, json: f.json }), ui.close()
2092
2092
  if (f['no-memory']) app.memory = null
2093
- const chat = f['resume-id'] ? loadChat(f['resume-id']) : f.continue && headless ? listChats(app.root)[0] : f['session-id'] ? (loadChat(f['session-id']) ?? { ...newChat(app.root), id: f['session-id'] }) : null
2093
+ const chat = f['resume-id'] ? loadChat(f['resume-id'], app.root) : f.continue && headless ? listChats(app.root)[0] : f['session-id'] ? (loadChat(f['session-id'], app.root) ?? { ...newChat(app.root), id: f['session-id'] }) : null
2094
2094
  if (f['resume-id'] && !chat) throw new Error(`no session ${f['resume-id']}`)
2095
2095
  if (chat && (headless || !f['resume-id'])) app.setChat(chat) // interactive: resumed below, with its transcript
2096
2096
  if (headless || positionals.length) watchSettings(() => [app], cfg) // an app's run takes the settings page's changes too
2097
2097
  if (headless) {
2098
2098
  app.allowTools = [...(f.allowedTools ?? []), ...(f['allowed-tools'] ?? [])]
2099
2099
  app.denyTools = [...(f.disallowedTools ?? []), ...(f['disallowed-tools'] ?? [])]
2100
- const code = await runHeadless(app, { prompt: positionals.join(' '), input: f['input-format'], output: f['output-format'], appendSystem: f['append-system-prompt'] })
2100
+ const code = await runHeadless(app, { prompt: positionals.join(' '), input: f['input-format'], output: f['output-format'], appendSystem: f['append-system-prompt'], partial: f['include-partial-messages'] })
2101
2101
  if (wt && worktreeState(wt).empty) removeWorktree(wt) // else kept, for the caller to merge (its path is in the log)
2102
2102
  process.exit(code) // MCP servers are stopped by the exit hooks
2103
2103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartcode",
3
- "version": "0.1.45",
3
+ "version": "0.1.54",
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",
@@ -34,7 +34,7 @@
34
34
  "heartcode": "bin/heart.js"
35
35
  },
36
36
  "engines": {
37
- "node": ">=20"
37
+ "node": ">=22"
38
38
  },
39
39
  "scripts": {
40
40
  "start": "node scripts/install.js"
package/prompts/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Prompts
2
2
 
3
- Everything HeartCode sends to a model, in four files. Each `## name` heading is one prompt.
3
+ Everything HeartCode sends to a model, in these files. Each `## name` heading is one prompt.
4
4
 
5
5
  | file | used for |
6
6
  |---|---|