@thegitai/cli 1.0.0-preview.9 → 1.0.1
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/LICENSE +1 -1
- package/README.md +301 -15
- package/dist/bin/ai.js +139 -111
- package/dist/bin/browser-host.js +284 -0
- package/dist/src/agent-mode.js +33 -7
- package/dist/src/api/auth.js +8 -2
- package/dist/src/api/browser-login.js +77 -34
- package/dist/src/api/chat.js +702 -173
- package/dist/src/api/contracts.js +55 -1
- package/dist/src/api/default-host.js +1 -0
- package/dist/src/api/http.js +168 -8
- package/dist/src/api/models.js +75 -10
- package/dist/src/api/startup-handshake.js +36 -0
- package/dist/src/api/turn-recovery.js +189 -0
- package/dist/src/background-jobs.js +14 -4
- package/dist/src/browser/bridge.js +268 -0
- package/dist/src/browser/chrome-profiles.js +73 -0
- package/dist/src/browser/framing.js +42 -0
- package/dist/src/browser/native-host.js +219 -0
- package/dist/src/browser/protocol.js +46 -0
- package/dist/src/browser/session-bridge.js +130 -0
- package/dist/src/cli-args.js +19 -5
- package/dist/src/client-environment.js +2 -0
- package/dist/src/core/clipboard.js +8 -14
- package/dist/src/core/image-limits.js +56 -0
- package/dist/src/core/image-path-extractor.js +70 -3
- package/dist/src/core/session-image-store.js +271 -0
- package/dist/src/edit-journal.js +33 -2
- package/dist/src/executor.js +26 -4
- package/dist/src/help-text.js +152 -41
- package/dist/src/install-id.js +32 -0
- package/dist/src/job-follow-up.js +40 -0
- package/dist/src/mcp-client.js +335 -0
- package/dist/src/mcp-command.js +176 -0
- package/dist/src/mcp-config.js +123 -0
- package/dist/src/mcp-sdk.js +3 -0
- package/dist/src/mcp-types.js +26 -0
- package/dist/src/patcher.js +46 -4
- package/dist/src/permissions.js +301 -0
- package/dist/src/preferences.js +39 -0
- package/dist/src/project-key.js +11 -0
- package/dist/src/project-model-preferences.js +74 -0
- package/dist/src/quota-notice.js +62 -0
- package/dist/src/reasoning-effort.js +27 -0
- package/dist/src/scratch-dir.js +6 -2
- package/dist/src/session-context.js +11 -0
- package/dist/src/session-safety.js +0 -12
- package/dist/src/session-store.js +76 -10
- package/dist/src/session.js +14 -4
- package/dist/src/signin.js +58 -0
- package/dist/src/skills/discovery.js +280 -0
- package/dist/src/skills/frontmatter.js +192 -0
- package/dist/src/skills/install.js +394 -0
- package/dist/src/skills/types.js +43 -0
- package/dist/src/skills-command.js +71 -0
- package/dist/src/todo-list.js +16 -9
- package/dist/src/tool-executor.js +42 -51
- package/dist/src/tools/browser.js +928 -0
- package/dist/src/tools/delete-file.js +21 -5
- package/dist/src/tools/index.js +34 -10
- package/dist/src/tools/patch-file.js +14 -29
- package/dist/src/tools/read-file.js +7 -1
- package/dist/src/tools/read-image-file.js +85 -0
- package/dist/src/tools/replace-document-text.js +28 -18
- package/dist/src/tools/restore-checkpoint.js +1 -2
- package/dist/src/tools/run-command.js +14 -71
- package/dist/src/tools/run-node-script.js +13 -82
- package/dist/src/tools/save-generated-image.js +120 -0
- package/dist/src/tools/shell-diagnostics.js +248 -72
- package/dist/src/tools/str-replace.js +14 -29
- package/dist/src/tools/undo-edit.js +2 -7
- package/dist/src/tools/use-skill.js +38 -0
- package/dist/src/tools/write-file.js +69 -14
- package/dist/src/ui/repl.js +1141 -299
- package/dist/src/ui/slash-commands.js +140 -0
- package/dist/src/ui/tui/attention.js +25 -0
- package/dist/src/ui/tui/bridge.js +38 -5
- package/dist/src/ui/tui/build-frame.js +858 -303
- package/dist/src/ui/tui/composer-layout.js +76 -0
- package/dist/src/ui/tui/desktop-notification.js +118 -0
- package/dist/src/ui/tui/markdown-render.js +21 -11
- package/dist/src/ui/tui/model-label.js +13 -0
- package/dist/src/ui/tui/shell-input.js +266 -61
- package/dist/src/ui/tui/shortcuts.js +61 -0
- package/dist/src/ui/tui/terminal-theme.js +28 -0
- package/dist/src/ui/tui/text.js +31 -6
- package/dist/src/ui/tui/user-input.js +593 -0
- package/dist/src/update-check.js +205 -0
- package/dist/src/usage-notice.js +52 -0
- package/dist/src/usage.js +25 -2
- package/dist/src/utils.js +4 -0
- package/dist/src/version.js +52 -2
- package/dist/vendor/mcp/LICENSES.txt +414 -0
- package/dist/vendor/mcp/client.cjs +82 -0
- package/package.json +22 -9
- package/dist/src/project-index.js +0 -233
- package/dist/src/tools/code-intel.js +0 -472
- package/dist/src/tools/find-symbol.js +0 -70
- package/dist/src/tools/hover-symbol.js +0 -95
- package/dist/src/tools/list-symbols.js +0 -55
- package/dist/src/tools/search-code.js +0 -37
- package/dist/src/tools/signature-help.js +0 -118
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { isMcpToolName } from './mcp-types.js';
|
|
2
|
+
import { sessionMcp } from './mcp-client.js';
|
|
1
3
|
import { drainBackgroundJobNotifications, getBackgroundJob, } from './background-jobs.js';
|
|
2
4
|
import { canStoreEditSnapshot, isEditToolName, isGitWorkTree, MAX_EDIT_JOURNAL_RECORDS, operationFromSnapshots, readFileEditSnapshot, } from './edit-journal.js';
|
|
3
5
|
import { clearEditFailure, collectCommandMutations, captureMutationBaseline, ensureActiveCheckpoint, recordEditFailure, recordSessionEdit, rememberCheckpointFiles, } from './session-safety.js';
|
|
4
6
|
import { buildAgentModeToolBlockedResult, } from './agent-mode.js';
|
|
5
7
|
import { classifyProjectPath } from './patcher.js';
|
|
6
8
|
import { dispatchTool } from './tools/index.js';
|
|
7
|
-
import { syncIndexFromDisk } from './project-index.js';
|
|
8
9
|
import { PATH_REPAIRING_EDIT_TOOLS, repairFilePath } from './tools/path-suggest.js';
|
|
9
|
-
import { invalidateShellDiagnosticsCache, runShellDiagnostics, } from './tools/shell-diagnostics.js';
|
|
10
|
+
import { invalidateShellDiagnosticsCache, runBatchDiagnostics, runShellDiagnostics, } from './tools/shell-diagnostics.js';
|
|
10
11
|
import { extractTodosArg } from './todo-list.js';
|
|
11
12
|
const EDIT_FILE_PATH_ARG_ALIASES = [
|
|
12
13
|
'filePath',
|
|
@@ -43,9 +44,9 @@ function toolCallSummary(call) {
|
|
|
43
44
|
return args.query.slice(0, 120);
|
|
44
45
|
return '';
|
|
45
46
|
}
|
|
46
|
-
export function formatToolCallForStatus(call) {
|
|
47
|
+
export function formatToolCallForStatus(call, label = call.name) {
|
|
47
48
|
const summary = toolCallSummary(call);
|
|
48
|
-
return summary ? `Tool: ${
|
|
49
|
+
return summary ? `Tool: ${label} ${summary}` : `Tool: ${label}`;
|
|
49
50
|
}
|
|
50
51
|
function getEditToolFilePath(call) {
|
|
51
52
|
const args = call.args && typeof call.args === 'object' ? call.args : {};
|
|
@@ -69,7 +70,7 @@ function editToolWritesSeparateOutput(call) {
|
|
|
69
70
|
const output = args.outputPath ?? args.output_path;
|
|
70
71
|
return typeof output === 'string' && output.trim().length > 0;
|
|
71
72
|
}
|
|
72
|
-
async function collectTrackedCommandMutations({ session,
|
|
73
|
+
async function collectTrackedCommandMutations({ session, result, tracker, toolName, toolCallId, turnId, }) {
|
|
73
74
|
const checkpoint = ensureActiveCheckpoint(session.clientState.safety, turnId);
|
|
74
75
|
const records = collectCommandMutations({
|
|
75
76
|
state: session.clientState.safety,
|
|
@@ -84,40 +85,11 @@ async function collectTrackedCommandMutations({ session, projectIndex, result, t
|
|
|
84
85
|
return;
|
|
85
86
|
invalidateShellDiagnosticsCache(session.rootDir);
|
|
86
87
|
rememberCheckpointFiles(session.clientState.safety, session.rootDir, records.map((record) => record.filePath), turnId);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
removed: records.filter((record) => record.operation === 'delete').length,
|
|
93
|
-
indexedChunks: 0,
|
|
94
|
-
retrievalTokensUsed: 0,
|
|
95
|
-
};
|
|
96
|
-
if (priorSync?.error) {
|
|
97
|
-
result.repoSync = {
|
|
98
|
-
...mutationCounts,
|
|
99
|
-
indexSyncError: priorSync.error,
|
|
100
|
-
skipped: true,
|
|
101
|
-
reason: 'local index sync failed after command execution',
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
try {
|
|
106
|
-
const repoSync = await syncIndexFromDisk(projectIndex);
|
|
107
|
-
result.repoSync = {
|
|
108
|
-
...repoSync,
|
|
109
|
-
added: Math.max(repoSync.added, mutationCounts.added),
|
|
110
|
-
modified: Math.max(repoSync.modified, mutationCounts.modified),
|
|
111
|
-
removed: Math.max(repoSync.removed, mutationCounts.removed),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
const indexSyncError = error instanceof Error ? error.message : String(error);
|
|
116
|
-
result.repoSync = { ...mutationCounts, indexSyncError };
|
|
117
|
-
session.onStatus(`Repository changes were recorded, but local index sync failed: ${indexSyncError}`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
88
|
+
result.repoSync = {
|
|
89
|
+
added: records.filter((record) => record.operation === 'create').length,
|
|
90
|
+
modified: records.filter((record) => record.operation === 'update').length,
|
|
91
|
+
removed: records.filter((record) => record.operation === 'delete').length,
|
|
92
|
+
};
|
|
121
93
|
result.sessionEdits = records.map((record) => ({
|
|
122
94
|
id: record.id,
|
|
123
95
|
filePath: record.filePath,
|
|
@@ -125,9 +97,9 @@ async function collectTrackedCommandMutations({ session, projectIndex, result, t
|
|
|
125
97
|
beforeHash: record.beforeHash,
|
|
126
98
|
afterHash: record.afterHash,
|
|
127
99
|
}));
|
|
128
|
-
result.diagnostics = runShellDiagnostics(session.rootDir);
|
|
100
|
+
result.diagnostics = await runShellDiagnostics(session.rootDir);
|
|
129
101
|
}
|
|
130
|
-
export async function collectBackgroundJobUiKillMutations({ session,
|
|
102
|
+
export async function collectBackgroundJobUiKillMutations({ session, jobId, result, }) {
|
|
131
103
|
const normalizedJobId = String(jobId ?? result.snapshot?.id ?? '').trim();
|
|
132
104
|
if (!normalizedJobId || !result.ok)
|
|
133
105
|
return;
|
|
@@ -137,7 +109,6 @@ export async function collectBackgroundJobUiKillMutations({ session, projectInde
|
|
|
137
109
|
const mutationResult = result;
|
|
138
110
|
await collectTrackedCommandMutations({
|
|
139
111
|
session,
|
|
140
|
-
projectIndex,
|
|
141
112
|
result: mutationResult,
|
|
142
113
|
tracker: tracked.tracker,
|
|
143
114
|
toolName: tracked.toolName,
|
|
@@ -151,7 +122,7 @@ export async function collectBackgroundJobUiKillMutations({ session, projectInde
|
|
|
151
122
|
backgroundCommandTrackers.delete(normalizedJobId);
|
|
152
123
|
}
|
|
153
124
|
}
|
|
154
|
-
export async function collectBackgroundJobUiOutputMutations({ session,
|
|
125
|
+
export async function collectBackgroundJobUiOutputMutations({ session, jobId, }) {
|
|
155
126
|
const normalizedJobId = String(jobId ?? '').trim();
|
|
156
127
|
if (!normalizedJobId)
|
|
157
128
|
return;
|
|
@@ -165,7 +136,6 @@ export async function collectBackgroundJobUiOutputMutations({ session, projectIn
|
|
|
165
136
|
return;
|
|
166
137
|
await collectTrackedCommandMutations({
|
|
167
138
|
session,
|
|
168
|
-
projectIndex,
|
|
169
139
|
result: {},
|
|
170
140
|
tracker: tracked.tracker,
|
|
171
141
|
toolName: tracked.toolName,
|
|
@@ -244,8 +214,10 @@ function recordAssistantEdit(session, call, result, before) {
|
|
|
244
214
|
});
|
|
245
215
|
clearEditFailure(session.clientState.safety, filePath);
|
|
246
216
|
}
|
|
247
|
-
export async function executeLocalToolCall(
|
|
248
|
-
session.
|
|
217
|
+
export async function executeLocalToolCall(session, call, diagnosticsPlan) {
|
|
218
|
+
session.turnAbortSignal?.throwIfAborted();
|
|
219
|
+
session.onToolStart?.(call);
|
|
220
|
+
session.onStatus(formatToolCallForStatus(call, session.mcp?.label(call.name)));
|
|
249
221
|
try {
|
|
250
222
|
const agentModeBlocked = buildAgentModeToolBlockedResult(session.agentMode, call);
|
|
251
223
|
if (agentModeBlocked) {
|
|
@@ -253,6 +225,11 @@ export async function executeLocalToolCall(toolContext, session, call) {
|
|
|
253
225
|
session.onToolEvent?.({ call, result });
|
|
254
226
|
return result;
|
|
255
227
|
}
|
|
228
|
+
if (isMcpToolName(call.name)) {
|
|
229
|
+
const result = await sessionMcp(session).execute(session, call);
|
|
230
|
+
session.onToolEvent?.({ call, result });
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
256
233
|
const rawEditFilePath = isEditToolName(call.name)
|
|
257
234
|
? getEditToolFilePath(call)
|
|
258
235
|
: '';
|
|
@@ -275,17 +252,21 @@ export async function executeLocalToolCall(toolContext, session, call) {
|
|
|
275
252
|
const context = {
|
|
276
253
|
rootDir: session.rootDir,
|
|
277
254
|
sessionId: session.sessionId,
|
|
278
|
-
projectIndex: toolContext.projectIndex,
|
|
279
255
|
autoYes: session.autoYes,
|
|
280
|
-
|
|
281
|
-
|
|
256
|
+
agentMode: session.agentMode,
|
|
257
|
+
grants: session.grants,
|
|
258
|
+
requestPermission: session.requestPermission,
|
|
282
259
|
requestSudoPassword: session.requestSudoPassword,
|
|
260
|
+
requestUserInput: session.requestUserInput
|
|
261
|
+
? (request) => session.requestUserInput(request, session.turnAbortSignal)
|
|
262
|
+
: null,
|
|
283
263
|
onStatus: session.onStatus,
|
|
284
264
|
editJournal: session.clientState.editJournal,
|
|
285
265
|
safety: session.clientState.safety,
|
|
286
266
|
currentTurnId: session.turnState.id,
|
|
287
267
|
currentToolCallId: call.id,
|
|
288
268
|
env: session.env,
|
|
269
|
+
diagnosticsPlan,
|
|
289
270
|
markEditReverted: (editId, toolCallId) => {
|
|
290
271
|
const record = session.clientState.editJournal.find((entry) => entry.id === editId);
|
|
291
272
|
if (record) {
|
|
@@ -295,11 +276,11 @@ export async function executeLocalToolCall(toolContext, session, call) {
|
|
|
295
276
|
},
|
|
296
277
|
};
|
|
297
278
|
const result = await dispatchTool(context, call);
|
|
279
|
+
await checkBatchWhenLastEditDidNot(session, result, diagnosticsPlan);
|
|
298
280
|
recordAssistantEdit(session, call, result, beforeEditSnapshot);
|
|
299
281
|
if (result && typeof result === 'object' && commandTracker) {
|
|
300
282
|
await collectTrackedCommandMutations({
|
|
301
283
|
session,
|
|
302
|
-
projectIndex: toolContext.projectIndex,
|
|
303
284
|
result,
|
|
304
285
|
tracker: commandTracker,
|
|
305
286
|
toolName: call.name,
|
|
@@ -326,7 +307,6 @@ export async function executeLocalToolCall(toolContext, session, call) {
|
|
|
326
307
|
if (tracked) {
|
|
327
308
|
await collectTrackedCommandMutations({
|
|
328
309
|
session,
|
|
329
|
-
projectIndex: toolContext.projectIndex,
|
|
330
310
|
result,
|
|
331
311
|
tracker: tracked.tracker,
|
|
332
312
|
toolName: tracked.toolName,
|
|
@@ -363,7 +343,18 @@ export async function executeLocalToolCall(toolContext, session, call) {
|
|
|
363
343
|
},
|
|
364
344
|
error: error instanceof Error ? error.message : String(error),
|
|
365
345
|
};
|
|
346
|
+
await checkBatchWhenLastEditDidNot(session, result, diagnosticsPlan);
|
|
366
347
|
session.onToolEvent?.({ call, result });
|
|
367
348
|
return result;
|
|
368
349
|
}
|
|
369
350
|
}
|
|
351
|
+
export async function checkBatchWhenLastEditDidNot(session, result, plan) {
|
|
352
|
+
if (!plan?.files?.length || !result || typeof result !== 'object')
|
|
353
|
+
return;
|
|
354
|
+
if (session.turnAbortSignal?.aborted)
|
|
355
|
+
return;
|
|
356
|
+
const existing = result.diagnostics;
|
|
357
|
+
if (existing && typeof existing.available === 'boolean')
|
|
358
|
+
return;
|
|
359
|
+
result.diagnostics = await runBatchDiagnostics(session.rootDir, plan.files);
|
|
360
|
+
}
|