aegiscode 6.8.3 → 6.8.5

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.
Files changed (53) hide show
  1. package/README.md +2 -2
  2. package/bin/aegiscode.js +35 -5
  3. package/package.json +1 -6
  4. package/scripts/predist.mjs +99 -0
  5. package/src/agents.js +1 -1
  6. package/src/app.js +41 -9
  7. package/src/caps.js +1 -1
  8. package/src/chatflow.js +182 -34
  9. package/src/checkpoint.js +1 -1
  10. package/src/clipboard.js +1 -1
  11. package/src/commands.js +158 -21
  12. package/src/config.js +2 -2
  13. package/src/deps.js +2 -1
  14. package/src/devrun.js +1 -1
  15. package/src/diff.js +1 -1
  16. package/src/events.js +38 -15
  17. package/src/export.js +1 -1
  18. package/src/fuzzy.js +1 -1
  19. package/src/history.js +3 -3
  20. package/src/init.js +1 -1
  21. package/src/input.js +1 -1
  22. package/src/keys.js +1 -1
  23. package/src/markdown.js +2 -2
  24. package/src/mcp.js +683 -0
  25. package/src/overlays.js +2 -2
  26. package/src/panels.js +52 -19
  27. package/src/permissions.js +2 -2
  28. package/src/render.js +2 -2
  29. package/src/screen.js +133 -8
  30. package/src/screens.js +1 -1
  31. package/src/summarize.js +1 -1
  32. package/src/system.js +2 -2
  33. package/src/theme.js +6 -6
  34. package/src/title.js +217 -0
  35. package/src/tokens.js +75 -96
  36. package/src/update.js +75 -1
  37. package/vendor/desktop/lib/local/agents.js +1 -1
  38. package/vendor/desktop/lib/local/autonomous.js +1 -1
  39. package/vendor/desktop/lib/local/engine.js +32 -8
  40. package/vendor/desktop/lib/local/git-scope.js +1 -1
  41. package/vendor/desktop/lib/local/prompt.js +3 -3
  42. package/vendor/desktop/lib/local/queue.js +2 -2
  43. package/vendor/desktop/lib/local/shell.js +1 -1
  44. package/vendor/desktop/lib/local/tools.js +2 -2
  45. package/vendor/desktop/lib/local/turn-guard.js +1 -1
  46. package/vendor/desktop/lib/local/worktree-lock.js +1 -1
  47. package/vendor/desktop/lib/settings.js +67 -0
  48. package/vendor/desktop/renderer/usage.js +377 -46
  49. package/vendor/hosts/install.js +638 -0
  50. package/vendor/hosts/openai-shim.js +419 -0
  51. package/vendor/hosts/spec.js +164 -0
  52. package/vendor/hosts/targets.js +346 -0
  53. package/vendor/mcp/server.js +186 -0
package/src/config.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * can redirect the data dir. Reads and writes are best-effort: a corrupt
7
7
  * config falls back to defaults, and write failures never crash the session.
8
8
  *
9
- * Ported from aegiscodex-dev/src/config.js (ESM → CommonJS). The data dir was
9
+ * Ported from the upstream engine reference (ESM → CommonJS). The data dir was
10
10
  * renamed ~/.aegiscodex → ~/.aegiscode and the override env var
11
11
  * AEGISCODEX_HOME → AEGISCODE_HOME; `aegisDir` is the one shared helper every
12
12
  * other module imports rather than recomputing the path.
@@ -68,7 +68,7 @@ const DEFAULT_CONFIG = {
68
68
  // back to. Defaulted to the pooled class, which is the only one an account
69
69
  // key alone can run.
70
70
  modelClass: 'aegis',
71
- // Phase 6: the full model table (seeded from src/models.js MODELS on first
71
+ // The full model table (seeded from src/models.js MODELS on first
72
72
  // read by pickerModels()). 'currentModelId' mirrors `model` under the
73
73
  // aegiscode- name so /model add/remove/switch stay compatible both ways.
74
74
  models: null,
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/devrun.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * sub-shell. Output streams to the transcript as it happens; the session loop
6
6
  * can stop the process (Esc) via the returned job handle.
7
7
  *
8
- * Ported from aegiscodex-dev/src/devrun.js (ESM → CommonJS).
8
+ * Ported from the upstream engine reference (ESM → CommonJS).
9
9
  */
10
10
 
11
11
  const { spawn } = require('node:child_process');
package/src/diff.js CHANGED
@@ -21,7 +21,7 @@
21
21
  * ANSI painting lives in diffview.js, exactly the split render.js already
22
22
  * keeps between structure and paint.
23
23
  *
24
- * Ported from `aegiscodex-dev/src/diff.js`; the engine's tool names are
24
+ * Ported from the upstream engine reference; the engine's tool names are
25
25
  * `Edit`/`Write`/`MultiEdit`, this host's are `editFile`/`writeFile`, so
26
26
  * `editPreview` accepts both spellings. `MultiEdit` has no counterpart here
27
27
  * and is kept only so a newer engine frame cannot silently render nothing.
package/src/events.js CHANGED
@@ -15,7 +15,7 @@
15
15
  * · SGR mouse wheel events (DECSET 1000+1006), decoded to `{name:'wheel'}`
16
16
  * instead of being mistaken for Escape (which would abort a working turn).
17
17
  *
18
- * Ported from `aegiscodex-dev/src/events.js`. It is a module-level singleton —
18
+ * Ported from the upstream engine reference. It is a module-level singleton —
19
19
  * one stdin, one queue — which is what lets the session loop, a command
20
20
  * handler's `askInput()`, and the mid-turn Esc drain all read keys through the
21
21
  * same nextKey() without fighting over the `data` listener.
@@ -188,28 +188,45 @@ function feed(c) {
188
188
  }
189
189
 
190
190
  /**
191
- * SGR mouse event → decoded value. Wheel codes 64/65 decode to 'up'/'down'
192
- * (modifier bits masked off so Shift+wheel still scrolls). A left button PRESS
193
- * decodes to `{name:'click', col, row}` with 1-based coordinates from the
194
- * payload. Everything else — a release (`m`), a drag, another button, or a
195
- * horizontal wheel — returns null, and the caller's CSI decoder ignores it, so
196
- * stray mouse bytes can neither type into the editor nor abort a turn.
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 the upstream engine reference 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
- if (!Number.isFinite(code)) return null;
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
- // Left press only: button bits 0-1 clear, wheel bits (0b1100000) clear, no
207
- // motion bit, and the `M` (press) terminator — a release or drag toggles
208
- // nothing.
209
- if (m[4] === 'M' && (code & 3) === 0 && (code & 0b1100000) === 0 && (code & 0b100000) === 0) {
210
- return { name: 'click', col: parseInt(m[2], 10), row: parseInt(m[3], 10) };
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,
package/src/export.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * extraction for /copy. Exports are written to the current directory (or the
6
6
  * clipboard) and the resulting path is reported in the transcript.
7
7
  *
8
- * Ported from aegiscodex-dev/src/export.js (ESM → CommonJS). Output strings
8
+ * Ported from the upstream engine reference (ESM → CommonJS). Output strings
9
9
  * (the # Aegiscodex session header, the ## Claude / ## User role headers, the
10
10
  * aegiscodex-export- filename) are kept as in the reference.
11
11
  */
package/src/fuzzy.js CHANGED
@@ -14,7 +14,7 @@
14
14
  // substring 700 − position (earlier substring wins)
15
15
  // scattered 50 + bonuses (consecutive runs, name-start hits)
16
16
  //
17
- // Ported verbatim from aegiscodex-dev/src/fuzzy.js (ESM → CommonJS). The tier
17
+ // Ported verbatim from the upstream engine reference (ESM → CommonJS). The tier
18
18
  // numbers are a contract: cli-fuzzy.test.mjs asserts the ordering they encode.
19
19
 
20
20
  function fuzzyScore(query, name) {
package/src/history.js CHANGED
@@ -16,7 +16,7 @@
16
16
  * and without a key. `readResumeList` merges both sources by id, so no session
17
17
  * is listed twice.
18
18
  *
19
- * Ported from aegiscodex-dev/src/history.js (ESM → CommonJS). The data dir now
19
+ * Ported from the upstream engine reference (ESM → CommonJS). The data dir now
20
20
  * comes from config.js's shared `aegisDir()` helper.
21
21
  */
22
22
 
@@ -41,7 +41,7 @@ function ensureHistoryDir() {
41
41
 
42
42
  /**
43
43
  * Record one exchange. `reply` is stored in full so /resume can restore the
44
- * transcript exactly. Token accounting (Phase 4):
44
+ * transcript exactly. Token accounting:
45
45
  * live — `usage` carries the real numbers from the provider stream-json
46
46
  * (input/output/cacheRead/cacheWrite + costUsd), stored verbatim;
47
47
  * demo — estimated from text length (~4 chars/token), labeled real:false.
@@ -211,7 +211,7 @@ function sessionHistoryEntries(sessionId) {
211
211
  }
212
212
 
213
213
  /**
214
- * Drop every history record for a session (Phase 10b, 2.1.228 port). /clear
214
+ * Drop every history record for a session. /clear
215
215
  * calls this so /cost stops summing old rows — the sessionId stays stable, so
216
216
  * rewind checkpoints and the transcript lineage are unaffected.
217
217
  */
package/src/init.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * and generate an AEGIS.md with real project instructions. Never overwrites an
6
6
  * existing file — the handler reports and leaves the file alone.
7
7
  *
8
- * Ported from aegiscodex-dev/src/init.js (ESM → CommonJS). The reference wrote
8
+ * Ported from the upstream engine reference (ESM → CommonJS). The reference wrote
9
9
  * a CLAUDE.md; this build writes AEGIS.md and the generated document is headed
10
10
  * "# AEGIS.md" and references "AEGIS Code". The `buildClaudeMd` export is kept
11
11
  * as an alias of `buildAegisMd` so callers ported from the reference still
package/src/input.js CHANGED
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Line editor with history — the input line's buffer, cursor and recall.
5
5
  *
6
- * Ported from `aegiscodex-dev/src/input.js`. The one thing worth knowing before
6
+ * Ported from the upstream engine reference. The one thing worth knowing before
7
7
  * touching it: `cursor` is a **codepoint** index, not a UTF-16 index. Slicing
8
8
  * `buf` directly corrupts a surrogate pair the moment one has been inserted
9
9
  * (the next insert's slice lands mid-pair and leaves a lone surrogate, which
package/src/keys.js CHANGED
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Raw key decoding for the terminal (raw-mode stdin).
5
5
  *
6
- * Ported from `aegiscodex-dev/src/keys.js` so the aegiscode CLI and the
6
+ * Ported from the upstream engine reference so the aegiscode CLI and the
7
7
  * reference client decode the same bytes into the same key names — the
8
8
  * chatflow's key handling (history recall, vim motions, Esc-to-interrupt) is
9
9
  * only correct if the decoder agrees with it.
package/src/markdown.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // Minimal markdown → styled span lines, in the spirit of Claude Code's
4
4
  // transcript rendering (monokai-flavored code, bold text, inline code).
5
5
  //
6
- // Ported from aegiscodex-dev/src/markdown.js (ESM → CommonJS). The one
6
+ // Ported from the upstream engine reference (ESM → CommonJS). The one
7
7
  // structural change: instead of importing `span`/`w` from screen.js — which a
8
8
  // concurrent workstream is rewriting — this module carries a local cell-width
9
9
  // function and a local `span()` that produce the *same* shape the rest of the
@@ -24,7 +24,7 @@ const {
24
24
  themeOf,
25
25
  } = require('./theme.js');
26
26
 
27
- // Real terminal cell width, mirroring aegiscodex-dev/src/screen.js's w():
27
+ // Real terminal cell width, mirroring the upstream engine's w():
28
28
  // combining marks / variation selectors are zero-width, CJK fullwidth forms and
29
29
  // emoji are two cells, everything else one. A plain codepoint count misaligns
30
30
  // every width decision the moment a line contains CJK or emoji.