MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _enter_worktree_call

Function _enter_worktree_call

src/tool_system/tools/worktree.py:15–39  ·  view source on GitHub ↗
(tool_input: dict[str, Any], context: ToolContext)

Source from the content-addressed store, hash-verified

13
14
15def _enter_worktree_call(tool_input: dict[str, Any], context: ToolContext) -> ToolResult:
16 if context.worktree_root is not None:
17 raise ToolPermissionError("already in a worktree session")
18 name = tool_input.get("name")
19 if name is not None:
20 if not isinstance(name, str) or not name.strip():
21 raise ToolInputError("name must be a non-empty string when provided")
22 if len(name) > 64 or not _NAME_RE.match(name):
23 raise ToolInputError("invalid worktree name")
24 slug = name
25 else:
26 slug = "worktree"
27
28 root = context.workspace_root / ".clawcodex" / "worktrees" / slug
29 root.mkdir(parents=True, exist_ok=True)
30 context.worktree_root = root
31 context.cwd = root
32 return ToolResult(
33 name="EnterWorktree",
34 output={
35 "worktreePath": str(root),
36 "worktreeBranch": None,
37 "message": f"Created worktree at {root}. The session is now working in the worktree.",
38 },
39 )
40
41
42EnterWorktreeTool: Tool = build_tool(

Callers

nothing calls this directly

Calls 4

ToolPermissionErrorClass · 0.85
ToolInputErrorClass · 0.85
ToolResultClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected