@wirecat/cli-core 0.734.0 → 0.736.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/background/report/messages.d.ts +4 -0
  4. package/dist/background/report/messages.js +2 -0
  5. package/dist/background/report/templates/schedule-failed.email.en.liquid +2 -1
  6. package/dist/background/report/templates/schedule-failed.email.ru.liquid +2 -1
  7. package/dist/background/report/templates/schedule-failed.sample.json +2 -1
  8. package/dist/background/report/templates/schedule-failed.telegram.en.liquid +2 -1
  9. package/dist/background/report/templates/schedule-failed.telegram.ru.liquid +2 -1
  10. package/dist/background/report/templates/schedule-failed.text.en.liquid +2 -1
  11. package/dist/background/report/templates/schedule-failed.text.ru.liquid +2 -1
  12. package/dist/background/schedules.js +11 -7
  13. package/dist/cli/documents/file-edit.d.ts +4 -4
  14. package/dist/cli/documents/file-edit.js +69 -5
  15. package/dist/cli/enrichment-consents-command.js +2 -1
  16. package/dist/cli/messenger/catch-up-answers.js +1 -0
  17. package/dist/cli/messenger/download-command.js +3 -0
  18. package/dist/cli/messenger/inbox.js +4 -1
  19. package/dist/cli/messenger/review.js +4 -1
  20. package/dist/cli/messenger/search-answers.js +1 -0
  21. package/dist/cli/schedule/schedule-command.js +10 -1
  22. package/dist/cli/search-harder-consents-command.js +2 -1
  23. package/dist/cli/templates-command.js +7 -6
  24. package/dist/crm/cli/records.js +16 -1
  25. package/dist/domain/models.d.ts +4 -0
  26. package/dist/domain/providers.d.ts +7 -0
  27. package/dist/domain/providers.js +15 -2
  28. package/dist/entities/hit.d.ts +2 -0
  29. package/dist/entities/hit.js +2 -0
  30. package/dist/entities/index.d.ts +1 -0
  31. package/dist/errors/reasons.js +9 -2
  32. package/dist/office/create.d.ts +34 -0
  33. package/dist/office/create.js +216 -0
  34. package/dist/office/index.d.ts +1 -0
  35. package/dist/office/index.js +1 -0
  36. package/dist/office/package.d.ts +1 -0
  37. package/dist/office/package.js +1 -1
  38. package/dist/ports/messenger.d.ts +12 -1
  39. package/dist/search/word-match.d.ts +16 -0
  40. package/dist/search/word-match.js +28 -0
  41. package/dist/sends/upload.d.ts +3 -0
  42. package/dist/sends/upload.js +2 -2
  43. package/dist/services/documents/ingestion.js +4 -2
  44. package/dist/services/file-download.js +4 -2
  45. package/dist/services/inbox.d.ts +1 -1
  46. package/dist/services/inbox.js +6 -2
  47. package/dist/services/metadata.d.ts +1 -1
  48. package/dist/services/search-all.d.ts +2 -0
  49. package/dist/services/search-all.js +47 -17
  50. package/dist/store/sqlite/crm-rows.d.ts +4 -0
  51. package/dist/store/sqlite/crm-rows.js +30 -0
  52. package/dist/store/sqlite/crm.d.ts +2 -0
  53. package/dist/store/sqlite/crm.js +3 -10
  54. package/dist/store/sqlite/deals.js +1 -24
  55. package/dist/store/sqlite/tracker-chunks.d.ts +24 -8
  56. package/dist/store/sqlite/tracker-chunks.js +137 -38
  57. package/dist/store/sqlite/tracker.d.ts +5 -0
  58. package/dist/store/sqlite/tracker.js +118 -17
  59. package/dist/tracker/cli/index.js +1 -1
  60. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,91 @@ 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.736.0 — 23.11.2026
9
+
10
+ ### Added
11
+
12
+ - **New Word and Excel files: `createXlsx`, `createDocx`, and `files sheets create` and `files documents create`.**
13
+ `createXlsx({ sheets: [{ name, rows }], boldHeader? })` makes a workbook from rows of values (numbers and booleans
14
+ typed, a text that starts with `=` stays text), `createDocx({ paragraphs: [{ text, style? }] })` a document with
15
+ `Title`, `Heading1` to `Heading3`, `Normal` and `ListBullet` styles; the same input gives the same bytes. The
16
+ commands, mounted by `addFileEditCommands`, write a new file only (`office.file-exists` points to `update`), ask the
17
+ write's own permission and answer the `sha256` that `update` takes next. See
18
+ [New files](docs/office.md#new-files) and [New Office files](docs/dev/DOCUMENTS.md#create-office-files).
19
+ - **`unreadChats` may say what it did not look at.** Its answer takes `left`, reasons in the owner's words such as
20
+ "channels are not counted"; `inbox`, `inbox --new` and `review` list each in `missing` and warn with it in the
21
+ terminal, in place of the generic note that the messenger did not list every chat.
22
+
23
+ ### Changed — may break callers
24
+
25
+ - **Issues, projects and comments are found by other forms of their words.** `store.tracker.find`, and with it
26
+ `issues search` and the tracker lane of `search all`, matches a query word to a word of the same stem
27
+ («поставки цемента» finds «Поставка цемента», `invoice failing` finds "Invoices fail") and to a word it begins, as
28
+ CRM deals are matched. A word starts others from four letters, not three as before: `bug` no longer finds `bugfix`,
29
+ only `bug` and `bugs`. `--exact` keeps the words as written. One search reads at most 2,000 rows the word index
30
+ offers; when it offered more, the answer has `capped: true` and `hasMore` while the page found any. See
31
+ [TRACKER.md](docs/dev/TRACKER.md#storetracker).
32
+
33
+ - **`search all` shows an issue, project or comment two sign-ins hold once.** Two tracker accounts on one workspace
34
+ showed every item twice side by side, so ten results held about five items. For a provider whose entry says
35
+ `globalItemIds: true` (seeded for `linear`), the copies (same provider, kind and id) now fold into the best-placed
36
+ one, whose new `accounts` field names every account that holds it; `account` and `ref`
37
+ are that copy's. A page holds more distinct items, so a caller counting hits per account sees fewer. See
38
+ [TRACKER.md](docs/dev/TRACKER.md#search-all).
39
+
40
+ ### Fixed
41
+
42
+ - **A comment is found by meaning together with its issue.** Its embedded text starts with the issue's key and title
43
+ (`ENG-12 Fix login`), so "it works after clearing the cache" is found by what the issue is about. A comment of fewer
44
+ than 16 characters (`LGTM`, `+1`) is no longer embedded, and its words still find it. A retitled or moved issue's
45
+ comments are cut again on save, and `embedTracker` cuts the comments of a store embedded by 0.730–0.732 once, so
46
+ their vectors are made again. A chunk whose text no longer hashes to its hash, as one an older build cut, is never
47
+ embedded: its item is cut again first. Measured in cli-testing
48
+ [performance/search/tracker-meaning](https://github.com/WireCatLabs/cli-testing/tree/main/performance/search/tracker-meaning).
49
+ - `people show` and `organizations show` take the `person:<id>` and `organization:<id>` a stored deal gives. They
50
+ answered `not_found`, so an agent could not open a deal's company or contact by the ref it was handed.
51
+ - A failed schedule's desktop notification says since when it fails, why, and the command that shows what is wrong
52
+ (`max work doctor`), above the log's path, instead of only "failed (exit 12)" and a path the notification cuts off.
53
+ The Telegram and e-mail notices name the same command (template variable `check`).
54
+ - A run that cannot read its sign-in no longer only says the keyring was locked: the notice says it is locked or holds
55
+ no sign-in, and to sign in again when the computer is unlocked.
56
+
57
+ ### Security
58
+
59
+ - **`schedule exec` runs only a schedule file in the tool's own schedules folder, and an MCP server no longer offers
60
+ it.** The file's real path is compared, so a link or `..` that leads elsewhere is refused (`schedule.outside-folder`).
61
+ A timer installed by `schedule agent` or `schedule command` already names a file there, with or without its seal, so
62
+ installed schedules keep running. An agent runs a saved schedule with `schedule run <name>`.
63
+ - **`templates preview --file` is the owner's option.** An MCP server no longer offers it; an agent previews the
64
+ template that applies. `templates edit`, `templates reset`, `models consents set --yes` and
65
+ `models search-consents set --yes` refuse an MCP run as they refuse an agent's shell, whatever its environment holds.
66
+ - **`messages download --output-dir` refuses credential folders, the CLI's own folders and the message store**, as
67
+ `attachments extract --output-dir` does, for one message, `--all` and `--offline`. A file named after its message
68
+ stays inside the chosen folder whatever the message id holds.
69
+ - **`documents history document:<n>` answers only for a document of the selected profile's account.** A ref of
70
+ another account's document is `document.not-imported`, like a source id that is not in the profile's local copy.
71
+
72
+ ## 0.735.0 — 23.11.2026
73
+
74
+ ### Added
75
+
76
+ - **`unreadChats`, an optional messenger port for `inbox` and `review`.** A messenger whose chat list carries no
77
+ unread counts or last message times, because each costs a request (Slack), answers them here; `inbox`, `inbox --new`
78
+ and `review` use it when present, and every other command keeps the cheap `chats`. `hasMore` marks the answer
79
+ partial.
80
+
81
+ ### Fixed
82
+
83
+ - **`search conversations --like` shows the part of a huge conversation that answers the question.** A conversation of
84
+ more than 50 chunks holds text near any question, so its nearest chunk was often about something else. With a
85
+ made-up reply, such a hit now shows the chunk that ranks best by meaning (to the question and the reply together)
86
+ and by the words of both that are rare inside that conversation. Without `--like` nothing changes.
87
+ - **A usage error says how to fix the call.** An unknown flag that a sibling command takes names it
88
+ (`unknown option '--like' — --like is an option of search conversations`). `--filter` on `search messages` and
89
+ `search all` says the filter goes in the query. A query that fails after `--` quotes the words read as the query and
90
+ says to put options before `--`: an unknown option there (`messages list -- -100… --around 5419`) used to fail as
91
+ bare `query.invalid-syntax at position 2`.
92
+
8
93
  ## 0.734.0 — 23.11.2026
9
94
 
10
95
  ### Added
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
24
24
  }
25
25
  export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
26
26
  export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
27
- action?: undefined;
28
27
  name: string;
29
28
  installed: boolean;
30
29
  active: boolean;
31
30
  servicePath: string;
32
31
  timerPath: string;
32
+ action?: undefined;
33
33
  } | {
34
34
  active?: undefined;
35
35
  name: string;
@@ -55,6 +55,8 @@ export interface ScheduleFailure {
55
55
  cause: FailureCause;
56
56
  /** The one "fix" link: the tool's sync screen. */
57
57
  refs: string[];
58
+ /** The command that shows what is wrong, such as `max work doctor`. */
59
+ check?: string;
58
60
  }
59
61
  export declare const parseScheduleFailure: (json: string) => ScheduleFailure;
60
62
  export declare const GAPS_CAP = 15;
@@ -99,6 +101,8 @@ export interface NoticeView {
99
101
  plural: string;
100
102
  cause: FailureCause;
101
103
  links: ViewLink[];
104
+ /** The command that shows what is wrong; none, the line is left out. */
105
+ check: string | null;
102
106
  }
103
107
  export declare const noticeView: (failure: ScheduleFailure, { language, now, timeZone, linkOf, }: {
104
108
  language: string;
@@ -181,6 +181,7 @@ export const parseScheduleFailure = (json) => {
181
181
  failures: count(document.failures, "failures"),
182
182
  cause: document.cause,
183
183
  refs: stringsOf(document.refs),
184
+ ...(typeof document.check === "string" ? { check: document.check } : {}),
184
185
  };
185
186
  };
186
187
  const LINK_WORDS = {
@@ -230,4 +231,5 @@ export const noticeView = (failure, { language, now, timeZone, linkOf = () => nu
230
231
  plural: new Intl.PluralRules(language).select(failure.failures),
231
232
  cause: failure.cause,
232
233
  links: linkOfRefs(failure.refs, linkOf, wordsOf(language).fix),
234
+ check: failure.check ?? null,
233
235
  });
@@ -7,6 +7,7 @@ of the view model. No colour on the body: the grey (#8a8a8a) and the link blue (
7
7
  <div style="max-width:600px;font-family:-apple-system,Segoe UI,Roboto,Arial,sans-serif;font-size:15px">
8
8
  {{- nl }}<p style="margin:0 0 8px;font-size:19px"><b>⚠️ {% if schedule == "morning-digest" %}The morning digest could not be built{% else %}The schedule “{{ tool }} {{ schedule }}” is failing{% endif %}</b></p>
9
9
  {{- nl }}<p style="margin:0 0 4px">{% if failures > 1 %}Failing since {{ since.date }}{% if since.time %}, {{ since.time }}{% endif %} · {{ failures }} runs in a row{% else %}Failed {% if at.day == "today" %}today{% elsif at.day == "yesterday" %}yesterday{% else %}on {{ at.date }}{% endif %}{% if at.time %} at {{ at.time }}{% endif %}{% endif %}</p>
10
- {{- nl }}<p style="margin:0 0 12px">Why: {% case cause %}{% when "locked" %}the keyring was locked; unlock the computer{% when "sign-in" %}the account needs a new sign-in{% when "network" %}the service could not be reached{% when "provider" %}the service answered with an error{% when "setup" %}something is wrong in the settings{% when "stopped" %}the run was stopped{% else %}the program ended with an error{% endcase %}</p>
10
+ {{- nl }}<p style="margin:0 0 12px">Why: {% case cause %}{% when "locked" %}the keyring is locked or holds no sign-in: unlock the computer, and if it is unlocked, sign in again{% when "sign-in" %}the account needs a new sign-in{% when "network" %}the service could not be reached{% when "provider" %}the service answered with an error{% when "setup" %}something is wrong in the settings{% when "stopped" %}the run was stopped{% else %}the program ended with an error{% endcase %}</p>
11
+ {%- if check %}{{ nl }}<p style="margin:0 0 12px">Check: {{ check }}</p>{% endif -%}
11
12
  {%- for link in links %}{{ nl }}<p style="margin:0"><a href="{{ link.url }}" style="color:#3b82c4">{{ link.label }}</a></p>{% endfor -%}
12
13
  {{ nl }}</div>
@@ -7,6 +7,7 @@ of the view model. No colour on the body: the grey (#8a8a8a) and the link blue (
7
7
  <div style="max-width:600px;font-family:-apple-system,Segoe UI,Roboto,Arial,sans-serif;font-size:15px">
8
8
  {{- nl }}<p style="margin:0 0 8px;font-size:19px"><b>⚠️ {% if schedule == "morning-digest" %}Утренняя сводка не собралась{% else %}Расписание «{{ tool }} {{ schedule }}» не работает{% endif %}</b></p>
9
9
  {{- nl }}<p style="margin:0 0 4px">{% if failures > 1 %}Не работает с {{ since.date }}{% if since.time %}, {{ since.time }}{% endif %} · {{ failures }} {% case plural %}{% when "one" %}запуск{% when "few" %}запуска{% else %}запусков{% endcase %} подряд{% else %}Сбой {% if at.day == "today" %}сегодня{% elsif at.day == "yesterday" %}вчера{% else %}{{ at.date }}{% endif %}{% if at.time %} в {{ at.time }}{% endif %}{% endif %}</p>
10
- {{- nl }}<p style="margin:0 0 12px">Причина: {% case cause %}{% when "locked" %}хранилище паролей было заблокировано, разблокируйте компьютер{% when "sign-in" %}нужно заново войти в аккаунт{% when "network" %}нет связи с сервисом{% when "provider" %}сервис ответил ошибкой{% when "setup" %}ошибка в настройках{% when "stopped" %}запуск остановили{% else %}программа завершилась с ошибкой{% endcase %}</p>
10
+ {{- nl }}<p style="margin:0 0 12px">Причина: {% case cause %}{% when "locked" %}хранилище паролей заблокировано или в нём нет входа: разблокируйте компьютер, а если он разблокирован, войдите заново{% when "sign-in" %}нужно заново войти в аккаунт{% when "network" %}нет связи с сервисом{% when "provider" %}сервис ответил ошибкой{% when "setup" %}ошибка в настройках{% when "stopped" %}запуск остановили{% else %}программа завершилась с ошибкой{% endcase %}</p>
11
+ {%- if check %}{{ nl }}<p style="margin:0 0 12px">Проверить: {{ check }}</p>{% endif -%}
11
12
  {%- for link in links %}{{ nl }}<p style="margin:0"><a href="{{ link.url }}" style="color:#3b82c4">{{ link.label }}</a></p>{% endfor -%}
12
13
  {{ nl }}</div>
@@ -6,5 +6,6 @@
6
6
  "since": "2026-11-05T08:31:00+03:00",
7
7
  "failures": 2,
8
8
  "cause": "sign-in",
9
- "refs": ["sync:memo"]
9
+ "refs": ["sync:memo"],
10
+ "check": "memo work doctor"
10
11
  }
@@ -5,5 +5,6 @@ Telegram HTML: only <b>, <i> and <a href> survive, and an href only to a link of
5
5
  {% endcapture -%}
6
6
  ⚠️ <b>{% if schedule == "morning-digest" %}The morning digest could not be built{% else %}The schedule “{{ tool }} {{ schedule }}” is failing{% endif %}</b>
7
7
  {{- nl }}{% if failures > 1 %}Failing since {{ since.date }}{% if since.time %}, {{ since.time }}{% endif %} · {{ failures }} runs in a row{% else %}Failed {% if at.day == "today" %}today{% elsif at.day == "yesterday" %}yesterday{% else %}on {{ at.date }}{% endif %}{% if at.time %} at {{ at.time }}{% endif %}{% endif %}
8
- {{- nl }}Why: {% case cause %}{% when "locked" %}the keyring was locked; unlock the computer{% when "sign-in" %}the account needs a new sign-in{% when "network" %}the service could not be reached{% when "provider" %}the service answered with an error{% when "setup" %}something is wrong in the settings{% when "stopped" %}the run was stopped{% else %}the program ended with an error{% endcase %}
8
+ {{- nl }}Why: {% case cause %}{% when "locked" %}the keyring is locked or holds no sign-in: unlock the computer, and if it is unlocked, sign in again{% when "sign-in" %}the account needs a new sign-in{% when "network" %}the service could not be reached{% when "provider" %}the service answered with an error{% when "setup" %}something is wrong in the settings{% when "stopped" %}the run was stopped{% else %}the program ended with an error{% endcase %}
9
+ {%- if check %}{{ nl }}Check: {{ check }}{% endif -%}
9
10
  {%- for link in links %}{{ nl }}<a href="{{ link.url }}">{{ link.label }}</a>{% endfor -%}
@@ -5,5 +5,6 @@ Telegram HTML: only <b>, <i> and <a href> survive, and an href only to a link of
5
5
  {% endcapture -%}
6
6
  ⚠️ <b>{% if schedule == "morning-digest" %}Утренняя сводка не собралась{% else %}Расписание «{{ tool }} {{ schedule }}» не работает{% endif %}</b>
7
7
  {{- nl }}{% if failures > 1 %}Не работает с {{ since.date }}{% if since.time %}, {{ since.time }}{% endif %} · {{ failures }} {% case plural %}{% when "one" %}запуск{% when "few" %}запуска{% else %}запусков{% endcase %} подряд{% else %}Сбой {% if at.day == "today" %}сегодня{% elsif at.day == "yesterday" %}вчера{% else %}{{ at.date }}{% endif %}{% if at.time %} в {{ at.time }}{% endif %}{% endif %}
8
- {{- nl }}Причина: {% case cause %}{% when "locked" %}хранилище паролей было заблокировано, разблокируйте компьютер{% when "sign-in" %}нужно заново войти в аккаунт{% when "network" %}нет связи с сервисом{% when "provider" %}сервис ответил ошибкой{% when "setup" %}ошибка в настройках{% when "stopped" %}запуск остановили{% else %}программа завершилась с ошибкой{% endcase %}
8
+ {{- nl }}Причина: {% case cause %}{% when "locked" %}хранилище паролей заблокировано или в нём нет входа: разблокируйте компьютер, а если он разблокирован, войдите заново{% when "sign-in" %}нужно заново войти в аккаунт{% when "network" %}нет связи с сервисом{% when "provider" %}сервис ответил ошибкой{% when "setup" %}ошибка в настройках{% when "stopped" %}запуск остановили{% else %}программа завершилась с ошибкой{% endcase %}
9
+ {%- if check %}{{ nl }}Проверить: {{ check }}{% endif -%}
9
10
  {%- for link in links %}{{ nl }}<a href="{{ link.url }}">{{ link.label }}</a>{% endfor -%}
@@ -5,5 +5,6 @@ Plain text: the email's plain part and the terminal.
5
5
  {% endcapture -%}
6
6
  ⚠️ {% if schedule == "morning-digest" %}The morning digest could not be built{% else %}The schedule “{{ tool }} {{ schedule }}” is failing{% endif %}
7
7
  {{- nl }}{% if failures > 1 %}Failing since {{ since.date }}{% if since.time %}, {{ since.time }}{% endif %} · {{ failures }} runs in a row{% else %}Failed {% if at.day == "today" %}today{% elsif at.day == "yesterday" %}yesterday{% else %}on {{ at.date }}{% endif %}{% if at.time %} at {{ at.time }}{% endif %}{% endif %}
8
- {{- nl }}Why: {% case cause %}{% when "locked" %}the keyring was locked; unlock the computer{% when "sign-in" %}the account needs a new sign-in{% when "network" %}the service could not be reached{% when "provider" %}the service answered with an error{% when "setup" %}something is wrong in the settings{% when "stopped" %}the run was stopped{% else %}the program ended with an error{% endcase %}
8
+ {{- nl }}Why: {% case cause %}{% when "locked" %}the keyring is locked or holds no sign-in: unlock the computer, and if it is unlocked, sign in again{% when "sign-in" %}the account needs a new sign-in{% when "network" %}the service could not be reached{% when "provider" %}the service answered with an error{% when "setup" %}something is wrong in the settings{% when "stopped" %}the run was stopped{% else %}the program ended with an error{% endcase %}
9
+ {%- if check %}{{ nl }}Check: {{ check }}{% endif -%}
9
10
  {%- for link in links %}{{ nl }}{{ link.label }}: {{ link.url }}{% endfor -%}
@@ -5,5 +5,6 @@ Plain text: the email's plain part and the terminal.
5
5
  {% endcapture -%}
6
6
  ⚠️ {% if schedule == "morning-digest" %}Утренняя сводка не собралась{% else %}Расписание «{{ tool }} {{ schedule }}» не работает{% endif %}
7
7
  {{- nl }}{% if failures > 1 %}Не работает с {{ since.date }}{% if since.time %}, {{ since.time }}{% endif %} · {{ failures }} {% case plural %}{% when "one" %}запуск{% when "few" %}запуска{% else %}запусков{% endcase %} подряд{% else %}Сбой {% if at.day == "today" %}сегодня{% elsif at.day == "yesterday" %}вчера{% else %}{{ at.date }}{% endif %}{% if at.time %} в {{ at.time }}{% endif %}{% endif %}
8
- {{- nl }}Причина: {% case cause %}{% when "locked" %}хранилище паролей было заблокировано, разблокируйте компьютер{% when "sign-in" %}нужно заново войти в аккаунт{% when "network" %}нет связи с сервисом{% when "provider" %}сервис ответил ошибкой{% when "setup" %}ошибка в настройках{% when "stopped" %}запуск остановили{% else %}программа завершилась с ошибкой{% endcase %}
8
+ {{- nl }}Причина: {% case cause %}{% when "locked" %}хранилище паролей заблокировано или в нём нет входа: разблокируйте компьютер, а если он разблокирован, войдите заново{% when "sign-in" %}нужно заново войти в аккаунт{% when "network" %}нет связи с сервисом{% when "provider" %}сервис ответил ошибкой{% when "setup" %}ошибка в настройках{% when "stopped" %}запуск остановили{% else %}программа завершилась с ошибкой{% endcase %}
9
+ {%- if check %}{{ nl }}Проверить: {{ check }}{% endif -%}
9
10
  {%- for link in links %}{{ nl }}{{ link.label }}: {{ link.url }}{% endfor -%}
@@ -5,7 +5,7 @@ import { tmpdir } from "node:os";
5
5
  import { basename, dirname, join, relative } from "node:path";
6
6
  import { CliError, errorCodes, writeSecurely } from "@wirecat/cli-base";
7
7
  import { linkConfigOf, linkFor } from "../domain/links.js";
8
- import { mailHolderVariable, readOnlyLockOf } from "../ports/app.js";
8
+ import { envName, mailHolderVariable, readOnlyLockOf } from "../ports/app.js";
9
9
  import { recordLogFor } from "../runs/record-log.js";
10
10
  import { childTrace } from "../runs/scope.js";
11
11
  import { storePath } from "../store/path.js";
@@ -406,6 +406,11 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
406
406
  if (!kept.has(stampOf(file)))
407
407
  rmSync(join(runs, file), { force: true });
408
408
  const title = `${app.command} ${schedule.name}`;
409
+ const messageOptions = async () => ({
410
+ language: await ownerLanguage(runEnv).catch(() => "ru"),
411
+ linkOf: (ref) => linkFor(ref, { form: "web", config: sharedLinks(runEnv), env: runEnv }),
412
+ ...(reportTemplates ? { templates: reportTemplates(runEnv, schedule.name) } : {}),
413
+ });
409
414
  // Routes the owner named for this run go whatever the schedule's notify says; none named, nobody is told.
410
415
  const mode = chosen === undefined ? notifyOf(schedule) : chosen.length ? "always" : "never";
411
416
  if (answered && exitCode === 0) {
@@ -419,7 +424,10 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
419
424
  }
420
425
  }
421
426
  else if (exitCode !== 0 && mode !== "never") {
422
- await notify(system, env, title, `failed (exit ${exitCode}) — ${errors}`);
427
+ // The notice's lines under its title (the notification's own title): since when, why, and the command to check.
428
+ const notice = await failureNotice(app, schedule, last, now(), await messageOptions());
429
+ const lines = notice?.text.split("\n").slice(1).join("\n");
430
+ await notify(system, env, title, lines ? `${lines}\n${errors}` : `failed (exit ${exitCode}) — ${errors}`);
423
431
  }
424
432
  const routes = chosen ?? schedule.to ?? [];
425
433
  const locked = readOnlyLockOf(app, runEnv);
@@ -435,11 +443,6 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
435
443
  }
436
444
  return deliveries;
437
445
  };
438
- const messageOptions = async () => ({
439
- language: await ownerLanguage(runEnv).catch(() => "ru"),
440
- linkOf: (ref) => linkFor(ref, { form: "web", config: sharedLinks(runEnv), env: runEnv }),
441
- ...(reportTemplates ? { templates: reportTemplates(runEnv, schedule.name) } : {}),
442
- });
443
446
  if (routes.length > 0 && (exitCode === 0 ? mode === "always" : mode !== "never")) {
444
447
  const at = shortTime(last.at);
445
448
  const notice = exitCode === 0 ? undefined : await failureNotice(app, schedule, last, now(), await messageOptions());
@@ -490,6 +493,7 @@ const failureNotice = async (app, schedule, last, at, options) => {
490
493
  failures: last.failures ?? 1,
491
494
  cause: lockedOut(last) ? "locked" : causeOf(last.errorCode, last.exitCode),
492
495
  refs: [`sync:${app.command}`],
496
+ check: [app.command, schedule.environment?.[envName(app, "PROFILE")], "doctor"].filter(Boolean).join(" "),
493
497
  };
494
498
  return prepareMessage("schedule-failed", (language) => noticeView(failure, { language, now: at.getTime(), linkOf: options.linkOf }), options).catch(() => undefined);
495
499
  };
@@ -21,9 +21,9 @@ export declare const sheetRangeOf: (input: string | undefined) => {
21
21
  /** The cells `values` fills from the range's top-left cell; a range of more than one cell must have their shape. */
22
22
  export declare const cellEditsOf: (sheet: string, range: string, values: CellValue[][]) => XlsxEdit[];
23
23
  /**
24
- * Mounts `<files> update`, `sheets show|update`, `documents show|update`, `history` and `restore` under the CLI's own
25
- * files group: Office files edited in place and earlier versions put back, every write at the sha256 it was read at
26
- * and with the replaced content kept (`guardedFileWrite`). The CLI keeps no `restore` of its own; a trash restore
27
- * goes in as `restoreFromTrash`.
24
+ * Mounts `<files> update`, `sheets show|update|create`, `documents show|update|create`, `history` and `restore` under
25
+ * the CLI's own files group: Office files created, edited in place and earlier versions put back. Every write over a
26
+ * file is at the sha256 it was read at and keeps the replaced content (`guardedFileWrite`); a create refuses a file
27
+ * already there. The CLI keeps no `restore` of its own; a trash restore goes in as `restoreFromTrash`.
28
28
  */
29
29
  export declare const addFileEditCommands: (files: Command, helpers: FileEditCommands) => void;
@@ -5,7 +5,7 @@ import { join } from "node:path";
5
5
  import { CliError, isCliError } from "@wirecat/cli-base";
6
6
  import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
7
7
  import * as v from "valibot";
8
- import { editDocxParagraphs, editXlsxCells, readDocxParagraphs, readXlsxCells, } from "../../office/index.js";
8
+ import { createDocx, createXlsx, editDocxParagraphs, editXlsxCells, NEW_PARAGRAPH_STYLES, readDocxParagraphs, readXlsxCells, } from "../../office/index.js";
9
9
  import { guardedFileWrite, remoteChanged } from "../../services/files/guarded-write.js";
10
10
  import { honoursDryRun } from "../dry-run-guard.js";
11
11
  import { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
@@ -113,6 +113,8 @@ const docxEditsOf = (payload) => payload.map((edit) => {
113
113
  };
114
114
  return edit;
115
115
  });
116
+ const NEW_PARAGRAPHS = v.pipe(v.array(v.strictObject({ text: v.string(), style: v.optional(v.picklist(NEW_PARAGRAPH_STYLES)) })), v.minLength(1));
117
+ const NEW_PARAGRAPHS_SHAPE = `paragraphs as JSON: [{"text": "…", "style": "Heading1"}]; a style is one of ${NEW_PARAGRAPH_STYLES.join(", ")}`;
116
118
  const addFileEditCommandsDefinition = (files, helpers) => {
117
119
  const { prefix, place } = wordsOf(helpers.words);
118
120
  const group = files.name();
@@ -150,6 +152,33 @@ const addFileEditCommandsDefinition = (files, helpers) => {
150
152
  }, command);
151
153
  helpers.output(itemOf(answer), command);
152
154
  };
155
+ /** Writes a new file that must not be there: a file already there is for `update`, which reads it first. */
156
+ const createNew = async (command, kind, input, extension, made) => {
157
+ const path = helpers.path(input);
158
+ if (!path.toLowerCase().endsWith(extension))
159
+ throw new CliError("validation_error", `${kind} create writes a ${extension} file; ${path} is not one`, {
160
+ reason: "office.wrong-format",
161
+ });
162
+ const answer = await helpers.write([], async ({ target, versions, signal }) => {
163
+ if (await target.exists(path, signal))
164
+ throw new CliError("conflict", `${path} exists; create never replaces a file. Read it (${show(kind, input)}) and change it with ` +
165
+ `${prefix} ${group} ${kind} update`, { reason: "office.file-exists" });
166
+ return inTemp(async (folder) => {
167
+ const from = join(folder, "new");
168
+ await writeFile(from, made.bytes, { mode: 0o600 });
169
+ const done = await guardedFileWrite({
170
+ target,
171
+ versions,
172
+ path,
173
+ from,
174
+ reread: show(kind, input),
175
+ ...(signal ? { signal } : {}),
176
+ });
177
+ return { path, sha256: done.file.sha256 ?? sha256(made.bytes), ...made.answer };
178
+ });
179
+ }, command);
180
+ helpers.output(itemOf(answer), command);
181
+ };
153
182
  const readOffice = async (command, input, answer) => {
154
183
  const path = helpers.path(input);
155
184
  const item = await helpers.read(async (port) => {
@@ -239,6 +268,22 @@ const addFileEditCommandsDefinition = (files, helpers) => {
239
268
  }
240
269
  });
241
270
  });
271
+ examples(annotate(sheets.command("create"), { effects: REMOTE_WRITE, offline: false })
272
+ .summary("create a new workbook from rows of values")
273
+ .description(`create a new .xlsx on ${place} with one sheet holding these rows from A1. Numbers and booleans are typed, a ` +
274
+ "text stays text, even one that starts with =. A file already there is refused: change it with sheets update")
275
+ .argument("<path>", `the new .xlsx file on ${place}`)
276
+ .option("--values <json>", "the rows as JSON; null leaves a cell empty")
277
+ .option("--name <name>", "the sheet's name; Sheet1 without it"), [`${prefix} ${group} sheets create /budget.xlsx --values '[["Item", "Cost"], ["Rent", 950]]' --name Budget`]).action(async function (input, args) {
278
+ if (args.values === undefined)
279
+ throw new CliError("validation_error", `give the rows with --values: ${VALUES_SHAPE}`, { param: "--values" });
280
+ const rows = jsonOf(args.values, "--values", VALUES, VALUES_SHAPE);
281
+ const name = args.name ?? "Sheet1";
282
+ await createNew(this, "sheets", input, ".xlsx", {
283
+ bytes: createXlsx({ sheets: [{ name, rows }] }),
284
+ answer: { sheets: [{ name, rows: rows.length }] },
285
+ });
286
+ });
242
287
  const documents = annotate(files.command("documents"), { effects: REMOTE_READ }).description(`the paragraphs of a Word document (.docx) on ${place}, read and changed in place`);
243
288
  examples(marksUntrusted(annotate(documents.command("show"), { effects: REMOTE_READ, offline: false }), ["paragraphs.text"])
244
289
  .summary("show a document's paragraphs and the sha256 to edit them at")
@@ -283,6 +328,25 @@ const addFileEditCommandsDefinition = (files, helpers) => {
283
328
  };
284
329
  });
285
330
  });
331
+ examples(annotate(documents.command("create"), { effects: REMOTE_WRITE, offline: false })
332
+ .summary("create a new Word document from paragraphs")
333
+ .description(`create a new .docx on ${place} with these paragraphs, each in a style: ${NEW_PARAGRAPH_STYLES.join(", ")} ` +
334
+ "(Normal without one; ListBullet is a bullet list). A file already there is refused: change it with " +
335
+ "documents update")
336
+ .argument("<path>", `the new .docx file on ${place}`)
337
+ .option("--payload <json>", "the paragraphs as JSON: [{text, style?}]"), [
338
+ `${prefix} ${group} documents create /report.docx --payload '[{"text": "Report", "style": "Title"}, {"text": "Revenue grew 12%."}]'`,
339
+ ]).action(async function (input, args) {
340
+ if (args.payload === undefined)
341
+ throw new CliError("validation_error", `give the paragraphs with --payload: ${NEW_PARAGRAPHS_SHAPE}`, {
342
+ param: "--payload",
343
+ });
344
+ const paragraphs = jsonOf(args.payload, "--payload", NEW_PARAGRAPHS, NEW_PARAGRAPHS_SHAPE);
345
+ await createNew(this, "documents", input, ".docx", {
346
+ bytes: createDocx({ paragraphs }),
347
+ answer: { paragraphs: paragraphs.length },
348
+ });
349
+ });
286
350
  examples(annotate(files.command("history"), { effects: REMOTE_READ, offline: false })
287
351
  .summary("list the earlier versions of a file kept on this computer")
288
352
  .description("list what the writes and syncs of this profile replaced in a file, newest last. Each entry's version is the " +
@@ -349,9 +413,9 @@ const addFileEditCommandsDefinition = (files, helpers) => {
349
413
  addFileUpdateCommand(files, helpers);
350
414
  };
351
415
  /**
352
- * Mounts `<files> update`, `sheets show|update`, `documents show|update`, `history` and `restore` under the CLI's own
353
- * files group: Office files edited in place and earlier versions put back, every write at the sha256 it was read at
354
- * and with the replaced content kept (`guardedFileWrite`). The CLI keeps no `restore` of its own; a trash restore
355
- * goes in as `restoreFromTrash`.
416
+ * Mounts `<files> update`, `sheets show|update|create`, `documents show|update|create`, `history` and `restore` under
417
+ * the CLI's own files group: Office files created, edited in place and earlier versions put back. Every write over a
418
+ * file is at the sha256 it was read at and keeps the replaced content (`guardedFileWrite`); a create refuses a file
419
+ * already there. The CLI keeps no `restore` of its own; a trash restore goes in as `restoreFromTrash`.
356
420
  */
357
421
  export const addFileEditCommands = honoursDryRun(sharedCommand(addFileEditCommandsDefinition));
@@ -6,6 +6,7 @@ import { agentOf } from "../runs/run-context.js";
6
6
  import { enrichmentState } from "../services/enrichment.js";
7
7
  import { ENRICHMENT_PROVIDERS, enrichmentEndpoint, isEnrichmentProvider, readEnrichmentSetting, writeEnrichmentSetting, } from "../services/enrichment-setting.js";
8
8
  import { openStore } from "../store/store.js";
9
+ import { environmentOf } from "./context.js";
9
10
  import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
10
11
  import { itemOf } from "./envelope.js";
11
12
  const withStore = async (env, work) => {
@@ -57,7 +58,7 @@ export const enrichmentConsentsCommand = (app, options) => {
57
58
  throw new CliError("validation_error", `enrichment goes to ${ENRICHMENT_PROVIDERS.join(" or ")}, not ${provider}`);
58
59
  const env = options.env();
59
60
  // An agent that turned this on would send the owner's whole store out; only the owner may.
60
- if (agentOf(env) && given.yes)
61
+ if ((environmentOf(this).agent || agentOf(env)) && given.yes)
61
62
  throw new CliError("permission_error", "only the owner turns enrichment on, not an agent", {
62
63
  reason: "enrichment.owner-only",
63
64
  });
@@ -78,6 +78,7 @@ const catchUpList = (command, found, hearing, reader, { transcribe, first = [],
78
78
  ...(found.quiet > 0
79
79
  ? [{ field: "items", why: `${found.quiet} muted or archived chats left out`, step: `${command}.all` }]
80
80
  : []),
81
+ ...(found.left ?? []).map((why) => ({ field: "items", why })),
81
82
  ...hearingMissing(hearing, transcribe),
82
83
  ...left,
83
84
  ];
@@ -12,6 +12,7 @@ import { saveFiles } from "../../services/file-download.js";
12
12
  export { safeName } from "../../files/safe-name.js";
13
13
  export { downloadMessage, save } from "../../services/file-download.js";
14
14
  import { parseDuration } from "../../domain/duration.js";
15
+ import { refusedPlace } from "../../sends/upload.js";
15
16
  import { OFFLINE } from "../../services/deps.js";
16
17
  import { patiently } from "../../services/patience.js";
17
18
  import { FETCH } from "../effects.js";
@@ -42,6 +43,8 @@ export const downloadSubcommand = (messages, messenger) => annotate(messages.com
42
43
  .action(async function (chat, messageId) {
43
44
  const context = messengerContext(this, messenger);
44
45
  const { outputDir: output, all, pause, extract, attachment, } = this.opts();
46
+ if (refusedPlace(output, messenger.app, context.env))
47
+ throw new CliError("validation_error", "--output-dir cannot write credential folders, the CLI's own folders or the message store");
45
48
  if (context.settings.offline) {
46
49
  if (all || extract)
47
50
  throw new CliError("validation_error", "--offline copies one message's saved files; leave out --all and --extract");
@@ -74,7 +74,10 @@ export const inboxCommand = (messenger) => annotate(new Command("inbox"), {
74
74
  const hearing = await hearForCommand(context, messenger, read, transcribe === true, hearWith, connect);
75
75
  return { inbox, hearing, reader };
76
76
  });
77
- if (inbox.partial && format === "pretty")
77
+ if (format === "pretty")
78
+ for (const why of inbox.left ?? [])
79
+ renderer.warn(why);
80
+ if (inbox.partial && !inbox.left?.length && format === "pretty")
78
81
  renderer.warn(PARTIAL_NOTE);
79
82
  const answer = inboxAnswer(inbox, hearing, reader, transcribe === true, meta);
80
83
  renderAnswer(this, context, answer, () => {
@@ -109,7 +109,10 @@ const notes = (found, pretty, renderer) => {
109
109
  if (found.tasks && found.tasks.added + found.tasks.closed > 0)
110
110
  renderer.note(`tasks: ${found.tasks.added} opened, ${found.tasks.closed} closed by the rules` +
111
111
  (found.tasks.review > 0 ? `, ${found.tasks.review} pair(s) to review — tasks duplicates list` : ""));
112
- if (found.partial && pretty)
112
+ if (pretty)
113
+ for (const why of found.left ?? [])
114
+ renderer.warn(why);
115
+ if (found.partial && !found.left?.length && pretty)
113
116
  renderer.warn(PARTIAL_NOTE);
114
117
  if (found.offline && pretty)
115
118
  renderer.warn(OFFLINE_REVIEW);
@@ -332,6 +332,7 @@ export const allHitItem = (item) => item.kind === "meeting"
332
332
  ref: item.ref,
333
333
  provider: item.provider,
334
334
  account: item.account,
335
+ accounts: item.accounts,
335
336
  title: item.title,
336
337
  timestamp: item.timestamp,
337
338
  url: item.url,
@@ -7,12 +7,13 @@ import { backfillSchedule } from "../../background/backfill.js";
7
7
  import { parseRoute, ROUTE_HELP, routeText } from "../../background/deliver.js";
8
8
  import { REPORT_CHANNELS } from "../../background/report/render.js";
9
9
  import { reportKeysOf } from "../../background/report/stored-templates.js";
10
- import { calendarOf, describeWhen, isCalendar, lastRun, listSchedules, NOTIFY_WHEN, notifyOf, readSchedule, recordSkip, runSchedule, SCHEDULE_DEFAULTS, SKIP_REASONS, scheduleFile, scheduleName, slotsOf, spentToday, timerFor, WEEKDAYS, } from "../../background/schedules.js";
10
+ import { calendarOf, describeWhen, isCalendar, lastRun, listSchedules, NOTIFY_WHEN, notifyOf, readSchedule, recordSkip, runSchedule, SCHEDULE_DEFAULTS, SKIP_REASONS, scheduleFile, scheduleName, schedulesDir, slotsOf, spentToday, timerFor, WEEKDAYS, } from "../../background/schedules.js";
11
11
  import { thisMachine } from "../../background/system.js";
12
12
  import { locationVariables } from "../../background/units.js";
13
13
  import { parseDuration } from "../../domain/duration.js";
14
14
  import { HOLDER } from "../../mail/marks.js";
15
15
  import { readOnlyLockOf } from "../../ports/app.js";
16
+ import { inside, realPathOf } from "../../sends/upload.js";
16
17
  import { aheadOf } from "../../services/moment.js";
17
18
  import { openCache } from "../../store/open.js";
18
19
  import { storePath } from "../../store/path.js";
@@ -678,6 +679,8 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, agentInpu
678
679
  .action(setPaused(false));
679
680
  annotate(command.command("exec"), {
680
681
  effects: REMOTE_WRITE,
682
+ // An agent runs a saved schedule by its name with `schedule run`, never a file it names.
683
+ mcp: false,
681
684
  examples: [`${app.command} schedule exec ~/.local/share/${app.appName}/schedules/health/schedule.json`],
682
685
  })
683
686
  .description("what a timer runs, given the schedule's file; to run one by hand, use run")
@@ -686,6 +689,12 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, agentInpu
686
689
  .action(async function (file, seal) {
687
690
  // A timer starts it with no profile named; the schedule's own environment carries the profile.
688
691
  const { context, system, timer } = prepare(this, { needsProfile: false });
692
+ const folder = realPathOf(schedulesDir(scheduleState({ app, env: context.env })));
693
+ const real = realPathOf(file);
694
+ if (real === folder || !inside(real, folder))
695
+ throw new CliError("permission_error", `schedule exec runs only a schedule saved in ${folder}, not ${file}`, {
696
+ reason: "schedule.outside-folder",
697
+ });
689
698
  // A timer left behind by a pause that could not remove it must not run the schedule.
690
699
  if (existsSync(file) && readSchedule(file).paused)
691
700
  return;
@@ -7,6 +7,7 @@ import { agentOf } from "../runs/run-context.js";
7
7
  import { keyLookup, keyVariable } from "../services/enrichment.js";
8
8
  import { ENRICHMENT_PROVIDERS, enrichmentEndpoint, enrichmentPrice, isEnrichmentProvider, readEnrichmentSetting, } from "../services/enrichment-setting.js";
9
9
  import { HARDER_CANDIDATES, HARDER_CHARS, HARDER_MODELS, HARDER_TIMEOUT_S, harderTimeoutSeconds, readHarderSetting, readHarderTimeout, writeHarderSetting, writeHarderTimeout, } from "../services/search-harder.js";
10
+ import { environmentOf } from "./context.js";
10
11
  import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
11
12
  import { itemOf } from "./envelope.js";
12
13
  // One search: 30 hits of up to 400 characters plus the prompt, and a short list of hit numbers back.
@@ -98,7 +99,7 @@ export const harderConsentsCommand = (app, options) => {
98
99
  throw new CliError("validation_error", "--base-url needs --model: name the model that API serves");
99
100
  const env = options.env();
100
101
  // An agent that turned this on would decide for the owner that his records may leave the machine.
101
- if (agentOf(env) && given.yes)
102
+ if ((environmentOf(this).agent || agentOf(env)) && given.yes)
102
103
  throw new CliError("permission_error", "only the owner allows search all --harder, not an agent", {
103
104
  reason: "search-harder.owner-only",
104
105
  });
@@ -12,7 +12,8 @@ import { listSchedules } from "../background/schedules.js";
12
12
  import { template } from "../entities/index.js";
13
13
  import { agentOf } from "../runs/run-context.js";
14
14
  import { openStore } from "../store/store.js";
15
- import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
15
+ import { environmentOf } from "./context.js";
16
+ import { grantsAuthority, LOCAL_READ, LOCAL_WRITE, ownerOnlyOption } from "./effects.js";
16
17
  import { itemOf, listOf } from "./envelope.js";
17
18
  import { queryTerms, withQuery } from "./list-query.js";
18
19
  import { ownerLanguageOf, scheduleState } from "./schedule/schedule-command.js";
@@ -80,9 +81,9 @@ const addressOf = async (key, given, env, state) => {
80
81
  const appliedBody = (store, address, kind, schedule) => reportKeysOf(kind, schedule)
81
82
  .map((key) => store.templates.get({ ...address, key })?.body)
82
83
  .find((body) => body !== undefined);
83
- const refuseAgent = (env) => {
84
+ const refuseAgent = (command, env) => {
84
85
  // A template decides what every later digest says to the owner; an agent could make it hide or invent things.
85
- if (agentOf(env))
86
+ if (environmentOf(command).agent || agentOf(env))
86
87
  throw new CliError("permission_error", "only the owner changes a message template, not an agent", {
87
88
  reason: "template.owner-only",
88
89
  });
@@ -180,7 +181,7 @@ export const templatesCommand = (app, options) => {
180
181
  .addOption(new Option("--undo", "put back the body your last change replaced; twice is back where you were").conflicts("file"))
181
182
  .action(async function (key, given) {
182
183
  const env = options.env();
183
- refuseAgent(env);
184
+ refuseAgent(this, env);
184
185
  const { address, kind, channel, schedule } = await addressOf(key, given, env, stateOf(app, env));
185
186
  const { current, previous } = await withStore(env, (store) => ({
186
187
  current: appliedBody(store, address, kind, schedule),
@@ -248,7 +249,7 @@ export const templatesCommand = (app, options) => {
248
249
  .argument("<key>", "the template, such as report/morning-digest")
249
250
  .addOption(channelOption())
250
251
  .addOption(localeOption())
251
- .option("--file <file>", "preview this draft instead of the template that applies; - reads stdin")
252
+ .addOption(ownerOnlyOption("--file <file>", "preview this draft instead of the template that applies; - reads stdin"))
252
253
  .action(async function (key, given) {
253
254
  const env = options.env();
254
255
  const { address, kind, channel, schedule } = await addressOf(key, given, env, stateOf(app, env));
@@ -279,7 +280,7 @@ export const templatesCommand = (app, options) => {
279
280
  .addOption(localeOption())
280
281
  .action(async function (key, given) {
281
282
  const env = options.env();
282
- refuseAgent(env);
283
+ refuseAgent(this, env);
283
284
  const { address } = await addressOf(key, given, env, stateOf(app, env));
284
285
  const changed = await withStore(env, (store) => store.templates.reset(address));
285
286
  options.diagnostic(changed