mcp-probe-kit 3.0.18 → 3.0.21
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/README.md +87 -55
- package/build/index.js +3 -1
- package/build/lib/__tests__/agents-md-template.unit.test.d.ts +1 -0
- package/build/lib/__tests__/agents-md-template.unit.test.js +27 -0
- package/build/lib/__tests__/memory-config.unit.test.js +9 -0
- package/build/lib/__tests__/memory-injection.unit.test.d.ts +1 -0
- package/build/lib/__tests__/memory-injection.unit.test.js +51 -0
- package/build/lib/__tests__/memory-orchestration.unit.test.d.ts +1 -0
- package/build/lib/__tests__/memory-orchestration.unit.test.js +84 -0
- package/build/lib/__tests__/memory-payload.unit.test.d.ts +1 -0
- package/build/lib/__tests__/memory-payload.unit.test.js +35 -0
- package/build/lib/__tests__/project-context-layout.unit.test.d.ts +1 -0
- package/build/lib/__tests__/project-context-layout.unit.test.js +80 -0
- package/build/lib/agents-md-template.d.ts +25 -0
- package/build/lib/agents-md-template.js +57 -0
- package/build/lib/memory-client.d.ts +8 -1
- package/build/lib/memory-client.js +53 -44
- package/build/lib/memory-config.d.ts +8 -0
- package/build/lib/memory-config.js +19 -0
- package/build/lib/memory-orchestration.d.ts +10 -3
- package/build/lib/memory-orchestration.js +146 -7
- package/build/lib/memory-payload.d.ts +21 -0
- package/build/lib/memory-payload.js +65 -0
- package/build/lib/merge-agents-md.d.ts +6 -0
- package/build/lib/merge-agents-md.js +51 -0
- package/build/lib/project-context-layout.d.ts +78 -0
- package/build/lib/project-context-layout.js +350 -0
- package/build/lib/workspace-root.js +6 -1
- package/build/resources/ui-ux-data/metadata.json +1 -1
- package/build/schemas/index.d.ts +62 -11
- package/build/schemas/memory-tools.d.ts +38 -9
- package/build/schemas/memory-tools.js +24 -9
- package/build/schemas/project-tools.d.ts +24 -2
- package/build/schemas/project-tools.js +24 -2
- package/build/tools/__tests__/code_insight.unit.test.js +3 -3
- package/build/tools/__tests__/init_project_context.unit.test.js +32 -21
- package/build/tools/__tests__/start_feature.unit.test.js +2 -1
- package/build/tools/code_insight.js +11 -9
- package/build/tools/index.d.ts +1 -0
- package/build/tools/index.js +1 -0
- package/build/tools/init_project_context.js +563 -506
- package/build/tools/memorize_asset.js +12 -0
- package/build/tools/scan_and_extract_patterns.js +7 -7
- package/build/tools/search_memory.d.ts +7 -0
- package/build/tools/search_memory.js +57 -0
- package/build/tools/start_bugfix.js +257 -251
- package/build/tools/start_feature.js +140 -134
- package/build/tools/start_ui.js +405 -405
- package/docs/.mcp-probe/layout.json +11 -0
- package/docs/data/tools.js +18 -0
- package/docs/i18n/all-tools/en.json +6 -1
- package/docs/i18n/all-tools/ja.json +2 -1
- package/docs/i18n/all-tools/ko.json +2 -1
- package/docs/i18n/all-tools/zh-CN.json +7 -2
- package/docs/i18n/en.json +38 -7
- package/docs/i18n/ja.json +9 -2
- package/docs/i18n/ko.json +9 -2
- package/docs/i18n/zh-CN.json +40 -9
- package/docs/memory-local-setup.md +314 -0
- package/docs/memory-local-setup.zh-CN.md +283 -0
- package/docs/pages/getting-started.html +252 -33
- package/package.json +2 -2
|
@@ -42,6 +42,17 @@ export async function memorizeAsset(args) {
|
|
|
42
42
|
if (!client.isEnabled()) {
|
|
43
43
|
return okStructured('记忆服务未开启,已跳过沉淀。', { enabled: false, stored: false });
|
|
44
44
|
}
|
|
45
|
+
const warnings = [];
|
|
46
|
+
if (type === 'bugfix') {
|
|
47
|
+
const requiredSections = ['【现象】', '【根因】', '【修复】'];
|
|
48
|
+
const missing = requiredSections.filter((section) => !content.includes(section));
|
|
49
|
+
if (missing.length > 0) {
|
|
50
|
+
warnings.push(`建议 content 包含 ${missing.join('、')},便于跨仓库检索与复用`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (sourceProject || sourcePath) {
|
|
54
|
+
warnings.push('跨仓库共享记忆时请勿依赖 source_project/source_path;路径请写入 content 正文(可选)');
|
|
55
|
+
}
|
|
45
56
|
const asset = await client.upsertAsset({
|
|
46
57
|
name,
|
|
47
58
|
type,
|
|
@@ -58,6 +69,7 @@ export async function memorizeAsset(args) {
|
|
|
58
69
|
enabled: true,
|
|
59
70
|
stored: true,
|
|
60
71
|
asset,
|
|
72
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
61
73
|
});
|
|
62
74
|
}
|
|
63
75
|
catch (error) {
|
|
@@ -108,21 +108,22 @@ function summarizeContent(content, maxChars = 200) {
|
|
|
108
108
|
.trim()
|
|
109
109
|
.slice(0, maxChars);
|
|
110
110
|
}
|
|
111
|
-
function buildPattern(content, filePath
|
|
111
|
+
function buildPattern(content, filePath) {
|
|
112
112
|
const normalized = content.trim();
|
|
113
113
|
const candidateNames = collectCandidateNames(normalized);
|
|
114
114
|
const primaryName = candidateNames[0] || (filePath ? path.basename(filePath) : 'snippet');
|
|
115
115
|
const type = detectPatternType(normalized, filePath);
|
|
116
116
|
const summary = summarizeContent(normalized);
|
|
117
|
+
const fileHint = filePath ? `(摘录自 ${filePath})` : '';
|
|
117
118
|
return {
|
|
118
119
|
name: primaryName,
|
|
119
120
|
type,
|
|
120
|
-
description: filePath
|
|
121
|
+
description: filePath
|
|
122
|
+
? `从 ${filePath} 提取的可复用模式${fileHint}`
|
|
123
|
+
: '从代码片段提取的可复用模式',
|
|
121
124
|
summary,
|
|
122
125
|
content: normalized,
|
|
123
126
|
tags: inferTags(normalized, filePath),
|
|
124
|
-
sourcePath: filePath || undefined,
|
|
125
|
-
sourceProject: projectName || undefined,
|
|
126
127
|
confidence: filePath ? 0.62 : 0.55,
|
|
127
128
|
candidateNames,
|
|
128
129
|
};
|
|
@@ -271,7 +272,6 @@ export async function scanAndExtractPatterns(args) {
|
|
|
271
272
|
});
|
|
272
273
|
const content = getString(parsed.content);
|
|
273
274
|
const filePath = getString(parsed.file_path);
|
|
274
|
-
const projectName = getString(parsed.project_name);
|
|
275
275
|
const directoryPath = getString(parsed.directory_path);
|
|
276
276
|
const projectRoot = resolveWorkspaceRoot(getString(parsed.project_root));
|
|
277
277
|
const maxFiles = Math.max(1, Math.min(200, getNumber(parsed.max_files, 30)));
|
|
@@ -282,7 +282,7 @@ export async function scanAndExtractPatterns(args) {
|
|
|
282
282
|
.map((item) => item.startsWith('.') ? item.toLowerCase() : `.${item.toLowerCase()}`)
|
|
283
283
|
: DEFAULT_INCLUDE_EXTENSIONS);
|
|
284
284
|
if (content) {
|
|
285
|
-
const pattern = buildPattern(content, filePath
|
|
285
|
+
const pattern = buildPattern(content, filePath);
|
|
286
286
|
return okStructured(`已提取 1 个候选模式${filePath ? `: ${filePath}` : ''}`, {
|
|
287
287
|
mode: 'single',
|
|
288
288
|
patterns: [pattern],
|
|
@@ -331,7 +331,7 @@ export async function scanAndExtractPatterns(args) {
|
|
|
331
331
|
continue;
|
|
332
332
|
}
|
|
333
333
|
const relativePath = toRelativePath(absoluteFile, projectRoot).replace(/\\/g, '/');
|
|
334
|
-
patterns.push(buildPattern(normalized, relativePath
|
|
334
|
+
patterns.push(buildPattern(normalized, relativePath));
|
|
335
335
|
}
|
|
336
336
|
return okStructured(`已扫描 ${files.length} 个文件,提取 ${patterns.length} 个候选模式`, {
|
|
337
337
|
mode: 'directory',
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { parseArgs, getString, getNumber } from '../utils/parseArgs.js';
|
|
2
|
+
import { okStructured } from '../lib/response.js';
|
|
3
|
+
import { createMemoryClient } from '../lib/memory-client.js';
|
|
4
|
+
import { shouldShowSourceInSearch } from '../lib/memory-orchestration.js';
|
|
5
|
+
import { getMemoryConfig } from '../lib/memory-config.js';
|
|
6
|
+
import { handleToolError } from '../utils/error-handler.js';
|
|
7
|
+
export async function searchMemory(args) {
|
|
8
|
+
try {
|
|
9
|
+
const parsed = parseArgs(args, {
|
|
10
|
+
defaultValues: {
|
|
11
|
+
query: '',
|
|
12
|
+
type: '',
|
|
13
|
+
limit: 0,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
const query = getString(parsed.query);
|
|
17
|
+
if (!query) {
|
|
18
|
+
throw new Error('缺少必填参数: query');
|
|
19
|
+
}
|
|
20
|
+
const client = createMemoryClient();
|
|
21
|
+
if (!client.isEnabled()) {
|
|
22
|
+
return okStructured('记忆服务未开启,无法检索。', {
|
|
23
|
+
enabled: false,
|
|
24
|
+
results: [],
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const config = getMemoryConfig();
|
|
28
|
+
const limit = getNumber(parsed.limit, config.searchLimit);
|
|
29
|
+
const typeFilter = getString(parsed.type);
|
|
30
|
+
const tags = Array.isArray(parsed.tags)
|
|
31
|
+
? parsed.tags.filter((item) => typeof item === 'string')
|
|
32
|
+
: [];
|
|
33
|
+
const results = await client.search(query, {
|
|
34
|
+
limit,
|
|
35
|
+
preferTypes: typeFilter ? [typeFilter] : [],
|
|
36
|
+
preferTags: tags,
|
|
37
|
+
});
|
|
38
|
+
const items = results.map((item) => ({
|
|
39
|
+
id: item.id,
|
|
40
|
+
score: item.score,
|
|
41
|
+
name: item.name,
|
|
42
|
+
type: item.type,
|
|
43
|
+
summary: item.summary,
|
|
44
|
+
tags: item.tags,
|
|
45
|
+
sourcePath: shouldShowSourceInSearch(item, config) ? item.sourcePath : undefined,
|
|
46
|
+
}));
|
|
47
|
+
return okStructured(results.length > 0 ? `找到 ${results.length} 条相关记忆` : '未找到相关记忆', {
|
|
48
|
+
enabled: true,
|
|
49
|
+
query,
|
|
50
|
+
count: results.length,
|
|
51
|
+
results: items,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return handleToolError(error, 'search_memory');
|
|
56
|
+
}
|
|
57
|
+
}
|