@wirecat/cli-core 0.401.0 → 0.403.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/dist/cli/bot/api.js +5 -2
- package/dist/cli/config-command.js +13 -7
- package/dist/cli/context.d.ts +2 -0
- package/dist/cli/first-run.d.ts +68 -0
- package/dist/cli/first-run.js +224 -0
- package/dist/cli/help/first-screen.d.ts +2 -0
- package/dist/cli/help/first-screen.js +31 -6
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/messenger/context.js +4 -2
- package/dist/cli/messenger/store-maintenance-command.d.ts +10 -0
- package/dist/cli/messenger/store-maintenance-command.js +1 -1
- package/dist/cli/permission-keys.js +2 -2
- package/dist/cli/program.js +16 -1
- package/dist/cli/settings.js +15 -2
- package/dist/cli/setup-answers.d.ts +24 -0
- package/dist/cli/setup-answers.js +47 -0
- package/dist/documents/index.d.ts +1 -0
- package/dist/documents/index.js +1 -0
- package/dist/mcp/agent.js +4 -2
- package/dist/search/dictionary.d.ts +20 -0
- package/dist/search/dictionary.js +106 -0
- package/dist/sends/guard.d.ts +2 -0
- package/dist/sends/guard.js +8 -3
- package/dist/sends/permissions.d.ts +14 -0
- package/dist/sends/permissions.js +23 -1
- package/dist/services/documents/mirror-watch.d.ts +39 -0
- package/dist/services/documents/mirror-watch.js +155 -0
- package/dist/services/documents/push.d.ts +2 -0
- package/dist/services/documents/push.js +2 -0
- package/dist/store/shared-config.d.ts +4 -0
- package/dist/store/shared-config.js +10 -6
- package/dist/store/sqlite/transcript-query.js +15 -5
- package/package.json +3 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { dictionaryLanguages, knownWord } from "../../search/dictionary.js";
|
|
1
2
|
import { isNumberWord, widenWords } from "../../search/garbled.js";
|
|
2
|
-
import { knownRussianWord } from "../../search/russian-dictionary.js";
|
|
3
3
|
import { createStemmer, DEFAULT_STEMMERS, STEM_SEPARATOR } from "../../search/stem.js";
|
|
4
4
|
import { normalize } from "../normalize.js";
|
|
5
5
|
import { ftsMatch, quoted, SPEECH, stemMatch } from "./lucene-fields.js";
|
|
@@ -9,6 +9,13 @@ const predicates = (node) => node.kind === "predicate" ? [node] : node.clauses.f
|
|
|
9
9
|
const readsTranscripts = (node) => (node.operator === "term" || node.operator === "phrase") &&
|
|
10
10
|
/[\p{L}\p{N}]/u.test(normalize(node.value)) &&
|
|
11
11
|
(node.field === "transcript" || (node.implicit === true && (node.field === "text" || node.field === "exact")));
|
|
12
|
+
/** `isNumberWord` knows Russian numbers only; a widened number is a wrong fact in any language. */
|
|
13
|
+
const LATIN_NUMBERS = new Set(`zero one two three four five six seven eight nine ten eleven twelve twenty thirty forty fifty sixty seventy
|
|
14
|
+
eighty ninety hundred thousand million billion first second third fourth fifth sixth seventh eighth ninth tenth
|
|
15
|
+
half quarter cero uno una dos tres cuatro cinco seis siete ocho nueve diez once doce veinte treinta cuarenta
|
|
16
|
+
cincuenta sesenta setenta ochenta noventa cien ciento mil millon primero segundo tercero cuarto quinto medio`.split(/\s+/));
|
|
17
|
+
/** A word widens when its alphabet has a dictionary to tell a garbled spelling from another real word. */
|
|
18
|
+
const widens = (word, covered) => covered(word) && !isNumberWord(word) && !LATIN_NUMBERS.has(word);
|
|
12
19
|
/**
|
|
13
20
|
* Each leaf that reads transcripts, with what it matches there. A transcript always widens, not only when nothing
|
|
14
21
|
* matched as typed text does: a correct and a garbled spelling sit in one chat. Only a single word widens —
|
|
@@ -20,7 +27,9 @@ export const transcriptTerms = (database, root, item) => {
|
|
|
20
27
|
const saved = savedStemmers(database);
|
|
21
28
|
if (item !== "message" || !leaves.length || saved === null)
|
|
22
29
|
return terms;
|
|
23
|
-
const
|
|
30
|
+
const stemmers = saved ?? DEFAULT_STEMMERS;
|
|
31
|
+
const stemmer = createStemmer(stemmers);
|
|
32
|
+
const dictionary = knownWord(dictionaryLanguages(stemmers));
|
|
24
33
|
const stemsOf = (word) => [...new Set(stemmer.explain(word).map((part) => part.stem))];
|
|
25
34
|
const widening = [];
|
|
26
35
|
for (const [node, one] of terms) {
|
|
@@ -31,8 +40,9 @@ export const transcriptTerms = (database, root, item) => {
|
|
|
31
40
|
if (stems)
|
|
32
41
|
Object.assign(one, { stems: node.slop === undefined ? stems : `(${stems}) NOT ${quoted(STEM_SEPARATOR)}` });
|
|
33
42
|
const words = normalize(node.value).match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
const [word] = words;
|
|
44
|
+
if (node.operator === "term" && word !== undefined && words.length === 1 && widens(word, dictionary.covers))
|
|
45
|
+
widening.push({ node, literal: word, stems: stemsOf(node.value) });
|
|
36
46
|
}
|
|
37
47
|
if (!widening.length)
|
|
38
48
|
return terms;
|
|
@@ -40,7 +50,7 @@ export const transcriptTerms = (database, root, item) => {
|
|
|
40
50
|
.prepare("SELECT term, doc FROM transcript_words_vocab WHERE col = 'normalized_text'")
|
|
41
51
|
.all()
|
|
42
52
|
.map((row) => ({ term: String(row.term), docs: Number(row.doc) }));
|
|
43
|
-
widenWords(widening, vocabulary, stemsOf,
|
|
53
|
+
widenWords(widening, vocabulary, stemsOf, dictionary.known).forEach((words, at) => {
|
|
44
54
|
const leaf = widening[at];
|
|
45
55
|
if (leaf)
|
|
46
56
|
Object.assign(terms.get(leaf.node), { widened: words });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.403.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",
|
|
@@ -173,6 +173,8 @@
|
|
|
173
173
|
"@xmldom/xmldom": "0.9.12",
|
|
174
174
|
"chardet": "2.2.0",
|
|
175
175
|
"defuddle": "0.19.5",
|
|
176
|
+
"dictionary-en": "4.0.0",
|
|
177
|
+
"dictionary-es": "4.0.0",
|
|
176
178
|
"dictionary-ru": "3.0.0",
|
|
177
179
|
"echarts": "6.1.0",
|
|
178
180
|
"fflate": "0.8.3",
|