@omercnet/paseo-omp 5.4.0 → 5.5.0-next.427.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/OVERVIEW.md +7 -1
- package/README.md +2 -1
- package/client/ast-edit.tsx +53 -0
- package/client/composer-pill-settings.tsx +0 -5
- package/client/config-sidebar.tsx +15 -0
- package/client/generated-image.tsx +79 -0
- package/client/lsp-diagnostics.tsx +69 -0
- package/client/omp-config-surface.tsx +438 -108
- package/client/omp-config-views.ts +32 -5
- package/client/omp-extensions-section.tsx +145 -0
- package/client/omp-local-models-section.tsx +215 -0
- package/client/omp-plugin-manager.tsx +198 -3
- package/client/omp-routing-editor.tsx +123 -2
- package/client/omp-rule-test.tsx +140 -0
- package/client/omp-rules-section.tsx +353 -0
- package/client/omp-security-section.tsx +99 -0
- package/client/omp-security-state.ts +14 -0
- package/client/omp-skills-section.tsx +195 -0
- package/client/omp-tool-config-section.tsx +204 -0
- package/client/omp-tool-policy-state.ts +101 -0
- package/client/omp-tool-policy.tsx +435 -0
- package/client/omp-update-row.tsx +87 -0
- package/client/provider-diagnostics-state.ts +38 -1
- package/client/provider-image.tsx +1 -1
- package/client/rule-notice.tsx +33 -0
- package/client/sidebar-compat.ts +0 -109
- package/client/web.ts +34 -0
- package/index.client.tsx +79 -46
- package/index.server.ts +77 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
- package/server/generated-images.ts +57 -0
- package/server/omp-agents.ts +170 -0
- package/server/omp-extensions.ts +235 -0
- package/server/omp-list-setting.ts +98 -0
- package/server/omp-local-models.ts +202 -0
- package/server/omp-models-file.ts +178 -0
- package/server/omp-plugins.ts +182 -0
- package/server/omp-prompt-files.ts +41 -0
- package/server/omp-rule-firings.ts +211 -0
- package/server/omp-rule-switch.ts +38 -0
- package/server/omp-rule-test.ts +82 -0
- package/server/omp-rules.ts +452 -0
- package/server/omp-security.ts +169 -0
- package/server/omp-settings.ts +92 -16
- package/server/omp-skills.ts +179 -0
- package/server/omp-tool-config.ts +144 -0
- package/server/omp-update.ts +203 -0
- package/server/package-version.ts +1 -1
- package/server/provider/connection.ts +1 -1
- package/server/provider/image-cache.ts +1 -1
- package/server/provider/omp-rpc-environment.ts +1 -1
- package/server/provider/session-descriptors.ts +3 -0
- package/server/provider-diagnostics.ts +26 -4
- package/server/regular-file.ts +30 -0
- package/server/rule-notices.ts +112 -0
- package/server/turn-rows.ts +59 -0
- package/server/turn-screenshots.ts +140 -0
- package/shared/ast-edit.ts +124 -0
- package/shared/composer-pill-settings.ts +0 -2
- package/shared/generated-image.ts +68 -0
- package/shared/lsp-diagnostics.ts +141 -0
- package/shared/omp-agents.ts +26 -0
- package/shared/omp-extensions.ts +45 -0
- package/shared/omp-local-models.ts +44 -0
- package/shared/omp-models-file.ts +30 -0
- package/shared/omp-plugins.ts +90 -0
- package/shared/omp-prompt-files.ts +24 -0
- package/shared/omp-rules.ts +134 -0
- package/shared/omp-security.ts +50 -0
- package/shared/omp-settings.ts +211 -2
- package/shared/omp-skills.ts +80 -0
- package/shared/omp-tool-config.ts +283 -0
- package/shared/omp-update.ts +27 -0
- package/shared/provider-image.ts +10 -3
- package/shared/rule-notices.ts +20 -0
- package/client/hub-sidebar.tsx +0 -99
- package/client/sessions-popover.tsx +0 -78
- package/server/sessions.ts +0 -58
- package/shared/sessions.ts +0 -24
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { copyText, Icon, useToast } from "@getpaseo/plugin/client/ui";
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Pressable, Switch, Text, View } from "react-native";
|
|
6
|
+
import {
|
|
7
|
+
listOmpRuleFirings,
|
|
8
|
+
listOmpRules,
|
|
9
|
+
type OmpRule,
|
|
10
|
+
type OmpRuleFiring,
|
|
11
|
+
type OmpRuleKind,
|
|
12
|
+
setOmpRuleEnabled,
|
|
13
|
+
} from "../shared/omp-rules";
|
|
14
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
15
|
+
import { describe } from "./omp-accounts-section";
|
|
16
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
17
|
+
import { OmpRuleTest } from "./omp-rule-test";
|
|
18
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
19
|
+
|
|
20
|
+
type Theme = PluginSurfaceProps["theme"];
|
|
21
|
+
type CopyState = "idle" | "copied" | "failed";
|
|
22
|
+
|
|
23
|
+
const COPY_LABELS: Record<CopyState, string> = {
|
|
24
|
+
idle: "Copy path",
|
|
25
|
+
copied: "Copied",
|
|
26
|
+
failed: "Copy failed",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const RULES_KEY = ["paseo-omp", "rules"] as const;
|
|
30
|
+
const FIRINGS_KEY = ["paseo-omp", "rule-firings"] as const;
|
|
31
|
+
const MOST_FIRED = 3;
|
|
32
|
+
|
|
33
|
+
function firingText(firing: OmpRuleFiring): string {
|
|
34
|
+
const times = firing.count === 1 ? "1 time" : `${firing.count} times`;
|
|
35
|
+
return firing.lastFiredAt
|
|
36
|
+
? `${times}, last ${new Date(firing.lastFiredAt).toLocaleString()}`
|
|
37
|
+
: times;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function firedSummary(counted: {
|
|
41
|
+
firings: readonly OmpRuleFiring[];
|
|
42
|
+
sessions: number;
|
|
43
|
+
partial: boolean;
|
|
44
|
+
}): string {
|
|
45
|
+
const top = counted.firings
|
|
46
|
+
.slice(0, MOST_FIRED)
|
|
47
|
+
.map((firing) => `${firing.name} (${firing.count})`)
|
|
48
|
+
.join(", ");
|
|
49
|
+
const sessions = `${counted.sessions} ${counted.sessions === 1 ? "session" : "sessions"}`;
|
|
50
|
+
const bound = counted.partial ? ", so some firings are not counted" : "";
|
|
51
|
+
return top
|
|
52
|
+
? `Most fired: ${top}. Counted by rule name from ${sessions}${bound}.`
|
|
53
|
+
: `No rule fired in the ${sessions} counted${bound}.`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const GROUPS: readonly { kind: OmpRuleKind; title: string; empty: string }[] = [
|
|
57
|
+
{ kind: "watch", title: "Watch", empty: "No watch rules" },
|
|
58
|
+
{ kind: "always", title: "Always applied", empty: "No always-applied rules" },
|
|
59
|
+
{ kind: "rulebook", title: "Rulebook", empty: "No rulebook rules" },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
function sourceLabel(rule: OmpRule): string {
|
|
63
|
+
if (rule.source === "project") return "Project";
|
|
64
|
+
if (rule.source === "user") return "User";
|
|
65
|
+
if (rule.source === "builtin") return "Built-in";
|
|
66
|
+
if (rule.provider === "omp-plugins") return "From an OMP plugin";
|
|
67
|
+
return `Imported from ${rule.provider}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function Detail({
|
|
71
|
+
styles,
|
|
72
|
+
label,
|
|
73
|
+
value,
|
|
74
|
+
}: {
|
|
75
|
+
styles: OmpConfigStyles;
|
|
76
|
+
label: string;
|
|
77
|
+
value: string;
|
|
78
|
+
}) {
|
|
79
|
+
return (
|
|
80
|
+
<View style={styles.recordRow}>
|
|
81
|
+
<Text style={styles.recordKey}>{label}</Text>
|
|
82
|
+
<Text selectable style={styles.recordValue}>
|
|
83
|
+
{value}
|
|
84
|
+
</Text>
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface RuleSwitch {
|
|
90
|
+
busy: boolean;
|
|
91
|
+
toggle: (name: string, enabled: boolean) => void;
|
|
92
|
+
/** How often the rule fired in the counted sessions; null until they are counted. */
|
|
93
|
+
firingLabel: (name: string) => string | null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function RuleRow({
|
|
97
|
+
styles,
|
|
98
|
+
rule,
|
|
99
|
+
rules,
|
|
100
|
+
}: {
|
|
101
|
+
styles: OmpConfigStyles;
|
|
102
|
+
rule: OmpRule;
|
|
103
|
+
rules: RuleSwitch;
|
|
104
|
+
}) {
|
|
105
|
+
const [copyState, setCopyState] = useState<CopyState>("idle");
|
|
106
|
+
async function copyPath() {
|
|
107
|
+
try {
|
|
108
|
+
await copyText(rule.path);
|
|
109
|
+
setCopyState("copied");
|
|
110
|
+
} catch {
|
|
111
|
+
setCopyState("failed");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const details: [string, string[]][] = [
|
|
115
|
+
["Text matches", rule.condition],
|
|
116
|
+
["Code matches", rule.astCondition],
|
|
117
|
+
["Asks the judge", rule.question ? [rule.question] : []],
|
|
118
|
+
["Watches", rule.scope],
|
|
119
|
+
["Files", rule.globs],
|
|
120
|
+
["Agents", rule.agents],
|
|
121
|
+
];
|
|
122
|
+
// Only watch rules fire; always-applied and rulebook rules sit in the prompt.
|
|
123
|
+
const fired = rule.kind === "watch" ? rules.firingLabel(rule.name) : null;
|
|
124
|
+
return (
|
|
125
|
+
<View style={styles.setting}>
|
|
126
|
+
<View style={styles.settingHeader}>
|
|
127
|
+
<Text selectable style={styles.settingValue}>
|
|
128
|
+
{rule.name}
|
|
129
|
+
</Text>
|
|
130
|
+
<Text style={styles.source}>{sourceLabel(rule)}</Text>
|
|
131
|
+
<Switch
|
|
132
|
+
accessibilityLabel={`Rule ${rule.name} is on`}
|
|
133
|
+
disabled={rules.busy}
|
|
134
|
+
value
|
|
135
|
+
onValueChange={() => rules.toggle(rule.name, false)}
|
|
136
|
+
/>
|
|
137
|
+
</View>
|
|
138
|
+
{rule.description ? <Text style={styles.settingDescription}>{rule.description}</Text> : null}
|
|
139
|
+
{fired ? <Detail styles={styles} label="Fired" value={fired} /> : null}
|
|
140
|
+
{details.map(([label, values]) =>
|
|
141
|
+
values.length > 0 ? (
|
|
142
|
+
<Detail key={label} styles={styles} label={label} value={values.join(", ")} />
|
|
143
|
+
) : null,
|
|
144
|
+
)}
|
|
145
|
+
<View style={styles.settingHeader}>
|
|
146
|
+
<Text selectable style={styles.settingPath}>
|
|
147
|
+
{rule.path}
|
|
148
|
+
</Text>
|
|
149
|
+
<Pressable
|
|
150
|
+
accessibilityRole="button"
|
|
151
|
+
accessibilityLabel={`Copy the path of rule ${rule.name}`}
|
|
152
|
+
onPress={copyPath}
|
|
153
|
+
>
|
|
154
|
+
<Text style={styles.resetAction}>{COPY_LABELS[copyState]}</Text>
|
|
155
|
+
</Pressable>
|
|
156
|
+
</View>
|
|
157
|
+
</View>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function BuiltinRules({
|
|
162
|
+
theme,
|
|
163
|
+
styles,
|
|
164
|
+
rules,
|
|
165
|
+
rulesSwitch,
|
|
166
|
+
}: {
|
|
167
|
+
theme: Theme;
|
|
168
|
+
styles: OmpConfigStyles;
|
|
169
|
+
rules: OmpRule[];
|
|
170
|
+
rulesSwitch: RuleSwitch;
|
|
171
|
+
}) {
|
|
172
|
+
const [expanded, setExpanded] = useState(false);
|
|
173
|
+
if (rules.length === 0) return null;
|
|
174
|
+
return (
|
|
175
|
+
<>
|
|
176
|
+
<Pressable
|
|
177
|
+
accessibilityRole="button"
|
|
178
|
+
accessibilityState={{ expanded }}
|
|
179
|
+
accessibilityLabel={`${expanded ? "Hide" : "Show"} ${rules.length} built-in rules`}
|
|
180
|
+
onPress={() => setExpanded(!expanded)}
|
|
181
|
+
style={[styles.setting, styles.sectionHeaderRow]}
|
|
182
|
+
>
|
|
183
|
+
<Icon
|
|
184
|
+
name={expanded ? "ChevronDown" : "ChevronRight"}
|
|
185
|
+
size={14}
|
|
186
|
+
color={theme.colors.foregroundMuted}
|
|
187
|
+
/>
|
|
188
|
+
<Text style={styles.rowValue}>Built-in rules ({rules.length})</Text>
|
|
189
|
+
</Pressable>
|
|
190
|
+
{expanded
|
|
191
|
+
? rules.map((rule) => (
|
|
192
|
+
<RuleRow key={rule.name} styles={styles} rule={rule} rules={rulesSwitch} />
|
|
193
|
+
))
|
|
194
|
+
: null}
|
|
195
|
+
</>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function OmpRulesSection({
|
|
200
|
+
theme,
|
|
201
|
+
styles,
|
|
202
|
+
cwd,
|
|
203
|
+
store,
|
|
204
|
+
focusRule,
|
|
205
|
+
}: {
|
|
206
|
+
theme: Theme;
|
|
207
|
+
styles: OmpConfigStyles;
|
|
208
|
+
cwd?: string;
|
|
209
|
+
store?: OmpStore;
|
|
210
|
+
/** The rule a "fired" link opened this tab for, shown first. */
|
|
211
|
+
focusRule?: string;
|
|
212
|
+
}) {
|
|
213
|
+
const loadRules = useRpc(listOmpRules);
|
|
214
|
+
const setEnabled = useRpc(setOmpRuleEnabled);
|
|
215
|
+
const toast = useToast();
|
|
216
|
+
const queryClient = useQueryClient();
|
|
217
|
+
const rules = useQuery({
|
|
218
|
+
queryKey: [...RULES_KEY, ompStoreKey(store), cwd ?? "global"],
|
|
219
|
+
queryFn: () => loadRules({ store, ...(cwd ? { cwd } : {}) }),
|
|
220
|
+
});
|
|
221
|
+
const loadFirings = useRpc(listOmpRuleFirings);
|
|
222
|
+
const firingsQuery = useQuery({
|
|
223
|
+
queryKey: [...FIRINGS_KEY, ompStoreKey(store), cwd ?? "global"],
|
|
224
|
+
queryFn: () => loadFirings({ store, ...(cwd ? { cwd } : {}) }),
|
|
225
|
+
staleTime: 30_000,
|
|
226
|
+
});
|
|
227
|
+
const counted = firingsQuery.data;
|
|
228
|
+
const firingByName = new Map((counted?.firings ?? []).map((firing) => [firing.name, firing]));
|
|
229
|
+
function firingLabel(name: string): string | null {
|
|
230
|
+
const firing = firingByName.get(name);
|
|
231
|
+
if (firing) return firingText(firing);
|
|
232
|
+
return counted && !counted.partial ? "Not fired in the sessions counted" : null;
|
|
233
|
+
}
|
|
234
|
+
function noisiestFirst(left: OmpRule, right: OmpRule): number {
|
|
235
|
+
return (firingByName.get(right.name)?.count ?? 0) - (firingByName.get(left.name)?.count ?? 0);
|
|
236
|
+
}
|
|
237
|
+
const toggle = useMutation({
|
|
238
|
+
mutationKey: [...RULES_KEY, "toggle"],
|
|
239
|
+
mutationFn: (change: { name: string; enabled: boolean }) =>
|
|
240
|
+
setEnabled({ store, ...(cwd ? { cwd } : {}), ...change }),
|
|
241
|
+
onSuccess: async (result) => {
|
|
242
|
+
if (result.status === "error") toast.error(result.message);
|
|
243
|
+
await queryClient.invalidateQueries({ queryKey: RULES_KEY });
|
|
244
|
+
},
|
|
245
|
+
onError: (error) => toast.error(describe(error)),
|
|
246
|
+
});
|
|
247
|
+
const rulesSwitch: RuleSwitch = {
|
|
248
|
+
busy: toggle.isPending,
|
|
249
|
+
toggle: (name, enabled) => toggle.mutate({ name, enabled }),
|
|
250
|
+
firingLabel,
|
|
251
|
+
};
|
|
252
|
+
const list = rules.data;
|
|
253
|
+
const focused =
|
|
254
|
+
list?.status === "ready" ? list.rules.find((rule) => rule.name === focusRule) : undefined;
|
|
255
|
+
const focusNote =
|
|
256
|
+
list?.status === "ready" && list.disabled.includes(focusRule ?? "")
|
|
257
|
+
? "This rule is turned off. Switch it on under Turned off below."
|
|
258
|
+
: "No rule with this name is in this scope.";
|
|
259
|
+
return (
|
|
260
|
+
<>
|
|
261
|
+
<View style={styles.sectionHeader}>
|
|
262
|
+
<Text style={styles.sectionTitle}>Rules</Text>
|
|
263
|
+
<Text style={styles.muted}>
|
|
264
|
+
Watch rules step in when the agent writes something they match. Always-applied rules are
|
|
265
|
+
part of every prompt. Rulebook rules are listed by name and read when relevant. Changes
|
|
266
|
+
apply to new sessions, or after an agent reload.
|
|
267
|
+
</Text>
|
|
268
|
+
<Text style={styles.muted}>
|
|
269
|
+
Rules imported from other tools, such as Cursor or Windsurf, appear here only when they
|
|
270
|
+
are watch rules.
|
|
271
|
+
</Text>
|
|
272
|
+
<Text style={styles.muted}>Rule settings (ttsr.*) are in the Configuration tab.</Text>
|
|
273
|
+
</View>
|
|
274
|
+
{counted ? <Text style={styles.muted}>{firedSummary(counted)}</Text> : null}
|
|
275
|
+
{focusRule && list?.status === "ready" ? (
|
|
276
|
+
<View style={styles.card}>
|
|
277
|
+
<Text style={styles.cardTitle}>Rule named {focusRule}</Text>
|
|
278
|
+
<Text style={styles.muted}>
|
|
279
|
+
Matched by name in this scope. If the rule that fired came from a project's .omp folder,
|
|
280
|
+
look in that workspace's OMP tab.
|
|
281
|
+
</Text>
|
|
282
|
+
{focused ? (
|
|
283
|
+
<RuleRow styles={styles} rule={focused} rules={rulesSwitch} />
|
|
284
|
+
) : (
|
|
285
|
+
<Text style={styles.muted}>{focusNote}</Text>
|
|
286
|
+
)}
|
|
287
|
+
</View>
|
|
288
|
+
) : null}
|
|
289
|
+
<OmpRuleTest theme={theme} styles={styles} cwd={cwd} store={store} />
|
|
290
|
+
{rules.isLoading ? <Text style={styles.muted}>Loading rules...</Text> : null}
|
|
291
|
+
{rules.error ? (
|
|
292
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
293
|
+
Could not list OMP's rules.
|
|
294
|
+
</Text>
|
|
295
|
+
) : null}
|
|
296
|
+
{list?.status === "error" ? (
|
|
297
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
298
|
+
{list.message}
|
|
299
|
+
</Text>
|
|
300
|
+
) : null}
|
|
301
|
+
{list?.status === "ready" ? (
|
|
302
|
+
<>
|
|
303
|
+
{GROUPS.map((group) => {
|
|
304
|
+
const members = list.rules.filter((rule) => rule.kind === group.kind);
|
|
305
|
+
const own = members.filter((rule) => rule.source !== "builtin").sort(noisiestFirst);
|
|
306
|
+
const builtin = members.filter((rule) => rule.source === "builtin").sort(noisiestFirst);
|
|
307
|
+
return (
|
|
308
|
+
<View key={group.kind} style={styles.card}>
|
|
309
|
+
<Text style={styles.cardTitle}>{group.title}</Text>
|
|
310
|
+
{members.length === 0 ? <Text style={styles.muted}>{group.empty}</Text> : null}
|
|
311
|
+
{own.map((rule) => (
|
|
312
|
+
<RuleRow key={rule.name} styles={styles} rule={rule} rules={rulesSwitch} />
|
|
313
|
+
))}
|
|
314
|
+
<BuiltinRules
|
|
315
|
+
theme={theme}
|
|
316
|
+
styles={styles}
|
|
317
|
+
rules={builtin}
|
|
318
|
+
rulesSwitch={rulesSwitch}
|
|
319
|
+
/>
|
|
320
|
+
{group.kind === "watch" && !list.builtinRules ? (
|
|
321
|
+
<Text style={styles.muted}>Built-in rules are off (ttsr.builtinRules)</Text>
|
|
322
|
+
) : null}
|
|
323
|
+
</View>
|
|
324
|
+
);
|
|
325
|
+
})}
|
|
326
|
+
<View style={styles.card}>
|
|
327
|
+
<Text style={styles.cardTitle}>Turned off</Text>
|
|
328
|
+
{list.disabled.length === 0 ? (
|
|
329
|
+
<Text style={styles.muted}>No rules turned off</Text>
|
|
330
|
+
) : (
|
|
331
|
+
<>
|
|
332
|
+
<Text style={styles.muted}>Listed in ttsr.disabledRules, so OMP skips them</Text>
|
|
333
|
+
{list.disabled.map((name) => (
|
|
334
|
+
<View key={name} style={[styles.setting, styles.settingHeader]}>
|
|
335
|
+
<Text selectable style={styles.settingValue}>
|
|
336
|
+
{name}
|
|
337
|
+
</Text>
|
|
338
|
+
<Switch
|
|
339
|
+
accessibilityLabel={`Rule ${name} is off`}
|
|
340
|
+
disabled={rulesSwitch.busy}
|
|
341
|
+
value={false}
|
|
342
|
+
onValueChange={() => rulesSwitch.toggle(name, true)}
|
|
343
|
+
/>
|
|
344
|
+
</View>
|
|
345
|
+
))}
|
|
346
|
+
</>
|
|
347
|
+
)}
|
|
348
|
+
</View>
|
|
349
|
+
</>
|
|
350
|
+
) : null}
|
|
351
|
+
</>
|
|
352
|
+
);
|
|
353
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import {
|
|
3
|
+
SettingsAction,
|
|
4
|
+
SettingsCard,
|
|
5
|
+
SettingsRow,
|
|
6
|
+
SettingsSection,
|
|
7
|
+
} from "@getpaseo/plugin/client/ui";
|
|
8
|
+
import { useQuery } from "@tanstack/react-query";
|
|
9
|
+
import { Text, View } from "react-native";
|
|
10
|
+
import { listOmpSecurity, type OmpSecurityScan } from "../shared/omp-security";
|
|
11
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
12
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
13
|
+
import { SECURITY_QUERY_KEY, severityText } from "./omp-security-state";
|
|
14
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
15
|
+
|
|
16
|
+
const INFO =
|
|
17
|
+
"Scans the agent ran with OMP's security_scan tool for this project, read through omp itself. Only each scan's phase and finding counts are shown: findings are private, so titles, locations and reports stay in OMP. Starting, cancelling or validating a scan happens inside an agent session; ask the agent. Opening this tab makes OMP create an empty store entry for the project.";
|
|
18
|
+
|
|
19
|
+
/** A refetch runs up to 22 omp processes, so it is manual or at most once a minute. */
|
|
20
|
+
const STALE_MS = 60_000;
|
|
21
|
+
|
|
22
|
+
function rowLabel(scan: OmpSecurityScan): string {
|
|
23
|
+
const noun = scan.findingCount === 1 ? "finding" : "findings";
|
|
24
|
+
return `${scan.phase} · ${scan.findingCount} ${noun}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function OmpSecuritySection({
|
|
28
|
+
styles,
|
|
29
|
+
cwd,
|
|
30
|
+
store,
|
|
31
|
+
}: {
|
|
32
|
+
styles: OmpConfigStyles;
|
|
33
|
+
cwd: string;
|
|
34
|
+
store?: OmpStore;
|
|
35
|
+
}) {
|
|
36
|
+
const load = useRpc(listOmpSecurity);
|
|
37
|
+
const security = useQuery({
|
|
38
|
+
queryKey: [...SECURITY_QUERY_KEY, ompStoreKey(store), cwd],
|
|
39
|
+
queryFn: () => load({ store, cwd }),
|
|
40
|
+
staleTime: STALE_MS,
|
|
41
|
+
refetchOnWindowFocus: false,
|
|
42
|
+
});
|
|
43
|
+
const list = security.data;
|
|
44
|
+
return (
|
|
45
|
+
<View style={{ gap: 12 }}>
|
|
46
|
+
<SettingsSection title="Security scans" info={INFO}>
|
|
47
|
+
<SettingsCard>
|
|
48
|
+
<SettingsAction
|
|
49
|
+
label="Refresh list"
|
|
50
|
+
hint="Read the scans from omp again"
|
|
51
|
+
actionLabel={security.isFetching ? "Refreshing..." : "Refresh"}
|
|
52
|
+
disabled={security.isFetching}
|
|
53
|
+
onPress={() => void security.refetch()}
|
|
54
|
+
/>
|
|
55
|
+
</SettingsCard>
|
|
56
|
+
</SettingsSection>
|
|
57
|
+
{security.isLoading ? <Text style={styles.muted}>Loading security scans...</Text> : null}
|
|
58
|
+
{security.error ? (
|
|
59
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
60
|
+
Could not read OMP's security scans.
|
|
61
|
+
</Text>
|
|
62
|
+
) : null}
|
|
63
|
+
{list?.status === "error" ? (
|
|
64
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
65
|
+
{list.message}
|
|
66
|
+
</Text>
|
|
67
|
+
) : null}
|
|
68
|
+
{list?.status === "off" ? (
|
|
69
|
+
<Text style={styles.muted}>
|
|
70
|
+
Security scans are off. Turn on security.enabled in the Configuration tab to use them.
|
|
71
|
+
</Text>
|
|
72
|
+
) : null}
|
|
73
|
+
{list?.status === "ready" && list.scans.length === 0 ? (
|
|
74
|
+
<Text style={styles.muted}>No scans are stored for this project</Text>
|
|
75
|
+
) : null}
|
|
76
|
+
{list?.status === "ready" && list.skipped > 0 ? (
|
|
77
|
+
<Text style={styles.muted}>
|
|
78
|
+
{`${list.skipped} ${list.skipped === 1 ? "entry" : "entries"} in OMP's scan list could not be read`}
|
|
79
|
+
</Text>
|
|
80
|
+
) : null}
|
|
81
|
+
{list?.status === "ready" && list.scans.length > 0 ? (
|
|
82
|
+
<SettingsSection title="Scans">
|
|
83
|
+
<SettingsCard>
|
|
84
|
+
{list.scans.map((scan) => (
|
|
85
|
+
<SettingsRow
|
|
86
|
+
key={scan.id}
|
|
87
|
+
label={rowLabel(scan)}
|
|
88
|
+
hint={`${severityText(scan)} · ${scan.producer} · ${scan.createdAt}`}
|
|
89
|
+
/>
|
|
90
|
+
))}
|
|
91
|
+
</SettingsCard>
|
|
92
|
+
{list.truncated ? (
|
|
93
|
+
<Text style={styles.muted}>Only the first scans OMP lists are shown</Text>
|
|
94
|
+
) : null}
|
|
95
|
+
</SettingsSection>
|
|
96
|
+
) : null}
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OMP_SECURITY_SEVERITIES, type OmpSecurityScan } from "../shared/omp-security";
|
|
2
|
+
|
|
3
|
+
/** The security tab's query key prefix, invalidated when a setting such as security.enabled is saved. */
|
|
4
|
+
export const SECURITY_QUERY_KEY = ["paseo-omp", "security"] as const;
|
|
5
|
+
|
|
6
|
+
/** The per-severity counts of one scan, worded for both a cut-short list and a failed read. */
|
|
7
|
+
export function severityText(scan: OmpSecurityScan): string {
|
|
8
|
+
if (scan.findingCount === 0) return "No findings";
|
|
9
|
+
const listed = OMP_SECURITY_SEVERITIES.flatMap((level) =>
|
|
10
|
+
scan.severities[level] ? [`${scan.severities[level]} ${level}`] : [],
|
|
11
|
+
).join(", ");
|
|
12
|
+
if (scan.severitiesComplete) return listed;
|
|
13
|
+
return listed === "" ? "Severity counts unavailable" : `${listed} (counts may be incomplete)`;
|
|
14
|
+
}
|
|
@@ -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
|
+
}
|