MCPcopy Index your code
hub / github.com/AI45Lab/Code / runAll

Method runAll

sdk/node/examples/git/test_worktree_git.ts:47–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45 }
46
47 async runAll(): Promise<void> {
48 console.log(`Config: ${this.configPath}`);
49 console.log("Agent created");
50
51 // Create temp workspace
52 const workspace: string = fs.mkdtempSync(path.join(os.tmpdir(), "a3s-wt-"));
53 try {
54 GitWorktreeTest.initGitRepo(workspace);
55 console.log(`Git repo initialized at: ${workspace}\n`);
56
57 const session: Session = this.agent.session(workspace);
58
59 // --- Test 1: Direct tool call -- status ---
60 console.log("=== Test 1: git status ===");
61 let result: ToolResult = await session.git({ command: "status" });
62 console.log(result.output);
63 GitWorktreeTest.assert(result.exitCode === 0, "status should succeed");
64 console.log();
65
66 // --- Test 2: Direct tool call -- create worktree ---
67 console.log("=== Test 2: git worktree create ===");
68 const wtPath: string = path.join(workspace, "wt-feature-auth");
69 result = await session.git({
70 command: "worktree",
71 subcommand: "create",
72 name: "feature-auth",
73 path: wtPath,
74 });
75 console.log(result.output);
76 GitWorktreeTest.assert(result.exitCode === 0, `create failed: ${result.output}`);
77 GitWorktreeTest.assert(fs.existsSync(wtPath), "worktree directory should exist");
78 console.log();
79
80 // --- Test 3: Direct tool call -- list ---
81 console.log("=== Test 3: git worktree list ===");
82 result = await session.git({ command: "worktree", subcommand: "list" });
83 console.log(result.output);
84 GitWorktreeTest.assert(result.exitCode === 0, "list should succeed");
85 GitWorktreeTest.assert(result.output.includes("feature-auth"), "list should contain the new branch");
86 console.log();
87
88 // --- Test 4: LLM-driven query ---
89 console.log("=== Test 4: LLM-driven worktree query ===");
90 const llmResult: AgentResult = await session.send(
91 "Use the git tool with command 'worktree' and subcommand 'list' to show me all worktrees. " +
92 "Just show the tool output, nothing else."
93 );
94 console.log(`LLM response:\n${llmResult.text}`);
95 GitWorktreeTest.assert(llmResult.toolCallsCount > 0, "LLM should have called git");
96 console.log();
97
98 // --- Test 5: Direct tool call -- remove ---
99 console.log("=== Test 5: git worktree remove ===");
100 result = await session.git({
101 command: "worktree",
102 subcommand: "remove",
103 path: wtPath,
104 });

Callers 1

mainFunction · 0.95

Calls 6

initGitRepoMethod · 0.80
logMethod · 0.45
sessionMethod · 0.45
gitMethod · 0.45
assertMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected