@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
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,49 @@ All notable changes to `@koinzhang/paseo-plugin-customize` are documented in thi
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.0] - 2026-09-28
|
|
9
|
+
|
|
10
|
+
Requires Paseo **>= 0.9.0**.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Entries can switch between the list and a responsive card grid with the button to the right of the search field. Cards show the same name, status, description, path/reason, token estimate, and Agent Plugins badge, reflow from one to three columns with the panel width, and open the same preview. The view choice is saved with Provider and Project.
|
|
15
|
+
- Every provider with a detected version shows it with a `v` prefix between the compatibility icon and the Provider picker, on every category. The version comes from the host provider diagnostic first, then a fallback probe of the provider's local CLI — standard semver, product-prefixed and parenthesized output, and Cursor's date build are understood; missing versions and probe failures hide the area. It refreshes with each scan and persists in the saved snapshot.
|
|
16
|
+
- OpenCode v2 skills with `metadata.opencode/autoinvoke: false` (boolean or string `"false"`) show as Manual only: hidden from the model's available list, but still explicitly loadable by ID. The version is detected from the host diagnostic first, then `opencode --version` on the daemon's PATH; an unknown version leaves flagged skills awaiting confirmation, and v1 ignores the field. The mechanism note explains the matching v1/v2 behavior.
|
|
17
|
+
- The Provider picker groups Built-in providers above ACP ones, sorted by name within each group and separated by a divider.
|
|
18
|
+
- Every Instructions, Rules, Skills, Commands, Subagents, and Plugins row now shows an estimated token count after the status pill. The estimate uses a script-aware heuristic (`ceil(ascii / 4 + cjk * 1.05 + otherNonAsciiBytes / 3)`), calibrated against GPT's `o200k_base` on local Chinese `AGENTS.md` files and a 2168-file corpus (about 10% mean error). Instructions and Rules show one always-on number; Skills, Commands, and Subagents show the advertised metadata (`≈114 tok`) plus the body that arrives on invoke (`+1.2k on invoke`); plugin rows recursively sum their bundled component prompts with the same split. MCP is not counted, because a server's real context cost is its `tools/list` payload rather than anything on disk. Counts are cached by path + mtime + size and persisted with the scan snapshot.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- The Command Center item is titled **Customize** again; the `/customize` slash command keeps its "Open Customize" description.
|
|
23
|
+
- The Provider picker keeps the Built-in / ACP badge flush right by rendering the selected check before it, matching the host menu order.
|
|
24
|
+
- The category toolbar splits into two rows before either section wraps internally; tabs then wrap within their own row and the search field can shrink to its 180 px minimum.
|
|
25
|
+
- The preview copy icon matches the Open and Reveal icons in the same row (the 24×24 hit area and tooltip are unchanged).
|
|
26
|
+
- Scrolled entries keep a gap below the fixed toolbar instead of touching it.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- The Rescan icon in the toolbar now matches the search, chevron, and mechanism icons at 14 px.
|
|
31
|
+
- Entry icons in list rows and cards are 14 px and centered with the title; the view toggle no longer shows a hover tooltip.
|
|
32
|
+
|
|
33
|
+
[0.3.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/customize-v0.3.0
|
|
34
|
+
|
|
35
|
+
## [0.2.1] - 2026-09-28
|
|
36
|
+
|
|
37
|
+
Requires Paseo **>= 0.9.0**.
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- The board no longer shifts sideways when the entry list grows past one page: the list scrollbar is hidden, the provider/project controls stay pinned at the top, and only the entry list scrolls.
|
|
42
|
+
- The search field shows focus on its outer border only, without the inner outline.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- Category tabs, the Skills invocation filter, and search now share one top toolbar.
|
|
47
|
+
- The loading-mechanism note became an inline toolbar dropdown; it opens as an overlay and no longer takes a row of its own.
|
|
48
|
+
|
|
49
|
+
[0.2.1]: https://github.com/koinzhang/paseo-plugins/releases/tag/customize-v0.2.1
|
|
50
|
+
|
|
8
51
|
## [0.2.0] - 2026-09-28
|
|
9
52
|
|
|
10
53
|
Requires Paseo **>= 0.9.0**.
|
package/README.md
CHANGED
|
@@ -8,12 +8,14 @@ Requires Paseo >= 0.9.0.
|
|
|
8
8
|
|
|
9
9
|
- A **Customize** item in the sidebar's top navigation (next to New workspace, History, Search, Schedules) and in the Command Center opens the board.
|
|
10
10
|
- Submit `/customize` in an agent composer to open the board. It selects the agent's Provider and workspace Project when available, updating each independently and keeping the current selection for any unavailable value.
|
|
11
|
-
- Top-right **Provider** and **Project** pickers. The Provider menu lists enabled Paseo providers that Customize can scan, including Cursor, Cline, CodeBuddy Code, Gemini CLI, Goose, Grok Build, Kilo Code, Kiro CLI, Kimi Code, Qwen Code, and TraeCode CLI. It marks each as Built-in or ACP. Choices persist on the Paseo host; before a project is chosen, it defaults to the workspace you were last on. The Project menu lists every Paseo project.
|
|
11
|
+
- Top-right **Provider** and **Project** pickers. The Provider menu lists enabled Paseo providers that Customize can scan, including Cursor, Cline, CodeBuddy Code, Gemini CLI, Goose, Grok Build, Kilo Code, Kiro CLI, Kimi Code, Qwen Code, and TraeCode CLI. It groups Built-in providers above ACP ones, each group sorted by name and separated by a divider, and marks each option as Built-in or ACP. Choices persist on the Paseo host; before a project is chosen, it defaults to the workspace you were last on. The Project menu lists every Paseo project.
|
|
12
12
|
- Tabs for Instructions / Rules / Skills / MCP / Commands / Subagents / Plugins. Each tab starts with a "how it loads" note for that provider and then **Project** and **User** sections grouped by source directory.
|
|
13
13
|
- On Skills, a switch beside search shows all skills, automatic skills (Auto and Conditional), or manual-only skills. Disabled and not-loaded skills stay under All. The choice stays on the page and is not saved with Provider or Project.
|
|
14
|
+
- Entries can be shown as a list or as a responsive card grid. The toggle to the right of the search field switches views (grid icon = card view, list icon = list view). Cards carry the same name, status, description, path/reason, token estimate, and Agent Plugins badge, reflow from one to three columns with the panel width, and open the same preview pane. The choice is saved on the Paseo host together with Provider and Project.
|
|
14
15
|
- A link icon to the left of Provider marks agents that search shared skill directories; providers without compatibility support show no icon. Cursor's icon follows its local `thirdPartyExtensibilityEnabled` IDE setting; OpenCode's follows its external-skill environment flags. The icon and skill explanation update on the next scan when those settings change.
|
|
16
|
+
- Every provider with a detected version shows it with a `v` prefix to the left of Provider, between the compatibility icon (when present) and the picker. Versions come from the host diagnostic first, then a local CLI fallback; missing versions and probe/parse failures hide the version area entirely. Version metadata refreshes with each scan and persists in the saved snapshot. Compact layouts keep the compatibility icon, version, and Provider together while the remaining controls can wrap.
|
|
15
17
|
- A skill reachable through several symlinked roots appears once. Customize prefers the provider's native path, then `.agents/skills`, then another path. Same-name skills backed by different files remain separate.
|
|
16
|
-
-
|
|
18
|
+
- OpenCode v2 skills with `metadata.opencode/autoinvoke: false` (boolean or string `"false"`) show as Manual only: hidden from the model's available list, but still explicitly loadable by ID. Customize detects the version from the host's provider diagnostic first, then falls back to `opencode --version` on the daemon's PATH. The mechanism note explains the matching v1/v2 behavior; an unknown version leaves flagged skills awaiting confirmation. v1 ignores this field. OpenCode ignores other agents' `disable-model-invocation`; skill deny permissions still hide and block loading (v1 `permission.skill`, v2 `permissions[]`).
|
|
17
19
|
- Each row shows name, description, directory, and a status:
|
|
18
20
|
|
|
19
21
|
| Status | Meaning |
|
|
@@ -27,6 +29,8 @@ Requires Paseo >= 0.9.0.
|
|
|
27
29
|
|
|
28
30
|
The reason (the exact frontmatter key or config setting) is shown next to the status.
|
|
29
31
|
|
|
32
|
+
- Each row shows an estimated token count after the status pill for Instructions, Rules, Skills, Commands, Subagents, and Plugins. The estimate is a script-aware heuristic — `ceil(ascii / 4 + cjk * 1.05 + otherNonAsciiBytes / 3)` — calibrated against GPT's `o200k_base` on local Chinese `AGENTS.md` files and a 2168-file corpus (about 10% mean error; Claude-family tokenizers run another 10–20% denser on CJK). Instructions and Rules show one number (`≈1.2k tok`) because they are always on. Skills, Commands, and Subagents show two: the advertised `name` + `description` that is always in context (`≈114 tok`) plus the body that arrives when the entry is invoked (`+1.2k on invoke`); manual-only entries show the invoke segment alone, and disabled or not-loaded entries show none. Plugin rows recursively sum the prompt files (`.md` / `.markdown` / `.mdc` / `.rules` / `.txt`) under the package's `skills`, `commands`, `agents`, `rules`, and `instructions` directories with the same split; manifests, code, and `node_modules` are not counted. **MCP is not counted**, because a server's real cost is its `tools/list` payload, which cannot be read from a config file. Counts are cached by path + mtime + size and persisted with the scan snapshot.
|
|
33
|
+
|
|
30
34
|
- Click a row for a preview pane at the bottom (first 64 KiB / 400 lines) with **Open**, **Reveal**, and **Copy path**. MCP previews mask `env` / `headers` values and secret-looking arguments.
|
|
31
35
|
|
|
32
36
|
Scanning is read-only. Preview and open only accept paths returned by a scan.
|
package/client/design-tokens.ts
CHANGED
|
@@ -62,6 +62,11 @@ export function titleGap(compact = false): number {
|
|
|
62
62
|
|
|
63
63
|
export const ROW_PADDING = { dense: 6, regular: 9 } as const;
|
|
64
64
|
|
|
65
|
+
/** Card-view grid metrics; defined in `grid.ts` so pure tests avoid the React Native import. */
|
|
66
|
+
export { GRID } from "./grid.ts";
|
|
67
|
+
|
|
68
|
+
export const CARD = { padding: 12 } as const;
|
|
69
|
+
|
|
65
70
|
export const RADIUS = {
|
|
66
71
|
swatch: 3,
|
|
67
72
|
control: 6,
|
|
@@ -86,6 +91,7 @@ export const CONTROL = {
|
|
|
86
91
|
hitSlop: 8,
|
|
87
92
|
pillBadgeHeight: 18,
|
|
88
93
|
searchHeight: 30,
|
|
94
|
+
providerVersionMaxWidth: 140,
|
|
89
95
|
} as const;
|
|
90
96
|
|
|
91
97
|
export const iconButton: ViewStyle = {
|
package/client/dropdown.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
2
|
-
import { useState, type ReactNode } from "react";
|
|
2
|
+
import { Fragment, useState, type ReactNode } from "react";
|
|
3
3
|
import { Platform, Pressable, ScrollView, Text, View } from "react-native";
|
|
4
4
|
import { CONTROL, FONT_WEIGHT, ICON_SIZE, MENU, RADIUS, TEXT } from "./design-tokens.ts";
|
|
5
5
|
import type { Colors } from "./ui.tsx";
|
|
@@ -9,6 +9,8 @@ export interface DropdownOption {
|
|
|
9
9
|
label: string;
|
|
10
10
|
hint?: string;
|
|
11
11
|
badge?: string;
|
|
12
|
+
/** Options are rendered in array order; a group change draws a divider. */
|
|
13
|
+
group?: string;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -92,42 +94,47 @@ export function Dropdown({
|
|
|
92
94
|
}}
|
|
93
95
|
>
|
|
94
96
|
<ScrollView style={{ maxHeight: MENU.visibleRows * MENU.rowHeight + 8 }} contentContainerStyle={{ paddingVertical: 4 }}>
|
|
95
|
-
{options.map((option) => {
|
|
97
|
+
{options.map((option, index) => {
|
|
96
98
|
const selected = option.id === value;
|
|
99
|
+
const startsGroup = index > 0 && option.group !== undefined && option.group !== options[index - 1]?.group;
|
|
97
100
|
return (
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{option.hint}
|
|
101
|
+
<Fragment key={option.id}>
|
|
102
|
+
{startsGroup ? (
|
|
103
|
+
<View style={{ height: 1, marginVertical: 4, marginHorizontal: 4, backgroundColor: colors.border }} />
|
|
104
|
+
) : null}
|
|
105
|
+
<Pressable
|
|
106
|
+
accessibilityRole="button"
|
|
107
|
+
accessibilityState={{ selected }}
|
|
108
|
+
onPress={() => {
|
|
109
|
+
onChange(option.id);
|
|
110
|
+
setOpen(false);
|
|
111
|
+
}}
|
|
112
|
+
style={({ pressed, hovered }: { pressed: boolean; hovered?: boolean }) => ({
|
|
113
|
+
flexDirection: "row",
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
minHeight: MENU.rowHeight,
|
|
116
|
+
gap: 8,
|
|
117
|
+
marginHorizontal: 4,
|
|
118
|
+
paddingHorizontal: 8,
|
|
119
|
+
paddingVertical: option.hint ? 4 : 0,
|
|
120
|
+
borderRadius: RADIUS.control,
|
|
121
|
+
backgroundColor: pressed || hovered ? colors.surface2 : "transparent",
|
|
122
|
+
})}
|
|
123
|
+
>
|
|
124
|
+
<View style={{ flex: 1, minWidth: 0 }}>
|
|
125
|
+
<Text style={{ ...TEXT.menu, color: colors.foreground }} numberOfLines={1}>
|
|
126
|
+
{option.label}
|
|
125
127
|
</Text>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
{option.hint ? (
|
|
129
|
+
<Text style={{ ...TEXT.caption, color: colors.foregroundMuted }} numberOfLines={1}>
|
|
130
|
+
{option.hint}
|
|
131
|
+
</Text>
|
|
132
|
+
) : null}
|
|
133
|
+
</View>
|
|
134
|
+
{selected ? <Icon name="Check" size={ICON_SIZE.action} color={colors.foreground} /> : null}
|
|
135
|
+
{option.badge ? <Text style={{ ...TEXT.caption, color: colors.foregroundMuted }}>{option.badge}</Text> : null}
|
|
136
|
+
</Pressable>
|
|
137
|
+
</Fragment>
|
|
131
138
|
);
|
|
132
139
|
})}
|
|
133
140
|
</ScrollView>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
2
|
+
import { memo, type ReactNode } from "react";
|
|
3
|
+
import { Pressable, Text, View } from "react-native";
|
|
4
|
+
import type { Entry } from "../shared/contracts.ts";
|
|
5
|
+
import { formatTokenCount, type Messages } from "../shared/i18n.ts";
|
|
6
|
+
import { CARD, ICON_SIZE, RADIUS, TEXT } from "./design-tokens.ts";
|
|
7
|
+
import { CATEGORY_ICONS, entryLabel, entryMeta } from "./entry-row.tsx";
|
|
8
|
+
import { StatusBadge, TokenBadge, type Colors } from "./ui.tsx";
|
|
9
|
+
|
|
10
|
+
/** Card-view twin of `EntryRow`: same facts, wrapped for a responsive grid. */
|
|
11
|
+
export const EntryCard = memo(function EntryCard({
|
|
12
|
+
entry,
|
|
13
|
+
selected,
|
|
14
|
+
onSelect,
|
|
15
|
+
colors,
|
|
16
|
+
m,
|
|
17
|
+
width,
|
|
18
|
+
}: {
|
|
19
|
+
entry: Entry;
|
|
20
|
+
selected: boolean;
|
|
21
|
+
onSelect: (entry: Entry) => void;
|
|
22
|
+
colors: Colors;
|
|
23
|
+
m: Messages;
|
|
24
|
+
width?: number;
|
|
25
|
+
}): ReactNode {
|
|
26
|
+
const muted = entry.status === "inactive" || entry.status === "disabled";
|
|
27
|
+
const atRest = entry.tokens?.atRest ? formatTokenCount(entry.tokens.atRest) : null;
|
|
28
|
+
const onInvoke = entry.tokens?.onInvoke ? formatTokenCount(entry.tokens.onInvoke) : null;
|
|
29
|
+
const plugin = entry.agentPlugin;
|
|
30
|
+
return (
|
|
31
|
+
<Pressable
|
|
32
|
+
accessibilityRole="button"
|
|
33
|
+
accessibilityState={{ selected }}
|
|
34
|
+
accessibilityLabel={entryLabel(entry, m)}
|
|
35
|
+
onPress={() => onSelect(entry)}
|
|
36
|
+
style={({ hovered, pressed }: { hovered?: boolean; pressed: boolean }) => ({
|
|
37
|
+
width,
|
|
38
|
+
flexGrow: width == null ? 1 : 0,
|
|
39
|
+
flexBasis: width == null ? "100%" : undefined,
|
|
40
|
+
padding: CARD.padding,
|
|
41
|
+
borderRadius: RADIUS.block,
|
|
42
|
+
borderWidth: 1,
|
|
43
|
+
borderColor: selected ? colors.accent : colors.border,
|
|
44
|
+
backgroundColor: selected || hovered || pressed ? colors.surface2 : colors.surface1,
|
|
45
|
+
})}
|
|
46
|
+
>
|
|
47
|
+
<View style={{ flexDirection: "row", alignItems: "flex-start", gap: 10 }}>
|
|
48
|
+
<View style={{ paddingTop: 2, opacity: muted ? 0.5 : 1 }}>
|
|
49
|
+
<Icon name={CATEGORY_ICONS[entry.category]} size={ICON_SIZE.inline} color={colors.foregroundMuted} />
|
|
50
|
+
</View>
|
|
51
|
+
<View style={{ flex: 1, minWidth: 0, gap: 3 }}>
|
|
52
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 }}>
|
|
53
|
+
<Text
|
|
54
|
+
style={{ ...TEXT.rowTitle, color: muted ? colors.foregroundMuted : colors.foreground, flexShrink: 1 }}
|
|
55
|
+
numberOfLines={1}
|
|
56
|
+
>
|
|
57
|
+
{entry.name}
|
|
58
|
+
</Text>
|
|
59
|
+
<StatusBadge status={entry.status} label={m.statuses[entry.status]} colors={colors} />
|
|
60
|
+
</View>
|
|
61
|
+
{entry.description ? (
|
|
62
|
+
<Text style={{ ...TEXT.meta, color: colors.foregroundMuted }} numberOfLines={2}>
|
|
63
|
+
{entry.description}
|
|
64
|
+
</Text>
|
|
65
|
+
) : null}
|
|
66
|
+
<Text style={{ ...TEXT.meta, color: colors.foregroundMuted }} numberOfLines={2}>
|
|
67
|
+
{entryMeta(entry, m)}
|
|
68
|
+
</Text>
|
|
69
|
+
{atRest || onInvoke || plugin ? (
|
|
70
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 6, paddingTop: 2 }}>
|
|
71
|
+
{atRest ? <TokenBadge label={m.tokens(atRest)} hint={m.tokensHint(atRest)} colors={colors} /> : null}
|
|
72
|
+
{onInvoke ? <TokenBadge label={m.tokensOnInvoke(onInvoke)} hint={m.tokensOnInvokeHint(onInvoke)} colors={colors} /> : null}
|
|
73
|
+
{plugin ? (
|
|
74
|
+
<View style={{ borderRadius: RADIUS.control, borderWidth: 1, borderColor: plugin.validation === "valid" ? colors.accent : colors.statusWarning, paddingHorizontal: 6, paddingVertical: 2, flexShrink: 0 }}>
|
|
75
|
+
<Text style={{ ...TEXT.pillBadge, color: plugin.validation === "valid" ? colors.accent : colors.statusWarning }} numberOfLines={1}>
|
|
76
|
+
{m.agentPluginLabel(plugin.version, plugin.validation)}
|
|
77
|
+
</Text>
|
|
78
|
+
</View>
|
|
79
|
+
) : null}
|
|
80
|
+
</View>
|
|
81
|
+
) : null}
|
|
82
|
+
</View>
|
|
83
|
+
</View>
|
|
84
|
+
</Pressable>
|
|
85
|
+
);
|
|
86
|
+
});
|
package/client/entry-row.tsx
CHANGED
|
@@ -3,8 +3,9 @@ import { memo, type ReactNode } from "react";
|
|
|
3
3
|
import { Pressable, Text, View } from "react-native";
|
|
4
4
|
import type { Category, Entry } from "../shared/contracts.ts";
|
|
5
5
|
import type { Messages } from "../shared/i18n.ts";
|
|
6
|
+
import { formatTokenCount } from "../shared/i18n.ts";
|
|
6
7
|
import { ICON_SIZE, RADIUS, ROW_PADDING, TEXT } from "./design-tokens.ts";
|
|
7
|
-
import { StatusBadge, type Colors } from "./ui.tsx";
|
|
8
|
+
import { StatusBadge, TokenBadge, type Colors } from "./ui.tsx";
|
|
8
9
|
|
|
9
10
|
export const CATEGORY_ICONS: Record<Category, string> = {
|
|
10
11
|
instructions: "FileText",
|
|
@@ -26,6 +27,13 @@ export function entryMeta(entry: Entry, m: Messages, includeFormat = false): str
|
|
|
26
27
|
return parts.join(" · ");
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/** Shared row / card accessibility label: name, status, token estimate, plugin format. */
|
|
31
|
+
export function entryLabel(entry: Entry, m: Messages): string {
|
|
32
|
+
const atRest = entry.tokens?.atRest ? formatTokenCount(entry.tokens.atRest) : null;
|
|
33
|
+
const onInvoke = entry.tokens?.onInvoke ? formatTokenCount(entry.tokens.onInvoke) : null;
|
|
34
|
+
return `${entry.name}, ${m.statuses[entry.status]}${atRest ? `, ${m.tokens(atRest)}` : ""}${onInvoke ? `, ${m.tokensOnInvoke(onInvoke)}` : ""}${entry.agentPlugin ? `, ${m.agentPluginLabel(entry.agentPlugin.version, entry.agentPlugin.validation)}` : ""}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
export const EntryRow = memo(function EntryRow({
|
|
30
38
|
entry,
|
|
31
39
|
selected,
|
|
@@ -40,11 +48,13 @@ export const EntryRow = memo(function EntryRow({
|
|
|
40
48
|
m: Messages;
|
|
41
49
|
}): ReactNode {
|
|
42
50
|
const muted = entry.status === "inactive" || entry.status === "disabled";
|
|
51
|
+
const atRest = entry.tokens?.atRest ? formatTokenCount(entry.tokens.atRest) : null;
|
|
52
|
+
const onInvoke = entry.tokens?.onInvoke ? formatTokenCount(entry.tokens.onInvoke) : null;
|
|
43
53
|
return (
|
|
44
54
|
<Pressable
|
|
45
55
|
accessibilityRole="button"
|
|
46
56
|
accessibilityState={{ selected }}
|
|
47
|
-
accessibilityLabel={
|
|
57
|
+
accessibilityLabel={entryLabel(entry, m)}
|
|
48
58
|
onPress={() => onSelect(entry)}
|
|
49
59
|
style={({ hovered, pressed }: { hovered?: boolean; pressed: boolean }) => ({
|
|
50
60
|
flexDirection: "row",
|
|
@@ -57,8 +67,8 @@ export const EntryRow = memo(function EntryRow({
|
|
|
57
67
|
backgroundColor: selected ? colors.surface2 : hovered || pressed ? colors.surface1 : "transparent",
|
|
58
68
|
})}
|
|
59
69
|
>
|
|
60
|
-
<View style={{ paddingTop:
|
|
61
|
-
<Icon name={CATEGORY_ICONS[entry.category]} size={ICON_SIZE.
|
|
70
|
+
<View style={{ paddingTop: 2, opacity: muted ? 0.5 : 1 }}>
|
|
71
|
+
<Icon name={CATEGORY_ICONS[entry.category]} size={ICON_SIZE.inline} color={colors.foregroundMuted} />
|
|
62
72
|
</View>
|
|
63
73
|
<View style={{ flex: 1, minWidth: 0, gap: 3 }}>
|
|
64
74
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
@@ -69,6 +79,8 @@ export const EntryRow = memo(function EntryRow({
|
|
|
69
79
|
{entry.name}
|
|
70
80
|
</Text>
|
|
71
81
|
<StatusBadge status={entry.status} label={m.statuses[entry.status]} colors={colors} />
|
|
82
|
+
{atRest ? <TokenBadge label={m.tokens(atRest)} hint={m.tokensHint(atRest)} colors={colors} /> : null}
|
|
83
|
+
{onInvoke ? <TokenBadge label={m.tokensOnInvoke(onInvoke)} hint={m.tokensOnInvokeHint(onInvoke)} colors={colors} /> : null}
|
|
72
84
|
{entry.agentPlugin ? (
|
|
73
85
|
<View style={{ borderRadius: RADIUS.control, borderWidth: 1, borderColor: entry.agentPlugin.validation === "valid" ? colors.accent : colors.statusWarning, paddingHorizontal: 6, paddingVertical: 2, flexShrink: 0 }}>
|
|
74
86
|
<Text style={{ ...TEXT.pillBadge, color: entry.agentPlugin.validation === "valid" ? colors.accent : colors.statusWarning }} numberOfLines={1}>{m.agentPluginLabel(entry.agentPlugin.version, entry.agentPlugin.validation)}</Text>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { cardWidth, gridColumns, GRID } from "./grid.ts";
|
|
4
|
+
|
|
5
|
+
test("gridColumns: 1 column narrow, up to maxColumns wide", () => {
|
|
6
|
+
assert.equal(gridColumns(0), 1);
|
|
7
|
+
assert.equal(gridColumns(491), 1); // 2 columns need 2 * 240 + 12 = 492
|
|
8
|
+
assert.equal(gridColumns(492), 2);
|
|
9
|
+
assert.equal(gridColumns(743), 2); // 3 columns need 3 * 240 + 2 * 12 = 744
|
|
10
|
+
assert.equal(gridColumns(744), 3);
|
|
11
|
+
assert.equal(gridColumns(1_600), GRID.maxColumns);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("cardWidth: splits the row minus gaps; undefined before measurement", () => {
|
|
15
|
+
assert.equal(cardWidth(0, 1), undefined);
|
|
16
|
+
assert.equal(cardWidth(492, 2), GRID.minCardWidth);
|
|
17
|
+
assert.equal(cardWidth(744, 3), GRID.minCardWidth);
|
|
18
|
+
assert.equal(cardWidth(1_000, 3), (1_000 - GRID.gap * 2) / 3);
|
|
19
|
+
});
|
package/client/grid.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card-view grid metrics (re-exported by `design-tokens.ts`).
|
|
3
|
+
* Kept in this React Native-free module so Node tests can import the grid math.
|
|
4
|
+
*/
|
|
5
|
+
export const GRID = { minCardWidth: 240, maxColumns: 3, gap: 12, labelGap: 6 } as const;
|
|
6
|
+
|
|
7
|
+
/** Card columns for the measured content width; 0 means not measured yet. */
|
|
8
|
+
export function gridColumns(availableWidth: number): number {
|
|
9
|
+
if (!(availableWidth > 0)) return 1;
|
|
10
|
+
const columns = Math.floor((availableWidth + GRID.gap) / (GRID.minCardWidth + GRID.gap));
|
|
11
|
+
return Math.max(1, Math.min(GRID.maxColumns, columns));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Card width for a column count; undefined until the content width is measured. */
|
|
15
|
+
export function cardWidth(availableWidth: number, columns: number): number | undefined {
|
|
16
|
+
if (!(availableWidth > 0) || columns < 1) return undefined;
|
|
17
|
+
return (availableWidth - GRID.gap * (columns - 1)) / columns;
|
|
18
|
+
}
|
|
@@ -1,74 +1,106 @@
|
|
|
1
1
|
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
2
2
|
import { useState, type ReactNode } from "react";
|
|
3
|
-
import { Pressable, Text, View } from "react-native";
|
|
3
|
+
import { Platform, Pressable, ScrollView, Text, View } from "react-native";
|
|
4
4
|
import type { Mechanism } from "../shared/mechanisms.ts";
|
|
5
5
|
import type { AppLanguage, Messages } from "../shared/i18n.ts";
|
|
6
|
-
import { CONTROL, FONT_WEIGHT, ICON_SIZE, RADIUS, TEXT } from "./design-tokens.ts";
|
|
6
|
+
import { CONTROL, FONT_WEIGHT, ICON_SIZE, MENU, RADIUS, TEXT } from "./design-tokens.ts";
|
|
7
7
|
import type { Colors } from "./ui.tsx";
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/** Inline entry with a dropdown for the provider/category loading details. */
|
|
10
10
|
export function MechanismCard({
|
|
11
11
|
mechanism,
|
|
12
12
|
language,
|
|
13
13
|
colors,
|
|
14
14
|
m,
|
|
15
|
+
compact,
|
|
15
16
|
}: {
|
|
16
17
|
mechanism: Mechanism;
|
|
17
18
|
language: AppLanguage;
|
|
18
19
|
colors: Colors;
|
|
19
20
|
m: Messages;
|
|
21
|
+
compact: boolean;
|
|
20
22
|
}): ReactNode {
|
|
21
23
|
const [open, setOpen] = useState(false);
|
|
22
24
|
const pick = (text: { en: string; zh: string }) => (language === "zh-CN" ? text.zh : text.en);
|
|
25
|
+
const title = mechanism.supported ? m.howItWorks : m.unsupported;
|
|
26
|
+
const icon = mechanism.supported ? "Info" : "Ban";
|
|
23
27
|
const [first, ...rest] = mechanism.notes;
|
|
24
|
-
const expandable = mechanism.locations.length > 0 || rest.length > 0;
|
|
25
28
|
|
|
26
29
|
return (
|
|
27
|
-
<View
|
|
28
|
-
style={{
|
|
29
|
-
borderRadius: RADIUS.overlay,
|
|
30
|
-
borderWidth: 1,
|
|
31
|
-
borderColor: colors.border,
|
|
32
|
-
backgroundColor: colors.surface1,
|
|
33
|
-
paddingHorizontal: 12,
|
|
34
|
-
paddingVertical: 8,
|
|
35
|
-
gap: 6,
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
30
|
+
<View style={{ position: "relative", zIndex: open ? 40 : 1, flexShrink: 0 }}>
|
|
38
31
|
<Pressable
|
|
39
32
|
accessibilityRole="button"
|
|
40
33
|
accessibilityState={{ expanded: open }}
|
|
41
|
-
accessibilityLabel={
|
|
42
|
-
disabled={!expandable}
|
|
43
|
-
hitSlop={CONTROL.hitSlop}
|
|
34
|
+
accessibilityLabel={title}
|
|
44
35
|
onPress={() => setOpen((prev) => !prev)}
|
|
45
|
-
style={{
|
|
36
|
+
style={{
|
|
37
|
+
flexDirection: "row",
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
gap: 6,
|
|
40
|
+
height: CONTROL.searchHeight,
|
|
41
|
+
paddingHorizontal: 10,
|
|
42
|
+
borderRadius: RADIUS.control,
|
|
43
|
+
borderWidth: 1,
|
|
44
|
+
borderColor: colors.border,
|
|
45
|
+
backgroundColor: colors.surface1,
|
|
46
|
+
}}
|
|
46
47
|
>
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<Text style={{ ...TEXT.meta, color: colors.foreground, flex: 1 }}>
|
|
51
|
-
<Text style={{ fontWeight: FONT_WEIGHT.semibold }}>{mechanism.supported ? m.howItWorks : m.unsupported}</Text>
|
|
52
|
-
{first ? ` ${pick(first)}` : ""}
|
|
53
|
-
</Text>
|
|
54
|
-
{expandable ? <Icon name={open ? "ChevronUp" : "ChevronDown"} size={ICON_SIZE.inline} color={colors.foregroundMuted} /> : null}
|
|
48
|
+
<Icon name={icon} size={ICON_SIZE.inline} color={colors.foregroundMuted} />
|
|
49
|
+
<Text style={{ ...TEXT.small, fontWeight: FONT_WEIGHT.medium, color: colors.foreground }}>{title}</Text>
|
|
50
|
+
<Icon name={open ? "ChevronUp" : "ChevronDown"} size={ICON_SIZE.inline} color={colors.foregroundMuted} />
|
|
55
51
|
</Pressable>
|
|
56
52
|
{open ? (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
<>
|
|
54
|
+
<Pressable
|
|
55
|
+
accessibilityRole="button"
|
|
56
|
+
accessibilityLabel={m.closeMenu}
|
|
57
|
+
onPress={() => setOpen(false)}
|
|
58
|
+
style={{
|
|
59
|
+
position: (Platform.OS === "web" ? "fixed" : "absolute") as "absolute",
|
|
60
|
+
top: 0,
|
|
61
|
+
left: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
bottom: 0,
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
<View
|
|
67
|
+
style={{
|
|
68
|
+
position: "absolute",
|
|
69
|
+
top: "100%",
|
|
70
|
+
right: 0,
|
|
71
|
+
marginTop: 4,
|
|
72
|
+
width: compact ? 280 : MENU.maxWidth,
|
|
73
|
+
borderRadius: RADIUS.overlay,
|
|
74
|
+
borderWidth: 1,
|
|
75
|
+
borderColor: colors.border,
|
|
76
|
+
backgroundColor: colors.surface1,
|
|
77
|
+
shadowColor: "rgba(0, 0, 0, 0.04)",
|
|
78
|
+
shadowOffset: { width: 0, height: 4 },
|
|
79
|
+
shadowRadius: 16,
|
|
80
|
+
elevation: 4,
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<ScrollView
|
|
84
|
+
style={{ maxHeight: MENU.visibleRows * MENU.rowHeight + 8 }}
|
|
85
|
+
contentContainerStyle={{ padding: 12, gap: 12 }}
|
|
86
|
+
>
|
|
87
|
+
{first ? <Text style={{ ...TEXT.body, color: colors.foreground }}>{pick(first)}</Text> : null}
|
|
88
|
+
{mechanism.locations.map((location, index) => (
|
|
89
|
+
<View key={index} style={{ flexDirection: "row", gap: 8 }}>
|
|
90
|
+
<Text style={{ ...TEXT.meta, color: colors.foregroundMuted, minWidth: 56 }}>{m.scopes[location.scope]}</Text>
|
|
91
|
+
<Text style={{ ...TEXT.path, color: colors.foreground, flex: 1 }} selectable>
|
|
92
|
+
{location.path}
|
|
93
|
+
</Text>
|
|
94
|
+
</View>
|
|
95
|
+
))}
|
|
96
|
+
{rest.map((note, index) => (
|
|
97
|
+
<Text key={index} style={{ ...TEXT.meta, color: colors.foreground }}>
|
|
98
|
+
• {pick(note)}
|
|
99
|
+
</Text>
|
|
100
|
+
))}
|
|
101
|
+
</ScrollView>
|
|
102
|
+
</View>
|
|
103
|
+
</>
|
|
72
104
|
) : null}
|
|
73
105
|
</View>
|
|
74
106
|
);
|
package/client/preview-pane.tsx
CHANGED
|
@@ -4,10 +4,10 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
5
|
import { Text, View } from "react-native";
|
|
6
6
|
import { openRpc, previewRpc, type Entry } from "../shared/contracts.ts";
|
|
7
|
-
import { formatBytes, type Messages } from "../shared/i18n.ts";
|
|
8
|
-
import { RADIUS, TEXT } from "./design-tokens.ts";
|
|
7
|
+
import { formatBytes, formatTokenCount, type Messages } from "../shared/i18n.ts";
|
|
8
|
+
import { ICON_SIZE, RADIUS, TEXT } from "./design-tokens.ts";
|
|
9
9
|
import { entryMeta } from "./entry-row.tsx";
|
|
10
|
-
import { ErrorState, IconButton, LoadingState, StatusBadge, TextButton, type Colors } from "./ui.tsx";
|
|
10
|
+
import { ErrorState, IconButton, LoadingState, StatusBadge, TextButton, TokenBadge, type Colors } from "./ui.tsx";
|
|
11
11
|
|
|
12
12
|
export function PreviewPane({
|
|
13
13
|
entry,
|
|
@@ -51,6 +51,12 @@ export function PreviewPane({
|
|
|
51
51
|
{entry.name}
|
|
52
52
|
</Text>
|
|
53
53
|
<StatusBadge status={entry.status} label={m.statuses[entry.status]} colors={colors} />
|
|
54
|
+
{entry.tokens?.atRest ? (
|
|
55
|
+
<TokenBadge label={m.tokens(formatTokenCount(entry.tokens.atRest))} hint={m.tokensHint(formatTokenCount(entry.tokens.atRest))} colors={colors} />
|
|
56
|
+
) : null}
|
|
57
|
+
{entry.tokens?.onInvoke ? (
|
|
58
|
+
<TokenBadge label={m.tokensOnInvoke(formatTokenCount(entry.tokens.onInvoke))} hint={m.tokensOnInvokeHint(formatTokenCount(entry.tokens.onInvoke))} colors={colors} />
|
|
59
|
+
) : null}
|
|
54
60
|
<View style={{ flex: 1 }} />
|
|
55
61
|
<TextButton icon="ExternalLink" label={m.preview.open} onPress={() => run(false)} colors={colors} />
|
|
56
62
|
{!compact && !isUrl ? <TextButton icon="FolderOpen" label={m.preview.reveal} onPress={() => run(true)} colors={colors} /> : null}
|
|
@@ -58,6 +64,7 @@ export function PreviewPane({
|
|
|
58
64
|
icon="Copy"
|
|
59
65
|
label={m.preview.copyPath}
|
|
60
66
|
color={colors.foregroundMuted}
|
|
67
|
+
size={ICON_SIZE.inline}
|
|
61
68
|
onPress={() => {
|
|
62
69
|
copyText(entry.path).then(() => toast.show(m.preview.copied), () => {});
|
|
63
70
|
}}
|
|
@@ -12,10 +12,10 @@ test("only enabled providers with Customize scanners appear, including unavailab
|
|
|
12
12
|
], "Built-in");
|
|
13
13
|
|
|
14
14
|
assert.deepEqual(options, [
|
|
15
|
-
{ id: "codex", label: "My Codex", badge: "Built-in" },
|
|
16
|
-
{ id: "
|
|
17
|
-
{ id: "
|
|
18
|
-
{ id: "gemini", label: "Gemini CLI", badge: "ACP" },
|
|
15
|
+
{ id: "codex", label: "My Codex", badge: "Built-in", group: "builtin" },
|
|
16
|
+
{ id: "pi", label: "Pi", badge: "Built-in", group: "builtin" },
|
|
17
|
+
{ id: "cursor", label: "Cursor", badge: "ACP", group: "acp" },
|
|
18
|
+
{ id: "gemini", label: "Gemini CLI", badge: "ACP", group: "acp" },
|
|
19
19
|
]);
|
|
20
20
|
assert.equal(selectedProvider("claude", options), "codex");
|
|
21
21
|
assert.equal(selectedProvider("cursor", options), "cursor");
|
|
@@ -27,5 +27,16 @@ test("snapshot duplicates and older source omissions keep one option", () => {
|
|
|
27
27
|
{ provider: "cursor", enabled: true },
|
|
28
28
|
{ provider: "cursor", enabled: true, source: "custom" },
|
|
29
29
|
], "内置");
|
|
30
|
-
assert.deepEqual(options, [{ id: "cursor", label: "Cursor", badge: "ACP" }]);
|
|
30
|
+
assert.deepEqual(options, [{ id: "cursor", label: "Cursor", badge: "ACP", group: "acp" }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("each group sorts by display name, built-ins before ACP", () => {
|
|
34
|
+
const options = enabledProviderOptions([
|
|
35
|
+
{ provider: "pi", enabled: true, source: "builtin", label: "zeta" },
|
|
36
|
+
{ provider: "codex", enabled: true, source: "builtin", label: "Alpha" },
|
|
37
|
+
{ provider: "gemini", enabled: true, source: "custom", label: "beta" },
|
|
38
|
+
{ provider: "cursor", enabled: true, source: "custom", label: "Gamma" },
|
|
39
|
+
], "Built-in");
|
|
40
|
+
assert.deepEqual(options.map((option) => option.label), ["Alpha", "zeta", "beta", "Gamma"]);
|
|
41
|
+
assert.deepEqual(options.map((option) => option.group), ["builtin", "builtin", "acp", "acp"]);
|
|
31
42
|
});
|