fix: honor CLAUDE_CONFIG_DIR environment variable (#261)
Fixes #255 - Add getClaudeConfigDir() utility function that respects CLAUDE_CONFIG_DIR env var - Update all hardcoded ~/.claude paths to use the new utility - Add comprehensive tests for getClaudeConfigDir() - Maintain backward compatibility with default ~/.claude when env var is not set Files updated: - src/shared/claude-config-dir.ts (new utility) - src/shared/claude-config-dir.test.ts (tests) - src/hooks/claude-code-hooks/config.ts - src/hooks/claude-code-hooks/todo.ts - src/hooks/claude-code-hooks/transcript.ts - src/features/claude-code-command-loader/loader.ts - src/features/claude-code-agent-loader/loader.ts - src/features/claude-code-skill-loader/loader.ts - src/features/claude-code-mcp-loader/loader.ts - src/tools/session-manager/constants.ts - src/tools/slashcommand/tools.ts Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { existsSync, readdirSync, readFileSync } from "fs"
|
||||
import { homedir } from "os"
|
||||
import { join, basename } from "path"
|
||||
import { parseFrontmatter } from "../../shared/frontmatter"
|
||||
import { sanitizeModelField } from "../../shared/model-sanitizer"
|
||||
import { isMarkdownFile } from "../../shared/file-utils"
|
||||
import { getClaudeConfigDir } from "../../shared"
|
||||
import type { CommandScope, CommandDefinition, CommandFrontmatter, LoadedCommand } from "./types"
|
||||
|
||||
function loadCommandsFromDir(commandsDir: string, scope: CommandScope): LoadedCommand[] {
|
||||
@@ -68,7 +68,7 @@ function commandsToRecord(commands: LoadedCommand[]): Record<string, CommandDefi
|
||||
}
|
||||
|
||||
export function loadUserCommands(): Record<string, CommandDefinition> {
|
||||
const userCommandsDir = join(homedir(), ".claude", "commands")
|
||||
const userCommandsDir = join(getClaudeConfigDir(), "commands")
|
||||
const commands = loadCommandsFromDir(userCommandsDir, "user")
|
||||
return commandsToRecord(commands)
|
||||
}
|
||||
@@ -80,6 +80,7 @@ export function loadProjectCommands(): Record<string, CommandDefinition> {
|
||||
}
|
||||
|
||||
export function loadOpencodeGlobalCommands(): Record<string, CommandDefinition> {
|
||||
const { homedir } = require("os")
|
||||
const opencodeCommandsDir = join(homedir(), ".config", "opencode", "command")
|
||||
const commands = loadCommandsFromDir(opencodeCommandsDir, "opencode")
|
||||
return commandsToRecord(commands)
|
||||
|
||||
Reference in New Issue
Block a user