heartcode 0.1.59 → 0.1.62
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 +70 -0
- package/README.md +35 -15
- package/SKILL.md +2 -1
- package/bin/heart.js +1 -1
- package/bin/heartcode.js +86 -58
- package/package.json +1 -1
- package/prompts/agent.md +97 -15
- package/src/acp.js +3 -3
- package/src/agent.js +191 -25
- package/src/background.js +2 -8
- package/src/capabilities.js +2 -2
- package/src/check.js +69 -4
- package/src/client.js +37 -12
- package/src/config.js +30 -1
- package/src/context.js +1 -1
- package/src/format.js +5 -3
- package/src/headless.js +3 -2
- package/src/http.js +96 -0
- package/src/importer.js +8 -7
- package/src/log.js +2 -2
- package/src/lsp.js +3 -6
- package/src/mcp.js +5 -7
- package/src/memory.js +1 -1
- package/src/oauth.js +2 -1
- package/src/probe.js +14 -4
- package/src/rankings.js +7 -0
- package/src/reset.js +2 -2
- package/src/sessions.js +2 -2
- package/src/settings.html +236 -178
- package/src/settings.js +51 -24
- package/src/spawn.js +48 -0
- package/src/telegram.js +2 -1
- package/src/tools.js +274 -29
- package/src/tree.js +1 -1
- package/src/ui.js +66 -27
- package/src/update.js +1 -0
- package/src/usage.js +10 -0
- package/src/voice.js +21 -7
- package/src/web.js +2 -1
package/bin/heartcode.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Client, limitSaid, estMessages } from '../src/client.js'
|
|
|
5
5
|
import { loadConfig, saveConfig, readJson, writeJson, providerName, CONFIG_FILE, HOME, TEMP, AUTO_MODEL, isAuto, parseModel, takeIn, whatOf, VERSION, speedOf, jobsOf } from '../src/config.js'
|
|
6
6
|
import { loadProfile, strategy, describe, profilePath, profileFrom } from '../src/probe.js'
|
|
7
7
|
import { learnFromUsage, LIMIT_MS, RATE_CAP_MS } from '../src/context.js'
|
|
8
|
+
import { loadRankings, scoreOf } from '../src/rankings.js'
|
|
8
9
|
import { Session, transcript, contextReport } from '../src/agent.js'
|
|
9
10
|
import { listJobs, getJob, stopJob, removeJob, runningJobs, tailLines, ago as ranFor } from '../src/background.js'
|
|
10
11
|
import { checkUpdate, installKind, UPDATE_COMMANDS, packageDir, whatsNew } from '../src/update.js'
|
|
@@ -42,24 +43,24 @@ ${c.bold('usage')}
|
|
|
42
43
|
heart ~/code/my-app in that folder (a folder, not a file)
|
|
43
44
|
heart "fix the failing test" run one task and exit
|
|
44
45
|
heart providers list added providers
|
|
45
|
-
heart models [filter] what -m takes, one per line: "auto" (
|
|
46
|
+
heart models [filter] what -m takes, one per line: "auto" (the list), then each model
|
|
46
47
|
as provider/model, #1 first
|
|
47
|
-
heart models --all [filter] every provider's models (provider/model)
|
|
48
|
+
heart models --all [filter] every switched-on provider's models (provider/model)
|
|
48
49
|
heart models --json as JSON (with --all too), for other programs
|
|
49
50
|
heart config show the config file
|
|
50
|
-
heart settings change providers, models and settings in
|
|
51
|
+
heart settings change providers, models and settings in the browser
|
|
51
52
|
|
|
52
53
|
${c.bold('options')}
|
|
53
54
|
-u, --base-url <url> use this server for this run (add --save to keep it)
|
|
54
55
|
-m, --model <name> this model alone for this run (provider/model, or a model of #1's provider);
|
|
55
|
-
"auto" (the default):
|
|
56
|
+
"auto" (the default): the list, #1 then the next when one fails
|
|
56
57
|
--fallback-model <name> after -m's model when it fails (repeatable)
|
|
57
58
|
--api-key <key> API key for --base-url
|
|
58
59
|
-y, --yes do everything without asking (the default; through --acp, an editor: ask)
|
|
59
60
|
--ask ask before every edit and command, this run
|
|
60
61
|
--hide-thinking the model's thinking: only its last two lines while it thinks (the default; Alt+O shows all of it)
|
|
61
62
|
-C, --cwd <dir> project folder (default: current folder)
|
|
62
|
-
--temp keep nothing: a throwaway settings folder (
|
|
63
|
+
--temp keep nothing: a throwaway settings folder (providers, model info,
|
|
63
64
|
prices and notes copied in), shared by the --temp runs going on at once
|
|
64
65
|
and deleted after the last, with its logs; ~/.heart and the project's
|
|
65
66
|
.heartcode/ aren't touched (their notes and research are read from a copy)
|
|
@@ -101,16 +102,17 @@ ${c.bold('in a session')} attach an image with @path/to/shot.png · /help for c
|
|
|
101
102
|
// [name, description, takes an argument], by section. /help and the "/" menu are built from it.
|
|
102
103
|
const SECTIONS = [
|
|
103
104
|
['providers and models', [
|
|
104
|
-
['/select_model', 'pick the model(s) for this session: one pins it, several rotate among them, auto =
|
|
105
|
+
['/select_model', 'pick the model(s) for this session: one pins it, several rotate among them, auto = the whole list', true],
|
|
105
106
|
]],
|
|
106
107
|
['settings', [
|
|
107
108
|
['/toggle_thinking', "the model's thinking: its last two lines, or all of it (Alt+O)"],
|
|
108
|
-
['/
|
|
109
|
+
['/todos', 'the whole plan of the task at work, every step and its state (Alt+L)'],
|
|
110
|
+
['/voice', 'dictate a message (or Space in an empty box, once voice is set up): it shows in the box while speaking, Enter sends it, Esc cancels'],
|
|
109
111
|
]],
|
|
110
112
|
['session', [
|
|
111
113
|
['/resume', 'continue an earlier session in this folder'],
|
|
112
114
|
['/rewind', 'go back to an earlier message: conversation, code or both (Esc Esc); what came after stays in /tree'],
|
|
113
|
-
['/tree', "every message on every branch of this session: go to any, the files follow, a summary of
|
|
115
|
+
['/tree', "every message on every branch of this session: go to any, the files follow, a summary of the branch left behind comes along"],
|
|
114
116
|
['/rename', 'name this session (shown in /resume)', true],
|
|
115
117
|
['/fork', 'go on in a copy of this session (the original stays in /resume)'],
|
|
116
118
|
['/export', 'save the conversation as Markdown, HTML or JSON', true],
|
|
@@ -127,12 +129,12 @@ const SECTIONS = [
|
|
|
127
129
|
['/install_skill', 'install a skill from a GitHub repo or a SKILL.md URL (add --project for this folder only)', true],
|
|
128
130
|
['/doctor', 'check the outside tools HeartCode features need (voice, browser, git) and what to install'],
|
|
129
131
|
['/update', 'install the newest HeartCode (shows what changed first)'],
|
|
130
|
-
['/mcp', '
|
|
132
|
+
['/mcp', 'the MCP servers and whether each needs signing in'],
|
|
131
133
|
['/login_mcp', 'sign in (again) to a remote MCP server', true],
|
|
132
134
|
['/compact', 'summarize the conversation to free up context (add what to keep)', true],
|
|
133
135
|
['/clear_chat', 'forget the conversation'],
|
|
134
136
|
['/reset', "HeartCode's settings (or also providers, or everything) back to the start; asks for a code first"],
|
|
135
|
-
['/settings', 'change providers, models, settings, MCP servers, hooks, keys and skills in
|
|
137
|
+
['/settings', 'change providers, models, settings, MCP servers, hooks, keys and skills in the browser'],
|
|
136
138
|
['/help', 'this list'],
|
|
137
139
|
['/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],
|
|
138
140
|
['/close_tab', 'close this tab (Alt+W); asks first'],
|
|
@@ -144,7 +146,7 @@ for (const [, list] of SECTIONS) list.sort(byName) // alphabetical, in /help and
|
|
|
144
146
|
const COMMANDS = SECTIONS.flatMap(([, list]) => list).sort(byName)
|
|
145
147
|
// Typed while a task works, these run at once, beside it: they leave the conversation alone. The
|
|
146
148
|
// others (/compact, /rewind, /resume, /init…) wait in the queue until it's done.
|
|
147
|
-
const RIGHT_AWAY = new Set(['help', 'cost', 'context', 'background', 'model_info', 'diff', 'copy', 'mcp', 'doctor', 'toggle_thinking', 'btw', 'rename', 'export', 'tab', 'close_tab', 'exit', 'quit', 'settings', 'login_mcp', 'install_skill', 'import', 'voice', 'select_model'])
|
|
149
|
+
const RIGHT_AWAY = new Set(['help', 'todos', 'cost', 'context', 'background', 'model_info', 'diff', 'copy', 'mcp', 'doctor', 'toggle_thinking', 'btw', 'rename', 'export', 'tab', 'close_tab', 'exit', 'quit', 'settings', 'login_mcp', 'install_skill', 'import', 'voice', 'select_model'])
|
|
148
150
|
const helpText = (sections) => sections.map(([title, list]) => ` ${c.bold(title)}\n` + list.map(([n, d]) => ` ${c.cyan(n.padEnd(17))} ${d}`).join('\n')).join('\n\n')
|
|
149
151
|
const SLASH = helpText(SECTIONS)
|
|
150
152
|
|
|
@@ -154,13 +156,14 @@ function keysHelp(keys = {}, mouse = false, voice = false) {
|
|
|
154
156
|
const forAct = (a) => Object.entries(keys).filter(([, v]) => v === a).map(([k]) => prettyKey(k)).join(' / ')
|
|
155
157
|
const tabs = Object.values(keys).some((v) => /^tab_[1-9]$/.test(v))
|
|
156
158
|
const rows = [
|
|
157
|
-
[voice ? 'Space' : '', 'voice: listens at once, Enter sends what
|
|
159
|
+
[voice ? 'Space' : '', 'voice: listens at once, Enter sends what was said (in an empty box)'],
|
|
158
160
|
['Enter', 'send · while it works, queue the message (commands like /help, /cost, /select_model run at once)'],
|
|
159
161
|
['Option+Enter or Shift+Enter', 'new line in the box (also while it works)'],
|
|
160
162
|
['Esc', 'while it works: queued messages back into the box, then clears the box, then stops the task (twice)'],
|
|
161
163
|
['Esc Esc', 'rewind to an earlier message (at the prompt)'],
|
|
162
164
|
['Shift+Tab', 'change what runs without asking (permissions)'],
|
|
163
165
|
[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"],
|
|
166
|
+
[forAct('show_plan'), 'the whole plan in a box (only three of its steps show while it works)'],
|
|
164
167
|
[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
168
|
[forAct('new_tab'), 'new tab'],
|
|
166
169
|
[forAct('close_tab'), 'close this tab'],
|
|
@@ -182,13 +185,13 @@ function keysHelp(keys = {}, mouse = false, voice = false) {
|
|
|
182
185
|
return rows
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
const HOWTO = `${c.yellow('No model set up yet.')} Add a provider and choose its models in
|
|
188
|
+
const HOWTO = `${c.yellow('No model set up yet.')} Add a provider and choose its models in the browser:
|
|
186
189
|
|
|
187
190
|
${c.cyan('/settings')} (or ${c.cyan('heart settings')} in another terminal)
|
|
188
191
|
|
|
189
192
|
${c.dim('Ollama, LM Studio or llama.cpp running on this machine is found on its own.')}`
|
|
190
193
|
const NO_MODELS = `${c.yellow('No model chosen yet.')} Choose one on ${c.cyan('/settings')}: a provider's models, click one.`
|
|
191
|
-
const ALL_OFF = `${c.yellow('The providers of all
|
|
194
|
+
const ALL_OFF = `${c.yellow('The providers of all the models are switched off.')} Switch one on on ${c.cyan('/settings')}, or add a model of one that's on.`
|
|
192
195
|
|
|
193
196
|
// Choices for commands that take one (also offered in the "/" menu).
|
|
194
197
|
const ARGS = {
|
|
@@ -248,10 +251,10 @@ class App {
|
|
|
248
251
|
// a remote server asks to sign in: its page opens in the browser (and the link is shown)
|
|
249
252
|
if (!this.ui.noUser)
|
|
250
253
|
mcp.onSignIn = (name, url) => {
|
|
251
|
-
this.ui.print(`${c.info('↗')} ${c.bold(name)} ${c.muted('needs
|
|
254
|
+
this.ui.print(`${c.info('↗')} ${c.bold(name)} ${c.muted('needs a sign-in; opening the browser…')}\n ${c.faint(url)}`)
|
|
252
255
|
const [cmd, ...args] = process.platform === 'darwin' ? ['open', url] : process.platform === 'win32' ? ['rundll32', 'url.dll,FileProtocolHandler', url] : ['xdg-open', url]
|
|
253
256
|
spawnSync(cmd, args, { stdio: 'ignore' })
|
|
254
|
-
this.ui.spinner(`waiting for
|
|
257
|
+
this.ui.spinner(`waiting for the sign-in to ${name} in the browser · Esc twice to stop`)
|
|
255
258
|
}
|
|
256
259
|
return mcp
|
|
257
260
|
}
|
|
@@ -370,7 +373,7 @@ class App {
|
|
|
370
373
|
const from = failed?.t
|
|
371
374
|
const why = f ? `${failed.t.model} ${f.status === 429 ? 'rate-limited (429)' : `failed (${clip(shortError(f), 50)})`} → ` : ''
|
|
372
375
|
failed = null
|
|
373
|
-
switched = c.dim(`↻ ${why}${t.provider} · ${t.model} answered${i ? ` (#${i + 1} in
|
|
376
|
+
switched = c.dim(`↻ ${why}${t.provider} · ${t.model} answered${i ? ` (#${i + 1} in the model list)` : ' (#1 again)'}`)
|
|
374
377
|
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 })
|
|
375
378
|
setImmediate(client.announceSwitch)
|
|
376
379
|
}
|
|
@@ -555,7 +558,7 @@ class App {
|
|
|
555
558
|
// leave is kept, the files can follow, and a summary of what you leave can come along.
|
|
556
559
|
async tree() {
|
|
557
560
|
const { ui, chat } = this
|
|
558
|
-
if (!chat.turns.length && !chat.branches?.length) return ui.print('Nothing here yet: the tree grows as
|
|
561
|
+
if (!chat.turns.length && !chat.branches?.length) return ui.print('Nothing here yet: the tree grows as messages are sent and rewound (/rewind, /tree).')
|
|
559
562
|
chat.log = ui.log
|
|
560
563
|
const n = (chat.branches?.length ?? 0) + 1
|
|
561
564
|
const it = await ui.pick(`This session${n > 1 ? `, ${n} branches` : ''} · pick a message`, treeItems(chat, ago))
|
|
@@ -580,7 +583,7 @@ class App {
|
|
|
580
583
|
}
|
|
581
584
|
let summarize = false
|
|
582
585
|
if (leaving(chat, it.branch, go.keep) && (this.s || this.cfg.providers[this.cfg.provider])) {
|
|
583
|
-
const a = await ui.pick('Bring a summary of the messages
|
|
586
|
+
const a = await ui.pick('Bring a summary of the messages left behind?', [
|
|
584
587
|
{ label: 'Yes', desc: 'one request to the model, so this branch knows what was tried there', yes: true },
|
|
585
588
|
{ label: 'No', desc: 'they stay in the tree, the model just won\'t know about them' },
|
|
586
589
|
])
|
|
@@ -594,13 +597,13 @@ class App {
|
|
|
594
597
|
if (summarize) {
|
|
595
598
|
const s = await this.session()
|
|
596
599
|
if (s) {
|
|
597
|
-
ui.spinner('summarizing the branch
|
|
600
|
+
ui.spinner('summarizing the branch left behind')
|
|
598
601
|
try {
|
|
599
602
|
const changedThere = leftFiles(left)
|
|
600
603
|
const summary = await s.summarizeBranch(leftText(left, transcript), changedThere, this.signal)
|
|
601
604
|
chat.branchNote = prompt('compact/branch-note', { summary, files: changedThere.join(', '), kept: changedThere.length && !code, restored: changedThere.length && code })
|
|
602
605
|
ui.stopSpin()
|
|
603
|
-
ui.print(`${c.faint('✻')} ${c.muted(`summary of the branch
|
|
606
|
+
ui.print(`${c.faint('✻')} ${c.muted(`summary of the branch left behind (goes with the next message): ${clip(summary.split('\n').find((l) => l.trim()) ?? '', 120)}`)}`)
|
|
604
607
|
} catch (e) {
|
|
605
608
|
ui.stopSpin()
|
|
606
609
|
if (e.name === 'AbortError') throw e
|
|
@@ -608,7 +611,7 @@ class App {
|
|
|
608
611
|
}
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
|
-
ui.print(c.dim(`${go.edit ? 'edit the message and send it: a new branch' : 'here now'} · the branch
|
|
614
|
+
ui.print(c.dim(`${go.edit ? 'edit the message and send it: a new branch' : 'here now'} · the branch left behind stays in /tree`))
|
|
612
615
|
if (go.edit) this.nextInput = it.task
|
|
613
616
|
if (this.s) this.s.client.lastTokens = 0
|
|
614
617
|
this.save()
|
|
@@ -634,7 +637,7 @@ class App {
|
|
|
634
637
|
help() {
|
|
635
638
|
const mine = this.commands().slice(COMMANDS.length)
|
|
636
639
|
const sections = [...SECTIONS]
|
|
637
|
-
if (mine.length) sections.push(['
|
|
640
|
+
if (mine.length) sections.push(['skills (type /skill:name)', mine])
|
|
638
641
|
sections.push(['keyboard', keysHelp(this.ui.keys, this.cfg?.mouse !== false, Boolean(this.ui.voiceReady?.()))])
|
|
639
642
|
return helpText(sections)
|
|
640
643
|
}
|
|
@@ -699,7 +702,7 @@ class App {
|
|
|
699
702
|
if (!cfg.providers[cfg.provider] || !cfg.model) return c.dim('no model · /settings to choose one')
|
|
700
703
|
const rot = this.s?.client.rotation
|
|
701
704
|
const now = this.inUse() // the model list's one in use; never one of a provider that's off
|
|
702
|
-
if (!now) return c.dim('the providers of all
|
|
705
|
+
if (!now) return c.dim('the providers of all the models are off · /settings to switch one on')
|
|
703
706
|
const count = this.sessionModels().length
|
|
704
707
|
// the model answering now; a yellow "↻" before it when it's a fallback (rotated to after one failed)
|
|
705
708
|
const rotated = rot && rot.at > 0
|
|
@@ -714,7 +717,7 @@ class App {
|
|
|
714
717
|
const parts = {
|
|
715
718
|
provider: `${c.brand('●')} ${c.muted(now.provider)}`,
|
|
716
719
|
model,
|
|
717
|
-
mode: strat ? (strat.actions === 'tools' ? null : c.muted('no tool calls (guided)')) : c.faint('checked at
|
|
720
|
+
mode: strat ? (strat.actions === 'tools' ? null : c.muted('no tool calls (guided)')) : c.faint('checked at the first message'), // what it can do: known once it's been asked
|
|
718
721
|
thinking: strat?.thinking ? c.think(`thinking · ${effortOf(cfg)}`) + (ui.showThinking ? c.faint(' (all)') : '') : null,
|
|
719
722
|
images: strat?.vision ? c.muted('images') : null,
|
|
720
723
|
ctx: null,
|
|
@@ -851,13 +854,26 @@ class App {
|
|
|
851
854
|
return this.sessionModels()
|
|
852
855
|
.filter((t) => !(t.provider === now?.provider && t.model === now?.model))
|
|
853
856
|
.map((t) => ({ ...t, ...this.abilities(t), jobs: jobsOf(this.cfg.helpers?.[`${t.provider}/${t.model}`]) })) // jobs: ticked as a helper on Your models (what for)
|
|
854
|
-
.sort(this.byProvider()) // helpers picked in your list's order,
|
|
857
|
+
.sort(this.byProvider()) // helpers picked in your list's order, your provider ranking's, or by score (Your models)
|
|
855
858
|
}
|
|
856
859
|
|
|
857
860
|
// Your models' "Helper order": by your provider ranking, a sort that puts the higher-ranked
|
|
858
861
|
// provider's models first (each provider's in your list's order; providers not ranked after, A to
|
|
859
862
|
// Z); in your list's order, one that keeps it.
|
|
863
|
+
// By score: the best placed in LMArena's rankings first (its best share of a list: #5 of 200 is 2.5%),
|
|
864
|
+
// across the lists the helpers are picked by (coding, web apps, long real tasks, hard prompts);
|
|
865
|
+
// models not in them after, in your list's order.
|
|
860
866
|
byProvider() {
|
|
867
|
+
if ((this.cfg.helperOrder ?? 'score') === 'score') { // the default: a small model early in your list isn't who looks at a screenshot
|
|
868
|
+
const data = loadRankings()
|
|
869
|
+
const share = new Map()
|
|
870
|
+
const of = (t) => {
|
|
871
|
+
const k = `${t.provider}/${t.model}`
|
|
872
|
+
if (!share.has(k)) share.set(k, scoreOf(t.model, data))
|
|
873
|
+
return share.get(k)
|
|
874
|
+
}
|
|
875
|
+
return (a, b) => (of(a) === of(b) ? 0 : of(a) < of(b) ? -1 : 1) // Infinity (not ranked) last; ties keep your order
|
|
876
|
+
}
|
|
861
877
|
const rank = this.cfg.helperOrder === 'provider' && Array.isArray(this.cfg.providerRank) ? this.cfg.providerRank : null
|
|
862
878
|
if (!rank) return () => 0
|
|
863
879
|
const at = (p) => (rank.includes(p) ? rank.indexOf(p) : rank.length)
|
|
@@ -919,13 +935,20 @@ class App {
|
|
|
919
935
|
|
|
920
936
|
// Alt+B, /background: the background commands' logs in a dialog, one at a time with a tab each.
|
|
921
937
|
// ←/→ (or a click on a tab): another one; ↑/↓, PgUp/PgDn, the wheel: back in its log (End: the
|
|
922
|
-
// newest again); K twice: stop it and close its tab; Esc or Alt+B: closed.
|
|
938
|
+
// newest again); K twice: stop it and close its tab; A: the stopped ones too; Esc or Alt+B: closed.
|
|
923
939
|
toggleJobs(on = !this.jobsShown) {
|
|
924
940
|
const { ui } = this
|
|
925
941
|
if (!on) return ui.setDialog(null)
|
|
926
942
|
this.jobsShown = true
|
|
927
943
|
const ERROR = /\b(error|errors|failed|fail|exception|traceback|panic|fatal)\b/i
|
|
928
|
-
|
|
944
|
+
// running ones only (and any that stop while it's open); A: the stopped and finished ones too
|
|
945
|
+
let showAll = false
|
|
946
|
+
const live = new Set()
|
|
947
|
+
const jobs = () => {
|
|
948
|
+
for (const j of runningJobs(this.root)) live.add(j.id) // a command's leftover that's gone counts as stopped
|
|
949
|
+
const list = listJobs(this.root)
|
|
950
|
+
return showAll ? list : list.filter((j) => live.has(j.id))
|
|
951
|
+
}
|
|
929
952
|
const current = () => jobs().find((j) => j.id === this.jobTab) ?? jobs().findLast((j) => !j.exited) ?? jobs().at(-1)
|
|
930
953
|
let spots = [] // where each tab is on its row: { from, to, id }
|
|
931
954
|
let back = 0 // lines scrolled back from the newest (0: following it)
|
|
@@ -964,6 +987,7 @@ class App {
|
|
|
964
987
|
if (key.name === 'end') return (back = 0)
|
|
965
988
|
if (key.name === 'home') return (back = 1e6)
|
|
966
989
|
if (key.name === 'k' && !key.ctrl && !key.meta) return kill()
|
|
990
|
+
if (key.name === 'a' && !key.ctrl && !key.meta) return (showAll = !showAll), (back = 0)
|
|
967
991
|
},
|
|
968
992
|
click: (col, row) => {
|
|
969
993
|
const hit = row === 0 && spots.find((t) => col >= t.from && col < t.to)
|
|
@@ -971,7 +995,8 @@ class App {
|
|
|
971
995
|
},
|
|
972
996
|
draw: (w, h) => {
|
|
973
997
|
const all = jobs()
|
|
974
|
-
|
|
998
|
+
const ended = listJobs(this.root).length - all.length // stopped or finished, not shown
|
|
999
|
+
if (!all.length) return ['', ...wrapWords('Nothing runs in the background. The model starts servers and watchers there.', w - 2).map((l) => ` ${c.faint(l.trim())}`), '', ` ${c.faint(`${ended ? `A show ${ended} stopped · ` : ''}Esc close`)}`]
|
|
975
1000
|
const job = current()
|
|
976
1001
|
this.jobTab = job.id
|
|
977
1002
|
// the tabs, scrolled so the one shown is on screen
|
|
@@ -1002,7 +1027,7 @@ class App {
|
|
|
1002
1027
|
` ${c.bold(clip(job.command, Math.max(10, w - 2 - width(` · ${state} · ${ranFor(job)}${where}`.replace(/\x1b\[[0-9;]*m/g, '')))))} ${c.faint('·')} ${state} ${c.faint(`· ${ranFor(job)}`)}${where}`, // the command, as much as the rest leaves room for
|
|
1003
1028
|
...Array.from({ length: n }, (_, i) => (shown.length ? (shown[i] === undefined ? '' : ` ${ERROR.test(shown[i]) ? c.red(shown[i]) : c.muted(shown[i])}`) : i ? '' : ` ${c.faint('(no output yet)')}`)),
|
|
1004
1029
|
c.ghost('─'.repeat(w)),
|
|
1005
|
-
` ${said ? c.yellow(said) : c.faint(`${all.length > 1 ? '←/→ another one · ' : ''}↑/↓ PgUp/PgDn scroll · K ${job.exited ? 'close' : 'stop'} it · Esc close`)}`,
|
|
1030
|
+
` ${said ? c.yellow(said) : c.faint(`${all.length > 1 ? '←/→ another one · ' : ''}↑/↓ PgUp/PgDn scroll · K ${job.exited ? 'close' : 'stop'} it · ${showAll ? 'A running only' : ended ? `A show ${ended} stopped` : ''}${showAll || ended ? ' · ' : ''}Esc close`)}`,
|
|
1006
1031
|
]
|
|
1007
1032
|
},
|
|
1008
1033
|
})
|
|
@@ -1019,7 +1044,7 @@ class App {
|
|
|
1019
1044
|
this.s = null
|
|
1020
1045
|
}
|
|
1021
1046
|
const msg = list.length === 1 ? `${c.green('using')} ${c.cyan(list[0].model)} ${c.dim('· pinned for this folder')}` : `${c.green(`using ${list.length} models for this folder`)}: ${c.cyan(list.map((t) => t.model).join(', '))}`
|
|
1022
|
-
if (later) return this.later.push(apply), this.ui.print(`${msg} ${c.dim('· from
|
|
1047
|
+
if (later) return this.later.push(apply), this.ui.print(`${msg} ${c.dim('· from the next message')}`)
|
|
1023
1048
|
apply()
|
|
1024
1049
|
this.ui.print(msg)
|
|
1025
1050
|
await this.session()
|
|
@@ -1036,7 +1061,7 @@ class App {
|
|
|
1036
1061
|
}
|
|
1037
1062
|
const n = this.myModels().length
|
|
1038
1063
|
const msg = `${c.green('using')} ${c.dim('auto')} ${c.cyan(`(${n} model${n === 1 ? '' : 's'})`)}`
|
|
1039
|
-
if (later) return this.later.push(apply), this.ui.print(`${msg} ${c.dim('· from
|
|
1064
|
+
if (later) return this.later.push(apply), this.ui.print(`${msg} ${c.dim('· from the next message')}`)
|
|
1040
1065
|
apply()
|
|
1041
1066
|
this.ui.print(msg)
|
|
1042
1067
|
await this.session()
|
|
@@ -1055,7 +1080,7 @@ class App {
|
|
|
1055
1080
|
const chosen = new Set((cfg.session ?? mine).map(key)) // pre-ticked: this session's set, or all (auto)
|
|
1056
1081
|
const items = mine.map((t) => ({ label: t.model, t, checked: chosen.has(key(t)), desc: this.modelDesc(t, mine.indexOf(t)) }))
|
|
1057
1082
|
// first, standing alone: back to auto (Enter on it, whatever is ticked)
|
|
1058
|
-
const auto = { label: 'auto', only: true, auto: true, desc: `
|
|
1083
|
+
const auto = { label: 'auto', only: true, auto: true, desc: `the whole list, in its order (${mine.length} model${mine.length === 1 ? '' : 's'})${cfg.session ? ' · forgets what this folder picked' : ' · in use'}` }
|
|
1059
1084
|
const guessed = mine.some((t) => this.abilities(t).guessed) ? "\n~128k and the like: the window's size is a guess (models.dev doesn't list the model)" : ''
|
|
1060
1085
|
const picked = await ui.pick('Models for this session', [auto, ...items], { filter, multi: true, body: `Tick several to rotate among them, one to pin it, or choose auto.${guessed}` })
|
|
1061
1086
|
if (!picked) return
|
|
@@ -1085,7 +1110,7 @@ class App {
|
|
|
1085
1110
|
const missing = []
|
|
1086
1111
|
for (const spec of specs) (resolve(spec) ? found : missing).push(resolve(spec) ?? spec)
|
|
1087
1112
|
if (missing.length || !found.length) {
|
|
1088
|
-
if (missing.length) this.ui.print(c.dim(`not in
|
|
1113
|
+
if (missing.length) this.ui.print(c.dim(`not in the model list: ${missing.join(', ')} · add on /settings`))
|
|
1089
1114
|
return this.chooseModel(specs.length === 1 ? specs[0] : '', later)
|
|
1090
1115
|
}
|
|
1091
1116
|
return this.setSession(found, later)
|
|
@@ -1104,16 +1129,17 @@ class App {
|
|
|
1104
1129
|
|
|
1105
1130
|
// `heart models`: what -m takes, one per line (as \`opencode models\`): "auto" (your list: #1, then
|
|
1106
1131
|
// the next when one fails; also no -m), then your models as provider/model, #1 first. all: every
|
|
1107
|
-
// provider's models (fetched from each; a provider whose list is off: the ones added by
|
|
1132
|
+
// switched-on provider's models (fetched from each; a provider whose list is off: the ones added by
|
|
1133
|
+
// name). A provider switched off isn't listed at all: its models aren't offered anywhere.
|
|
1108
1134
|
// json: one JSON object on stdout, for other programs:
|
|
1109
1135
|
// { "models": [{ "id": "auto", "fallbacks": true }, { "id": "groq/openai/gpt-oss-120b", "provider", "model", "place": 1 }, …],
|
|
1110
|
-
// "providers": [{ "name", "baseUrl", "list": true, "
|
|
1136
|
+
// "providers": [{ "name", "baseUrl", "list": true, "models": ["provider/model", …], "error"? }] } (--all)
|
|
1111
1137
|
async listModels(filter = '', { all = false, json = false } = {}) {
|
|
1112
1138
|
const { ui, cfg } = this
|
|
1113
1139
|
const match = (id) => id.toLowerCase().includes(filter.toLowerCase())
|
|
1114
1140
|
const mine = this.myModels().map((t, i) => ({ id: `${t.provider}/${t.model}`, provider: t.provider, model: t.model, place: i + 1 }))
|
|
1115
|
-
const providers = !all ? [] : await Promise.all(Object.entries(cfg.providers).map(async ([name, p]) => {
|
|
1116
|
-
const out = { name, baseUrl: p.baseUrl, list: p.list !== false,
|
|
1141
|
+
const providers = !all ? [] : await Promise.all(Object.entries(cfg.providers).filter(([, p]) => !p.off).map(async ([name, p]) => {
|
|
1142
|
+
const out = { name, baseUrl: p.baseUrl, list: p.list !== false, models: [] }
|
|
1117
1143
|
if (out.list) {
|
|
1118
1144
|
try {
|
|
1119
1145
|
out.models = await new Client({ baseUrl: p.baseUrl, apiKey: p.apiKey }).listModels()
|
|
@@ -1176,7 +1202,7 @@ async function continueTabs(app, saved) {
|
|
|
1176
1202
|
if (!open.length) return
|
|
1177
1203
|
const many = open.length > 1
|
|
1178
1204
|
const newest = open.map((t) => t.chat.updated).sort().at(-1)
|
|
1179
|
-
const go = await ui.pick(many ? `Continue where
|
|
1205
|
+
const go = await ui.pick(many ? `Continue where it left off? ${open.length} tabs` : 'Continue the last session here?', [
|
|
1180
1206
|
{ label: many ? `Yes, with its ${open.length} tabs` : 'Yes', desc: `${open.map((t) => `"${t.chat.title}"`).join(', ')} · ${ago(newest)}`, yes: true },
|
|
1181
1207
|
{ label: 'No, start a new session', desc: '/resume finds it later' },
|
|
1182
1208
|
], { quiet: true, fixed: true })
|
|
@@ -1202,8 +1228,8 @@ async function continueTabs(app, saved) {
|
|
|
1202
1228
|
// A continued tab's own model, as it was (unless its provider is gone: then the current one).
|
|
1203
1229
|
function useModel(app, { provider, model }) {
|
|
1204
1230
|
if (!provider || !model || (provider === app.cfg.provider && model === app.cfg.model)) return
|
|
1205
|
-
if (!app.cfg.providers[provider]) return app.ui.warn(`this tab used ${provider} · ${model}, but there's no provider "${provider}" now: using
|
|
1206
|
-
if (app.cfg.providers[provider].off) return app.ui.warn(`this tab used ${provider} · ${model}, but ${provider} is switched off: using
|
|
1231
|
+
if (!app.cfg.providers[provider]) return app.ui.warn(`this tab used ${provider} · ${model}, but there's no provider "${provider}" now: using the list`)
|
|
1232
|
+
if (app.cfg.providers[provider].off) return app.ui.warn(`this tab used ${provider} · ${model}, but ${provider} is switched off: using the list`)
|
|
1207
1233
|
Object.assign(app.cfg, { provider, model })
|
|
1208
1234
|
app.s = null
|
|
1209
1235
|
}
|
|
@@ -1243,7 +1269,7 @@ function applySettings(apps, cfg, what) {
|
|
|
1243
1269
|
if (what === 'model' && !app.cfg.session) {
|
|
1244
1270
|
app.lists = {}
|
|
1245
1271
|
if (app.s && !(cfg.providers[cfg.provider] && cfg.model)) now(() => ((app.s = null), ui.print(c.dim('settings: no model chosen'))))
|
|
1246
|
-
else if (app.s && !app.myModels().length) now(() => ((app.s = null), ui.print(c.dim('settings: the providers of all
|
|
1272
|
+
else if (app.s && !app.myModels().length) now(() => ((app.s = null), ui.print(c.dim('settings: the providers of all the models are switched off'))))
|
|
1247
1273
|
}
|
|
1248
1274
|
// your model list: into the running session now, its next request goes to the new #1
|
|
1249
1275
|
if (['model', 'setting:rotation'].includes(what) && !app.cfg.session && app.s && cfg.providers[cfg.provider] && cfg.model) {
|
|
@@ -1422,7 +1448,7 @@ async function slash(app, line, working = false) {
|
|
|
1422
1448
|
const n = app.tabs?.list.length ?? 1
|
|
1423
1449
|
if (n > 1 || working) {
|
|
1424
1450
|
const go = await ui.pick(`Quit HeartCode?${working ? ' It is still working: that stops.' : ''}${n > 1 ? ` ${n} tabs are open` : ''}`, [
|
|
1425
|
-
{ label: 'Yes, quit', desc: 'they come back next time
|
|
1451
|
+
{ label: 'Yes, quit', desc: 'they come back the next time HeartCode starts here', yes: true },
|
|
1426
1452
|
{ label: 'No', desc: 'Alt+W closes just this tab' },
|
|
1427
1453
|
])
|
|
1428
1454
|
if (!go?.yes) return
|
|
@@ -1439,7 +1465,7 @@ async function slash(app, line, working = false) {
|
|
|
1439
1465
|
const home = process.env.HOME
|
|
1440
1466
|
const tilde = (f) => (home && f.startsWith(home) ? '~' + f.slice(home.length) : f)
|
|
1441
1467
|
const files = resetPaths(it.level)
|
|
1442
|
-
const what = [...(it.level === 'settings' ? [`the settings in ${tilde(CONFIG_FILE)} (not
|
|
1468
|
+
const what = [...(it.level === 'settings' ? [`the settings in ${tilde(CONFIG_FILE)} (not the providers, keys or model)`] : []), ...files.map(tilde)]
|
|
1443
1469
|
ui.print(`${c.warn('!')} ${c.bold(`Reset: ${it.label.toLowerCase()}.`)} ${c.muted("This can't be undone. It removes:")}\n${what.length ? what.map((f) => ` ${c.faint('·')} ${f}`).join('\n') : c.faint(' (nothing there yet)')}`)
|
|
1444
1470
|
const code = resetCode()
|
|
1445
1471
|
const typed = await ui.ask(` Type ${c.bold(code)} to reset ${c.dim('(anything else: no)')}: `)
|
|
@@ -1453,7 +1479,7 @@ async function slash(app, line, working = false) {
|
|
|
1453
1479
|
settingsPage ??= startSettings({ cfg, root: app.root, onLoginMcp: (name) => signInMcp(app, name, null), apply: (what) => applySettings(app.tabs ? app.tabs.list.map((t) => t.app) : [app], cfg, what) })
|
|
1454
1480
|
const { url, local, close } = await settingsPage
|
|
1455
1481
|
openBrowser(local)
|
|
1456
|
-
if (!ui.full) ui.print(`${c.info('↗')} ${c.bold('settings')} ${c.muted(overSsh ? 'open this link in
|
|
1482
|
+
if (!ui.full) ui.print(`${c.info('↗')} ${c.bold('settings')} ${c.muted(overSsh ? 'open this link in a browser:' : 'opened in the browser:')}\n ${c.faint(url)}`)
|
|
1457
1483
|
// a dialog until it's turned off: nothing else meanwhile, in any tab (Esc turns it off too).
|
|
1458
1484
|
// Not busy meanwhile: what's changed on the page applies at once, here too (opened while a task
|
|
1459
1485
|
// works: once it's done).
|
|
@@ -1461,7 +1487,7 @@ async function slash(app, line, working = false) {
|
|
|
1461
1487
|
if (app.tabs) app.tabs.locked = true
|
|
1462
1488
|
ui.setMouse(false) // the terminal's own selection for the link: OSC 52 copying fails in some terminals
|
|
1463
1489
|
try {
|
|
1464
|
-
await ui.pick('The settings page is on', [{ label: 'Turn off', desc: 'stops the page and gives HeartCode back' }], { fixed: true, quiet: true, ctrlC: true, body: `${overSsh ? 'Open this link in
|
|
1490
|
+
await ui.pick('The settings page is on', [{ label: 'Turn off', desc: 'stops the page and gives HeartCode back' }], { fixed: true, quiet: true, ctrlC: true, body: `${overSsh ? 'Open this link in a browser:' : "It's open in the browser:"}\n${url}\n\nTo copy it, select it with the mouse.\nChanges there apply right away.` })
|
|
1465
1491
|
} finally {
|
|
1466
1492
|
ui.setMouse(cfg.mouse !== false)
|
|
1467
1493
|
if (app.tabs) app.tabs.locked = false
|
|
@@ -1493,9 +1519,9 @@ async function slash(app, line, working = false) {
|
|
|
1493
1519
|
if (!u.newer) return ui.print(c.dim(`HeartCode ${u.current} is the newest`))
|
|
1494
1520
|
const kind = installKind()
|
|
1495
1521
|
const notes = await whatsNew(u.current, u.latest)
|
|
1496
|
-
if (kind === 'git') return ui.showText(`HeartCode ${u.latest} is out (
|
|
1522
|
+
if (kind === 'git') return ui.showText(`HeartCode ${u.latest} is out (this is ${u.current})`, `${notes || '(no changelog found)'}\n\nThis HeartCode runs from a git checkout (${packageDir}): update it there with git pull.`)
|
|
1497
1523
|
const cmd = UPDATE_COMMANDS[kind]
|
|
1498
|
-
ui.showText(`HeartCode ${u.latest} is out (
|
|
1524
|
+
ui.showText(`HeartCode ${u.latest} is out (this is ${u.current})`, notes || '(no changelog found)')
|
|
1499
1525
|
if ((await ui.confirm(`Update now with ${c.bold(cmd)}?`, 'command')) !== true) return ui.print(c.dim('not updated'))
|
|
1500
1526
|
ui.spinner(`running ${cmd}`)
|
|
1501
1527
|
const r = await runCommand(process.cwd(), cmd, { timeout: 300_000 })
|
|
@@ -1520,7 +1546,7 @@ async function slash(app, line, working = false) {
|
|
|
1520
1546
|
const was = app.chat.id
|
|
1521
1547
|
app.setChat(forkChat(app.chat))
|
|
1522
1548
|
app.save()
|
|
1523
|
-
return ui.print(c.dim(`forked:
|
|
1549
|
+
return ui.print(c.dim(`forked: now in "${app.chat.name}"; the original (${was}) stays in /resume`))
|
|
1524
1550
|
}
|
|
1525
1551
|
case 'export': {
|
|
1526
1552
|
if (!app.chat.turns.length) return ui.print('Nothing to export yet.')
|
|
@@ -1565,7 +1591,7 @@ async function slash(app, line, working = false) {
|
|
|
1565
1591
|
const answer = app.chat.history.at(-1)?.answer?.trim()
|
|
1566
1592
|
if (!answer) return ui.print('No answer to copy yet.')
|
|
1567
1593
|
const how = copyText(answer)
|
|
1568
|
-
return ui.print(c.dim(`copied the last answer (${answer.split('\n').length} lines)${how === 'osc' ? ' if
|
|
1594
|
+
return ui.print(c.dim(`copied the last answer (${answer.split('\n').length} lines)${how === 'osc' ? ' if the terminal allows it' : ''}`))
|
|
1569
1595
|
}
|
|
1570
1596
|
case 'background': {
|
|
1571
1597
|
const jobs = listJobs(app.root)
|
|
@@ -1585,7 +1611,7 @@ async function slash(app, line, working = false) {
|
|
|
1585
1611
|
}
|
|
1586
1612
|
case 'context': {
|
|
1587
1613
|
const s = app.s
|
|
1588
|
-
if (!s?.messages?.length) return ui.print('Nothing in the context yet: it fills with
|
|
1614
|
+
if (!s?.messages?.length) return ui.print('Nothing in the context yet: it fills with the first message.')
|
|
1589
1615
|
const r = contextReport(s)
|
|
1590
1616
|
const share = (n) => (r.window ? `${Math.round((n / r.window) * 100)}%` : '')
|
|
1591
1617
|
const bar = (n) => c.brand('█'.repeat(r.window ? Math.round((n / r.window) * 40) : 0) || (n ? '▏' : ''))
|
|
@@ -1720,6 +1746,8 @@ async function slash(app, line, working = false) {
|
|
|
1720
1746
|
if (text) ui.ahead.push(text) // sent: the next prompt takes it, as if typed
|
|
1721
1747
|
return
|
|
1722
1748
|
}
|
|
1749
|
+
case 'todos':
|
|
1750
|
+
return ui.showPlan()
|
|
1723
1751
|
case 'toggle_thinking':
|
|
1724
1752
|
ui.showThinking = !ui.showThinking
|
|
1725
1753
|
ui.print(c.dim(ui.showThinking ? 'thinking shown: all of it (Alt+O: last two lines)' : 'thinking shown: its last two lines (Alt+O: all of it)'))
|
|
@@ -1733,7 +1761,7 @@ async function slash(app, line, working = false) {
|
|
|
1733
1761
|
const name = cmd.slice(6)
|
|
1734
1762
|
const k = app.skills.get(name)
|
|
1735
1763
|
if (k && (k.use === 'me' || k.use === 'both')) return runTask(app, await app.expandSkill(k, args.join(' ')), { signal: app.signal })
|
|
1736
|
-
return ui.print(`unknown skill /skill:${name} ${c.dim('· /help lists
|
|
1764
|
+
return ui.print(`unknown skill /skill:${name} ${c.dim('· /help lists the skills')}`)
|
|
1737
1765
|
}
|
|
1738
1766
|
if (app.skills.has(cmd)) return ui.print(`${c.dim(`/${cmd} is a skill — run it as`)} ${c.cyan(`/skill:${cmd}`)}`) // bare skill name: point to the namespaced form
|
|
1739
1767
|
return ui.print(`unknown command /${cmd} ${c.dim('· /help lists them')}`)
|
|
@@ -1801,7 +1829,7 @@ async function repl(app, f = {}) {
|
|
|
1801
1829
|
.catch((e) => (log('error', e.stack), ui.print(c.red(`error: ${e.message}`))))
|
|
1802
1830
|
return true
|
|
1803
1831
|
}
|
|
1804
|
-
ui.onWaiting = (question) => notify(cfg, 'waiting', `⏳ Waiting for
|
|
1832
|
+
ui.onWaiting = (question) => notify(cfg, 'waiting', `⏳ Waiting for an answer · ${path.basename(app.root)}\n${clip(question.replace(/\x1b\[[0-9;]*m/g, '').replace(/\s*›\s*$/, '').replace(/^\?\s*/, '').trim(), 1000)}`) // a question or a permission while it works (Telegram)
|
|
1805
1833
|
ui.isCommand = (l) => app.isCommand(l)
|
|
1806
1834
|
loadPrices().then(() => ui.render?.()) // models.dev: what each model can do, for the model lists
|
|
1807
1835
|
ui.voiceConfig = () => ({ voice: cfg.voice, providers: cfg.providers })
|
|
@@ -1892,7 +1920,7 @@ async function repl(app, f = {}) {
|
|
|
1892
1920
|
else if (f.resume) await app.resume()
|
|
1893
1921
|
if (f.model) useModel(app, f.model) // a continued tab's own model
|
|
1894
1922
|
// models this folder picked earlier (/select_model): said, with the way back to your whole list
|
|
1895
|
-
if (app.folderModels && cfg.session?.length) ui.print(`${c.muted('this folder uses')} ${c.cyan(cfg.session.map((t) => t.model).join(', '))} ${c.faint(`(picked earlier) · ${c.cyan('/select_model auto')} for
|
|
1923
|
+
if (app.folderModels && cfg.session?.length) ui.print(`${c.muted('this folder uses')} ${c.cyan(cfg.session.map((t) => t.model).join(', '))} ${c.faint(`(picked earlier) · ${c.cyan('/select_model auto')} for the whole list again`)}`)
|
|
1896
1924
|
app.tabs?.onChange?.() // the conversation it opened with
|
|
1897
1925
|
// a newer HeartCode: asked of npm in the background at every start, said once and kept in the status bar
|
|
1898
1926
|
if (cfg.updateCheck !== false)
|
|
@@ -1900,7 +1928,7 @@ async function repl(app, f = {}) {
|
|
|
1900
1928
|
.then((u) => {
|
|
1901
1929
|
if (!u?.newer) return
|
|
1902
1930
|
app.update = u
|
|
1903
|
-
ui.print(`${c.green('⬆')} ${c.muted('HeartCode')} ${c.green(u.latest)} ${c.muted(`is out (
|
|
1931
|
+
ui.print(`${c.green('⬆')} ${c.muted('HeartCode')} ${c.green(u.latest)} ${c.muted(`is out (this is ${u.current})`)} ${c.faint('·')} ${c.cyan('/update')}`)
|
|
1904
1932
|
ui.render?.()
|
|
1905
1933
|
})
|
|
1906
1934
|
.catch(() => {})
|
|
@@ -2036,14 +2064,14 @@ async function main() {
|
|
|
2036
2064
|
if (!cfg.providers[f.provider]) throw new Error(`no provider "${f.provider}" (heartcode providers lists them)`)
|
|
2037
2065
|
if (!f.model) {
|
|
2038
2066
|
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}:
|
|
2067
|
+
if (!t) throw new Error(`--provider ${f.provider}: no model in the list is from it; add -m <model>`)
|
|
2040
2068
|
Object.assign(cfg, { ...t, session: [t], pinned: true })
|
|
2041
2069
|
}
|
|
2042
2070
|
}
|
|
2043
2071
|
// --fallback-model: after the model given (as in Claude Code's -p), when it fails
|
|
2044
2072
|
cfg.fallbacks = (f['fallback-model'] ?? []).map((v) => {
|
|
2045
2073
|
const t = parseModel(v, cfg.providers, cfg.provider)
|
|
2046
|
-
if (isAuto(v) || !cfg.providers[t.provider]) throw new Error(`--fallback-model ${v}: give provider/model, or a model of ${cfg.provider} (heart models lists
|
|
2074
|
+
if (isAuto(v) || !cfg.providers[t.provider]) throw new Error(`--fallback-model ${v}: give provider/model, or a model of ${cfg.provider} (heart models lists them)`)
|
|
2047
2075
|
return t
|
|
2048
2076
|
})
|
|
2049
2077
|
if (f.effort) cfg.effort = f.effort === 'default' ? undefined : f.effort
|
|
@@ -2060,7 +2088,7 @@ async function main() {
|
|
|
2060
2088
|
|
|
2061
2089
|
if (sub === 'settings') {
|
|
2062
2090
|
const { url, local } = await startSettings({ cfg })
|
|
2063
|
-
console.log(`${c.brand('♥')} HeartCode settings: ${url}\n${c.dim(`${overSsh ? 'open it in
|
|
2091
|
+
console.log(`${c.brand('♥')} HeartCode settings: ${url}\n${c.dim(`${overSsh ? 'open it in a browser' : 'opened in the browser'} · from another device on this network, open the link above · Ctrl+C to stop`)}`)
|
|
2064
2092
|
openBrowser(local)
|
|
2065
2093
|
return new Promise(() => {}) // until Ctrl+C
|
|
2066
2094
|
}
|