@progress/kendo-react-mcp 1.0.3 → 1.0.4
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 +4 -3
- package/dist/lib/logger.js +24 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48,11 +48,12 @@ specify its name in the 'component' parameter. This tool can be automatically tr
|
|
|
48
48
|
code_matches_count: 0,
|
|
49
49
|
allowed_types: ['documentation'],
|
|
50
50
|
});
|
|
51
|
+
log('Response from context API: ', JSON.stringify(response));
|
|
51
52
|
const content = [
|
|
52
|
-
|
|
53
|
+
{
|
|
53
54
|
type: 'text',
|
|
54
|
-
text:
|
|
55
|
-
}
|
|
55
|
+
text: response.values.join('\n\n'),
|
|
56
|
+
},
|
|
56
57
|
];
|
|
57
58
|
log('Response from tool: ', JSON.stringify(content));
|
|
58
59
|
return {
|
package/dist/lib/logger.js
CHANGED
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
let LOG_ENABLED = false;
|
|
3
4
|
const LOG_FILE = process.env.DEBUG_LOG_FILE;
|
|
4
5
|
const LOG_FILE_DEFINED = !!(LOG_FILE && typeof LOG_FILE === 'string');
|
|
5
6
|
// check if the log file is a valid path
|
|
6
7
|
if (LOG_FILE_DEFINED) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const resolvedLogFile = path.resolve(LOG_FILE);
|
|
9
|
+
const logDir = path.dirname(resolvedLogFile);
|
|
10
|
+
// Only create directory if it's not the current directory and doesn't exist
|
|
11
|
+
if (logDir !== '.' && logDir !== process.cwd() && !fs.existsSync(logDir)) {
|
|
12
|
+
try {
|
|
13
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
console.error('Error creating log directory:', err);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Create the log file if it doesn't exist
|
|
20
|
+
if (!fs.existsSync(resolvedLogFile)) {
|
|
21
|
+
try {
|
|
22
|
+
fs.writeFileSync(resolvedLogFile, '');
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
console.error('Error creating log file:', err);
|
|
26
|
+
}
|
|
11
27
|
}
|
|
12
28
|
}
|
|
13
|
-
LOG_ENABLED = LOG_FILE_DEFINED && fs.existsSync(LOG_FILE);
|
|
29
|
+
LOG_ENABLED = LOG_FILE_DEFINED && !!LOG_FILE && fs.existsSync(path.resolve(LOG_FILE));
|
|
14
30
|
export function log(...args) {
|
|
15
|
-
if (LOG_ENABLED) {
|
|
31
|
+
if (LOG_ENABLED && LOG_FILE) {
|
|
16
32
|
// write a new line to the file with the date and time
|
|
17
33
|
const date = new Date();
|
|
18
34
|
const dateString = date.toISOString();
|
|
19
35
|
const logString = `${dateString}: ${args.join(' ')}\n`;
|
|
20
|
-
|
|
36
|
+
const resolvedLogFile = path.resolve(LOG_FILE);
|
|
37
|
+
fs.appendFile(resolvedLogFile, logString, (err) => {
|
|
21
38
|
if (err) {
|
|
22
39
|
console.error('Error writing to log file:', err);
|
|
23
40
|
}
|