@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
48 lines • 1.98 kB
JavaScript
import chalk from "chalk";
import { existsSync, readdirSync, renameSync } from "fs";
import { join } from "path";
import { CONFIG_DIR_NAME, getAgentDir } from "./config.js";
function migrateCommandsToPrompts(baseDir, label) {
const commandsDir = join(baseDir, "commands");
const promptsDir = join(baseDir, "prompts");
if (existsSync(commandsDir) && !existsSync(promptsDir)) {
try {
renameSync(commandsDir, promptsDir);
console.log(chalk.green(`Migrated ${label} commands/ → prompts/`));
return true;
}
catch (err) {
console.log(chalk.yellow(`Warning: Could not migrate ${label} commands/ to prompts/: ${err instanceof Error ? err.message : err}`));
}
}
return false;
}
function checkDeprecatedExtensionDirs(baseDir, label) {
const hooksDir = join(baseDir, "hooks");
const toolsDir = join(baseDir, "tools");
const warnings = [];
if (existsSync(hooksDir)) {
warnings.push(`${label} hooks/ directory found. Hooks have been renamed to extensions.`);
}
if (existsSync(toolsDir)) {
try {
const entries = readdirSync(toolsDir);
const customTools = entries.filter((entry) => existsSync(join(toolsDir, entry, "index.ts")));
if (customTools.length > 0) {
warnings.push(`${label} tools/ directory contains custom tools. Custom tools have been merged into extensions.`);
}
}
catch {
return warnings;
}
}
return warnings;
}
export function migrateExtensionSystem(cwd) {
const agentDir = getAgentDir();
const projectDir = join(cwd, CONFIG_DIR_NAME);
migrateCommandsToPrompts(agentDir, "Global");
migrateCommandsToPrompts(projectDir, "Project");
return [...checkDeprecatedExtensionDirs(agentDir, "Global"), ...checkDeprecatedExtensionDirs(projectDir, "Project")];
}
//# sourceMappingURL=extension-system-migration.js.map