heartcode 0.1.36 → 0.1.40
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/.claude/scheduled_tasks.lock +1 -0
- package/CHANGELOG.md +93 -0
- package/README.md +20 -7
- package/SKILL.md +5 -3
- package/bin/heart.js +7 -20
- package/bin/heartcode.js +61 -13
- package/package.json +1 -1
- package/prompts/agent.md +114 -115
- package/src/agent.js +63 -252
- package/src/background.js +39 -12
- package/src/client.js +41 -6
- package/src/config.js +1 -1
- package/src/fit.js +65 -0
- package/src/log.js +69 -18
- package/src/parquet.js +209 -0
- package/src/rankings.js +115 -0
- package/src/settings.html +173 -52
- package/src/settings.js +45 -13
- package/src/skills.js +7 -3
- package/src/tools.js +189 -50
- package/src/ui.js +37 -10
- package/src/update.js +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"sessionId":"4639584a-9f21-4557-8aab-bb929b2c0d12","pid":1642,"procStart":"Mon Nov 2 08:59:52 2026","acquiredAt":1793649027261}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,99 @@
|
|
|
2
2
|
|
|
3
3
|
What changed in each version of HeartCode, newest first.
|
|
4
4
|
|
|
5
|
+
## 0.1.40 (2026-11-03)
|
|
6
|
+
|
|
7
|
+
- **A smaller, general system prompt** (about 6,700 tokens to start a task, from 13,000+): its rules
|
|
8
|
+
in working order (ask what they want → research and plan → find your way → write code → install
|
|
9
|
+
tools → prove it works, then stop → keep going → how to answer), the discipline skill merged into
|
|
10
|
+
them (no separate copy), nothing about one kind of project: a check is "the way the person will use
|
|
11
|
+
it", for a page, a script or a server alike. Gone: the web UI guide, the reminder on every
|
|
12
|
+
message, the automatic page review with screenshots, and asking models what they're good at
|
|
13
|
+
(best fit's rankings do that). Your other models in a short list; an MCP server's own
|
|
14
|
+
instructions sent once, the first time its tool is used.
|
|
15
|
+
- **Your terminal's mouse**: HeartCode no longer takes the mouse, so text is selected and copied the
|
|
16
|
+
terminal's own way, over SSH too (to the computer you connect from). `"mouse": true` in config.json
|
|
17
|
+
brings back the wheel scrolling the conversation and drag to copy.
|
|
18
|
+
- **A model that doesn't start answering** within the time allowed: a helper, the image describer or
|
|
19
|
+
the reviewer goes to your next model at once, not after three more waits.
|
|
20
|
+
- **Gemini, then another model**: Gemini's tool-call signature goes back to Gemini only; Mistral and
|
|
21
|
+
others refused the request with it (422).
|
|
22
|
+
- **/update's changelog** wrapped at words, not mid-word, and a list item's lines joined.
|
|
23
|
+
- Lessons learned from a fixed mistake are tagged by the tool that failed (npm, python3, cargo…).
|
|
24
|
+
|
|
25
|
+
## 0.1.39 (2026-11-03)
|
|
26
|
+
|
|
27
|
+
- **Best fit picks by public rankings**, not by a model's opinion of models: for each new message,
|
|
28
|
+
one short request names the skills the task needs (web pages, code, images, long inputs…), and
|
|
29
|
+
your models are ranked by their places in LMArena's rankings of those skills (people comparing
|
|
30
|
+
two models' answers, per skill). The best becomes the lead, the next take over when it fails; the
|
|
31
|
+
code review and the page review go to the best-ranked others (not the lead). Models the rankings
|
|
32
|
+
don't know come after, in your order. The rankings are fetched once a week into
|
|
33
|
+
~/.heart/rankings.json, and only in best fit: with "your order", your list is followed as it is.
|
|
34
|
+
- **Your models shows each model's ranks**: Coding, Web apps and Vision columns (its place in
|
|
35
|
+
LMArena's ranking; the top tenth in green), sortable like the others, with Get rankings /
|
|
36
|
+
Refresh rankings above the list.
|
|
37
|
+
- **Gemini 3.x works with tools**: the thought signature Gemini sends with each tool call is kept
|
|
38
|
+
and sent back, so its second step is no longer refused (400 "missing a thought_signature").
|
|
39
|
+
|
|
40
|
+
## 0.1.38 (2026-11-02)
|
|
41
|
+
|
|
42
|
+
- **Asks what you want before building**: the questions whose answers change the result (what it's
|
|
43
|
+
for, looks, testing, robustness, scope), in rounds, each with a recommended answer; again for a
|
|
44
|
+
new message that leaves things open. The answers are kept with the conversation and steer the
|
|
45
|
+
checks and reviews: a demo isn't sent back for polish or tests nobody asked for. The UI guide and
|
|
46
|
+
the page review only go for looks when looks were asked for. When it made something that runs, it
|
|
47
|
+
ends with how to run it.
|
|
48
|
+
- **The discipline skill**, built in and always on (from Karpathy's guidelines, Grill Me,
|
|
49
|
+
Superpowers, Ponytail and Caveman): think first, ask in rounds, root cause first, done-when and
|
|
50
|
+
non-goals, the least code that works, surgical changes, test first when tests are wanted, evidence
|
|
51
|
+
before claims, stop when proven, answers kept short. Skills with `use: always` go in every message;
|
|
52
|
+
Make my own copy on the settings page to change it or turn it off.
|
|
53
|
+
- **Your models, by strength**: what each model is good and weak at is learned once (a web search,
|
|
54
|
+
kept in model-strengths.json for every project) and shown to the model with your test results.
|
|
55
|
+
The plan's parts can go to other models at the same time (parallel, model, files), each helper
|
|
56
|
+
changing only its own files. **Best fit** (Your models → HeartCode picks the model by): for each
|
|
57
|
+
new message the models that suit it best do the work, review it and check pages; your order breaks
|
|
58
|
+
ties. `--model-choice order|fit` for one run.
|
|
59
|
+
- **Nothing hangs**: every command can carry on in the background, the model choosing how long to
|
|
60
|
+
wait and checking back; processes a command leaves running (`server &`) are kept as background
|
|
61
|
+
commands instead of killed. A reply must start within 60 seconds (Your models: A reply must start
|
|
62
|
+
within), then the next model answers; reviews, picks and summaries are streamed too, so a silent
|
|
63
|
+
model is given up on.
|
|
64
|
+
- **Nothing lost**: the conversation is saved after every step, so a crash or kill mid-task loses
|
|
65
|
+
nothing and "continue" picks it up; the answers to its questions and folders named earlier come
|
|
66
|
+
back too.
|
|
67
|
+
- **Logs, kind by kind**: requests, tools & commands, model choices, the agent's decisions, errors,
|
|
68
|
+
the conversation, debug, each switched on by itself (all off by default), a file per kind per run;
|
|
69
|
+
read on the settings page by run, searched and live.
|
|
70
|
+
- **Updates**: a newer HeartCode is shown at start and in the status bar (asked of npm once a day);
|
|
71
|
+
`/update` shows what changed and installs it the way you installed HeartCode (a git checkout:
|
|
72
|
+
git pull). Check for updates on General.
|
|
73
|
+
- Reads folders your message names (read only, outside the project); MCP arguments mended from the
|
|
74
|
+
tool's schema (a missing page id, msgId for msgid, a value for a list…); page syntax errors with
|
|
75
|
+
their line; "enough checks" after five with nothing changed; a nudge at the third change to the
|
|
76
|
+
same spot; plan-first holds back the whole reply.
|
|
77
|
+
- Scrolled up, the conversation stays where you're reading while the answer comes in;
|
|
78
|
+
Alt+Shift+↑/↓ (or Ctrl+Home/End) to its top and bottom.
|
|
79
|
+
|
|
80
|
+
## 0.1.37 (2026-11-02)
|
|
81
|
+
|
|
82
|
+
- Settings page, Your models: filters (search, provider, test result with counts, context, tools,
|
|
83
|
+
thinking, images, free) that combine and are kept. Filtered, **Use these N** makes the models shown
|
|
84
|
+
the only ones HeartCode uses, in the order shown (asked first; the others stay under Providers);
|
|
85
|
+
Test N shown tests just them; dragging works while filtered. The page laid out in full-width rows:
|
|
86
|
+
the list's settings in three cells, filters on one line, what's shown and the list's actions on
|
|
87
|
+
one line, the column names (or the selection's actions) sticky above aligned rows.
|
|
88
|
+
- The whole settings page with icons and colors: each part's icon on its own color in the sidebar
|
|
89
|
+
and on its title, buttons with icons colored by what they do, card titles with icons, less room
|
|
90
|
+
around pages and cards, General's cards packed in two columns, rows' actions as icon buttons,
|
|
91
|
+
Providers one line a model.
|
|
92
|
+
- Saving the list builds the page's state once, not three times (the server skips its own writes);
|
|
93
|
+
a sort or filter changed on the page isn't undone by an older state.
|
|
94
|
+
- Contexts with two decimals (1.05M, not rounded up to 1.1M), on the page and in the status bar;
|
|
95
|
+
the exact count on hover. Checked against models.dev for every model: the data is right.
|
|
96
|
+
- Logs are kept 3 days by default instead of 30 (Advanced → Logs changes it).
|
|
97
|
+
|
|
5
98
|
## 0.1.36 (2026-11-02)
|
|
6
99
|
|
|
7
100
|
- Voice: Space in an empty box (or /voice) starts listening at once, no second key; what you say
|
package/README.md
CHANGED
|
@@ -52,9 +52,21 @@ tried did what I needed:
|
|
|
52
52
|
- **Set up in a web page** on your own machine (`/settings`), not by editing config files.
|
|
53
53
|
- **Usable by other tools and AI agents**: `heart -p` runs one task headless, like `claude -p`
|
|
54
54
|
(see [SKILL.md](SKILL.md)).
|
|
55
|
-
- **Logs
|
|
56
|
-
|
|
55
|
+
- **Logs what you need, nothing else**: seven kinds, each switched on by itself (all off by
|
|
56
|
+
default): requests, tools & commands, model choices, the agent's decisions, errors, the
|
|
57
|
+
conversation, debug. Read them on the settings page, searched and live.
|
|
57
58
|
- **Takes skills, MCP servers and hooks** in Claude Code's formats; `/import` brings yours over.
|
|
59
|
+
- **Tells you when a newer version is out** (a check with npm at most once a day, in the status bar):
|
|
60
|
+
`/update` shows what changed and installs it the way you installed HeartCode. Switch it off in
|
|
61
|
+
`/settings` → General.
|
|
62
|
+
- **Best fit by public rankings**: with "HeartCode picks the model by" set to best fit, each message's
|
|
63
|
+
lead and code reviewer are your models ranked on the skills that task needs (web
|
|
64
|
+
pages, code, images…) by LMArena's public rankings, fetched once a week. Your models shows each
|
|
65
|
+
one's Coding, Web apps and Vision rank.
|
|
66
|
+
- **Works with discipline by default**: its rules (from Karpathy's guidelines, Grill Me,
|
|
67
|
+
Superpowers, Ponytail and Caveman) have it ask before building, find a bug's root cause first,
|
|
68
|
+
write the least code that works, change only what the task needs, prove it before saying done,
|
|
69
|
+
then stop, and answer short. A skill with `use: always` adds rules of your own to every message.
|
|
58
70
|
- **Tabs** (`Alt+T`), each with its own conversation, and git worktrees for work kept apart.
|
|
59
71
|
- **Servers and watchers in the background**: the model starts one and goes on working, reads its
|
|
60
72
|
output when it needs to, and stops it. `Alt+B` (or `/background`) shows their logs live above the input,
|
|
@@ -108,7 +120,7 @@ The sidebar, in four groups:
|
|
|
108
120
|
effort, voice input, web search: your own SearXNG and the engines' order, and which outside tools are ready) and *Status bar* (drag and drop what the
|
|
109
121
|
bottom lines show, with a live preview). **Notifications**: Telegram.
|
|
110
122
|
- **Skills**, **MCP servers** and **System prompt**: what HeartCode can do and how it's told.
|
|
111
|
-
- **Advanced**: *Logs* (
|
|
123
|
+
- **Advanced**: *Logs* (seven kinds, each on or off, and a viewer) and *Files* (the rest of the settings, as files).
|
|
112
124
|
|
|
113
125
|
### 4. Add a provider and pick models
|
|
114
126
|
|
|
@@ -133,9 +145,9 @@ On **Models → Your list**:
|
|
|
133
145
|
Each test waits up to 10 seconds; the **Timeout** box next to it changes that.
|
|
134
146
|
4. **Filter them** (optional): by name, provider, test result (works, doesn't, not tested, or one
|
|
135
147
|
error like 402), context, tools, thinking, images or free. **Test all** then tests only the ones
|
|
136
|
-
shown
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
shown, and **Use these N** makes them the models HeartCode uses, in the order you see (the others
|
|
149
|
+
stay under Providers). Filter to the working ones, sort by Works?, Use these: HeartCode uses your
|
|
150
|
+
working models, fastest first.
|
|
139
151
|
|
|
140
152
|
If a model says *not found* in models.dev, **Retry** looks it up again, or **Set up** tells
|
|
141
153
|
HeartCode what it can do.
|
|
@@ -145,7 +157,8 @@ HeartCode what it can do.
|
|
|
145
157
|
- **Notifications**: a Telegram message when a task finishes, fails or waits for you. Make a bot
|
|
146
158
|
with [@BotFather](https://t.me/BotFather), paste its token, press Start in the bot, and
|
|
147
159
|
HeartCode finds your chat.
|
|
148
|
-
- **Advanced → Logs**:
|
|
160
|
+
- **Advanced → Logs**: switch on only the kinds you need (requests, tools & commands, model choices,
|
|
161
|
+
the agent's decisions, errors, the conversation, debug), and read them there: by run, searched, live.
|
|
149
162
|
Logs older than 3 days are deleted (you can change that).
|
|
150
163
|
|
|
151
164
|
### 7. Back to HeartCode
|
package/SKILL.md
CHANGED
|
@@ -208,9 +208,11 @@ empty folders the task made (a test script, a debug log). It runs after the answ
|
|
|
208
208
|
`result` (or the printed answer) comes first, and `heart -p` exits once the wrap-up is done (a few
|
|
209
209
|
seconds more).
|
|
210
210
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
No command blocks: `run_command` waits up to `wait` seconds (the model's choice, 30 if left out)
|
|
212
|
+
and a command still running then carries on in the background; one meant to keep running (a dev
|
|
213
|
+
server, a watcher) takes `background: true`. The `background` tool reads a command's new output
|
|
214
|
+
(after waiting up to `wait` seconds for it), lists them and stops one. Whatever is still running is
|
|
215
|
+
stopped when HeartCode exits.
|
|
214
216
|
|
|
215
217
|
Before a task that changed files ends, another of the user's models (the same one when only one is
|
|
216
218
|
used) reviews the work against the request in a request of its own; a NO sends it back to fix.
|
package/bin/heart.js
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
// your config.json (providers, keys), the models' test results and
|
|
9
9
|
// prices copied in; deleted when the last of them quits; your own is
|
|
10
10
|
// never written to
|
|
11
|
-
// Logs,
|
|
12
|
-
// ~/.heart/logs/runs/<day-month-year-hour-min-sec>/, a file per
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
11
|
+
// Logs, each kind switched on by itself (the settings page: Logs; "logs" in config.json), all off
|
|
12
|
+
// by default: text logs in ~/.heart/logs/runs/<day-month-year-hour-min-sec>/, a file per kind
|
|
13
|
+
// (tools.log, models.log, agent.log, errors.log, conversation.log, debug.log); each request to a
|
|
14
|
+
// model in ~/.heart/logs/requests/<same>/, a file per request. Kept for logDays days (3 unless
|
|
15
|
+
// changed). HEART_LOG=/path/file.log logs everything of this run in that one file; HEART_LOG=off: none.
|
|
16
16
|
import fs from 'node:fs'
|
|
17
17
|
import os from 'node:os'
|
|
18
18
|
import path from 'node:path'
|
|
@@ -75,26 +75,13 @@ if (first && !first.startsWith('-') && !SUBCOMMANDS.includes(first)) {
|
|
|
75
75
|
// else: words, a task to run (heart "fix the failing test")
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
// the run's
|
|
79
|
-
//
|
|
80
|
-
const logOn = (() => {
|
|
81
|
-
try {
|
|
82
|
-
return JSON.parse(fs.readFileSync(path.join(process.env.HEART_HOME || realHome, 'config.json'), 'utf8')).log === true
|
|
83
|
-
} catch {
|
|
84
|
-
return false
|
|
85
|
-
}
|
|
86
|
-
})()
|
|
78
|
+
// where the logs go, and this run's name for its folders (src/log.js: each kind of log is switched on
|
|
79
|
+
// by itself in config.json's "logs", also while HeartCode runs)
|
|
87
80
|
const logs = temp ? path.join(os.tmpdir(), 'heart-temp-logs') : path.join(realHome, 'logs')
|
|
88
81
|
process.env.HEART_LOGS ??= logs
|
|
89
82
|
let runStamp = stamp
|
|
90
83
|
for (let n = 2; ['runs', 'requests'].some((d) => fs.existsSync(path.join(logs, d, runStamp))); n++) runStamp = `${stamp}-${n}` // two runs in the same second
|
|
91
84
|
process.env.HEART_LOG_STAMP ??= runStamp
|
|
92
|
-
// The run's folder is set aside either way (made with its first line): the Logging page's switch
|
|
93
|
-
// turns the log on or off while HeartCode runs (src/log.js, HEART_LOG_RUN).
|
|
94
|
-
if (!process.env.HEART_LOG && !process.env.HEART_LOG_DIR && !args.some((a) => ['-p', '--print', '-h', '--help', '-v', '--version'].includes(a))) {
|
|
95
|
-
process.env.HEART_LOG_DIR = path.join(logs, 'runs', runStamp) // old ones: deleted after logDays (src/log.js)
|
|
96
|
-
process.env.HEART_LOG_RUN = logOn ? 'on' : 'off' // how it starts
|
|
97
|
-
}
|
|
98
85
|
|
|
99
86
|
process.argv = [process.argv[0], fileURLToPath(new URL('./heartcode.js', import.meta.url)), ...args]
|
|
100
87
|
await import('./heartcode.js')
|
package/bin/heartcode.js
CHANGED
|
@@ -7,6 +7,7 @@ import { probe, loadProfile, strategy, describe, profilePath, profileFrom } from
|
|
|
7
7
|
import { learnFromUsage, LIMIT_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
|
+
import { checkUpdate, installKind, UPDATE_COMMANDS, packageDir, whatsNew } from '../src/update.js'
|
|
10
11
|
import { treeItems, codePlan, move, leaving, leftText, leftFiles } from '../src/tree.js'
|
|
11
12
|
import { UI, c, PERMISSIONS, duration, copyText, rank, setTheme, themeCodes, renderDiff, diffLines, DEFAULT_KEYS, loadKeys, width } from '../src/ui.js'
|
|
12
13
|
import { listFiles, runCommand, clip } from '../src/tools.js'
|
|
@@ -80,6 +81,7 @@ ${c.bold('headless')} (for other programs; flags and output as in Claude Code's
|
|
|
80
81
|
--skills-dir <dir> more skills (repeatable)
|
|
81
82
|
--allowedTools <list> only these tools (HeartCode's or Claude Code's names: Read, Edit, Bash…)
|
|
82
83
|
--disallowedTools <list> never these tools
|
|
84
|
+
--model-choice <order|fit> your models' order (#1, then the next), or the best fit for each task
|
|
83
85
|
--permission-mode <m> all, commands, ask, plan (or bypassPermissions, acceptEdits, default);
|
|
84
86
|
--dangerously-skip-permissions = all. Nothing is asked: the rest is declined
|
|
85
87
|
--session-id <id> start (or continue) the session with this id
|
|
@@ -93,7 +95,7 @@ ${c.bold('headless')} (for other programs; flags and output as in Claude Code's
|
|
|
93
95
|
${c.bold('editors')} heartcode --acp the Agent Client Protocol on stdin/stdout (Zed, JetBrains, Neovim)
|
|
94
96
|
|
|
95
97
|
${c.bold('env')} HEART_BASE_URL, HEART_MODEL, HEART_API_KEY (or OPENAI_BASE_URL / OPENAI_API_KEY)
|
|
96
|
-
HEART_LOG=<file>
|
|
98
|
+
HEART_LOG=<file> every kind of log of this run in that one file, whatever is switched on (off: none)
|
|
97
99
|
|
|
98
100
|
${c.bold('in a session')} attach an image with @path/to/shot.png · /help for commands`
|
|
99
101
|
|
|
@@ -126,6 +128,7 @@ const SECTIONS = [
|
|
|
126
128
|
['/import', 'bring commands, skills, MCP servers and memory from other CLIs'],
|
|
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'],
|
|
131
|
+
['/update', 'install the newest HeartCode (shows what changed first)'],
|
|
129
132
|
['/mcp', 'your MCP servers and whether each needs signing in'],
|
|
130
133
|
['/login_mcp', 'sign in (again) to a remote MCP server', true],
|
|
131
134
|
['/compact', 'summarize the conversation to free up context (add what to keep)', true],
|
|
@@ -149,7 +152,7 @@ const SLASH = helpText(SECTIONS)
|
|
|
149
152
|
|
|
150
153
|
// The keyboard shortcuts, as [keys, what] rows, read from the effective keybindings (keybindings.json
|
|
151
154
|
// can change any of them) plus the fixed ones (Space, Enter, Esc, Shift+Tab, Ctrl+C).
|
|
152
|
-
function keysHelp(keys = {}) {
|
|
155
|
+
function keysHelp(keys = {}, mouse = false) {
|
|
153
156
|
const NAMES = { pageup: 'PgUp', pagedown: 'PgDn', up: '↑', down: '↓', left: '←', right: '→', ctrl: 'Ctrl', alt: 'Alt', shift: 'Shift' }
|
|
154
157
|
const pretty = (k) => k.split('+').map((p) => NAMES[p] ?? (p.length === 1 ? p.toUpperCase() : p[0].toUpperCase() + p.slice(1))).join('+')
|
|
155
158
|
const forAct = (a) => Object.entries(keys).filter(([, v]) => v === a).map(([k]) => pretty(k)).join(' / ')
|
|
@@ -171,11 +174,13 @@ function keysHelp(keys = {}) {
|
|
|
171
174
|
[forAct('send_all'), 'queue: send all now'],
|
|
172
175
|
[forAct('queue_mode'), 'queue: one by one, or all together'],
|
|
173
176
|
[[forAct('scroll_up'), forAct('scroll_down')].filter(Boolean).join(' / '), 'scroll the conversation a page'],
|
|
177
|
+
[[forAct('scroll_top'), forAct('scroll_bottom')].filter(Boolean).join(' / '), 'to the top / bottom of the conversation (scrolled up, it stays put while the answer comes in)'],
|
|
174
178
|
[[forAct('scroll_line_up'), forAct('scroll_line_down')].filter(Boolean).join(' / '), 'scroll a few lines'],
|
|
175
179
|
['Ctrl+C', 'stop · twice quits HeartCode'],
|
|
176
|
-
['Drag', 'select and copy: the conversation, a dialog, the folder, the input, the status bar'],
|
|
177
|
-
['Double-click', 'copy the word under it (an address, a path, a model)'],
|
|
178
|
-
[process.platform === 'darwin' ? 'Option+drag' : 'Shift+drag', "the terminal's own selection, past HeartCode's"],
|
|
180
|
+
[mouse ? 'Drag' : '', 'select and copy: the conversation, a dialog, the folder, the input, the status bar'],
|
|
181
|
+
[mouse ? 'Double-click' : '', 'copy the word under it (an address, a path, a model)'],
|
|
182
|
+
[mouse ? (process.platform === 'darwin' ? 'Option+drag' : 'Shift+drag') : '', "the terminal's own selection, past HeartCode's"],
|
|
183
|
+
[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)'],
|
|
179
184
|
].filter(([k]) => k)
|
|
180
185
|
return rows
|
|
181
186
|
}
|
|
@@ -374,6 +379,7 @@ class App {
|
|
|
374
379
|
// to the window (a command can run for minutes). Nothing goes on with an old copy.
|
|
375
380
|
client.refresh = () => {
|
|
376
381
|
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
|
|
377
383
|
if (stampOf(profilePath(client)) !== stamp) client.onUse({ provider: client.provider, model: client.model })
|
|
378
384
|
}
|
|
379
385
|
// What this run learned about the model, onto its file as it is now: the rest (what you set up for
|
|
@@ -585,7 +591,7 @@ class App {
|
|
|
585
591
|
// Built-in commands (/name), then the skills you can type, namespaced as /skill:name so they're
|
|
586
592
|
// easy to tell apart from HeartCode's own commands (and can't clash with them).
|
|
587
593
|
commands() {
|
|
588
|
-
const mine = [...this.skills.values()].filter((k) => k.use
|
|
594
|
+
const mine = [...this.skills.values()].filter((k) => k.use === 'me' || k.use === 'both').map((k) => [`/skill:${k.name}`, k.description, true]).sort(byName)
|
|
589
595
|
return [...COMMANDS, ...mine]
|
|
590
596
|
}
|
|
591
597
|
|
|
@@ -603,7 +609,7 @@ class App {
|
|
|
603
609
|
const mine = this.commands().slice(COMMANDS.length)
|
|
604
610
|
const sections = [...SECTIONS]
|
|
605
611
|
if (mine.length) sections.push(['your skills (type /skill:name)', mine])
|
|
606
|
-
sections.push(['keyboard', keysHelp(this.ui.keys)])
|
|
612
|
+
sections.push(['keyboard', keysHelp(this.ui.keys, this.cfg?.mouse === true)])
|
|
607
613
|
return helpText(sections)
|
|
608
614
|
}
|
|
609
615
|
|
|
@@ -674,7 +680,7 @@ class App {
|
|
|
674
680
|
const rotated = rot && rot.at > 0
|
|
675
681
|
const name = rotated ? c.yellow('↻ ' + now.model) : c.info(now.model)
|
|
676
682
|
const model =
|
|
677
|
-
count === 1 ? name : cfg.session ? `${name} ${c.faint(`(${count} chosen)`)}` : `${c.muted('auto')} ${c.faint('(')}${name}${c.faint(')')} ${c.faint(`(${count})`)}`
|
|
683
|
+
count === 1 ? name : cfg.session ? `${name} ${c.faint(`(${count} chosen)`)}` : `${c.muted(fitMode(cfg) ? 'best fit' : 'auto')} ${c.faint('(')}${name}${c.faint(')')} ${c.faint(`(${count})`)}`
|
|
678
684
|
const key = `${now.provider}/${now.model}`
|
|
679
685
|
if (this.profileKey !== key) [this.profileKey, this.profile] = [key, this.s?.profile ?? loadProfile(this.client(now.provider, now.model))]
|
|
680
686
|
const profile = this.s?.profile ?? this.profile
|
|
@@ -692,6 +698,7 @@ class App {
|
|
|
692
698
|
autocompact: cfg.autoCompact === false ? c.faint('auto-compact off') : null,
|
|
693
699
|
worktree: this.worktree ? c.info(`⎇ ${this.worktree.branch}`) : null,
|
|
694
700
|
background: runningJobs(this.root).length ? c.info(`⚙ ${runningJobs(this.root).length} running`) + c.faint(' Alt+B') : null,
|
|
701
|
+
update: this.update?.newer ? c.green(`⬆ ${this.update.latest}`) + c.faint(' /update') : null,
|
|
695
702
|
permissions: { all: c.green('⏵⏵ all allowed'), commands: c.yellow('ask before commands'), ask: c.yellow('ask before changes'), plan: c.info('⏸ plan mode') }[ui.permission],
|
|
696
703
|
}
|
|
697
704
|
if (strat) {
|
|
@@ -707,8 +714,8 @@ class App {
|
|
|
707
714
|
const sep = c.ghost(' │ ')
|
|
708
715
|
const vis = (str) => width(str.replace(/\x1b\[[0-9;]*m/g, ''))
|
|
709
716
|
let layout = Array.isArray(cfg.statusBar) && cfg.statusBar.length ? cfg.statusBar : DEFAULT_STATUS
|
|
710
|
-
// commands
|
|
711
|
-
if (parts
|
|
717
|
+
// background commands and a newer HeartCode are shown also on a bar laid out before there were these items
|
|
718
|
+
for (const id of ['update', 'background']) if (parts[id] && !JSON.stringify(layout).includes(`"${id}"`)) layout = [...layout.slice(0, -1), ...layout.slice(-1).map((row) => (Array.isArray(row) ? { left: row, right: [id] } : { ...row, right: [id, ...(row.right ?? [])] }))]
|
|
712
719
|
const line = (row) => {
|
|
713
720
|
const names = (g) => (g ?? []).map((t) => parts[t]).filter(Boolean).join(sep)
|
|
714
721
|
const left = names(Array.isArray(row) ? row : row?.left)
|
|
@@ -772,6 +779,8 @@ class App {
|
|
|
772
779
|
Object.assign(this.s, { noFormat: cfg.format === false, noLsp: cfg.lsp === false })
|
|
773
780
|
Object.assign(this.s, { mcp: this.mcp, memory: this.memory, skills: this.skills, director: this.director })
|
|
774
781
|
this.s.team = () => this.team() // your other models: a job this one can't do goes to one of them
|
|
782
|
+
this.s.allModels = () => this.sessionModels().map((t) => ({ ...t, ...this.abilities(t) })) // all of them, for a best-fit pick
|
|
783
|
+
this.s.fitMode = () => fitMode(this.cfg) // models picked by strengths per message, not by the list's order
|
|
775
784
|
this.s.engineFor = (t) => this.engine(t.provider, t.model, ui, undefined, { quiet: true })
|
|
776
785
|
// A model's context window, read from its saved profile (no probe, no network): so the agent can
|
|
777
786
|
// see, before compacting, whether another model in the list has room for the whole conversation.
|
|
@@ -1169,6 +1178,10 @@ let settingsPage = null
|
|
|
1169
1178
|
|
|
1170
1179
|
// The browser, with a page. Windows: its URL handler (cmd's start mangles a URL whose arguments
|
|
1171
1180
|
// it reads as its own, and wants a quoted empty title first).
|
|
1181
|
+
// How HeartCode picks your models: "fit" (by strengths, per message) or your order; --model-choice for this run wins.
|
|
1182
|
+
let modelChoiceFlag
|
|
1183
|
+
const fitMode = (cfg) => (modelChoiceFlag ?? cfg.modelChoice) === 'fit'
|
|
1184
|
+
|
|
1172
1185
|
function openBrowser(url) {
|
|
1173
1186
|
if (process.env.HEART_NO_BROWSER) return
|
|
1174
1187
|
const [cmd, ...args] = process.platform === 'darwin' ? ['open', url] : process.platform === 'win32' ? ['rundll32', 'url.dll,FileProtocolHandler', url] : ['xdg-open', url]
|
|
@@ -1182,7 +1195,7 @@ function applySettings(apps, cfg, what) {
|
|
|
1182
1195
|
const before = themeCodes()
|
|
1183
1196
|
if (what === 'theme' || what === 'setting:theme') setTheme(cfg.theme)
|
|
1184
1197
|
if (what === 'prompts') reloadPrompts()
|
|
1185
|
-
if (['setting:log', 'setting:logRequests', 'setting:logDetail'].includes(what)) useRequestLog(cfg) //
|
|
1198
|
+
if (['setting:logs', 'setting:log', 'setting:logRequests', 'setting:logDetail'].includes(what)) useRequestLog(cfg) // each kind of log, on or off now
|
|
1186
1199
|
if (what === 'setting:logDays') pruneLogs(logDays(cfg))
|
|
1187
1200
|
settingsSeen(what) // the watcher (watchSettings) mustn't take it in a second time
|
|
1188
1201
|
for (const app of apps) {
|
|
@@ -1441,6 +1454,28 @@ async function slash(app, line, working = false) {
|
|
|
1441
1454
|
}
|
|
1442
1455
|
case 'help':
|
|
1443
1456
|
return ui.showText('Commands and keys', app.help())
|
|
1457
|
+
case 'update': {
|
|
1458
|
+
ui.spinner('asking npm for the newest HeartCode')
|
|
1459
|
+
const u = await checkUpdate({ force: true })
|
|
1460
|
+
ui.stopSpin()
|
|
1461
|
+
if (!u) return ui.warn("couldn't reach npm to check for a newer HeartCode")
|
|
1462
|
+
app.update = u
|
|
1463
|
+
ui.render?.()
|
|
1464
|
+
if (!u.newer) return ui.print(c.dim(`HeartCode ${u.current} is the newest`))
|
|
1465
|
+
const kind = installKind()
|
|
1466
|
+
const notes = await whatsNew(u.current, u.latest)
|
|
1467
|
+
if (kind === 'git') return ui.showText(`HeartCode ${u.latest} is out (you have ${u.current})`, `${notes || '(no changelog found)'}\n\nThis HeartCode runs from a git checkout (${packageDir}): update it there with git pull.`)
|
|
1468
|
+
const cmd = UPDATE_COMMANDS[kind]
|
|
1469
|
+
ui.showText(`HeartCode ${u.latest} is out (you have ${u.current})`, notes || '(no changelog found)')
|
|
1470
|
+
if ((await ui.confirm(`Update now with ${c.bold(cmd)}?`, 'command')) !== true) return ui.print(c.dim('not updated'))
|
|
1471
|
+
ui.spinner(`running ${cmd}`)
|
|
1472
|
+
const r = await runCommand(process.cwd(), cmd, { timeout: 300_000 })
|
|
1473
|
+
ui.stopSpin()
|
|
1474
|
+
if (r.code !== 0) return ui.warn(`the update failed (exit ${r.code}): ${r.output.trim().split('\n').slice(-3).join(' · ')}`)
|
|
1475
|
+
app.update = { ...u, newer: false }
|
|
1476
|
+
ui.render?.()
|
|
1477
|
+
return ui.print(`${c.green('✓')} HeartCode ${u.latest} installed ${c.dim('· restart HeartCode to use it (/exit, then heart)')}`)
|
|
1478
|
+
}
|
|
1444
1479
|
case 'select_model':
|
|
1445
1480
|
return app.pickModel(args, working)
|
|
1446
1481
|
case 'rename': {
|
|
@@ -1659,7 +1694,7 @@ async function slash(app, line, working = false) {
|
|
|
1659
1694
|
if (cmd.startsWith('skill:')) {
|
|
1660
1695
|
const name = cmd.slice(6)
|
|
1661
1696
|
const k = app.skills.get(name)
|
|
1662
|
-
if (k && k.use
|
|
1697
|
+
if (k && (k.use === 'me' || k.use === 'both')) return runTask(app, await app.expandSkill(k, args.join(' ')), { signal: app.signal })
|
|
1663
1698
|
return ui.print(`unknown skill /skill:${name} ${c.dim('· /help lists your skills')}`)
|
|
1664
1699
|
}
|
|
1665
1700
|
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
|
|
@@ -1713,7 +1748,7 @@ async function runTask(app, task, ctl) {
|
|
|
1713
1748
|
|
|
1714
1749
|
async function repl(app, f = {}) {
|
|
1715
1750
|
const { ui, cfg } = app
|
|
1716
|
-
ui.fullscreen()
|
|
1751
|
+
ui.fullscreen({ mouse: cfg.mouse === true }) // off: the terminal selects and copies text itself
|
|
1717
1752
|
ui.onDoubleEscape = () => '/rewind'
|
|
1718
1753
|
let ctl = null
|
|
1719
1754
|
ui.onEscape = () => ctl?.abort()
|
|
@@ -1805,6 +1840,16 @@ async function repl(app, f = {}) {
|
|
|
1805
1840
|
// models this folder picked earlier (/select_model): said, with the way back to your whole list
|
|
1806
1841
|
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 your whole list again`)}`)
|
|
1807
1842
|
app.tabs?.onChange?.() // the conversation it opened with
|
|
1843
|
+
// a newer HeartCode: asked in the background (once a day at most), said once and kept in the status bar
|
|
1844
|
+
if (cfg.updateCheck !== false)
|
|
1845
|
+
checkUpdate()
|
|
1846
|
+
.then((u) => {
|
|
1847
|
+
if (!u?.newer) return
|
|
1848
|
+
app.update = u
|
|
1849
|
+
ui.print(`${c.green('⬆')} ${c.muted('HeartCode')} ${c.green(u.latest)} ${c.muted(`is out (you have ${u.current})`)} ${c.faint('·')} ${c.cyan('/update')}`)
|
|
1850
|
+
ui.render?.()
|
|
1851
|
+
})
|
|
1852
|
+
.catch(() => {})
|
|
1808
1853
|
for (;;) {
|
|
1809
1854
|
const line = await ui.ask(` ${c.magenta('♥')} `, { suggest: true, initial: app.nextInput, history: true })
|
|
1810
1855
|
app.nextInput = undefined
|
|
@@ -1892,6 +1937,7 @@ async function main() {
|
|
|
1892
1937
|
disallowedTools: { type: 'string', multiple: true },
|
|
1893
1938
|
'disallowed-tools': { type: 'string', multiple: true },
|
|
1894
1939
|
'permission-mode': { type: 'string' },
|
|
1940
|
+
'model-choice': { type: 'string' },
|
|
1895
1941
|
'dangerously-skip-permissions': { type: 'boolean' },
|
|
1896
1942
|
'session-id': { type: 'string' },
|
|
1897
1943
|
effort: { type: 'string' },
|
|
@@ -1914,6 +1960,8 @@ async function main() {
|
|
|
1914
1960
|
if (f.context && !(Number(f.context) > 0)) throw new Error('--context must be a number of tokens')
|
|
1915
1961
|
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`)
|
|
1916
1962
|
if (f['permission-mode'] && !PERMISSION_MODES[f['permission-mode']]) throw new Error(`--permission-mode must be one of ${Object.keys(PERMISSION_MODES).join(', ')}`)
|
|
1963
|
+
if (f['model-choice'] && !['order', 'fit'].includes(f['model-choice'])) throw new Error('--model-choice must be order or fit')
|
|
1964
|
+
modelChoiceFlag = f['model-choice']
|
|
1917
1965
|
|
|
1918
1966
|
const cfg = loadConfig({ baseUrl: f['base-url'], model: f.model, apiKey: f['api-key'], context: f.context })
|
|
1919
1967
|
setTheme(cfg.theme)
|