dsh-crate 0.5.10 → 0.6.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/lib/routes.js CHANGED
@@ -14,6 +14,7 @@ import { Readable } from 'node:stream';
14
14
  import { isDeepStrictEqual } from 'node:util';
15
15
  import { load as loadYaml } from 'js-yaml';
16
16
  import { packageFileFromRegistry } from './catalog-npm.js';
17
+ import { aiRecommend, aiSearch, FindPluginError, resultFor, setUserPluginsReader, setUsesMyPlugins, usesMyPlugins } from './find-plugin.js';
17
18
  import { forgetCatalog, loadRegistry, pluginCategories } from './registry.js';
18
19
  import { settingsNamespaceState } from './settings.js';
19
20
  import { statePath } from './state.js';
@@ -451,6 +452,11 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
451
452
  throw new Error(message);
452
453
  }
453
454
  const activeProfileDir = profileDir(config.profile, config.profileDirectory);
455
+ // AI search and /find-plugin read these only after the user allowed it.
456
+ setUserPluginsReader(() => ({
457
+ installed: Object.keys(readInstalled(config.profile, activeProfileDir)),
458
+ favorites: readMarketState(activeProfileDir).favorites ?? [],
459
+ }));
454
460
  // #987: a remove that died between deleting the package and clearing the
455
461
  // rows its bundle patch declares leaves an insert naming a missing module —
456
462
  // and DSH's boot is all-or-nothing, so that row can keep the host from
@@ -837,23 +843,61 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
837
843
  if (await themes.setEntryDisabled(name, true))
838
844
  logEvent('info', 'boot', `plugin kept off: ${name}`);
839
845
  }
846
+ /**
847
+ * The boot pass: shim-mount client-only packages, then put the persisted
848
+ * disable list back down.
849
+ *
850
+ * It is started from the `ctx.inject(['webServer','loader'], …)` callback,
851
+ * so it runs on that callback's context — and it keeps running after the
852
+ * callback returns. The host re-provisions services while it boots, and
853
+ * cordis refreshes EVERY fiber that injects a re-provided name: that
854
+ * disposes this context and re-runs `apply` on a fresh one, while the work
855
+ * started here is still going against the disposed copy. Reading
856
+ * `host.loader` there throws `cannot get required service "loader" in
857
+ * inactive context` — including from `includePrefix`, whose only job is to
858
+ * strip a row-id prefix (#1277).
859
+ *
860
+ * Nothing awaits this pass, so the throw left as a rejection nobody
861
+ * handled, and the host turned that into `fatal load failure`: on a profile
862
+ * whose disable list was non-empty the app came up empty — no sessions, no
863
+ * workspace, "settings could not be read, saving paused" — while the
864
+ * profile on disk was untouched. The list is what decides whether the pass
865
+ * runs at all, which is why an empty one never showed this.
866
+ *
867
+ * Catching here is not bookkeeping. The instance that replaced this one
868
+ * reads the same state and replays the same list, so the stale pass has
869
+ * nothing left to do — and if nothing replaced it, the next boot replays.
870
+ * Whatever else a replay can throw, one package's boot work must never be
871
+ * able to take the host down with it.
872
+ */
873
+ async function replayBootDisables() {
874
+ // Named in the log line, so a reader knows which step stopped rather than
875
+ // being told "boot failed" and nothing else.
876
+ let stage = 'mounting client-only shims';
877
+ try {
878
+ const mounted = await mountClientOnlyDeps(host, activeProfileDir);
879
+ if (mounted.length > 0)
880
+ logEvent('info', 'boot', `client-only shims mounted: ${mounted.join(', ')}`);
881
+ // Replay the persisted disable list: bundle-layer plugins the user
882
+ // switched away from get live-disabled again (bundle trees are
883
+ // in-memory, so the disable never persists on its own). Client-only
884
+ // shims for disabled plugins were already skipped by mountClientOnlyDeps.
885
+ for (const name of [...disabled]) {
886
+ stage = `replaying ${name}`;
887
+ if (followOutsideEnable(name))
888
+ continue;
889
+ noteHomeLayerConflict(name);
890
+ await replayDisabledPackage(name);
891
+ }
892
+ }
893
+ catch (error) {
894
+ logEvent('warn', 'boot', `boot replay stopped while ${stage}: ${error instanceof Error ? error.message : String(error)}. The disable list on disk is unchanged, so the next boot applies it again — and so does the market instance that replaces this one when the host rebuilt it mid-boot; a package this pass had not reached yet stays on until then (#1277)`);
895
+ }
896
+ }
840
897
  // Client-only packages (dsh.client without dsh.bundle) are invisible to the
841
898
  // bundle layer in every boot; the market shim-mounts them so their client
842
899
  // bundles are actually served.
843
- void mountClientOnlyDeps(host, activeProfileDir).then(async (mounted) => {
844
- if (mounted.length > 0)
845
- logEvent('info', 'boot', `client-only shims mounted: ${mounted.join(', ')}`);
846
- // Replay the persisted disable list: bundle-layer plugins the user
847
- // switched away from get live-disabled again (bundle trees are
848
- // in-memory, so the disable never persists on its own). Client-only
849
- // shims for disabled plugins were already skipped by mountClientOnlyDeps.
850
- for (const name of [...disabled]) {
851
- if (followOutsideEnable(name))
852
- continue;
853
- noteHomeLayerConflict(name);
854
- await replayDisabledPackage(name);
855
- }
856
- });
900
+ void replayBootDisables();
857
901
  // Self-healing guard: dsh's own patch overlay can re-update entries during
858
902
  // activation and wipe the runtime disabled flag — whenever a fiber comes
859
903
  // up for a plugin the user switched off, put it back down.
@@ -3901,6 +3945,128 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
3901
3945
  }
3902
3946
  },
3903
3947
  }),
3948
+ registerRoute({
3949
+ kind: 'exact',
3950
+ // The card behind one `/find-plugin` row: the chat keeps only the
3951
+ // command's text, the structured picks live here under its command id.
3952
+ path: '/dsh-crate/find-plugin/result',
3953
+ handler: async (request, response) => {
3954
+ if (request.method !== 'GET') {
3955
+ response.writeHead(405, { allow: 'GET' });
3956
+ response.end();
3957
+ return;
3958
+ }
3959
+ const params = new URL(request.url ?? '', 'http://x').searchParams;
3960
+ const id = params.get('id') ?? '';
3961
+ const session = params.get('session') ?? '';
3962
+ const result = id !== '' ? resultFor(id) : session !== '' ? resultFor(`session:${session}`) : undefined;
3963
+ if (result === undefined)
3964
+ sendJson(response, 404, { error: 'unknown result' });
3965
+ else
3966
+ sendJson(response, 200, { result });
3967
+ },
3968
+ }),
3969
+ registerRoute({
3970
+ kind: 'exact',
3971
+ // The market page's AI search: the user's default model picks from the catalog.
3972
+ path: '/dsh-crate/ai-search',
3973
+ handler: async (request, response) => {
3974
+ if (request.method !== 'POST') {
3975
+ response.writeHead(405, { allow: 'POST' });
3976
+ response.end();
3977
+ return;
3978
+ }
3979
+ if (!sameOrigin(request)) {
3980
+ sendJson(response, 403, { error: 'untrusted origin' });
3981
+ return;
3982
+ }
3983
+ const body = await readJsonBody(request).catch(() => null);
3984
+ const query = typeof body?.query === 'string' ? body.query.slice(0, 500) : '';
3985
+ if (query.trim() === '') {
3986
+ sendJson(response, 400, { code: 'empty', error: '请先描述你想要什么样的插件。 / Describe the plugin you want first.' });
3987
+ return;
3988
+ }
3989
+ try {
3990
+ sendJson(response, 200, { result: await aiSearch(query, () => loadRegistry()) });
3991
+ }
3992
+ catch (error) {
3993
+ if (error instanceof FindPluginError) {
3994
+ sendJson(response, error.code === 'no-model' ? 409 : 502, { code: error.code, error: error.message });
3995
+ return;
3996
+ }
3997
+ sendJson(response, 500, { code: 'model-failed', error: error instanceof Error ? error.message : String(error) });
3998
+ }
3999
+ },
4000
+ }),
4001
+ registerRoute({
4002
+ kind: 'exact',
4003
+ // The user's say-so for AI search and /find-plugin to read their
4004
+ // installed and favorited plugins. GET reads it, POST {on} sets it.
4005
+ path: '/dsh-crate/ai-use-my-plugins',
4006
+ handler: async (request, response) => {
4007
+ if (request.method === 'GET') {
4008
+ sendJson(response, 200, { on: usesMyPlugins() });
4009
+ return;
4010
+ }
4011
+ if (request.method !== 'POST') {
4012
+ response.writeHead(405, { allow: 'GET, POST' });
4013
+ response.end();
4014
+ return;
4015
+ }
4016
+ if (!sameOrigin(request)) {
4017
+ sendJson(response, 403, { error: 'untrusted origin' });
4018
+ return;
4019
+ }
4020
+ const body = await readJsonBody(request).catch(() => null);
4021
+ if (typeof body?.on !== 'boolean') {
4022
+ sendJson(response, 400, { error: 'on must be true or false' });
4023
+ return;
4024
+ }
4025
+ try {
4026
+ setUsesMyPlugins(body.on);
4027
+ sendJson(response, 200, { on: body.on });
4028
+ }
4029
+ catch (error) {
4030
+ sendJson(response, 500, { error: `没能保存这个设置(${error instanceof Error ? error.message : String(error)})。请重试。 / Could not save this setting. Try again.` });
4031
+ }
4032
+ },
4033
+ }),
4034
+ registerRoute({
4035
+ kind: 'exact',
4036
+ // "Recommend for me": the user's installed and favorited plugins, judged
4037
+ // by their default model. Only on a click (it reads both lists and spends
4038
+ // the user's tokens); nothing here runs by itself.
4039
+ path: '/dsh-crate/ai-recommend',
4040
+ handler: async (request, response) => {
4041
+ if (request.method !== 'POST') {
4042
+ response.writeHead(405, { allow: 'POST' });
4043
+ response.end();
4044
+ return;
4045
+ }
4046
+ if (!sameOrigin(request)) {
4047
+ sendJson(response, 403, { error: 'untrusted origin' });
4048
+ return;
4049
+ }
4050
+ const body = await readJsonBody(request).catch(() => null);
4051
+ const exclude = Array.isArray(body?.exclude) ? body.exclude.filter((name) => typeof name === 'string').slice(0, 200) : [];
4052
+ try {
4053
+ const result = await aiRecommend({
4054
+ installed: Object.keys(readInstalled(config.profile, activeProfileDir)),
4055
+ favorites: readMarketState(activeProfileDir).favorites ?? [],
4056
+ exclude,
4057
+ preferZh: body?.lang !== 'en' && body?.lang !== 'ja',
4058
+ }, () => loadRegistry());
4059
+ sendJson(response, 200, { result });
4060
+ }
4061
+ catch (error) {
4062
+ if (error instanceof FindPluginError) {
4063
+ sendJson(response, error.code === 'no-model' || error.code === 'no-seeds' ? 409 : 502, { code: error.code, error: error.message });
4064
+ return;
4065
+ }
4066
+ sendJson(response, 500, { code: 'model-failed', error: error instanceof Error ? error.message : String(error) });
4067
+ }
4068
+ },
4069
+ }),
3904
4070
  registerRoute({
3905
4071
  kind: 'exact',
3906
4072
  path: '/dsh-crate/registry',
@@ -0,0 +1,55 @@
1
+ export const SEARCH_SYNONYM_GROUPS = [
2
+ // Notifications
3
+ // 推送 (also git push) and alert are left out on purpose: two meanings.
4
+ { terms: ['通知', 'notify', 'notification', 'notifier', '消息提醒'], broad: ['提醒', 'reminder'] },
5
+ // Image generation
6
+ { terms: ['生图', '画图', '绘图', '作图', '出图', '图片生成', '生成图片', '生成图', '文生图', 'image generation', 'image gen', 'imagegen', 'text2img', 'text to image'] },
7
+ { terms: ['视频', 'video'] },
8
+ // Chat apps
9
+ { terms: ['飞书', 'feishu', 'lark'] },
10
+ { terms: ['微信', 'wechat', 'weixin'] },
11
+ { terms: ['企业微信', '企微', 'wecom'] },
12
+ { terms: ['钉钉', 'dingtalk'] },
13
+ { terms: ['qq', 'qqbot', 'onebot', 'napcat'] },
14
+ // Memory
15
+ { terms: ['记忆', '长期记忆', '记忆库', 'memory', 'long term memory'] },
16
+ // Themes
17
+ { terms: ['主题', '皮肤', '配色', '换肤', 'theme', 'skin', 'color scheme'] },
18
+ // Voice
19
+ {
20
+ terms: ['语音', 'voice', 'speech'],
21
+ broad: ['tts', 'stt', '朗读', '语音识别', '语音合成', 'text to speech', 'speech to text'],
22
+ },
23
+ { terms: ['tts', 'text to speech', '朗读', '语音合成', '文字转语音'] },
24
+ { terms: ['stt', 'asr', 'speech to text', '语音识别', '语音转文字', '听写'] },
25
+ // Translation
26
+ { terms: ['翻译', 'translate', 'translation', 'translator', '双语', 'bilingual'] },
27
+ // Search, browser, MCP
28
+ { terms: ['搜索', '检索', 'search', '联网搜索', '网页搜索', 'web search'] },
29
+ { terms: ['浏览器', 'browser'], broad: ['chrome', 'cdp', 'playwright', 'puppeteer', '网页自动化'] },
30
+ { terms: ['mcp', 'model context protocol', '模型上下文协议'] },
31
+ // Models and keys
32
+ { terms: ['模型接入', '接入模型', '模型供应商', '模型提供商', '自定义模型', 'provider'] },
33
+ { terms: ['api key', 'apikey', '密钥', 'api 密钥'] },
34
+ // Cost and usage
35
+ { terms: ['费用', '花费', '计费', '账单', 'cost', 'billing'] },
36
+ { terms: ['用量', '额度', 'usage', 'quota'] },
37
+ // Context
38
+ { terms: ['上下文', '上下文窗口', 'context window', 'context'], broad: ['上下文压缩', 'context compression', 'compaction'] },
39
+ { terms: ['上下文压缩', 'context compression', 'compaction'] },
40
+ // Office
41
+ { terms: ['ppt', 'pptx', 'powerpoint', '幻灯片', 'slides', '演示文稿'] },
42
+ { terms: ['excel', 'xlsx', 'spreadsheet'] },
43
+ { terms: ['docx', 'word 文档', 'microsoft word'] },
44
+ { terms: ['剪贴板', 'clipboard'] },
45
+ { terms: ['邮件', '邮箱', 'email', 'mail'] },
46
+ { terms: ['定时', '定时任务', '计划任务', 'cron'] },
47
+ // Developer
48
+ { terms: ['git', '版本控制', 'version control'] },
49
+ { terms: ['终端', 'terminal', 'shell', '命令行', 'command line'], broad: ['pty', 'tmux', 'tui'] },
50
+ // Pets
51
+ { terms: ['桌宠', '宠物', '桌面宠物', '看板娘', 'pet', 'mascot'], broad: ['live2d'] },
52
+ // Mobile and remote
53
+ { terms: ['手机', '手机端', '移动端', 'mobile', 'phone'], broad: ['pwa', 'android', 'ios'] },
54
+ { terms: ['远程', '远程控制', '远程访问', 'remote', 'remote control'], broad: ['内网穿透', 'tunnel'] },
55
+ ];
@@ -394,6 +394,26 @@ export declare function lastPnpmProbeFailure(): {
394
394
  * publishes a broken invocation cannot make things worse than they were.
395
395
  */
396
396
  export declare function probePnpm(): Promise<boolean>;
397
+ /**
398
+ * The cwd to hand a provisioning child.
399
+ *
400
+ * `corepack enable`, `npm i -g` and `npm prefix -g` read no project files, so
401
+ * they gain nothing from inheriting this process's directory — and a host
402
+ * whose boot directory was deleted loses everything to it: the child dies
403
+ * inside `getcwd()` before running a line of its own logic, which is how a
404
+ * one-click setup ended up reporting `npm -g: exit=7` with `syscall:
405
+ * 'uv_cwd'` (#1270).
406
+ *
407
+ * A readable directory is still inherited unchanged, so a healthy machine
408
+ * behaves exactly as before, including the per-project `.npmrc` npm would
409
+ * read from it. Only an unreadable one is replaced, and then with a directory
410
+ * that exists by definition.
411
+ *
412
+ * `process.cwd()` throws instead of returning a stale path, so the call
413
+ * itself is the test.
414
+ * @returns `undefined` to inherit, or a directory that is known to exist.
415
+ */
416
+ export declare function provisionCwd(): string | undefined;
397
417
  /**
398
418
  * Provision pnpm without user involvement: corepack (ships with Node) first,
399
419
  * a global npm install as fallback.
@@ -0,0 +1,208 @@
1
+ import { type Registry, type RegistryPlugin } from './registry.ts';
2
+ /** How many candidates go to the model. Enough to cover a vague request, few enough to read. */
3
+ export declare const CANDIDATE_LIMIT = 30;
4
+ /** What was asked, minus the filler: the words worth matching. */
5
+ export declare function extractTerms(input: string): string[];
6
+ export interface Candidate {
7
+ plugin: RegistryPlugin;
8
+ score: number;
9
+ }
10
+ /**
11
+ * The entries worth showing the model. Every entry matching any term, best
12
+ * first; when fewer than the limit match (a vague or unmatched request), the
13
+ * most downloaded of the rest fill the list, because a model can still pick
14
+ * something sensible from popular plugins, and an empty list helps no one.
15
+ */
16
+ export declare function recall(registry: Registry, terms: string[], limit?: number, exclude?: ReadonlySet<string>): {
17
+ candidates: Candidate[];
18
+ matched: number;
19
+ };
20
+ /** One recommended plugin, with everything a card needs to draw it. */
21
+ export interface FindPick {
22
+ name: string;
23
+ owner: string;
24
+ url: string;
25
+ npm: string | null;
26
+ install: string;
27
+ categories: string[];
28
+ description: string;
29
+ downloads: number | null;
30
+ stars: number | null;
31
+ /** The model's one-sentence reason this fits the request. */
32
+ why: string;
33
+ }
34
+ export interface FindResult {
35
+ request: string;
36
+ /** One short sentence from the model framing the picks (may be empty). */
37
+ intro: string;
38
+ picks: FindPick[];
39
+ /** Which model answered, for the card's footnote. */
40
+ model: string;
41
+ at: string;
42
+ /** Whether the user's installed and favorited plugins informed the picks (they allowed it). */
43
+ personalized?: boolean;
44
+ }
45
+ export type FindErrorCode = 'empty' | 'catalog' | 'no-model' | 'no-seeds' | 'model-failed';
46
+ export declare class FindPluginError extends Error {
47
+ readonly code: FindErrorCode;
48
+ constructor(code: FindErrorCode, message: string);
49
+ }
50
+ /** The slice of the host's `llm` service this uses. */
51
+ export interface LlmLike {
52
+ stream(options: {
53
+ provider: string;
54
+ model: string;
55
+ reasoningEffort?: string;
56
+ messages: unknown[];
57
+ system?: string;
58
+ maxTokens?: number;
59
+ temperature?: number;
60
+ signal?: AbortSignal;
61
+ }): AsyncIterable<{
62
+ type: string;
63
+ text?: string;
64
+ error?: unknown;
65
+ reason?: unknown;
66
+ }>;
67
+ }
68
+ export interface ModelSelectionLike {
69
+ provider: string;
70
+ model: string;
71
+ reasoningEffort?: string;
72
+ }
73
+ /** The instruction and the candidates, as the one message the model reads. */
74
+ export declare function buildPickPrompt(request: string, registry: Registry, found: {
75
+ candidates: Candidate[];
76
+ matched: number;
77
+ }, have?: UserSeeds): {
78
+ system: string;
79
+ user: string;
80
+ };
81
+ /** Pull the JSON object out of a model reply (it may wrap it in a code fence). */
82
+ export declare function parsePickReply(text: string, allowed: Set<string>, max?: number): {
83
+ intro: string;
84
+ picks: Array<{
85
+ name: string;
86
+ why: string;
87
+ }>;
88
+ };
89
+ /** Recall, then let the model pick. Throws FindPluginError with a user-facing message. */
90
+ export declare function findPlugins(options: {
91
+ request: string;
92
+ registry: Registry;
93
+ llm: LlmLike | undefined;
94
+ selection: ModelSelectionLike | undefined;
95
+ /** The user's own plugins, only when they allowed reading them. */
96
+ have?: UserSeeds;
97
+ signal?: AbortSignal;
98
+ }): Promise<FindResult>;
99
+ /** How many candidates a recommendation offers the model. */
100
+ export declare const RECOMMEND_CANDIDATES = 40;
101
+ /** How many plugins a recommendation shows. */
102
+ export declare const RECOMMEND_MAX = 10;
103
+ /**
104
+ * The catalog entries the user already has: installed (by package name) or
105
+ * favorited (by repository URL, as favorites are stored).
106
+ */
107
+ export interface UserSeeds {
108
+ installed: RegistryPlugin[];
109
+ favorited: RegistryPlugin[];
110
+ }
111
+ export declare function userSeeds(registry: Registry, have: {
112
+ installed: string[];
113
+ favorites: string[];
114
+ }): UserSeeds;
115
+ /**
116
+ * What to offer the model: entries that share categories and words with what
117
+ * the user has (their taste), plus some popular ones from categories they have
118
+ * not touched (so a recommendation can open a new need, not only repeat one).
119
+ * Never what they already have, what was shown last time, or a deprecated one.
120
+ */
121
+ export declare function recommendCandidates(registry: Registry, seeds: RegistryPlugin[], exclude?: string[], limit?: number): Candidate[];
122
+ export declare function buildRecommendPrompt(registry: Registry, seeds: UserSeeds, candidates: Candidate[], preferZh: boolean): {
123
+ system: string;
124
+ user: string;
125
+ };
126
+ /** Recommend plugins from what the user installed and favorited. Throws FindPluginError. */
127
+ export declare function recommendPlugins(options: {
128
+ registry: Registry;
129
+ installed: string[];
130
+ favorites: string[];
131
+ exclude?: string[];
132
+ preferZh: boolean;
133
+ llm: LlmLike | undefined;
134
+ selection: ModelSelectionLike | undefined;
135
+ signal?: AbortSignal;
136
+ }): Promise<FindResult>;
137
+ /** Plain text of a result, for hosts that draw the command row as text. */
138
+ export declare function resultText(result: FindResult): string;
139
+ export declare function resultsFile(home?: string): string;
140
+ export declare function rememberResult(id: string, result: FindResult, file?: string): void;
141
+ export declare function resultFor(id: string, file?: string): FindResult | undefined;
142
+ /** Tests only. */
143
+ export declare function forgetResults(): void;
144
+ /** What the command handler needs from the host, structurally: no host package is imported. */
145
+ export interface FindPluginInvocation {
146
+ commandId: string;
147
+ agent: {
148
+ id?: string;
149
+ options?: {
150
+ provider?: string;
151
+ model?: string;
152
+ };
153
+ };
154
+ rawInput: string;
155
+ signal: AbortSignal;
156
+ }
157
+ export type FindPluginResult = {
158
+ kind: 'success';
159
+ text?: string;
160
+ } | {
161
+ kind: 'error';
162
+ text: string;
163
+ };
164
+ export interface ModelAccess {
165
+ llm(): LlmLike | undefined;
166
+ defaultSelection(): ModelSelectionLike | undefined;
167
+ }
168
+ /** Set once by the plugin entry; routes read it at request time. */
169
+ export declare function setModelAccess(next: ModelAccess): void;
170
+ export declare function modelAccess(): ModelAccess;
171
+ /**
172
+ * Whether AI search and `/find-plugin` may read the user's installed and
173
+ * favorited plugins. Off until the user allows it from a result; one switch
174
+ * for the whole DSH home, kept beside the saved results.
175
+ */
176
+ export declare function consentFile(home?: string): string;
177
+ export declare function usesMyPlugins(file?: string): boolean;
178
+ export declare function setUsesMyPlugins(on: boolean, file?: string): void;
179
+ export interface UserPluginLists {
180
+ installed: string[];
181
+ favorites: string[];
182
+ }
183
+ /** Set by the routes, which know the active profile. */
184
+ export declare function setUserPluginsReader(next: () => UserPluginLists): void;
185
+ /** The market page's AI search: the same recall and pick, with the default model. */
186
+ export declare function aiSearch(request: string, loadRegistry: () => Promise<Registry>, signal?: AbortSignal): Promise<FindResult>;
187
+ /** The market page's "recommend for me": what the user has, judged by their default model. */
188
+ export declare function aiRecommend(have: {
189
+ installed: string[];
190
+ favorites: string[];
191
+ exclude?: string[];
192
+ preferZh: boolean;
193
+ }, loadRegistry: () => Promise<Registry>, signal?: AbortSignal): Promise<FindResult>;
194
+ /** Run one `/find-plugin`. The structured result is kept under the command id for the card renderer. */
195
+ export declare function runFindPlugin(invocation: FindPluginInvocation, loadRegistry: () => Promise<Registry>, models: ModelAccess): Promise<FindPluginResult>;
196
+ /** The slice of the host's `commands` service this uses. */
197
+ export interface CommandsServiceLike {
198
+ register(definition: {
199
+ name: string;
200
+ description: string;
201
+ input?: {
202
+ hint: string;
203
+ };
204
+ handler(invocation: FindPluginInvocation): FindPluginResult | Promise<FindPluginResult>;
205
+ }): () => void;
206
+ }
207
+ /** Register `/find-plugin` on a host that has the command registry. */
208
+ export declare function registerFindPlugin(commands: CommandsServiceLike, loadRegistry: () => Promise<Registry>, models: ModelAccess): () => void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Intent table for catalog search (#611).
3
+ *
4
+ * People search by what they want ("通知"), not by the word a plugin author
5
+ * happened to pick ("推送", "notification", "alert"). Each group lists words
6
+ * that mean the same thing to a user; searching any one of them also finds
7
+ * plugins that only use another one. Literal hits always rank above these.
8
+ *
9
+ * How to extend
10
+ * - `terms`: words that are interchangeable. Typing any of them searches all
11
+ * of them. Keep it to words that really occur in the catalog (check with
12
+ * `npm run snapshot` and grep data/registry-snapshot.json).
13
+ * - `broad` (optional): looser neighbours. They are found when the user types
14
+ * any of `terms`, but typing a broad word does NOT expand back (so "语音"
15
+ * finds TTS plugins while "tts" does not drag in speech-to-text).
16
+ * - Write words in any case, with or without spaces between Han and Latin;
17
+ * they are normalized like the catalog text. Use the plain spoken form.
18
+ * - Avoid words that are common in unrelated text ("model", "key", "tool",
19
+ * "word", "cli"): a synonym for them would flood results. Single letters
20
+ * and one-character words are ignored on purpose.
21
+ * - Latin words only match whole words (plus a plural "s"), so "git" never
22
+ * matches "digital". Han words match as substrings, as in plain search.
23
+ */
24
+ export interface SynonymGroup {
25
+ terms: readonly string[];
26
+ broad?: readonly string[];
27
+ }
28
+ export declare const SEARCH_SYNONYM_GROUPS: readonly SynonymGroup[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-crate",
3
3
  "description": "逛一逛,点一下,装好。浏览和搜索 DeepSeek Harness 社区插件,看详情、一键安装,收藏和更新都在一处。",
4
- "version": "0.5.10",
4
+ "version": "0.6.0",
5
5
  "icon": "assets/logo.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",