aegiscode 6.5.5 → 6.5.7
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 +2 -2
- package/scripts/predist.mjs +7 -0
- package/src/app.js +24 -2
- package/src/chatflow.js +68 -26
- package/src/theme.js +1 -1
- package/src/tokens.js +48 -1
- package/vendor/desktop/lib/local/engine.js +243 -66
- package/vendor/desktop/lib/local/git-scope.js +71 -0
- package/vendor/desktop/lib/local/turn-guard.js +297 -0
- package/vendor/desktop/lib/local/worktree-lock.js +232 -0
- package/vendor/desktop/renderer/usage.js +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.5.
|
|
5
|
-
"description": "aegiscode
|
|
4
|
+
"version": "6.5.7",
|
|
5
|
+
"description": "aegiscode \u2014 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",
|
|
8
8
|
"email": "nborneklint@gmail.com"
|
package/scripts/predist.mjs
CHANGED
|
@@ -55,6 +55,13 @@ const FILES = [
|
|
|
55
55
|
'desktop/lib/local/shell.js',
|
|
56
56
|
'desktop/lib/local/agents.js',
|
|
57
57
|
'desktop/lib/local/prompt.js',
|
|
58
|
+
// engine.js requires all three at load time (turn-guard -> git-scope, and
|
|
59
|
+
// worktree-lock), so leaving them out stages a vendor tree whose engine
|
|
60
|
+
// throws MODULE_NOT_FOUND before it can answer anything — which is what
|
|
61
|
+
// test/cli-package.test.mjs caught in the published 6.5.6 tarball.
|
|
62
|
+
'desktop/lib/local/turn-guard.js',
|
|
63
|
+
'desktop/lib/local/worktree-lock.js',
|
|
64
|
+
'desktop/lib/local/git-scope.js',
|
|
58
65
|
];
|
|
59
66
|
|
|
60
67
|
function main() {
|
package/src/app.js
CHANGED
|
@@ -65,6 +65,26 @@ function defaultSystemPrompt() {
|
|
|
65
65
|
return _defaultSystem || undefined;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// The engine accepts exactly 'once' | 'session' and coerces anything else to
|
|
69
|
+
// 'deny' (vendor/desktop/lib/local/engine.js → respondApproval). Bridging the
|
|
70
|
+
// vocabularies here, rather than trusting every prompter to speak the engine's
|
|
71
|
+
// dialect, is what stops an approval from silently becoming a denial. The
|
|
72
|
+
// failure mode is invisible from the outside: the tool is refused, the model
|
|
73
|
+
// is told the user declined, and it retries against a gate that can only ever
|
|
74
|
+
// say no — the turn burns its whole budget.
|
|
75
|
+
//
|
|
76
|
+
// Module scope on purpose: this must exist before createApp() runs, because it
|
|
77
|
+
// is re-exported for the conformance tests. A nested copy here previously left
|
|
78
|
+
// the export binding undefined and threw on require.
|
|
79
|
+
function normalizeDecision(decision) {
|
|
80
|
+
const v = typeof decision === 'string' ? decision.trim().toLowerCase() : '';
|
|
81
|
+
if (v === 'session') return 'session';
|
|
82
|
+
if (v === 'once' || v === 'allow' || v === 'yes' || v === 'approve' || v === 'approved') {
|
|
83
|
+
return 'once';
|
|
84
|
+
}
|
|
85
|
+
return 'deny';
|
|
86
|
+
}
|
|
87
|
+
|
|
68
88
|
function createApp(options = {}) {
|
|
69
89
|
const opts = {
|
|
70
90
|
model: null,
|
|
@@ -453,6 +473,8 @@ function createApp(options = {}) {
|
|
|
453
473
|
return Promise.resolve('deny');
|
|
454
474
|
};
|
|
455
475
|
|
|
476
|
+
// Vocabulary bridging lives at module scope (see normalizeDecision) so the
|
|
477
|
+
// same function the tests import is the one the live path calls.
|
|
456
478
|
const onDelta = (chunk) => {
|
|
457
479
|
if (!chunk) return;
|
|
458
480
|
if (chunk.reasoning) {
|
|
@@ -481,7 +503,7 @@ function createApp(options = {}) {
|
|
|
481
503
|
const decide = p.approval || approvalPrompter || denyNoPrompter;
|
|
482
504
|
Promise.resolve(decide(info))
|
|
483
505
|
.catch(() => 'deny')
|
|
484
|
-
.then((decision) => engine.respondApproval(info.id, decision));
|
|
506
|
+
.then((decision) => engine.respondApproval(info.id, normalizeDecision(decision)));
|
|
485
507
|
}
|
|
486
508
|
};
|
|
487
509
|
|
|
@@ -1366,4 +1388,4 @@ function createApp(options = {}) {
|
|
|
1366
1388
|
};
|
|
1367
1389
|
}
|
|
1368
1390
|
|
|
1369
|
-
module.exports = { createApp, VERSION };
|
|
1391
|
+
module.exports = { createApp, VERSION, normalizeDecision };
|
package/src/chatflow.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* ─────────────────────────────
|
|
13
13
|
* ❯ what should I fix? input line, with history + completion
|
|
14
14
|
* ─────────────────────────────
|
|
15
|
-
* ⏸ manual mode on · ? for shortcuts
|
|
15
|
+
* ⏸ manual mode on · ? for shortcuts status line (→ switches the mode)
|
|
16
16
|
*
|
|
17
17
|
* driven by a raw key stream, with the turn lifecycle of the reference: a user
|
|
18
18
|
* row, a live assistant row that grows as the model streams, tool rows that
|
|
@@ -258,20 +258,30 @@ function spinnerLine(state, ctx) {
|
|
|
258
258
|
return [span(t.coral, glyph), ...tinted, span(t.white, '… '), tail];
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
/**
|
|
261
|
+
/**
|
|
262
|
+
* The idle/modifier status line at the bottom of the frame.
|
|
263
|
+
*
|
|
264
|
+
* The idle form advertises `→`, the chord that switches the approval mode
|
|
265
|
+
* (manual ⇄ auto) — see the RIGHT branch in `handleKey`. It replaces the
|
|
266
|
+
* reference's "← for agents" hint, which this host printed on every idle frame
|
|
267
|
+
* while binding nothing to it: LEFT was wired only to `editor.left()`, so the
|
|
268
|
+
* one chord the status line offered did nothing. A hint for a key with no
|
|
269
|
+
* handler is worse than no hint, and the agents panel is reachable by the
|
|
270
|
+
* `/agents` command it was really standing in for.
|
|
271
|
+
*/
|
|
262
272
|
function statusLine(state, cols, ctx) {
|
|
263
273
|
const t = themeOf(ctx);
|
|
264
274
|
let left;
|
|
265
275
|
if (state.inputPrompt) {
|
|
266
276
|
left = [span(t.gray, 'enter to confirm · esc to cancel')];
|
|
267
277
|
} else if (state.working) {
|
|
268
|
-
left = [span(t.gray, ` ${GLYPH.bullet} esc to interrupt
|
|
278
|
+
left = [span(t.gray, ` ${GLYPH.bullet} esc to interrupt`)];
|
|
269
279
|
} else if (state.streamJob) {
|
|
270
|
-
left = [span(t.gray, `${GLYPH.bullet} esc to stop
|
|
280
|
+
left = [span(t.gray, `${GLYPH.bullet} esc to stop`)];
|
|
271
281
|
} else if (state.yolo) {
|
|
272
|
-
left = [span(t.gray, `${GLYPH.bullet} YOLO mode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.
|
|
282
|
+
left = [span(t.gray, `${GLYPH.bullet} YOLO mode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for auto mode`)];
|
|
273
283
|
} else {
|
|
274
|
-
left = [span(t.gray, `${GLYPH.pause} manual mode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.
|
|
284
|
+
left = [span(t.gray, `${GLYPH.pause} manual mode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for auto mode`)];
|
|
275
285
|
}
|
|
276
286
|
return padLine(left, cols);
|
|
277
287
|
}
|
|
@@ -298,6 +308,27 @@ function shortcutsGrid(cols, ctx) {
|
|
|
298
308
|
];
|
|
299
309
|
}
|
|
300
310
|
|
|
311
|
+
/**
|
|
312
|
+
* The engine's approval vocabulary — and the ONLY tokens that survive
|
|
313
|
+
* `respondApproval` (see cli/vendor/desktop/lib/local/engine.js). It accepts
|
|
314
|
+
* 'once' and 'session' and coerces EVERYTHING ELSE to 'deny'.
|
|
315
|
+
*
|
|
316
|
+
* This overlay used to answer 'allow': the desktop renderer's word for "yes",
|
|
317
|
+
* not the engine's. So a user who pressed "1. Yes" was denied anyway — silently,
|
|
318
|
+
* on every mutating tool, every time. The model then read "the user denied the
|
|
319
|
+
* request" and retried with a different command, which was denied too, and the
|
|
320
|
+
* turn burned several rounds of tokens to accomplish nothing. Emitting the
|
|
321
|
+
* engine's own words is the whole fix; `test/cli-approval.test.mjs` pins it so
|
|
322
|
+
* the two vocabularies cannot drift apart again.
|
|
323
|
+
*/
|
|
324
|
+
const APPROVE_ONCE = 'once';
|
|
325
|
+
const APPROVE_SESSION = 'session';
|
|
326
|
+
const DENY_TOKEN = 'deny';
|
|
327
|
+
|
|
328
|
+
/** Choice labels, in overlay order. Index maps 1:1 onto DECISIONS. */
|
|
329
|
+
const APPROVAL_CHOICES = ['Yes', 'Yes, allow for this session', 'No'];
|
|
330
|
+
const APPROVAL_DECISIONS = [APPROVE_ONCE, APPROVE_SESSION, DENY_TOKEN];
|
|
331
|
+
|
|
301
332
|
/** The tool-approval dialog body. */
|
|
302
333
|
function confirmLines(overlay, cols, ctx) {
|
|
303
334
|
const t = themeOf(ctx);
|
|
@@ -322,8 +353,13 @@ function confirmLines(overlay, cols, ctx) {
|
|
|
322
353
|
const left = active ? span(t.lavender, GLYPH.cursor) : span('', ' ');
|
|
323
354
|
return [left, span(t.gray, ` ${i + 1}. `), span(active ? t.lavender : t.white, label)];
|
|
324
355
|
};
|
|
325
|
-
|
|
326
|
-
|
|
356
|
+
const toolName = overlay.name || 'this tool';
|
|
357
|
+
APPROVAL_CHOICES.forEach((label, i) => {
|
|
358
|
+
// The session option names the tool it will stop asking about, so the
|
|
359
|
+
// blanket allow is never something the user has to infer.
|
|
360
|
+
const text = i === 1 ? `Yes, and allow ${toolName} for this session` : label;
|
|
361
|
+
lines.push(opt(i, text));
|
|
362
|
+
});
|
|
327
363
|
lines.push([span('', '')]);
|
|
328
364
|
lines.push([span(t.gray, 'Esc to cancel')]);
|
|
329
365
|
return lines;
|
|
@@ -815,34 +851,28 @@ async function runSession(host) {
|
|
|
815
851
|
overlay = { type: 'confirm', name: info.tool || info.name || 'tool', args: info.args || {}, sel: 0, info };
|
|
816
852
|
render();
|
|
817
853
|
(async () => {
|
|
854
|
+
const choose = (decision) => {
|
|
855
|
+
overlay = null;
|
|
856
|
+
render();
|
|
857
|
+
resolve(decision);
|
|
858
|
+
};
|
|
818
859
|
for (;;) {
|
|
819
860
|
const key = await nextKey();
|
|
820
861
|
if (key.name === KEY.UP || key.name === KEY.DOWN || key.name === KEY.TAB) {
|
|
821
|
-
|
|
862
|
+
const step = key.name === KEY.UP ? -1 : 1;
|
|
863
|
+
overlay.sel = (overlay.sel + step + APPROVAL_CHOICES.length) % APPROVAL_CHOICES.length;
|
|
822
864
|
render();
|
|
823
865
|
} else if (key.name === KEY.ENTER) {
|
|
824
|
-
|
|
825
|
-
overlay = null;
|
|
826
|
-
render();
|
|
827
|
-
resolve(yes ? 'allow' : 'deny');
|
|
866
|
+
choose(APPROVAL_DECISIONS[overlay.sel] || DENY_TOKEN);
|
|
828
867
|
return;
|
|
829
868
|
} else if (key.name === KEY.ESC || key.name === KEY.CTRL_C) {
|
|
830
|
-
|
|
831
|
-
render();
|
|
832
|
-
resolve('deny');
|
|
869
|
+
choose(DENY_TOKEN);
|
|
833
870
|
return;
|
|
834
871
|
} else if (key.name === 'char') {
|
|
835
872
|
const ch = String(key.ch).trim();
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
resolve('allow');
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
if (ch === '2') {
|
|
843
|
-
overlay = null;
|
|
844
|
-
render();
|
|
845
|
-
resolve('deny');
|
|
873
|
+
const idx = Number(ch) - 1;
|
|
874
|
+
if (Number.isInteger(idx) && idx >= 0 && idx < APPROVAL_DECISIONS.length) {
|
|
875
|
+
choose(APPROVAL_DECISIONS[idx]);
|
|
846
876
|
return;
|
|
847
877
|
}
|
|
848
878
|
}
|
|
@@ -1495,6 +1525,14 @@ async function runSession(host) {
|
|
|
1495
1525
|
render();
|
|
1496
1526
|
return;
|
|
1497
1527
|
}
|
|
1528
|
+
// → on an empty line switches the approval mode (manual ⇄ auto) — the chord
|
|
1529
|
+
// the status line advertises. With an empty buffer the cursor already sits
|
|
1530
|
+
// at column 0, so `editor.right()` was a no-op there: the binding costs no
|
|
1531
|
+
// editing behaviour, and a line with text keeps plain cursor movement.
|
|
1532
|
+
if (key.name === KEY.RIGHT && !editor.buf) {
|
|
1533
|
+
await dispatch(!(host.isYolo && host.isYolo()) ? '/yolo on' : '/yolo off');
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1498
1536
|
if (key.name === KEY.RIGHT || key.name === KEY.CTRL_RIGHT) {
|
|
1499
1537
|
editor.right();
|
|
1500
1538
|
render();
|
|
@@ -1765,6 +1803,10 @@ module.exports = {
|
|
|
1765
1803
|
statusLine,
|
|
1766
1804
|
shortcutsGrid,
|
|
1767
1805
|
confirmLines,
|
|
1806
|
+
// The approval vocabulary, exported so a test can assert the CLI only ever
|
|
1807
|
+
// answers with tokens the engine actually honours (see APPROVAL_CHOICES).
|
|
1808
|
+
APPROVAL_CHOICES,
|
|
1809
|
+
APPROVAL_DECISIONS,
|
|
1768
1810
|
rowLines,
|
|
1769
1811
|
transcriptLines,
|
|
1770
1812
|
inputPreviewText,
|
package/src/theme.js
CHANGED
|
@@ -89,7 +89,7 @@ function glyphsFor(platform = process.platform) {
|
|
|
89
89
|
hint: '❯', // "Try ..." suggestion marker
|
|
90
90
|
pause: '⏸', // bottom status line (manual mode)
|
|
91
91
|
star: stencilGlyph(STAR, platform), // own-session marker, decorations
|
|
92
|
-
|
|
92
|
+
rightarrow: '→', // the manual ⇄ auto mode switch, advertised on the status line
|
|
93
93
|
pointer: '▸', // tips list bullets
|
|
94
94
|
hook: '⎿', // inline command / tip rows (tool commands, usage hints)
|
|
95
95
|
block: '●', // streaming cursor / assistant answer marker
|
package/src/tokens.js
CHANGED
|
@@ -9,13 +9,59 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
// Per-million-token USD rates. Cache-read/write matter for long sessions.
|
|
12
|
+
//
|
|
13
|
+
// These are the PROVIDER's rates, for the fallback path where a turn has no
|
|
14
|
+
// server-settled charge (a direct provider, ollama, a custom endpoint). A
|
|
15
|
+
// pooled turn reports the ledger figure instead — see accountingFromUsage's
|
|
16
|
+
// `costUsd` — because the pool's bill carries a margin and a prompt-cache
|
|
17
|
+
// discount this table cannot see.
|
|
18
|
+
//
|
|
19
|
+
// Keys are matched by exact id first, then by prefix (ratesFor below), so a
|
|
20
|
+
// family row covers every dated variant of it.
|
|
12
21
|
const RATES = {
|
|
13
22
|
sonnet: { input: 3.00, output: 15.00, cacheRead: 0.30, cacheWrite: 3.75 },
|
|
14
23
|
default: { input: 3.00, output: 15.00, cacheRead: 0.30, cacheWrite: 3.75 },
|
|
15
24
|
fable: { input: 5.00, output: 25.00, cacheRead: 0.50, cacheWrite: 6.25 },
|
|
16
25
|
opus: { input: 5.00, output: 25.00, cacheRead: 0.50, cacheWrite: 6.25 },
|
|
26
|
+
// DeepSeek V4 — the provider's published rate, independently corroborated by
|
|
27
|
+
// aegis1 services/nexus_provider/catalog.py (cost_per_1k_input=0.00014,
|
|
28
|
+
// cost_per_1k_output=0.00028) and referenced in services/pricing.py.
|
|
29
|
+
//
|
|
30
|
+
// This row was MISSING, and usageCost fell through to RATES.sonnet for every
|
|
31
|
+
// DeepSeek turn: $3.00/$15.00 per M against a real $0.14/$0.28 — 21x the
|
|
32
|
+
// input rate and 54x the output rate, on every direct DeepSeek call. That is
|
|
33
|
+
// the number that made a local turn look like it cost a fraction of the
|
|
34
|
+
// cloud's, when most of the reported gap was the meter itself.
|
|
35
|
+
//
|
|
36
|
+
// cacheRead is 0.1x input (aegis1 services/pricing.py
|
|
37
|
+
// CACHE_READ_FRACTION_BY_COMPANY["deepseek"] = 0.1 -> $0.014/M).
|
|
38
|
+
// cacheWrite is the input rate: DeepSeek bills a cache write as ordinary
|
|
39
|
+
// input tokens and charges no separate write premium, unlike Anthropic's
|
|
40
|
+
// 1.25x. A zero here would understate a session that writes cache.
|
|
41
|
+
deepseek: { input: 0.14, output: 0.28, cacheRead: 0.014, cacheWrite: 0.14 },
|
|
17
42
|
};
|
|
18
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The rate row for a model id, provider, or alias. Exact id wins, then the
|
|
46
|
+
* longest matching prefix, then the Sonnet-class default — the same resolution
|
|
47
|
+
* order contextWindowFor uses, so the cost meter and the context meter cannot
|
|
48
|
+
* disagree about which family a model belongs to.
|
|
49
|
+
*/
|
|
50
|
+
function ratesFor(model) {
|
|
51
|
+
const id = String(model || '').toLowerCase();
|
|
52
|
+
if (!id) return RATES.default;
|
|
53
|
+
if (RATES[id]) return RATES[id];
|
|
54
|
+
let best = null;
|
|
55
|
+
let bestLen = 0;
|
|
56
|
+
for (const [prefix, rates] of Object.entries(RATES)) {
|
|
57
|
+
if (id.startsWith(prefix) && prefix.length > bestLen) {
|
|
58
|
+
best = rates;
|
|
59
|
+
bestLen = prefix.length;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return best || RATES.default;
|
|
63
|
+
}
|
|
64
|
+
|
|
19
65
|
// System prompt + tool definitions overhead, roughly, in tokens.
|
|
20
66
|
const SYSTEM_TOKENS = 18000;
|
|
21
67
|
const TOOL_TOKENS = 12000;
|
|
@@ -86,7 +132,7 @@ function transcriptUsage(transcript, model = 'sonnet') {
|
|
|
86
132
|
|
|
87
133
|
/** Dollar cost of a usage record at the given model's rates. */
|
|
88
134
|
function usageCost(usage, model = 'sonnet') {
|
|
89
|
-
const r =
|
|
135
|
+
const r = ratesFor(model);
|
|
90
136
|
const toD = (n, rate) => (n / 1_000_000) * rate;
|
|
91
137
|
return toD(usage.input, r.input)
|
|
92
138
|
+ toD(usage.output, r.output)
|
|
@@ -156,6 +202,7 @@ module.exports = {
|
|
|
156
202
|
CONTEXT_WINDOW,
|
|
157
203
|
CONTEXT_WINDOWS,
|
|
158
204
|
contextWindowFor,
|
|
205
|
+
ratesFor,
|
|
159
206
|
estimateTokens,
|
|
160
207
|
transcriptUsage,
|
|
161
208
|
usageCost,
|