smart-context-mcp 0.8.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/LICENSE +21 -0
- package/README.md +414 -0
- package/package.json +63 -0
- package/scripts/devctx-server.js +4 -0
- package/scripts/init-clients.js +356 -0
- package/scripts/report-metrics.js +195 -0
- package/src/index.js +976 -0
- package/src/mcp-server.js +3 -0
- package/src/metrics.js +65 -0
- package/src/server.js +143 -0
- package/src/tokenCounter.js +12 -0
- package/src/tools/smart-context.js +1192 -0
- package/src/tools/smart-read/additional-languages.js +684 -0
- package/src/tools/smart-read/code.js +216 -0
- package/src/tools/smart-read/fallback.js +23 -0
- package/src/tools/smart-read/python.js +178 -0
- package/src/tools/smart-read/shared.js +39 -0
- package/src/tools/smart-read/structured.js +72 -0
- package/src/tools/smart-read-batch.js +63 -0
- package/src/tools/smart-read.js +459 -0
- package/src/tools/smart-search.js +412 -0
- package/src/tools/smart-shell.js +213 -0
- package/src/utils/fs.js +47 -0
- package/src/utils/paths.js +1 -0
- package/src/utils/runtime-config.js +29 -0
- package/src/utils/text.js +38 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const truncate = (text = '', maxChars = 4000) => {
|
|
2
|
+
if (text.length <= maxChars) {
|
|
3
|
+
return text;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return `${text.slice(0, maxChars)}\n\n[truncated ${text.length - maxChars} chars]`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const uniqueLines = (text = '') => {
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
|
|
12
|
+
return text
|
|
13
|
+
.split('\n')
|
|
14
|
+
.filter((line) => {
|
|
15
|
+
const key = line.trim();
|
|
16
|
+
|
|
17
|
+
if (!key) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (seen.has(key)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
seen.add(key);
|
|
26
|
+
return true;
|
|
27
|
+
})
|
|
28
|
+
.join('\n');
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const pickRelevantLines = (text = '', patterns = []) => {
|
|
32
|
+
const lines = text.split('\n');
|
|
33
|
+
const loweredPatterns = patterns.map((pattern) => pattern.toLowerCase());
|
|
34
|
+
|
|
35
|
+
return lines
|
|
36
|
+
.filter((line) => loweredPatterns.some((pattern) => line.toLowerCase().includes(pattern)))
|
|
37
|
+
.join('\n');
|
|
38
|
+
};
|