diff --git a/src/server/hono/route.ts b/src/server/hono/route.ts index c9425c3..14e48de 100644 --- a/src/server/hono/route.ts +++ b/src/server/hono/route.ts @@ -167,7 +167,7 @@ export const routes = (app: HonoAppType) => { "query", z.object({ basePath: z.string().optional().default("/"), - }) + }), ), async (c) => { const { projectId } = c.req.param(); @@ -182,14 +182,14 @@ export const routes = (app: HonoAppType) => { try { const result = await getFileCompletion( project.meta.projectPath, - basePath + basePath, ); return c.json(result); } catch (error) { console.error("File completion error:", error); return c.json({ error: "Failed to get file completion" }, 500); } - } + }, ) .get("/projects/:projectId/claude-commands", async (c) => { @@ -202,18 +202,18 @@ export const routes = (app: HonoAppType) => { }).then((dirents) => dirents .filter((d) => d.isFile() && d.name.endsWith(".md")) - .map((d) => d.name.replace(/\.md$/, "")) + .map((d) => d.name.replace(/\.md$/, "")), ), project.meta.projectPath !== null ? readdir( resolve(project.meta.projectPath, ".claude", "commands"), { withFileTypes: true, - } + }, ).then((dirents) => dirents .filter((d) => d.isFile() && d.name.endsWith(".md")) - .map((d) => d.name.replace(/\.md$/, "")) + .map((d) => d.name.replace(/\.md$/, "")), ) : [], ]); @@ -274,7 +274,7 @@ export const routes = (app: HonoAppType) => { z.object({ fromRef: z.string().min(1, "fromRef is required"), toRef: z.string().min(1, "toRef is required"), - }) + }), ), async (c) => { const { projectId } = c.req.param(); @@ -289,7 +289,7 @@ export const routes = (app: HonoAppType) => { const result = await getDiff( project.meta.projectPath, fromRef, - toRef + toRef, ); return c.json(result); } catch (error) { @@ -299,7 +299,7 @@ export const routes = (app: HonoAppType) => { } return c.json({ error: "Failed to get diff" }, 500); } - } + }, ) .get("/mcp/list", async (c) => { @@ -313,7 +313,7 @@ export const routes = (app: HonoAppType) => { "json", z.object({ message: z.string(), - }) + }), ), async (c) => { const { projectId } = c.req.param(); @@ -325,13 +325,13 @@ export const routes = (app: HonoAppType) => { } const task = await getTaskController( - c.get("config") + c.get("config"), ).startOrContinueTask( { projectId, cwd: project.meta.projectPath, }, - message + message, ); return c.json({ @@ -339,7 +339,7 @@ export const routes = (app: HonoAppType) => { sessionId: task.sessionId, userMessageId: task.userMessageId, }); - } + }, ) .post( @@ -348,7 +348,7 @@ export const routes = (app: HonoAppType) => { "json", z.object({ resumeMessage: z.string(), - }) + }), ), async (c) => { const { projectId, sessionId } = c.req.param(); @@ -360,14 +360,14 @@ export const routes = (app: HonoAppType) => { } const task = await getTaskController( - c.get("config") + c.get("config"), ).startOrContinueTask( { projectId, sessionId, cwd: project.meta.projectPath, }, - resumeMessage + resumeMessage, ); return c.json({ @@ -375,7 +375,7 @@ export const routes = (app: HonoAppType) => { sessionId: task.sessionId, userMessageId: task.userMessageId, }); - } + }, ) .get("/tasks/alive", async (c) => { @@ -386,7 +386,7 @@ export const routes = (app: HonoAppType) => { status: task.status, sessionId: task.sessionId, userMessageId: task.userMessageId, - }) + }), ), }); }) @@ -398,7 +398,7 @@ export const routes = (app: HonoAppType) => { const { sessionId } = c.req.valid("json"); getTaskController(c.get("config")).abortTask(sessionId); return c.json({ message: "Task aborted" }); - } + }, ) .post( @@ -408,15 +408,15 @@ export const routes = (app: HonoAppType) => { z.object({ permissionRequestId: z.string(), decision: z.enum(["allow", "deny"]), - }) + }), ), async (c) => { const permissionResponse = c.req.valid("json"); getTaskController(c.get("config")).respondToPermissionRequest( - permissionResponse + permissionResponse, ); return c.json({ message: "Permission response received" }); - } + }, ) .get("/sse", async (c) => { @@ -426,7 +426,7 @@ export const routes = (app: HonoAppType) => { const stream = writeTypeSafeSSE(rawStream); const onSessionListChanged = ( - event: InternalEventDeclaration["sessionListChanged"] + event: InternalEventDeclaration["sessionListChanged"], ) => { stream.writeSSE("sessionListChanged", { projectId: event.projectId, @@ -434,7 +434,7 @@ export const routes = (app: HonoAppType) => { }; const onSessionChanged = ( - event: InternalEventDeclaration["sessionChanged"] + event: InternalEventDeclaration["sessionChanged"], ) => { stream.writeSSE("sessionChanged", { projectId: event.projectId, @@ -443,7 +443,7 @@ export const routes = (app: HonoAppType) => { }; const onTaskChanged = ( - event: InternalEventDeclaration["taskChanged"] + event: InternalEventDeclaration["taskChanged"], ) => { stream.writeSSE("taskChanged", { aliveTasks: event.aliveTasks, @@ -467,7 +467,7 @@ export const routes = (app: HonoAppType) => { }, async (err) => { console.error("Streaming error:", err); - } + }, ); }) ); diff --git a/src/server/service/claude-code/ClaudeCodeExecutor.ts b/src/server/service/claude-code/ClaudeCodeExecutor.ts index 691117e..d3c1678 100644 --- a/src/server/service/claude-code/ClaudeCodeExecutor.ts +++ b/src/server/service/claude-code/ClaudeCodeExecutor.ts @@ -19,7 +19,7 @@ export class ClaudeCodeExecutor { ? resolve(executablePath) : execSync("which claude", {}).toString().trim(); this.claudeCodeVersion = ClaudeCodeVersion.fromCLIString( - execSync(`${this.pathToClaudeCodeExecutable} --version`, {}).toString() + execSync(`${this.pathToClaudeCodeExecutable} --version`, {}).toString(), ); } @@ -27,11 +27,11 @@ export class ClaudeCodeExecutor { return { enableToolApproval: this.claudeCodeVersion?.greaterThanOrEqual( - new ClaudeCodeVersion({ major: 1, minor: 0, patch: 82 }) + new ClaudeCodeVersion({ major: 1, minor: 0, patch: 82 }), ) ?? false, extractUuidFromSDKMessage: this.claudeCodeVersion?.greaterThanOrEqual( - new ClaudeCodeVersion({ major: 1, minor: 0, patch: 86 }) + new ClaudeCodeVersion({ major: 1, minor: 0, patch: 86 }), ) ?? false, }; } diff --git a/src/server/service/claude-code/ClaudeCodeTaskController.ts b/src/server/service/claude-code/ClaudeCodeTaskController.ts index 2f859cf..a097f6b 100644 --- a/src/server/service/claude-code/ClaudeCodeTaskController.ts +++ b/src/server/service/claude-code/ClaudeCodeTaskController.ts @@ -46,7 +46,7 @@ export class ClaudeCodeTaskController { return async ( toolName: string, toolInput: Record, - _options: { signal: AbortSignal } + _options: { signal: AbortSignal }, ) => { // If not in default mode, use the configured permission mode behavior if (this.config.permissionMode !== "default") { @@ -81,7 +81,7 @@ export class ClaudeCodeTaskController { // Store the request this.pendingPermissionRequests.set( permissionRequest.id, - permissionRequest + permissionRequest, ); // Emit event to notify UI @@ -92,7 +92,7 @@ export class ClaudeCodeTaskController { // Wait for user response with timeout const response = await this.waitForPermissionResponse( permissionRequest.id, - 60000 + 60000, ); // 60 second timeout if (response) { @@ -120,7 +120,7 @@ export class ClaudeCodeTaskController { private async waitForPermissionResponse( permissionRequestId: string, - timeoutMs: number + timeoutMs: number, ): Promise { return new Promise((resolve) => { const checkResponse = () => { @@ -153,7 +153,7 @@ export class ClaudeCodeTaskController { public get aliveTasks() { return this.tasks.filter( - (task) => task.status === "running" || task.status === "paused" + (task) => task.status === "running" || task.status === "paused", ); } @@ -163,10 +163,10 @@ export class ClaudeCodeTaskController { projectId: string; sessionId?: string; }, - message: string + message: string, ): Promise { const existingTask = this.aliveTasks.find( - (task) => task.sessionId === currentSession.sessionId + (task) => task.sessionId === currentSession.sessionId, ); if (existingTask) { @@ -190,7 +190,7 @@ export class ClaudeCodeTaskController { projectId: string; sessionId?: string; }, - message: string + message: string, ) { const { generateMessages, @@ -221,7 +221,7 @@ export class ClaudeCodeTaskController { (resolve, reject) => { aliveTaskResolve = resolve; aliveTaskReject = reject; - } + }, ); let resolved = false; @@ -240,10 +240,10 @@ export class ClaudeCodeTaskController { permissionMode: this.config.permissionMode, canUseTool: this.createCanUseToolCallback( task.id, - task.baseSessionId + task.baseSessionId, ), abortController: abortController, - } + }, )) { currentTask ??= this.aliveTasks.find((t) => t.id === task.id); @@ -257,13 +257,9 @@ export class ClaudeCodeTaskController { // 初回の system message だとまだ history ファイルが作成されていないので if (message.type === "user" || message.type === "assistant") { // 本来は message.uuid の存在チェックをしたいが、古いバージョンでは存在しないことがある - console.log( - "[DEBUG startTask] 9. Processing user/assistant message" - ); - if (!resolved) { console.log( - "[DEBUG startTask] 10. Resolving task for first time" + "[DEBUG startTask] 10. Resolving task for first time", ); const runningTask: RunningClaudeCodeTask = { @@ -283,12 +279,12 @@ export class ClaudeCodeTaskController { }; this.tasks.push(runningTask); console.log( - "[DEBUG startTask] 11. About to call aliveTaskResolve" + "[DEBUG startTask] 11. About to call aliveTaskResolve", ); aliveTaskResolve(runningTask); resolved = true; console.log( - "[DEBUG startTask] 12. aliveTaskResolve called, resolved=true" + "[DEBUG startTask] 12. aliveTaskResolve called, resolved=true", ); } @@ -298,13 +294,10 @@ export class ClaudeCodeTaskController { await Promise.all( task.onMessageHandlers.map(async (onMessageHandler) => { await onMessageHandler(message); - }) + }), ); if (currentTask !== undefined && message.type === "result") { - console.log( - "[DEBUG startTask] 15. Result message received, pausing task" - ); this.upsertExistingTask({ ...currentTask, status: "paused", @@ -318,12 +311,12 @@ export class ClaudeCodeTaskController { if (updatedTask === undefined) { console.log( - "[DEBUG startTask] 17. ERROR: Task not found in aliveTasks" + "[DEBUG startTask] 17. ERROR: Task not found in aliveTasks", ); const error = new Error( `illegal state: task is not running, task: ${JSON.stringify( - updatedTask - )}` + updatedTask, + )}`, ); aliveTaskReject(error); throw error; @@ -336,7 +329,7 @@ export class ClaudeCodeTaskController { } catch (error) { if (!resolved) { console.log( - "[DEBUG startTask] 20. Rejecting task (not yet resolved)" + "[DEBUG startTask] 20. Rejecting task (not yet resolved)", ); aliveTaskReject(error); resolved = true; diff --git a/src/server/service/events/EventBus.ts b/src/server/service/events/EventBus.ts index c9deac7..42fa9e4 100644 --- a/src/server/service/events/EventBus.ts +++ b/src/server/service/events/EventBus.ts @@ -10,7 +10,7 @@ class EventBus { public emit( event: EventName, - data: InternalEventDeclaration[EventName] + data: InternalEventDeclaration[EventName], ): void { this.emitter.emit(event, { ...data, @@ -20,8 +20,8 @@ class EventBus { public on( event: EventName, listener: ( - data: InternalEventDeclaration[EventName] - ) => void | Promise + data: InternalEventDeclaration[EventName], + ) => void | Promise, ): void { this.emitter.on(event, listener); } @@ -29,8 +29,8 @@ class EventBus { public off( event: EventName, listener: ( - data: InternalEventDeclaration[EventName] - ) => void | Promise + data: InternalEventDeclaration[EventName], + ) => void | Promise, ): void { this.emitter.off(event, listener); }