@omercnet/paseo-omp 5.4.0-next.396.1 → 5.4.0-next.398.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.
@@ -44,6 +44,7 @@ import { normalizeOmpModels } from "./omp-model-picker-state";
44
44
  import { OmpPluginManagerSection } from "./omp-plugin-manager";
45
45
  import { type OmpModelCatalogState, StructuredRoutingEditor } from "./omp-routing-editor";
46
46
  import { OmpRulesSection } from "./omp-rules-section";
47
+ import { OmpSkillsSection } from "./omp-skills-section";
47
48
  import { OmpStorePicker } from "./omp-store-picker";
48
49
  import { ompStoreKey } from "./omp-store-state";
49
50
  import {
@@ -595,6 +596,7 @@ function SupportDiagnosticsSection({
595
596
  const CATEGORY_LABELS: Record<OmpSettingCategory, string> = {
596
597
  appearance: "Appearance",
597
598
  model: "Model",
599
+ budget: "Budget",
598
600
  interaction: "Interaction",
599
601
  context: "Context",
600
602
  memory: "Memory",
@@ -763,7 +765,8 @@ function EditableScalarValue({
763
765
  accessibilityLabel={`Edit ${formatOmpSettingLabel(setting.path)}`}
764
766
  editable={!disabled}
765
767
  keyboardType={setting.type === "number" ? "numeric" : "default"}
766
- value={value === undefined ? "" : String(value)}
768
+ placeholder="Not set"
769
+ value={value === undefined || value === null ? "" : String(value)}
767
770
  onChangeText={onSet}
768
771
  style={styles.scalarInput}
769
772
  />
@@ -1170,6 +1173,9 @@ function OmpConfigContent({
1170
1173
  {view === "rules" ? (
1171
1174
  <OmpRulesSection theme={theme} styles={styles} cwd={cwd} store={store} />
1172
1175
  ) : null}
1176
+ {view === "skills" ? (
1177
+ <OmpSkillsSection theme={theme} styles={styles} cwd={cwd} store={store} />
1178
+ ) : null}
1173
1179
  {view === "composer" && !cwd && onComposerPillSettingsChange ? (
1174
1180
  <ComposerPillSettingsSection theme={theme} onChange={onComposerPillSettingsChange} />
1175
1181
  ) : null}
@@ -5,6 +5,7 @@ export type OmpConfigSurfaceView =
5
5
  | "plugin"
6
6
  | "plugins"
7
7
  | "rules"
8
+ | "skills"
8
9
  | "composer"
9
10
  | "configuration"
10
11
  | "diagnostics"
@@ -17,6 +18,7 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
17
18
  { id: "plugin", label: "Plugin" },
18
19
  { id: "plugins", label: "OMP plugins" },
19
20
  { id: "rules", label: "Rules" },
21
+ { id: "skills", label: "Skills" },
20
22
  { id: "composer", label: "Composer" },
21
23
  { id: "configuration", label: "Configuration" },
22
24
  { id: "diagnostics", label: "Diagnostics" },
@@ -0,0 +1,195 @@
1
+ import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
2
+ import {
3
+ SettingsAction,
4
+ SettingsCard,
5
+ SettingsSection,
6
+ SettingsSwitch,
7
+ useToast,
8
+ } from "@getpaseo/plugin/client/ui";
9
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
10
+ import { useState } from "react";
11
+ import { Text, View } from "react-native";
12
+ import {
13
+ deleteOmpManagedSkill,
14
+ listOmpSkills,
15
+ type OmpSkill,
16
+ type OmpSkillOff,
17
+ SKILL_ENTRY_PREFIX,
18
+ setOmpSkillEnabled,
19
+ } from "../shared/omp-skills";
20
+ import type { OmpStore } from "../shared/omp-store";
21
+ import { ConfirmModal, describe } from "./omp-accounts-section";
22
+ import type { OmpConfigStyles } from "./omp-config-styles";
23
+ import { ompStoreKey } from "./omp-store-state";
24
+
25
+ type Theme = PluginSurfaceProps["theme"];
26
+
27
+ const SKILLS_KEY = ["paseo-omp", "skills"] as const;
28
+
29
+ const INFO =
30
+ "OMP hides turned-off skills from its own list, so they are read from skills.ignoredSkills and disabledExtensions. In a workspace, a change is saved to the project's .omp/config.yml with the whole list, because a project list replaces the user list. Changes apply to new sessions, or after an agent reload.";
31
+
32
+ interface SkillGroup {
33
+ title: string;
34
+ skills: OmpSkill[];
35
+ }
36
+
37
+ function groupSkills(skills: readonly OmpSkill[]): SkillGroup[] {
38
+ const groups: SkillGroup[] = [
39
+ { title: "Project", skills: skills.filter((s) => !s.managed && s.level === "project") },
40
+ { title: "User", skills: skills.filter((s) => !s.managed && s.level === "user") },
41
+ { title: "Learned by the agent", skills: skills.filter((s) => s.managed) },
42
+ { title: "Other", skills: skills.filter((s) => !s.managed && s.level === "other") },
43
+ ];
44
+ return groups.filter((group) => group.skills.length > 0);
45
+ }
46
+
47
+ function skillHint(skill: OmpSkill): string {
48
+ const origin = skill.managed ? "Learned by the agent" : skill.source;
49
+ return skill.description ? `${origin} · ${skill.description}` : origin;
50
+ }
51
+
52
+ function offLabel(off: OmpSkillOff): string {
53
+ return off.list === "disabledExtensions" ? off.entry.slice(SKILL_ENTRY_PREFIX.length) : off.entry;
54
+ }
55
+
56
+ function offHint(off: OmpSkillOff): string {
57
+ const pattern = offLabel(off).includes("*") ? "Pattern, may match several skills · " : "";
58
+ return `${pattern}Listed in ${off.list}`;
59
+ }
60
+
61
+ export function OmpSkillsSection({
62
+ theme,
63
+ styles,
64
+ cwd,
65
+ store,
66
+ }: {
67
+ theme: Theme;
68
+ styles: OmpConfigStyles;
69
+ cwd?: string;
70
+ store?: OmpStore;
71
+ }) {
72
+ const toast = useToast();
73
+ const queryClient = useQueryClient();
74
+ const load = useRpc(listOmpSkills);
75
+ const setEnabled = useRpc(setOmpSkillEnabled);
76
+ const remove = useRpc(deleteOmpManagedSkill);
77
+ const [pendingDelete, setPendingDelete] = useState<OmpSkill | null>(null);
78
+ const scope = cwd ? { cwd } : {};
79
+ const skills = useQuery({
80
+ queryKey: [...SKILLS_KEY, ompStoreKey(store), cwd ?? "global"],
81
+ queryFn: () => load({ store, ...scope }),
82
+ });
83
+ const toggle = useMutation({
84
+ mutationKey: [...SKILLS_KEY, "toggle"],
85
+ mutationFn: (change: { list: OmpSkillOff["list"]; entry: string; enabled: boolean }) =>
86
+ setEnabled({ store, ...scope, ...change }),
87
+ onSuccess: async (result) => {
88
+ if (result.status === "error") toast.error(result.message);
89
+ await queryClient.invalidateQueries({ queryKey: SKILLS_KEY });
90
+ },
91
+ onError: (error) => toast.error(describe(error)),
92
+ });
93
+ const del = useMutation({
94
+ mutationKey: [...SKILLS_KEY, "delete"],
95
+ mutationFn: (skill: OmpSkill) => remove({ store, path: skill.path }),
96
+ onSuccess: async (result) => {
97
+ if (result.status === "error") toast.error(result.message);
98
+ else toast.show("Skill deleted", { variant: "success" });
99
+ await queryClient.invalidateQueries({ queryKey: SKILLS_KEY });
100
+ },
101
+ onError: (error) => toast.error(describe(error)),
102
+ onSettled: () => setPendingDelete(null),
103
+ });
104
+
105
+ const list = skills.data;
106
+ const busy = toggle.isPending || del.isPending;
107
+ return (
108
+ <View style={{ gap: 12 }}>
109
+ <SettingsSection title="Skills" info={INFO}>
110
+ <Text style={styles.muted}>
111
+ Skills are listed by omp, in this {cwd ? "workspace" : "user"} scope.
112
+ </Text>
113
+ </SettingsSection>
114
+ {skills.isLoading ? <Text style={styles.muted}>Loading skills...</Text> : null}
115
+ {skills.error ? (
116
+ <Text accessibilityRole="alert" style={styles.error}>
117
+ Could not list OMP's skills.
118
+ </Text>
119
+ ) : null}
120
+ {list?.status === "error" ? (
121
+ <Text accessibilityRole="alert" style={styles.error}>
122
+ {list.message}
123
+ </Text>
124
+ ) : null}
125
+ {list?.status === "ready" ? (
126
+ <>
127
+ {list.skills.length === 0 ? <Text style={styles.muted}>No skills found</Text> : null}
128
+ {groupSkills(list.skills).map((group) => (
129
+ <SettingsSection key={group.title} title={group.title}>
130
+ <SettingsCard>
131
+ {group.skills.map((skill) => (
132
+ <View key={`${skill.source}/${skill.path}`}>
133
+ <SettingsSwitch
134
+ label={skill.name}
135
+ hint={skillHint(skill)}
136
+ value
137
+ disabled={busy}
138
+ onValueChange={() =>
139
+ toggle.mutate({
140
+ list: "skills.ignoredSkills",
141
+ entry: skill.name,
142
+ enabled: false,
143
+ })
144
+ }
145
+ />
146
+ {skill.managed ? (
147
+ <SettingsAction
148
+ label={`Delete ${skill.name}`}
149
+ hint="Deletes the skill folder the agent wrote, for the terminal too"
150
+ actionLabel="Delete"
151
+ disabled={busy}
152
+ onPress={() => setPendingDelete(skill)}
153
+ />
154
+ ) : null}
155
+ </View>
156
+ ))}
157
+ </SettingsCard>
158
+ </SettingsSection>
159
+ ))}
160
+ <SettingsSection title="Turned off">
161
+ <SettingsCard>
162
+ {list.off.length === 0 ? (
163
+ <Text style={styles.muted}>No skills turned off</Text>
164
+ ) : (
165
+ list.off.map((off) => (
166
+ <SettingsSwitch
167
+ key={`${off.list}/${off.entry}`}
168
+ label={offLabel(off)}
169
+ hint={offHint(off)}
170
+ value={false}
171
+ disabled={busy}
172
+ onValueChange={() => toggle.mutate({ ...off, enabled: true })}
173
+ />
174
+ ))
175
+ )}
176
+ </SettingsCard>
177
+ </SettingsSection>
178
+ </>
179
+ ) : null}
180
+ {pendingDelete ? (
181
+ <ConfirmModal
182
+ styles={styles}
183
+ theme={theme}
184
+ title={`Delete ${pendingDelete.name}?`}
185
+ body="This deletes the skill folder from OMP's managed skills, for the terminal too. It cannot be undone."
186
+ confirmLabel="Delete"
187
+ tone="danger"
188
+ busy={del.isPending}
189
+ onConfirm={() => del.mutate(pendingDelete)}
190
+ onCancel={() => setPendingDelete(null)}
191
+ />
192
+ ) : null}
193
+ </View>
194
+ );
195
+ }
package/index.server.ts CHANGED
@@ -17,6 +17,11 @@ import {
17
17
  } from "./server/omp-plugins";
18
18
  import { resolveListOmpRules } from "./server/omp-rules";
19
19
  import { resolveListOmpSettings, resolveUpdateOmpSettings } from "./server/omp-settings";
20
+ import {
21
+ resolveDeleteOmpManagedSkill,
22
+ resolveListOmpSkills,
23
+ resolveSetOmpSkillEnabled,
24
+ } from "./server/omp-skills";
20
25
  import { OmpOperationalFailureCollector } from "./server/operational-failure-diagnostics";
21
26
  import { withOmpStore } from "./server/paths";
22
27
  import { OmpProtocolViolationCollector } from "./server/protocol-violation-diagnostics";
@@ -71,6 +76,7 @@ import {
71
76
  } from "./shared/omp-plugins";
72
77
  import { listOmpRules } from "./shared/omp-rules";
73
78
  import { listOmpSettings, updateOmpSettings } from "./shared/omp-settings";
79
+ import { deleteOmpManagedSkill, listOmpSkills, setOmpSkillEnabled } from "./shared/omp-skills";
74
80
  import { listOmpStores, type OmpStore } from "./shared/omp-store";
75
81
  import { getOmpProviderHealth } from "./shared/provider-diagnostics";
76
82
  import { getOmpImage } from "./shared/provider-image";
@@ -189,6 +195,9 @@ export default function contribute(server: PluginServerContext) {
189
195
  server.handle(listOmpModels, scoped(resolveListOmpModels));
190
196
  server.handle(listOmpPlugins, scoped(resolveListOmpPlugins));
191
197
  server.handle(listOmpRules, scoped(resolveListOmpRules));
198
+ server.handle(listOmpSkills, scoped(resolveListOmpSkills));
199
+ server.handle(setOmpSkillEnabled, scoped(resolveSetOmpSkillEnabled));
200
+ server.handle(deleteOmpManagedSkill, scoped(resolveDeleteOmpManagedSkill));
192
201
  server.handle(inspectOmpPluginConfig, scoped(resolveInspectOmpPluginConfig));
193
202
  server.handle(mutateOmpPlugin, scoped(resolveMutateOmpPlugin));
194
203
  server.handle(mutateOmpPluginConfig, scoped(resolveMutateOmpPluginConfig));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.4.0-next.396.1",
3
+ "version": "5.4.0-next.398.1",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -106,8 +106,8 @@ function toWatchRule(rule: WatchRule, cwd: string | undefined): OmpRule {
106
106
  };
107
107
  }
108
108
 
109
- async function runJson(
110
- dependencies: OmpRulesDependencies,
109
+ export async function runJson(
110
+ dependencies: Pick<OmpRulesDependencies, "run">,
111
111
  executable: string,
112
112
  args: readonly string[],
113
113
  cwd: string,
@@ -125,8 +125,8 @@ async function runJson(
125
125
  }
126
126
  }
127
127
 
128
- async function readSetting<T>(
129
- dependencies: OmpRulesDependencies,
128
+ export async function readSetting<T>(
129
+ dependencies: Pick<OmpRulesDependencies, "run">,
130
130
  executable: string,
131
131
  path: string,
132
132
  schema: z.ZodType<{ value: T }>,
@@ -373,10 +373,15 @@ async function listRulesIn(
373
373
  };
374
374
  }
375
375
 
376
- async function listRules(
376
+ /**
377
+ * Runs `operation` where OMP finds only this scope: the workspace, or an empty directory so no
378
+ * project's files leak into the global (user-level) view.
379
+ */
380
+ export async function inOmpScope<T>(
377
381
  cwd: string | undefined,
378
- dependencies: OmpRulesDependencies,
379
- ): Promise<OmpRulesList> {
382
+ dependencies: Pick<OmpRulesDependencies, "makeScratchDir" | "removeDir">,
383
+ operation: (runIn: string) => Promise<T>,
384
+ ): Promise<T> {
380
385
  if (cwd !== undefined) {
381
386
  const isDirectory =
382
387
  isAbsolute(cwd) &&
@@ -386,13 +391,12 @@ async function listRules(
386
391
  () => false,
387
392
  ));
388
393
  if (!isDirectory) throw new OmpRulesError("The workspace path is invalid");
389
- return listRulesIn(cwd, cwd, dependencies);
394
+ return operation(cwd);
390
395
  }
391
- // An empty directory keeps every project's rules out of the global listing.
392
396
  const prefix = join(tmpdir(), "paseo-omp-rules-");
393
397
  const scratch = await dependencies.makeScratchDir(prefix);
394
398
  try {
395
- return await listRulesIn(scratch, undefined, dependencies);
399
+ return await operation(scratch);
396
400
  } finally {
397
401
  // Only ever delete the directory this call created directly under the system temp directory.
398
402
  const ours =
@@ -409,14 +413,16 @@ export async function listOmpRulesWithDependencies(
409
413
  dependencies: OmpRulesDependencies,
410
414
  ): Promise<OmpRulesList> {
411
415
  try {
412
- return await listRules(input.cwd, dependencies);
416
+ return await inOmpScope(input.cwd, dependencies, (runIn) =>
417
+ listRulesIn(runIn, input.cwd, dependencies),
418
+ );
413
419
  } catch (error) {
414
420
  if (error instanceof OmpRulesError) return { status: "error", message: error.message };
415
421
  throw error;
416
422
  }
417
423
  }
418
424
 
419
- const DEFAULT_DEPENDENCIES: OmpRulesDependencies = {
425
+ export const ompCommandDependencies: OmpRulesDependencies = {
420
426
  resolveExecutable: resolveOmpExecutable,
421
427
  run: (executable, args, cwd) =>
422
428
  runBounded(
@@ -434,5 +440,5 @@ const DEFAULT_DEPENDENCIES: OmpRulesDependencies = {
434
440
  };
435
441
 
436
442
  export function resolveListOmpRules(input: RpcInput<typeof listOmpRules>): Promise<OmpRulesList> {
437
- return listOmpRulesWithDependencies(input, DEFAULT_DEPENDENCIES);
443
+ return listOmpRulesWithDependencies(input, ompCommandDependencies);
438
444
  }
@@ -7,6 +7,7 @@ import { parseDocument, parse as parseYaml } from "yaml";
7
7
  import {
8
8
  isOmpStructuredSettingPath,
9
9
  type listOmpSettings,
10
+ OMP_SETTING_FALLBACK_DESCRIPTIONS,
10
11
  OMP_SETTINGS_CATALOG_VERSION,
11
12
  type OmpSetting,
12
13
  type OmpSettingType,
@@ -63,7 +64,7 @@ export interface OmpSettingsDependencies {
63
64
  validateProjectConfig(executable: string, path: string): Promise<BoundedRun>;
64
65
  }
65
66
 
66
- async function readProjectConfigText(path: string): Promise<string> {
67
+ export async function readProjectConfigText(path: string): Promise<string> {
67
68
  try {
68
69
  return await readFile(path, "utf8");
69
70
  } catch (error) {
@@ -82,12 +83,16 @@ function runSucceeded(result: BoundedRun): boolean {
82
83
  );
83
84
  }
84
85
 
85
- async function writeProjectChanges(
86
+ export type ProjectChange =
87
+ | { operation: "set"; path: string; value: unknown }
88
+ | { operation: "reset"; path: string };
89
+
90
+ export async function writeProjectChanges(
86
91
  cwd: string,
87
92
  expectedText: string,
88
- changes: RpcInput<typeof updateOmpSettings>["changes"],
93
+ changes: readonly ProjectChange[],
89
94
  executable: string,
90
- dependencies: OmpSettingsDependencies,
95
+ dependencies: Pick<OmpSettingsDependencies, "validateProjectConfig">,
91
96
  ): Promise<"applied" | "conflict"> {
92
97
  const path = join(cwd, ".omp", "config.yml");
93
98
  try {
@@ -191,7 +196,10 @@ export function parseOmpSettingsList(raw: unknown): ParsedOmpSettings {
191
196
  settings.push({
192
197
  path,
193
198
  type: parsedType.data,
194
- description: typeof entry.description === "string" ? entry.description : "",
199
+ description:
200
+ typeof entry.description === "string" && entry.description
201
+ ? entry.description
202
+ : (OMP_SETTING_FALLBACK_DESCRIPTIONS[path] ?? ""),
195
203
  ...(redacted
196
204
  ? { redacted: true, ...(configured === undefined ? {} : { configured }) }
197
205
  : { value: entry.value }),
@@ -238,7 +246,7 @@ async function validateOmpProjectConfig(executable: string, path: string): Promi
238
246
  );
239
247
  }
240
248
 
241
- const DEFAULT_DEPENDENCIES: OmpSettingsDependencies = {
249
+ export const ompSettingsDependencies: OmpSettingsDependencies = {
242
250
  resolveExecutable: resolveOmpExecutable,
243
251
  runConfig: runOmpConfig,
244
252
  validateProjectConfig: validateOmpProjectConfig,
@@ -347,7 +355,7 @@ export async function listOmpSettingsWithDependencies(
347
355
  export async function resolveListOmpSettings(
348
356
  input: RpcInput<typeof listOmpSettings>,
349
357
  ): Promise<CatalogResult> {
350
- return listOmpSettingsWithDependencies(input, DEFAULT_DEPENDENCIES);
358
+ return listOmpSettingsWithDependencies(input, ompSettingsDependencies);
351
359
  }
352
360
 
353
361
  export async function updateOmpSettingsWithDependencies(
@@ -500,10 +508,15 @@ export async function updateOmpSettingsWithDependencies(
500
508
 
501
509
  const settingsMutationQueue = new SerialMutationQueue();
502
510
 
511
+ /** Settings and skill edits share this queue so they never write one config file at once. */
512
+ export function runSettingsMutation<T>(operation: () => Promise<T>): Promise<T> {
513
+ return settingsMutationQueue.run(operation);
514
+ }
515
+
503
516
  export function resolveUpdateOmpSettings(
504
517
  input: RpcInput<typeof updateOmpSettings>,
505
518
  ): Promise<OmpSettingsUpdateResult> {
506
- return settingsMutationQueue.run(() =>
507
- updateOmpSettingsWithDependencies(input, DEFAULT_DEPENDENCIES),
519
+ return runSettingsMutation(() =>
520
+ updateOmpSettingsWithDependencies(input, ompSettingsDependencies),
508
521
  );
509
522
  }
@@ -0,0 +1,259 @@
1
+ import { lstat, realpath } from "node:fs/promises";
2
+ import { basename, dirname, join, resolve } from "node:path";
3
+ import type { RpcInput } from "@getpaseo/plugin";
4
+ import { z } from "zod";
5
+ import type {
6
+ deleteOmpManagedSkill,
7
+ listOmpSkills,
8
+ OmpSkill,
9
+ OmpSkillList,
10
+ OmpSkillOff,
11
+ OmpSkillsList,
12
+ setOmpSkillEnabled,
13
+ } from "../shared/omp-skills";
14
+ import { SKILL_ENTRY_PREFIX } from "../shared/omp-skills";
15
+ import {
16
+ inOmpScope,
17
+ type OmpRulesDependencies,
18
+ ompCommandDependencies,
19
+ readSetting,
20
+ runJson,
21
+ } from "./omp-rules";
22
+ import {
23
+ type OmpSettingsDependencies,
24
+ ompSettingsDependencies,
25
+ readProjectConfigText,
26
+ runSettingsMutation,
27
+ writeProjectChanges,
28
+ } from "./omp-settings";
29
+ import { ompAgentDir } from "./paths";
30
+ import { OmpPublicError } from "./provider/security";
31
+
32
+ const MAX_SKILLS = 500;
33
+ const MAX_OFF_ENTRIES = 200;
34
+ const MAX_TEXT_CHARS = 2_000;
35
+ const MANAGED_SOURCE = "omp-managed";
36
+ const UNREADABLE_CONFIG = "The workspace OMP configuration could not be read";
37
+
38
+ export class OmpSkillsError extends OmpPublicError {}
39
+
40
+ export interface OmpSkillsDependencies extends OmpRulesDependencies {
41
+ validateProjectConfig: OmpSettingsDependencies["validateProjectConfig"];
42
+ }
43
+
44
+ /** One entry of `omp skill list --json`. */
45
+ const SkillEntrySchema = z.object({
46
+ name: z.string().min(1).max(256),
47
+ description: z
48
+ .string()
49
+ .nullish()
50
+ .transform((text) => (text ?? "").slice(0, MAX_TEXT_CHARS)),
51
+ baseDir: z.string().min(1).max(4_096),
52
+ source: z.string().min(1).max(128),
53
+ });
54
+ const SkillListSchema = z.object({ skills: z.array(z.unknown()) });
55
+ const ListSettingSchema = z.object({ value: z.array(z.string()) });
56
+
57
+ /** A source reads `<provider>:<level>`, such as `native:project` or `omp-managed:user`. */
58
+ function toSkill(entry: z.infer<typeof SkillEntrySchema>): OmpSkill {
59
+ const split = entry.source.lastIndexOf(":");
60
+ const provider = split < 0 ? entry.source : entry.source.slice(0, split);
61
+ const scope = split < 0 ? "" : entry.source.slice(split + 1);
62
+ return {
63
+ name: entry.name,
64
+ description: entry.description,
65
+ source: provider,
66
+ level: scope === "project" || scope === "user" ? scope : "other",
67
+ path: entry.baseDir,
68
+ managed: provider === MANAGED_SOURCE,
69
+ };
70
+ }
71
+
72
+ async function listSkills(
73
+ dependencies: OmpSkillsDependencies,
74
+ executable: string,
75
+ runIn: string,
76
+ ): Promise<OmpSkill[]> {
77
+ const raw = await runJson(dependencies, executable, ["skill", "list", "--json"], runIn);
78
+ const parsed = SkillListSchema.safeParse(raw);
79
+ if (!parsed.success) throw new OmpSkillsError("omp skill list gave output the plugin can't read");
80
+ return parsed.data.skills.slice(0, MAX_SKILLS).flatMap((entry) => {
81
+ const skill = SkillEntrySchema.safeParse(entry);
82
+ return skill.success ? [toSkill(skill.data)] : [];
83
+ });
84
+ }
85
+
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
+ /** OMP trims each entry. Only `skill:` entries of `disabledExtensions` concern skills. */
96
+ function offEntries(ignored: readonly string[], extensions: readonly string[]): OmpSkillOff[] {
97
+ const entries: OmpSkillOff[] = [
98
+ ...ignored.map((entry) => ({ list: "skills.ignoredSkills" as const, entry: entry.trim() })),
99
+ ...extensions
100
+ .map((entry) => entry.trim())
101
+ .filter(
102
+ (entry) => entry.startsWith(SKILL_ENTRY_PREFIX) && entry.length > SKILL_ENTRY_PREFIX.length,
103
+ )
104
+ .map((entry) => ({ list: "disabledExtensions" as const, entry })),
105
+ ];
106
+ const seen = new Set<string>();
107
+ return entries
108
+ .filter(({ list, entry }) => {
109
+ const key = `${list}\0${entry}`;
110
+ if (entry === "" || seen.has(key)) return false;
111
+ seen.add(key);
112
+ return true;
113
+ })
114
+ .slice(0, MAX_OFF_ENTRIES)
115
+ .map(({ list, entry }) => ({ list, entry: entry.slice(0, MAX_TEXT_CHARS) }));
116
+ }
117
+
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
+ export async function listOmpSkillsWithDependencies(
125
+ input: RpcInput<typeof listOmpSkills>,
126
+ dependencies: OmpSkillsDependencies,
127
+ ): Promise<OmpSkillsList> {
128
+ try {
129
+ const executable = await requireExecutable(dependencies);
130
+ return await inOmpScope(input.cwd, dependencies, async (runIn) => {
131
+ const [skills, ignored, extensions] = await Promise.all([
132
+ listSkills(dependencies, executable, runIn),
133
+ readList(dependencies, executable, "skills.ignoredSkills", runIn),
134
+ readList(dependencies, executable, "disabledExtensions", runIn),
135
+ ]);
136
+ return { status: "ready" as const, skills, off: offEntries(ignored, extensions) };
137
+ });
138
+ } catch (error) {
139
+ if (error instanceof OmpPublicError) return { status: "error", message: error.message };
140
+ throw error;
141
+ }
142
+ }
143
+
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
+ export async function setOmpSkillEnabledWithDependencies(
193
+ input: RpcInput<typeof setOmpSkillEnabled>,
194
+ dependencies: OmpSkillsDependencies,
195
+ ): Promise<{ status: "ok" } | { status: "error"; message: string }> {
196
+ try {
197
+ if (input.list === "disabledExtensions" && !input.entry.startsWith(SKILL_ENTRY_PREFIX)) {
198
+ throw new OmpSkillsError("That entry is not a skill");
199
+ }
200
+ const executable = await requireExecutable(dependencies);
201
+ await inOmpScope(input.cwd, dependencies, (runIn) =>
202
+ runSettingsMutation(() => writeList(input, dependencies, executable, runIn)),
203
+ );
204
+ return { status: "ok" };
205
+ } catch (error) {
206
+ if (error instanceof OmpPublicError) return { status: "error", message: error.message };
207
+ throw error;
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Deletes one agent-learned skill folder. The path must be a managed skill OMP lists right now
213
+ * and a real directory directly inside `<agent dir>/managed-skills`, so a client can never name
214
+ * anything else.
215
+ */
216
+ export async function deleteOmpManagedSkillWithDependencies(
217
+ input: RpcInput<typeof deleteOmpManagedSkill>,
218
+ dependencies: OmpSkillsDependencies,
219
+ ): Promise<{ status: "ok" } | { status: "error"; message: string }> {
220
+ try {
221
+ const executable = await requireExecutable(dependencies);
222
+ const skills = await inOmpScope(undefined, dependencies, (runIn) =>
223
+ listSkills(dependencies, executable, runIn),
224
+ );
225
+ const skill = skills.find((candidate) => candidate.managed && candidate.path === input.path);
226
+ if (!skill) throw new OmpSkillsError("That is not a skill the agent learned");
227
+ const root = join(await realpath(ompAgentDir()), "managed-skills");
228
+ const folder = await lstat(skill.path).catch(() => null);
229
+ const inside =
230
+ folder?.isDirectory() === true &&
231
+ skill.path === resolve(skill.path) &&
232
+ basename(skill.path) !== "" &&
233
+ (await realpath(dirname(skill.path))) === root;
234
+ if (!inside)
235
+ throw new OmpSkillsError("That skill folder is not in OMP's managed skills folder");
236
+ await dependencies.removeDir(skill.path);
237
+ return { status: "ok" };
238
+ } catch (error) {
239
+ if (error instanceof OmpPublicError) return { status: "error", message: error.message };
240
+ throw error;
241
+ }
242
+ }
243
+
244
+ const DEFAULT_DEPENDENCIES: OmpSkillsDependencies = {
245
+ ...ompCommandDependencies,
246
+ validateProjectConfig: ompSettingsDependencies.validateProjectConfig,
247
+ };
248
+
249
+ export function resolveListOmpSkills(input: RpcInput<typeof listOmpSkills>) {
250
+ return listOmpSkillsWithDependencies(input, DEFAULT_DEPENDENCIES);
251
+ }
252
+
253
+ export function resolveSetOmpSkillEnabled(input: RpcInput<typeof setOmpSkillEnabled>) {
254
+ return setOmpSkillEnabledWithDependencies(input, DEFAULT_DEPENDENCIES);
255
+ }
256
+
257
+ export function resolveDeleteOmpManagedSkill(input: RpcInput<typeof deleteOmpManagedSkill>) {
258
+ return deleteOmpManagedSkillWithDependencies(input, DEFAULT_DEPENDENCIES);
259
+ }
@@ -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.396.1"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.398.1"; // x-release-please-version
@@ -190,6 +190,7 @@ export type OmpSetting = z.infer<typeof OmpSettingSchema>;
190
190
  export const OMP_SETTING_CATEGORIES = [
191
191
  "appearance",
192
192
  "model",
193
+ "budget",
193
194
  "interaction",
194
195
  "context",
195
196
  "memory",
@@ -244,6 +245,7 @@ const CATEGORY_PREFIXES: Readonly<Record<OmpSettingCategory, readonly string[]>>
244
245
  "prewalk.",
245
246
  "tier.",
246
247
  ],
248
+ budget: ["session.warnCost", "session.maxCost"],
247
249
  interaction: [
248
250
  "autoResume",
249
251
  "power.",
@@ -325,6 +327,14 @@ export function formatOmpSettingLabel(path: string): string {
325
327
  return words ? `${words[0]?.toUpperCase() ?? ""}${words.slice(1)}` : path;
326
328
  }
327
329
 
330
+ /** OMP ships these without a description; unset means no cap. */
331
+ export const OMP_SETTING_FALLBACK_DESCRIPTIONS: Readonly<Record<string, string>> = {
332
+ "session.warnCost":
333
+ "Warn once when a session's spend reaches this many US dollars. Leave unset for no warning. Applies to every session, including subagents, and takes effect on the next request.",
334
+ "session.maxCost":
335
+ "Stop a session from sending new model requests once its spend reaches this many US dollars. Leave unset for no limit. Requests already in flight can finish past the limit; raise or reset the value to continue.",
336
+ };
337
+
328
338
  export const listOmpSettings = defineRpc({
329
339
  name: "paseo-omp.list-settings",
330
340
  input: z
@@ -0,0 +1,80 @@
1
+ import { defineRpc } from "@getpaseo/plugin";
2
+ import { z } from "zod";
3
+ import { OmpWorkspaceCwdSchema } from "./hub";
4
+ import { OmpStoreSchema } from "./omp-store";
5
+
6
+ /** A `disabledExtensions` entry for a skill reads `skill:<name>`. */
7
+ export const SKILL_ENTRY_PREFIX = "skill:";
8
+
9
+ export const OmpSkillLevelSchema = z.enum(["project", "user", "other"]);
10
+ export type OmpSkillLevel = z.infer<typeof OmpSkillLevelSchema>;
11
+
12
+ export const OmpSkillSchema = z.object({
13
+ name: z.string(),
14
+ description: z.string(),
15
+ /** OMP's provider id, such as `native`, `claude`, or `omp-managed`. */
16
+ source: z.string(),
17
+ level: OmpSkillLevelSchema,
18
+ /** The skill's folder. */
19
+ path: z.string(),
20
+ /** Written by the agent through autolearn (`omp-managed`); only these can be deleted here. */
21
+ managed: z.boolean(),
22
+ });
23
+ export type OmpSkill = z.infer<typeof OmpSkillSchema>;
24
+
25
+ /** The two lists that turn a skill off. A `disabledExtensions` entry reads `skill:<name>`. */
26
+ export const OmpSkillListSchema = z.enum(["skills.ignoredSkills", "disabledExtensions"]);
27
+ export type OmpSkillList = z.infer<typeof OmpSkillListSchema>;
28
+
29
+ /** OMP drops turned-off skills from its listing, so only the list entry is known. */
30
+ export const OmpSkillOffSchema = z.object({
31
+ list: OmpSkillListSchema,
32
+ /** The entry as written: a name or a glob, with `skill:` in `disabledExtensions`. */
33
+ entry: z.string(),
34
+ });
35
+ export type OmpSkillOff = z.infer<typeof OmpSkillOffSchema>;
36
+
37
+ export const OmpSkillsListSchema = z.discriminatedUnion("status", [
38
+ z.object({
39
+ status: z.literal("ready"),
40
+ skills: z.array(OmpSkillSchema),
41
+ off: z.array(OmpSkillOffSchema),
42
+ }),
43
+ z.object({ status: z.literal("error"), message: z.string() }),
44
+ ]);
45
+ export type OmpSkillsList = z.infer<typeof OmpSkillsListSchema>;
46
+
47
+ const OmpSkillsResultSchema = z.discriminatedUnion("status", [
48
+ z.object({ status: z.literal("ok") }),
49
+ z.object({ status: z.literal("error"), message: z.string() }),
50
+ ]);
51
+
52
+ const ScopeSchema = { store: OmpStoreSchema.optional(), cwd: OmpWorkspaceCwdSchema.optional() };
53
+
54
+ export const listOmpSkills = defineRpc({
55
+ name: "paseo-omp.list-skills",
56
+ input: z.object(ScopeSchema).strict(),
57
+ output: OmpSkillsListSchema,
58
+ });
59
+
60
+ /** Off adds `entry` to `list`; on removes it. A workspace writes its own `.omp/config.yml`. */
61
+ export const setOmpSkillEnabled = defineRpc({
62
+ name: "paseo-omp.set-skill-enabled",
63
+ input: z
64
+ .object({
65
+ ...ScopeSchema,
66
+ list: OmpSkillListSchema,
67
+ entry: z.string().trim().min(1).max(256),
68
+ enabled: z.boolean(),
69
+ })
70
+ .strict(),
71
+ output: OmpSkillsResultSchema,
72
+ });
73
+
74
+ export const deleteOmpManagedSkill = defineRpc({
75
+ name: "paseo-omp.delete-managed-skill",
76
+ input: z
77
+ .object({ store: OmpStoreSchema.optional(), path: z.string().min(1).max(4_096) })
78
+ .strict(),
79
+ output: OmpSkillsResultSchema,
80
+ });