codebuff 1.0.251 → 1.0.252
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/dist/background-process-manager.d.ts +50 -0
- package/dist/background-process-manager.js +359 -0
- package/dist/background-process-manager.js.map +1 -0
- package/dist/browser-runner.d.ts +35 -0
- package/dist/browser-runner.js +680 -0
- package/dist/browser-runner.js.map +1 -0
- package/dist/chat-storage.d.ts +2 -0
- package/dist/chat-storage.js +93 -0
- package/dist/chat-storage.js.map +1 -0
- package/dist/checkpoints/checkpoint-manager.d.ts +94 -0
- package/dist/checkpoints/checkpoint-manager.js +280 -0
- package/dist/checkpoints/checkpoint-manager.js.map +1 -0
- package/dist/checkpoints/file-manager.d.ts +72 -0
- package/dist/checkpoints/file-manager.js +311 -0
- package/dist/checkpoints/file-manager.js.map +1 -0
- package/dist/cli-handlers/api-key.d.ts +25 -0
- package/dist/cli-handlers/api-key.js +66 -0
- package/dist/cli-handlers/api-key.js.map +1 -0
- package/dist/cli-handlers/checkpoint.d.ts +18 -0
- package/dist/cli-handlers/checkpoint.js +195 -0
- package/dist/cli-handlers/checkpoint.js.map +1 -0
- package/dist/cli-handlers/diff.d.ts +2 -0
- package/dist/cli-handlers/diff.js +31 -0
- package/dist/cli-handlers/diff.js.map +1 -0
- package/dist/cli-handlers/easter-egg.d.ts +1 -0
- package/dist/cli-handlers/easter-egg.js +126 -0
- package/dist/cli-handlers/easter-egg.js.map +1 -0
- package/dist/cli-handlers/inititalization-flow.d.ts +1 -0
- package/dist/cli-handlers/inititalization-flow.js +24 -0
- package/dist/cli-handlers/inititalization-flow.js.map +1 -0
- package/dist/cli.d.ts +44 -0
- package/dist/cli.js +478 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +157 -0
- package/dist/client.js +836 -0
- package/dist/client.js.map +1 -0
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/create-template-project.d.ts +1 -0
- package/dist/create-template-project.js +107 -0
- package/dist/create-template-project.js.map +1 -0
- package/dist/credentials.d.ts +4 -0
- package/dist/credentials.js +38 -0
- package/dist/credentials.js.map +1 -0
- package/dist/dev-process-manager.d.ts +10 -0
- package/dist/dev-process-manager.js +54 -0
- package/dist/dev-process-manager.js.map +1 -0
- package/dist/fingerprint.d.ts +1 -0
- package/dist/fingerprint.js +48 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +117 -0
- package/dist/index.js.map +1 -0
- package/dist/menu.d.ts +3 -0
- package/dist/menu.js +126 -0
- package/dist/menu.js.map +1 -0
- package/dist/project-files.d.ts +114 -0
- package/dist/project-files.js +513 -0
- package/dist/project-files.js.map +1 -0
- package/dist/startup-process-handler.d.ts +2 -0
- package/dist/startup-process-handler.js +21 -0
- package/dist/startup-process-handler.js.map +1 -0
- package/dist/tool-handlers.d.ts +28 -0
- package/dist/tool-handlers.js +240 -0
- package/dist/tool-handlers.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/update-codebuff.d.ts +1 -0
- package/dist/update-codebuff.js +160 -0
- package/dist/update-codebuff.js.map +1 -0
- package/dist/utils/__tests__/background-process-manager.test.d.ts +1 -0
- package/dist/utils/__tests__/background-process-manager.test.js +289 -0
- package/dist/utils/__tests__/background-process-manager.test.js.map +1 -0
- package/dist/utils/__tests__/tool-renderers.test.d.ts +1 -0
- package/dist/utils/__tests__/tool-renderers.test.js +51 -0
- package/dist/utils/__tests__/tool-renderers.test.js.map +1 -0
- package/dist/utils/__tests__/xml-stream-parser.test.d.ts +1 -0
- package/dist/utils/__tests__/xml-stream-parser.test.js +229 -0
- package/dist/utils/__tests__/xml-stream-parser.test.js.map +1 -0
- package/dist/utils/analytics.d.ts +6 -0
- package/dist/utils/analytics.js +59 -0
- package/dist/utils/analytics.js.map +1 -0
- package/dist/utils/detect-shell.d.ts +1 -0
- package/dist/utils/detect-shell.js +60 -0
- package/dist/utils/detect-shell.js.map +1 -0
- package/dist/utils/logger.d.ts +21 -0
- package/dist/utils/logger.js +105 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/spinner.d.ts +11 -0
- package/dist/utils/spinner.js +87 -0
- package/dist/utils/spinner.js.map +1 -0
- package/dist/utils/system-info.d.ts +8 -0
- package/dist/utils/system-info.js +22 -0
- package/dist/utils/system-info.js.map +1 -0
- package/dist/utils/terminal.d.ts +41 -0
- package/dist/utils/terminal.js +474 -0
- package/dist/utils/terminal.js.map +1 -0
- package/dist/utils/tool-renderers.d.ts +16 -0
- package/dist/utils/tool-renderers.js +145 -0
- package/dist/utils/tool-renderers.js.map +1 -0
- package/dist/utils/xml-stream-parser.d.ts +9 -0
- package/dist/utils/xml-stream-parser.js +128 -0
- package/dist/utils/xml-stream-parser.js.map +1 -0
- package/dist/web-scraper.d.ts +3 -0
- package/dist/web-scraper.js +57 -0
- package/dist/web-scraper.js.map +1 -0
- package/dist/workers/checkpoint-worker.d.ts +1 -0
- package/dist/workers/checkpoint-worker.js +48 -0
- package/dist/workers/checkpoint-worker.js.map +1 -0
- package/dist/workers/project-context.d.ts +1 -0
- package/dist/workers/project-context.js +17 -0
- package/dist/workers/project-context.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fs = void 0;
|
|
7
|
+
exports.getBareRepoPath = getBareRepoPath;
|
|
8
|
+
exports.hasUnsavedChanges = hasUnsavedChanges;
|
|
9
|
+
exports.getLatestCommit = getLatestCommit;
|
|
10
|
+
exports.initializeCheckpointFileManager = initializeCheckpointFileManager;
|
|
11
|
+
exports.storeFileState = storeFileState;
|
|
12
|
+
exports.restoreFileState = restoreFileState;
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const crypto_1 = require("crypto");
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
exports.fs = fs_1.default;
|
|
17
|
+
const os_1 = __importDefault(require("os"));
|
|
18
|
+
const path_1 = require("path");
|
|
19
|
+
const isomorphic_git_1 = require("isomorphic-git");
|
|
20
|
+
const project_files_1 = require("../project-files");
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the native git command is available on the system.
|
|
23
|
+
* Caches the result to avoid repeated checks.
|
|
24
|
+
* @returns boolean indicating if git command is available
|
|
25
|
+
*/
|
|
26
|
+
let cachedGitAvailable = null;
|
|
27
|
+
function gitCommandIsAvailable() {
|
|
28
|
+
if (cachedGitAvailable === null) {
|
|
29
|
+
try {
|
|
30
|
+
(0, child_process_1.execFileSync)('git', ['--version'], { stdio: 'ignore' });
|
|
31
|
+
cachedGitAvailable = true;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
cachedGitAvailable = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return cachedGitAvailable;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generates a unique path for storing the bare git repository based on the project directory.
|
|
41
|
+
* Uses SHA-256 hashing to create a unique identifier.
|
|
42
|
+
* @param dir - The project directory path to hash
|
|
43
|
+
* @returns The full path where the bare repo should be stored
|
|
44
|
+
*/
|
|
45
|
+
function getBareRepoPath(dir) {
|
|
46
|
+
const bareRepoName = (0, crypto_1.createHash)('sha256').update(dir).digest('hex');
|
|
47
|
+
return (0, path_1.join)((0, project_files_1.getProjectDataDir)(), bareRepoName);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Checks if there are any uncommitted changes in the working directory.
|
|
51
|
+
* First attempts to use native git commands, falling back to isomorphic-git if unavailable.
|
|
52
|
+
* @param projectDir - The working tree directory path
|
|
53
|
+
* @param bareRepoPath - The bare git repository path
|
|
54
|
+
* @param relativeFilepaths - Array of file paths relative to projectDir to check
|
|
55
|
+
* @returns Promise resolving to true if there are uncommitted changes, false otherwise
|
|
56
|
+
*/
|
|
57
|
+
async function hasUnsavedChanges({ projectDir, bareRepoPath, relativeFilepaths, }) {
|
|
58
|
+
if (gitCommandIsAvailable()) {
|
|
59
|
+
try {
|
|
60
|
+
const output = (0, child_process_1.execFileSync)('git', [
|
|
61
|
+
'--git-dir',
|
|
62
|
+
bareRepoPath,
|
|
63
|
+
'--work-tree',
|
|
64
|
+
projectDir,
|
|
65
|
+
'status',
|
|
66
|
+
'--porcelain',
|
|
67
|
+
], { stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
68
|
+
return output.trim().length > 0;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// error running git
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const [, , workdirStatus, stageStatus] of await (0, isomorphic_git_1.statusMatrix)({
|
|
75
|
+
fs: fs_1.default,
|
|
76
|
+
dir: projectDir,
|
|
77
|
+
gitdir: bareRepoPath,
|
|
78
|
+
filepaths: relativeFilepaths,
|
|
79
|
+
})) {
|
|
80
|
+
if (workdirStatus !== stageStatus) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Gets the hash of the latest commit in the repository.
|
|
88
|
+
* First attempts to use native git commands, falling back to isomorphic-git if unavailable.
|
|
89
|
+
* @param bareRepoPath - The bare git repository path
|
|
90
|
+
* @returns Promise resolving to the commit hash
|
|
91
|
+
*/
|
|
92
|
+
async function getLatestCommit({ bareRepoPath, }) {
|
|
93
|
+
if (gitCommandIsAvailable()) {
|
|
94
|
+
try {
|
|
95
|
+
return (0, child_process_1.execFileSync)('git', ['--git-dir', bareRepoPath, 'rev-parse', 'HEAD'], { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
96
|
+
.toString()
|
|
97
|
+
.trim();
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// unable to get head
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return await (0, isomorphic_git_1.resolveRef)({
|
|
104
|
+
fs: fs_1.default,
|
|
105
|
+
gitdir: bareRepoPath,
|
|
106
|
+
ref: 'HEAD',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Initializes a bare git repository for tracking file changes.
|
|
111
|
+
* Creates the repository if it doesn't exist, otherwise uses the existing one.
|
|
112
|
+
* Makes an initial commit of the current file state.
|
|
113
|
+
* @param projectDir - The working tree directory path
|
|
114
|
+
* @param relativeFilepaths - Array of file paths relative to projectDir to track
|
|
115
|
+
*/
|
|
116
|
+
async function initializeCheckpointFileManager({ projectDir, relativeFilepaths, }) {
|
|
117
|
+
if (projectDir === os_1.default.homedir()) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const bareRepoPath = getBareRepoPath(projectDir);
|
|
121
|
+
// Create the bare repo directory if it doesn't exist
|
|
122
|
+
fs_1.default.mkdirSync(bareRepoPath, { recursive: true });
|
|
123
|
+
try {
|
|
124
|
+
// Check if it's already a valid Git repo
|
|
125
|
+
await (0, isomorphic_git_1.resolveRef)({ fs: fs_1.default, gitdir: bareRepoPath, ref: 'HEAD' });
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
// Bare repo doesn't exist yet
|
|
129
|
+
await (0, isomorphic_git_1.init)({
|
|
130
|
+
fs: fs_1.default,
|
|
131
|
+
dir: projectDir,
|
|
132
|
+
gitdir: bareRepoPath,
|
|
133
|
+
bare: true,
|
|
134
|
+
defaultBranch: 'master',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
// Commit the files in the bare repo
|
|
138
|
+
await storeFileState({
|
|
139
|
+
projectDir,
|
|
140
|
+
bareRepoPath,
|
|
141
|
+
message: 'Initial Commit',
|
|
142
|
+
relativeFilepaths,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Stages all changes in the working directory.
|
|
147
|
+
* First attempts to use native git commands, falling back to isomorphic-git if unavailable.
|
|
148
|
+
* @param projectDir - The working tree directory path
|
|
149
|
+
* @param bareRepoPath - The bare git repository path
|
|
150
|
+
* @param relativeFilepaths - Array of file paths relative to projectDir to stage
|
|
151
|
+
*/
|
|
152
|
+
async function gitAddAll({ projectDir, bareRepoPath, relativeFilepaths, }) {
|
|
153
|
+
if (gitCommandIsAvailable()) {
|
|
154
|
+
try {
|
|
155
|
+
(0, child_process_1.execFileSync)('git', [
|
|
156
|
+
'--git-dir',
|
|
157
|
+
bareRepoPath,
|
|
158
|
+
'--work-tree',
|
|
159
|
+
projectDir,
|
|
160
|
+
'-C',
|
|
161
|
+
projectDir,
|
|
162
|
+
'add',
|
|
163
|
+
'.',
|
|
164
|
+
], { stdio: 'ignore' });
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
// Failed to `git add .`
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Stage files with isomorphic-git
|
|
172
|
+
// Get status of all files in the project directory
|
|
173
|
+
const currStatusMatrix = (await (0, isomorphic_git_1.statusMatrix)({
|
|
174
|
+
fs: fs_1.default,
|
|
175
|
+
dir: projectDir,
|
|
176
|
+
gitdir: bareRepoPath,
|
|
177
|
+
filepaths: relativeFilepaths,
|
|
178
|
+
})) ?? [];
|
|
179
|
+
for (const [filepath, , workdirStatus, stageStatus] of currStatusMatrix) {
|
|
180
|
+
if (workdirStatus === stageStatus) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (workdirStatus === 2) {
|
|
184
|
+
// Existing file different from HEAD
|
|
185
|
+
try {
|
|
186
|
+
await (0, isomorphic_git_1.add)({ fs: fs_1.default, dir: projectDir, gitdir: bareRepoPath, filepath });
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
// error adding files
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else if (workdirStatus === 0) {
|
|
193
|
+
// Deleted file
|
|
194
|
+
try {
|
|
195
|
+
await (0, isomorphic_git_1.remove)({ fs: fs_1.default, dir: projectDir, gitdir: bareRepoPath, filepath });
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
// error removing file
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function gitCommit({ projectDir, bareRepoPath, message, }) {
|
|
204
|
+
if (gitCommandIsAvailable()) {
|
|
205
|
+
try {
|
|
206
|
+
(0, child_process_1.execFileSync)('git', [
|
|
207
|
+
'--git-dir',
|
|
208
|
+
bareRepoPath,
|
|
209
|
+
'--work-tree',
|
|
210
|
+
projectDir,
|
|
211
|
+
'commit',
|
|
212
|
+
'-m',
|
|
213
|
+
message,
|
|
214
|
+
], { stdio: 'ignore' });
|
|
215
|
+
return await getLatestCommit({ bareRepoPath });
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
// Failed to commit, continue to isomorphic-git implementation
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const commitHash = await (0, isomorphic_git_1.commit)({
|
|
222
|
+
fs: fs_1.default,
|
|
223
|
+
dir: projectDir,
|
|
224
|
+
gitdir: bareRepoPath,
|
|
225
|
+
author: { name: 'Codebuff' },
|
|
226
|
+
message,
|
|
227
|
+
ref: '/refs/heads/master',
|
|
228
|
+
});
|
|
229
|
+
if (gitCommandIsAvailable()) {
|
|
230
|
+
try {
|
|
231
|
+
(0, child_process_1.execFileSync)('git', [
|
|
232
|
+
'--git-dir',
|
|
233
|
+
bareRepoPath,
|
|
234
|
+
'--work-tree',
|
|
235
|
+
projectDir,
|
|
236
|
+
'checkout',
|
|
237
|
+
'master',
|
|
238
|
+
], { stdio: 'ignore' });
|
|
239
|
+
return commitHash;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
// Unable to checkout with git
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
await (0, isomorphic_git_1.checkout)({ fs: fs_1.default, dir: projectDir, gitdir: bareRepoPath, ref: 'master' });
|
|
246
|
+
return commitHash;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Creates a new commit with the current state of all tracked files.
|
|
250
|
+
* Stages all changes and creates a commit with the specified message.
|
|
251
|
+
* @param projectDir - The working tree directory path
|
|
252
|
+
* @param bareRepoPath - The bare git repository path
|
|
253
|
+
* @param message - The commit message
|
|
254
|
+
* @param relativeFilepaths - Array of file paths relative to projectDir to commit
|
|
255
|
+
* @returns Promise resolving to the new commit's hash
|
|
256
|
+
*/
|
|
257
|
+
async function storeFileState({ projectDir, bareRepoPath, message, relativeFilepaths: relativeFilepaths, }) {
|
|
258
|
+
await gitAddAll({
|
|
259
|
+
projectDir,
|
|
260
|
+
bareRepoPath,
|
|
261
|
+
relativeFilepaths,
|
|
262
|
+
});
|
|
263
|
+
return await gitCommit({ projectDir, bareRepoPath, message });
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Restores the working directory and index to match the specified commit.
|
|
267
|
+
* Equivalent to `git reset --hard`
|
|
268
|
+
* First attempts to use native git commands, falling back to isomorphic-git if unavailable.
|
|
269
|
+
* @param projectDir - The working tree directory path
|
|
270
|
+
* @param bareRepoPath - The bare git repository path
|
|
271
|
+
* @param commit - The commit hash to restore to
|
|
272
|
+
* @param relativeFilepaths - Array of file paths relative to projectDir to restore
|
|
273
|
+
*/
|
|
274
|
+
async function restoreFileState({ projectDir, bareRepoPath, commit, relativeFilepaths, }) {
|
|
275
|
+
let resetDone = false;
|
|
276
|
+
if (gitCommandIsAvailable()) {
|
|
277
|
+
try {
|
|
278
|
+
(0, child_process_1.execFileSync)('git', [
|
|
279
|
+
'--git-dir',
|
|
280
|
+
bareRepoPath,
|
|
281
|
+
'--work-tree',
|
|
282
|
+
projectDir,
|
|
283
|
+
'reset',
|
|
284
|
+
'--hard',
|
|
285
|
+
commit,
|
|
286
|
+
]);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
// Failed to use git, continue to isomorphic-git implementation
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// Update the working directory to reflect the specified commit
|
|
294
|
+
await (0, isomorphic_git_1.checkout)({
|
|
295
|
+
fs: fs_1.default,
|
|
296
|
+
dir: projectDir,
|
|
297
|
+
gitdir: bareRepoPath,
|
|
298
|
+
ref: commit,
|
|
299
|
+
filepaths: relativeFilepaths,
|
|
300
|
+
force: true,
|
|
301
|
+
});
|
|
302
|
+
// Reset the index to match the specified commit
|
|
303
|
+
await Promise.all(relativeFilepaths.map((filepath) => (0, isomorphic_git_1.resetIndex)({
|
|
304
|
+
fs: fs_1.default,
|
|
305
|
+
dir: projectDir,
|
|
306
|
+
gitdir: bareRepoPath,
|
|
307
|
+
filepath,
|
|
308
|
+
ref: commit,
|
|
309
|
+
})));
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=file-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-manager.js","sourceRoot":"","sources":["../../src/checkpoints/file-manager.ts"],"names":[],"mappings":";;;;;;AA4CA,0CAGC;AAUD,8CAwCC;AAQD,0CAuBC;AASD,0EAoCC;AAmJD,wCAkBC;AAWD,4CAmDC;AAhZD,iDAA4C;AAC5C,mCAAmC;AACnC,4CAAmB;AAiZV,aAjZF,YAAE,CAiZE;AAhZX,4CAAmB;AACnB,+BAA2B;AAE3B,mDASuB;AAEvB,oDAAoD;AAEpD;;;;GAIG;AACH,IAAI,kBAAkB,GAAmB,IAAI,CAAA;AAC7C,SAAS,qBAAqB;IAC5B,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,IAAA,4BAAY,EAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,K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AE,iBAAiB;QAC5B,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,gDAAgD;IAChD,MAAM,OAAO,CAAC,GAAG,CACf,iBAAiB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACjC,IAAA,2BAAU,EAAC;QACT,EAAE,EAAF,YAAE;QACF,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,GAAG,EAAE,MAAM;KACZ,CAAC,CACH,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Client } from '../client';
|
|
2
|
+
import { ApiKeyType } from '../common/api-keys/constants';
|
|
3
|
+
export type ApiKeyDetectionResult = {
|
|
4
|
+
status: 'found';
|
|
5
|
+
type: ApiKeyType;
|
|
6
|
+
key: string;
|
|
7
|
+
} | {
|
|
8
|
+
status: 'prefix_only';
|
|
9
|
+
type: ApiKeyType;
|
|
10
|
+
prefix: string;
|
|
11
|
+
length: number;
|
|
12
|
+
} | {
|
|
13
|
+
status: 'not_found';
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Detects if the user input contains a known API key pattern.
|
|
17
|
+
* Returns information about the detected key or prefix.
|
|
18
|
+
*/
|
|
19
|
+
export declare function detectApiKey(userInput: string): ApiKeyDetectionResult;
|
|
20
|
+
/**
|
|
21
|
+
* Handles the result of API key detection.
|
|
22
|
+
*/
|
|
23
|
+
export declare function handleApiKeyInput(client: Client, detectionResult: Exclude<ApiKeyDetectionResult, {
|
|
24
|
+
status: 'not_found';
|
|
25
|
+
}>, readyPromise: Promise<any>, returnControlToUser: () => void): Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectApiKey = detectApiKey;
|
|
4
|
+
exports.handleApiKeyInput = handleApiKeyInput;
|
|
5
|
+
const picocolors_1 = require("picocolors");
|
|
6
|
+
const constants_1 = require("../common/api-keys/constants");
|
|
7
|
+
/**
|
|
8
|
+
* Detects if the user input contains a known API key pattern.
|
|
9
|
+
* Returns information about the detected key or prefix.
|
|
10
|
+
*/
|
|
11
|
+
function detectApiKey(userInput) {
|
|
12
|
+
// Build regex patterns for each key type
|
|
13
|
+
const keyPatterns = constants_1.API_KEY_TYPES.map((keyType) => {
|
|
14
|
+
const prefix = constants_1.KEY_PREFIXES[keyType];
|
|
15
|
+
const length = constants_1.KEY_LENGTHS[keyType];
|
|
16
|
+
const escapedPrefix = prefix.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
17
|
+
return {
|
|
18
|
+
type: keyType,
|
|
19
|
+
prefix: prefix,
|
|
20
|
+
length: length,
|
|
21
|
+
// Regex to find the key potentially surrounded by whitespace or at start/end
|
|
22
|
+
regex: new RegExp(`(?:^|\\s)(${escapedPrefix}[^\\s]{${length - prefix.length}})(?:\\s|$)`),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
// Test input against each pattern for a full match
|
|
26
|
+
for (const patternInfo of keyPatterns) {
|
|
27
|
+
const match = userInput.match(patternInfo.regex);
|
|
28
|
+
if (match && match[1]) {
|
|
29
|
+
// Found a full, valid key pattern
|
|
30
|
+
return { status: 'found', type: patternInfo.type, key: match[1] };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// If no full key matched, check if the input *starts* with any known prefix
|
|
34
|
+
for (const patternInfo of keyPatterns) {
|
|
35
|
+
if (userInput.includes(patternInfo.prefix)) {
|
|
36
|
+
// Found a prefix, but it didn't match the full pattern (wrong length/format)
|
|
37
|
+
return {
|
|
38
|
+
status: 'prefix_only',
|
|
39
|
+
type: patternInfo.type,
|
|
40
|
+
prefix: patternInfo.prefix,
|
|
41
|
+
length: patternInfo.length,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// No valid key or known prefix detected
|
|
46
|
+
return { status: 'not_found' };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Handles the result of API key detection.
|
|
50
|
+
*/
|
|
51
|
+
async function handleApiKeyInput(client, detectionResult, readyPromise, returnControlToUser) {
|
|
52
|
+
switch (detectionResult.status) {
|
|
53
|
+
case 'found':
|
|
54
|
+
await readyPromise;
|
|
55
|
+
// Call the client method to add the valid key
|
|
56
|
+
await client.handleAddApiKey(detectionResult.type, detectionResult.key);
|
|
57
|
+
// Note: client.handleAddApiKey calls returnControlToUser internally
|
|
58
|
+
break;
|
|
59
|
+
case 'prefix_only':
|
|
60
|
+
// Print the warning for incorrect format/length
|
|
61
|
+
console.log((0, picocolors_1.yellow)(`Input looks like a ${detectionResult.type} API key but has the wrong length or format. Expected ${detectionResult.length} characters starting with "${detectionResult.prefix}".`));
|
|
62
|
+
returnControlToUser(); // Give the user a fresh prompt after the warning
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=api-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.js","sourceRoot":"","sources":["../../src/cli-handlers/api-key.ts"],"names":[],"mappings":";;AAaA,oCAyCC;AAKD,8CA0BC;AArFD,2CAAmC;AAEnC,yDAAgG;AAOhG;;;GAGG;AACH,SAAgB,YAAY,CAAC,SAAiB;IAC5C,yCAAyC;IACzC,MAAM,WAAW,GAAG,yBAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAChD,MAAM,MAAM,GAAG,wBAAY,CAAC,OAAO,CAAC,CAAA;QACpC,MAAM,MAAM,GAAG,uBAAW,CAAC,OAAO,CAAC,CAAA;QACnC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAA;QACtE,OAAO;YACL,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,MAAM;YACd,6EAA6E;YAC7E,KAAK,EAAE,IAAI,MAAM,CACf,aAAa,aA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AA,mBAAM,EACJ,sBAAsB,eAAe,CAAC,IAAI,yDAAyD,eAAe,CAAC,MAAM,8BAA8B,eAAe,CAAC,MAAM,IAAI,CAClL,CACF,CAAA;YACD,mBAAmB,EAAE,CAAA,CAAC,iDAAiD;YACvE,MAAK;IACT,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Interface as ReadlineInterface } from 'readline';
|
|
2
|
+
import type { Client } from '../client';
|
|
3
|
+
export declare const checkpointCommands: {
|
|
4
|
+
readonly save: readonly [readonly ["checkpoint"], "Save current state as a new checkpoint"];
|
|
5
|
+
readonly list: readonly [readonly ["checkpoint list", "checkpoints"], "List all saved checkpoints"];
|
|
6
|
+
readonly clear: readonly [readonly ["checkpoint clear"], "Clear all checkpoints"];
|
|
7
|
+
readonly undo: readonly [readonly ["undo", "u"], "Undo to previous checkpoint"];
|
|
8
|
+
readonly redo: readonly [readonly ["redo", "r"], "Redo previously undone checkpoint"];
|
|
9
|
+
readonly restore: readonly [readonly [RegExp], "Restore to checkpoint number <n>"];
|
|
10
|
+
};
|
|
11
|
+
export declare function displayCheckpointMenu(): void;
|
|
12
|
+
export declare function isCheckpointCommand(userInput: string, type?: keyof typeof checkpointCommands | null): boolean | RegExpMatchArray;
|
|
13
|
+
export declare function listCheckpoints(): Promise<void>;
|
|
14
|
+
export declare function handleUndo(client: Client, rl: ReadlineInterface): Promise<string>;
|
|
15
|
+
export declare function handleRedo(client: Client, rl: ReadlineInterface): Promise<string>;
|
|
16
|
+
export declare function handleRestoreCheckpoint(id: number, client: Client, rl: ReadlineInterface): Promise<string>;
|
|
17
|
+
export declare function handleClearCheckpoints(): void;
|
|
18
|
+
export declare function saveCheckpoint(userInput: string, client: Client, readyPromise: Promise<any>, saveWithNoChanges?: boolean): Promise<void>;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkpointCommands = void 0;
|
|
4
|
+
exports.displayCheckpointMenu = displayCheckpointMenu;
|
|
5
|
+
exports.isCheckpointCommand = isCheckpointCommand;
|
|
6
|
+
exports.listCheckpoints = listCheckpoints;
|
|
7
|
+
exports.handleUndo = handleUndo;
|
|
8
|
+
exports.handleRedo = handleRedo;
|
|
9
|
+
exports.handleRestoreCheckpoint = handleRestoreCheckpoint;
|
|
10
|
+
exports.handleClearCheckpoints = handleClearCheckpoints;
|
|
11
|
+
exports.saveCheckpoint = saveCheckpoint;
|
|
12
|
+
const picocolors_1 = require("picocolors");
|
|
13
|
+
const checkpoint_manager_1 = require("../checkpoints/checkpoint-manager");
|
|
14
|
+
const spinner_1 = require("../utils/spinner");
|
|
15
|
+
exports.checkpointCommands = {
|
|
16
|
+
save: [['checkpoint'], 'Save current state as a new checkpoint'],
|
|
17
|
+
list: [['checkpoint list', 'checkpoints'], 'List all saved checkpoints'],
|
|
18
|
+
clear: [['checkpoint clear'], 'Clear all checkpoints'],
|
|
19
|
+
undo: [['undo', 'u'], 'Undo to previous checkpoint'],
|
|
20
|
+
redo: [['redo', 'r'], 'Redo previously undone checkpoint'],
|
|
21
|
+
restore: [[/^checkpoint\s+(\d+)$/], 'Restore to checkpoint number <n>'],
|
|
22
|
+
};
|
|
23
|
+
const allCheckpointCommands = Object.entries(exports.checkpointCommands)
|
|
24
|
+
.map((entry) => entry[1][0])
|
|
25
|
+
.flat();
|
|
26
|
+
function displayCheckpointMenu() {
|
|
27
|
+
console.log('\n' + (0, picocolors_1.bold)((0, picocolors_1.underline)('Checkpoint Commands:')));
|
|
28
|
+
Object.entries(exports.checkpointCommands).forEach(([, [aliases, description]]) => {
|
|
29
|
+
const formattedAliases = aliases
|
|
30
|
+
.map((a) => (typeof a === 'string' ? (0, picocolors_1.cyan)(a) : (0, picocolors_1.cyan)('checkpoint <n>')))
|
|
31
|
+
.join(', ');
|
|
32
|
+
console.log(`${formattedAliases} - ${description}`);
|
|
33
|
+
});
|
|
34
|
+
console.log();
|
|
35
|
+
}
|
|
36
|
+
function isCheckpointCommand(userInput, type = null) {
|
|
37
|
+
if (type === null) {
|
|
38
|
+
if (userInput.startsWith('checkpoint')) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
for (const pattern of allCheckpointCommands) {
|
|
42
|
+
if (pattern instanceof RegExp) {
|
|
43
|
+
const m = userInput.match(pattern);
|
|
44
|
+
if (m) {
|
|
45
|
+
return m;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (userInput === pattern) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
for (const pattern of exports.checkpointCommands[type][0]) {
|
|
55
|
+
if (pattern instanceof RegExp) {
|
|
56
|
+
const m = userInput.match(pattern);
|
|
57
|
+
if (m) {
|
|
58
|
+
return m;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (userInput === pattern) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
async function listCheckpoints() {
|
|
68
|
+
console.log(checkpoint_manager_1.checkpointManager.getCheckpointsAsString());
|
|
69
|
+
}
|
|
70
|
+
async function handleUndo(client, rl) {
|
|
71
|
+
let failed = false;
|
|
72
|
+
try {
|
|
73
|
+
await checkpoint_manager_1.checkpointManager.restoreUndoCheckpoint();
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
failed = true;
|
|
77
|
+
if (error instanceof checkpoint_manager_1.CheckpointsDisabledError) {
|
|
78
|
+
console.log((0, picocolors_1.red)(`Checkpoints not enabled: ${error.message}`));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.log((0, picocolors_1.red)(`Unable to undo: ${error.message}`));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
let userInput = '';
|
|
85
|
+
if (!failed) {
|
|
86
|
+
const currentCheckpoint = checkpoint_manager_1.checkpointManager.checkpoints[checkpoint_manager_1.checkpointManager.currentCheckpointId - 1];
|
|
87
|
+
// Restore the agentState
|
|
88
|
+
client.agentState = JSON.parse(currentCheckpoint.agentStateString);
|
|
89
|
+
client.lastToolResults = JSON.parse(currentCheckpoint.lastToolResultsString);
|
|
90
|
+
console.log((0, picocolors_1.green)(`Checkpoint #${checkpoint_manager_1.checkpointManager.currentCheckpointId} restored.`));
|
|
91
|
+
userInput =
|
|
92
|
+
checkpoint_manager_1.checkpointManager.checkpoints[checkpoint_manager_1.checkpointManager.currentCheckpointId - 1]
|
|
93
|
+
?.userInput ?? '';
|
|
94
|
+
}
|
|
95
|
+
return isCheckpointCommand(userInput) ? '' : userInput;
|
|
96
|
+
}
|
|
97
|
+
async function handleRedo(client, rl) {
|
|
98
|
+
let failed = false;
|
|
99
|
+
try {
|
|
100
|
+
await checkpoint_manager_1.checkpointManager.restoreRedoCheckpoint();
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
failed = true;
|
|
104
|
+
if (error instanceof checkpoint_manager_1.CheckpointsDisabledError) {
|
|
105
|
+
console.log((0, picocolors_1.red)(`Checkpoints not enabled: ${error.message}`));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
console.log((0, picocolors_1.red)(`Unable to redo: ${error.message}`));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
let userInput = '';
|
|
112
|
+
if (!failed) {
|
|
113
|
+
const currentCheckpoint = checkpoint_manager_1.checkpointManager.checkpoints[checkpoint_manager_1.checkpointManager.currentCheckpointId - 1];
|
|
114
|
+
// Restore the agentState
|
|
115
|
+
client.agentState = JSON.parse(currentCheckpoint.agentStateString);
|
|
116
|
+
client.lastToolResults = JSON.parse(currentCheckpoint.lastToolResultsString);
|
|
117
|
+
console.log((0, picocolors_1.green)(`Checkpoint #${checkpoint_manager_1.checkpointManager.currentCheckpointId} restored.`));
|
|
118
|
+
userInput =
|
|
119
|
+
checkpoint_manager_1.checkpointManager.checkpoints[checkpoint_manager_1.checkpointManager.currentCheckpointId - 1]
|
|
120
|
+
?.userInput ?? '';
|
|
121
|
+
}
|
|
122
|
+
return isCheckpointCommand(userInput) ? '' : userInput;
|
|
123
|
+
}
|
|
124
|
+
async function handleRestoreCheckpoint(id, client, rl) {
|
|
125
|
+
spinner_1.Spinner.get().start();
|
|
126
|
+
if (checkpoint_manager_1.checkpointManager.disabledReason !== null) {
|
|
127
|
+
console.log((0, picocolors_1.red)(`Checkpoints not enabled: ${checkpoint_manager_1.checkpointManager.disabledReason}`));
|
|
128
|
+
return '';
|
|
129
|
+
}
|
|
130
|
+
const checkpoint = checkpoint_manager_1.checkpointManager.checkpoints[id - 1];
|
|
131
|
+
if (!checkpoint) {
|
|
132
|
+
console.log((0, picocolors_1.red)(`Checkpoint #${id} not found.`));
|
|
133
|
+
return '';
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
// Wait for save before trying to restore checkpoint
|
|
137
|
+
const latestCheckpoint = checkpoint_manager_1.checkpointManager.getLatestCheckpoint();
|
|
138
|
+
await latestCheckpoint?.fileStateIdPromise;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
// Should never happen
|
|
142
|
+
}
|
|
143
|
+
// Restore the agentState
|
|
144
|
+
client.agentState = JSON.parse(checkpoint.agentStateString);
|
|
145
|
+
client.lastToolResults = JSON.parse(checkpoint.lastToolResultsString);
|
|
146
|
+
let failed = false;
|
|
147
|
+
try {
|
|
148
|
+
// Restore file state
|
|
149
|
+
await checkpoint_manager_1.checkpointManager.restoreCheckointFileState({
|
|
150
|
+
id: checkpoint.id,
|
|
151
|
+
resetUndoIds: true,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
failed = true;
|
|
156
|
+
spinner_1.Spinner.get().stop();
|
|
157
|
+
console.log((0, picocolors_1.red)(`Unable to restore checkpoint: ${error.message}`));
|
|
158
|
+
}
|
|
159
|
+
if (!failed) {
|
|
160
|
+
spinner_1.Spinner.get().stop();
|
|
161
|
+
console.log((0, picocolors_1.green)(`Restored to checkpoint #${id}.`));
|
|
162
|
+
}
|
|
163
|
+
// Insert the original user input that created this checkpoint
|
|
164
|
+
return isCheckpointCommand(checkpoint.userInput) ? '' : checkpoint.userInput;
|
|
165
|
+
}
|
|
166
|
+
function handleClearCheckpoints() {
|
|
167
|
+
checkpoint_manager_1.checkpointManager.clearCheckpoints();
|
|
168
|
+
console.log('Cleared all checkpoints.');
|
|
169
|
+
}
|
|
170
|
+
async function saveCheckpoint(userInput, client, readyPromise, saveWithNoChanges = false) {
|
|
171
|
+
if (checkpoint_manager_1.checkpointManager.disabledReason !== null) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
spinner_1.Spinner.get().start();
|
|
175
|
+
await readyPromise;
|
|
176
|
+
spinner_1.Spinner.get().stop();
|
|
177
|
+
try {
|
|
178
|
+
// Make sure the previous checkpoint is done
|
|
179
|
+
await checkpoint_manager_1.checkpointManager.getLatestCheckpoint().fileStateIdPromise;
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
// No latest checkpoint available, no need to wait
|
|
183
|
+
}
|
|
184
|
+
// Save the current agent state
|
|
185
|
+
try {
|
|
186
|
+
const { checkpoint, created } = await checkpoint_manager_1.checkpointManager.addCheckpoint(client.agentState, client.lastToolResults, userInput, saveWithNoChanges);
|
|
187
|
+
if (created) {
|
|
188
|
+
console.log(`[checkpoint #${checkpoint.id} saved]`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
// Unable to add checkpoint, do not display anything to user
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=checkpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.js","sourceRoot":"","sources":["../../src/cli-handlers/checkpoint.ts"],"names":[],"mappings":";;;AAwBA,sDASC;AAED,kDAoCC;AAED,0CAE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