codebuff 1.0.256 → 1.0.258
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 +294 -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 +485 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +151 -0
- package/dist/client.js +833 -0
- package/dist/client.js.map +1 -0
- package/dist/common/constants/analytics-events.d.ts +2 -1
- package/dist/common/constants/analytics-events.js +2 -1
- package/dist/common/constants/analytics-events.js.map +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/display.d.ts +9 -0
- package/dist/display.js +68 -0
- package/dist/display.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 +119 -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 +75 -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/git.d.ts +1 -0
- package/dist/utils/git.js +23 -0
- package/dist/utils/git.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 +43 -0
- package/dist/utils/terminal.js +493 -0
- package/dist/utils/terminal.js.map +1 -0
- package/dist/utils/tool-renderers.d.ts +16 -0
- package/dist/utils/tool-renderers.js +148 -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
package/dist/cli.js
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.CLI = void 0;
|
|
27
|
+
const fs_1 = require("fs");
|
|
28
|
+
const os_1 = require("os");
|
|
29
|
+
const path_1 = __importStar(require("path"));
|
|
30
|
+
const readline = __importStar(require("readline"));
|
|
31
|
+
const analytics_events_1 = require("./common/constants/analytics-events");
|
|
32
|
+
const string_1 = require("./common/util/string");
|
|
33
|
+
const picocolors_1 = require("picocolors");
|
|
34
|
+
const background_process_manager_1 = require("./background-process-manager");
|
|
35
|
+
const chat_storage_1 = require("./chat-storage");
|
|
36
|
+
const checkpoint_manager_1 = require("./checkpoints/checkpoint-manager");
|
|
37
|
+
const api_key_1 = require("./cli-handlers/api-key");
|
|
38
|
+
const checkpoint_1 = require("./cli-handlers/checkpoint");
|
|
39
|
+
const diff_1 = require("./cli-handlers/diff");
|
|
40
|
+
const easter_egg_1 = require("./cli-handlers/easter-egg");
|
|
41
|
+
const inititalization_flow_1 = require("./cli-handlers/inititalization-flow");
|
|
42
|
+
const client_1 = require("./client");
|
|
43
|
+
const config_1 = require("./config");
|
|
44
|
+
const display_1 = require("./display");
|
|
45
|
+
const menu_1 = require("./menu");
|
|
46
|
+
const project_files_1 = require("./project-files");
|
|
47
|
+
const analytics_1 = require("./utils/analytics");
|
|
48
|
+
const spinner_1 = require("./utils/spinner");
|
|
49
|
+
const terminal_1 = require("./utils/terminal");
|
|
50
|
+
class CLI {
|
|
51
|
+
client;
|
|
52
|
+
readyPromise;
|
|
53
|
+
git;
|
|
54
|
+
costMode;
|
|
55
|
+
rl;
|
|
56
|
+
isReceivingResponse = false;
|
|
57
|
+
stopResponse = null;
|
|
58
|
+
lastSigintTime = 0;
|
|
59
|
+
lastInputTime = 0;
|
|
60
|
+
consecutiveFastInputs = 0;
|
|
61
|
+
pastedContent = '';
|
|
62
|
+
isPasting = false;
|
|
63
|
+
shouldReconnectWhenIdle = false;
|
|
64
|
+
constructor(readyPromise, { git, costMode, model }) {
|
|
65
|
+
this.git = git;
|
|
66
|
+
this.costMode = costMode;
|
|
67
|
+
this.setupSignalHandlers();
|
|
68
|
+
this.initReadlineInterface();
|
|
69
|
+
this.client = new client_1.Client({
|
|
70
|
+
websocketUrl: config_1.websocketUrl,
|
|
71
|
+
onWebSocketError: this.onWebSocketError.bind(this),
|
|
72
|
+
onWebSocketReconnect: this.onWebSocketReconnect.bind(this),
|
|
73
|
+
freshPrompt: this.freshPrompt.bind(this),
|
|
74
|
+
reconnectWhenNextIdle: this.reconnectWhenNextIdle.bind(this),
|
|
75
|
+
costMode: this.costMode,
|
|
76
|
+
git: this.git,
|
|
77
|
+
rl: this.rl,
|
|
78
|
+
model,
|
|
79
|
+
});
|
|
80
|
+
this.readyPromise = Promise.all([
|
|
81
|
+
readyPromise.then((results) => {
|
|
82
|
+
const [fileContext, ,] = results;
|
|
83
|
+
this.client.initAgentState(fileContext);
|
|
84
|
+
return this.client.warmContextCache();
|
|
85
|
+
}),
|
|
86
|
+
this.client.connect(),
|
|
87
|
+
]);
|
|
88
|
+
this.setPrompt();
|
|
89
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
90
|
+
console.error('\nUnhandled Rejection at:', promise, 'reason:', reason);
|
|
91
|
+
this.freshPrompt();
|
|
92
|
+
});
|
|
93
|
+
process.on('uncaughtException', (err, origin) => {
|
|
94
|
+
console.error(`\nCaught exception: ${err}\n` + `Exception origin: ${origin}`);
|
|
95
|
+
console.error(err.stack);
|
|
96
|
+
this.freshPrompt();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
setupSignalHandlers() {
|
|
100
|
+
process.on('exit', () => {
|
|
101
|
+
spinner_1.Spinner.get().restoreCursor();
|
|
102
|
+
// Kill the persistent PTY process first
|
|
103
|
+
if (terminal_1.persistentProcess?.type === 'pty') {
|
|
104
|
+
terminal_1.persistentProcess.pty.kill();
|
|
105
|
+
}
|
|
106
|
+
(0, background_process_manager_1.sendKillSignalToAllBackgroundProcesses)();
|
|
107
|
+
console.log((0, picocolors_1.green)('Codebuff out!'));
|
|
108
|
+
});
|
|
109
|
+
for (const signal of ['SIGTERM', 'SIGHUP']) {
|
|
110
|
+
process.on(signal, async () => {
|
|
111
|
+
process.removeAllListeners('unhandledRejection');
|
|
112
|
+
process.removeAllListeners('uncaughtException');
|
|
113
|
+
spinner_1.Spinner.get().restoreCursor();
|
|
114
|
+
await (0, background_process_manager_1.killAllBackgroundProcesses)();
|
|
115
|
+
await (0, analytics_1.flushAnalytics)();
|
|
116
|
+
process.exit(0);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
process.on('SIGTSTP', async () => await this.handleExit());
|
|
120
|
+
// Doesn't catch SIGKILL (e.g. `kill -9`)
|
|
121
|
+
}
|
|
122
|
+
initReadlineInterface() {
|
|
123
|
+
this.rl = readline.createInterface({
|
|
124
|
+
input: process.stdin,
|
|
125
|
+
output: process.stdout,
|
|
126
|
+
historySize: 1000,
|
|
127
|
+
terminal: true,
|
|
128
|
+
completer: this.filePathCompleter.bind(this),
|
|
129
|
+
});
|
|
130
|
+
this.rl.on('line', (line) => this.handleLine(line));
|
|
131
|
+
this.rl.on('SIGINT', async () => await this.handleSigint());
|
|
132
|
+
this.rl.on('close', async () => await this.handleExit());
|
|
133
|
+
process.stdin.on('keypress', (str, key) => this.handleKeyPress(str, key));
|
|
134
|
+
}
|
|
135
|
+
filePathCompleter(line) {
|
|
136
|
+
const lastWord = line.split(' ').pop() || '';
|
|
137
|
+
const input = lastWord.startsWith('~')
|
|
138
|
+
? (0, os_1.homedir)() + lastWord.slice(1)
|
|
139
|
+
: lastWord;
|
|
140
|
+
const directorySuffix = process.platform === 'win32' ? '\\' : '/';
|
|
141
|
+
const dir = input.endsWith(directorySuffix)
|
|
142
|
+
? input.slice(0, input.length - 1)
|
|
143
|
+
: (0, path_1.dirname)(input);
|
|
144
|
+
const partial = input.endsWith(directorySuffix) ? '' : (0, path_1.basename)(input);
|
|
145
|
+
let baseDir = (0, path_1.isAbsolute)(dir) ? dir : path_1.default.join((0, project_files_1.getProjectRoot)(), dir);
|
|
146
|
+
try {
|
|
147
|
+
const files = (0, fs_1.readdirSync)(baseDir);
|
|
148
|
+
const matches = files
|
|
149
|
+
.filter((file) => file.startsWith(partial))
|
|
150
|
+
.map((file) => file + ((0, project_files_1.isDir)(path_1.default.join(baseDir, file)) ? directorySuffix : ''));
|
|
151
|
+
return [matches, partial];
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return [[], line];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
setPrompt() {
|
|
158
|
+
this.rl.setPrompt((0, picocolors_1.green)(`${(0, path_1.parse)((0, project_files_1.getProjectRoot)()).base} > `));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Prompts the user with a clean prompt state
|
|
162
|
+
*/
|
|
163
|
+
freshPrompt(userInput = '') {
|
|
164
|
+
spinner_1.Spinner.get().stop();
|
|
165
|
+
this.isReceivingResponse = false;
|
|
166
|
+
if (this.shouldReconnectWhenIdle) {
|
|
167
|
+
this.client.reconnect();
|
|
168
|
+
this.shouldReconnectWhenIdle = false;
|
|
169
|
+
}
|
|
170
|
+
readline.cursorTo(process.stdout, 0);
|
|
171
|
+
const rlAny = this.rl;
|
|
172
|
+
// Check for pending auto-topup message before showing prompt
|
|
173
|
+
if (this.client.pendingTopUpMessageAmount > 0) {
|
|
174
|
+
console.log('\n\n' +
|
|
175
|
+
(0, picocolors_1.green)(`Auto top-up successful! ${this.client.pendingTopUpMessageAmount.toLocaleString()} credits added.`) +
|
|
176
|
+
'\n');
|
|
177
|
+
this.client.pendingTopUpMessageAmount = 0;
|
|
178
|
+
}
|
|
179
|
+
// clear line first
|
|
180
|
+
rlAny.line = '';
|
|
181
|
+
this.setPrompt();
|
|
182
|
+
// then prompt
|
|
183
|
+
this.rl.prompt();
|
|
184
|
+
(0, display_1.disableSquashNewlines)();
|
|
185
|
+
if (!userInput) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// then rewrite new prompt
|
|
189
|
+
this.rl.write(' '.repeat(userInput.length)); // hacky way to move cursor
|
|
190
|
+
rlAny.line = userInput;
|
|
191
|
+
rlAny._refreshLine();
|
|
192
|
+
}
|
|
193
|
+
async printInitialPrompt({ initialInput, runInitFlow, }) {
|
|
194
|
+
if (this.client.user) {
|
|
195
|
+
(0, menu_1.displayGreeting)(this.costMode, this.client.user.name);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
console.log(`Welcome to Codebuff! Give us a sec to get your account set up...`);
|
|
199
|
+
await this.client.login();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
this.freshPrompt();
|
|
203
|
+
if (runInitFlow) {
|
|
204
|
+
process.stdout.write('init\n');
|
|
205
|
+
await this.handleUserInput('init');
|
|
206
|
+
}
|
|
207
|
+
if (initialInput) {
|
|
208
|
+
process.stdout.write(initialInput + '\n');
|
|
209
|
+
await this.handleUserInput(initialInput);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async printDiff() {
|
|
213
|
+
(0, diff_1.handleDiff)(this.client.lastChanges);
|
|
214
|
+
this.freshPrompt();
|
|
215
|
+
}
|
|
216
|
+
async handleLine(line) {
|
|
217
|
+
this.detectPasting();
|
|
218
|
+
if (this.isPasting) {
|
|
219
|
+
this.pastedContent += line + '\n';
|
|
220
|
+
}
|
|
221
|
+
else if (!this.isReceivingResponse) {
|
|
222
|
+
if (this.pastedContent) {
|
|
223
|
+
await this.handleUserInput((this.pastedContent + line).trim());
|
|
224
|
+
this.pastedContent = '';
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
await this.handleUserInput(line.trim());
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async handleUserInput(userInput) {
|
|
232
|
+
(0, display_1.enableSquashNewlines)();
|
|
233
|
+
this.rl.setPrompt('');
|
|
234
|
+
if (!userInput) {
|
|
235
|
+
this.freshPrompt();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
userInput = userInput.trim();
|
|
239
|
+
if (await this.processCommand(userInput)) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
await this.forwardUserInput(userInput);
|
|
243
|
+
}
|
|
244
|
+
async processCommand(userInput) {
|
|
245
|
+
if (userInput === 'help' || userInput === 'h' || userInput === '/help') {
|
|
246
|
+
(0, menu_1.displayMenu)();
|
|
247
|
+
this.freshPrompt();
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
if (userInput === 'login' || userInput === 'signin') {
|
|
251
|
+
await this.client.login();
|
|
252
|
+
checkpoint_manager_1.checkpointManager.clearCheckpoints();
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
if (userInput === 'logout' || userInput === 'signout') {
|
|
256
|
+
await this.client.logout();
|
|
257
|
+
this.freshPrompt();
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
if (userInput.startsWith('ref-')) {
|
|
261
|
+
await this.client.handleReferralCode(userInput.trim());
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
// Detect potential API key input first
|
|
265
|
+
const detectionResult = (0, api_key_1.detectApiKey)(userInput);
|
|
266
|
+
if (detectionResult.status !== 'not_found') {
|
|
267
|
+
// If something resembling an API key was detected (valid or just prefix), handle it
|
|
268
|
+
await (0, api_key_1.handleApiKeyInput)(this.client, detectionResult, this.readyPromise, this.freshPrompt.bind(this));
|
|
269
|
+
return true; // Indicate command was handled
|
|
270
|
+
}
|
|
271
|
+
// Continue with other commands if no API key input was detected/handled
|
|
272
|
+
if (userInput === 'usage' || userInput === 'credits') {
|
|
273
|
+
await this.client.getUsage();
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
if (userInput === 'quit' || userInput === 'exit' || userInput === 'q') {
|
|
277
|
+
await this.handleExit();
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
if (['diff', 'doff', 'dif', 'iff', 'd'].includes(userInput)) {
|
|
281
|
+
(0, diff_1.handleDiff)(this.client.lastChanges);
|
|
282
|
+
this.freshPrompt();
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
if (userInput === 'uuddlrlrba' ||
|
|
286
|
+
userInput === 'konami' ||
|
|
287
|
+
userInput === 'codebuffy') {
|
|
288
|
+
(0, easter_egg_1.showEasterEgg)(this.freshPrompt.bind(this));
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
// Checkpoint commands
|
|
292
|
+
if ((0, checkpoint_1.isCheckpointCommand)(userInput)) {
|
|
293
|
+
(0, analytics_1.trackEvent)(analytics_events_1.AnalyticsEvent.CHECKPOINT_COMMAND_USED, {
|
|
294
|
+
command: userInput,
|
|
295
|
+
});
|
|
296
|
+
if ((0, checkpoint_1.isCheckpointCommand)(userInput, 'undo')) {
|
|
297
|
+
await (0, checkpoint_1.saveCheckpoint)(userInput, this.client, this.readyPromise);
|
|
298
|
+
const toRestore = await (0, checkpoint_1.handleUndo)(this.client, this.rl);
|
|
299
|
+
this.freshPrompt(toRestore);
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
if ((0, checkpoint_1.isCheckpointCommand)(userInput, 'redo')) {
|
|
303
|
+
await (0, checkpoint_1.saveCheckpoint)(userInput, this.client, this.readyPromise);
|
|
304
|
+
const toRestore = await (0, checkpoint_1.handleRedo)(this.client, this.rl);
|
|
305
|
+
this.freshPrompt(toRestore);
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
if ((0, checkpoint_1.isCheckpointCommand)(userInput, 'list')) {
|
|
309
|
+
await (0, checkpoint_1.saveCheckpoint)(userInput, this.client, this.readyPromise);
|
|
310
|
+
await (0, checkpoint_1.listCheckpoints)();
|
|
311
|
+
this.freshPrompt();
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
const restoreMatch = (0, checkpoint_1.isCheckpointCommand)(userInput, 'restore');
|
|
315
|
+
if (restoreMatch) {
|
|
316
|
+
const id = parseInt(restoreMatch[1], 10);
|
|
317
|
+
await (0, checkpoint_1.saveCheckpoint)(userInput, this.client, this.readyPromise);
|
|
318
|
+
const toRestore = await (0, checkpoint_1.handleRestoreCheckpoint)(id, this.client, this.rl);
|
|
319
|
+
this.freshPrompt(toRestore);
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
if ((0, checkpoint_1.isCheckpointCommand)(userInput, 'clear')) {
|
|
323
|
+
(0, checkpoint_1.handleClearCheckpoints)();
|
|
324
|
+
this.freshPrompt();
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
if ((0, checkpoint_1.isCheckpointCommand)(userInput, 'save')) {
|
|
328
|
+
await (0, checkpoint_1.saveCheckpoint)(userInput, this.client, this.readyPromise, true);
|
|
329
|
+
(0, checkpoint_1.displayCheckpointMenu)();
|
|
330
|
+
this.freshPrompt();
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
(0, checkpoint_1.displayCheckpointMenu)();
|
|
334
|
+
this.freshPrompt();
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
if (userInput === 'init') {
|
|
338
|
+
// no need to save checkpoint, since we are passing request to backend
|
|
339
|
+
(0, inititalization_flow_1.handleInitializationFlowLocally)();
|
|
340
|
+
// Also forward user input to the backend
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
async forwardUserInput(userInput) {
|
|
346
|
+
await (0, checkpoint_1.saveCheckpoint)(userInput, this.client, this.readyPromise);
|
|
347
|
+
spinner_1.Spinner.get().start();
|
|
348
|
+
this.client.lastChanges = [];
|
|
349
|
+
const newMessage = {
|
|
350
|
+
role: 'user',
|
|
351
|
+
content: userInput,
|
|
352
|
+
};
|
|
353
|
+
if (this.client.agentState) {
|
|
354
|
+
(0, chat_storage_1.setMessages)([...this.client.agentState.messageHistory, newMessage]);
|
|
355
|
+
}
|
|
356
|
+
this.isReceivingResponse = true;
|
|
357
|
+
const { responsePromise, stopResponse } = await this.client.sendUserInput(userInput);
|
|
358
|
+
this.stopResponse = stopResponse;
|
|
359
|
+
await responsePromise;
|
|
360
|
+
this.stopResponse = null;
|
|
361
|
+
this.isReceivingResponse = false;
|
|
362
|
+
spinner_1.Spinner.get().stop();
|
|
363
|
+
this.freshPrompt();
|
|
364
|
+
}
|
|
365
|
+
reconnectWhenNextIdle() {
|
|
366
|
+
if (!this.isReceivingResponse) {
|
|
367
|
+
this.client.reconnect();
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
this.shouldReconnectWhenIdle = true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
onWebSocketError() {
|
|
374
|
+
spinner_1.Spinner.get().stop();
|
|
375
|
+
this.isReceivingResponse = false;
|
|
376
|
+
if (this.stopResponse) {
|
|
377
|
+
this.stopResponse();
|
|
378
|
+
this.stopResponse = null;
|
|
379
|
+
}
|
|
380
|
+
console.error((0, picocolors_1.yellow)('\nCould not connect. Retrying...'));
|
|
381
|
+
}
|
|
382
|
+
onWebSocketReconnect() {
|
|
383
|
+
console.log((0, picocolors_1.green)('\nReconnected!'));
|
|
384
|
+
this.freshPrompt();
|
|
385
|
+
}
|
|
386
|
+
handleKeyPress(str, key) {
|
|
387
|
+
if (key.name === 'escape') {
|
|
388
|
+
this.handleEscKey();
|
|
389
|
+
}
|
|
390
|
+
if (!this.isPasting &&
|
|
391
|
+
str === ' ' &&
|
|
392
|
+
'_refreshLine' in this.rl &&
|
|
393
|
+
'line' in this.rl &&
|
|
394
|
+
'cursor' in this.rl) {
|
|
395
|
+
const rlAny = this.rl;
|
|
396
|
+
const { cursor, line } = rlAny;
|
|
397
|
+
const prevTwoChars = cursor > 1 ? line.slice(cursor - 2, cursor) : '';
|
|
398
|
+
if (prevTwoChars === ' ') {
|
|
399
|
+
rlAny.line = line.slice(0, cursor - 2) + '\n\n' + line.slice(cursor);
|
|
400
|
+
rlAny._refreshLine();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
this.detectPasting();
|
|
404
|
+
}
|
|
405
|
+
async handleSigint() {
|
|
406
|
+
if ((0, terminal_1.isCommandRunning)()) {
|
|
407
|
+
(0, terminal_1.resetShell)((0, project_files_1.getProjectRoot)());
|
|
408
|
+
}
|
|
409
|
+
if ('line' in this.rl) {
|
|
410
|
+
;
|
|
411
|
+
this.rl.line = '';
|
|
412
|
+
}
|
|
413
|
+
if (this.isReceivingResponse) {
|
|
414
|
+
this.handleStopResponse();
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
const now = Date.now();
|
|
418
|
+
if (now - this.lastSigintTime < 5000) {
|
|
419
|
+
await this.handleExit();
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
this.lastSigintTime = now;
|
|
423
|
+
console.log('\nPress Ctrl-C again to exit');
|
|
424
|
+
this.freshPrompt();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
handleEscKey() {
|
|
429
|
+
if (this.isReceivingResponse) {
|
|
430
|
+
this.handleStopResponse();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
handleStopResponse() {
|
|
434
|
+
console.log((0, picocolors_1.yellow)('\n[Response stopped by user]'));
|
|
435
|
+
this.isReceivingResponse = false;
|
|
436
|
+
if (this.stopResponse) {
|
|
437
|
+
this.stopResponse();
|
|
438
|
+
}
|
|
439
|
+
spinner_1.Spinner.get().stop();
|
|
440
|
+
}
|
|
441
|
+
async handleExit() {
|
|
442
|
+
spinner_1.Spinner.get().restoreCursor();
|
|
443
|
+
process.removeAllListeners('unhandledRejection');
|
|
444
|
+
process.removeAllListeners('uncaughtException');
|
|
445
|
+
console.log('\n');
|
|
446
|
+
// Kill the persistent PTY process first
|
|
447
|
+
(0, terminal_1.killAndResetPersistentProcess)();
|
|
448
|
+
await (0, background_process_manager_1.killAllBackgroundProcesses)();
|
|
449
|
+
const logMessages = [];
|
|
450
|
+
const totalCreditsUsedThisSession = Object.values(this.client.creditsByPromptId)
|
|
451
|
+
.flat()
|
|
452
|
+
.reduce((sum, credits) => sum + credits, 0);
|
|
453
|
+
logMessages.push(`${(0, string_1.pluralize)(totalCreditsUsedThisSession, 'credit')} used this session${this.client.usageData.remainingBalance !== null
|
|
454
|
+
? `, ${this.client.usageData.remainingBalance.toLocaleString()} credits left.`
|
|
455
|
+
: '.'}`);
|
|
456
|
+
if (this.client.usageData.next_quota_reset) {
|
|
457
|
+
const daysUntilReset = Math.ceil((new Date(this.client.usageData.next_quota_reset).getTime() -
|
|
458
|
+
Date.now()) /
|
|
459
|
+
(1000 * 60 * 60 * 24));
|
|
460
|
+
logMessages.push(`Your free credits will reset in ${(0, string_1.pluralize)(daysUntilReset, 'day')}.`);
|
|
461
|
+
}
|
|
462
|
+
console.log(logMessages.join(' '));
|
|
463
|
+
await (0, analytics_1.flushAnalytics)();
|
|
464
|
+
process.exit(0);
|
|
465
|
+
}
|
|
466
|
+
detectPasting() {
|
|
467
|
+
const currentTime = Date.now();
|
|
468
|
+
const timeDiff = currentTime - this.lastInputTime;
|
|
469
|
+
if (timeDiff < 10) {
|
|
470
|
+
this.consecutiveFastInputs++;
|
|
471
|
+
if (this.consecutiveFastInputs >= 2) {
|
|
472
|
+
this.isPasting = true;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
this.consecutiveFastInputs = 0;
|
|
477
|
+
if (this.isPasting) {
|
|
478
|
+
this.isPasting = false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
this.lastInputTime = currentTime;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
exports.CLI = CLI;
|
|
485
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAgC;AAChC,2BAA4B;AAC5B,6CAAiE;AACjE,mDAAoC;AAIpC,wEAAkE;AAGlE,+CAA8C;AAC9C,2CAA0C;AAE1C,6EAGqC;AACrC,iDAA4C;AAC5C,yEAAoE;AACpE,oDAAwE;AACxE,0DASkC;AAClC,8CAAgD;AAChD,0DAAyD;AACzD,8EAAqF;AACrF,qCAAiC;AACjC,qCAAuC;AACvC,uCAAuE;AACvE,iCAAqD;AACrD,mDAAuD;AAEvD,iDAA8D;AAC9D,6CAAyC;AACzC,+CAKyB;AAOzB,MAAa,GAAG;IACN,MAAM,CAAQ;IACd,YAAY,CAAc;IAC1B,GAAG,CAAY;IACf,QAAQ,CAAU;IAClB,EAAE,CAAqB;IACvB,mBAAmB,GAAY,KAAK,CAAA;IACpC,YAAY,GAAwB,IAAI,CAAA;IACxC,cAAc,GAAW,CAAC,CAAA;IAC1B,aAAa,GAAW,CAAC,CAAA;IACzB,qBAAqB,GAAW,CAAC,CAAA;IACjC,aAAa,GAAW,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C,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE;gBACzD,IAAI,CAAC,GAAG,EAAE,CAAC;gBACX,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CACxB,CAAA;YACD,WAAW,CAAC,IAAI,CACd,mCAAmC,IAAA,kBAAS,EAAC,cAAc,EAAE,KAAK,CAAC,GAAG,CACvE,CAAA;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QAClC,MAAM,IAAA,0BAAc,GAAE,CAAA;QAEtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAEO,aAAa;QACnB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC9B,MAAM,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC,aAAa,CAAA;QACjD,IAAI,QAAQ,GAAG,EAAE,EAAE,CAAC;YAClB,IAAI,CAAC,qBAAqB,EAAE,CAAA;YAC5B,IAAI,IAAI,CAAC,qBAAqB,IAAI,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;YACvB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAA;YAC9B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;YACxB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,WAAW,CAAA;IAClC,CAAC;CACF;AAphBD,kBAohBC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Interface } from 'readline';
|
|
2
|
+
import { FileChanges, UsageResponse } from './common/actions';
|
|
3
|
+
import { ApiKeyType } from './common/api-keys/constants';
|
|
4
|
+
import { CostMode } from './common/constants';
|
|
5
|
+
import { AgentState, ToolResult } from './common/types/agent-state';
|
|
6
|
+
import { User } from './common/util/credentials';
|
|
7
|
+
import { ProjectFileContext } from './common/util/file';
|
|
8
|
+
import { GitCommand, MakeNullable } from './types';
|
|
9
|
+
type UsageData = Omit<MakeNullable<UsageResponse, 'remainingBalance'>, 'type'>;
|
|
10
|
+
export declare class Client {
|
|
11
|
+
private webSocket;
|
|
12
|
+
private freshPrompt;
|
|
13
|
+
private reconnectWhenNextIdle;
|
|
14
|
+
private fingerprintId;
|
|
15
|
+
private costMode;
|
|
16
|
+
private hadFileChanges;
|
|
17
|
+
private git;
|
|
18
|
+
private rl;
|
|
19
|
+
private responseComplete;
|
|
20
|
+
private responseBuffer;
|
|
21
|
+
private oneTimeFlags;
|
|
22
|
+
usageData: UsageData;
|
|
23
|
+
pendingTopUpMessageAmount: number;
|
|
24
|
+
fileContext: ProjectFileContext | undefined;
|
|
25
|
+
lastChanges: FileChanges;
|
|
26
|
+
agentState: AgentState | undefined;
|
|
27
|
+
originalFileVersions: Record<string, string | null>;
|
|
28
|
+
creditsByPromptId: Record<string, number[]>;
|
|
29
|
+
user: User | undefined;
|
|
30
|
+
lastWarnedPct: number;
|
|
31
|
+
storedApiKeyTypes: ApiKeyType[];
|
|
32
|
+
lastToolResults: ToolResult[];
|
|
33
|
+
model: string | undefined;
|
|
34
|
+
constructor({ websocketUrl, onWebSocketError, onWebSocketReconnect, freshPrompt, reconnectWhenNextIdle, costMode, git, rl, model, }: {
|
|
35
|
+
websocketUrl: string;
|
|
36
|
+
onWebSocketError: () => void;
|
|
37
|
+
onWebSocketReconnect: () => void;
|
|
38
|
+
freshPrompt: () => void;
|
|
39
|
+
reconnectWhenNextIdle: () => void;
|
|
40
|
+
costMode: CostMode;
|
|
41
|
+
git: GitCommand;
|
|
42
|
+
rl: Interface;
|
|
43
|
+
model: string | undefined;
|
|
44
|
+
});
|
|
45
|
+
exit(): Promise<void>;
|
|
46
|
+
initAgentState(projectFileContext: ProjectFileContext): void;
|
|
47
|
+
private initFingerprintId;
|
|
48
|
+
private getUser;
|
|
49
|
+
connect(): Promise<void>;
|
|
50
|
+
fetchStoredApiKeyTypes(): Promise<void>;
|
|
51
|
+
handleAddApiKey(keyType: ApiKeyType, apiKey: string): Promise<void>;
|
|
52
|
+
handleReferralCode(referralCode: string): Promise<void>;
|
|
53
|
+
logout(): Promise<void>;
|
|
54
|
+
login(referralCode?: string): Promise<void>;
|
|
55
|
+
setUsage(usageData: Omit<UsageResponse, 'type'>): void;
|
|
56
|
+
reconnect(): void;
|
|
57
|
+
private setupSubscriptions;
|
|
58
|
+
private showUsageWarning;
|
|
59
|
+
generateCommitMessage(stagedChanges: string): Promise<string>;
|
|
60
|
+
sendUserInput(prompt: string): Promise<{
|
|
61
|
+
responsePromise: Promise<{
|
|
62
|
+
type: "prompt-response";
|
|
63
|
+
promptId: string;
|
|
64
|
+
agentState: {
|
|
65
|
+
agentContext: string;
|
|
66
|
+
fileContext: {
|
|
67
|
+
currentWorkingDirectory: string;
|
|
68
|
+
fileTree: import("./common/util/file").FileTreeNode[];
|
|
69
|
+
fileTokenScores: Record<string, Record<string, number>>;
|
|
70
|
+
knowledgeFiles: Record<string, string>;
|
|
71
|
+
gitChanges: {
|
|
72
|
+
status: string;
|
|
73
|
+
diff: string;
|
|
74
|
+
diffCached: string;
|
|
75
|
+
lastCommitMessages: string;
|
|
76
|
+
};
|
|
77
|
+
changesSinceLastChat: Record<string, string>;
|
|
78
|
+
shellConfigFiles: Record<string, string>;
|
|
79
|
+
systemInfo: {
|
|
80
|
+
platform: string;
|
|
81
|
+
shell: string;
|
|
82
|
+
nodeVersion: string;
|
|
83
|
+
arch: string;
|
|
84
|
+
homedir: string;
|
|
85
|
+
cpus: number;
|
|
86
|
+
};
|
|
87
|
+
userKnowledgeFiles?: Record<string, string> | undefined;
|
|
88
|
+
fileVersions?: {
|
|
89
|
+
path: string;
|
|
90
|
+
content: string;
|
|
91
|
+
}[][] | undefined;
|
|
92
|
+
};
|
|
93
|
+
messageHistory: {
|
|
94
|
+
content: string | ({
|
|
95
|
+
type: "text";
|
|
96
|
+
text: string;
|
|
97
|
+
cache_control?: {
|
|
98
|
+
type: "ephemeral";
|
|
99
|
+
} | undefined;
|
|
100
|
+
} | {
|
|
101
|
+
type: "tool_use";
|
|
102
|
+
name: string;
|
|
103
|
+
id: string;
|
|
104
|
+
input: Record<string, any>;
|
|
105
|
+
cache_control?: {
|
|
106
|
+
type: "ephemeral";
|
|
107
|
+
} | undefined;
|
|
108
|
+
} | {
|
|
109
|
+
type: "tool_result";
|
|
110
|
+
content: string;
|
|
111
|
+
tool_use_id: string;
|
|
112
|
+
cache_control?: {
|
|
113
|
+
type: "ephemeral";
|
|
114
|
+
} | undefined;
|
|
115
|
+
} | {
|
|
116
|
+
type: "image";
|
|
117
|
+
source: {
|
|
118
|
+
type: "base64";
|
|
119
|
+
media_type: "image/jpeg";
|
|
120
|
+
data: string;
|
|
121
|
+
};
|
|
122
|
+
cache_control?: {
|
|
123
|
+
type: "ephemeral";
|
|
124
|
+
} | undefined;
|
|
125
|
+
})[];
|
|
126
|
+
role: "user" | "assistant";
|
|
127
|
+
}[];
|
|
128
|
+
consecutiveAssistantMessages?: number | undefined;
|
|
129
|
+
};
|
|
130
|
+
toolResults: {
|
|
131
|
+
name: string;
|
|
132
|
+
id: string;
|
|
133
|
+
result: string;
|
|
134
|
+
}[];
|
|
135
|
+
toolCalls: {
|
|
136
|
+
name: string;
|
|
137
|
+
id: string;
|
|
138
|
+
parameters: Record<string, string>;
|
|
139
|
+
}[];
|
|
140
|
+
} & {
|
|
141
|
+
type: "prompt-response";
|
|
142
|
+
} & {
|
|
143
|
+
wasStoppedByUser: boolean;
|
|
144
|
+
}>;
|
|
145
|
+
stopResponse: () => void;
|
|
146
|
+
}>;
|
|
147
|
+
private subscribeToResponse;
|
|
148
|
+
getUsage(): Promise<void>;
|
|
149
|
+
warmContextCache(): Promise<void>;
|
|
150
|
+
}
|
|
151
|
+
export {};
|