@forge/cli
14.2.015.0.0-next.23
out/command-line/controller/skills-controller.js+
out/command-line/controller/skills-controller.jsNew file+65
Index: package/out/command-line/controller/skills-controller.js
===================================================================
--- package/out/command-line/controller/skills-controller.js
+++ package/out/command-line/controller/skills-controller.js
@@ -0,0 +1,65 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.SkillsController = void 0;
+const cli_shared_1 = require("@forge/cli-shared");
+const skills_agents_1 = require("../../service/skills-agents");
+class SkillsController {
+ view;
+ service;
+ constructor(view, service) {
+ this.view = view;
+ this.service = service;
+ }
+ async install(options) {
+ const scope = (0, skills_agents_1.parseSkillsScope)(options.scope);
+ const agents = this.parseAgents(options) ?? (await this.selectDetectedAgents());
+ const { skills, mcp, dryRun, json } = options;
+ const results = await this.view.progress(json, cli_shared_1.Text.skills.install.progress, () => this.service.install(agents, { scope, skills, mcp, dryRun }));
+ this.view.installResults(results, { dryRun, json });
+ return outcome(results, scope, dryRun);
+ }
+ status({ json }) {
+ this.view.status(this.service.status(), json);
+ }
+ shouldSuggestInstall() {
+ return this.service.shouldSuggestInstall();
+ }
+ async remove(options) {
+ const scope = (0, skills_agents_1.parseSkillsScope)(options.scope);
+ let agents = this.parseAgents(options);
+ if (!agents) {
+ const installed = this.service.installedAgents(scope);
+ if (!installed.length) {
+ this.view.nothingToRemove(scope, options.json);
+ return outcome([], scope, false);
+ }
+ agents = await this.select(cli_shared_1.Text.skills.remove.prompt, installed, installed);
+ }
+ if (!options.nonInteractive && !(await this.view.confirmRemoval(agents, scope)))
+ return outcome([], scope, false);
+ const results = this.service.remove(agents, scope);
+ this.view.removeResults(results, options.json);
+ return outcome(results, scope, false);
+ }
+ parseAgents({ agents }) {
+ return agents && [...new Set(agents.map(skills_agents_1.parseSkillsAgent))];
+ }
+ async selectDetectedAgents() {
+ const detected = this.service.detectAgents();
+ if (!detected.length)
+ throw new cli_shared_1.ValidationError(cli_shared_1.Text.skills.errors.noAgentsDetected);
+ return this.select(cli_shared_1.Text.skills.install.prompt, skills_agents_1.SKILLS_AGENTS, detected);
+ }
+ async select(prompt, choices, preselected) {
+ const selected = await this.view.selectAgents(prompt, choices, preselected);
+ if (!selected.length)
+ throw new cli_shared_1.ValidationError(cli_shared_1.Text.skills.errors.noAgentsSelected);
+ return selected;
+ }
+}
+exports.SkillsController = SkillsController;
+function outcome(results, scope, dryRun) {
+ const agentsFailed = results.filter((result) => result.error).length;
+ return { analytics: { agentsRequested: results.length, agentsFailed, scope, dryRun }, success: agentsFailed === 0 };
+}
+//# sourceMappingURL=skills-controller.js.map
\ No newline at end of file