@involvex/super-agent-cli 0.0.88 → 0.0.89
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/index.js +75 -48
- package/dist/super-agent-cli.exe +0 -0
- package/dist/super-agent.js +5 -1
- package/eslint.config.mjs +1 -1
- package/package.json +3 -4
- package/super-agent.js +5 -1
- package/vscode-extension/.vscodeignore +1 -1
- package/vscode-extension/build.js +4 -4
- package/vscode-extension/dist/chat-provider.js +262 -0
- package/vscode-extension/dist/chat-provider.js.map +1 -0
- package/vscode-extension/dist/chat.css +268 -0
- package/vscode-extension/dist/chat.js +234 -0
- package/vscode-extension/dist/cli-connector.js +296 -0
- package/vscode-extension/dist/cli-connector.js.map +1 -0
- package/vscode-extension/dist/extension.js +156 -0
- package/vscode-extension/dist/extension.js.map +1 -0
- package/vscode-extension/dist/file-context.js +230 -0
- package/vscode-extension/dist/file-context.js.map +1 -0
- package/vscode-extension/dist/node_modules/ws/LICENSE +20 -0
- package/vscode-extension/dist/node_modules/ws/README.md +548 -0
- package/vscode-extension/dist/node_modules/ws/browser.js +8 -0
- package/vscode-extension/dist/node_modules/ws/index.js +13 -0
- package/vscode-extension/dist/node_modules/ws/lib/buffer-util.js +131 -0
- package/vscode-extension/dist/node_modules/ws/lib/constants.js +19 -0
- package/vscode-extension/dist/node_modules/ws/lib/event-target.js +292 -0
- package/vscode-extension/dist/node_modules/ws/lib/extension.js +203 -0
- package/vscode-extension/dist/node_modules/ws/lib/limiter.js +55 -0
- package/vscode-extension/dist/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/vscode-extension/dist/node_modules/ws/lib/receiver.js +706 -0
- package/vscode-extension/dist/node_modules/ws/lib/sender.js +602 -0
- package/vscode-extension/dist/node_modules/ws/lib/stream.js +161 -0
- package/vscode-extension/dist/node_modules/ws/lib/subprotocol.js +62 -0
- package/vscode-extension/dist/node_modules/ws/lib/validation.js +152 -0
- package/vscode-extension/dist/node_modules/ws/lib/websocket-server.js +554 -0
- package/vscode-extension/dist/node_modules/ws/lib/websocket.js +1393 -0
- package/vscode-extension/dist/node_modules/ws/package.json +69 -0
- package/vscode-extension/dist/node_modules/ws/wrapper.mjs +8 -0
- package/vscode-extension/dist/super-agent-vscode-0.0.2.vsix +0 -0
- package/vscode-extension/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1731,7 +1731,7 @@ var init_indexer = __esm(() => {
|
|
|
1731
1731
|
var require_package = __commonJS((exports, module) => {
|
|
1732
1732
|
module.exports = {
|
|
1733
1733
|
name: "@involvex/super-agent-cli",
|
|
1734
|
-
version: "0.0.
|
|
1734
|
+
version: "0.0.89",
|
|
1735
1735
|
description: "An open-source AI agent that brings the power of Super Agent directly into your terminal.",
|
|
1736
1736
|
keywords: [
|
|
1737
1737
|
"cli",
|
|
@@ -1759,7 +1759,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
1759
1759
|
},
|
|
1760
1760
|
main: "dist/index.js",
|
|
1761
1761
|
bin: {
|
|
1762
|
-
"super-agent": "super-agent.js"
|
|
1762
|
+
"super-agent": "dist/super-agent.js"
|
|
1763
1763
|
},
|
|
1764
1764
|
workspaces: [
|
|
1765
1765
|
"@plugins/templates/*",
|
|
@@ -1768,7 +1768,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
1768
1768
|
],
|
|
1769
1769
|
scripts: {
|
|
1770
1770
|
prebuild: "bun run format && bun run lint:fix && bun run typecheck",
|
|
1771
|
-
build: "bun build src/index.ts --outdir ./dist --target node --packages external --format esm && bun run copy-bin && bun run build:web",
|
|
1771
|
+
build: "bun build src/index.ts --outdir ./dist --target node --packages external --format esm && bun run copy-bin && bun run build:web && bun run build:plugins && bun run build:vscode && bun run package:vscode",
|
|
1772
1772
|
"build:bun": "bun build src/index.ts --outdir ./dist --target node --packages external --format esm",
|
|
1773
1773
|
"build:plugins": "bun run -F @involvex/super-agent\\* build",
|
|
1774
1774
|
"build:vscode": "bun run -F super-agent-vscode build",
|
|
@@ -1805,7 +1805,6 @@ var require_package = __commonJS((exports, module) => {
|
|
|
1805
1805
|
commander: "^14.0.3",
|
|
1806
1806
|
"conventional-changelog-cli": "^5.0.0",
|
|
1807
1807
|
dotenv: "^17.2.3",
|
|
1808
|
-
enquirer: "^2.4.1",
|
|
1809
1808
|
firebase: "^12.8.0",
|
|
1810
1809
|
"fs-extra": "^11.3.3",
|
|
1811
1810
|
ignore: "^7.0.5",
|
|
@@ -7416,7 +7415,11 @@ function getLogger() {
|
|
|
7416
7415
|
// src/ui/components/config-viewer.tsx
|
|
7417
7416
|
import { Box as Box10, Text as Text9 } from "ink";
|
|
7418
7417
|
import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
|
|
7419
|
-
function ConfigViewer({
|
|
7418
|
+
function ConfigViewer({
|
|
7419
|
+
config,
|
|
7420
|
+
isVisible = true,
|
|
7421
|
+
onClose
|
|
7422
|
+
}) {
|
|
7420
7423
|
if (!isVisible) {
|
|
7421
7424
|
return null;
|
|
7422
7425
|
}
|
|
@@ -10252,6 +10255,9 @@ IMPORTANT RESPONSE GUIDELINES:
|
|
|
10252
10255
|
Current working directory: ${process.cwd()}`
|
|
10253
10256
|
});
|
|
10254
10257
|
}
|
|
10258
|
+
getChatHistory() {
|
|
10259
|
+
return this.chatHistory;
|
|
10260
|
+
}
|
|
10255
10261
|
async setProvider(providerId) {
|
|
10256
10262
|
const manager = getSettingsManager();
|
|
10257
10263
|
const activeProviderId = (providerId || "grok").toLowerCase();
|
|
@@ -11935,16 +11941,23 @@ class WebServer {
|
|
|
11935
11941
|
ws.on("message", async (data) => {
|
|
11936
11942
|
try {
|
|
11937
11943
|
const message = JSON.parse(data.toString());
|
|
11938
|
-
if (message.type === "prompt") {
|
|
11939
|
-
|
|
11944
|
+
if (message.type === "prompt" || message.type === "chat_message") {
|
|
11945
|
+
const content = message.content?.message || message.content || "";
|
|
11946
|
+
await this.handlePrompt(content, ws);
|
|
11940
11947
|
} else if (message.type === "get_file_tree") {
|
|
11941
11948
|
await this.handleGetFileTree(ws);
|
|
11942
11949
|
} else if (message.type === "get_file_content") {
|
|
11943
|
-
|
|
11950
|
+
const filePath = message.path || message.filePath;
|
|
11951
|
+
await this.handleGetFileContent(filePath, ws);
|
|
11944
11952
|
} else if (message.type === "list_sessions") {
|
|
11945
11953
|
await this.handleListSessions(ws);
|
|
11946
11954
|
} else if (message.type === "switch_session") {
|
|
11947
11955
|
await this.handleSwitchSession(message.sessionId, ws);
|
|
11956
|
+
} else if (message.type === "get_chat_history") {
|
|
11957
|
+
await this.handleGetChatHistory(ws);
|
|
11958
|
+
} else if (message.type === "abort") {
|
|
11959
|
+
this.agent.abortCurrentOperation();
|
|
11960
|
+
ws.send(JSON.stringify({ type: "done", content: "Operation aborted" }));
|
|
11948
11961
|
}
|
|
11949
11962
|
} catch (error) {
|
|
11950
11963
|
console.error("WebSocket message error:", error);
|
|
@@ -12068,6 +12081,23 @@ class WebServer {
|
|
|
12068
12081
|
ws.send(JSON.stringify({ type: "error", content: error.message }));
|
|
12069
12082
|
}
|
|
12070
12083
|
}
|
|
12084
|
+
async handleGetChatHistory(ws) {
|
|
12085
|
+
try {
|
|
12086
|
+
const history = this.agent.getChatHistory();
|
|
12087
|
+
ws.send(JSON.stringify({
|
|
12088
|
+
type: "chat_history",
|
|
12089
|
+
messages: history.map((entry) => ({
|
|
12090
|
+
role: entry.type === "user" ? "user" : "assistant",
|
|
12091
|
+
content: entry.content,
|
|
12092
|
+
timestamp: entry.timestamp,
|
|
12093
|
+
toolCall: entry.toolCall,
|
|
12094
|
+
toolResult: entry.toolResult
|
|
12095
|
+
}))
|
|
12096
|
+
}));
|
|
12097
|
+
} catch (error) {
|
|
12098
|
+
ws.send(JSON.stringify({ type: "error", content: error.message }));
|
|
12099
|
+
}
|
|
12100
|
+
}
|
|
12071
12101
|
async checkAndSendUpdateNotification(ws) {
|
|
12072
12102
|
try {
|
|
12073
12103
|
const pkg = await Promise.resolve().then(() => __toESM(require_package(), 1));
|
|
@@ -13012,7 +13042,7 @@ function createGitCommand() {
|
|
|
13012
13042
|
// src/commands/statusbar.ts
|
|
13013
13043
|
init_settings_manager();
|
|
13014
13044
|
import { Command as Command11 } from "commander";
|
|
13015
|
-
import
|
|
13045
|
+
import inquirer4 from "inquirer";
|
|
13016
13046
|
function createStatusBarCommand() {
|
|
13017
13047
|
const command = new Command11("statusbar");
|
|
13018
13048
|
command.description("Configure status bar settings").action(async () => {
|
|
@@ -13026,43 +13056,40 @@ function createStatusBarCommand() {
|
|
|
13026
13056
|
show_context: false
|
|
13027
13057
|
};
|
|
13028
13058
|
try {
|
|
13029
|
-
const response = await prompt(
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
}
|
|
13064
|
-
]
|
|
13065
|
-
});
|
|
13059
|
+
const response = await inquirer4.prompt([
|
|
13060
|
+
{
|
|
13061
|
+
type: "checkbox",
|
|
13062
|
+
name: "features",
|
|
13063
|
+
message: "Select status bar features to display:",
|
|
13064
|
+
choices: [
|
|
13065
|
+
{
|
|
13066
|
+
name: "Model Name",
|
|
13067
|
+
value: "show_model",
|
|
13068
|
+
checked: currentConfig.show_model
|
|
13069
|
+
},
|
|
13070
|
+
{
|
|
13071
|
+
name: "Token Count",
|
|
13072
|
+
value: "show_tokens",
|
|
13073
|
+
checked: currentConfig.show_tokens
|
|
13074
|
+
},
|
|
13075
|
+
{
|
|
13076
|
+
name: "Git Status",
|
|
13077
|
+
value: "show_git_status",
|
|
13078
|
+
checked: currentConfig.show_git_status
|
|
13079
|
+
},
|
|
13080
|
+
{
|
|
13081
|
+
name: "Memory Usage",
|
|
13082
|
+
value: "show_memory",
|
|
13083
|
+
checked: currentConfig.show_memory
|
|
13084
|
+
},
|
|
13085
|
+
{
|
|
13086
|
+
name: "Context Size",
|
|
13087
|
+
value: "show_context",
|
|
13088
|
+
checked: currentConfig.show_context
|
|
13089
|
+
}
|
|
13090
|
+
]
|
|
13091
|
+
}
|
|
13092
|
+
]);
|
|
13066
13093
|
const newConfig = {
|
|
13067
13094
|
show_model: response.features.includes("show_model"),
|
|
13068
13095
|
show_tokens: response.features.includes("show_tokens"),
|
|
@@ -13170,12 +13197,12 @@ function loadModel2() {
|
|
|
13170
13197
|
}
|
|
13171
13198
|
return model;
|
|
13172
13199
|
}
|
|
13173
|
-
async function processPromptHeadless(
|
|
13200
|
+
async function processPromptHeadless(prompt, apiKey, baseURL, model, maxToolRounds) {
|
|
13174
13201
|
try {
|
|
13175
13202
|
const agent = new SuperAgent(apiKey, baseURL, model, maxToolRounds);
|
|
13176
13203
|
const confirmationService = ConfirmationService.getInstance();
|
|
13177
13204
|
confirmationService.setSessionFlag("allOperations", true);
|
|
13178
|
-
const chatEntries = await agent.processUserMessage(
|
|
13205
|
+
const chatEntries = await agent.processUserMessage(prompt);
|
|
13179
13206
|
const messages = [];
|
|
13180
13207
|
for (const entry of chatEntries) {
|
|
13181
13208
|
switch (entry.type) {
|
package/dist/super-agent-cli.exe
CHANGED
|
Binary file
|
package/dist/super-agent.js
CHANGED
|
@@ -9,4 +9,8 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
9
9
|
const __dirname = dirname(__filename);
|
|
10
10
|
|
|
11
11
|
// Import and run the bundled CLI
|
|
12
|
-
|
|
12
|
+
const indexPath = __dirname.endsWith("dist")
|
|
13
|
+
? join(__dirname, "index.js")
|
|
14
|
+
: join(__dirname, "dist", "index.js");
|
|
15
|
+
|
|
16
|
+
import(indexPath);
|
package/eslint.config.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@involvex/super-agent-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.89",
|
|
4
4
|
"description": "An open-source AI agent that brings the power of Super Agent directly into your terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"main": "dist/index.js",
|
|
30
30
|
"bin": {
|
|
31
|
-
"super-agent": "super-agent.js"
|
|
31
|
+
"super-agent": "dist/super-agent.js"
|
|
32
32
|
},
|
|
33
33
|
"workspaces": [
|
|
34
34
|
"@plugins/templates/*",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
39
|
"prebuild": "bun run format && bun run lint:fix && bun run typecheck",
|
|
40
|
-
"build": "bun build src/index.ts --outdir ./dist --target node --packages external --format esm && bun run copy-bin && bun run build:web",
|
|
40
|
+
"build": "bun build src/index.ts --outdir ./dist --target node --packages external --format esm && bun run copy-bin && bun run build:web && bun run build:plugins && bun run build:vscode && bun run package:vscode",
|
|
41
41
|
"build:bun": "bun build src/index.ts --outdir ./dist --target node --packages external --format esm",
|
|
42
42
|
"build:plugins": "bun run -F @involvex/super-agent\\* build",
|
|
43
43
|
"build:vscode": "bun run -F super-agent-vscode build",
|
|
@@ -74,7 +74,6 @@
|
|
|
74
74
|
"commander": "^14.0.3",
|
|
75
75
|
"conventional-changelog-cli": "^5.0.0",
|
|
76
76
|
"dotenv": "^17.2.3",
|
|
77
|
-
"enquirer": "^2.4.1",
|
|
78
77
|
"firebase": "^12.8.0",
|
|
79
78
|
"fs-extra": "^11.3.3",
|
|
80
79
|
"ignore": "^7.0.5",
|
package/super-agent.js
CHANGED
|
@@ -9,4 +9,8 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
9
9
|
const __dirname = dirname(__filename);
|
|
10
10
|
|
|
11
11
|
// Import and run the bundled CLI
|
|
12
|
-
|
|
12
|
+
const indexPath = __dirname.endsWith("dist")
|
|
13
|
+
? join(__dirname, "index.js")
|
|
14
|
+
: join(__dirname, "dist", "index.js");
|
|
15
|
+
|
|
16
|
+
import(indexPath);
|
|
@@ -2,7 +2,7 @@ const path = require("path");
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
|
|
4
4
|
const srcDir = path.join(__dirname, "src");
|
|
5
|
-
const outDir = path.join(__dirname, "
|
|
5
|
+
const outDir = path.join(__dirname, "dist");
|
|
6
6
|
|
|
7
7
|
// Ensure out directory exists
|
|
8
8
|
if (!fs.existsSync(outDir)) {
|
|
@@ -18,20 +18,20 @@ for (const file of assetsToCopy) {
|
|
|
18
18
|
|
|
19
19
|
if (fs.existsSync(srcPath)) {
|
|
20
20
|
fs.copyFileSync(srcPath, outPath);
|
|
21
|
-
console.log(`Copied ${file} to
|
|
21
|
+
console.log(`Copied ${file} to dist/`);
|
|
22
22
|
} else {
|
|
23
23
|
console.warn(`Source file not found: ${srcPath}`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// Copy ws dependency to
|
|
27
|
+
// Copy ws dependency to dist/node_modules for packaging
|
|
28
28
|
const wsSrc = path.join(__dirname, "node_modules", "ws");
|
|
29
29
|
const wsDest = path.join(outDir, "node_modules", "ws");
|
|
30
30
|
|
|
31
31
|
if (fs.existsSync(wsSrc)) {
|
|
32
32
|
// Copy recursively
|
|
33
33
|
copyDirectory(wsSrc, wsDest);
|
|
34
|
-
console.log("Copied ws to
|
|
34
|
+
console.log("Copied ws to dist/node_modules/");
|
|
35
35
|
} else {
|
|
36
36
|
console.warn("ws not found in node_modules");
|
|
37
37
|
}
|
|
@@ -0,0 +1,262 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ChatProvider = void 0;
|
|
37
|
+
const vscode = __importStar(require("vscode"));
|
|
38
|
+
class ChatProvider {
|
|
39
|
+
context;
|
|
40
|
+
extensionUri;
|
|
41
|
+
cliConnector;
|
|
42
|
+
fileContextProvider;
|
|
43
|
+
messages = [];
|
|
44
|
+
webviewView;
|
|
45
|
+
disposables = [];
|
|
46
|
+
constructor(context, extensionUri, cliConnector, fileContextProvider) {
|
|
47
|
+
this.context = context;
|
|
48
|
+
this.extensionUri = extensionUri;
|
|
49
|
+
this.cliConnector = cliConnector;
|
|
50
|
+
this.fileContextProvider = fileContextProvider;
|
|
51
|
+
this.setupCLIMessageHandlers();
|
|
52
|
+
// Listen for status changes from the connector
|
|
53
|
+
this.disposables.push(new vscode.Disposable(this.cliConnector.onStatusChange(connected => {
|
|
54
|
+
this.updateConnectionStatus(connected);
|
|
55
|
+
})));
|
|
56
|
+
}
|
|
57
|
+
setupCLIMessageHandlers() {
|
|
58
|
+
// Handle incoming messages from CLI
|
|
59
|
+
// CLI sends 'assistant_message', 'user_message', 'tool_call', 'tool_result', 'done', 'error'
|
|
60
|
+
this.cliConnector.onMessage("assistant_message", (response) => {
|
|
61
|
+
this.addAssistantMessage(response.content || "");
|
|
62
|
+
this.updateWebview();
|
|
63
|
+
});
|
|
64
|
+
this.cliConnector.onMessage("user_message", (response) => {
|
|
65
|
+
// Optional: handle if we want to sync user messages from other clients
|
|
66
|
+
});
|
|
67
|
+
this.cliConnector.onMessage("tool_call", (response) => {
|
|
68
|
+
this.addSystemMessage(`Tool: ${response.content || "Executing..."}`);
|
|
69
|
+
this.updateWebview();
|
|
70
|
+
});
|
|
71
|
+
this.cliConnector.onMessage("error", (response) => {
|
|
72
|
+
this.addSystemMessage(`Error: ${response.error || response.content}`);
|
|
73
|
+
this.updateWebview();
|
|
74
|
+
});
|
|
75
|
+
this.cliConnector.onMessage("done", () => {
|
|
76
|
+
// Handle completion if needed
|
|
77
|
+
});
|
|
78
|
+
this.cliConnector.onMessage("file_tree", (response) => {
|
|
79
|
+
// Handle file tree if needed
|
|
80
|
+
});
|
|
81
|
+
this.cliConnector.onMessage("file_content", (response) => {
|
|
82
|
+
// Handle file content if needed
|
|
83
|
+
});
|
|
84
|
+
this.cliConnector.onMessage("chat_history", (response) => {
|
|
85
|
+
if (response.messages) {
|
|
86
|
+
this.messages = response.messages.map((msg) => ({
|
|
87
|
+
id: this.generateId(),
|
|
88
|
+
role: msg.role,
|
|
89
|
+
content: msg.content,
|
|
90
|
+
timestamp: new Date(msg.timestamp),
|
|
91
|
+
}));
|
|
92
|
+
this.updateWebview();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
resolveWebviewView(webviewView) {
|
|
97
|
+
this.webviewView = webviewView;
|
|
98
|
+
webviewView.webview.options = {
|
|
99
|
+
enableScripts: true,
|
|
100
|
+
localResourceRoots: [this.extensionUri],
|
|
101
|
+
};
|
|
102
|
+
webviewView.webview.html = this.getHtmlContent(webviewView.webview);
|
|
103
|
+
// Handle messages from webview
|
|
104
|
+
webviewView.webview.onDidReceiveMessage(async (message) => {
|
|
105
|
+
await this.handleWebviewMessage(message);
|
|
106
|
+
}, null, this.disposables);
|
|
107
|
+
// Update with current connection status
|
|
108
|
+
this.updateConnectionStatus(this.cliConnector.getConnectionStatus());
|
|
109
|
+
}
|
|
110
|
+
async handleWebviewMessage(message) {
|
|
111
|
+
switch (message.type) {
|
|
112
|
+
case "ready":
|
|
113
|
+
this.updateConnectionStatus(this.cliConnector.getConnectionStatus());
|
|
114
|
+
this.cliConnector.requestChatHistory();
|
|
115
|
+
break;
|
|
116
|
+
case "sendMessage":
|
|
117
|
+
await this.handleSendMessage(message.content);
|
|
118
|
+
break;
|
|
119
|
+
case "getFileContext":
|
|
120
|
+
await this.handleGetFileContext();
|
|
121
|
+
break;
|
|
122
|
+
case "openFile":
|
|
123
|
+
await this.handleOpenFile(message.filePath);
|
|
124
|
+
break;
|
|
125
|
+
case "requestHistory":
|
|
126
|
+
this.cliConnector.requestChatHistory();
|
|
127
|
+
break;
|
|
128
|
+
case "clearHistory":
|
|
129
|
+
this.messages = [];
|
|
130
|
+
this.updateWebview();
|
|
131
|
+
break;
|
|
132
|
+
case "abort":
|
|
133
|
+
this.cliConnector.abortOperation();
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async handleSendMessage(content) {
|
|
138
|
+
// Expand file mentions if any
|
|
139
|
+
const expandedContent = await this.fileContextProvider.expandFileMentions(content);
|
|
140
|
+
// Parse file mentions for display
|
|
141
|
+
const mentions = this.fileContextProvider.parseFileMentions(content);
|
|
142
|
+
const fileContexts = [];
|
|
143
|
+
for (const mention of mentions) {
|
|
144
|
+
const filePath = mention.startsWith("/") ? mention : mention; // Handle both absolute and relative paths
|
|
145
|
+
if (vscode.workspace.workspaceFolders) {
|
|
146
|
+
const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath;
|
|
147
|
+
const absolutePath = require("path").join(workspaceRoot, filePath);
|
|
148
|
+
const fileMention = await this.fileContextProvider.getFileMention(absolutePath);
|
|
149
|
+
if (fileMention) {
|
|
150
|
+
fileContexts.push(fileMention);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Add user message
|
|
155
|
+
this.addUserMessage(content, fileContexts);
|
|
156
|
+
this.updateWebview();
|
|
157
|
+
// Send to CLI
|
|
158
|
+
this.cliConnector.sendChatMessage(expandedContent, mentions);
|
|
159
|
+
}
|
|
160
|
+
async handleGetFileContext() {
|
|
161
|
+
const currentFile = await this.fileContextProvider.getCurrentFileMention();
|
|
162
|
+
const openFiles = await this.fileContextProvider.getOpenFileMentions();
|
|
163
|
+
this.postMessageToWebview({
|
|
164
|
+
type: "fileContext",
|
|
165
|
+
currentFile,
|
|
166
|
+
openFiles,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
async handleOpenFile(filePath) {
|
|
170
|
+
try {
|
|
171
|
+
const document = await vscode.workspace.openTextDocument(vscode.Uri.file(filePath));
|
|
172
|
+
await vscode.window.showTextDocument(document);
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
vscode.window.showErrorMessage(`Failed to open file: ${filePath}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
addUserMessage(content, fileContexts) {
|
|
179
|
+
this.messages.push({
|
|
180
|
+
id: this.generateId(),
|
|
181
|
+
role: "user",
|
|
182
|
+
content,
|
|
183
|
+
timestamp: new Date(),
|
|
184
|
+
fileContexts,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
addAssistantMessage(content) {
|
|
188
|
+
this.messages.push({
|
|
189
|
+
id: this.generateId(),
|
|
190
|
+
role: "assistant",
|
|
191
|
+
content,
|
|
192
|
+
timestamp: new Date(),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
addSystemMessage(content) {
|
|
196
|
+
this.messages.push({
|
|
197
|
+
id: this.generateId(),
|
|
198
|
+
role: "system",
|
|
199
|
+
content,
|
|
200
|
+
timestamp: new Date(),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
updateWebview() {
|
|
204
|
+
this.postMessageToWebview({
|
|
205
|
+
type: "messages",
|
|
206
|
+
messages: this.messages,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
updateConnectionStatus(connected) {
|
|
210
|
+
this.postMessageToWebview({
|
|
211
|
+
type: "connectionStatus",
|
|
212
|
+
connected,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
postMessageToWebview(message) {
|
|
216
|
+
if (this.webviewView) {
|
|
217
|
+
this.webviewView.webview.postMessage(message);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
getHtmlContent(webview) {
|
|
221
|
+
const scriptUri = webview.asWebviewUri(vscode.Uri.file(this.extensionUri.path + "/dist/chat.js"));
|
|
222
|
+
const styleUri = webview.asWebviewUri(vscode.Uri.file(this.extensionUri.path + "/dist/chat.css"));
|
|
223
|
+
return `<!DOCTYPE html>
|
|
224
|
+
<html>
|
|
225
|
+
<head>
|
|
226
|
+
<meta charset="UTF-8">
|
|
227
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
228
|
+
<title>Super Agent Chat</title>
|
|
229
|
+
<link rel="stylesheet" href="${styleUri}">
|
|
230
|
+
</head>
|
|
231
|
+
<body>
|
|
232
|
+
<div class="container">
|
|
233
|
+
<div class="header">
|
|
234
|
+
<span class="title">Super Agent</span>
|
|
235
|
+
<span class="status" id="status">Connecting...</span>
|
|
236
|
+
</div>
|
|
237
|
+
<div class="messages" id="messages"></div>
|
|
238
|
+
<div class="input-area">
|
|
239
|
+
<input type="text" id="prompt" placeholder="@file.ts Ask something... (Press Enter to send)" autocomplete="off">
|
|
240
|
+
<button id="send">Send</button>
|
|
241
|
+
<button id="abort" style="display: none;">Stop</button>
|
|
242
|
+
</div>
|
|
243
|
+
<div class="file-context" id="fileContext" style="display: none;">
|
|
244
|
+
<button id="mentionCurrent">@ Current File</button>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
<script src="${scriptUri}"></script>
|
|
248
|
+
</body>
|
|
249
|
+
</html>`;
|
|
250
|
+
}
|
|
251
|
+
generateId() {
|
|
252
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
253
|
+
}
|
|
254
|
+
dispose() {
|
|
255
|
+
for (const disposable of this.disposables) {
|
|
256
|
+
disposable.dispose();
|
|
257
|
+
}
|
|
258
|
+
this.disposables = [];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.ChatProvider = ChatProvider;
|
|
262
|
+
//# sourceMappingURL=chat-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-provider.js","sourceRoot":"","sources":["../src/chat-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+CAAiC;AAUjC,MAAa,YAAY;IAMb;IACA;IACA;IACA;IARF,QAAQ,GAAkB,EAAE,CAAC;IAC7B,WAAW,CAAiC;IAC5C,WAAW,GAAwB,EAAE,CAAC;IAE9C,YACU,OAAgC,EAChC,YAAwB,EACxB,YAA0B,EAC1B,mBAA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