heartcode 0.1.25 → 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,87 @@
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
+
5
86
  ## 0.1.25 (2026-10-31)
6
87
 
7
88
  - The model(s) you choose for a folder with /select_model are remembered per folder, in
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 })
@@ -528,31 +569,37 @@ class App {
528
569
  this.save()
529
570
  }
530
571
 
531
- // 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).
532
574
  commands() {
533
- const builtIn = new Set(COMMANDS.map(([n]) => n))
534
- 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])
535
576
  return [...COMMANDS, ...mine]
536
577
  }
537
578
 
538
- // A command: "/name …" with the name of a built-in command or a skill you can type. Anything else
539
- // 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.
540
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
541
584
  const name = /^\/([\w-]+)(?=\s|$)/.exec(line)?.[1]
542
- 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)
543
587
  }
544
588
 
545
589
  help() {
546
590
  const mine = this.commands().slice(COMMANDS.length)
547
- 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)
548
595
  }
549
596
 
550
- // "/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.
551
598
  async expandSkill(k, args) {
552
599
  let text = fillArgs(k.body, args).replace(/(^|\s)@([\w./-]+)/g, '$1$2') // @file: HeartCode attaches files a message names
553
600
  for (const m of [...text.matchAll(/!`([^`]+)`|```!\n([\s\S]*?)```/g)]) {
554
601
  const cmd = (m[1] ?? m[2]).trim()
555
- 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')
556
603
  const out = ok === true ? (await runCommand(this.root, cmd, { signal: this.signal })).output.trim() : '(not run)'
557
604
  log('skill', `/${k.name} ran ${cmd}`)
558
605
  text = text.replace(m[0], () => `\n\`\`\`\n$ ${cmd}\n${clip(out, 8000)}\n\`\`\`\n`)
@@ -596,56 +643,66 @@ class App {
596
643
  return rank(items, typed).slice(0, 200)
597
644
  }
598
645
 
599
- // The status bar: what's in use, its abilities, and how full the context is.
600
- 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) {
601
652
  const { cfg, ui } = this
602
- const sep = c.ghost(' │ ')
653
+ if (cfg.statusBar === false) return '' // turned off: no status bar at all
603
654
  if (!cfg.providers[cfg.provider] || !cfg.model) return c.dim('no model · /settings to choose one')
604
655
  const rot = this.s?.client.rotation
605
656
  const now = this.inUse() // the model list's one in use; never one of a provider that's off
606
657
  if (!now) return c.dim('the providers of all your models are off · /settings to switch one on')
607
- // provider (providers on) · the model. Auto (rotating your list): "auto (current model) (list
608
- // size)". A model you picked (pinned, no rotation): just its name.
609
658
  const on = Object.values(cfg.providers).filter((p) => !p.off).length
610
- // one model (pinned): just its name. Several chosen for this session: the one in use + "N chosen".
611
- // Your whole list (auto): "auto (in use) (N)". ↻ shows the rotation position while rotating.
612
659
  const count = this.sessionModels().length
613
- // the model answering now; a "↻" before it, in yellow, when it's a fallback (rotated to after one
614
- // failed) — so you can see at a glance it isn't the first/preferred one
660
+ // the model answering now; a yellow "↻" before it when it's a fallback (rotated to after one failed)
615
661
  const rotated = rot && rot.at > 0
616
- const name = rotated ? `${c.yellow('↻ ' + now.model)}` : c.info(now.model)
662
+ const name = rotated ? c.yellow('↻ ' + now.model) : c.info(now.model)
617
663
  const model =
618
- count === 1
619
- ? name
620
- : cfg.session
621
- ? `${name} ${c.faint(`(${count} chosen)`)}`
622
- : `${c.muted('auto')} ${c.faint('(')}${name}${c.faint(')')} ${c.faint(`(${count})`)}`
623
- // two lines so nothing is crammed: the model and what it can do, then the run's stats and controls
624
- const first = [`${c.brand('●')} ${c.muted(now.provider)} ${c.faint(`(${on})`)} ${c.ghost('·')} ${model}`]
625
- const second = []
664
+ count === 1 ? name : cfg.session ? `${name} ${c.faint(`(${count} chosen)`)}` : `${c.muted('auto')} ${c.faint('(')}${name}${c.faint(')')} ${c.faint(`(${count})`)}`
626
665
  const key = `${now.provider}/${now.model}`
627
666
  if (this.profileKey !== key) [this.profileKey, this.profile] = [key, this.s?.profile ?? loadProfile(this.client(now.provider, now.model))]
628
667
  const profile = this.s?.profile ?? this.profile
629
- if (profile) {
630
- const strat = this.s?.strat ?? strategy(profile, cfg)
631
- first.push(c.muted(strat.actions === 'tools' ? 'tools' : 'guided'))
632
- if (strat.thinking) first.push(c.think(`thinking${cfg.effort ? ` · ${cfg.effort}` : ''}`) + (ui.showThinking ? '' : c.faint(' (collapsed)')))
633
- if (strat.vision) first.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) {
634
684
  const used = this.s?.client.lastTokens ?? 0
635
685
  const pct = Math.round((used / strat.context) * 100)
636
686
  const paint = pct >= 80 ? c.red : pct >= 50 ? c.yellow : c.green
637
687
  const guess = strat.contextSure ? '' : '~' // not said by the server: assumed, and growing as bigger requests work
638
- second.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}%`)}`
639
689
  const tps = this.s?.client.tps
640
- if (tps) second.push(`${c.muted(String(tps))} ${c.faint('tok/s')}`)
641
- if (this.chat.usage?.priced) second.push(c.muted(money(this.chat.usage.cost)))
642
- } else {
643
- first.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))
644
692
  }
645
- if (cfg.autoCompact === false) second.push(c.faint('auto-compact off'))
646
- if (this.worktree) second.push(c.info(`⎇ ${this.worktree.branch}`))
647
- second.push({ all: c.green('⏵⏵ all allowed'), commands: c.yellow('ask before commands'), ask: c.yellow('ask before changes'), plan: c.info('⏸ plan mode') }[ui.permission]) // Shift+Tab changes it
648
- return [first.join(sep), second.join(sep)].filter((l) => l.replace(/\x1b\[[0-9;]*m/g, '').trim()).join('\n')
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')
649
706
  }
650
707
 
651
708
  client(name, model) {
@@ -998,7 +1055,7 @@ function applySettings(apps, cfg, what) {
998
1055
  const { ui } = app
999
1056
  const busy = Boolean(ui.busySince || app.working)
1000
1057
  const now = (fn) => (busy ? app.later.push(fn) : fn())
1001
- 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]
1002
1059
  // a model pinned in this CLI (/select_model) is a session choice: a model/order change on the
1003
1060
  // settings page leaves it alone (only /select_model auto here returns it to the list)
1004
1061
  if (what === 'model' && !app.cfg.session) {
@@ -1015,6 +1072,7 @@ function applySettings(apps, cfg, what) {
1015
1072
  }
1016
1073
  if (what === 'provider') app.lists = {} // its list switched on or off, a model added by name
1017
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
1018
1076
  if (what === 'setting:effort' && app.s?.strat.thinking) app.s.client.effort = cfg.effort
1019
1077
  if (what === 'setting:autoCompact' && app.s) app.s.autoCompact = cfg.autoCompact !== false
1020
1078
  if (what === 'setting:format' && app.s) app.s.noFormat = cfg.format === false
@@ -1163,6 +1221,18 @@ async function choose(ui, cmd, arg, title, current) {
1163
1221
  return (await ui.pick(title, ARGS[cmd].map(([label, desc]) => ({ label, desc, current: label === current }))))?.label ?? null
1164
1222
  }
1165
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
+
1166
1236
  async function slash(app, line) {
1167
1237
  const [cmd, ...args] = line.slice(1).trim().split(/\s+/)
1168
1238
  const { ui, cfg } = app
@@ -1175,7 +1245,7 @@ async function slash(app, line) {
1175
1245
  if (n > 1) {
1176
1246
  const go = await ui.pick(`Quit HeartCode? ${n} tabs are open`, [
1177
1247
  { label: 'Yes, quit', desc: 'they come back next time you start HeartCode here', yes: true },
1178
- { label: 'No', desc: 'Ctrl+Q closes just this tab' },
1248
+ { label: 'No', desc: 'Alt+W closes just this tab' },
1179
1249
  ])
1180
1250
  if (!go?.yes) return
1181
1251
  }
@@ -1198,7 +1268,7 @@ async function slash(app, line) {
1198
1268
  return ui.print(`${c.ok('✓')} ${c.muted(`reset: ${it.label.toLowerCase()}`)}${it.level === 'settings' ? '' : c.dim(' · add a provider on /settings')}`)
1199
1269
  }
1200
1270
  case 'settings': {
1201
- 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) })
1202
1272
  const { url, close } = await settingsPage
1203
1273
  openBrowser(url)
1204
1274
  ui.print(`${c.info('↗')} ${c.bold('settings')} ${c.muted('opened in your browser:')}\n ${c.faint(url)}`)
@@ -1315,19 +1385,45 @@ async function slash(app, line) {
1315
1385
  if (!s) return
1316
1386
  return s.tidyMemory(app.signal)
1317
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
+ }
1318
1413
  case 'login_mcp': {
1319
1414
  const remote = app.mcp.names.filter((n) => app.mcp.get(n).url)
1320
- 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
1321
1416
  if (!name) return remote.length ? undefined : ui.print('No remote MCP servers (ones with a "url") to sign in to.')
1322
- const sv = app.mcp.get(name)
1323
- if (!sv?.url) return ui.print(`No remote MCP server "${name}".`)
1324
- forget(sv.url) // a fresh sign-in
1325
- sv.stop()
1326
- Object.assign(sv, { token: null, tools: null })
1417
+ if (!app.mcp.get(name)?.url) return ui.print(`No remote MCP server "${name}".`)
1327
1418
  ui.spinner(`connecting to ${name}`)
1328
- const tools = await sv.listTools(app.signal)
1329
- ui.stopSpin()
1330
- 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
+ }
1331
1427
  }
1332
1428
  case 'import': {
1333
1429
  const items = findImports(app.root)
@@ -1346,6 +1442,21 @@ async function slash(app, line) {
1346
1442
  log('import', chosen.map((it) => `${it.group}: ${it.label}`))
1347
1443
  return
1348
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
+ }
1349
1460
  case 'btw':
1350
1461
  return app.btw(line.trim().replace(/^\/btw\b/, '').trim())
1351
1462
  case 'voice': {
@@ -1360,8 +1471,13 @@ async function slash(app, line) {
1360
1471
  if (!['model_info', 'test_model', 'compact'].includes(cmd)) {
1361
1472
  app.skills = loadSkills(app.root) // edits to skill files apply right away
1362
1473
  if (app.s) app.s.skills = app.skills
1363
- const k = app.skills.get(cmd)
1364
- 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
1365
1481
  return ui.print(`unknown command /${cmd} ${c.dim('· /help lists them')}`)
1366
1482
  }
1367
1483
  const s = await app.session()
@@ -1425,7 +1541,7 @@ async function repl(app, f = {}) {
1425
1541
  ui.close()
1426
1542
  process.exit(0)
1427
1543
  }
1428
- // 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
1429
1545
  let closing = false
1430
1546
  app.closeTab = async (working = false) => {
1431
1547
  if (closing) return
@@ -1448,7 +1564,7 @@ async function repl(app, f = {}) {
1448
1564
  ui.onCloseTab = () => {
1449
1565
  if (closing) return
1450
1566
  if (!ui.asking) return app.closeTab(true) // working: asked over the work
1451
- 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)
1452
1568
  ui.submit('/close_tab') // at the prompt: asked in its turn, like a typed /close_tab
1453
1569
  }
1454
1570
  const others = () => (app.tabs?.list.length ?? 1) - 1
@@ -1473,7 +1589,7 @@ async function repl(app, f = {}) {
1473
1589
  const where = home && app.root.startsWith(home) ? '~' + app.root.slice(home.length) : app.root
1474
1590
  ui.header = (cols = 100) => [
1475
1591
  `${c.brand('♥')} ${c.bright(c.bold('HeartCode'))} ${c.faint(VERSION)} ${c.muted(where.length > cols - 16 ? '…' + where.slice(-(cols - 17)) : where)}`,
1476
- [['/', '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(' · ')),
1477
1593
  '',
1478
1594
  ]
1479
1595
  if (!ui.full) ui.print(ui.header().join('\n'))
@@ -1495,6 +1611,7 @@ async function repl(app, f = {}) {
1495
1611
  if (!t) continue
1496
1612
  ctl = new AbortController()
1497
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
1498
1615
  ui.busy() // the spinner stays until this line's work is done
1499
1616
  if (app.isCommand(t)) {
1500
1617
  try {
@@ -1668,7 +1785,7 @@ async function main() {
1668
1785
  const app = new App(cfg, ui, root)
1669
1786
  usePromptsFrom(app.root) // its .heartcode/prompts override the built-in sections
1670
1787
  ui.suggest = (line, cursor) => app.suggest(line, cursor)
1671
- ui.status = () => app.status()
1788
+ ui.status = (cols) => app.status(cols)
1672
1789
  ui.requestSince = () => app.s?.client.inFlight // the spinner shows how long the model has been answering
1673
1790
  return app
1674
1791
  }
@@ -1679,7 +1796,7 @@ async function main() {
1679
1796
  log('worktree', `working in ${wt.dir} on ${wt.branch}`)
1680
1797
  process.on('exit', () => wt.done || activeUI?.noUser || console.error(c.dim(`worktree kept: ${wt.dir} (branch ${wt.branch})`)))
1681
1798
  }
1682
- // 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).
1683
1800
  if (!headless && !sub && !positionals.length && process.stdin.isTTY && process.stdout.isTTY) {
1684
1801
  if (f['resume-id'] && !loadChat(f['resume-id'])) throw new Error(`no session ${f['resume-id']}`)
1685
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.25",
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",
package/prompts/agent.md CHANGED
@@ -28,13 +28,15 @@ Language servers used in this project before: {{servers}}.{{/if}}
28
28
  Everything else (more features, clever code) comes after these two.
29
29
 
30
30
  ## Before you start: research, then plan
31
- 1. What you know is out of date: it stopped long before today. Before you build anything (an app, a feature, a setup, a library, a command you haven't run here), research it — the kind of thing it is and the tools you'll make it with, never the names in the request: those are what you're making (asked for an app called "Nimbus": research that kind of app, not "Nimbus"). Get everything the task needs to be done right, however much that is:
31
+ 1. First check what you already saved for this project. Before searching the web, look in memory (the memory tool, scope project) — you may have researched this exact thing before and saved it; if so, use that and skip the search.
32
+ 2. What you know is out of date: it stopped long before today. Before you build anything (an app, a feature, a setup, a library, a command you haven't run here), research it — the kind of thing it is and the tools you'll make it with, never the names in the request: those are what you're making (asked for an app called "Nimbus": research that kind of app, not "Nimbus"). Get everything the task needs to be done right, however much that is:
32
33
  - always the official source first — the tool's or library's own docs, site or repository — never a blog, a listicle or memory; web_search to find that official page (this year's, not your training years'), then web_fetch and read it, not just the snippet;
33
34
  - assume what you remember is stale and relearn it from that page: the current way to do it, the real API, the exact setup steps;
34
35
  - check each one's latest version (`npm view <pkg> version`, `pip index versions <pkg>`, …) and use the latest stable.
35
36
  Then follow those official docs — not what you remember: it changes between major versions.
36
- 2. Then plan the whole job before the first change: the end result in one line, then every step, in your todo list. Only a small, obvious task (one known edit, a question the code answers) skips this.
37
- 3. Something you're still not sure of after the research — what the user means (it can be read two ways that give different results) or a choice that's theirs: ask before you build, every question in one numbered message (ask_user). Then do the whole job.
37
+ 3. Save what you learned, for this project. When you've researched something you'll likely need again here — a library's current API and setup, a framework's conventions, a design direction and why — save it as a project note (memory tool, scope "project", type "reference") with the key facts and the official source URL. Next session (and the rest of this one) reuses it instead of searching again. Keep each note short and factual; don't save what the code or git history already shows.
38
+ 4. Then plan the whole job before the first change: the end result in one line, then every step, in your todo list. Only a small, obvious task (one known edit, a question the code answers) skips this.
39
+ 5. Something you're still not sure of after the research — what the user means (it can be read two ways that give different results) or a choice that's theirs: ask before you build, every question in one numbered message (ask_user). Then do the whole job.
38
40
 
39
41
  ## Before you say you're done: prove it works
40
42
  Whatever you made — not only web — run it and see it work with your own eyes before you finish. "It should work" and "no syntax error" are not proof. Match the check to what it is:
@@ -59,6 +61,11 @@ It must look excellent — clean, modern, consistent, as good as the best produc
59
61
  4. Command-line tools: check one with find_command just before you rely on it; a better one that's installed (rg over grep): use it.
60
62
  5. search and read_file always work: whatever fails above, fall back to them, never to giving up.
61
63
 
64
+ ## Writing code
65
+ 1. Reuse before you add. Before you write anything, look at what the project already has — a function, a helper, a type, a component, a pattern — and use it. Never write a second version of something that already lives here (DRY); search for it first. One change in a shared place beats the same change copied around.
66
+ 2. Keep it clean and minimal: the least code that does the job, in the project's existing style. No dead code, no copy-paste, no abstraction you don't need yet.
67
+ 3. Let the names do the explaining. Name variables, functions and types so plainly that the code reads on its own. Don't comment what the code already says — add a comment only for something genuinely non-obvious (a reason, a gotcha, a tricky invariant), never to narrate ordinary code.
68
+
62
69
  ## How you work
63
70
  1. You're only as good as what you know for this task: make yourself strong first. Before you do it, get everything it needs — the code it touches, the docs of what you'll use, the best current way and good examples — as much as it takes; there's no limit. Then do it, with all of that in front of you.
64
71
  2. Look things up together: every call that doesn't need another's result goes in the same reply — several searches, pages, files, commands to check at once; they run at the same time. One at a time only when the next call needs this one's result.
@@ -185,7 +192,10 @@ Ask a language server about the code. `server`: the command that starts it over
185
192
 
186
193
  ## tool-edit_file
187
194
 
188
- Change an existing file: replace `search`, copied exactly from the file (including indentation) and matching one place, with `replace`. For several changes, call it several times in one reply.
195
+ Change an existing file, two ways:
196
+ - By text: `search` (copied exactly from the file, indentation and all, matching one place) is replaced with `replace`.
197
+ - By line number: `start_line` (and `end_line` for a range) say which lines to replace with `replace` — no `search` needed. Use this when you know the line numbers (e.g. from read_file, which numbers them) or when a text match keeps failing; it can't mis-match.
198
+ Give one or the other, plus `path` and `replace` ("replace": "" deletes). For several changes, call it several times in one reply.
189
199
 
190
200
  ## tool-write_file
191
201
 
@@ -327,6 +337,11 @@ The plan is approved: go ahead with it now.
327
337
  {{items}}
328
338
  Carry on with them. If one is no longer needed or can't be done, update the list and say why.)
329
339
 
340
+ ## stopped-early
341
+
342
+ <!-- Sent when the model named a next step but stopped without doing it (no tool call followed). -->
343
+ (You described a next step but stopped before doing it. If the task isn't fully done, do the rest now with the tools — actually make the change, don't just say you will. If everything the user asked for is truly complete and verified, reply with your final result and nothing else.)
344
+
330
345
  ## hook-blocked-prompt
331
346
 
332
347
  <!-- HeartCode's answer when a UserPromptSubmit hook blocked the message. {{reason}}: what the hook said. -->
package/prompts/guided.md CHANGED
@@ -12,6 +12,7 @@ You are HeartCode, a precise coding agent working inside the user's project.
12
12
  HeartCode drives the work in small steps. Each message asks you ONE thing — answer exactly that, in the form asked, and nothing else: no explanation, no extra text.
13
13
  Base every answer on what you are shown, never on a guess: don't invent a file path, a name, a flag or code that isn't there. When you write code, write it complete and correct — no placeholders, and keep what should stay.
14
14
  Your memory of any external tool, library or API is out of date: get its current official docs online (search, then read the page) before using it, and follow the docs, not memory.
15
+ Reuse what the project already has instead of writing it twice; keep code clean with clear names, and no comments unless something is genuinely non-obvious.
15
16
 
16
17
  ## context
17
18