@koinzhang/paseo-plugin-customize 0.1.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 +24 -0
- package/LICENSE +21 -0
- package/README.md +58 -0
- package/client/category-visibility.test.ts +26 -0
- package/client/design-tokens.test.ts +39 -0
- package/client/design-tokens.ts +104 -0
- package/client/dropdown.tsx +139 -0
- package/client/entries.test.ts +50 -0
- package/client/entries.ts +47 -0
- package/client/entry-row.tsx +89 -0
- package/client/mechanism-card.tsx +75 -0
- package/client/preview-pane.tsx +101 -0
- package/client/provider-options.test.ts +31 -0
- package/client/provider-options.ts +37 -0
- package/client/query-policy.test.ts +57 -0
- package/client/query-policy.ts +20 -0
- package/client/route.ts +29 -0
- package/client/selection-settings.test.ts +16 -0
- package/client/slash-command.test.ts +94 -0
- package/client/slash-command.ts +36 -0
- package/client/surface.tsx +332 -0
- package/client/ui.tsx +265 -0
- package/client/use-app-language.ts +28 -0
- package/client/web.ts +111 -0
- package/index.client.tsx +57 -0
- package/index.server.ts +13 -0
- package/package.json +37 -0
- package/paseo-plugin.json +6 -0
- package/server/agent-plugins.ts +41 -0
- package/server/compatibility.test.ts +104 -0
- package/server/compatibility.ts +46 -0
- package/server/frontmatter.ts +49 -0
- package/server/glob.ts +46 -0
- package/server/handlers.ts +193 -0
- package/server/jsonc.ts +40 -0
- package/server/mcp.ts +87 -0
- package/server/parsers.test.ts +92 -0
- package/server/providers/acp.ts +186 -0
- package/server/providers/claude.ts +284 -0
- package/server/providers/codex.ts +219 -0
- package/server/providers/copilot.ts +116 -0
- package/server/providers/cursor.ts +194 -0
- package/server/providers/omp.ts +263 -0
- package/server/providers/opencode.ts +215 -0
- package/server/providers/pi.ts +102 -0
- package/server/providers.test.ts +306 -0
- package/server/scan-kit.ts +368 -0
- package/server/scan-snapshot.test.ts +56 -0
- package/server/scan-snapshot.ts +58 -0
- package/server/skill-aliases.ts +60 -0
- package/server/toml.ts +240 -0
- package/server/yaml-lite.ts +172 -0
- package/shared/acp-configs.ts +107 -0
- package/shared/category-visibility.ts +26 -0
- package/shared/compatibility.ts +6 -0
- package/shared/contracts.ts +116 -0
- package/shared/i18n.ts +293 -0
- package/shared/mechanisms.ts +380 -0
- package/shared/providers.ts +27 -0
- package/shared/selection-settings.ts +14 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@koinzhang/paseo-plugin-customize` are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-09-25
|
|
9
|
+
|
|
10
|
+
Requires Paseo **>= 0.9.0**.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Customize board (sidebar navigation item + Command Center): instructions, rules, skills, MCP servers, commands, subagents, and plugins for supported providers and projects, split into project and user scope.
|
|
15
|
+
- `/customize` command opens the board from an agent composer and selects its provider and workspace project when available.
|
|
16
|
+
- Provider picker lists enabled, supported Paseo providers and identifies Built-in and ACP providers; provider and project choices persist on the host.
|
|
17
|
+
- Discovery status per entry (auto / conditional / manual only / needs approval / disabled / not loaded) with the frontmatter or config reason.
|
|
18
|
+
- Bottom preview pane with open, reveal, and copy path; MCP previews redact secrets.
|
|
19
|
+
- Provider-specific loading notes, category visibility, and skill-directory compatibility status, including Cursor and OpenCode switches.
|
|
20
|
+
- Agent Plugins manifest version badge, with unverified labeling for future schema versions, and Cursor local test-plugin discovery.
|
|
21
|
+
- Private, persistent scan snapshots with a last-scan tooltip, background refresh after 10 minutes, and retry after failures.
|
|
22
|
+
- Skill aliases that resolve to the same file appear once, while distinct files with the same name remain separate.
|
|
23
|
+
|
|
24
|
+
[0.1.0]: https://www.npmjs.com/package/@koinzhang/paseo-plugin-customize/v/0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 koinzhang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Customize
|
|
2
|
+
|
|
3
|
+
One board that scans local agent configuration for a project: **instructions** (AGENTS.md, CLAUDE.md …), **rules**, **skills**, **MCP servers**, **commands**, **subagents**, and **plugins** at project and user level.
|
|
4
|
+
|
|
5
|
+
Requires Paseo >= 0.9.0.
|
|
6
|
+
|
|
7
|
+
## What you get
|
|
8
|
+
|
|
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
|
+
- 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.
|
|
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
|
+
- 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.
|
|
14
|
+
- 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.
|
|
15
|
+
- For OpenCode 1.18, every discovered and permitted skill is advertised automatically, even if its frontmatter contains another agent's `disable-model-invocation` setting. The skill body loads only when the agent calls the `skill` tool; `permission.skill: deny` still hides a skill.
|
|
16
|
+
- Each row shows name, description, directory, and a status:
|
|
17
|
+
|
|
18
|
+
| Status | Meaning |
|
|
19
|
+
|---|---|
|
|
20
|
+
| Auto | Loaded / offered to the model without you doing anything |
|
|
21
|
+
| Conditional | Loaded when a glob, nested directory, or the agent's judgement matches |
|
|
22
|
+
| Manual only | Only when you invoke it (`/name`, `@rule`, `disable-model-invocation`, `allow_implicit_invocation: false` …) |
|
|
23
|
+
| Needs approval | Found, but the provider asks before using it (e.g. unapproved `.mcp.json` servers) |
|
|
24
|
+
| Disabled | Explicitly turned off in config (`enabled = false`, `skillOverrides: off`, `disabledMcpServers` …) |
|
|
25
|
+
| Not loaded | Present but ignored (shadowed by a higher-priority file, untrusted project, off by default) |
|
|
26
|
+
|
|
27
|
+
The reason (the exact frontmatter key or config setting) is shown next to the status.
|
|
28
|
+
|
|
29
|
+
- 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.
|
|
30
|
+
|
|
31
|
+
Scanning is read-only. Preview and open only accept paths returned by a scan.
|
|
32
|
+
The list is disk evidence, not a live CLI inventory. Trust, plugin enablement, command-line flags, and newer CLI versions may change what a running agent uses. An empty category marked "No scanned location" means no verified file location is configured in Customize; it does not mean the provider lacks that capability.
|
|
33
|
+
|
|
34
|
+
Provider/Project scans are saved as private JSON snapshots in the Paseo host's `plugin-data/customize/` directory (`$PASEO_HOME`, or `~/.paseo` by default). The board shows the saved list after an app or plugin restart; hover over Rescan to see the last scan time. It scans in the background when the snapshot is at least 10 minutes old, a compatibility switch changes, no snapshot exists, or you press Rescan. A failed refresh keeps the last list visible with a retry action. Damaged or incompatible snapshots are ignored. Previews and Open recheck paths from saved snapshots against a current scan.
|
|
35
|
+
|
|
36
|
+
Plugin rows read the declared specification version from the root `plugin.json` `$schema`. A valid supported manifest shows **Agent Plugins 1.0.0**; a future canonical version shows its declared version with an **unverified** qualifier until Customize supports that schema. The badge does not validate bundled skills or MCP servers, or confirm runtime activation.
|
|
37
|
+
For Cursor, the Plugins tab also scans local test packages under `~/.cursor/plugins/local/<plugin-name>`.
|
|
38
|
+
|
|
39
|
+
Per-provider mechanisms and their sources are recorded in [`specs/001-customize-board/research.md`](./specs/001-customize-board/research.md) and [`specs/003-acp-configurations/research.md`](./specs/003-acp-configurations/research.md).
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
paseo plugin add koinzhang/paseo-plugins --path customize
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Development
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cd customize
|
|
51
|
+
npm install
|
|
52
|
+
npm run typecheck
|
|
53
|
+
npm test
|
|
54
|
+
paseo plugin install "$PWD"
|
|
55
|
+
paseo plugin reload customize
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Provider scanners live in `server/providers/`; shared helpers (nested directory index, skill discovery, redaction) in `server/scan-kit.ts` and `server/mcp.ts`. The "how it loads" notes are data in `shared/mechanisms.ts`. UI follows the Activity design tokens (`client/design-tokens.ts`); `npm test` rejects raw font / radius / icon literals.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { resolveCategory, visibleCategories } from "../shared/category-visibility.ts";
|
|
4
|
+
import { CATEGORIES } from "../shared/contracts.ts";
|
|
5
|
+
|
|
6
|
+
test("hides categories without verified provider support", () => {
|
|
7
|
+
assert.deepEqual(visibleCategories("cursor"), [...CATEGORIES]);
|
|
8
|
+
assert.deepEqual(visibleCategories("pi"), ["instructions", "skills", "commands", "plugins"]);
|
|
9
|
+
assert.equal(visibleCategories("gemini").includes("rules"), false);
|
|
10
|
+
assert.equal(visibleCategories("kiro").includes("commands"), false);
|
|
11
|
+
assert.equal(visibleCategories("kimi").includes("rules"), false);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("keeps confirmed capabilities visible when their local scan is incomplete", () => {
|
|
15
|
+
assert.equal(visibleCategories("cline").includes("commands"), true);
|
|
16
|
+
assert.equal(visibleCategories("kilo").includes("plugins"), true);
|
|
17
|
+
assert.equal(visibleCategories("traecli").includes("plugins"), true);
|
|
18
|
+
assert.equal(visibleCategories("copilot").includes("subagents"), true);
|
|
19
|
+
assert.equal(visibleCategories("opencode").includes("plugins"), true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("selects a visible category when switching providers", () => {
|
|
23
|
+
assert.equal(resolveCategory("pi", "mcp"), "instructions");
|
|
24
|
+
assert.equal(resolveCategory("kiro", "commands"), "instructions");
|
|
25
|
+
assert.equal(resolveCategory("cursor", "commands"), "commands");
|
|
26
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { test } from "node:test";
|
|
5
|
+
|
|
6
|
+
const CLIENT_DIR = new URL(".", import.meta.url).pathname;
|
|
7
|
+
|
|
8
|
+
const RULES: ReadonlyArray<{ name: string; pattern: RegExp }> = [
|
|
9
|
+
{ name: "fontSize literal", pattern: /fontSize:\s*[0-9]/ },
|
|
10
|
+
{ name: "fontWeight literal", pattern: /fontWeight:\s*["'][0-9a-z]+["']/ },
|
|
11
|
+
{ name: "border radius literal", pattern: /[bB]order\w*Radius:\s*[0-9]/ },
|
|
12
|
+
{ name: "Icon size literal", pattern: /<Icon\b[^>]*\bsize=\{[0-9]/ },
|
|
13
|
+
{ name: "multi-line Icon size literal", pattern: /^\s*size=\{[0-9]+\}\s*$/ },
|
|
14
|
+
{ name: "hitSlop literal", pattern: /hitSlop=\{[0-9]/ },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
function tsxFiles(dir: string): string[] {
|
|
18
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
19
|
+
const path = join(dir, entry.name);
|
|
20
|
+
if (entry.isDirectory()) return tsxFiles(path);
|
|
21
|
+
return entry.name.endsWith(".tsx") ? [path] : [];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
test("client UI uses design tokens instead of raw type / radius / icon literals", () => {
|
|
26
|
+
const violations: string[] = [];
|
|
27
|
+
for (const file of tsxFiles(CLIENT_DIR)) {
|
|
28
|
+
readFileSync(file, "utf8")
|
|
29
|
+
.split("\n")
|
|
30
|
+
.forEach((line, index) => {
|
|
31
|
+
for (const rule of RULES) {
|
|
32
|
+
if (rule.pattern.test(line)) {
|
|
33
|
+
violations.push(`${relative(CLIENT_DIR, file)}:${index + 1} ${rule.name}: ${line.trim()}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
assert.deepEqual(violations, [], "use client/design-tokens.ts (see docs/design-system.md)");
|
|
39
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Platform, type TextStyle, type ViewStyle } from "react-native";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Customize design tokens, shared with the Activity plugin
|
|
5
|
+
* (`activity/client/design-tokens.ts`, `activity/docs/design-system.md`).
|
|
6
|
+
* The host only supplies `theme.colors` and `layout.compact`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const MONO = Platform.select({ ios: "Menlo", default: "monospace" });
|
|
10
|
+
|
|
11
|
+
export const FONT_SIZE = {
|
|
12
|
+
badge: 9,
|
|
13
|
+
caption: 11,
|
|
14
|
+
label: 12,
|
|
15
|
+
small: 13,
|
|
16
|
+
body: 14,
|
|
17
|
+
title: 15,
|
|
18
|
+
metric: 18,
|
|
19
|
+
display: 19,
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
export const FONT_WEIGHT = {
|
|
23
|
+
regular: "normal",
|
|
24
|
+
medium: "500",
|
|
25
|
+
semibold: "600",
|
|
26
|
+
bold: "700",
|
|
27
|
+
} as const satisfies Record<string, TextStyle["fontWeight"]>;
|
|
28
|
+
|
|
29
|
+
const TABULAR: TextStyle["fontVariant"] = ["tabular-nums"];
|
|
30
|
+
|
|
31
|
+
/** Text roles without color; components add `color` from `theme.colors`. */
|
|
32
|
+
export const TEXT = {
|
|
33
|
+
display: { fontSize: FONT_SIZE.display, fontWeight: FONT_WEIGHT.medium },
|
|
34
|
+
rowTitle: { fontSize: FONT_SIZE.body, fontWeight: FONT_WEIGHT.medium },
|
|
35
|
+
body: { fontSize: FONT_SIZE.body },
|
|
36
|
+
small: { fontSize: FONT_SIZE.small },
|
|
37
|
+
meta: { fontSize: FONT_SIZE.label },
|
|
38
|
+
caption: { fontSize: FONT_SIZE.caption },
|
|
39
|
+
count: { fontSize: FONT_SIZE.small, fontVariant: TABULAR },
|
|
40
|
+
pillBadge: { fontSize: FONT_SIZE.caption, fontWeight: FONT_WEIGHT.semibold, fontVariant: TABULAR },
|
|
41
|
+
code: { fontSize: FONT_SIZE.small, lineHeight: 20, fontFamily: MONO },
|
|
42
|
+
path: { fontSize: FONT_SIZE.label, fontFamily: MONO },
|
|
43
|
+
menu: { fontSize: FONT_SIZE.body, lineHeight: 18, fontWeight: FONT_WEIGHT.regular },
|
|
44
|
+
} as const satisfies Record<string, TextStyle>;
|
|
45
|
+
|
|
46
|
+
export function sectionTitle(compact = false): TextStyle {
|
|
47
|
+
return {
|
|
48
|
+
fontSize: compact ? FONT_SIZE.body : FONT_SIZE.title,
|
|
49
|
+
fontWeight: FONT_WEIGHT.semibold,
|
|
50
|
+
letterSpacing: -0.3,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Sidebar surface rhythm (Activity `pageLayout("surface")`). */
|
|
55
|
+
export function pageLayout(compact: boolean): { padding: number; gap: number } {
|
|
56
|
+
return { padding: compact ? 16 : 24, gap: compact ? 24 : 32 };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function titleGap(compact = false): number {
|
|
60
|
+
return compact ? 10 : 12;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const ROW_PADDING = { dense: 6, regular: 9 } as const;
|
|
64
|
+
|
|
65
|
+
export const RADIUS = {
|
|
66
|
+
swatch: 3,
|
|
67
|
+
control: 6,
|
|
68
|
+
overlay: 8,
|
|
69
|
+
block: 12,
|
|
70
|
+
card: 20,
|
|
71
|
+
} as const;
|
|
72
|
+
|
|
73
|
+
export function pillRadius(height: number): number {
|
|
74
|
+
return height / 2;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const ICON_SIZE = {
|
|
78
|
+
badge: 12,
|
|
79
|
+
inline: 14,
|
|
80
|
+
action: 16,
|
|
81
|
+
leading: 18,
|
|
82
|
+
} as const;
|
|
83
|
+
|
|
84
|
+
export const CONTROL = {
|
|
85
|
+
iconButton: 24,
|
|
86
|
+
hitSlop: 8,
|
|
87
|
+
pillBadgeHeight: 18,
|
|
88
|
+
searchHeight: 30,
|
|
89
|
+
} as const;
|
|
90
|
+
|
|
91
|
+
export const iconButton: ViewStyle = {
|
|
92
|
+
width: CONTROL.iconButton,
|
|
93
|
+
height: CONTROL.iconButton,
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
justifyContent: "center",
|
|
96
|
+
borderRadius: RADIUS.control,
|
|
97
|
+
flexShrink: 0,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Floating menu surface (Activity `ProviderDropdown`). */
|
|
101
|
+
export const MENU = { minWidth: 200, maxWidth: 360, rowHeight: 28, visibleRows: 12 } as const;
|
|
102
|
+
|
|
103
|
+
/** Bottom preview pane height as a fraction of the panel. */
|
|
104
|
+
export const PREVIEW_FRACTION = { regular: 0.45, compact: 0.5 } as const;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
2
|
+
import { useState, type ReactNode } from "react";
|
|
3
|
+
import { Platform, Pressable, ScrollView, Text, View } from "react-native";
|
|
4
|
+
import { CONTROL, FONT_WEIGHT, ICON_SIZE, MENU, RADIUS, TEXT } from "./design-tokens.ts";
|
|
5
|
+
import type { Colors } from "./ui.tsx";
|
|
6
|
+
|
|
7
|
+
export interface DropdownOption {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
badge?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* `Label: Value ▾` trigger with a floating menu. A transparent backdrop
|
|
16
|
+
* closes it on outside press.
|
|
17
|
+
*/
|
|
18
|
+
export function Dropdown({
|
|
19
|
+
label,
|
|
20
|
+
options,
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
colors,
|
|
24
|
+
triggerLabel,
|
|
25
|
+
closeLabel,
|
|
26
|
+
emptyLabel,
|
|
27
|
+
menuAlign = "right",
|
|
28
|
+
disabled = false,
|
|
29
|
+
}: {
|
|
30
|
+
label: string;
|
|
31
|
+
options: readonly DropdownOption[];
|
|
32
|
+
value: string | null;
|
|
33
|
+
onChange: (id: string) => void;
|
|
34
|
+
colors: Colors;
|
|
35
|
+
triggerLabel: string;
|
|
36
|
+
closeLabel: string;
|
|
37
|
+
emptyLabel?: string;
|
|
38
|
+
menuAlign?: "left" | "right";
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
}): ReactNode {
|
|
41
|
+
const [open, setOpen] = useState(false);
|
|
42
|
+
const current = options.find((option) => option.id === value);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<View style={{ position: "relative", zIndex: open ? 40 : 20, flexShrink: 1, minWidth: 0 }}>
|
|
46
|
+
<Pressable
|
|
47
|
+
accessibilityRole="button"
|
|
48
|
+
accessibilityLabel={triggerLabel}
|
|
49
|
+
accessibilityState={{ expanded: open, disabled }}
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
hitSlop={CONTROL.hitSlop}
|
|
52
|
+
onPress={() => setOpen((prev) => !prev)}
|
|
53
|
+
style={{ flexDirection: "row", alignItems: "center", gap: 4, paddingVertical: 6, minWidth: 0 }}
|
|
54
|
+
>
|
|
55
|
+
<Text style={{ ...TEXT.body, color: colors.foregroundMuted }}>{label}:</Text>
|
|
56
|
+
<Text style={{ ...TEXT.body, fontWeight: FONT_WEIGHT.semibold, color: colors.foreground, flexShrink: 1 }} numberOfLines={1}>
|
|
57
|
+
{current?.label ?? emptyLabel ?? ""}
|
|
58
|
+
</Text>
|
|
59
|
+
<Icon name="ChevronDown" size={ICON_SIZE.inline} color={colors.foregroundMuted} />
|
|
60
|
+
</Pressable>
|
|
61
|
+
|
|
62
|
+
{open ? (
|
|
63
|
+
<>
|
|
64
|
+
<Pressable
|
|
65
|
+
accessibilityRole="button"
|
|
66
|
+
accessibilityLabel={closeLabel}
|
|
67
|
+
onPress={() => setOpen(false)}
|
|
68
|
+
style={{
|
|
69
|
+
position: (Platform.OS === "web" ? "fixed" : "absolute") as "absolute",
|
|
70
|
+
top: 0,
|
|
71
|
+
left: 0,
|
|
72
|
+
right: 0,
|
|
73
|
+
bottom: 0,
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
<View
|
|
77
|
+
style={{
|
|
78
|
+
position: "absolute",
|
|
79
|
+
top: "100%",
|
|
80
|
+
...(menuAlign === "left" ? { left: 0 } : { right: 0 }),
|
|
81
|
+
marginTop: 4,
|
|
82
|
+
minWidth: MENU.minWidth,
|
|
83
|
+
maxWidth: MENU.maxWidth,
|
|
84
|
+
borderRadius: RADIUS.overlay,
|
|
85
|
+
borderWidth: 1,
|
|
86
|
+
borderColor: colors.border,
|
|
87
|
+
backgroundColor: colors.surface1,
|
|
88
|
+
shadowColor: "rgba(0, 0, 0, 0.04)",
|
|
89
|
+
shadowOffset: { width: 0, height: 4 },
|
|
90
|
+
shadowRadius: 16,
|
|
91
|
+
elevation: 4,
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
<ScrollView style={{ maxHeight: MENU.visibleRows * MENU.rowHeight + 8 }} contentContainerStyle={{ paddingVertical: 4 }}>
|
|
95
|
+
{options.map((option) => {
|
|
96
|
+
const selected = option.id === value;
|
|
97
|
+
return (
|
|
98
|
+
<Pressable
|
|
99
|
+
key={option.id}
|
|
100
|
+
accessibilityRole="button"
|
|
101
|
+
accessibilityState={{ selected }}
|
|
102
|
+
onPress={() => {
|
|
103
|
+
onChange(option.id);
|
|
104
|
+
setOpen(false);
|
|
105
|
+
}}
|
|
106
|
+
style={({ pressed, hovered }: { pressed: boolean; hovered?: boolean }) => ({
|
|
107
|
+
flexDirection: "row",
|
|
108
|
+
alignItems: "center",
|
|
109
|
+
minHeight: MENU.rowHeight,
|
|
110
|
+
gap: 8,
|
|
111
|
+
marginHorizontal: 4,
|
|
112
|
+
paddingHorizontal: 8,
|
|
113
|
+
paddingVertical: option.hint ? 4 : 0,
|
|
114
|
+
borderRadius: RADIUS.control,
|
|
115
|
+
backgroundColor: pressed || hovered ? colors.surface2 : "transparent",
|
|
116
|
+
})}
|
|
117
|
+
>
|
|
118
|
+
<View style={{ flex: 1, minWidth: 0 }}>
|
|
119
|
+
<Text style={{ ...TEXT.menu, color: colors.foreground }} numberOfLines={1}>
|
|
120
|
+
{option.label}
|
|
121
|
+
</Text>
|
|
122
|
+
{option.hint ? (
|
|
123
|
+
<Text style={{ ...TEXT.caption, color: colors.foregroundMuted }} numberOfLines={1}>
|
|
124
|
+
{option.hint}
|
|
125
|
+
</Text>
|
|
126
|
+
) : null}
|
|
127
|
+
</View>
|
|
128
|
+
{option.badge ? <Text style={{ ...TEXT.caption, color: colors.foregroundMuted }}>{option.badge}</Text> : null}
|
|
129
|
+
{selected ? <Icon name="Check" size={ICON_SIZE.action} color={colors.foreground} /> : null}
|
|
130
|
+
</Pressable>
|
|
131
|
+
);
|
|
132
|
+
})}
|
|
133
|
+
</ScrollView>
|
|
134
|
+
</View>
|
|
135
|
+
</>
|
|
136
|
+
) : null}
|
|
137
|
+
</View>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import type { Entry } from "../shared/contracts.ts";
|
|
4
|
+
import { messagesFor, resolveAppLanguage } from "../shared/i18n.ts";
|
|
5
|
+
import { countByCategory, groupEntries, projectLabel } from "./entries.ts";
|
|
6
|
+
|
|
7
|
+
const entry = (over: Partial<Entry>): Entry => ({
|
|
8
|
+
id: over.name ?? "x",
|
|
9
|
+
category: "skills",
|
|
10
|
+
scope: "project",
|
|
11
|
+
name: "x",
|
|
12
|
+
path: "/p/x",
|
|
13
|
+
dir: "./x",
|
|
14
|
+
source: ".agents/skills",
|
|
15
|
+
status: "auto",
|
|
16
|
+
tags: [],
|
|
17
|
+
...over,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("groupEntries: project before user, sources grouped, query filters", () => {
|
|
21
|
+
const entries = [
|
|
22
|
+
entry({ name: "b", scope: "user", source: "~/.agents/skills" }),
|
|
23
|
+
entry({ name: "a" }),
|
|
24
|
+
entry({ name: "c", source: ".claude/skills" }),
|
|
25
|
+
entry({ name: "r", category: "rules" }),
|
|
26
|
+
];
|
|
27
|
+
const groups = groupEntries(entries, "skills", "");
|
|
28
|
+
assert.deepEqual(groups.map((group) => [group.scope, group.count]), [["project", 2], ["user", 1]]);
|
|
29
|
+
assert.deepEqual(groups[0]?.sources.map((source) => source.source), [".agents/skills", ".claude/skills"]);
|
|
30
|
+
assert.equal(groupEntries(entries, "skills", "CLAUDE")[0]?.count, 1);
|
|
31
|
+
assert.deepEqual(countByCategory(entries), { instructions: 0, rules: 1, skills: 3, mcp: 0, commands: 0, subagents: 0, plugins: 0 });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("projectLabel / resolveAppLanguage", () => {
|
|
35
|
+
assert.equal(projectLabel("/Users/me/repo/"), "repo");
|
|
36
|
+
assert.equal(resolveAppLanguage("zh-CN"), "zh-CN");
|
|
37
|
+
assert.equal(resolveAppLanguage("system", ["zh-Hans-CN"]), "zh-CN");
|
|
38
|
+
assert.equal(resolveAppLanguage("fr"), "en");
|
|
39
|
+
assert.equal(messagesFor("en").agentPluginLabel("1.0.0", "valid"), "Agent Plugins 1.0.0");
|
|
40
|
+
assert.equal(messagesFor("zh-CN").agentPluginLabel("2.0.0", "unsupported"), "Agent Plugins 2.0.0(未校验)");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("workspaceIdFromPath: plain, encoded, b64_, non-workspace routes", async () => {
|
|
44
|
+
const { workspaceIdFromPath } = await import("./route.ts");
|
|
45
|
+
assert.equal(workspaceIdFromPath("/h/srv/workspace/ws_123"), "ws_123");
|
|
46
|
+
assert.equal(workspaceIdFromPath("/h/srv/workspace/ws%20a?open=x"), "ws a");
|
|
47
|
+
const encoded = Buffer.from("/Users/me/repo").toString("base64url");
|
|
48
|
+
assert.equal(workspaceIdFromPath(`/h/srv/workspace/b64_${encoded}`), "/Users/me/repo");
|
|
49
|
+
assert.equal(workspaceIdFromPath("/h/srv/plugin/customize/customize"), null);
|
|
50
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CATEGORIES, type Category, type Entry, type Scope } from "../shared/contracts.ts";
|
|
2
|
+
|
|
3
|
+
export interface SourceGroup {
|
|
4
|
+
source: string;
|
|
5
|
+
entries: Entry[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ScopeGroup {
|
|
9
|
+
scope: Scope;
|
|
10
|
+
count: number;
|
|
11
|
+
sources: SourceGroup[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const SCOPE_ORDER: readonly Scope[] = ["project", "user"];
|
|
15
|
+
|
|
16
|
+
export function countByCategory(entries: readonly Entry[]): Record<Category, number> {
|
|
17
|
+
const out = Object.fromEntries(CATEGORIES.map((category) => [category, 0])) as Record<Category, number>;
|
|
18
|
+
for (const entry of entries) out[entry.category]++;
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function matchesQuery(entry: Entry, query: string): boolean {
|
|
23
|
+
const needle = query.trim().toLowerCase();
|
|
24
|
+
if (!needle) return true;
|
|
25
|
+
return [entry.name, entry.dir, entry.source, entry.description ?? ""].some((field) => field.toLowerCase().includes(needle));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Project first, then user; within a scope, sources keep discovery order. */
|
|
29
|
+
export function groupEntries(entries: readonly Entry[], category: Category, query: string): ScopeGroup[] {
|
|
30
|
+
return SCOPE_ORDER.map((scope) => {
|
|
31
|
+
const sources = new Map<string, Entry[]>();
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
if (entry.category !== category || entry.scope !== scope || !matchesQuery(entry, query)) continue;
|
|
34
|
+
const list = sources.get(entry.source) ?? [];
|
|
35
|
+
list.push(entry);
|
|
36
|
+
sources.set(entry.source, list);
|
|
37
|
+
}
|
|
38
|
+
const groups = [...sources].map(([source, list]) => ({ source, entries: list }));
|
|
39
|
+
return { scope, count: groups.reduce((sum, group) => sum + group.entries.length, 0), sources: groups };
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Last directory segment the project root display name falls back to. */
|
|
44
|
+
export function projectLabel(root: string): string {
|
|
45
|
+
const trimmed = root.replace(/[\\/]+$/, "");
|
|
46
|
+
return trimmed.split(/[\\/]/).pop() || trimmed;
|
|
47
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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 { Category, Entry } from "../shared/contracts.ts";
|
|
5
|
+
import type { Messages } from "../shared/i18n.ts";
|
|
6
|
+
import { ICON_SIZE, RADIUS, ROW_PADDING, TEXT } from "./design-tokens.ts";
|
|
7
|
+
import { StatusBadge, type Colors } from "./ui.tsx";
|
|
8
|
+
|
|
9
|
+
export const CATEGORY_ICONS: Record<Category, string> = {
|
|
10
|
+
instructions: "FileText",
|
|
11
|
+
rules: "ScrollText",
|
|
12
|
+
skills: "Sparkles",
|
|
13
|
+
mcp: "Plug",
|
|
14
|
+
commands: "Terminal",
|
|
15
|
+
subagents: "Users",
|
|
16
|
+
plugins: "Puzzle",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function entryMeta(entry: Entry, m: Messages, includeFormat = false): string {
|
|
20
|
+
const parts: string[] = [];
|
|
21
|
+
if (entry.mcp) parts.push(entry.mcp.transport);
|
|
22
|
+
else parts.push(entry.dir);
|
|
23
|
+
if (entry.reason) parts.push(m.reason(entry.reason.code, entry.reason.value));
|
|
24
|
+
if (includeFormat && entry.agentPlugin) parts.push(m.agentPluginLabel(entry.agentPlugin.version, entry.agentPlugin.validation));
|
|
25
|
+
for (const tag of entry.tags) parts.push(m.tags[tag]);
|
|
26
|
+
return parts.join(" · ");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const EntryRow = memo(function EntryRow({
|
|
30
|
+
entry,
|
|
31
|
+
selected,
|
|
32
|
+
onSelect,
|
|
33
|
+
colors,
|
|
34
|
+
m,
|
|
35
|
+
}: {
|
|
36
|
+
entry: Entry;
|
|
37
|
+
selected: boolean;
|
|
38
|
+
onSelect: (entry: Entry) => void;
|
|
39
|
+
colors: Colors;
|
|
40
|
+
m: Messages;
|
|
41
|
+
}): ReactNode {
|
|
42
|
+
const muted = entry.status === "inactive" || entry.status === "disabled";
|
|
43
|
+
return (
|
|
44
|
+
<Pressable
|
|
45
|
+
accessibilityRole="button"
|
|
46
|
+
accessibilityState={{ selected }}
|
|
47
|
+
accessibilityLabel={`${entry.name}, ${m.statuses[entry.status]}${entry.agentPlugin ? `, ${m.agentPluginLabel(entry.agentPlugin.version, entry.agentPlugin.validation)}` : ""}`}
|
|
48
|
+
onPress={() => onSelect(entry)}
|
|
49
|
+
style={({ hovered, pressed }: { hovered?: boolean; pressed: boolean }) => ({
|
|
50
|
+
flexDirection: "row",
|
|
51
|
+
alignItems: "flex-start",
|
|
52
|
+
gap: 10,
|
|
53
|
+
paddingVertical: ROW_PADDING.dense,
|
|
54
|
+
paddingHorizontal: 8,
|
|
55
|
+
marginHorizontal: -8,
|
|
56
|
+
borderRadius: RADIUS.control,
|
|
57
|
+
backgroundColor: selected ? colors.surface2 : hovered || pressed ? colors.surface1 : "transparent",
|
|
58
|
+
})}
|
|
59
|
+
>
|
|
60
|
+
<View style={{ paddingTop: 1, opacity: muted ? 0.5 : 1 }}>
|
|
61
|
+
<Icon name={CATEGORY_ICONS[entry.category]} size={ICON_SIZE.leading} color={colors.foregroundMuted} />
|
|
62
|
+
</View>
|
|
63
|
+
<View style={{ flex: 1, minWidth: 0, gap: 3 }}>
|
|
64
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
65
|
+
<Text
|
|
66
|
+
style={{ ...TEXT.rowTitle, color: muted ? colors.foregroundMuted : colors.foreground, flexShrink: 1 }}
|
|
67
|
+
numberOfLines={1}
|
|
68
|
+
>
|
|
69
|
+
{entry.name}
|
|
70
|
+
</Text>
|
|
71
|
+
<StatusBadge status={entry.status} label={m.statuses[entry.status]} colors={colors} />
|
|
72
|
+
{entry.agentPlugin ? (
|
|
73
|
+
<View style={{ borderRadius: RADIUS.control, borderWidth: 1, borderColor: entry.agentPlugin.validation === "valid" ? colors.accent : colors.statusWarning, paddingHorizontal: 6, paddingVertical: 2, flexShrink: 0 }}>
|
|
74
|
+
<Text style={{ ...TEXT.pillBadge, color: entry.agentPlugin.validation === "valid" ? colors.accent : colors.statusWarning }} numberOfLines={1}>{m.agentPluginLabel(entry.agentPlugin.version, entry.agentPlugin.validation)}</Text>
|
|
75
|
+
</View>
|
|
76
|
+
) : null}
|
|
77
|
+
</View>
|
|
78
|
+
{entry.description ? (
|
|
79
|
+
<Text style={{ ...TEXT.meta, color: colors.foregroundMuted }} numberOfLines={1}>
|
|
80
|
+
{entry.description}
|
|
81
|
+
</Text>
|
|
82
|
+
) : null}
|
|
83
|
+
<Text style={{ ...TEXT.meta, color: colors.foregroundMuted }} numberOfLines={1}>
|
|
84
|
+
{entryMeta(entry, m)}
|
|
85
|
+
</Text>
|
|
86
|
+
</View>
|
|
87
|
+
</Pressable>
|
|
88
|
+
);
|
|
89
|
+
});
|