@codebolt/codeboltjs 1.1.70 → 1.1.73
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/index.js +2 -0
- package/package.json +4 -2
- package/src/index.ts +3 -1
- package/webpack.config.js +1 -1
- package/docs/modules/_internal_.EventEmitter.html +0 -6
- package/docs/modules/_internal_.WebSocket.html +0 -21
- package/docs/modules/_internal_._node_stream_consumers_.html +0 -6
- package/docs/modules/_internal_._node_stream_promises_.html +0 -3
- package/docs/modules/_internal_.html +0 -228
- package/docs/modules/_internal_.internal.finished.html +0 -2
- package/docs/modules/_internal_.internal.html +0 -36
- package/docs/modules/_internal_.internal.pipeline.html +0 -2
- package/index.d.ts +0 -238
- package/modules/browser.d.ts +0 -108
- package/modules/browser.js +0 -331
- package/modules/chat.d.ts +0 -63
- package/modules/chat.js +0 -174
- package/modules/codeparsers.d.ts +0 -23
- package/modules/codeparsers.js +0 -30
- package/modules/codeutils.d.ts +0 -37
- package/modules/codeutils.js +0 -166
- package/modules/crawler.d.ts +0 -45
- package/modules/crawler.js +0 -123
- package/modules/dbmemory.d.ts +0 -20
- package/modules/dbmemory.js +0 -54
- package/modules/debug.d.ts +0 -23
- package/modules/debug.js +0 -64
- package/modules/docutils.d.ts +0 -12
- package/modules/docutils.js +0 -19
- package/modules/fs.d.ts +0 -94
- package/modules/fs.js +0 -264
- package/modules/git.d.ts +0 -76
- package/modules/git.js +0 -240
- package/modules/history.d.ts +0 -19
- package/modules/history.js +0 -46
- package/modules/knowledge.d.ts +0 -2
- package/modules/knowledge.js +0 -6
- package/modules/llm.d.ts +0 -18
- package/modules/llm.js +0 -39
- package/modules/outputparsers.d.ts +0 -24
- package/modules/outputparsers.js +0 -32
- package/modules/project.d.ts +0 -21
- package/modules/project.js +0 -72
- package/modules/rag.d.ts +0 -22
- package/modules/rag.js +0 -30
- package/modules/search.d.ts +0 -23
- package/modules/search.js +0 -37
- package/modules/state.d.ts +0 -21
- package/modules/state.js +0 -68
- package/modules/task.d.ts +0 -23
- package/modules/task.js +0 -75
- package/modules/terminal.d.ts +0 -46
- package/modules/terminal.js +0 -108
- package/modules/tokenizer.d.ts +0 -19
- package/modules/tokenizer.js +0 -56
- package/modules/vectordb.d.ts +0 -33
- package/modules/vectordb.js +0 -103
- package/modules/websocket.d.ts +0 -27
- package/modules/websocket.js +0 -88
- package/src/modules/browser.ts +0 -352
- package/src/modules/chat.ts +0 -182
- package/src/modules/codeparsers.ts +0 -30
- package/src/modules/codeutils.ts +0 -181
- package/src/modules/crawler.ts +0 -121
- package/src/modules/dbmemory.ts +0 -52
- package/src/modules/debug.ts +0 -68
- package/src/modules/docutils.ts +0 -18
- package/src/modules/fs.ts +0 -263
- package/src/modules/git.ts +0 -237
- package/src/modules/history.ts +0 -61
- package/src/modules/knowledge.ts +0 -5
- package/src/modules/llm.ts +0 -36
- package/src/modules/outputparsers.ts +0 -30
- package/src/modules/project.ts +0 -68
- package/src/modules/rag.ts +0 -28
- package/src/modules/search.ts +0 -35
- package/src/modules/state.ts +0 -69
- package/src/modules/task.ts +0 -73
- package/src/modules/terminal.ts +0 -114
- package/src/modules/tokenizer.ts +0 -56
- package/src/modules/vectordb.ts +0 -102
- package/src/modules/websocket.ts +0 -89
package/modules/chat.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { ChatMessage, UserMessage } from '@codebolt/types';
|
|
4
|
-
/**
|
|
5
|
-
* CustomEventEmitter class that extends the Node.js EventEmitter class.
|
|
6
|
-
*/
|
|
7
|
-
declare class CustomEventEmitter extends EventEmitter {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Chat module to interact with the WebSocket server.
|
|
11
|
-
*/
|
|
12
|
-
declare const cbchat: {
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves the chat history from the server.
|
|
15
|
-
* @returns {Promise<ChatMessage[]>} A promise that resolves with an array of ChatMessage objects representing the chat history.
|
|
16
|
-
*/
|
|
17
|
-
getChatHistory: () => Promise<ChatMessage[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Sets up a listener for incoming WebSocket messages and emits a custom event when a message is received.
|
|
20
|
-
* @returns {EventEmitter} The event emitter used for emitting custom events.
|
|
21
|
-
*/
|
|
22
|
-
onActionMessage: () => CustomEventEmitter | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Sends a message through the WebSocket connection.
|
|
25
|
-
* @param {string} message - The message to be sent.
|
|
26
|
-
*/
|
|
27
|
-
sendMessage: (message: string, payload: any) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Waits for a reply to a sent message.
|
|
30
|
-
* @param {string} message - The message for which a reply is expected.
|
|
31
|
-
* @returns {Promise<UserMessage>} A promise that resolves with the reply.
|
|
32
|
-
*/
|
|
33
|
-
waitforReply: (message: string) => Promise<UserMessage>;
|
|
34
|
-
/**
|
|
35
|
-
* Notifies the server that a process has started and sets up an event listener for stopProcessClicked events.
|
|
36
|
-
* @returns An object containing the event emitter and a stopProcess method.
|
|
37
|
-
*/
|
|
38
|
-
processStarted: () => {
|
|
39
|
-
event: CustomEventEmitter;
|
|
40
|
-
stopProcess: () => void;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Stops the ongoing process.
|
|
44
|
-
* Sends a specific message to the server to stop the process.
|
|
45
|
-
*/
|
|
46
|
-
stopProcess: () => void;
|
|
47
|
-
/**
|
|
48
|
-
* Stops the ongoing process.
|
|
49
|
-
* Sends a specific message to the server to stop the process.
|
|
50
|
-
*/
|
|
51
|
-
processFinished: () => void;
|
|
52
|
-
/**
|
|
53
|
-
* Sends a confirmation request to the server with two options: Yes or No.
|
|
54
|
-
* @returns {Promise<string>} A promise that resolves with the server's response.
|
|
55
|
-
*/
|
|
56
|
-
sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
|
|
57
|
-
/**
|
|
58
|
-
* Sends a notification event to the server.
|
|
59
|
-
* @param {string} notificationMessage - The message to be sent in the notification.
|
|
60
|
-
*/
|
|
61
|
-
sendNotificationEvent: (notificationMessage: string, type: 'debug' | 'git' | 'planner' | 'browser' | 'editor' | 'terminal' | 'preview') => void;
|
|
62
|
-
};
|
|
63
|
-
export default cbchat;
|
package/modules/chat.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// chat.ts
|
|
7
|
-
const websocket_1 = __importDefault(require("./websocket"));
|
|
8
|
-
const events_1 = require("events");
|
|
9
|
-
/**
|
|
10
|
-
* CustomEventEmitter class that extends the Node.js EventEmitter class.
|
|
11
|
-
*/
|
|
12
|
-
class CustomEventEmitter extends events_1.EventEmitter {
|
|
13
|
-
}
|
|
14
|
-
let eventEmitter = new CustomEventEmitter();
|
|
15
|
-
/**
|
|
16
|
-
* Chat module to interact with the WebSocket server.
|
|
17
|
-
*/
|
|
18
|
-
const cbchat = {
|
|
19
|
-
/**
|
|
20
|
-
* Retrieves the chat history from the server.
|
|
21
|
-
* @returns {Promise<ChatMessage[]>} A promise that resolves with an array of ChatMessage objects representing the chat history.
|
|
22
|
-
*/
|
|
23
|
-
getChatHistory: () => {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
26
|
-
"type": "getChatHistory"
|
|
27
|
-
}));
|
|
28
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
29
|
-
const response = JSON.parse(data);
|
|
30
|
-
if (response.type === "getChatHistoryResponse") {
|
|
31
|
-
resolve(response); // Resolve the Promise with the response data
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Sets up a listener for incoming WebSocket messages and emits a custom event when a message is received.
|
|
38
|
-
* @returns {EventEmitter} The event emitter used for emitting custom events.
|
|
39
|
-
*/
|
|
40
|
-
onActionMessage: () => {
|
|
41
|
-
if (!websocket_1.default.getWebsocket)
|
|
42
|
-
return;
|
|
43
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
44
|
-
const response = JSON.parse(data);
|
|
45
|
-
if (response.type === "messageResponse") {
|
|
46
|
-
// Pass a callback function as an argument to the emit method
|
|
47
|
-
eventEmitter.emit("userMessage", response, (message) => {
|
|
48
|
-
console.log("Callback function invoked with message:", message);
|
|
49
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
50
|
-
"type": "processStoped"
|
|
51
|
-
}));
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return eventEmitter;
|
|
56
|
-
},
|
|
57
|
-
/**
|
|
58
|
-
* Sends a message through the WebSocket connection.
|
|
59
|
-
* @param {string} message - The message to be sent.
|
|
60
|
-
*/
|
|
61
|
-
sendMessage: (message, payload) => {
|
|
62
|
-
console.log(message);
|
|
63
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
64
|
-
"type": "sendMessage",
|
|
65
|
-
"message": message,
|
|
66
|
-
payload
|
|
67
|
-
}));
|
|
68
|
-
},
|
|
69
|
-
/**
|
|
70
|
-
* Waits for a reply to a sent message.
|
|
71
|
-
* @param {string} message - The message for which a reply is expected.
|
|
72
|
-
* @returns {Promise<UserMessage>} A promise that resolves with the reply.
|
|
73
|
-
*/
|
|
74
|
-
waitforReply: (message) => {
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
77
|
-
"type": "waitforReply",
|
|
78
|
-
"message": message
|
|
79
|
-
}));
|
|
80
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
81
|
-
const response = JSON.parse(data);
|
|
82
|
-
if (response.type === "waitFormessageResponse") {
|
|
83
|
-
resolve(response); // Resolve the Promise with the response data
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* Notifies the server that a process has started and sets up an event listener for stopProcessClicked events.
|
|
90
|
-
* @returns An object containing the event emitter and a stopProcess method.
|
|
91
|
-
*/
|
|
92
|
-
processStarted: () => {
|
|
93
|
-
// Send the process started message
|
|
94
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
95
|
-
"type": "processStarted"
|
|
96
|
-
}));
|
|
97
|
-
// Register event listener for WebSocket messages
|
|
98
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
99
|
-
const message = JSON.parse(data);
|
|
100
|
-
console.log("Received message:", message);
|
|
101
|
-
if (message.type === 'stopProcessClicked')
|
|
102
|
-
// Emit a custom event based on the message type
|
|
103
|
-
eventEmitter.emit("stopProcessClicked", message);
|
|
104
|
-
});
|
|
105
|
-
// Return an object that includes the event emitter and the stopProcess method
|
|
106
|
-
return {
|
|
107
|
-
event: eventEmitter,
|
|
108
|
-
stopProcess: () => {
|
|
109
|
-
// Implement the logic to stop the process here
|
|
110
|
-
console.log("Stopping process...");
|
|
111
|
-
// For example, you might want to send a specific message to the server to stop the process
|
|
112
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
113
|
-
"type": "processStoped"
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
/**
|
|
119
|
-
* Stops the ongoing process.
|
|
120
|
-
* Sends a specific message to the server to stop the process.
|
|
121
|
-
*/
|
|
122
|
-
stopProcess: () => {
|
|
123
|
-
// Implement the logic to stop the process here
|
|
124
|
-
console.log("Stopping process...");
|
|
125
|
-
// For example, you might want to send a specific message to the server to stop the process
|
|
126
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
127
|
-
"type": "processStoped"
|
|
128
|
-
}));
|
|
129
|
-
},
|
|
130
|
-
/**
|
|
131
|
-
* Stops the ongoing process.
|
|
132
|
-
* Sends a specific message to the server to stop the process.
|
|
133
|
-
*/
|
|
134
|
-
processFinished: () => {
|
|
135
|
-
// Implement the logic to stop the process here
|
|
136
|
-
console.log("Process Finished ...");
|
|
137
|
-
// For example, you might want to send a specific message to the server to stop the process
|
|
138
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
139
|
-
"type": "processFinished"
|
|
140
|
-
}));
|
|
141
|
-
},
|
|
142
|
-
/**
|
|
143
|
-
* Sends a confirmation request to the server with two options: Yes or No.
|
|
144
|
-
* @returns {Promise<string>} A promise that resolves with the server's response.
|
|
145
|
-
*/
|
|
146
|
-
sendConfirmationRequest: (confirmationMessage, buttons = [], withFeedback = false) => {
|
|
147
|
-
return new Promise((resolve, reject) => {
|
|
148
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
149
|
-
"type": "confirmationRequest",
|
|
150
|
-
"message": confirmationMessage,
|
|
151
|
-
buttons: buttons,
|
|
152
|
-
withFeedback
|
|
153
|
-
}));
|
|
154
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
155
|
-
const response = JSON.parse(data);
|
|
156
|
-
if (response.type === "confirmationResponse" || response.type === "feedbackResponse") {
|
|
157
|
-
resolve(response); // Resolve the Promise with the server's response
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
/**
|
|
163
|
-
* Sends a notification event to the server.
|
|
164
|
-
* @param {string} notificationMessage - The message to be sent in the notification.
|
|
165
|
-
*/
|
|
166
|
-
sendNotificationEvent: (notificationMessage, type) => {
|
|
167
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
168
|
-
"type": "notificationEvent",
|
|
169
|
-
"message": notificationMessage,
|
|
170
|
-
"eventType": type
|
|
171
|
-
}));
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
exports.default = cbchat;
|
package/modules/codeparsers.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A collection of code parser functions.
|
|
3
|
-
*/
|
|
4
|
-
declare const cbcodeparsers: {
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves the classes in a given file.
|
|
7
|
-
* @param file The file to parse for classes.
|
|
8
|
-
*/
|
|
9
|
-
getClassesInFile: (file: any) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves the functions in a given class within a file.
|
|
12
|
-
* @param file The file containing the class.
|
|
13
|
-
* @param className The name of the class to parse for functions.
|
|
14
|
-
*/
|
|
15
|
-
getFunctionsinClass: (file: any, className: any) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Generates an Abstract Syntax Tree (AST) for a given file.
|
|
18
|
-
* @param file The file to generate an AST for.
|
|
19
|
-
* @param className The name of the class to focus the AST generation on.
|
|
20
|
-
*/
|
|
21
|
-
getAstTreeInFile: (file: any, className: any) => void;
|
|
22
|
-
};
|
|
23
|
-
export default cbcodeparsers;
|
package/modules/codeparsers.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* A collection of code parser functions.
|
|
5
|
-
*/
|
|
6
|
-
const cbcodeparsers = {
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves the classes in a given file.
|
|
9
|
-
* @param file The file to parse for classes.
|
|
10
|
-
*/
|
|
11
|
-
getClassesInFile: (file) => {
|
|
12
|
-
console.log('Code parsers initialized');
|
|
13
|
-
},
|
|
14
|
-
/**
|
|
15
|
-
* Retrieves the functions in a given class within a file.
|
|
16
|
-
* @param file The file containing the class.
|
|
17
|
-
* @param className The name of the class to parse for functions.
|
|
18
|
-
*/
|
|
19
|
-
getFunctionsinClass: (file, className) => {
|
|
20
|
-
console.log('Code parsers initialized');
|
|
21
|
-
},
|
|
22
|
-
/**
|
|
23
|
-
* Generates an Abstract Syntax Tree (AST) for a given file.
|
|
24
|
-
* @param file The file to generate an AST for.
|
|
25
|
-
* @param className The name of the class to focus the AST generation on.
|
|
26
|
-
*/
|
|
27
|
-
getAstTreeInFile: (file, className) => {
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
exports.default = cbcodeparsers;
|
package/modules/codeutils.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types';
|
|
2
|
-
/**
|
|
3
|
-
* A utility module for working with code.
|
|
4
|
-
*/
|
|
5
|
-
declare const cbcodeutils: {
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves a JavaScript tree structure for a given file path.
|
|
8
|
-
* @param {string} filePath - The path of the file to retrieve the JS tree for.
|
|
9
|
-
* @returns {Promise<GetJsTreeResponse>} A promise that resolves with the JS tree response.
|
|
10
|
-
*/
|
|
11
|
-
getJsTree: (filePath?: string) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Retrieves all files as Markdown.
|
|
14
|
-
* @returns {Promise<string>} A promise that resolves with the Markdown content of all files.
|
|
15
|
-
*/
|
|
16
|
-
getAllFilesAsMarkDown: () => Promise<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Performs a matching operation based on the provided matcher definition and problem patterns.
|
|
19
|
-
* @param {object} matcherDefinition - The definition of the matcher.
|
|
20
|
-
* @param {Array} problemPatterns - The patterns to match against.
|
|
21
|
-
* @param {Array} problems - The list of problems.
|
|
22
|
-
* @returns {Promise<MatchProblemResponse>} A promise that resolves with the matching problem response.
|
|
23
|
-
*/
|
|
24
|
-
performMatch: (matcherDefinition: object, problemPatterns: any[], problems: any[]) => Promise<MatchProblemResponse>;
|
|
25
|
-
/**
|
|
26
|
-
* Retrieves the list of matchers.
|
|
27
|
-
* @returns {Promise<GetMatcherListTreeResponse>} A promise that resolves with the list of matchers response.
|
|
28
|
-
*/
|
|
29
|
-
getMatcherList: () => Promise<GetMatcherListTreeResponse>;
|
|
30
|
-
/**
|
|
31
|
-
* Retrieves details of a match.
|
|
32
|
-
* @param {string} matcher - The matcher to retrieve details for.
|
|
33
|
-
* @returns {Promise<getMatchDetail>} A promise that resolves with the match detail response.
|
|
34
|
-
*/
|
|
35
|
-
matchDetail: (matcher: string) => Promise<getMatchDetail>;
|
|
36
|
-
};
|
|
37
|
-
export default cbcodeutils;
|
package/modules/codeutils.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
-
/**
|
|
8
|
-
* A utility module for working with code.
|
|
9
|
-
*/
|
|
10
|
-
const cbcodeutils = {
|
|
11
|
-
/**
|
|
12
|
-
* Retrieves a JavaScript tree structure for a given file path.
|
|
13
|
-
* @param {string} filePath - The path of the file to retrieve the JS tree for.
|
|
14
|
-
* @returns {Promise<GetJsTreeResponse>} A promise that resolves with the JS tree response.
|
|
15
|
-
*/
|
|
16
|
-
getJsTree: (filePath) => {
|
|
17
|
-
// return new Promise( async (resolve, reject) => {
|
|
18
|
-
// cbws.getWebsocket.send(JSON.stringify({
|
|
19
|
-
// "type": "settingEvent",
|
|
20
|
-
// "action": "getProjectPath"
|
|
21
|
-
// }));
|
|
22
|
-
// cbws.getWebsocket.on('message', (data: string) => {
|
|
23
|
-
// const response = JSON.parse(data);
|
|
24
|
-
// if (response.type === "getProjectPathResponse") {
|
|
25
|
-
// // resolve(response);
|
|
26
|
-
// try {
|
|
27
|
-
// let pathInput= response.projectPath;
|
|
28
|
-
// let parser= new Parser();
|
|
29
|
-
// // Initialize the parser with the JavaScript language
|
|
30
|
-
// parser.setLanguage(JavaScript);
|
|
31
|
-
// const trees = [];
|
|
32
|
-
// const functionNodes = [];
|
|
33
|
-
// const processDirectory = (directory:any) => {
|
|
34
|
-
// console.log("isdir")
|
|
35
|
-
// // Read all files in the directory
|
|
36
|
-
// const files = fs.readdirSync(directory, { withFileTypes: true });
|
|
37
|
-
// files.forEach(file => {
|
|
38
|
-
// if (file.isDirectory()) {
|
|
39
|
-
// if (file.name !== 'node_modules') { // Ignore node_modules directory
|
|
40
|
-
// processDirectory(path.join(directory, file.name)); // Recursive call for subdirectories
|
|
41
|
-
// }
|
|
42
|
-
// } else if (path.extname(file.name) === '.js') {
|
|
43
|
-
// const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
|
|
44
|
-
// console.log(code);
|
|
45
|
-
// let tree:any = parser.parse(code);
|
|
46
|
-
// tree.rootNode.path = path.join(directory, file.name); // Set file path for t
|
|
47
|
-
// trees.push(tree);
|
|
48
|
-
// }
|
|
49
|
-
// });
|
|
50
|
-
// };
|
|
51
|
-
// if (fs.lstatSync(pathInput).isDirectory()) {
|
|
52
|
-
// processDirectory(pathInput);
|
|
53
|
-
// } else if (path.extname(pathInput) === '.js') {
|
|
54
|
-
// // Read a single JavaScript file
|
|
55
|
-
// const code = fs.readFileSync(pathInput, 'utf-8');
|
|
56
|
-
// let tree:any = parser.parse(code);
|
|
57
|
-
// tree.rootNode.path = pathInput; // Set file path for t
|
|
58
|
-
// trees.push(tree);
|
|
59
|
-
// }
|
|
60
|
-
// resolve({ event: 'GetJsTreeResponse',payload:trees}); // Return an array of abstract syntax trees (ASTs)
|
|
61
|
-
// } catch (error) {
|
|
62
|
-
// console.error('An error occurred:', error);
|
|
63
|
-
// return { event: 'GetJsTreeResponse',payload:null}; // Return null in case of error
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
66
|
-
// });
|
|
67
|
-
// // cbws.getWebsocket.send(JSON.stringify({
|
|
68
|
-
// // "type": "codeEvent",
|
|
69
|
-
// // "action":"getJsTree",
|
|
70
|
-
// // payload:{
|
|
71
|
-
// // filePath
|
|
72
|
-
// // }
|
|
73
|
-
// // }));
|
|
74
|
-
// // cbws.getWebsocket.on('message', (data: string) => {
|
|
75
|
-
// // const response = JSON.parse(data);
|
|
76
|
-
// // if (response.type === "getJsTreeResponse") {
|
|
77
|
-
// // resolve(response); // Resolve the Promise with the response data
|
|
78
|
-
// // }
|
|
79
|
-
// // });
|
|
80
|
-
// });
|
|
81
|
-
},
|
|
82
|
-
/**
|
|
83
|
-
* Retrieves all files as Markdown.
|
|
84
|
-
* @returns {Promise<string>} A promise that resolves with the Markdown content of all files.
|
|
85
|
-
*/
|
|
86
|
-
getAllFilesAsMarkDown: () => {
|
|
87
|
-
return new Promise((resolve, reject) => {
|
|
88
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
89
|
-
"type": "codeEvent",
|
|
90
|
-
"action": "getAllFilesMarkdown"
|
|
91
|
-
}));
|
|
92
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
93
|
-
const response = JSON.parse(data);
|
|
94
|
-
if (response.type === "getAllFilesMarkdownResponse") {
|
|
95
|
-
resolve(response); // Resolve the Promise with the response data
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
/**
|
|
101
|
-
* Performs a matching operation based on the provided matcher definition and problem patterns.
|
|
102
|
-
* @param {object} matcherDefinition - The definition of the matcher.
|
|
103
|
-
* @param {Array} problemPatterns - The patterns to match against.
|
|
104
|
-
* @param {Array} problems - The list of problems.
|
|
105
|
-
* @returns {Promise<MatchProblemResponse>} A promise that resolves with the matching problem response.
|
|
106
|
-
*/
|
|
107
|
-
performMatch: (matcherDefinition, problemPatterns, problems) => {
|
|
108
|
-
return new Promise((resolve, reject) => {
|
|
109
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
110
|
-
"type": "codeEvent",
|
|
111
|
-
"action": "performMatch",
|
|
112
|
-
payload: {
|
|
113
|
-
matcherDefinition,
|
|
114
|
-
problemPatterns,
|
|
115
|
-
}
|
|
116
|
-
}));
|
|
117
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
118
|
-
const response = JSON.parse(data);
|
|
119
|
-
if (response.type === "getgetJsTreeResponse") {
|
|
120
|
-
resolve(response); // Resolve the Promise with the response data
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
/**
|
|
126
|
-
* Retrieves the list of matchers.
|
|
127
|
-
* @returns {Promise<GetMatcherListTreeResponse>} A promise that resolves with the list of matchers response.
|
|
128
|
-
*/
|
|
129
|
-
getMatcherList: () => {
|
|
130
|
-
return new Promise((resolve, reject) => {
|
|
131
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
132
|
-
"type": "codeEvent",
|
|
133
|
-
"action": "getMatcherList",
|
|
134
|
-
}));
|
|
135
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
136
|
-
const response = JSON.parse(data);
|
|
137
|
-
if (response.type === "getMatcherListTreeResponse") {
|
|
138
|
-
resolve(response); // Resolve the Promise with the response data
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
},
|
|
143
|
-
/**
|
|
144
|
-
* Retrieves details of a match.
|
|
145
|
-
* @param {string} matcher - The matcher to retrieve details for.
|
|
146
|
-
* @returns {Promise<getMatchDetail>} A promise that resolves with the match detail response.
|
|
147
|
-
*/
|
|
148
|
-
matchDetail: (matcher) => {
|
|
149
|
-
return new Promise((resolve, reject) => {
|
|
150
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
151
|
-
"type": "codeEvent",
|
|
152
|
-
"action": "getMatchDetail",
|
|
153
|
-
payload: {
|
|
154
|
-
match: matcher
|
|
155
|
-
}
|
|
156
|
-
}));
|
|
157
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
158
|
-
const response = JSON.parse(data);
|
|
159
|
-
if (response.type === "matchDetailTreeResponse") {
|
|
160
|
-
resolve(response); // Resolve the Promise with the response data
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
exports.default = cbcodeutils;
|
package/modules/crawler.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A module for controlling a web crawler through WebSocket messages.
|
|
3
|
-
*/
|
|
4
|
-
declare const cbcrawler: {
|
|
5
|
-
/**
|
|
6
|
-
* Starts the crawler.
|
|
7
|
-
*/
|
|
8
|
-
start: () => void;
|
|
9
|
-
/**
|
|
10
|
-
* Takes a screenshot using the crawler.
|
|
11
|
-
*/
|
|
12
|
-
screenshot: () => void;
|
|
13
|
-
/**
|
|
14
|
-
* Directs the crawler to navigate to a specified URL.
|
|
15
|
-
* @param url - The URL for the crawler to navigate to.
|
|
16
|
-
*/
|
|
17
|
-
goToPage: (url: string) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Scrolls the crawler in a specified direction.
|
|
20
|
-
* @param direction - The direction to scroll ('up', 'down', 'left', 'right').
|
|
21
|
-
*/
|
|
22
|
-
scroll: (direction: string) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Simulates a click event on an element with the specified ID.
|
|
25
|
-
* @param id - The ID of the element to be clicked.
|
|
26
|
-
* @returns {Promise<any>} A promise that resolves when the click action is complete.
|
|
27
|
-
*/
|
|
28
|
-
click: (id: string) => Promise<unknown>;
|
|
29
|
-
/**
|
|
30
|
-
* Types the provided text into an element with the specified ID.
|
|
31
|
-
* @param id - The ID of the element where text will be typed.
|
|
32
|
-
* @param text - The text to type into the element.
|
|
33
|
-
* @returns {Promise<any>} A promise that resolves when the type action is complete.
|
|
34
|
-
*/
|
|
35
|
-
type: (id: string, text: string) => Promise<unknown>;
|
|
36
|
-
/**
|
|
37
|
-
* Simulates the Enter key press using the crawler.
|
|
38
|
-
*/
|
|
39
|
-
enter: () => void;
|
|
40
|
-
/**
|
|
41
|
-
* Initiates a crawl process.
|
|
42
|
-
*/
|
|
43
|
-
crawl: (query: string) => Promise<unknown>;
|
|
44
|
-
};
|
|
45
|
-
export default cbcrawler;
|
package/modules/crawler.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
-
/**
|
|
8
|
-
* A module for controlling a web crawler through WebSocket messages.
|
|
9
|
-
*/
|
|
10
|
-
const cbcrawler = {
|
|
11
|
-
/**
|
|
12
|
-
* Starts the crawler.
|
|
13
|
-
*/
|
|
14
|
-
start: () => {
|
|
15
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
16
|
-
"type": "crawlerEvent",
|
|
17
|
-
action: 'start'
|
|
18
|
-
}));
|
|
19
|
-
},
|
|
20
|
-
/**
|
|
21
|
-
* Takes a screenshot using the crawler.
|
|
22
|
-
*/
|
|
23
|
-
screenshot: () => {
|
|
24
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
25
|
-
"type": "crawlerEvent",
|
|
26
|
-
action: 'screenshot'
|
|
27
|
-
}));
|
|
28
|
-
},
|
|
29
|
-
/**
|
|
30
|
-
* Directs the crawler to navigate to a specified URL.
|
|
31
|
-
* @param url - The URL for the crawler to navigate to.
|
|
32
|
-
*/
|
|
33
|
-
goToPage: (url) => {
|
|
34
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
35
|
-
"type": "crawlerEvent",
|
|
36
|
-
action: 'goToPage',
|
|
37
|
-
url
|
|
38
|
-
}));
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Scrolls the crawler in a specified direction.
|
|
42
|
-
* @param direction - The direction to scroll ('up', 'down', 'left', 'right').
|
|
43
|
-
*/
|
|
44
|
-
scroll: (direction) => {
|
|
45
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
46
|
-
"type": "crawlerEvent",
|
|
47
|
-
action: 'scroll',
|
|
48
|
-
direction
|
|
49
|
-
}));
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* Simulates a click event on an element with the specified ID.
|
|
53
|
-
* @param id - The ID of the element to be clicked.
|
|
54
|
-
* @returns {Promise<any>} A promise that resolves when the click action is complete.
|
|
55
|
-
*/
|
|
56
|
-
click: (id) => {
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
59
|
-
"type": "crawlerEvent",
|
|
60
|
-
action: 'click',
|
|
61
|
-
id
|
|
62
|
-
}));
|
|
63
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
64
|
-
const response = JSON.parse(data);
|
|
65
|
-
if (response.event === "clickFinished") {
|
|
66
|
-
resolve(response);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
/**
|
|
72
|
-
* Types the provided text into an element with the specified ID.
|
|
73
|
-
* @param id - The ID of the element where text will be typed.
|
|
74
|
-
* @param text - The text to type into the element.
|
|
75
|
-
* @returns {Promise<any>} A promise that resolves when the type action is complete.
|
|
76
|
-
*/
|
|
77
|
-
type: (id, text) => {
|
|
78
|
-
return new Promise((resolve, reject) => {
|
|
79
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
80
|
-
"type": "crawlerEvent",
|
|
81
|
-
action: 'type',
|
|
82
|
-
id,
|
|
83
|
-
text
|
|
84
|
-
}));
|
|
85
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
86
|
-
const response = JSON.parse(data);
|
|
87
|
-
if (response.event === "typeFinished") {
|
|
88
|
-
resolve(response);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
/**
|
|
94
|
-
* Simulates the Enter key press using the crawler.
|
|
95
|
-
*/
|
|
96
|
-
enter: () => {
|
|
97
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
98
|
-
"type": "crawlerEvent",
|
|
99
|
-
action: 'enter'
|
|
100
|
-
}));
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* Initiates a crawl process.
|
|
104
|
-
*/
|
|
105
|
-
crawl: (query) => {
|
|
106
|
-
return new Promise((resolve, reject) => {
|
|
107
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
108
|
-
"type": "crawlerEvent",
|
|
109
|
-
"action": 'crawl',
|
|
110
|
-
"message": {
|
|
111
|
-
query
|
|
112
|
-
}
|
|
113
|
-
}));
|
|
114
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
115
|
-
const response = JSON.parse(data);
|
|
116
|
-
if (response.type === "crawlResponse") {
|
|
117
|
-
resolve(response); // Resolve the Promise with the response data
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
exports.default = cbcrawler;
|