@infaris/calendar-cli 0.9.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/README.md +426 -0
- package/dist/activity.js +165 -0
- package/dist/api.js +409 -0
- package/dist/auth.js +378 -0
- package/dist/browser.js +24 -0
- package/dist/config.js +196 -0
- package/dist/crm-api.js +37 -0
- package/dist/crm-index.js +198 -0
- package/dist/dates.js +164 -0
- package/dist/event-input.js +39 -0
- package/dist/freebusy.js +92 -0
- package/dist/hours-cli.js +335 -0
- package/dist/hours.js +276 -0
- package/dist/index.js +1047 -0
- package/dist/legacy.js +43 -0
- package/dist/selectors.js +49 -0
- package/dist/task-download.js +56 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
# @infaris/calendar-cli
|
|
2
|
+
|
|
3
|
+
Command line interface for [Calendar](https://calendar.infaris.com). Log in
|
|
4
|
+
once on your device with a browser (or have an AI agent relay the sign-in
|
|
5
|
+
through chat, see below), then read your agenda, find free time,
|
|
6
|
+
create/move/delete events, manage work tasks (with image attachments), stage
|
|
7
|
+
mail concepts and fill the urenstaat from your terminal (or from tools like
|
|
8
|
+
Claude Code, Codex, OpenCode or Cursor).
|
|
9
|
+
|
|
10
|
+
Built for AI assistants: every read command supports `--json`, accepts relative
|
|
11
|
+
dates ("today", "tomorrow", "+3d", "tomorrow 09:00"), and the agenda expands
|
|
12
|
+
recurring events into concrete occurrences so an agent can answer "what's on my
|
|
13
|
+
calendar?" without understanding RRULEs.
|
|
14
|
+
|
|
15
|
+
It also respects your Calendar **settings**: new events land on your default
|
|
16
|
+
calendar and use your default duration, `free` uses your configured working
|
|
17
|
+
hours, weekend visibility and week start. Override any of these with flags.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g @infaris/calendar-cli
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This installs `infaris-calendar` and `infaris-crm` (customer dossiers, same login).
|
|
26
|
+
|
|
27
|
+
## Log in
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
infaris-calendar login
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This opens your browser, signs you in through Infaris (OAuth with loopback
|
|
34
|
+
PKCE, same flow as the Env CLI CLI), and stores tokens in
|
|
35
|
+
`~/.infaris-calendar/credentials.json`. Only Infaris **admin** accounts can use the
|
|
36
|
+
CLI (Calendar is an internal tool), and your account must have signed in
|
|
37
|
+
to the Calendar web app at least once.
|
|
38
|
+
|
|
39
|
+
Access tokens are short-lived and refreshed automatically via the stored
|
|
40
|
+
refresh token; you only need to log in again when the refresh token expires
|
|
41
|
+
(30 days of inactivity).
|
|
42
|
+
|
|
43
|
+
### Signing in over SSH / a remote session (e.g. t3code)
|
|
44
|
+
|
|
45
|
+
The default flow opens a browser on the same machine that runs the CLI and
|
|
46
|
+
waits for Infaris to redirect back to a local port - that only works when the
|
|
47
|
+
CLI and the browser are on the same box. When you're on a remote/SSH session,
|
|
48
|
+
run:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
infaris-calendar login --manual
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
(an SSH session is auto-detected via `$SSH_CONNECTION`/`$SSH_TTY`, so most of
|
|
55
|
+
the time you don't even need the flag). Instead of a local callback, it prints
|
|
56
|
+
a URL to open on any device - your Windows laptop, phone, whatever has a
|
|
57
|
+
browser. After you sign in there, Infaris shows your code on a page with a
|
|
58
|
+
Copy button. Paste it back into the terminal.
|
|
59
|
+
|
|
60
|
+
### Signing in through an AI agent (Claude Code, Codex, OpenCode, Cursor)
|
|
61
|
+
|
|
62
|
+
`login --manual` needs one process to stay open waiting for your paste, which
|
|
63
|
+
doesn't work when an agent is relaying the URL and code through a chat instead
|
|
64
|
+
of a live terminal. For that, the sign-in is split into two separate commands:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
infaris-calendar login link # 1. prints a URL, then exits immediately
|
|
68
|
+
infaris-calendar login code <value> # 2. run later, once you have the code
|
|
69
|
+
printf '%s' "$CODE" | infaris-calendar login code - # same, keeps the code out of argv/history
|
|
70
|
+
infaris-calendar login status --json # signed-in account + pending link, never tokens
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Re-running `login link` prints the same URL while the pending sign-in still has
|
|
74
|
+
more than 5 minutes left, so an agent retry never invalidates the link you are
|
|
75
|
+
completing; `login link --new` forces a fresh one. Token refreshes are locked
|
|
76
|
+
across processes, so parallel agents sharing one home don't rotate the same
|
|
77
|
+
refresh token twice (Infaris revokes the whole token family on reuse). Without
|
|
78
|
+
a terminal, `login --manual` fails immediately with the `login link` hint
|
|
79
|
+
instead of hanging.
|
|
80
|
+
|
|
81
|
+
`login link` stores the pending PKCE state under `~/.infaris-calendar/` (expires
|
|
82
|
+
after 15 minutes) and exits, so an agent can post the printed URL in the chat;
|
|
83
|
+
you open it on your own device, sign in, and Infaris shows your code with a
|
|
84
|
+
Copy button. Paste that code back to the agent, which runs
|
|
85
|
+
`login code <value>` to finish. A wrong or expired paste doesn't invalidate the
|
|
86
|
+
pending sign-in - rerun `login code` with the right value without starting
|
|
87
|
+
over, as long as you're still inside the 15-minute window.
|
|
88
|
+
|
|
89
|
+
To point at a non-production instance:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
infaris-calendar login --url http://localhost:3000
|
|
93
|
+
# or set it for the whole session:
|
|
94
|
+
export INFARIS_CALENDAR_URL=http://localhost:3000
|
|
95
|
+
# the OAuth issuer can be overridden too:
|
|
96
|
+
export INFARIS_CALENDAR_ISSUER=https://infaris.com
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Read your agenda
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
infaris-calendar agenda # today
|
|
103
|
+
infaris-calendar agenda --tomorrow
|
|
104
|
+
infaris-calendar agenda --week # current week (Mon-Sun)
|
|
105
|
+
infaris-calendar agenda --month
|
|
106
|
+
infaris-calendar agenda --days 7 # next 7 days
|
|
107
|
+
infaris-calendar agenda --from 2026-07-01 --to 2026-07-07
|
|
108
|
+
infaris-calendar agenda --calendar <id> # one calendar only
|
|
109
|
+
infaris-calendar agenda --week --json # full details for an AI assistant
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Calendars you've turned off (hidden) in Calendar are excluded, just like in
|
|
113
|
+
the web app. Pass `--include-hidden` to show them, or `--calendar <id>` to target
|
|
114
|
+
one specific calendar regardless of its visibility.
|
|
115
|
+
|
|
116
|
+
Recurring events are expanded into individual occurrences within the range by
|
|
117
|
+
default (pass `--no-expand` to get the raw master events with their RRULE).
|
|
118
|
+
`--json` includes every detail: description, location, attendees, status,
|
|
119
|
+
timezone, colour, the calendar id and name, and `recurringEventId`/`isOccurrence`
|
|
120
|
+
for expanded occurrences.
|
|
121
|
+
|
|
122
|
+
`list events` is an alias for `agenda`.
|
|
123
|
+
|
|
124
|
+
Agenda options:
|
|
125
|
+
|
|
126
|
+
| Flag | Description |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| `--from <date>` | Range start (ISO, or `today`/`tomorrow`/`+3d`) |
|
|
129
|
+
| `--to <date>` | Range end (inclusive) |
|
|
130
|
+
| `--days <n>` | Number of days from `--from` or today |
|
|
131
|
+
| `--today` / `--tomorrow` | Single day (today is the default) |
|
|
132
|
+
| `--week` / `--month` | Current week (Mon-Sun) / calendar month |
|
|
133
|
+
| `--calendar <id>` | Only events from this calendar id |
|
|
134
|
+
| `--search <text>` | Filter by title, description or location |
|
|
135
|
+
| `--include-hidden` | Also include calendars you turned off |
|
|
136
|
+
| `--no-expand` | Do not expand recurring events |
|
|
137
|
+
| `--json` | Output as JSON |
|
|
138
|
+
|
|
139
|
+
## List your calendars
|
|
140
|
+
|
|
141
|
+
Your personal calendar, location/shared calendars and any connected Google/
|
|
142
|
+
iCloud/Microsoft/CalDAV accounts:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
infaris-calendar calendars
|
|
146
|
+
infaris-calendar calendars --json
|
|
147
|
+
infaris-calendar calendars --set-default "Arjan"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Use the printed calendar id with `agenda --calendar` and `free --calendar`.
|
|
151
|
+
`create event --calendar`, `update event --calendar` and `--set-default` accept
|
|
152
|
+
either an exact calendar name or an id and only select a writable calendar.
|
|
153
|
+
|
|
154
|
+
## Create a calendar event
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
infaris-calendar create event --title "Lunch with client" \
|
|
158
|
+
--start "tomorrow 12:00" --duration 60 --location "Café Central, Amsterdam"
|
|
159
|
+
|
|
160
|
+
infaris-calendar create event -t "Sprint review" \
|
|
161
|
+
--start 2026-07-01T14:00 --end 2026-07-01T15:00 --calendar <id>
|
|
162
|
+
|
|
163
|
+
infaris-calendar create event -t "Day off" --start 2026-07-04 --all-day
|
|
164
|
+
|
|
165
|
+
infaris-calendar create event -t "Conference" \
|
|
166
|
+
--start 2026-10-19 --end 2026-10-20 --all-day \
|
|
167
|
+
--calendar "Arjan" --attendee Michan Noah
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
New timed events that overlap something already on your calendar print a
|
|
171
|
+
non-blocking warning (turn it off with `--no-conflict-check`).
|
|
172
|
+
|
|
173
|
+
| Flag | Description | Default |
|
|
174
|
+
| --- | --- | --- |
|
|
175
|
+
| `-t, --title` | Event title (required) | — |
|
|
176
|
+
| `-s, --start` | Start (ISO or relative, required) | — |
|
|
177
|
+
| `-e, --end` | End (ISO or relative). With `--all-day`, the date is inclusive | start + duration |
|
|
178
|
+
| `--duration <minutes>` | Used when `--end` is omitted | your settings (60) |
|
|
179
|
+
| `-a, --attendee <people...>` | Invite team members by first name, full name or email | none |
|
|
180
|
+
| `--all-day` | All-day event | — |
|
|
181
|
+
| `-l, --location` | Location | — |
|
|
182
|
+
| `-d, --description` / `--description-file` | Description (file `-` = stdin) | — |
|
|
183
|
+
| `--calendar <id>` | Target calendar | your default calendar |
|
|
184
|
+
| `--no-conflict-check` | Skip the overlap warning | — |
|
|
185
|
+
| `--json` | Output the created event as JSON | — |
|
|
186
|
+
|
|
187
|
+
## Your next event
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
infaris-calendar next # next 3 upcoming events
|
|
191
|
+
infaris-calendar next --limit 1 # just the next one
|
|
192
|
+
infaris-calendar next --days 7 --json
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Find free time
|
|
196
|
+
|
|
197
|
+
Find open slots within working hours, in your local timezone. All-day events
|
|
198
|
+
(e.g. holidays) count as busy by default. Weekends are skipped unless you ask
|
|
199
|
+
for them.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
infaris-calendar free --tomorrow # gaps tomorrow
|
|
203
|
+
infaris-calendar free --week --min 60 # 1h+ slots this week
|
|
204
|
+
infaris-calendar free --days 5 --work-start 08:00 --work-end 18:00
|
|
205
|
+
infaris-calendar free --week --json # for an AI to pick a slot
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
| Flag | Description | Default |
|
|
209
|
+
| --- | --- | --- |
|
|
210
|
+
| range flags | Same as `agenda` (`--today`/`--week`/`--days`/`--from`...) | today |
|
|
211
|
+
| `--work-start <HH:mm>` / `--work-end <HH:mm>` | Working hours | your settings (09:00 / 17:00) |
|
|
212
|
+
| `--min <minutes>` | Minimum slot length to report | `30` |
|
|
213
|
+
| `--include-weekends` | Include Saturday and Sunday | your settings |
|
|
214
|
+
| `--ignore-all-day` | Don't treat all-day events as busy | off |
|
|
215
|
+
| `--calendar <id>` | Only consider this calendar as busy | all |
|
|
216
|
+
| `--json` | Output slots as JSON | — |
|
|
217
|
+
|
|
218
|
+
## Show, reschedule or delete an event
|
|
219
|
+
|
|
220
|
+
Get the event id from `agenda --json` (or `next --json`), then:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
infaris-calendar show event <id> # full details
|
|
224
|
+
infaris-calendar show event <id> --json
|
|
225
|
+
|
|
226
|
+
infaris-calendar update event --id <id> --start "tomorrow 15:00" --end "tomorrow 16:00"
|
|
227
|
+
infaris-calendar update event --id <id> --shift 15 # move 15 min later (-15 = earlier)
|
|
228
|
+
infaris-calendar update event --id <id> --title "New title" --location "Room 2"
|
|
229
|
+
infaris-calendar update event --id <id> --attendee Michan Noah
|
|
230
|
+
infaris-calendar update event --id <id> --clear-attendees
|
|
231
|
+
|
|
232
|
+
infaris-calendar delete event --id <id>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
For recurring events the change applies to the whole series (the CLI tells you
|
|
236
|
+
when that's the case).
|
|
237
|
+
|
|
238
|
+
| `update event` flag | Description |
|
|
239
|
+
| --- | --- |
|
|
240
|
+
| `--id <id>` | Event id (required) |
|
|
241
|
+
| `-t, --title` / `-l, --location` / `-d, --description` | Edit fields |
|
|
242
|
+
| `-s, --start` / `-e, --end` | New start/end (ISO or relative) |
|
|
243
|
+
| `--shift <minutes>` | Move the whole event by N minutes (+later, -earlier) |
|
|
244
|
+
| `--calendar <id>` | Move to another calendar |
|
|
245
|
+
| `-a, --attendee <people...>` | Replace attendees by first name, full name or email |
|
|
246
|
+
| `--clear-attendees` | Remove all attendees |
|
|
247
|
+
| `--json` | Output the updated event as JSON |
|
|
248
|
+
|
|
249
|
+
## Create a task
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
infaris-calendar create task \
|
|
253
|
+
--title "Agent: collect disk I/O metrics" \
|
|
254
|
+
--product pulseguard \
|
|
255
|
+
--priority medium \
|
|
256
|
+
--type development \
|
|
257
|
+
--category feature_request \
|
|
258
|
+
--description "Add per-disk read/write throughput and IOPS to the agent."
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Long descriptions can be read from a file (or stdin with `-`):
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
infaris-calendar create task --title "..." --product pulseguard --description-file ./task.md
|
|
265
|
+
cat task.md | infaris-calendar create task --title "..." --description-file -
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Options:
|
|
269
|
+
|
|
270
|
+
| Flag | Description | Default |
|
|
271
|
+
| --- | --- | --- |
|
|
272
|
+
| `-t, --title` | Task title (required) | — |
|
|
273
|
+
| `-p, --product` | `general`, `pulseguard`, `pulsefiles`, `pulseqr`, `pulsecalendar`, `pulsesupport`, `pulsemail`, `ipulse` | `pulseguard` |
|
|
274
|
+
| `-d, --description` | Markdown description | — |
|
|
275
|
+
| `--description-file` | Read description from a file (`-` = stdin) | — |
|
|
276
|
+
| `--priority` | `high`, `medium`, `low` | `medium` |
|
|
277
|
+
| `--status` | `not_started`, `in_progress`, `done` | `not_started` |
|
|
278
|
+
| `--type` | one or more of `general`, `development`, `marketing` | `development` |
|
|
279
|
+
| `--category` | one or more of `bug`, `refinement`, `feature_request` | — |
|
|
280
|
+
| `--relation-number` | linked customer relation number | — |
|
|
281
|
+
| `--due` | due date (ISO) | — |
|
|
282
|
+
| `--image <paths...>` | attach image(s) or a PDF (max 10 MB each) | — |
|
|
283
|
+
| `--json` | print the created task as JSON | — |
|
|
284
|
+
|
|
285
|
+
## Attach a file to a task
|
|
286
|
+
|
|
287
|
+
Add an image or PDF to a task after the fact (creating a task already accepts
|
|
288
|
+
`--image` directly):
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
infaris-calendar attach task --id 427 ./screenshot.png
|
|
292
|
+
infaris-calendar attach task --id 427 ./screenshot.png ./logs.pdf
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
10 MB per file, same limit as the web app's attachment upload.
|
|
296
|
+
|
|
297
|
+
## Stage a mail draft
|
|
298
|
+
|
|
299
|
+
Prepares an editable concept in your own webmail; it never sends anything.
|
|
300
|
+
Open the printed URL to review and send it from `/dashboard/mail`.
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
infaris-calendar mail draft --to client@example.com --subject "Offerte" \
|
|
304
|
+
--body "<p>Hoi,</p><p>Zie bijlage.</p>" --attach ./offerte.pdf
|
|
305
|
+
|
|
306
|
+
infaris-calendar mail draft --to client@example.com --subject "Screenshot" \
|
|
307
|
+
--body-file ./mail.html --from support@ipulse.one --json
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
| Flag | Description |
|
|
311
|
+
| --- | --- |
|
|
312
|
+
| `--to <email>` | Recipient (required) |
|
|
313
|
+
| `--subject <text>` | Subject |
|
|
314
|
+
| `--body <html>` / `--body-file <path>` | HTML body (file `-` = stdin) |
|
|
315
|
+
| `--from <email>` | Preferred sender mailbox address |
|
|
316
|
+
| `--attach <path>` | Image or PDF to attach (max 10 MB) |
|
|
317
|
+
| `--json` | Output the draft id/url as JSON |
|
|
318
|
+
|
|
319
|
+
## List tasks
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
infaris-calendar list tasks
|
|
323
|
+
infaris-calendar list tasks --status in_progress
|
|
324
|
+
infaris-calendar list tasks --search agent --include-done
|
|
325
|
+
infaris-calendar list tasks --assignee me --json
|
|
326
|
+
infaris-calendar list tasks --json
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Urenstaat
|
|
330
|
+
|
|
331
|
+
Fill https://calendar.infaris.com/dashboard/hours from Calendar tasks, git
|
|
332
|
+
commits (`IF-687` / `#687` in the subject; legacy `IP-687` also works) and GitHub PRs for that day.
|
|
333
|
+
Needs `infaris-calendar login`, a git checkout, and optionally `gh auth login`.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
infaris-calendar hours # today
|
|
337
|
+
infaris-calendar hours --week
|
|
338
|
+
infaris-calendar hours fill # draft from tasks + commits + PRs
|
|
339
|
+
infaris-calendar hours fill --date yesterday --json
|
|
340
|
+
infaris-calendar hours fill --date 2026-09-02 --write
|
|
341
|
+
infaris-calendar hours fill --date yesterday --write --replace # overwrite
|
|
342
|
+
infaris-calendar hours log --date today --hours 8 --notes "#687 uren-skill"
|
|
343
|
+
infaris-calendar hours delete --date today
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
`hours fill` writes nothing until you pass `--write`. If that day already has a
|
|
347
|
+
row, it refuses unless you also pass `--replace`. Hours default to your
|
|
348
|
+
weekday default (8u on a normal weekday). Notes are one summarised line:
|
|
349
|
+
Guard / Calendar / Env / reviews / meetings, with task keys in parentheses.
|
|
350
|
+
|
|
351
|
+
## Other commands
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
infaris-calendar whoami # show the logged-in account
|
|
355
|
+
infaris-calendar logout # remove the stored token
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## How auth works
|
|
359
|
+
|
|
360
|
+
The CLI is a public OAuth client (`pulsecalendar-cli`, a server-side registration) on the Infaris identity
|
|
361
|
+
provider, using authorization code + PKCE with a loopback redirect (same
|
|
362
|
+
pattern as `gh auth login` and the Env CLI CLI):
|
|
363
|
+
|
|
364
|
+
1. The CLI starts a one-shot HTTP server on `127.0.0.1:47655`.
|
|
365
|
+
2. It opens `https://infaris.com/api/oauth/authorize` in your browser with a
|
|
366
|
+
PKCE challenge.
|
|
367
|
+
3. Infaris signs you in and redirects back to
|
|
368
|
+
`http://127.0.0.1:47655/callback` with an authorization code.
|
|
369
|
+
4. The CLI exchanges the code (plus PKCE verifier) for access and refresh
|
|
370
|
+
tokens and stores them locally.
|
|
371
|
+
|
|
372
|
+
The Calendar API verifies these RS256 tokens against the Infaris JWKS and
|
|
373
|
+
maps your Infaris account to your Calendar user by e-mail. New tasks are
|
|
374
|
+
assigned to you by default, with priority `medium`, type `development`, status
|
|
375
|
+
`not_started` and the current sprint, so AI agents can create a task with just
|
|
376
|
+
a `--title`.
|
|
377
|
+
|
|
378
|
+
## Develop
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
npm install
|
|
382
|
+
npm run dev -- create task --title "test" --product pulseguard # run from source via tsx
|
|
383
|
+
npm run build # emit dist/
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Customer dossiers and complete ticket context (0.8.0)
|
|
387
|
+
|
|
388
|
+
This package now also installs **`infaris-crm`**, using the same login as
|
|
389
|
+
`infaris-calendar`. Read the [customer support workflow](../../../docs/customer-support-workflow.md)
|
|
390
|
+
for documentation ownership, daily work, handoff and rollout.
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
infaris-crm list --search "Customer" --json
|
|
394
|
+
infaris-crm create --name "Customer" --website https://example.com --json
|
|
395
|
+
infaris-crm show RELATION --include-done --json
|
|
396
|
+
infaris-crm contact RELATION --name "Person" --email person@example.com
|
|
397
|
+
infaris-crm note RELATION --method PHONE --outcome SPOKEN --body-file call.md
|
|
398
|
+
infaris-crm ticket RELATION --title "Slow website" --description-file problem.md --image screenshot.png --json
|
|
399
|
+
infaris-calendar list tasks --relation-number RELATION --json
|
|
400
|
+
infaris-calendar show task 427 --customer-context --download-dir /tmp/ticket-427 --json
|
|
401
|
+
infaris-calendar comment 427 --body-file investigation.md --json
|
|
402
|
+
infaris-calendar update task --id 427 --assignee me --status in_progress
|
|
403
|
+
infaris-calendar update task --id 427 --clear-assignees
|
|
404
|
+
infaris-calendar link-pr 427 https://github.com/InfarisHQ/monorepo/pull/123 --json
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Task creation also accepts `--assignee <people...>` by team name, email, id or
|
|
408
|
+
`me`. `show task` includes description, comments, subtasks, PRs and attachment
|
|
409
|
+
URLs. `--customer-context` adds the linked CRM dossier. `--download-dir` downloads
|
|
410
|
+
attachments without overwriting existing files. Open images with your agent's
|
|
411
|
+
image viewer; do not infer their contents from filenames.
|
|
412
|
+
|
|
413
|
+
CRM commands return JSON by default. `list` supports `--limit` and `--offset`. Customer history defaults to the latest
|
|
414
|
+
50 entries; `entriesPagination` reports the total and next offset. Read older
|
|
415
|
+
entries with `show --entries-offset <n>` and `--entries-limit <n>` (max 200).
|
|
416
|
+
`contact --id` replaces that contact's details, so include fields you want to
|
|
417
|
+
keep. `note` appends; it never overwrites the history. `create` creates a prospect
|
|
418
|
+
without billing or a Guard license. Check returned `warning` values before
|
|
419
|
+
retrying. Ticket creation reports its task number if a later upload fails;
|
|
420
|
+
retry with `attach task`, not a second ticket.
|
|
421
|
+
|
|
422
|
+
Use `infaris-crm login`, or `login link` / `login code <value>` for remote sessions.
|
|
423
|
+
The logout affects both CLI tools. `INFARIS_CALENDAR_CONFIG_DIR` can select an
|
|
424
|
+
isolated login directory for a separate profile or automation session. Override the CRM server with `INFARIS_CRM_URL`;
|
|
425
|
+
a non-production Calendar login requires this explicitly. Support must deploy
|
|
426
|
+
the `/api/crm/*` routes before CRM commands are available.
|
package/dist/activity.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { extractTaskKeys, filterCommitsByAuthor, isJunkCommitSubject, parseGitLog, } from "./hours.js";
|
|
5
|
+
export const DEFAULT_GITHUB_REPO = "InfarisHQ/monorepo";
|
|
6
|
+
export function findGitRoot(start = process.cwd()) {
|
|
7
|
+
let dir = start;
|
|
8
|
+
for (;;) {
|
|
9
|
+
if (existsSync(join(dir, ".git")))
|
|
10
|
+
return dir;
|
|
11
|
+
const parent = dirname(dir);
|
|
12
|
+
if (parent === dir)
|
|
13
|
+
return null;
|
|
14
|
+
dir = parent;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function run(command, args, cwd) {
|
|
18
|
+
const result = spawnSync(command, args, {
|
|
19
|
+
cwd,
|
|
20
|
+
encoding: "utf8",
|
|
21
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
ok: result.status === 0,
|
|
25
|
+
stdout: result.stdout ?? "",
|
|
26
|
+
stderr: result.stderr ?? "",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function gitIdentity(gitRoot) {
|
|
30
|
+
const email = run("git", ["config", "user.email"], gitRoot).stdout.trim();
|
|
31
|
+
const name = run("git", ["config", "user.name"], gitRoot).stdout.trim();
|
|
32
|
+
return {
|
|
33
|
+
emails: email ? [email] : [],
|
|
34
|
+
names: name ? [name] : [],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function gitCommitsForDay(gitRoot, iso) {
|
|
38
|
+
const log = run("git", [
|
|
39
|
+
"log",
|
|
40
|
+
"--all",
|
|
41
|
+
"--no-merges",
|
|
42
|
+
`--since=${iso} 00:00:00`,
|
|
43
|
+
`--until=${iso} 23:59:59`,
|
|
44
|
+
"--pretty=format:%H%x09%an%x09%ae%x09%s",
|
|
45
|
+
], gitRoot);
|
|
46
|
+
if (!log.ok)
|
|
47
|
+
return [];
|
|
48
|
+
return filterCommitsByAuthor(parseGitLog(log.stdout), gitIdentity(gitRoot))
|
|
49
|
+
.filter((c) => !isJunkCommitSubject(c.subject))
|
|
50
|
+
.map((c) => ({
|
|
51
|
+
hash: c.hash,
|
|
52
|
+
subject: c.subject,
|
|
53
|
+
authorName: c.authorName,
|
|
54
|
+
authorEmail: c.authorEmail,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
function searchPullRequests(args) {
|
|
58
|
+
const search = run("gh", [
|
|
59
|
+
"search",
|
|
60
|
+
"prs",
|
|
61
|
+
...args,
|
|
62
|
+
"--limit=50",
|
|
63
|
+
"--json",
|
|
64
|
+
"number,title,url,state",
|
|
65
|
+
]);
|
|
66
|
+
if (!search.ok) {
|
|
67
|
+
const detail = (search.stderr || search.stdout).trim().split("\n")[0];
|
|
68
|
+
return {
|
|
69
|
+
prs: [],
|
|
70
|
+
warning: detail
|
|
71
|
+
? `gh search prs mislukt (${detail})`
|
|
72
|
+
: "gh niet beschikbaar of niet ingelogd",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
return { prs: JSON.parse(search.stdout) };
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return { prs: [], warning: "gh search prs gaf ongeldige JSON" };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function githubPullRequestsForDay(iso, repo) {
|
|
83
|
+
const queries = [
|
|
84
|
+
[`--repo=${repo}`, "--author=@me", `--created=${iso}..${iso}`],
|
|
85
|
+
[`--repo=${repo}`, "--author=@me", `--merged-at=${iso}`],
|
|
86
|
+
[
|
|
87
|
+
`--repo=${repo}`,
|
|
88
|
+
"--reviewed-by=@me",
|
|
89
|
+
`--updated=${iso}..${iso}`,
|
|
90
|
+
],
|
|
91
|
+
];
|
|
92
|
+
const byNumber = new Map();
|
|
93
|
+
const warnings = [];
|
|
94
|
+
for (const [index, args] of queries.entries()) {
|
|
95
|
+
const { prs, warning } = searchPullRequests(args);
|
|
96
|
+
if (warning)
|
|
97
|
+
warnings.push(warning);
|
|
98
|
+
const reviewed = index === 2;
|
|
99
|
+
for (const pr of prs) {
|
|
100
|
+
const current = byNumber.get(pr.number);
|
|
101
|
+
if (!current) {
|
|
102
|
+
byNumber.set(pr.number, {
|
|
103
|
+
number: pr.number,
|
|
104
|
+
title: pr.title,
|
|
105
|
+
url: pr.url,
|
|
106
|
+
state: pr.state,
|
|
107
|
+
reviewed,
|
|
108
|
+
});
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (current.reviewed && !reviewed)
|
|
112
|
+
current.reviewed = false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
prs: [...byNumber.values()],
|
|
117
|
+
warning: warnings[0],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Git commits + GitHub PRs for one local calendar day. Best-effort: missing
|
|
122
|
+
* git/gh is a warning, not a failure.
|
|
123
|
+
*/
|
|
124
|
+
export function gatherDayActivity(iso, opts = {}) {
|
|
125
|
+
const warnings = [];
|
|
126
|
+
const gitRoot = findGitRoot(opts.cwd ?? process.cwd());
|
|
127
|
+
const repo = opts.repo ?? DEFAULT_GITHUB_REPO;
|
|
128
|
+
const identity = gitRoot
|
|
129
|
+
? gitIdentity(gitRoot)
|
|
130
|
+
: { emails: [], names: [] };
|
|
131
|
+
let commits = [];
|
|
132
|
+
if (!gitRoot) {
|
|
133
|
+
warnings.push("geen git-repo in deze map (commits overgeslagen)");
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
commits = gitCommitsForDay(gitRoot, iso);
|
|
137
|
+
if (identity.emails.length === 0 && identity.names.length === 0) {
|
|
138
|
+
warnings.push("git user.name/email is leeg; alle commits van die dag zijn meegenomen");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const { prs, warning } = githubPullRequestsForDay(iso, repo);
|
|
142
|
+
if (warning)
|
|
143
|
+
warnings.push(warning);
|
|
144
|
+
return {
|
|
145
|
+
date: iso,
|
|
146
|
+
gitRoot,
|
|
147
|
+
identity,
|
|
148
|
+
commits,
|
|
149
|
+
pullRequests: prs,
|
|
150
|
+
warnings,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export function activityTaskKeys(activity) {
|
|
154
|
+
const keys = new Set();
|
|
155
|
+
for (const commit of activity.commits) {
|
|
156
|
+
for (const key of extractTaskKeys(commit.subject))
|
|
157
|
+
keys.add(key);
|
|
158
|
+
}
|
|
159
|
+
for (const pr of activity.pullRequests) {
|
|
160
|
+
for (const key of extractTaskKeys(`${pr.title} ${pr.url ?? ""}`)) {
|
|
161
|
+
keys.add(key);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return [...keys];
|
|
165
|
+
}
|