@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
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegitai/cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "TheGitAI is an AI coding
|
|
3
|
+
"version": "1.0.1",
|
|
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
|
-
"ai",
|
|
6
|
+
"agentic-ai",
|
|
7
7
|
"ai-coding-agent",
|
|
8
8
|
"coding-agent",
|
|
9
|
+
"ai-agent",
|
|
10
|
+
"agentic-coding",
|
|
11
|
+
"autonomous-agent",
|
|
12
|
+
"ai-pair-programming",
|
|
9
13
|
"coding-assistant",
|
|
14
|
+
"code-assistant",
|
|
15
|
+
"ai",
|
|
10
16
|
"terminal",
|
|
11
17
|
"cli",
|
|
12
18
|
"developer-tools"
|
|
@@ -14,14 +20,16 @@
|
|
|
14
20
|
"license": "SEE LICENSE IN LICENSE",
|
|
15
21
|
"homepage": "https://thegit.ai",
|
|
16
22
|
"bugs": {
|
|
23
|
+
"url": "https://github.com/thegitai/thegitai-cli/issues",
|
|
17
24
|
"email": "support@thegit.ai"
|
|
18
25
|
},
|
|
19
26
|
"type": "module",
|
|
20
27
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
28
|
+
"node": ">=22"
|
|
22
29
|
},
|
|
23
30
|
"bin": {
|
|
24
|
-
"ai": "./dist/bin/ai.js"
|
|
31
|
+
"ai": "./dist/bin/ai.js",
|
|
32
|
+
"thegitai": "./dist/bin/ai.js"
|
|
25
33
|
},
|
|
26
34
|
"files": [
|
|
27
35
|
"dist",
|
|
@@ -37,12 +45,17 @@
|
|
|
37
45
|
"@lydell/node-pty-linux-x64": "1.1.0",
|
|
38
46
|
"@lydell/node-pty-win32-arm64": "1.1.0",
|
|
39
47
|
"@lydell/node-pty-win32-x64": "1.1.0",
|
|
40
|
-
"@thegitai/tui-darwin-arm64": "1.0.
|
|
41
|
-
"@thegitai/tui-darwin-x64": "1.0.
|
|
42
|
-
"@thegitai/tui-linux-
|
|
43
|
-
"@thegitai/tui-
|
|
48
|
+
"@thegitai/tui-darwin-arm64": "1.0.1",
|
|
49
|
+
"@thegitai/tui-darwin-x64": "1.0.1",
|
|
50
|
+
"@thegitai/tui-linux-arm64": "1.0.1",
|
|
51
|
+
"@thegitai/tui-linux-x64": "1.0.1",
|
|
52
|
+
"@thegitai/tui-win32-x64": "1.0.1",
|
|
44
53
|
"@vscode/ripgrep": "1.18.0"
|
|
45
54
|
},
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/thegitai/thegitai-cli.git"
|
|
58
|
+
},
|
|
46
59
|
"publishConfig": {
|
|
47
60
|
"access": "public"
|
|
48
61
|
}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { existsSync, statSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { listProjectFiles, scanFiles, shouldIgnorePath, } from './scanner.js';
|
|
4
|
-
import { truncate } from './utils.js';
|
|
5
|
-
function normalizeProjectFilePath(rootDir, filePath) {
|
|
6
|
-
const resolvedRoot = path.resolve(rootDir);
|
|
7
|
-
const resolvedFile = path.resolve(resolvedRoot, filePath);
|
|
8
|
-
const relative = path.relative(resolvedRoot, resolvedFile);
|
|
9
|
-
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return relative.replace(/\\/g, '/');
|
|
13
|
-
}
|
|
14
|
-
function getFileSignature(rootDir, relPath) {
|
|
15
|
-
try {
|
|
16
|
-
const stat = statSync(path.join(rootDir, relPath));
|
|
17
|
-
if (!stat.isFile()) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return `${stat.size}:${stat.mtimeMs}`;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function setChunksForFile(index, relPath, chunks) {
|
|
27
|
-
if (chunks.length === 0) {
|
|
28
|
-
index.chunksByFile.delete(relPath);
|
|
29
|
-
index.fileSignatures.delete(relPath);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
index.chunksByFile.set(relPath, chunks);
|
|
33
|
-
const signature = getFileSignature(index.rootDir, relPath);
|
|
34
|
-
if (signature) {
|
|
35
|
-
index.fileSignatures.set(relPath, signature);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function removeFile(index, relPath) {
|
|
39
|
-
index.chunksByFile.delete(relPath);
|
|
40
|
-
index.fileSignatures.delete(relPath);
|
|
41
|
-
}
|
|
42
|
-
function countIndexedChunks(index) {
|
|
43
|
-
return Array.from(index.chunksByFile.values()).reduce((sum, chunks) => sum + chunks.length, 0);
|
|
44
|
-
}
|
|
45
|
-
async function initializeIndex(index) {
|
|
46
|
-
if (index.initialized) {
|
|
47
|
-
return countIndexedChunks(index);
|
|
48
|
-
}
|
|
49
|
-
if (!index._initializing) {
|
|
50
|
-
index._initializing = scanProjectIntoIndex(index).finally(() => {
|
|
51
|
-
index._initializing = null;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return index._initializing;
|
|
55
|
-
}
|
|
56
|
-
async function scanProjectIntoIndex(index) {
|
|
57
|
-
const files = listProjectFiles(index.rootDir);
|
|
58
|
-
const chunks = await scanFiles(index.rootDir, files);
|
|
59
|
-
index.fileSignatures.clear();
|
|
60
|
-
index.chunksByFile.clear();
|
|
61
|
-
for (const filePath of files) {
|
|
62
|
-
const signature = getFileSignature(index.rootDir, filePath);
|
|
63
|
-
if (signature) {
|
|
64
|
-
index.fileSignatures.set(filePath, signature);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
for (const chunk of chunks) {
|
|
68
|
-
const current = index.chunksByFile.get(chunk.filePath) ?? [];
|
|
69
|
-
current.push(chunk);
|
|
70
|
-
index.chunksByFile.set(chunk.filePath, current);
|
|
71
|
-
}
|
|
72
|
-
index.initialized = true;
|
|
73
|
-
index.onStatus?.(`Local code index ready: ${index.fileSignatures.size.toLocaleString()} files.`);
|
|
74
|
-
return chunks.length;
|
|
75
|
-
}
|
|
76
|
-
function queryTerms(query) {
|
|
77
|
-
const parts = query
|
|
78
|
-
.toLowerCase()
|
|
79
|
-
.split(/[^a-z0-9_./-]+/i)
|
|
80
|
-
.map((part) => part.trim())
|
|
81
|
-
.filter(Boolean);
|
|
82
|
-
return [...new Set(parts)];
|
|
83
|
-
}
|
|
84
|
-
function countOccurrences(haystack, needle) {
|
|
85
|
-
if (!needle)
|
|
86
|
-
return 0;
|
|
87
|
-
let count = 0;
|
|
88
|
-
let cursor = 0;
|
|
89
|
-
while (cursor < haystack.length) {
|
|
90
|
-
const index = haystack.indexOf(needle, cursor);
|
|
91
|
-
if (index === -1)
|
|
92
|
-
break;
|
|
93
|
-
count += 1;
|
|
94
|
-
cursor = index + needle.length;
|
|
95
|
-
}
|
|
96
|
-
return count;
|
|
97
|
-
}
|
|
98
|
-
function scoreChunk(terms, chunk) {
|
|
99
|
-
const filePath = chunk.filePath.toLowerCase();
|
|
100
|
-
const content = chunk.content.toLowerCase();
|
|
101
|
-
let score = 0;
|
|
102
|
-
for (const term of terms) {
|
|
103
|
-
if (term.length < 2)
|
|
104
|
-
continue;
|
|
105
|
-
score += countOccurrences(filePath, term) * 3;
|
|
106
|
-
score += countOccurrences(content, term);
|
|
107
|
-
if (chunk.label?.toLowerCase().includes(term)) {
|
|
108
|
-
score += 2;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return score;
|
|
112
|
-
}
|
|
113
|
-
function flattenChunks(index) {
|
|
114
|
-
return Array.from(index.chunksByFile.values()).flat();
|
|
115
|
-
}
|
|
116
|
-
export function createIndex({ rootDir, onStatus = null, onContextLog = null, }) {
|
|
117
|
-
return {
|
|
118
|
-
rootDir: path.resolve(rootDir),
|
|
119
|
-
initialized: false,
|
|
120
|
-
_initializing: null,
|
|
121
|
-
fileSignatures: new Map(),
|
|
122
|
-
chunksByFile: new Map(),
|
|
123
|
-
onStatus,
|
|
124
|
-
onContextLog,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
export async function searchIndex(index, query, limit = 10) {
|
|
128
|
-
await initializeIndex(index);
|
|
129
|
-
const terms = queryTerms(query);
|
|
130
|
-
if (terms.length === 0) {
|
|
131
|
-
return { results: [], retrievalTokensUsed: 0 };
|
|
132
|
-
}
|
|
133
|
-
const scored = flattenChunks(index)
|
|
134
|
-
.map((chunk) => ({
|
|
135
|
-
...chunk,
|
|
136
|
-
score: scoreChunk(terms, chunk),
|
|
137
|
-
}))
|
|
138
|
-
.filter((chunk) => chunk.score > 0)
|
|
139
|
-
.sort((a, b) => b.score - a.score || a.filePath.localeCompare(b.filePath))
|
|
140
|
-
.slice(0, Math.max(1, Math.min(limit, 20)));
|
|
141
|
-
if (scored.length) {
|
|
142
|
-
const visible = scored
|
|
143
|
-
.slice(0, 6)
|
|
144
|
-
.map((chunk) => `${chunk.filePath}:${chunk.startLine}-${chunk.endLine}`)
|
|
145
|
-
.join(', ');
|
|
146
|
-
index.onContextLog?.(`Local search hit: ${visible}`);
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
results: scored,
|
|
150
|
-
retrievalTokensUsed: 0,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
export function formatIndexResults(results) {
|
|
154
|
-
return results.map((chunk) => ({
|
|
155
|
-
...chunk,
|
|
156
|
-
content: truncate(chunk.content, 1200),
|
|
157
|
-
}));
|
|
158
|
-
}
|
|
159
|
-
export function listIndexFiles(index) {
|
|
160
|
-
return [...index.fileSignatures.keys()].sort();
|
|
161
|
-
}
|
|
162
|
-
export async function upsertIndexFile(index, filePath) {
|
|
163
|
-
if (!index.initialized) {
|
|
164
|
-
return { indexedChunks: 0, retrievalTokensUsed: 0 };
|
|
165
|
-
}
|
|
166
|
-
const relPath = normalizeProjectFilePath(index.rootDir, filePath);
|
|
167
|
-
if (!relPath || shouldIgnorePath(relPath)) {
|
|
168
|
-
return { indexedChunks: 0, retrievalTokensUsed: 0 };
|
|
169
|
-
}
|
|
170
|
-
const chunks = existsSync(path.join(index.rootDir, relPath))
|
|
171
|
-
? await scanFiles(index.rootDir, [relPath])
|
|
172
|
-
: [];
|
|
173
|
-
setChunksForFile(index, relPath, chunks);
|
|
174
|
-
return {
|
|
175
|
-
indexedChunks: chunks.length,
|
|
176
|
-
retrievalTokensUsed: 0,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
export async function removeIndexFile(index, filePath) {
|
|
180
|
-
const relPath = normalizeProjectFilePath(index.rootDir, filePath);
|
|
181
|
-
if (!relPath)
|
|
182
|
-
return;
|
|
183
|
-
removeFile(index, relPath);
|
|
184
|
-
}
|
|
185
|
-
export async function syncIndexFromDisk(index) {
|
|
186
|
-
if (!index.initialized) {
|
|
187
|
-
const indexedChunks = await initializeIndex(index);
|
|
188
|
-
return {
|
|
189
|
-
added: index.fileSignatures.size,
|
|
190
|
-
modified: 0,
|
|
191
|
-
removed: 0,
|
|
192
|
-
indexedChunks,
|
|
193
|
-
retrievalTokensUsed: 0,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
const currentFiles = new Set(listProjectFiles(index.rootDir));
|
|
197
|
-
let added = 0;
|
|
198
|
-
let modified = 0;
|
|
199
|
-
let removed = 0;
|
|
200
|
-
let indexedChunks = 0;
|
|
201
|
-
for (const existing of [...index.fileSignatures.keys()]) {
|
|
202
|
-
if (!currentFiles.has(existing)) {
|
|
203
|
-
removeFile(index, existing);
|
|
204
|
-
removed += 1;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
for (const relPath of currentFiles) {
|
|
208
|
-
const nextSignature = getFileSignature(index.rootDir, relPath);
|
|
209
|
-
if (!nextSignature)
|
|
210
|
-
continue;
|
|
211
|
-
const previousSignature = index.fileSignatures.get(relPath);
|
|
212
|
-
if (!previousSignature) {
|
|
213
|
-
const chunks = await scanFiles(index.rootDir, [relPath]);
|
|
214
|
-
setChunksForFile(index, relPath, chunks);
|
|
215
|
-
added += 1;
|
|
216
|
-
indexedChunks += chunks.length;
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
if (previousSignature !== nextSignature) {
|
|
220
|
-
const chunks = await scanFiles(index.rootDir, [relPath]);
|
|
221
|
-
setChunksForFile(index, relPath, chunks);
|
|
222
|
-
modified += 1;
|
|
223
|
-
indexedChunks += chunks.length;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return {
|
|
227
|
-
added,
|
|
228
|
-
modified,
|
|
229
|
-
removed,
|
|
230
|
-
indexedChunks,
|
|
231
|
-
retrievalTokensUsed: 0,
|
|
232
|
-
};
|
|
233
|
-
}
|