mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-19 11:03:41 +00:00
feat(coding-agent): configurable app name and config dir for forks (#95)
- Add piConfig to package.json for app name and config directory - Consolidate paths.ts into config.ts with clearer naming - Fix Bun binary detection (changed from %7EBUN to $bunfs) - Update all hardcoded paths to use config.ts exports - getThemesDir() for built-in themes, getCustomThemesDir() for user themes
This commit is contained in:
parent
9d5fe1fe85
commit
e82fb0fc83
17 changed files with 241 additions and 167 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { existsSync, readdirSync, readFileSync } from "fs";
|
||||
import { homedir } from "os";
|
||||
import { join, resolve } from "path";
|
||||
import { CONFIG_DIR_NAME, getCommandsDir } from "./config.js";
|
||||
|
||||
/**
|
||||
* Represents a custom slash command loaded from a file
|
||||
|
|
@ -167,19 +167,18 @@ function loadCommandsFromDir(dir: string, source: "user" | "project", subdir: st
|
|||
|
||||
/**
|
||||
* Load all custom slash commands from:
|
||||
* 1. Global: ~/.pi/agent/commands/
|
||||
* 2. Project: ./.pi/commands/
|
||||
* 1. Global: ~/{CONFIG_DIR_NAME}/agent/commands/
|
||||
* 2. Project: ./{CONFIG_DIR_NAME}/commands/
|
||||
*/
|
||||
export function loadSlashCommands(): FileSlashCommand[] {
|
||||
const commands: FileSlashCommand[] = [];
|
||||
|
||||
// 1. Load global commands from ~/.pi/agent/commands/
|
||||
const homeDir = homedir();
|
||||
const globalCommandsDir = resolve(process.env.PI_CODING_AGENT_DIR || join(homeDir, ".pi/agent/"), "commands");
|
||||
// 1. Load global commands from ~/{CONFIG_DIR_NAME}/agent/commands/
|
||||
const globalCommandsDir = getCommandsDir();
|
||||
commands.push(...loadCommandsFromDir(globalCommandsDir, "user"));
|
||||
|
||||
// 2. Load project commands from ./.pi/commands/
|
||||
const projectCommandsDir = resolve(process.cwd(), ".pi/commands");
|
||||
// 2. Load project commands from ./{CONFIG_DIR_NAME}/commands/
|
||||
const projectCommandsDir = resolve(process.cwd(), CONFIG_DIR_NAME, "commands");
|
||||
commands.push(...loadCommandsFromDir(projectCommandsDir, "project"));
|
||||
|
||||
return commands;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue