Repository navigation
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (40 loc) · 1.97 KB
/
Copy pathindex.ts
File metadata and controls
43 lines (40 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/** Model tool for creating and entering a new Git worktree through the shared runtime. */
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-experimental-worktree'
import { defineTool } from '@deepseek-ai/dsh-tools'
/** Cordis plugin name. */
export const name = 'tool-worktree'
/** Services required to register and execute the worktree tool. */
export const inject = ['tools', 'worktrees']
/**
* Register create_worktree for model and PTC callers.
* @param ctx - tool registry and worktree runtime.
*/
export function apply(ctx: Context): void {
ctx.tools.register(defineTool({
name: 'create_worktree',
description: 'Create a new Git branch and worktree from a local commit, branch, or tag, then change this session\'s working directory to it. Defaults to HEAD and a generated name. Uncommitted files stay in the source checkout. Existing names fail. Use working_directory with cd to leave; the checkout and branch remain.',
parameters: {
name: { type: 'string', description: 'New branch name, also used as the checkout directory. Omit to generate a unique name.' },
from: { type: 'string', description: 'Local commit, branch, or tag to start from. Defaults to HEAD; no fetch is performed.' },
},
output: {
schema: {
type: 'object',
additionalProperties: false,
properties: {
path: { type: 'string', required: true },
branch: { type: 'string', required: true },
baseCommit: { type: 'string', required: true },
repositoryRoot: { type: 'string', required: true },
},
},
render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }],
},
async execute(args, exec) {
if (exec.agent === undefined) throw new Error('create_worktree requires a calling agent')
return ctx.worktrees.create(exec.agent, args, exec.signal)
},
presentCall: args => ({ card: 'generic', title: 'create_worktree', rawInput: args }),
}))
}