@aragon-agent/cli 0.6.2 → 0.6.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.
Files changed (167) hide show
  1. package/CHANGELOG.md +321 -0
  2. package/README.md +297 -2
  3. package/dist/agent/controller.d.ts +193 -1
  4. package/dist/agent/controller.js +475 -2
  5. package/dist/agent/headless.d.ts +8 -0
  6. package/dist/agent/headless.js +47 -0
  7. package/dist/agent/reducer.d.ts +189 -0
  8. package/dist/agent/reducer.js +301 -2
  9. package/dist/agent/system-prompt.d.ts +14 -0
  10. package/dist/agent/system-prompt.js +2 -0
  11. package/dist/cli.js +297 -16
  12. package/dist/commands/builtins.js +165 -24
  13. package/dist/commands/registry.d.ts +27 -0
  14. package/dist/compaction/archive.d.ts +175 -0
  15. package/dist/compaction/archive.js +267 -0
  16. package/dist/compaction/child.d.ts +97 -0
  17. package/dist/compaction/child.js +118 -0
  18. package/dist/compaction/command.d.ts +41 -0
  19. package/dist/compaction/command.js +355 -0
  20. package/dist/compaction/compactor.d.ts +302 -0
  21. package/dist/compaction/compactor.js +810 -0
  22. package/dist/compaction/digest.d.ts +62 -0
  23. package/dist/compaction/digest.js +164 -0
  24. package/dist/compaction/limits.d.ts +165 -0
  25. package/dist/compaction/limits.js +172 -0
  26. package/dist/compaction/pressure.d.ts +135 -0
  27. package/dist/compaction/pressure.js +167 -0
  28. package/dist/compaction/summarize-call.d.ts +70 -0
  29. package/dist/compaction/summarize-call.js +86 -0
  30. package/dist/compaction/summary-prompt.d.ts +85 -0
  31. package/dist/compaction/summary-prompt.js +197 -0
  32. package/dist/compaction/tail-budget.d.ts +52 -0
  33. package/dist/compaction/tail-budget.js +67 -0
  34. package/dist/compaction/types.d.ts +215 -0
  35. package/dist/compaction/types.js +22 -0
  36. package/dist/compaction/wiring.d.ts +264 -0
  37. package/dist/compaction/wiring.js +577 -0
  38. package/dist/config/app-paths.d.ts +14 -0
  39. package/dist/config/app-paths.js +16 -0
  40. package/dist/config/cli-commands.d.ts +41 -0
  41. package/dist/config/cli-commands.js +77 -1
  42. package/dist/config/env.d.ts +5 -2
  43. package/dist/config/env.js +140 -3
  44. package/dist/config/load.d.ts +42 -0
  45. package/dist/config/load.js +101 -1
  46. package/dist/config/schema.d.ts +244 -0
  47. package/dist/config/schema.js +170 -0
  48. package/dist/config/store.js +37 -1
  49. package/dist/config/ui-state.d.ts +28 -1
  50. package/dist/config/ui-state.js +9 -0
  51. package/dist/exec/events.d.ts +50 -1
  52. package/dist/exec/runner.js +42 -0
  53. package/dist/input/limits.d.ts +72 -0
  54. package/dist/input/limits.js +63 -0
  55. package/dist/input/mouse-events.d.ts +31 -5
  56. package/dist/input/mouse-events.js +86 -27
  57. package/dist/input/paste-parse.d.ts +71 -0
  58. package/dist/input/paste-parse.js +95 -0
  59. package/dist/input/stdin-filter.d.ts +81 -0
  60. package/dist/input/stdin-filter.js +379 -0
  61. package/dist/logging/install.d.ts +53 -1
  62. package/dist/logging/install.js +81 -1
  63. package/dist/logging/logger.d.ts +1 -1
  64. package/dist/proc/classify.d.ts +52 -0
  65. package/dist/proc/classify.js +143 -0
  66. package/dist/proc/kill-tree.d.ts +42 -0
  67. package/dist/proc/kill-tree.js +119 -0
  68. package/dist/proc/limits.d.ts +84 -0
  69. package/dist/proc/limits.js +84 -0
  70. package/dist/proc/log-ring.d.ts +68 -0
  71. package/dist/proc/log-ring.js +102 -0
  72. package/dist/proc/prompt.d.ts +24 -0
  73. package/dist/proc/prompt.js +49 -0
  74. package/dist/proc/readiness.d.ts +102 -0
  75. package/dist/proc/readiness.js +219 -0
  76. package/dist/proc/supervisor.d.ts +103 -0
  77. package/dist/proc/supervisor.js +465 -0
  78. package/dist/proc/types.d.ts +175 -0
  79. package/dist/proc/types.js +15 -0
  80. package/dist/session/persist.js +55 -1
  81. package/dist/team/report.js +7 -1
  82. package/dist/team/runtime.d.ts +10 -0
  83. package/dist/team/runtime.js +7 -0
  84. package/dist/team/subagent.d.ts +31 -1
  85. package/dist/team/subagent.js +42 -15
  86. package/dist/team/types.d.ts +8 -0
  87. package/dist/tools/bash-tool.d.ts +51 -2
  88. package/dist/tools/bash-tool.js +321 -51
  89. package/dist/tools/fs-tools.d.ts +17 -0
  90. package/dist/tools/index.d.ts +55 -2
  91. package/dist/tools/index.js +39 -1
  92. package/dist/tools/proc-tools.d.ts +25 -0
  93. package/dist/tools/proc-tools.js +102 -0
  94. package/dist/ui/ActivityLine.d.ts +19 -1
  95. package/dist/ui/ActivityLine.js +10 -2
  96. package/dist/ui/App.d.ts +62 -2
  97. package/dist/ui/App.js +546 -16
  98. package/dist/ui/Composer.d.ts +66 -1
  99. package/dist/ui/Composer.js +50 -6
  100. package/dist/ui/PromptInput.d.ts +82 -3
  101. package/dist/ui/PromptInput.js +232 -49
  102. package/dist/ui/StatusBar.d.ts +59 -0
  103. package/dist/ui/StatusBar.js +16 -4
  104. package/dist/ui/TeamPanel.js +7 -1
  105. package/dist/ui/Transcript.d.ts +21 -1
  106. package/dist/ui/Transcript.js +61 -3
  107. package/dist/ui/clipboard.d.ts +52 -0
  108. package/dist/ui/clipboard.js +91 -0
  109. package/dist/ui/composer-limits.d.ts +31 -0
  110. package/dist/ui/composer-limits.js +50 -0
  111. package/dist/ui/composer-rows.d.ts +73 -0
  112. package/dist/ui/composer-rows.js +201 -0
  113. package/dist/ui/editor-reducer.d.ts +37 -0
  114. package/dist/ui/editor-reducer.js +88 -12
  115. package/dist/ui/entries/CompactionCard.d.ts +75 -0
  116. package/dist/ui/entries/CompactionCard.js +158 -0
  117. package/dist/ui/entries/ServiceCard.d.ts +66 -0
  118. package/dist/ui/entries/ServiceCard.js +116 -0
  119. package/dist/ui/entries/UserEntry.d.ts +17 -3
  120. package/dist/ui/entries/UserEntry.js +34 -5
  121. package/dist/ui/frame-differ.d.ts +46 -0
  122. package/dist/ui/frame-differ.js +94 -10
  123. package/dist/ui/gauge.d.ts +16 -1
  124. package/dist/ui/gauge.js +25 -6
  125. package/dist/ui/glyphs.d.ts +11 -0
  126. package/dist/ui/glyphs.js +2 -0
  127. package/dist/ui/layout/ScrollViewport.d.ts +43 -6
  128. package/dist/ui/layout/ScrollViewport.js +128 -21
  129. package/dist/ui/layout/budget.d.ts +44 -9
  130. package/dist/ui/layout/budget.js +42 -10
  131. package/dist/ui/layout/follow-state.d.ts +137 -0
  132. package/dist/ui/layout/follow-state.js +150 -0
  133. package/dist/ui/layout/virtual-window.d.ts +11 -0
  134. package/dist/ui/layout/virtual-window.js +85 -1
  135. package/dist/ui/overlays/HelpOverlay.js +9 -1
  136. package/dist/ui/overlays/PlanReviewOverlay.js +10 -2
  137. package/dist/ui/overlays/QuestionOverlay.js +5 -1
  138. package/dist/ui/overlays/SettingsScreen.d.ts +47 -1
  139. package/dist/ui/overlays/SettingsScreen.js +74 -2
  140. package/dist/ui/palettes.d.ts +16 -0
  141. package/dist/ui/palettes.js +6 -0
  142. package/dist/ui/paste-frames.d.ts +87 -0
  143. package/dist/ui/paste-frames.js +112 -0
  144. package/dist/ui/paste-tokens.d.ts +90 -0
  145. package/dist/ui/paste-tokens.js +147 -0
  146. package/dist/ui/screen.d.ts +38 -0
  147. package/dist/ui/screen.js +113 -8
  148. package/dist/ui/selection/highlight.d.ts +39 -0
  149. package/dist/ui/selection/highlight.js +64 -0
  150. package/dist/ui/selection/screen-mirror.d.ts +24 -0
  151. package/dist/ui/selection/screen-mirror.js +35 -0
  152. package/dist/ui/selection/selection-controller.d.ts +88 -0
  153. package/dist/ui/selection/selection-controller.js +282 -0
  154. package/dist/ui/selection/selection.d.ts +90 -0
  155. package/dist/ui/selection/selection.js +223 -0
  156. package/dist/ui/stdout-frame-writer.d.ts +33 -0
  157. package/dist/ui/stdout-frame-writer.js +15 -0
  158. package/dist/ui/theme.d.ts +11 -0
  159. package/dist/ui/theme.js +2 -0
  160. package/dist/ui/transcript-text.js +72 -0
  161. package/dist/ui/use-startup-notices.d.ts +27 -1
  162. package/dist/ui/use-startup-notices.js +43 -11
  163. package/dist/ui/use-wheel-routing.d.ts +1 -1
  164. package/dist/ui/use-wheel-routing.js +8 -0
  165. package/package.json +4 -2
  166. package/dist/input/stdin-mouse-filter.d.ts +0 -42
  167. package/dist/input/stdin-mouse-filter.js +0 -153
@@ -1,153 +0,0 @@
1
- /**
2
- * Stdin mouse filter (mouse-wheel-region-routing §4.2 / §5.2).
3
- *
4
- * WHY A WRAPPER AND NOT A SECOND LISTENER. Ink 5.2.1 owns stdin in a way that
5
- * forbids a second reader: `components/App.js` calls `setEncoding('utf8')`,
6
- * `ref()`, `setRawMode(true)`, subscribes to `'readable'` and drains with
7
- * `read()`. Attaching our own `'data'` listener to the same `process.stdin`
8
- * would switch the stream into flowing mode and RACE Ink's `read()` for chunks
9
- * — some keystrokes would reach Ink, some would not, non-deterministically
10
- * (D-3). So the filter REPLACES the stream Ink is given: it reads the real
11
- * stdin, strips every mouse report, and writes the remainder into a
12
- * `PassThrough` that carries the surface Ink requires.
13
- *
14
- * ORDERING IS AN INVARIANT, NOT A CONVENTION (I-8). The caller must build this
15
- * filter BEFORE anything writes `\x1b[?1000h`. Reporting enabled while Ink
16
- * still holds the raw stream does not degrade the feature — it types
17
- * `[<0;12;5M` into the user's message on every click, which is strictly worse
18
- * than the bug this feature fixes. `cli.tsx::runInteractive` is the only caller
19
- * and passes `filter !== null` to `enterAltScreen`.
20
- */
21
- import { PassThrough } from 'node:stream';
22
- import { splitMouseEvents } from './mouse-events.js';
23
- /**
24
- * How long a possible-prefix tail is held before being flushed as text.
25
- *
26
- * This is what stops a lone `\x1b` — the Esc key, which aborts a run — from
27
- * being held hostage waiting for a `[` that will never arrive. Worst-case Esc
28
- * latency becomes 12 ms, and only for the keystroke that is literally a bare
29
- * ESC; every other key resolves `isMousePrefix` to false immediately.
30
- */
31
- const PENDING_FLUSH_MS = 12;
32
- /** Assign a method onto the PassThrough without widening its public type. */
33
- function define(target, name, value) {
34
- Object.defineProperty(target, name, { value, writable: true, configurable: true });
35
- }
36
- export function createMouseFilter(real) {
37
- const wrapper = new PassThrough();
38
- const listeners = new Set();
39
- let pending = '';
40
- let flushTimer = null;
41
- let disposed = false;
42
- // --- The surface Ink reads off the stream it is handed. ------------------
43
- // `isRawModeSupported()` reads `props.stdin.isTTY` (App.js:34), so this has
44
- // to be a DELEGATING GETTER rather than a snapshot: a stdin that is not a TTY
45
- // must still report so through the wrapper, or Ink throws instead of falling
46
- // back.
47
- Object.defineProperty(wrapper, 'isTTY', {
48
- get: () => real.isTTY,
49
- configurable: true,
50
- });
51
- define(wrapper, 'setRawMode', (mode) => {
52
- real.setRawMode?.(mode);
53
- return wrapper;
54
- });
55
- define(wrapper, 'ref', () => {
56
- real.ref?.();
57
- return wrapper;
58
- });
59
- define(wrapper, 'unref', () => {
60
- real.unref?.();
61
- return wrapper;
62
- });
63
- const emit = (event) => {
64
- for (const listener of [...listeners])
65
- listener(event);
66
- };
67
- const clearFlushTimer = () => {
68
- if (!flushTimer)
69
- return;
70
- clearTimeout(flushTimer);
71
- flushTimer = null;
72
- };
73
- const flushPending = () => {
74
- clearFlushTimer();
75
- if (pending.length === 0 || disposed)
76
- return;
77
- const text = pending;
78
- pending = '';
79
- wrapper.write(text);
80
- };
81
- const onData = (chunk) => {
82
- if (disposed)
83
- return;
84
- clearFlushTimer();
85
- const decoded = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
86
- const split = splitMouseEvents(pending + decoded);
87
- pending = split.pending;
88
- if (split.text.length > 0)
89
- wrapper.write(split.text);
90
- for (const event of split.events)
91
- emit(event);
92
- if (pending.length > 0) {
93
- // `.unref()` so a held tail can never keep the process alive on its own.
94
- flushTimer = setTimeout(flushPending, PENDING_FLUSH_MS);
95
- flushTimer.unref?.();
96
- }
97
- };
98
- // P2-7: a closed stdin must still terminate Ink's reader, or it waits forever
99
- // on a stream that will never produce another byte.
100
- const onEnd = () => {
101
- flushPending();
102
- if (!wrapper.writableEnded)
103
- wrapper.end();
104
- };
105
- // `setEncoding('utf8')` on the REAL stream so Node's StringDecoder handles
106
- // multi-byte boundaries for us — the parser works on characters, and a UTF-8
107
- // sequence split across two chunks would otherwise become two mojibake
108
- // characters before it ever reached `splitMouseEvents`.
109
- real.setEncoding?.('utf8');
110
- real.on('data', onData);
111
- real.once('end', onEnd);
112
- real.once('close', onEnd);
113
- return {
114
- stdin: wrapper,
115
- source: {
116
- subscribe(listener) {
117
- listeners.add(listener);
118
- return () => listeners.delete(listener);
119
- },
120
- },
121
- dispose() {
122
- if (disposed)
123
- return;
124
- disposed = true;
125
- clearFlushTimer();
126
- real.removeListener('data', onData);
127
- real.removeListener('end', onEnd);
128
- real.removeListener('close', onEnd);
129
- listeners.clear();
130
- // I-7: a live `'data'` listener on stdin keeps the event loop alive, and
131
- // `aragon` would hang on exit instead of returning to the shell.
132
- real.pause?.();
133
- real.unref?.();
134
- },
135
- };
136
- }
137
- /**
138
- * Build a filter, or `null` if construction throws.
139
- *
140
- * The `null` return is the whole point (P0-1): `enterAltScreen` derives whether
141
- * to enable mouse reporting from `filter !== null`, so a construction failure
142
- * degrades to "the wheel is inert" — a supported, tested rung of the fail-safe
143
- * ladder — rather than leaving reporting on with no filter in front of Ink.
144
- */
145
- export function tryCreateMouseFilter(real, onError) {
146
- try {
147
- return createMouseFilter(real);
148
- }
149
- catch (err) {
150
- onError?.(err instanceof Error ? err.message : String(err));
151
- return null;
152
- }
153
- }