heartcode 0.1.24 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/README.md +1 -1
- package/bin/heartcode.js +210 -70
- package/package.json +1 -1
- package/prompts/agent.md +19 -4
- package/prompts/guided.md +1 -0
- package/src/agent.js +16 -3
- package/src/capabilities.js +48 -0
- package/src/config.js +1 -1
- package/src/edit.js +39 -9
- package/src/importer.js +99 -0
- package/src/mcp.js +21 -3
- package/src/oauth.js +3 -0
- package/src/settings.html +289 -12
- package/src/settings.js +77 -5
- package/src/tabs.js +2 -2
- package/src/tools.js +56 -7
- package/src/ui.js +36 -13
package/src/settings.html
CHANGED
|
@@ -177,6 +177,21 @@
|
|
|
177
177
|
.mono { font-family: var(--mono); font-size: 12.5px; }
|
|
178
178
|
.muted { color: var(--muted); }
|
|
179
179
|
.tag { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 600; line-height: 18px; padding: 0 7px; border-radius: 6px; background: var(--hover); color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
180
|
+
.tag.ok { background: var(--ok-soft); color: var(--ok); }
|
|
181
|
+
.tag.need { background: rgba(217, 164, 6, .14); color: #caa106; }
|
|
182
|
+
/* External tools / capabilities */
|
|
183
|
+
.cap { padding: 13px 0; border-bottom: 1px solid var(--line); }
|
|
184
|
+
.cap:first-child { padding-top: 2px; }
|
|
185
|
+
.cap:last-child { border-bottom: 0; padding-bottom: 2px; }
|
|
186
|
+
.cap-h { display: flex; align-items: center; gap: 8px; }
|
|
187
|
+
.cap-h b { font-weight: 600; }
|
|
188
|
+
.cap-h .tag { margin-left: auto; }
|
|
189
|
+
.cap-mark { width: 18px; text-align: center; font-weight: 700; color: var(--ok); flex: none; }
|
|
190
|
+
.cap.cap-off .cap-mark { color: var(--faint); }
|
|
191
|
+
.cap.cap-off .cap-h b, .cap.cap-off .cap-what { color: var(--faint); } /* grayed out until it's set up */
|
|
192
|
+
.cap-what { color: var(--muted); font-size: 12.5px; margin: 4px 0 0 26px; text-wrap: pretty; }
|
|
193
|
+
.cap-need { font-size: 12.5px; margin: 7px 0 0 26px; padding: 8px 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-s); }
|
|
194
|
+
.cap-need b { color: var(--muted); }
|
|
180
195
|
.tag.brand { background: var(--accent-soft); color: var(--accent); }
|
|
181
196
|
.tag.ok { background: var(--ok-soft); color: var(--ok); }
|
|
182
197
|
.tag.err { background: var(--err-soft); color: var(--err); }
|
|
@@ -497,6 +512,48 @@
|
|
|
497
512
|
.md.fill .detail > .card > textarea.editor { min-height: 260px; }
|
|
498
513
|
.prov-head, .prov-body { padding-left: 14px; padding-right: 14px; }
|
|
499
514
|
}
|
|
515
|
+
/* Status-bar editor */
|
|
516
|
+
.sb-wrap { display: flex; flex-direction: column; gap: 18px; max-width: 940px; }
|
|
517
|
+
.sb-onoff { padding-top: 0; padding-bottom: 16px; cursor: default; }
|
|
518
|
+
.sb-onoff #sb-switch { display: inline-flex; align-items: center; flex: none; } /* so the switch inside is a flex item and gets its width/height */
|
|
519
|
+
.sb-cardhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
|
|
520
|
+
.sb-cardhead .sub { margin-bottom: 0; }
|
|
521
|
+
.sb-cardhead button { flex: none; }
|
|
522
|
+
.sb-hint { font-size: 11px; color: var(--faint); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .04em; }
|
|
523
|
+
.sb-preview { background: #0c0d10; color: #ececf0; border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 11px 13px; font-family: var(--mono); font-size: 13px; line-height: 1.75; overflow-x: auto; white-space: pre; }
|
|
524
|
+
.sb-preview .sb-row { display: flex; }
|
|
525
|
+
.sb-preview .sb-grow { flex: 1; }
|
|
526
|
+
.sb-preview .sb-sep { color: #4b4e57; }
|
|
527
|
+
.sb-preview .sb-empty { color: #6d717c; font-style: italic; }
|
|
528
|
+
.sb-lines { display: flex; flex-direction: column; gap: 10px; }
|
|
529
|
+
.sb-line { display: flex; gap: 8px; align-items: stretch; }
|
|
530
|
+
.sb-line .sb-no { width: 16px; flex: none; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: center; }
|
|
531
|
+
.sb-zone { flex: 1; min-width: 0; min-height: 44px; border: 1px dashed var(--line-strong); border-radius: var(--radius-s); padding: 8px 9px; background: var(--panel2); display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; transition: background .12s, border-color .12s; }
|
|
532
|
+
.sb-zone .sb-ztag { width: 100%; font-size: 10.5px; color: var(--faint); margin-bottom: 1px; text-transform: uppercase; letter-spacing: .05em; }
|
|
533
|
+
.sb-zone .sb-drop { color: var(--faint); font-size: 12px; font-style: italic; padding: 2px 1px; }
|
|
534
|
+
.sb-zone.sb-over { border-color: var(--accent); border-style: solid; background: var(--accent-soft); }
|
|
535
|
+
.sb-line .sb-del { flex: none; width: 30px; align-self: stretch; border: 1px solid transparent; background: none; color: var(--faint); cursor: pointer; border-radius: var(--radius-s); font-size: 14px; }
|
|
536
|
+
.sb-line .sb-del:hover { background: var(--err-soft); color: var(--err); }
|
|
537
|
+
.sb-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px 4px 10px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12.5px; font-weight: 500; cursor: grab; user-select: none; box-shadow: var(--shadow); }
|
|
538
|
+
.sb-chip:active { cursor: grabbing; }
|
|
539
|
+
.sb-chip.sb-dragging { opacity: .4; }
|
|
540
|
+
.sb-chip .sb-x { border: none; background: none; color: var(--faint); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; border-radius: 50%; }
|
|
541
|
+
.sb-chip .sb-x:hover { color: var(--err); background: var(--err-soft); }
|
|
542
|
+
.sb-palette { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
543
|
+
.sb-palette .sb-chip { background: var(--panel2); padding: 5px 11px; }
|
|
544
|
+
.sb-palette .sb-chip.sb-used { opacity: .4; cursor: not-allowed; }
|
|
545
|
+
#sb-editor.sb-off { opacity: .55; } /* off: dimmed as a hint, but still editable so turning it back on keeps the layout */
|
|
546
|
+
/* Import dialog */
|
|
547
|
+
#imp { width: 560px; max-width: calc(100vw - 32px); }
|
|
548
|
+
.imp-list { max-height: 56vh; overflow: auto; margin-top: 4px; }
|
|
549
|
+
.imp-group { margin-bottom: 14px; }
|
|
550
|
+
.imp-gh { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
|
|
551
|
+
.imp-gh label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
|
|
552
|
+
.imp-row { display: flex; align-items: baseline; gap: 10px; padding: 7px 8px; border-radius: var(--radius-s); cursor: pointer; }
|
|
553
|
+
.imp-row:hover { background: var(--hover); }
|
|
554
|
+
.imp-row input { margin: 0; flex: none; align-self: center; }
|
|
555
|
+
.imp-row .imp-label { font-weight: 500; font-family: var(--mono); font-size: 12.5px; flex: none; }
|
|
556
|
+
.imp-row .imp-desc { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
500
557
|
</style>
|
|
501
558
|
</head>
|
|
502
559
|
<body>
|
|
@@ -507,6 +564,7 @@
|
|
|
507
564
|
<a href="#providers" data-page="providers"><span class="ic">◉</span> Providers & models <span class="count" id="n-providers"></span></a>
|
|
508
565
|
<a href="#models" data-page="models"><span class="ic">☰</span> Your models <span class="count" id="n-mine"></span></a>
|
|
509
566
|
<a href="#general" data-page="general"><span class="ic">⚙</span> General</a>
|
|
567
|
+
<a href="#statusbar" data-page="statusbar"><span class="ic">▭</span> Status bar</a>
|
|
510
568
|
<a href="#logging" data-page="logging"><span class="ic">▤</span> Logging <span class="count" id="n-failed"></span></a>
|
|
511
569
|
<a href="#prompts" data-page="prompts"><span class="ic">✎</span> System prompt</a>
|
|
512
570
|
<a href="#mcp" data-page="mcp"><span class="ic">⧉</span> MCP servers <span class="count" id="n-mcp"></span></a>
|
|
@@ -633,6 +691,39 @@
|
|
|
633
691
|
<textarea id="v-text" spellcheck="false" rows="3" placeholder="(whisper-cli on this machine)"></textarea>
|
|
634
692
|
<div class="actions"><button class="primary" id="v-save">Save voice</button></div>
|
|
635
693
|
</div>
|
|
694
|
+
<div class="card">
|
|
695
|
+
<h2>External tools</h2>
|
|
696
|
+
<p class="sub">Some features need a tool or service on your machine. Ready ones are ticked; the rest show what to install.</p>
|
|
697
|
+
<div id="g-caps"></div>
|
|
698
|
+
</div>
|
|
699
|
+
</div>
|
|
700
|
+
</div>
|
|
701
|
+
</section>
|
|
702
|
+
|
|
703
|
+
<!-- Status bar: visual drag-and-drop editor -->
|
|
704
|
+
<section class="page" id="page-statusbar">
|
|
705
|
+
<div class="head"><div><h1>Status bar</h1><p class="lead">The line(s) at the bottom of HeartCode. Drag items into each line, or onto the right to push them to the edge. Saved for next time; a running HeartCode updates right away.</p></div></div>
|
|
706
|
+
<div class="sb-wrap">
|
|
707
|
+
<div class="card">
|
|
708
|
+
<label class="opt sb-onoff">
|
|
709
|
+
<div class="t"><b>Show the status bar</b><span>Turn the whole thing on or off.</span></div>
|
|
710
|
+
<span id="sb-switch"></span>
|
|
711
|
+
</label>
|
|
712
|
+
<div class="sb-hint">Live preview</div>
|
|
713
|
+
<div class="sb-preview" id="sb-preview"></div>
|
|
714
|
+
</div>
|
|
715
|
+
<div class="card" id="sb-editor">
|
|
716
|
+
<div class="sb-cardhead">
|
|
717
|
+
<div><h2>Lines</h2><p class="sub">Drag an item from the palette into <b>Left</b> or <b>Right</b>. Drag chips to reorder or move between lines; the × removes one.</p></div>
|
|
718
|
+
<button id="sb-reset">Reset to default</button>
|
|
719
|
+
</div>
|
|
720
|
+
<div id="sb-lines"></div>
|
|
721
|
+
<div class="actions"><button id="sb-addline">+ Add a line</button></div>
|
|
722
|
+
</div>
|
|
723
|
+
<div class="card">
|
|
724
|
+
<h2>Items</h2>
|
|
725
|
+
<p class="sub">Drag any of these into a line above. Each one appears once it's placed.</p>
|
|
726
|
+
<div class="sb-palette" id="sb-palette"></div>
|
|
636
727
|
</div>
|
|
637
728
|
</div>
|
|
638
729
|
</section>
|
|
@@ -657,7 +748,15 @@
|
|
|
657
748
|
|
|
658
749
|
<!-- Skills -->
|
|
659
750
|
<section class="page" id="page-skills">
|
|
660
|
-
<div class="head"><div><h1>Skills</h1><p class="lead">Ready-made prompts. You type one as <span class="mono">/name</span>, or the model uses it when it fits.</p></div><button class="primary" id="k-new">+ New skill</button></div>
|
|
751
|
+
<div class="head"><div><h1>Skills</h1><p class="lead">Ready-made prompts. You type one as <span class="mono">/skill:name</span>, or the model uses it when it fits.</p></div><div class="head-actions"><button id="k-import">Import from other tools</button><button class="primary" id="k-new">+ New skill</button></div></div>
|
|
752
|
+
<div class="card" id="k-install-card">
|
|
753
|
+
<h2>Install from GitHub or a URL</h2>
|
|
754
|
+
<p class="sub">A GitHub repo (<span class="mono">owner/repo</span> or its link) or a link to a <span class="mono">SKILL.md</span>. Same as <span class="mono">/install_skill</span> in HeartCode; installed for every project.</p>
|
|
755
|
+
<div class="row">
|
|
756
|
+
<div class="grow"><input type="text" id="k-url" placeholder="owner/repo or https://github.com/owner/repo" spellcheck="false"></div>
|
|
757
|
+
<button class="primary" id="k-install">Install</button>
|
|
758
|
+
</div>
|
|
759
|
+
</div>
|
|
661
760
|
<div class="md">
|
|
662
761
|
<div class="list"><div class="items" id="k-items"></div></div>
|
|
663
762
|
<div class="detail" id="k-detail"></div>
|
|
@@ -718,6 +817,12 @@
|
|
|
718
817
|
<div class="actions"><button id="c-cancel">Cancel</button><button class="primary" id="c-add">Add server</button></div>
|
|
719
818
|
</dialog>
|
|
720
819
|
<dialog id="k-form" aria-labelledby="k-title"></dialog>
|
|
820
|
+
<dialog id="imp" aria-labelledby="imp-title">
|
|
821
|
+
<h2 id="imp-title">Import from other coding tools</h2>
|
|
822
|
+
<p class="sub">Skills, commands, MCP servers, instructions and memory found in Claude Code, Cursor, Gemini CLI and Codex. Tick what to bring into HeartCode — nothing already here is overwritten.</p>
|
|
823
|
+
<div id="imp-list" class="imp-list"></div>
|
|
824
|
+
<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>
|
|
825
|
+
</dialog>
|
|
721
826
|
<dialog id="gone" aria-labelledby="gone-title">
|
|
722
827
|
<h2 id="gone-title">Disconnected</h2>
|
|
723
828
|
<p class="sub">HeartCode's settings page was turned off, so nothing here can be changed or saved now.</p>
|
|
@@ -847,6 +952,7 @@ const DOING = {
|
|
|
847
952
|
'/api/provider/list': 'Saving the model list setting',
|
|
848
953
|
'/api/provider/on': 'Switching the provider',
|
|
849
954
|
'/api/order': 'Saving your models',
|
|
955
|
+
'/api/mcp/login': 'Signing in — your browser will open',
|
|
850
956
|
'/api/models-dev': null, // its own strip
|
|
851
957
|
}
|
|
852
958
|
let acting = 0
|
|
@@ -904,7 +1010,7 @@ addEventListener('scroll', drawVirtual, { capture: true, passive: true }) // the
|
|
|
904
1010
|
addEventListener('resize', drawVirtual)
|
|
905
1011
|
|
|
906
1012
|
// pages: one at a time, from the address (#providers…)
|
|
907
|
-
const PAGES = ['providers', 'models', 'general', 'logging', 'prompts', 'mcp', 'skills', 'files']
|
|
1013
|
+
const PAGES = ['providers', 'models', 'general', 'statusbar', 'logging', 'prompts', 'mcp', 'skills', 'files']
|
|
908
1014
|
const page = () => (PAGES.includes(location.hash.slice(1)) ? location.hash.slice(1) : 'providers')
|
|
909
1015
|
function showPage() {
|
|
910
1016
|
for (const p of PAGES) $('page-' + p).classList.toggle('on', p === page())
|
|
@@ -1946,6 +2052,11 @@ function drawGeneral(s) {
|
|
|
1946
2052
|
h('div', { className: 't' }, h('b', { textContent: TOGGLE_INFO[k] ?? k }), h('span', { textContent: d[0].toUpperCase() + d.slice(1) })),
|
|
1947
2053
|
sw({ checked: s.settings[k], onchange: (e) => act('/api/setting', { name: k, value: e.target.checked }, `${TOGGLE_INFO[k] ?? k}: ${e.target.checked ? 'on' : 'off'}`) }))))
|
|
1948
2054
|
if (document.activeElement !== $('v-text')) $('v-text').value = s.voice
|
|
2055
|
+
put($('g-caps'), ...(s.capabilities || []).map((c) =>
|
|
2056
|
+
h('div', { className: 'cap' + (c.ok ? '' : ' cap-off') },
|
|
2057
|
+
h('div', { className: 'cap-h' }, h('span', { className: 'cap-mark', textContent: c.ok ? '✓' : '✗' }), h('b', { textContent: c.name }), h('span', { className: c.ok ? 'tag ok' : 'tag need', textContent: c.ok ? 'ready' : 'needs setup' })),
|
|
2058
|
+
h('div', { className: 'cap-what', textContent: c.what }),
|
|
2059
|
+
c.ok ? null : h('div', { className: 'cap-need' }, h('b', {}, 'Install: '), c.need))))
|
|
1949
2060
|
}
|
|
1950
2061
|
$('g-effort').onchange = (e) => act('/api/setting', { name: 'effort', value: e.target.value }, 'effort saved')
|
|
1951
2062
|
$('g-context').onchange = (e) => act('/api/setting', { name: 'context', value: e.target.value.trim() ? Number(e.target.value) : null }, 'context window saved')
|
|
@@ -2116,9 +2227,11 @@ $('c-add').onclick = async () => {
|
|
|
2116
2227
|
$('c-open').onclick = () => ($('c-form').showModal(), $('c-name').focus())
|
|
2117
2228
|
$('c-cancel').onclick = () => $('c-form').close()
|
|
2118
2229
|
function drawMcp(s) {
|
|
2119
|
-
|
|
2230
|
+
const authTag = (a) => (a === 'in' ? h('span', { className: 'tag ok', textContent: 'signed in' }) : h('span', { className: 'tag need', textContent: 'sign-in needed' }))
|
|
2231
|
+
put($('c-list'), h('h2', { textContent: 'Servers' }), h('p', { className: 'sub', textContent: 'Built in, and yours. Remote ones (a URL) may need signing in; local ones don\'t. Switch one off to keep it without using it.' }),
|
|
2120
2232
|
s.mcp.length ? s.mcp.map((m) => h('div', { className: 'opt' },
|
|
2121
|
-
h('div', { className: 't' }, h('b', {}, m.name, ' ', h('span', { className: 'tag', textContent: m.from })), m.description ? h('span', { textContent: m.description }) : null, h('div', { className: 'mono muted', style: 'word-break:break-all;margin-top:3px', textContent: m.what })),
|
|
2233
|
+
h('div', { className: 't' }, h('b', {}, m.name, ' ', h('span', { className: 'tag', textContent: m.from }), m.remote ? authTag(m.auth) : null), m.description ? h('span', { textContent: m.description }) : null, h('div', { className: 'mono muted', style: 'word-break:break-all;margin-top:3px', textContent: m.what })),
|
|
2234
|
+
m.remote ? h('button', { className: 'small', textContent: m.auth === 'in' ? 'Sign in again' : 'Sign in', onclick: () => act('/api/mcp/login', { name: m.name }, `signed in to ${m.name}`) }) : null,
|
|
2122
2235
|
m.from === 'yours' ? h('button', { className: 'small danger', textContent: 'Remove', onclick: () => confirm(`Remove the MCP server ${m.name}?`) && act('/api/mcp/remove', { name: m.name }, `removed ${m.name}`) }) : null,
|
|
2123
2236
|
sw({ checked: m.on, 'aria-label': `${m.name} on`, onchange: (e) => act('/api/mcp/toggle', { name: m.name, on: e.target.checked }, `${m.name}: ${e.target.checked ? 'on' : 'off'}`) }))) : h('div', { className: 'empty', textContent: 'No MCP servers.' }))
|
|
2124
2237
|
const f = s.files.find((x) => x.name === 'mcp.json')
|
|
@@ -2128,7 +2241,7 @@ function drawMcp(s) {
|
|
|
2128
2241
|
}
|
|
2129
2242
|
|
|
2130
2243
|
// --- skills: a form (name, who uses it, what it's for, the prompt); SKILL.md is made from it ---
|
|
2131
|
-
const USES = [['both', 'You and the model', 'type /name, or the model uses it when it fits'], ['me', 'Only you', 'only when you type /name'], ['model', 'Only the model', "when it fits; you don't type it"]]
|
|
2244
|
+
const USES = [['both', 'You and the model', 'type /skill:name, or the model uses it when it fits'], ['me', 'Only you', 'only when you type /skill:name'], ['model', 'Only the model', "when it fits; you don't type it"]]
|
|
2132
2245
|
function parseSkill(text) {
|
|
2133
2246
|
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(text)
|
|
2134
2247
|
const out = { description: '', use: 'both', extra: [], body: (m ? m[2] : text).replace(/^\s*\n/, '') }
|
|
@@ -2169,30 +2282,84 @@ function skillForm(id, start, { isNew, readOnly }) {
|
|
|
2169
2282
|
const uses = h('div', { className: 'choices' }, USES.map(([v, t, sub]) => h('label', { className: 'choice' + (d.use === v ? ' on' : '') },
|
|
2170
2283
|
h('input', { type: 'radio', name: `use-${id}`, checked: d.use === v, disabled: readOnly, onchange: () => ((d.use = v), touch(), uses.querySelectorAll('.choice').forEach((c) => c.classList.toggle('on', c.querySelector('input').checked))) }),
|
|
2171
2284
|
h('b', { textContent: t }), h('span', { textContent: sub }))))
|
|
2172
|
-
const body = grow(h('textarea', { className: 'editor', spellcheck: false, readOnly, value: d.body, placeholder: 'What the model should do. $ARGUMENTS is what you type after /name: "/review the login page" gives "the login page".', oninput: (e) => ((d.body = e.target.value), touch()) }), 220)
|
|
2285
|
+
const body = grow(h('textarea', { className: 'editor', spellcheck: false, readOnly, value: d.body, placeholder: 'What the model should do. $ARGUMENTS is what you type after /skill:name: "/skill:review the login page" gives "the login page".', oninput: (e) => ((d.body = e.target.value), touch()) }), 220)
|
|
2173
2286
|
return { d, el: [
|
|
2174
2287
|
h('div', { className: 'row' },
|
|
2175
|
-
isNew ? h('div', { className: 'grow' }, h('label', { className: 'f', textContent: "Name: you'll type /name" }), field('name', { placeholder: 'review' })) : null,
|
|
2288
|
+
isNew ? h('div', { className: 'grow' }, h('label', { className: 'f', textContent: "Name: you'll type /skill:name" }), field('name', { placeholder: 'review' })) : null,
|
|
2176
2289
|
h('div', { className: 'grow', style: 'flex:3' }, h('label', { className: 'f', textContent: 'What it does (the model reads this to know when to use it)' }), field('description', { placeholder: 'Reviews the changes for bugs and unclear code' }))),
|
|
2177
2290
|
h('label', { className: 'f', textContent: 'Who uses it' }), uses,
|
|
2178
2291
|
h('label', { className: 'f', textContent: 'The prompt' }), body,
|
|
2179
2292
|
] }
|
|
2180
2293
|
}
|
|
2294
|
+
// Import from other coding CLIs (/import): list what was found, grouped with checkboxes, then run the picks.
|
|
2295
|
+
async function openImport() {
|
|
2296
|
+
let r
|
|
2297
|
+
try {
|
|
2298
|
+
r = await api('/api/imports', {})
|
|
2299
|
+
} catch (e) {
|
|
2300
|
+
return toast(e.message, true)
|
|
2301
|
+
}
|
|
2302
|
+
const items = r.items || []
|
|
2303
|
+
if (!items.length) return toast('Nothing found in Claude Code, Cursor, Gemini CLI or Codex on this machine')
|
|
2304
|
+
const byGroup = {}
|
|
2305
|
+
for (const it of items) (byGroup[it.group] ??= []).push(it)
|
|
2306
|
+
put($('imp-list'), ...Object.entries(byGroup).map(([g, its]) =>
|
|
2307
|
+
h('div', { className: 'imp-group' },
|
|
2308
|
+
h('div', { className: 'imp-gh' }, h('label', {}, h('input', { type: 'checkbox', onchange: (e) => its.forEach((it) => ($('imp-cb-' + it.id).checked = e.target.checked)) }), ' ', g + ` (${its.length})`)),
|
|
2309
|
+
...its.map((it) => h('label', { className: 'imp-row' }, h('input', { type: 'checkbox', id: 'imp-cb-' + it.id, value: it.id }), h('span', { className: 'imp-label', textContent: it.label }), h('span', { className: 'imp-desc', textContent: it.desc || '' }))))))
|
|
2310
|
+
$('imp-cancel').onclick = () => $('imp').close()
|
|
2311
|
+
$('imp-go').onclick = async () => {
|
|
2312
|
+
const ids = [...$('imp-list').querySelectorAll('input[type=checkbox][id^="imp-cb-"]:checked')].map((c) => Number(c.value))
|
|
2313
|
+
if (!ids.length) return toast('Nothing ticked', true)
|
|
2314
|
+
job('import', { where: ['page'], what: 'Importing', detail: `${ids.length} item${ids.length === 1 ? '' : 's'}` })
|
|
2315
|
+
try {
|
|
2316
|
+
const res = await api('/api/imports/run', { ids })
|
|
2317
|
+
$('imp').close()
|
|
2318
|
+
const ok = (res.results || []).filter((x) => x.ok).length
|
|
2319
|
+
toast(`Imported ${ok} of ${ids.length}`)
|
|
2320
|
+
render(res)
|
|
2321
|
+
} catch (e) {
|
|
2322
|
+
toast(e.message, true)
|
|
2323
|
+
} finally {
|
|
2324
|
+
job('import')
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
$('imp').showModal()
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2181
2330
|
function drawSkills(s) {
|
|
2182
2331
|
const mine = s.skills.filter((k) => k.mine)
|
|
2183
2332
|
const theirs = s.skills.filter((k) => !k.mine)
|
|
2184
|
-
const item = (k) => ({ id: k.name, title: '/' + k.name, sub: k.description, k })
|
|
2333
|
+
const item = (k) => ({ id: k.name, title: '/skill:' + k.name, sub: k.description, k })
|
|
2334
|
+
const install = async () => {
|
|
2335
|
+
const url = $('k-url').value.trim()
|
|
2336
|
+
if (!url) return toast('Enter a GitHub repo or a SKILL.md URL', true)
|
|
2337
|
+
job('kinstall', { where: ['page'], what: 'Installing the skill', detail: url })
|
|
2338
|
+
try {
|
|
2339
|
+
const r = await api('/api/skill/install', { url })
|
|
2340
|
+
$('k-url').value = ''
|
|
2341
|
+
toast(r.message || 'installed')
|
|
2342
|
+
render(r)
|
|
2343
|
+
} catch (e) {
|
|
2344
|
+
toast(e.message, true)
|
|
2345
|
+
} finally {
|
|
2346
|
+
job('kinstall')
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
$('k-install').onclick = install
|
|
2350
|
+
$('k-url').onkeydown = (e) => e.key === 'Enter' && install()
|
|
2351
|
+
$('k-import').onclick = openImport
|
|
2185
2352
|
masterDetail('skills', $('k-items'), $('k-detail'), [{ title: mine.length && theirs.length ? 'Yours' : '', items: mine.map(item) }, { title: 'From projects', items: theirs.map(item) }], (x) => {
|
|
2186
|
-
if (!x) return h('div', { className: 'card' }, h('h2', { textContent: 'No skills yet' }), h('p', { className: 'sub', textContent: 'A skill is a prompt you use again and again, like "review this" or "write the release notes". Make one with + New skill, or bring them from Claude Code and others with /import in HeartCode.' }))
|
|
2353
|
+
if (!x) return h('div', { className: 'card' }, h('h2', { textContent: 'No skills yet' }), h('p', { className: 'sub', textContent: 'A skill is a prompt you use again and again, like "review this" or "write the release notes". Make one with + New skill, install one from GitHub above, or bring them from Claude Code and others with /import in HeartCode.' }))
|
|
2187
2354
|
const k = x.k
|
|
2188
2355
|
const f = skillForm(k.name, parseSkill(k.text), { readOnly: !k.mine })
|
|
2189
2356
|
return h('div', { className: 'card' },
|
|
2190
|
-
h('div', { className: 'row', style: 'justify-content:space-between;align-items:center' }, h('h2', { style: 'margin:0', className: 'mono', textContent: '/' + k.name }), k.mine ? null : h('span', { className: 'tag', textContent: 'from a project: read only' })),
|
|
2357
|
+
h('div', { className: 'row', style: 'justify-content:space-between;align-items:center' }, h('h2', { style: 'margin:0', className: 'mono', textContent: '/skill:' + k.name }), k.mine ? null : h('span', { className: 'tag', textContent: 'from a project: read only' })),
|
|
2191
2358
|
f.el,
|
|
2192
2359
|
k.mine ? h('div', { className: 'actions' },
|
|
2193
|
-
h('button', { className: 'primary', textContent: 'Save', onclick: () => saveItem('skills', k.name, '/api/skill', { name: k.name, was: k.name, text: skillText(f.d) }, `saved
|
|
2360
|
+
h('button', { className: 'primary', textContent: 'Save', onclick: () => saveItem('skills', k.name, '/api/skill', { name: k.name, was: k.name, text: skillText(f.d) }, `saved /skill:${k.name}`) }),
|
|
2194
2361
|
h('span', { className: 'spacer' }),
|
|
2195
|
-
h('button', { className: 'danger', textContent: 'Delete', onclick: () => confirm(`Delete the skill
|
|
2362
|
+
h('button', { className: 'danger', textContent: 'Delete', onclick: () => confirm(`Delete the skill /skill:${k.name}?`) && saveItem('skills', k.name, '/api/skill/delete', { name: k.name }, `deleted /skill:${k.name}`) })) : null)
|
|
2196
2363
|
})
|
|
2197
2364
|
$('n-skills').textContent = s.skills.length || ''
|
|
2198
2365
|
}
|
|
@@ -2214,6 +2381,115 @@ function drawFiles(s) {
|
|
|
2214
2381
|
})
|
|
2215
2382
|
}
|
|
2216
2383
|
|
|
2384
|
+
// ---- Status bar: visual drag-and-drop editor ----
|
|
2385
|
+
let SB_ITEMS = [] // [{ id, label, sample }] from the server
|
|
2386
|
+
let sbOn = true // the bar shown at all
|
|
2387
|
+
let sbLines = [] // [{ left:[id…], right:[id…] }]
|
|
2388
|
+
let sbDrag = null // the chip being dragged: { id, from: 'palette' | { line, side, idx } }
|
|
2389
|
+
let sbSaveTimer = null
|
|
2390
|
+
const SB_DEFAULT = () => [
|
|
2391
|
+
{ left: ['provider', 'model'], right: ['mode', 'thinking', 'images'] },
|
|
2392
|
+
{ left: ['ctx', 'tps', 'autocompact'], right: ['permissions', 'worktree', 'cost'] },
|
|
2393
|
+
]
|
|
2394
|
+
const sbLabel = (id) => (SB_ITEMS.find((i) => i.id === id) || {}).label || id
|
|
2395
|
+
const sbSample = (id) => (SB_ITEMS.find((i) => i.id === id) || {}).sample || id
|
|
2396
|
+
const sbUsed = () => new Set(sbLines.flatMap((l) => [...l.left, ...l.right]))
|
|
2397
|
+
|
|
2398
|
+
function drawStatusBar(s) {
|
|
2399
|
+
if (s.choices?.statusItems) SB_ITEMS = s.choices.statusItems
|
|
2400
|
+
const sb = s.statusBar
|
|
2401
|
+
if (sb === false) { sbOn = false; sbLines = SB_DEFAULT() }
|
|
2402
|
+
else if (Array.isArray(sb)) { sbOn = true; sbLines = sb.map((row) => (Array.isArray(row) ? { left: [...row], right: [] } : { left: [...(row.left || [])], right: [...(row.right || [])] })) }
|
|
2403
|
+
else { sbOn = true; sbLines = SB_DEFAULT() }
|
|
2404
|
+
if (!sbLines.length) sbLines = [{ left: [], right: [] }]
|
|
2405
|
+
put($('sb-switch'), sw({ checked: sbOn, onchange: (e) => { sbOn = e.target.checked; sbRenderAll(); sbSave() } }))
|
|
2406
|
+
$('sb-reset').onclick = () => { sbOn = true; sbLines = SB_DEFAULT(); sbRenderAll(); sbSave() }
|
|
2407
|
+
$('sb-addline').onclick = () => { sbLines.push({ left: [], right: [] }); sbRenderAll(); sbSave() }
|
|
2408
|
+
sbRenderAll()
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
function sbRenderAll() {
|
|
2412
|
+
$('sb-editor').classList.toggle('sb-off', !sbOn)
|
|
2413
|
+
sbRenderLines()
|
|
2414
|
+
sbRenderPalette()
|
|
2415
|
+
sbRenderPreview()
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
function sbChip(id, from) {
|
|
2419
|
+
const chip = h('span', {
|
|
2420
|
+
className: 'sb-chip', draggable: true,
|
|
2421
|
+
ondragstart: (e) => { sbDrag = { id, from }; chip.classList.add('sb-dragging'); e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/plain', id) },
|
|
2422
|
+
ondragend: () => { chip.classList.remove('sb-dragging'); sbDrag = null },
|
|
2423
|
+
}, h('span', { textContent: sbLabel(id) }))
|
|
2424
|
+
if (from !== 'palette') chip.append(h('button', { className: 'sb-x', title: 'Remove', textContent: '×', onclick: () => { sbLines[from.line][from.side].splice(from.idx, 1); sbRenderAll(); sbSave() } }))
|
|
2425
|
+
return chip
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
function sbDropIndex(zone, e) { // where in the zone the drop lands, by the cursor's x
|
|
2429
|
+
const chips = [...zone.querySelectorAll('.sb-chip')]
|
|
2430
|
+
for (let i = 0; i < chips.length; i++) { const r = chips[i].getBoundingClientRect(); if (e.clientX < r.left + r.width / 2) return i }
|
|
2431
|
+
return chips.length
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
function sbZone(lineIdx, side) {
|
|
2435
|
+
const items = sbLines[lineIdx][side]
|
|
2436
|
+
const zone = h('div', { className: 'sb-zone' }, h('span', { className: 'sb-ztag', textContent: side === 'left' ? 'Left' : 'Right' }),
|
|
2437
|
+
...(items.length ? items.map((id, i) => sbChip(id, { line: lineIdx, side, idx: i })) : [h('span', { className: 'sb-drop', textContent: 'drop here' })]))
|
|
2438
|
+
zone.addEventListener('dragover', (e) => { e.preventDefault(); zone.classList.add('sb-over') })
|
|
2439
|
+
zone.addEventListener('dragleave', () => zone.classList.remove('sb-over'))
|
|
2440
|
+
zone.addEventListener('drop', (e) => {
|
|
2441
|
+
e.preventDefault(); zone.classList.remove('sb-over')
|
|
2442
|
+
if (!sbDrag) return
|
|
2443
|
+
let at = sbDropIndex(zone, e)
|
|
2444
|
+
const dest = sbLines[lineIdx][side]
|
|
2445
|
+
if (sbDrag.from !== 'palette') {
|
|
2446
|
+
const src = sbLines[sbDrag.from.line][sbDrag.from.side]
|
|
2447
|
+
src.splice(sbDrag.from.idx, 1) // take it out of where it was
|
|
2448
|
+
if (src === dest && sbDrag.from.idx < at) at-- // same zone, removed before the insert point
|
|
2449
|
+
if (!dest.includes(sbDrag.id)) dest.splice(at, 0, sbDrag.id)
|
|
2450
|
+
} else if (!sbUsed().has(sbDrag.id)) dest.splice(at, 0, sbDrag.id) // from the palette, if not already placed
|
|
2451
|
+
sbDrag = null
|
|
2452
|
+
sbRenderAll(); sbSave()
|
|
2453
|
+
})
|
|
2454
|
+
return zone
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
function sbRenderLines() {
|
|
2458
|
+
put($('sb-lines'), ...sbLines.map((_, i) => h('div', { className: 'sb-line' },
|
|
2459
|
+
h('span', { className: 'sb-no', textContent: String(i + 1) }),
|
|
2460
|
+
sbZone(i, 'left'), sbZone(i, 'right'),
|
|
2461
|
+
h('button', { className: 'sb-del', title: 'Remove this line', textContent: '🗑', onclick: () => { sbLines.splice(i, 1); if (!sbLines.length) sbLines = [{ left: [], right: [] }]; sbRenderAll(); sbSave() } }))))
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
function sbRenderPalette() {
|
|
2465
|
+
const used = sbUsed()
|
|
2466
|
+
const pal = $('sb-palette')
|
|
2467
|
+
put(pal, ...SB_ITEMS.map((it) => { const chip = sbChip(it.id, 'palette'); if (used.has(it.id)) chip.classList.add('sb-used'); return chip }))
|
|
2468
|
+
pal.ondragover = (e) => { if (sbDrag && sbDrag.from !== 'palette') e.preventDefault() } // drop a placed chip here to remove it
|
|
2469
|
+
pal.ondrop = (e) => { if (sbDrag && sbDrag.from !== 'palette') { e.preventDefault(); sbLines[sbDrag.from.line][sbDrag.from.side].splice(sbDrag.from.idx, 1); sbDrag = null; sbRenderAll(); sbSave() } }
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
function sbRenderPreview() {
|
|
2473
|
+
const box = $('sb-preview')
|
|
2474
|
+
if (!sbOn) return put(box, h('span', { className: 'sb-empty', textContent: '(the status bar is off)' }))
|
|
2475
|
+
const lines = sbLines.filter((l) => l.left.length || l.right.length)
|
|
2476
|
+
if (!lines.length) return put(box, h('span', { className: 'sb-empty', textContent: '(no items — the bar will be empty)' }))
|
|
2477
|
+
const sepJoin = (ids) => ids.flatMap((id, i) => [i ? h('span', { className: 'sb-sep', textContent: ' │ ' }) : null, document.createTextNode(sbSample(id))].filter(Boolean))
|
|
2478
|
+
put(box, ...lines.map((l) => (l.right.length
|
|
2479
|
+
? h('div', { className: 'sb-row' }, h('span', { className: 'sb-grow' }, ...sepJoin(l.left)), h('span', {}, ...sepJoin(l.right)))
|
|
2480
|
+
: h('div', { className: 'sb-row' }, ...sepJoin(l.left)))))
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
function sbPayload() {
|
|
2484
|
+
if (!sbOn) return false
|
|
2485
|
+
const lines = sbLines.map((l) => ({ left: l.left, right: l.right })).filter((l) => l.left.length || l.right.length)
|
|
2486
|
+
return lines.length ? lines : false
|
|
2487
|
+
}
|
|
2488
|
+
function sbSave() {
|
|
2489
|
+
clearTimeout(sbSaveTimer)
|
|
2490
|
+
sbSaveTimer = setTimeout(() => api('/api/statusbar', { statusBar: sbPayload() }).catch((e) => toast(e.message, true)), 350)
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2217
2493
|
function render(s) {
|
|
2218
2494
|
if (s.prefs) {
|
|
2219
2495
|
// the page's choices, as kept (also changed on another page: shown here too)
|
|
@@ -2234,6 +2510,7 @@ function render(s) {
|
|
|
2234
2510
|
drawMine(s)
|
|
2235
2511
|
drawUsing(s)
|
|
2236
2512
|
drawGeneral(s)
|
|
2513
|
+
drawStatusBar(s)
|
|
2237
2514
|
drawLogging(s)
|
|
2238
2515
|
if (REQS) drawReqs()
|
|
2239
2516
|
drawPrompts(s)
|
package/src/settings.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from 'node:path'
|
|
|
9
9
|
import crypto from 'node:crypto'
|
|
10
10
|
import os from 'node:os'
|
|
11
11
|
import { HOME, saveConfig, readJson, writeJson, byName, takeIn, whatOf } from './config.js'
|
|
12
|
-
import { DEFAULT_SERVERS } from './mcp.js'
|
|
12
|
+
import { DEFAULT_SERVERS, mcpAuth } from './mcp.js'
|
|
13
13
|
import { sections, BUILTIN_PROMPTS } from './prompts.js'
|
|
14
14
|
import { Client } from './client.js'
|
|
15
15
|
import { clip } from './tools.js'
|
|
@@ -17,6 +17,8 @@ import { loadProfile, strategy, profilePath, profileFrom } from './probe.js'
|
|
|
17
17
|
import { loadPrices, priceOf, limitsOf } from './usage.js'
|
|
18
18
|
import { THEMES, PERMISSIONS } from './ui.js'
|
|
19
19
|
import { loadSkills, frontMatter } from './skills.js'
|
|
20
|
+
import { installSkill, findImports } from './importer.js'
|
|
21
|
+
import { capabilities } from './capabilities.js'
|
|
20
22
|
import { log, LOGS, REQUESTS, useRequestLog, listRequests, readRequest, pruneLogs, logDays, logSize, clearLogs } from './log.js'
|
|
21
23
|
|
|
22
24
|
const PAGE = new URL('./settings.html', import.meta.url)
|
|
@@ -24,6 +26,22 @@ const EFFORTS = ['default', 'low', 'medium', 'high']
|
|
|
24
26
|
const TOGGLES = { autoCompact: 'compact the conversation when it fills 85% of the model\'s context window', director: 'let the model add skills, MCP servers and change settings when asked', format: "run the project's formatter on every file HeartCode writes", lsp: "show the model a language server's errors after each edit" }
|
|
25
27
|
// The Logging page's: both off unless switched on; how much of each request ("full" or "summary")
|
|
26
28
|
const LOG_SWITCHES = ['log', 'logRequests']
|
|
29
|
+
// The status-bar items the visual editor offers (id must match App.status in bin/heartcode.js).
|
|
30
|
+
// `sample` is shown in the page's live preview.
|
|
31
|
+
const STATUS_ITEMS = [
|
|
32
|
+
{ id: 'provider', label: 'Provider', sample: '● openai (2)' },
|
|
33
|
+
{ id: 'model', label: 'Model', sample: 'gpt-5' },
|
|
34
|
+
{ id: 'mode', label: 'Mode', sample: 'tools' },
|
|
35
|
+
{ id: 'thinking', label: 'Thinking', sample: 'thinking' },
|
|
36
|
+
{ id: 'images', label: 'Images', sample: 'images' },
|
|
37
|
+
{ id: 'ctx', label: 'Context used', sample: 'ctx 12k/128k 9%' },
|
|
38
|
+
{ id: 'tps', label: 'Tokens / sec', sample: '48 tok/s' },
|
|
39
|
+
{ id: 'cost', label: 'Cost', sample: '$0.14' },
|
|
40
|
+
{ id: 'autocompact', label: 'Auto-compact off', sample: 'auto-compact off' },
|
|
41
|
+
{ id: 'worktree', label: 'Git worktree', sample: '⎇ feature' },
|
|
42
|
+
{ id: 'permissions', label: 'Permissions', sample: '⏵⏵ all allowed' },
|
|
43
|
+
]
|
|
44
|
+
const STATUS_IDS = new Set(STATUS_ITEMS.map((i) => i.id))
|
|
27
45
|
const DETAILS = ['full', 'summary']
|
|
28
46
|
// Files in ~/.heart the page edits as text: [name, what it is, JSON?]
|
|
29
47
|
const FILES = [
|
|
@@ -70,7 +88,7 @@ function mcpServers() {
|
|
|
70
88
|
const from = Object.fromEntries(Object.keys(DEFAULT_SERVERS).map((n) => [n, 'built in']))
|
|
71
89
|
const all = structuredClone(DEFAULT_SERVERS)
|
|
72
90
|
for (const [n, c] of Object.entries(own)) all[n] = { ...all[n], ...c }
|
|
73
|
-
return Object.entries(all).map(([name, c]) => ({ name, from: from[name] ?? 'yours', on: !c.disabled, what: c.url ?? [c.command, ...(c.args ?? [])].filter(Boolean).join(' '), description: c.description ?? '' }))
|
|
91
|
+
return Object.entries(all).map(([name, c]) => ({ name, from: from[name] ?? 'yours', on: !c.disabled, remote: Boolean(c.url), auth: mcpAuth(c), what: c.url ?? [c.command, ...(c.args ?? [])].filter(Boolean).join(' '), description: c.description ?? '' }))
|
|
74
92
|
}
|
|
75
93
|
|
|
76
94
|
// The model list: #1 is the model (cfg.provider/model), the rest cfg.rotation.then, in order.
|
|
@@ -114,7 +132,8 @@ function forgetList(...names) {
|
|
|
114
132
|
writeJson(LISTS, all)
|
|
115
133
|
}
|
|
116
134
|
|
|
117
|
-
export function startSettings({ cfg, apply = () => {}, port = 0 } = {}) {
|
|
135
|
+
export function startSettings({ cfg, apply = () => {}, port = 0, root = process.cwd(), onLoginMcp = null } = {}) {
|
|
136
|
+
let importCache = [] // the last /api/imports listing, so /api/imports/run can execute by id
|
|
118
137
|
const token = crypto.randomBytes(24).toString('hex')
|
|
119
138
|
const changed = (what) => {
|
|
120
139
|
try {
|
|
@@ -341,7 +360,9 @@ export function startSettings({ cfg, apply = () => {}, port = 0 } = {}) {
|
|
|
341
360
|
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])), ...Object.fromEntries(LOG_SWITCHES.map((k) => [k, cfg[k] === true])), logDetail: cfg.logDetail === 'summary' ? 'summary' : 'full', logDays: logDays(cfg) },
|
|
342
361
|
logs: { runs: tilde(path.join(LOGS, 'runs')), requests: tilde(REQUESTS) },
|
|
343
362
|
voice: cfg.voice ? JSON.stringify(cfg.voice, null, 2) : '',
|
|
344
|
-
|
|
363
|
+
statusBar: cfg.statusBar === undefined ? null : cfg.statusBar, // false (off), a list of lines, or null (default)
|
|
364
|
+
capabilities: capabilities(cfg), // features that need outside tools, and whether they're here
|
|
365
|
+
choices: { permissions: PERMISSIONS, effort: EFFORTS, theme: Object.keys(THEMES), toggles: TOGGLES, statusItems: STATUS_ITEMS },
|
|
345
366
|
files: FILES.map(([name, about, json, example]) => ({ name, about, json, example, text: fs.existsSync(path.join(HOME, name)) ? fs.readFileSync(path.join(HOME, name), 'utf8') : '' })),
|
|
346
367
|
skills: [...loadSkills(null).values()].map((s) => ({ name: s.name, description: s.description, use: s.use, mine: s.file.startsWith(skillsDir() + path.sep), text: fs.readFileSync(s.file, 'utf8') })),
|
|
347
368
|
mcp: mcpServers(),
|
|
@@ -628,6 +649,20 @@ export function startSettings({ cfg, apply = () => {}, port = 0 } = {}) {
|
|
|
628
649
|
save('setting:voice')
|
|
629
650
|
return state()
|
|
630
651
|
},
|
|
652
|
+
// The status bar's layout from the visual editor: false (off), null (back to default), or a list
|
|
653
|
+
// of lines ({ left:[item ids], right:[item ids] }). Unknown item ids are dropped; empty = off.
|
|
654
|
+
'POST /api/statusbar': ({ statusBar }) => {
|
|
655
|
+
const clean = (a) => (Array.isArray(a) ? a.filter((x) => STATUS_IDS.has(x)) : [])
|
|
656
|
+
if (statusBar === false) cfg.statusBar = false
|
|
657
|
+
else if (statusBar == null) cfg.statusBar = undefined
|
|
658
|
+
else if (Array.isArray(statusBar)) {
|
|
659
|
+
const line = (row) => (Array.isArray(row) ? { left: clean(row), right: [] } : { left: clean(row?.left), right: clean(row?.right) }) // a line is a bare list (all left) or { left, right }
|
|
660
|
+
const lines = statusBar.map(line).filter((r) => r.left.length || r.right.length)
|
|
661
|
+
cfg.statusBar = lines.length ? lines : false // every line emptied out: same as off
|
|
662
|
+
} else throw new Error('statusBar: false, null, or a list of lines')
|
|
663
|
+
save('setting:statusBar')
|
|
664
|
+
return state()
|
|
665
|
+
},
|
|
631
666
|
'POST /api/file': ({ name, text }) => {
|
|
632
667
|
const f = FILES.find(([n]) => n === name)
|
|
633
668
|
if (!f) throw new Error(`not a settings file: ${name}`)
|
|
@@ -654,7 +689,9 @@ export function startSettings({ cfg, apply = () => {}, port = 0 } = {}) {
|
|
|
654
689
|
const servers = (data.mcpServers ??= {})
|
|
655
690
|
if (on) {
|
|
656
691
|
if (servers[name]) delete servers[name].disabled
|
|
657
|
-
if (
|
|
692
|
+
if (DEFAULT_SERVERS[name]?.disabled)
|
|
693
|
+
servers[name] = { ...(servers[name] ?? {}), disabled: false } // a built-in that's off by default: write an explicit "on" to beat the default
|
|
694
|
+
else if (servers[name] && !Object.keys(servers[name]).length) delete servers[name] // a default-on server we'd only turned off: back to the default
|
|
658
695
|
} else servers[name] = { ...servers[name], disabled: true }
|
|
659
696
|
writeJson(file, data)
|
|
660
697
|
changed('mcp')
|
|
@@ -687,6 +724,13 @@ export function startSettings({ cfg, apply = () => {}, port = 0 } = {}) {
|
|
|
687
724
|
changed('mcp')
|
|
688
725
|
return state()
|
|
689
726
|
},
|
|
727
|
+
// Sign in to a remote MCP server — needs the running HeartCode (it opens your browser). Not
|
|
728
|
+
// available when the page was opened standalone with `heart settings`.
|
|
729
|
+
'POST /api/mcp/login': async ({ name }) => {
|
|
730
|
+
if (!onLoginMcp) throw new Error('open the settings from HeartCode (/settings), or sign in there with /login_mcp')
|
|
731
|
+
const message = await onLoginMcp(String(name ?? ''))
|
|
732
|
+
return { ...state(), message }
|
|
733
|
+
},
|
|
690
734
|
'POST /api/prompt': ({ id, text }) => {
|
|
691
735
|
const [file, name] = String(id ?? '').split('/')
|
|
692
736
|
const b = PROMPT_FILES.includes(file) && builtinPrompts(file).find((x) => x.name === name)
|
|
@@ -720,6 +764,34 @@ export function startSettings({ cfg, apply = () => {}, port = 0 } = {}) {
|
|
|
720
764
|
changed('skill')
|
|
721
765
|
return state()
|
|
722
766
|
},
|
|
767
|
+
// Install a skill from a GitHub repo or a SKILL.md URL (same as /install_skill); global scope,
|
|
768
|
+
// since the dashboard isn't tied to a project folder.
|
|
769
|
+
'POST /api/skill/install': async ({ url }) => {
|
|
770
|
+
const msg = await installSkill(null, String(url ?? ''), 'global')
|
|
771
|
+
changed('skill')
|
|
772
|
+
return { ...state(), message: msg }
|
|
773
|
+
},
|
|
774
|
+
// What other coding CLIs have set up that can be brought in (same as /import), listed to pick from.
|
|
775
|
+
'POST /api/imports': () => {
|
|
776
|
+
importCache = findImports(root)
|
|
777
|
+
return { items: importCache.map((it, id) => ({ id, group: it.group, label: it.label, desc: it.desc })) }
|
|
778
|
+
},
|
|
779
|
+
// Run the picked imports (by id, from the last listing) and reload.
|
|
780
|
+
'POST /api/imports/run': ({ ids }) => {
|
|
781
|
+
const results = []
|
|
782
|
+
for (const id of Array.isArray(ids) ? ids : []) {
|
|
783
|
+
const it = importCache[id]
|
|
784
|
+
if (!it) continue
|
|
785
|
+
try {
|
|
786
|
+
results.push({ ok: true, label: it.label, message: it.run() })
|
|
787
|
+
} catch (e) {
|
|
788
|
+
results.push({ ok: false, label: it.label, message: e.message })
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
changed('skill')
|
|
792
|
+
changed('mcp')
|
|
793
|
+
return { ...state(), results }
|
|
794
|
+
},
|
|
723
795
|
}
|
|
724
796
|
|
|
725
797
|
// Settings changed by anyone else (another HeartCode or page on this folder, a hand): taken in, and
|
package/src/tabs.js
CHANGED
|
@@ -115,7 +115,7 @@ export class Tabs {
|
|
|
115
115
|
// The tab bar, three rows: tabs drawn as tabs, the one on screen open onto it (its bottom
|
|
116
116
|
// edge missing), the others closed off. Number, name, and what it's doing.
|
|
117
117
|
// ╭─────────────╮ ╭──────────────╮
|
|
118
|
-
// │ 1 heart_cli │ │ 2 fix tests ●│
|
|
118
|
+
// │ 1 heart_cli │ │ 2 fix tests ●│ Alt+T open a new tab
|
|
119
119
|
// ─╯ ╰─┴──────────────┴──────────────────
|
|
120
120
|
bar(cols = 100) {
|
|
121
121
|
const mark = { '?': c.warn('?'), '●': c.brand('●'), '✓': c.ok('✓') }
|
|
@@ -137,7 +137,7 @@ export class Tabs {
|
|
|
137
137
|
mid += line('│') + label + line('│') + ' '
|
|
138
138
|
bottom += (on ? c.brand(`╯${' '.repeat(w)}╰`) : c.ghost(`┴${'─'.repeat(w)}┴`)) + c.ghost('─')
|
|
139
139
|
})
|
|
140
|
-
const hint = this.list.length > 1 ? '
|
|
140
|
+
const hint = this.list.length > 1 ? 'Alt+T open a tab · Alt+W close this one · Alt+N/P (or Ctrl+PgUp/PgDn) switch tabs' : 'Alt+T open a new tab'
|
|
141
141
|
mid += ` ${c.faint(hint)}`
|
|
142
142
|
bottom += c.ghost('─'.repeat(Math.max(0, cols - width(bottom.replace(/\x1b\[[0-9;]*m/g, '')))))
|
|
143
143
|
return [top, mid, bottom]
|