@wirecat/cli-core 0.743.0 → 0.745.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 +27 -0
- package/dist/cli/documents/index.d.ts +1 -1
- package/dist/cli/documents/index.js +1 -1
- package/dist/cli/documents/knowledge.js +7 -15
- package/dist/cli/untrusted-marks.d.ts +10 -2
- package/dist/cli/untrusted-marks.js +20 -3
- package/dist/crm/cli/records.js +22 -15
- package/dist/crm/manifest/writer.js +1 -0
- package/dist/crm/writer.d.ts +7 -0
- package/dist/search/respell.d.ts +8 -2
- package/dist/search/respell.js +72 -7
- package/dist/store/sqlite/memories.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,33 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.745.0 — 24.11.2026
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- `search all` and `deals list` find a CRM record whose Cyrillic name is typed in Latin: `finpoint` and `finpoynt` find
|
|
13
|
+
ФинПоинт, marked as corrected to `финпоинт`. Only a Cyrillic spelling the store holds as it is counts, so `cement`
|
|
14
|
+
does not turn into цемент. Message search reads a Latin word the same way (#3285).
|
|
15
|
+
- **Memories, facts and the names a provider shows for a document's accounts are marked untrusted for a scheduled
|
|
16
|
+
agent.** In a run locked read-only with a mark, `memories list|show|search` and `facts list|show` mark each one's
|
|
17
|
+
`text`, `identities list` marks an account's `name` and its person's `name`, and `documents context` marks the same
|
|
18
|
+
in its `memories`, `facts` and `people`. A model's memory repeats the words of whoever wrote the document, so an
|
|
19
|
+
instruction planted there would reach the agent unmarked. Elsewhere the answers are unchanged. A CLI with its own
|
|
20
|
+
copies of these commands wraps them with the new `KNOWLEDGE_UNTRUSTED` and `IDENTITY_UNTRUSTED` from
|
|
21
|
+
`@wirecat/cli-core/documents/cli` ([DOCUMENTS.md](docs/dev/DOCUMENTS.md)).
|
|
22
|
+
- **`memories search` in a documents CLI finds a memory added with `memories add`.** The search reads its index
|
|
23
|
+
read-only and only a writable open builds it, so a new memory stayed unfound. Adding one now indexes it.
|
|
24
|
+
|
|
25
|
+
## 0.744.0 — 24.11.2026
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- **`people` and `organizations` `create` and `update` offer only the flags the CRM's write takes.** A CRM CLI made
|
|
30
|
+
from a manifest offered `--owner`, `--position`, `--email`, `--phone` and `--field` on every contact and company
|
|
31
|
+
write, though the manifest may write none of them: Attio's people take no owner, so `--owner` was first refused by
|
|
32
|
+
`crm.assign-others` and then by the writer. `CrmWriteCapabilities.fields` names the fields each kind takes, and
|
|
33
|
+
`crmManifestWriteCapabilities` fills it. A writer that leaves it out keeps every flag.
|
|
34
|
+
|
|
8
35
|
## 0.743.0 — 24.11.2026
|
|
9
36
|
|
|
10
37
|
### Added
|
|
@@ -8,7 +8,7 @@ import { type DocumentMirrorCommands } from "./mirrors.js";
|
|
|
8
8
|
import { type DocumentSearchCommands } from "./search.js";
|
|
9
9
|
import { type DocumentSyncCommands } from "./sync.js";
|
|
10
10
|
import type { DocumentWords } from "./words.js";
|
|
11
|
-
export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
11
|
+
export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, IDENTITY_UNTRUSTED, KNOWLEDGE_UNTRUSTED, marksUntrusted, } from "../untrusted-marks.js";
|
|
12
12
|
export { addDocumentCatalogCommands, CATALOG_FIELDS, type CatalogTree, type CatalogTreeSource, catalogId, catalogOutput, catalogSource, catalogTree, type DocumentCatalog, type DocumentCatalogCommands, type DocumentCatalogStores, } from "./catalog.js";
|
|
13
13
|
export { addLocalDocumentCommands, type ImportedDocument, type LocalDocumentCommands } from "./documents.js";
|
|
14
14
|
export { type FileConflictCommands, type FileConflictConnection, fileConflictsCommand } from "./file-conflicts.js";
|
|
@@ -6,7 +6,7 @@ import { addDocumentKnowledgeCommands } from "./knowledge.js";
|
|
|
6
6
|
import { addDocumentMirrorCommands } from "./mirrors.js";
|
|
7
7
|
import { addDocumentSearchCommand } from "./search.js";
|
|
8
8
|
import { addDocumentSyncCommands } from "./sync.js";
|
|
9
|
-
export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
9
|
+
export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, IDENTITY_UNTRUSTED, KNOWLEDGE_UNTRUSTED, marksUntrusted, } from "../untrusted-marks.js";
|
|
10
10
|
export { addDocumentCatalogCommands, CATALOG_FIELDS, catalogId, catalogOutput, catalogSource, catalogTree, } from "./catalog.js";
|
|
11
11
|
export { addLocalDocumentCommands } from "./documents.js";
|
|
12
12
|
export { fileConflictsCommand } from "./file-conflicts.js";
|
|
@@ -7,7 +7,7 @@ import { honoursDryRun } from "../dry-run-guard.js";
|
|
|
7
7
|
import { LOCAL_READ, LOCAL_WRITE, REMOTE_WRITE } from "../effects.js";
|
|
8
8
|
import { itemOf, listOf } from "../envelope.js";
|
|
9
9
|
import { queryHelp, queryTerms, withQuery } from "../list-query.js";
|
|
10
|
-
import { DOCUMENT_CONTEXT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
10
|
+
import { DOCUMENT_CONTEXT_UNTRUSTED, IDENTITY_UNTRUSTED, KNOWLEDGE_UNTRUSTED, marksUntrusted, } from "../untrusted-marks.js";
|
|
11
11
|
import { bindQuery, documentQueries, FACT_QUERY, factItem, identityRow, linkRow, MEMORY_QUERY, MEMORY_SEARCH_QUERY, memoryItem, memorySearch, tagRow, termsOf, } from "./queries.js";
|
|
12
12
|
import { allOf, documentsGroup, examples, positive, wordsOf } from "./words.js";
|
|
13
13
|
const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
@@ -119,10 +119,7 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
119
119
|
.addOption(new Option("--kind <kind>", "what kind of memory it is").choices(MEMORY_KINDS).default("summary"))
|
|
120
120
|
.option("--supersedes <ref>", "a memory:<id> about the same document that this one replaces")
|
|
121
121
|
.action(async (doc, body, args) => output(itemOf(memoryItem(await run(doc, (k, p, ref) => k.addMemory(p, ref, { body, ...args, status: "proposed", author: author() }))))));
|
|
122
|
-
withQuery(examples(annotate(memories.command("list"), { effects: LOCAL_READ }).description("list a document's memories"), [
|
|
123
|
-
`${prefix} memories list DOC_ID scope:work`,
|
|
124
|
-
`${prefix} memories list DOC_ID kind:preference status:confirmed`,
|
|
125
|
-
]).argument("<document>", documentArgument), MEMORY_QUERY)
|
|
122
|
+
withQuery(examples(marksUntrusted(annotate(memories.command("list"), { effects: LOCAL_READ }), KNOWLEDGE_UNTRUSTED).description("list a document's memories"), [`${prefix} memories list DOC_ID scope:work`, `${prefix} memories list DOC_ID kind:preference status:confirmed`]).argument("<document>", documentArgument), MEMORY_QUERY)
|
|
126
123
|
.option("--limit <n>", "how many memories to return", positive, 50)
|
|
127
124
|
.action(async (doc, words, { limit }) => {
|
|
128
125
|
const terms = queryTerms(words, MEMORY_QUERY, "memories list");
|
|
@@ -139,11 +136,11 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
139
136
|
stale: "mark a memory as out of date",
|
|
140
137
|
};
|
|
141
138
|
for (const [action, description] of Object.entries(memoryActions))
|
|
142
|
-
examples(annotate(memories.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`${prefix} memories ${action} DOC_ID memory:MEMORY_ID`])
|
|
139
|
+
examples(marksUntrusted(annotate(memories.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }), KNOWLEDGE_UNTRUSTED).description(description), [`${prefix} memories ${action} DOC_ID memory:MEMORY_ID`])
|
|
143
140
|
.argument("<document>", documentArgument)
|
|
144
141
|
.argument("<memory>", memoryArgument)
|
|
145
142
|
.action(async (doc, memoryRef) => output(itemOf(memoryItem(await run(doc, (k, p, ref) => action === "show" ? k.memory(p, ref, memoryRef) : k.memory(p, ref, memoryRef, action, decider()))))));
|
|
146
|
-
const search = examples(annotate(memories.command("search"), { effects: LOCAL_READ }).description("search a document's memories by words"), [`${prefix} memories search DOC_ID reviews scope:work`, `${prefix} memories search DOC_ID "async reviews"`])
|
|
143
|
+
const search = examples(marksUntrusted(annotate(memories.command("search"), { effects: LOCAL_READ }), KNOWLEDGE_UNTRUSTED).description("search a document's memories by words"), [`${prefix} memories search DOC_ID reviews scope:work`, `${prefix} memories search DOC_ID "async reviews"`])
|
|
147
144
|
.argument("<document>", documentArgument)
|
|
148
145
|
.argument("<query...>", "words to look for, and scope:personal or scope:work — the fields are below")
|
|
149
146
|
.allowUnknownOption()
|
|
@@ -194,10 +191,7 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
194
191
|
by: author(),
|
|
195
192
|
...(occurredTime === undefined ? {} : { occurredAt: occurredTime }),
|
|
196
193
|
}))))));
|
|
197
|
-
withQuery(examples(annotate(facts.command("list"), { effects: LOCAL_READ }).description("list a document's facts"), [
|
|
198
|
-
`${prefix} facts list DOC_ID status:proposed`,
|
|
199
|
-
`${prefix} facts list DOC_ID kind:decision`,
|
|
200
|
-
]).argument("<document>", documentArgument), FACT_QUERY)
|
|
194
|
+
withQuery(examples(marksUntrusted(annotate(facts.command("list"), { effects: LOCAL_READ }), KNOWLEDGE_UNTRUSTED).description("list a document's facts"), [`${prefix} facts list DOC_ID status:proposed`, `${prefix} facts list DOC_ID kind:decision`]).argument("<document>", documentArgument), FACT_QUERY)
|
|
201
195
|
.option("--limit <n>", "how many facts to return", positive, 50)
|
|
202
196
|
.action(async (doc, words, { limit }) => {
|
|
203
197
|
const terms = queryTerms(words, FACT_QUERY, "facts list");
|
|
@@ -213,14 +207,12 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
213
207
|
reverse: "an accepted decision no longer holds, and nothing replaced it",
|
|
214
208
|
};
|
|
215
209
|
for (const [action, description] of Object.entries(factActions))
|
|
216
|
-
examples(annotate(facts.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`${prefix} facts ${action} DOC_ID fact:FACT_ID`])
|
|
210
|
+
examples(marksUntrusted(annotate(facts.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }), KNOWLEDGE_UNTRUSTED).description(description), [`${prefix} facts ${action} DOC_ID fact:FACT_ID`])
|
|
217
211
|
.argument("<document>", documentArgument)
|
|
218
212
|
.argument("<fact>", factArgument)
|
|
219
213
|
.action(async (doc, factRef) => output(itemOf(factItem(await run(doc, (k, p, ref) => action === "show" ? k.fact(p, ref, factRef) : k.fact(p, ref, factRef, action, decider()))))));
|
|
220
214
|
const identities = annotate(program.command("identities"), { effects: LOCAL_READ }).description(text.identities);
|
|
221
|
-
bindQuery(examples(annotate(identities.command("list"), { effects: LOCAL_READ }).description(text.identitiesList), [
|
|
222
|
-
`${prefix} identities list DOC_ID`,
|
|
223
|
-
]).argument("<document>", documentArgument), queries.identities, identityRow).action(async (doc, words) => {
|
|
215
|
+
bindQuery(examples(marksUntrusted(annotate(identities.command("list"), { effects: LOCAL_READ }), IDENTITY_UNTRUSTED).description(text.identitiesList), [`${prefix} identities list DOC_ID`]).argument("<document>", documentArgument), queries.identities, identityRow).action(async (doc, words) => {
|
|
224
216
|
const filter = termsOf(words, queries.identities, "identities list");
|
|
225
217
|
output(itemOf(await run(doc, (k, p, ref) => k.people(p, ref, filter))));
|
|
226
218
|
});
|
|
@@ -30,8 +30,16 @@ export declare const CONTACT_UNTRUSTED: readonly ["description", "chats.title"];
|
|
|
30
30
|
*/
|
|
31
31
|
export declare const DOCUMENT_UNTRUSTED: readonly ["name", "title", "path", "text", "description", "excerpt", "target_text", "targetText"];
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* A memory's or a fact's text about a document. A model's repeats the words of whoever wrote the document, and the
|
|
34
|
+
* store cannot tell which text an owner or an agent copied from it, so every one is marked.
|
|
35
|
+
*/
|
|
36
|
+
export declare const KNOWLEDGE_UNTRUSTED: readonly ["text"];
|
|
37
|
+
/** The accounts a provider shows on a document: the names their holders chose, and the person named after one. */
|
|
38
|
+
export declare const IDENTITY_UNTRUSTED: readonly ["name"];
|
|
39
|
+
/**
|
|
40
|
+
* `documents context`: the document, the links written in it, the memories and facts about it and the provider's
|
|
41
|
+
* names of its accounts. The notes and tags beside it are the owner's own, as a note is in `search notes`, so a bare
|
|
42
|
+
* `text` or `title` would mark them too.
|
|
35
43
|
*/
|
|
36
44
|
export declare const DOCUMENT_CONTEXT_UNTRUSTED: string[];
|
|
37
45
|
/** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
|
|
@@ -105,10 +105,27 @@ export const DOCUMENT_UNTRUSTED = [
|
|
|
105
105
|
"targetText",
|
|
106
106
|
];
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
108
|
+
* A memory's or a fact's text about a document. A model's repeats the words of whoever wrote the document, and the
|
|
109
|
+
* store cannot tell which text an owner or an agent copied from it, so every one is marked.
|
|
110
110
|
*/
|
|
111
|
-
export const
|
|
111
|
+
export const KNOWLEDGE_UNTRUSTED = ["text"];
|
|
112
|
+
/** The accounts a provider shows on a document: the names their holders chose, and the person named after one. */
|
|
113
|
+
export const IDENTITY_UNTRUSTED = ["name"];
|
|
114
|
+
/**
|
|
115
|
+
* `documents context`: the document, the links written in it, the memories and facts about it and the provider's
|
|
116
|
+
* names of its accounts. The notes and tags beside it are the owner's own, as a note is in `search notes`, so a bare
|
|
117
|
+
* `text` or `title` would mark them too.
|
|
118
|
+
*/
|
|
119
|
+
export const DOCUMENT_CONTEXT_UNTRUSTED = [
|
|
120
|
+
"document.title",
|
|
121
|
+
"document.text",
|
|
122
|
+
"document.path",
|
|
123
|
+
"links.targetText",
|
|
124
|
+
"memories.text",
|
|
125
|
+
"facts.text",
|
|
126
|
+
"people.items.name",
|
|
127
|
+
"people.items.person.name",
|
|
128
|
+
];
|
|
112
129
|
const DECLARED = new WeakMap();
|
|
113
130
|
/** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
|
|
114
131
|
export const marksUntrusted = (command, fields = MESSAGE_UNTRUSTED) => {
|
package/dist/crm/cli/records.js
CHANGED
|
@@ -382,26 +382,33 @@ const addRecordWrites = (group, noun, { within, example, writes }) => {
|
|
|
382
382
|
if (!writes?.kinds.includes(noun.kind))
|
|
383
383
|
return;
|
|
384
384
|
const person = noun.kind === "person";
|
|
385
|
+
const written = writes.fields?.[noun.kind];
|
|
386
|
+
const takes = (field) => !written || written.includes(field);
|
|
385
387
|
const fields = (command) => {
|
|
386
388
|
command.option("--name <name>", person ? "the whole name" : "the company's name");
|
|
387
|
-
if (person)
|
|
389
|
+
if (person) {
|
|
388
390
|
command
|
|
389
391
|
.option("--first-name <name>", "the first name; empty clears it")
|
|
390
|
-
.option("--last-name <name>", "the last name; empty clears it")
|
|
391
|
-
|
|
392
|
+
.option("--last-name <name>", "the last name; empty clears it");
|
|
393
|
+
if (takes("position"))
|
|
394
|
+
command.option("--position <title>", "the job title; empty clears it");
|
|
395
|
+
}
|
|
392
396
|
const repeated = (value, previous = []) => [...previous, value];
|
|
393
|
-
|
|
394
|
-
.option("--email <address>", "an e-mail address to give it; repeat it for more; replaces its list, and an empty one clears it", repeated)
|
|
395
|
-
|
|
396
|
-
"
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
"
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
397
|
+
if (takes("emails"))
|
|
398
|
+
command.option("--email <address>", "an e-mail address to give it; repeat it for more; replaces its list, and an empty one clears it", repeated);
|
|
399
|
+
if (takes("phones"))
|
|
400
|
+
command.option("--phone <phone>", "a phone number to give it, in international form starting with +; repeat it for more; replaces its list, " +
|
|
401
|
+
"and an empty one clears it", repeated);
|
|
402
|
+
if (takes("owner"))
|
|
403
|
+
command.option("--owner <user>", "the CRM user it is assigned to; anyone but the sign-in's own user checks crm.assign-others");
|
|
404
|
+
if (takes("custom"))
|
|
405
|
+
command.option("--field <key=value>", "one of the CRM's own fields, by its code or label as `fields list` prints them, and its value; a list " +
|
|
406
|
+
"field takes its option's label or id; repeat it for more fields, or for each value of a multiple field; " +
|
|
407
|
+
"an empty value clears it", (value, previous = []) => {
|
|
408
|
+
if (value.indexOf("=") < 1)
|
|
409
|
+
throw new CliError("validation_error", "--field takes <key>=<value>");
|
|
410
|
+
return [...previous, value];
|
|
411
|
+
}, []);
|
|
405
412
|
if (writes.idempotent)
|
|
406
413
|
command.option("--operation-id <id>", "the operation_id a write that ended in outcome_unknown named: the CRM answers the repeat from its record");
|
|
407
414
|
return command;
|
|
@@ -33,6 +33,7 @@ const capabilitiesOf = (manifest) => {
|
|
|
33
33
|
verbs: CRM_VERBS.filter((verb) => written.some(({ kind, one }) => takes(kind, one, verb))),
|
|
34
34
|
// No slot sends the operation id, so a repeated write would be made again.
|
|
35
35
|
idempotent: false,
|
|
36
|
+
fields: Object.fromEntries(written.map(({ kind, one }) => [kind, [...Object.keys(one.fields), ...(one.custom ? ["custom"] : [])]])),
|
|
36
37
|
};
|
|
37
38
|
};
|
|
38
39
|
/** What the manifest's writes take, for `addCrmCommands({ writes })`; none when it describes no writes. */
|
package/dist/crm/writer.d.ts
CHANGED
|
@@ -22,6 +22,13 @@ export interface CrmWriteCapabilities {
|
|
|
22
22
|
* Left out, the CLI gets neither, and the writer needs no `createActivity` or `completeActivity`.
|
|
23
23
|
*/
|
|
24
24
|
activities?: readonly CrmActivityWrite[];
|
|
25
|
+
/**
|
|
26
|
+
* The fields a write of each kind takes, in `CrmWriteFields`' names and `custom` for the account's own: the commands
|
|
27
|
+
* offer no flag for another. Left out for a kind, every flag is offered.
|
|
28
|
+
*/
|
|
29
|
+
fields?: {
|
|
30
|
+
readonly [K in CrmKind]?: readonly string[];
|
|
31
|
+
};
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* A deal's or lead's fields in `CrmItem`'s names, each the CRM's own id; `null` clears one. `custom` holds the CRM's
|
package/dist/search/respell.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { type Vocabulary } from "./correct.js";
|
|
2
2
|
/** A Cyrillic word as Latin letters, the way a Latin name is written in Russian («хецнер», «ноксвел» for noxvel). */
|
|
3
3
|
export declare const latinSpellings: (word: string) => string[];
|
|
4
|
+
/**
|
|
5
|
+
* A Latin word as Cyrillic letters, the way a Russian name is typed in Latin («finpoint», «finpoynt» for ФинПоинт).
|
|
6
|
+
* A lone `y` may be и, й or ы, so each is tried, for up to three of them.
|
|
7
|
+
*/
|
|
8
|
+
export declare const cyrillicSpellings: (word: string) => string[];
|
|
4
9
|
/**
|
|
5
10
|
* For each word no message holds, not even as the beginning of a longer one, the words the store does hold that it
|
|
6
|
-
* may stand for: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
7
|
-
* nearest known spellings (up to two edits, as `correctWords` allows). A word
|
|
11
|
+
* may stand for. A Cyrillic word: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
12
|
+
* none, its own nearest known spellings (up to two edits, as `correctWords` allows). A Latin word: its Cyrillic
|
|
13
|
+
* spelling when the store holds it as it is, else its own nearest spellings. A word any message holds is left alone, so a
|
|
8
14
|
* correct word never turns into another.
|
|
9
15
|
*/
|
|
10
16
|
export declare const respelled: (vocabulary: Vocabulary, words: string[]) => Promise<Map<string, string[]>>;
|
package/dist/search/respell.js
CHANGED
|
@@ -40,10 +40,67 @@ export const latinSpellings = (word) => {
|
|
|
40
40
|
const plain = [...normalize(word)].map((letter) => LATIN[letter] ?? letter).join("");
|
|
41
41
|
return [...new Set([plain, plain.replaceAll("ks", "x")])];
|
|
42
42
|
};
|
|
43
|
+
// Longest first, so "shch" is read before "sh" and "s".
|
|
44
|
+
const CYRILLIC = Object.entries({
|
|
45
|
+
shch: "щ",
|
|
46
|
+
sch: "щ",
|
|
47
|
+
zh: "ж",
|
|
48
|
+
kh: "х",
|
|
49
|
+
ts: "ц",
|
|
50
|
+
ch: "ч",
|
|
51
|
+
sh: "ш",
|
|
52
|
+
yu: "ю",
|
|
53
|
+
ya: "я",
|
|
54
|
+
yo: "е",
|
|
55
|
+
y: "ы",
|
|
56
|
+
a: "а",
|
|
57
|
+
b: "б",
|
|
58
|
+
c: "к",
|
|
59
|
+
d: "д",
|
|
60
|
+
e: "е",
|
|
61
|
+
f: "ф",
|
|
62
|
+
g: "г",
|
|
63
|
+
h: "х",
|
|
64
|
+
i: "и",
|
|
65
|
+
j: "дж",
|
|
66
|
+
k: "к",
|
|
67
|
+
l: "л",
|
|
68
|
+
m: "м",
|
|
69
|
+
n: "н",
|
|
70
|
+
o: "о",
|
|
71
|
+
p: "п",
|
|
72
|
+
q: "к",
|
|
73
|
+
r: "р",
|
|
74
|
+
s: "с",
|
|
75
|
+
t: "т",
|
|
76
|
+
u: "у",
|
|
77
|
+
v: "в",
|
|
78
|
+
w: "в",
|
|
79
|
+
x: "кс",
|
|
80
|
+
z: "з",
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* A Latin word as Cyrillic letters, the way a Russian name is typed in Latin («finpoint», «finpoynt» for ФинПоинт).
|
|
84
|
+
* A lone `y` may be и, й or ы, so each is tried, for up to three of them.
|
|
85
|
+
*/
|
|
86
|
+
export const cyrillicSpellings = (word) => {
|
|
87
|
+
const latin = normalize(word);
|
|
88
|
+
if (!/^[a-z]+$/.test(latin) || latin.split("y").length > 4)
|
|
89
|
+
return [];
|
|
90
|
+
let spellings = [""];
|
|
91
|
+
for (let at = 0; at < latin.length;) {
|
|
92
|
+
const [from, to] = CYRILLIC.find(([one]) => latin.startsWith(one, at)) ?? [latin[at], latin[at]];
|
|
93
|
+
const letters = from === "y" ? ["и", "й", "ы"] : [to];
|
|
94
|
+
spellings = spellings.flatMap((start) => letters.map((letter) => start + letter));
|
|
95
|
+
at += from.length;
|
|
96
|
+
}
|
|
97
|
+
return spellings;
|
|
98
|
+
};
|
|
43
99
|
/**
|
|
44
100
|
* For each word no message holds, not even as the beginning of a longer one, the words the store does hold that it
|
|
45
|
-
* may stand for: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
46
|
-
* nearest known spellings (up to two edits, as `correctWords` allows). A word
|
|
101
|
+
* may stand for. A Cyrillic word: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
102
|
+
* none, its own nearest known spellings (up to two edits, as `correctWords` allows). A Latin word: its Cyrillic
|
|
103
|
+
* spelling when the store holds it as it is, else its own nearest spellings. A word any message holds is left alone, so a
|
|
47
104
|
* correct word never turns into another.
|
|
48
105
|
*/
|
|
49
106
|
export const respelled = async (vocabulary, words) => {
|
|
@@ -51,11 +108,19 @@ export const respelled = async (vocabulary, words) => {
|
|
|
51
108
|
const found = new Map();
|
|
52
109
|
for (const word of words.filter((one) => !known.has(one))) {
|
|
53
110
|
const latin = latinSpellings(word);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
111
|
+
if (latin.length) {
|
|
112
|
+
const held = await vocabulary.knownTerms(latin);
|
|
113
|
+
const nearLatin = await correctWords(vocabulary, latin.filter((one) => !held.has(one)));
|
|
114
|
+
const asLatin = [...new Set([...held, ...[...nearLatin.values()].flat()])];
|
|
115
|
+
// A Latin name found in Latin letters says what the word was; its Cyrillic neighbours are then other words.
|
|
116
|
+
const forms = asLatin.length ? asLatin : ((await correctWords(vocabulary, [word])).get(normalize(word)) ?? []);
|
|
117
|
+
if (forms.length)
|
|
118
|
+
found.set(word, forms);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
// Only a Cyrillic word held exactly as typed: one near it is often a translation, not the name («cement», цемент).
|
|
122
|
+
const held = [...(await vocabulary.knownTerms(cyrillicSpellings(word)))];
|
|
123
|
+
const forms = held.length ? held : ((await correctWords(vocabulary, [word])).get(normalize(word)) ?? []);
|
|
59
124
|
if (forms.length)
|
|
60
125
|
found.set(word, forms);
|
|
61
126
|
}
|
|
@@ -244,6 +244,8 @@ export const memoriesStoreOver = (context) => {
|
|
|
244
244
|
}
|
|
245
245
|
return made;
|
|
246
246
|
});
|
|
247
|
+
// A read-only open never builds the index, so a memory added from a CLI would stay unfound by its search.
|
|
248
|
+
drainCorpus(database, CORPORA.memory, stemmerFor);
|
|
247
249
|
return memoryOf(rowOf(`memory:${id}`));
|
|
248
250
|
};
|
|
249
251
|
/** Applies a pending correction; only the owner retires a confirmed memory, whatever `agent_decisions` says. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.745.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",
|