feat: CodePilot - desktop GUI for Claude Code
Full-featured desktop application built with Next.js + Electron: - Streaming chat with Claude Code via Agent SDK - Session management with SQLite persistence - Project file tree and file preview - MCP server and custom skills management - Permission controls with Code/Plan/Ask modes - Dark/light theme, token tracking - macOS DMG packaging with electron-builder Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
6776cc6297
commit
ff1fb38735
149 files changed
+31117
-122
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
|
||||
const SETTINGS_PATH = path.join(os.homedir(), ".claude", "settings.json");
|
||||
|
||||
function readSettingsFile(): Record<string, unknown> {
|
||||
try {
|
||||
if (fs.existsSync(SETTINGS_PATH)) {
|
||||
const content = fs.readFileSync(SETTINGS_PATH, "utf-8");
|
||||
return JSON.parse(content);
|
||||
}
|
||||
} catch {
|
||||
// Return empty object if file doesn't exist or is invalid
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
function writeSettingsFile(data: Record<string, unknown>): void {
|
||||
const dir = path.dirname(SETTINGS_PATH);
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(data, null, 2), "utf-8");
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const settings = readSettingsFile();
|
||||
return NextResponse.json({ settings });
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to read settings" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { settings } = body;
|
||||
|
||||
if (!settings || typeof settings !== "object") {
|
||||
return NextResponse.json(
|
||||
{ error: "Invalid settings data" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
writeSettingsFile(settings);
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to save settings" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user