@iola_adm/iola-cli 0.2.41 → 0.2.42

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/package.json +1 -1
  2. package/src/cli.js +28 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iola_adm/iola-cli",
3
- "version": "0.2.41",
3
+ "version": "0.2.42",
4
4
  "description": "CLI и AI-агент городского округа Йошкар-Ола.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/adm-iola/iola-cli#readme",
package/src/cli.js CHANGED
@@ -3832,12 +3832,18 @@ function isAmbiguousPersonalYandexGoPoint(query) {
3832
3832
  function normalizeYandexGoGeocoderQuery(query) {
3833
3833
  const text = String(query || "").trim();
3834
3834
  const lower = text.toLocaleLowerCase("ru-RU");
3835
- if (/администрац/iu.test(lower) && /(йошкар|иошкар|йошк|yoshkar|yoshkar-ola)/iu.test(lower)) {
3835
+ if (/администрац/iu.test(lower) && /(медведевск|медведево)/iu.test(lower)) {
3836
+ return "Россия, Республика Марий Эл, Медведево, Советская улица, 20";
3837
+ }
3838
+ if (/(администрац|мэри)/iu.test(lower) && /(йошкар|иошкар|йошк|yoshkar|yoshkar-ola)/iu.test(lower)) {
3836
3839
  return "Россия, Республика Марий Эл, Йошкар-Ола, Ленинский проспект, 27";
3837
3840
  }
3838
3841
  if (/^(?:администрац(?:ия|ии)?|мэрия)$/iu.test(lower)) {
3839
3842
  return "Россия, Республика Марий Эл, Йошкар-Ола, Ленинский проспект, 27";
3840
3843
  }
3844
+ if (/^(?:пгт\s+)?медведево\s+.+/iu.test(lower) && !/(ул\.|улица)/iu.test(lower)) {
3845
+ return `Россия, Республика Марий Эл, Медведево, ${text.replace(/^(?:пгт\s+)?медведево\s+/iu, "")}`;
3846
+ }
3841
3847
  if (!/(йошкар|медведево|сем[её]новк|республика\s+марий\s+эл|марий\s+эл)/iu.test(lower)
3842
3848
  && /(администрац|мэрия|школ|сад|лицей|гимназ|ул\.|улица|проспект|пр-т|бульвар|переулок|дом|д\.|\d)/iu.test(lower)) {
3843
3849
  return `Россия, Республика Марий Эл, Йошкар-Ола, ${text}`;
@@ -3918,7 +3924,7 @@ function formatYandexGoDeeplinkResult(result) {
3918
3924
  ].join("\n");
3919
3925
  }
3920
3926
 
3921
- function extractYandexGoRouteFromText(text) {
3927
+ function extractYandexGoRouteFromText(text, previousText = "") {
3922
3928
  const source = String(text || "").trim();
3923
3929
  const tariffMatch = source.match(/(эконом|комфорт\+?|комфорт плюс|бизнес|минивен|детск\w*|econom|business|comfortplus|minivan|vip)/iu);
3924
3930
  const cleaned = source
@@ -3929,7 +3935,18 @@ function extractYandexGoRouteFromText(text) {
3929
3935
  .trim();
3930
3936
  const match = cleaned.match(/(?:от|из|с)\s+(.+?)\s+(?:до|в|на)\s+(.+)$/iu)
3931
3937
  || cleaned.match(/^(.+?)\s*,?\s+(?:до|в)\s+(.+)$/iu);
3932
- if (!match) return { from: "", to: "", tariff: tariffMatch ? normalizeYandexGoTariff(tariffMatch[1]) : "econom" };
3938
+ if (!match) {
3939
+ const partialFrom = cleaned.match(/(?:^|\s)(?:от|из|с)\s+(.+)$/iu)?.[1]?.trim() || "";
3940
+ const previousRoute = previousText ? extractYandexGoRouteFromText(previousText, "") : { from: "", to: "" };
3941
+ if (partialFrom && previousRoute.to) {
3942
+ return { from: partialFrom.replace(/[,.;]\s*$/u, "").trim(), to: previousRoute.to, tariff: tariffMatch ? normalizeYandexGoTariff(tariffMatch[1]) : "econom" };
3943
+ }
3944
+ const partialTo = cleaned.match(/(?:^|\s)(?:до|в)\s+(.+)$/iu)?.[1]?.trim() || "";
3945
+ if (partialTo && previousRoute.from && !isAmbiguousPersonalYandexGoPoint(previousRoute.from)) {
3946
+ return { from: previousRoute.from, to: partialTo.replace(/[,.;]\s*$/u, "").trim(), tariff: tariffMatch ? normalizeYandexGoTariff(tariffMatch[1]) : "econom" };
3947
+ }
3948
+ return { from: "", to: "", tariff: tariffMatch ? normalizeYandexGoTariff(tariffMatch[1]) : "econom" };
3949
+ }
3933
3950
  const from = match[1].replace(/[,.;]\s*$/u, "").trim();
3934
3951
  const to = match[2].replace(/[,.;]\s*(?:тариф|эконом|комфорт\+?|комфорт плюс|бизнес|минивен|детск\w*).*$/iu, "").trim();
3935
3952
  return { from, to, tariff: tariffMatch ? normalizeYandexGoTariff(tariffMatch[1]) : "econom" };
@@ -12547,9 +12564,12 @@ async function buildDirectDataAnswer(question, dataContext) {
12547
12564
  async function buildYandexDirectAnswer(question, history = []) {
12548
12565
  const normalized = String(question || "").toLocaleLowerCase("ru-RU");
12549
12566
  const previousAssistantText = [...(history || [])].reverse().find((item) => item.role === "assistant")?.content || "";
12567
+ const previousUserText = [...(history || [])].reverse().find((item) => item.role === "user")?.content || "";
12550
12568
  const mailContext = /Яндекс Почта|Письмо #|\bUID\b|#\d{3,}/iu.test(previousAssistantText);
12551
12569
  const mailFollowup = mailContext && isYandexMailFollowupQuestion(normalized, question);
12552
- if (!isYandexServiceQuestion(normalized) && !mailFollowup) return "";
12570
+ const goContext = /(?:Ссылка Яндекс Go|Для ссылки Яндекс Go|Не знаю адрес|Геокодер вернул|Укажите полный адрес отправления)/iu.test(previousAssistantText);
12571
+ const goFollowup = goContext && /(?:^|\s)(?:от|из|с|до|в)\s+/iu.test(normalized);
12572
+ if (!isYandexServiceQuestion(normalized) && !mailFollowup && !goFollowup) return "";
12553
12573
  try {
12554
12574
  if (mailFollowup && (isYandexMailReadRequest(normalized) || isYandexMailSelectionQuestion(question))) {
12555
12575
  const uid = resolveYandexMailUidFromQuestion(question, previousAssistantText)
@@ -12569,9 +12589,10 @@ async function buildYandexDirectAnswer(question, history = []) {
12569
12589
  ].join("\n");
12570
12590
  }
12571
12591
 
12572
- if (/(яндекс\s*go|яндекс\s*го|такси|deeplink|диплинк|ссылк.*маршрут)/iu.test(normalized)
12573
- && /(маршрут|ссылк|откуда|куда|поездк|такси|от\s+.+\s+до\s+)/iu.test(normalized)) {
12574
- const route = extractYandexGoRouteFromText(question);
12592
+ if (goFollowup
12593
+ || (/(яндекс\s*go|яндекс\s*го|такси|deeplink|диплинк|ссылк.*маршрут)/iu.test(normalized)
12594
+ && /(маршрут|ссылк|откуда|куда|поездк|такси|от\s+.+\s+до\s+)/iu.test(normalized))) {
12595
+ const route = extractYandexGoRouteFromText(question, previousUserText);
12575
12596
  if (!route.from || !route.to) {
12576
12597
  return 'Для ссылки Яндекс Go нужны два адреса. Пример: "такси от Медведево, Школьная 15 до Медведево, Советская 20".';
12577
12598
  }