mcp-probe-kit 3.0.9 → 3.0.10

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 (52) hide show
  1. package/README.md +14 -4
  2. package/build/lib/__tests__/gitnexus-bridge.unit.test.d.ts +1 -0
  3. package/build/lib/__tests__/gitnexus-bridge.unit.test.js +86 -0
  4. package/build/lib/gitnexus-bridge.d.ts +23 -0
  5. package/build/lib/gitnexus-bridge.js +517 -21
  6. package/build/schemas/code-analysis-tools.d.ts +9 -1
  7. package/build/schemas/code-analysis-tools.js +9 -1
  8. package/build/schemas/git-tools.d.ts +1 -1
  9. package/build/schemas/git-tools.js +1 -1
  10. package/build/schemas/index.d.ts +23 -3
  11. package/build/schemas/orchestration-tools.d.ts +13 -1
  12. package/build/schemas/orchestration-tools.js +13 -1
  13. package/build/schemas/output/core-tools.d.ts +130 -1
  14. package/build/schemas/output/core-tools.js +71 -1
  15. package/build/schemas/output/index.d.ts +2 -2
  16. package/build/schemas/output/index.js +2 -2
  17. package/build/schemas/output/project-tools.d.ts +13 -0
  18. package/build/schemas/output/project-tools.js +9 -0
  19. package/build/schemas/structured-output.d.ts +358 -5
  20. package/build/schemas/structured-output.js +169 -5
  21. package/build/tools/__tests__/code_insight.unit.test.js +81 -1
  22. package/build/tools/__tests__/fix_bug.unit.test.d.ts +1 -0
  23. package/build/tools/__tests__/fix_bug.unit.test.js +31 -0
  24. package/build/tools/__tests__/gencommit.unit.test.d.ts +1 -0
  25. package/build/tools/__tests__/gencommit.unit.test.js +41 -0
  26. package/build/tools/__tests__/init_project_context.unit.test.d.ts +1 -0
  27. package/build/tools/__tests__/init_project_context.unit.test.js +63 -0
  28. package/build/tools/__tests__/start_bugfix.unit.test.js +10 -0
  29. package/build/tools/__tests__/start_feature.unit.test.js +10 -0
  30. package/build/tools/code_insight.d.ts +10 -0
  31. package/build/tools/code_insight.js +156 -3
  32. package/build/tools/fix_bug.d.ts +3 -3
  33. package/build/tools/fix_bug.js +297 -312
  34. package/build/tools/gencommit.js +144 -123
  35. package/build/tools/init_project_context.js +211 -53
  36. package/build/tools/start_bugfix.js +170 -70
  37. package/build/tools/start_feature.js +79 -25
  38. package/docs/data/tools.js +33 -31
  39. package/docs/i18n/all-tools/en.json +9 -9
  40. package/docs/i18n/all-tools/ja.json +9 -9
  41. package/docs/i18n/all-tools/ko.json +9 -9
  42. package/docs/i18n/all-tools/zh-CN.json +9 -9
  43. package/docs/i18n/en.json +480 -481
  44. package/docs/i18n/ja.json +478 -479
  45. package/docs/i18n/ko.json +480 -481
  46. package/docs/i18n/zh-CN.json +480 -481
  47. package/docs/index.html +2 -2
  48. package/docs/pages/all-tools.html +2 -2
  49. package/docs/pages/examples.html +2 -2
  50. package/docs/pages/getting-started.html +2 -2
  51. package/docs/pages/migration.html +2 -2
  52. package/package.json +1 -2
package/README.md CHANGED
@@ -66,11 +66,21 @@ A powerful MCP (Model Context Protocol) server providing **22 tools** covering t
66
66
 
67
67
  - `code_insight` bridges GitNexus by default for query/context/impact analysis
68
68
  - The bridge launches `npx -y gitnexus@latest mcp` by default to reduce stale package risk
69
- - `start_feature` and `start_bugfix` automatically enrich plans with graph context when available
69
+ - `init_project_context` bootstraps baseline graph docs under `docs/graph-insights/`; if `docs/project-context.md` already exists, it preserves the old context docs and only backfills graph docs plus the index entry
70
+ - `start_feature` refreshes the GitNexus index and runs task-level `query/context/impact` narrowing before spec generation to reduce over-scoping
71
+ - `start_bugfix` refreshes the GitNexus index and runs task-level graph analysis before TBP RCA to constrain failure boundary and blast radius
72
+ - Older projects that already have `project-context.md` but no graph docs are bootstrapped automatically through the `init_project_context` step
70
73
  - If GitNexus is unavailable, the server falls back automatically without breaking orchestration
74
+ - Real graph queries read the `.gitnexus` index; `docs/graph-insights/latest.md|json` are readable snapshots for humans and AI agents
71
75
  - Graph snapshots are exposed as resources (`probe://graph/latest`, `probe://graph/history`, `probe://graph/latest.md`)
72
76
  - Graph snapshots are also persisted to readable files in `.mcp-probe-kit/graph-snapshots` (customizable via `MCP_GRAPH_SNAPSHOT_DIR`)
73
77
  - Tool responses include `_meta.graph` with snapshot URI and local JSON/Markdown file paths
78
+
79
+ ### 🐛 TBP 8-Step RCA for Bug Workflows
80
+
81
+ - `start_bugfix` defaults to Toyota-style TBP 8-step root-cause analysis before repair
82
+ - `fix_bug` returns a structured TBP skeleton covering phenomenon, timeline, ruled-out paths, boundary, root cause, evidence, and repair plan
83
+ - This makes bug, regression, anomaly, and "why didn't it work" investigations follow analyze-first discipline instead of patching symptoms
74
84
 
75
85
  ### 🎯 Structured Output
76
86
 
@@ -173,7 +183,7 @@ This mode performs 1-2 rounds of structured clarification before entering spec/f
173
183
 
174
184
  6 intelligent orchestration tools that automatically combine multiple basic tools for one-click complex development workflows:
175
185
  - `start_feature` - New feature development (Requirements → Design → Estimation)
176
- - `start_bugfix` - Bug fixing (Analysis → Fix → Testing)
186
+ - `start_bugfix` - Bug fixing (TBP 8-step RCA → Fix → Testing)
177
187
  - `start_onboard` - Project onboarding (Generate project context docs)
178
188
  - `start_ui` - UI development (Design system → Components → Code)
179
189
  - `start_product` - Product design (PRD → Prototype → Design system → HTML)
@@ -252,8 +262,8 @@ This ensures `start_ui` can generate professional-grade UI code even offline.
252
262
  |---------|-----------------|--------|
253
263
  | Develop new feature (complete flow) | `start_feature` | Auto-complete: spec→estimation |
254
264
  | Only need feature spec docs | `add_feature` | More lightweight, only generates docs |
255
- | Fix bug (complete flow) | `start_bugfix` | Auto-complete: analysis→fix→test |
256
- | Only need bug analysis | `fix_bug` | Faster, only analyzes problem |
265
+ | Fix bug (complete flow) | `start_bugfix` | Root-cause-first flow: TBP RCA fix test |
266
+ | Only need bug analysis | `fix_bug` | TBP 8-step RCA only, without full orchestration |
257
267
  | Generate design system | `ui_design_system` | Directly generate design specs |
258
268
  | Develop UI components | `start_ui` | Complete flow: design→components→code |
259
269
  | Product design (requirements to prototype) | `start_product` | One-click: PRD→prototype→HTML |
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,86 @@
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 { prepareBridgeWorkspace, resolveExecutableCommand, resolveSpawnCommand } from "../gitnexus-bridge.js";
6
+ const tempRoots = [];
7
+ afterEach(() => {
8
+ while (tempRoots.length > 0) {
9
+ const dir = tempRoots.pop();
10
+ if (dir) {
11
+ fs.rmSync(dir, { recursive: true, force: true });
12
+ }
13
+ }
14
+ });
15
+ function makeTempDir(prefix) {
16
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
17
+ tempRoots.push(dir);
18
+ return dir;
19
+ }
20
+ describe("gitnexus-bridge workspace preparation", () => {
21
+ test("Windows 下将 npx/git 解析为 cmd 可执行文件", () => {
22
+ const npxResolved = resolveExecutableCommand("npx", "win32").toLowerCase();
23
+ expect(npxResolved).toContain("npx");
24
+ if (npxResolved.includes("\\")) {
25
+ expect(npxResolved.endsWith(".cmd") || npxResolved.endsWith("\\npx")).toBe(true);
26
+ }
27
+ expect(resolveExecutableCommand("git", "win32").toLowerCase()).toContain("git");
28
+ expect(resolveExecutableCommand("npx", "linux").toLowerCase()).toContain("npx");
29
+ });
30
+ test("Windows 下将 cmd 工具包装为 cmd.exe /c 启动", () => {
31
+ const wrapped = resolveSpawnCommand("npx", ["-y", "gitnexus@latest", "mcp"], "win32");
32
+ expect(wrapped.command.toLowerCase()).toContain("cmd");
33
+ expect(wrapped.args.slice(0, 3)).toEqual(["/d", "/s", "/c"]);
34
+ expect(String(wrapped.args[3]).toLowerCase()).toContain("npx");
35
+ });
36
+ test("Windows 下 git.exe 直接启动,不走 git.cmd 壳层", () => {
37
+ const resolved = resolveExecutableCommand("git", "win32").toLowerCase();
38
+ const spawned = resolveSpawnCommand("git", ["init", "-q"], "win32");
39
+ expect(resolved).toContain("git");
40
+ expect(resolved.endsWith(".exe") || resolved === "git").toBe(true);
41
+ expect(spawned.command.toLowerCase()).not.toContain("cmd.exe /d /s /c git.cmd");
42
+ if (spawned.command.toLowerCase().includes("cmd")) {
43
+ expect(String(spawned.args[3]).toLowerCase()).not.toContain("git.cmd");
44
+ }
45
+ else {
46
+ expect(spawned.command.toLowerCase()).toContain("git");
47
+ }
48
+ });
49
+ test("git 目录直接使用源仓库", async () => {
50
+ const repoRoot = makeTempDir("gitnexus-direct-");
51
+ fs.mkdirSync(path.join(repoRoot, ".git"));
52
+ fs.mkdirSync(path.join(repoRoot, "src"), { recursive: true });
53
+ fs.writeFileSync(path.join(repoRoot, "package.json"), JSON.stringify({ name: "video-pipeline" }, null, 2), "utf-8");
54
+ const nested = path.join(repoRoot, "src");
55
+ const workspace = await prepareBridgeWorkspace(nested);
56
+ expect(workspace.workspaceMode).toBe("direct");
57
+ expect(workspace.sourceRoot).toBe(repoRoot);
58
+ expect(workspace.analysisRoot).toBe(repoRoot);
59
+ expect(workspace.repoName).toBe("video-pipeline");
60
+ expect(workspace.pathMapped).toBe(false);
61
+ expect(workspace.cleanup).toBeUndefined();
62
+ });
63
+ test("non-git 目录创建项目内一次性工作区并忽略敏感目录", async () => {
64
+ const sourceRoot = makeTempDir("gitnexus-temp-");
65
+ fs.writeFileSync(path.join(sourceRoot, "index.ts"), "export const ok = true;\n", "utf-8");
66
+ fs.mkdirSync(path.join(sourceRoot, "node_modules", "left-pad"), { recursive: true });
67
+ fs.writeFileSync(path.join(sourceRoot, "node_modules", "left-pad", "index.js"), "module.exports = 1;\n", "utf-8");
68
+ fs.mkdirSync(path.join(sourceRoot, ".mcp-probe-kit"), { recursive: true });
69
+ fs.writeFileSync(path.join(sourceRoot, ".env"), "TOKEN=secret\n", "utf-8");
70
+ fs.mkdirSync(path.join(sourceRoot, "output"), { recursive: true });
71
+ fs.writeFileSync(path.join(sourceRoot, "output", "video.mp4"), "binary-ish\n", "utf-8");
72
+ const workspace = await prepareBridgeWorkspace(sourceRoot, undefined, { bootstrap: false });
73
+ expect(workspace.workspaceMode).toBe("temp-repo");
74
+ expect(workspace.sourceRoot).toBe(sourceRoot);
75
+ expect(workspace.analysisRoot).toContain(path.join(sourceRoot, ".mcp-probe-kit", "gitnexus-temp"));
76
+ expect(fs.existsSync(path.join(workspace.analysisRoot, "index.ts"))).toBe(true);
77
+ expect(fs.existsSync(path.join(workspace.analysisRoot, "node_modules"))).toBe(false);
78
+ expect(fs.existsSync(path.join(workspace.analysisRoot, ".mcp-probe-kit"))).toBe(false);
79
+ expect(fs.existsSync(path.join(workspace.analysisRoot, ".env"))).toBe(false);
80
+ expect(fs.existsSync(path.join(workspace.analysisRoot, "output"))).toBe(false);
81
+ const tempWorkspaceRoot = path.dirname(workspace.analysisRoot);
82
+ await workspace.cleanup?.();
83
+ expect(fs.existsSync(workspace.analysisRoot)).toBe(false);
84
+ expect(fs.existsSync(tempWorkspaceRoot)).toBe(false);
85
+ });
86
+ });
@@ -5,6 +5,7 @@ export interface CodeInsightRequest {
5
5
  query?: string;
6
6
  target?: string;
7
7
  repo?: string;
8
+ projectRoot?: string;
8
9
  goal?: string;
9
10
  taskContext?: string;
10
11
  direction?: CodeInsightDirection;
@@ -32,6 +33,10 @@ export interface CodeInsightBridgeResult {
32
33
  executions: CodeInsightExecution[];
33
34
  warnings: string[];
34
35
  repo?: string;
36
+ workspaceMode: "direct" | "temp-repo";
37
+ sourceRoot: string;
38
+ analysisRoot: string;
39
+ pathMapped: boolean;
35
40
  }
36
41
  export interface EmbeddedGraphContext {
37
42
  enabled: boolean;
@@ -43,16 +48,34 @@ export interface EmbeddedGraphContext {
43
48
  mode: "query" | "context" | "impact";
44
49
  highlights: string[];
45
50
  }
51
+ export declare function resolveExecutableCommand(command: string, platform?: NodeJS.Platform): string;
52
+ export declare function resolveSpawnCommand(command: string, args: string[], platform?: NodeJS.Platform): {
53
+ command: string;
54
+ args: string[];
55
+ };
56
+ export interface BridgeWorkspace {
57
+ workspaceMode: "direct" | "temp-repo";
58
+ sourceRoot: string;
59
+ analysisRoot: string;
60
+ repoName?: string;
61
+ pathMapped: boolean;
62
+ cleanup?: () => Promise<void>;
63
+ }
64
+ export declare function prepareBridgeWorkspace(cwd?: string, signal?: AbortSignal, options?: {
65
+ bootstrap?: boolean;
66
+ }): Promise<BridgeWorkspace>;
46
67
  export declare function runCodeInsightBridge(request: CodeInsightRequest): Promise<CodeInsightBridgeResult>;
47
68
  export declare function buildFeatureGraphContext(input: {
48
69
  featureName: string;
49
70
  description: string;
50
71
  signal?: AbortSignal;
51
72
  repo?: string;
73
+ projectRoot?: string;
52
74
  }): Promise<EmbeddedGraphContext>;
53
75
  export declare function buildBugfixGraphContext(input: {
54
76
  errorMessage: string;
55
77
  stackTrace?: string;
56
78
  signal?: AbortSignal;
57
79
  repo?: string;
80
+ projectRoot?: string;
58
81
  }): Promise<EmbeddedGraphContext>;