codebuff 1.0.174 → 1.0.176
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/checkpoint-file-manager.d.ts +17 -5
- package/dist/checkpoint-file-manager.js +115 -77
- package/dist/checkpoint-file-manager.js.map +1 -1
- package/dist/checkpoints.d.ts +3 -2
- package/dist/checkpoints.js +20 -32
- package/dist/checkpoints.js.map +1 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +24 -49
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +13 -12
- package/dist/client.js +8 -1
- package/dist/client.js.map +1 -1
- package/dist/common/actions.d.ts +182 -182
- package/dist/common/browser-actions.d.ts +44 -44
- package/dist/common/constants.d.ts +0 -1
- package/dist/common/constants.js +1 -44
- package/dist/common/constants.js.map +1 -1
- package/dist/common/logger.d.ts +1 -0
- package/dist/common/logger.js +7 -0
- package/dist/common/logger.js.map +1 -0
- package/dist/common/project-file-tree.d.ts +1 -0
- package/dist/common/project-file-tree.js +3 -1
- package/dist/common/project-file-tree.js.map +1 -1
- package/dist/common/types/agent-state.d.ts +26 -26
- package/dist/common/types/message.d.ts +14 -14
- package/dist/common/types/usage.d.ts +2 -2
- package/dist/common/util/constants.d.ts +1 -0
- package/dist/common/util/constants.js +7 -0
- package/dist/common/util/constants.js.map +1 -0
- package/dist/common/util/credentials.d.ts +2 -2
- package/dist/common/util/helpers.d.ts +1 -0
- package/dist/common/util/helpers.js +6 -0
- package/dist/common/util/helpers.js.map +1 -0
- package/dist/common/util/token-counter.d.ts +3 -0
- package/dist/common/util/token-counter.js +27 -0
- package/dist/common/util/token-counter.js.map +1 -0
- package/dist/common/websockets/websocket-schema.d.ts +364 -364
- package/dist/index.js +1 -1
- package/dist/tool-handlers.d.ts +2 -1
- package/dist/tool-handlers.js +3 -3
- package/dist/tool-handlers.js.map +1 -1
- package/dist/utils/terminal.js +4 -40
- package/dist/utils/terminal.js.map +1 -1
- package/dist/utils/tool-renderers.js +14 -2
- package/dist/utils/tool-renderers.js.map +1 -1
- package/dist/worker-script-project-context.js +4 -4
- package/dist/worker-script-project-context.js.map +1 -1
- package/package.json +1 -1
- package/dist/common/advanced-analyzer.d.ts +0 -19
- package/dist/common/advanced-analyzer.js +0 -140
- package/dist/common/advanced-analyzer.js.map +0 -1
- package/dist/common/message-image-handling.d.ts +0 -41
- package/dist/common/message-image-handling.js +0 -57
- package/dist/common/message-image-handling.js.map +0 -1
- package/dist/common/util/process-stream.d.ts +0 -8
- package/dist/common/util/process-stream.js +0 -102
- package/dist/common/util/process-stream.js.map +0 -1
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
export declare function getBareRepoPath(dir: string): string;
|
|
2
|
-
export declare function initializeCheckpointFileManager(
|
|
2
|
+
export declare function initializeCheckpointFileManager({ projectDir, relativeFilepaths, }: {
|
|
3
|
+
projectDir: string;
|
|
4
|
+
relativeFilepaths: Array<string>;
|
|
5
|
+
}): Promise<void>;
|
|
3
6
|
/**
|
|
4
7
|
* Stores the current state of all files in the project as a git commit
|
|
8
|
+
* (git add . && git commit)
|
|
5
9
|
* @param message The commit message to use for this file state
|
|
6
10
|
* @returns A promise that resolves to the id hash that can be used to restore this file state
|
|
7
11
|
*/
|
|
8
|
-
export declare function storeFileState(projectDir
|
|
12
|
+
export declare function storeFileState({ projectDir, bareRepoPath, message, relativeFilepaths: relativeFilepaths, }: {
|
|
13
|
+
projectDir: string;
|
|
14
|
+
bareRepoPath: string;
|
|
15
|
+
message: string;
|
|
16
|
+
relativeFilepaths: Array<string>;
|
|
17
|
+
}): Promise<string>;
|
|
9
18
|
/**
|
|
10
19
|
* Resets the index and working directory to the specified commit.
|
|
20
|
+
* (git reset --hard)
|
|
21
|
+
* TODO redo this jsdoc
|
|
11
22
|
* @param dir - The working tree directory path.
|
|
12
23
|
* @param gitdir - The git directory path (typically the .git folder).
|
|
13
24
|
* @param commit - The commit hash to reset to.
|
|
14
25
|
*/
|
|
15
|
-
export declare function
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
export declare function restoreFileState({ projectDir, bareRepoPath, commit, relativeFilepaths, }: {
|
|
27
|
+
projectDir: string;
|
|
28
|
+
bareRepoPath: string;
|
|
18
29
|
commit: string;
|
|
30
|
+
relativeFilepaths: Array<string>;
|
|
19
31
|
}): Promise<void>;
|
|
@@ -1,116 +1,126 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.getBareRepoPath = getBareRepoPath;
|
|
27
7
|
exports.initializeCheckpointFileManager = initializeCheckpointFileManager;
|
|
28
8
|
exports.storeFileState = storeFileState;
|
|
29
|
-
exports.
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
9
|
+
exports.restoreFileState = restoreFileState;
|
|
10
|
+
const crypto_1 = require("crypto");
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const isomorphic_git_1 = require("isomorphic-git");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const child_process_1 = require("child_process");
|
|
34
15
|
const project_files_1 = require("./project-files");
|
|
16
|
+
function gitCommandIsAvailable() {
|
|
17
|
+
try {
|
|
18
|
+
(0, child_process_1.execFileSync)('which', ['git']);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
35
25
|
function getBareRepoPath(dir) {
|
|
36
|
-
const bareRepoName =
|
|
37
|
-
return
|
|
26
|
+
const bareRepoName = (0, crypto_1.createHash)('sha256').update(dir).digest('hex');
|
|
27
|
+
return (0, path_1.join)((0, project_files_1.getProjectDataDir)(), bareRepoName);
|
|
38
28
|
}
|
|
39
|
-
async function initializeCheckpointFileManager(
|
|
40
|
-
const bareRepoPath = getBareRepoPath(
|
|
29
|
+
async function initializeCheckpointFileManager({ projectDir, relativeFilepaths, }) {
|
|
30
|
+
const bareRepoPath = getBareRepoPath(projectDir);
|
|
41
31
|
// Create the bare repo directory if it doesn't exist
|
|
42
|
-
|
|
32
|
+
fs_1.default.mkdirSync(bareRepoPath, { recursive: true });
|
|
43
33
|
try {
|
|
44
34
|
// Check if it's already a valid Git repo
|
|
45
|
-
await
|
|
46
|
-
return; // Exit if the repository exists
|
|
35
|
+
await (0, isomorphic_git_1.resolveRef)({ fs: fs_1.default, dir: bareRepoPath, ref: 'HEAD' });
|
|
47
36
|
}
|
|
48
37
|
catch (error) {
|
|
49
38
|
// Bare repo doesn't exist yet
|
|
39
|
+
await (0, isomorphic_git_1.init)({ fs: fs_1.default, dir: bareRepoPath, bare: true });
|
|
50
40
|
}
|
|
51
|
-
// Initialize a bare repository
|
|
52
|
-
await git.init({ fs, dir: bareRepoPath, bare: true });
|
|
53
41
|
// Commit the files in the bare repo
|
|
54
|
-
await storeFileState(
|
|
42
|
+
await storeFileState({
|
|
43
|
+
projectDir,
|
|
44
|
+
bareRepoPath,
|
|
45
|
+
message: 'Initial Commit',
|
|
46
|
+
relativeFilepaths,
|
|
47
|
+
});
|
|
55
48
|
}
|
|
56
|
-
async function stageFilesIndividually(projectDir, bareRepoPath) {
|
|
49
|
+
async function stageFilesIndividually({ projectDir, bareRepoPath, relativeFilepaths, }) {
|
|
57
50
|
// Get status of all files in the project directory
|
|
58
|
-
const
|
|
59
|
-
fs,
|
|
51
|
+
const currStatusMatrix = await (0, isomorphic_git_1.statusMatrix)({
|
|
52
|
+
fs: fs_1.default,
|
|
60
53
|
dir: projectDir,
|
|
61
54
|
gitdir: bareRepoPath,
|
|
55
|
+
filepaths: relativeFilepaths,
|
|
62
56
|
});
|
|
63
|
-
|
|
57
|
+
for (const [filepath, , workdirStatus, stageStatus] of currStatusMatrix) {
|
|
64
58
|
if (workdirStatus === stageStatus) {
|
|
65
|
-
|
|
59
|
+
continue;
|
|
66
60
|
}
|
|
67
61
|
if (workdirStatus === 2) {
|
|
68
|
-
//
|
|
62
|
+
// Existing file different from HEAD
|
|
69
63
|
try {
|
|
70
|
-
|
|
71
|
-
fs,
|
|
72
|
-
dir: projectDir,
|
|
73
|
-
gitdir: bareRepoPath,
|
|
74
|
-
filepath,
|
|
75
|
-
});
|
|
64
|
+
await (0, isomorphic_git_1.add)({ fs: fs_1.default, dir: projectDir, gitdir: bareRepoPath, filepath });
|
|
76
65
|
}
|
|
77
66
|
catch (error) {
|
|
78
|
-
// error adding
|
|
67
|
+
// error adding files
|
|
79
68
|
}
|
|
80
69
|
}
|
|
81
70
|
else if (workdirStatus === 0) {
|
|
82
|
-
//
|
|
71
|
+
// Deleted file
|
|
83
72
|
try {
|
|
84
|
-
|
|
85
|
-
fs,
|
|
86
|
-
dir: projectDir,
|
|
87
|
-
gitdir: bareRepoPath,
|
|
88
|
-
filepath,
|
|
89
|
-
});
|
|
73
|
+
await (0, isomorphic_git_1.remove)({ fs: fs_1.default, dir: projectDir, gitdir: bareRepoPath, filepath });
|
|
90
74
|
}
|
|
91
75
|
catch (error) {
|
|
92
|
-
// error
|
|
76
|
+
// error removing file
|
|
93
77
|
}
|
|
94
78
|
}
|
|
95
|
-
}
|
|
79
|
+
}
|
|
96
80
|
}
|
|
97
81
|
/**
|
|
98
82
|
* Stores the current state of all files in the project as a git commit
|
|
83
|
+
* (git add . && git commit)
|
|
99
84
|
* @param message The commit message to use for this file state
|
|
100
85
|
* @returns A promise that resolves to the id hash that can be used to restore this file state
|
|
101
86
|
*/
|
|
102
|
-
async function storeFileState(projectDir, bareRepoPath, message) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
async function storeFileState({ projectDir, bareRepoPath, message, relativeFilepaths: relativeFilepaths, }) {
|
|
88
|
+
let added = false;
|
|
89
|
+
if (gitCommandIsAvailable()) {
|
|
90
|
+
try {
|
|
91
|
+
(0, child_process_1.execFileSync)('git', [
|
|
92
|
+
'--git-dir',
|
|
93
|
+
bareRepoPath,
|
|
94
|
+
'--work-tree',
|
|
95
|
+
projectDir,
|
|
96
|
+
'-C',
|
|
97
|
+
projectDir,
|
|
98
|
+
'add',
|
|
99
|
+
'.',
|
|
100
|
+
]);
|
|
101
|
+
added = true;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// Failed to add .
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!added) {
|
|
108
|
+
await stageFilesIndividually({
|
|
109
|
+
projectDir,
|
|
110
|
+
bareRepoPath,
|
|
111
|
+
relativeFilepaths,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const commitHash = await (0, isomorphic_git_1.commit)({
|
|
115
|
+
fs: fs_1.default,
|
|
106
116
|
dir: projectDir,
|
|
107
117
|
gitdir: bareRepoPath,
|
|
108
118
|
author: { name: 'codebuff' },
|
|
109
119
|
ref: 'refs/heads/master',
|
|
110
120
|
message,
|
|
111
121
|
});
|
|
112
|
-
await
|
|
113
|
-
fs,
|
|
122
|
+
await (0, isomorphic_git_1.checkout)({
|
|
123
|
+
fs: fs_1.default,
|
|
114
124
|
dir: projectDir,
|
|
115
125
|
gitdir: bareRepoPath,
|
|
116
126
|
ref: commitHash,
|
|
@@ -119,21 +129,49 @@ async function storeFileState(projectDir, bareRepoPath, message) {
|
|
|
119
129
|
}
|
|
120
130
|
/**
|
|
121
131
|
* Resets the index and working directory to the specified commit.
|
|
132
|
+
* (git reset --hard)
|
|
133
|
+
* TODO redo this jsdoc
|
|
122
134
|
* @param dir - The working tree directory path.
|
|
123
135
|
* @param gitdir - The git directory path (typically the .git folder).
|
|
124
136
|
* @param commit - The commit hash to reset to.
|
|
125
137
|
*/
|
|
126
|
-
async function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
async function restoreFileState({ projectDir, bareRepoPath, commit, relativeFilepaths, }) {
|
|
139
|
+
let resetDone = false;
|
|
140
|
+
if (gitCommandIsAvailable()) {
|
|
141
|
+
try {
|
|
142
|
+
(0, child_process_1.execFileSync)('git', [
|
|
143
|
+
'--git-dir',
|
|
144
|
+
bareRepoPath,
|
|
145
|
+
'--work-tree',
|
|
146
|
+
projectDir,
|
|
147
|
+
'reset',
|
|
148
|
+
'--hard',
|
|
149
|
+
commit,
|
|
150
|
+
]);
|
|
151
|
+
resetDone = true;
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
// Failed to use git, continue to isomorphic-git implementation
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!resetDone) {
|
|
158
|
+
// Update the working directory to reflect the specified commit
|
|
159
|
+
await (0, isomorphic_git_1.checkout)({
|
|
160
|
+
fs: fs_1.default,
|
|
161
|
+
dir: projectDir,
|
|
162
|
+
gitdir: bareRepoPath,
|
|
163
|
+
ref: commit,
|
|
164
|
+
filepaths: relativeFilepaths,
|
|
165
|
+
force: true,
|
|
166
|
+
});
|
|
167
|
+
// Reset the index to match the specified commit
|
|
168
|
+
await Promise.all(relativeFilepaths.map((filepath) => (0, isomorphic_git_1.resetIndex)({
|
|
169
|
+
fs: fs_1.default,
|
|
170
|
+
dir: projectDir,
|
|
171
|
+
gitdir: bareRepoPath,
|
|
172
|
+
filepath,
|
|
173
|
+
ref: commit,
|
|
174
|
+
})));
|
|
175
|
+
}
|
|
138
176
|
}
|
|
139
177
|
//# sourceMappingURL=checkpoint-file-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint-file-manager.js","sourceRoot":"","sources":["../src/checkpoint-file-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkpoint-file-manager.js","sourceRoot":"","sources":["../src/checkpoint-file-manager.ts"],"names":[],"mappings":";;;;;AA0BA,0CAGC;AAED,0EA2BC;AAgDD,wCAuDC;AAUD,4CAqDC;AAhOD,mCAAmC;AACnC,4CAAmB;AACnB,mDASuB;AACvB,+BAA2B;AAC3B,iDAA4C;AAE5C,mDAAmD;AAEnD,SAAS,qBAAqB;IAC5B,IAAI,CAAC;QACH,IAAA,4BAAY,EAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,YAAY,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACnE,OAAO,IAAA,WA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;SACZ,CAAC,CACH,CACF,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/dist/checkpoints.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AgentState } from './common/types/agent-state';
|
|
|
4
4
|
*/
|
|
5
5
|
export interface Checkpoint {
|
|
6
6
|
agentStateString: string;
|
|
7
|
+
enabled: boolean;
|
|
7
8
|
fileStateIdPromise: Promise<string>;
|
|
8
9
|
historyLength: number;
|
|
9
10
|
id: number;
|
|
@@ -24,7 +25,7 @@ export declare class CheckpointManager {
|
|
|
24
25
|
* @param userInput - The user input associated with this checkpoint
|
|
25
26
|
* @returns The ID of the created checkpoint
|
|
26
27
|
*/
|
|
27
|
-
addCheckpoint(agentState: AgentState, userInput: string): Promise<
|
|
28
|
+
addCheckpoint(agentState: AgentState, userInput: string): Promise<Checkpoint>;
|
|
28
29
|
/**
|
|
29
30
|
* Get a checkpoint by ID
|
|
30
31
|
* @param id The checkpoint ID
|
|
@@ -41,7 +42,7 @@ export declare class CheckpointManager {
|
|
|
41
42
|
* @returns The most recent checkpoint or null if none exist
|
|
42
43
|
*/
|
|
43
44
|
getLatestCheckpoint(): Checkpoint | null;
|
|
44
|
-
|
|
45
|
+
restoreCheckointFileState(id: number): Promise<boolean>;
|
|
45
46
|
/**
|
|
46
47
|
* Clear all checkpoints
|
|
47
48
|
*/
|
package/dist/checkpoints.js
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.checkpointManager = exports.CheckpointManager = void 0;
|
|
27
4
|
const picocolors_1 = require("picocolors");
|
|
28
|
-
const
|
|
5
|
+
const project_file_tree_1 = require("./common/project-file-tree");
|
|
6
|
+
const checkpoint_file_manager_1 = require("./checkpoint-file-manager");
|
|
29
7
|
const project_files_1 = require("./project-files");
|
|
30
8
|
/**
|
|
31
9
|
* Simple in-memory checkpoint manager for agent states
|
|
@@ -36,8 +14,7 @@ class CheckpointManager {
|
|
|
36
14
|
bareRepoPath = null;
|
|
37
15
|
getBareRepoPath() {
|
|
38
16
|
if (!this.bareRepoPath) {
|
|
39
|
-
this.bareRepoPath =
|
|
40
|
-
checkpointFileManager.getBareRepoPath((0, project_files_1.getProjectRoot)());
|
|
17
|
+
this.bareRepoPath = (0, checkpoint_file_manager_1.getBareRepoPath)((0, project_files_1.getProjectRoot)());
|
|
41
18
|
}
|
|
42
19
|
return this.bareRepoPath;
|
|
43
20
|
}
|
|
@@ -50,9 +27,17 @@ class CheckpointManager {
|
|
|
50
27
|
async addCheckpoint(agentState, userInput) {
|
|
51
28
|
// Use incremental ID starting at 1
|
|
52
29
|
const id = this.nextId++;
|
|
53
|
-
const
|
|
30
|
+
const relativeFilepaths = (0, project_file_tree_1.getAllFilePaths)(agentState.fileContext.fileTree);
|
|
31
|
+
const enabled = relativeFilepaths.length < project_file_tree_1.DEFAULT_MAX_FILES;
|
|
32
|
+
const fileStateIdPromise = enabled ? (0, checkpoint_file_manager_1.storeFileState)({
|
|
33
|
+
projectDir: (0, project_files_1.getProjectRoot)(),
|
|
34
|
+
bareRepoPath: this.getBareRepoPath(),
|
|
35
|
+
message: `Checkpoint ${id}`,
|
|
36
|
+
relativeFilepaths: (0, project_file_tree_1.getAllFilePaths)(agentState.fileContext.fileTree),
|
|
37
|
+
}) : Promise.resolve('');
|
|
54
38
|
const checkpoint = {
|
|
55
39
|
agentStateString: JSON.stringify(agentState), // Deep clone to prevent reference issues
|
|
40
|
+
enabled,
|
|
56
41
|
fileStateIdPromise,
|
|
57
42
|
historyLength: agentState.messageHistory.length,
|
|
58
43
|
id,
|
|
@@ -61,7 +46,7 @@ class CheckpointManager {
|
|
|
61
46
|
};
|
|
62
47
|
// Add to map
|
|
63
48
|
this.checkpoints.set(id, checkpoint);
|
|
64
|
-
return
|
|
49
|
+
return checkpoint;
|
|
65
50
|
}
|
|
66
51
|
/**
|
|
67
52
|
* Get a checkpoint by ID
|
|
@@ -89,15 +74,18 @@ class CheckpointManager {
|
|
|
89
74
|
getLatestCheckpoint() {
|
|
90
75
|
return this.checkpoints.get(this.nextId - 1) || null;
|
|
91
76
|
}
|
|
92
|
-
async
|
|
77
|
+
async restoreCheckointFileState(id) {
|
|
93
78
|
const checkpoint = this.getCheckpoint(id);
|
|
94
79
|
if (!checkpoint) {
|
|
95
80
|
return false;
|
|
96
81
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
const relativeFilepaths = (0, project_file_tree_1.getAllFilePaths)(JSON.parse(checkpoint.agentStateString).fileContext
|
|
83
|
+
.fileTree);
|
|
84
|
+
await (0, checkpoint_file_manager_1.restoreFileState)({
|
|
85
|
+
projectDir: (0, project_files_1.getProjectRoot)(),
|
|
86
|
+
bareRepoPath: this.getBareRepoPath(),
|
|
100
87
|
commit: await checkpoint.fileStateIdPromise,
|
|
88
|
+
relativeFilepaths,
|
|
101
89
|
});
|
|
102
90
|
return true;
|
|
103
91
|
}
|
package/dist/checkpoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoints.js","sourceRoot":"","sources":["../src/checkpoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkpoints.js","sourceRoot":"","sources":["../src/checkpoints.ts"],"names":[],"mappings":";;;AAAA,2CAAsE;AAEtE,gEAA6E;AAE7E,uEAIkC;AAClC,mDAAgD;AAehD;;GAEG;AACH,MAAa,iBAAiB;IACpB,WAAW,GAA4B,IAAI,GAAG,EAAE,CAAA;IAChD,MAAM,GAAW,CAAC,CAAA;IAClB,YAAY,GAAkB,IAAI,CAAA;IAE1C,eAAe;QACb,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,GAAG,IAAA,yCAAe,EAAC,IAAA,8BAAc,GAAE,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CACjB,UAAsB,EACtB,SAAiB;QAEjB,mCAAmC;QACnC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QAExB,MAAM,iBAAiB,GAAG,IAAA,mCAAe,EAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAC1E,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,GAAG,qCAAiB,CAAA;QAE5D,MAAM,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,IAAA,wCAAc,EAAC;YAChD,UAAU,EAAE,IAAA,8BAAc,GAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,OAAO,EAA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AAC,cAAc,EAAE,CAAA;QAC3C,KAAK,CAAC,IAAI,CAAC,GAAG,IAAA,iBAAI,EAAC,YAAY,CAAC,KAAK,aAAa,EAAE,CAAC,CAAA;QAErD,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,GAAG,IAAA,iBAAI,EAAC,YAAY,CAAC,KAAK,UAAU,CAAC,SAAS,EAAE,CAAC,CAAA;QAC9D,CAAC;QAED,0DAA0D;QAC1D,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAA;QAC7C,KAAK,CAAC,IAAI,CAAC,GAAG,IAAA,iBAAI,EAAC,iBAAiB,CAAC,KAAK,YAAY,WAAW,CAAC,CAAA;QAElE,yDAAyD;QAEzD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AA5LD,8CA4LC;AAED,iEAAiE;AACpD,QAAA,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAA"}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -36,7 +36,6 @@ const client_1 = require("./client");
|
|
|
36
36
|
const config_1 = require("./config");
|
|
37
37
|
const menu_1 = require("./menu");
|
|
38
38
|
const project_files_1 = require("./project-files");
|
|
39
|
-
const tool_handlers_1 = require("./tool-handlers");
|
|
40
39
|
const spinner_1 = require("./utils/spinner");
|
|
41
40
|
const terminal_1 = require("./utils/terminal");
|
|
42
41
|
const web_scraper_1 = require("./web-scraper");
|
|
@@ -123,11 +122,7 @@ class CLI {
|
|
|
123
122
|
return [matchingTokens, lastWord];
|
|
124
123
|
}
|
|
125
124
|
setPrompt() {
|
|
126
|
-
this.rl.setPrompt((0, picocolors_1.green)(`${(0, path_1.parse)((0, project_files_1.getProjectRoot)()).base}
|
|
127
|
-
}
|
|
128
|
-
promptWithCheckpointNumber() {
|
|
129
|
-
this.setPrompt();
|
|
130
|
-
this.rl.prompt();
|
|
125
|
+
this.rl.setPrompt((0, picocolors_1.green)(`${(0, path_1.parse)((0, project_files_1.getProjectRoot)()).base} > `));
|
|
131
126
|
}
|
|
132
127
|
async printInitialPrompt(initialInput) {
|
|
133
128
|
if (this.client.user) {
|
|
@@ -138,7 +133,7 @@ class CLI {
|
|
|
138
133
|
await this.client.login();
|
|
139
134
|
return;
|
|
140
135
|
}
|
|
141
|
-
this.
|
|
136
|
+
this.rl.prompt();
|
|
142
137
|
if (initialInput) {
|
|
143
138
|
process.stdout.write(initialInput + '\n');
|
|
144
139
|
this.handleUserInput(initialInput);
|
|
@@ -146,7 +141,7 @@ class CLI {
|
|
|
146
141
|
}
|
|
147
142
|
async printDiff() {
|
|
148
143
|
this.handleDiff();
|
|
149
|
-
this.
|
|
144
|
+
this.rl.prompt();
|
|
150
145
|
}
|
|
151
146
|
async handleLine(line) {
|
|
152
147
|
this.detectPasting();
|
|
@@ -179,13 +174,16 @@ class CLI {
|
|
|
179
174
|
// Make sure the previous checkpoint is done
|
|
180
175
|
await checkpoints_1.checkpointManager.getLatestCheckpoint()?.fileStateIdPromise;
|
|
181
176
|
// Save the current agent state
|
|
182
|
-
await checkpoints_1.checkpointManager.addCheckpoint(this.client.agentState, userInput);
|
|
177
|
+
const checkpoint = await checkpoints_1.checkpointManager.addCheckpoint(this.client.agentState, userInput);
|
|
178
|
+
if (checkpoint.enabled) {
|
|
179
|
+
console.log((0, picocolors_1.green)(`Checkpoint #${checkpoint.id} saved!`));
|
|
180
|
+
}
|
|
183
181
|
}
|
|
184
182
|
async processCommand(userInput) {
|
|
185
183
|
await this.beforeProcessCommand(userInput);
|
|
186
184
|
if (userInput === 'help' || userInput === 'h') {
|
|
187
185
|
(0, menu_1.displayMenu)();
|
|
188
|
-
this.
|
|
186
|
+
this.rl.prompt();
|
|
189
187
|
return true;
|
|
190
188
|
}
|
|
191
189
|
if (userInput === 'login' || userInput === 'signin') {
|
|
@@ -194,7 +192,7 @@ class CLI {
|
|
|
194
192
|
}
|
|
195
193
|
if (userInput === 'logout' || userInput === 'signout') {
|
|
196
194
|
await this.client.logout();
|
|
197
|
-
this.
|
|
195
|
+
this.rl.prompt();
|
|
198
196
|
return true;
|
|
199
197
|
}
|
|
200
198
|
if (userInput.startsWith('ref-')) {
|
|
@@ -215,7 +213,7 @@ class CLI {
|
|
|
215
213
|
}
|
|
216
214
|
if (['diff', 'doff', 'dif', 'iff', 'd'].includes(userInput)) {
|
|
217
215
|
this.handleDiff();
|
|
218
|
-
this.
|
|
216
|
+
this.rl.prompt();
|
|
219
217
|
return true;
|
|
220
218
|
}
|
|
221
219
|
if (userInput === 'uuddlrlrba' ||
|
|
@@ -239,34 +237,6 @@ class CLI {
|
|
|
239
237
|
this.handleClearCheckpoints();
|
|
240
238
|
return true;
|
|
241
239
|
}
|
|
242
|
-
const runPrefix = '/run ';
|
|
243
|
-
const bangPrefix = '!';
|
|
244
|
-
const hasRunPrefix = userInput.startsWith(runPrefix);
|
|
245
|
-
const hasBangPrefix = userInput.startsWith(bangPrefix);
|
|
246
|
-
if (hasRunPrefix ||
|
|
247
|
-
hasBangPrefix ||
|
|
248
|
-
(!constants_1.SKIPPED_TERMINAL_COMMANDS.some((cmd) => userInput.toLowerCase().startsWith(cmd)) &&
|
|
249
|
-
!userInput.includes('error ') &&
|
|
250
|
-
!userInput.includes("'") &&
|
|
251
|
-
userInput.split(' ').length <= 5)) {
|
|
252
|
-
let commandToRun = userInput;
|
|
253
|
-
if (hasRunPrefix) {
|
|
254
|
-
commandToRun = userInput.replace(runPrefix, '');
|
|
255
|
-
}
|
|
256
|
-
else if (hasBangPrefix) {
|
|
257
|
-
commandToRun = userInput.replace(bangPrefix, '');
|
|
258
|
-
}
|
|
259
|
-
const { result, stdout } = await (0, tool_handlers_1.handleRunTerminalCommand)({ command: commandToRun }, 'user', 'user', (0, project_files_1.getProjectRoot)());
|
|
260
|
-
if (result !== 'command not found') {
|
|
261
|
-
this.promptWithCheckpointNumber();
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
else if (hasRunPrefix || hasBangPrefix) {
|
|
265
|
-
process.stdout.write(stdout);
|
|
266
|
-
this.promptWithCheckpointNumber();
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
240
|
return false;
|
|
271
241
|
}
|
|
272
242
|
async forwardUserInput(userInput) {
|
|
@@ -294,10 +264,10 @@ class CLI {
|
|
|
294
264
|
}
|
|
295
265
|
this.client.showUsageWarning();
|
|
296
266
|
console.log();
|
|
297
|
-
this.
|
|
267
|
+
this.rl.prompt();
|
|
298
268
|
}
|
|
299
269
|
returnControlToUser() {
|
|
300
|
-
this.
|
|
270
|
+
this.rl.prompt();
|
|
301
271
|
this.isReceivingResponse = false;
|
|
302
272
|
if (this.stopResponse) {
|
|
303
273
|
this.stopResponse();
|
|
@@ -322,7 +292,7 @@ class CLI {
|
|
|
322
292
|
const checkpointId = checkpoints_1.checkpointManager.getLatestCheckpoint().id - 1;
|
|
323
293
|
if (checkpointId < 1) {
|
|
324
294
|
console.log((0, picocolors_1.red)('Nothing to undo.'));
|
|
325
|
-
this.
|
|
295
|
+
this.rl.prompt();
|
|
326
296
|
return;
|
|
327
297
|
}
|
|
328
298
|
await this.handleRestoreCheckpoint(checkpointId);
|
|
@@ -365,7 +335,7 @@ class CLI {
|
|
|
365
335
|
else {
|
|
366
336
|
this.lastSigintTime = now;
|
|
367
337
|
console.log('\nPress Ctrl-C again to exit');
|
|
368
|
-
this.
|
|
338
|
+
this.rl.prompt();
|
|
369
339
|
}
|
|
370
340
|
}
|
|
371
341
|
}
|
|
@@ -561,29 +531,34 @@ class CLI {
|
|
|
561
531
|
// Checkpoint command handlers
|
|
562
532
|
async handleCheckpoints() {
|
|
563
533
|
console.log(checkpoints_1.checkpointManager.getCheckpointsAsString());
|
|
564
|
-
this.
|
|
534
|
+
this.rl.prompt();
|
|
565
535
|
}
|
|
566
536
|
async handleRestoreCheckpoint(id) {
|
|
567
537
|
const checkpoint = checkpoints_1.checkpointManager.getCheckpoint(id);
|
|
568
538
|
if (!checkpoint) {
|
|
569
539
|
console.log((0, picocolors_1.red)(`Checkpoint #${id} not found.`));
|
|
570
|
-
this.
|
|
540
|
+
this.rl.prompt();
|
|
571
541
|
return;
|
|
572
542
|
}
|
|
573
543
|
// Wait for save before trying to restore checkpoint
|
|
574
544
|
const latestCheckpoint = checkpoints_1.checkpointManager.getLatestCheckpoint();
|
|
575
545
|
await latestCheckpoint?.fileStateIdPromise;
|
|
546
|
+
if (!latestCheckpoint?.enabled) {
|
|
547
|
+
console.log((0, picocolors_1.red)(`Checkpoints not enabled: project too large`));
|
|
548
|
+
this.rl.prompt();
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
576
551
|
await this.restoreAgentStateAndFiles(checkpoint);
|
|
577
552
|
console.log((0, picocolors_1.green)(`Restored to checkpoint #${id}.`));
|
|
578
553
|
// Insert the original user input that created this checkpoint
|
|
579
|
-
this.
|
|
554
|
+
this.rl.prompt();
|
|
580
555
|
this.rl.write(checkpoint.userInput);
|
|
581
556
|
}
|
|
582
557
|
async restoreAgentStateAndFiles(checkpoint) {
|
|
583
558
|
// Restore the agentState
|
|
584
559
|
this.client.agentState = JSON.parse(checkpoint.agentStateString);
|
|
585
560
|
// Restore file state
|
|
586
|
-
if (!(await checkpoints_1.checkpointManager.
|
|
561
|
+
if (!(await checkpoints_1.checkpointManager.restoreCheckointFileState(checkpoint.id))) {
|
|
587
562
|
throw new assert_1.AssertionError({
|
|
588
563
|
message: `Internal error: checkpoint ${checkpoint.id} not found`,
|
|
589
564
|
});
|
|
@@ -591,7 +566,7 @@ class CLI {
|
|
|
591
566
|
}
|
|
592
567
|
async handleClearCheckpoints() {
|
|
593
568
|
checkpoints_1.checkpointManager.clearCheckpoints();
|
|
594
|
-
this.
|
|
569
|
+
this.rl.prompt();
|
|
595
570
|
}
|
|
596
571
|
}
|
|
597
572
|
exports.CLI = CLI;
|