@wirecat/cli-memo 0.48.0 → 0.49.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/dist/doctor/command.d.ts +1 -1
- package/dist/mail/messages-command.d.ts +12 -0
- package/dist/mail/messages-command.d.ts.map +1 -1
- package/dist/mail/messages-command.js +46 -4
- package/dist/mail/messages-command.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/dist/doctor/command.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { type Streams } from "@wirecat/cli-base";
|
|
2
|
+
import { readMail } from "@wirecat/cli-core/services";
|
|
2
3
|
import type { Command } from "commander";
|
|
4
|
+
/** Enough for a bill's amounts and dates; `--full` gives the rest. */
|
|
5
|
+
export declare const ATTACHMENT_CHARS = 4000;
|
|
6
|
+
type Shown = Awaited<ReturnType<typeof readMail>>[number];
|
|
7
|
+
interface StoredFile {
|
|
8
|
+
text: string | null;
|
|
9
|
+
extraction: string | null;
|
|
10
|
+
extractionError: string | null;
|
|
11
|
+
}
|
|
12
|
+
/** The extracted text of each attachment, next to the name the email lists; a file without text says why. */
|
|
13
|
+
export declare const withAttachmentText: (hit: Shown, files: readonly StoredFile[], full: boolean) => Shown;
|
|
3
14
|
export declare const messagesCommand: (program: Command, streams: Streams, env: NodeJS.ProcessEnv) => void;
|
|
15
|
+
export {};
|
|
4
16
|
//# sourceMappingURL=messages-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-command.d.ts","sourceRoot":"","sources":["../../src/mail/messages-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"messages-command.d.ts","sourceRoot":"","sources":["../../src/mail/messages-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMxC,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC,KAAK,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzD,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AAED,6GAA6G;AAC7G,eAAO,MAAM,kBAAkB,QAAS,KAAK,SAAS,SAAS,UAAU,EAAE,QAAQ,OAAO,KAAG,KAc3F,CAAA;AAaF,eAAO,MAAM,eAAe,YAAa,OAAO,WAAW,OAAO,OAAO,MAAM,CAAC,UAAU,KAAG,IAmC5F,CAAA"}
|
|
@@ -5,23 +5,65 @@ import { answers, itemAnswer, wholeList, withStore } from "../answer.js";
|
|
|
5
5
|
import { whole } from "../options.js";
|
|
6
6
|
import { atDetail } from "../output.js";
|
|
7
7
|
import { found } from "../search/command.js";
|
|
8
|
+
/** Enough for a bill's amounts and dates; `--full` gives the rest. */
|
|
9
|
+
export const ATTACHMENT_CHARS = 4000;
|
|
10
|
+
/** The extracted text of each attachment, next to the name the email lists; a file without text says why. */
|
|
11
|
+
export const withAttachmentText = (hit, files, full) => ({
|
|
12
|
+
...hit,
|
|
13
|
+
attachments: (hit.attachments ?? []).map((attachment, at) => {
|
|
14
|
+
const file = files[at];
|
|
15
|
+
const text = file?.text ?? "";
|
|
16
|
+
if (!text)
|
|
17
|
+
return { ...attachment, extraction: file?.extractionError ?? file?.extraction ?? "none" };
|
|
18
|
+
const cut = !full && text.length > ATTACHMENT_CHARS;
|
|
19
|
+
return {
|
|
20
|
+
...attachment,
|
|
21
|
+
text: cut ? text.slice(0, ATTACHMENT_CHARS) : text,
|
|
22
|
+
text_chars: text.length,
|
|
23
|
+
...(cut ? { text_cut: true } : {}),
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
const attachmentText = (hit) => (hit.attachments ?? [])
|
|
28
|
+
.map((attachment) => {
|
|
29
|
+
const file = attachment;
|
|
30
|
+
const name = file.name ?? file.kind;
|
|
31
|
+
if (file.text === undefined)
|
|
32
|
+
return ` ── attachment ${name}: no text (${file.extraction}) ──`;
|
|
33
|
+
const cut = file.text.length < (file.text_chars ?? 0) ? `, first ${file.text.length} of ${file.text_chars}` : "";
|
|
34
|
+
return ` ── attachment ${name} (${file.text_chars} characters${cut}) ──\n ${file.text.replace(/\n/g, "\n ")}`;
|
|
35
|
+
})
|
|
36
|
+
.join("\n");
|
|
8
37
|
export const messagesCommand = (program, streams, env) => {
|
|
9
38
|
const { print } = answers(program, streams, env);
|
|
10
39
|
const messages = program.command("messages").description("stored emails; tg and max read messenger messages");
|
|
11
40
|
messages
|
|
12
41
|
.command("show")
|
|
13
|
-
.description("one stored email
|
|
42
|
+
.description("one stored email whole, with its attachments' text and nearby thread emails")
|
|
14
43
|
.argument("<message>", "the email's msg:email/… reference, as search answers give it")
|
|
15
44
|
.option("--before-n <n>", "also this many earlier emails of its thread", whole, 0)
|
|
16
45
|
.option("--after-n <n>", "also this many later emails of its thread", whole, 0)
|
|
46
|
+
.option("--full", `whole attachment text, not the first ${ATTACHMENT_CHARS} characters of each`)
|
|
17
47
|
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
18
48
|
.action(async (reference, options) => {
|
|
19
|
-
|
|
49
|
+
const locator = parseLocator(reference);
|
|
50
|
+
if (locator.provider !== "email")
|
|
20
51
|
throw new CliError("validation_error", `${reference} is not an email; tg and max show messenger messages`);
|
|
21
|
-
const emails = await withStore(env, (store) =>
|
|
52
|
+
const emails = await withStore(env, async (store) => {
|
|
53
|
+
const shown = await readMail(store, reference, { before: options.beforeN, after: options.afterN });
|
|
54
|
+
const account = await store.storedAccount({ provider: "email", account: locator.account });
|
|
55
|
+
if (!account)
|
|
56
|
+
return shown;
|
|
57
|
+
return Promise.all(shown.map(async (hit) => {
|
|
58
|
+
if (!hit.attachments?.length)
|
|
59
|
+
return hit;
|
|
60
|
+
const email = await store.mail.email(account.id, hit.id);
|
|
61
|
+
return withAttachmentText(hit, email?.attachments ?? [], options.full === true);
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
22
64
|
print(options.json, options.beforeN || options.afterN
|
|
23
65
|
? wholeList("messages show", atDetail(emails))
|
|
24
|
-
: itemAnswer(atDetail(emails[0])), emails.map((email) => found(email, "full")).join("\n\n"));
|
|
66
|
+
: itemAnswer(atDetail(emails[0])), emails.map((email) => [found(email, "full"), attachmentText(email)].filter(Boolean).join("\n")).join("\n\n"));
|
|
25
67
|
});
|
|
26
68
|
};
|
|
27
69
|
//# sourceMappingURL=messages-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-command.js","sourceRoot":"","sources":["../../src/mail/messages-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,OAAgB,EAAE,GAAsB,EAAQ,EAAE;IAClG,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,OAAO,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AE,OAAO,KAAK,CAAA;YAC1B,OAAO,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBACtB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM;oBAAE,OAAO,GAAG,CAAA;gBACxC,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;gBACxD,OAAO,kBAAkB,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,IAAI,EAAE,EAAE,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;YACjF,CAAC,CAAC,CACH,CAAA;QACH,CAAC,CAAC,CAAA;QACF,KAAK,CACH,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM;YAC/B,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EACnC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAC7G,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC,CAAA"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.49.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.49.0";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-memo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "Context about people across messengers, notes and mail, from a local store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@modelcontextprotocol/server": "2.1.0",
|
|
49
49
|
"@valibot/to-json-schema": "1.8.0",
|
|
50
|
-
"@wirecat/cli-base": "0.
|
|
51
|
-
"@wirecat/cli-core": "0.
|
|
50
|
+
"@wirecat/cli-base": "0.40.0",
|
|
51
|
+
"@wirecat/cli-core": "0.295.0",
|
|
52
52
|
"commander": "15.0.0",
|
|
53
53
|
"disposable-email-domains-js": "1.26.0",
|
|
54
54
|
"postal-mime": "4.0.0",
|