@koinzhang/paseo-plugin-customize 0.2.0 → 0.3.0
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/CHANGELOG.md +43 -0
- package/README.md +6 -2
- package/client/design-tokens.ts +6 -0
- package/client/dropdown.tsx +41 -34
- package/client/entry-card.tsx +86 -0
- package/client/entry-row.tsx +16 -4
- package/client/grid.test.ts +19 -0
- package/client/grid.ts +18 -0
- package/client/mechanism-card.tsx +74 -42
- package/client/preview-pane.tsx +10 -3
- package/client/provider-options.test.ts +16 -5
- package/client/provider-options.ts +14 -3
- package/client/selection-settings.test.ts +5 -2
- package/client/slash-command.test.ts +23 -6
- package/client/surface.tsx +181 -118
- package/client/ui.tsx +25 -1
- package/index.client.tsx +3 -3
- package/package.json +1 -1
- package/server/compatibility.test.ts +13 -0
- package/server/handlers.ts +9 -4
- package/server/provider-version.test.ts +74 -0
- package/server/provider-version.ts +60 -0
- package/server/providers/opencode.ts +25 -8
- package/server/providers.test.ts +48 -3
- package/server/scan-kit.ts +2 -1
- package/server/scan-snapshot.test.ts +9 -9
- package/server/scan-snapshot.ts +1 -1
- package/server/tokens.test.ts +146 -0
- package/server/tokens.ts +178 -0
- package/shared/contracts.ts +14 -0
- package/shared/i18n.ts +29 -0
- package/shared/mechanisms.ts +15 -5
- package/shared/selection-settings.ts +1 -0
|
@@ -7,29 +7,40 @@ export interface ProviderSnapshotOptionEntry {
|
|
|
7
7
|
label?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export type ProviderMenuGroup = "builtin" | "acp";
|
|
11
|
+
|
|
10
12
|
export interface ProviderMenuOption {
|
|
11
13
|
id: ProviderId;
|
|
12
14
|
label: string;
|
|
13
15
|
badge: string;
|
|
16
|
+
group: ProviderMenuGroup;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
const BUILTIN_IDS = new Set<ProviderId>(["claude", "codex", "copilot", "opencode", "pi", "omp"]);
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
const GROUP_ORDER: Record<ProviderMenuGroup, number> = { builtin: 0, acp: 1 };
|
|
22
|
+
|
|
23
|
+
/** Only providers with a Customize scanner can be offered; built-ins come first, each group by name. */
|
|
19
24
|
export function enabledProviderOptions(
|
|
20
25
|
entries: readonly ProviderSnapshotOptionEntry[],
|
|
21
26
|
builtinLabel: string,
|
|
22
27
|
): ProviderMenuOption[] {
|
|
23
28
|
const byId = new Map(entries.map((entry) => [entry.provider, entry]));
|
|
24
|
-
|
|
29
|
+
const options = PROVIDER_IDS.flatMap<ProviderMenuOption>((id) => {
|
|
25
30
|
const entry = byId.get(id);
|
|
26
31
|
if (!entry?.enabled) return [];
|
|
32
|
+
const acp = entry.source === "custom" || (entry.source == null && !BUILTIN_IDS.has(id));
|
|
27
33
|
return [{
|
|
28
34
|
id,
|
|
29
35
|
label: entry.label || PROVIDER_LABELS[id],
|
|
30
|
-
badge:
|
|
36
|
+
badge: acp ? "ACP" : builtinLabel,
|
|
37
|
+
group: acp ? "acp" : "builtin",
|
|
31
38
|
}];
|
|
32
39
|
});
|
|
40
|
+
return options.sort((a, b) =>
|
|
41
|
+
GROUP_ORDER[a.group] - GROUP_ORDER[b.group]
|
|
42
|
+
|| a.label.localeCompare(b.label, undefined, { sensitivity: "base" }),
|
|
43
|
+
);
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
export function selectedProvider(saved: ProviderId, options: readonly ProviderMenuOption[]): ProviderId | null {
|
|
@@ -3,14 +3,17 @@ import { test } from "node:test";
|
|
|
3
3
|
import { selectionSettings } from "../shared/selection-settings.ts";
|
|
4
4
|
|
|
5
5
|
test("board selection defaults only before a project is chosen", () => {
|
|
6
|
-
assert.deepEqual(selectionSettings.schema.parse({}), { provider: "claude", projectRoot: null });
|
|
6
|
+
assert.deepEqual(selectionSettings.schema.parse({}), { provider: "claude", projectRoot: null, layout: "list" });
|
|
7
7
|
assert.deepEqual(selectionSettings.schema.parse({ provider: "codex", projectRoot: "" }), {
|
|
8
8
|
provider: "codex",
|
|
9
9
|
projectRoot: "",
|
|
10
|
+
layout: "list",
|
|
10
11
|
});
|
|
11
|
-
assert.deepEqual(selectionSettings.schema.parse({ provider: "pi", projectRoot: "/project" }), {
|
|
12
|
+
assert.deepEqual(selectionSettings.schema.parse({ provider: "pi", projectRoot: "/project", layout: "card" }), {
|
|
12
13
|
provider: "pi",
|
|
13
14
|
projectRoot: "/project",
|
|
15
|
+
layout: "card",
|
|
14
16
|
});
|
|
15
17
|
assert.equal(selectionSettings.schema.safeParse({ provider: "unknown" }).success, false);
|
|
18
|
+
assert.equal(selectionSettings.schema.safeParse({ layout: "grid" }).success, false);
|
|
16
19
|
});
|
|
@@ -27,16 +27,16 @@ test("/customize selects the current agent provider and workspace project", asyn
|
|
|
27
27
|
|
|
28
28
|
assert.deepEqual(calls, [
|
|
29
29
|
{ name: "settings.board-selection.read", input: {} },
|
|
30
|
-
{ name: "settings.board-selection.write", input: { revision: "one", values: { provider: "codex", projectRoot: "/repo" } } },
|
|
30
|
+
{ name: "settings.board-selection.write", input: { revision: "one", values: { provider: "codex", projectRoot: "/repo", layout: "list" } } },
|
|
31
31
|
]);
|
|
32
32
|
assert.deepEqual(opened, ["customize"]);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
test("/customize updates each available selection and keeps the unavailable one", async () => {
|
|
36
36
|
const cases = [
|
|
37
|
-
{ provider: "", project: "/repo", expected: { provider: "claude", projectRoot: "/repo" } },
|
|
38
|
-
{ provider: "codex", project: "", expected: { provider: "codex", projectRoot: "/old" } },
|
|
39
|
-
{ provider: "unknown", project: "/repo", expected: { provider: "claude", projectRoot: "/repo" } },
|
|
37
|
+
{ provider: "", project: "/repo", expected: { provider: "claude", projectRoot: "/repo", layout: "list" } },
|
|
38
|
+
{ provider: "codex", project: "", expected: { provider: "codex", projectRoot: "/old", layout: "list" } },
|
|
39
|
+
{ provider: "unknown", project: "/repo", expected: { provider: "claude", projectRoot: "/repo", layout: "list" } },
|
|
40
40
|
];
|
|
41
41
|
for (const { provider, project, expected } of cases) {
|
|
42
42
|
const calls: Array<{ name: string; input: unknown }> = [];
|
|
@@ -79,12 +79,29 @@ test("/customize retries a conflicting selection with the latest revision", asyn
|
|
|
79
79
|
|
|
80
80
|
assert.equal(reads, 2);
|
|
81
81
|
assert.deepEqual(writes, [
|
|
82
|
-
{ revision: "revision-1", values: { provider: "pi", projectRoot: "/repo" } },
|
|
83
|
-
{ revision: "revision-2", values: { provider: "pi", projectRoot: "/repo" } },
|
|
82
|
+
{ revision: "revision-1", values: { provider: "pi", projectRoot: "/repo", layout: "list" } },
|
|
83
|
+
{ revision: "revision-2", values: { provider: "pi", projectRoot: "/repo", layout: "list" } },
|
|
84
84
|
]);
|
|
85
85
|
assert.deepEqual(opened, ["customize"]);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
+
test("/customize keeps the stored view layout", async () => {
|
|
89
|
+
const writes: unknown[] = [];
|
|
90
|
+
const { context } = commandContext("codex", "/repo", async (name, input) => {
|
|
91
|
+
if (name.endsWith(".read")) {
|
|
92
|
+
return { status: "ready", revision: "one", values: { provider: "claude", projectRoot: "/old", layout: "card" } };
|
|
93
|
+
}
|
|
94
|
+
writes.push(input);
|
|
95
|
+
return { status: "saved", revision: "two", values: {} };
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await openCustomizeFromAgent(context);
|
|
99
|
+
|
|
100
|
+
assert.deepEqual(writes, [
|
|
101
|
+
{ revision: "one", values: { provider: "codex", projectRoot: "/repo", layout: "card" } },
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
|
|
88
105
|
test("/customize opens the board when settings cannot be read", async () => {
|
|
89
106
|
const { context, opened } = commandContext("codex", "/repo", async () => {
|
|
90
107
|
throw new Error("offline");
|
package/client/surface.tsx
CHANGED
|
@@ -9,10 +9,12 @@ import { messagesFor } from "../shared/i18n.ts";
|
|
|
9
9
|
import { MECHANISMS, mechanismFor } from "../shared/mechanisms.ts";
|
|
10
10
|
import { type ProviderId } from "../shared/providers.ts";
|
|
11
11
|
import { selectionSettings } from "../shared/selection-settings.ts";
|
|
12
|
-
import { CONTROL, ICON_SIZE, PREVIEW_FRACTION, RADIUS, TEXT, pageLayout, titleGap } from "./design-tokens.ts";
|
|
12
|
+
import { CONTROL, GRID, ICON_SIZE, PREVIEW_FRACTION, RADIUS, TEXT, pageLayout, titleGap } from "./design-tokens.ts";
|
|
13
13
|
import { Dropdown, type DropdownOption } from "./dropdown.tsx";
|
|
14
14
|
import { countByCategory, countSkillInvocation, groupEntries, matchesSkillInvocation, projectLabel, SKILL_INVOCATION_FILTERS, type SkillInvocationFilter } from "./entries.ts";
|
|
15
|
+
import { EntryCard } from "./entry-card.tsx";
|
|
15
16
|
import { EntryRow } from "./entry-row.tsx";
|
|
17
|
+
import { cardWidth, gridColumns } from "./grid.ts";
|
|
16
18
|
import { MechanismCard } from "./mechanism-card.tsx";
|
|
17
19
|
import { PreviewPane } from "./preview-pane.tsx";
|
|
18
20
|
import { enabledProviderOptions, selectedProvider } from "./provider-options.ts";
|
|
@@ -74,8 +76,12 @@ export function CustomizeSurface({ theme, layout }: PluginSurfaceProps): ReactNo
|
|
|
74
76
|
const [category, setCategoryState] = useState<Category>("instructions");
|
|
75
77
|
const activeCategory = resolveCategory(provider, category);
|
|
76
78
|
const [query, setQuery] = useState("");
|
|
79
|
+
const [searchFocused, setSearchFocused] = useState(false);
|
|
77
80
|
const [skillFilter, setSkillFilter] = useState<SkillInvocationFilter>("all");
|
|
78
81
|
const [selected, setSelected] = useState<Entry | null>(null);
|
|
82
|
+
const [contentWidth, setContentWidth] = useState(0);
|
|
83
|
+
const viewLayout = settings.status === "ready" ? settings.values.layout : "list";
|
|
84
|
+
const cardWidthValue = cardWidth(contentWidth, gridColumns(contentWidth));
|
|
79
85
|
|
|
80
86
|
const setProvider = (id: string) => {
|
|
81
87
|
if (settings.status !== "ready" || settings.saving || !providerOptions.some((option) => option.id === id)) return;
|
|
@@ -84,13 +90,19 @@ export function CustomizeSurface({ theme, layout }: PluginSurfaceProps): ReactNo
|
|
|
84
90
|
};
|
|
85
91
|
const setCategory = (next: Category) => {
|
|
86
92
|
setCategoryState(next);
|
|
93
|
+
setSearchFocused(false);
|
|
87
94
|
setSelected(null);
|
|
88
95
|
};
|
|
96
|
+
const toggleLayout = () => {
|
|
97
|
+
if (settings.status !== "ready" || settings.saving) return;
|
|
98
|
+
void settings.save({ ...settings.values, layout: viewLayout === "list" ? "card" : "list" }, settings.revision);
|
|
99
|
+
};
|
|
89
100
|
|
|
90
101
|
useEffect(() => {
|
|
91
102
|
setCategoryState((current) => resolveCategory(provider, current));
|
|
92
103
|
setSelected(null);
|
|
93
104
|
setQuery("");
|
|
105
|
+
setSearchFocused(false);
|
|
94
106
|
}, [provider]);
|
|
95
107
|
|
|
96
108
|
const projects = useQuery({
|
|
@@ -133,7 +145,7 @@ export function CustomizeSurface({ theme, layout }: PluginSurfaceProps): ReactNo
|
|
|
133
145
|
() => groupEntries(entries, activeCategory, query, skillFilter),
|
|
134
146
|
[entries, activeCategory, query, skillFilter],
|
|
135
147
|
);
|
|
136
|
-
const mechanism = mechanismFor(provider, activeCategory, displayed?.compatibility);
|
|
148
|
+
const mechanism = mechanismFor(provider, activeCategory, displayed?.compatibility, displayed?.providerVersion);
|
|
137
149
|
const compatibility = displayed?.compatibility;
|
|
138
150
|
const compatibilityState = compatibility?.source === "builtIn" ? "supported"
|
|
139
151
|
: compatibility?.enabled === true ? "on" : compatibility?.enabled === false ? "off" : "unknown";
|
|
@@ -187,22 +199,31 @@ export function CustomizeSurface({ theme, layout }: PluginSurfaceProps): ReactNo
|
|
|
187
199
|
return (
|
|
188
200
|
<View style={{ flex: 1, minHeight: 0, backgroundColor: colors.surface0 }}>
|
|
189
201
|
<View style={{ flex: selected ? 1 - (compact ? PREVIEW_FRACTION.compact : PREVIEW_FRACTION.regular) : 1, minHeight: 0 }}>
|
|
190
|
-
<
|
|
191
|
-
<View
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
>
|
|
200
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap:
|
|
202
|
+
<View style={{ paddingHorizontal: page.padding, paddingTop: page.padding, paddingBottom: titleGap(compact), gap: titleGap(compact), zIndex: 1 }}>
|
|
203
|
+
<View
|
|
204
|
+
style={{
|
|
205
|
+
flexDirection: "row",
|
|
206
|
+
alignItems: "center",
|
|
207
|
+
justifyContent: "flex-end",
|
|
208
|
+
zIndex: 30,
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", justifyContent: "flex-end", gap: 14, flexShrink: 1, minWidth: 0 }}>
|
|
212
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexShrink: 1, minWidth: 0 }}>
|
|
201
213
|
{compatibility ? (
|
|
202
214
|
<View accessible accessibilityRole="image" accessibilityLabel={m.compatibility(compatibilityState)}>
|
|
203
215
|
<Icon name={compatibilityState === "off" ? "Link2Off" : "Link2"} size={ICON_SIZE.action} color={compatibilityState === "on" || compatibilityState === "supported" ? colors.statusSuccess : compatibilityState === "off" ? colors.foregroundMuted : colors.statusWarning} />
|
|
204
216
|
</View>
|
|
205
217
|
) : null}
|
|
218
|
+
{displayed?.providerVersion?.version ? (
|
|
219
|
+
<Text
|
|
220
|
+
style={{ ...TEXT.meta, color: colors.foregroundMuted, maxWidth: CONTROL.providerVersionMaxWidth, flexShrink: 1 }}
|
|
221
|
+
numberOfLines={1}
|
|
222
|
+
accessibilityLabel={m.providerVersion(`v${displayed.providerVersion.version}`)}
|
|
223
|
+
>
|
|
224
|
+
{`v${displayed.providerVersion.version}`}
|
|
225
|
+
</Text>
|
|
226
|
+
) : null}
|
|
206
227
|
<Dropdown
|
|
207
228
|
label={m.provider}
|
|
208
229
|
options={providerOptions}
|
|
@@ -214,74 +235,43 @@ export function CustomizeSurface({ theme, layout }: PluginSurfaceProps): ReactNo
|
|
|
214
235
|
menuAlign={compact ? "left" : "right"}
|
|
215
236
|
disabled={settings.saving}
|
|
216
237
|
/>
|
|
217
|
-
<Dropdown
|
|
218
|
-
label={m.project}
|
|
219
|
-
options={projectOptions}
|
|
220
|
-
value={projectRoot ?? NO_PROJECT}
|
|
221
|
-
onChange={(id) => {
|
|
222
|
-
if (settings.saving) return;
|
|
223
|
-
void settings.save({ ...settings.values, projectRoot: id }, settings.revision);
|
|
224
|
-
setSelected(null);
|
|
225
|
-
}}
|
|
226
|
-
colors={colors}
|
|
227
|
-
triggerLabel={m.chooseProject}
|
|
228
|
-
closeLabel={m.closeMenu}
|
|
229
|
-
emptyLabel={m.noProject}
|
|
230
|
-
disabled={settings.saving}
|
|
231
|
-
/>
|
|
232
|
-
<IconButton
|
|
233
|
-
icon="RefreshCw"
|
|
234
|
-
label={m.refresh}
|
|
235
|
-
color={colors.foregroundMuted}
|
|
236
|
-
busy={result.isFetching}
|
|
237
|
-
tooltip={displayed ? {
|
|
238
|
-
text: m.lastScanned(new Date(displayed.scannedAt).toLocaleString(language)),
|
|
239
|
-
colors,
|
|
240
|
-
} : undefined}
|
|
241
|
-
onPress={() => {
|
|
242
|
-
void providerSnapshot.refetch();
|
|
243
|
-
void result.refetch();
|
|
244
|
-
}}
|
|
245
|
-
/>
|
|
246
238
|
</View>
|
|
239
|
+
<Dropdown
|
|
240
|
+
label={m.project}
|
|
241
|
+
options={projectOptions}
|
|
242
|
+
value={projectRoot ?? NO_PROJECT}
|
|
243
|
+
onChange={(id) => {
|
|
244
|
+
if (settings.saving) return;
|
|
245
|
+
void settings.save({ ...settings.values, projectRoot: id }, settings.revision);
|
|
246
|
+
setSelected(null);
|
|
247
|
+
}}
|
|
248
|
+
colors={colors}
|
|
249
|
+
triggerLabel={m.chooseProject}
|
|
250
|
+
closeLabel={m.closeMenu}
|
|
251
|
+
emptyLabel={m.noProject}
|
|
252
|
+
disabled={settings.saving}
|
|
253
|
+
/>
|
|
254
|
+
<IconButton
|
|
255
|
+
icon="RefreshCw"
|
|
256
|
+
label={m.refresh}
|
|
257
|
+
color={colors.foregroundMuted}
|
|
258
|
+
size={ICON_SIZE.inline}
|
|
259
|
+
busy={result.isFetching}
|
|
260
|
+
tooltip={displayed ? {
|
|
261
|
+
text: m.lastScanned(new Date(displayed.scannedAt).toLocaleString(language)),
|
|
262
|
+
colors,
|
|
263
|
+
} : undefined}
|
|
264
|
+
onPress={() => {
|
|
265
|
+
void providerSnapshot.refetch();
|
|
266
|
+
void result.refetch();
|
|
267
|
+
}}
|
|
268
|
+
/>
|
|
247
269
|
</View>
|
|
248
|
-
<CategoryTabs options={tabs} value={activeCategory} onChange={setCategory} colors={colors} />
|
|
249
|
-
{settings.saveError ? <Text style={{ ...TEXT.small, color: colors.statusDanger }}>{settings.saveError}</Text> : null}
|
|
250
|
-
<MechanismCard key={`${provider}:${activeCategory}`} mechanism={mechanism} language={language} colors={colors} m={m} />
|
|
251
|
-
{result.isError && displayed ? <ErrorState error={result.error} onRetry={() => void result.refetch()} colors={colors} /> : null}
|
|
252
270
|
</View>
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
<View style={{ flexDirection: "row",
|
|
256
|
-
|
|
257
|
-
style={{
|
|
258
|
-
flexGrow: 1,
|
|
259
|
-
flexBasis: 180,
|
|
260
|
-
flexDirection: "row",
|
|
261
|
-
alignItems: "center",
|
|
262
|
-
gap: 6,
|
|
263
|
-
height: CONTROL.searchHeight,
|
|
264
|
-
paddingHorizontal: 10,
|
|
265
|
-
borderRadius: RADIUS.control,
|
|
266
|
-
borderWidth: 1,
|
|
267
|
-
borderColor: colors.border,
|
|
268
|
-
backgroundColor: colors.surface1,
|
|
269
|
-
}}
|
|
270
|
-
>
|
|
271
|
-
<Icon name="Search" size={ICON_SIZE.inline} color={colors.foregroundMuted} />
|
|
272
|
-
<TextInput
|
|
273
|
-
value={query}
|
|
274
|
-
onChangeText={setQuery}
|
|
275
|
-
placeholder={m.search}
|
|
276
|
-
placeholderTextColor={colors.foregroundMuted}
|
|
277
|
-
accessibilityLabel={m.search}
|
|
278
|
-
autoCorrect={false}
|
|
279
|
-
autoCapitalize="none"
|
|
280
|
-
style={{ flex: 1, ...TEXT.small, color: colors.foreground, paddingVertical: 0 }}
|
|
281
|
-
/>
|
|
282
|
-
{queryActive ? <IconButton icon="X" label={m.preview.close} color={colors.foregroundMuted} size={ICON_SIZE.inline} onPress={() => setQuery("")} /> : null}
|
|
283
|
-
</View>
|
|
284
|
-
{activeCategory === "skills" ? (
|
|
271
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 }}>
|
|
272
|
+
<CategoryTabs options={tabs} value={activeCategory} onChange={setCategory} colors={colors} />
|
|
273
|
+
<View style={{ flexGrow: 1, flexShrink: 1, minWidth: 0, flexDirection: "row", flexWrap: "wrap", justifyContent: "flex-end", alignItems: "center", gap: 8 }}>
|
|
274
|
+
{mechanism.supported && activeCategory === "skills" ? (
|
|
285
275
|
<SegmentedControl
|
|
286
276
|
label={m.skillInvocation}
|
|
287
277
|
options={skillFilterOptions}
|
|
@@ -290,49 +280,122 @@ export function CustomizeSurface({ theme, layout }: PluginSurfaceProps): ReactNo
|
|
|
290
280
|
colors={colors}
|
|
291
281
|
/>
|
|
292
282
|
) : null}
|
|
283
|
+
<MechanismCard key={`${provider}:${activeCategory}`} mechanism={mechanism} language={language} colors={colors} m={m} compact={compact} />
|
|
284
|
+
{mechanism.supported ? (
|
|
285
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 6, flexShrink: 1, minWidth: 0 }}>
|
|
286
|
+
<View
|
|
287
|
+
style={{
|
|
288
|
+
width: 220,
|
|
289
|
+
minWidth: 180,
|
|
290
|
+
flexShrink: 1,
|
|
291
|
+
flexDirection: "row",
|
|
292
|
+
alignItems: "center",
|
|
293
|
+
gap: 6,
|
|
294
|
+
height: CONTROL.searchHeight,
|
|
295
|
+
paddingHorizontal: 10,
|
|
296
|
+
borderRadius: RADIUS.control,
|
|
297
|
+
borderWidth: 1,
|
|
298
|
+
borderColor: searchFocused ? colors.foregroundMuted : colors.border,
|
|
299
|
+
backgroundColor: colors.surface1,
|
|
300
|
+
}}
|
|
301
|
+
>
|
|
302
|
+
<Icon name="Search" size={ICON_SIZE.inline} color={colors.foregroundMuted} />
|
|
303
|
+
<TextInput
|
|
304
|
+
value={query}
|
|
305
|
+
onChangeText={setQuery}
|
|
306
|
+
onFocus={() => setSearchFocused(true)}
|
|
307
|
+
onBlur={() => setSearchFocused(false)}
|
|
308
|
+
placeholder={m.search}
|
|
309
|
+
placeholderTextColor={colors.foregroundMuted}
|
|
310
|
+
accessibilityLabel={m.search}
|
|
311
|
+
autoCorrect={false}
|
|
312
|
+
autoCapitalize="none"
|
|
313
|
+
style={{ flex: 1, ...TEXT.small, color: colors.foreground, paddingVertical: 0, borderWidth: 0, ...(Platform.OS === "web" ? ({ outlineStyle: "none" } as object) : null) }}
|
|
314
|
+
/>
|
|
315
|
+
{queryActive ? <IconButton icon="X" label={m.preview.close} color={colors.foregroundMuted} size={ICON_SIZE.inline} onPress={() => setQuery("")} /> : null}
|
|
316
|
+
</View>
|
|
317
|
+
<IconButton
|
|
318
|
+
icon={viewLayout === "card" ? "List" : "LayoutGrid"}
|
|
319
|
+
label={viewLayout === "card" ? m.showList : m.showCards}
|
|
320
|
+
color={colors.foregroundMuted}
|
|
321
|
+
disabled={settings.saving}
|
|
322
|
+
onPress={toggleLayout}
|
|
323
|
+
/>
|
|
324
|
+
</View>
|
|
325
|
+
) : null}
|
|
293
326
|
</View>
|
|
294
|
-
|
|
327
|
+
</View>
|
|
328
|
+
{settings.saveError ? <Text style={{ ...TEXT.small, color: colors.statusDanger }}>{settings.saveError}</Text> : null}
|
|
329
|
+
{result.isError && displayed ? <ErrorState error={result.error} onRetry={() => void result.refetch()} colors={colors} /> : null}
|
|
330
|
+
</View>
|
|
295
331
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
332
|
+
<ScrollView
|
|
333
|
+
style={{ flex: 1, minHeight: 0, ...(Platform.OS === "web" ? ({ scrollbarWidth: "none", msOverflowStyle: "none" } as object) : null) }}
|
|
334
|
+
contentContainerStyle={{ paddingHorizontal: page.padding, paddingTop: page.gap, paddingBottom: page.padding }}
|
|
335
|
+
keyboardShouldPersistTaps="handled"
|
|
336
|
+
showsVerticalScrollIndicator={false}
|
|
337
|
+
>
|
|
338
|
+
<View
|
|
339
|
+
style={{ gap: page.gap }}
|
|
340
|
+
onLayout={(event) => setContentWidth(event.nativeEvent.layout.width)}
|
|
341
|
+
>
|
|
342
|
+
{!displayed && (saved.isPending || result.isPending) ? (
|
|
343
|
+
<LoadingState color={colors.foregroundMuted} />
|
|
344
|
+
) : !displayed && (result.isError || saved.isError) ? (
|
|
345
|
+
<ErrorState error={result.error ?? saved.error} onRetry={() => void result.refetch()} colors={colors} />
|
|
346
|
+
) : !mechanism.supported ? null : (
|
|
347
|
+
groups.map((group) => (
|
|
348
|
+
<View key={group.scope} style={{ gap: titleGap(compact) }}>
|
|
349
|
+
<SectionHeader
|
|
350
|
+
title={m.scopes[group.scope]}
|
|
351
|
+
count={group.count}
|
|
352
|
+
colors={colors}
|
|
353
|
+
compact={compact}
|
|
313
354
|
/>
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
355
|
+
{group.count === 0 ? (
|
|
356
|
+
<InlineEmpty
|
|
357
|
+
text={listNarrowed ? m.noMatches : group.scope === "project" && !projectRoot ? m.noProject : m.emptyScope(m.scopes[group.scope])}
|
|
358
|
+
color={colors.foregroundMuted}
|
|
359
|
+
/>
|
|
360
|
+
) : (
|
|
361
|
+
group.sources.map((source) => (
|
|
362
|
+
<View key={source.source} style={{ gap: viewLayout === "card" ? GRID.labelGap : 2 }}>
|
|
363
|
+
<Text style={{ ...TEXT.path, color: colors.foregroundMuted, paddingBottom: 2 }} numberOfLines={1}>
|
|
364
|
+
{source.source}
|
|
365
|
+
</Text>
|
|
366
|
+
{viewLayout === "card" ? (
|
|
367
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "stretch", gap: GRID.gap }}>
|
|
368
|
+
{source.entries.map((entry) => (
|
|
369
|
+
<EntryCard
|
|
370
|
+
key={entry.id}
|
|
371
|
+
entry={entry}
|
|
372
|
+
selected={selected?.id === entry.id}
|
|
373
|
+
onSelect={onSelect}
|
|
374
|
+
colors={colors}
|
|
375
|
+
m={m}
|
|
376
|
+
width={cardWidthValue}
|
|
377
|
+
/>
|
|
378
|
+
))}
|
|
379
|
+
</View>
|
|
380
|
+
) : (
|
|
381
|
+
source.entries.map((entry) => (
|
|
382
|
+
<EntryRow
|
|
383
|
+
key={entry.id}
|
|
384
|
+
entry={entry}
|
|
385
|
+
selected={selected?.id === entry.id}
|
|
386
|
+
onSelect={onSelect}
|
|
387
|
+
colors={colors}
|
|
388
|
+
m={m}
|
|
389
|
+
/>
|
|
390
|
+
))
|
|
391
|
+
)}
|
|
392
|
+
</View>
|
|
393
|
+
))
|
|
394
|
+
)}
|
|
395
|
+
</View>
|
|
396
|
+
))
|
|
397
|
+
)}
|
|
398
|
+
</View>
|
|
336
399
|
</ScrollView>
|
|
337
400
|
</View>
|
|
338
401
|
|
package/client/ui.tsx
CHANGED
|
@@ -195,7 +195,7 @@ export function CategoryTabs<T extends string>({
|
|
|
195
195
|
colors: Pick<Colors, "foreground" | "foregroundMuted">;
|
|
196
196
|
}): ReactNode {
|
|
197
197
|
return (
|
|
198
|
-
<View accessibilityRole="tablist" style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center",
|
|
198
|
+
<View accessibilityRole="tablist" style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 18, rowGap: 2, flexShrink: 1, minWidth: 0 }}>
|
|
199
199
|
{options.map((option) => {
|
|
200
200
|
const active = option.id === value;
|
|
201
201
|
return (
|
|
@@ -328,3 +328,27 @@ export function StatusBadge({ status, label, colors }: { status: Status; label:
|
|
|
328
328
|
</View>
|
|
329
329
|
);
|
|
330
330
|
}
|
|
331
|
+
|
|
332
|
+
/** Outlined token pill: same shell as `StatusBadge`, neutral color so it never competes with status. */
|
|
333
|
+
export function TokenBadge({ label, hint, colors }: { label: string; hint: string; colors: Colors }): ReactNode {
|
|
334
|
+
return (
|
|
335
|
+
<View
|
|
336
|
+
accessible
|
|
337
|
+
accessibilityLabel={hint}
|
|
338
|
+
style={{
|
|
339
|
+
height: CONTROL.pillBadgeHeight,
|
|
340
|
+
paddingHorizontal: 7,
|
|
341
|
+
borderRadius: pillRadius(CONTROL.pillBadgeHeight),
|
|
342
|
+
borderWidth: 1,
|
|
343
|
+
borderColor: colors.border,
|
|
344
|
+
alignItems: "center",
|
|
345
|
+
justifyContent: "center",
|
|
346
|
+
flexShrink: 0,
|
|
347
|
+
}}
|
|
348
|
+
>
|
|
349
|
+
<Text style={{ ...TEXT.pillBadge, color: colors.foregroundMuted }} numberOfLines={1}>
|
|
350
|
+
{label}
|
|
351
|
+
</Text>
|
|
352
|
+
</View>
|
|
353
|
+
);
|
|
354
|
+
}
|
package/index.client.tsx
CHANGED
|
@@ -10,10 +10,10 @@ const SURFACE_ID = "customize";
|
|
|
10
10
|
|
|
11
11
|
/** Command titles follow the app language; the host has no update(), so re-register on change. */
|
|
12
12
|
function addCommands(client: PluginClientContext): () => void {
|
|
13
|
-
const
|
|
13
|
+
const messages = messagesFor(currentAppLanguage());
|
|
14
14
|
const removeCommandCenterItem = client.addCommandCenterItem({
|
|
15
15
|
id: "open-customize",
|
|
16
|
-
title:
|
|
16
|
+
title: messages.title,
|
|
17
17
|
icon: "FolderCog",
|
|
18
18
|
keywords: ["customize", "agents.md", "claude.md", "rules", "skills", "mcp", "instructions", "provider"],
|
|
19
19
|
context: "global",
|
|
@@ -23,7 +23,7 @@ function addCommands(client: PluginClientContext): () => void {
|
|
|
23
23
|
});
|
|
24
24
|
const removeSlashCommand = client.addSlashCommand({
|
|
25
25
|
name: "customize",
|
|
26
|
-
description,
|
|
26
|
+
description: messages.openBoard,
|
|
27
27
|
argumentHint: "",
|
|
28
28
|
context: "agent",
|
|
29
29
|
onSubmit: openCustomizeFromAgent,
|
package/package.json
CHANGED
|
@@ -102,3 +102,16 @@ test("a changed compatibility switch makes an otherwise fresh snapshot stale", (
|
|
|
102
102
|
rmSync(paseoHome, { recursive: true, force: true });
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
+
|
|
106
|
+
test("OpenCode's mechanism preserves version-dependent behavior without repeating the toolbar version", () => {
|
|
107
|
+
const state = { enabled: true, source: "default" };
|
|
108
|
+
const v2 = mechanismFor("opencode", "skills", state, { version: "2.0.18", source: "host" });
|
|
109
|
+
assert.equal(v2.notes.some((note) => note.en.includes("2.0.18") || note.en.includes("host diagnostic")), false);
|
|
110
|
+
assert.ok(v2.notes.some((note) => note.zh.includes("仍可按 ID 显式加载")));
|
|
111
|
+
const v1 = mechanismFor("opencode", "skills", state, { version: "1.18.32", source: "cli" });
|
|
112
|
+
assert.equal(v1.notes.some((note) => note.en.includes("CLI fallback") || note.en.includes("1.18.32")), false);
|
|
113
|
+
assert.ok(v1.notes.some((note) => note.en.includes("v1 advertises")));
|
|
114
|
+
assert.equal(v1.notes.some((note) => note.en.includes("can still be loaded explicitly")), false);
|
|
115
|
+
const unknown = mechanismFor("opencode", "skills", state, { version: null, source: "unknown" });
|
|
116
|
+
assert.ok(unknown.notes.some((note) => note.en.includes("await version confirmation")));
|
|
117
|
+
});
|
package/server/handlers.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
|
|
6
|
+
import type { PluginHandlerContext } from "@getpaseo/plugin/server";
|
|
6
7
|
import type { Entry } from "../shared/contracts.ts";
|
|
7
8
|
import { cachedScanRpc, openRpc, previewRpc, scanRpc } from "../shared/contracts.ts";
|
|
8
9
|
import type { ProviderId } from "../shared/providers.ts";
|
|
@@ -22,6 +23,8 @@ import { compatibilityFor } from "./compatibility.ts";
|
|
|
22
23
|
import { mergeSkillAliases } from "./skill-aliases.ts";
|
|
23
24
|
import { parseToml } from "./toml.ts";
|
|
24
25
|
import { parseYaml } from "./yaml-lite.ts";
|
|
26
|
+
import { detectProviderVersion } from "./provider-version.ts";
|
|
27
|
+
import { withTokens } from "./tokens.ts";
|
|
25
28
|
|
|
26
29
|
const execFileAsync = promisify(execFile);
|
|
27
30
|
|
|
@@ -62,15 +65,16 @@ function nestedIndex(root: string): NestedIndex {
|
|
|
62
65
|
return index;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
export function scanProvider(provider: ProviderId, projectRoot: string | null, env: Pick<ScanContext, "home" | "env" | "platform">): Entry[] {
|
|
68
|
+
export function scanProvider(provider: ProviderId, projectRoot: string | null, env: Pick<ScanContext, "home" | "env" | "platform" | "providerVersion">): Entry[] {
|
|
66
69
|
const root = projectRoot && isDir(projectRoot) ? path.resolve(projectRoot) : null;
|
|
67
70
|
const ctx: ScanContext = { ...env, projectRoot: root, nested: root ? nestedIndex(root) : null };
|
|
68
|
-
return mergeSkillAliases(provider, SCANNERS[provider](ctx));
|
|
71
|
+
return withTokens(mergeSkillAliases(provider, SCANNERS[provider](ctx)));
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
export async function handleScan(input: RpcInput<typeof scanRpc
|
|
74
|
+
export async function handleScan(input: RpcInput<typeof scanRpc>, context?: PluginHandlerContext): Promise<RpcOutput<typeof scanRpc>> {
|
|
72
75
|
const home = homedir();
|
|
73
|
-
const
|
|
76
|
+
const providerVersion = await detectProviderVersion(input.provider, context ? (provider) => context.paseo.providers.diagnostic(provider) : undefined);
|
|
77
|
+
const entries = scanProvider(input.provider, input.projectRoot, { home, env: process.env, platform: process.platform, providerVersion });
|
|
74
78
|
const ctx: ScanContext = { home, env: process.env, platform: process.platform, projectRoot: input.projectRoot, nested: null };
|
|
75
79
|
for (const entry of entries) allowed.add(entry.path);
|
|
76
80
|
const result = {
|
|
@@ -79,6 +83,7 @@ export async function handleScan(input: RpcInput<typeof scanRpc>): Promise<RpcOu
|
|
|
79
83
|
home,
|
|
80
84
|
entries,
|
|
81
85
|
compatibility: compatibilityFor(input.provider, ctx),
|
|
86
|
+
providerVersion,
|
|
82
87
|
scannedAt: new Date().toISOString(),
|
|
83
88
|
};
|
|
84
89
|
try {
|