diff --git a/src/app/api/skills/route.ts b/src/app/api/skills/route.ts index 3fcceff..b83fb77 100644 --- a/src/app/api/skills/route.ts +++ b/src/app/api/skills/route.ts @@ -1,4 +1,4 @@ -import { NextResponse } from "next/server"; +import { NextRequest, NextResponse } from "next/server"; import fs from "fs"; import path from "path"; import os from "os"; @@ -15,8 +15,8 @@ function getGlobalCommandsDir(): string { return path.join(os.homedir(), ".claude", "commands"); } -function getProjectCommandsDir(): string { - return path.join(process.cwd(), ".claude", "commands"); +function getProjectCommandsDir(cwd?: string): string { + return path.join(cwd || process.cwd(), ".claude", "commands"); } function getPluginCommandsDirs(): string[] { @@ -157,10 +157,12 @@ function scanDirectory( return skills; } -export async function GET() { +export async function GET(request: NextRequest) { try { + // Accept optional cwd query param for project-level skills + const cwd = request.nextUrl.searchParams.get("cwd") || undefined; const globalSkills = scanDirectory(getGlobalCommandsDir(), "global"); - const projectSkills = scanDirectory(getProjectCommandsDir(), "project"); + const projectSkills = scanDirectory(getProjectCommandsDir(cwd), "project"); const installedSkills = scanInstalledSkills(); // Scan installed plugin skills diff --git a/src/lib/claude-client.ts b/src/lib/claude-client.ts index 3ad0be4..4f870cd 100644 --- a/src/lib/claude-client.ts +++ b/src/lib/claude-client.ts @@ -138,6 +138,11 @@ export function streamClaude(options: ClaudeStreamOptions): ReadableStream = { ...process.env as Record }; + // Ensure HOME is explicitly set so Claude Code can find ~/.claude/commands/ + if (!sdkEnv.HOME) { + sdkEnv.HOME = os.homedir(); + } + const appToken = getSetting('anthropic_auth_token'); const appBaseUrl = getSetting('anthropic_base_url'); if (appToken) {