@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +58 -0
  4. package/client/category-visibility.test.ts +26 -0
  5. package/client/design-tokens.test.ts +39 -0
  6. package/client/design-tokens.ts +104 -0
  7. package/client/dropdown.tsx +139 -0
  8. package/client/entries.test.ts +50 -0
  9. package/client/entries.ts +47 -0
  10. package/client/entry-row.tsx +89 -0
  11. package/client/mechanism-card.tsx +75 -0
  12. package/client/preview-pane.tsx +101 -0
  13. package/client/provider-options.test.ts +31 -0
  14. package/client/provider-options.ts +37 -0
  15. package/client/query-policy.test.ts +57 -0
  16. package/client/query-policy.ts +20 -0
  17. package/client/route.ts +29 -0
  18. package/client/selection-settings.test.ts +16 -0
  19. package/client/slash-command.test.ts +94 -0
  20. package/client/slash-command.ts +36 -0
  21. package/client/surface.tsx +332 -0
  22. package/client/ui.tsx +265 -0
  23. package/client/use-app-language.ts +28 -0
  24. package/client/web.ts +111 -0
  25. package/index.client.tsx +57 -0
  26. package/index.server.ts +13 -0
  27. package/package.json +37 -0
  28. package/paseo-plugin.json +6 -0
  29. package/server/agent-plugins.ts +41 -0
  30. package/server/compatibility.test.ts +104 -0
  31. package/server/compatibility.ts +46 -0
  32. package/server/frontmatter.ts +49 -0
  33. package/server/glob.ts +46 -0
  34. package/server/handlers.ts +193 -0
  35. package/server/jsonc.ts +40 -0
  36. package/server/mcp.ts +87 -0
  37. package/server/parsers.test.ts +92 -0
  38. package/server/providers/acp.ts +186 -0
  39. package/server/providers/claude.ts +284 -0
  40. package/server/providers/codex.ts +219 -0
  41. package/server/providers/copilot.ts +116 -0
  42. package/server/providers/cursor.ts +194 -0
  43. package/server/providers/omp.ts +263 -0
  44. package/server/providers/opencode.ts +215 -0
  45. package/server/providers/pi.ts +102 -0
  46. package/server/providers.test.ts +306 -0
  47. package/server/scan-kit.ts +368 -0
  48. package/server/scan-snapshot.test.ts +56 -0
  49. package/server/scan-snapshot.ts +58 -0
  50. package/server/skill-aliases.ts +60 -0
  51. package/server/toml.ts +240 -0
  52. package/server/yaml-lite.ts +172 -0
  53. package/shared/acp-configs.ts +107 -0
  54. package/shared/category-visibility.ts +26 -0
  55. package/shared/compatibility.ts +6 -0
  56. package/shared/contracts.ts +116 -0
  57. package/shared/i18n.ts +293 -0
  58. package/shared/mechanisms.ts +380 -0
  59. package/shared/providers.ts +27 -0
  60. package/shared/selection-settings.ts +14 -0
package/shared/i18n.ts ADDED
@@ -0,0 +1,293 @@
1
+ import type { Category, ReasonCode, Scope, Status, Tag } from "./contracts.ts";
2
+
3
+ export const APP_LANGUAGES = ["en", "zh-CN"] as const;
4
+ export type AppLanguage = (typeof APP_LANGUAGES)[number];
5
+
6
+ /** Paseo `language` setting (or `system` → OS languages) → a supported catalog. */
7
+ export function resolveAppLanguage(setting: string | null | undefined, systemLanguages: readonly string[] = []): AppLanguage {
8
+ const explicit = matchLanguage(setting ?? "");
9
+ if (explicit && setting !== "system") return explicit;
10
+ for (const candidate of systemLanguages) {
11
+ const match = matchLanguage(candidate);
12
+ if (match) return match;
13
+ }
14
+ return "en";
15
+ }
16
+
17
+ function matchLanguage(tag: string): AppLanguage | null {
18
+ const lower = tag.trim().toLowerCase();
19
+ if (!lower || lower === "system") return null;
20
+ if (lower.split(/[-_]/)[0] === "zh") return "zh-CN";
21
+ if (lower.split(/[-_]/)[0] === "en") return "en";
22
+ return null;
23
+ }
24
+
25
+ export interface Messages {
26
+ title: string;
27
+ openBoard: string;
28
+ provider: string;
29
+ compatibility: (state: "on" | "off" | "unknown" | "supported") => string;
30
+ builtinProvider: string;
31
+ noEnabledProvider: string;
32
+ project: string;
33
+ noProject: string;
34
+ chooseProvider: string;
35
+ chooseProject: string;
36
+ closeMenu: string;
37
+ refresh: string;
38
+ lastScanned: (date: string) => string;
39
+ search: string;
40
+ categories: Record<Category, string>;
41
+ scopes: Record<Scope | "managed", string>;
42
+ statuses: Record<Status, string>;
43
+ tags: Record<Tag, string>;
44
+ agentPluginLabel: (version: string, validation: "valid" | "unsupported") => string;
45
+ reason: (code: ReasonCode, value: string | undefined) => string;
46
+ howItWorks: string;
47
+ showDetails: string;
48
+ hideDetails: string;
49
+ unsupported: string;
50
+ empty: string;
51
+ emptyScope: (scope: string) => string;
52
+ noMatches: string;
53
+ loadFailed: string;
54
+ retry: string;
55
+ preview: {
56
+ open: string;
57
+ reveal: string;
58
+ copyPath: string;
59
+ copied: string;
60
+ close: string;
61
+ truncated: (bytes: string) => string;
62
+ directory: string;
63
+ missing: string;
64
+ url: string;
65
+ redacted: string;
66
+ openFailed: string;
67
+ };
68
+ count: (n: number) => string;
69
+ }
70
+
71
+ const en: Messages = {
72
+ title: "Customize",
73
+ openBoard: "Open Customize",
74
+ provider: "Provider",
75
+ compatibility: (state) => state === "on" ? "Third-party skill directories enabled" : state === "off" ? "Third-party skill directories disabled" : state === "supported" ? "Supports shared skill directories" : "Third-party skill directory state unavailable",
76
+ builtinProvider: "Built-in",
77
+ noEnabledProvider: "No supported providers are enabled in Paseo.",
78
+ project: "Project",
79
+ noProject: "No project",
80
+ chooseProvider: "Choose provider",
81
+ chooseProject: "Choose project",
82
+ closeMenu: "Close menu",
83
+ refresh: "Rescan",
84
+ lastScanned: (date) => `Last scanned: ${date}`,
85
+ search: "Filter by name or path",
86
+ categories: { instructions: "Instructions", rules: "Rules", skills: "Skills", mcp: "MCP", commands: "Commands", subagents: "Subagents", plugins: "Plugins" },
87
+ scopes: { project: "Project", user: "User", managed: "Managed" },
88
+ statuses: {
89
+ auto: "Auto",
90
+ conditional: "Conditional",
91
+ manual: "Manual only",
92
+ pending: "Needs approval",
93
+ disabled: "Disabled",
94
+ inactive: "Not loaded",
95
+ },
96
+ tags: {
97
+ managed: "managed",
98
+ system: "system",
99
+ builtin: "built-in",
100
+ legacy: "compat",
101
+ deprecated: "deprecated",
102
+ nested: "nested",
103
+ parent: "parent dir",
104
+ command: "command",
105
+ symlink: "symlink",
106
+ local: "local",
107
+ trust: "needs trust",
108
+ systemPrompt: "replaces system prompt",
109
+ appendPrompt: "appends to system prompt",
110
+ sticky: "sticky",
111
+ userInvocableOff: "hidden from /",
112
+ nameOnly: "name only",
113
+ ask: "asks first",
114
+ url: "URL",
115
+ autolearn: "auto-learn",
116
+ synced: "claude.ai sync",
117
+ },
118
+ agentPluginLabel: (version, validation) => `Agent Plugins ${version}${validation === "unsupported" ? " (unverified)" : ""}`,
119
+ reason: (code, value) => {
120
+ switch (code) {
121
+ case "frontmatter":
122
+ return value ?? "frontmatter";
123
+ case "config":
124
+ return value ?? "config";
125
+ case "shadowedBy":
126
+ return `Shadowed by ${value ?? "another file"}`;
127
+ case "nestedDir":
128
+ return `Only inside ${value ?? "its directory"}`;
129
+ case "onDemand":
130
+ return `Loads when working in ${value ?? "its directory"}`;
131
+ case "globs":
132
+ return value ?? "globs";
133
+ case "agentDecides":
134
+ return "Agent decides from description";
135
+ case "manualMention":
136
+ return "Only when @-mentioned";
137
+ case "always":
138
+ return "Always applied";
139
+ case "untrusted":
140
+ return "Project is not trusted";
141
+ case "needsApproval":
142
+ return "Not approved yet";
143
+ case "offByDefault":
144
+ return `Off by default (${value ?? "setting"})`;
145
+ case "ignoredExt":
146
+ return `${value ?? "This extension"} files are ignored`;
147
+ case "env":
148
+ return `Disabled by ${value ?? "environment"}`;
149
+ case "oversize":
150
+ return `Larger than ${value ?? "the size limit"}; truncated`;
151
+ }
152
+ },
153
+ howItWorks: "How it loads",
154
+ showDetails: "Show details",
155
+ hideDetails: "Hide details",
156
+ unsupported: "No scanned location",
157
+ empty: "Nothing configured",
158
+ emptyScope: (scope) => `No ${scope.toLowerCase()} entries`,
159
+ noMatches: "No matches",
160
+ loadFailed: "Failed to load",
161
+ retry: "Retry",
162
+ preview: {
163
+ open: "Open",
164
+ reveal: "Reveal",
165
+ copyPath: "Copy path",
166
+ copied: "Path copied",
167
+ close: "Close preview",
168
+ truncated: (bytes) => `Preview truncated · ${bytes}`,
169
+ directory: "This entry is a directory.",
170
+ missing: "File not found.",
171
+ url: "Remote URL; open it in the browser.",
172
+ redacted: "env / headers values and secret-looking arguments are masked.",
173
+ openFailed: "Could not open file",
174
+ },
175
+ count: (n) => String(n),
176
+ };
177
+
178
+ const zh: Messages = {
179
+ title: "Customize",
180
+ openBoard: "打开 Customize",
181
+ provider: "Provider",
182
+ compatibility: (state) => state === "on" ? "已开启第三方技能目录兼容" : state === "off" ? "已关闭第三方技能目录兼容" : state === "supported" ? "支持共享技能目录" : "第三方技能目录兼容状态未知",
183
+ builtinProvider: "内置",
184
+ noEnabledProvider: "Paseo 中没有已启用且受 Customize 支持的 Provider。",
185
+ project: "项目",
186
+ noProject: "无项目",
187
+ chooseProvider: "选择 provider",
188
+ chooseProject: "选择项目",
189
+ closeMenu: "关闭菜单",
190
+ refresh: "重新扫描",
191
+ lastScanned: (date) => `上次扫描:${date}`,
192
+ search: "按名称或路径筛选",
193
+ categories: { instructions: "指令", rules: "规则", skills: "Skills", mcp: "MCP", commands: "命令", subagents: "子代理", plugins: "插件" },
194
+ scopes: { project: "项目级", user: "用户级", managed: "托管" },
195
+ statuses: {
196
+ auto: "自动",
197
+ conditional: "按条件",
198
+ manual: "仅手动",
199
+ pending: "待批准",
200
+ disabled: "已禁用",
201
+ inactive: "未生效",
202
+ },
203
+ tags: {
204
+ managed: "托管",
205
+ system: "系统",
206
+ builtin: "内置",
207
+ legacy: "兼容",
208
+ deprecated: "已弃用",
209
+ nested: "嵌套",
210
+ parent: "上级目录",
211
+ command: "命令",
212
+ symlink: "符号链接",
213
+ local: "本地",
214
+ trust: "需信任项目",
215
+ systemPrompt: "替换系统提示",
216
+ appendPrompt: "追加系统提示",
217
+ sticky: "常驻",
218
+ userInvocableOff: "不在 / 菜单",
219
+ nameOnly: "仅名称",
220
+ ask: "需确认",
221
+ url: "URL",
222
+ autolearn: "自动学习",
223
+ synced: "claude.ai 同步",
224
+ },
225
+ agentPluginLabel: (version, validation) => `Agent Plugins ${version}${validation === "unsupported" ? "(未校验)" : ""}`,
226
+ reason: (code, value) => {
227
+ switch (code) {
228
+ case "frontmatter":
229
+ return value ?? "frontmatter";
230
+ case "config":
231
+ return value ?? "配置";
232
+ case "shadowedBy":
233
+ return `被 ${value ?? "其他文件"} 覆盖`;
234
+ case "nestedDir":
235
+ return `仅在 ${value ?? "所在目录"} 内生效`;
236
+ case "onDemand":
237
+ return `在 ${value ?? "所在目录"} 工作时加载`;
238
+ case "globs":
239
+ return value ?? "globs";
240
+ case "agentDecides":
241
+ return "Agent 根据 description 决定";
242
+ case "manualMention":
243
+ return "仅在 @ 提及时";
244
+ case "always":
245
+ return "总是应用";
246
+ case "untrusted":
247
+ return "项目未被信任";
248
+ case "needsApproval":
249
+ return "尚未批准";
250
+ case "offByDefault":
251
+ return `默认关闭(${value ?? "设置"})`;
252
+ case "ignoredExt":
253
+ return `${value ?? "该扩展名"} 文件会被忽略`;
254
+ case "env":
255
+ return `被 ${value ?? "环境变量"} 关闭`;
256
+ case "oversize":
257
+ return `超过 ${value ?? "大小上限"},会被截断`;
258
+ }
259
+ },
260
+ howItWorks: "加载机制",
261
+ showDetails: "展开详情",
262
+ hideDetails: "收起详情",
263
+ unsupported: "暂无扫描位置",
264
+ empty: "没有配置",
265
+ emptyScope: (scope) => `没有${scope}条目`,
266
+ noMatches: "没有匹配项",
267
+ loadFailed: "加载失败",
268
+ retry: "重试",
269
+ preview: {
270
+ open: "打开",
271
+ reveal: "在 Finder 中显示",
272
+ copyPath: "复制路径",
273
+ copied: "已复制路径",
274
+ close: "关闭预览",
275
+ truncated: (bytes) => `预览已截断 · ${bytes}`,
276
+ directory: "该条目是目录。",
277
+ missing: "文件不存在。",
278
+ url: "远程 URL,请在浏览器中打开。",
279
+ redacted: "env / headers 的值及疑似密钥参数已打码。",
280
+ openFailed: "无法打开文件",
281
+ },
282
+ count: (n) => String(n),
283
+ };
284
+
285
+ export function messagesFor(language: string): Messages {
286
+ return resolveAppLanguage(language) === "zh-CN" ? zh : en;
287
+ }
288
+
289
+ export function formatBytes(bytes: number): string {
290
+ if (bytes < 1024) return `${bytes} B`;
291
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KiB`;
292
+ return `${(bytes / 1024 / 1024).toFixed(1)} MiB`;
293
+ }