phantomx-tool-client 1.0.0
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/bin/tool-server.js +16 -0
- package/dist/Services/EditTool.d.ts +86 -0
- package/dist/Services/EditTool.d.ts.map +1 -0
- package/dist/Services/EditTool.js +516 -0
- package/dist/Services/EditTool.js.map +1 -0
- package/dist/Services/Logger.d.ts +32 -0
- package/dist/Services/Logger.d.ts.map +1 -0
- package/dist/Services/Logger.js +185 -0
- package/dist/Services/Logger.js.map +1 -0
- package/dist/Services/ReadFileTool.d.ts +49 -0
- package/dist/Services/ReadFileTool.d.ts.map +1 -0
- package/dist/Services/ReadFileTool.js +239 -0
- package/dist/Services/ReadFileTool.js.map +1 -0
- package/dist/__tests__/__mocks__/tool-server.mock.d.ts +4 -0
- package/dist/__tests__/__mocks__/tool-server.mock.d.ts.map +1 -0
- package/dist/__tests__/__mocks__/tool-server.mock.js +8 -0
- package/dist/__tests__/__mocks__/tool-server.mock.js.map +1 -0
- package/dist/__tests__/toolExecutionService_tempAI.test.d.ts +13 -0
- package/dist/__tests__/toolExecutionService_tempAI.test.d.ts.map +1 -0
- package/dist/__tests__/toolExecutionService_tempAI.test.js +491 -0
- package/dist/__tests__/toolExecutionService_tempAI.test.js.map +1 -0
- package/dist/githubOperationsHanlder.d.ts +274 -0
- package/dist/githubOperationsHanlder.d.ts.map +1 -0
- package/dist/githubOperationsHanlder.js +1487 -0
- package/dist/githubOperationsHanlder.js.map +1 -0
- package/dist/tool-server.d.ts +4 -0
- package/dist/tool-server.d.ts.map +1 -0
- package/dist/tool-server.js +190 -0
- package/dist/tool-server.js.map +1 -0
- package/dist/toolExecutionService.d.ts +28 -0
- package/dist/toolExecutionService.d.ts.map +1 -0
- package/dist/toolExecutionService.js +464 -0
- package/dist/toolExecutionService.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
DEBUG = 0,
|
|
3
|
+
INFO = 1,
|
|
4
|
+
SUCCESS = 2,
|
|
5
|
+
WARN = 3,
|
|
6
|
+
ERROR = 4,
|
|
7
|
+
NONE = 5
|
|
8
|
+
}
|
|
9
|
+
export declare class Logger {
|
|
10
|
+
private context;
|
|
11
|
+
private static globalLogLevel;
|
|
12
|
+
userId: string;
|
|
13
|
+
organizationId: string;
|
|
14
|
+
private static serverMode;
|
|
15
|
+
private static logFilePath;
|
|
16
|
+
constructor(context: string, userId?: string, organizationId?: string);
|
|
17
|
+
static setGlobalLogLevel(level: LogLevel): void;
|
|
18
|
+
static setServerMode(mode: number): void;
|
|
19
|
+
static getServerMode(): number;
|
|
20
|
+
private getTimestamp;
|
|
21
|
+
private formatMessage;
|
|
22
|
+
private writeLog;
|
|
23
|
+
debug(message: string, data?: any): void;
|
|
24
|
+
info(message: string, data?: any): void;
|
|
25
|
+
success(message: string, data?: any): void;
|
|
26
|
+
warn(message: string, data?: any): void;
|
|
27
|
+
error(message: string, error?: any): void;
|
|
28
|
+
operation(operation: string): void;
|
|
29
|
+
operationComplete(operation: string, duration?: number): void;
|
|
30
|
+
}
|
|
31
|
+
export declare const createLogger: (context: string) => Logger;
|
|
32
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Services/Logger.ts"],"names":[],"mappings":"AAMA,oBAAY,QAAQ;IAChB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,OAAO,IAAI;IACX,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;CACX;AAED,qBAAa,MAAM;IACf,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,cAAc,CAA2B;IACjD,MAAM,EAAE,MAAM,CAAM;IACpB,cAAc,EAAE,MAAM,CAAM;IACnC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAa;IACtC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAc;gBAG5B,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;IAMrE,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/C,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAaxC,MAAM,CAAC,aAAa,IAAI,MAAM;IAI9B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,QAAQ;IAkBhB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAWxC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAWvC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAW1C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAWvC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAezC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKlC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAMhE;AAGD,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAA6B,CAAC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createLogger = exports.Logger = exports.LogLevel = void 0;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const dotenv = __importStar(require("dotenv"));
|
|
44
|
+
dotenv.config();
|
|
45
|
+
// TEST_EDIT_MARKER: file edited successfully for testing.
|
|
46
|
+
var LogLevel;
|
|
47
|
+
(function (LogLevel) {
|
|
48
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
49
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
50
|
+
LogLevel[LogLevel["SUCCESS"] = 2] = "SUCCESS";
|
|
51
|
+
LogLevel[LogLevel["WARN"] = 3] = "WARN";
|
|
52
|
+
LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
|
|
53
|
+
LogLevel[LogLevel["NONE"] = 5] = "NONE";
|
|
54
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
55
|
+
class Logger {
|
|
56
|
+
constructor(context, userId, organizationId) {
|
|
57
|
+
this.userId = "";
|
|
58
|
+
this.organizationId = "";
|
|
59
|
+
this.context = context;
|
|
60
|
+
this.userId = userId;
|
|
61
|
+
this.organizationId = organizationId;
|
|
62
|
+
}
|
|
63
|
+
static setGlobalLogLevel(level) {
|
|
64
|
+
Logger.globalLogLevel = level;
|
|
65
|
+
}
|
|
66
|
+
static setServerMode(mode) {
|
|
67
|
+
Logger.serverMode = mode;
|
|
68
|
+
Logger.logFilePath = process.env.SERVER_LOG_FILE || '/tmp/tool-server-logs.log';
|
|
69
|
+
// If in production mode and log file path is set, ensure directory exists
|
|
70
|
+
const logDir = path.dirname(Logger.logFilePath);
|
|
71
|
+
if (!fs.existsSync(logDir)) {
|
|
72
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
static getServerMode() {
|
|
76
|
+
return Logger.serverMode;
|
|
77
|
+
}
|
|
78
|
+
getTimestamp() {
|
|
79
|
+
const now = new Date();
|
|
80
|
+
return now.toISOString();
|
|
81
|
+
}
|
|
82
|
+
formatMessage(level, message, data) {
|
|
83
|
+
const timestamp = this.getTimestamp();
|
|
84
|
+
let formattedMsg = `[${timestamp}] [${level}] [${this.context}] ${message}`;
|
|
85
|
+
if (data !== undefined) {
|
|
86
|
+
formattedMsg += ` ${typeof data === 'object' ? JSON.stringify(data) : data}`;
|
|
87
|
+
}
|
|
88
|
+
return formattedMsg;
|
|
89
|
+
}
|
|
90
|
+
writeLog(message) {
|
|
91
|
+
// Production mode: write to file
|
|
92
|
+
if (Logger.logFilePath) {
|
|
93
|
+
try {
|
|
94
|
+
// Append to log file with newline
|
|
95
|
+
fs.appendFileSync(Logger.logFilePath, message + '\n', 'utf8');
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// Fallback to console if file writing fails
|
|
99
|
+
console.error('Failed to write to log file:', error);
|
|
100
|
+
console.log(message);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Fallback to console if no log file path is configured
|
|
105
|
+
console.log(message);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
debug(message, data) {
|
|
109
|
+
if (Logger.globalLogLevel <= LogLevel.DEBUG) {
|
|
110
|
+
const formattedMsg = this.formatMessage('DEBUG', message, data);
|
|
111
|
+
if (Logger.serverMode === 0) {
|
|
112
|
+
console.log(chalk_1.default.gray(formattedMsg));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
this.writeLog(formattedMsg);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
info(message, data) {
|
|
120
|
+
if (Logger.globalLogLevel <= LogLevel.INFO) {
|
|
121
|
+
const formattedMsg = this.formatMessage('INFO', message, data);
|
|
122
|
+
if (Logger.serverMode === 0) {
|
|
123
|
+
console.log(chalk_1.default.blue(formattedMsg));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.writeLog(formattedMsg);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
success(message, data) {
|
|
131
|
+
if (Logger.globalLogLevel <= LogLevel.SUCCESS) {
|
|
132
|
+
const formattedMsg = this.formatMessage('SUCCESS', message, data);
|
|
133
|
+
if (Logger.serverMode === 0) {
|
|
134
|
+
console.log(chalk_1.default.green(formattedMsg));
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.writeLog(formattedMsg);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
warn(message, data) {
|
|
142
|
+
if (Logger.globalLogLevel <= LogLevel.WARN) {
|
|
143
|
+
const formattedMsg = this.formatMessage('WARN', message, data);
|
|
144
|
+
if (Logger.serverMode === 0) {
|
|
145
|
+
console.log(chalk_1.default.yellow(formattedMsg));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.writeLog(formattedMsg);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
error(message, error) {
|
|
153
|
+
if (Logger.globalLogLevel <= LogLevel.ERROR) {
|
|
154
|
+
const errorMsg = error instanceof Error
|
|
155
|
+
? `${error.message}\n${error.stack}`
|
|
156
|
+
: error;
|
|
157
|
+
const formattedMsg = this.formatMessage('ERROR', message, errorMsg);
|
|
158
|
+
if (Logger.serverMode === 0) {
|
|
159
|
+
console.error(chalk_1.default.red(formattedMsg));
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.writeLog(formattedMsg);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Shorthand for logging operation start
|
|
167
|
+
operation(operation) {
|
|
168
|
+
this.info(`Starting operation: ${operation}`);
|
|
169
|
+
}
|
|
170
|
+
// Shorthand for logging operation completion
|
|
171
|
+
operationComplete(operation, duration) {
|
|
172
|
+
const msg = duration
|
|
173
|
+
? `${operation} completed in ${duration}ms`
|
|
174
|
+
: `${operation} completed`;
|
|
175
|
+
this.success(msg);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.Logger = Logger;
|
|
179
|
+
Logger.globalLogLevel = LogLevel.INFO;
|
|
180
|
+
Logger.serverMode = 0; // 0 = dev (console), 1 = prod (file)
|
|
181
|
+
Logger.logFilePath = '';
|
|
182
|
+
// Export a factory function for convenience
|
|
183
|
+
const createLogger = (context) => new Logger(context);
|
|
184
|
+
exports.createLogger = createLogger;
|
|
185
|
+
//# sourceMappingURL=Logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Services/Logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAChB,0DAA0D;AAC1D,IAAY,QAOX;AAPD,WAAY,QAAQ;IAChB,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,6CAAW,CAAA;IACX,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,uCAAQ,CAAA;AACZ,CAAC,EAPW,QAAQ,wBAAR,QAAQ,QAOnB;AAED,MAAa,MAAM;IASf,YAAY,OAAe,EAAE,MAAe,EAAE,cAAuB;QAN9D,WAAM,GAAW,EAAE,CAAC;QACpB,mBAAc,GAAW,EAAE,CAAC;QAM/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAa,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,cAAqB,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,KAAe;QACpC,MAAM,CAAC,cAAc,GAAG,KAAK,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,IAAY;QAC7B,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,2BAA2B,CAAC;QAEhF,0EAA0E;QAEtE,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,EAA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C;IAC7C,iBAAiB,CAAC,SAAiB,EAAE,QAAiB;QAClD,MAAM,GAAG,GAAG,QAAQ;YAChB,CAAC,CAAC,GAAG,SAAS,iBAAiB,QAAQ,IAAI;YAC3C,CAAC,CAAC,GAAG,SAAS,YAAY,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;;AA3IL,wBA4IC;AA1IkB,qBAAc,GAAa,QAAQ,CAAC,IAAI,AAA1B,CAA2B;AAGzC,iBAAU,GAAW,CAAC,AAAZ,CAAa,CAAC,qCAAqC;AAC7D,kBAAW,GAAW,EAAE,AAAb,CAAc;AAwI5C,4CAA4C;AACrC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAAhE,QAAA,YAAY,gBAAoD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface defining the structure for file reading operations
|
|
3
|
+
*/
|
|
4
|
+
interface ReadFileOptions {
|
|
5
|
+
targetFile: string;
|
|
6
|
+
absolutePath: string;
|
|
7
|
+
shouldReadEntireFile: boolean;
|
|
8
|
+
startLineOneIndexed: number;
|
|
9
|
+
endLineOneIndexedInclusive: number;
|
|
10
|
+
explanation?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Class that provides file reading functionality
|
|
14
|
+
*/
|
|
15
|
+
export declare class ReadFileTool {
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for ReadFileTool
|
|
18
|
+
* No longer requires a folderPath parameter as we'll use absolute paths directly
|
|
19
|
+
*/
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Reads the contents of a file within the specified line range
|
|
23
|
+
* @param options The read operation options
|
|
24
|
+
* @returns A promise that resolves to the file contents and summary
|
|
25
|
+
*/
|
|
26
|
+
readFile(options: ReadFileOptions): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Validates the read options to ensure they have all required fields and are within valid ranges
|
|
29
|
+
* @param options The read options to validate
|
|
30
|
+
* @param fullPath The full path to the file
|
|
31
|
+
*/
|
|
32
|
+
private validateReadOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the total number of lines in a file
|
|
35
|
+
* @param filePath Path to the file
|
|
36
|
+
* @returns The total number of lines in the file
|
|
37
|
+
*/
|
|
38
|
+
getLineCount(filePath: string): Promise<number>;
|
|
39
|
+
/**
|
|
40
|
+
* Adjusts the line range to ensure we read at least 200 lines when possible
|
|
41
|
+
* @param startLine The starting line number
|
|
42
|
+
* @param endLine The ending line number
|
|
43
|
+
* @param totalLines The total number of lines in the file
|
|
44
|
+
* @returns An object with adjusted start and end line numbers
|
|
45
|
+
*/
|
|
46
|
+
private adjustLineRange;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=ReadFileTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadFileTool.d.ts","sourceRoot":"","sources":["../../src/Services/ReadFileTool.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAC,MAAM,CAAC;IACpB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,0BAA0B,EAAE,MAAM,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB;;;OAGG;;IAGH;;;;OAIG;IACU,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IA8DhE;;;;OAIG;YACW,mBAAmB;IA2CjC;;;;OAIG;IACU,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAY5D;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;CA4BxB"}
|
|
@@ -0,0 +1,239 @@
|
|
|
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.ReadFileTool = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Normalizes a path for the current OS.
|
|
41
|
+
* On Windows: converts Linux-style WSL paths (/mnt/f/...) to Windows paths (F:\...)
|
|
42
|
+
* On Linux/Mac: returns the path as-is.
|
|
43
|
+
*/
|
|
44
|
+
const normalizePath = (inputPath) => {
|
|
45
|
+
if (process.platform !== 'win32') {
|
|
46
|
+
return inputPath; // Linux/Mac — no translation needed
|
|
47
|
+
}
|
|
48
|
+
// Match /mnt/<single-letter>/<rest> — WSL mount convention
|
|
49
|
+
const wslMountPattern = /^\/mnt\/([a-zA-Z])(\/.*)?$/;
|
|
50
|
+
const match = inputPath.match(wslMountPattern);
|
|
51
|
+
if (match) {
|
|
52
|
+
const driveLetter = match[1].toUpperCase();
|
|
53
|
+
const rest = match[2] ? match[2].replace(/\//g, '\\') : '\\';
|
|
54
|
+
return `${driveLetter}:${rest}`;
|
|
55
|
+
}
|
|
56
|
+
return inputPath; // already a Windows path or unrecognised format
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Class that provides file reading functionality
|
|
60
|
+
*/
|
|
61
|
+
class ReadFileTool {
|
|
62
|
+
/**
|
|
63
|
+
* Constructor for ReadFileTool
|
|
64
|
+
* No longer requires a folderPath parameter as we'll use absolute paths directly
|
|
65
|
+
*/
|
|
66
|
+
constructor() { }
|
|
67
|
+
/**
|
|
68
|
+
* Reads the contents of a file within the specified line range
|
|
69
|
+
* @param options The read operation options
|
|
70
|
+
* @returns A promise that resolves to the file contents and summary
|
|
71
|
+
*/
|
|
72
|
+
async readFile(options) {
|
|
73
|
+
try {
|
|
74
|
+
// Normalize path for the current OS (handles Linux /mnt/<drive> paths on Windows)
|
|
75
|
+
const fullPath = normalizePath(options.absolutePath);
|
|
76
|
+
// Validate the read request
|
|
77
|
+
await this.validateReadOptions(options, fullPath);
|
|
78
|
+
// Check if file exists
|
|
79
|
+
if (!fs.existsSync(fullPath)) {
|
|
80
|
+
throw new Error(`File not found: ${fullPath}`);
|
|
81
|
+
}
|
|
82
|
+
// Read the file content
|
|
83
|
+
const fileContent = await fs.promises.readFile(fullPath, 'utf8');
|
|
84
|
+
const lines = fileContent.split('\n');
|
|
85
|
+
const totalLines = lines.length;
|
|
86
|
+
// If reading the entire file is requested
|
|
87
|
+
if (options.shouldReadEntireFile) {
|
|
88
|
+
// Check if the file has been edited or manually attached
|
|
89
|
+
const fileName = path.basename(fullPath);
|
|
90
|
+
// Check if the file is too large (more than 1000 lines)
|
|
91
|
+
if (totalLines > 1000) {
|
|
92
|
+
throw new Error(`File is too large to read entirely (${totalLines} lines). Please specify a line range.`);
|
|
93
|
+
}
|
|
94
|
+
return fileContent;
|
|
95
|
+
}
|
|
96
|
+
// If the file has fewer than 200 lines, read the entire file
|
|
97
|
+
if (totalLines < 200) {
|
|
98
|
+
return fileContent;
|
|
99
|
+
}
|
|
100
|
+
// Ensure the line indices are valid and adjust to read at least 200 lines when possible
|
|
101
|
+
let startLine = Math.max(1, options.startLineOneIndexed);
|
|
102
|
+
let endLine = Math.min(totalLines, options.endLineOneIndexedInclusive);
|
|
103
|
+
// Adjust the range to ensure we read at least 200 lines when possible
|
|
104
|
+
const adjustedRange = this.adjustLineRange(startLine, endLine, totalLines);
|
|
105
|
+
startLine = adjustedRange.start;
|
|
106
|
+
endLine = adjustedRange.end;
|
|
107
|
+
// Convert to 0-indexed for array access
|
|
108
|
+
const startIndex = startLine - 1;
|
|
109
|
+
const endIndex = endLine - 1;
|
|
110
|
+
// Extract the requested lines and return them without any summary
|
|
111
|
+
const requestedLines = lines.slice(startIndex, endIndex + 1);
|
|
112
|
+
return requestedLines.join('\n');
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error instanceof Error) {
|
|
116
|
+
return `Failed to read file: ${error.message}`;
|
|
117
|
+
}
|
|
118
|
+
return 'Failed to read file due to an unknown error';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validates the read options to ensure they have all required fields and are within valid ranges
|
|
123
|
+
* @param options The read options to validate
|
|
124
|
+
* @param fullPath The full path to the file
|
|
125
|
+
*/
|
|
126
|
+
async validateReadOptions(options, fullPath) {
|
|
127
|
+
if (!options.targetFile) {
|
|
128
|
+
throw new Error('Target file path is required');
|
|
129
|
+
}
|
|
130
|
+
if (typeof options.shouldReadEntireFile !== 'boolean') {
|
|
131
|
+
throw new Error('should_read_entire_file must be a boolean');
|
|
132
|
+
}
|
|
133
|
+
if (!options.shouldReadEntireFile) {
|
|
134
|
+
// Check if file exists before validating line numbers
|
|
135
|
+
if (!fs.existsSync(fullPath)) {
|
|
136
|
+
throw new Error(`File not found: ${fullPath}`);
|
|
137
|
+
}
|
|
138
|
+
// Get total line count
|
|
139
|
+
const fileContent = await fs.promises.readFile(fullPath, 'utf8');
|
|
140
|
+
const totalLines = fileContent.split('\n').length;
|
|
141
|
+
if (typeof options.startLineOneIndexed !== 'number' || options.startLineOneIndexed < 1) {
|
|
142
|
+
throw new Error('Start line must be a positive number');
|
|
143
|
+
}
|
|
144
|
+
if (typeof options.endLineOneIndexedInclusive !== 'number' || options.endLineOneIndexedInclusive < 1) {
|
|
145
|
+
throw new Error('End line must be a positive number');
|
|
146
|
+
}
|
|
147
|
+
if (options.endLineOneIndexedInclusive < options.startLineOneIndexed) {
|
|
148
|
+
throw new Error('End line cannot be before start line');
|
|
149
|
+
}
|
|
150
|
+
// Check if the requested range is within the allowed limits (max 250 lines, min 200 lines)
|
|
151
|
+
const requestedLineCount = options.endLineOneIndexedInclusive - options.startLineOneIndexed + 1;
|
|
152
|
+
if (requestedLineCount > 250) {
|
|
153
|
+
throw new Error('Cannot read more than 250 lines at a time');
|
|
154
|
+
}
|
|
155
|
+
// Ensure minimum 200 lines are read when possible
|
|
156
|
+
if (requestedLineCount < 200 && totalLines >= 200) {
|
|
157
|
+
throw new Error('Must read at least 200 lines at a time unless the file is smaller');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Gets the total number of lines in a file
|
|
163
|
+
* @param filePath Path to the file
|
|
164
|
+
* @returns The total number of lines in the file
|
|
165
|
+
*/
|
|
166
|
+
async getLineCount(filePath) {
|
|
167
|
+
try {
|
|
168
|
+
// Normalize path for the current OS (handles Linux /mnt/<drive> paths on Windows)
|
|
169
|
+
const fullPath = normalizePath(filePath);
|
|
170
|
+
const fileContent = await fs.promises.readFile(fullPath, 'utf8');
|
|
171
|
+
return fileContent.split('\n').length;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
throw new Error(`Failed to get line count: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Adjusts the line range to ensure we read at least 200 lines when possible
|
|
179
|
+
* @param startLine The starting line number
|
|
180
|
+
* @param endLine The ending line number
|
|
181
|
+
* @param totalLines The total number of lines in the file
|
|
182
|
+
* @returns An object with adjusted start and end line numbers
|
|
183
|
+
*/
|
|
184
|
+
adjustLineRange(startLine, endLine, totalLines) {
|
|
185
|
+
const requestedLineCount = endLine - startLine + 1;
|
|
186
|
+
// If the file has fewer than 200 lines or the requested range is already at least 200 lines, return as is
|
|
187
|
+
if (totalLines < 200 || requestedLineCount >= 200) {
|
|
188
|
+
return { start: startLine, end: endLine };
|
|
189
|
+
}
|
|
190
|
+
// We need to expand the range to include at least 200 lines
|
|
191
|
+
const linesToAdd = 200 - requestedLineCount;
|
|
192
|
+
// Try to add lines evenly before and after the requested range
|
|
193
|
+
const addBefore = Math.floor(linesToAdd / 2);
|
|
194
|
+
const addAfter = linesToAdd - addBefore;
|
|
195
|
+
// Calculate new start and end lines
|
|
196
|
+
let newStart = Math.max(1, startLine - addBefore);
|
|
197
|
+
let newEnd = Math.min(totalLines, endLine + addAfter);
|
|
198
|
+
// If we couldn't add enough lines at one end, add more at the other end
|
|
199
|
+
if (newStart > 1 && (newEnd - newStart + 1) < 200) {
|
|
200
|
+
newStart = Math.max(1, newStart - (200 - (newEnd - newStart + 1)));
|
|
201
|
+
}
|
|
202
|
+
else if (newEnd < totalLines && (newEnd - newStart + 1) < 200) {
|
|
203
|
+
newEnd = Math.min(totalLines, newEnd + (200 - (newEnd - newStart + 1)));
|
|
204
|
+
}
|
|
205
|
+
return { start: newStart, end: newEnd };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.ReadFileTool = ReadFileTool;
|
|
209
|
+
// Example usage:
|
|
210
|
+
/*
|
|
211
|
+
async function example() {
|
|
212
|
+
try {
|
|
213
|
+
const readFileTool = new ReadFileTool('/path/to/base/folder');
|
|
214
|
+
|
|
215
|
+
// Read a specific range of lines
|
|
216
|
+
const result = await readFileTool.readFile({
|
|
217
|
+
targetFile: 'path/to/file.ts',
|
|
218
|
+
shouldReadEntireFile: false,
|
|
219
|
+
startLineOneIndexed: 10,
|
|
220
|
+
endLineOneIndexedInclusive: 50,
|
|
221
|
+
explanation: 'Reading function implementation'
|
|
222
|
+
});
|
|
223
|
+
console.log(result);
|
|
224
|
+
|
|
225
|
+
// Read the entire file
|
|
226
|
+
const entireFile = await readFileTool.readFile({
|
|
227
|
+
targetFile: 'path/to/file.ts',
|
|
228
|
+
shouldReadEntireFile: true,
|
|
229
|
+
startLineOneIndexed: 1,
|
|
230
|
+
endLineOneIndexedInclusive: 1,
|
|
231
|
+
explanation: 'Reading the entire file'
|
|
232
|
+
});
|
|
233
|
+
console.log(entireFile);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.error('Error:', error);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
*/
|
|
239
|
+
//# sourceMappingURL=ReadFileTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadFileTool.js","sourceRoot":"","sources":["../../src/Services/ReadFileTool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAAyB;AACzB,2CAA6B;AAE7B;;;;GAIG;AACH,MAAM,aAAa,GAAG,CA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["../../../src/__tests__/__mocks__/tool-server.mock.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,UAAU,QAAgB,CAAC;AACxC,eAAO,MAAM,aAAa,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.githubOrgName = exports.folderPath = exports.githubPATToken = void 0;
|
|
4
|
+
// Mock for tool-server module to avoid socket/env dependencies in tests
|
|
5
|
+
exports.githubPATToken = 'mock-pat-token';
|
|
6
|
+
exports.folderPath = process.cwd();
|
|
7
|
+
exports.githubOrgName = 'mock-org';
|
|
8
|
+
//# sourceMappingURL=tool-server.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-server.mock.js","sourceRoot":"","sources":["../../../src/__tests__/__mocks__/tool-server.mock.ts"],"names":[],"mappings":";;;AAAA,wEAAwE;AAC3D,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC3B,QAAA,aAAa,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test suite for executeSelfHostedTool in toolExecutionService.ts
|
|
3
|
+
*
|
|
4
|
+
* Strategy:
|
|
5
|
+
* - All tests inject a fully-mocked SelfHostedContext via the second argument
|
|
6
|
+
* of executeSelfHostedTool so no real file-system, bash, docker or GitHub
|
|
7
|
+
* calls are made.
|
|
8
|
+
* - GithubOperationsService is jest-mocked at the module level.
|
|
9
|
+
* - A few integration-style tests for executeCommand / executeHostCommand use
|
|
10
|
+
* real bash (available on Windows via WSL2).
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=toolExecutionService_tempAI.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolExecutionService_tempAI.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/toolExecutionService_tempAI.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|