@2501-ai/cli
Version:
[](https://www.npmjs.com/package/@2501-ai/cli) [](https://www.2501.ai/research/full-humaneval-benchmark) [); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initPlugins = exports.pluginService = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const logger_1 = __importDefault(require("./logger"));
const constants_1 = require("../constants");
class PluginService {
constructor() {
this.pluginsPath = null;
this.plugins = {};
}
static getInstance() {
if (!PluginService.instance) {
PluginService.instance = new PluginService();
}
return PluginService.instance;
}
initialize(pluginsPath) {
if (!pluginsPath) {
logger_1.default.debug('No plugins path provided');
return;
}
const resolvedPath = path_1.default.resolve(pluginsPath);
if (!fs_1.default.existsSync(resolvedPath)) {
throw new Error(`Plugins file not found at ${resolvedPath}`);
}
this.pluginsPath = resolvedPath;
const pluginsContent = fs_1.default.readFileSync(resolvedPath, 'utf-8');
this.plugins = JSON.parse(pluginsContent);
logger_1.default.debug(this.plugins);
logger_1.default.debug('Plugins loaded successfully');
}
getPlugins() {
return this.plugins;
}
}
exports.pluginService = PluginService.getInstance();
const initPlugins = (thisCommand, actionCommand) => __awaiter(void 0, void 0, void 0, function* () {
const defaultPluginsPath = path_1.default.join(constants_1.CONFIG_DIR, 'plugins.json');
const options = actionCommand.opts();
if (options.plugins) {
exports.pluginService.initialize(options.plugins);
}
else if (fs_1.default.existsSync(defaultPluginsPath)) {
exports.pluginService.initialize(defaultPluginsPath);
}
});
exports.initPlugins = initPlugins;