@moxxy/cli 0.48.0 → 0.48.1

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.
Files changed (2) hide show
  1. package/dist/bin.js +189 -23
  2. package/package.json +2 -2
package/dist/bin.js CHANGED
@@ -76018,6 +76018,82 @@ var init_id = __esm({
76018
76018
  }
76019
76019
  });
76020
76020
 
76021
+ // ../chat-model/dist/trim-trailing.js
76022
+ function trimTrailing2(text3, marks) {
76023
+ let end = text3.length;
76024
+ while (end > 0 && marks.has(text3.charAt(end - 1)))
76025
+ end -= 1;
76026
+ return text3.slice(0, end);
76027
+ }
76028
+ var init_trim_trailing = __esm({
76029
+ "../chat-model/dist/trim-trailing.js"() {
76030
+ }
76031
+ });
76032
+
76033
+ // ../chat-model/dist/speech-tables.js
76034
+ function isTableRow(line) {
76035
+ return line !== void 0 && line.includes("|") && line.trim() !== "";
76036
+ }
76037
+ function cells(line) {
76038
+ return line.trim().replace(/^\|/u, "").replace(/\|$/u, "").split("|").map((cell) => cell.trim());
76039
+ }
76040
+ function isSeparatorFor(header, line) {
76041
+ if (line === void 0)
76042
+ return false;
76043
+ const marks = cells(line);
76044
+ return marks.length === cells(header).length && marks.every((mark) => SEPARATOR_CELL.test(mark));
76045
+ }
76046
+ function tableStartsAt(lines, index) {
76047
+ const header = lines[index];
76048
+ return header !== void 0 && isTableRow(header) && isSeparatorFor(header, lines[index + 1]);
76049
+ }
76050
+ function tableLength(lines, index) {
76051
+ let end = index + 2;
76052
+ while (isTableRow(lines[end]))
76053
+ end += 1;
76054
+ return end - index;
76055
+ }
76056
+ function bare(cell) {
76057
+ return trimTrailing2(cell, SENTENCE_PUNCTUATION);
76058
+ }
76059
+ function speakTable(lines) {
76060
+ if (!tableStartsAt(lines, 0))
76061
+ return null;
76062
+ const [header = "", , ...rows] = lines;
76063
+ const names = cells(header);
76064
+ return rows.map((row) => {
76065
+ const [first = "", ...rest] = cells(row).map(bare);
76066
+ const values = rest.map((value2, index) => value2 ? `${names[index + 1] ?? ""} ${value2}`.trim() : "").filter(Boolean);
76067
+ if (!first)
76068
+ return values.length ? `${values.join("; ")}.` : "";
76069
+ return values.length ? `${first}: ${values.join("; ")}.` : `${first}.`;
76070
+ }).filter(Boolean);
76071
+ }
76072
+ function speakMarkdownTables(markdown) {
76073
+ const lines = markdown.split("\n");
76074
+ const out = [];
76075
+ for (let index = 0; index < lines.length; ) {
76076
+ if (!tableStartsAt(lines, index)) {
76077
+ out.push(lines[index] ?? "");
76078
+ index += 1;
76079
+ continue;
76080
+ }
76081
+ const length = tableLength(lines, index);
76082
+ const spoken = speakTable(lines.slice(index, index + length)) ?? [];
76083
+ out.push(...spoken.flatMap((sentence, at) => at === 0 ? [sentence] : ["", sentence]));
76084
+ index += length;
76085
+ }
76086
+ return out.join("\n");
76087
+ }
76088
+ var SEPARATOR_CELL, SENTENCE_PUNCTUATION;
76089
+ var init_speech_tables = __esm({
76090
+ "../chat-model/dist/speech-tables.js"() {
76091
+ init_trim_trailing();
76092
+ SEPARATOR_CELL = /^:?-{3,}:?$/u;
76093
+ SENTENCE_PUNCTUATION = /* @__PURE__ */ new Set([".", ",", ";", ":"]);
76094
+ }
76095
+ });
76096
+
76021
76097
  // ../chat-model/dist/streaming-speech.js
76022
76098
  function detectSpeechLanguage(text3, previous) {
76023
76099
  const lower2 = text3.toLocaleLowerCase();
@@ -76045,6 +76121,7 @@ function detectSpeechLanguage(text3, previous) {
76045
76121
  var POLISH_WORDS, ENGLISH_WORDS, POLISH_DIACRITIC_RE, WORD_RE, ENGLISH_SUFFIX_RE, POLISH_CLUSTER_RE;
76046
76122
  var init_streaming_speech = __esm({
76047
76123
  "../chat-model/dist/streaming-speech.js"() {
76124
+ init_speech_tables();
76048
76125
  POLISH_WORDS = /* @__PURE__ */ new Set([
76049
76126
  "a",
76050
76127
  "aby",
@@ -76256,6 +76333,104 @@ var init_streaming_speech = __esm({
76256
76333
  }
76257
76334
  });
76258
76335
 
76336
+ // ../chat-model/dist/spoken-links.js
76337
+ function hostOf(address) {
76338
+ return address.replace(SCHEME_RE, "").split(/[/?#]/u)[0]?.replace(/:\d+$/u, "") ?? "";
76339
+ }
76340
+ function siteName(address) {
76341
+ const labels = hostOf(address).replace(/^www\./iu, "").split(".").filter(Boolean);
76342
+ if (labels.length === 0 || labels.every((label3) => /^\d+$/u.test(label3)))
76343
+ return null;
76344
+ if (labels.length > 1)
76345
+ labels.pop();
76346
+ if (labels.length > 1 && SECOND_LEVEL_LABELS.has(labels.at(-1)?.toLowerCase() ?? ""))
76347
+ labels.pop();
76348
+ return labels.at(-1) ?? null;
76349
+ }
76350
+ function isWebAddress(value2) {
76351
+ if (SCHEME_RE.test(value2))
76352
+ return true;
76353
+ const host = hostOf(value2);
76354
+ return host.length < value2.length && DOMAIN_RE.test(host);
76355
+ }
76356
+ function isBareDomain(value2) {
76357
+ return DOMAIN_RE.test(value2);
76358
+ }
76359
+ function spokenLink(address, language) {
76360
+ const site = siteName(address);
76361
+ if (language === "pl")
76362
+ return site ? `link do strony ${site}` : "link";
76363
+ return site ? `a link to ${site}` : "a link";
76364
+ }
76365
+ var SECOND_LEVEL_LABELS, SCHEME_RE, DOMAIN_RE;
76366
+ var init_spoken_links = __esm({
76367
+ "../chat-model/dist/spoken-links.js"() {
76368
+ SECOND_LEVEL_LABELS = /* @__PURE__ */ new Set(["ac", "co", "com", "edu", "gov", "net", "org"]);
76369
+ SCHEME_RE = /^[a-z][a-z0-9+.-]*:\/\//iu;
76370
+ DOMAIN_RE = /^(?:www\.)?(?:[a-z0-9-]+\.)+[a-z]{2,}$/iu;
76371
+ }
76372
+ });
76373
+
76374
+ // ../chat-model/dist/speech-text.js
76375
+ function stripNonVerbalArtifacts(text3) {
76376
+ return text3.replace(KEYCAP_EMOJI_RE, " ").replace(NON_VERBAL_SYMBOL_RE, " ").replace(EMOJI_MODIFIER_RE, "").replace(EMOJI_JOINER_RE, "").replace(/\*/g, " ");
76377
+ }
76378
+ function isUrlOrFileReference(value2) {
76379
+ const candidate = trimTrailing2(value2.trim(), TRAILING_PUNCTUATION);
76380
+ return /^(?:https?:\/\/|www\.)/iu.test(candidate) || /^(?:~[\\/]|\.{1,2}[\\/]|[A-Za-z]:[\\/]|\/)/u.test(candidate) || /[\\/][^\\/]+\.[A-Za-z0-9]{2,8}(?::\d+(?::\d+)?)?$/u.test(candidate) || FILE_EXTENSION_RE.test(candidate) || /^(?:[a-z0-9-]+\.)+[a-z]{2,}(?:\/[^\s<>)]*)?$/iu.test(candidate) && !FILE_EXTENSION_RE.test(candidate);
76381
+ }
76382
+ function speakReference(value2, language) {
76383
+ const trimmed = value2.trim();
76384
+ const reference = trimTrailing2(trimmed, TRAILING_PUNCTUATION);
76385
+ const after = trimmed.slice(reference.length);
76386
+ if (isWebAddress(reference))
76387
+ return `${spokenLink(reference, language)}${after}`;
76388
+ if (isBareDomain(reference) && !FILE_EXTENSION_RE.test(reference))
76389
+ return `${siteName(reference) ?? " "}${after}`;
76390
+ return isUrlOrFileReference(reference) ? " " : value2;
76391
+ }
76392
+ function proseLanguage(markdown) {
76393
+ return detectSpeechLanguage(markdown.replace(/\([^()]*\)|<[^<>]*>/gu, " ").replace(WEB_ADDRESS_RE, " "));
76394
+ }
76395
+ function normalizeSpeakableMarkdown(markdown, fencedCodeReplacement) {
76396
+ const language = proseLanguage(markdown);
76397
+ const stripped = speakMarkdownTables(markdown).replace(/```[\s\S]*?```/g, fencedCodeReplacement).replace(/~~~[\s\S]*?~~~/g, fencedCodeReplacement).replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm, " ").replace(/!\[([^\]]*)\]\([^)]*\)/g, (_match, label3) => speakReference(label3, language)).replace(/\[([^\]]+)\]\([^)]*\)/g, (_match, label3) => speakReference(label3, language)).replace(/\[([^\]]+)\]\s*\[[^\]]*\]/g, (_match, label3) => speakReference(label3, language)).replace(/<(https?:\/\/[^>]+)>/giu, (_match, address) => spokenLink(address, language)).replace(WEB_ADDRESS_RE, (address) => speakReference(address, language)).replace(/`([^`]+)`/g, (_match, code) => speakReference(code, language)).replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/__([^_]+)__/g, "$1").replace(/(^|[^a-zA-Z0-9])_([^_]+)_(?![a-zA-Z0-9])/g, "$1$2").replace(/~~([^~]+)~~/g, "$1").replace(/^\s{0,3}#{1,6}\s+/gm, "").replace(/^\s*>\s?/gm, "").replace(/^\s*[-*+]\s+/gm, "").replace(/^\s*\d+[.)]\s+/gm, "").replace(/^\s*([-*_])\1{2,}\s*$/gm, "").replace(/\|/g, " ");
76398
+ const withoutPaths = stripped.replace(ABSOLUTE_FILE_PATH_RE, " ").replace(FILE_PATH_RE, (match) => {
76399
+ if (SLASHED_PROSE_RE.test(match))
76400
+ return match;
76401
+ return isWebAddress(match) ? speakReference(match, language) : " ";
76402
+ }).replace(DOMAIN_RE2, (match, offset, whole) => FILE_EXTENSION_RE.test(match) || DOTTED_PROSE_RE.test(match) || whole[offset - 1] === "@" ? match : speakReference(match, language));
76403
+ return stripNonVerbalArtifacts(withoutPaths).split(/\n{2,}/).map((p3) => p3.replace(/\s+/g, " ").trim()).filter(Boolean).map((p3) => /[.!?:]$/.test(p3) ? p3 : `${p3}.`).join(" ").replace(/\s+([.!?])/gu, "$1").replace(/\s+([,;:!?])/gu, "$1").replace(/([,;:])\s*[.!?]/gu, ".").replace(/([,;:])(?:\s*[,;:])+/gu, "$1").replace(/\s{2,}/g, " ").trim();
76404
+ }
76405
+ function toSpeakableText(markdown) {
76406
+ return normalizeSpeakableMarkdown(markdown, " (code block) ");
76407
+ }
76408
+ function toVoiceConversationText(markdown) {
76409
+ const withoutCode = markdown.replace(/```[\s\S]*?```/g, " ").replace(/~~~[\s\S]*?~~~/g, " ").replace(/```[\s\S]*$/g, " ").replace(/~~~[\s\S]*$/g, " ").replace(/^(?: {4}|\t).*(?:\n|$)/gm, " ");
76410
+ return normalizeSpeakableMarkdown(withoutCode, " ");
76411
+ }
76412
+ var KEYCAP_EMOJI_RE, NON_VERBAL_SYMBOL_RE, EMOJI_MODIFIER_RE, EMOJI_JOINER_RE, DOMAIN_RE2, FILE_EXTENSION_RE, ABSOLUTE_FILE_PATH_RE, FILE_PATH_RE, DOTTED_PROSE_RE, SLASHED_PROSE_RE, TRAILING_PUNCTUATION, WEB_ADDRESS_RE;
76413
+ var init_speech_text = __esm({
76414
+ "../chat-model/dist/speech-text.js"() {
76415
+ init_speech_tables();
76416
+ init_spoken_links();
76417
+ init_streaming_speech();
76418
+ init_trim_trailing();
76419
+ KEYCAP_EMOJI_RE = /[#*0-9]\uFE0F?\u20E3/gu;
76420
+ NON_VERBAL_SYMBOL_RE = new RegExp("(?!\xB0)\\p{So}", "gu");
76421
+ EMOJI_MODIFIER_RE = new RegExp("\\p{Emoji_Modifier}", "gu");
76422
+ EMOJI_JOINER_RE = /(?:\uFE0E|\uFE0F|\u200D|[\u{E0020}-\u{E007F}])/gu;
76423
+ DOMAIN_RE2 = /\b(?:[a-z0-9-]+\.)+[a-z]{2,}(?:\/[^\s<>)]*)?/giu;
76424
+ FILE_EXTENSION_RE = /\.(?:js|jsx|ts|tsx|mjs|cjs|json|jsonl|ya?ml|toml|md|mdx|txt|log|pdf|docx|xlsx|pptx|csv|tsv|py|rs|go|java|kt|c|h|cpp|hpp|cs|php|sh|bash|zsh|sql|html|css|scss|xml|ini|env|conf|png|jpe?g|svg|webp|wav|mp3|ogg)(?::\d+(?::\d+)?)?$/iu;
76425
+ ABSOLUTE_FILE_PATH_RE = /(?<![\p{L}\p{N}_])(?:~[\\/]|[A-Za-z]:[\\/]|\/)[^<>\r\n`"'()[\],;!?]*?\.[A-Za-z]{2,8}(?::\d+(?::\d+)?)?(?=$|[\s),;.!?])/gu;
76426
+ FILE_PATH_RE = /(?<![\p{L}\p{N}_])(?:~[\\/]|\.{1,2}[\\/]|[A-Za-z]:[\\/]|\/)?(?:[\p{L}\p{N}_.@+-]+[\\/])+[\p{L}\p{N}_.@+-]+(?:\.[A-Za-z0-9]{2,8})?(?::\d+(?::\d+)?)?(?![\p{L}\p{N}_])/gu;
76427
+ DOTTED_PROSE_RE = /^m\.in$/iu;
76428
+ SLASHED_PROSE_RE = new RegExp("^(?:\\d+(?:[.,]\\d+)?(?:\\/\\d+(?:[.,]\\d+)?)+|(?:k?m|mi|[kKMG][bB])\\/(?:h|s|min)|\\p{Lu}{1,5}\\/\\p{Lu}{1,5}|and\\/or|i\\/lub)[.,;:!?]?$", "u");
76429
+ TRAILING_PUNCTUATION = /* @__PURE__ */ new Set([")", ",", ".", ";", ":", "!", "?"]);
76430
+ WEB_ADDRESS_RE = /\b(?:https?:\/\/|www\.)[^\s<>()[\]`]+/giu;
76431
+ }
76432
+ });
76433
+
76259
76434
  // ../chat-model/dist/voice-operations.js
76260
76435
  var init_voice_operations = __esm({
76261
76436
  "../chat-model/dist/voice-operations.js"() {
@@ -76373,6 +76548,8 @@ var init_dist24 = __esm({
76373
76548
  init_log2();
76374
76549
  init_id();
76375
76550
  init_streaming_speech();
76551
+ init_speech_tables();
76552
+ init_speech_text();
76376
76553
  init_voice_feedback_scheduler();
76377
76554
  init_voice_operations();
76378
76555
  init_account_limit();
@@ -76424,12 +76601,12 @@ function parseBlocks(src) {
76424
76601
  assertDefined4(row, "line index within bounds");
76425
76602
  if (!row.trim().startsWith("|"))
76426
76603
  break;
76427
- const cells = parseTableCells(row);
76428
- if (cells.length === 0)
76604
+ const cells2 = parseTableCells(row);
76605
+ if (cells2.length === 0)
76429
76606
  break;
76430
- while (cells.length < header.length)
76431
- cells.push("");
76432
- rows.push(cells.slice(0, header.length));
76607
+ while (cells2.length < header.length)
76608
+ cells2.push("");
76609
+ rows.push(cells2.slice(0, header.length));
76433
76610
  i2++;
76434
76611
  }
76435
76612
  blocks.push({ kind: "table", header, aligns, rows });
@@ -76558,8 +76735,8 @@ function parseTableCells(line) {
76558
76735
  return stripOuterPipes(line).split("|").map((s) => s.trim());
76559
76736
  }
76560
76737
  function parseTableAligns(sep8) {
76561
- const cells = stripOuterPipes(sep8).split("|");
76562
- return cells.map((c3) => {
76738
+ const cells2 = stripOuterPipes(sep8).split("|");
76739
+ return cells2.map((c3) => {
76563
76740
  const t2 = c3.trim();
76564
76741
  const left = t2.startsWith(":");
76565
76742
  const right = t2.endsWith(":");
@@ -76822,8 +76999,8 @@ var init_table = __esm({
76822
76999
  const aligns = block2.header.map((_2, ci) => block2.aligns[ci] ?? "left");
76823
77000
  return (0, import_jsx_runtime10.jsxs)(Box_default, { flexDirection: "column", marginTop: suppressTopMargin ? 0 : 1, children: [(0, import_jsx_runtime10.jsx)(TableRow, { cells: block2.header, widths, aligns, bold: true }), (0, import_jsx_runtime10.jsx)(TableRule, { widths }), block2.rows.map((row, i2) => (0, import_jsx_runtime10.jsx)(TableRow, { cells: row, widths, aligns }, i2))] });
76824
77001
  };
76825
- TableRow = ({ cells, widths, aligns, bold }) => (0, import_jsx_runtime10.jsx)(Box_default, { children: widths.map((w, ci) => {
76826
- const text3 = padCell(cells[ci] ?? "", w, aligns[ci] ?? "left");
77002
+ TableRow = ({ cells: cells2, widths, aligns, bold }) => (0, import_jsx_runtime10.jsx)(Box_default, { children: widths.map((w, ci) => {
77003
+ const text3 = padCell(cells2[ci] ?? "", w, aligns[ci] ?? "left");
76827
77004
  return (0, import_jsx_runtime10.jsxs)(import_react31.default.Fragment, { children: [ci > 0 ? (0, import_jsx_runtime10.jsx)(Text, { dimColor: true, children: " \u2502 " }) : null, (0, import_jsx_runtime10.jsx)(Box_default, { width: w, flexShrink: 0, children: (0, import_jsx_runtime10.jsx)(Text, { bold, color: "white", wrap: "truncate", children: text3 }) })] }, ci);
76828
77005
  }) });
76829
77006
  TableRule = ({ widths }) => (0, import_jsx_runtime10.jsx)(Text, { dimColor: true, children: widths.map((w) => "\u2500".repeat(w)).join("\u2500\u253C\u2500") });
@@ -79167,19 +79344,7 @@ var init_dedupe2 = __esm({
79167
79344
  }
79168
79345
  });
79169
79346
  function toSpeech(markdown) {
79170
- let t2 = markdown ?? "";
79171
- t2 = t2.replace(/```[\s\S]*?```/g, " (code omitted) ");
79172
- t2 = t2.replace(/```[\s\S]*$/g, " (code omitted) ");
79173
- t2 = t2.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1");
79174
- t2 = t2.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1");
79175
- t2 = t2.replace(/`([^`]+)`/g, "$1");
79176
- t2 = t2.replace(/(\*\*|__|~~|\*|_)/g, "");
79177
- t2 = t2.replace(/^\s{0,3}#{1,6}\s*/gm, "");
79178
- t2 = t2.replace(/^\s{0,3}>\s?/gm, "");
79179
- t2 = t2.replace(/^\s{0,3}[-*+]\s+/gm, "");
79180
- t2 = t2.replace(/[ \t]+/g, " ");
79181
- t2 = t2.replace(/\n{3,}/g, "\n\n");
79182
- return t2.trim();
79347
+ return toSpeakableText(markdown ?? "");
79183
79348
  }
79184
79349
  function truncateForSpeech(text3, max) {
79185
79350
  if (text3.length <= max)
@@ -79199,7 +79364,8 @@ async function synthesizeReply(session, text3, opts = {}) {
79199
79364
  }
79200
79365
  if (!synth)
79201
79366
  return { ok: false, reason: "no-synthesizer" };
79202
- const speech = truncateForSpeech(toSpeech(text3), opts.maxChars ?? DEFAULT_MAX_SPEECH_CHARS);
79367
+ const spoken = opts.conversation ? toVoiceConversationText(text3 ?? "") : toSpeech(text3);
79368
+ const speech = truncateForSpeech(spoken, opts.maxChars ?? DEFAULT_MAX_SPEECH_CHARS);
79203
79369
  if (!speech)
79204
79370
  return { ok: false, reason: "empty" };
79205
79371
  const synthOpts = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxxy/cli",
3
- "version": "0.48.0",
3
+ "version": "0.48.1",
4
4
  "description": "moxxy command-line agent: TUI, one-shot prompts, setup, services, and API-key or installed-CLI subscription providers.",
5
5
  "keywords": [
6
6
  "moxxy",
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "undici": "^8.12.2",
51
51
  "zod": "^4.6.6",
52
- "@moxxy/sdk": "0.48.0"
52
+ "@moxxy/sdk": "0.48.1"
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "@napi-rs/keyring": "^2.1.0"