@forge/cli
14.2.015.0.0-next.23
out/command-line/view/skills-view.js+
out/command-line/view/skills-view.jsNew file+85
Index: package/out/command-line/view/skills-view.js
===================================================================
--- package/out/command-line/view/skills-view.js
+++ package/out/command-line/view/skills-view.js
@@ -0,0 +1,85 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.SkillsView = void 0;
+const cli_shared_1 = require("@forge/cli-shared");
+const skills_agents_1 = require("../../service/skills-agents");
+class SkillsView {
+ ui;
+ constructor(ui) {
+ this.ui = ui;
+ }
+ progress(json, text, work) {
+ return json ? work() : this.ui.displayTemporaryMessage(work, text, { animateEllipsis: true });
+ }
+ selectAgents(prompt, choices, preselected) {
+ return this.ui.promptForMultiple(prompt, [...choices], { preselected, format: skills_agents_1.agentName });
+ }
+ confirmRemoval(agents, scope) {
+ return this.ui.confirm(cli_shared_1.Text.skills.remove.confirm(agents.map(skills_agents_1.agentName).join(', '), scope));
+ }
+ installResults(results, { dryRun, json }) {
+ if (json)
+ return this.json({ dryRun, results });
+ if (dryRun)
+ this.ui.info(cli_shared_1.Text.skills.install.dryRun);
+ for (const result of results) {
+ if (this.failed(result))
+ continue;
+ const message = dryRun ? cli_shared_1.Text.skills.install.planned : cli_shared_1.Text.skills.install.done;
+ this.ui.info(message((0, skills_agents_1.agentName)(result.agent), result.skills.length, result.skillsPath, mcpSummary(result)));
+ }
+ if (!dryRun && results.some((result) => !result.error))
+ this.ui.info(cli_shared_1.Text.skills.install.restart);
+ }
+ status(statuses, json) {
+ if (json)
+ return this.json({ results: statuses });
+ this.ui.table(Object.entries(cli_shared_1.Text.skills.status.columns), skills_agents_1.SKILLS_AGENTS.map((agent) => {
+ const rows = statuses.filter((status) => status.agent === agent);
+ const scopes = (installed) => rows
+ .filter(installed)
+ .map((status) => status.scope)
+ .join(', ') || cli_shared_1.Text.skills.status.none;
+ return {
+ agent: (0, skills_agents_1.agentName)(agent),
+ skills: scopes((status) => status.skills.length > 0),
+ mcp: scopes((status) => status.mcpConfigured)
+ };
+ }));
+ }
+ removeResults(results, json) {
+ if (json)
+ return this.json({ results });
+ for (const result of results) {
+ if (this.failed(result))
+ continue;
+ const name = (0, skills_agents_1.agentName)(result.agent);
+ const removed = result.skills.length > 0 || result.mcp?.some((change) => change.action === 'removed');
+ this.ui.info(removed ? cli_shared_1.Text.skills.remove.done(name) : cli_shared_1.Text.skills.remove.notFound(name, result.scope));
+ if (result.keptSkills?.length)
+ this.ui.info(cli_shared_1.Text.skills.remove.kept(name, result.keptSkills.length));
+ }
+ }
+ nothingToRemove(scope, json) {
+ if (json)
+ this.json({ results: [] });
+ else
+ this.ui.info(cli_shared_1.Text.skills.remove.nothingInstalled(scope));
+ }
+ failed(result) {
+ if (result.error)
+ this.ui.error(new Error(cli_shared_1.Text.skills.agentFailed((0, skills_agents_1.agentName)(result.agent), result.error)));
+ return result.error !== undefined;
+ }
+ json(data) {
+ this.ui.info(JSON.stringify(data, null, 2));
+ }
+}
+exports.SkillsView = SkillsView;
+function mcpSummary({ mcp, scope }) {
+ if (!mcp)
+ return cli_shared_1.Text.skills.mcpSkipped;
+ const [change] = mcp;
+ return change ? cli_shared_1.Text.skills.mcpChange(change.action, change.path) : cli_shared_1.Text.skills.mcpUnsupported(scope);
+}
+//# sourceMappingURL=skills-view.js.map
\ No newline at end of file