@wirecat/cli-core 0.421.0 → 0.423.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 +29 -1
- package/dist/analysis/settings.d.ts +0 -6
- package/dist/analysis/settings.js +2 -5
- package/dist/cli/analysis-choice.d.ts +0 -1
- package/dist/cli/analysis-choice.js +9 -22
- package/dist/cli/bot/context.js +1 -1
- package/dist/cli/commands-command.js +1 -1
- package/dist/cli/config-command.d.ts +0 -4
- package/dist/cli/config-command.js +36 -26
- package/dist/cli/config-issues.d.ts +52 -0
- package/dist/cli/config-issues.js +187 -0
- package/dist/cli/config-keys.js +4 -28
- package/dist/cli/embedding-choice.d.ts +1 -2
- package/dist/cli/embedding-choice.js +2 -4
- package/dist/cli/first-run.d.ts +0 -16
- package/dist/cli/first-run.js +1 -6
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/messenger/context.js +1 -1
- package/dist/cli/messenger/conversations-command.js +5 -9
- package/dist/cli/messenger/doctor-command.js +38 -4
- package/dist/cli/messenger/inbox.js +2 -6
- package/dist/cli/messenger/private-people-command.js +1 -2
- package/dist/cli/messenger/review.js +2 -5
- package/dist/cli/permission-keys.d.ts +9 -2
- package/dist/cli/permission-keys.js +21 -6
- package/dist/cli/preview.d.ts +3 -2
- package/dist/cli/preview.js +4 -3
- package/dist/cli/profile.d.ts +2 -0
- package/dist/cli/profile.js +10 -0
- package/dist/cli/program.d.ts +1 -1
- package/dist/cli/program.js +18 -10
- package/dist/cli/settings.d.ts +21 -117
- package/dist/cli/settings.js +107 -114
- package/dist/cli/shared-command-exports.d.ts +4 -232
- package/dist/mcp/surface.js +9 -3
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/models/settings.d.ts +1 -7
- package/dist/models/settings.js +1 -18
- package/dist/ports/app.d.ts +6 -0
- package/dist/search/account-list.js +8 -7
- package/dist/search/dictionary.d.ts +3 -6
- package/dist/search/dictionary.js +2 -1
- package/dist/search/languages.d.ts +28 -0
- package/dist/search/languages.js +7 -0
- package/dist/search/stem.d.ts +5 -4
- package/dist/search/stem.js +3 -2
- package/package.json +1 -1
package/dist/mcp/surface.js
CHANGED
|
@@ -62,10 +62,16 @@ export const registerCommands = (server, prefix, commands, errors,
|
|
|
62
62
|
/** Throws the refusal of a command left out because the lock or a level stops it, so the agent learns why. */
|
|
63
63
|
withheld) => {
|
|
64
64
|
const byNormal = new Map(Object.keys(commands).map((command) => [normal(command), command]));
|
|
65
|
+
// No AppIdentity reaches here; only a messenger's catalogue has `messages` commands.
|
|
66
|
+
const messenger = Object.keys(commands).some((command) => command.split(" ")[0] === "messages");
|
|
67
|
+
const tasks = messenger ? '"unread", "send message", "chat members"' : '"list", "show", "change a setting"';
|
|
68
|
+
const sample = messenger
|
|
69
|
+
? "messages list"
|
|
70
|
+
: (Object.entries(commands).find(([, one]) => !one.writes)?.[0] ?? Object.keys(commands)[0] ?? "");
|
|
65
71
|
server.registerTool(`${prefix}_tools_search`, {
|
|
66
72
|
outputSchema: toStandardJsonSchema(v.looseObject({})),
|
|
67
73
|
title: "Find a command",
|
|
68
|
-
description: `Find the command for a task —
|
|
74
|
+
description: `Find the command for a task — ${tasks} — before calling ` +
|
|
69
75
|
`${prefix}_read or ${prefix}_write with it. Each match gives its command, whether it writes, its arguments and the shape of its answer. ` +
|
|
70
76
|
"With no words, lists every command and title, without arguments.",
|
|
71
77
|
inputSchema: toStandardJsonSchema(v.strictObject({ query: v.optional(v.pipe(v.string(), v.description("words that describe the task"))) })),
|
|
@@ -122,7 +128,7 @@ withheld) => {
|
|
|
122
128
|
}
|
|
123
129
|
};
|
|
124
130
|
const call = v.strictObject({
|
|
125
|
-
command: v.pipe(v.string(), v.minLength(1), v.description(`a command ${prefix}_tools_search returned: "
|
|
131
|
+
command: v.pipe(v.string(), v.minLength(1), v.description(`a command ${prefix}_tools_search returned: "${sample}"`)),
|
|
126
132
|
arguments: v.optional(v.pipe(v.record(v.string(), v.unknown()), v.description("that command's arguments"))),
|
|
127
133
|
});
|
|
128
134
|
server.registerTool(`${prefix}_read`, {
|
|
@@ -136,7 +142,7 @@ withheld) => {
|
|
|
136
142
|
server.registerTool(`${prefix}_write`, {
|
|
137
143
|
outputSchema: toStandardJsonSchema(ANSWER),
|
|
138
144
|
title: "Run a writing command",
|
|
139
|
-
description: `Run one command that changes something — sends, edits, deletes, joins — with the arguments ${prefix}_tools_search showed. ${UNTRUSTED}`,
|
|
145
|
+
description: `Run one command that changes something — ${messenger ? "sends, edits, deletes, joins" : "creates, edits, deletes"} — with the arguments ${prefix}_tools_search showed. ${UNTRUSTED}`,
|
|
140
146
|
inputSchema: toStandardJsonSchema(call),
|
|
141
147
|
annotations: WRITE,
|
|
142
148
|
}, runner(true));
|
|
@@ -38,7 +38,6 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
-
limit?: undefined;
|
|
42
41
|
event_id?: undefined;
|
|
43
42
|
series_id?: undefined;
|
|
44
43
|
page?: undefined;
|
|
@@ -54,11 +53,11 @@ export declare const meetingTools: ({
|
|
|
54
53
|
format?: undefined;
|
|
55
54
|
transcript_id?: undefined;
|
|
56
55
|
query?: undefined;
|
|
56
|
+
limit?: undefined;
|
|
57
57
|
scan_limit?: undefined;
|
|
58
58
|
max_read_bytes?: undefined;
|
|
59
59
|
cursor?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
limit?: undefined;
|
|
62
61
|
event_id?: undefined;
|
|
63
62
|
series_id?: undefined;
|
|
64
63
|
page?: undefined;
|
|
@@ -76,11 +75,11 @@ export declare const meetingTools: ({
|
|
|
76
75
|
format?: undefined;
|
|
77
76
|
transcript_id?: undefined;
|
|
78
77
|
query?: undefined;
|
|
78
|
+
limit?: undefined;
|
|
79
79
|
scan_limit?: undefined;
|
|
80
80
|
max_read_bytes?: undefined;
|
|
81
81
|
cursor?: undefined;
|
|
82
82
|
} | {
|
|
83
|
-
limit?: undefined;
|
|
84
83
|
event_id?: undefined;
|
|
85
84
|
series_id?: undefined;
|
|
86
85
|
page?: undefined;
|
|
@@ -102,6 +101,7 @@ export declare const meetingTools: ({
|
|
|
102
101
|
minimum: number;
|
|
103
102
|
};
|
|
104
103
|
query?: undefined;
|
|
104
|
+
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,7 +188,6 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
-
limit?: undefined;
|
|
192
191
|
event_id?: undefined;
|
|
193
192
|
series_id?: undefined;
|
|
194
193
|
page?: undefined;
|
|
@@ -204,11 +203,11 @@ export declare const meetingTools: ({
|
|
|
204
203
|
format?: undefined;
|
|
205
204
|
transcript_id?: undefined;
|
|
206
205
|
query?: undefined;
|
|
206
|
+
limit?: undefined;
|
|
207
207
|
scan_limit?: undefined;
|
|
208
208
|
max_read_bytes?: undefined;
|
|
209
209
|
cursor?: undefined;
|
|
210
210
|
} | {
|
|
211
|
-
limit?: undefined;
|
|
212
211
|
event_id?: undefined;
|
|
213
212
|
series_id?: undefined;
|
|
214
213
|
page?: undefined;
|
|
@@ -226,11 +225,11 @@ export declare const meetingTools: ({
|
|
|
226
225
|
format?: undefined;
|
|
227
226
|
transcript_id?: undefined;
|
|
228
227
|
query?: undefined;
|
|
228
|
+
limit?: undefined;
|
|
229
229
|
scan_limit?: undefined;
|
|
230
230
|
max_read_bytes?: undefined;
|
|
231
231
|
cursor?: undefined;
|
|
232
232
|
} | {
|
|
233
|
-
limit?: undefined;
|
|
234
233
|
event_id?: undefined;
|
|
235
234
|
series_id?: undefined;
|
|
236
235
|
page?: undefined;
|
|
@@ -252,6 +251,7 @@ export declare const meetingTools: ({
|
|
|
252
251
|
minimum: number;
|
|
253
252
|
};
|
|
254
253
|
query?: undefined;
|
|
254
|
+
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,7 +338,6 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
-
limit?: undefined;
|
|
342
341
|
event_id?: undefined;
|
|
343
342
|
series_id?: undefined;
|
|
344
343
|
page?: undefined;
|
|
@@ -354,11 +353,11 @@ export declare const meetingTools: ({
|
|
|
354
353
|
format?: undefined;
|
|
355
354
|
transcript_id?: undefined;
|
|
356
355
|
query?: undefined;
|
|
356
|
+
limit?: undefined;
|
|
357
357
|
scan_limit?: undefined;
|
|
358
358
|
max_read_bytes?: undefined;
|
|
359
359
|
cursor?: undefined;
|
|
360
360
|
} | {
|
|
361
|
-
limit?: undefined;
|
|
362
361
|
event_id?: undefined;
|
|
363
362
|
series_id?: undefined;
|
|
364
363
|
page?: undefined;
|
|
@@ -376,11 +375,11 @@ export declare const meetingTools: ({
|
|
|
376
375
|
format?: undefined;
|
|
377
376
|
transcript_id?: undefined;
|
|
378
377
|
query?: undefined;
|
|
378
|
+
limit?: undefined;
|
|
379
379
|
scan_limit?: undefined;
|
|
380
380
|
max_read_bytes?: undefined;
|
|
381
381
|
cursor?: undefined;
|
|
382
382
|
} | {
|
|
383
|
-
limit?: undefined;
|
|
384
383
|
event_id?: undefined;
|
|
385
384
|
series_id?: undefined;
|
|
386
385
|
page?: undefined;
|
|
@@ -402,6 +401,7 @@ export declare const meetingTools: ({
|
|
|
402
401
|
minimum: number;
|
|
403
402
|
};
|
|
404
403
|
query?: undefined;
|
|
404
|
+
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,7 +488,6 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
-
limit?: undefined;
|
|
492
491
|
event_id?: undefined;
|
|
493
492
|
series_id?: undefined;
|
|
494
493
|
page?: undefined;
|
|
@@ -504,11 +503,11 @@ export declare const meetingTools: ({
|
|
|
504
503
|
format?: undefined;
|
|
505
504
|
transcript_id?: undefined;
|
|
506
505
|
query?: undefined;
|
|
506
|
+
limit?: undefined;
|
|
507
507
|
scan_limit?: undefined;
|
|
508
508
|
max_read_bytes?: undefined;
|
|
509
509
|
cursor?: undefined;
|
|
510
510
|
} | {
|
|
511
|
-
limit?: undefined;
|
|
512
511
|
event_id?: undefined;
|
|
513
512
|
series_id?: undefined;
|
|
514
513
|
page?: undefined;
|
|
@@ -526,11 +525,11 @@ export declare const meetingTools: ({
|
|
|
526
525
|
format?: undefined;
|
|
527
526
|
transcript_id?: undefined;
|
|
528
527
|
query?: undefined;
|
|
528
|
+
limit?: undefined;
|
|
529
529
|
scan_limit?: undefined;
|
|
530
530
|
max_read_bytes?: undefined;
|
|
531
531
|
cursor?: undefined;
|
|
532
532
|
} | {
|
|
533
|
-
limit?: undefined;
|
|
534
533
|
event_id?: undefined;
|
|
535
534
|
series_id?: undefined;
|
|
536
535
|
page?: undefined;
|
|
@@ -552,6 +551,7 @@ export declare const meetingTools: ({
|
|
|
552
551
|
minimum: number;
|
|
553
552
|
};
|
|
554
553
|
query?: undefined;
|
|
554
|
+
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,7 +638,6 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
-
limit?: undefined;
|
|
642
641
|
event_id?: undefined;
|
|
643
642
|
series_id?: undefined;
|
|
644
643
|
page?: undefined;
|
|
@@ -654,11 +653,11 @@ export declare const meetingTools: ({
|
|
|
654
653
|
format?: undefined;
|
|
655
654
|
transcript_id?: undefined;
|
|
656
655
|
query?: undefined;
|
|
656
|
+
limit?: undefined;
|
|
657
657
|
scan_limit?: undefined;
|
|
658
658
|
max_read_bytes?: undefined;
|
|
659
659
|
cursor?: undefined;
|
|
660
660
|
} | {
|
|
661
|
-
limit?: undefined;
|
|
662
661
|
event_id?: undefined;
|
|
663
662
|
series_id?: undefined;
|
|
664
663
|
page?: undefined;
|
|
@@ -676,11 +675,11 @@ export declare const meetingTools: ({
|
|
|
676
675
|
format?: undefined;
|
|
677
676
|
transcript_id?: undefined;
|
|
678
677
|
query?: undefined;
|
|
678
|
+
limit?: undefined;
|
|
679
679
|
scan_limit?: undefined;
|
|
680
680
|
max_read_bytes?: undefined;
|
|
681
681
|
cursor?: undefined;
|
|
682
682
|
} | {
|
|
683
|
-
limit?: undefined;
|
|
684
683
|
event_id?: undefined;
|
|
685
684
|
series_id?: undefined;
|
|
686
685
|
page?: undefined;
|
|
@@ -702,6 +701,7 @@ export declare const meetingTools: ({
|
|
|
702
701
|
minimum: number;
|
|
703
702
|
};
|
|
704
703
|
query?: undefined;
|
|
704
|
+
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
|
@@ -7,16 +7,10 @@ export declare const modelSettingsShape: v.RecordSchema<v.SchemaWithPipe<readonl
|
|
|
7
7
|
readonly base_url: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
|
|
8
8
|
}, undefined>, undefined>;
|
|
9
9
|
export type ModelSettings = v.InferOutput<typeof modelSettingsShape>;
|
|
10
|
-
export declare const resolveModelSettings: (prefix: string, layers: readonly (readonly [string, Readonly<Record<string, unknown>> | undefined])[], env: NodeJS.ProcessEnv
|
|
11
|
-
values: Record<string, unknown>;
|
|
12
|
-
sources: Record<string, string>;
|
|
13
|
-
}) => {
|
|
10
|
+
export declare const resolveModelSettings: (prefix: string, layers: readonly (readonly [string, Readonly<Record<string, unknown>> | undefined])[], env: NodeJS.ProcessEnv) => {
|
|
14
11
|
models: ModelSettings;
|
|
15
12
|
sources: Record<string, string>;
|
|
16
13
|
};
|
|
17
14
|
export declare const modelTarget: (settings: {
|
|
18
15
|
models?: ModelSettings;
|
|
19
|
-
analysisProvider?: string;
|
|
20
|
-
analysisModel?: string;
|
|
21
|
-
analysisBaseUrl?: string;
|
|
22
16
|
}, purpose: string) => ModelTarget | undefined;
|
package/dist/models/settings.js
CHANGED
|
@@ -7,7 +7,7 @@ export const modelSettingsShape = v.record(v.pipe(v.string(), v.regex(/^[a-z][a-
|
|
|
7
7
|
model: v.optional(v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(200))),
|
|
8
8
|
base_url: v.optional(v.pipe(v.string(), v.check((value) => endpoint(value), "use an HTTP/S endpoint without credentials, query or fragment"))),
|
|
9
9
|
}));
|
|
10
|
-
export const resolveModelSettings = (prefix, layers, env
|
|
10
|
+
export const resolveModelSettings = (prefix, layers, env) => {
|
|
11
11
|
const configured = layers.map(([from, scope]) => [from, (scope?.models ?? {})]);
|
|
12
12
|
const purposes = new Set([
|
|
13
13
|
"default",
|
|
@@ -26,21 +26,12 @@ export const resolveModelSettings = (prefix, layers, env, legacy) => {
|
|
|
26
26
|
const resolved = {};
|
|
27
27
|
for (const field of MODEL_FIELDS) {
|
|
28
28
|
const variable = `${prefix}_MODELS_${purpose.replaceAll("-", "_").toUpperCase()}_${field.toUpperCase()}`;
|
|
29
|
-
const legacyKey = { provider: "analysisProvider", model: "analysisModel", base_url: "analysisBaseUrl" }[field];
|
|
30
29
|
const candidates = [
|
|
31
30
|
[variable, env[variable]?.trim() || undefined],
|
|
32
31
|
...configured.map(([from, model]) => [
|
|
33
32
|
`${from}: models.${purpose}.${field}`,
|
|
34
33
|
model[purpose]?.[field],
|
|
35
34
|
]),
|
|
36
|
-
...(purpose === "analysis" && legacy.sources[legacyKey] !== "default"
|
|
37
|
-
? [
|
|
38
|
-
[
|
|
39
|
-
legacy.sources[legacyKey] ?? "legacy analysis setting",
|
|
40
|
-
legacy.values[legacyKey] === "agent" ? "off" : legacy.values[legacyKey],
|
|
41
|
-
],
|
|
42
|
-
]
|
|
43
|
-
: []),
|
|
44
35
|
...(purpose === "default"
|
|
45
36
|
? []
|
|
46
37
|
: [
|
|
@@ -69,14 +60,6 @@ export const resolveModelSettings = (prefix, layers, env, legacy) => {
|
|
|
69
60
|
};
|
|
70
61
|
export const modelTarget = (settings, purpose) => {
|
|
71
62
|
const configured = { ...settings.models?.default, ...settings.models?.[purpose] };
|
|
72
|
-
if (purpose === "analysis" &&
|
|
73
|
-
configured.provider === undefined &&
|
|
74
|
-
settings.analysisProvider &&
|
|
75
|
-
settings.analysisProvider !== "agent") {
|
|
76
|
-
configured.provider = settings.analysisProvider;
|
|
77
|
-
configured.model ??= settings.analysisModel;
|
|
78
|
-
configured.base_url ??= settings.analysisBaseUrl;
|
|
79
|
-
}
|
|
80
63
|
if (configured.provider === undefined || configured.provider === "off")
|
|
81
64
|
return undefined;
|
|
82
65
|
if (!configured.model)
|
package/dist/ports/app.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface AppIdentity {
|
|
|
19
19
|
* can stem in place of English and the system's language; the person still confirms, since the choice is shared.
|
|
20
20
|
*/
|
|
21
21
|
contentLanguages?: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* `false` for a CLI that is not a messenger — notes, files, a calendar. The shared help, `config`, `commands info`
|
|
24
|
+
* and MCP text then name its own commands and leave out chats, messages and senders. Unset means a messenger, so
|
|
25
|
+
* tg, max and wa print what they always did.
|
|
26
|
+
*/
|
|
27
|
+
messenger?: boolean;
|
|
22
28
|
/** Error reasons and detail keys of its own — max's `max_code`, tg's `migrated_chat_id` — kept in every error it prints. */
|
|
23
29
|
errors?: AppErrors;
|
|
24
30
|
}
|
|
@@ -34,12 +34,12 @@ const heldOf = (stored, running) => [
|
|
|
34
34
|
{ provider: "notes", account: INTERNAL_NOTES, name: null, kind: "notes" },
|
|
35
35
|
...stored
|
|
36
36
|
.filter(({ provider }) => isFolderProvider(provider))
|
|
37
|
-
.map(({ id, name, provider }) => ({
|
|
37
|
+
.map(({ id, name, provider, account }) => ({
|
|
38
38
|
provider: "notes",
|
|
39
39
|
account: String(id),
|
|
40
40
|
name,
|
|
41
41
|
kind: "notes",
|
|
42
|
-
|
|
42
|
+
stored: { provider, account },
|
|
43
43
|
})),
|
|
44
44
|
...stored
|
|
45
45
|
.filter(({ provider }) => isDocumentAccountProvider(provider))
|
|
@@ -78,8 +78,11 @@ const accountOf = (prefix, ref, held, context) => {
|
|
|
78
78
|
if (stored)
|
|
79
79
|
return stored;
|
|
80
80
|
}
|
|
81
|
-
const
|
|
82
|
-
const
|
|
81
|
+
const folder = isFolderProvider(provider);
|
|
82
|
+
const ofProvider = folder
|
|
83
|
+
? storedAs(held, { provider, account: "" })
|
|
84
|
+
: held.filter((one) => one.provider === provider);
|
|
85
|
+
const byId = ofProvider.find(({ account, stored }) => account === ref || account === ref.toLowerCase() || (folder && stored?.account === ref.toUpperCase()));
|
|
83
86
|
if (byId)
|
|
84
87
|
return byId;
|
|
85
88
|
const keyed = (key) => ofProvider.find(({ account }) => account === key.account) ?? {
|
|
@@ -132,10 +135,8 @@ const accountsOfWord = (word, held, context) => {
|
|
|
132
135
|
Object.values(recorded).every((key) => isFolderProvider(key.provider) || isDocumentAccountProvider(key.provider)))
|
|
133
136
|
return Object.keys(recorded).map((profile) => accountOf(word, profile, held, context));
|
|
134
137
|
const provider = providerOf(word, held, context);
|
|
135
|
-
if (isDocumentAccountProvider(provider))
|
|
138
|
+
if (isDocumentAccountProvider(provider) || isFolderProvider(provider))
|
|
136
139
|
return storedAs(held, { provider, account: "" });
|
|
137
|
-
if (isFolderProvider(provider))
|
|
138
|
-
return held.filter(({ folder }) => folder === provider);
|
|
139
140
|
return held.filter((one) => one.provider === provider);
|
|
140
141
|
};
|
|
141
142
|
const keyOf = ({ provider, account }) => `${provider}\u0000${account}`;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
import { type Language } from "./languages.js";
|
|
1
2
|
/** The Hunspell dictionary that tells a real word from a garbled one, for each language the store stems. */
|
|
2
|
-
export declare const DICTIONARIES:
|
|
3
|
-
|
|
4
|
-
readonly english: "dictionary-en";
|
|
5
|
-
readonly spanish: "dictionary-es";
|
|
6
|
-
};
|
|
7
|
-
export type DictionaryLanguage = keyof typeof DICTIONARIES;
|
|
3
|
+
export declare const DICTIONARIES: Record<Language, string>;
|
|
4
|
+
export type DictionaryLanguage = Language;
|
|
8
5
|
/**
|
|
9
6
|
* `known`: whether a folded word the index stores is real in one of `languages` that write in its alphabet.
|
|
10
7
|
* `covers`: whether any of them does; without one, a garbled spelling cannot be told from a real word.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { fold } from "../store/normalize.js";
|
|
3
|
+
import { LANGUAGES } from "./languages.js";
|
|
3
4
|
/** The Hunspell dictionary that tells a real word from a garbled one, for each language the store stems. */
|
|
4
|
-
export const DICTIONARIES = {
|
|
5
|
+
export const DICTIONARIES = Object.fromEntries(LANGUAGES.map(({ name, dictionary }) => [name, dictionary]));
|
|
5
6
|
/** `fold`, without Unicode normalisation for plain Russian letters: it would double the time Russian loads in. */
|
|
6
7
|
const folded = (word) => /^[а-яё'-]*$/.test(word) ? word.replaceAll("ё", "е").replaceAll("й", "и") : fold(word);
|
|
7
8
|
const loaded = new Map();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The languages search can stem and spell-check. Adding one here needs its Snowball stemmer in `stem.ts`. */
|
|
2
|
+
export declare const LANGUAGES: readonly [{
|
|
3
|
+
readonly name: "russian";
|
|
4
|
+
readonly code: "ru";
|
|
5
|
+
readonly label: "Russian";
|
|
6
|
+
readonly script: "cyrillic";
|
|
7
|
+
readonly dictionary: "dictionary-ru";
|
|
8
|
+
}, {
|
|
9
|
+
readonly name: "english";
|
|
10
|
+
readonly code: "en";
|
|
11
|
+
readonly label: "English";
|
|
12
|
+
readonly script: "latin";
|
|
13
|
+
readonly dictionary: "dictionary-en";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "spanish";
|
|
16
|
+
readonly code: "es";
|
|
17
|
+
readonly label: "Spanish";
|
|
18
|
+
readonly script: "latin";
|
|
19
|
+
readonly dictionary: "dictionary-es";
|
|
20
|
+
}];
|
|
21
|
+
type Entry = (typeof LANGUAGES)[number];
|
|
22
|
+
export type Language = Entry["name"];
|
|
23
|
+
export type Script = Entry["script"];
|
|
24
|
+
export type LanguageOf<S extends Script> = Extract<Entry, {
|
|
25
|
+
script: S;
|
|
26
|
+
}>["name"];
|
|
27
|
+
export declare const languagesOf: <S extends Script>(script: S) => LanguageOf<S>[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The languages search can stem and spell-check. Adding one here needs its Snowball stemmer in `stem.ts`. */
|
|
2
|
+
export const LANGUAGES = [
|
|
3
|
+
{ name: "russian", code: "ru", label: "Russian", script: "cyrillic", dictionary: "dictionary-ru" },
|
|
4
|
+
{ name: "english", code: "en", label: "English", script: "latin", dictionary: "dictionary-en" },
|
|
5
|
+
{ name: "spanish", code: "es", label: "Spanish", script: "latin", dictionary: "dictionary-es" },
|
|
6
|
+
];
|
|
7
|
+
export const languagesOf = (script) => LANGUAGES.filter((one) => one.script === script).map(({ name }) => name);
|
package/dist/search/stem.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { type LanguageOf } from "./languages.js";
|
|
1
2
|
/** The version of the vendored files in `./snowball/`; `bin/snowball-update` regenerates them. */
|
|
2
3
|
export declare const SNOWBALL_VERSION = "3.1.1";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
4
|
+
export type CyrillicStemmer = LanguageOf<"cyrillic"> | "none";
|
|
5
|
+
export type LatinStemmer = LanguageOf<"latin"> | "none";
|
|
6
|
+
export declare const CYRILLIC_STEMMERS: readonly CyrillicStemmer[];
|
|
7
|
+
export declare const LATIN_STEMMERS: readonly LatinStemmer[];
|
|
7
8
|
/** `latin` is one stemmer, `none`, or several joined by commas in alphabetical order (`english,spanish`). */
|
|
8
9
|
export type Stemmers = {
|
|
9
10
|
cyrillic: CyrillicStemmer;
|
package/dist/search/stem.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { normalize } from "../store/normalize.js";
|
|
3
|
+
import { languagesOf } from "./languages.js";
|
|
3
4
|
import EnglishStemmer from "./snowball/english-stemmer.js";
|
|
4
5
|
import RussianStemmer from "./snowball/russian-stemmer.js";
|
|
5
6
|
import SpanishStemmer from "./snowball/spanish-stemmer.js";
|
|
6
7
|
/** The version of the vendored files in `./snowball/`; `bin/snowball-update` regenerates them. */
|
|
7
8
|
export const SNOWBALL_VERSION = "3.1.1";
|
|
8
|
-
export const CYRILLIC_STEMMERS = ["
|
|
9
|
-
export const LATIN_STEMMERS = ["
|
|
9
|
+
export const CYRILLIC_STEMMERS = [...languagesOf("cyrillic"), "none"];
|
|
10
|
+
export const LATIN_STEMMERS = [...languagesOf("latin"), "none"];
|
|
10
11
|
export const DEFAULT_STEMMERS = { cyrillic: "russian", latin: "english,spanish" };
|
|
11
12
|
/**
|
|
12
13
|
* Raised with every change to `DEFAULT_STEMMERS`. A default saved in the store carries it, so a newer build
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.423.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|