feat: archive zoo_backup for home sync
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { parametersSchema as z, defineCustomTool } from "@roo-code/types"
|
||||
import { spawnSync } from "child_process"
|
||||
|
||||
export default defineCustomTool({
|
||||
name: "git_recent_changes",
|
||||
description: "Get recent git commits across all branches as structured JSON. Shows hash, branch, author, date, and message. Useful at session start for situational awareness.",
|
||||
parameters: z.object({
|
||||
repoPath: z.string().optional().describe("Path to git repo (required)"),
|
||||
count: z.number().optional().describe("Number of commits to return. Default: 15"),
|
||||
branch: z.string().optional().describe("Specific branch to query. Default: --all (all branches)"),
|
||||
}),
|
||||
async execute({ repoPath, count = 15, branch }) {
|
||||
const repo = repoPath
|
||||
const args = ["-C", repo, "log", "--oneline", `--max-count=${count}`, "--format=%H|%h|%an|%ai|%D|%s"]
|
||||
|
||||
if (branch) {
|
||||
args.push(branch)
|
||||
} else {
|
||||
args.push("--all")
|
||||
}
|
||||
|
||||
const result = spawnSync("git", args, {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
})
|
||||
|
||||
if (result.status !== 0) {
|
||||
return `Error: ${result.stderr || "git log failed"}`
|
||||
}
|
||||
|
||||
const commits = result.stdout.trim().split("\n").filter(Boolean).map(line => {
|
||||
const [hash, shortHash, author, date, refs, ...msgParts] = line.split("|")
|
||||
return {
|
||||
hash,
|
||||
shortHash,
|
||||
author,
|
||||
date,
|
||||
refs: refs || null,
|
||||
message: msgParts.join("|"),
|
||||
}
|
||||
})
|
||||
|
||||
return JSON.stringify(commits, null, 2)
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user