@wirecat/cli-core 0.612.0 → 0.613.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 +35 -0
- package/dist/background/report/render.d.ts +10 -1
- package/dist/background/report/render.js +20 -7
- package/dist/background/report/schema.d.ts +37 -0
- package/dist/background/report/schema.js +98 -4
- package/dist/background/report/templates/morning-digest.email.en.liquid +49 -8
- package/dist/background/report/templates/morning-digest.email.ru.liquid +49 -8
- package/dist/background/report/templates/morning-digest.telegram.en.liquid +49 -9
- package/dist/background/report/templates/morning-digest.telegram.ru.liquid +49 -9
- package/dist/background/report/templates/morning-digest.text.en.liquid +49 -9
- package/dist/background/report/templates/morning-digest.text.ru.liquid +49 -9
- package/dist/background/report/view.d.ts +34 -3
- package/dist/background/report/view.js +59 -5
- package/dist/background/schedules.js +19 -3
- package/dist/domain/links.d.ts +72 -0
- package/dist/domain/links.js +139 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/metadata.d.ts +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
|
|
|
10
10
|
{%- if summary %}{{ nl }}{{ summary }}{% endif -%}
|
|
11
11
|
{%- if quiet -%}
|
|
12
12
|
{{ nl }}{{ nl }}
|
|
13
|
-
{%- if health.items.size > 0 %}Новых дел нет, но
|
|
13
|
+
{%- if health.items.size > 0 %}Новых дел нет, но синхронизация требует внимания.
|
|
14
14
|
{%- else %}Тихое утро: ничего срочного.{% endif -%}
|
|
15
15
|
{%- endif -%}
|
|
16
16
|
{%- for section in sections -%}
|
|
@@ -35,7 +35,7 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
|
|
|
35
35
|
{%- case item.type -%}
|
|
36
36
|
{%- when "reply" %}<b>{{ item.who }} · {{ item.topic }}</b> — {{ item.action }}
|
|
37
37
|
{%- when "question" %}<b>{{ item.who }}</b> спрашивает: {{ item.action }}
|
|
38
|
-
{%- when "task" %}<b>{{ item.topic }}</b> — {{ due }}
|
|
38
|
+
{%- when "task" %}<b>{{ item.topic }}</b>{% if due != "" %} — {{ due }}{% elsif item.who %} — {{ item.who }}{% endif %}
|
|
39
39
|
{%- when "fact" %}<b>{{ item.topic }}</b>: {{ item.detail }}
|
|
40
40
|
{%- when "risk" %}<b>{{ item.topic }}</b>: {{ item.detail }} → {{ item.action }}
|
|
41
41
|
{%- when "money" %}<b>{{ item.amount.text }} · {{ item.who }} · {{ item.topic }}</b>{% if item.action %} — {{ item.action }}{% endif %}
|
|
@@ -53,7 +53,8 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
|
|
|
53
53
|
{%- if due != "" and "risk,money,decision" contains item.type %}{{ sep }}{{ due }}{% assign sep = " · " %}{% endif -%}
|
|
54
54
|
{%- if item.action and "task,meeting" contains item.type %}{{ sep }}{{ item.action }}{% assign sep = " · " %}{% endif -%}
|
|
55
55
|
{%- if item.detail and "task,money,meeting,decision" contains item.type %}{{ sep }}{{ item.detail }}{% assign sep = " · " %}{% endif -%}
|
|
56
|
-
{%- if item.who and "
|
|
56
|
+
{%- if item.who and "fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
|
|
57
|
+
{%- if item.who and item.type == "task" and due != "" %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
|
|
57
58
|
{%- if item.channel %}{{ sep }}
|
|
58
59
|
{%- case item.channel -%}
|
|
59
60
|
{%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
|
|
@@ -67,11 +68,50 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
|
|
|
67
68
|
{%- if second != "" %}{{ nl }}{{ second }}{% endif -%}
|
|
68
69
|
{%- endfor -%}
|
|
69
70
|
{%- if section.more > 0 %}{{ nl }}ещё {{ section.more }}{% endif -%}
|
|
71
|
+
{%- if section.groups.size > 0 %}{{ nl }}
|
|
72
|
+
{%- for group in section.groups -%}
|
|
73
|
+
{%- unless forloop.first %} · {% endunless -%}
|
|
74
|
+
{%- capture words -%}
|
|
75
|
+
{%- case group.filter -%}
|
|
76
|
+
{%- when "overdue" %}Все просроченные
|
|
77
|
+
{%- when "today" %}{% if forloop.first %}На сегодня{% else %}на сегодня{% endif %}
|
|
78
|
+
{%- when "tomorrow" %}{% if forloop.first %}На завтра{% else %}на завтра{% endif %}
|
|
79
|
+
{%- when "new" %}{% if forloop.first %}Новые{% else %}новые{% endif %}
|
|
80
|
+
{%- endcase %} ({{ group.count }})
|
|
81
|
+
{%- endcapture -%}
|
|
82
|
+
{%- if group.link %}<a href="{{ group.link.url }}">{{ words }}</a>{% else %}{{ words }}{% endif -%}
|
|
83
|
+
{%- endfor -%}
|
|
84
|
+
{%- endif -%}
|
|
70
85
|
{%- endfor -%}
|
|
71
|
-
{%-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
{%- if health.items.size > 0 %}{{ nl }}{% endif -%}
|
|
87
|
+
{%- for source in health.items -%}
|
|
88
|
+
{{ nl }}{{ health.emoji }} {{ source.source }}
|
|
89
|
+
{%- if source.account %} ({{ source.account }}){% endif -%}
|
|
90
|
+
{%- case source.reason -%}
|
|
91
|
+
{%- when "sync-failed" %}: синхронизация падает{% if source.since %} с {{ source.since.date }}{% endif %}
|
|
92
|
+
{%- when "no-schedule" %}: нет расписания синхронизации
|
|
93
|
+
{%- when "quiet" %}: ничего нового {% if source.since %}с {{ source.since.date }}{% else %}{{ source.span }}{% endif %}
|
|
94
|
+
{%- else %} не обновлялся {{ source.span }}
|
|
95
|
+
{%- endcase -%}
|
|
96
|
+
{%- for link in source.links %} · <a href="{{ link.url }}">{{ link.label }}</a>{% endfor -%}
|
|
97
|
+
{%- endfor -%}
|
|
98
|
+
{%- if scope -%}
|
|
99
|
+
{{ nl }}{{ nl }}Просмотрено за {{ scope.window }}
|
|
100
|
+
{%- for source in scope.sources -%}
|
|
101
|
+
{%- if forloop.first %}: {% else %}, {% endif -%}
|
|
102
|
+
{%- case source.kind -%}
|
|
103
|
+
{%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
|
|
104
|
+
{%- when "mail" %}почта{% when "meeting" %}встречи{% when "task" %}задачи
|
|
105
|
+
{%- endcase -%}
|
|
106
|
+
{%- if source.accounts > 1 %} ({{ source.accounts }} {% if source.kind == "mail" %}{% case source.plural %}{% when "one" %}ящик{% when "few" %}ящика{% else %}ящиков{% endcase %}{% else %}{% case source.plural %}{% when "one" %}аккаунт{% when "few" %}аккаунта{% else %}аккаунтов{% endcase %}{% endif %}){% endif -%}
|
|
76
107
|
{%- endfor -%}
|
|
77
|
-
{%-
|
|
108
|
+
{%- for count in scope.counts -%}
|
|
109
|
+
{%- if forloop.first %} · {% else %}, {% endif -%}
|
|
110
|
+
{{ count.count }} {% case count.kind -%}
|
|
111
|
+
{%- when "chats" %}{% case count.plural %}{% when "one" %}чат{% when "few" %}чата{% else %}чатов{% endcase %}
|
|
112
|
+
{%- when "mail" %}{% case count.plural %}{% when "one" %}письмо{% when "few" %}письма{% else %}писем{% endcase %}
|
|
113
|
+
{%- when "tasks" %}{% case count.plural %}{% when "one" %}задача{% when "few" %}задачи{% else %}задач{% endcase %}
|
|
114
|
+
{%- when "meetings" %}{% case count.plural %}{% when "one" %}встреча{% when "few" %}встречи{% else %}встреч{% endcase %}
|
|
115
|
+
{%- endcase -%}
|
|
116
|
+
{%- endfor -%}
|
|
117
|
+
{%- endif -%}
|
|
@@ -9,7 +9,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
9
9
|
{%- if summary %}{{ nl }}{{ summary }}{% endif -%}
|
|
10
10
|
{%- if quiet -%}
|
|
11
11
|
{{ nl }}{{ nl }}
|
|
12
|
-
{%- if health.items.size > 0 %}Nothing new, but
|
|
12
|
+
{%- if health.items.size > 0 %}Nothing new, but sync needs attention.
|
|
13
13
|
{%- else %}A quiet morning: nothing urgent.{% endif -%}
|
|
14
14
|
{%- endif -%}
|
|
15
15
|
{%- for section in sections -%}
|
|
@@ -34,7 +34,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
34
34
|
{%- case item.type -%}
|
|
35
35
|
{%- when "reply" %}{{ item.who }} · {{ item.topic }} — {{ item.action }}
|
|
36
36
|
{%- when "question" %}{{ item.who }} asks: {{ item.action }}
|
|
37
|
-
{%- when "task" %}{{ item.topic }} — {{ due }}
|
|
37
|
+
{%- when "task" %}{{ item.topic }}{% if due != "" %} — {{ due }}{% elsif item.who %} — {{ item.who }}{% endif %}
|
|
38
38
|
{%- when "fact" %}{{ item.topic }}: {{ item.detail }}
|
|
39
39
|
{%- when "risk" %}{{ item.topic }}: {{ item.detail }} → {{ item.action }}
|
|
40
40
|
{%- when "money" %}{{ item.amount.text }} · {{ item.who }} · {{ item.topic }}{% if item.action %} — {{ item.action }}{% endif %}
|
|
@@ -52,7 +52,8 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
52
52
|
{%- if due != "" and "risk,money,decision" contains item.type %}{{ sep }}{{ due }}{% assign sep = " · " %}{% endif -%}
|
|
53
53
|
{%- if item.action and "task,meeting" contains item.type %}{{ sep }}{{ item.action }}{% assign sep = " · " %}{% endif -%}
|
|
54
54
|
{%- if item.detail and "task,money,meeting,decision" contains item.type %}{{ sep }}{{ item.detail }}{% assign sep = " · " %}{% endif -%}
|
|
55
|
-
{%- if item.who and "
|
|
55
|
+
{%- if item.who and "fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
|
|
56
|
+
{%- if item.who and item.type == "task" and due != "" %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
|
|
56
57
|
{%- if item.channel %}{{ sep }}
|
|
57
58
|
{%- case item.channel -%}
|
|
58
59
|
{%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
|
|
@@ -66,11 +67,50 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
66
67
|
{%- if second != "" %}{{ nl }} {{ second }}{% endif -%}
|
|
67
68
|
{%- endfor -%}
|
|
68
69
|
{%- if section.more > 0 %}{{ nl }}{{ section.more }} more{% endif -%}
|
|
70
|
+
{%- if section.groups.size > 0 %}{{ nl }}
|
|
71
|
+
{%- for group in section.groups -%}
|
|
72
|
+
{%- unless forloop.first %} · {% endunless -%}
|
|
73
|
+
{%- capture words -%}
|
|
74
|
+
{%- case group.filter -%}
|
|
75
|
+
{%- when "overdue" %}All overdue
|
|
76
|
+
{%- when "today" %}{% if forloop.first %}Due today{% else %}due today{% endif %}
|
|
77
|
+
{%- when "tomorrow" %}{% if forloop.first %}Due tomorrow{% else %}due tomorrow{% endif %}
|
|
78
|
+
{%- when "new" %}{% if forloop.first %}New{% else %}new{% endif %}
|
|
79
|
+
{%- endcase %} ({{ group.count }})
|
|
80
|
+
{%- endcapture -%}
|
|
81
|
+
{%- if group.link %}{{ words }} {{ group.link.url }}{% else %}{{ words }}{% endif -%}
|
|
82
|
+
{%- endfor -%}
|
|
83
|
+
{%- endif -%}
|
|
69
84
|
{%- endfor -%}
|
|
70
|
-
{%-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
{%- if health.items.size > 0 %}{{ nl }}{% endif -%}
|
|
86
|
+
{%- for source in health.items -%}
|
|
87
|
+
{{ nl }}{{ health.emoji }} {{ source.source }}
|
|
88
|
+
{%- if source.account %} ({{ source.account }}){% endif -%}
|
|
89
|
+
{%- case source.reason -%}
|
|
90
|
+
{%- when "sync-failed" %}: sync failing{% if source.since %} since {{ source.since.date }}{% endif %}
|
|
91
|
+
{%- when "no-schedule" %}: no sync schedule
|
|
92
|
+
{%- when "quiet" %}: nothing new {% if source.since %}since {{ source.since.date }}{% else %}for {{ source.span }}{% endif %}
|
|
93
|
+
{%- else %} has not synced for {{ source.span }}
|
|
94
|
+
{%- endcase -%}
|
|
95
|
+
{%- for link in source.links %} · {{ link.url }}{% endfor -%}
|
|
96
|
+
{%- endfor -%}
|
|
97
|
+
{%- if scope -%}
|
|
98
|
+
{{ nl }}{{ nl }}Viewed over {{ scope.window }}
|
|
99
|
+
{%- for source in scope.sources -%}
|
|
100
|
+
{%- if forloop.first %}: {% else %}, {% endif -%}
|
|
101
|
+
{%- case source.kind -%}
|
|
102
|
+
{%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
|
|
103
|
+
{%- when "mail" %}mail{% when "meeting" %}meetings{% when "task" %}tasks
|
|
104
|
+
{%- endcase -%}
|
|
105
|
+
{%- if source.accounts > 1 %} ({{ source.accounts }} {% if source.kind == "mail" %}{% if source.plural == "one" %}mailbox{% else %}mailboxes{% endif %}{% else %}{% if source.plural == "one" %}account{% else %}accounts{% endif %}{% endif %}){% endif -%}
|
|
75
106
|
{%- endfor -%}
|
|
76
|
-
{%-
|
|
107
|
+
{%- for count in scope.counts -%}
|
|
108
|
+
{%- if forloop.first %} · {% else %}, {% endif -%}
|
|
109
|
+
{{ count.count }} {% case count.kind -%}
|
|
110
|
+
{%- when "chats" %}{% if count.plural == "one" %}chat{% else %}chats{% endif %}
|
|
111
|
+
{%- when "mail" %}{% if count.plural == "one" %}email{% else %}emails{% endif %}
|
|
112
|
+
{%- when "tasks" %}{% if count.plural == "one" %}task{% else %}tasks{% endif %}
|
|
113
|
+
{%- when "meetings" %}{% if count.plural == "one" %}meeting{% else %}meetings{% endif %}
|
|
114
|
+
{%- endcase -%}
|
|
115
|
+
{%- endfor -%}
|
|
116
|
+
{%- endif -%}
|
|
@@ -9,7 +9,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
9
9
|
{%- if summary %}{{ nl }}{{ summary }}{% endif -%}
|
|
10
10
|
{%- if quiet -%}
|
|
11
11
|
{{ nl }}{{ nl }}
|
|
12
|
-
{%- if health.items.size > 0 %}Новых дел нет, но
|
|
12
|
+
{%- if health.items.size > 0 %}Новых дел нет, но синхронизация требует внимания.
|
|
13
13
|
{%- else %}Тихое утро: ничего срочного.{% endif -%}
|
|
14
14
|
{%- endif -%}
|
|
15
15
|
{%- for section in sections -%}
|
|
@@ -34,7 +34,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
34
34
|
{%- case item.type -%}
|
|
35
35
|
{%- when "reply" %}{{ item.who }} · {{ item.topic }} — {{ item.action }}
|
|
36
36
|
{%- when "question" %}{{ item.who }} спрашивает: {{ item.action }}
|
|
37
|
-
{%- when "task" %}{{ item.topic }} — {{ due }}
|
|
37
|
+
{%- when "task" %}{{ item.topic }}{% if due != "" %} — {{ due }}{% elsif item.who %} — {{ item.who }}{% endif %}
|
|
38
38
|
{%- when "fact" %}{{ item.topic }}: {{ item.detail }}
|
|
39
39
|
{%- when "risk" %}{{ item.topic }}: {{ item.detail }} → {{ item.action }}
|
|
40
40
|
{%- when "money" %}{{ item.amount.text }} · {{ item.who }} · {{ item.topic }}{% if item.action %} — {{ item.action }}{% endif %}
|
|
@@ -52,7 +52,8 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
52
52
|
{%- if due != "" and "risk,money,decision" contains item.type %}{{ sep }}{{ due }}{% assign sep = " · " %}{% endif -%}
|
|
53
53
|
{%- if item.action and "task,meeting" contains item.type %}{{ sep }}{{ item.action }}{% assign sep = " · " %}{% endif -%}
|
|
54
54
|
{%- if item.detail and "task,money,meeting,decision" contains item.type %}{{ sep }}{{ item.detail }}{% assign sep = " · " %}{% endif -%}
|
|
55
|
-
{%- if item.who and "
|
|
55
|
+
{%- if item.who and "fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
|
|
56
|
+
{%- if item.who and item.type == "task" and due != "" %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
|
|
56
57
|
{%- if item.channel %}{{ sep }}
|
|
57
58
|
{%- case item.channel -%}
|
|
58
59
|
{%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
|
|
@@ -66,11 +67,50 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
|
|
|
66
67
|
{%- if second != "" %}{{ nl }} {{ second }}{% endif -%}
|
|
67
68
|
{%- endfor -%}
|
|
68
69
|
{%- if section.more > 0 %}{{ nl }}ещё {{ section.more }}{% endif -%}
|
|
70
|
+
{%- if section.groups.size > 0 %}{{ nl }}
|
|
71
|
+
{%- for group in section.groups -%}
|
|
72
|
+
{%- unless forloop.first %} · {% endunless -%}
|
|
73
|
+
{%- capture words -%}
|
|
74
|
+
{%- case group.filter -%}
|
|
75
|
+
{%- when "overdue" %}Все просроченные
|
|
76
|
+
{%- when "today" %}{% if forloop.first %}На сегодня{% else %}на сегодня{% endif %}
|
|
77
|
+
{%- when "tomorrow" %}{% if forloop.first %}На завтра{% else %}на завтра{% endif %}
|
|
78
|
+
{%- when "new" %}{% if forloop.first %}Новые{% else %}новые{% endif %}
|
|
79
|
+
{%- endcase %} ({{ group.count }})
|
|
80
|
+
{%- endcapture -%}
|
|
81
|
+
{%- if group.link %}{{ words }} {{ group.link.url }}{% else %}{{ words }}{% endif -%}
|
|
82
|
+
{%- endfor -%}
|
|
83
|
+
{%- endif -%}
|
|
69
84
|
{%- endfor -%}
|
|
70
|
-
{%-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
{%- if health.items.size > 0 %}{{ nl }}{% endif -%}
|
|
86
|
+
{%- for source in health.items -%}
|
|
87
|
+
{{ nl }}{{ health.emoji }} {{ source.source }}
|
|
88
|
+
{%- if source.account %} ({{ source.account }}){% endif -%}
|
|
89
|
+
{%- case source.reason -%}
|
|
90
|
+
{%- when "sync-failed" %}: синхронизация падает{% if source.since %} с {{ source.since.date }}{% endif %}
|
|
91
|
+
{%- when "no-schedule" %}: нет расписания синхронизации
|
|
92
|
+
{%- when "quiet" %}: ничего нового {% if source.since %}с {{ source.since.date }}{% else %}{{ source.span }}{% endif %}
|
|
93
|
+
{%- else %} не обновлялся {{ source.span }}
|
|
94
|
+
{%- endcase -%}
|
|
95
|
+
{%- for link in source.links %} · {{ link.url }}{% endfor -%}
|
|
96
|
+
{%- endfor -%}
|
|
97
|
+
{%- if scope -%}
|
|
98
|
+
{{ nl }}{{ nl }}Просмотрено за {{ scope.window }}
|
|
99
|
+
{%- for source in scope.sources -%}
|
|
100
|
+
{%- if forloop.first %}: {% else %}, {% endif -%}
|
|
101
|
+
{%- case source.kind -%}
|
|
102
|
+
{%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
|
|
103
|
+
{%- when "mail" %}почта{% when "meeting" %}встречи{% when "task" %}задачи
|
|
104
|
+
{%- endcase -%}
|
|
105
|
+
{%- if source.accounts > 1 %} ({{ source.accounts }} {% if source.kind == "mail" %}{% case source.plural %}{% when "one" %}ящик{% when "few" %}ящика{% else %}ящиков{% endcase %}{% else %}{% case source.plural %}{% when "one" %}аккаунт{% when "few" %}аккаунта{% else %}аккаунтов{% endcase %}{% endif %}){% endif -%}
|
|
75
106
|
{%- endfor -%}
|
|
76
|
-
{%-
|
|
107
|
+
{%- for count in scope.counts -%}
|
|
108
|
+
{%- if forloop.first %} · {% else %}, {% endif -%}
|
|
109
|
+
{{ count.count }} {% case count.kind -%}
|
|
110
|
+
{%- when "chats" %}{% case count.plural %}{% when "one" %}чат{% when "few" %}чата{% else %}чатов{% endcase %}
|
|
111
|
+
{%- when "mail" %}{% case count.plural %}{% when "one" %}письмо{% when "few" %}письма{% else %}писем{% endcase %}
|
|
112
|
+
{%- when "tasks" %}{% case count.plural %}{% when "one" %}задача{% when "few" %}задачи{% else %}задач{% endcase %}
|
|
113
|
+
{%- when "meetings" %}{% case count.plural %}{% when "one" %}встреча{% when "few" %}встречи{% else %}встреч{% endcase %}
|
|
114
|
+
{%- endcase -%}
|
|
115
|
+
{%- endfor -%}
|
|
116
|
+
{%- endif -%}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChannelKind, ItemType, Report, ReportKind, SectionKind } from "./schema.js";
|
|
2
|
-
/** A link the renderer built; a template may point an `href` only at one of these.
|
|
1
|
+
import type { ChannelKind, HealthReason, ItemType, Report, ReportKind, SectionKind } from "./schema.js";
|
|
2
|
+
/** A link the renderer built from a ref; a template may point an `href` only at one of these. */
|
|
3
3
|
export interface ViewLink {
|
|
4
4
|
kind: "open" | "web";
|
|
5
5
|
url: string;
|
|
@@ -40,19 +40,46 @@ export interface ViewItem {
|
|
|
40
40
|
time: Moment | null;
|
|
41
41
|
links: ViewLink[];
|
|
42
42
|
}
|
|
43
|
+
export interface ViewTaskGroup {
|
|
44
|
+
filter: "overdue" | "today" | "tomorrow" | "new";
|
|
45
|
+
count: number;
|
|
46
|
+
/** `tasks/<filter>`; null when links are off, or `new` has no time to count from. */
|
|
47
|
+
link: ViewLink | null;
|
|
48
|
+
}
|
|
43
49
|
export interface ViewSection {
|
|
44
50
|
kind: SectionKind;
|
|
45
51
|
emoji: string;
|
|
46
52
|
items: ViewItem[];
|
|
47
53
|
/** The "ещё N" count: what the agent left out plus what the cap or the Telegram fit dropped. */
|
|
48
54
|
more: number;
|
|
55
|
+
/** The task group links, on the section that holds the task items only; zero groups left out. */
|
|
56
|
+
groups: ViewTaskGroup[];
|
|
49
57
|
}
|
|
50
58
|
export interface ViewHealth {
|
|
51
59
|
source: string;
|
|
60
|
+
account: string | null;
|
|
61
|
+
reason: HealthReason | null;
|
|
62
|
+
since: Moment | null;
|
|
52
63
|
hours: number;
|
|
53
64
|
span: string;
|
|
54
65
|
links: ViewLink[];
|
|
55
66
|
}
|
|
67
|
+
/** The footer line: a template picks a word's form by `plural` (`Intl.PluralRules`: one, few, many, other). */
|
|
68
|
+
export interface ViewScope {
|
|
69
|
+
/** "24 ч", "3 дня": hours below two days or for a part of a day, else days. */
|
|
70
|
+
window: string;
|
|
71
|
+
sources: {
|
|
72
|
+
kind: ChannelKind;
|
|
73
|
+
accounts: number;
|
|
74
|
+
plural: string;
|
|
75
|
+
}[];
|
|
76
|
+
/** Zero counts left out, in the order chats, mail, tasks, meetings. */
|
|
77
|
+
counts: {
|
|
78
|
+
kind: "chats" | "mail" | "tasks" | "meetings";
|
|
79
|
+
count: number;
|
|
80
|
+
plural: string;
|
|
81
|
+
}[];
|
|
82
|
+
}
|
|
56
83
|
/** What a report template gets. Every string an agent wrote is already escaped for an HTML channel. */
|
|
57
84
|
export interface ReportView {
|
|
58
85
|
kind: ReportKind;
|
|
@@ -72,8 +99,11 @@ export interface ReportView {
|
|
|
72
99
|
today: number;
|
|
73
100
|
money: number;
|
|
74
101
|
};
|
|
102
|
+
scope: ViewScope | null;
|
|
75
103
|
links: ViewLink[];
|
|
76
104
|
}
|
|
105
|
+
/** Builds the URL a ref opens, or null; the renderer passes `linkFor` with the form its channel needs. */
|
|
106
|
+
export type LinkOf = (ref: string) => string | null;
|
|
77
107
|
export declare const SECTION_EMOJI: Record<SectionKind, string>;
|
|
78
108
|
export declare const SECTION_CAPS: Record<SectionKind | "health", number>;
|
|
79
109
|
export declare const momentFor: (iso: string, now: number, language: string, timeZone?: string) => Moment;
|
|
@@ -81,8 +111,9 @@ export declare const momentFor: (iso: string, now: number, language: string, tim
|
|
|
81
111
|
* The view model of a checked report: sections in their fixed order, each cut to its cap with the rest counted in
|
|
82
112
|
* `more`, dates and money formatted in `language` and `timeZone`. Refs never reach it.
|
|
83
113
|
*/
|
|
84
|
-
export declare const reportView: (report: Report, { language, now, timeZone }: {
|
|
114
|
+
export declare const reportView: (report: Report, { language, now, timeZone, linkOf, }: {
|
|
85
115
|
language: string;
|
|
86
116
|
now: number;
|
|
87
117
|
timeZone?: string;
|
|
118
|
+
linkOf?: LinkOf;
|
|
88
119
|
}) => ReportView;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const LINK_WORDS = {
|
|
2
|
+
ru: { open: "открыть", fix: "исправить" },
|
|
3
|
+
en: { open: "open", fix: "fix" },
|
|
4
|
+
};
|
|
1
5
|
export const SECTION_EMOJI = {
|
|
2
6
|
today: "🔥",
|
|
3
7
|
decisions: "🗳",
|
|
@@ -16,6 +20,7 @@ export const SECTION_CAPS = {
|
|
|
16
20
|
health: 3,
|
|
17
21
|
};
|
|
18
22
|
const STALE_HOURS = 24;
|
|
23
|
+
const HOUR_MS = 3_600_000;
|
|
19
24
|
const emojiOf = (item, overdue) => {
|
|
20
25
|
switch (item.type) {
|
|
21
26
|
case "reply":
|
|
@@ -78,12 +83,52 @@ const amountText = (amount, language) => {
|
|
|
78
83
|
}).format(amount.value);
|
|
79
84
|
return `${amount.direction === "in" ? "+" : "−"}${money}`;
|
|
80
85
|
};
|
|
86
|
+
const taskGroups = (tasks, linkOf, label) => {
|
|
87
|
+
if (!tasks)
|
|
88
|
+
return [];
|
|
89
|
+
const groups = [
|
|
90
|
+
{ filter: "overdue", count: tasks.overdue, ref: "tasks:overdue" },
|
|
91
|
+
{ filter: "today", count: tasks.today, ref: "tasks:today" },
|
|
92
|
+
{ filter: "tomorrow", count: tasks.tomorrow, ref: "tasks:tomorrow" },
|
|
93
|
+
{
|
|
94
|
+
filter: "new",
|
|
95
|
+
count: tasks.new,
|
|
96
|
+
ref: tasks.newSince === null ? null : `tasks:new/${encodeURIComponent(tasks.newSince)}`,
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
return groups
|
|
100
|
+
.filter((group) => group.count > 0)
|
|
101
|
+
.map(({ filter, count, ref }) => {
|
|
102
|
+
const url = ref === null ? null : linkOf(ref);
|
|
103
|
+
return { filter, count, link: url === null ? null : { kind: "open", url, label } };
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const scopeView = (scope, language) => {
|
|
107
|
+
const plural = new Intl.PluralRules(language);
|
|
108
|
+
const hours = Math.round((Date.parse(scope.to) - Date.parse(scope.from)) / HOUR_MS);
|
|
109
|
+
const window = hours >= 48 && hours % 24 === 0
|
|
110
|
+
? new Intl.NumberFormat(language, { style: "unit", unit: "day", unitDisplay: "long" }).format(hours / 24)
|
|
111
|
+
: new Intl.NumberFormat(language, { style: "unit", unit: "hour", unitDisplay: "short" }).format(hours);
|
|
112
|
+
const counts = ["chats", "mail", "tasks", "meetings"]
|
|
113
|
+
.map((kind) => ({ kind, count: scope.counts[kind], plural: plural.select(scope.counts[kind]) }))
|
|
114
|
+
.filter((one) => one.count > 0);
|
|
115
|
+
return {
|
|
116
|
+
window,
|
|
117
|
+
sources: scope.sources.map((source) => ({ ...source, plural: plural.select(source.accounts) })),
|
|
118
|
+
counts,
|
|
119
|
+
};
|
|
120
|
+
};
|
|
81
121
|
/**
|
|
82
122
|
* The view model of a checked report: sections in their fixed order, each cut to its cap with the rest counted in
|
|
83
123
|
* `more`, dates and money formatted in `language` and `timeZone`. Refs never reach it.
|
|
84
124
|
*/
|
|
85
|
-
export const reportView = (report, { language, now, timeZone }) => {
|
|
125
|
+
export const reportView = (report, { language, now, timeZone, linkOf = () => null, }) => {
|
|
86
126
|
const moment = (iso) => (iso === null ? null : momentFor(iso, now, language, timeZone));
|
|
127
|
+
const words = LINK_WORDS[language] ?? LINK_WORDS.en;
|
|
128
|
+
const linksOf = (refs, label) => {
|
|
129
|
+
const url = refs.map(linkOf).find((one) => one !== null);
|
|
130
|
+
return url ? [{ kind: "open", url, label }] : [];
|
|
131
|
+
};
|
|
87
132
|
const itemOf = (item) => {
|
|
88
133
|
const due = moment(item.due);
|
|
89
134
|
const overdue = (item.type === "task" || item.type === "money" || item.type === "risk") && due?.past === true;
|
|
@@ -103,7 +148,7 @@ export const reportView = (report, { language, now, timeZone }) => {
|
|
|
103
148
|
since: moment(item.since),
|
|
104
149
|
due,
|
|
105
150
|
time: moment(item.time),
|
|
106
|
-
links:
|
|
151
|
+
links: linksOf(item.refs, words.open),
|
|
107
152
|
};
|
|
108
153
|
};
|
|
109
154
|
const order = Object.keys(SECTION_EMOJI);
|
|
@@ -120,10 +165,15 @@ export const reportView = (report, { language, now, timeZone }) => {
|
|
|
120
165
|
emoji: SECTION_EMOJI[kind],
|
|
121
166
|
items: items.slice(0, cap).map(itemOf),
|
|
122
167
|
more: more + Math.max(items.length - cap, 0),
|
|
168
|
+
groups: [],
|
|
123
169
|
},
|
|
124
170
|
];
|
|
125
171
|
});
|
|
126
|
-
const
|
|
172
|
+
const groups = taskGroups(report.tasks, linkOf, words.open);
|
|
173
|
+
const holder = sections.find((section) => section.items.some((item) => item.type === "task")) ??
|
|
174
|
+
sections.find((section) => section.kind === "today") ??
|
|
175
|
+
sections.at(-1);
|
|
176
|
+
const stale = report.health.filter((entry) => entry.reason !== null || entry.staleHours > STALE_HOURS);
|
|
127
177
|
const count = (kind) => {
|
|
128
178
|
const section = sections.find((one) => one.kind === kind);
|
|
129
179
|
return section ? section.items.length + section.more : 0;
|
|
@@ -134,19 +184,23 @@ export const reportView = (report, { language, now, timeZone }) => {
|
|
|
134
184
|
emoji: "☀️",
|
|
135
185
|
date: momentFor(report.date, now, language, timeZone),
|
|
136
186
|
summary: report.summary,
|
|
137
|
-
sections,
|
|
187
|
+
sections: sections.map((section) => (section === holder ? { ...section, groups } : section)),
|
|
138
188
|
health: {
|
|
139
189
|
emoji: "🛠",
|
|
140
190
|
items: stale.slice(0, SECTION_CAPS.health).map((entry) => ({
|
|
141
191
|
source: entry.source,
|
|
192
|
+
account: entry.account,
|
|
193
|
+
reason: entry.reason,
|
|
194
|
+
since: moment(entry.since),
|
|
142
195
|
hours: entry.staleHours,
|
|
143
196
|
span: new Intl.NumberFormat(language, { style: "unit", unit: "day", unitDisplay: "long" }).format(Math.floor(entry.staleHours / 24)),
|
|
144
|
-
links:
|
|
197
|
+
links: linksOf(entry.refs, words.fix),
|
|
145
198
|
})),
|
|
146
199
|
more: Math.max(stale.length - SECTION_CAPS.health, 0),
|
|
147
200
|
},
|
|
148
201
|
quiet: sections.length === 0,
|
|
149
202
|
counts: { today: count("today"), money: count("money") },
|
|
203
|
+
scope: report.scope && scopeView(report.scope, language),
|
|
150
204
|
links: [],
|
|
151
205
|
};
|
|
152
206
|
};
|
|
@@ -2,9 +2,12 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, join } from "node:path";
|
|
4
4
|
import { CliError, errorCodes, writeSecurely } from "@wirecat/cli-base";
|
|
5
|
+
import { linkConfigOf } from "../domain/links.js";
|
|
5
6
|
import { mailHolderVariable, readOnlyLockOf } from "../ports/app.js";
|
|
6
7
|
import { recordLogFor } from "../runs/record-log.js";
|
|
7
8
|
import { childTrace } from "../runs/scope.js";
|
|
9
|
+
import { storePath } from "../store/path.js";
|
|
10
|
+
import { readSharedSection, sharedConfigPath } from "../store/shared-config.js";
|
|
8
11
|
import { deliver } from "./deliver.js";
|
|
9
12
|
import { prepareReport } from "./report/render.js";
|
|
10
13
|
export const NOTIFY_WHEN = ["always", "failures", "never"];
|
|
@@ -342,6 +345,15 @@ export const timerFor = (app, system, env) => {
|
|
|
342
345
|
return launchdTimer(app, system, env, env.HOME);
|
|
343
346
|
throw new CliError("validation_error", `${app.command} schedule knows Linux, macOS and Windows, not ${system.platform}`);
|
|
344
347
|
};
|
|
348
|
+
/** The shared `links` settings; a config file that cannot be read keeps the default rather than stop a digest. */
|
|
349
|
+
const sharedLinks = (env) => {
|
|
350
|
+
try {
|
|
351
|
+
return linkConfigOf(readSharedSection(sharedConfigPath(storePath(env), env), "links"));
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
return linkConfigOf(undefined);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
345
357
|
/** A desktop notification; a machine without one loses only the notice, never the run. */
|
|
346
358
|
export const notify = async (system, env, title, body) => {
|
|
347
359
|
const argv = system.platform === "linux"
|
|
@@ -462,15 +474,20 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
|
|
|
462
474
|
const errors = agent ? output.replace(/\.md$/, ".log") : output;
|
|
463
475
|
if (agent && exitCode === 0)
|
|
464
476
|
copyFileSync(output, join(folder, "latest.md"));
|
|
477
|
+
const runEnv = { ...env, ...schedule.environment };
|
|
465
478
|
const prepared = agent && exitCode === 0
|
|
466
479
|
? await prepareReport(readFileSync(output, "utf8"), {
|
|
467
|
-
language: await ownerLanguage(
|
|
480
|
+
language: await ownerLanguage(runEnv).catch(() => "ru"),
|
|
468
481
|
now: now().getTime(),
|
|
482
|
+
links: sharedLinks(runEnv),
|
|
483
|
+
env: runEnv,
|
|
469
484
|
})
|
|
470
485
|
: undefined;
|
|
471
486
|
const latestText = join(folder, "latest.txt");
|
|
472
487
|
if (prepared) {
|
|
473
|
-
writeFileSync(latestText, `${prepared.
|
|
488
|
+
writeFileSync(latestText, `${prepared.terminal}\n`, { mode: 0o600 });
|
|
489
|
+
if (prepared.document)
|
|
490
|
+
writeFileSync(output.replace(/\.md$/, ".report.json"), prepared.document, { mode: 0o600 });
|
|
474
491
|
last = rewriteRun(join(folder, "last.json"), { ...last, report: prepared.run });
|
|
475
492
|
}
|
|
476
493
|
else if (agent && exitCode === 0)
|
|
@@ -497,7 +514,6 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
|
|
|
497
514
|
const routes = schedule.to ?? [];
|
|
498
515
|
if (routes.length > 0 && (exitCode === 0 ? mode === "always" : mode !== "never")) {
|
|
499
516
|
const at = shortTime(last.at);
|
|
500
|
-
const runEnv = { ...env, ...schedule.environment };
|
|
501
517
|
const locked = readOnlyLockOf(app, runEnv);
|
|
502
518
|
const deliveries = await deliver(system, runEnv, routes, exitCode === 0
|
|
503
519
|
? {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a WireCat link opens. A link only opens a screen in WireCat Desktop: no kind performs an action, a proposal
|
|
3
|
+
* link shows the proposal and the owner presses Confirm or Reject there.
|
|
4
|
+
*/
|
|
5
|
+
export type DeepLinkTarget = {
|
|
6
|
+
type: "message";
|
|
7
|
+
provider: string;
|
|
8
|
+
account: string;
|
|
9
|
+
chat: string;
|
|
10
|
+
message: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "chat";
|
|
13
|
+
provider: string;
|
|
14
|
+
account: string;
|
|
15
|
+
chat: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "task";
|
|
18
|
+
id: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "tasks";
|
|
21
|
+
filter: "overdue" | "today" | "tomorrow";
|
|
22
|
+
} | {
|
|
23
|
+
type: "tasks";
|
|
24
|
+
filter: "new";
|
|
25
|
+
since: string;
|
|
26
|
+
}
|
|
27
|
+
/** A review id as `memo review` shows it (`17070`, `fact:512`): not a reference, so it is one encoded part. */
|
|
28
|
+
| {
|
|
29
|
+
type: "proposal";
|
|
30
|
+
id: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: "digest";
|
|
33
|
+
date: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "sync";
|
|
36
|
+
tool: string;
|
|
37
|
+
account?: string;
|
|
38
|
+
};
|
|
39
|
+
export type LinkForm = "web" | "app";
|
|
40
|
+
export interface LinkConfig {
|
|
41
|
+
/** The bounce page: the path goes after its `#`, so the host never sees it. */
|
|
42
|
+
base: string;
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare const LINK_VERSION = "v1";
|
|
46
|
+
export declare const DEFAULT_LINK_CONFIG: LinkConfig;
|
|
47
|
+
/** `/v1/msg/max/1001/-2002/3003`, the part both forms share. */
|
|
48
|
+
export declare const formatLink: (target: DeepLinkTarget) => string;
|
|
49
|
+
/**
|
|
50
|
+
* The target of a link in either form (`https://…#/v1/…`, `wirecat://open/v1/…`) or of its bare path (`/v1/…`), or
|
|
51
|
+
* `null` for anything else: another version, an unknown kind, a part too many or empty, a path over 512 characters.
|
|
52
|
+
*/
|
|
53
|
+
export declare const parseLink: (text: string) => DeepLinkTarget | null;
|
|
54
|
+
/**
|
|
55
|
+
* The target a ref names, or `null` when it names nothing a link opens. A store reference (`msg:`, `chat:`, `task:`)
|
|
56
|
+
* is read by its own grammar; the kinds that are no reference are written as their path with a colon after the
|
|
57
|
+
* kind: `proposal:fact%3A512`, `tasks:overdue`, `tasks:new/2026-11-07T08%3A00%3A00Z`, `digest:2026-11-08`,
|
|
58
|
+
* `sync:telegram/1001`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const linkTargetOf: (ref: string) => DeepLinkTarget | null;
|
|
61
|
+
/** The `links` section of the shared config, with the default for what is missing or not a usable value. */
|
|
62
|
+
export declare const linkConfigOf: (section: unknown) => LinkConfig;
|
|
63
|
+
/**
|
|
64
|
+
* The one way to build a WireCat link: the web form for messages and mail (an https page that hands it to the app),
|
|
65
|
+
* the app form for a desktop terminal. `null` when links are off (`links.enabled: false`, or `WIRECAT_LINKS=off` for
|
|
66
|
+
* one run) or the ref names nothing a link opens; the caller then leaves the link out.
|
|
67
|
+
*/
|
|
68
|
+
export declare const linkFor: (ref: DeepLinkTarget | string, { form, config, env, }: {
|
|
69
|
+
form: LinkForm;
|
|
70
|
+
config?: LinkConfig;
|
|
71
|
+
env?: NodeJS.ProcessEnv;
|
|
72
|
+
}) => string | null;
|