Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ lib/
session-reader.ts session .jsonl parsing + path cache + buildSessionContext
session-resume.ts running-session list for auto-resume after a restart
web-settings.ts omp-web server settings (~/.omp/agent/omp-web-settings.json)
skills-service.ts pure-Node skill discovery mirroring omp's providers
skills-service.ts skill listing via `omp skill list --json`; pure-Node replica scan as fallback
tool-presets.ts PRESET_NONE/DEFAULT/FULL + getToolNamesForPreset()
types.ts shared TypeScript types
normalize.ts normalizeToolCalls() — field name mismatch between file format and our types
Expand Down Expand Up @@ -362,8 +362,9 @@ handled or safely ignored.

### Plugins and skills
- `/api/plugins` shells out to the user's `omp plugin` CLI (`list/install/uninstall/enable/disable/upgrade`, `--json` where available) — never the Bun-only SDK.
- `/api/skills` uses `lib/skills-service.ts`, a pure-Node scanner mirroring omp's discovery order: project `.omp/skills` (walk-up), `~/.omp/agent/skills`, then the `.claude` / `.agent(s)` / `.codex` / `.github` compat dirs and managed skills.
- Skill toggling edits only the `disable-model-invocation` frontmatter key on the target `SKILL.md`; keep that surgical so user formatting survives.
- `/api/skills` lists through `lib/skills-service.ts`, which execs `omp skill list --json` with the project as the process cwd (omp ≥ 18.3.3; never pass the directory as an argument — Windows `.cmd` launchers run through `cmd.exe`, which would interpret `&` in it). That is the same discovery sessions use, including `namespace/name` collision aliases and plugin/registry/custom-directory skills. A pure-Node replica scan (project `.omp/skills` walk-up, `~/.omp/agent/skills`, the `.claude` / `.agent(s)` / `.codex` / `.github` compat dirs, managed skills) is only the fallback for older binaries and failed or malformed output. A failed run is negative-cached per binary fingerprint **and cwd** (5 min) so old installs don't spawn per request while one broken project config cannot degrade the others. Listing runs omp's normal startup, so it has omp's side effects (e.g. omp renames an unparseable `config.yml` aside, as a session would).
- Skill toggling edits only the `disable-model-invocation` frontmatter key on the target `SKILL.md`; keep that surgical so user formatting survives. omp reports it back as `hide` (it reads `hide`/`disableModelInvocation`/`disable-model-invocation`). Frontmatter is omp's only per-skill "hide from model, keep `/skill:`" knob; `disabledExtensions: ["skill:<name>"]` removes the skill entirely.
- Only user-owned skills are togglable: `getSkillToggleRoots()` (allowed file roots — workspaces the user opened — plus replica scan roots) is the single allowlist for both PATCH and the `togglable` flag GET returns; it is `main`'s pre-CLI allowlist, unchanged. Skills omp lists from anywhere else (the plugin cache, registry installs, custom directories outside a workspace) render a disabled toggle — their files belong to an installer and an update would discard the edit. Never widen PATCH to whatever omp lists.
- `/api/skills/install` shells through `npx skills add ... --agent universal`, which installs into the ecosystem-standard `.agents/skills` dirs omp reads; project installs run with the selected cwd.

### Update notifications (`/api/omp-update`, `/api/app-update`)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f

### Fixes & Improvements

- The Skills page lists exactly what omp resolves, through `omp skill list --json` (omp 18.3.3 or later): plugin, custom-directory and registry skills appear, and colliding names show as `namespace/name`. Skills that live outside omp-web's skill folders, such as plugin installs, show a disabled toggle because an update would undo the edit. Older omp binaries keep the built-in scan.
- On phones, the top bar's **⋯** menu no longer repeats the session name already shown in the title, and its theme and language pickers open fully instead of being cut off at the bar's edge.
- Keep **Collapse input** available after expanding a long user message with **Show full input**, so the message can be collapsed again.
- Agent host tools (`open_url`, `notify`, `open_file`) no longer fail when you switch to another session mid-run. Any open omp-web tab now answers them, and a URL or file from a session you are not viewing opens only after you confirm it in a dialog.
Expand Down
23 changes: 11 additions & 12 deletions app/api/skills/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
import { existsSync, readFileSync, realpathSync, writeFileSync } from "fs";
import { basename } from "path";
import {
getSkillScanRootDirs,
getSkillToggleRoots,
loadSkillsWithInstallInfo,
parseSkillFrontmatter,
readDisableModelInvocation,
Expand All @@ -13,8 +13,9 @@ import { getAllowedFileRoots, isExistingFilePathAllowed } from "@/lib/file-acces
export const dynamic = "force-dynamic";

// GET /api/skills?cwd=<path>
// Scans the same skill roots omp discovers (~/.omp/agent/skills, project
// .omp/skills, and the .claude/.agents/.codex/.github compat directories).
// Lists what omp resolves (`omp skill list --json`), falling back to a scan
// of omp's skill roots on binaries that predate the command. Each skill
// carries `togglable`, the same check PATCH applies.
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
const cwd = searchParams.get("cwd");
Expand All @@ -41,15 +42,13 @@ export async function PATCH(req: Request) {
return NextResponse.json({ error: "not a SKILL.md file", code: "not_a_skill_file" }, { status: 400 });
}
if (!existsSync(filePath)) return NextResponse.json({ error: "file not found", code: "file_not_found" }, { status: 404 });
// Every root the scanner reads must be writable here, or skills in the
// compat dirs (~/.agents/skills — where the app's own global installs land,
// ~/.claude/skills, ~/.codex/skills, managed-skills) could be listed but
// never toggled. Session cwds cover the project-scope roots.
const allowedRoots = new Set(await getAllowedFileRoots());
// An optional cwd (already an allowed root) additionally covers the
// project walk-up roots discovery visits above the session directory.
const scanCwd = cwd && isExistingFilePathAllowed(cwd, allowedRoots) ? cwd : undefined;
for (const dir of getSkillScanRootDirs(scanCwd)) allowedRoots.add(dir);
// Every user-owned root the scanner reads must be writable here, or skills
// in the compat dirs (~/.agents/skills — where the app's own global
// installs land, ~/.claude/skills, ~/.codex/skills, managed-skills) could
// be listed but never toggled. Session cwds cover the project-scope roots;
// an optional cwd (already an allowed root) adds the project walk-up roots.
// Plugin/registry skills stay read-only (see getSkillToggleRoots).
const allowedRoots = await getSkillToggleRoots(cwd);
// Resolve symlinks once up front and authorize the resolved path: the
// read/write below then operate on the same resolved path, so a symlink
// swapped between the authorization check and the write cannot redirect
Expand Down
25 changes: 19 additions & 6 deletions components/SkillsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,27 @@ function shortVersion(version: string | undefined, t: (key: string) => string):
function Toggle({
enabled,
loading,
readOnly = false,
onToggle,
}: {
enabled: boolean;
loading: boolean;
readOnly?: boolean;
onToggle: () => void;
}) {
const { t } = useI18n();
return (
<button
type="button"
onClick={onToggle}
disabled={loading}
disabled={loading || readOnly}
aria-pressed={enabled}
title={
enabled
? t("skillsConfig.visibleInPrompt")
: t("skillsConfig.hiddenFromPrompt")
readOnly
? t("skillsConfig.toggleReadOnly")
: enabled
? t("skillsConfig.visibleInPrompt")
: t("skillsConfig.hiddenFromPrompt")
}
style={{
flexShrink: 0,
Expand All @@ -86,7 +90,8 @@ function Toggle({
borderRadius: 11,
border: "none",
padding: 0,
cursor: loading ? "wait" : "pointer",
cursor: readOnly ? "not-allowed" : loading ? "wait" : "pointer",
opacity: readOnly ? 0.5 : 1,
background: enabled ? "var(--accent-strong)" : "var(--border)",
position: "relative",
transition: "background var(--dur-med) var(--ease-out-warm)",
Expand Down Expand Up @@ -183,6 +188,7 @@ function SkillDetail({
<Toggle
enabled={enabled}
loading={toggling}
readOnly={skill.togglable === false}
onToggle={() => onToggle(skill)}
/>
{saveError && (
Expand All @@ -191,6 +197,12 @@ function SkillDetail({
</span>
)}
</div>
{skill.togglable === false && (
// Visible too: a disabled button's title is unreachable by keyboard and touch.
<p style={{ margin: 0, fontSize: 12, color: "var(--text-muted)" }}>
{t("skillsConfig.toggleReadOnly")}
</p>
)}

{skill.install?.skillsShUrl && (
<div style={{ display: "flex", flexDirection: "column", gap: 5 }}>
Expand Down Expand Up @@ -861,6 +873,7 @@ export function SkillsConfig({
body: JSON.stringify({
filePath: skill.filePath,
disableModelInvocation: next,
cwd,
}),
});
const d = (await res.json()) as { success?: boolean; error?: string };
Expand Down Expand Up @@ -889,7 +902,7 @@ export function SkillsConfig({
return n;
});
}
}, [t]);
}, [cwd, t]);

const selectedSkill = skills.find((s) => s.filePath === selected) ?? null;

Expand Down
3 changes: 3 additions & 0 deletions lib/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export interface SkillInfo {
scope?: string;
};
install?: SkillInstallInfo;
/** False when the SKILL.md sits outside the user-owned skill roots
* (plugin, registry, custom directory): listed, but not rewritable. */
togglable?: boolean;
}

export type PluginScope = "global" | "project";
Expand Down
15 changes: 11 additions & 4 deletions lib/file-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ export function isPathWithinRoots(target: string, roots: Set<string>): boolean {

export const isFilePathAllowed = isPathWithinRoots;

export function isExistingPathWithinRoots(target: string, roots: Set<string>): boolean {
let realTarget: string;
try { realTarget = stripLongPathPrefix(realpathSync(target)); } catch { return false; }
/** isExistingPathWithinRoots for many targets: realpaths the roots once. */
export function existingPathWithinRootsChecker(roots: Set<string>): (target: string) => boolean {
const realRoots = new Set<string>();
for (const root of roots) { try { realRoots.add(stripLongPathPrefix(realpathSync(root))); } catch { /* stale */ } }
return isPathWithinRoots(realTarget, realRoots);
return (target) => {
let realTarget: string;
try { realTarget = stripLongPathPrefix(realpathSync(target)); } catch { return false; }
return isPathWithinRoots(realTarget, realRoots);
};
}

export function isExistingPathWithinRoots(target: string, roots: Set<string>): boolean {
return existingPathWithinRootsChecker(roots)(target);
}

export function isExistingFilePathAllowed(target: string, allowedRoots: Set<string>): boolean {
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@
"skillsConfig.description": "Description",
"skillsConfig.dormant": "Dormant ({count})",
"skillsConfig.toggleErrorTitle": "Could not update skill",
"skillsConfig.toggleReadOnly": "This skill lives outside the skill folders omp-web edits (for example a plugin or package install), so it can't be toggled here",
"skillsConfig.toggleSuccessTitle": "Skill updated",
"skillsConfig.groupGlobalSkillsSh": "global / skills.sh",
"skillsConfig.groupProjectSkillsSh": "project / skills.sh",
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@
"skillsConfig.description": "説明",
"skillsConfig.dormant": "休止中({count})",
"skillsConfig.toggleErrorTitle": "スキルの更新に失敗しました",
"skillsConfig.toggleReadOnly": "このスキルは omp-web が編集するスキルフォルダーの外(プラグインやパッケージのインストール先など)にあるため、ここでは切り替えられません",
"skillsConfig.toggleSuccessTitle": "スキルを更新しました",
"skillsConfig.groupGlobalSkillsSh": "グローバル / skills.sh",
"skillsConfig.groupProjectSkillsSh": "プロジェクト / skills.sh",
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@
"skillsConfig.description": "描述",
"skillsConfig.dormant": "休眠({count})",
"skillsConfig.toggleErrorTitle": "更新技能失败",
"skillsConfig.toggleReadOnly": "此技能位于 omp-web 可编辑的技能文件夹之外(例如插件或软件包的安装位置),因此无法在此切换",
"skillsConfig.toggleSuccessTitle": "技能已更新",
"skillsConfig.groupGlobalSkillsSh": "全局 / skills.sh",
"skillsConfig.groupProjectSkillsSh": "项目 / skills.sh",
Expand Down
3 changes: 2 additions & 1 deletion lib/omp/omp-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export function getOmpVersion(): Promise<string | null> {
return versionProbe;
}

function versionFingerprint(bin: string): string | null {
/** Identity of the binary on disk; changes when it is replaced or updated. */
export function versionFingerprint(bin: string): string | null {
try {
const target = realpathSync(bin);
const stat = statSync(target, { bigint: true });
Expand Down
3 changes: 3 additions & 0 deletions lib/skill-lock.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ test("annotates only lock entries that exist in the matching Pi scope", () => {
makeSkill("find-skills", projectSkillPath, "project"),
makeSkill("manual", manualSkillPath, "user"),
makeSkill("tts", otherAgentSkillPath, "user"),
// omp's collision alias for the same installed skill.
makeSkill("agents/edge-tts", globalSkillPath, "user"),
],
{ cwd, agentDir, globalLockPath, projectLockPath },
);
Expand All @@ -108,6 +110,7 @@ test("annotates only lock entries that exist in the matching Pi scope", () => {
});
assert.equal(annotated[2].install, undefined);
assert.equal(annotated[3].install, undefined);
assert.deepEqual(annotated[4].install, annotated[0].install);
} finally {
rmSync(root, { recursive: true, force: true });
}
Expand Down
7 changes: 5 additions & 2 deletions lib/skill-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,14 @@ export function annotateSkillsWithInstallInfo(

return skills.map((skill) => {
if (!existsSync(skill.filePath)) return skill;
// omp lists colliding skills as `namespace/name`; lock files key the
// installed name.
const lockName = skill.name.slice(skill.name.lastIndexOf("/") + 1);

const install = globalSkillsRoots.some((root) => isWithin(skill.filePath, root))
? getInstallInfo(globalEntries, skill.name, "global")
? getInstallInfo(globalEntries, lockName, "global")
: projectSkillsRoots.some((root) => isWithin(skill.filePath, root))
? getInstallInfo(projectEntries, skill.name, "project")
? getInstallInfo(projectEntries, lockName, "project")
: undefined;

return install ? { ...skill, install } : skill;
Expand Down
Loading
Loading