dshmarket 1.75.0 → 1.76.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/README.md +20 -0
- package/README.zh.md +20 -0
- package/client/client.js +790 -63
- package/lib/find-plugin.js +401 -0
- package/lib/index.js +23 -0
- package/lib/routes.js +54 -0
- package/lib/search-synonyms.js +55 -0
- package/lib/types/find-plugin.d.ts +143 -0
- package/lib/types/search-synonyms.d.ts +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1,143 @@
|
|
|
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): {
|
|
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
|
+
}
|
|
43
|
+
export type FindErrorCode = 'empty' | 'catalog' | 'no-model' | 'model-failed';
|
|
44
|
+
export declare class FindPluginError extends Error {
|
|
45
|
+
readonly code: FindErrorCode;
|
|
46
|
+
constructor(code: FindErrorCode, message: string);
|
|
47
|
+
}
|
|
48
|
+
/** The slice of the host's `llm` service this uses. */
|
|
49
|
+
export interface LlmLike {
|
|
50
|
+
stream(options: {
|
|
51
|
+
provider: string;
|
|
52
|
+
model: string;
|
|
53
|
+
reasoningEffort?: string;
|
|
54
|
+
messages: unknown[];
|
|
55
|
+
system?: string;
|
|
56
|
+
maxTokens?: number;
|
|
57
|
+
temperature?: number;
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
}): AsyncIterable<{
|
|
60
|
+
type: string;
|
|
61
|
+
text?: string;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export interface ModelSelectionLike {
|
|
65
|
+
provider: string;
|
|
66
|
+
model: string;
|
|
67
|
+
reasoningEffort?: string;
|
|
68
|
+
}
|
|
69
|
+
/** The instruction and the candidates, as the one message the model reads. */
|
|
70
|
+
export declare function buildPickPrompt(request: string, registry: Registry, found: {
|
|
71
|
+
candidates: Candidate[];
|
|
72
|
+
matched: number;
|
|
73
|
+
}): {
|
|
74
|
+
system: string;
|
|
75
|
+
user: string;
|
|
76
|
+
};
|
|
77
|
+
/** Pull the JSON object out of a model reply (it may wrap it in a code fence). */
|
|
78
|
+
export declare function parsePickReply(text: string, allowed: Set<string>): {
|
|
79
|
+
intro: string;
|
|
80
|
+
picks: Array<{
|
|
81
|
+
name: string;
|
|
82
|
+
why: string;
|
|
83
|
+
}>;
|
|
84
|
+
};
|
|
85
|
+
/** Recall, then let the model pick. Throws FindPluginError with a user-facing message. */
|
|
86
|
+
export declare function findPlugins(options: {
|
|
87
|
+
request: string;
|
|
88
|
+
registry: Registry;
|
|
89
|
+
llm: LlmLike | undefined;
|
|
90
|
+
selection: ModelSelectionLike | undefined;
|
|
91
|
+
signal?: AbortSignal;
|
|
92
|
+
}): Promise<FindResult>;
|
|
93
|
+
/** Plain text of a result, for hosts that draw the command row as text. */
|
|
94
|
+
export declare function resultText(result: FindResult): string;
|
|
95
|
+
export declare function resultsFile(home?: string): string;
|
|
96
|
+
export declare function rememberResult(id: string, result: FindResult, file?: string): void;
|
|
97
|
+
export declare function resultFor(id: string, file?: string): FindResult | undefined;
|
|
98
|
+
/** Tests only. */
|
|
99
|
+
export declare function forgetResults(): void;
|
|
100
|
+
/** What the command handler needs from the host, structurally: no host package is imported. */
|
|
101
|
+
export interface FindPluginInvocation {
|
|
102
|
+
commandId: string;
|
|
103
|
+
agent: {
|
|
104
|
+
id?: string;
|
|
105
|
+
options?: {
|
|
106
|
+
provider?: string;
|
|
107
|
+
model?: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
rawInput: string;
|
|
111
|
+
signal: AbortSignal;
|
|
112
|
+
}
|
|
113
|
+
export type FindPluginResult = {
|
|
114
|
+
kind: 'success';
|
|
115
|
+
text?: string;
|
|
116
|
+
} | {
|
|
117
|
+
kind: 'error';
|
|
118
|
+
text: string;
|
|
119
|
+
};
|
|
120
|
+
export interface ModelAccess {
|
|
121
|
+
llm(): LlmLike | undefined;
|
|
122
|
+
defaultSelection(): ModelSelectionLike | undefined;
|
|
123
|
+
}
|
|
124
|
+
/** Set once by the plugin entry; routes read it at request time. */
|
|
125
|
+
export declare function setModelAccess(next: ModelAccess): void;
|
|
126
|
+
export declare function modelAccess(): ModelAccess;
|
|
127
|
+
/** The market page's AI search: the same recall and pick, with the default model. */
|
|
128
|
+
export declare function aiSearch(request: string, loadRegistry: () => Promise<Registry>, signal?: AbortSignal): Promise<FindResult>;
|
|
129
|
+
/** Run one `/find-plugin`. The structured result is kept under the command id for the card renderer. */
|
|
130
|
+
export declare function runFindPlugin(invocation: FindPluginInvocation, loadRegistry: () => Promise<Registry>, models: ModelAccess): Promise<FindPluginResult>;
|
|
131
|
+
/** The slice of the host's `commands` service this uses. */
|
|
132
|
+
export interface CommandsServiceLike {
|
|
133
|
+
register(definition: {
|
|
134
|
+
name: string;
|
|
135
|
+
description: string;
|
|
136
|
+
input?: {
|
|
137
|
+
hint: string;
|
|
138
|
+
};
|
|
139
|
+
handler(invocation: FindPluginInvocation): FindPluginResult | Promise<FindPluginResult>;
|
|
140
|
+
}): () => void;
|
|
141
|
+
}
|
|
142
|
+
/** Register `/find-plugin` on a host that has the command registry. */
|
|
143
|
+
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": "dshmarket",
|
|
3
3
|
"description": "Visual plugin market inside DeepSeek Harness — browse, search, and one-click install community plugins. · DSH 可视化插件市场:逛一逛,点一下,装好。",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.76.0",
|
|
5
5
|
"icon": "assets/logo.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|