mcp-probe-kit 3.6.3 → 3.6.5

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.
@@ -6,8 +6,9 @@ import { resolveWorkspaceRoot, isLikelyProjectNamedRelativePath, buildProjectRoo
6
6
  import { detectDocumentLocale, layoutAbsPath, legacyProjectContextExists, parseLayoutArgsFromRecord, resolveProjectContextLayout, toPosixPath, writeLayoutManifest, } from "../lib/project-context-layout.js";
7
7
  import { mergeAgentsMdBlock } from "../lib/merge-agents-md.js";
8
8
  import { generateAgentsMdInner } from "../lib/agents-md-template.js";
9
- import * as fs from 'fs';
10
- import * as path from 'path';
9
+ import { formatFileDeliverySection, writeProjectFile, } from "../lib/file-delivery.js";
10
+ import * as fs from "fs";
11
+ import * as path from "path";
11
12
  /**
12
13
  * init_project_context 工具
13
14
  *
@@ -180,12 +181,39 @@ async function generateProjectContext(layout, projectRoot) {
180
181
  });
181
182
  const mergedAgents = mergeAgentsMdBlock(existingAgentsRaw, agentsInner);
182
183
  const manifestWritten = writeLayoutManifest(projectRootAbs, layout);
184
+ const agentsMdWritten = writeProjectFile(projectRootAbs, layout.indexPath, mergedAgents.content, "always");
185
+ const writtenFiles = [
186
+ agentsMdWritten,
187
+ { path: manifestWritten, action: "updated" },
188
+ ];
189
+ const pendingFiles = [
190
+ ...(modularExists
191
+ ? []
192
+ : [
193
+ {
194
+ path: layout.legacyIndexPath,
195
+ reason: "由 Agent 按本工具返回的模板写入",
196
+ },
197
+ ...docs.map((doc) => ({
198
+ path: `${layout.modularDir}/${doc.file}`,
199
+ reason: "由 Agent 按模板写入",
200
+ })),
201
+ ]),
202
+ {
203
+ path: graphDocs.latestMarkdownFilePath,
204
+ reason: "由 Agent 按 code_insight 分析结果写入",
205
+ },
206
+ {
207
+ path: graphDocs.latestJsonFilePath,
208
+ reason: "由 Agent 按 code_insight 结构化结果写入",
209
+ },
210
+ ];
211
+ const deliverySection = formatFileDeliverySection({ writtenFiles, pendingFiles });
183
212
  const codeInsightArgs = JSON.stringify({
184
213
  mode: "auto",
185
214
  project_root: layout.projectRootPosix,
186
215
  docs_dir: docsDir,
187
216
  });
188
- const modularOutputs = docs.map((doc) => `${layout.modularDir}/${doc.file}`);
189
217
  const plan = {
190
218
  mode: "delegated",
191
219
  steps: modularExists
@@ -194,60 +222,49 @@ async function generateProjectContext(layout, projectRoot) {
194
222
  id: "bootstrap-code-insight",
195
223
  action: `检测到现有 ${layout.legacyIndexPath},跳过重写分类文档,调用 code_insight 补齐图谱`,
196
224
  outputs: [graphDocs.latestMarkdownFilePath, graphDocs.latestJsonFilePath],
197
- note: `调用参数: ${codeInsightArgs}`,
225
+ note: `调用参数: ${codeInsightArgs};${layout.indexPath} 与 layout 已由 MCP 写入`,
198
226
  },
199
227
  {
200
228
  id: "persist-graph-docs",
201
- action: `执行 code_insight 的 delegated plan,写入 ${layout.graphDir}/`,
229
+ action: `执行 code_insight 的 delegated plan,由 Agent 写入 ${layout.graphDir}/`,
202
230
  outputs: [graphDocs.latestMarkdownFilePath, graphDocs.latestJsonFilePath],
203
231
  note: "保留现有 project-context 分类文档",
204
232
  },
205
- {
206
- id: "finalize-agents-md",
207
- action: `将下方 agentsMdTemplate 写入 ${layout.indexPath}(mcp-probe 块置顶,保留用户原有内容)`,
208
- outputs: [layout.indexPath],
209
- note: `mergeMode: ${mergedAgents.mergeMode};layout manifest 已由服务端写入 ${manifestWritten}`,
210
- },
211
233
  ]
212
234
  : [
213
235
  {
214
236
  id: "write-modular-docs",
215
- action: `先创建 ${layout.legacyIndexPath}(文档索引),再创建 ${layout.modularDir}/ 分类文档`,
216
- outputs: [layout.legacyIndexPath, ...modularOutputs],
217
- note: modularExists
218
- ? "跳过:索引与分类文档已存在"
219
- : "project-context.md 是细节入口;AGENTS.md 仅含 MCP 规则",
237
+ action: `由 Agent 创建 ${layout.legacyIndexPath} ${layout.modularDir}/ 分类文档(见下方模板)`,
238
+ outputs: [
239
+ layout.legacyIndexPath,
240
+ ...docs.map((doc) => `${layout.modularDir}/${doc.file}`),
241
+ ],
220
242
  },
221
243
  {
222
244
  id: "bootstrap-code-insight",
223
245
  action: "调用 code_insight 做整体图谱分析",
224
246
  outputs: [graphDocs.latestMarkdownFilePath, graphDocs.latestJsonFilePath],
225
- note: `调用参数: ${codeInsightArgs}`,
247
+ note: `调用参数: ${codeInsightArgs};${layout.indexPath} 已由 MCP 写入`,
226
248
  },
227
249
  {
228
250
  id: "persist-graph-docs",
229
- action: `执行 code_insight 的 delegated plan,写入 ${layout.graphDir}/`,
251
+ action: `执行 code_insight 的 delegated plan,由 Agent 写入 ${layout.graphDir}/`,
230
252
  outputs: [graphDocs.latestMarkdownFilePath, graphDocs.latestJsonFilePath],
231
253
  },
232
- {
233
- id: "finalize-agents-md",
234
- action: `将下方 agentsMdTemplate 写入 ${layout.indexPath}(mcp-probe 块置顶)`,
235
- outputs: [layout.indexPath],
236
- note: `mergeMode: ${mergedAgents.mergeMode};manifest 已写入 ${manifestWritten}`,
237
- },
238
254
  ],
239
255
  };
240
256
  const guide = generateGuideText(detection, projectInfo, docs, layout, resolvedRoot, {
241
257
  modularExists,
258
+ agentsMdWritten: true,
242
259
  });
243
260
  const header = renderOrchestrationHeader({
244
261
  tool: "init_project_context",
245
262
  goal: modularExists
246
- ? "补齐图谱与 AGENTS.md 入口(保留现有分类文档)"
247
- : "生成项目上下文、图谱入口与 AGENTS.md 操作规则",
263
+ ? "补齐图谱(保留现有分类文档;AGENTS.md 已由 MCP 写入)"
264
+ : "写入 AGENTS.md 与 layout,由 Agent 生成 project-context 与图谱",
248
265
  tasks: modularExists
249
- ? ["保留现有分类文档", "code_insight 生成图谱", `写入 ${layout.indexPath}`]
250
- : ["写分类文档", "code_insight", `写入 ${layout.indexPath}`],
266
+ ? ["保留现有分类文档", "code_insight + Agent 落盘图谱"]
267
+ : ["MCP 已写 AGENTS.md 与 layout", "Agent 写分类文档", "code_insight + Agent 落盘图谱"],
251
268
  notes: [
252
269
  `项目根目录: ${toPosixPath(resolvedRoot)}`,
253
270
  `上下文目录: ${docsDir}`,
@@ -289,16 +306,17 @@ async function generateProjectContext(layout, projectRoot) {
289
306
  nextSteps: [
290
307
  ...(modularExists
291
308
  ? [`保留 ${layout.legacyIndexPath} 与分类文档`]
292
- : [`生成 ${layout.modularDir}/ 分类文档`]),
293
- "调用 code_insight",
294
- `将 agentsMdTemplate 写入 ${layout.indexPath}`,
309
+ : [`由 Agent 按模板创建 ${layout.modularDir}/ 分类文档`]),
310
+ "调用 code_insight,由 Agent 落盘图谱",
311
+ `${layout.indexPath} ${manifestWritten} 已由 MCP 写入(mergeMode: ${mergedAgents.mergeMode})`,
295
312
  ],
313
+ writtenFiles,
314
+ pendingFiles,
296
315
  metadata: {
297
316
  plan,
298
317
  graphDocs,
299
318
  layout,
300
319
  locale,
301
- agentsMdTemplate: mergedAgents.content,
302
320
  agentsMdMergeMode: mergedAgents.mergeMode,
303
321
  manifestWritten,
304
322
  projectContextFilePath: agentsPath,
@@ -306,15 +324,12 @@ async function generateProjectContext(layout, projectRoot) {
306
324
  projectContextExists: modularExists,
307
325
  },
308
326
  };
309
- return okStructured(`${header}${guide}
310
-
311
- ## AGENTS.md 终稿(finalize-agents-md 使用 fsWrite 写入 \`${layout.indexPath}\`)
327
+ return okStructured(`${header}
328
+ ${deliverySection}
312
329
 
313
- \`\`\`markdown
314
- ${mergedAgents.content}
315
- \`\`\`
330
+ ${guide}
316
331
 
317
- ## delegated plan
332
+ ## 后续 delegated plan(分类文档与图谱由 Agent 落盘)
318
333
  ${renderPlanSteps(plan.steps)}
319
334
  `, structuredData, {
320
335
  schema: (await import("../schemas/output/project-tools.js")).ProjectContextSchema,
@@ -332,7 +347,14 @@ function generateGuideText(detection, projectInfo, docs, layout, projectRoot, op
332
347
  const timestamp = new Date().toISOString();
333
348
  const docsDir = layout.contextRoot;
334
349
  const projectContextExists = options?.modularExists === true;
350
+ const agentsMdWritten = options?.agentsMdWritten === true;
335
351
  return `# 项目上下文文档生成指导
352
+ ${agentsMdWritten ? `
353
+ ## ⚠️ 文件落盘说明
354
+
355
+ **MCP 已写入** \`${layout.indexPath}\` 与 \`${layout.manifestPath}\`。
356
+ **分类文档与图谱**须由 Agent 按下方模板与 \`code_insight\` 结果自行落盘(见 pendingFiles)。
357
+ ` : ""}
336
358
 
337
359
  ## 📊 项目信息
338
360
 
@@ -345,8 +367,8 @@ function generateGuideText(detection, projectInfo, docs, layout, projectRoot, op
345
367
 
346
368
  ## 🔎 当前状态
347
369
 
348
- - **${layout.indexPath}**: Agent 入口(finalize-agents-md 写入,mcp-probe 块置顶)
349
- - **${layout.legacyIndexPath}**: ${projectContextExists ? '已存在(将保留分类文档)' : '将随分类文档一并生成'}
370
+ - **${layout.indexPath}**: Agent 入口(${agentsMdWritten ? "已由 MCP 写入" : "待 MCP 写入"},mcp-probe 块置顶)
371
+ - **${layout.legacyIndexPath}**: ${projectContextExists ? "已存在(将保留分类文档)" : "由 Agent 按模板创建"}
350
372
  - **图谱文档**: 需要确保 ${layout.latestMarkdownPath} 与 ${layout.latestJsonPath} 可用
351
373
 
352
374
  ## 📋 需要生成的文档
@@ -431,7 +453,7 @@ ${generateDevGuide(docs)}
431
453
  *生成工具: MCP Probe Kit - init_project_context v2.1*
432
454
  \`\`\`
433
455
 
434
- ${projectContextExists ? '**如果该文件已存在,跳过此步骤,不要覆盖**' : '**使用 fsWrite 创建此文件**'}
456
+ ${projectContextExists ? '**如果该文件已存在,跳过此步骤,不要覆盖**' : '**由 Agent 使用 fsWrite 创建此文件**'}
435
457
 
436
458
  ---
437
459
 
@@ -445,7 +467,7 @@ ${docs.map((doc, index) => generateDocTemplate(doc, index + 2, projectInfo, dete
445
467
 
446
468
  请确认:
447
469
 
448
- - [ ] ${projectContextExists ? '保留现有 project-context 及分类文档,不做覆盖' : `已使用 fsWrite 创建 **${docs.length + 1}** 个文件`}
470
+ - [ ] ${projectContextExists ? '保留现有 project-context 及分类文档,不做覆盖' : `由 Agent 创建 **${docs.length + 1}** 个分类文档`}
449
471
  - [ ] 索引文件 \`project-context.md\` ${projectContextExists ? '已存在并保留' : '已创建(最重要!)'}
450
472
  - [ ] 索引文件已包含 \`graph-insights/latest.md\` 的入口
451
473
  - [ ] 所有文档都包含**真实的文件路径**(不是 [xxx] 占位符)
@@ -770,7 +792,7 @@ function generateDocTemplate(doc, step, projectInfo, detection, docsDir) {
770
792
 
771
793
  ${template}
772
794
 
773
- **使用 fsWrite 创建此文件**`;
795
+ **由 Agent 使用 fsWrite 创建此文件**`;
774
796
  }
775
797
  /**
776
798
  * init_project_context 工具实现
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-probe-kit",
3
- "version": "3.6.3",
3
+ "version": "3.6.5",
4
4
  "description": "AI-Powered Development Toolkit - MCP Server with 30 tools covering code quality, development efficiency, project management, and UI/UX design. Features: Structured Output, Workflow Orchestration, MCP Skill auto-sync, UI/UX Pro Max, and Requirements Interview.",
5
5
  "mcpName": "io.github.mybolide/mcp-probe-kit",
6
6
  "type": "module",