feat: Add sync/push buttons to ClawHub UI
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user