@thegitai/cli 1.8.0 → 1.10.0
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/README.md
CHANGED
|
@@ -16,7 +16,7 @@ This package is the CLI. The same agent is also available as a
|
|
|
16
16
|
- **Your signed-in Chrome** - with the TheGitAI Chrome extension it works in the
|
|
17
17
|
browser you already have open, signed in as you, in its own tab group.
|
|
18
18
|
- **Computer Control** - it uses the apps on your computer on Linux, macOS and Windows:
|
|
19
|
-
in front of you, or, on Linux and macOS, on a screen of its own while you keep working.
|
|
19
|
+
in front of you, or, on Linux and macOS, on a screen of its own that you can pause and take over while you keep working.
|
|
20
20
|
[Setup guide](https://thegit.ai/docs/computer-control/overview).
|
|
21
21
|
- **Skills** - teach it your team's workflows as `SKILL.md` folders. It uses one
|
|
22
22
|
when a request calls for it, or when you type `/<name>`.
|
|
@@ -23,6 +23,9 @@ export const COMPUTER_OPERATIONS = [
|
|
|
23
23
|
];
|
|
24
24
|
const CALL_TIMEOUT_MS = 90_000;
|
|
25
25
|
const TYPE_MS_PER_CHARACTER = 20;
|
|
26
|
+
const SCREEN_CHECK_MS = 3_000;
|
|
27
|
+
const PAUSE_LIMIT_MS = 25 * 60_000;
|
|
28
|
+
const WAIT_SECONDS = 20;
|
|
26
29
|
let helper = null;
|
|
27
30
|
const currentTurn = new AsyncLocalStorage();
|
|
28
31
|
const computerUsers = new Set();
|
|
@@ -78,11 +81,11 @@ function startHelper(helperPath, env) {
|
|
|
78
81
|
proc.on('error', (error) => fail(`The desktop helper could not start: ${error.message}`));
|
|
79
82
|
return state;
|
|
80
83
|
}
|
|
81
|
-
function send(helperPath, env, request, signal) {
|
|
84
|
+
function send(helperPath, env, request, signal, probe) {
|
|
82
85
|
if (!helper)
|
|
83
86
|
helper = startHelper(helperPath, env);
|
|
84
87
|
const state = helper;
|
|
85
|
-
if (request.op !== 'end')
|
|
88
|
+
if (request.op !== 'end' && !probe)
|
|
86
89
|
state.inUse = true;
|
|
87
90
|
const id = state.nextId++;
|
|
88
91
|
const owner = currentTurn.getStore();
|
|
@@ -95,11 +98,11 @@ function send(helperPath, env, request, signal) {
|
|
|
95
98
|
state.proc.stdin.write(`${JSON.stringify({ op: 'end', id: state.nextId++ })}\n`);
|
|
96
99
|
return true;
|
|
97
100
|
};
|
|
98
|
-
const timeoutMs = CALL_TIMEOUT_MS +
|
|
101
|
+
const timeoutMs = probe?.timeoutMs ?? CALL_TIMEOUT_MS +
|
|
99
102
|
(request.op === 'type_text' ? String(request.text ?? '').length * TYPE_MS_PER_CHARACTER : 0);
|
|
100
103
|
return new Promise((resolve) => {
|
|
101
104
|
const timer = setTimeout(() => {
|
|
102
|
-
const stopped = stop();
|
|
105
|
+
const stopped = probe ? false : stop();
|
|
103
106
|
state.pending.delete(id);
|
|
104
107
|
const seconds = Math.round(timeoutMs / 1000);
|
|
105
108
|
resolve({
|
|
@@ -119,25 +122,38 @@ const deniedNotes = new Map();
|
|
|
119
122
|
function conversation() {
|
|
120
123
|
return scopedSessionId() ?? '';
|
|
121
124
|
}
|
|
122
|
-
function promptBody() {
|
|
125
|
+
function promptBody(screenNeedsLogin) {
|
|
123
126
|
if (process.platform === 'win32') {
|
|
124
127
|
return "It works on your screen: it moves your pointer and types until it's done. Press Esc anytime to take over.";
|
|
125
128
|
}
|
|
126
129
|
const background = process.platform === 'darwin'
|
|
127
130
|
? 'In the background, it works on a virtual display in your login session. Adding the display can briefly move your pointer before restoring it. Targeted input is experimental: some apps can take focus or ignore gestures. Hover requires control on your screen. You can move the same running window to your desktop afterward. '
|
|
128
131
|
: 'In the background, it works on a screen of its own with its own mouse and keyboard, so you keep yours. ';
|
|
132
|
+
if (screenNeedsLogin) {
|
|
133
|
+
return background +
|
|
134
|
+
'You can watch it in a small window.\n' +
|
|
135
|
+
'To let it work on your screen, log out and back in once, then ask again.';
|
|
136
|
+
}
|
|
129
137
|
return background +
|
|
130
138
|
'You can watch it in a small window.\n' +
|
|
131
139
|
"On your screen, it moves your pointer and types until it's done. Press Esc anytime to take over.";
|
|
132
140
|
}
|
|
133
|
-
async function
|
|
141
|
+
async function screenNeedsLogin(helperPath, env, signal) {
|
|
142
|
+
if (process.platform !== 'linux')
|
|
143
|
+
return false;
|
|
144
|
+
const reply = await send(helperPath, env, { op: 'screen_ready' }, signal, { timeoutMs: SCREEN_CHECK_MS });
|
|
145
|
+
return reply?.ok === true && reply.text === 'log_in';
|
|
146
|
+
}
|
|
147
|
+
async function askForDesktop(context, key, helperPath, env) {
|
|
134
148
|
if (!context.requestPermission)
|
|
135
149
|
return null;
|
|
150
|
+
const needsLogin = await screenNeedsLogin(helperPath, env, context.signal);
|
|
151
|
+
context.signal?.throwIfAborted();
|
|
136
152
|
const decision = await context.requestPermission({
|
|
137
153
|
bucket: 'computer',
|
|
138
154
|
alwaysAsk: true,
|
|
139
155
|
title: 'TheGitAI wants to use apps on this computer',
|
|
140
|
-
body: promptBody(),
|
|
156
|
+
body: promptBody(needsLogin),
|
|
141
157
|
options: process.platform === 'win32'
|
|
142
158
|
? [
|
|
143
159
|
{ label: 'Allow on my screen', decision: { kind: 'computer', desktop: 'screen', session: false } },
|
|
@@ -165,7 +181,7 @@ async function askForDesktop(context, key) {
|
|
|
165
181
|
taskChoices.set(key, decision.desktop);
|
|
166
182
|
return decision.desktop;
|
|
167
183
|
}
|
|
168
|
-
function chooseDesktop(context) {
|
|
184
|
+
function chooseDesktop(context, helperPath, env) {
|
|
169
185
|
const remembered = context.grants?.computer;
|
|
170
186
|
if (remembered)
|
|
171
187
|
return Promise.resolve(remembered);
|
|
@@ -177,11 +193,50 @@ function chooseDesktop(context) {
|
|
|
177
193
|
return Promise.resolve(choice);
|
|
178
194
|
let pending = pendingChoices.get(key);
|
|
179
195
|
if (!pending) {
|
|
180
|
-
pending = askForDesktop(context, key).finally(() => pendingChoices.delete(key));
|
|
196
|
+
pending = askForDesktop(context, key, helperPath, env).finally(() => pendingChoices.delete(key));
|
|
181
197
|
pendingChoices.set(key, pending);
|
|
182
198
|
}
|
|
183
199
|
return pending;
|
|
184
200
|
}
|
|
201
|
+
function askAgain(context) {
|
|
202
|
+
if (!context.requestPermission)
|
|
203
|
+
return;
|
|
204
|
+
if (context.grants)
|
|
205
|
+
delete context.grants.computer;
|
|
206
|
+
const key = conversation();
|
|
207
|
+
if (taskChoices.get(key) !== 'denied')
|
|
208
|
+
taskChoices.delete(key);
|
|
209
|
+
}
|
|
210
|
+
function permissionLine(context, desktop) {
|
|
211
|
+
const where = desktop === 'background' ? "TheGitAI's background screen" : "the user's own screen";
|
|
212
|
+
const span = context.grants?.computer === desktop ? 'for this session' : 'for this request';
|
|
213
|
+
return `Permission: ${where}, ${span}.`;
|
|
214
|
+
}
|
|
215
|
+
function stoppedNote(desktop) {
|
|
216
|
+
const how = desktop === 'background' ? " with Stop in the window showing TheGitAI's screen" : '';
|
|
217
|
+
return `The user took back control${how}. That is their choice, not an error: do not use the computer tools again for this request, and tell them what you had done.`;
|
|
218
|
+
}
|
|
219
|
+
const CLOSED_NOTE = "The user closed the window showing TheGitAI's screen, which closes that screen and the apps on it. " +
|
|
220
|
+
'That is their choice, not an error: do not use the computer tools again for this request, and tell them what you had done.';
|
|
221
|
+
const RESUMED_NOTE = "The user paused you on TheGitAI's screen to use it themselves, then pressed Resume. That is their choice, not an error. " +
|
|
222
|
+
'This action was stopped and may have done only part of its work. Look at the app again before you continue, ' +
|
|
223
|
+
'do not repeat what already took effect, and expect changes they made while you waited.';
|
|
224
|
+
const STILL_PAUSED_NOTE = "The user paused you on TheGitAI's screen and has not pressed Resume yet. That is their choice, not an error. " +
|
|
225
|
+
'Do not use the computer tools again for now: tell them what is left, and that they can ask you in the chat to continue when they are ready.';
|
|
226
|
+
async function waitForResume(context, helperPath, env, desktop) {
|
|
227
|
+
context.onStatus("Paused on TheGitAI's screen. Waiting for Resume.");
|
|
228
|
+
const started = Date.now();
|
|
229
|
+
while (Date.now() - started < PAUSE_LIMIT_MS) {
|
|
230
|
+
context.signal?.throwIfAborted();
|
|
231
|
+
const reply = await send(helperPath, env, { op: 'wait', desktop, seconds: WAIT_SECONDS }, context.signal);
|
|
232
|
+
context.signal?.throwIfAborted();
|
|
233
|
+
if (!reply?.ok)
|
|
234
|
+
return 'paused';
|
|
235
|
+
if (reply.text === 'resumed' || reply.text === 'stopped' || reply.text === 'closed')
|
|
236
|
+
return reply.text;
|
|
237
|
+
}
|
|
238
|
+
return 'paused';
|
|
239
|
+
}
|
|
185
240
|
export async function withComputerTurn(run) {
|
|
186
241
|
const token = Symbol();
|
|
187
242
|
const key = conversation();
|
|
@@ -225,7 +280,11 @@ export function computerTool(operation) {
|
|
|
225
280
|
failureCategory: 'policy_blocked',
|
|
226
281
|
};
|
|
227
282
|
}
|
|
228
|
-
|
|
283
|
+
if (operation === 'list_apps' && args.ask_again === true)
|
|
284
|
+
askAgain(context);
|
|
285
|
+
const request = { ...args };
|
|
286
|
+
delete request.ask_again;
|
|
287
|
+
const desktop = await chooseDesktop(context, helperPath, env);
|
|
229
288
|
context.signal?.throwIfAborted();
|
|
230
289
|
if (!desktop) {
|
|
231
290
|
return {
|
|
@@ -241,17 +300,42 @@ export function computerTool(operation) {
|
|
|
241
300
|
const turn = currentTurn.getStore();
|
|
242
301
|
if (turn)
|
|
243
302
|
computerUsers.add(turn);
|
|
244
|
-
const reply = await send(helperPath, env, { ...
|
|
303
|
+
const reply = await send(helperPath, env, { ...request, op: operation, desktop }, context.signal);
|
|
304
|
+
if (reply?.paused) {
|
|
305
|
+
const outcome = await waitForResume(context, helperPath, env, desktop);
|
|
306
|
+
return {
|
|
307
|
+
ok: false,
|
|
308
|
+
error: outcome === 'resumed' ? RESUMED_NOTE
|
|
309
|
+
: outcome === 'stopped' ? stoppedNote(desktop)
|
|
310
|
+
: outcome === 'closed' ? CLOSED_NOTE
|
|
311
|
+
: STILL_PAUSED_NOTE,
|
|
312
|
+
failureCategory: 'user_declined',
|
|
313
|
+
userControl: outcome,
|
|
314
|
+
desktop,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
if (reply?.skipped) {
|
|
318
|
+
return { ok: false, skipped: true, error: String(reply.error ?? ''), failureCategory: 'command_failed', desktop };
|
|
319
|
+
}
|
|
320
|
+
if (reply?.cancelled && !String(reply.error ?? '').startsWith('Only the user can fix this')) {
|
|
321
|
+
return {
|
|
322
|
+
ok: false,
|
|
323
|
+
error: reply.closed ? CLOSED_NOTE : stoppedNote(desktop),
|
|
324
|
+
failureCategory: 'user_declined',
|
|
325
|
+
userControl: reply.closed ? 'closed' : 'stopped',
|
|
326
|
+
desktop,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
245
329
|
if (!reply?.ok) {
|
|
246
330
|
return {
|
|
247
331
|
ok: false,
|
|
248
|
-
error: String(reply?.error ?? 'The desktop helper failed.'),
|
|
249
|
-
failureCategory:
|
|
332
|
+
error: `${String(reply?.error ?? 'The desktop helper failed.')}\n${permissionLine(context, desktop)}`,
|
|
333
|
+
failureCategory: 'command_failed',
|
|
250
334
|
desktop,
|
|
251
335
|
};
|
|
252
336
|
}
|
|
253
337
|
const { png, width, height, text } = reply;
|
|
254
|
-
const result = { ok: true, state: String(text ?? ''), desktop };
|
|
338
|
+
const result = { ok: true, state: `${String(text ?? '')}\n${permissionLine(context, desktop)}`, desktop };
|
|
255
339
|
if (typeof png === 'string') {
|
|
256
340
|
result.screenshot = { width, height };
|
|
257
341
|
result.imageBytes = { base64Data: png, mimeType: 'image/png' };
|
package/dist/src/ui/repl.js
CHANGED
|
@@ -1749,7 +1749,15 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
1749
1749
|
syncTerminalTitle();
|
|
1750
1750
|
syncAttention();
|
|
1751
1751
|
const elapsedSeconds = busyElapsedSeconds(state, Date.now());
|
|
1752
|
-
|
|
1752
|
+
const frame = buildTuiFrame(state, terminalCols, terminalRows, spinnerFrame, elapsedSeconds, Date.now());
|
|
1753
|
+
if (frame.transcriptScrollOffset < state.transcriptScrollOffset) {
|
|
1754
|
+
store.update((current) => ({
|
|
1755
|
+
...current,
|
|
1756
|
+
transcriptScrollOffset: frame.transcriptScrollOffset,
|
|
1757
|
+
}));
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
bridge.render(frame);
|
|
1753
1761
|
};
|
|
1754
1762
|
const remountTui = async () => {
|
|
1755
1763
|
if (remountPromise) {
|
|
@@ -1633,6 +1633,15 @@ function sliceTranscriptLines(lines, maxLines, scrollOffset) {
|
|
|
1633
1633
|
const start = Math.max(0, lines.length - maxLines - offset);
|
|
1634
1634
|
return lines.slice(start, start + maxLines);
|
|
1635
1635
|
}
|
|
1636
|
+
const BACK_TO_BOTTOM_LABEL = '↓ Back to Bottom (Ctrl + End)';
|
|
1637
|
+
function backToBottomLines(width) {
|
|
1638
|
+
const label = fitLine(BACK_TO_BOTTOM_LABEL, width);
|
|
1639
|
+
const pad = Math.max(0, Math.floor((width - displayWidth(label)) / 2));
|
|
1640
|
+
return [
|
|
1641
|
+
line(span(' '.repeat(pad)), span(label, { color: 'cyan', bold: true })),
|
|
1642
|
+
plainLine(''),
|
|
1643
|
+
];
|
|
1644
|
+
}
|
|
1636
1645
|
export function buildTuiFrame(state, cols, rows, spinnerFrame, elapsedSeconds, nowMs = 0) {
|
|
1637
1646
|
const contentWidth = frameContentWidth(cols);
|
|
1638
1647
|
const gutter = Math.max(Math.floor((cols - contentWidth) / 2), 0);
|
|
@@ -1721,13 +1730,26 @@ export function buildTuiFrame(state, cols, rows, spinnerFrame, elapsedSeconds, n
|
|
|
1721
1730
|
}
|
|
1722
1731
|
const reservedLines = countSectionLines(sections.filter((section) => section.kind !== 'transcript'));
|
|
1723
1732
|
const composerGap = sections.some((section) => section.kind === 'composer') ? 1 : 0;
|
|
1724
|
-
|
|
1733
|
+
let transcriptBudget = Math.max(1, rows - reservedLines - composerGap - 1);
|
|
1725
1734
|
let transcriptScrollLimit = Math.max(0, transcriptLines.length - transcriptBudget);
|
|
1726
1735
|
if (transcriptScrollLimit > 0 && contentWidth > 2) {
|
|
1727
1736
|
transcriptLines = buildTranscriptLines(contentWidth - 2);
|
|
1728
1737
|
transcriptScrollLimit = Math.max(0, transcriptLines.length - transcriptBudget);
|
|
1729
1738
|
}
|
|
1730
|
-
|
|
1739
|
+
let transcriptScrollOffset = Math.min(Math.max(state.transcriptScrollOffset, 0), transcriptScrollLimit);
|
|
1740
|
+
if (transcriptScrollOffset > 0 && transcriptBudget > 1) {
|
|
1741
|
+
transcriptBudget -= 1;
|
|
1742
|
+
transcriptScrollLimit += 1;
|
|
1743
|
+
transcriptScrollOffset = Math.min(state.transcriptScrollOffset, transcriptScrollLimit);
|
|
1744
|
+
const pill = backToBottomLines(contentWidth > 2 ? contentWidth - 2 : contentWidth);
|
|
1745
|
+
const liveIndex = sections.findIndex((section) => section.kind === 'live');
|
|
1746
|
+
if (liveIndex >= 0) {
|
|
1747
|
+
sections[liveIndex] = { ...sections[liveIndex], lines: [...pill, ...sections[liveIndex].lines] };
|
|
1748
|
+
}
|
|
1749
|
+
else {
|
|
1750
|
+
sections.unshift({ kind: 'live', lines: pill });
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1731
1753
|
sections.unshift({
|
|
1732
1754
|
kind: 'transcript',
|
|
1733
1755
|
lines: sliceTranscriptLines(transcriptLines, transcriptBudget, transcriptScrollOffset),
|
|
@@ -277,6 +277,10 @@ export function handleShellKeyEvent(store, handlers, event) {
|
|
|
277
277
|
handlers.onRequestExit();
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
|
+
if (key.ctrl && key.end && state.transcriptScrollOffset > 0) {
|
|
281
|
+
scrollTranscriptTo(store, handlers, 0);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
280
284
|
if (state.userInputPrompt &&
|
|
281
285
|
applyUserInputPromptEvent(store, handlers, key)) {
|
|
282
286
|
return;
|
|
@@ -56,6 +56,7 @@ export function buildShortcutGroups(platform = process.platform, shortcuts = {})
|
|
|
56
56
|
title: 'Transcript',
|
|
57
57
|
rows: [
|
|
58
58
|
{ keys: 'PageUp / PageDown', description: 'Scroll - the mouse wheel works too' },
|
|
59
|
+
{ keys: 'Ctrl+End', description: 'Back to bottom' },
|
|
59
60
|
{ keys: 'Drag', description: 'Select and copy' },
|
|
60
61
|
{ keys: 'Double-click', description: 'Copy a word' },
|
|
61
62
|
{ keys: 'Triple-click', description: 'Copy a whole row' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegitai/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "TheGitAI is an AI coding agent. It reads and searches your repository, writes and edits files, runs your tests, verifies the change before handing it back, uses the apps on your computer, and remembers your corrections between sessions. Talk to it with voice dictation, and customize its keyboard shortcuts in your editor.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentic-ai",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"@lydell/node-pty-linux-x64": "1.1.0",
|
|
51
51
|
"@lydell/node-pty-win32-arm64": "1.1.0",
|
|
52
52
|
"@lydell/node-pty-win32-x64": "1.1.0",
|
|
53
|
-
"@thegitai/tui-darwin-arm64": "1.
|
|
54
|
-
"@thegitai/tui-darwin-x64": "1.
|
|
55
|
-
"@thegitai/tui-linux-arm64": "1.
|
|
56
|
-
"@thegitai/tui-linux-x64": "1.
|
|
57
|
-
"@thegitai/tui-win32-x64": "1.
|
|
53
|
+
"@thegitai/tui-darwin-arm64": "1.10.0",
|
|
54
|
+
"@thegitai/tui-darwin-x64": "1.10.0",
|
|
55
|
+
"@thegitai/tui-linux-arm64": "1.10.0",
|
|
56
|
+
"@thegitai/tui-linux-x64": "1.10.0",
|
|
57
|
+
"@thegitai/tui-win32-x64": "1.10.0",
|
|
58
58
|
"@vscode/ripgrep": "1.18.0"
|
|
59
59
|
},
|
|
60
60
|
"repository": {
|