mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
* feat(omp): add native Oh My Pi support Support OMP skills, instructions, MCP, code hooks and guarded extension selection using its verified native contracts rather than Pi aliases. Add reviewed marketplace plugin installation, cache-preserving scoped removal and fresh-cache reinstall. Align Pi/OMP extension cards and localize inventory guidance while keeping native ownership and read-only constraints. Include regression coverage, isolated E2E runbooks, documentation and verification policies. Native plugin updates and unverified runtime platforms remain guarded. Refs #409 * fix(omp): guard runtime ownership and localize inventory guidance Native install recursively replaces its runtime destination, and a missing cache manifest could leave the real runtime link installed after removal. Bind and recheck an absent reviewed destination, and recover removal names only from verified scope-local links. Localize fixed backend reasons and warnings across dashboard locales while preserving paths and external diagnostics. Restore the reviewed source in the existing reinstall fixture and record real native verification. * fix(omp): allow forgetting natively removed plugins A different plugin can retain node_modules after native uninstall deletes this installation. When its cache, registration and known runtime state are absent, forget only the stale Skillshare binding instead of demanding runtime-name proof for unrelated files. Extend the existing removal recovery test with a failing-before-fix case that verifies the binding is dropped and unrelated native lock bytes and plugin files are preserved. make check passes.
73 lines
3.1 KiB
TypeScript
73 lines
3.1 KiB
TypeScript
import { apiFetch } from './client';
|
|
|
|
/** Where an extension row comes from: a file in the extensions folder, a settings entry, a plugin, or a Skillshare hook. */
|
|
export type OmpExtensionSource = 'native' | 'configured' | 'plugin' | 'hook';
|
|
/** What the settings select for the file; whether Oh My Pi loaded it is never known here. */
|
|
export type OmpSelection = 'selected' | 'disabled' | 'shadowed' | 'unknown';
|
|
export type OmpScope = 'global' | 'project' | 'account';
|
|
|
|
export interface OmpExtensionRow {
|
|
/** Addresses the row in a change; stable across a refresh of the same file. */
|
|
key: string;
|
|
path: string;
|
|
name: string;
|
|
derivedId: string;
|
|
source: OmpExtensionSource;
|
|
scope: OmpScope;
|
|
selection: OmpSelection;
|
|
/** The settings' answer: null when it cannot be told. Never says whether omp loaded the file. */
|
|
enabled: boolean | null;
|
|
/** A switch is offered only here; `readOnlyReason` says why not, as the server wrote it. */
|
|
selectable: boolean;
|
|
readOnlyReason: string;
|
|
/** `native` is unmanaged by Skillshare; `hooks` only when the hooks ledger proves it. */
|
|
owner: 'native' | 'hooks' | 'plugin' | 'unknown';
|
|
notes: string[];
|
|
/** Set only for a hooks-owned row: the target whose Hooks tab manages it. */
|
|
hooksTarget?: string;
|
|
/** Native plugin identity/root and its declared version, when inspected. */
|
|
pluginName?: string;
|
|
pluginRoot?: string;
|
|
pluginVersion?: string;
|
|
}
|
|
|
|
/** GET /targets/{name}/omp-extensions. `revision` is what a preview checks the settings file against. */
|
|
export interface OmpExtensionsView {
|
|
target: string;
|
|
scope: OmpScope;
|
|
root: string;
|
|
settingsPath: string;
|
|
revision: string;
|
|
/** The whole target is listed only; `reasons` say why. */
|
|
readOnly: boolean;
|
|
reasons: string[];
|
|
warnings: string[];
|
|
rows: OmpExtensionRow[];
|
|
}
|
|
|
|
export interface OmpExtensionChange { key: string; enabled: boolean }
|
|
|
|
/** The preview's `revision` is a plan token; apply sends it back, so only that reviewed plan is written. */
|
|
export interface OmpExtensionsPlan {
|
|
revision: string;
|
|
settingsPath: string;
|
|
rows: { key: string; derivedId: string; before: boolean; after: boolean }[];
|
|
warnings: string[];
|
|
backupId?: string;
|
|
}
|
|
|
|
const base = (target: string) => `/targets/${encodeURIComponent(target)}/omp-extensions`;
|
|
const post = (target: string, verb: string, changes: OmpExtensionChange[], revision: string) =>
|
|
apiFetch<OmpExtensionsPlan>(`${base(target)}/${verb}`, { method: 'POST', body: JSON.stringify({ changes, revision }) });
|
|
|
|
export const ompExtensionsApi = {
|
|
get: (target: string) => apiFetch<OmpExtensionsView>(base(target)),
|
|
/** Writes nothing; `revision` is the view's. */
|
|
preview: (target: string, changes: OmpExtensionChange[], revision: string) => post(target, 'preview', changes, revision),
|
|
/** `revision` is the previewed plan's. */
|
|
apply: (target: string, changes: OmpExtensionChange[], revision: string) => post(target, 'apply', changes, revision),
|
|
};
|
|
|
|
/** A target whose Agent is Oh My Pi: omp itself or an omp account. A project's omp has its tab on the project page. */
|
|
export const isOmpTarget = (t: { name: string; agent?: string }) => t.name === 'omp' || t.agent === 'omp';
|