@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
|
@@ -2,13 +2,48 @@ import chalk from '../colors.js';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { normalizeProjectRelativePath } from '../artifact-policy.js';
|
|
4
4
|
import { classifyProjectPath, writeProjectFile } from '../patcher.js';
|
|
5
|
-
import {
|
|
5
|
+
import { readFileEditSnapshot } from '../edit-journal.js';
|
|
6
6
|
import { isTuiMode } from '../runtime-mode.js';
|
|
7
7
|
import { getCurrentFileHash, hasFreshFullReadCoverage, resolveRedactionTokens, } from '../session-safety.js';
|
|
8
|
-
import {
|
|
8
|
+
import { diagnoseEditedFile } from './shell-diagnostics.js';
|
|
9
|
+
import { ensurePermission } from '../permissions.js';
|
|
9
10
|
const DOCUMENT_EXTENSIONS = new Set(['.pdf', '.xlsx', '.docx']);
|
|
11
|
+
const MAX_WRITE_PREVIEW_LINES = 400;
|
|
12
|
+
function boundedLines(text, limit) {
|
|
13
|
+
const lines = [];
|
|
14
|
+
let omitted = 0;
|
|
15
|
+
let start = 0;
|
|
16
|
+
for (;;) {
|
|
17
|
+
const newline = text.indexOf('\n', start);
|
|
18
|
+
if (lines.length < limit) {
|
|
19
|
+
lines.push(text.slice(start, newline === -1 ? undefined : newline));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
omitted += 1;
|
|
23
|
+
}
|
|
24
|
+
if (newline === -1)
|
|
25
|
+
break;
|
|
26
|
+
start = newline + 1;
|
|
27
|
+
}
|
|
28
|
+
return { lines, omitted };
|
|
29
|
+
}
|
|
30
|
+
function buildWritePreview(previous, next) {
|
|
31
|
+
const rows = ['@@ write_file @@'];
|
|
32
|
+
const append = (text, sign, marker) => {
|
|
33
|
+
const { lines, omitted } = boundedLines(text, MAX_WRITE_PREVIEW_LINES);
|
|
34
|
+
for (const line of lines)
|
|
35
|
+
rows.push(`${sign}${line}`);
|
|
36
|
+
if (omitted > 0) {
|
|
37
|
+
rows.push(`@@ ${omitted} more ${marker} line(s) not shown @@`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if (previous !== null)
|
|
41
|
+
append(previous, '-', 'removed');
|
|
42
|
+
append(next, '+', 'added');
|
|
43
|
+
return rows.join('\n');
|
|
44
|
+
}
|
|
10
45
|
export async function writeFile(context, args) {
|
|
11
|
-
const { rootDir
|
|
46
|
+
const { rootDir } = context;
|
|
12
47
|
const filePath = String(args.filePath ?? '').trim();
|
|
13
48
|
let content = typeof args.content === 'string' ? args.content : '';
|
|
14
49
|
if (!filePath) {
|
|
@@ -60,18 +95,40 @@ export async function writeFile(context, args) {
|
|
|
60
95
|
};
|
|
61
96
|
}
|
|
62
97
|
content = resolveRedactionTokens(context.safety, content, coveragePath, currentHash);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
if (!scratchPath) {
|
|
99
|
+
const before = currentHash === null ? null : readFileEditSnapshot(rootDir, filePath);
|
|
100
|
+
const existing = before && before.contentEncoding === 'utf8' ? before.content : null;
|
|
101
|
+
const denied = await ensurePermission(context, {
|
|
102
|
+
bucket: currentHash === null ? 'create' : 'edit',
|
|
103
|
+
title: currentHash === null ? 'Approve new file?' : 'Approve patch?',
|
|
104
|
+
body: 'Review changes before applying.',
|
|
105
|
+
filePath,
|
|
106
|
+
diff: buildWritePreview(existing, content),
|
|
107
|
+
}, 'write_file', { filePath });
|
|
108
|
+
if (denied) {
|
|
109
|
+
if (!isTuiMode())
|
|
110
|
+
console.log(chalk.dim(` ⏭ write_file skipped: ${filePath}`));
|
|
111
|
+
return denied;
|
|
112
|
+
}
|
|
113
|
+
if (getCurrentFileHash(rootDir, filePath) !== currentHash) {
|
|
114
|
+
return {
|
|
115
|
+
ok: false,
|
|
116
|
+
filePath,
|
|
117
|
+
failureCategory: 'conflict',
|
|
118
|
+
error: `write_file refused: ${filePath} changed on disk while the approval prompt was open.`,
|
|
119
|
+
failureDetails: {
|
|
120
|
+
category: 'conflict',
|
|
121
|
+
tool: 'write_file',
|
|
122
|
+
action: 'Re-read the file to see its current contents, then decide whether the write is still correct and retry.',
|
|
123
|
+
},
|
|
124
|
+
currentHash,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
70
127
|
}
|
|
128
|
+
const { changed } = writeProjectFile(rootDir, filePath, content);
|
|
71
129
|
let diagnostics;
|
|
72
130
|
if (!scratchPath) {
|
|
73
|
-
|
|
74
|
-
diagnostics = runShellDiagnostics(rootDir, filePath);
|
|
131
|
+
diagnostics = await diagnoseEditedFile(rootDir, filePath, 'write_file', context.diagnosticsPlan);
|
|
75
132
|
}
|
|
76
133
|
if (!isTuiMode()) {
|
|
77
134
|
const icon = changed ? '✨' : '📝';
|
|
@@ -84,8 +141,6 @@ export async function writeFile(context, args) {
|
|
|
84
141
|
changed,
|
|
85
142
|
operation: 'write',
|
|
86
143
|
...(scratchPath ? { scratch: true } : {}),
|
|
87
|
-
indexedChunks,
|
|
88
|
-
retrievalTokensUsed,
|
|
89
144
|
bytesWritten: Buffer.byteLength(content, 'utf-8'),
|
|
90
145
|
diagnostics,
|
|
91
146
|
};
|