feat: Add sync/push buttons to ClawHub UI

This commit is contained in:
2026-03-24 18:16:07 +01:00
parent 064812d730
commit 4c699a65a4
2 changed files with 85 additions and 7 deletions
+25
View File
@@ -56,6 +56,13 @@ export async function GET(req: NextRequest) {
const agents = ["horus", "amun", "cleo"];
const installed: Record<string, string[]> = {};
// Sync Horus repo first
try {
await execAsync(`cd ${SKILLS_BASE} && git pull origin main 2>&1`);
} catch {}
for (const agent of agents) {
for (const agent of agents) {
const agentPath = path.join(SKILLS_BASE, agent);
if (existsSync(agentPath)) {
@@ -79,6 +86,24 @@ export async function GET(req: NextRequest) {
return NextResponse.json({ info: stdout });
}
if (action === "sync") {
try {
const { stdout, stderr } = await execAsync(`cd ${SKILLS_BASE} && git pull origin main 2>&1`);
return NextResponse.json({ output: stdout || "Already up to date", error: stderr });
} catch (e: any) {
return NextResponse.json({ output: "Sync failed", error: e.message });
}
}
if (action === "push") {
try {
const { stdout, stderr } = await execAsync(`cd ${SKILLS_BASE} && git add -A && git commit -m "Update skills" && git push origin main 2>&1`);
return NextResponse.json({ output: stdout || "Pushed", error: stderr });
} catch (e: any) {
return NextResponse.json({ output: "Push failed", error: e.message });
}
}
return NextResponse.json({ error: "Unknown action" }, { status: 400 });
} catch (e: unknown) {
const error = e as Error & { stdout?: string; message?: string };