heartcode 0.1.24 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,99 @@
2
2
 
3
3
  What changed in each version of HeartCode, newest first.
4
4
 
5
+ ## 0.1.27 (2026-10-31)
6
+
7
+ - A built-in computer-use MCP server (@zavora-ai/computer-use-mcp), off by default: switch it on in
8
+ /settings → MCP servers (or see it with /mcp) to let a capable vision model control your desktop —
9
+ screenshots, mouse, keyboard, clipboard. It's off by default because it controls your whole machine
10
+ and needs the OS's screen/accessibility permission and a model that's good at computer use.
11
+ - /mcp now lists installed-but-off servers too (marked "off"), not only the running ones.
12
+
13
+ - Features that need an outside tool now say so. The settings page's General tab has an "External
14
+ tools" card that lists each such feature (voice input, browser preview/UI review, installing skills
15
+ from GitHub), ticks the ready ones, and grays out the rest with what to install — just the name of
16
+ what's needed, since how to install it differs by OS. /doctor shows the same in the CLI.
17
+
18
+ - MCP servers now show whether they need signing in. In the CLI, /mcp lists every server with its
19
+ status: "local · no sign-in", "signed in", or "sign-in needed". In the settings page, each remote
20
+ server on the MCP page shows a "signed in" / "sign-in needed" badge and a Sign in button (it opens
21
+ your browser; available when the page was opened from HeartCode with /settings). Local servers show
22
+ no sign-in, since they don't need it.
23
+
24
+ - The settings page's Skills page can install a skill from a GitHub repo or URL (owner/repo, a repo
25
+ link, or a link to a SKILL.md) — the /install_skill command, now a button and input. Skills show
26
+ with the /skill: prefix throughout the page.
27
+ - The settings page can import from other coding CLIs (the /import command): "Import from other tools"
28
+ on the Skills page lists the skills, commands, MCP servers, instructions and memory found in Claude
29
+ Code, Cursor, Gemini CLI and Codex, grouped with checkboxes, and brings in what you tick.
30
+
31
+ - /install_skill <github repo or SKILL.md url> installs a skill straight from GitHub (or any URL) —
32
+ "user/repo", a repo link, a .git URL, or a link to a SKILL.md. It clones (or downloads a tarball)
33
+ and installs every skill it finds; add --project to keep it to this folder. Run it as /skill:<name>.
34
+ - /help now lists the keyboard shortcuts (voice, tabs, the message queue, scrolling, permissions,
35
+ stop), read from your effective keybindings.
36
+
37
+ - Skills are now typed as /skill:name, so they're easy to tell apart from HeartCode's own commands
38
+ (and can't clash with them). The command menu and /help show the /skill: form; typing a bare
39
+ /name of a skill points you to /skill:name. Built-in commands (/help, /settings, …) are unchanged.
40
+ - The settings page (/settings) has a visual Status bar editor: drag items into each line, drop some
41
+ on the right to push them to the edge, add or remove lines, turn the whole bar off, and see a live
42
+ preview — no editing config.json by hand. Saved changes apply to a running HeartCode right away.
43
+ - Before building, HeartCode now checks what the project already has and reuses it (DRY), keeps code
44
+ clean with self-explaining names, and adds comments only where something is genuinely non-obvious.
45
+ - Research is remembered per project: HeartCode checks the project's memory before searching, and
46
+ saves what it learns (a library's API, setup, a design direction, with the source) as a project
47
+ note, so later sessions reuse it instead of searching again.
48
+ - Esc no longer stops a running task on a single stray tap: it asks for a second Esc within 2.5s
49
+ first. Flushing the queue (Alt+S / Alt+A) still stops at once.
50
+ - When the model describes a next step but stops without doing it, HeartCode nudges it once to finish
51
+ the work (alongside the existing nudge for unfinished todo items).
52
+ - The status bar is configurable. "statusBar" in config.json is a list of lines; each line is a list
53
+ of item names (all left-aligned) or { "left": [...], "right": [...] } to push some to the right
54
+ edge. Item names: provider, model, mode, thinking, images, ctx, tps, cost, autocompact, worktree,
55
+ permissions. "statusBar": false hides the whole bar. Left out, it keeps the default two-line
56
+ layout. Changes to config.json apply live. Example:
57
+ "statusBar": [["provider", "model"], { "left": ["ctx", "tps"], "right": ["permissions"] }]
58
+ - Text you type while the model is answering keeps its cursor: when the answer finishes, the cursor
59
+ stays where it was in what you'd typed, instead of jumping to the start of the line.
60
+ - The built-in keyboard shortcuts moved off Ctrl, which collided with the shell and line editing
61
+ (Ctrl+N/P history, Ctrl+T transpose, Ctrl+Q flow-control, Ctrl+\ quit), onto Alt/Option: tabs are
62
+ Alt+T (new), Alt+W (close), Alt+N/Alt+P (switch, and Alt+1…9 to jump); the message queue is Alt+S
63
+ (send first), Alt+A (send all), Alt+M (change when-done). Ctrl+PgUp/PgDn still cycle tabs for
64
+ terminals without an Option-as-Meta key. Scrolling (Shift+↑↓, Alt+↑↓) is unchanged. On macOS
65
+ Terminal.app, Alt shortcuts need "Use Option as Meta key" on (Settings → Profiles → Keyboard);
66
+ keybindings.json can remap any of them.
67
+ - Voice input without the /voice command: when voice is set up, press Space while the input box is
68
+ empty and it starts listening straight away (Space again to pause, Enter to finish, Esc to cancel).
69
+ The shortcut is shown in the header hint ("Space talk (voice)"). With text already in the box, or
70
+ when voice isn't set up, Space types a space as before.
71
+
72
+ ## 0.1.26 (2026-10-31)
73
+
74
+ - edit_file can now change a file by line number: give start_line (and end_line for a range) with the
75
+ new replace text and no search is needed — so a weak model that can't reproduce the file's exact
76
+ bytes can still edit it, and a line edit can't mis-match. "replace": "" with a range deletes those
77
+ lines. Text-based search still works exactly as before.
78
+ - A failed edit_file (the SEARCH text not matching) no longer sends the model in circles. The error
79
+ now shows a line-by-line diff of what it sent (✗) against what the file actually has (✓) at the
80
+ right place — found by how alike the lines are, not loose word overlap — so a one-character or
81
+ whitespace mistake is obvious. If the same file misses twice in a row, the error includes the file
82
+ itself with line numbers (the whole thing if short, else the lines around the target) and steers
83
+ the model to edit by line number (start_line/end_line), copy an exact block, or use write_file —
84
+ so it can't keep guessing. The count clears once an edit to that file lands.
85
+
86
+ ## 0.1.25 (2026-10-31)
87
+
88
+ - The model(s) you choose for a folder with /select_model are remembered per folder, in
89
+ .heartcode/models.json, and restored when you open that folder again; auto stays auto (the file
90
+ is removed). A -m model on the command line still wins for that run.
91
+ - The status bar and the working spinner use two lines instead of cramming everything onto one: the
92
+ status shows the model and what it can do on one line, the run's stats and controls on the next;
93
+ the spinner shows what it's doing, with the elapsed time and Esc on the line below.
94
+ - When a chosen set or auto rotates to a fallback (the model answering now isn't your first/preferred
95
+ one, because it failed), the status bar marks that model with a yellow "↻" so you can see at a
96
+ glance it came after rotating. No rotation, or back on the first model: no marker.
97
+
5
98
  ## 0.1.24 (2026-10-31)
6
99
 
7
100
  - A pinned model (one picked with /select_model, or -m) is now used by the helpers it spawns too:
package/README.md CHANGED
@@ -28,7 +28,7 @@ tried did what I needed. In short, HeartCode:
28
28
  - **Logs each request and its reply** in a file of its own, when you switch logging on, so you
29
29
  can see what went wrong.
30
30
  - **Takes skills, MCP servers and hooks** in Claude Code's formats; `/import` brings yours over.
31
- - **Has tabs** (`Ctrl+T`), each with its own conversation, and git worktrees for work kept apart.
31
+ - **Has tabs** (`Alt+T`), each with its own conversation, and git worktrees for work kept apart.
32
32
 
33
33
  ## How I set it up and use it
34
34
 
package/bin/heartcode.js CHANGED
@@ -7,17 +7,18 @@ import { probe, loadProfile, strategy, describe, profilePath, profileFrom } from
7
7
  import { learnFromUsage, LIMIT_MS } from '../src/context.js'
8
8
  import { Session, transcript } from '../src/agent.js'
9
9
  import { treeItems, codePlan, move, leaving, leftText, leftFiles } from '../src/tree.js'
10
- import { UI, c, PERMISSIONS, duration, copyText, rank, setTheme, themeCodes, renderDiff, diffLines, DEFAULT_KEYS, loadKeys } from '../src/ui.js'
10
+ import { UI, c, PERMISSIONS, duration, copyText, rank, setTheme, themeCodes, renderDiff, diffLines, DEFAULT_KEYS, loadKeys, width } from '../src/ui.js'
11
11
  import { listFiles, runCommand, clip } from '../src/tools.js'
12
12
  import { log, LOG_FILE, LOG_DIR, requestLog, useRequestLog, useLogs, pruneLogs, logDays } from '../src/log.js'
13
13
  import { prompt, usePromptsFrom, reloadPrompts } from '../src/prompts.js'
14
14
  import { newChat, saveChat, listChats, loadChat, restoreFiles, ago, forkChat, exportChat } from '../src/sessions.js'
15
15
  import { loadPrices, priceOf, addUsage, money, limitsOf } from '../src/usage.js'
16
- import { Mcp } from '../src/mcp.js'
16
+ import { Mcp, mcpAuth, loadServers } from '../src/mcp.js'
17
17
  import { forget } from '../src/oauth.js'
18
18
  import { loadSkills, fillArgs, extraSkillDirs } from '../src/skills.js'
19
19
  import { HeadlessUI, runHeadless, toolNames, PERMISSION_MODES } from '../src/headless.js'
20
- import { findImports } from '../src/importer.js'
20
+ import { findImports, installSkill } from '../src/importer.js'
21
+ import { capabilities } from '../src/capabilities.js'
21
22
  import { spawnSync } from 'node:child_process'
22
23
  import fs from 'node:fs'
23
24
  import { Memory } from '../src/memory.js'
@@ -119,21 +120,53 @@ const SECTIONS = [
119
120
  ['/test_model', 'test the model for real (otherwise what it can do comes from models.dev, or your settings)'],
120
121
  ['/tidy_memory', 'merge, update and link the memory notes now'],
121
122
  ['/import', 'bring commands, skills, MCP servers and memory from other CLIs'],
123
+ ['/install_skill', 'install a skill from a GitHub repo or a SKILL.md URL (add --project for this folder only)', true],
124
+ ['/doctor', 'check the outside tools HeartCode features need (voice, browser, git) and what to install'],
125
+ ['/mcp', 'your MCP servers and whether each needs signing in'],
122
126
  ['/login_mcp', 'sign in (again) to a remote MCP server', true],
123
127
  ['/compact', 'summarize the conversation to free up context (add what to keep)', true],
124
128
  ['/clear_chat', 'forget the conversation'],
125
129
  ['/reset', "HeartCode's settings (or also providers, or everything) back to the start; asks for a code first"],
126
130
  ['/settings', 'change providers, models, settings, MCP servers, hooks, keys and skills in your browser'],
127
131
  ['/help', 'this list'],
128
- ['/tab', 'a new tab (Ctrl+T): another conversation beside this one · /tab worktree [name]: in its own git worktree · /tab 2: go to tab 2 (Ctrl+N/P) · Ctrl+Q closes one', true],
129
- ['/close_tab', 'close this tab (Ctrl+Q); asks first'],
130
- ['/exit', 'quit HeartCode (Ctrl+Q closes just this tab)'],
132
+ ['/tab', 'a new tab (Alt+T): another conversation beside this one · /tab worktree [name]: in its own git worktree · /tab 2: go to tab 2 (Alt+N/P) · Alt+W closes one', true],
133
+ ['/close_tab', 'close this tab (Alt+W); asks first'],
134
+ ['/exit', 'quit HeartCode (Alt+W closes just this tab)'],
131
135
  ]],
132
136
  ]
133
137
  const COMMANDS = SECTIONS.flatMap(([, list]) => list)
134
138
  const helpText = (sections) => sections.map(([title, list]) => ` ${c.bold(title)}\n` + list.map(([n, d]) => ` ${c.cyan(n.padEnd(18))} ${d}`).join('\n')).join('\n\n')
135
139
  const SLASH = helpText(SECTIONS)
136
140
 
141
+ // The keyboard shortcuts, as [keys, what] rows, read from the effective keybindings (keybindings.json
142
+ // can change any of them) plus the fixed ones (Space, Enter, Esc, Shift+Tab, Ctrl+C).
143
+ function keysHelp(keys = {}) {
144
+ const NAMES = { pageup: 'PgUp', pagedown: 'PgDn', up: '↑', down: '↓', left: '←', right: '→', ctrl: 'Ctrl', alt: 'Alt', shift: 'Shift' }
145
+ const pretty = (k) => k.split('+').map((p) => NAMES[p] ?? (p.length === 1 ? p.toUpperCase() : p[0].toUpperCase() + p.slice(1))).join('+')
146
+ const forAct = (a) => Object.entries(keys).filter(([, v]) => v === a).map(([k]) => pretty(k)).join(' / ')
147
+ const tabs = /(^|,)alt\+[1-9]/.test(Object.keys(keys).join(','))
148
+ const rows = [
149
+ ['Space', 'start voice input (when the input box is empty)'],
150
+ ['Enter', 'send · while it works, queue the message'],
151
+ ['Option/Shift/Ctrl+Enter', 'new line in the box'],
152
+ ['Esc', 'stop the task (press twice to confirm)'],
153
+ ['Esc Esc', 'rewind to an earlier message (at the prompt)'],
154
+ ['Shift+Tab', 'change what runs without asking (permissions)'],
155
+ [forAct('new_tab'), 'new tab'],
156
+ [forAct('close_tab'), 'close this tab'],
157
+ [forAct('next_tab'), 'next tab'],
158
+ [forAct('prev_tab'), 'previous tab'],
159
+ [tabs ? 'Alt+1…9' : '', 'go to tab 1–9'],
160
+ [forAct('send_first'), 'queue: send the first one now'],
161
+ [forAct('send_all'), 'queue: send all now'],
162
+ [forAct('queue_mode'), 'queue: one by one, or all together'],
163
+ [[forAct('scroll_up'), forAct('scroll_down')].filter(Boolean).join(' / '), 'scroll the conversation a page'],
164
+ [[forAct('scroll_line_up'), forAct('scroll_line_down')].filter(Boolean).join(' / '), 'scroll a few lines'],
165
+ ['Ctrl+C', 'stop · twice quits HeartCode'],
166
+ ].filter(([k]) => k)
167
+ return rows
168
+ }
169
+
137
170
  const HOWTO = `${c.yellow('No model set up yet.')} Add a provider and choose its models in your browser:
138
171
 
139
172
  ${c.cyan('/settings')} (or ${c.cyan('heart settings')} in another terminal)
@@ -156,6 +189,14 @@ const kTokens = (n) => (n >= 1e6 ? `${Math.round(n / 1e5) / 10}M` : n >= 1000 ?
156
189
 
157
190
  const mask = (k) => (k ? (k.length > 12 ? `${k.slice(0, 4)}…${k.slice(-4)}` : '…') : c.dim('no key'))
158
191
 
192
+ // The status bar's default layout (two lines): the model and what it can do, then the run's stats and
193
+ // controls — model and context on the left, abilities and controls pushed to the right. cfg.statusBar
194
+ // overrides it — see App.status for the item names and format.
195
+ const DEFAULT_STATUS = [
196
+ { left: ['provider', 'model'], right: ['mode', 'thinking', 'images'] },
197
+ { left: ['ctx', 'tps', 'autocompact'], right: ['permissions', 'worktree', 'cost'] },
198
+ ]
199
+
159
200
  class App {
160
201
  constructor(cfg, ui, root) {
161
202
  Object.assign(this, { cfg, ui, root })
@@ -168,6 +209,23 @@ class App {
168
209
  this.director = new Director(this) // the manage tool: skills, MCP servers and settings by asking
169
210
  this.later = [] // setting changes that wait until the current message is done
170
211
  this.failures = {} // "provider model" → failed requests this session (engine: onFail)
212
+ this.loadProjectModels() // the model(s) you last chose for this folder (.heartcode/models.json)
213
+ }
214
+
215
+ // Per folder: the model set you picked with /select_model, remembered in .heartcode/models.json and
216
+ // restored when you open this folder again. Absent/empty means auto (your whole list). A -m model
217
+ // from the command line (cfg.session already set) wins and isn't overwritten.
218
+ loadProjectModels() {
219
+ if (this.cfg.session) return
220
+ const saved = readJson(path.join(this.root, '.heartcode', 'models.json'), null)
221
+ const valid = (saved?.session ?? []).filter((t) => t?.provider && t?.model && this.cfg.providers[t.provider])
222
+ if (valid.length) this.cfg.session = valid
223
+ }
224
+
225
+ saveProjectModels() {
226
+ const file = path.join(this.root, '.heartcode', 'models.json')
227
+ if (this.cfg.session?.length) writeJson(file, { session: this.cfg.session.map((t) => ({ provider: t.provider, model: t.model })) })
228
+ else fs.rmSync(file, { force: true }) // auto: forget the folder's choice
171
229
  }
172
230
 
173
231
  newMcp() {
@@ -511,31 +569,37 @@ class App {
511
569
  this.save()
512
570
  }
513
571
 
514
- // Built-in commands, then the skills you can type (a built-in wins on the same name).
572
+ // Built-in commands (/name), then the skills you can type, namespaced as /skill:name so they're
573
+ // easy to tell apart from HeartCode's own commands (and can't clash with them).
515
574
  commands() {
516
- const builtIn = new Set(COMMANDS.map(([n]) => n))
517
- const mine = [...this.skills.values()].filter((k) => k.use !== 'model' && !builtIn.has(`/${k.name}`)).map((k) => [`/${k.name}`, k.description, true])
575
+ const mine = [...this.skills.values()].filter((k) => k.use !== 'model').map((k) => [`/skill:${k.name}`, k.description, true])
518
576
  return [...COMMANDS, ...mine]
519
577
  }
520
578
 
521
- // A command: "/name …" with the name of a built-in command or a skill you can type. Anything else
522
- // starting with "/" (a path like /Users/me/shot.png) is a message for the model.
579
+ // A command: a built-in "/name", or a skill "/skill:name". A bare "/name" that matches a skill is
580
+ // still caught (slash points it to /skill:name). Anything else starting with "/" (a path like
581
+ // /Users/me/shot.png) is a message for the model.
523
582
  isCommand(line) {
583
+ if (/^\s*\/skill:\S/.test(line)) return true // any /skill:x is a command attempt; slash() says if the skill is unknown
524
584
  const name = /^\/([\w-]+)(?=\s|$)/.exec(line)?.[1]
525
- return Boolean(name) && (name === 'quit' || this.commands().some(([n]) => n === `/${name}`))
585
+ if (!name) return false
586
+ return name === 'quit' || COMMANDS.some(([n]) => n === `/${name}`) || this.skills.has(name)
526
587
  }
527
588
 
528
589
  help() {
529
590
  const mine = this.commands().slice(COMMANDS.length)
530
- return helpText(mine.length ? [...SECTIONS, ['your skills', mine]] : SECTIONS)
591
+ const sections = [...SECTIONS]
592
+ if (mine.length) sections.push(['your skills (type /skill:name)', mine])
593
+ sections.push(['keyboard', keysHelp(this.ui.keys)])
594
+ return helpText(sections)
531
595
  }
532
596
 
533
- // "/review focus on tests": the skill's text, arguments filled in, `!command` output added.
597
+ // "/skill:review focus on tests": the skill's text, arguments filled in, `!command` output added.
534
598
  async expandSkill(k, args) {
535
599
  let text = fillArgs(k.body, args).replace(/(^|\s)@([\w./-]+)/g, '$1$2') // @file: HeartCode attaches files a message names
536
600
  for (const m of [...text.matchAll(/!`([^`]+)`|```!\n([\s\S]*?)```/g)]) {
537
601
  const cmd = (m[1] ?? m[2]).trim()
538
- const ok = await this.ui.confirm(`Run ${c.bold(cmd)} (from /${k.name})?`, 'command')
602
+ const ok = await this.ui.confirm(`Run ${c.bold(cmd)} (from /skill:${k.name})?`, 'command')
539
603
  const out = ok === true ? (await runCommand(this.root, cmd, { signal: this.signal })).output.trim() : '(not run)'
540
604
  log('skill', `/${k.name} ran ${cmd}`)
541
605
  text = text.replace(m[0], () => `\n\`\`\`\n$ ${cmd}\n${clip(out, 8000)}\n\`\`\`\n`)
@@ -579,53 +643,66 @@ class App {
579
643
  return rank(items, typed).slice(0, 200)
580
644
  }
581
645
 
582
- // The status bar: what's in use, its abilities, and how full the context is.
583
- status() {
646
+ // The status bar. The layout is config-driven (cfg.statusBar): a list of lines, each either a list
647
+ // of item names (all left-aligned) or { left: [...], right: [...] } to push some to the right edge.
648
+ // Item names: provider, model, mode, thinking, images, ctx, tps, cost, autocompact, worktree,
649
+ // permissions. cfg.statusBar === false hides the whole bar. Unknown names and items that don't
650
+ // apply right now are skipped. `cols` (from the renderer) is used to right-align.
651
+ status(cols = 100) {
584
652
  const { cfg, ui } = this
585
- const sep = c.ghost(' │ ')
653
+ if (cfg.statusBar === false) return '' // turned off: no status bar at all
586
654
  if (!cfg.providers[cfg.provider] || !cfg.model) return c.dim('no model · /settings to choose one')
587
655
  const rot = this.s?.client.rotation
588
656
  const now = this.inUse() // the model list's one in use; never one of a provider that's off
589
657
  if (!now) return c.dim('the providers of all your models are off · /settings to switch one on')
590
- // provider (providers on) · the model. Auto (rotating your list): "auto (current model) (list
591
- // size)". A model you picked (pinned, no rotation): just its name.
592
658
  const on = Object.values(cfg.providers).filter((p) => !p.off).length
593
- // one model (pinned): just its name. Several chosen for this session: the one in use + "N chosen".
594
- // Your whole list (auto): "auto (in use) (N)". ↻ shows the rotation position while rotating.
595
659
  const count = this.sessionModels().length
596
- const spin = rot ? c.faint(` ↻ ${rot.at + 1}/${rot.list.length}`) : ''
660
+ // the model answering now; a yellow "↻" before it when it's a fallback (rotated to after one failed)
661
+ const rotated = rot && rot.at > 0
662
+ const name = rotated ? c.yellow('↻ ' + now.model) : c.info(now.model)
597
663
  const model =
598
- count === 1
599
- ? c.info(now.model)
600
- : cfg.session
601
- ? `${c.info(now.model)} ${c.faint(`(${count} chosen)`)}${spin}`
602
- : `${c.muted('auto')} ${c.faint('(')}${c.info(now.model)}${c.faint(')')} ${c.faint(`(${count})`)}${spin}`
603
- const parts = [`${c.brand('●')} ${c.muted(now.provider)} ${c.faint(`(${on})`)} ${c.ghost('·')} ${model}`]
664
+ count === 1 ? name : cfg.session ? `${name} ${c.faint(`(${count} chosen)`)}` : `${c.muted('auto')} ${c.faint('(')}${name}${c.faint(')')} ${c.faint(`(${count})`)}`
604
665
  const key = `${now.provider}/${now.model}`
605
666
  if (this.profileKey !== key) [this.profileKey, this.profile] = [key, this.s?.profile ?? loadProfile(this.client(now.provider, now.model))]
606
667
  const profile = this.s?.profile ?? this.profile
607
- if (profile) {
608
- const strat = this.s?.strat ?? strategy(profile, cfg)
609
- parts.push(c.muted(strat.actions === 'tools' ? 'tools' : 'guided'))
610
- if (strat.thinking) parts.push(c.think(`thinking${cfg.effort ? ` · ${cfg.effort}` : ''}`) + (ui.showThinking ? '' : c.faint(' (collapsed)')))
611
- if (strat.vision) parts.push(c.muted('images'))
668
+ const strat = profile && (this.s?.strat ?? strategy(profile, cfg))
669
+ // each item, rendered (or null when it doesn't apply)
670
+ const parts = {
671
+ provider: `${c.brand('●')} ${c.muted(now.provider)} ${c.faint(`(${on})`)}`,
672
+ model,
673
+ mode: strat ? c.muted(strat.actions === 'tools' ? 'tools' : 'guided') : c.dim('not probed yet'),
674
+ thinking: strat?.thinking ? c.think(`thinking${cfg.effort ? ` · ${cfg.effort}` : ''}`) + (ui.showThinking ? '' : c.faint(' (collapsed)')) : null,
675
+ images: strat?.vision ? c.muted('images') : null,
676
+ ctx: null,
677
+ tps: null,
678
+ cost: null,
679
+ autocompact: cfg.autoCompact === false ? c.faint('auto-compact off') : null,
680
+ worktree: this.worktree ? c.info(`⎇ ${this.worktree.branch}`) : null,
681
+ 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],
682
+ }
683
+ if (strat) {
612
684
  const used = this.s?.client.lastTokens ?? 0
613
685
  const pct = Math.round((used / strat.context) * 100)
614
686
  const paint = pct >= 80 ? c.red : pct >= 50 ? c.yellow : c.green
615
687
  const guess = strat.contextSure ? '' : '~' // not said by the server: assumed, and growing as bigger requests work
616
- parts.push(`${c.faint('ctx')} ${paint(`${kTokens(used)}/${guess}${kTokens(strat.context)}`)} ${c.faint(`${pct}%`)}`)
688
+ parts.ctx = `${c.faint('ctx')} ${paint(`${kTokens(used)}/${guess}${kTokens(strat.context)}`)} ${c.faint(`${pct}%`)}`
617
689
  const tps = this.s?.client.tps
618
- if (tps) parts.push(`${c.muted(String(tps))} ${c.faint('tok/s')}`)
619
- if (this.chat.usage?.priced) parts.push(c.muted(money(this.chat.usage.cost)))
620
- } else {
621
- parts.push(c.dim('not probed yet'))
690
+ if (tps) parts.tps = `${c.muted(String(tps))} ${c.faint('tok/s')}`
691
+ if (this.chat.usage?.priced) parts.cost = c.muted(money(this.chat.usage.cost))
622
692
  }
623
- if (cfg.autoCompact === false) parts.push(c.faint('auto-compact off'))
624
- if (this.worktree) parts.push(c.info(`⎇ ${this.worktree.branch}`))
625
-
626
- const perm = { all: c.green('⏵⏵ all allowed'), commands: c.yellow('ask before commands'), ask: c.yellow('ask before changes'), plan: c.info('⏸ plan mode') }[ui.permission]
627
- parts.push(perm) // Shift+Tab changes it (see the header)
628
- return parts.join(sep)
693
+ const sep = c.ghost(' │ ')
694
+ const vis = (str) => width(str.replace(/\x1b\[[0-9;]*m/g, ''))
695
+ const layout = Array.isArray(cfg.statusBar) && cfg.statusBar.length ? cfg.statusBar : DEFAULT_STATUS
696
+ const line = (row) => {
697
+ const names = (g) => (g ?? []).map((t) => parts[t]).filter(Boolean).join(sep)
698
+ const left = names(Array.isArray(row) ? row : row?.left)
699
+ const right = names(Array.isArray(row) ? null : row?.right)
700
+ if (!right) return left
701
+ if (!left) return right
702
+ const pad = cols - 1 - vis(left) - vis(right) - 1 // the renderer adds a leading space; keep 1 to spare on the right
703
+ return pad > 0 ? left + ' '.repeat(pad) + right : `${left}${sep}${right}` // too narrow to split: just join
704
+ }
705
+ return layout.map(line).filter((l) => l.replace(/\x1b\[[0-9;]*m/g, '').trim()).join('\n')
629
706
  }
630
707
 
631
708
  client(name, model) {
@@ -771,20 +848,23 @@ class App {
771
848
  return cfg.session.filter((t) => cfg.providers[t.provider] && (all || !cfg.providers[t.provider].off) && t.model && !seen.has(`${t.provider}/${t.model}`) && seen.add(`${t.provider}/${t.model}`))
772
849
  }
773
850
 
774
- // Use a chosen set of models for this session (session-local, not saved): one pins it (no
775
- // rotation), several rotate among just those. The saved ranking (settings page / auto) is untouched.
851
+ // Use a chosen set of models for this session: one pins it (no rotation), several rotate among
852
+ // just those. Remembered for this folder (.heartcode/models.json); the saved ranking is untouched.
776
853
  async setSession(list) {
777
854
  const { cfg } = this
778
- cfg.session = list // only here; cfg.provider/model stay your global #1, so your whole list and the picker are unchanged
855
+ cfg.session = list // the global #1 (cfg.provider/model) stays, so your whole list and the picker are unchanged
856
+ this.saveProjectModels()
779
857
  this.s = null
780
- this.ui.print(list.length === 1 ? `${c.green('using')} ${c.cyan(list[0].model)} ${c.dim('· pinned for this session')}` : `${c.green(`using ${list.length} models this session`)}: ${c.cyan(list.map((t) => t.model).join(', '))}`)
858
+ this.ui.print(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(', '))}`)
781
859
  await this.session()
782
860
  }
783
861
 
784
- // Back to auto: your whole list again (#1, then the next when one fails), following the saved ranking.
862
+ // Back to auto: your whole list again (#1, then the next when one fails), following the saved
863
+ // ranking. The folder's remembered choice is cleared.
785
864
  async auto() {
786
865
  const { cfg } = this
787
- delete cfg.session // back to your whole list (cfg.provider/model + the ranking)
866
+ delete cfg.session
867
+ this.saveProjectModels()
788
868
  this.s = null
789
869
  this.ui.print(`${c.green('using')} ${c.dim('auto')} ${c.cyan(`(${this.myModels().length} models)`)}`)
790
870
  await this.session()
@@ -975,7 +1055,7 @@ function applySettings(apps, cfg, what) {
975
1055
  const { ui } = app
976
1056
  const busy = Boolean(ui.busySince || app.working)
977
1057
  const now = (fn) => (busy ? app.later.push(fn) : fn())
978
- if (app.cfg !== cfg) for (const k of ['providers', 'provider', 'model', 'effort', 'theme', 'context', 'autoCompact', 'director', 'format', 'lsp', 'voice', 'rotation']) app.cfg[k] = cfg[k]
1058
+ 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]
979
1059
  // a model pinned in this CLI (/select_model) is a session choice: a model/order change on the
980
1060
  // settings page leaves it alone (only /select_model auto here returns it to the list)
981
1061
  if (what === 'model' && !app.cfg.session) {
@@ -992,6 +1072,7 @@ function applySettings(apps, cfg, what) {
992
1072
  }
993
1073
  if (what === 'provider') app.lists = {} // its list switched on or off, a model added by name
994
1074
  if (what === 'setting:permissions') ui.setPermission(cfg.permissions)
1075
+ if (what === 'setting:statusBar') ui.render?.() // the status bar's layout changed: redraw it now
995
1076
  if (what === 'setting:effort' && app.s?.strat.thinking) app.s.client.effort = cfg.effort
996
1077
  if (what === 'setting:autoCompact' && app.s) app.s.autoCompact = cfg.autoCompact !== false
997
1078
  if (what === 'setting:format' && app.s) app.s.noFormat = cfg.format === false
@@ -1140,6 +1221,18 @@ async function choose(ui, cmd, arg, title, current) {
1140
1221
  return (await ui.pick(title, ARGS[cmd].map(([label, desc]) => ({ label, desc, current: label === current }))))?.label ?? null
1141
1222
  }
1142
1223
 
1224
+ // Fresh sign-in to a remote MCP server: forget the old token, reconnect (opens the browser via
1225
+ // app.mcp.onSignIn), list its tools. Used by /login_mcp and the settings page's Sign in button.
1226
+ async function signInMcp(app, name, signal) {
1227
+ const sv = app.mcp.get(name)
1228
+ if (!sv?.url) throw new Error(`no remote MCP server "${name}"`)
1229
+ forget(sv.url)
1230
+ sv.stop()
1231
+ Object.assign(sv, { token: null, tools: null })
1232
+ const tools = await sv.listTools(signal)
1233
+ return `signed in to ${name} · ${tools.length} tools`
1234
+ }
1235
+
1143
1236
  async function slash(app, line) {
1144
1237
  const [cmd, ...args] = line.slice(1).trim().split(/\s+/)
1145
1238
  const { ui, cfg } = app
@@ -1152,7 +1245,7 @@ async function slash(app, line) {
1152
1245
  if (n > 1) {
1153
1246
  const go = await ui.pick(`Quit HeartCode? ${n} tabs are open`, [
1154
1247
  { label: 'Yes, quit', desc: 'they come back next time you start HeartCode here', yes: true },
1155
- { label: 'No', desc: 'Ctrl+Q closes just this tab' },
1248
+ { label: 'No', desc: 'Alt+W closes just this tab' },
1156
1249
  ])
1157
1250
  if (!go?.yes) return
1158
1251
  }
@@ -1175,7 +1268,7 @@ async function slash(app, line) {
1175
1268
  return ui.print(`${c.ok('✓')} ${c.muted(`reset: ${it.label.toLowerCase()}`)}${it.level === 'settings' ? '' : c.dim(' · add a provider on /settings')}`)
1176
1269
  }
1177
1270
  case 'settings': {
1178
- settingsPage ??= startSettings({ cfg, apply: (what) => applySettings(app.tabs ? app.tabs.list.map((t) => t.app) : [app], cfg, what) })
1271
+ 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) })
1179
1272
  const { url, close } = await settingsPage
1180
1273
  openBrowser(url)
1181
1274
  ui.print(`${c.info('↗')} ${c.bold('settings')} ${c.muted('opened in your browser:')}\n ${c.faint(url)}`)
@@ -1292,19 +1385,45 @@ async function slash(app, line) {
1292
1385
  if (!s) return
1293
1386
  return s.tidyMemory(app.signal)
1294
1387
  }
1388
+ case 'doctor': {
1389
+ const caps = capabilities(cfg)
1390
+ const rows = caps.map((cp) => {
1391
+ const head = ` ${cp.ok ? c.green('✓') : c.red('✗')} ${c.bold(cp.name)}${cp.ok ? c.dim(' · ready') : c.yellow(' · needs setup')}`
1392
+ return cp.ok ? head : `${head}\n ${c.faint(`install ${cp.need}`)}`
1393
+ })
1394
+ return ui.print(`${c.bold('External tools HeartCode features use')}\n${rows.join('\n')}`)
1395
+ }
1396
+ case 'mcp': {
1397
+ const all = loadServers(app.root, { includeDisabled: true }) // enabled and off, so off ones are visible
1398
+ const names = Object.keys(all)
1399
+ if (!names.length) return ui.print('No MCP servers. Add one in /settings → MCP servers, or /import from another CLI.')
1400
+ const running = new Set(app.mcp.names)
1401
+ const label = { local: c.dim('local · no sign-in'), in: c.green('signed in'), out: c.yellow('sign-in needed') }
1402
+ const rows = names.map((n) => {
1403
+ const cfg = all[n]
1404
+ const on = running.has(n)
1405
+ const where = cfg.url ?? [cfg.command, ...(cfg.args ?? [])].filter(Boolean).join(' ')
1406
+ const head = on ? `${c.brand('●')} ${c.bold(n.padEnd(16))} ${label[mcpAuth(cfg)]}` : `${c.dim('○')} ${c.dim(n.padEnd(16))} ${c.dim('off')}`
1407
+ return ` ${head}\n ${c.faint(clip(where, 90))}`
1408
+ })
1409
+ const needs = names.some((n) => running.has(n) && mcpAuth(all[n]) === 'out')
1410
+ const off = names.some((n) => !running.has(n))
1411
+ return ui.print(`${c.bold('MCP servers')}\n${rows.join('\n')}${needs ? `\n ${c.dim('sign in to a remote one with /login_mcp <name>')}` : ''}${off ? `\n ${c.dim('turn one on in /settings → MCP servers')}` : ''}`)
1412
+ }
1295
1413
  case 'login_mcp': {
1296
1414
  const remote = app.mcp.names.filter((n) => app.mcp.get(n).url)
1297
- const name = args[0] ?? (await ui.pick('Sign in to which server?', remote.map((n) => ({ label: n, desc: app.mcp.get(n).url }))))?.label
1415
+ const name = args[0] ?? (await ui.pick('Sign in to which server?', remote.map((n) => ({ label: n, desc: app.mcp.get(n).url, hint: mcpAuth(app.mcp.get(n).cfg) === 'in' ? 'signed in' : 'not signed in' }))))?.label
1298
1416
  if (!name) return remote.length ? undefined : ui.print('No remote MCP servers (ones with a "url") to sign in to.')
1299
- const sv = app.mcp.get(name)
1300
- if (!sv?.url) return ui.print(`No remote MCP server "${name}".`)
1301
- forget(sv.url) // a fresh sign-in
1302
- sv.stop()
1303
- Object.assign(sv, { token: null, tools: null })
1417
+ if (!app.mcp.get(name)?.url) return ui.print(`No remote MCP server "${name}".`)
1304
1418
  ui.spinner(`connecting to ${name}`)
1305
- const tools = await sv.listTools(app.signal)
1306
- ui.stopSpin()
1307
- return ui.print(`${c.green('connected')} ${c.bold(name)} · ${tools.length} tools`)
1419
+ try {
1420
+ const msg = await signInMcp(app, name, app.signal)
1421
+ ui.stopSpin()
1422
+ return ui.print(`${c.green('✓')} ${msg}`)
1423
+ } catch (e) {
1424
+ ui.stopSpin()
1425
+ return ui.print(`${c.red('✗')} ${e.message}`)
1426
+ }
1308
1427
  }
1309
1428
  case 'import': {
1310
1429
  const items = findImports(app.root)
@@ -1323,6 +1442,21 @@ async function slash(app, line) {
1323
1442
  log('import', chosen.map((it) => `${it.group}: ${it.label}`))
1324
1443
  return
1325
1444
  }
1445
+ case 'install_skill': {
1446
+ const url = args.find((a) => !a.startsWith('--'))
1447
+ if (!url) return ui.print('Usage: /install_skill <github repo or a SKILL.md url> [--project]')
1448
+ const scope = args.includes('--project') ? 'project' : 'global'
1449
+ ui.spinner(`installing from ${url}`)
1450
+ try {
1451
+ const msg = await installSkill(app.root, url, scope, { signal: app.signal })
1452
+ ui.stopSpin()
1453
+ app.reload('skill')
1454
+ return ui.print(`${c.green('✓')} ${msg}${scope === 'project' ? ' (this folder)' : ''} ${c.dim('· run with /skill:<name>, /help lists them')}`)
1455
+ } catch (e) {
1456
+ ui.stopSpin()
1457
+ return ui.print(`${c.red('✗')} could not install: ${e.message}`)
1458
+ }
1459
+ }
1326
1460
  case 'btw':
1327
1461
  return app.btw(line.trim().replace(/^\/btw\b/, '').trim())
1328
1462
  case 'voice': {
@@ -1337,8 +1471,13 @@ async function slash(app, line) {
1337
1471
  if (!['model_info', 'test_model', 'compact'].includes(cmd)) {
1338
1472
  app.skills = loadSkills(app.root) // edits to skill files apply right away
1339
1473
  if (app.s) app.s.skills = app.skills
1340
- const k = app.skills.get(cmd)
1341
- if (k && k.use !== 'model') return runTask(app, await app.expandSkill(k, args.join(' ')), { signal: app.signal })
1474
+ if (cmd.startsWith('skill:')) {
1475
+ const name = cmd.slice(6)
1476
+ const k = app.skills.get(name)
1477
+ if (k && k.use !== 'model') return runTask(app, await app.expandSkill(k, args.join(' ')), { signal: app.signal })
1478
+ return ui.print(`unknown skill /skill:${name} ${c.dim('· /help lists your skills')}`)
1479
+ }
1480
+ 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
1342
1481
  return ui.print(`unknown command /${cmd} ${c.dim('· /help lists them')}`)
1343
1482
  }
1344
1483
  const s = await app.session()
@@ -1402,7 +1541,7 @@ async function repl(app, f = {}) {
1402
1541
  ui.close()
1403
1542
  process.exit(0)
1404
1543
  }
1405
- // Ctrl+Q, /close_tab: this tab, after asking (working: that stops too); the last one quits
1544
+ // Alt+W, /close_tab: this tab, after asking (working: that stops too); the last one quits
1406
1545
  let closing = false
1407
1546
  app.closeTab = async (working = false) => {
1408
1547
  if (closing) return
@@ -1425,7 +1564,7 @@ async function repl(app, f = {}) {
1425
1564
  ui.onCloseTab = () => {
1426
1565
  if (closing) return
1427
1566
  if (!ui.asking) return app.closeTab(true) // working: asked over the work
1428
- if (!ui.histOn || ui.menu.pick) return ui.notice('Answer this first, then Ctrl+Q', 2000)
1567
+ if (!ui.histOn || ui.menu.pick) return ui.notice('Answer this first, then Alt+W', 2000)
1429
1568
  ui.submit('/close_tab') // at the prompt: asked in its turn, like a typed /close_tab
1430
1569
  }
1431
1570
  const others = () => (app.tabs?.list.length ?? 1) - 1
@@ -1450,7 +1589,7 @@ async function repl(app, f = {}) {
1450
1589
  const where = home && app.root.startsWith(home) ? '~' + app.root.slice(home.length) : app.root
1451
1590
  ui.header = (cols = 100) => [
1452
1591
  `${c.brand('♥')} ${c.bright(c.bold('HeartCode'))} ${c.faint(VERSION)} ${c.muted(where.length > cols - 16 ? '…' + where.slice(-(cols - 17)) : where)}`,
1453
- [['/', 'run a command'], ['@', 'attach a file'], [NEWLINE_KEY, 'add a new line'], ['Esc', 'stop'], ['Shift+Tab', 'change permissions']].map(([k, d]) => `${c.muted(k)} ${c.faint(d)}`).join(c.ghost(' · ')),
1592
+ [['/', 'run a command'], ['@', 'attach a file'], ...(ui.voiceReady?.() ? [['Space', 'talk (voice)']] : []), [NEWLINE_KEY, 'add a new line'], ['Esc', 'stop'], ['Shift+Tab', 'change permissions']].map(([k, d]) => `${c.muted(k)} ${c.faint(d)}`).join(c.ghost(' · ')),
1454
1593
  '',
1455
1594
  ]
1456
1595
  if (!ui.full) ui.print(ui.header().join('\n'))
@@ -1472,6 +1611,7 @@ async function repl(app, f = {}) {
1472
1611
  if (!t) continue
1473
1612
  ctl = new AbortController()
1474
1613
  app.signal = ctl.signal // Esc stops whatever this line started (a task, a probe, …)
1614
+ ui.escArm = 0 // a fresh task: a first Esc from before doesn't count toward stopping this one
1475
1615
  ui.busy() // the spinner stays until this line's work is done
1476
1616
  if (app.isCommand(t)) {
1477
1617
  try {
@@ -1645,7 +1785,7 @@ async function main() {
1645
1785
  const app = new App(cfg, ui, root)
1646
1786
  usePromptsFrom(app.root) // its .heartcode/prompts override the built-in sections
1647
1787
  ui.suggest = (line, cursor) => app.suggest(line, cursor)
1648
- ui.status = () => app.status()
1788
+ ui.status = (cols) => app.status(cols)
1649
1789
  ui.requestSince = () => app.s?.client.inFlight // the spinner shows how long the model has been answering
1650
1790
  return app
1651
1791
  }
@@ -1656,7 +1796,7 @@ async function main() {
1656
1796
  log('worktree', `working in ${wt.dir} on ${wt.branch}`)
1657
1797
  process.on('exit', () => wt.done || activeUI?.noUser || console.error(c.dim(`worktree kept: ${wt.dir} (branch ${wt.branch})`)))
1658
1798
  }
1659
- // The full screen: in tabs (the first one is this folder; /tab and Ctrl+T open more).
1799
+ // The full screen: in tabs (the first one is this folder; /tab and Alt+T open more).
1660
1800
  if (!headless && !sub && !positionals.length && process.stdin.isTTY && process.stdout.isTTY) {
1661
1801
  if (f['resume-id'] && !loadChat(f['resume-id'])) throw new Error(`no session ${f['resume-id']}`)
1662
1802
  const saved = readJson(TABS_FILE, {})[root] // before this run's first tab replaces it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartcode",
3
- "version": "0.1.24",
3
+ "version": "0.1.27",
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",