/**
 * Git status tool for Clawx.
 *
 * EXTRACTION NOTE: OpenClaw does not expose git tools to the model.
 * Written fresh as simple wrappers around `git` CLI.
 */
import { Type } from "@sinclair/typebox";
import { execFile } from "node:child_process";
import { promisify } from "node:util";
const execFileAsync = promisify(execFile);
const GitStatusSchema = Type.Object({
    path: Type.Optional(Type.String({ description: "Directory to check status in (default: working directory)" })),
});
export function createGitStatusTool(defaultCwd) {
    return {
        name: "git_status",
        label: "Git Status",
        description: "Show the working tree status of a git repository",
        parameters: GitStatusSchema,
        async execute(_toolCallId, params) {
            const cwd = params.path || defaultCwd;
            try {
                const { stdout } = await execFileAsync("git", ["status", "--porcelain=v2", "--branch"], {
                    cwd,
                    timeout: 10_000,
                    encoding: "utf-8",
                });
                return {
                    content: [{ type: "text", text: stdout.trim() || "(clean working tree)" }],
                    details: {},
                };
            }
            catch (e) {
                const msg = e instanceof Error ? e.message : String(e);
                return {
                    content: [{ type: "text", text: `git status error: ${msg}` }],
                    details: {},
                };
            }
        },
    };
}
//# sourceMappingURL=gitStatus.js.map