aegiscode 6.8.25 → 6.8.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/package.json +1 -1
- package/src/app.js +32 -1
- package/src/chatflow.js +135 -8
- package/src/clipboard.js +349 -66
- package/src/events.js +50 -0
- package/src/history.js +85 -3
- package/src/keys.js +12 -0
- package/src/naming.js +226 -0
- package/vendor/client/platform.js +130 -0
- package/vendor/client/session-store.js +32 -1
- package/vendor/desktop/lib/local/engine.js +78 -3
- package/vendor/desktop/lib/local/prompt.js +86 -2
- package/vendor/desktop/lib/local/tools.js +4 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.8.
|
|
4
|
+
"version": "6.8.27",
|
|
5
5
|
"description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "AEGIS Code",
|
package/src/app.js
CHANGED
|
@@ -45,7 +45,8 @@ const events = require('./events.js');
|
|
|
45
45
|
const cloudsync = require('./cloudsync.js');
|
|
46
46
|
const { readSecret } = require('./secret.js');
|
|
47
47
|
const { normalizeModelCatalog, pickerEntries, catalogIds } = require('./models.js');
|
|
48
|
-
const { appendHistory, readSessionTranscript, readOwnSessions } = require('./history.js');
|
|
48
|
+
const { appendHistory, readSessionTranscript, readOwnSessions, setSessionTitle } = require('./history.js');
|
|
49
|
+
const naming = require('./naming.js');
|
|
49
50
|
const { snapshotCheckpoint } = require('./checkpoint.js');
|
|
50
51
|
const screens = require('./screens.js');
|
|
51
52
|
const chatflow = require('./chatflow.js');
|
|
@@ -1560,6 +1561,35 @@ function createApp(options = {}) {
|
|
|
1560
1561
|
|
|
1561
1562
|
/** Fold one completed turn's usage into the session tallies.
|
|
1562
1563
|
* @returns {number|null} the total token count for the turn, when known. */
|
|
1564
|
+
/**
|
|
1565
|
+
* Name the conversation, on this host's own turn path (naming.js).
|
|
1566
|
+
*
|
|
1567
|
+
* The model round goes through `ask()`, so it uses the same client, the same
|
|
1568
|
+
* key and the same model the session is already talking to — a naming round
|
|
1569
|
+
* cannot become a second, differently-authenticated caller, and it costs one
|
|
1570
|
+
* short completion. `naming.js` owns every rule about what a name is: a
|
|
1571
|
+
* greeting is answered locally without a call at all, an echo of the prompt
|
|
1572
|
+
* is not a name, and the local derivation is the floor when nothing answers.
|
|
1573
|
+
*
|
|
1574
|
+
* The name is also written onto the session's history records, so `/resume`
|
|
1575
|
+
* lists the conversation by what it is about instead of by its raw first
|
|
1576
|
+
* message. Best-effort throughout: a failure here costs a label.
|
|
1577
|
+
*/
|
|
1578
|
+
async function nameConversation(prompt, { signal = null } = {}) {
|
|
1579
|
+
const title = await naming.nameConversation(prompt, {
|
|
1580
|
+
signal,
|
|
1581
|
+
callModel: (text, o) =>
|
|
1582
|
+
ask(text, {
|
|
1583
|
+
system: (o && o.system) || naming.TITLE_SYSTEM,
|
|
1584
|
+
maxTokens: 64,
|
|
1585
|
+
signal: (o && o.signal) || signal,
|
|
1586
|
+
}).then((r) => (r && r.text) || null),
|
|
1587
|
+
});
|
|
1588
|
+
const clean = String(title || '').trim();
|
|
1589
|
+
if (clean) setSessionTitle(commandCtx.sessionId, clean);
|
|
1590
|
+
return clean;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1563
1593
|
function recordTurn(res) {
|
|
1564
1594
|
session.turns++;
|
|
1565
1595
|
session.calls += Number((res && res.calls) || 1) || 1;
|
|
@@ -1794,6 +1824,7 @@ function createApp(options = {}) {
|
|
|
1794
1824
|
// discount) and reported a number the customer never paid. The parameter
|
|
1795
1825
|
// is the whole reason the ledger is consulted before persisting.
|
|
1796
1826
|
persistTurn: (prompt, res, status, costEur) => persistTurn(prompt, res, status, costEur),
|
|
1827
|
+
nameConversation: (prompt, o) => nameConversation(prompt, o),
|
|
1797
1828
|
visibleCommands: () => visibleCommands(),
|
|
1798
1829
|
tokensFor: (usage) => usageTokens(usage),
|
|
1799
1830
|
recordTurn: (res) => recordTurn(res),
|
package/src/chatflow.js
CHANGED
|
@@ -53,7 +53,11 @@ const fuzzy = require('./fuzzy.js');
|
|
|
53
53
|
const { fmtTokens, fmtEur, fmtElapsed } = require('./format.js');
|
|
54
54
|
const { editPreview } = require('./diff.js');
|
|
55
55
|
const { renderDiffBlock, defaultOpen } = require('./diffview.js');
|
|
56
|
-
const { copyToClipboard } = require('./clipboard.js');
|
|
56
|
+
const { copyToClipboard, describeCopy, readClipboardText, readClipboardImage } = require('./clipboard.js');
|
|
57
|
+
const { transcriptToMarkdown } = require('./export.js');
|
|
58
|
+
const fs = require('node:fs');
|
|
59
|
+
const path = require('node:path');
|
|
60
|
+
const { aegisDir } = require('./config.js');
|
|
57
61
|
|
|
58
62
|
/** The rotating placeholder shown on an empty input line. */
|
|
59
63
|
const SUGGESTIONS = [
|
|
@@ -70,6 +74,7 @@ const SUGGESTIONS = [
|
|
|
70
74
|
* because this module's export list is part of the tested surface.
|
|
71
75
|
*/
|
|
72
76
|
const { TITLE_SPIN, titleText, topicFrom, adoptTopic, titleEnabled, writeTitle } = require('./title.js');
|
|
77
|
+
const { GENERIC_TITLE, isGenericTitle } = require('./naming.js');
|
|
73
78
|
|
|
74
79
|
const FRAME_MS = 33; // ~30fps cap for streaming repaints
|
|
75
80
|
|
|
@@ -800,9 +805,14 @@ async function runSession(host) {
|
|
|
800
805
|
let streamJob = null;
|
|
801
806
|
let streamStartedAt = 0;
|
|
802
807
|
let tabCycle = null;
|
|
803
|
-
// The terminal title's topic — what this session is about
|
|
804
|
-
// from the user's own prompts (
|
|
808
|
+
// The terminal title's topic — what this session is about. Derived locally
|
|
809
|
+
// from the user's own prompts (title.js) until the model names the
|
|
810
|
+
// conversation (naming.js), after which the model's name is the topic and is
|
|
811
|
+
// NOT re-derived per prompt: a follow-up must not rename the session away
|
|
812
|
+
// from what it is about.
|
|
805
813
|
let topic = '';
|
|
814
|
+
let sessionTitle = '';
|
|
815
|
+
let namingStarted = false;
|
|
806
816
|
let titleBar = true;
|
|
807
817
|
try {
|
|
808
818
|
titleBar = titleEnabled(process.env, host.loadConfig ? host.loadConfig() : host.config || {});
|
|
@@ -826,6 +836,107 @@ async function runSession(host) {
|
|
|
826
836
|
writeTitle(titleText({ topic, frame }), process.stdout);
|
|
827
837
|
};
|
|
828
838
|
|
|
839
|
+
/**
|
|
840
|
+
* Ask the model to name the conversation (naming.js), off the critical path.
|
|
841
|
+
*
|
|
842
|
+
* Fire-and-forget by construction: the turn is already streaming, and a name
|
|
843
|
+
* that arrives a moment late is a name — a name that blocks the first frame
|
|
844
|
+
* is a regression. `host.nameConversation` is the app's own model seam, so
|
|
845
|
+
* the round runs on the session's model through the session's own client and
|
|
846
|
+
* key; a host without that seam (tests, demo) simply keeps the local topic
|
|
847
|
+
* from title.js.
|
|
848
|
+
*
|
|
849
|
+
* A greeting is answered locally by naming.js with GENERIC_TITLE and the
|
|
850
|
+
* ladder is re-run on later turns, so a session opened with "heey" gets its
|
|
851
|
+
* real name once the user says what they actually want.
|
|
852
|
+
*/
|
|
853
|
+
const ensureNamed = (prompt) => {
|
|
854
|
+
if (typeof host.nameConversation !== 'function') return;
|
|
855
|
+
namingStarted = true;
|
|
856
|
+
let p;
|
|
857
|
+
try {
|
|
858
|
+
p = Promise.resolve(host.nameConversation(prompt, { signal: abort ? abort.signal : null }));
|
|
859
|
+
} catch {
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
p.then((name) => {
|
|
863
|
+
const clean = String(name || '').trim();
|
|
864
|
+
if (!clean) return;
|
|
865
|
+
sessionTitle = clean;
|
|
866
|
+
topic = clean;
|
|
867
|
+
setTitle(!!working);
|
|
868
|
+
render();
|
|
869
|
+
}).catch(() => { /* naming is best-effort */ });
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
/** Re-ask only while the session is still wearing the generic name. */
|
|
873
|
+
const maybeName = (prompt) => {
|
|
874
|
+
if (!sessionTitle) {
|
|
875
|
+
if (!namingStarted) ensureNamed(prompt);
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
if (!isGenericTitle(sessionTitle)) return;
|
|
879
|
+
ensureNamed(prompt);
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
// ── clipboard paste (Ctrl+V) and transcript copy (Ctrl+B) ────────────────
|
|
883
|
+
// Neither chord existed here: `\x16` and `\x02` had no case in keys.js, so
|
|
884
|
+
// they fell into its "any other control char → ESC" branch — Ctrl+V did
|
|
885
|
+
// nothing at all (the terminal's own bracketed paste, and its own
|
|
886
|
+
// Ctrl+Shift+V, are the only ways text ever arrived), and Ctrl+B aborted a
|
|
887
|
+
// running turn. Both are real keys now (`KEY.CTRL_V` / `KEY.CTRL_B`).
|
|
888
|
+
//
|
|
889
|
+
// Ctrl+V pastes the clipboard's image when it holds one — written under the
|
|
890
|
+
// data dir and inserted as its PATH, which is what every file-reading tool
|
|
891
|
+
// here accepts and what the reference CLI hands the model for a screenshot —
|
|
892
|
+
// and its text otherwise. Both land in the input line, so nothing is sent
|
|
893
|
+
// until Enter.
|
|
894
|
+
const flash = (text) => {
|
|
895
|
+
hintText = text;
|
|
896
|
+
hintUntil = Date.now() + 2500;
|
|
897
|
+
setTimeout(() => { if (Date.now() >= hintUntil) render(); }, 2600);
|
|
898
|
+
render();
|
|
899
|
+
};
|
|
900
|
+
const pasteClipboard = () => {
|
|
901
|
+
const img = readClipboardImage({ env: process.env });
|
|
902
|
+
if (img.ok) {
|
|
903
|
+
try {
|
|
904
|
+
const dir = path.join(aegisDir(), 'clipboard');
|
|
905
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
906
|
+
const ext = img.mime === 'image/jpeg' ? 'jpg' : 'png';
|
|
907
|
+
const file = path.join(dir, `pasted-${new Date().toISOString().replace(/[:.]/g, '-')}.${ext}`);
|
|
908
|
+
fs.writeFileSync(file, img.data, { mode: 0o600 });
|
|
909
|
+
const lead = editor.buf && !/\s$/.test(editor.buf) ? ' ' : '';
|
|
910
|
+
editor.insert(lead + file);
|
|
911
|
+
flash(`Pasted image → ${file}`);
|
|
912
|
+
return;
|
|
913
|
+
} catch (e) {
|
|
914
|
+
flash(`Could not save the pasted image: ${(e && e.message) || e}`);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
const txt = readClipboardText({ env: process.env });
|
|
919
|
+
if (txt.ok && txt.text) {
|
|
920
|
+
editor.insert(txt.text);
|
|
921
|
+
flash(`Pasted ${txt.text.length} character${txt.text.length === 1 ? '' : 's'} from the clipboard`);
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
// Honest failure: say WHICH side is missing. "Nothing to paste" when the
|
|
925
|
+
// host simply has no clipboard reader sends the user looking for an empty
|
|
926
|
+
// clipboard instead of a missing tool.
|
|
927
|
+
flash(txt.ok
|
|
928
|
+
? 'Clipboard is empty — nothing to paste'
|
|
929
|
+
: `Cannot read the clipboard here (${txt.error}) — use your terminal's own paste shortcut instead`);
|
|
930
|
+
};
|
|
931
|
+
// Ctrl+B: the whole conversation onto the clipboard, so it can be pasted into
|
|
932
|
+
// an issue, a chat or a file without a marking drag or a /export round trip
|
|
933
|
+
// through the disk.
|
|
934
|
+
const copyTranscript = () => {
|
|
935
|
+
if (!transcript.length) { flash('Nothing to copy yet'); return; }
|
|
936
|
+
const res = copyToClipboard(transcriptToMarkdown(transcript), { stdout: process.stdout, env: process.env });
|
|
937
|
+
flash(describeCopy(res, 'Copied the conversation'));
|
|
938
|
+
};
|
|
939
|
+
|
|
829
940
|
const buildFrame = () => {
|
|
830
941
|
const { cols, rows } = getSize();
|
|
831
942
|
const lines = [];
|
|
@@ -1033,7 +1144,11 @@ async function runSession(host) {
|
|
|
1033
1144
|
verb = VERBS[turnCount % VERBS.length];
|
|
1034
1145
|
// Adopt the ask as this session's topic (kept when it is a follow-up), so
|
|
1035
1146
|
// the tab reads what is being worked on from the first frame of the turn.
|
|
1036
|
-
|
|
1147
|
+
// A model-given name outranks the local derivation — that is the whole
|
|
1148
|
+
// point of asking the model — and ask the model to name the conversation
|
|
1149
|
+
// off the critical path until it has a real one.
|
|
1150
|
+
topic = sessionTitle || adoptTopic(topic, prompt);
|
|
1151
|
+
maybeName(prompt);
|
|
1037
1152
|
abort = new AbortController();
|
|
1038
1153
|
spinnerTimer = setInterval(() => {
|
|
1039
1154
|
spinnerFrame++;
|
|
@@ -1404,11 +1519,15 @@ async function runSession(host) {
|
|
|
1404
1519
|
// Confirm in the transient hint slot (the line the Tab tip uses) rather
|
|
1405
1520
|
// than in the transcript: a copy is a UI action, not a turn, and pushing a
|
|
1406
1521
|
// note would edit the conversation the reader is copying FROM.
|
|
1407
|
-
|
|
1522
|
+
//
|
|
1523
|
+
// The sentence comes from describeCopy() and is therefore honest about
|
|
1524
|
+
// WHERE the text went: on a host with a tool or a terminal that answers
|
|
1525
|
+
// OSC 52 it says the clipboard, and when neither exists it names the file
|
|
1526
|
+
// instead of claiming a copy that never happened. Before, every drag said
|
|
1527
|
+
// "Marked N lines" whether or not anything reached a clipboard.
|
|
1528
|
+
const res = copyToClipboard(text, { stdout: process.stdout, env: process.env });
|
|
1408
1529
|
const n = text.split('\n').length;
|
|
1409
|
-
hintText =
|
|
1410
|
-
: res.via === 'file' ? `Marked ${n} line${n === 1 ? '' : 's'} → ${res.path}`
|
|
1411
|
-
: `Copied ${n} line${n === 1 ? '' : 's'}`;
|
|
1530
|
+
hintText = describeCopy(res, `Marked ${n} line${n === 1 ? '' : 's'}`);
|
|
1412
1531
|
hintUntil = Date.now() + 2500;
|
|
1413
1532
|
setTimeout(() => { if (Date.now() >= hintUntil) render(); }, 2600);
|
|
1414
1533
|
return true;
|
|
@@ -1840,6 +1959,14 @@ async function runSession(host) {
|
|
|
1840
1959
|
await dispatch(text);
|
|
1841
1960
|
return;
|
|
1842
1961
|
}
|
|
1962
|
+
if (key.name === KEY.CTRL_V) {
|
|
1963
|
+
pasteClipboard();
|
|
1964
|
+
return;
|
|
1965
|
+
}
|
|
1966
|
+
if (key.name === KEY.CTRL_B) {
|
|
1967
|
+
copyTranscript();
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1843
1970
|
if (key.name === 'paste') {
|
|
1844
1971
|
if (ctx.vim) insertMode = true;
|
|
1845
1972
|
editor.insert(String(key.text));
|