UNPKG

@2501-ai/cli

Version:

[![npm version](https://img.shields.io/npm/v/@2501-ai/cli.svg)](https://www.npmjs.com/package/@2501-ai/cli) [![HumanEval Score](https://img.shields.io/badge/HumanEval-96.95%25-brightgreen.svg)](https://www.2501.ai/research/full-humaneval-benchmark) [![Lic

62 lines (61 loc) 2.68 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } 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;