@thegitai/cli 1.0.3 → 1.1.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 +27 -8
- package/dist/src/api/chat.js +5 -1
- package/dist/src/client-environment.js +2 -0
- package/dist/src/help-text.js +6 -1
- package/dist/src/permissions.js +3 -1
- package/dist/src/session.js +2 -0
- package/dist/src/tool-executor.js +4 -0
- package/dist/src/tools/computer.js +273 -0
- package/dist/src/tools/index.js +2 -0
- package/dist/src/ui/repl.js +14 -4
- package/dist/src/ui/slash-commands.js +1 -1
- package/dist/src/ui/tui/build-frame.js +34 -10
- package/dist/src/ui/tui/model-picker-window.js +9 -0
- package/dist/src/ui/tui/shell-input.js +13 -6
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
# TheGitAI - AI coding agent
|
|
1
|
+
# TheGitAI - AI coding agent
|
|
2
2
|
|
|
3
|
-
TheGitAI is an AI coding agent that
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
TheGitAI is an AI coding agent that finishes the job: it changes your code,
|
|
4
|
+
runs and tests it, and can use your signed-in Chrome and the apps on your
|
|
5
|
+
computer to check the result. Every edit it makes can be undone without
|
|
6
|
+
touching yours.
|
|
7
|
+
|
|
8
|
+
This package is the CLI. The same agent is also available as a
|
|
9
|
+
[desktop app](https://thegit.ai/desktop), with the same account and plan.
|
|
7
10
|
|
|
8
11
|
- **Your repository and shell** - literal, regex and natural-language code
|
|
9
12
|
search, multi-file edits, shell commands, tests, builds and diagnostics, with
|
|
@@ -12,6 +15,9 @@ back. Every edit it makes can be undone without touching yours.
|
|
|
12
15
|
running in the background while it reproduces a bug and reads the logs.
|
|
13
16
|
- **Your signed-in Chrome** - with the TheGitAI Chrome extension it works in the
|
|
14
17
|
browser you already have open, signed in as you, in its own tab group.
|
|
18
|
+
- **Computer Control** - it uses the apps on your computer on GNOME Wayland,
|
|
19
|
+
Linux Mint and macOS: in front of you, or on a screen of its own while you
|
|
20
|
+
keep working. [Setup guide](https://thegit.ai/docs/computer-control/overview).
|
|
15
21
|
- **Skills** - teach it your team's workflows as `SKILL.md` folders. It uses one
|
|
16
22
|
when a request calls for it, or when you type `/<name>`.
|
|
17
23
|
- **MCP servers** - connect local or remote MCP servers with `ai mcp add`.
|
|
@@ -20,18 +26,28 @@ back. Every edit it makes can be undone without touching yours.
|
|
|
20
26
|
- **Steering and recovery** - send corrections while it works, switch between
|
|
21
27
|
Default, Bypass all permissions and Plan modes, and undo an edit, a turn or a
|
|
22
28
|
file, or restore a checkpoint.
|
|
23
|
-
- **Curated frontier models** -
|
|
24
|
-
|
|
29
|
+
- **Curated frontier models** - models from OpenAI, Anthropic, Google, xAI and
|
|
30
|
+
leading Chinese labs, or Auto to pick one for each task. Switch mid-session
|
|
31
|
+
without losing the conversation. No provider API keys to manage.
|
|
25
32
|
|
|
26
33
|
Documentation: https://thegit.ai/docs
|
|
27
34
|
|
|
35
|
+
Models: https://thegit.ai/models
|
|
36
|
+
|
|
37
|
+
Full manual for AI tools: https://thegit.ai/llms-full.txt
|
|
38
|
+
|
|
39
|
+
Demos: [Desktop app](https://youtu.be/hQ-K_VFlMrM),
|
|
40
|
+
[Browser Control](https://youtu.be/yFbGC5r9WbY),
|
|
41
|
+
[Computer Control](https://youtu.be/2K3klt4DNYc)
|
|
42
|
+
|
|
28
43
|
## Install
|
|
29
44
|
|
|
30
45
|
```bash
|
|
31
46
|
npm i -g @thegitai/cli
|
|
32
47
|
```
|
|
33
48
|
|
|
34
|
-
Supports Node.js 22 and newer. Node.js 24 is
|
|
49
|
+
Runs on macOS, Linux and Windows. Supports Node.js 22 and newer. Node.js 24 is
|
|
50
|
+
recommended.
|
|
35
51
|
|
|
36
52
|
This installs the `ai` command. If `ai` is already taken by another command on
|
|
37
53
|
your machine, `thegitai` starts the same CLI.
|
|
@@ -99,6 +115,9 @@ Type `/model` to choose with **↑ / ↓**, and adjust a model's reasoning effor
|
|
|
99
115
|
with **← / →** in the same panel: **Default / Low / Balanced / Deep**.
|
|
100
116
|
**Enter** saves the selected model's choice for this project; **Esc** cancels.
|
|
101
117
|
Each model remembers its own choice across new and resumed sessions.
|
|
118
|
+
In short terminals, the list scrolls around the highlighted model and shows how
|
|
119
|
+
many models are above and below. Use **PageUp / PageDown** to move a page, or
|
|
120
|
+
**Home / End** to reach the first or last model. Effort controls stay visible.
|
|
102
121
|
A model your plan does not include stays in the list, grayed out with the
|
|
103
122
|
reason, and **Enter** does not select it.
|
|
104
123
|
On Plus or Pro, the footer names the plan after **TheGitAI**.
|
package/dist/src/api/chat.js
CHANGED
|
@@ -18,6 +18,7 @@ import { describeSessionImageStore } from '../core/session-image-store.js';
|
|
|
18
18
|
import { autoAttachImages } from '../core/image-path-extractor.js';
|
|
19
19
|
import { formatTurnFailureMarker } from '../turn-failure-marker.js';
|
|
20
20
|
import { browserExtensionSeen, releaseBrowserAfterTurn } from '../browser/session-bridge.js';
|
|
21
|
+
import { withComputerTurn } from '../tools/computer.js';
|
|
21
22
|
export class TurnCancelledError extends Error {
|
|
22
23
|
name = 'TurnCancelledError';
|
|
23
24
|
constructor(message = 'Turn cancelled.') {
|
|
@@ -742,7 +743,10 @@ async function runTurnStream({ openStream, config, session, input, request, reco
|
|
|
742
743
|
}
|
|
743
744
|
}
|
|
744
745
|
}
|
|
745
|
-
export
|
|
746
|
+
export function sendServerUserMessage(request) {
|
|
747
|
+
return withComputerTurn(() => sendServerUserMessageInner(request));
|
|
748
|
+
}
|
|
749
|
+
async function sendServerUserMessageInner({ config, session, input, jobFollowUp = false, imageAttachments = [], fetchImpl = globalThis.fetch, signal, onTurnStart, onInterjectionDelivered, recoverySleep, }) {
|
|
746
750
|
if (!jobFollowUp)
|
|
747
751
|
session.sessionLastPromptAt = new Date().toISOString();
|
|
748
752
|
const autoAttach = autoAttachImages(input, session.rootDir, imageAttachments);
|
|
@@ -3,6 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { ensureSessionScratchDir } from './scratch-dir.js';
|
|
5
5
|
import { browserExtensionSeen } from './browser/session-bridge.js';
|
|
6
|
+
import { computerHelperPath } from './tools/computer.js';
|
|
6
7
|
const PACKAGE_MANAGER_CANDIDATES = [
|
|
7
8
|
'apt',
|
|
8
9
|
'apt-get',
|
|
@@ -127,5 +128,6 @@ export function collectClientEnvironment(options = {}) {
|
|
|
127
128
|
packageManagers: detectPackageManagers(env, platform, executableExists),
|
|
128
129
|
scratchDir: options.scratchDir ?? ensureSessionScratchDir(),
|
|
129
130
|
browserExtensionSeen: options.browserExtensionSeen ?? browserExtensionSeen(env),
|
|
131
|
+
computerControl: (platform === 'linux' || platform === 'darwin') && Boolean(computerHelperPath(env)),
|
|
130
132
|
};
|
|
131
133
|
}
|
package/dist/src/help-text.js
CHANGED
|
@@ -147,7 +147,7 @@ const HELP_MARKDOWN = [
|
|
|
147
147
|
'- `/<skill> [what to do]` - run a skill yourself. Skills show up in the',
|
|
148
148
|
' command picker, and the agent also loads a matching skill on its own',
|
|
149
149
|
'- `/about` - show version and platform info',
|
|
150
|
-
'- `/report` -
|
|
150
|
+
'- `/report` - report a bug or request a feature privately through the TheGitAI website in your',
|
|
151
151
|
' browser (sign in with your existing account)',
|
|
152
152
|
'- `/usage` - show account usage percentage and reset times',
|
|
153
153
|
'- `/model` - ↑/↓ picks a model, ←/→ adjusts effort; Enter saves for this project, Esc cancels',
|
|
@@ -192,6 +192,11 @@ const HELP_MARKDOWN = [
|
|
|
192
192
|
' command and keeps the password masked and local.',
|
|
193
193
|
'- `-y` / `--yes` at startup auto-approves every shell command and file',
|
|
194
194
|
' edit for the whole session - use with care.',
|
|
195
|
+
'- Using desktop apps (GNOME or Linux Mint, preview) always asks first, even in',
|
|
196
|
+
' Bypass all permissions mode: in the background, on a screen of its own',
|
|
197
|
+
' you watch in a small window while you keep your mouse and keyboard, or on',
|
|
198
|
+
' your screen, where Esc takes over. The answer lasts for the task, or for',
|
|
199
|
+
' the session if you choose that.',
|
|
195
200
|
'- Long-running commands (e.g. dev servers) can run as managed background',
|
|
196
201
|
' jobs after the same approval as any other command. Background output',
|
|
197
202
|
' stays quiet once the model has responded; the footer shows only a compact',
|
package/dist/src/permissions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getUnquotedShellText } from './agent-mode.js';
|
|
2
|
-
export const PERMISSION_BUCKETS = ['create', 'edit', 'delete', 'run', 'browse', 'mcp'];
|
|
2
|
+
export const PERMISSION_BUCKETS = ['create', 'edit', 'delete', 'run', 'browse', 'mcp', 'computer'];
|
|
3
3
|
export function createSessionGrants() {
|
|
4
4
|
return { buckets: [], commandPrefixes: [], origins: [] };
|
|
5
5
|
}
|
|
@@ -14,6 +14,8 @@ export function bucketActionLabel(bucket) {
|
|
|
14
14
|
return 'act on any website';
|
|
15
15
|
if (bucket === 'mcp')
|
|
16
16
|
return 'use MCP tools';
|
|
17
|
+
if (bucket === 'computer')
|
|
18
|
+
return 'use apps on this computer';
|
|
17
19
|
return 'run commands';
|
|
18
20
|
}
|
|
19
21
|
export function originForUrl(url) {
|
package/dist/src/session.js
CHANGED
|
@@ -3,6 +3,7 @@ import { normalizeAgentMode, } from './agent-mode.js';
|
|
|
3
3
|
import { createSessionGrants, } from './permissions.js';
|
|
4
4
|
import { createSessionSafetyState, } from './session-safety.js';
|
|
5
5
|
import { closeBrowserBridge } from './browser/session-bridge.js';
|
|
6
|
+
import { disconnectComputerHelper } from './tools/computer.js';
|
|
6
7
|
import { clampInteger } from './utils.js';
|
|
7
8
|
const DEFAULT_MAX_TOOL_STEPS = 32;
|
|
8
9
|
function defaultStatus(message) {
|
|
@@ -103,6 +104,7 @@ export function clearConversation(session) {
|
|
|
103
104
|
}
|
|
104
105
|
export async function disposeSession(session) {
|
|
105
106
|
closeBrowserBridge();
|
|
107
|
+
disconnectComputerHelper();
|
|
106
108
|
await session.mcp?.close();
|
|
107
109
|
}
|
|
108
110
|
export function switchModel(session, modelId) {
|
|
@@ -37,6 +37,9 @@ function toolCallSummary(call) {
|
|
|
37
37
|
return '';
|
|
38
38
|
return `${todos.length} item${todos.length === 1 ? '' : 's'}`;
|
|
39
39
|
}
|
|
40
|
+
if (call.name.startsWith('computer_')) {
|
|
41
|
+
return String(args.title ?? args.app ?? '').trim();
|
|
42
|
+
}
|
|
40
43
|
const filePath = getEditToolFilePath(call);
|
|
41
44
|
if (filePath)
|
|
42
45
|
return filePath;
|
|
@@ -250,6 +253,7 @@ export async function executeLocalToolCall(session, call, diagnosticsPlan) {
|
|
|
250
253
|
? captureMutationBaseline(session.rootDir)
|
|
251
254
|
: null;
|
|
252
255
|
const context = {
|
|
256
|
+
signal: session.turnAbortSignal,
|
|
253
257
|
rootDir: session.rootDir,
|
|
254
258
|
sessionId: session.sessionId,
|
|
255
259
|
autoYes: session.autoYes,
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import readline from 'node:readline';
|
|
6
|
+
import { storeSessionImageBytes } from '../core/session-image-store.js';
|
|
7
|
+
import { scopedSessionId } from '../session-context.js';
|
|
8
|
+
export const COMPUTER_OPERATIONS = [
|
|
9
|
+
'list_apps',
|
|
10
|
+
'open_app',
|
|
11
|
+
'get_app_state',
|
|
12
|
+
'click',
|
|
13
|
+
'perform_secondary_action',
|
|
14
|
+
'set_value',
|
|
15
|
+
'type_text',
|
|
16
|
+
'press_key',
|
|
17
|
+
'scroll',
|
|
18
|
+
'drag',
|
|
19
|
+
'zoom',
|
|
20
|
+
'hover',
|
|
21
|
+
'move_window',
|
|
22
|
+
];
|
|
23
|
+
const CALL_TIMEOUT_MS = 90_000;
|
|
24
|
+
const TYPE_MS_PER_CHARACTER = 20;
|
|
25
|
+
let helper = null;
|
|
26
|
+
const activeTurns = new Set();
|
|
27
|
+
const currentTurn = new AsyncLocalStorage();
|
|
28
|
+
const computerUsers = new Set();
|
|
29
|
+
const screenHolders = new Set();
|
|
30
|
+
function defaultHelperPath(env) {
|
|
31
|
+
const home = env.HOME?.trim();
|
|
32
|
+
const dataHome = env.XDG_DATA_HOME?.trim() || (home ? path.join(home, '.local', 'share') : '');
|
|
33
|
+
return dataHome ? path.join(dataHome, 'thegitai', 'computer', 'helper') : null;
|
|
34
|
+
}
|
|
35
|
+
export function computerHelperPath(env = process.env) {
|
|
36
|
+
const candidate = String(env.THEGITAI_COMPUTER_HELPER ?? '').trim() || defaultHelperPath(env);
|
|
37
|
+
if (!candidate)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
41
|
+
return candidate;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function startHelper(helperPath, env) {
|
|
48
|
+
const proc = spawn(helperPath, [], { stdio: ['pipe', 'pipe', 'ignore'], env });
|
|
49
|
+
const state = { proc, pending: new Map(), nextId: 1, inUse: false, backgroundUsed: false, path: helperPath, env };
|
|
50
|
+
readline.createInterface({ input: proc.stdout }).on('line', (line) => {
|
|
51
|
+
let message;
|
|
52
|
+
try {
|
|
53
|
+
message = JSON.parse(line);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const waiting = state.pending.get(Number(message?.id));
|
|
59
|
+
if (!waiting)
|
|
60
|
+
return;
|
|
61
|
+
state.pending.delete(Number(message.id));
|
|
62
|
+
clearTimeout(waiting.timer);
|
|
63
|
+
waiting.resolve(message);
|
|
64
|
+
});
|
|
65
|
+
const fail = (reason) => {
|
|
66
|
+
for (const [id, waiting] of state.pending) {
|
|
67
|
+
clearTimeout(waiting.timer);
|
|
68
|
+
waiting.resolve({ id, ok: false, error: reason });
|
|
69
|
+
}
|
|
70
|
+
state.pending.clear();
|
|
71
|
+
if (helper === state)
|
|
72
|
+
helper = null;
|
|
73
|
+
};
|
|
74
|
+
proc.on('exit', (code) => fail(`The desktop helper stopped (exit ${code}).`));
|
|
75
|
+
proc.on('error', (error) => fail(`The desktop helper could not start: ${error.message}`));
|
|
76
|
+
return state;
|
|
77
|
+
}
|
|
78
|
+
function send(helperPath, env, request, signal) {
|
|
79
|
+
if (!helper)
|
|
80
|
+
helper = startHelper(helperPath, env);
|
|
81
|
+
const state = helper;
|
|
82
|
+
if (request.op !== 'end')
|
|
83
|
+
state.inUse = true;
|
|
84
|
+
if (request.desktop === 'background' && request.op !== 'begin')
|
|
85
|
+
state.backgroundUsed = true;
|
|
86
|
+
const id = state.nextId++;
|
|
87
|
+
const owner = currentTurn.getStore();
|
|
88
|
+
const stop = () => {
|
|
89
|
+
if (!state.pending.has(id) || helper !== state)
|
|
90
|
+
return false;
|
|
91
|
+
if ([...computerUsers].some((user) => user !== owner))
|
|
92
|
+
return false;
|
|
93
|
+
state.inUse = false;
|
|
94
|
+
state.proc.stdin.write(`${JSON.stringify({ op: 'end', id: state.nextId++ })}\n`);
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
97
|
+
const timeoutMs = CALL_TIMEOUT_MS +
|
|
98
|
+
(request.op === 'type_text' ? String(request.text ?? '').length * TYPE_MS_PER_CHARACTER : 0);
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
const timer = setTimeout(() => {
|
|
101
|
+
const stopped = stop();
|
|
102
|
+
state.pending.delete(id);
|
|
103
|
+
const seconds = Math.round(timeoutMs / 1000);
|
|
104
|
+
resolve({
|
|
105
|
+
id,
|
|
106
|
+
ok: false,
|
|
107
|
+
error: `The desktop helper did not answer within ${seconds}s${stopped ? ', so the action was stopped' : ''}.`,
|
|
108
|
+
});
|
|
109
|
+
}, timeoutMs);
|
|
110
|
+
state.pending.set(id, { resolve, timer });
|
|
111
|
+
state.proc.stdin.write(`${JSON.stringify({ ...request, id })}\n`);
|
|
112
|
+
signal?.addEventListener('abort', stop, { once: true });
|
|
113
|
+
}).finally(() => signal?.removeEventListener('abort', stop));
|
|
114
|
+
}
|
|
115
|
+
const taskChoices = new Map();
|
|
116
|
+
const pendingChoices = new Map();
|
|
117
|
+
function conversation() {
|
|
118
|
+
return scopedSessionId() ?? '';
|
|
119
|
+
}
|
|
120
|
+
function promptBody() {
|
|
121
|
+
const background = process.platform === 'darwin'
|
|
122
|
+
? '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. '
|
|
123
|
+
: 'In the background, it works on a screen of its own with its own mouse and keyboard, so you keep yours. ';
|
|
124
|
+
return background +
|
|
125
|
+
'You can watch it in a small window.\n' +
|
|
126
|
+
"On your screen, it moves your pointer and types until it's done. Press Esc anytime to take over.";
|
|
127
|
+
}
|
|
128
|
+
async function askForDesktop(context, key) {
|
|
129
|
+
if (!context.requestPermission)
|
|
130
|
+
return null;
|
|
131
|
+
const decision = await context.requestPermission({
|
|
132
|
+
bucket: 'computer',
|
|
133
|
+
alwaysAsk: true,
|
|
134
|
+
title: 'TheGitAI wants to use apps on this computer',
|
|
135
|
+
body: promptBody(),
|
|
136
|
+
options: [
|
|
137
|
+
{ label: 'Allow in the background', decision: { kind: 'computer', desktop: 'background', session: false } },
|
|
138
|
+
{ label: 'Allow on my screen', decision: { kind: 'computer', desktop: 'screen', session: false } },
|
|
139
|
+
{
|
|
140
|
+
label: 'Allow in the background for this session',
|
|
141
|
+
decision: { kind: 'computer', desktop: 'background', session: true },
|
|
142
|
+
},
|
|
143
|
+
{ label: 'Allow on my screen for this session', decision: { kind: 'computer', desktop: 'screen', session: true } },
|
|
144
|
+
{ label: 'Deny', decision: { kind: 'deny' } },
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
if (decision.kind !== 'computer') {
|
|
148
|
+
taskChoices.set(key, 'denied');
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
if (decision.session && context.grants)
|
|
152
|
+
context.grants.computer = decision.desktop;
|
|
153
|
+
taskChoices.set(key, decision.desktop);
|
|
154
|
+
return decision.desktop;
|
|
155
|
+
}
|
|
156
|
+
function chooseDesktop(context) {
|
|
157
|
+
const remembered = context.grants?.computer;
|
|
158
|
+
if (remembered)
|
|
159
|
+
return Promise.resolve(remembered);
|
|
160
|
+
const key = conversation();
|
|
161
|
+
const choice = taskChoices.get(key);
|
|
162
|
+
if (choice === 'denied')
|
|
163
|
+
return Promise.resolve(null);
|
|
164
|
+
if (choice)
|
|
165
|
+
return Promise.resolve(choice);
|
|
166
|
+
let pending = pendingChoices.get(key);
|
|
167
|
+
if (!pending) {
|
|
168
|
+
pending = askForDesktop(context, key).finally(() => pendingChoices.delete(key));
|
|
169
|
+
pendingChoices.set(key, pending);
|
|
170
|
+
}
|
|
171
|
+
return pending;
|
|
172
|
+
}
|
|
173
|
+
export async function withComputerTurn(run) {
|
|
174
|
+
const token = Symbol();
|
|
175
|
+
const key = conversation();
|
|
176
|
+
activeTurns.add(token);
|
|
177
|
+
try {
|
|
178
|
+
const state = helper;
|
|
179
|
+
if (activeTurns.size === 1 && state?.backgroundUsed) {
|
|
180
|
+
const response = await send(state.path, state.env, { op: 'begin', desktop: 'background' });
|
|
181
|
+
if (response?.ok)
|
|
182
|
+
screenHolders.add(token);
|
|
183
|
+
else
|
|
184
|
+
state.backgroundUsed = false;
|
|
185
|
+
}
|
|
186
|
+
return await currentTurn.run(token, run);
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
activeTurns.delete(token);
|
|
190
|
+
computerUsers.delete(token);
|
|
191
|
+
screenHolders.delete(token);
|
|
192
|
+
taskChoices.delete(key);
|
|
193
|
+
if (screenHolders.size === 0)
|
|
194
|
+
await releaseComputerAfterTurn();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async function releaseComputerAfterTurn() {
|
|
198
|
+
if (!helper?.inUse)
|
|
199
|
+
return;
|
|
200
|
+
helper.inUse = false;
|
|
201
|
+
await send(helper.path, helper.env, { op: 'end' });
|
|
202
|
+
}
|
|
203
|
+
export function disconnectComputerHelper() {
|
|
204
|
+
const state = helper;
|
|
205
|
+
helper = null;
|
|
206
|
+
if (!state)
|
|
207
|
+
return;
|
|
208
|
+
for (const [id, waiting] of state.pending) {
|
|
209
|
+
clearTimeout(waiting.timer);
|
|
210
|
+
waiting.resolve({ id, ok: false, error: 'The CLI session closed.' });
|
|
211
|
+
}
|
|
212
|
+
state.pending.clear();
|
|
213
|
+
state.proc.stdin?.end();
|
|
214
|
+
}
|
|
215
|
+
export function computerTool(operation) {
|
|
216
|
+
return async (context, args) => {
|
|
217
|
+
const env = context.env ?? process.env;
|
|
218
|
+
const helperPath = computerHelperPath(env);
|
|
219
|
+
if (!helperPath) {
|
|
220
|
+
return {
|
|
221
|
+
ok: false,
|
|
222
|
+
error: 'Desktop control is not set up on this machine.',
|
|
223
|
+
failureCategory: 'policy_blocked',
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const desktop = await chooseDesktop(context);
|
|
227
|
+
context.signal?.throwIfAborted();
|
|
228
|
+
if (!desktop) {
|
|
229
|
+
return {
|
|
230
|
+
ok: false,
|
|
231
|
+
error: context.requestPermission
|
|
232
|
+
? 'The user did not allow TheGitAI to use apps on this computer for this request. Do not use the computer tools again for it; do it another way or tell the user.'
|
|
233
|
+
: 'Using apps on this computer needs the user to allow it, and they cannot be asked here.',
|
|
234
|
+
failureCategory: 'user_declined',
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const title = String(args.title ?? '').trim();
|
|
238
|
+
context.onStatus(title || operation.replace(/_/g, ' '));
|
|
239
|
+
const turn = currentTurn.getStore();
|
|
240
|
+
if (turn) {
|
|
241
|
+
computerUsers.add(turn);
|
|
242
|
+
screenHolders.add(turn);
|
|
243
|
+
}
|
|
244
|
+
const reply = await send(helperPath, env, { ...args, op: operation, desktop }, context.signal);
|
|
245
|
+
if (!reply?.ok) {
|
|
246
|
+
return {
|
|
247
|
+
ok: false,
|
|
248
|
+
error: String(reply?.error ?? 'The desktop helper failed.'),
|
|
249
|
+
failureCategory: reply?.cancelled ? 'user_declined' : 'command_failed',
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const { png, width, height, text } = reply;
|
|
253
|
+
const result = { ok: true, state: String(text ?? '') };
|
|
254
|
+
if (typeof png === 'string') {
|
|
255
|
+
result.screenshot = { width, height };
|
|
256
|
+
result.imageBytes = { base64Data: png, mimeType: 'image/png' };
|
|
257
|
+
if (context.sessionId) {
|
|
258
|
+
try {
|
|
259
|
+
const stored = storeSessionImageBytes({
|
|
260
|
+
sessionId: context.sessionId,
|
|
261
|
+
base64Data: png,
|
|
262
|
+
mimeType: 'image/png',
|
|
263
|
+
env: context.env,
|
|
264
|
+
});
|
|
265
|
+
result.imageBytes.cachePath = stored.cachePath;
|
|
266
|
+
result.imageBytes.index = stored.index;
|
|
267
|
+
}
|
|
268
|
+
catch { }
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
}
|
package/dist/src/tools/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { browserBatch, browserComputer, browserConsole, browserDownloads, browserEvaluate, browserFileUpload, browserFind, browserFormInput, browserGateway, browserGetPageText, browserNavigate, browserNetwork, browserReadPage, browserResize, browserTabClose, browserTabNew, browserTabs, } from './browser.js';
|
|
2
2
|
import { shellJobOutput } from './shell-job-output.js';
|
|
3
|
+
import { COMPUTER_OPERATIONS, computerTool } from './computer.js';
|
|
3
4
|
import { deleteFile } from './delete-file.js';
|
|
4
5
|
import { getDiagnostics } from './get-diagnostics.js';
|
|
5
6
|
import { grepCode } from './grep-code.js';
|
|
@@ -64,6 +65,7 @@ export const TOOL_MAP = {
|
|
|
64
65
|
browser_file_upload: browserFileUpload,
|
|
65
66
|
browser_downloads: browserDownloads,
|
|
66
67
|
browser_batch: browserBatch,
|
|
68
|
+
...Object.fromEntries(COMPUTER_OPERATIONS.map((operation) => [`computer_${operation}`, computerTool(operation)])),
|
|
67
69
|
generate_image: (_context, args) => {
|
|
68
70
|
if (!String(args.base64Data ?? '').trim()) {
|
|
69
71
|
return {
|
package/dist/src/ui/repl.js
CHANGED
|
@@ -4,7 +4,7 @@ import { REASONING_EFFORT_LABELS } from '../reasoning-effort.js';
|
|
|
4
4
|
import { basename, join as joinPath } from 'node:path';
|
|
5
5
|
import { createRatatuiBridge } from './tui/bridge.js';
|
|
6
6
|
import { bucketActionLabel, } from '../permissions.js';
|
|
7
|
-
import { AGENT_MODE_LOCKED_STATUS, approvalScrollLimit, buildTuiFrame, formatJobElapsed, formatTodoProgress, pickThinkingFallbackPhrase, renderTranscriptEntryLines, THINKING_FALLBACK_PHRASES, userInputViewportForFrame, } from './tui/build-frame.js';
|
|
7
|
+
import { AGENT_MODE_LOCKED_STATUS, approvalScrollLimit, buildTuiFrame, modelPickerPageSize, formatJobElapsed, formatTodoProgress, pickThinkingFallbackPhrase, renderTranscriptEntryLines, THINKING_FALLBACK_PHRASES, userInputViewportForFrame, } from './tui/build-frame.js';
|
|
8
8
|
import { createAttentionController, INITIAL_TERMINAL_FOCUS, } from './tui/attention.js';
|
|
9
9
|
import { backendFor, createNotificationQueue, } from './tui/desktop-notification.js';
|
|
10
10
|
import { readPreferences, writePreferences } from '../preferences.js';
|
|
@@ -97,14 +97,14 @@ export function buildReportTranscriptEntries(openedUrl) {
|
|
|
97
97
|
return openedUrl
|
|
98
98
|
? [
|
|
99
99
|
{
|
|
100
|
-
body: `Opening the private
|
|
100
|
+
body: `Opening the private form for bugs and feature requests in your browser. If nothing opened, visit:\n\n${REPORT_ISSUE_URL}\n`,
|
|
101
101
|
kind: 'system',
|
|
102
102
|
title: 'Report',
|
|
103
103
|
},
|
|
104
104
|
]
|
|
105
105
|
: [
|
|
106
106
|
{
|
|
107
|
-
body: `Could not open a browser. Report the bug
|
|
107
|
+
body: `Could not open a browser. Report the bug or request the feature at:\n\n${REPORT_ISSUE_URL}\n`,
|
|
108
108
|
kind: 'error',
|
|
109
109
|
title: 'Report',
|
|
110
110
|
},
|
|
@@ -3366,7 +3366,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
3366
3366
|
const deny = { kind: 'deny' };
|
|
3367
3367
|
if (exiting)
|
|
3368
3368
|
return deny;
|
|
3369
|
-
if (sessionAutoYes)
|
|
3369
|
+
if (sessionAutoYes && !request.alwaysAsk)
|
|
3370
3370
|
return { kind: 'once' };
|
|
3371
3371
|
const decision = await openApprovalPrompt(request, session.turnAbortSignal);
|
|
3372
3372
|
if (decision.kind === 'always-bucket') {
|
|
@@ -3397,9 +3397,19 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
3397
3397
|
title: 'Approvals',
|
|
3398
3398
|
});
|
|
3399
3399
|
}
|
|
3400
|
+
else if (decision.kind === 'computer' && decision.session) {
|
|
3401
|
+
appendTurnAwareEntry({
|
|
3402
|
+
body: decision.desktop === 'background'
|
|
3403
|
+
? 'Allowed for the rest of this session: using apps in the background.'
|
|
3404
|
+
: 'Allowed for the rest of this session: using apps on your screen.',
|
|
3405
|
+
kind: 'system',
|
|
3406
|
+
title: 'Approvals',
|
|
3407
|
+
});
|
|
3408
|
+
}
|
|
3400
3409
|
return decision;
|
|
3401
3410
|
};
|
|
3402
3411
|
const shellInputHandlers = {
|
|
3412
|
+
getModelPickerPageSize: () => modelPickerPageSize(store.getState(), terminalCols, terminalRows),
|
|
3403
3413
|
getApprovalScrollLimit: () => {
|
|
3404
3414
|
const contentWidth = frameContentWidth(terminalCols);
|
|
3405
3415
|
return approvalScrollLimit(store.getState().approvalPrompt, contentWidth, terminalRows);
|
|
@@ -14,7 +14,7 @@ export const SLASH_COMMANDS = [
|
|
|
14
14
|
command: '/notify',
|
|
15
15
|
description: 'Toggle desktop notifications when a turn ends (Ctrl+G)',
|
|
16
16
|
},
|
|
17
|
-
{ command: '/report', description: 'Report a bug privately on the TheGitAI website' },
|
|
17
|
+
{ command: '/report', description: 'Report a bug or request a feature privately on the TheGitAI website' },
|
|
18
18
|
{ command: '/about', description: 'Show version and platform info' },
|
|
19
19
|
{ command: '/logout', description: 'Sign out and quit' },
|
|
20
20
|
{ command: '/exit', description: 'Quit the current session', aliases: ['/quit'] },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modelPickerWindow, modelPickerScrollLabel } from './model-picker-window.js';
|
|
1
2
|
import { fitModelLabel } from './model-label.js';
|
|
2
3
|
import { projectModelEffort } from '../../project-model-preferences.js';
|
|
3
4
|
import { REASONING_EFFORTS, REASONING_EFFORT_LABELS, REASONING_EFFORT_DESCRIPTIONS } from '../../reasoning-effort.js';
|
|
@@ -862,8 +863,9 @@ function pickerTopBorder(panelWidth, fullTitle, compactTitle) {
|
|
|
862
863
|
const right = available - left;
|
|
863
864
|
return line(span(`╭${'─'.repeat(left)}`, { color: MODEL_PICKER_BORDER_COLOR }), span(title, { color: MODEL_PICKER_ACCENT_COLOR, bold: true }), span(`${'─'.repeat(right)}╮`, { color: MODEL_PICKER_BORDER_COLOR }));
|
|
864
865
|
}
|
|
865
|
-
function modelPickerDivider(panelWidth) {
|
|
866
|
-
|
|
866
|
+
function modelPickerDivider(panelWidth, scrollLabel = '') {
|
|
867
|
+
const label = scrollLabel ? ` ${fitLine(scrollLabel, panelWidth - 4)} ` : '';
|
|
868
|
+
return plainLine(`├${label}${'─'.repeat(Math.max(0, panelWidth - 2 - displayWidth(label)))}┤`, {
|
|
867
869
|
color: MODEL_PICKER_BORDER_COLOR,
|
|
868
870
|
});
|
|
869
871
|
}
|
|
@@ -955,16 +957,32 @@ function modelPickerDisplayRows(options, pausedCount, innerWidth) {
|
|
|
955
957
|
}
|
|
956
958
|
return rows;
|
|
957
959
|
}
|
|
958
|
-
function
|
|
959
|
-
const panelWidth = Math.max(28, Math.min(width, MODEL_PICKER_PANEL_MAX_WIDTH));
|
|
960
|
-
const innerWidth = Math.max(1, panelWidth - 4);
|
|
960
|
+
function modelPickerLayout(options, selectedIndex, innerWidth, availableHeight, pausedCount) {
|
|
961
961
|
const rows = modelPickerDisplayRows(options, pausedCount, innerWidth);
|
|
962
962
|
const showEffortDetails = rows.length + 8 <= availableHeight;
|
|
963
963
|
const fixedLineCount = showEffortDetails ? 8 : 5;
|
|
964
|
-
const visibleCount = Math.min(rows.length, Math.max(1, availableHeight - fixedLineCount));
|
|
965
964
|
const selectedRow = Math.max(0, rows.findIndex((row) => row.kind === 'option' && row.index === selectedIndex));
|
|
966
|
-
const
|
|
967
|
-
const visibleRows = rows.slice(
|
|
965
|
+
const window = modelPickerWindow(rows.length, selectedRow, availableHeight - fixedLineCount);
|
|
966
|
+
const visibleRows = rows.slice(window.start, window.end);
|
|
967
|
+
return {
|
|
968
|
+
showEffortDetails,
|
|
969
|
+
fixedLineCount,
|
|
970
|
+
visibleRows,
|
|
971
|
+
above: rows.slice(0, window.start).filter((row) => row.kind === 'option').length,
|
|
972
|
+
below: rows.slice(window.end).filter((row) => row.kind === 'option').length,
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
export function modelPickerPageSize(state, cols, rows) {
|
|
976
|
+
const options = buildModelPickerOptions(state.currentModelId, state.serverModels);
|
|
977
|
+
const panelWidth = Math.max(28, Math.min(frameContentWidth(cols), MODEL_PICKER_PANEL_MAX_WIDTH));
|
|
978
|
+
const layout = modelPickerLayout(options, state.modelPickerIndex, panelWidth - 4, rows, pausedModelCount(state.serverModels));
|
|
979
|
+
return Math.max(1, layout.visibleRows.filter((row) => row.kind === 'option').length);
|
|
980
|
+
}
|
|
981
|
+
function buildModelPickerPanel(options, selectedIndex, width, availableHeight, efforts = {}, pausedCount = 0) {
|
|
982
|
+
const panelWidth = Math.max(28, Math.min(width, MODEL_PICKER_PANEL_MAX_WIDTH));
|
|
983
|
+
const innerWidth = Math.max(1, panelWidth - 4);
|
|
984
|
+
const { showEffortDetails, fixedLineCount, visibleRows, above, below } = modelPickerLayout(options, selectedIndex, innerWidth, availableHeight, pausedCount);
|
|
985
|
+
const scrolling = above > 0 || below > 0;
|
|
968
986
|
const bodyLineCount = visibleRows.length + fixedLineCount;
|
|
969
987
|
const marginLineCount = Math.max(0, Math.min(MODEL_PICKER_PANEL_MARGIN_LINES, Math.floor((availableHeight - bodyLineCount) / 2)));
|
|
970
988
|
const margin = Array.from({ length: marginLineCount }, () => plainLine(''));
|
|
@@ -1003,8 +1021,14 @@ function buildModelPickerPanel(options, selectedIndex, width, availableHeight, e
|
|
|
1003
1021
|
? '↑/↓ model • Enter select • Esc cancel'
|
|
1004
1022
|
: '↑/↓ model • ←/→ effort • Enter select/save • Esc cancel';
|
|
1005
1023
|
const compactHint = autoSelected ? '↑↓ · Enter · Esc' : '↑↓ · ←→ · Enter · Esc';
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1024
|
+
const navigationHint = scrolling
|
|
1025
|
+
? fullHint.replace('↑/↓ model', '↑/↓ scroll • PgUp/PgDn page • Home/End')
|
|
1026
|
+
: fullHint;
|
|
1027
|
+
const compactNavigationHint = scrolling
|
|
1028
|
+
? innerWidth >= 39 ? '↑↓ PgUp/PgDn Home/End · ←→ · Enter · Esc' : '↑↓ PgUp/PgDn Enter Esc'
|
|
1029
|
+
: compactHint;
|
|
1030
|
+
const hint = [...navigationHint].length <= innerWidth ? navigationHint : compactNavigationHint;
|
|
1031
|
+
body.push(modelPickerDivider(panelWidth, scrolling ? modelPickerScrollLabel(above, below, innerWidth) : ''), lockedSelection
|
|
1008
1032
|
? modelPickerPanelSideLine(plainLine(fitLine(showEffortDetails ? (lockedLines[0] ?? '') : lockedSelection.note, innerWidth), { color: 'yellow', bold: true }), innerWidth)
|
|
1009
1033
|
: modelPickerPanelSideLine(plainLine(fitLine(effortText, innerWidth), { color: 'cyan', bold: true }), innerWidth), ...(showEffortDetails ? [
|
|
1010
1034
|
modelPickerPanelSideLine(plainLine(''), innerWidth),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function modelPickerWindow(rowCount, selectedRow, capacity) {
|
|
2
|
+
const count = Math.min(rowCount, Math.max(1, capacity));
|
|
3
|
+
const start = Math.max(0, Math.min(selectedRow - Math.floor(count / 2), rowCount - count));
|
|
4
|
+
return { start, end: start + count };
|
|
5
|
+
}
|
|
6
|
+
export function modelPickerScrollLabel(above, below, width) {
|
|
7
|
+
const full = `↑ ${above} more above • ↓ ${below} more below`;
|
|
8
|
+
return full.length <= width ? full : `↑ ${above} above · ↓ ${below} below`;
|
|
9
|
+
}
|
|
@@ -322,7 +322,7 @@ export function handleShellKeyEvent(store, handlers, event) {
|
|
|
322
322
|
if (state.exiting) {
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
|
-
if (key.pageUp || key.pageDown) {
|
|
325
|
+
if (!state.modelPickerOpen && (key.pageUp || key.pageDown)) {
|
|
326
326
|
scrollTranscript(store, handlers, key.pageUp ? 8 : -8);
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
@@ -364,13 +364,20 @@ export function handleShellKeyEvent(store, handlers, event) {
|
|
|
364
364
|
store.update((current) => ({ ...current, modelPickerOpen: false }));
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
|
-
if (key.upArrow || key.downArrow) {
|
|
367
|
+
if (key.upArrow || key.downArrow || key.pageUp || key.pageDown || key.home || key.end) {
|
|
368
368
|
store.update((current) => {
|
|
369
369
|
const options = buildModelPickerOptions(Number(current.currentModelId ?? 0), current.serverModels ?? []);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
370
|
+
const direction = key.upArrow || key.pageUp || key.home ? -1 : 1;
|
|
371
|
+
const steps = key.home || key.end ? options.length
|
|
372
|
+
: key.pageUp || key.pageDown ? Math.max(1, handlers.getModelPickerPageSize?.() ?? 1) : 1;
|
|
373
|
+
let index = current.modelPickerIndex;
|
|
374
|
+
for (let step = 0; step < steps; step++) {
|
|
375
|
+
const next = getNextModelPickerIndex(options, index, direction);
|
|
376
|
+
if (!(key.upArrow || key.downArrow) && (direction < 0 ? next > index : next < index))
|
|
377
|
+
break;
|
|
378
|
+
index = next;
|
|
379
|
+
}
|
|
380
|
+
return { ...current, modelPickerIndex: index };
|
|
374
381
|
});
|
|
375
382
|
return;
|
|
376
383
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegitai/cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "TheGitAI is an agentic AI coding tool for your terminal. It reads and searches your repository, writes and edits files, runs your tests, and verifies the change before handing it back.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentic-ai",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@lydell/node-pty-linux-x64": "1.1.0",
|
|
46
46
|
"@lydell/node-pty-win32-arm64": "1.1.0",
|
|
47
47
|
"@lydell/node-pty-win32-x64": "1.1.0",
|
|
48
|
-
"@thegitai/tui-darwin-arm64": "1.0
|
|
49
|
-
"@thegitai/tui-darwin-x64": "1.0
|
|
50
|
-
"@thegitai/tui-linux-arm64": "1.0
|
|
51
|
-
"@thegitai/tui-linux-x64": "1.0
|
|
52
|
-
"@thegitai/tui-win32-x64": "1.0
|
|
48
|
+
"@thegitai/tui-darwin-arm64": "1.1.0",
|
|
49
|
+
"@thegitai/tui-darwin-x64": "1.1.0",
|
|
50
|
+
"@thegitai/tui-linux-arm64": "1.1.0",
|
|
51
|
+
"@thegitai/tui-linux-x64": "1.1.0",
|
|
52
|
+
"@thegitai/tui-win32-x64": "1.1.0",
|
|
53
53
|
"@vscode/ripgrep": "1.18.0"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|