@omercnet/paseo-omp 5.4.0-next.406.1 → 5.4.0-next.408.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/omp-config-surface.tsx +4 -0
- package/client/omp-config-views.ts +2 -0
- package/client/omp-extensions-section.tsx +145 -0
- package/index.server.ts +4 -0
- package/package.json +1 -1
- package/server/omp-extensions.ts +235 -0
- package/server/omp-list-setting.ts +98 -0
- package/server/omp-rules.ts +6 -6
- package/server/omp-skills.ts +19 -99
- package/server/package-version.ts +1 -1
- package/shared/omp-extensions.ts +45 -0
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
OMP_SETTINGS_REFERENCE,
|
|
45
45
|
type OmpDocumentationLink,
|
|
46
46
|
} from "./omp-doc-links";
|
|
47
|
+
import { OmpExtensionsSection } from "./omp-extensions-section";
|
|
47
48
|
import { OmpMcpsSection } from "./omp-mcps-section";
|
|
48
49
|
import { normalizeOmpModels } from "./omp-model-picker-state";
|
|
49
50
|
import { OmpPluginManagerSection } from "./omp-plugin-manager";
|
|
@@ -1268,6 +1269,9 @@ function OmpConfigContent({
|
|
|
1268
1269
|
{view === "skills" ? (
|
|
1269
1270
|
<OmpSkillsSection theme={theme} styles={styles} cwd={cwd} store={store} />
|
|
1270
1271
|
) : null}
|
|
1272
|
+
{view === "extensions" ? (
|
|
1273
|
+
<OmpExtensionsSection theme={theme} styles={styles} cwd={cwd} store={store} />
|
|
1274
|
+
) : null}
|
|
1271
1275
|
{view === "composer" && !cwd && onComposerPillSettingsChange ? (
|
|
1272
1276
|
<ComposerPillSettingsSection theme={theme} onChange={onComposerPillSettingsChange} />
|
|
1273
1277
|
) : null}
|
|
@@ -6,6 +6,7 @@ export type OmpConfigSurfaceView =
|
|
|
6
6
|
| "plugins"
|
|
7
7
|
| "rules"
|
|
8
8
|
| "skills"
|
|
9
|
+
| "extensions"
|
|
9
10
|
| "composer"
|
|
10
11
|
| "configuration"
|
|
11
12
|
| "diagnostics"
|
|
@@ -19,6 +20,7 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
|
|
|
19
20
|
{ id: "plugins", label: "OMP plugins" },
|
|
20
21
|
{ id: "rules", label: "Rules" },
|
|
21
22
|
{ id: "skills", label: "Skills" },
|
|
23
|
+
{ id: "extensions", label: "Extensions" },
|
|
22
24
|
{ id: "composer", label: "Composer" },
|
|
23
25
|
{ id: "configuration", label: "Configuration" },
|
|
24
26
|
{ id: "diagnostics", label: "Diagnostics" },
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import {
|
|
3
|
+
SettingsCard,
|
|
4
|
+
SettingsSection,
|
|
5
|
+
SettingsSwitch,
|
|
6
|
+
useToast,
|
|
7
|
+
} from "@getpaseo/plugin/client/ui";
|
|
8
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { Text, View } from "react-native";
|
|
11
|
+
import {
|
|
12
|
+
listOmpExtensions,
|
|
13
|
+
type OmpExtensionItem,
|
|
14
|
+
type OmpExtensionKind,
|
|
15
|
+
setOmpExtensionEnabled,
|
|
16
|
+
} from "../shared/omp-extensions";
|
|
17
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
18
|
+
import { ConfirmModal, describe } from "./omp-accounts-section";
|
|
19
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
20
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
21
|
+
|
|
22
|
+
type Theme = PluginSurfaceProps["theme"];
|
|
23
|
+
|
|
24
|
+
const EXTENSIONS_KEY = ["paseo-omp", "extensions"] as const;
|
|
25
|
+
|
|
26
|
+
const GROUPS: readonly { kind: OmpExtensionKind; title: string }[] = [
|
|
27
|
+
{ kind: "extension", title: "Extensions" },
|
|
28
|
+
{ kind: "hook", title: "Hooks" },
|
|
29
|
+
{ kind: "tool", title: "Custom tools" },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const INFO =
|
|
33
|
+
"Read from the folders OMP documents: the workspace's .omp/ and OMP's agent directory (the agent directory itself is read even if it is a symlink; nothing below it is). OMP has no list command, so this is a close inventory, not OMP's own list: it does not read .gitignore or the extensions setting, it leaves out folders whose package.json declares entries (or cannot be read safely), declaration files, JSON and Markdown tool definitions and symlinked entries, and it shows one row where two files share a name. Turning one off adds it to disabledExtensions; in a workspace the whole list is saved to the project's .omp/config.yml, because a project list replaces the user list. Changes apply to new sessions. OMP does not report extension load errors for the built-in omp agents.";
|
|
34
|
+
|
|
35
|
+
const RESTART_HINT = "Turned on. An agent that is already running needs a restart to load it.";
|
|
36
|
+
|
|
37
|
+
/** Extensions and hooks can block or rewrite tool calls; a tool only adds one. */
|
|
38
|
+
function needsWarning(item: OmpExtensionItem): boolean {
|
|
39
|
+
return item.kind !== "tool";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function itemHint(item: OmpExtensionItem): string {
|
|
43
|
+
const level = item.level === "project" ? "Project" : "User";
|
|
44
|
+
return `${level} · ${item.path}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function OmpExtensionsSection({
|
|
48
|
+
theme,
|
|
49
|
+
styles,
|
|
50
|
+
cwd,
|
|
51
|
+
store,
|
|
52
|
+
}: {
|
|
53
|
+
theme: Theme;
|
|
54
|
+
styles: OmpConfigStyles;
|
|
55
|
+
cwd?: string;
|
|
56
|
+
store?: OmpStore;
|
|
57
|
+
}) {
|
|
58
|
+
const toast = useToast();
|
|
59
|
+
const queryClient = useQueryClient();
|
|
60
|
+
const load = useRpc(listOmpExtensions);
|
|
61
|
+
const setEnabled = useRpc(setOmpExtensionEnabled);
|
|
62
|
+
const [pendingOff, setPendingOff] = useState<OmpExtensionItem | null>(null);
|
|
63
|
+
const scope = cwd ? { cwd } : {};
|
|
64
|
+
const extensions = useQuery({
|
|
65
|
+
queryKey: [...EXTENSIONS_KEY, ompStoreKey(store), cwd ?? "global"],
|
|
66
|
+
queryFn: () => load({ store, ...scope }),
|
|
67
|
+
});
|
|
68
|
+
const toggle = useMutation({
|
|
69
|
+
mutationKey: [...EXTENSIONS_KEY, "toggle"],
|
|
70
|
+
mutationFn: (change: { id: string; enabled: boolean }) =>
|
|
71
|
+
setEnabled({ store, ...scope, ...change }),
|
|
72
|
+
onSuccess: async (result, change) => {
|
|
73
|
+
if (result.status === "error") toast.error(result.message);
|
|
74
|
+
else if (change.enabled) toast.show(RESTART_HINT, { variant: "success" });
|
|
75
|
+
await queryClient.invalidateQueries({ queryKey: EXTENSIONS_KEY });
|
|
76
|
+
},
|
|
77
|
+
onError: (error) => toast.error(describe(error)),
|
|
78
|
+
onSettled: () => setPendingOff(null),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
function flip(item: OmpExtensionItem) {
|
|
82
|
+
if (item.enabled && needsWarning(item)) setPendingOff(item);
|
|
83
|
+
else toggle.mutate({ id: item.id, enabled: !item.enabled });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const list = extensions.data;
|
|
87
|
+
return (
|
|
88
|
+
<View style={{ gap: 12 }}>
|
|
89
|
+
<SettingsSection title="Extensions, hooks and tools" info={INFO}>
|
|
90
|
+
<Text style={styles.muted}>
|
|
91
|
+
Code OMP runs for this {cwd ? "workspace" : "user"}. Turned-off items stay listed.
|
|
92
|
+
</Text>
|
|
93
|
+
</SettingsSection>
|
|
94
|
+
{extensions.isLoading ? <Text style={styles.muted}>Loading extensions...</Text> : null}
|
|
95
|
+
{extensions.error ? (
|
|
96
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
97
|
+
Could not list OMP's extensions.
|
|
98
|
+
</Text>
|
|
99
|
+
) : null}
|
|
100
|
+
{list?.status === "error" ? (
|
|
101
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
102
|
+
{list.message}
|
|
103
|
+
</Text>
|
|
104
|
+
) : null}
|
|
105
|
+
{list?.status === "ready" && list.items.length === 0 ? (
|
|
106
|
+
<Text style={styles.muted}>No extensions, hooks or custom tools found</Text>
|
|
107
|
+
) : null}
|
|
108
|
+
{list?.status === "ready"
|
|
109
|
+
? GROUPS.map((group) => {
|
|
110
|
+
const members = list.items.filter((item) => item.kind === group.kind);
|
|
111
|
+
if (members.length === 0) return null;
|
|
112
|
+
return (
|
|
113
|
+
<SettingsSection key={group.kind} title={group.title}>
|
|
114
|
+
<SettingsCard>
|
|
115
|
+
{members.map((item) => (
|
|
116
|
+
<SettingsSwitch
|
|
117
|
+
key={item.path}
|
|
118
|
+
label={item.name}
|
|
119
|
+
hint={itemHint(item)}
|
|
120
|
+
value={item.enabled}
|
|
121
|
+
disabled={toggle.isPending}
|
|
122
|
+
onValueChange={() => flip(item)}
|
|
123
|
+
/>
|
|
124
|
+
))}
|
|
125
|
+
</SettingsCard>
|
|
126
|
+
</SettingsSection>
|
|
127
|
+
);
|
|
128
|
+
})
|
|
129
|
+
: null}
|
|
130
|
+
{pendingOff ? (
|
|
131
|
+
<ConfirmModal
|
|
132
|
+
styles={styles}
|
|
133
|
+
theme={theme}
|
|
134
|
+
title={`Turn off ${pendingOff.name}?`}
|
|
135
|
+
body="It may be guarding or rewriting tool calls, such as a safety hook. Turning it off removes that protection for new sessions, for the terminal too."
|
|
136
|
+
confirmLabel="Turn off"
|
|
137
|
+
tone="danger"
|
|
138
|
+
busy={toggle.isPending}
|
|
139
|
+
onConfirm={() => toggle.mutate({ id: pendingOff.id, enabled: false })}
|
|
140
|
+
onCancel={() => setPendingOff(null)}
|
|
141
|
+
/>
|
|
142
|
+
) : null}
|
|
143
|
+
</View>
|
|
144
|
+
);
|
|
145
|
+
}
|
package/index.server.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { resolveListOmpMemory } from "./server/memory";
|
|
|
9
9
|
import { OmpAccounts } from "./server/omp-accounts";
|
|
10
10
|
import { resolveListOmpAgents } from "./server/omp-agents";
|
|
11
11
|
import { resolveListOmpConfig } from "./server/omp-config";
|
|
12
|
+
import { resolveListOmpExtensions, resolveSetOmpExtensionEnabled } from "./server/omp-extensions";
|
|
12
13
|
import { OmpMcps } from "./server/omp-mcps";
|
|
13
14
|
import { resolveListOmpModels } from "./server/omp-models";
|
|
14
15
|
import {
|
|
@@ -68,6 +69,7 @@ import {
|
|
|
68
69
|
} from "./shared/omp-accounts";
|
|
69
70
|
import { listOmpAgents } from "./shared/omp-agents";
|
|
70
71
|
import { listOmpConfig } from "./shared/omp-config";
|
|
72
|
+
import { listOmpExtensions, setOmpExtensionEnabled } from "./shared/omp-extensions";
|
|
71
73
|
import {
|
|
72
74
|
addOmpMcp,
|
|
73
75
|
cancelOmpMcpAuth,
|
|
@@ -213,6 +215,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
213
215
|
server.handle(browseOmpMarketplace, scoped(resolveBrowseOmpMarketplace));
|
|
214
216
|
server.handle(mutateOmpMarketplace, scoped(resolveMutateOmpMarketplace));
|
|
215
217
|
server.handle(listOmpRules, scoped(resolveListOmpRules));
|
|
218
|
+
server.handle(listOmpExtensions, scoped(resolveListOmpExtensions));
|
|
219
|
+
server.handle(setOmpExtensionEnabled, scoped(resolveSetOmpExtensionEnabled));
|
|
216
220
|
server.handle(listOmpSkills, scoped(resolveListOmpSkills));
|
|
217
221
|
server.handle(setOmpSkillEnabled, scoped(resolveSetOmpSkillEnabled));
|
|
218
222
|
server.handle(deleteOmpManagedSkill, scoped(resolveDeleteOmpManagedSkill));
|
package/package.json
CHANGED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import type { Dirent } from "node:fs";
|
|
2
|
+
import { lstat, readdir } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import type { RpcInput } from "@getpaseo/plugin";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import type {
|
|
7
|
+
listOmpExtensions,
|
|
8
|
+
OmpExtensionItem,
|
|
9
|
+
OmpExtensionsList,
|
|
10
|
+
setOmpExtensionEnabled,
|
|
11
|
+
} from "../shared/omp-extensions";
|
|
12
|
+
import {
|
|
13
|
+
type OmpListDependencies,
|
|
14
|
+
ompListDependencies,
|
|
15
|
+
readList,
|
|
16
|
+
requireOmpExecutable,
|
|
17
|
+
writeListEntry,
|
|
18
|
+
} from "./omp-list-setting";
|
|
19
|
+
import { inOmpScope, readRegularFile } from "./omp-rules";
|
|
20
|
+
import { runSettingsMutation } from "./omp-settings";
|
|
21
|
+
import { ompAgentDir } from "./paths";
|
|
22
|
+
import { OmpPublicError } from "./provider/security";
|
|
23
|
+
|
|
24
|
+
const MAX_ENTRIES_PER_DIR = 200;
|
|
25
|
+
const MAX_ITEMS = 500;
|
|
26
|
+
const MAX_NAME_CHARS = 256;
|
|
27
|
+
const SCRIPT_SUFFIX = /\.(ts|js)$/u;
|
|
28
|
+
const TOOL_SUFFIX = /\.(ts|js|sh|bash|py)$/u;
|
|
29
|
+
const DECLARATION = /\.d\.(ts|js)$/u;
|
|
30
|
+
const DeclaredEntries = z.object({ extensions: z.array(z.unknown()).min(1) });
|
|
31
|
+
const ManifestSchema = z.object({ omp: z.unknown().optional(), pi: z.unknown().optional() });
|
|
32
|
+
|
|
33
|
+
export class OmpExtensionsError extends OmpPublicError {}
|
|
34
|
+
|
|
35
|
+
type Found = Omit<OmpExtensionItem, "enabled">;
|
|
36
|
+
type Level = Found["level"];
|
|
37
|
+
|
|
38
|
+
interface Candidate {
|
|
39
|
+
name: string;
|
|
40
|
+
path: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function isRealDirectory(path: string): Promise<boolean> {
|
|
44
|
+
const info = await lstat(path).catch(() => null);
|
|
45
|
+
return info?.isDirectory() === true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function isRealFile(path: string): Promise<boolean> {
|
|
49
|
+
const info = await lstat(path).catch(() => null);
|
|
50
|
+
return info?.isFile() === true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The visible entries of a real directory, bounded. A symlinked directory or entry is never
|
|
55
|
+
* followed: a Dirent reports a link as a link, so it is neither a file nor a directory here.
|
|
56
|
+
*/
|
|
57
|
+
async function entriesOf(dir: string): Promise<Dirent[]> {
|
|
58
|
+
if (!(await isRealDirectory(dir))) return [];
|
|
59
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
60
|
+
return entries
|
|
61
|
+
.filter((entry) => !entry.name.startsWith("."))
|
|
62
|
+
.sort((a, b) => (a.name < b.name ? -1 : 1))
|
|
63
|
+
.slice(0, MAX_ENTRIES_PER_DIR);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function indexIn(dir: string): Promise<string | null> {
|
|
67
|
+
for (const name of ["index.ts", "index.js"]) {
|
|
68
|
+
if (await isRealFile(join(dir, name))) return join(dir, name);
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* OMP loads the entries a folder's package.json declares instead of its index file, under names
|
|
75
|
+
* this scan cannot derive. Such a folder is left out, and so is one whose manifest cannot be read
|
|
76
|
+
* safely (a link, a pipe, an oversize file), rather than listing a switch that would turn off
|
|
77
|
+
* nothing.
|
|
78
|
+
*/
|
|
79
|
+
async function declaresExtensions(folder: string): Promise<boolean> {
|
|
80
|
+
const path = join(folder, "package.json");
|
|
81
|
+
const info = await lstat(path).catch(() => null);
|
|
82
|
+
if (!info) return false;
|
|
83
|
+
const text = info.isFile() ? await readRegularFile(path) : null;
|
|
84
|
+
if (text === null) return true;
|
|
85
|
+
try {
|
|
86
|
+
const manifest = ManifestSchema.safeParse(JSON.parse(text));
|
|
87
|
+
// OMP reads `omp` when the manifest has it and `pi` otherwise.
|
|
88
|
+
const selected = manifest.success ? (manifest.data.omp ?? manifest.data.pi) : undefined;
|
|
89
|
+
return DeclaredEntries.safeParse(selected).success;
|
|
90
|
+
} catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* `extensions/<name>.ts|js` and `extensions/<name>/index.ts|js`, as OMP's native discovery. OMP
|
|
97
|
+
* lists direct files in path order before folder indexes and keeps the first of a name, so the
|
|
98
|
+
* order is the precedence: `a.js` beats `a.ts`, and a direct file beats a folder index.
|
|
99
|
+
*/
|
|
100
|
+
async function extensionCandidates(root: string): Promise<Candidate[]> {
|
|
101
|
+
const dir = join(root, "extensions");
|
|
102
|
+
const files: Candidate[] = [];
|
|
103
|
+
const folders: Candidate[] = [];
|
|
104
|
+
for (const entry of await entriesOf(dir)) {
|
|
105
|
+
if (entry.isFile() && SCRIPT_SUFFIX.test(entry.name) && !DECLARATION.test(entry.name)) {
|
|
106
|
+
files.push({ name: entry.name.replace(SCRIPT_SUFFIX, ""), path: join(dir, entry.name) });
|
|
107
|
+
} else if (entry.isDirectory() && !(await declaresExtensions(join(dir, entry.name)))) {
|
|
108
|
+
const index = await indexIn(join(dir, entry.name));
|
|
109
|
+
if (index) folders.push({ name: entry.name, path: index });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return [...files, ...folders];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** `tools/<name>.<ts|js|sh|bash|py>` and `tools/<name>/index.ts`; files first, as for extensions. */
|
|
116
|
+
async function toolCandidates(root: string): Promise<Candidate[]> {
|
|
117
|
+
const dir = join(root, "tools");
|
|
118
|
+
const files: Candidate[] = [];
|
|
119
|
+
const folders: Candidate[] = [];
|
|
120
|
+
for (const entry of await entriesOf(dir)) {
|
|
121
|
+
if (entry.isFile() && TOOL_SUFFIX.test(entry.name) && !DECLARATION.test(entry.name)) {
|
|
122
|
+
files.push({ name: entry.name.replace(TOOL_SUFFIX, ""), path: join(dir, entry.name) });
|
|
123
|
+
} else if (entry.isDirectory() && (await isRealFile(join(dir, entry.name, "index.ts")))) {
|
|
124
|
+
folders.push({ name: entry.name, path: join(dir, entry.name, "index.ts") });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return [...files, ...folders];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function entryFor(
|
|
131
|
+
kind: Found["kind"],
|
|
132
|
+
level: Level,
|
|
133
|
+
name: string,
|
|
134
|
+
path: string,
|
|
135
|
+
id: string,
|
|
136
|
+
): Found {
|
|
137
|
+
return { kind, name: name.slice(0, MAX_NAME_CHARS), level, path, id };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function scanRoot(root: string, level: Level): Promise<Found[]> {
|
|
141
|
+
const items: Found[] = [];
|
|
142
|
+
for (const { name, path } of await extensionCandidates(root)) {
|
|
143
|
+
items.push(entryFor("extension", level, name, path, `extension-module:${name}`));
|
|
144
|
+
}
|
|
145
|
+
const hooksReal = await isRealDirectory(join(root, "hooks"));
|
|
146
|
+
for (const type of hooksReal ? ["pre", "post"] : []) {
|
|
147
|
+
const dir = join(root, "hooks", type);
|
|
148
|
+
for (const entry of await entriesOf(dir)) {
|
|
149
|
+
if (!entry.isFile()) continue;
|
|
150
|
+
const dot = entry.name.lastIndexOf(".");
|
|
151
|
+
const tool = dot < 0 ? entry.name : entry.name.slice(0, dot);
|
|
152
|
+
const id = `hook:${type}:${tool}:${entry.name}`;
|
|
153
|
+
items.push(entryFor("hook", level, `${type}/${entry.name}`, join(dir, entry.name), id));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const { name, path } of await toolCandidates(root)) {
|
|
157
|
+
items.push(entryFor("tool", level, name, path, `tool:${name}`));
|
|
158
|
+
}
|
|
159
|
+
// OMP keys extensions and tools by name, so of two same-named entries only the first loads;
|
|
160
|
+
// the candidates are already in OMP's order. Keep one row per id.
|
|
161
|
+
const byId = new Map<string, Found>();
|
|
162
|
+
for (const item of items) {
|
|
163
|
+
if (!byId.has(item.id)) byId.set(item.id, item);
|
|
164
|
+
}
|
|
165
|
+
return [...byId.values()];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* What OMP would discover in the documented folders: the workspace's `.omp/` (project level) and
|
|
170
|
+
* the agent directory (user level). It does not read `.gitignore` or the `extensions` setting, and
|
|
171
|
+
* it leaves out folders whose `package.json` declares entries, so it is a close inventory, not
|
|
172
|
+
* OMP's own list.
|
|
173
|
+
*/
|
|
174
|
+
export async function scanExtensions(cwd: string | undefined, agentDir: string): Promise<Found[]> {
|
|
175
|
+
const projectRoot = cwd ? join(cwd, ".omp") : null;
|
|
176
|
+
const project =
|
|
177
|
+
projectRoot && (await isRealDirectory(projectRoot))
|
|
178
|
+
? await scanRoot(projectRoot, "project")
|
|
179
|
+
: [];
|
|
180
|
+
const user = await scanRoot(agentDir, "user");
|
|
181
|
+
return [...project, ...user].slice(0, MAX_ITEMS);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function listOmpExtensionsWithDependencies(
|
|
185
|
+
input: RpcInput<typeof listOmpExtensions>,
|
|
186
|
+
dependencies: OmpListDependencies,
|
|
187
|
+
): Promise<OmpExtensionsList> {
|
|
188
|
+
try {
|
|
189
|
+
const executable = await requireOmpExecutable(dependencies);
|
|
190
|
+
return await inOmpScope(input.cwd, dependencies, async (runIn) => {
|
|
191
|
+
const list = await readList(dependencies, executable, "disabledExtensions", runIn);
|
|
192
|
+
const disabled = new Set(list.map((entry) => entry.trim()));
|
|
193
|
+
const items = (await scanExtensions(input.cwd, ompAgentDir())).map((item) => ({
|
|
194
|
+
...item,
|
|
195
|
+
enabled: !disabled.has(item.id),
|
|
196
|
+
}));
|
|
197
|
+
return { status: "ready" as const, items };
|
|
198
|
+
});
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof OmpPublicError) return { status: "error", message: error.message };
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Only an id the scan finds right now can be written, so the list never collects stray entries. */
|
|
206
|
+
export async function setOmpExtensionEnabledWithDependencies(
|
|
207
|
+
input: RpcInput<typeof setOmpExtensionEnabled>,
|
|
208
|
+
dependencies: OmpListDependencies,
|
|
209
|
+
): Promise<{ status: "ok" } | { status: "error"; message: string }> {
|
|
210
|
+
try {
|
|
211
|
+
const executable = await requireOmpExecutable(dependencies);
|
|
212
|
+
await inOmpScope(input.cwd, dependencies, async (runIn) => {
|
|
213
|
+
const items = await scanExtensions(input.cwd, ompAgentDir());
|
|
214
|
+
if (!items.some((item) => item.id === input.id)) {
|
|
215
|
+
throw new OmpExtensionsError("OMP does not discover that extension, hook or tool here");
|
|
216
|
+
}
|
|
217
|
+
const change = { cwd: input.cwd, list: "disabledExtensions" as const, entry: input.id };
|
|
218
|
+
await runSettingsMutation(() =>
|
|
219
|
+
writeListEntry({ ...change, enabled: input.enabled }, dependencies, executable, runIn),
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
return { status: "ok" };
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (error instanceof OmpPublicError) return { status: "error", message: error.message };
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function resolveListOmpExtensions(input: RpcInput<typeof listOmpExtensions>) {
|
|
230
|
+
return listOmpExtensionsWithDependencies(input, ompListDependencies);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function resolveSetOmpExtensionEnabled(input: RpcInput<typeof setOmpExtensionEnabled>) {
|
|
234
|
+
return setOmpExtensionEnabledWithDependencies(input, ompListDependencies);
|
|
235
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type OmpRulesDependencies, ompCommandDependencies, readSetting } from "./omp-rules";
|
|
4
|
+
import {
|
|
5
|
+
type OmpSettingsDependencies,
|
|
6
|
+
ompSettingsDependencies,
|
|
7
|
+
readProjectConfigText,
|
|
8
|
+
writeProjectChanges,
|
|
9
|
+
} from "./omp-settings";
|
|
10
|
+
import { OmpPublicError } from "./provider/security";
|
|
11
|
+
|
|
12
|
+
export type OmpListName = "skills.ignoredSkills" | "disabledExtensions";
|
|
13
|
+
|
|
14
|
+
export class OmpListError extends OmpPublicError {}
|
|
15
|
+
|
|
16
|
+
export interface OmpListDependencies extends OmpRulesDependencies {
|
|
17
|
+
validateProjectConfig: OmpSettingsDependencies["validateProjectConfig"];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ompListDependencies: OmpListDependencies = {
|
|
21
|
+
...ompCommandDependencies,
|
|
22
|
+
validateProjectConfig: ompSettingsDependencies.validateProjectConfig,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ListSettingSchema = z.object({ value: z.array(z.string()) });
|
|
26
|
+
const UNREADABLE_CONFIG = "The workspace OMP configuration could not be read";
|
|
27
|
+
|
|
28
|
+
export async function requireOmpExecutable(dependencies: OmpListDependencies): Promise<string> {
|
|
29
|
+
const executable = await dependencies.resolveExecutable();
|
|
30
|
+
if (!executable) throw new OmpListError("The omp command was not found on this host");
|
|
31
|
+
return executable;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The effective list in `runIn`: a workspace's own list when it has one, else the user's. */
|
|
35
|
+
export function readList(
|
|
36
|
+
dependencies: OmpListDependencies,
|
|
37
|
+
executable: string,
|
|
38
|
+
list: OmpListName,
|
|
39
|
+
runIn: string,
|
|
40
|
+
): Promise<string[]> {
|
|
41
|
+
return readSetting(dependencies, executable, list, ListSettingSchema, runIn);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ListEntryChange {
|
|
45
|
+
cwd?: string;
|
|
46
|
+
list: OmpListName;
|
|
47
|
+
entry: string;
|
|
48
|
+
/** Enabled removes the entry from the list; disabled adds it. */
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A project list replaces the user list, so a workspace edit starts from the effective list and
|
|
54
|
+
* saves all of it to the project file. Starting from the project file alone would turn every
|
|
55
|
+
* entry the user turned off back on. Run it inside `runSettingsMutation`.
|
|
56
|
+
*/
|
|
57
|
+
export async function writeListEntry(
|
|
58
|
+
change: ListEntryChange,
|
|
59
|
+
dependencies: OmpListDependencies,
|
|
60
|
+
executable: string,
|
|
61
|
+
runIn: string,
|
|
62
|
+
): Promise<void> {
|
|
63
|
+
const projectPath = change.cwd ? join(change.cwd, ".omp", "config.yml") : null;
|
|
64
|
+
const snapshot = projectPath
|
|
65
|
+
? await readProjectConfigText(projectPath).catch(() => {
|
|
66
|
+
throw new OmpListError(UNREADABLE_CONFIG);
|
|
67
|
+
})
|
|
68
|
+
: "";
|
|
69
|
+
const current = await readList(dependencies, executable, change.list, runIn);
|
|
70
|
+
const kept = current.filter((entry) => entry.trim() !== change.entry);
|
|
71
|
+
const next = change.enabled ? kept : [...kept, change.entry];
|
|
72
|
+
if (change.cwd) {
|
|
73
|
+
const outcome = await writeProjectChanges(
|
|
74
|
+
change.cwd,
|
|
75
|
+
snapshot,
|
|
76
|
+
[{ operation: "set", path: change.list, value: next }],
|
|
77
|
+
executable,
|
|
78
|
+
dependencies,
|
|
79
|
+
).catch((error: unknown) => {
|
|
80
|
+
// The writer's messages are written for the user, as in the settings editor.
|
|
81
|
+
throw new OmpListError(
|
|
82
|
+
error instanceof Error ? error.message : "Could not update workspace settings.",
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
if (outcome === "conflict") {
|
|
86
|
+
throw new OmpListError("The workspace configuration changed. Try again");
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const run = await dependencies.run(
|
|
91
|
+
executable,
|
|
92
|
+
["config", "set", change.list, "--json", "--", JSON.stringify(next)],
|
|
93
|
+
runIn,
|
|
94
|
+
);
|
|
95
|
+
if (run.outcome !== "exited" || run.exitCode !== 0) {
|
|
96
|
+
throw new OmpListError("OMP rejected the change");
|
|
97
|
+
}
|
|
98
|
+
}
|
package/server/omp-rules.ts
CHANGED
|
@@ -21,7 +21,7 @@ const KILL_GRACE_MS = 1_000;
|
|
|
21
21
|
const MAX_OUTPUT_BYTES = 2 * 1024 * 1024;
|
|
22
22
|
const MAX_RULES = 500;
|
|
23
23
|
const MAX_RULE_FILES = 200;
|
|
24
|
-
const
|
|
24
|
+
const MAX_FILE_BYTES = 256 * 1024;
|
|
25
25
|
const MAX_TEXT_CHARS = 2_000;
|
|
26
26
|
const MAX_LIST_ENTRIES = 50;
|
|
27
27
|
|
|
@@ -139,8 +139,8 @@ export async function readSetting<T>(
|
|
|
139
139
|
return parsed.data.value;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
/** Reads a regular file without following a symlink, or returns null. */
|
|
143
|
-
async function
|
|
142
|
+
/** Reads a small regular file without following a symlink or blocking on a pipe, or returns null. */
|
|
143
|
+
export async function readRegularFile(path: string): Promise<string | null> {
|
|
144
144
|
let handle: FileHandle | undefined;
|
|
145
145
|
try {
|
|
146
146
|
// O_NOFOLLOW does not exist on Windows, so reject a symlink before opening it too.
|
|
@@ -151,9 +151,9 @@ async function readRuleFile(path: string): Promise<string | null> {
|
|
|
151
151
|
);
|
|
152
152
|
const info = await handle.stat();
|
|
153
153
|
if (!info.isFile()) return null;
|
|
154
|
-
const buffer = Buffer.alloc(
|
|
154
|
+
const buffer = Buffer.alloc(MAX_FILE_BYTES + 1);
|
|
155
155
|
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
156
|
-
if (bytesRead >
|
|
156
|
+
if (bytesRead > MAX_FILE_BYTES) return null;
|
|
157
157
|
return buffer.toString("utf8", 0, bytesRead);
|
|
158
158
|
} catch {
|
|
159
159
|
return null;
|
|
@@ -327,7 +327,7 @@ export async function readPromptRules(
|
|
|
327
327
|
const rules: OmpRule[] = [];
|
|
328
328
|
for (const file of await ruleFiles(cwd)) {
|
|
329
329
|
if (seen.has(file.name)) continue;
|
|
330
|
-
const text = await
|
|
330
|
+
const text = await readRegularFile(file.path);
|
|
331
331
|
// OMP drops an empty RULES.md and an `enabled: false` file before the first-wins check.
|
|
332
332
|
if (text === null || (file.sticky && text.trim() === "")) continue;
|
|
333
333
|
const meta = frontmatter(text);
|
package/server/omp-skills.ts
CHANGED
|
@@ -6,26 +6,20 @@ import type {
|
|
|
6
6
|
deleteOmpManagedSkill,
|
|
7
7
|
listOmpSkills,
|
|
8
8
|
OmpSkill,
|
|
9
|
-
OmpSkillList,
|
|
10
9
|
OmpSkillOff,
|
|
11
10
|
OmpSkillsList,
|
|
12
11
|
setOmpSkillEnabled,
|
|
13
12
|
} from "../shared/omp-skills";
|
|
14
13
|
import { SKILL_ENTRY_PREFIX } from "../shared/omp-skills";
|
|
15
14
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from "./omp-
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
ompSettingsDependencies,
|
|
25
|
-
readProjectConfigText,
|
|
26
|
-
runSettingsMutation,
|
|
27
|
-
writeProjectChanges,
|
|
28
|
-
} from "./omp-settings";
|
|
15
|
+
type OmpListDependencies,
|
|
16
|
+
ompListDependencies,
|
|
17
|
+
readList,
|
|
18
|
+
requireOmpExecutable,
|
|
19
|
+
writeListEntry,
|
|
20
|
+
} from "./omp-list-setting";
|
|
21
|
+
import { inOmpScope, runJson } from "./omp-rules";
|
|
22
|
+
import { runSettingsMutation } from "./omp-settings";
|
|
29
23
|
import { ompAgentDir } from "./paths";
|
|
30
24
|
import { OmpPublicError } from "./provider/security";
|
|
31
25
|
|
|
@@ -33,14 +27,9 @@ const MAX_SKILLS = 500;
|
|
|
33
27
|
const MAX_OFF_ENTRIES = 200;
|
|
34
28
|
const MAX_TEXT_CHARS = 2_000;
|
|
35
29
|
const MANAGED_SOURCE = "omp-managed";
|
|
36
|
-
const UNREADABLE_CONFIG = "The workspace OMP configuration could not be read";
|
|
37
30
|
|
|
38
31
|
export class OmpSkillsError extends OmpPublicError {}
|
|
39
32
|
|
|
40
|
-
export interface OmpSkillsDependencies extends OmpRulesDependencies {
|
|
41
|
-
validateProjectConfig: OmpSettingsDependencies["validateProjectConfig"];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
33
|
/** One entry of `omp skill list --json`. */
|
|
45
34
|
const SkillEntrySchema = z.object({
|
|
46
35
|
name: z.string().min(1).max(256),
|
|
@@ -52,7 +41,6 @@ const SkillEntrySchema = z.object({
|
|
|
52
41
|
source: z.string().min(1).max(128),
|
|
53
42
|
});
|
|
54
43
|
const SkillListSchema = z.object({ skills: z.array(z.unknown()) });
|
|
55
|
-
const ListSettingSchema = z.object({ value: z.array(z.string()) });
|
|
56
44
|
|
|
57
45
|
/** A source reads `<provider>:<level>`, such as `native:project` or `omp-managed:user`. */
|
|
58
46
|
function toSkill(entry: z.infer<typeof SkillEntrySchema>): OmpSkill {
|
|
@@ -70,7 +58,7 @@ function toSkill(entry: z.infer<typeof SkillEntrySchema>): OmpSkill {
|
|
|
70
58
|
}
|
|
71
59
|
|
|
72
60
|
async function listSkills(
|
|
73
|
-
dependencies:
|
|
61
|
+
dependencies: OmpListDependencies,
|
|
74
62
|
executable: string,
|
|
75
63
|
runIn: string,
|
|
76
64
|
): Promise<OmpSkill[]> {
|
|
@@ -83,15 +71,6 @@ async function listSkills(
|
|
|
83
71
|
});
|
|
84
72
|
}
|
|
85
73
|
|
|
86
|
-
function readList(
|
|
87
|
-
dependencies: OmpSkillsDependencies,
|
|
88
|
-
executable: string,
|
|
89
|
-
list: OmpSkillList,
|
|
90
|
-
runIn: string,
|
|
91
|
-
): Promise<string[]> {
|
|
92
|
-
return readSetting(dependencies, executable, list, ListSettingSchema, runIn);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
74
|
/** OMP trims each entry. Only `skill:` entries of `disabledExtensions` concern skills. */
|
|
96
75
|
function offEntries(ignored: readonly string[], extensions: readonly string[]): OmpSkillOff[] {
|
|
97
76
|
const entries: OmpSkillOff[] = [
|
|
@@ -115,18 +94,12 @@ function offEntries(ignored: readonly string[], extensions: readonly string[]):
|
|
|
115
94
|
.map(({ list, entry }) => ({ list, entry: entry.slice(0, MAX_TEXT_CHARS) }));
|
|
116
95
|
}
|
|
117
96
|
|
|
118
|
-
async function requireExecutable(dependencies: OmpSkillsDependencies): Promise<string> {
|
|
119
|
-
const executable = await dependencies.resolveExecutable();
|
|
120
|
-
if (!executable) throw new OmpSkillsError("The omp command was not found on this host");
|
|
121
|
-
return executable;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
97
|
export async function listOmpSkillsWithDependencies(
|
|
125
98
|
input: RpcInput<typeof listOmpSkills>,
|
|
126
|
-
dependencies:
|
|
99
|
+
dependencies: OmpListDependencies,
|
|
127
100
|
): Promise<OmpSkillsList> {
|
|
128
101
|
try {
|
|
129
|
-
const executable = await
|
|
102
|
+
const executable = await requireOmpExecutable(dependencies);
|
|
130
103
|
return await inOmpScope(input.cwd, dependencies, async (runIn) => {
|
|
131
104
|
const [skills, ignored, extensions] = await Promise.all([
|
|
132
105
|
listSkills(dependencies, executable, runIn),
|
|
@@ -141,65 +114,17 @@ export async function listOmpSkillsWithDependencies(
|
|
|
141
114
|
}
|
|
142
115
|
}
|
|
143
116
|
|
|
144
|
-
/**
|
|
145
|
-
* A project list replaces the user list, so a workspace edit starts from the effective list and
|
|
146
|
-
* saves all of it to the project file. Starting from the project file alone would turn every
|
|
147
|
-
* skill the user turned off back on.
|
|
148
|
-
*/
|
|
149
|
-
async function writeList(
|
|
150
|
-
input: RpcInput<typeof setOmpSkillEnabled>,
|
|
151
|
-
dependencies: OmpSkillsDependencies,
|
|
152
|
-
executable: string,
|
|
153
|
-
runIn: string,
|
|
154
|
-
): Promise<void> {
|
|
155
|
-
const projectPath = input.cwd ? join(input.cwd, ".omp", "config.yml") : null;
|
|
156
|
-
const snapshot = projectPath
|
|
157
|
-
? await readProjectConfigText(projectPath).catch(() => {
|
|
158
|
-
throw new OmpSkillsError(UNREADABLE_CONFIG);
|
|
159
|
-
})
|
|
160
|
-
: "";
|
|
161
|
-
const current = await readList(dependencies, executable, input.list, runIn);
|
|
162
|
-
const kept = current.filter((entry) => entry.trim() !== input.entry);
|
|
163
|
-
const next = input.enabled ? kept : [...kept, input.entry];
|
|
164
|
-
if (input.cwd) {
|
|
165
|
-
const outcome = await writeProjectChanges(
|
|
166
|
-
input.cwd,
|
|
167
|
-
snapshot,
|
|
168
|
-
[{ operation: "set", path: input.list, value: next }],
|
|
169
|
-
executable,
|
|
170
|
-
dependencies,
|
|
171
|
-
).catch((error: unknown) => {
|
|
172
|
-
// The writer's messages are written for the user, as in the settings editor.
|
|
173
|
-
throw new OmpSkillsError(
|
|
174
|
-
error instanceof Error ? error.message : "Could not update workspace settings.",
|
|
175
|
-
);
|
|
176
|
-
});
|
|
177
|
-
if (outcome === "conflict") {
|
|
178
|
-
throw new OmpSkillsError("The workspace configuration changed. Try again");
|
|
179
|
-
}
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
const run = await dependencies.run(
|
|
183
|
-
executable,
|
|
184
|
-
["config", "set", input.list, "--json", "--", JSON.stringify(next)],
|
|
185
|
-
runIn,
|
|
186
|
-
);
|
|
187
|
-
if (run.outcome !== "exited" || run.exitCode !== 0) {
|
|
188
|
-
throw new OmpSkillsError("OMP rejected the change");
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
117
|
export async function setOmpSkillEnabledWithDependencies(
|
|
193
118
|
input: RpcInput<typeof setOmpSkillEnabled>,
|
|
194
|
-
dependencies:
|
|
119
|
+
dependencies: OmpListDependencies,
|
|
195
120
|
): Promise<{ status: "ok" } | { status: "error"; message: string }> {
|
|
196
121
|
try {
|
|
197
122
|
if (input.list === "disabledExtensions" && !input.entry.startsWith(SKILL_ENTRY_PREFIX)) {
|
|
198
123
|
throw new OmpSkillsError("That entry is not a skill");
|
|
199
124
|
}
|
|
200
|
-
const executable = await
|
|
125
|
+
const executable = await requireOmpExecutable(dependencies);
|
|
201
126
|
await inOmpScope(input.cwd, dependencies, (runIn) =>
|
|
202
|
-
runSettingsMutation(() =>
|
|
127
|
+
runSettingsMutation(() => writeListEntry(input, dependencies, executable, runIn)),
|
|
203
128
|
);
|
|
204
129
|
return { status: "ok" };
|
|
205
130
|
} catch (error) {
|
|
@@ -215,10 +140,10 @@ export async function setOmpSkillEnabledWithDependencies(
|
|
|
215
140
|
*/
|
|
216
141
|
export async function deleteOmpManagedSkillWithDependencies(
|
|
217
142
|
input: RpcInput<typeof deleteOmpManagedSkill>,
|
|
218
|
-
dependencies:
|
|
143
|
+
dependencies: OmpListDependencies,
|
|
219
144
|
): Promise<{ status: "ok" } | { status: "error"; message: string }> {
|
|
220
145
|
try {
|
|
221
|
-
const executable = await
|
|
146
|
+
const executable = await requireOmpExecutable(dependencies);
|
|
222
147
|
const skills = await inOmpScope(undefined, dependencies, (runIn) =>
|
|
223
148
|
listSkills(dependencies, executable, runIn),
|
|
224
149
|
);
|
|
@@ -241,19 +166,14 @@ export async function deleteOmpManagedSkillWithDependencies(
|
|
|
241
166
|
}
|
|
242
167
|
}
|
|
243
168
|
|
|
244
|
-
const DEFAULT_DEPENDENCIES: OmpSkillsDependencies = {
|
|
245
|
-
...ompCommandDependencies,
|
|
246
|
-
validateProjectConfig: ompSettingsDependencies.validateProjectConfig,
|
|
247
|
-
};
|
|
248
|
-
|
|
249
169
|
export function resolveListOmpSkills(input: RpcInput<typeof listOmpSkills>) {
|
|
250
|
-
return listOmpSkillsWithDependencies(input,
|
|
170
|
+
return listOmpSkillsWithDependencies(input, ompListDependencies);
|
|
251
171
|
}
|
|
252
172
|
|
|
253
173
|
export function resolveSetOmpSkillEnabled(input: RpcInput<typeof setOmpSkillEnabled>) {
|
|
254
|
-
return setOmpSkillEnabledWithDependencies(input,
|
|
174
|
+
return setOmpSkillEnabledWithDependencies(input, ompListDependencies);
|
|
255
175
|
}
|
|
256
176
|
|
|
257
177
|
export function resolveDeleteOmpManagedSkill(input: RpcInput<typeof deleteOmpManagedSkill>) {
|
|
258
|
-
return deleteOmpManagedSkillWithDependencies(input,
|
|
178
|
+
return deleteOmpManagedSkillWithDependencies(input, ompListDependencies);
|
|
259
179
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Release Please keeps this bundle-safe constant aligned with package.json. */
|
|
2
|
-
export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.
|
|
2
|
+
export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.408.1"; // x-release-please-version
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { OmpWorkspaceCwdSchema } from "./hub";
|
|
4
|
+
import { OmpStoreSchema } from "./omp-store";
|
|
5
|
+
|
|
6
|
+
export const OmpExtensionKindSchema = z.enum(["extension", "hook", "tool"]);
|
|
7
|
+
export type OmpExtensionKind = z.infer<typeof OmpExtensionKindSchema>;
|
|
8
|
+
|
|
9
|
+
export const OmpExtensionItemSchema = z.object({
|
|
10
|
+
kind: OmpExtensionKindSchema,
|
|
11
|
+
/** A hook reads `pre/<file>` or `post/<file>`. */
|
|
12
|
+
name: z.string(),
|
|
13
|
+
level: z.enum(["project", "user"]),
|
|
14
|
+
path: z.string(),
|
|
15
|
+
/** The entry OMP matches in `disabledExtensions`. */
|
|
16
|
+
id: z.string(),
|
|
17
|
+
enabled: z.boolean(),
|
|
18
|
+
});
|
|
19
|
+
export type OmpExtensionItem = z.infer<typeof OmpExtensionItemSchema>;
|
|
20
|
+
|
|
21
|
+
export const OmpExtensionsListSchema = z.discriminatedUnion("status", [
|
|
22
|
+
z.object({ status: z.literal("ready"), items: z.array(OmpExtensionItemSchema) }),
|
|
23
|
+
z.object({ status: z.literal("error"), message: z.string() }),
|
|
24
|
+
]);
|
|
25
|
+
export type OmpExtensionsList = z.infer<typeof OmpExtensionsListSchema>;
|
|
26
|
+
|
|
27
|
+
const ScopeSchema = { store: OmpStoreSchema.optional(), cwd: OmpWorkspaceCwdSchema.optional() };
|
|
28
|
+
|
|
29
|
+
export const listOmpExtensions = defineRpc({
|
|
30
|
+
name: "paseo-omp.list-extensions",
|
|
31
|
+
input: z.object(ScopeSchema).strict(),
|
|
32
|
+
output: OmpExtensionsListSchema,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** Off adds `id` to `disabledExtensions`; on removes it. A workspace writes its own `.omp/config.yml`. */
|
|
36
|
+
export const setOmpExtensionEnabled = defineRpc({
|
|
37
|
+
name: "paseo-omp.set-extension-enabled",
|
|
38
|
+
input: z
|
|
39
|
+
.object({ ...ScopeSchema, id: z.string().trim().min(1).max(512), enabled: z.boolean() })
|
|
40
|
+
.strict(),
|
|
41
|
+
output: z.discriminatedUnion("status", [
|
|
42
|
+
z.object({ status: z.literal("ok") }),
|
|
43
|
+
z.object({ status: z.literal("error"), message: z.string() }),
|
|
44
|
+
]),
|
|
45
|
+
});
|