@saber2pr/ai-agent 0.0.59 → 0.0.61
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.
|
@@ -312,7 +312,9 @@ async function searchFilesWithValidation(cwd, rootPath, pattern, allowedDirector
|
|
|
312
312
|
if (shouldExclude)
|
|
313
313
|
continue;
|
|
314
314
|
// Use glob matching for the search pattern
|
|
315
|
-
if ((0, minimatch_1.minimatch)(relativePath, pattern, { dot: true })
|
|
315
|
+
if ((0, minimatch_1.minimatch)(relativePath, pattern, { dot: true }) ||
|
|
316
|
+
path_1.default.basename(fullPath) === pattern // 新增:如果文件名完全一致也算匹配
|
|
317
|
+
) {
|
|
316
318
|
results.push(fullPath);
|
|
317
319
|
}
|
|
318
320
|
if (entry.isDirectory()) {
|
|
@@ -3,13 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getIncrementalRepoMapPrompt = void 0;
|
|
4
4
|
const ts_context_mcp_1 = require("@saber2pr/ts-context-mcp");
|
|
5
5
|
let lastRepoMapContent = '';
|
|
6
|
+
const MAX_LINES = 50; // 设定阈值
|
|
6
7
|
const getIncrementalRepoMapPrompt = (targetDir, isFirstTurn) => {
|
|
7
8
|
try {
|
|
8
9
|
const engine = new ts_context_mcp_1.PromptEngine(targetDir);
|
|
9
10
|
const currentContent = engine.getRepoMap();
|
|
11
|
+
const lines = currentContent.split('\n');
|
|
10
12
|
// 1. 第一轮对话:必须全量发送
|
|
11
13
|
if (isFirstTurn || !lastRepoMapContent) {
|
|
12
14
|
lastRepoMapContent = currentContent;
|
|
15
|
+
// 如果超过 50 行,进行截断
|
|
16
|
+
if (lines.length > MAX_LINES) {
|
|
17
|
+
const truncatedContent = lines.slice(0, MAX_LINES).join('\n');
|
|
18
|
+
return `
|
|
19
|
+
# Initial Project Repository Map (Truncated)
|
|
20
|
+
\`\`\`text
|
|
21
|
+
${truncatedContent}
|
|
22
|
+
...
|
|
23
|
+
[${lines.length - MAX_LINES} more lines truncated for brevity]
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
**Note**: The map above only shows the core structure.
|
|
27
|
+
- If the file you need is not listed, use the tool \`list_directory\` to explore.
|
|
28
|
+
`.trim();
|
|
29
|
+
}
|
|
13
30
|
return `\n# Initial Project Repository Map\n\`\`\`text\n${currentContent}\n\`\`\``;
|
|
14
31
|
}
|
|
15
32
|
// 2. 如果完全没变:发送静默占位符
|