mcp-probe-kit 3.3.0 → 3.6.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.
Files changed (81) hide show
  1. package/README.md +15 -7
  2. package/build/index.js +45 -79
  3. package/build/lib/__tests__/agents-md-template.unit.test.js +1 -0
  4. package/build/lib/__tests__/dev-workflow.unit.test.d.ts +1 -0
  5. package/build/lib/__tests__/dev-workflow.unit.test.js +22 -0
  6. package/build/lib/__tests__/handles.unit.test.d.ts +1 -0
  7. package/build/lib/__tests__/handles.unit.test.js +19 -0
  8. package/build/lib/__tests__/mcp-apps.unit.test.d.ts +1 -0
  9. package/build/lib/__tests__/mcp-apps.unit.test.js +52 -0
  10. package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.d.ts +1 -0
  11. package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.js +18 -0
  12. package/build/lib/__tests__/memory-client.unit.test.js +105 -0
  13. package/build/lib/__tests__/spec-gate.unit.test.d.ts +1 -0
  14. package/build/lib/__tests__/spec-gate.unit.test.js +54 -0
  15. package/build/lib/__tests__/task-defaults.unit.test.d.ts +1 -0
  16. package/build/lib/__tests__/task-defaults.unit.test.js +27 -0
  17. package/build/lib/__tests__/workflow-skill-installer.unit.test.d.ts +1 -0
  18. package/build/lib/__tests__/workflow-skill-installer.unit.test.js +110 -0
  19. package/build/lib/agents-md-template.js +10 -2
  20. package/build/lib/dev-workflow.d.ts +36 -0
  21. package/build/lib/dev-workflow.js +497 -0
  22. package/build/lib/handles.d.ts +31 -0
  23. package/build/lib/handles.js +36 -0
  24. package/build/lib/mcp-apps.d.ts +14 -0
  25. package/build/lib/mcp-apps.js +234 -0
  26. package/build/lib/mcp-tool-skill-registry.d.ts +46 -0
  27. package/build/lib/mcp-tool-skill-registry.js +256 -0
  28. package/build/lib/memory-client.d.ts +19 -0
  29. package/build/lib/memory-client.js +69 -0
  30. package/build/lib/memory-orchestration.d.ts +5 -0
  31. package/build/lib/memory-orchestration.js +20 -0
  32. package/build/lib/merge-agents-md.d.ts +2 -2
  33. package/build/lib/merge-agents-md.js +7 -4
  34. package/build/lib/output-schema-registry.d.ts +11 -0
  35. package/build/lib/output-schema-registry.js +80 -0
  36. package/build/lib/spec-gate.d.ts +32 -0
  37. package/build/lib/spec-gate.js +83 -0
  38. package/build/lib/task-defaults.d.ts +6 -0
  39. package/build/lib/task-defaults.js +20 -0
  40. package/build/lib/tool-annotations.js +3 -0
  41. package/build/lib/toolset-manager.js +2 -0
  42. package/build/lib/workflow-skill-installer.d.ts +38 -0
  43. package/build/lib/workflow-skill-installer.js +158 -0
  44. package/build/lib/workflow-skill-template.d.ts +9 -0
  45. package/build/lib/workflow-skill-template.js +85 -0
  46. package/build/lib/workflow-skill-version.d.ts +15 -0
  47. package/build/lib/workflow-skill-version.js +68 -0
  48. package/build/schemas/index.d.ts +110 -0
  49. package/build/schemas/index.js +1 -0
  50. package/build/schemas/memory-tools.d.ts +83 -0
  51. package/build/schemas/memory-tools.js +43 -0
  52. package/build/schemas/orchestration-tools.d.ts +8 -0
  53. package/build/schemas/orchestration-tools.js +8 -0
  54. package/build/schemas/output/code-insight-tools.d.ts +65 -0
  55. package/build/schemas/output/code-insight-tools.js +42 -0
  56. package/build/schemas/output/memory-tools.d.ts +576 -0
  57. package/build/schemas/output/memory-tools.js +148 -0
  58. package/build/schemas/project-tools.d.ts +19 -0
  59. package/build/schemas/project-tools.js +20 -0
  60. package/build/tools/__tests__/delete_memory_asset.unit.test.d.ts +1 -0
  61. package/build/tools/__tests__/delete_memory_asset.unit.test.js +87 -0
  62. package/build/tools/__tests__/search_memory.unit.test.js +1 -0
  63. package/build/tools/__tests__/start_bugfix.unit.test.js +34 -1
  64. package/build/tools/__tests__/update_memory_asset.unit.test.d.ts +1 -0
  65. package/build/tools/__tests__/update_memory_asset.unit.test.js +82 -0
  66. package/build/tools/__tests__/workflow.unit.test.d.ts +1 -0
  67. package/build/tools/__tests__/workflow.unit.test.js +24 -0
  68. package/build/tools/code_insight.js +5 -1
  69. package/build/tools/delete_memory_asset.d.ts +7 -0
  70. package/build/tools/delete_memory_asset.js +57 -0
  71. package/build/tools/index.d.ts +3 -0
  72. package/build/tools/index.js +3 -0
  73. package/build/tools/search_memory.js +5 -2
  74. package/build/tools/start_bugfix.js +37 -4
  75. package/build/tools/start_feature.js +4 -3
  76. package/build/tools/start_ui.js +5 -4
  77. package/build/tools/update_memory_asset.d.ts +7 -0
  78. package/build/tools/update_memory_asset.js +98 -0
  79. package/build/tools/workflow.d.ts +13 -0
  80. package/build/tools/workflow.js +69 -0
  81. package/package.json +5 -3
@@ -0,0 +1,110 @@
1
+ import * as fs from "node:fs";
2
+ import * as os from "node:os";
3
+ import * as path from "node:path";
4
+ import { afterEach, describe, expect, test } from "vitest";
5
+ import { VERSION } from "../../version.js";
6
+ import { ensureAgentsMdSkillReference, ensureMcpProbeKitBootstrap, ensureMcpProbeSkill, resolveProjectRootFromToolArgs, } from "../workflow-skill-installer.js";
7
+ import { formatSkillVersionMarker, agentsContextNeedsUpgrade, compareSemver, skillContentNeedsUpgrade, } from "../workflow-skill-version.js";
8
+ import { LEGACY_WORKFLOW_SKILL_REL_PATH, MCP_PROBE_SKILL_REL_PATH, } from "../workflow-skill-template.js";
9
+ import { wrapMcpProbeBlock } from "../merge-agents-md.js";
10
+ const tempDirs = [];
11
+ afterEach(() => {
12
+ while (tempDirs.length > 0) {
13
+ const dir = tempDirs.pop();
14
+ if (dir) {
15
+ fs.rmSync(dir, { recursive: true, force: true });
16
+ }
17
+ }
18
+ });
19
+ describe("workflow-skill-version", () => {
20
+ test("compareSemver 比较主次补丁", () => {
21
+ expect(compareSemver("3.5.0", "3.5.1")).toBeLessThan(0);
22
+ expect(compareSemver("3.6.0", "3.5.9")).toBeGreaterThan(0);
23
+ expect(compareSemver("3.5.0", "3.5.0")).toBe(0);
24
+ });
25
+ test("无版本标记视为需要升级", () => {
26
+ expect(skillContentNeedsUpgrade("# custom", VERSION)).toBe(true);
27
+ expect(agentsContextNeedsUpgrade("<!-- mcp-probe:context begin -->", VERSION)).toBe(true);
28
+ });
29
+ });
30
+ describe("workflow-skill-installer", () => {
31
+ test("缺失时创建 mcp-probe-kit Skill", () => {
32
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
33
+ tempDirs.push(root);
34
+ const result = ensureMcpProbeSkill(root);
35
+ expect(result.created).toBe(true);
36
+ expect(result.updated).toBe(false);
37
+ expect(result.version).toBe(VERSION);
38
+ const text = fs.readFileSync(path.join(root, MCP_PROBE_SKILL_REL_PATH), "utf8");
39
+ expect(text).toContain(formatSkillVersionMarker(VERSION));
40
+ expect(text).toContain("MCP 调用时机");
41
+ });
42
+ test("同版本 Skill 不覆盖", () => {
43
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
44
+ tempDirs.push(root);
45
+ const skillPath = path.join(root, MCP_PROBE_SKILL_REL_PATH);
46
+ const content = `${formatSkillVersionMarker(VERSION)}\n# same version\n`;
47
+ fs.mkdirSync(path.dirname(skillPath), { recursive: true });
48
+ fs.writeFileSync(skillPath, content, "utf8");
49
+ const result = ensureMcpProbeSkill(root);
50
+ expect(result.created).toBe(false);
51
+ expect(result.updated).toBe(false);
52
+ expect(fs.readFileSync(skillPath, "utf8")).toBe(content);
53
+ });
54
+ test("旧版本 Skill 会升级覆盖", () => {
55
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
56
+ tempDirs.push(root);
57
+ const skillPath = path.join(root, MCP_PROBE_SKILL_REL_PATH);
58
+ fs.mkdirSync(path.dirname(skillPath), { recursive: true });
59
+ fs.writeFileSync(skillPath, `${formatSkillVersionMarker("0.1.0")}\n# stale tools list\n`, "utf8");
60
+ const result = ensureMcpProbeSkill(root);
61
+ expect(result.updated).toBe(true);
62
+ expect(result.previousVersion).toBe("0.1.0");
63
+ const text = fs.readFileSync(skillPath, "utf8");
64
+ expect(text).toContain(formatSkillVersionMarker(VERSION));
65
+ expect(text).toContain("何时调用");
66
+ expect(text).not.toContain("stale tools list");
67
+ });
68
+ test("无 AGENTS.md 时创建并引用 Skill", () => {
69
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
70
+ tempDirs.push(root);
71
+ const result = ensureAgentsMdSkillReference(root);
72
+ expect(result.created).toBe(true);
73
+ const agents = fs.readFileSync(path.join(root, "AGENTS.md"), "utf8");
74
+ expect(agents).toContain("mcp-probe:context-version");
75
+ expect(agents).toContain(MCP_PROBE_SKILL_REL_PATH);
76
+ });
77
+ test("已有 AGENTS.md 但缺 Skill 引用时更新", () => {
78
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
79
+ tempDirs.push(root);
80
+ fs.writeFileSync(path.join(root, "AGENTS.md"), "# Custom rules\n", "utf8");
81
+ const result = ensureAgentsMdSkillReference(root);
82
+ expect(result.updated).toBe(true);
83
+ const agents = fs.readFileSync(path.join(root, "AGENTS.md"), "utf8");
84
+ expect(agents).toContain("# Custom rules");
85
+ expect(agents).toContain(MCP_PROBE_SKILL_REL_PATH);
86
+ });
87
+ test("旧 workflow Skill 路径会触发 AGENTS.md 更新", () => {
88
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
89
+ tempDirs.push(root);
90
+ const legacyBlock = wrapMcpProbeBlock(`## MCP\nSee [skill](${LEGACY_WORKFLOW_SKILL_REL_PATH})`, "0.1.0");
91
+ fs.writeFileSync(path.join(root, "AGENTS.md"), `${legacyBlock}\n`, "utf8");
92
+ const result = ensureAgentsMdSkillReference(root);
93
+ expect(result.updated).toBe(true);
94
+ const agents = fs.readFileSync(path.join(root, "AGENTS.md"), "utf8");
95
+ expect(agents).toContain(MCP_PROBE_SKILL_REL_PATH);
96
+ expect(agents).toContain(`mcp-probe:context-version: ${VERSION}`);
97
+ });
98
+ test("bootstrap 同时处理 Skill 与 AGENTS.md", () => {
99
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
100
+ tempDirs.push(root);
101
+ const result = ensureMcpProbeKitBootstrap(root);
102
+ expect(result.skill.created).toBe(true);
103
+ expect(result.agentsMd.created).toBe(true);
104
+ });
105
+ test("从 tool args 解析 project_root", () => {
106
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "wf-skill-"));
107
+ tempDirs.push(root);
108
+ expect(resolveProjectRootFromToolArgs({ project_root: root })).toBe(path.resolve(root));
109
+ });
110
+ });
@@ -1,4 +1,5 @@
1
1
  import { relativeLink } from "./project-context-layout.js";
2
+ import { MCP_PROBE_SKILL_REL_PATH } from "./workflow-skill-template.js";
2
3
  function link(layout, targetRel) {
3
4
  return relativeLink(layout.indexPath, targetRel);
4
5
  }
@@ -8,6 +9,8 @@ function memorySection(locale) {
8
9
  记忆(需 MEMORY_QDRANT_URL 等已配置):
9
10
  - 检索:\`start_*\` 命中后**自动注入**历史经验全文;中途补查可用 \`search_memory\`;单条精读仍可用 \`read_memory_asset\`
10
11
  - 沉淀:跨仓库共享**勿填** source_project/source_path;路径写进 content;summary 写检索关键词
12
+ - 修正:已有资产可用 \`update_memory_asset\` 按 asset_id 原地更新(保留 ID)
13
+ - 清理:过时/错误/重复沉淀可用 \`delete_memory_asset\`(删除前建议 \`read_memory_asset\` 确认)
11
14
  - Bug 修完验证通过 → **必须** \`memorize_asset\` type=\`bugfix\` tags=\`bugfix,root-cause\`(content 含【现象】【根因】【修复】【验证】)
12
15
  - 功能/UI 可复用产出 → \`memorize_asset\` type=\`pattern\`/\`component\``;
13
16
  }
@@ -15,6 +18,8 @@ function memorySection(locale) {
15
18
  Memory (requires MEMORY_* env):
16
19
  - Search: \`start_*\` auto-injects full memory hits; use \`search_memory\` mid-task; \`read_memory_asset\` for a specific id
17
20
  - Store: do NOT use source_project/source_path for cross-repo pools; put paths in content; write keyword-rich summary
21
+ - Update: fix existing entries in place with \`update_memory_asset\` by asset_id (preserves ID)
22
+ - Cleanup: remove stale/wrong/duplicate entries with \`delete_memory_asset\` (confirm via \`read_memory_asset\` first)
18
23
  - After verified bugfix → MUST \`memorize_asset\` type=\`bugfix\` (sections: symptom, root cause, fix, verification)
19
24
  - Reusable feature/UI → \`memorize_asset\` type=\`pattern\`/\`component\``;
20
25
  }
@@ -25,10 +30,12 @@ export function generateAgentsMdInner(input) {
25
30
  const { layout, locale } = input;
26
31
  const graph = link(layout, layout.latestMarkdownPath);
27
32
  const ctxIndex = link(layout, layout.legacyIndexPath);
33
+ const skillLink = link(layout, MCP_PROBE_SKILL_REL_PATH);
28
34
  if (locale === "zh-CN") {
29
35
  return `## MCP(必须先调)
30
- 需已配置 mcp-probe-kit。\`start_*\` 若返回 delegated plan,逐步执行完再结束。
36
+ 需已配置 mcp-probe-kit。写代码前先读 Skill:[MCP 调用时机](${skillLink})(\`${MCP_PROBE_SKILL_REL_PATH}\`,首次 MCP 调用自动创建)。
31
37
 
38
+ - 不确定用哪个 MCP → \`workflow\`(返回 firstTool)
32
39
  - 新功能 → \`start_feature\`(会先搜记忆)
33
40
  - Bug → \`start_bugfix\`(会先搜记忆)
34
41
  - UI → \`start_ui\`(会先搜记忆)
@@ -40,8 +47,9 @@ export function generateAgentsMdInner(input) {
40
47
  图谱:大改前读 [latest](${graph});过期 \`code_insight\` mode=auto save_to_docs=true${memorySection(locale)}`;
41
48
  }
42
49
  return `## MCP (call first)
43
- Requires mcp-probe-kit. Complete every \`start_*\` delegated plan step before done.
50
+ Requires mcp-probe-kit. Before coding, read Skill: [When to call MCP](${skillLink}) (\`${MCP_PROBE_SKILL_REL_PATH}\`, auto-created on first MCP call).
44
51
 
52
+ - Unsure which MCP → \`workflow\` (returns firstTool)
45
53
  - Feature → \`start_feature\` (searches memory first)
46
54
  - Bug → \`start_bugfix\` (searches memory first)
47
55
  - UI → \`start_ui\` (searches memory first)
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 开发工作流路由:根据用户意图生成「何时调哪个 MCP 工具」的委托式指南。
3
+ * 解决 Agent 直接写代码、跳过 start_* / code_insight / check_spec 的问题。
4
+ */
5
+ export type WorkflowScenario = 'feature' | 'bugfix' | 'ui' | 'explore' | 'commit' | 'review' | 'refactor' | 'onboard' | 'spec' | 'memory' | 'unknown';
6
+ export interface WorkflowToolStep {
7
+ tool: string;
8
+ required: boolean;
9
+ when: string;
10
+ note?: string;
11
+ }
12
+ export interface WorkflowPhase {
13
+ id: string;
14
+ title: string;
15
+ when: string;
16
+ steps: WorkflowToolStep[];
17
+ }
18
+ export interface DevWorkflowPlan {
19
+ scenario: WorkflowScenario;
20
+ scenarioLabel: string;
21
+ confidence: 'high' | 'medium' | 'low';
22
+ summary: string;
23
+ firstTool: string;
24
+ firstToolArgsHint?: Record<string, unknown>;
25
+ phases: WorkflowPhase[];
26
+ avoid: string[];
27
+ memoryNotes: string[];
28
+ }
29
+ export declare function detectWorkflowScenario(intent: string, explicit?: string): {
30
+ scenario: WorkflowScenario;
31
+ confidence: 'high' | 'medium' | 'low';
32
+ };
33
+ export declare function buildDevWorkflow(intent: string, options?: {
34
+ scenario?: string;
35
+ }): DevWorkflowPlan;
36
+ export declare function renderWorkflowMarkdown(plan: DevWorkflowPlan, intent: string): string;