aegiscode 6.8.3 → 6.8.4
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/bin/aegiscode.js +35 -5
- package/package.json +1 -1
- package/scripts/predist.mjs +99 -0
- package/src/app.js +40 -8
- package/src/chatflow.js +181 -33
- package/src/commands.js +154 -17
- package/src/deps.js +2 -1
- package/src/events.js +37 -14
- package/src/mcp.js +683 -0
- package/src/panels.js +46 -13
- package/src/screen.js +130 -5
- package/src/title.js +217 -0
- package/src/tokens.js +74 -95
- package/src/update.js +75 -1
- package/vendor/desktop/lib/local/engine.js +24 -0
- package/vendor/desktop/lib/settings.js +67 -0
- package/vendor/desktop/renderer/usage.js +372 -41
- package/vendor/hosts/install.js +638 -0
- package/vendor/hosts/openai-shim.js +419 -0
- package/vendor/hosts/spec.js +164 -0
- package/vendor/hosts/targets.js +346 -0
- package/vendor/mcp/server.js +186 -0
package/src/commands.js
CHANGED
|
@@ -69,6 +69,7 @@ const { maskKey, fmtTokens } = require('./format.js');
|
|
|
69
69
|
const { pickerEntries } = require('./models.js');
|
|
70
70
|
const { openUrl, URLS } = require('./system.js');
|
|
71
71
|
const { sniffProject, buildAegisMd } = require('./init.js');
|
|
72
|
+
const { upgradeAdvice, latestPublishedVersion } = require('./update.js');
|
|
72
73
|
const {
|
|
73
74
|
AGENT_PRESETS, agentRoles, composeAgentPrompt, composeResearchPrompt, composeDebatePrompt,
|
|
74
75
|
} = require('./agents.js');
|
|
@@ -117,6 +118,106 @@ const tip = (c, text) => c.push({ role: 'tip', text });
|
|
|
117
118
|
const done = (c, text) => c.push({ role: 'done', text });
|
|
118
119
|
const shortCwd = () => process.cwd().split('/').filter(Boolean).pop() || '~';
|
|
119
120
|
|
|
121
|
+
// ── The multi-agent fan-out (/multi run, /multiyolo, /aegis-multi run) ────────
|
|
122
|
+
//
|
|
123
|
+
// These three commands used to only *compose* text: /multi <task> run and
|
|
124
|
+
// /aegis-multi <task> run printed "Running the task through the pooled brain
|
|
125
|
+
// (single-model — the reference fans it out)" and handed the raw task to
|
|
126
|
+
// c.runPrompt — a single turn, not a fan-out — while /multiyolo printed the
|
|
127
|
+
// paste-ready panel and never executed anything at all, so its `savePermissions
|
|
128
|
+
// ({ defaultMode: 'allow' })` turned YOLO on and then did nothing with it.
|
|
129
|
+
//
|
|
130
|
+
// The reference (aegiscodex-dev) calls `multiData(task, { signal })`, which
|
|
131
|
+
// shells out to aegis-cli (`aegis --print "/multi <task>"`) because the fan-out
|
|
132
|
+
// lives in that binary. This host has no aegis-cli, and a shell-out that fails
|
|
133
|
+
// on every machine without one is not a port — so the real multi-agent runtime
|
|
134
|
+
// here is the engine's own `task` tool (desktop/lib/local/engine.js
|
|
135
|
+
// `runSubagent`: a specialist subagent with its own tool loop, session id and
|
|
136
|
+
// approval card, primed from agents.js). One turn drives it, and the delegation
|
|
137
|
+
// is executed rather than described.
|
|
138
|
+
|
|
139
|
+
/** The fan-out prompt handed to the engine — the specialists are named so the delegation actually happens. */
|
|
140
|
+
function composeMultiFanoutPrompt(task) {
|
|
141
|
+
return [
|
|
142
|
+
'Execute this task as a multi-agent fan-out.',
|
|
143
|
+
'',
|
|
144
|
+
`Task: ${task}`,
|
|
145
|
+
'',
|
|
146
|
+
`Workspace: ${process.cwd()}`,
|
|
147
|
+
'',
|
|
148
|
+
'Use the task tool to delegate the independent parts to specialist subagents, in parallel where they do not depend on each other:',
|
|
149
|
+
'- reconnaissance first (scanner for secrets/unsafe patterns, analyzer for refactor targets),',
|
|
150
|
+
'- then design (architect, or planner when the work is a change to existing code),',
|
|
151
|
+
'- then an implementer subagent to make the change.',
|
|
152
|
+
'Finally review the result (reviewer subagent), fix what it finds, and verify with the repository\'s real commands.',
|
|
153
|
+
'',
|
|
154
|
+
'Return one consolidated report: what each subagent found, the files you changed, the exact commands you ran and their real output, and anything still blocked. No preamble.',
|
|
155
|
+
].join('\n');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The this-host `multiData(task, { signal })`. Returns the reference's shape —
|
|
160
|
+
* `{ result, model, provider }`, `{ cancelled }`, or `{ error }` — so callers
|
|
161
|
+
* render it through `panels.buildAegisPrint` exactly as the reference does.
|
|
162
|
+
* `{ error }` is the honest fallback: the caller says why and still hands the
|
|
163
|
+
* user a paste-ready command instead of pretending the fan-out ran.
|
|
164
|
+
*/
|
|
165
|
+
async function multiData(c, task) {
|
|
166
|
+
const prompt = composeMultiFanoutPrompt(task);
|
|
167
|
+
const run = c && c.withWorking ? (fn) => c.withWorking(fn) : (fn) => fn();
|
|
168
|
+
// A context with no agent loop at all (no ask, no runPrompt) is the one case
|
|
169
|
+
// this cannot execute — say so rather than returning an empty success.
|
|
170
|
+
if (!c || (typeof c.ask !== 'function' && typeof c.runPrompt !== 'function')) {
|
|
171
|
+
return { error: 'No agent loop in this context — the fan-out prompt was composed, not run.' };
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
if (typeof c.ask === 'function') {
|
|
175
|
+
const res = await run((signal) => c.ask(prompt, { signal }));
|
|
176
|
+
const text = (res && res.text) || '';
|
|
177
|
+
if (res && res.interrupted && !text) return { cancelled: true };
|
|
178
|
+
if (!text) return { error: 'The multi-agent fan-out returned nothing (the turn failed before it could delegate).' };
|
|
179
|
+
return { result: text, model: (res && res.model) || (c.ctx && c.ctx.model) || null, provider: 'aegis' };
|
|
180
|
+
}
|
|
181
|
+
// No captured-answer path: still execute, streamed into the transcript.
|
|
182
|
+
await run(() => c.runPrompt(prompt));
|
|
183
|
+
return { streamed: true };
|
|
184
|
+
} catch (e) {
|
|
185
|
+
return { error: `ÆGIS multi failed — ${(e && e.message) || e}` };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Drive one of the three fan-out commands end to end. `yolo` is /multiyolo's
|
|
191
|
+
* edge: the permission mode is set to allow *and* the task then executes under
|
|
192
|
+
* it (previously it was set and never used).
|
|
193
|
+
*/
|
|
194
|
+
async function runMultiCommand(c, task, { yolo = false, title = 'ÆGIS Multi' } = {}) {
|
|
195
|
+
if (yolo) {
|
|
196
|
+
const rules = loadPermissions();
|
|
197
|
+
savePermissions({ ...rules, defaultMode: 'allow' });
|
|
198
|
+
panel(c, panels.buildYolo(c.state(), c.ctx));
|
|
199
|
+
}
|
|
200
|
+
note(c, 'Running the multi-agent fan-out — the engine delegates to specialist subagents (headless: this skips aegis-cli\'s own confirmation step).');
|
|
201
|
+
c.render();
|
|
202
|
+
const res = await multiData(c, task);
|
|
203
|
+
if (res.cancelled) { note(c, 'ÆGIS multi cancelled.'); c.render(); return true; }
|
|
204
|
+
if (res.error) {
|
|
205
|
+
note(c, res.error);
|
|
206
|
+
// Unreachable is not the same as useless: hand over the command that runs
|
|
207
|
+
// it in a real aegis-cli session.
|
|
208
|
+
panel(c, panels.buildAegisMulti(task, c.ctx));
|
|
209
|
+
c.render();
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
if (res.streamed) return true;
|
|
213
|
+
panel(c, panels.buildAegisPrint(title, res, c.ctx));
|
|
214
|
+
c.render();
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** /upgrade's advice as panel rows (the advice itself is plain strings). */
|
|
219
|
+
const upgradePanelLines = (lines) => lines.map((l) => [span(C.white, l)]);
|
|
220
|
+
|
|
120
221
|
/**
|
|
121
222
|
* The pinnable-model list for the class the session is on, fetched fresh.
|
|
122
223
|
*
|
|
@@ -1002,7 +1103,13 @@ const COMMANDS = [
|
|
|
1002
1103
|
const task = (args._rest || '').trim().replace(/^\S+\s*/, '').trim();
|
|
1003
1104
|
if (!task) { note(c, `Usage: /agents <role> <task> — roles: ${agentRoles().join(', ')}`); c.render(); return true; }
|
|
1004
1105
|
if (!AGENT_PRESETS[role]) { note(c, `Unknown agent role "${role}". Roles: ${agentRoles().join(', ')}`); c.render(); return true; }
|
|
1005
|
-
|
|
1106
|
+
const prompt = composeAgentPrompt(role, task);
|
|
1107
|
+
if (c.runPrompt) {
|
|
1108
|
+
await c.runPrompt(prompt);
|
|
1109
|
+
return true;
|
|
1110
|
+
}
|
|
1111
|
+
note(c, `Composed ${role} prompt (${prompt.length} chars) — run in the TUI to send it.`);
|
|
1112
|
+
c.render();
|
|
1006
1113
|
return true;
|
|
1007
1114
|
}
|
|
1008
1115
|
panel(c, panels.buildAgents(c.state(), c.ctx));
|
|
@@ -1181,6 +1288,22 @@ const COMMANDS = [
|
|
|
1181
1288
|
return true;
|
|
1182
1289
|
},
|
|
1183
1290
|
},
|
|
1291
|
+
{
|
|
1292
|
+
name: 'upgrade', args: ['action'], hint: '[check]', category: 'support',
|
|
1293
|
+
desc: 'Check for a newer published version',
|
|
1294
|
+
handler: async (c) => {
|
|
1295
|
+
note(c, 'Checking the npm registry…');
|
|
1296
|
+
c.render();
|
|
1297
|
+
// The registry lookup is a blocking `npm view`, so it runs inside the
|
|
1298
|
+
// spinner when the context offers one (and is skipped entirely in demo
|
|
1299
|
+
// mode, where a network answer would be a lie).
|
|
1300
|
+
const run = c && c.withWorking ? (fn) => c.withWorking(fn) : (fn) => fn();
|
|
1301
|
+
const latest = c.ctx && c.ctx.demo ? null : await run(() => Promise.resolve(latestPublishedVersion()));
|
|
1302
|
+
panel(c, upgradePanelLines(upgradeAdvice({ latest }).lines));
|
|
1303
|
+
c.render();
|
|
1304
|
+
return true;
|
|
1305
|
+
},
|
|
1306
|
+
},
|
|
1184
1307
|
{
|
|
1185
1308
|
name: 'vim', args: ['mode'], hint: '[on|off]', category: 'model',
|
|
1186
1309
|
desc: 'Toggle vim keymap',
|
|
@@ -1581,13 +1704,10 @@ const COMMANDS = [
|
|
|
1581
1704
|
handler: async (c, args) => {
|
|
1582
1705
|
const task = (args._rest || args.task || '').trim();
|
|
1583
1706
|
if (!task) { note(c, 'Usage: /multiyolo <task>'); c.render(); return true; }
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
panel(c, panels.buildAegisMulti(task, c.ctx));
|
|
1589
|
-
c.render();
|
|
1590
|
-
return true;
|
|
1707
|
+
// YOLO is the point of this alias: auto-approve, then actually run the
|
|
1708
|
+
// fan-out. Composing the text and stopping (what this used to do) left the
|
|
1709
|
+
// user with an enabled YOLO mode and an unexecuted task.
|
|
1710
|
+
return runMultiCommand(c, task, { yolo: true });
|
|
1591
1711
|
},
|
|
1592
1712
|
},
|
|
1593
1713
|
{
|
|
@@ -1637,9 +1757,7 @@ const COMMANDS = [
|
|
|
1637
1757
|
if (mode !== 'run' && /\s+run$/i.test(task)) { mode = 'run'; task = task.replace(/\s+run$/i, '').trim(); }
|
|
1638
1758
|
if (!task) { note(c, 'Usage: /multi <task> [run]'); c.render(); return true; }
|
|
1639
1759
|
if (mode !== 'run') { panel(c, panels.buildAegisMulti(task, c.ctx)); c.render(); return true; }
|
|
1640
|
-
|
|
1641
|
-
await c.runPrompt(task);
|
|
1642
|
-
return true;
|
|
1760
|
+
return runMultiCommand(c, task);
|
|
1643
1761
|
},
|
|
1644
1762
|
},
|
|
1645
1763
|
{
|
|
@@ -1648,7 +1766,16 @@ const COMMANDS = [
|
|
|
1648
1766
|
handler: async (c, args) => {
|
|
1649
1767
|
const q = (args._rest || args.question || '').trim();
|
|
1650
1768
|
if (!q) { note(c, 'Usage: /research <question>'); c.render(); return true; }
|
|
1651
|
-
|
|
1769
|
+
const prompt = composeResearchPrompt(q, process.cwd());
|
|
1770
|
+
// Unguarded, `c.runPrompt` made this throw on any context without one
|
|
1771
|
+
// (the command smoke test caught the class of bug; the reference guards
|
|
1772
|
+
// it the same way). Composed-but-unrunnable is reported, not swallowed.
|
|
1773
|
+
if (c.runPrompt) {
|
|
1774
|
+
await c.runPrompt(prompt);
|
|
1775
|
+
return true;
|
|
1776
|
+
}
|
|
1777
|
+
note(c, `Composed research prompt (${prompt.length} chars) — run in the TUI to send it.`);
|
|
1778
|
+
c.render();
|
|
1652
1779
|
return true;
|
|
1653
1780
|
},
|
|
1654
1781
|
},
|
|
@@ -1658,7 +1785,13 @@ const COMMANDS = [
|
|
|
1658
1785
|
handler: async (c, args) => {
|
|
1659
1786
|
const topic = (args._rest || args.topic || '').trim();
|
|
1660
1787
|
if (!topic) { note(c, 'Usage: /debate <topic>'); c.render(); return true; }
|
|
1661
|
-
|
|
1788
|
+
const prompt = composeDebatePrompt(topic, c.ctx.model || '');
|
|
1789
|
+
if (c.runPrompt) {
|
|
1790
|
+
await c.runPrompt(prompt);
|
|
1791
|
+
return true;
|
|
1792
|
+
}
|
|
1793
|
+
note(c, `Composed debate prompt (${prompt.length} chars) — run in the TUI to send it.`);
|
|
1794
|
+
c.render();
|
|
1662
1795
|
return true;
|
|
1663
1796
|
},
|
|
1664
1797
|
},
|
|
@@ -1917,7 +2050,13 @@ const COMMANDS = [
|
|
|
1917
2050
|
handler: async (c, args) => {
|
|
1918
2051
|
const q = (args._rest || args.question || '').trim();
|
|
1919
2052
|
if (!q) { note(c, 'Usage: /aegis-council <question>'); c.render(); return true; }
|
|
1920
|
-
|
|
2053
|
+
const prompt = composeResearchPrompt(`Deliberate as a council and vote on: ${q}`, process.cwd());
|
|
2054
|
+
if (c.runPrompt) {
|
|
2055
|
+
await c.runPrompt(prompt);
|
|
2056
|
+
return true;
|
|
2057
|
+
}
|
|
2058
|
+
note(c, `Composed council prompt (${prompt.length} chars) — run in the TUI to send it.`);
|
|
2059
|
+
c.render();
|
|
1921
2060
|
return true;
|
|
1922
2061
|
},
|
|
1923
2062
|
},
|
|
@@ -1944,9 +2083,7 @@ const COMMANDS = [
|
|
|
1944
2083
|
if (mode !== 'run' && /\s+run$/i.test(task)) { mode = 'run'; task = task.replace(/\s+run$/i, '').trim(); }
|
|
1945
2084
|
if (!task) { note(c, 'Usage: /aegis-multi <task> [run]'); c.render(); return true; }
|
|
1946
2085
|
if (mode !== 'run') { panel(c, panels.buildAegisMulti(task, c.ctx)); c.render(); return true; }
|
|
1947
|
-
|
|
1948
|
-
await c.runPrompt(task);
|
|
1949
|
-
return true;
|
|
2086
|
+
return runMultiCommand(c, task);
|
|
1950
2087
|
},
|
|
1951
2088
|
},
|
|
1952
2089
|
|
package/src/deps.js
CHANGED
|
@@ -66,7 +66,7 @@ const autonomousPath = resolveShared(path.join('desktop', 'lib', 'local', 'auton
|
|
|
66
66
|
|
|
67
67
|
const { createClient } = require(clientPath);
|
|
68
68
|
const { createTools } = require(toolsPath);
|
|
69
|
-
const { usageTokens } = require(usagePath);
|
|
69
|
+
const { usageTokens, usageBuckets } = require(usagePath);
|
|
70
70
|
const { createLocalEngine } = require(enginePath);
|
|
71
71
|
const { createSettingsStore, isReservedNamespace } = require(settingsPath);
|
|
72
72
|
const { agentRoles, agentRoleLabel } = require(agentsPath);
|
|
@@ -80,6 +80,7 @@ module.exports = {
|
|
|
80
80
|
createClient,
|
|
81
81
|
createTools,
|
|
82
82
|
usageTokens,
|
|
83
|
+
usageBuckets,
|
|
83
84
|
createLocalEngine,
|
|
84
85
|
createSettingsStore,
|
|
85
86
|
isReservedNamespace,
|
package/src/events.js
CHANGED
|
@@ -188,28 +188,45 @@ function feed(c) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
|
-
* SGR mouse
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
191
|
+
* SGR mouse sequence → a wheel direction ('up'/'down') or a left-button
|
|
192
|
+
* gesture, with the wire's own 1-based coordinates.
|
|
193
|
+
*
|
|
194
|
+
* Button codes: 0/1/2 are left/middle/right, 64/65 are wheel up/down, and bit
|
|
195
|
+
* 32 (0b100000) marks a motion event — with DECSET 1002 the terminal reports
|
|
196
|
+
* one per cell of a sweep while the left button is held. Modifier bits (shift
|
|
197
|
+
* 4, meta 8, ctrl 16) are masked off so Shift+wheel and Shift-click still work.
|
|
198
|
+
*
|
|
199
|
+
* A gesture therefore arrives as a triplet and is named stage by stage, so the
|
|
200
|
+
* caller can tell a click from a marking:
|
|
201
|
+
*
|
|
202
|
+
* press {name:'click'} 'M', left button, no motion bit
|
|
203
|
+
* sweep {name:'drag'} 'M', left button, motion bit set
|
|
204
|
+
* release {name:'release'} 'm' terminator (or the X10-style code 3)
|
|
205
|
+
*
|
|
206
|
+
* chatflow.js defers the click to the release, because with 1002 tracking
|
|
207
|
+
* enabled the SAME press can turn into a drag: acting on 'click' straight away
|
|
208
|
+
* would toggle an edit block at the start of every text selection swept across
|
|
209
|
+
* one. Right/middle clicks and anything unrecognized return null, and the
|
|
210
|
+
* caller then falls through to the ordinary CSI decoder, which ignores it — so
|
|
211
|
+
* stray mouse bytes can't type into the editor or abort a turn.
|
|
212
|
+
* Ported from aegiscodex-dev/src/events.js so both hosts mark identically.
|
|
197
213
|
*/
|
|
198
214
|
function parseSgrMouse(seq) {
|
|
199
215
|
const m = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(seq);
|
|
200
216
|
if (!m) return null;
|
|
201
217
|
const code = parseInt(m[1], 10);
|
|
202
|
-
|
|
218
|
+
const col = parseInt(m[2], 10);
|
|
219
|
+
const row = parseInt(m[3], 10);
|
|
220
|
+
if (!Number.isFinite(code) || !Number.isFinite(col) || !Number.isFinite(row)) return null;
|
|
203
221
|
const base = code & ~0b111100;
|
|
204
222
|
if (base === 64) return 'up';
|
|
205
223
|
if (base === 65) return 'down';
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
return null;
|
|
224
|
+
// Code 3 is "no button" — the X10 encoding of a release, which some
|
|
225
|
+
// terminals and multiplexers still send instead of SGR's `m`.
|
|
226
|
+
if ((code & 3) === 3 && m[4] === 'M') return { name: 'release', col, row };
|
|
227
|
+
if ((code & 3) !== 0) return null; // middle/right button — not ours
|
|
228
|
+
if (m[4] === 'm') return { name: 'release', col, row };
|
|
229
|
+
return (code & 32) !== 0 ? { name: 'drag', col, row } : { name: 'click', col, row };
|
|
213
230
|
}
|
|
214
231
|
|
|
215
232
|
function dispatch(key) {
|
|
@@ -307,6 +324,12 @@ function resetKeyStream() {
|
|
|
307
324
|
|
|
308
325
|
module.exports = {
|
|
309
326
|
KEY,
|
|
327
|
+
// Exported for `test/cli-marking.test.mjs`: the click/drag/release split is
|
|
328
|
+
// the half of the marking gesture that is pure decoding, and it is the half
|
|
329
|
+
// that regressed silently once already (only left presses were named, so a
|
|
330
|
+
// sweep arrived as a single cell and nothing copied). A test that can't reach
|
|
331
|
+
// it can't pin it.
|
|
332
|
+
parseSgrMouse,
|
|
310
333
|
attachKeyStream,
|
|
311
334
|
suspendKeyStream,
|
|
312
335
|
resumeKeyStream,
|