codebuff 1.0.294 → 1.0.296
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 +3 -3
- package/dist/browser-runner.d.ts +35 -0
- package/dist/browser-runner.js +4 -4
- package/dist/chat-storage.d.ts +2 -0
- package/dist/chat-storage.js +2 -2
- package/dist/chat-storage.js.map +1 -1
- package/dist/checkpoints/checkpoint-manager.d.ts +94 -0
- package/dist/checkpoints/checkpoint-manager.js +1 -1
- 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-definitions.d.ts +9 -0
- package/dist/cli-definitions.js +54 -0
- package/dist/cli-definitions.js.map +1 -0
- package/dist/cli-handlers/api-key.d.ts +25 -0
- package/dist/cli-handlers/api-key.js +1 -1
- package/dist/cli-handlers/checkpoint.d.ts +18 -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 +1 -1
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +87 -30
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +10 -7
- package/dist/client.js +71 -12
- package/dist/client.js.map +1 -1
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- package/dist/common/actions.d.ts +3 -0
- package/dist/common/actions.js +1 -0
- package/dist/common/actions.js.map +1 -1
- package/dist/common/analytics.d.ts +1 -0
- package/dist/common/analytics.js +7 -0
- package/dist/common/analytics.js.map +1 -1
- package/dist/common/browser-actions.d.ts +234 -234
- package/dist/common/credit-delegation.d.ts +19 -0
- package/dist/common/credit-delegation.js +97 -0
- package/dist/common/credit-delegation.js.map +1 -0
- package/dist/common/types/organization.d.ts +102 -0
- package/dist/common/types/organization.js +3 -0
- package/dist/common/types/organization.js.map +1 -0
- package/dist/common/util/changes.d.ts +1 -0
- package/dist/common/util/changes.js +13 -4
- package/dist/common/util/changes.js.map +1 -1
- package/dist/common/websockets/websocket-schema.d.ts +10 -0
- 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 +2 -2
- package/dist/dev-process-manager.d.ts +10 -0
- package/dist/dev-process-manager.js +1 -1
- package/dist/display.d.ts +11 -0
- package/dist/display.js +85 -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 +2 -2
- package/dist/menu.d.ts +14 -0
- package/dist/menu.js +319 -0
- package/dist/menu.js.map +1 -0
- package/dist/organization-context.d.ts +47 -0
- package/dist/organization-context.js +170 -0
- package/dist/organization-context.js.map +1 -0
- package/dist/project-files.d.ts +4 -3
- package/dist/project-files.js +17 -8
- package/dist/project-files.js.map +1 -1
- package/dist/slash-commands.d.ts +7 -0
- package/dist/slash-commands.js +21 -0
- package/dist/slash-commands.js.map +1 -0
- package/dist/startup-process-handler.d.ts +2 -0
- package/dist/tool-handlers.d.ts +2 -2
- package/dist/tool-handlers.js +9 -6
- package/dist/tool-handlers.js.map +1 -1
- 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 +7 -4
- package/dist/update-codebuff.js.map +1 -1
- package/dist/utils/__tests__/background-process-manager.test.d.ts +1 -0
- package/dist/utils/__tests__/background-process-manager.test.js +327 -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 +2 -2
- package/dist/utils/__tests__/xml-stream-parser.test.d.ts +1 -0
- package/dist/utils/__tests__/xml-stream-parser.test.js +1 -1
- package/dist/utils/analytics.d.ts +7 -0
- package/dist/utils/analytics.js +8 -0
- package/dist/utils/analytics.js.map +1 -1
- 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 +10 -0
- package/dist/utils/git.js +112 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image.d.ts +4 -0
- package/dist/utils/image.js +67 -0
- package/dist/utils/image.js.map +1 -0
- package/dist/utils/logger.d.ts +21 -0
- package/dist/utils/logger.js +14 -7
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/spinner.d.ts +12 -0
- package/dist/utils/spinner.js +94 -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 +44 -0
- package/dist/utils/terminal.js +11 -7
- package/dist/utils/terminal.js.map +1 -1
- package/dist/utils/tool-renderers.d.ts +16 -0
- package/dist/utils/tool-renderers.js +2 -2
- package/dist/utils/xml-stream-parser.d.ts +1 -1
- package/dist/utils/xml-stream-parser.js +2 -2
- package/dist/web-scraper.d.ts +3 -0
- package/dist/web-scraper.js +1 -1
- 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 +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cliOptions = exports.cliArguments = void 0;
|
|
4
|
+
exports.cliArguments = [
|
|
5
|
+
{
|
|
6
|
+
flags: '[project-directory]',
|
|
7
|
+
description: 'Project directory (default: current directory)',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
flags: '[initial-prompt...]',
|
|
11
|
+
description: 'Initial prompt to send',
|
|
12
|
+
menuDescription: 'Initial prompt to send to Codebuff',
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
exports.cliOptions = [
|
|
16
|
+
{
|
|
17
|
+
flags: '--create <template> [name]',
|
|
18
|
+
description: 'Create new project from template',
|
|
19
|
+
menuDetails: [
|
|
20
|
+
'Available templates: nextjs, convex, vite, remix, node-cli,',
|
|
21
|
+
'python-cli, chrome-extension',
|
|
22
|
+
'See all: https://github.com/CodebuffAI/codebuff-community',
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
flags: '--init',
|
|
27
|
+
description: 'Initialize codebuff on this project for a smoother experience',
|
|
28
|
+
menuDescription: 'Initialize Codebuff for the project',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
flags: '--model <model>',
|
|
32
|
+
description: 'Experimental: Specify the main model to use for the agent ("sonnet-3.6", "sonnet-3.7", "gpt-4.1", "gemini-2.5-pro", "o4-mini", "o3"). Be aware codebuff might not work as well with non-default models.',
|
|
33
|
+
menuDescription: 'Specify main LLM (e.g., "sonnet-3.7") (Experimental)',
|
|
34
|
+
hidden: true,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
flags: '--lite',
|
|
38
|
+
description: 'Use budget models & fetch fewer files',
|
|
39
|
+
menuDescription: 'Use budget models & fetch fewer files (faster)',
|
|
40
|
+
hidden: false,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
flags: '--max',
|
|
44
|
+
description: 'Use higher quality models and fetch more files',
|
|
45
|
+
menuDescription: 'Use higher quality models and fetch more files (thorough)',
|
|
46
|
+
hidden: false,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
flags: '--experimental',
|
|
50
|
+
description: 'Use cutting-edge experimental features and models',
|
|
51
|
+
hidden: true,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
//# sourceMappingURL=cli-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-definitions.js","sourceRoot":"","sources":["../src/cli-definitions.ts"],"names":[],"mappings":";;;AAQa,QAAA,YAAY,GAAe;IACtC;QACE,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EAAE,gDAAgD;KAC9D;IACD;QACE,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EAAE,wBAAwB;QACrC,eAAe,EAAE,oCAAoC;KACtD;CACF,CAAA;AAEY,QAAA,UAAU,GAAe;IACpC;QACE,KAAK,EAAE,4BAA4B;QACnC,WAAW,EAAE,kCAAkC;QAC/C,WAAW,EAAE;YACX,6DAA6D;YAC7D,8BAA8B;YAC9B,2DAA2D;SAC5D;KACF;IACD;QACE,KAAK,EAAE,QAAQ;QACf,WAAW,EACT,+DAA+D;QACjE,eAAe,EAAE,qCAAqC;KACvD;IACD;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,yMAAyM;QAC3M,eAAe,EAAE,sDAAsD;QACvE,MAAM,EAAE,IAAI;KACb;IACD;QACE,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,uCAAuC;QACpD,eAAe,EAAE,gDAAgD;QACjE,MAAM,EAAE,KAAK;KACd;IACD;QACE,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,gDAAgD;QAC7D,eAAe,EACb,2DAA2D;QAC7D,MAAM,EAAE,KAAK;KACd;IACD;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,mDAAmD;QAChE,MAAM,EAAE,IAAI;KACb;CACF,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApiKeyType } from '../common/api-keys/constants';
|
|
2
|
+
import { Client } from '../client';
|
|
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>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.detectApiKey = detectApiKey;
|
|
4
4
|
exports.handleApiKeyInput = handleApiKeyInput;
|
|
5
|
-
const constants_1 = require("common/api-keys/constants");
|
|
5
|
+
const constants_1 = require("../common/api-keys/constants");
|
|
6
6
|
const picocolors_1 = require("picocolors");
|
|
7
7
|
/**
|
|
8
8
|
* Detects if the user input contains a known API key pattern.
|
|
@@ -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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleDiff = handleDiff;
|
|
4
|
+
const picocolors_1 = require("picocolors");
|
|
5
|
+
function handleDiff(lastChanges) {
|
|
6
|
+
if (lastChanges.length === 0) {
|
|
7
|
+
console.log((0, picocolors_1.yellow)('No changes found in the last assistant response.'));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
lastChanges.forEach((change) => {
|
|
11
|
+
console.log((0, picocolors_1.bold)(`___${change.path}___`));
|
|
12
|
+
const lines = change.content
|
|
13
|
+
.split('\n')
|
|
14
|
+
.map((line) => (change.type === 'file' ? '+' + line : line));
|
|
15
|
+
lines.forEach((line) => {
|
|
16
|
+
if (line.startsWith('+')) {
|
|
17
|
+
console.log((0, picocolors_1.green)(line));
|
|
18
|
+
}
|
|
19
|
+
else if (line.startsWith('-')) {
|
|
20
|
+
console.log((0, picocolors_1.red)(line));
|
|
21
|
+
}
|
|
22
|
+
else if (line.startsWith('@@')) {
|
|
23
|
+
console.log((0, picocolors_1.cyan)(line));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
console.log(line);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/cli-handlers/diff.ts"],"names":[],"mappings":";;AAGA,gCAwBC;AA1BD,2CAA2D;AAE3D,SAAgB,UAAU,CAAC,WAAyB;IAClD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,IAAA,mBAAM,EAAC,kDAAkD,CAAC,CAAC,CAAA;QACvE,OAAM;IACR,CAAC;IAED,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,OAAO,CAAC,GAAG,CAAC,IAAA,iBAAI,EAAC,MAAM,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAA;QACzC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO;aACzB,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;QAE9D,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,OAAO,CAAC,GAAG,CAAC,IAAA,kBAAK,EAAC,IAAI,CAAC,CAAC,CAAA;YAC1B,CAAC;iBAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,IAAA,gBAAG,EAAC,IAAI,CAAC,CAAC,CAAA;YACxB,CAAC;iBAAM,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,IAAA,iBAAI,EAAC,IAAI,CAAC,CAAC,CAAA;YACzB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACnB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function showEasterEgg(complete: () => void): Promise<void>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showEasterEgg = showEasterEgg;
|
|
4
|
+
const picocolors_1 = require("picocolors");
|
|
5
|
+
// Utility: clear the terminal screen
|
|
6
|
+
function clearScreen() {
|
|
7
|
+
process.stdout.write('\u001b[2J\u001b[0;0H');
|
|
8
|
+
}
|
|
9
|
+
// Utility: Generate a set of points tracing a "C" shape using an arc.
|
|
10
|
+
function generateCPath(cx, cy, r, steps) {
|
|
11
|
+
const points = [];
|
|
12
|
+
// A typical "C" opens to the right: from 45° to 315° (in radians)
|
|
13
|
+
const startAngle = Math.PI / 4;
|
|
14
|
+
const endAngle = (7 * Math.PI) / 4;
|
|
15
|
+
const angleStep = (endAngle - startAngle) / steps;
|
|
16
|
+
for (let i = 0; i <= steps; i++) {
|
|
17
|
+
const angle = startAngle + i * angleStep;
|
|
18
|
+
const x = Math.floor(cx + r * Math.cos(angle));
|
|
19
|
+
const y = Math.floor(cy + r * Math.sin(angle));
|
|
20
|
+
points.push({ x, y });
|
|
21
|
+
}
|
|
22
|
+
return points;
|
|
23
|
+
}
|
|
24
|
+
// Utility: Generate points along a quadratic Bézier curve.
|
|
25
|
+
function quadraticBezier(P0, P1, P2, steps) {
|
|
26
|
+
const points = [];
|
|
27
|
+
for (let i = 0; i <= steps; i++) {
|
|
28
|
+
const t = i / steps;
|
|
29
|
+
const x = Math.round((1 - t) ** 2 * P0.x + 2 * (1 - t) * t * P1.x + t ** 2 * P2.x);
|
|
30
|
+
const y = Math.round((1 - t) ** 2 * P0.y + 2 * (1 - t) * t * P1.y + t ** 2 * P2.y);
|
|
31
|
+
points.push({ x, y });
|
|
32
|
+
}
|
|
33
|
+
return points;
|
|
34
|
+
}
|
|
35
|
+
// Generate a vertical line from startY to endY at a given x.
|
|
36
|
+
function generateVerticalLine(x, startY, endY) {
|
|
37
|
+
const points = [];
|
|
38
|
+
const step = startY < endY ? 1 : -1;
|
|
39
|
+
for (let y = startY; y !== endY; y += step) {
|
|
40
|
+
points.push({ x, y });
|
|
41
|
+
}
|
|
42
|
+
points.push({ x, y: endY });
|
|
43
|
+
return points;
|
|
44
|
+
}
|
|
45
|
+
// Generate a path approximating a B shape using two quadratic Bézier curves
|
|
46
|
+
// for the rounded bubbles, and then closing the shape with a vertical spine.
|
|
47
|
+
function generateBPath(bX, bYTop, bYBottom, bWidth, bGap, stepsPerCurve) {
|
|
48
|
+
let points = [];
|
|
49
|
+
const middle = Math.floor((bYTop + bYBottom) / 2);
|
|
50
|
+
// Upper bubble: from top-left (spine) out then back to the spine at the middle.
|
|
51
|
+
const upperStart = { x: bX, y: bYTop };
|
|
52
|
+
const upperControl = {
|
|
53
|
+
x: bX + bWidth + bGap - 10,
|
|
54
|
+
y: Math.floor((bYTop + middle) / 2),
|
|
55
|
+
};
|
|
56
|
+
const upperEnd = { x: bX, y: middle };
|
|
57
|
+
const upperCurve = quadraticBezier(upperStart, upperControl, upperEnd, stepsPerCurve);
|
|
58
|
+
// Lower bubble: from the middle to the bottom.
|
|
59
|
+
const lowerStart = { x: bX, y: middle };
|
|
60
|
+
const lowerControl = {
|
|
61
|
+
x: bX + bWidth + bGap,
|
|
62
|
+
y: Math.floor((middle + bYBottom) / 2),
|
|
63
|
+
};
|
|
64
|
+
const lowerEnd = { x: bX, y: bYBottom };
|
|
65
|
+
const lowerCurve = quadraticBezier(lowerStart, lowerControl, lowerEnd, stepsPerCurve);
|
|
66
|
+
// Combine the curves.
|
|
67
|
+
points = points.concat(upperCurve, lowerCurve);
|
|
68
|
+
// Add a vertical line from the bottom of the B back up to the top.
|
|
69
|
+
const closingLine = generateVerticalLine(bX, bYBottom, bYTop);
|
|
70
|
+
points = points.concat(closingLine);
|
|
71
|
+
return points;
|
|
72
|
+
}
|
|
73
|
+
// Array of picocolors functions for random colors.
|
|
74
|
+
const colors = [picocolors_1.red, picocolors_1.green, picocolors_1.yellow, picocolors_1.blue, picocolors_1.magenta, picocolors_1.cyan];
|
|
75
|
+
function getRandomColor() {
|
|
76
|
+
return colors[Math.floor(Math.random() * colors.length)];
|
|
77
|
+
}
|
|
78
|
+
async function showEasterEgg(complete) {
|
|
79
|
+
const text = 'codebuffy';
|
|
80
|
+
const termWidth = process.stdout.columns;
|
|
81
|
+
const termHeight = process.stdout.rows;
|
|
82
|
+
const baselineWidth = 80;
|
|
83
|
+
const baselineHeight = 24;
|
|
84
|
+
const scaleFactor = Math.min(termWidth / baselineWidth, termHeight / baselineHeight);
|
|
85
|
+
// Dynamically scale parameters for the shapes.
|
|
86
|
+
// Use Math.max to ensure values don't get too small.
|
|
87
|
+
const cCenterX = Math.floor(termWidth * 0.3);
|
|
88
|
+
const cCenterY = Math.floor(termHeight / 2);
|
|
89
|
+
const cRadius = Math.max(2, Math.floor(8 * scaleFactor));
|
|
90
|
+
const cSteps = Math.max(10, Math.floor(30 * scaleFactor));
|
|
91
|
+
const bX = Math.floor(termWidth * 0.55);
|
|
92
|
+
const bYTop = Math.floor(termHeight / 2 - 7 * scaleFactor);
|
|
93
|
+
const bYBottom = Math.floor(termHeight / 2 + 7 * scaleFactor);
|
|
94
|
+
const bWidth = Math.max(2, Math.floor(8 * scaleFactor));
|
|
95
|
+
const bGap = Math.max(1, Math.floor(35 * scaleFactor));
|
|
96
|
+
const bStepsPerCurve = Math.max(10, Math.floor(20 * scaleFactor));
|
|
97
|
+
// Generate the paths.
|
|
98
|
+
const fullPath = [
|
|
99
|
+
...generateCPath(cCenterX, cCenterY, cRadius, cSteps),
|
|
100
|
+
...generateBPath(bX, bYTop, bYBottom, bWidth, bGap, bStepsPerCurve),
|
|
101
|
+
];
|
|
102
|
+
// Animation state: index into the fullPath.
|
|
103
|
+
let index = 0;
|
|
104
|
+
let completedCycle = false;
|
|
105
|
+
// Main animation function
|
|
106
|
+
function animate() {
|
|
107
|
+
if (index >= fullPath.length) {
|
|
108
|
+
completedCycle = true;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const { x, y } = fullPath[index];
|
|
112
|
+
const cursorPosition = `\u001b[${y + 1};${x + 1}H`;
|
|
113
|
+
process.stdout.write(cursorPosition + getRandomColor()(text));
|
|
114
|
+
index++;
|
|
115
|
+
}
|
|
116
|
+
clearScreen();
|
|
117
|
+
const interval = setInterval(() => {
|
|
118
|
+
animate();
|
|
119
|
+
if (completedCycle) {
|
|
120
|
+
clearInterval(interval);
|
|
121
|
+
clearScreen();
|
|
122
|
+
complete();
|
|
123
|
+
}
|
|
124
|
+
}, 100);
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=easter-egg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easter-egg.js","sourceRoot":"","sources":["../../src/cli-handlers/easter-egg.ts"],"names":[],"mappings":";;AAgHA,sCA2DC;AA3KD,2CAAoE;AAEpE,qCAAqC;AACrC,SAAS,WAAW;IAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;AAC9C,CAAC;AAED,sEAAsE;AACtE,SAAS,aAAa,CAAC,EAAU,EAAE,EAAU,EAAE,CAAS,EAAE,KAAa;IACrE,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,kEAAkE;IAClE,MAAM,UAAU,GAAG,I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nB,aAAa,CAAC,QAAQ,CAAC,CAAA;YACvB,WAAW,EAAE,CAAA;YACb,QAAQ,EAAE,CAAA;QACZ,CAAC;IACH,CAAC,EAAE,GAAG,CAAC,CAAA;AACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function handleInitializationFlowLocally(): void;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.handleInitializationFlowLocally = handleInitializationFlowLocally;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const constants_1 = require("common/json-config/constants");
|
|
9
|
+
const constants_1 = require("../common/json-config/constants");
|
|
10
10
|
const project_files_1 = require("../project-files");
|
|
11
11
|
function handleInitializationFlowLocally() {
|
|
12
12
|
const projectRoot = (0, project_files_1.getProjectRoot)();
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as readline from 'readline';
|
|
2
|
+
import { ProjectFileContext } from './common/util/file';
|
|
3
|
+
import { CliOptions } from './types';
|
|
4
|
+
export declare class CLI {
|
|
5
|
+
private static instance;
|
|
6
|
+
private readyPromise;
|
|
7
|
+
private git;
|
|
8
|
+
private costMode;
|
|
9
|
+
private isReceivingResponse;
|
|
10
|
+
private stopResponse;
|
|
11
|
+
private lastSigintTime;
|
|
12
|
+
private lastInputTime;
|
|
13
|
+
private consecutiveFastInputs;
|
|
14
|
+
private pastedContent;
|
|
15
|
+
private isPasting;
|
|
16
|
+
private shouldReconnectWhenIdle;
|
|
17
|
+
rl: readline.Interface;
|
|
18
|
+
private constructor();
|
|
19
|
+
static initialize(readyPromise: Promise<[ProjectFileContext, void, void]>, options: CliOptions): void;
|
|
20
|
+
static getInstance(): CLI;
|
|
21
|
+
private setupSignalHandlers;
|
|
22
|
+
private _loadHistory;
|
|
23
|
+
private _appendToHistory;
|
|
24
|
+
private initReadlineInterface;
|
|
25
|
+
private inputCompleter;
|
|
26
|
+
private getModeIndicator;
|
|
27
|
+
private setPrompt;
|
|
28
|
+
/**
|
|
29
|
+
* Prompts the user with a clean prompt state
|
|
30
|
+
*/
|
|
31
|
+
private freshPrompt;
|
|
32
|
+
printInitialPrompt({ initialInput, runInitFlow, }: {
|
|
33
|
+
initialInput?: string;
|
|
34
|
+
runInitFlow?: boolean;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
printDiff(): Promise<void>;
|
|
37
|
+
private handleLine;
|
|
38
|
+
private handleUserInput;
|
|
39
|
+
/**
|
|
40
|
+
* Cleans command input by removing leading slash while preserving special command syntax
|
|
41
|
+
* @param input The raw user input
|
|
42
|
+
* @returns The cleaned command string
|
|
43
|
+
*/
|
|
44
|
+
private cleanCommandInput;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a command is a known slash command
|
|
47
|
+
* @param command The command to check (without leading slash)
|
|
48
|
+
*/
|
|
49
|
+
private isKnownSlashCommand;
|
|
50
|
+
/**
|
|
51
|
+
* Handles an unknown slash command by displaying an error message
|
|
52
|
+
* @param command The unknown command that was entered
|
|
53
|
+
*/
|
|
54
|
+
private handleUnknownCommand;
|
|
55
|
+
private processCommand;
|
|
56
|
+
private forwardUserInput;
|
|
57
|
+
private reconnectWhenNextIdle;
|
|
58
|
+
private onWebSocketError;
|
|
59
|
+
private onWebSocketReconnect;
|
|
60
|
+
private handleKeyPress;
|
|
61
|
+
private handleSigint;
|
|
62
|
+
private handleEscKey;
|
|
63
|
+
private handleStopResponse;
|
|
64
|
+
private handleExit;
|
|
65
|
+
private detectPasting;
|
|
66
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -29,8 +29,8 @@ const os = __importStar(require("os"));
|
|
|
29
29
|
const os_1 = require("os");
|
|
30
30
|
const path_1 = __importStar(require("path"));
|
|
31
31
|
const readline = __importStar(require("readline"));
|
|
32
|
-
const analytics_events_1 = require("common/constants/analytics-events");
|
|
33
|
-
const string_1 = require("common/util/string");
|
|
32
|
+
const analytics_events_1 = require("./common/constants/analytics-events");
|
|
33
|
+
const string_1 = require("./common/util/string");
|
|
34
34
|
const picocolors_1 = require("picocolors");
|
|
35
35
|
const background_process_manager_1 = require("./background-process-manager");
|
|
36
36
|
const chat_storage_1 = require("./chat-storage");
|
|
@@ -48,7 +48,9 @@ const project_files_1 = require("./project-files");
|
|
|
48
48
|
const analytics_1 = require("./utils/analytics");
|
|
49
49
|
const spinner_1 = require("./utils/spinner");
|
|
50
50
|
const terminal_1 = require("./utils/terminal");
|
|
51
|
+
const parser_1 = require("./common/json-config/parser");
|
|
51
52
|
const credentials_1 = require("./credentials");
|
|
53
|
+
const startup_process_handler_1 = require("./startup-process-handler");
|
|
52
54
|
const PROMPT_HISTORY_PATH = path_1.default.join(credentials_1.CONFIG_DIR, 'prompt_history.json');
|
|
53
55
|
class CLI {
|
|
54
56
|
static instance = null;
|
|
@@ -223,6 +225,9 @@ class CLI {
|
|
|
223
225
|
return [[], line];
|
|
224
226
|
}
|
|
225
227
|
}
|
|
228
|
+
getModeIndicator() {
|
|
229
|
+
return this.costMode !== 'normal' ? ` (${this.costMode})` : '';
|
|
230
|
+
}
|
|
226
231
|
setPrompt() {
|
|
227
232
|
const projectRoot = (0, project_files_1.getProjectRoot)();
|
|
228
233
|
const cwd = (0, project_files_1.getWorkingDirectory)();
|
|
@@ -232,7 +237,8 @@ class CLI {
|
|
|
232
237
|
? ''
|
|
233
238
|
: (os.platform() === 'win32' ? '\\' : '/') +
|
|
234
239
|
path_1.default.relative(projectRoot, cwd));
|
|
235
|
-
this.
|
|
240
|
+
const modeIndicator = this.getModeIndicator();
|
|
241
|
+
this.rl.setPrompt((0, picocolors_1.green)(`${ps1Dir}${modeIndicator} > `));
|
|
236
242
|
}
|
|
237
243
|
/**
|
|
238
244
|
* Prompts the user with a clean prompt state
|
|
@@ -312,10 +318,13 @@ class CLI {
|
|
|
312
318
|
return;
|
|
313
319
|
}
|
|
314
320
|
userInput = userInput.trim();
|
|
315
|
-
|
|
321
|
+
const processedResult = await this.processCommand(userInput);
|
|
322
|
+
if (processedResult === null) {
|
|
323
|
+
// Command was fully handled by processCommand
|
|
316
324
|
return;
|
|
317
325
|
}
|
|
318
|
-
|
|
326
|
+
// processedResult is the string to be forwarded as a prompt
|
|
327
|
+
await this.forwardUserInput(processedResult);
|
|
319
328
|
}
|
|
320
329
|
/**
|
|
321
330
|
* Cleans command input by removing leading slash while preserving special command syntax
|
|
@@ -342,73 +351,120 @@ class CLI {
|
|
|
342
351
|
this.freshPrompt();
|
|
343
352
|
}
|
|
344
353
|
async processCommand(userInput) {
|
|
354
|
+
// Handle cost mode commands with optional message: /lite, /lite message, /normal, /normal message, etc.
|
|
355
|
+
const costModeMatch = userInput.match(/^\/(lite|normal|max)(?:\s+(.*))?$/i);
|
|
356
|
+
if (costModeMatch) {
|
|
357
|
+
const mode = costModeMatch[1].toLowerCase();
|
|
358
|
+
const message = costModeMatch[2]?.trim() || '';
|
|
359
|
+
// Track the cost mode command usage
|
|
360
|
+
(0, analytics_1.trackEvent)(analytics_events_1.AnalyticsEvent.SLASH_COMMAND_USED, {
|
|
361
|
+
userId: client_1.Client.getInstance().user?.id || 'unknown',
|
|
362
|
+
command: mode,
|
|
363
|
+
});
|
|
364
|
+
this.costMode = mode;
|
|
365
|
+
client_1.Client.getInstance().setCostMode(mode);
|
|
366
|
+
if (mode === 'lite') {
|
|
367
|
+
console.log((0, picocolors_1.yellow)('✨ Switched to lite mode (faster, cheaper)'));
|
|
368
|
+
}
|
|
369
|
+
else if (mode === 'normal') {
|
|
370
|
+
console.log((0, picocolors_1.green)('⚖️ Switched to normal mode (balanced)'));
|
|
371
|
+
}
|
|
372
|
+
else if (mode === 'max') {
|
|
373
|
+
console.log((0, picocolors_1.blueBright)('⚡ Switched to max mode (slower, more thorough)'));
|
|
374
|
+
}
|
|
375
|
+
if (!message) {
|
|
376
|
+
this.freshPrompt();
|
|
377
|
+
return null; // Fully handled, no message to forward
|
|
378
|
+
}
|
|
379
|
+
// Return the message part to be processed as user input
|
|
380
|
+
return message;
|
|
381
|
+
}
|
|
345
382
|
const cleanInput = this.cleanCommandInput(userInput);
|
|
346
383
|
// Handle empty slash command
|
|
347
384
|
if (userInput === '/') {
|
|
348
|
-
return
|
|
385
|
+
return userInput; // Let it be processed as a prompt
|
|
349
386
|
}
|
|
350
387
|
// Track slash command usage if it starts with '/'
|
|
351
388
|
if (userInput.startsWith('/') && !userInput.startsWith('/!')) {
|
|
352
|
-
|
|
389
|
+
const commandBase = cleanInput.split(' ')[0];
|
|
390
|
+
if (!this.isKnownSlashCommand(commandBase)) {
|
|
353
391
|
(0, analytics_1.trackEvent)(analytics_events_1.AnalyticsEvent.INVALID_COMMAND, {
|
|
354
392
|
userId: client_1.Client.getInstance().user?.id || 'unknown',
|
|
355
393
|
command: cleanInput,
|
|
356
394
|
});
|
|
357
395
|
this.handleUnknownCommand(userInput);
|
|
358
|
-
return
|
|
396
|
+
return null;
|
|
359
397
|
}
|
|
360
398
|
// Track successful slash command usage
|
|
361
399
|
(0, analytics_1.trackEvent)(analytics_events_1.AnalyticsEvent.SLASH_COMMAND_USED, {
|
|
362
400
|
userId: client_1.Client.getInstance().user?.id || 'unknown',
|
|
363
|
-
command:
|
|
401
|
+
command: commandBase,
|
|
364
402
|
});
|
|
365
403
|
}
|
|
366
404
|
if (cleanInput === 'help' || cleanInput === 'h') {
|
|
367
405
|
(0, menu_1.displayMenu)();
|
|
368
406
|
this.freshPrompt();
|
|
369
|
-
return
|
|
407
|
+
return null;
|
|
370
408
|
}
|
|
371
409
|
if (cleanInput === 'login' || cleanInput === 'signin') {
|
|
372
410
|
await client_1.Client.getInstance().login();
|
|
373
411
|
checkpoint_manager_1.checkpointManager.clearCheckpoints();
|
|
374
|
-
return
|
|
412
|
+
return null;
|
|
375
413
|
}
|
|
376
414
|
if (cleanInput === 'logout' || cleanInput === 'signout') {
|
|
377
415
|
await client_1.Client.getInstance().logout();
|
|
378
416
|
this.freshPrompt();
|
|
379
|
-
return
|
|
417
|
+
return null;
|
|
380
418
|
}
|
|
381
419
|
if (cleanInput.startsWith('ref-')) {
|
|
382
420
|
// Referral codes can be entered with or without a leading slash.
|
|
383
421
|
// Pass the cleaned input (without slash) to the handler.
|
|
384
422
|
await client_1.Client.getInstance().handleReferralCode(cleanInput.trim());
|
|
385
|
-
return
|
|
423
|
+
return null;
|
|
386
424
|
}
|
|
387
425
|
// Detect potential API key input first
|
|
388
426
|
// API keys are not slash commands, so use userInput
|
|
389
427
|
const detectionResult = (0, api_key_1.detectApiKey)(userInput);
|
|
390
428
|
if (detectionResult.status !== 'not_found') {
|
|
391
429
|
await (0, api_key_1.handleApiKeyInput)(client_1.Client.getInstance(), detectionResult, this.readyPromise, this.freshPrompt.bind(this));
|
|
392
|
-
return
|
|
430
|
+
return null;
|
|
393
431
|
}
|
|
394
432
|
if (cleanInput === 'usage' || cleanInput === 'credits') {
|
|
395
433
|
await client_1.Client.getInstance().getUsage();
|
|
396
|
-
return
|
|
434
|
+
return null;
|
|
397
435
|
}
|
|
398
436
|
if (cleanInput === 'quit' || cleanInput === 'exit' || cleanInput === 'q') {
|
|
399
437
|
await this.handleExit();
|
|
400
|
-
return
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
if (cleanInput === 'reset') {
|
|
441
|
+
await this.readyPromise;
|
|
442
|
+
await client_1.Client.getInstance().resetContext();
|
|
443
|
+
const projectRoot = (0, project_files_1.getProjectRoot)();
|
|
444
|
+
(0, terminal_1.clearScreen)();
|
|
445
|
+
// from index.ts
|
|
446
|
+
const config = (0, parser_1.loadCodebuffConfig)(projectRoot);
|
|
447
|
+
await (0, background_process_manager_1.killAllBackgroundProcesses)();
|
|
448
|
+
const processStartPromise = (0, startup_process_handler_1.logAndHandleStartup)(projectRoot, config);
|
|
449
|
+
const initFileContextPromise = (0, project_files_1.initProjectFileContextWithWorker)(projectRoot);
|
|
450
|
+
this.readyPromise = Promise.all([
|
|
451
|
+
initFileContextPromise,
|
|
452
|
+
processStartPromise,
|
|
453
|
+
]);
|
|
454
|
+
(0, menu_1.displayGreeting)(this.costMode, client_1.Client.getInstance().user?.name ?? null);
|
|
455
|
+
this.freshPrompt();
|
|
456
|
+
return null;
|
|
401
457
|
}
|
|
402
458
|
if (['diff', 'doff', 'dif', 'iff', 'd'].includes(cleanInput)) {
|
|
403
459
|
(0, diff_1.handleDiff)(client_1.Client.getInstance().lastChanges);
|
|
404
460
|
this.freshPrompt();
|
|
405
|
-
return
|
|
461
|
+
return null;
|
|
406
462
|
}
|
|
407
463
|
if (cleanInput === 'uuddlrlrba' ||
|
|
408
464
|
cleanInput === 'konami' ||
|
|
409
465
|
cleanInput === 'codebuffy') {
|
|
410
466
|
(0, easter_egg_1.showEasterEgg)(this.freshPrompt.bind(this));
|
|
411
|
-
return
|
|
467
|
+
return null;
|
|
412
468
|
}
|
|
413
469
|
// Checkpoint commands
|
|
414
470
|
if ((0, checkpoint_1.isCheckpointCommand)(cleanInput)) {
|
|
@@ -419,19 +475,19 @@ class CLI {
|
|
|
419
475
|
await (0, checkpoint_1.saveCheckpoint)(userInput, client_1.Client.getInstance(), this.readyPromise);
|
|
420
476
|
const toRestore = await (0, checkpoint_1.handleUndo)(client_1.Client.getInstance(), this.rl);
|
|
421
477
|
this.freshPrompt(toRestore);
|
|
422
|
-
return
|
|
478
|
+
return null;
|
|
423
479
|
}
|
|
424
480
|
if ((0, checkpoint_1.isCheckpointCommand)(cleanInput, 'redo')) {
|
|
425
481
|
await (0, checkpoint_1.saveCheckpoint)(userInput, client_1.Client.getInstance(), this.readyPromise);
|
|
426
482
|
const toRestore = await (0, checkpoint_1.handleRedo)(client_1.Client.getInstance(), this.rl);
|
|
427
483
|
this.freshPrompt(toRestore);
|
|
428
|
-
return
|
|
484
|
+
return null;
|
|
429
485
|
}
|
|
430
486
|
if ((0, checkpoint_1.isCheckpointCommand)(cleanInput, 'list')) {
|
|
431
487
|
await (0, checkpoint_1.saveCheckpoint)(userInput, client_1.Client.getInstance(), this.readyPromise);
|
|
432
488
|
await (0, checkpoint_1.listCheckpoints)();
|
|
433
489
|
this.freshPrompt();
|
|
434
|
-
return
|
|
490
|
+
return null;
|
|
435
491
|
}
|
|
436
492
|
const restoreMatch = (0, checkpoint_1.isCheckpointCommand)(cleanInput, 'restore');
|
|
437
493
|
if (restoreMatch) {
|
|
@@ -439,34 +495,35 @@ class CLI {
|
|
|
439
495
|
await (0, checkpoint_1.saveCheckpoint)(userInput, client_1.Client.getInstance(), this.readyPromise);
|
|
440
496
|
const toRestore = await (0, checkpoint_1.handleRestoreCheckpoint)(id, client_1.Client.getInstance(), this.rl);
|
|
441
497
|
this.freshPrompt(toRestore);
|
|
442
|
-
return
|
|
498
|
+
return null;
|
|
443
499
|
}
|
|
444
500
|
if ((0, checkpoint_1.isCheckpointCommand)(cleanInput, 'clear')) {
|
|
445
501
|
(0, checkpoint_1.handleClearCheckpoints)();
|
|
446
502
|
this.freshPrompt();
|
|
447
|
-
return
|
|
503
|
+
return null;
|
|
448
504
|
}
|
|
449
505
|
if ((0, checkpoint_1.isCheckpointCommand)(cleanInput, 'save')) {
|
|
450
506
|
await (0, checkpoint_1.saveCheckpoint)(userInput, client_1.Client.getInstance(), this.readyPromise, true);
|
|
451
507
|
(0, checkpoint_1.displayCheckpointMenu)();
|
|
452
508
|
this.freshPrompt();
|
|
453
|
-
return
|
|
509
|
+
return null;
|
|
454
510
|
}
|
|
455
511
|
// Default checkpoint action (if just "checkpoint" or "/checkpoint" is typed)
|
|
456
512
|
(0, checkpoint_1.displayCheckpointMenu)();
|
|
457
513
|
this.freshPrompt();
|
|
458
|
-
return
|
|
514
|
+
return null;
|
|
459
515
|
}
|
|
460
516
|
if (cleanInput === 'init') {
|
|
461
517
|
(0, inititalization_flow_1.handleInitializationFlowLocally)();
|
|
462
518
|
// Also forward user input (original with / if present, or cleanInput) to the backend
|
|
463
519
|
// The original forwardUserInput takes the raw userInput.
|
|
464
|
-
return
|
|
520
|
+
return userInput; // Let it fall through to forwardUserInput
|
|
465
521
|
}
|
|
466
|
-
return
|
|
522
|
+
// If no command was matched, return the original userInput to be processed as a prompt
|
|
523
|
+
return userInput;
|
|
467
524
|
}
|
|
468
|
-
async forwardUserInput(
|
|
469
|
-
const cleanedInput = this.cleanCommandInput(
|
|
525
|
+
async forwardUserInput(promptContent) {
|
|
526
|
+
const cleanedInput = this.cleanCommandInput(promptContent);
|
|
470
527
|
await (0, checkpoint_1.saveCheckpoint)(cleanedInput, client_1.Client.getInstance(), this.readyPromise);
|
|
471
528
|
spinner_1.Spinner.get().start();
|
|
472
529
|
client_1.Client.getInstance().lastChanges = [];
|
|
@@ -479,7 +536,7 @@ class CLI {
|
|
|
479
536
|
(0, chat_storage_1.setMessages)([...client.agentState.messageHistory, newMessage]);
|
|
480
537
|
}
|
|
481
538
|
this.isReceivingResponse = true;
|
|
482
|
-
const { responsePromise, stopResponse } = await client_1.Client.getInstance().sendUserInput(cleanedInput);
|
|
539
|
+
const { responsePromise, stopResponse } = await client_1.Client.getInstance().sendUserInput(cleanedInput);
|
|
483
540
|
this.stopResponse = stopResponse;
|
|
484
541
|
await responsePromise;
|
|
485
542
|
this.stopResponse = null;
|