heartcode 0.1.56 → 0.1.58

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,32 @@
2
2
 
3
3
  What changed in each version of HeartCode, newest first.
4
4
 
5
+ ## 0.1.58 (2026-11-07)
6
+
7
+ - **Helpers you pick**: on Your models, a Helper column: a switch (can #1 start this model for a part
8
+ of a task?) and four pills for what it's good at: UI & visuals, Code & logic, Big & hard, Quick &
9
+ cheap (hover one: what it covers, and what a click does). A click saves at once; #1 is told only
10
+ your helpers and what each is good at, and a job with no model named goes to the first helper.
11
+ Reviews go to the Code & logic ones first. None picked: everything works as before.
12
+ - **Suggest helpers**: every model that answered its test (#1 too, also ones without tool calls),
13
+ each with what it's good at: the top half of LMArena's web-app or coding ranking, thinking with a
14
+ big context or a place in its new agent and hardest-prompts rankings, a fast test. Shown dashed,
15
+ taken all at once or one by one. Not tested yet: a dialog offers Test all first, saying how many
16
+ of your models may charge for it.
17
+ - **Picked for you**: Helpers in the list's settings: HeartCode picks them, again after Update model
18
+ info, a test run or a new order; a click on a pill makes them yours again.
19
+ - **Helpers picked in your order or by provider**: beside Order providers; your list stays as it is.
20
+ - A Helpers filter; Save order is now Save list.
21
+
22
+ ## 0.1.57 (2026-11-06)
23
+
24
+ - **The `/settings` link can be copied over SSH**: while the page is on, the mouse is the terminal's,
25
+ so you select the link and copy it as usual (some terminals, like macOS Terminal, drop the copy
26
+ HeartCode sends through them). The link is shorter and stays on one row at 80 columns, uses the
27
+ address you reached the machine at, and no browser is started on the remote machine. Copies sent
28
+ through the terminal now say "if your terminal allows it".
29
+ - **Turning the page off closes it**: no second box to close; Enter, Esc or Ctrl+C turn it off.
30
+
5
31
  ## 0.1.56 (2026-11-05)
6
32
 
7
33
  - **Questions as tabs**: several questions come in one dialog, a tab each; go back and forth with
package/README.md CHANGED
@@ -129,7 +129,7 @@ On **Models → Providers**:
129
129
  On **Models → Your list**:
130
130
 
131
131
  1. **Sort.** Click *Abilities*, then *Context*: the most capable models come first, the biggest
132
- context window first among those. Click **Save order**.
132
+ context window first among those. Click **Save list**.
133
133
  2. **Drag rows** to fine-tune. #1 is the one HeartCode uses; the rest are its fallbacks, in order.
134
134
  3. **Test** (optional): **Test all** sends each model a short message and shows which answer and
135
135
  how fast (*Works?*). Sort by it to put the fastest first.
package/bin/heartcode.js CHANGED
@@ -2,14 +2,14 @@
2
2
  import path from 'node:path'
3
3
  import { parseArgs } from 'node:util'
4
4
  import { Client, limitSaid, estMessages } from '../src/client.js'
5
- import { loadConfig, saveConfig, readJson, writeJson, providerName, CONFIG_FILE, HOME, TEMP, AUTO_MODEL, isAuto, parseModel, takeIn, whatOf, VERSION, speedOf } from '../src/config.js'
5
+ import { loadConfig, saveConfig, readJson, writeJson, providerName, CONFIG_FILE, HOME, TEMP, AUTO_MODEL, isAuto, parseModel, takeIn, whatOf, VERSION, speedOf, jobsOf } from '../src/config.js'
6
6
  import { loadProfile, strategy, describe, profilePath, profileFrom } from '../src/probe.js'
7
7
  import { learnFromUsage, LIMIT_MS, RATE_CAP_MS } from '../src/context.js'
8
8
  import { Session, transcript, contextReport } from '../src/agent.js'
9
9
  import { listJobs, getJob, stopJob, removeJob, runningJobs, tailLines, ago as ranFor } from '../src/background.js'
10
10
  import { checkUpdate, installKind, UPDATE_COMMANDS, packageDir, whatsNew } from '../src/update.js'
11
11
  import { treeItems, codePlan, move, leaving, leftText, leftFiles } from '../src/tree.js'
12
- import { UI, c, PERMISSIONS, duration, copyText, rank, setTheme, themeCodes, renderDiff, diffLines, DEFAULT_KEYS, loadKeys, width, shortError, wrapWords } from '../src/ui.js'
12
+ import { UI, c, PERMISSIONS, duration, copyText, overSsh, rank, setTheme, themeCodes, renderDiff, diffLines, DEFAULT_KEYS, loadKeys, width, shortError, wrapWords } from '../src/ui.js'
13
13
  import { listFiles, runCommand, clip } from '../src/tools.js'
14
14
  import { notify } from '../src/telegram.js'
15
15
  import { log, LOG_FILE, LOG_DIR, requestLog, useRequestLog, useLogs, pruneLogs, logDays } from '../src/log.js'
@@ -848,7 +848,18 @@ class App {
848
848
  const now = this.s?.client.rotation?.list[this.s.client.rotation.at] ?? this.sessionModels()[0]
849
849
  return this.sessionModels()
850
850
  .filter((t) => !(t.provider === now?.provider && t.model === now?.model))
851
- .map((t) => ({ ...t, ...this.abilities(t) }))
851
+ .map((t) => ({ ...t, ...this.abilities(t), jobs: jobsOf(this.cfg.helpers?.[`${t.provider}/${t.model}`]) })) // jobs: ticked as a helper on Your models (what for)
852
+ .sort(this.byProvider()) // helpers picked in your list's order, or your provider ranking's (Your models)
853
+ }
854
+
855
+ // Your models' "Helper order": by your provider ranking, a sort that puts the higher-ranked
856
+ // provider's models first (each provider's in your list's order; providers not ranked after, A to
857
+ // Z); in your list's order, one that keeps it.
858
+ byProvider() {
859
+ const rank = this.cfg.helperOrder === 'provider' && Array.isArray(this.cfg.providerRank) ? this.cfg.providerRank : null
860
+ if (!rank) return () => 0
861
+ const at = (p) => (rank.includes(p) ? rank.indexOf(p) : rank.length)
862
+ return (a, b) => at(a.provider) - at(b.provider) || (at(a.provider) === rank.length ? a.provider.localeCompare(b.provider) : 0)
852
863
  }
853
864
 
854
865
  // What a model can do, from its saved profile or models.dev (guessed: neither knows it).
@@ -1205,7 +1216,7 @@ let settingsPage = null
1205
1216
  const effortOf = (cfg) => cfg.effort ?? 'low'
1206
1217
 
1207
1218
  function openBrowser(url) {
1208
- if (process.env.HEART_NO_BROWSER) return
1219
+ if (process.env.HEART_NO_BROWSER || overSsh) return // over SSH your browser isn't on this machine
1209
1220
  const [cmd, ...args] = process.platform === 'darwin' ? ['open', url] : process.platform === 'win32' ? ['rundll32', 'url.dll,FileProtocolHandler', url] : ['xdg-open', url]
1210
1221
  spawnSync(cmd, args, { stdio: 'ignore' })
1211
1222
  }
@@ -1440,15 +1451,17 @@ async function slash(app, line, working = false) {
1440
1451
  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) })
1441
1452
  const { url, local, close } = await settingsPage
1442
1453
  openBrowser(local)
1443
- ui.print(`${c.info('↗')} ${c.bold('settings')} ${c.muted('opened in your browser:')}\n ${c.faint(url)}`)
1454
+ if (!ui.full) ui.print(`${c.info('↗')} ${c.bold('settings')} ${c.muted(overSsh ? 'open this link in your browser:' : 'opened in your browser:')}\n ${c.faint(url)}`)
1444
1455
  // a dialog until it's turned off: nothing else meanwhile, in any tab (Esc turns it off too).
1445
1456
  // Not busy meanwhile: what's changed on the page applies at once, here too (opened while a task
1446
1457
  // works: once it's done).
1447
1458
  if (!working) ui.idle()
1448
1459
  if (app.tabs) app.tabs.locked = true
1460
+ ui.setMouse(false) // the terminal's own selection for the link: OSC 52 copying fails in some terminals
1449
1461
  try {
1450
- await ui.pick('The settings page is on', [{ label: 'Turn off', desc: 'stops the page and gives HeartCode back' }], { fixed: true, body: `It's open in your browser:\n${url}\n\nWhat you change there applies right away.` })
1462
+ await ui.pick('The settings page is on', [{ label: 'Turn off', desc: 'stops the page and gives HeartCode back' }], { fixed: true, quiet: true, ctrlC: true, body: `${overSsh ? 'Open this link in your browser:' : "It's open in your browser:"}\n${url}\n\nTo copy it, select it with the mouse.\nWhat you change there applies right away.` })
1451
1463
  } finally {
1464
+ ui.setMouse(cfg.mouse !== false)
1452
1465
  if (app.tabs) app.tabs.locked = false
1453
1466
  close()
1454
1467
  settingsPage = null
@@ -1550,7 +1563,7 @@ async function slash(app, line, working = false) {
1550
1563
  const answer = app.chat.history.at(-1)?.answer?.trim()
1551
1564
  if (!answer) return ui.print('No answer to copy yet.')
1552
1565
  const how = copyText(answer)
1553
- return ui.print(c.dim(`copied the last answer (${answer.split('\n').length} lines)${how === 'osc' ? ' through the terminal' : ''}`))
1566
+ return ui.print(c.dim(`copied the last answer (${answer.split('\n').length} lines)${how === 'osc' ? ' if your terminal allows it' : ''}`))
1554
1567
  }
1555
1568
  case 'background': {
1556
1569
  const jobs = listJobs(app.root)
@@ -2035,7 +2048,7 @@ async function main() {
2035
2048
 
2036
2049
  if (sub === 'settings') {
2037
2050
  const { url, local } = await startSettings({ cfg })
2038
- console.log(`${c.brand('♥')} HeartCode settings: ${url}\n${c.dim('opened in your browser · from another device on this network, open the link above · Ctrl+C to stop')}`)
2051
+ console.log(`${c.brand('♥')} HeartCode settings: ${url}\n${c.dim(`${overSsh ? 'open it in your browser' : 'opened in your browser'} · from another device on this network, open the link above · Ctrl+C to stop`)}`)
2039
2052
  openBrowser(local)
2040
2053
  return new Promise(() => {}) // until Ctrl+C
2041
2054
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartcode",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
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
@@ -243,14 +243,20 @@ Several agent calls in one reply run at the same time: one helper per independen
243
243
 
244
244
  ## team
245
245
 
246
- <!-- In the system prompt when the user set up other models. {{models}}: one per line, in the user's order, with what each can do. {{you}}: what this model can do. -->
247
- # Your other models
246
+ <!-- In the system prompt when the user set up other models. {{models}}: one per line, in the user's order, with what each can do (and with {{helpers}}: what the user picked it for). {{you}}: what this model can do. {{helpers}}: the user ticked helpers on Your models: only those are listed and can be started. -->
247
+ {{#if helpers}}# Your helpers
248
+
249
+ Besides you (tool calls, {{you}}), the user picked these helpers, in their order, each with what they're good at:
250
+ {{models}}
251
+
252
+ Use them with the agent tool ("model" picks one, "images" gives it images):
253
+ - Give a part to the helper good at it; none fits: the first one ("model" left out).{{else}}# Your other models
248
254
 
249
255
  Besides you (tool calls, {{you}}), the user set up these models, in their order:
250
256
  {{models}}
251
257
 
252
258
  Use them with the agent tool ("model" picks one, "images" gives it images):
253
- - Give a part to the first model in this order that can do it. Independent parts run at the same time; you plan, combine and check. Small jobs: do them yourself.
259
+ - Give a part to the first model in this order that can do it.{{/if}} Independent parts run at the same time; you plan, combine and check. Small jobs: do them yourself.
254
260
  - Can't do something (see an image, read more than fits)? Don't refuse or guess: ask a model that can.
255
261
  - Ask for exactly what you need to act ("which of tiles 1-9 show a chair? numbers only"), not a description. A loop that needs the ability at every step (look, act, look again) goes whole to that model.
256
262
  - Helpers take turns with the browser and MCP servers. Never give two helpers the same files. A failed helper's job goes to your next model. An unclear answer: ask again, sharper. Trust a clear answer; don't redo it.
package/src/agent.js CHANGED
@@ -12,7 +12,7 @@ import { TOOL_DEFS, PLAN_HIDDEN, folderView, readOnlyCommand, searchesOutside, e
12
12
  import { serversNote } from './lsp.js'
13
13
  import { newlyEnded, jobLine } from './background.js'
14
14
  import { loadHooks, runHooks } from './hooks.js'
15
- import { takeConfigErrors } from './config.js'
15
+ import { takeConfigErrors, HELPER_JOBS } from './config.js'
16
16
  import { c, duration, Block, Markdown, color, diffLines, renderDiff } from './ui.js'
17
17
 
18
18
  // Images for a helper (the agent tool's "images"), as data: URLs: image URLs (fetched), data: URLs,
@@ -248,15 +248,19 @@ export class Session {
248
248
  }
249
249
  const name = (t) => `${t.provider} ${t.model}`
250
250
  const self = { provider: this.client.provider, model: this.client.model, images: this.strat.vision, tools: this.strat.actions === 'tools', self: true }
251
- const all = [self, ...(this.team?.() ?? [])] // this model, then your others in your list's order
251
+ const team = this.team?.() ?? []
252
+ const helpers = helpersOf(team)
253
+ // the helpers you ticked (then this model), else this model and your others, in your list's order
254
+ const all = helpers ? [...helpers, self] : [self, ...team]
252
255
  const want = String(args.model ?? '').trim()
253
256
  // only one model available (a pinned model, or you have just one): helpers use it, whatever was asked
254
257
  const first = !want || all.length === 1 ? all[0] : (all.find((t) => name(t) === want || `${t.provider}/${t.model}` === want) ?? all.find((t) => t.model === want || want.endsWith(` ${t.model}`) || t.model.endsWith(`/${want}`)))
255
- if (!first) return `error: no model "${want}". Yours: ${all.map(name).join(', ')}`
258
+ if (!first) return `error: no model "${want}". ${helpers ? 'Your helpers' : 'Yours'}: ${all.map(name).join(', ')}`
256
259
  // the one asked for first, then the others in your list's order: only those that can do the job
257
260
  // (images need a model that sees them)
258
261
  const able = (t) => !images.length || t.images
259
- const order = [first, ...all.filter((t) => t !== first)].filter(able)
262
+ let order = [first, ...all.filter((t) => t !== first)].filter(able)
263
+ if (!order.length && helpers) order = [self, ...team].filter(able) // no helper sees images: any of yours that does
260
264
  if (!order.length) return 'error: none of your models can see images'
261
265
  const failed = []
262
266
  for (const [i, t] of order.entries()) {
@@ -579,14 +583,19 @@ const SYSTEM = (s) => {
579
583
  .join('\n\n')
580
584
  }
581
585
 
586
+ // The helpers you ticked on Your models (jobs: what for), in your order; null when none are.
587
+ export const helpersOf = (team) => (team.some((t) => t.jobs) ? team.filter((t) => t.jobs) : null)
588
+
582
589
  // Your other models and what each can do, for the agent tool's model (only when there are any): a
583
- // short line each, in your list's order.
590
+ // short line each, in your list's order. With helpers ticked: only them, and what each is good at.
584
591
  const teamPrompt = (s) => {
585
592
  const team = s.team?.() ?? []
586
593
  if (!team.length) return ''
594
+ const helpers = helpersOf(team)
587
595
  const can = (t) => [t.tools === false && 'no tool calls', t.images && 'images', t.thinking && 'thinking'].filter(Boolean)
588
- const line = (t) => `- ${t.provider} ${t.model}${can(t).length ? `: ${can(t).join(', ')}` : ''}`
589
- return prompt('agent/team', { models: team.map(line).join('\n'), you: [s.strat.vision ? 'images' : 'no images', s.strat.thinking && 'thinking'].filter(Boolean).join(', ') })
596
+ const good = (t) => (t.jobs?.length ? ` · good at: ${t.jobs.map((j) => HELPER_JOBS[j]?.[1]).filter(Boolean).join('; ')}` : '')
597
+ const line = (t) => `- ${t.provider} ${t.model}${can(t).length ? `: ${can(t).join(', ')}` : ''}${good(t)}`
598
+ return prompt('agent/team', { helpers: Boolean(helpers), models: (helpers ?? team).map(line).join('\n'), you: [s.strat.vision ? 'images' : 'no images', s.strat.thinking && 'thinking'].filter(Boolean).join(', ') })
590
599
  }
591
600
 
592
601
  const sizeOf = (m) =>
@@ -1433,7 +1442,9 @@ export async function review(s, task, answer, signal) {
1433
1442
  const ran = (s.ran ?? []).slice(-15).map((r) => `- ${clip(r.command.replace(/\s+/g, ' '), 160)} → ${r.result}`).join('\n')
1434
1443
  const ask = prompt('agent/review', { request: requestsOf(s.chat, 1200), emphasis: (s.chat?.choices ?? []).join('; '), plan: plan || '(none)', answer: clip(String(answer ?? ''), 3000), changes: diffs.join('\n\n'), ran: ran || '(nothing)' })
1435
1444
  const self = { provider: s.client.provider, model: s.client.model, self: true }
1436
- const team = (s.team?.() ?? []).filter((t) => t.tools !== false && !(t.provider === self.provider && t.model === self.model)) // your next two, in your order
1445
+ const others = (s.team?.() ?? []).filter((t) => t.tools !== false && !(t.provider === self.provider && t.model === self.model))
1446
+ const reviewers = others.filter((t) => t.jobs?.includes('code')).sort((a, b) => Boolean(b.thinking) - Boolean(a.thinking)) // ticked for Code & logic on Your models, the thinking ones first
1447
+ const team = reviewers.length ? reviewers : others // else your next two, in your order
1437
1448
  for (const t of [...team.slice(0, 2), self]) {
1438
1449
  s.ui.spinner(`${t.model} is reviewing the work`)
1439
1450
  try {
package/src/config.js CHANGED
@@ -19,7 +19,7 @@ export function projectDir(root, what) {
19
19
  return dir
20
20
  }
21
21
 
22
- const SETTINGS = ['context', 'effort', 'permissions', 'autoCompact', 'director', 'theme', 'format', 'lsp', 'voice', 'queue', 'rotation', 'statusBar', 'log', 'logRequests', 'logDetail', 'logDays', 'telegram', 'search', 'testTimeout', 'updateCheck', 'logs', 'replyStart', 'replyIdle', 'mouse']
22
+ const SETTINGS = ['context', 'effort', 'permissions', 'autoCompact', 'director', 'theme', 'format', 'lsp', 'voice', 'queue', 'rotation', 'statusBar', 'log', 'logRequests', 'logDetail', 'logDays', 'telegram', 'search', 'testTimeout', 'updateCheck', 'logs', 'replyStart', 'replyIdle', 'mouse', 'helpers', 'helpersAuto', 'helperOrder', 'providerRank']
23
23
  // How long a reply may take (the settings page's Your models), in seconds, with the defaults:
24
24
  // replyStart: a reply must start within it, else that model failed; replyIdle: a reply that stops
25
25
  // sending for it is stalled.
@@ -27,6 +27,18 @@ export function speedOf(cfg) {
27
27
  const sec = (v, d, min, max) => (Number.isInteger(Number(v)) && Number(v) >= min && Number(v) <= max ? Number(v) : d)
28
28
  return { replyStart: sec(cfg.replyStart, 60, 5, 600), replyIdle: sec(cfg.replyIdle, 150, 10, 1800) }
29
29
  }
30
+ // What a helper can be picked for (Your models' pills): [its label there, what #1 is told it's good at,
31
+ // what the pill covers (its tooltip)]
32
+ export const HELPER_JOBS = {
33
+ ui: ['UI & visuals', 'websites, app screens, games, animation, 3D, charts', 'Websites and landing pages, app screens, games and animation, 3D, charts and SVG: anything people look at.'],
34
+ code: ['Code & logic', 'backend, APIs, scripts, automation, fixing bugs, tests, reviewing changes', 'Backend and APIs, scripts and automation, fixing bugs, tests and refactoring. Reviews of the work go to these first.'],
35
+ hard: ['Big & hard', 'hard thinking, planning, long tasks with many steps, huge files', 'Planning and architecture, tricky logic, long tasks with many steps, huge files or whole folders.'],
36
+ quick: ['Quick & cheap', 'small jobs: searching and reading code, lookups, small edits', 'Searching and reading code, looking things up, small edits: simple jobs where fast and cheap matter most.'],
37
+ }
38
+ // a helper's jobs as saved, in today's names (picks from before the four: search, research → quick, review → code)
39
+ const WAS = { search: 'quick', research: 'quick', review: 'code' }
40
+ export const jobsOf = (jobs) => (Array.isArray(jobs) ? [...new Set(jobs.map((j) => WAS[j] ?? j).filter((j) => HELPER_JOBS[j]))] : undefined)
41
+ export const helpersOf = (map) => Object.fromEntries(Object.entries(map ?? {}).map(([k, jobs]) => [k, jobsOf(jobs)]).filter(([, jobs]) => jobs))
30
42
  export const SPEED_LIMITS = { replyStart: [5, 600], replyIdle: [10, 1800] }
31
43
 
32
44
  const LOCAL_NAMES = { 11434: 'ollama', 1234: 'lmstudio', 8080: 'llamacpp' }
package/src/guided.js CHANGED
@@ -600,7 +600,7 @@ class Guided {
600
600
  // Another of your models, one with tool calls, does the whole task; what it did goes in the notes.
601
601
  async delegate() {
602
602
  // the first of yours with tool calls (that sees images, if the task came with some)
603
- const team = this.s.team().filter((t) => t.tools && (!this.images || t.images))
603
+ const team = this.s.team().filter((t) => t.tools && (!this.images || t.images)).sort((a, b) => Boolean(b.jobs) - Boolean(a.jobs)) // your helpers first
604
604
  const t = team[0]
605
605
  const args = { description: 'the task', prompt: this.task, model: `${t.provider} ${t.model}` }
606
606
  const done = await this.tool('agent', args, (id) => this.s.subagent(args, this.signal, id))
package/src/rankings.js CHANGED
@@ -8,11 +8,12 @@ import { readParquet } from './parquet.js'
8
8
 
9
9
  const FILE = path.join(HOME, 'rankings.json')
10
10
  const WEEK = 7 * 24 * 3600_000
11
- const VERSION = 2 // 2: with each model's score; an older file is fetched again
11
+ const VERSION = 3 // 2: with each model's score; 3: with the agent ranking and hard prompts; an older file is fetched again
12
12
  const FILES = 'https://huggingface.co/datasets/lmarena-ai/leaderboard-dataset/resolve/main' // one Parquet file per ranking: text, webdev, vision, agent
13
13
 
14
- // The lists kept (ranking:category): shown on Your models and to the orchestrator
15
- const LISTS = ['text:overall', 'text:coding', 'webdev:webdev', 'vision:overall']
14
+ // The lists kept (ranking:category): shown on Your models; the helpers picked for you go by them too
15
+ // (agent: long real tasks, done by the model with tools; hard prompts: the hardest questions)
16
+ const LISTS = ['text:overall', 'text:coding', 'text:hard_prompts', 'webdev:webdev', 'vision:overall', 'agent:overall']
16
17
 
17
18
  export const loadRankings = () => readJson(FILE, null)
18
19
 
package/src/settings.html CHANGED
@@ -307,6 +307,7 @@
307
307
  .prov-h .by-name input { width: 190px; height: 28px; padding: 0 9px; font-size: 12px; font-family: var(--mono); background: transparent; }
308
308
  .prov-h .by-name button, .prov-h > button.small { height: 28px; }
309
309
  dialog#gone { width: min(560px, 92vw); }
310
+ dialog#h-test { width: min(560px, 92vw); }
310
311
  dialog#gone h2 { color: var(--err); font-family: inherit; font-size: 18px; }
311
312
  dialog#gone::backdrop { background: rgba(0, 0, 0, .75); }
312
313
  .hello-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@@ -427,7 +428,7 @@
427
428
  .mt-more-pill button:hover:not(:disabled) { background: var(--hover); }
428
429
  .mt-more-pill button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
429
430
  .mt-more-pill button:disabled { color: var(--faint); cursor: default; }
430
- .mt, .mt-h.mt-hpick { min-width: 1310px; } /* the columns below, their gaps and padding: the header, the selection bar and the rows line up (the rows are drawn a screenful at a time, so this can't come from them) */
431
+ .mt, .mt-h.mt-hpick { min-width: 1766px; } /* the columns below, their gaps and padding: the header, the selection bar and the rows line up (the rows are drawn a screenful at a time, so this can't come from them) */
431
432
  .mt-h input[type=checkbox], .mtable input[type=checkbox] { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); cursor: pointer; }
432
433
  .mtable li.picked { background: var(--brand-soft); }
433
434
  .mt-rules { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
@@ -449,9 +450,9 @@
449
450
  .pill .again:hover:not(:disabled) { color: var(--text); }
450
451
  .pill.on { border-color: var(--accent); background: var(--accent-soft); }
451
452
  .pill.on .again { border-left-color: color-mix(in srgb, var(--accent) 40%, transparent); }
452
- .mt-h, .mtable li { display: grid; grid-template-columns: 14px 18px 40px minmax(200px, 1fr) 104px 62px 46px 66px 56px 76px 76px 76px 112px 86px 124px; /* the last: Test · Request · Edit · ✕, as wide as they are */ align-items: center; column-gap: 6px; padding: 8px 18px; }
453
+ .mt-h, .mtable li { display: grid; grid-template-columns: 14px 18px 40px minmax(200px, 1fr) 104px 450px 62px 46px 66px 56px 76px 76px 76px 112px 86px 124px; /* the last: Test · Request · Edit · ✕, as wide as they are */ align-items: center; column-gap: 6px; padding: 8px 18px; }
453
454
  .mt-h button.mid, .mtable .mid { text-align: center; }
454
- .mt-h > :nth-child(14), .mtable .try { padding-left: 12px; } /* Works?: a little room after the right-aligned price */
455
+ .mt-h > :nth-child(15), .mtable .try { padding-left: 12px; } /* Works?: a little room after the right-aligned price */
455
456
  .mtable li .acts { justify-content: flex-start; }
456
457
  .mt-h { border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--faint); padding-top: 10px; padding-bottom: 10px; background: var(--panel2); }
457
458
  .mt-h button { display: inline; border: 0; background: none !important; padding: 0; font: inherit; color: inherit; text-align: left; white-space: nowrap; transform: none !important; }
@@ -473,6 +474,28 @@
473
474
  .mtable .m { font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
474
475
  .mtable .p { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
475
476
  .mtable .yes { color: var(--ok); }
477
+ /* Helper: a switch (can #1 start it for side jobs?), then what it's good at, as pills */
478
+ .hp { display: flex; align-items: center; gap: 4px; min-width: 0; }
479
+ .hp > span:first-child { display: inline-flex; }
480
+ .hp .sw { display: inline-block; width: 30px; height: 18px; margin: 0 4px 0 0; }
481
+ .hp .sw i::after { width: 12px; height: 12px; }
482
+ .hp .sw input:checked + i::after { transform: translateX(12px); }
483
+ .mtable li .hp .jp { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; font-size: 11.5px; font-weight: 400; color: var(--faint); white-space: nowrap; cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .1s; }
484
+ .mtable li .hp .jp:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
485
+ .mtable li .hp .jp:active:not(:disabled) { transform: scale(.95); }
486
+ .mtable li .hp .jp:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
487
+ .mtable li .hp .jp.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); font-weight: 500; }
488
+ .mtable li .hp .jp.on::before { content: '✓'; color: var(--accent); font-weight: 700; }
489
+ .mtable li .hp .jp.sug { border-style: dashed; border-color: var(--accent); color: var(--accent); }
490
+ .mtable li .hp .jp.sug::before { content: '+'; font-weight: 700; }
491
+ .mtable li .hp.off .jp:not(.sug) { opacity: .6; }
492
+ /* the helper suggestions, waiting for a yes: beside the list's buttons */
493
+ .hsug { display: inline-flex; align-items: center; gap: 6px; padding: 2px 3px 2px 10px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
494
+ .hsug .ic { color: var(--accent); }
495
+ .hbar { display: contents; }
496
+ .mtable li .hp .jp.saving, .hp .saving .sw { opacity: .55; animation: hp-pulse .9s ease-in-out infinite alternate; pointer-events: none; } /* its save on its way */
497
+ @keyframes hp-pulse { to { opacity: .25; } }
498
+ @media (prefers-reduced-motion: reduce) { .mtable li .hp .jp.saving, .hp .saving .sw { animation: none; } }
476
499
  .mtable .no { color: var(--faint); }
477
500
  .mtable .src { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
478
501
  .mtable .src.warn { color: var(--warn); }
@@ -541,6 +564,10 @@
541
564
  button.sorting::after { content: ''; display: inline-block; width: 9px; height: 9px; margin-left: 6px; vertical-align: -1px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
542
565
  /* Your models: the header's buttons, the list's settings, the toolbar (sticky), the table */
543
566
  .mt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
567
+ .h-order { display: inline-flex; align-items: center; gap: 8px; margin-right: 4px; }
568
+ .h-order .mt-setl { white-space: nowrap; }
569
+ .mt-actions .seg { height: 32px; }
570
+ .mt-actions .seg label { padding: 0 11px; font-size: 12.5px; }
544
571
  .mt-sets { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 18px 4px; } /* with the filters below: one toolbar, 8px between its two lines */
545
572
  .mt-mode-sets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
546
573
  .mt-set { display: flex; align-items: center; gap: 8px; min-width: 0; }
@@ -644,6 +671,8 @@
644
671
  #tip dt { color: var(--faint); }
645
672
  #tip dd { margin: 0; }
646
673
  #tip .tdesc { color: var(--muted); margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
674
+ #tip .tjob { font-weight: 650; font-size: 13.5px; }
675
+ #tip .tcover { color: var(--muted); margin-top: 6px; line-height: 1.5; }
647
676
  #tip .thint { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--accent); font-weight: 600; }
648
677
  #toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 8px); padding: 10px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow-pop); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 10; }
649
678
  #toast.show { opacity: 1; transform: translate(-50%, 0); }
@@ -1094,6 +1123,12 @@
1094
1123
  <div id="imp-list" class="imp-list"></div>
1095
1124
  <div class="actions"><span class="spacer"></span><button id="imp-cancel" type="button">Cancel</button><button class="primary" id="imp-go" type="button">Import selected</button></div>
1096
1125
  </dialog>
1126
+ <dialog id="h-test" aria-labelledby="h-test-title">
1127
+ <h2 id="h-test-title">Test your models first</h2>
1128
+ <p class="sub">Helpers are picked from the models that answer a short test. None of yours has been tested yet.</p>
1129
+ <p class="sub" id="h-test-cost"></p>
1130
+ <div class="actions"><span class="spacer"></span><button id="h-test-no" type="button" class="ghost">Cancel</button><button id="h-test-go" type="button" class="primary">Test all, then pick</button></div>
1131
+ </dialog>
1097
1132
  <dialog id="gone" aria-labelledby="gone-title">
1098
1133
  <h2 id="gone-title">Disconnected</h2>
1099
1134
  <p class="sub">HeartCode's settings page was turned off, so nothing here can be changed or saved now.</p>
@@ -1761,6 +1796,7 @@ async function tryAll(only) {
1761
1796
  const { run } = await api('/api/tests/start', only ? { only: only.map(({ provider, model }) => ({ provider, model })) } : {})
1762
1797
  showRun(run)
1763
1798
  } catch (e) {
1799
+ afterTests = null // no run: nothing to do after it
1764
1800
  toast(e.message, true)
1765
1801
  }
1766
1802
  }
@@ -1779,6 +1815,12 @@ function showRun(run) {
1779
1815
  if (!testingAll) {
1780
1816
  for (const [key, r] of Object.entries(TRIES)) if (r.going) r.before ? (TRIES[key] = r.before) : delete TRIES[key] // stopped before it: as it was
1781
1817
  job('test-all')
1818
+ if (run?.over && afterTests) {
1819
+ const then = afterTests
1820
+ afterTests = null
1821
+ if (then === 'suggest') suggestNow()
1822
+ else setAuto(true, $('h-auto'))
1823
+ } else if (!run?.over) afterTests = null // never started
1782
1824
  if (run?.over) toast(`${run.stopping ? `stopped after ${run.done} of ${run.total}: ` : ''}${run.good} of ${run.done} work${run.good === run.done ? '' : `; ${run.done - run.good} don't (Works? says why, on hover)`}`, run.good < run.done)
1783
1825
  } else
1784
1826
  job('test-all', {
@@ -1963,7 +2005,7 @@ function sortable(v, onMove) {
1963
2005
  const scrolled = () => (scroller === window ? scrollY : scroller.scrollTop)
1964
2006
  box.addEventListener('pointerdown', (e) => {
1965
2007
  const li = e.target.closest('li.in')
1966
- if (!li || e.button !== 0 || e.target.closest('button, a, input, select, textarea') || !box.classList.contains('drag')) return
2008
+ if (!li || e.button !== 0 || e.target.closest('button, a, input, select, textarea, .hp') || !box.classList.contains('drag')) return
1967
2009
  if (e.pointerType !== 'mouse' && !e.target.closest('.grip')) return // a finger scrolls the list, except on the grip
1968
2010
  const n = v.items
1969
2011
  const from = Number(li.dataset.i)
@@ -2351,6 +2393,7 @@ $('pr-save').onclick = () => {
2351
2393
  RANK = [...list, ...RANK.filter((n) => !list.includes(n))] // providers not in your list now keep their place for later
2352
2394
  savePref('rank', RANK)
2353
2395
  $('pr').close()
2396
+ if (S.helperOrder === 'provider') api('/api/helper-order', { by: 'provider', rank: RANK }).catch((e) => toast(e.message, true)) // helpers by the new ranking
2354
2397
  setSort(SORT.some((x) => x.key === 'provider') ? SORT : [{ key: 'provider', dir: 'down' }, ...SORT]) // sorted by it now
2355
2398
  }
2356
2399
  const firstDir = (key) => COLS[key].first // up: A to Z, low to high
@@ -2391,9 +2434,9 @@ function sorted(order) {
2391
2434
  }
2392
2435
  const dirText = (key, dir) => COLS[key].words[dir === 'up' ? 0 : 1] + (key === 'works' ? ' (then not tested, then not working)' : '')
2393
2436
  // Filters on the Your models page: which models are shown (and tested by "Test N shown", counted,
2394
- // sorted, selected by "select all", saved first by Save order). Combined: a model shows when it passes
2437
+ // sorted, selected by "select all", saved first by Save list). Combined: a model shows when it passes
2395
2438
  // all of them. Kept with the page's choices.
2396
- const NO_FILTER = { text: '', provider: '', works: '', context: 0, tools: false, thinking: false, images: false, free: false }
2439
+ const NO_FILTER = { text: '', provider: '', works: '', context: 0, tools: false, thinking: false, images: false, free: false, helpers: false }
2397
2440
  let FILTER = { ...NO_FILTER }
2398
2441
  let filtersLoaded = false
2399
2442
  const filtering = () => Object.keys(NO_FILTER).some((k) => FILTER[k] !== NO_FILTER[k])
@@ -2413,6 +2456,7 @@ function passes(t, skip) {
2413
2456
  const c = can(t)
2414
2457
  if ((f.tools && !c.tools) || (f.thinking && !c.thinking) || (f.images && !c.images)) return false
2415
2458
  if (f.free && !(t.price?.input === 0 && t.price?.output === 0)) return false
2459
+ if (f.helpers && !helpers()[keyOf(t)] && !HSUG?.[keyOf(t)]) return false // and the ones suggested, while they are
2416
2460
  return true
2417
2461
  }
2418
2462
  const setFilter = (change) => {
@@ -2446,7 +2490,8 @@ function filterBarOf(order, counts = {}) {
2446
2490
  toggle('tools', 'Tools', 'only models that call tools'),
2447
2491
  toggle('thinking', 'Thinking', 'only models that think'),
2448
2492
  toggle('images', 'Images', 'only models that see images'),
2449
- toggle('free', 'Free', 'only models that cost nothing, in and out')))
2493
+ toggle('free', 'Free', 'only models that cost nothing, in and out'),
2494
+ toggle('helpers', 'Helpers', 'only your helpers (the models #1 can start for side jobs), and the ones suggested')))
2450
2495
  }
2451
2496
  const bar = filterBar
2452
2497
  const focused = (el) => document.activeElement === el
@@ -2503,7 +2548,7 @@ function drawMine(s) {
2503
2548
  slots.forEach((k, m) => (all[k] = list[m]))
2504
2549
  return keep(all, true)
2505
2550
  }
2506
- // Save order: the models HeartCode uses become the ones shown, in the order shown. Filtered: only
2551
+ // Save list: the models HeartCode uses become the ones shown, in the order shown. Filtered: only
2507
2552
  // those (asked first; the others stay under Providers, to add back any time)
2508
2553
  const saveList = () => {
2509
2554
  if (filtered && !confirm(`HeartCode will use only these ${n(view.length)}, in this order.\n\nThe other ${n(order.length - view.length)} stay under Providers: add any back whenever you like.`)) return
@@ -2522,7 +2567,15 @@ function drawMine(s) {
2522
2567
  $('mt-lead').textContent = 'The models HeartCode uses, in your order: #1 answers, the next one when it fails.'
2523
2568
  const busy = locked()
2524
2569
  $('mt-actions').inert = busy
2570
+ // the order helpers are picked in when #1 starts them: your list's, or your provider ranking's
2571
+ const helperOrder = (by) => api('/api/helper-order', { by, rank: RANK }).then((r) => ((S.helperOrder = r.helperOrder), drawMine(S)), (e) => toast(e.message, true))
2572
+ const orderBy = h('span', { className: 'h-order' }, h('span', { className: 'mt-setl', textContent: 'Helpers picked' }),
2573
+ h('div', { className: 'seg', role: 'radiogroup', 'aria-label': 'The order helpers are picked in' },
2574
+ [['own', 'in your order', 'when #1 starts helpers, it picks from them in your list\'s order (the first one that fits the job)'], ['provider', 'by provider', 'when #1 starts helpers, it picks from them by your provider ranking (Order providers), each provider\'s in your list\'s order. Your list itself stays as it is']].map(([v, t, about]) =>
2575
+ h('label', { className: (S.helperOrder ?? 'own') === v ? 'on' : '', title: about },
2576
+ h('input', { type: 'radio', name: 'helper-order', checked: (S.helperOrder ?? 'own') === v, onchange: () => helperOrder(v) }), t))))
2525
2577
  put($('mt-actions'),
2578
+ order.some((t) => t.provider !== order[0]?.provider) ? orderBy : null, // one provider: nothing to order by
2526
2579
  ((why) => h('span', { title: why ?? '' }, h('button', { className: 'small', textContent: 'Order providers', disabled: Boolean(why), title: why ? '' : 'drag your providers into order; the Provider column sorts by it', onclick: openRanking })))( // disabled: why, on a span (a disabled button shows no tooltip in every browser)
2527
2580
  !order.some((t) => t.provider !== order[0]?.provider) ? 'All your models are from one provider: nothing to order' : null),
2528
2581
  h('button', { className: 'small', textContent: 'Update model info', disabled: !order.length, title: `what each model can do (context, tools, thinking, images, price) from models.dev, and its places in LMArena's public rankings (coding, web apps, vision${S.rankings ? `; rankings from ${new Date(S.rankings.fetched).toLocaleDateString()}` : ''})`, onclick: () => lookUp() }))
@@ -2555,14 +2608,19 @@ function drawMine(s) {
2555
2608
  } }), h('span', { className: 'unit', textContent: 'sec' })),
2556
2609
  cell('New message to', 'the model a new message goes to first',
2557
2610
  h('select', { onchange: (e) => saveOrder(S.order, 'saved', { next: e.target.value }) },
2558
- [['first', '#1'], ['stay', 'the last that worked']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.next === v }))))))
2611
+ [['first', '#1'], ['stay', 'the last that worked']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.next === v })))),
2612
+ cell('Helpers', 'who picks the helpers (the Helper column): HeartCode, from the models that answered their test and the rankings, again whenever those change; or you, with the pills',
2613
+ h('select', { id: 'h-auto', onchange: (e) => setAuto(e.target.value === 'auto', e.target) },
2614
+ [['auto', 'picked for you'], ['manual', 'you pick']].map(([v, t]) => h('option', { value: v, textContent: t, selected: (S.helpersAuto ? 'auto' : 'manual') === v }))))))
2559
2615
 
2560
2616
  // --- beside the filters: what's shown · what you do with it (the sorts show in the column heads) ---
2561
2617
  const line = h('div', { className: 'mt-line' },
2562
2618
  h('span', { className: 'count', title: SORT.length ? `sorted by ${SORT.map(({ key, dir }) => `${COLS[key].label} ${COLS[key].words[dir === 'up' ? 0 : 1]}`).join(', then ')}; ties keep your order` : '' }, filtered ? [h('b', { textContent: n(shown.length) }), ` of ${n(order.length)}`] : [h('b', { textContent: n(order.length) }), ` model${order.length === 1 ? '' : 's'}`]),
2563
2619
  filtering() || SORT.length ? h('button', { className: 'small ghost', textContent: 'Clear', title: 'every filter and the sort off: your whole list, in your order', onclick: clearView }) : null,
2620
+ order.length > 1 ? drawHelperBar() : null,
2564
2621
  h('button', { className: 'small', textContent: filtered ? `Test ${n(shown.length)}` : 'Test all', disabled: testingAll || !shown.length, title: `send ${filtered ? 'the models shown' : 'each model'} a short message to see which really answer, and how fast`, onclick: () => tryAll(filtered ? shown : order) }),
2565
- h('button', { className: 'small primary', textContent: filtered ? `Use only these ${n(view.length)}` : 'Save order', disabled: !view.length || order.length < 2, title: filtered ? `HeartCode uses only these ${n(view.length)}, in the order shown (the others stay under Providers)` : S.settings.modelChoice === 'fit' ? 'keep the order shown: the orchestrator sees the others in this order, and a failed model goes to the next' : 'HeartCode uses them in the order shown (#1 first)', onclick: saveList }))
2622
+ // not on the helpers' view: they're not a list to keep only
2623
+ filtered && FILTER.helpers ? null : h('button', { className: 'small primary', textContent: filtered ? `Use only these ${n(view.length)}` : 'Save list', disabled: !view.length || order.length < 2, title: filtered ? `HeartCode uses only these ${n(view.length)}, in the order shown (the others stay under Providers)` : S.settings.modelChoice === 'fit' ? 'keep the order shown: the orchestrator sees the others in this order, and a failed model goes to the next' : 'save your list as shown: HeartCode uses them in this order (#1 first)', onclick: saveList }))
2566
2624
 
2567
2625
  // --- the table ---
2568
2626
  const all = view.length > 0 && view.every((t) => PICKED.has(keyOf(t)))
@@ -2582,7 +2640,7 @@ function drawMine(s) {
2582
2640
  h('button', { className: 'small ghost', textContent: 'Invert', title: "select the ones shown that aren't selected, unselect the ones that are", onclick: () => (view.forEach((t) => (PICKED.has(keyOf(t)) ? PICKED.delete(keyOf(t)) : PICKED.add(keyOf(t)))), (lastPicked = null), drawMine(S)) }),
2583
2641
  h('button', { className: 'small ghost', textContent: 'Select none', onclick: () => (PICKED.clear(), drawMine(S)) })))
2584
2642
  : h('div', { className: 'mt mt-h' }, h('span'), selectAll,
2585
- h('span', { textContent: '#', title: 'its place in your list' }), head('model'), head('provider'), head('context', 'num'), head('tools', 'mid'), head('thinking', 'mid'), head('images', 'mid'), head('coding', 'num'), head('web', 'num'), head('vision', 'num'), head('price', 'num'), head('works'), h('span', { className: 'num', textContent: '' }))
2643
+ h('span', { textContent: '#', title: 'its place in your list' }), head('model'), head('provider'), h('span', { textContent: 'Helper', title: '#1 can hand a part of a task to a helper. Switch a model on, and pick what it\'s good at (hover a pill to see what it covers): #1 is told, and picks by it. None switched on: helpers run on the model that answers.' }), head('context', 'num'), head('tools', 'mid'), head('thinking', 'mid'), head('images', 'mid'), head('coding', 'num'), head('web', 'num'), head('vision', 'num'), head('price', 'num'), head('works'), h('span', { className: 'num', textContent: '' }))
2586
2644
  const table = view.length ? h('ol', { className: 'mtable' + (view.length < 2 || busy ? '' : ' drag') }) : null
2587
2645
  // ticked or not; with Shift, every row from the last one ticked to this one
2588
2646
  const pick = (i, e) => {
@@ -2667,6 +2725,150 @@ const src = (t) => {
2667
2725
  // a row of the table: one model of your list, in the order shown (at: its place in your order)
2668
2726
  const money = (x) => (x == null ? '–' : x === 0 ? '$0' : usd(x))
2669
2727
  const priceOf = (t) => (t.price?.input == null && t.price?.output == null ? '–' : t.price.input === 0 && t.price.output === 0 ? 'free' : `${money(t.price.input)} / ${money(t.price.output)}`)
2728
+ // --- Helpers: the models #1 may start for side jobs, and what each is good at (S.helpers: { key: [jobs] }).
2729
+ // A click saves at once, in the background: only that row's cell is redrawn, and the button clicked
2730
+ // shows it's saving. MINE: your latest picks while saves are on their way (each save sends them all,
2731
+ // one after another, so quick clicks don't undo each other).
2732
+ // HSUG: suggestions not taken yet ({ key: [jobs] }), shown dashed until you take or dismiss them.
2733
+ let HSUG = null
2734
+ let MINE = null
2735
+ let saving = Promise.resolve()
2736
+ let unsaved = 0
2737
+ const SAVING = new Set() // 'key|job' (or 'key|on'): the buttons whose save is on its way
2738
+ const helpers = () => MINE ?? S.helpers ?? {}
2739
+ let helperBar = null // the toolbar's part for helpers: the same element every time, filled in place
2740
+ const redrawCell = (k) => {
2741
+ const li = document.querySelector(`.mtable li[data-key="${CSS.escape(k)}"]`)
2742
+ const at = S.order.findIndex((t) => keyOf(t) === k)
2743
+ if (li && at >= 0) li.querySelector('.hp')?.replaceWith(helperCell(S.order[at], at))
2744
+ }
2745
+ function saveHelpers(next, marks = [], done) {
2746
+ MINE = next
2747
+ unsaved++
2748
+ for (const m of marks) SAVING.add(m)
2749
+ const cells = new Set(marks.map((m) => m.split('|')[0]))
2750
+ cells.forEach(redrawCell)
2751
+ drawHelperBar()
2752
+ saving = saving
2753
+ .then(() => api('/api/helpers', { helpers: next }))
2754
+ .then((r) => ((S.helpers = r.helpers), (S.helpersAuto = r.helpersAuto), $('h-auto') && ($('h-auto').value = r.helpersAuto ? 'auto' : 'manual'), done && toast(done)))
2755
+ .catch((e) => toast(e.message, true))
2756
+ .finally(() => {
2757
+ for (const m of marks) SAVING.delete(m)
2758
+ if (!--unsaved) MINE = null // all saved: what the server has is yours
2759
+ cells.forEach(redrawCell)
2760
+ drawHelperBar()
2761
+ })
2762
+ return saving
2763
+ }
2764
+ function setHelper(k, jobs, mark) {
2765
+ const next = { ...helpers() }
2766
+ jobs ? (next[k] = jobs) : delete next[k]
2767
+ if (HSUG?.[k] && jobs) {
2768
+ const left = HSUG[k].filter((j) => !jobs.includes(j))
2769
+ left.length ? (HSUG[k] = left) : delete HSUG[k]
2770
+ if (!Object.keys(HSUG).length) HSUG = null
2771
+ }
2772
+ saveHelpers(next, [`${k}|${mark}`])
2773
+ }
2774
+ function helperCell(t, at) {
2775
+ const k = keyOf(t)
2776
+ const jobs = helpers()[k]
2777
+ const sug = HSUG?.[k] ?? []
2778
+ const busy = locked()
2779
+ return h('span', { className: 'hp' + (jobs ? '' : ' off') },
2780
+ h('span', { className: SAVING.has(`${k}|on`) ? 'saving' : '', title: jobs ? 'a helper: #1 can start it for side jobs (click: not a helper)' : 'not a helper (click: #1 can start it for side jobs)' },
2781
+ sw({ checked: Boolean(jobs), disabled: busy, 'aria-label': `${t.model} is a helper`, onchange: (e) => setHelper(k, e.target.checked ? (jobs ?? []) : null, 'on') })),
2782
+ Object.entries(S.jobs ?? {}).map(([j, [label, , covers]]) => {
2783
+ const has = Boolean(jobs?.includes(j))
2784
+ const sugd = !has && sug.includes(j)
2785
+ const pill = h('button', { type: 'button', className: 'jp' + (has ? ' on' : sugd ? ' sug' : '') + (SAVING.has(`${k}|${j}`) ? ' saving' : ''), disabled: busy, 'aria-pressed': String(has), 'aria-label': `${label}: ${covers}`, onclick: () => setHelper(k, has ? jobs.filter((x) => x !== j) : [...(jobs ?? []), j], j) }, label)
2786
+ // what the pill means, and what a click does here
2787
+ return withTip(pill, () => [
2788
+ at === 0 ? h('div', { className: 'tcover', textContent: '#1 answers you; as a helper it\'s started when another of your models is answering.' }) : null,
2789
+ h('div', { className: 'tjob', textContent: label }),
2790
+ h('div', { className: 'tcover', textContent: covers }),
2791
+ sugd ? h('div', { className: 'tcover', textContent: `Suggested from ${SUGGEST_WHY[j]}.` }) : null,
2792
+ S.helpersAuto && has ? h('div', { className: 'tcover', textContent: 'Picked for you, from the rankings, tests and prices.' }) : null,
2793
+ h('div', { className: 'thint', textContent: (has ? `Click: ${t.model} isn't picked for this any more` : `Click: #1 gives these jobs to ${t.model}${jobs ? '' : ' (it becomes a helper)'}`) + (S.helpersAuto ? ' · from then on, you pick' : '') }),
2794
+ ])
2795
+ }))
2796
+ }
2797
+ // what each pill's suggestions go by (said in its tooltip)
2798
+ const SUGGEST_WHY = { ui: 'its place in the top half of the web-app ranking (LMArena)', code: 'its place in the top half of the coding ranking (LMArena)', hard: 'it thinks with a context of 128k or more, or its place in the top half of the ranking for long real tasks or the hardest prompts (LMArena)', quick: 'its test: faster than most of yours (or nothing else fits it)' }
2799
+ // Helpers are picked from the models that answered their test: how many did
2800
+ const working = () => S.order.filter((t) => TRIES[keyOf(t)]?.ok && !TRIES[keyOf(t)].going).length
2801
+ // No test yet: ask before testing them all (each gets a short message, which a paid model charges for);
2802
+ // then: what to do once the run is over ('suggest', or nothing: picked for you does it itself)
2803
+ let afterTests = null
2804
+ function testFirst(then) {
2805
+ const n = (x) => x.toLocaleString()
2806
+ const paid = S.order.filter((t) => t.price && (t.price.input > 0 || t.price.output > 0)).length
2807
+ const unknown = S.order.filter((t) => !t.price).length
2808
+ $('h-test-cost').textContent = `Test all sends each of your ${n(S.order.length)} models a short message. ${paid ? `${n(paid)} of them aren't free: each charges for its few tokens. ` : ''}${unknown ? `${n(unknown)} have no price we know of, and may charge too. ` : ''}When it's done, helpers are picked from the ones that worked.`
2809
+ $('h-test-go').onclick = () => {
2810
+ $('h-test').close()
2811
+ afterTests = then
2812
+ tryAll(S.order)
2813
+ }
2814
+ $('h-test-no').onclick = () => $('h-test').close()
2815
+ $('h-test').showModal()
2816
+ }
2817
+ // Picked for you (HeartCode makes them from what's known, again whenever that changes) or by you
2818
+ async function setAuto(on, select) {
2819
+ if (on && !working()) return (select.value = 'manual'), testFirst('auto') // nothing to pick from yet
2820
+ select.disabled = true
2821
+ try {
2822
+ const r = await api('/api/helpers/auto', { on })
2823
+ Object.assign(S, { helpers: r.helpers, helpersAuto: r.helpersAuto })
2824
+ HSUG = null
2825
+ drawMine(S)
2826
+ } catch (e) {
2827
+ toast(e.message, true)
2828
+ select.value = S.helpersAuto ? 'auto' : 'manual'
2829
+ } finally {
2830
+ select.disabled = false
2831
+ }
2832
+ }
2833
+
2834
+ // Suggest helpers: the server's picks, beside yours (nothing saved until you take them)
2835
+ async function suggestNow(b) {
2836
+ if (b) b.disabled = true
2837
+ const r = await api('/api/helpers/suggest', {}).catch((x) => (toast(x.message, true), null))
2838
+ if (b) b.disabled = false
2839
+ if (!r) return
2840
+ HSUG = Object.keys(r.suggest).length ? r.suggest : null
2841
+ if (!HSUG) return toast(working() ? 'Nothing more to suggest' : 'None of your models worked in the test: nothing to pick from', !working())
2842
+ setFilter({ helpers: true }) // your helpers and the suggested ones, together: not lost among the rest
2843
+ }
2844
+ // The toolbar's helpers part: suggestions waiting (take all · dismiss), or Suggest helpers and Clear
2845
+ // helpers. Each saves at once, its own button saying so.
2846
+ function drawHelperBar() {
2847
+ helperBar ??= h('span', { className: 'hbar' })
2848
+ const order = S.order
2849
+ const n = Object.keys(helpers()).length
2850
+ const busy = (b) => Object.assign(b, { disabled: true, textContent: 'Saving…' })
2851
+ put(helperBar,
2852
+ HSUG ? h('span', { className: 'hsug', title: 'shown dashed in the Helper column: click one to take just that' }, ic('sparkles'),
2853
+ h('span', { textContent: `${Object.keys(HSUG).length} suggested` }),
2854
+ h('button', { className: 'small primary', textContent: 'Take all', onclick: (e) => {
2855
+ busy(e.currentTarget)
2856
+ const next = { ...helpers() }
2857
+ const took = Object.keys(HSUG)
2858
+ for (const [k, jobs] of Object.entries(HSUG)) next[k] = [...new Set([...(next[k] ?? []), ...jobs])]
2859
+ HSUG = null
2860
+ saveHelpers(next, [], `${took.length} model${took.length === 1 ? ' is a helper' : 's are helpers'} now`).then(() => drawMine(S))
2861
+ } }),
2862
+ h('button', { className: 'small ghost', textContent: 'Dismiss', onclick: () => ((HSUG = null), drawMine(S)) })) : null,
2863
+ !HSUG && !S.helpersAuto ? h('button', { className: 'small', title: working() ? `suggest all ${working()} models that answered their test as helpers, each with what it's good at (from the rankings, its test, thinking and context): you see them first, then take them or not` : 'suggest helpers: your models are tested first (helpers are picked from the ones that answer)', onclick: (e) => (working() ? suggestNow(e.currentTarget) : testFirst('suggest')) }, ic('sparkles'), 'Suggest helpers') : null,
2864
+ !HSUG && n ? h('button', { className: 'small ghost', textContent: 'Clear helpers', title: `none of your models a helper (${n} now): helpers run on the model that answers`, onclick: (e) => {
2865
+ if (!confirm(`Clear your ${n} helper${n === 1 ? '' : 's'}? Helpers then run on the model that answers.`)) return
2866
+ busy(e.currentTarget)
2867
+ saveHelpers({}, [], 'no helpers: they run on the model that answers').then(() => (FILTER.helpers ? setFilter({ helpers: false }) : drawMine(S))) // no helpers left to show only
2868
+ } }) : null)
2869
+ return helperBar
2870
+ }
2871
+
2670
2872
  function tableRow(t, at, pick) {
2671
2873
  const c = can(t)
2672
2874
  const ctx = COLS.context.get(t)
@@ -2684,6 +2886,7 @@ function tableRow(t, at, pick) {
2684
2886
  h('span', { className: 'n', textContent: `#${at + 1}`, title: SORT.length || filtering() ? 'its place in your list' : '' }),
2685
2887
  h('span', { className: 'm' }, h('span', { className: 'name', textContent: t.model, title: t.model }), tag),
2686
2888
  h('span', { className: 'p', textContent: isOff(t.provider) ? `${t.provider} · off` : t.provider, title: t.provider }),
2889
+ helperCell(t, at),
2687
2890
  h('span', { className: 'num', textContent: ctx ? `${t.tested?.sure === false ? '~' : ''}${kTok(ctx)}` : '–', title: ctx ? `${ctx.toLocaleString()} tokens${t.tested?.sure === false ? ' (assumed: the server and models.dev don\'t say)' : ''}` : '' }),
2688
2891
  yes(c.tools), yes(c.thinking), yes(c.images),
2689
2892
  rankCell(t, 'coding'), rankCell(t, 'web'), rankCell(t, 'vision'),
@@ -3581,6 +3784,7 @@ if (token) {
3581
3784
  gotResult(key, result)
3582
3785
  })
3583
3786
  events.addEventListener('testrun', (e) => showRun(JSON.parse(e.data)))
3787
+ events.addEventListener('helpers', (e) => ((S.helpers = JSON.parse(e.data).helpers), drawMine(S))) // picked for you again, after a test run
3584
3788
  // many at once (thousands of models added): taken in once a frame, the table drawn once
3585
3789
  const news = new Map()
3586
3790
  events.addEventListener('test', (e) => {
package/src/settings.js CHANGED
@@ -8,7 +8,7 @@ import fs from 'node:fs'
8
8
  import path from 'node:path'
9
9
  import crypto from 'node:crypto'
10
10
  import os from 'node:os'
11
- import { HOME, saveConfig, readJson, writeJson, byName, takeIn, whatOf, VERSION, speedOf, SPEED_LIMITS } from './config.js'
11
+ import { HOME, saveConfig, readJson, writeJson, byName, takeIn, whatOf, VERSION, speedOf, SPEED_LIMITS, HELPER_JOBS, helpersOf } from './config.js'
12
12
  import { newer } from './update.js'
13
13
  import { DEFAULT_SERVERS, mcpAuth, serverName } from './mcp.js'
14
14
  import { sections, BUILTIN_PROMPTS, prompt, reloadPrompts } from './prompts.js'
@@ -159,7 +159,7 @@ function forgetList(...names) {
159
159
 
160
160
  export function startSettings({ cfg, apply = () => {}, port = 0, root = process.cwd(), onLoginMcp = null } = {}) {
161
161
  let importCache = [] // the last /api/imports listing, so /api/imports/run can execute by id
162
- const token = crypto.randomBytes(24).toString('hex')
162
+ const token = crypto.randomBytes(16).toString('hex') // short enough for the link to stay on one row of an 80-column dialog, to select it
163
163
  const changed = (what) => {
164
164
  if (what === 'prompts') reloadPrompts() // this page's own Tests use them too (heart settings has no HeartCode to apply them)
165
165
  try {
@@ -404,9 +404,46 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
404
404
  const over = { ...runState(), over: true }
405
405
  run = null
406
406
  emit('testrun', over)
407
+ if (autoPick()) emit('helpers', { helpers: helpersOf(cfg.helpers) }) // picked for you: what the tests found counts
407
408
  }
408
409
  }
409
410
 
411
+ const keyOf = (t) => `${t.provider}/${t.model}`
412
+
413
+ // Helpers picked from what's known: every model of yours (#1 too) that answered its test and whose
414
+ // provider is on, each with the jobs it's good at (at least one): UI & visuals and Code &
415
+ // logic when it's in the top half of LMArena's web-app or coding ranking; Big & hard when it thinks
416
+ // with a big context, or is in the top half of its agent (long real tasks) or hardest-prompts ranking; Quick & cheap when its test was faster than most (or it's good at none of the
417
+ // others). have: picks already made (a job a model has isn't picked again). { key: [jobs] }.
418
+ const pickHelpers = (have = {}) => {
419
+ const ranked = loadRankings()
420
+ const order = [{ provider: cfg.provider, model: cfg.model }, ...rotationOf(cfg).then]
421
+ const pool = order.map((t) => ({ ...t, can: testedOf(t), test: tests[keyOf(t)] })).filter((t) => !cfg.providers[t.provider]?.off && t.test?.ok && t.test.ms != null) // without tool calls too: a helper then works in guided mode
422
+ const top = (t, list) => ((x) => Boolean(x && x.rank / x.of <= 0.5))(rankIn(t.model, list, ranked))
423
+ const times = pool.map((t) => t.test.ms).sort((x, y) => x - y)
424
+ const fast = times[Math.floor((times.length - 1) / 2)] // the middle time: faster than that is quick
425
+ const picks = Object.fromEntries(pool.map((t) => {
426
+ const jobs = [top(t, 'webdev:webdev') && 'ui', top(t, 'text:coding') && 'code', ((t.can?.thinking && t.can.context >= 128_000) || top(t, 'agent:overall') || top(t, 'text:hard_prompts')) && 'hard', t.test.ms <= fast && 'quick'].filter(Boolean)
427
+ return [keyOf(t), jobs.length ? jobs : ['quick']]
428
+ }))
429
+ const out = {}
430
+ for (const [k, jobs] of Object.entries(picks)) {
431
+ const fresh = jobs.filter((j) => !have[k]?.includes(j))
432
+ if (fresh.length) out[k] = fresh
433
+ }
434
+ return out
435
+ }
436
+ // Picked for you: the helpers made again from what's known now (after Update model info, a test run,
437
+ // your list's order changed). true when they changed.
438
+ const autoPick = () => {
439
+ if (cfg.helpersAuto !== true) return false
440
+ const next = pickHelpers()
441
+ if (JSON.stringify(next) === JSON.stringify(helpersOf(cfg.helpers))) return false
442
+ cfg.helpers = Object.keys(next).length ? next : undefined
443
+ save('setting:helpers')
444
+ return true
445
+ }
446
+
410
447
  const state = (ranked = loadRankings()) => ({
411
448
  providers: Object.entries(byName(cfg.providers))
412
449
  .filter(([n]) => n !== cfg.adhoc)
@@ -418,6 +455,10 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
418
455
  order: [...(cfg.providers[cfg.provider] && cfg.model ? [{ provider: cfg.provider, model: cfg.model }] : []), ...rotationOf(cfg).then].map((t) => ({ ...t, tested: testedOf(t), known: knownOf(t), price: priceFor(t), ranks: ranksOf(t.model, ranked) })),
419
456
  rankings: ranked && { fetched: ranked.fetched, source: ranked.source },
420
457
  rotation: (({ then, ...opts }) => opts)(rotationOf(cfg)),
458
+ helpers: helpersOf(cfg.helpers), // { 'provider/model': [jobs] }
459
+ helperOrder: cfg.helperOrder === 'provider' ? 'provider' : 'own', // the order helpers are picked in: your list's, or your provider ranking's
460
+ helpersAuto: cfg.helpersAuto === true, // picked for you (pickHelpers), again whenever what's known changes: the models #1 may start as helpers, and what you picked each for
461
+ jobs: HELPER_JOBS,
421
462
  settings: { permissions: cfg.permissions ?? 'all', effort: cfg.effort ?? 'default', theme: cfg.theme ?? 'dark', context: cfg.context ?? null, ...Object.fromEntries(Object.keys(TOGGLES).map((k) => [k, cfg[k] !== false])), logs: kindsOn(cfg), logDetail: cfg.logDetail === 'summary' ? 'summary' : 'full', logDays: logDays(cfg), testTimeout: Number(cfg.testTimeout) > 0 ? Number(cfg.testTimeout) : 10, ...speedOf(cfg) },
422
463
  logs: { runs: tilde(path.join(LOGS, 'runs')), requests: tilde(REQUESTS) },
423
464
  voice: cfg.voice ? JSON.stringify(cfg.voice, null, 2) : '',
@@ -440,6 +481,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
440
481
  // LMArena's public rankings, fetched now (with models.dev: Update model info on Your models)
441
482
  'POST /api/rankings': async () => {
442
483
  if (!(await rankings({ now: true }))) throw new Error("couldn't get the rankings (huggingface.co)")
484
+ autoPick()
443
485
  return state()
444
486
  },
445
487
  'GET /api/log-size': () => logSize(),
@@ -574,6 +616,33 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
574
616
  forgetTests()
575
617
  return state()
576
618
  },
619
+ // the helpers, all at once: { 'provider/model': [jobs] } (a model in it can be started as a helper; its
620
+ // jobs: what you picked it for, told to #1). Models no longer in your list are left out.
621
+ // picked for you (on), or by you (off: the helpers stay as they are, yours to change)
622
+ 'POST /api/helpers/auto': ({ on }) => {
623
+ cfg.helpersAuto = on === true ? true : undefined
624
+ if (!autoPick()) save('setting:helpersAuto')
625
+ return { helpers: helpersOf(cfg.helpers), helpersAuto: cfg.helpersAuto === true }
626
+ },
627
+ // Suggest helpers: what would be picked, beside what you have (nothing saved)
628
+ 'POST /api/helpers/suggest': () => ({ suggest: pickHelpers(helpersOf(cfg.helpers)) }),
629
+ 'POST /api/helpers': ({ helpers }) => {
630
+ if (!helpers || typeof helpers !== 'object') throw new Error('helpers: an object')
631
+ cfg.helpersAuto = undefined // your own picks now
632
+ const yours = new Set(rotationOf(cfg).then.map((t) => `${t.provider}/${t.model}`).concat(cfg.provider && cfg.model ? [`${cfg.provider}/${cfg.model}`] : []))
633
+ const clean = helpersOf(Object.fromEntries(Object.entries(helpers).filter(([k]) => yours.has(k))))
634
+ cfg.helpers = Object.keys(clean).length ? clean : undefined
635
+ save('setting:helpers')
636
+ return { helpers: helpersOf(cfg.helpers), helpersAuto: false } // only these: the page saves a click at once, and the whole state of a long list takes seconds
637
+ },
638
+ // the order helpers are picked in: 'own' (your list's) or 'provider' (your provider ranking's, each
639
+ // provider's in your list's order; rank: the ranking as the page has it, kept for HeartCode to use)
640
+ 'POST /api/helper-order': ({ by, rank }) => {
641
+ cfg.helperOrder = by === 'provider' ? 'provider' : undefined
642
+ cfg.providerRank = cfg.helperOrder && (Array.isArray(rank) ? rank.filter((x) => typeof x === 'string') : readJson(PREFS, {}).rank)
643
+ save('setting:helperOrder')
644
+ return { helperOrder: cfg.helperOrder ?? 'own' }
645
+ },
577
646
  // the model list, in order (#1 is the model), and when to go on to the next
578
647
  'POST /api/order': ({ list, on, retries, next }) => {
579
648
  if (!Array.isArray(list)) throw new Error('a list of models is needed')
@@ -596,6 +665,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
596
665
  ownWrite = Date.now()
597
666
  saveConfig(cfg)
598
667
  changed(changed1 ? 'model' : 'setting:rotation')
668
+ autoPick() // picked for you: from your list as it is now
599
669
  test(clean)
600
670
  forgetTests()
601
671
  return state()
@@ -1050,7 +1120,8 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
1050
1120
  server.listen(port, '0.0.0.0', () => {
1051
1121
  const at = (host) => `http://${host}:${server.address().port}/?t=${token}`
1052
1122
  const local = at('127.0.0.1') // for a browser on this machine
1053
- const url = at(addresses()[0] ?? '127.0.0.1') // its network address when it has one: works from another device too
1123
+ const ssh = process.env.SSH_CONNECTION?.split(' ')[2] // over SSH: the address you reached this machine at
1124
+ const url = at((ssh?.includes(':') ? `[${ssh}]` : ssh) ?? addresses()[0] ?? '127.0.0.1') // else its network address when it has one: works from another device too
1054
1125
  log('web', `settings page at ${new URL(url).host}`)
1055
1126
  // models.dev's list (its sizes for your models, whether their providers' lists are on or not):
1056
1127
  // loaded now, and your models' lines brought up to date when it's in
package/src/tools.js CHANGED
@@ -697,7 +697,7 @@ export function extraTools(s) {
697
697
  }
698
698
  if (!s.isSub && s.subagent) {
699
699
  const team = s.team?.() ?? []
700
- const model = { type: 'string', description: 'Which of your models does the job ("provider model" from "Your other models"). Left out: yours, or with images you can\'t see, the first of yours that can.' }
700
+ const model = { type: 'string', description: team.some((t) => t.jobs) ? 'Which helper does the job ("provider model" from "Your helpers"). Left out: the first helper.' : 'Which of your models does the job ("provider model" from "Your other models"). Left out: yours, or with images you can\'t see, the first of yours that can.' }
701
701
  const images = { type: 'array', items: str, description: 'Image paths or URLs for the helper to look at. Needs a model that sees images.' }
702
702
  out.push({ name: 'agent', description: prompt('agent/tool-agent'), parameters: obj({ description: str, prompt: str, ...(team.length && { model, images }) }, ['description', 'prompt']) })
703
703
  }
package/src/ui.js CHANGED
@@ -140,11 +140,13 @@ export function loadKeys(file = path.join(HOME, 'keybindings.json')) {
140
140
  const MOUSE_ON = '\x1b[?1000h\x1b[?1002h\x1b[?1006h'
141
141
  const MOUSE_OFF = '\x1b[?1006l\x1b[?1002l\x1b[?1000l'
142
142
 
143
+ export const overSsh = Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY || process.env.SSH_CLIENT)
144
+
143
145
  // The system clipboard (pbcopy, clip, wl-copy, xclip, xsel); else the terminal's (OSC 52). Over SSH,
144
- // the terminal's only: the system's would be the remote machine's, not the one you're at.
146
+ // the terminal's only: the system's would be the remote machine's, not the one you're at. OSC 52 has
147
+ // no answer and some terminals drop it (macOS Terminal), so 'osc' doesn't mean it got there.
145
148
  export function copyText(text) {
146
- const remote = Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY || process.env.SSH_CLIENT)
147
- const tools = remote ? [] : process.platform === 'darwin' ? [['pbcopy']] : process.platform === 'win32' ? [['clip']] : [['wl-copy'], ['xclip', '-selection', 'clipboard'], ['xsel', '-b', '-i']]
149
+ const tools = overSsh ? [] : process.platform === 'darwin' ? [['pbcopy']] : process.platform === 'win32' ? [['clip']] : [['wl-copy'], ['xclip', '-selection', 'clipboard'], ['xsel', '-b', '-i']]
148
150
  for (const [cmd, ...args] of tools) if (spawnSync(cmd, args, { input: text, stdio: ['pipe', 'ignore', 'ignore'] }).status === 0) return 'system'
149
151
  process.stdout.write(`\x1b]52;c;${Buffer.from(text).toString('base64')}\x07`)
150
152
  return 'osc'
@@ -892,7 +894,7 @@ export class UI {
892
894
  const own = pick?.items.some((x) => x.own) // typing goes into "Something else", not a filter
893
895
  const typingOwn = m.items[m.sel]?.item?.own && m.items[m.sel].item.text // ←/→ move in what's typed; Tab goes on
894
896
  const body = pick?.body ? String(pick.body).split('\n') : []
895
- const hint = (pick?.nav ? (typingOwn ? 'Tab questions · ' : '←→ questions · ') : '') + (pick ? (pick.fixed ? '↑↓ move · Enter choose · Esc close' : pick.multi ? `↑↓ move · Space tick · Alt+A/N all/none · Enter take · Esc cancel · ${own ? 'type your own' : 'type to filter'}` : `↑↓ move · Enter choose · Esc cancel${own ? ' · type your own' : cards ? '' : ' · type to filter'}`) : 'Enter send · Esc cancel')
897
+ const hint = (pick?.nav ? (typingOwn ? 'Tab questions · ' : '←→ questions · ') : '') + (pick ? (pick.ctrlC ? 'Enter, Esc or Ctrl+C turn it off' : pick.fixed ? '↑↓ move · Enter choose · Esc close' : pick.multi ? `↑↓ move · Space tick · Alt+A/N all/none · Enter take · Esc cancel · ${own ? 'type your own' : 'type to filter'}` : `↑↓ move · Enter choose · Esc cancel${own ? ' · type your own' : cards ? '' : ' · type to filter'}`) : 'Enter send · Esc cancel')
896
898
  const timer = this.autoLine() // on its own line, so it's seen (and not cut off with the keys)
897
899
  const long = width(title) > this.#dialogBox(cols, rows).w - 6 // too long for the border: inside instead, said once
898
900
  // at most n rows; the rest said to be there
@@ -1212,7 +1214,7 @@ export class UI {
1212
1214
  this.render()
1213
1215
  }
1214
1216
  #copied(text) {
1215
- this.notice(`copied ${text.length} character${text.length === 1 ? '' : 's'}${copyText(text) === 'osc' ? ' (through the terminal)' : ''}`)
1217
+ this.notice(`copied ${text.length} character${text.length === 1 ? '' : 's'}${copyText(text) === 'osc' ? ' (if your terminal allows it)' : ''}`)
1216
1218
  }
1217
1219
  // A double click: the word under it (no spaces; quotes and brackets around it left out), copied.
1218
1220
  #copyWord(x, y) {
@@ -1495,6 +1497,7 @@ export class UI {
1495
1497
  return this.dialog.key?.(key, s), this.render()
1496
1498
  }
1497
1499
  if (this.recording) return this.recording.key(key, bound) // voice: Space, Enter, Esc; the rest waits
1500
+ if (this.menu.pick?.ctrlC && key.ctrl && key.name === 'c') return this.cancelAsk()
1498
1501
  // a fixed dialog (pick(…, { fixed })): only its keys, nothing typed and no shortcuts
1499
1502
  if (this.menu.pick?.fixed && !['up', 'down', 'return', 'escape'].includes(key.name) && !(key.ctrl && key.name === 'c')) return
1500
1503
  // In a multi-select: Alt+A ticks all, Alt+N unticks all (before Alt+A sends and Alt+N switches tabs)
@@ -2124,9 +2127,10 @@ export class UI {
2124
2127
  // multi: tick several with Space; returns the ticked items (an array), or null.
2125
2128
  // quiet: the question and answer aren't left in the conversation (a question before it starts).
2126
2129
  // fixed: a dialog: no typing to filter, no other keys meanwhile.
2130
+ // ctrlC: Ctrl+C closes it too, like Esc (not the first half of quitting).
2127
2131
  // auto: { item, secs }: nobody answers for secs seconds (each key starts the wait again) → item is chosen.
2128
2132
  // tabs: a row of tabs above it (several questions); nav: ←/→ (Tab, Shift+Tab) close it with { nav: -1 | 1 }.
2129
- async pick(title, items, { filter = '', multi = false, quiet = false, fixed = false, body = '', auto = null, tabs = '', nav = false } = {}) {
2133
+ async pick(title, items, { filter = '', multi = false, quiet = false, fixed = false, body = '', auto = null, tabs = '', nav = false, ctrlC = false } = {}) {
2130
2134
  if (!this.full) {
2131
2135
  items.forEach((it, i) => this.print(` ${i + 1}. ${it.group ? `${it.group} · ` : ''}${it.label}${it.desc ? ' ' + c.dim(it.desc) : ''}`))
2132
2136
  const a = await this.ask(`${title} ${c.dim(multi ? '(numbers, like 1,3)' : '(number)')}: `)
@@ -2138,7 +2142,7 @@ export class UI {
2138
2142
  }
2139
2143
  await this.#free()
2140
2144
  if (multi) for (const it of items) if (!it.only) it.checked ??= false
2141
- this.menu.pick = { items, chosen: null, multi, quiet, fixed, body, tabs, nav, auto: auto && { ...auto } }
2145
+ this.menu.pick = { items, chosen: null, multi, quiet, fixed, body, tabs, nav, ctrlC, auto: auto && { ...auto } }
2142
2146
  this.autoPicked = false // chosen for the user (nobody answered in time), for the caller to say so
2143
2147
  if (auto) {
2144
2148
  this.#armAuto()