Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

feat(agent): add project-aware slash skills

Rahman5b8b18f326c0
diff --git a/bin/mso b/bin/mso
index 54857ae2..bfafca13 100755
--- a/bin/mso
+++ b/bin/mso
@@ -126,7 +126,7 @@
# Docs: https://github.com/rahmanef63/mso
set -euo pipefail
-VERSION="1.5.0"
+VERSION="1.5.1"
ROOT="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
die() { echo "mso: $*" >&2; exit 1; }
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 1c83df16..0ea8c880 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Added**
+- `agent` add project-aware slash skills
- `agent` persist terminal and MCP sessions
- `mcp` render live workflow progress in ChatGPT
- `cli` add MSO folder ASCII icon
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 387a372e..61feace4 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -18,9 +18,11 @@ What changed:
- configurable remote Dokploy endpoints use the existing DNS-pinned safe-provider transport; remote HTTP is refused, redirects are refused, and private/link-local/metadata resolution is blocked. Literal loopback remains the explicit same-host exception;
- Cloudflare automation never performs a bulk zone PUT, refuses duplicate/conflicting rows, PATCHes one existing record or POSTs one new record, and defaults proxying off. Hostinger DNS now uses the provider's scoped RR-set replacement semantics (`overwrite:true` with one `name + type` row), so unrelated zone rows never enter the PUT payload; ambiguity/conflicts remain refused and the mutation stays approval-gated;
- official `mso-project-deploy` skill documents workflow start → inspect → provider doctor → bounded deployment/DNS operations → runtime/HTTPS verification → finish/cancel;
-- CLI version for this interaction milestone is **1.5.0**. `docs/INFRASTRUCTURE-PROVIDERS.md`, architecture/install/MCP/ChatGPT connector docs, generated CLI reference and slice catalog are synchronized.
+- MSO Agent slash skills are now executable: `/<skill>` selects a trusted global/current-project skill for the next message, `/<skill> <prompt>` runs immediately, `/skill <exact-id>` resolves cross-project ambiguity, and Tab completion only offers skills valid in the current scope; project skills follow the terminal working directory while untrusted instructions remain withheld;
+- terminal title art now uses a stable two-space gutter so the blue MSO icon is not flush against the terminal edge;
+- CLI version for this interaction milestone is **1.5.1**. `docs/INFRASTRUCTURE-PROVIDERS.md`, architecture/install/MCP/ChatGPT connector docs, generated CLI reference and slice catalog are synchronized.
-Verification added specifically for this slice covers provider-store symlink/permission/secret behavior, Cloudflare one-record semantics, Hostinger exact RR-set payloads, Owner-only agent/provider routes, exact-payload terminal approval, CLI onboarding/update fixtures, MCP parity/rate limits, and documentation/toolset markers. The final full repository gate passes with **250 test files / 1,903 passing tests** (1 expected fail, 4 skipped), typecheck and dependency audit green, zero value cycles, and zero lint errors (three pre-existing max-lines warnings remain). A targeted Codex Security pass first found two Medium issues in the new infrastructure surface — whole-response buffering before its nominal 1 MiB cap and a stale full-zone Hostinger PUT. Both were fixed; the final infrastructure re-scan completed **1/1 component with 0 findings**. A separate terminal-agent scan found one Medium issue where a truncated approval preview could conceal mutation fields. The terminal now renders the complete canonical tool name + nested input, refuses approval payloads above 32 KiB, removes session-wide mutation grants, and binds the approval SHA-256 to the exact payload that the server independently re-hashes before dispatch; the final terminal-agent re-scan completed **1/1 component with 0 findings**. A parallel-suite-only lifecycle harness race was also removed by holding the fixture lock until the assertion explicitly releases it; the lifecycle file then passed 5 consecutive runs (40/40 checks). The first production handoff also exposed a release-verification false negative: the system unit can spend close to its 90 s `TimeoutStopSec` draining the old npm/Next control group, while the finalizer only waited 40 s for a new MainPID. Production still reached the gated release SHA, and the verifier now uses a bounded 120 s default restart budget (override constrained to 30–300 s) so a valid slow systemd restart is not reported as rollback. Live Dokploy/Cloudflare/Hostinger API success is intentionally not claimed until an owner supplies credentials and `mso provider doctor` checks that provider.
+Verification added specifically for this slice covers provider-store symlink/permission/secret behavior, Cloudflare one-record semantics, Hostinger exact RR-set payloads, Owner-only agent/provider routes, exact-payload terminal approval, CLI onboarding/update fixtures, MCP parity/rate limits, and documentation/toolset markers. The final full repository gate passes with **252 test files / 1,911 passing tests** (1 expected fail, 4 skipped), typecheck and dependency audit green, zero value cycles, and zero lint errors (six pre-existing max-lines warnings remain). A targeted Codex Security pass first found two Medium issues in the new infrastructure surface — whole-response buffering before its nominal 1 MiB cap and a stale full-zone Hostinger PUT. Both were fixed; the final infrastructure re-scan completed **1/1 component with 0 findings**. A separate terminal-agent scan found one Medium issue where a truncated approval preview could conceal mutation fields. The terminal now renders the complete canonical tool name + nested input, refuses approval payloads above 32 KiB, removes session-wide mutation grants, and binds the approval SHA-256 to the exact payload that the server independently re-hashes before dispatch; the final terminal-agent re-scan completed **1/1 component with 0 findings**. A parallel-suite-only lifecycle harness race was also removed by holding the fixture lock until the assertion explicitly releases it; the lifecycle file then passed 5 consecutive runs (40/40 checks). The first production handoff also exposed a release-verification false negative: the system unit can spend close to its 90 s `TimeoutStopSec` draining the old npm/Next control group, while the finalizer only waited 40 s for a new MainPID. Production still reached the gated release SHA, and the verifier now uses a bounded 120 s default restart budget (override constrained to 30–300 s) so a valid slow systemd restart is not reported as rollback. Live Dokploy/Cloudflare/Hostinger API success is intentionally not claimed until an owner supplies credentials and `mso provider doctor` checks that provider.
## 2026-08-31 — Login-origin diagnosis + `mso doctor --fix` + runtime hardening (SHIPPED)
diff --git a/scripts/mso-agent-contract.test.ts b/scripts/mso-agent-contract.test.ts
index 742e35a5..d3385ffa 100644
--- a/scripts/mso-agent-contract.test.ts
+++ b/scripts/mso-agent-contract.test.ts
@@ -12,8 +12,11 @@ describe("MSO terminal agent contract", () => {
expect(src).toContain("███╗ ███╗███████╗ ██████╗");
expect(src).toContain("── MSO Agent ──");
expect(src).toContain("MSO_TITLE_ART");
+ expect(src).toContain("MSO_TITLE_GUTTER");
expect(src).not.toContain("╭──┘ ╰────────╮");
- for (const command of ["/model", "/setup", "/providers", "/provider", "/doctor", "/tools", "/skills", "/session", "/sessions", "/resume", "/clear", "/exit"]) expect(src).toContain(command);
+ for (const command of ["/model", "/setup", "/providers", "/provider", "/doctor", "/tools", "/skills", "/skill", "/<skill>", "/session", "/sessions", "/resume", "/clear", "/exit"]) expect(src).toContain(command);
+ expect(src).toContain("selected for the next message");
+ expect(src).toContain("completer:");
});
it("keeps infrastructure secrets out of model messages and binds write/exec approval to the exact full payload", () => {
diff --git a/scripts/mso-agent-runtime.mjs b/scripts/mso-agent-runtime.mjs
index 5651cb54..21fc01b7 100644
--- a/scripts/mso-agent-runtime.mjs
+++ b/scripts/mso-agent-runtime.mjs
@@ -69,13 +69,18 @@ export function printBanner(s, agentSession) {
return printAgentBanner(s, agentSession, { base: BASE, version: VERSION });
}
-function sessionSystem(agentSession) {
+function sessionSystem(agentSession, skillContext = null) {
const snapshot = agentSession?.memorySnapshot || {};
const user = fit(snapshot.user || "", 12000);
const memory = fit(snapshot.memory || "", 12000);
+ const cwd = process.cwd();
+ const skillInstructions = skillContext?.content ? String(skillContext.content).slice(0, 24000) : "";
+ const skillProject = skillContext?.project?.path ? ` Project context: ${skillContext.project.name || skillContext.project.id} at ${skillContext.project.path}.` : "";
return [
"You are MSO Agent, the interactive terminal setup and operations agent for Manef Shell OS on the user's own server.",
agentSession?.id ? `Current durable MSO session id: ${agentSession.id}.` : "",
+ `Terminal working directory: ${cwd}. Treat a project containing this directory as the current project context unless the user explicitly selects another project.`,
+ skillInstructions ? `The user explicitly selected skill ${skillContext.id || skillContext.name} for this turn.${skillProject} Follow these instructions for this turn:\n<SKILL.md>\n${skillInstructions}\n</SKILL.md>` : "",
"Use the provided tools to do real work instead of only describing commands. Prefer bounded tools over exec_run.",
"For setup, first inspect infrastructure with infra_providers_list and live-check configured providers with infra_provider_doctor.",
"Dokploy, Cloudflare, and Hostinger credentials are entered interactively with `mso provider set <id>` and are never exposed to you; never ask the user to paste API tokens into chat or shell commands.",
@@ -93,11 +98,11 @@ function toolForModel(tool) {
return { name: tool.name, description: tool.description, input_schema: tool.inputSchema || { type: "object", properties: {} } };
}
-export async function streamTurn(messages, tools, agentSession) {
+export async function streamTurn(messages, tools, agentSession, skillContext = null) {
const res = await fetch(`${BASE}/api/assistant`, {
method: "POST",
headers: { origin: ORIGIN, cookie: cookieHeader(), "content-type": "application/json" },
- body: JSON.stringify({ messages, tools: tools.map(toolForModel), system: sessionSystem(agentSession) }),
+ body: JSON.stringify({ messages, tools: tools.map(toolForModel), system: sessionSystem(agentSession, skillContext) }),
});
if (!res.ok || !res.body) {
let body = {}; try { body = await res.json(); } catch {}
diff --git a/scripts/mso-agent-skills.mjs b/scripts/mso-agent-skills.mjs
new file mode 100644
index 00000000..7b462720
--- /dev/null
+++ b/scripts/mso-agent-skills.mjs
@@ -0,0 +1,135 @@
+import path from "node:path";
+import process from "node:process";
+
+function skillRows(skillsData) {
+ return Array.isArray(skillsData?.skills) ? skillsData.skills : [];
+}
+
+function inside(root, cwd) {
+ if (!root) return false;
+ const rel = path.relative(path.resolve(root), path.resolve(cwd));
+ return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
+}
+
+export function currentSkillProject(skillsData, cwd = process.cwd()) {
+ const projects = new Map();
+ for (const skill of skillRows(skillsData)) {
+ const project = skill?.project;
+ if (!project?.id || !project?.path || !inside(project.path, cwd)) continue;
+ projects.set(project.id, project);
+ }
+ return [...projects.values()].sort((a, b) => String(b.path).length - String(a.path).length)[0] || null;
+}
+
+export function resolveSlashSkill(skillsData, requested, cwd = process.cwd()) {
+ const raw = String(requested || "").replace(/^\/+/, "").trim();
+ if (!raw) return { skill: null, ambiguous: [] };
+ const rows = skillRows(skillsData);
+
+ // Exact catalog ids contain a slash for project skills. /skill <exact-id> is
+ // the explicit escape hatch when the same skill name exists in many projects.
+ if (raw.includes("/")) {
+ const exact = rows.find((skill) => String(skill.id) === raw) || null;
+ return { skill: exact, ambiguous: [] };
+ }
+
+ const named = rows.filter((skill) => String(skill.name || skill.id) === raw);
+ const current = currentSkillProject(skillsData, cwd);
+ if (current) {
+ const local = named.filter((skill) => skill.project?.id === current.id);
+ if (local.length === 1) return { skill: local[0], ambiguous: [], currentProject: current };
+ if (local.length > 1) return { skill: null, ambiguous: local, currentProject: current };
+ }
+
+ const globals = named.filter((skill) => !skill.project);
+ if (globals.length === 1) return { skill: globals[0], ambiguous: [], currentProject: current };
+ if (globals.length > 1) return { skill: null, ambiguous: globals, currentProject: current };
+
+ // Never silently import a project skill from some other repository just because
+ // its name happens to be globally unique. Require an exact catalog id instead.
+ return { skill: null, ambiguous: named, currentProject: current };
+}
+
+export function slashSkillNames(skillsData, cwd = process.cwd()) {
+ const names = [...new Set(skillRows(skillsData)
+ .filter((skill) => skill?.trust !== "untrusted")
+ .map((skill) => String(skill.name || "").trim())
+ .filter(Boolean))];
+ return names.filter((name) => Boolean(resolveSlashSkill(skillsData, name, cwd).skill)).sort();
+}
+
+export async function loadSlashSkill(api, sessionId, skill) {
+ if (!skill?.id) throw new Error("skill has no catalog id");
+ const out = await api("/api/v1/agent-tools", {
+ method: "POST",
+ body: JSON.stringify({ name: "skills_read", input: { name: skill.id }, sessionId }),
+ });
+ if (!out?.ok) throw new Error(String(out?.result || `could not read skill ${skill.id}`));
+ let data;
+ try { data = JSON.parse(String(out.result || "{}")); }
+ catch { throw new Error(`skill ${skill.id} returned an invalid read payload`); }
+ if (data.instructionsWithheld) {
+ throw new Error(`/${skill.name || skill.id} is not executable yet (${data.reason || `trust=${data.trust || skill.trust || "untrusted"}`})`);
+ }
+ if (!data.content) throw new Error(`skill ${skill.id} has no readable instructions`);
+ return {
+ id: String(data.id || skill.id),
+ name: String(data.name || skill.name || skill.id),
+ description: String(data.description || skill.description || ""),
+ trust: String(data.trust || skill.trust || ""),
+ project: data.project || skill.project || null,
+ content: String(data.content),
+ };
+}
+
+
+export function printSkillChoices(rows, C) {
+ if (!rows?.length) return;
+ console.log(`${C.warn}skill name is project-specific or ambiguous; choose one exact id:${C.reset}`);
+ for (const skill of rows.slice(0, 20)) {
+ const project = skill.project?.name ? ` · ${skill.project.name}` : " · global";
+ console.log(` /skill ${skill.id}${project}`);
+ }
+}
+
+export function printSkills(session, C, query = "", cwd = process.cwd()) {
+ const all = skillRows(session.state.skills);
+ const q = query.trim().toLowerCase();
+ const current = currentSkillProject(session.state.skills, cwd);
+ const scoped = all.filter((skill) => !skill.project || (current && skill.project?.id === current.id));
+ let rows = q
+ ? all.filter((skill) => `${skill.name || ""} ${skill.id || ""} ${skill.description || ""}`.toLowerCase().includes(q))
+ : scoped;
+ rows = rows.slice().sort((a, b) => {
+ const ap = current && a.project?.id === current.id ? 0 : a.project ? 2 : 1;
+ const bp = current && b.project?.id === current.id ? 0 : b.project ? 2 : 1;
+ return ap - bp || String(a.name || a.id).localeCompare(String(b.name || b.id));
+ });
+ if (current) console.log(`${C.bold}Current project skills:${C.reset} ${current.name} · ${current.path}`);
+ const visible = rows.slice(0, 80);
+ for (const skill of visible) {
+ const scope = skill.project?.name ? `project:${skill.project.name}` : "global";
+ const trust = skill.trust === "untrusted" ? `${C.warn}untrusted${C.reset}` : skill.trust || "";
+ const description = skill.description
+ ? ` — ${String(skill.description).replace(/[\r\n\t]+/g, " ").slice(0, 120)}`
+ : "";
+ console.log(` ${C.blue}/${skill.name}${C.reset} ${C.dim}${scope}${trust ? ` · ${trust}` : ""}${C.reset}${description}`);
+ }
+ if (rows.length > visible.length) console.log(`${C.dim}… ${rows.length - visible.length} more; refine with /skills <query>${C.reset}`);
+ console.log(`${C.dim}Use /<skill> [prompt], or /skill <exact-id> [prompt] for an ambiguous project skill.${C.reset}`);
+}
+
+export const BUILTIN_SLASH = [
+ "/help", "/session", "/sessions", "/resume", "/model", "/setup", "/providers", "/provider",
+ "/doctor", "/tools", "/skills", "/skill", "/clear", "/exit",
+];
+
+export function slashCompleter(line, session) {
+ const text = String(line || "");
+ const trimmed = text.trimStart();
+ if (!trimmed.startsWith("/") || /\s/.test(trimmed)) return [[], text];
+ const dynamic = slashSkillNames(session.state.skills).map((name) => `/${name}`);
+ const all = [...new Set([...BUILTIN_SLASH, ...dynamic])];
+ const hits = all.filter((item) => item.startsWith(trimmed)).sort();
+ return [hits.length ? hits : all, trimmed];
+}
diff --git a/scripts/mso-agent-skills.test.ts b/scripts/mso-agent-skills.test.ts
new file mode 100644
index 00000000..f88e761a
--- /dev/null
+++ b/scripts/mso-agent-skills.test.ts
@@ -0,0 +1,34 @@
+import { describe, expect, it } from "vitest";
+import { currentSkillProject, resolveSlashSkill, slashSkillNames } from "./mso-agent-skills.mjs";
+
+const globalSkill = { id: "design", name: "design", trust: "local", source: "operator" };
+const projectA = { id: "root/a/design", name: "design", trust: "local", source: "project", project: { id: "root/a", name: "a", path: "/srv/projects/a" } };
+const projectB = { id: "root/b/design", name: "design", trust: "local", source: "project", project: { id: "root/b", name: "b", path: "/srv/projects/b" } };
+const projectOnly = { id: "root/a/ship-check", name: "ship-check", trust: "local", source: "project", project: { id: "root/a", name: "a", path: "/srv/projects/a" } };
+const untrusted = { id: "random", name: "random", trust: "untrusted", source: "agents" };
+const skills = { skills: [globalSkill, projectA, projectB, projectOnly, untrusted] };
+
+describe("MSO Agent slash skill resolution", () => {
+ it("prefers the current project's skill over a same-name global skill", () => {
+ expect(currentSkillProject(skills, "/srv/projects/a/src")?.id).toBe("root/a");
+ expect(resolveSlashSkill(skills, "design", "/srv/projects/a/src").skill?.id).toBe("root/a/design");
+ });
+
+ it("uses the global skill outside a project and never leaks into another project implicitly", () => {
+ expect(resolveSlashSkill(skills, "design", "/home/rahman").skill?.id).toBe("design");
+ const result = resolveSlashSkill(skills, "ship-check", "/home/rahman");
+ expect(result.skill).toBeNull();
+ expect(result.ambiguous.map((row: { id: string }) => row.id)).toEqual(["root/a/ship-check"]);
+ });
+
+ it("accepts an exact project catalog id as the explicit cross-project escape hatch", () => {
+ expect(resolveSlashSkill(skills, "root/b/design", "/srv/projects/a").skill?.id).toBe("root/b/design");
+ });
+
+ it("offers only trusted skills that resolve in the current scope for tab completion", () => {
+ expect(slashSkillNames(skills, "/home/rahman")).toContain("design");
+ expect(slashSkillNames(skills, "/home/rahman")).not.toContain("ship-check");
+ expect(slashSkillNames(skills, "/srv/projects/a")).toContain("ship-check");
+ expect(slashSkillNames(skills, "/srv/projects/a")).not.toContain("random");
+ });
+});
diff --git a/scripts/mso-agent-ui.mjs b/scripts/mso-agent-ui.mjs
index 85021c00..7ba6ae2d 100644
--- a/scripts/mso-agent-ui.mjs
+++ b/scripts/mso-agent-ui.mjs
@@ -10,6 +10,8 @@ C.a = C.blue;
C.b = C.blue;
C.c = C.cyan;
+export const MSO_TITLE_GUTTER = " ";
+
export const MSO_TITLE_ART = [
"████████████",
" ██ ██",
@@ -94,9 +96,9 @@ function panelTitle(title, inner) {
export function printAgentBanner(s, agentSession, { base, version }) {
const totalWidth = terminalWidth();
const inner = totalWidth - 2;
- const titleArtWidth = Math.max(...MSO_TITLE_ART.map(width));
+ const titleArtWidth = width(MSO_TITLE_GUTTER) + Math.max(...MSO_TITLE_ART.map(width));
if (totalWidth >= titleArtWidth) {
- for (const line of MSO_TITLE_ART) console.log(`${C.blue}${C.bold}${line}${C.reset}`);
+ for (const line of MSO_TITLE_ART) console.log(`${C.blue}${C.bold}${MSO_TITLE_GUTTER}${line}${C.reset}`);
} else console.log(`${C.blue}${C.bold}── MSO Agent ──${C.reset}`);
console.log();
@@ -139,7 +141,7 @@ export function printAgentBanner(s, agentSession, { base, version }) {
for (const line of lines) console.log(panelSingle(line, inner));
}
console.log(`└${rule("─", inner)}┘`);
- console.log(`${C.dim}${s.tools.length} tools · ${countSkills(s.skills)} skills · /sessions · /help for commands${C.reset}`);
+ console.log(`${C.dim}${s.tools.length} tools · ${countSkills(s.skills)} skills · /skills · /<skill> · /help${C.reset}`);
console.log();
console.log(`${C.bold}Welcome to MSO Agent!${C.reset} Type your message or /help for commands.`);
}
diff --git a/scripts/mso-agent.mjs b/scripts/mso-agent.mjs
index 876d1d92..92652997 100644
--- a/scripts/mso-agent.mjs
+++ b/scripts/mso-agent.mjs
@@ -3,6 +3,7 @@ import { spawnSync } from "node:child_process";
import readline from "node:readline/promises";
import process from "node:process";
import { canonicalAgentApproval } from "../lib/agent/approval.mjs";
+import { loadSlashSkill, printSkillChoices, printSkills, resolveSlashSkill, slashCompleter } from "./mso-agent-skills.mjs";
import {
BASE, CLI, C, api, createCliSession, listCliSessions, loadCliSession,
printBanner, saveCliSession, state, streamTurn,
@@ -46,9 +47,9 @@ async function executeTool(rl, tool, call, agentSession) {
}
}
-async function agentRound(rl, session) {
+async function agentRound(rl, session, skillContext = null) {
for (let turn = 0; turn < 10; turn++) {
- const result = await streamTurn(session.history, session.state.tools, session.agentSession);
+ const result = await streamTurn(session.history, session.state.tools, session.agentSession, skillContext);
session.history.push({ role: "assistant", text: result.text, toolUses: result.toolUses });
if (!result.toolUses.length) return;
const results = [];
@@ -94,10 +95,31 @@ async function resumeInto(session, id) {
if (!loaded || loaded.source !== "cli") throw new Error("session is not a CLI MSO Agent session");
session.agentSession = loaded;
session.history = Array.isArray(loaded.history) ? loaded.history.slice(-48) : [];
+ session.pendingSkill = null;
console.log(`${C.c}resumed ${loaded.id}${C.reset} · ${loaded.title || "MSO Agent session"}`);
}
-async function slash(line, session) {
+async function selectSlashSkill(rl, session, requested, prompt = "") {
+ const resolved = resolveSlashSkill(session.state.skills, requested, process.cwd());
+ if (!resolved.skill) {
+ printSkillChoices(resolved.ambiguous, C);
+ return resolved.ambiguous?.length ? "handled" : "unknown";
+ }
+ const loaded = await loadSlashSkill(api, session.agentSession.id, resolved.skill);
+ const scope = loaded.project?.name ? `project ${loaded.project.name}` : "global";
+ if (!prompt.trim()) {
+ session.pendingSkill = loaded;
+ console.log(`${C.c}✓ /${loaded.name}${C.reset} selected for the next message · ${scope}`);
+ return "handled";
+ }
+ session.history.push({ role: "user", text: prompt.trim() });
+ if (session.history.length > 48) session.history.splice(0, session.history.length - 48);
+ await agentRound(rl, session, loaded);
+ await persist(session);
+ return "handled";
+}
+
+async function slash(rl, line, session) {
const [cmd, ...args] = line.trim().split(/\s+/);
switch (cmd) {
case "/help":
@@ -111,7 +133,9 @@ async function slash(line, session) {
" /provider <id> configure dokploy|cloudflare|hostinger",
" /doctor run mso doctor",
" /tools list agent tools",
- " /skills list available skills",
+ " /skills [query] browse available slash skills",
+ " /skill <id> [prompt] select exact skill id (ambiguity escape hatch)",
+ " /<skill> [prompt] select for next message, or run prompt now",
" /clear clear this session conversation",
" /exit quit",
].join("\n")); return "handled";
@@ -129,10 +153,11 @@ async function slash(line, session) {
case "/provider": if (!args[0]) console.log("usage: /provider dokploy|cloudflare|hostinger"); else runCli(["provider", "set", args[0]]); session.state = await state(); return "refresh";
case "/doctor": runCli(["doctor"]); return "handled";
case "/tools": for (const tool of session.state.tools) console.log(` ${String(tool.scope).padEnd(5)} ${tool.name}`); return "handled";
- case "/skills": for (const skill of session.state.skills?.skills ?? []) console.log(` ${skill.id}${skill.description ? ` — ${skill.description}` : ""}`); return "handled";
- case "/clear": session.history = []; await persist(session); console.log("conversation cleared."); return "handled";
+ case "/skills": printSkills(session, C, args.join(" ")); return "handled";
+ case "/skill": if (!args[0]) { console.log("usage: /skill <name-or-exact-id> [prompt]"); return "handled"; } return selectSlashSkill(rl, session, args[0], args.slice(1).join(" "));
+ case "/clear": session.history = []; session.pendingSkill = null; await persist(session); console.log("conversation cleared."); return "handled";
case "/exit": return "exit";
- default: return "unknown";
+ default: return selectSlashSkill(rl, session, cmd.slice(1), args.join(" "));
}
}
@@ -156,12 +181,16 @@ async function main() {
]);
if (!agentSession || agentSession.source !== "cli") throw new Error("could not establish a CLI MSO Agent session");
printBanner(s, agentSession);
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true, historySize: 100 });
const session = {
state: s,
agentSession,
history: Array.isArray(agentSession.history) ? agentSession.history.slice(-48) : [],
+ pendingSkill: null,
};
+ const rl = readline.createInterface({
+ input: process.stdin, output: process.stdout, terminal: true, historySize: 100,
+ completer: (line) => slashCompleter(line, session),
+ });
process.on("SIGINT", () => { console.log("\nUse /exit to quit."); });
try {
while (true) {
@@ -171,7 +200,7 @@ async function main() {
if (!line) continue;
if (line.startsWith("/")) {
try {
- const result = await slash(line, session);
+ const result = await slash(rl, line, session);
if (result === "exit") break;
if (result === "unknown") console.log("unknown command; /help lists commands.");
} catch (error) {
@@ -182,7 +211,9 @@ async function main() {
session.history.push({ role: "user", text: line });
if (session.history.length > 48) session.history.splice(0, session.history.length - 48);
try {
- await agentRound(rl, session);
+ const skillContext = session.pendingSkill;
+ session.pendingSkill = null;
+ await agentRound(rl, session, skillContext);
await persist(session);
} catch (error) {
console.error(`${C.err}agent error: ${error instanceof Error ? error.message : String(error)}${C.reset}`);