surface-cli 0.3.4 → 0.3.9

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.
@@ -0,0 +1,339 @@
1
+ ---
2
+ name: surface-cli
3
+ description: "Use the Surface mail CLI to read and act on Gmail, Outlook, and generic IMAP/SMTP mail through one JSON-first contract. Prefer this skill when you need Outlook access for school or work accounts that do not expose IMAP, or generic IMAP for providers such as GMX, plus stable refs for unread fetch, sent-message lookup, structured search, thread refresh, message read, attachments, send or draft, archive, mark read or unread, and provider-supported RSVP."
4
+ metadata:
5
+ {
6
+ "openclaw":
7
+ {
8
+ "emoji": "📬",
9
+ "homepage": "https://github.com/VishalJ99/surface-cli",
10
+ "requires": { "bins": ["surface"] },
11
+ "install":
12
+ [
13
+ {
14
+ "id": "node",
15
+ "kind": "node",
16
+ "package": "surface-cli",
17
+ "bins": ["surface"],
18
+ "label": "Install Surface CLI (npm)",
19
+ },
20
+ ],
21
+ },
22
+ }
23
+ ---
24
+
25
+ # Surface CLI
26
+
27
+ Surface is a local-first mail CLI for Gmail, Outlook, and generic IMAP/SMTP. It is especially
28
+ useful for Outlook school or work accounts that only work through the web UI, and for mail
29
+ providers such as GMX that expose standard IMAP and SMTP settings. Surface prints
30
+ machine-readable JSON to stdout and stores local state in `~/.surface-cli`.
31
+
32
+ ## Use This Skill When
33
+
34
+ - the user wants to read or triage email from Gmail, Outlook, or an IMAP mailbox
35
+ - the user needs a provider-neutral CLI for search, unread fetch, read, attachments, or actions
36
+ - you need stable `thread_ref` / `message_ref` values for follow-up commands or thread watching
37
+
38
+ ## Prerequisites
39
+
40
+ 1. Surface CLI installed (`surface --help` should work)
41
+ 2. At least one configured account
42
+ 3. Valid auth for the target account
43
+
44
+ Check setup:
45
+
46
+ ```bash
47
+ surface account list
48
+ surface auth status
49
+ ```
50
+
51
+ If the user asks to install the Surface skill for another agent on the same machine, use:
52
+
53
+ ```bash
54
+ surface skill install codex
55
+ surface skill install claude-code
56
+ surface skill install all
57
+ ```
58
+
59
+ ## Account Setup
60
+
61
+ Add an account:
62
+
63
+ ```bash
64
+ surface account add personal_2 --provider gmail --email you@example.com
65
+ surface account add uni --provider outlook --email you@example.com
66
+ surface account add gmx --provider imap --email you@gmx.com
67
+ ```
68
+
69
+ For reliable `summary.needs_action`, Surface should know who the account owner is. Gmail auth can
70
+ verify the mailbox email automatically; Outlook may need explicit human identifiers:
71
+
72
+ ```bash
73
+ surface account identity set uni --email you@example.com --name "Your Name" --name-alias "FirstName"
74
+ surface account identity show uni
75
+ ```
76
+
77
+ Log in:
78
+
79
+ ```bash
80
+ surface auth login personal_2
81
+ surface auth login uni
82
+ surface auth login gmx \
83
+ --imap-host imap.gmx.com --imap-port 993 --imap-security tls \
84
+ --smtp-host mail.gmx.com --smtp-port 587 --smtp-security starttls \
85
+ --username you@gmx.com \
86
+ --password-command "security find-generic-password -w -s surface-gmx"
87
+ ```
88
+
89
+ For GMX and similar providers, make sure IMAP/POP3 access is enabled in the
90
+ provider web settings before logging in. Generic IMAP login does not need a
91
+ Google Cloud project, OAuth client JSON, Microsoft Graph app registration, or a
92
+ browser session. It does need the provider's IMAP/SMTP settings and a mailbox or
93
+ app password from a local secret source such as `--password-command`,
94
+ `--password-env`, or `--password-file`. Do not ask the user to paste mailbox
95
+ passwords into chat or store them in the repo.
96
+
97
+ Local policy lives in:
98
+
99
+ ```text
100
+ ~/.surface-cli/config.toml
101
+ ```
102
+
103
+ Important local knobs:
104
+
105
+ - `summarizer_backend`
106
+ - `summarizer_model`
107
+ - `writes_enabled`
108
+ - `send_mode`
109
+ - `test_recipients`
110
+ - `test_account_allowlist`
111
+
112
+ Summarization is opt-in and controlled by the user's local config. Do not change
113
+ `summarizer_backend`, `summarizer_model`, or related environment variables unless the user
114
+ explicitly asks. If an external summarizer backend is enabled, email thread content may be sent to
115
+ the configured model provider; confirm the user accepts that privacy tradeoff before enabling or
116
+ changing summarization.
117
+
118
+ ## Common Operations
119
+
120
+ ### List Accounts
121
+
122
+ ```bash
123
+ surface account list
124
+ surface auth status
125
+ surface auth status personal_2
126
+ ```
127
+
128
+ ### Fetch Unread Threads
129
+
130
+ ```bash
131
+ surface mail fetch-unread --account uni --limit 10
132
+ surface mail fetch-unread --account personal_2 --limit 20
133
+ surface mail fetch-unread --account uni --session sess_01... --limit 10
134
+ ```
135
+
136
+ ### Search Mail
137
+
138
+ ```bash
139
+ surface mail search --account uni --text "invoice" --limit 10
140
+ surface mail search --account uni --from registrar@school.edu --subject "waitlist" --limit 10
141
+ surface mail search --account uni --session sess_01... --from registrar@school.edu --limit 10
142
+ surface mail search --account personal_2 --mailbox inbox --label unread --text "sale" --limit 10
143
+ surface mail search --account personal_2 --text "has:attachment newer_than:30d" --limit 5
144
+ surface mail search --account gmx --mailbox inbox --limit 10
145
+ ```
146
+
147
+ ### List Sent Messages
148
+
149
+ ```bash
150
+ surface mail sent --account uni
151
+ surface mail sent --account uni --recipient person@example.com --limit 10
152
+ surface mail sent --account uni --thread thr_01... --limit 10
153
+ surface mail sent --account uni --session sess_01... --recipient person@example.com --limit 10
154
+ surface mail sent --account personal_2 --limit 10
155
+ ```
156
+
157
+ `sent` is message-first. Its default limit is the last 10 sent messages, not threads. Each returned
158
+ message includes `message_ref` and `thread_ref`; use `surface mail thread get <thread_ref>
159
+ --refresh` when you need the full conversation around a sent message.
160
+
161
+ Use `--thread <thread_ref>` when you already know the conversation and need only the user's sent
162
+ messages in that thread for style or consistency. `--thread` may be combined with `--recipient`.
163
+
164
+ ### Watching Threads And Topics
165
+
166
+ Surface is the polling primitive, not the scheduler or delivery transport. If the user asks to
167
+ watch mail, use the surrounding automation system to rerun Surface commands and surface updates to
168
+ the user-requested destination.
169
+
170
+ - For a specific thread watch, persist the `account`, `thread_ref`, and the newest known
171
+ message/timestamp. On each check, rerun `surface mail thread get <thread_ref> --refresh` and
172
+ notify only when the newest message state changes.
173
+ - For a topic watch, establish a baseline with `search`, then use periodic `fetch-unread` checks
174
+ to catch new inbox arrivals and targeted `search` checks when the topic has clear `--from`,
175
+ `--subject`, `--mailbox`, `--label`, or `--text` filters.
176
+ - Do not assume a delivery target. Return updates through the current agent conversation or the
177
+ explicit destination the user asked for.
178
+ - Reasonable starting cadences are: 5-10 minutes for one active thread, 30-60 minutes for a
179
+ narrow topic watch, and 2-4 hours for inbox digests. Avoid sub-5-minute polling unless the user
180
+ explicitly asks for it.
181
+ - For Outlook-heavy polling, keep concurrency modest and prefer one warm session per parallel
182
+ worker if several live checks will run close together.
183
+
184
+ ### Warm Sessions
185
+
186
+ ```bash
187
+ surface session start --account uni
188
+ surface session list
189
+ surface session stop sess_01...
190
+ ```
191
+
192
+ ### Parallel Read Guidance
193
+
194
+ Read-only commands may be run in parallel. Live probes passed for:
195
+
196
+ - two Gmail searches on the same account
197
+ - two cold Outlook searches on the same account
198
+ - Gmail and Outlook searches at the same time
199
+ - two separate Outlook warm sessions searched at the same time
200
+ - two searches sharing one Outlook warm session
201
+
202
+ For Outlook, keep concurrency modest because each cold command or warm session uses browser
203
+ resources. If planning multiple concurrent Outlook operations, prefer one warm session per
204
+ parallel worker. Reusing the same `--session` concurrently works in the tested case but can be
205
+ slower due to contention.
206
+
207
+ ### Read One Thread
208
+
209
+ ```bash
210
+ surface mail thread get thr_01...
211
+ surface mail thread get thr_01... --refresh
212
+ surface mail thread get thr_01... --refresh --session sess_01...
213
+ ```
214
+
215
+ ### Read One Message
216
+
217
+ ```bash
218
+ surface mail read msg_01...
219
+ surface mail read msg_01... --refresh
220
+ surface mail read msg_01... --refresh --session sess_01...
221
+ surface mail read msg_01... --mark-read
222
+ ```
223
+
224
+ ### Attachments
225
+
226
+ ```bash
227
+ surface attachment list msg_01...
228
+ surface attachment download msg_01... att_01...
229
+ ```
230
+
231
+ ### Compose And Send
232
+
233
+ ```bash
234
+ surface mail send --account personal_2 --to recipient@example.com --subject "Hello" --body "Test"
235
+ surface mail send --account personal_2 --to recipient@example.com --subject "Hello" --body "Test" --attach ./briefing.txt
236
+ surface mail send --account personal_2 --to recipient@example.com --subject "Hello" --body "Test" --draft
237
+ surface mail reply msg_01... --body "Thanks"
238
+ surface mail reply msg_01... --body "Thanks" --draft
239
+ surface mail reply-all msg_01... --body "Thanks everyone"
240
+ surface mail forward msg_01... --to recipient@example.com --body "FYI"
241
+ ```
242
+
243
+ ### Mailbox Actions
244
+
245
+ ```bash
246
+ surface mail archive msg_01... # IMAP requires an Archive/All Mail mailbox
247
+ surface mail mark-read msg_01...
248
+ surface mail mark-unread msg_01...
249
+ surface mail rsvp msg_01... --response accept # Gmail/Outlook only; IMAP returns unsupported
250
+ ```
251
+
252
+ ## Workflow
253
+
254
+ 1. Start with `surface account list` if the target account is unclear.
255
+ 2. Use `surface auth status` before assuming a provider is ready.
256
+ 3. Use `surface account identity show <account>` if `summary.needs_action` looks wrong; add
257
+ `--name-alias` or `--email-alias` with `surface account identity set` when the mailbox address
258
+ alone is not enough to identify the user in message bodies.
259
+ 4. For triage, prefer `fetch-unread` or `search` and inspect the returned thread/message refs.
260
+ 5. For style matching before drafting, run
261
+ `surface mail sent --account <account> --recipient <email> --limit 3` and use the returned sent
262
+ messages as tone/context. When replying in an existing thread, prefer
263
+ `surface mail sent --account <account> --thread <thread_ref> --limit 3`; use recipient matching
264
+ as fallback if the thread has no sent examples.
265
+ 6. If you expect several live Outlook reads in a row, start a warm session first and reuse its `session_id`.
266
+ 7. For a thread watch, use `surface mail thread get <thread_ref> --refresh` and compare the newest
267
+ message state against the stored prior observation before notifying.
268
+ 8. For a topic watch, start with `search` to set the baseline, then use `fetch-unread` for new
269
+ inbox arrivals plus targeted `search` when the watch has narrow filters.
270
+ 9. Read only the messages you need with `surface mail read <message_ref>`.
271
+ 10. For passive watching, do not mutate read state. If the user explicitly asks you to triage unread
272
+ mail and write safety is enabled, marking handled messages read after reporting is acceptable
273
+ unless the user asks to keep them unread.
274
+ 11. Act using refs from Surface output. Do not rely on array positions from previous JSON.
275
+
276
+ ## Important Rules
277
+
278
+ - Surface outputs JSON on stdout. Parse it instead of scraping terminal text.
279
+ - Use `message_ref` and `thread_ref` for follow-up commands.
280
+ - `search` accepts structured filters for sender, subject, mailbox, and labels in addition to raw `--text`.
281
+ - `session start` is the explicit opt-in path for warm Outlook read sessions. In v1, `--session` is supported on `search`, `fetch-unread`, `thread get --refresh`, and `read`.
282
+ - `thread get --refresh` is the thread-level live refresh path for automations that watch a specific conversation.
283
+ - `read` is cache-first by default. Use `--refresh` when you need live provider state.
284
+ - the first session-backed Outlook query still pays mailbox setup cost; the main win is faster follow-on live reads in the same mailbox session
285
+ - `read` does not download attachments. Use `surface attachment download`.
286
+ - Generic IMAP reads raw MIME directly and does not need webmail "show images" or "trust sender"
287
+ UI. Remote images are not fetched; message body text, links, and MIME attachments still work.
288
+ - `fetch-unread` and `search` do not mutate mailbox state.
289
+ - passive watching should stay read-only; do not mark watched mail read unless the user explicitly asks
290
+ - if the user asks for unread triage rather than passive watching, `mark-read` or `read --mark-read`
291
+ is acceptable only after reporting and only when local write safety allows it
292
+ - watcher notifications should go to the user-requested destination; do not invent a session,
293
+ channel, or DM target
294
+ - `--draft` is the safe compose path when you do not need to send immediately.
295
+ - direct `mail send` accepts repeatable `--attach <path>` flags; result JSON exposes attachment
296
+ metadata only, not local paths or file bytes
297
+
298
+ ## Provider Notes
299
+
300
+ - Gmail and Outlook both support read, search, unread fetch, attachments, send with `--attach`,
301
+ reply/reply-all/forward,
302
+ archive, mark-read, mark-unread, RSVP, and `--draft`.
303
+ - Generic IMAP/SMTP supports read, search, unread fetch, attachments, sent lookup,
304
+ send with `--attach`, reply/reply-all/forward, drafts, mark-read, and mark-unread. Archive works
305
+ only when the account exposes an Archive or All Mail style mailbox. RSVP is not supported for
306
+ generic IMAP.
307
+ - Generic IMAP does not expose a reliable cross-folder conversation ID. Replies return the created
308
+ Sent or Draft refs and include `in_reply_to_message_ref`; use `sent --recipient` or `sent
309
+ --thread` for sent-message lookup.
310
+ - Gmail RSVP requires Google Calendar API access on the authenticated account. If RSVP returns a
311
+ reauth error, re-run `surface auth login <account>`.
312
+
313
+ ## Safety
314
+
315
+ - Respect local write-safety policy from `~/.surface-cli/config.toml` and any `SURFACE_*` env vars.
316
+ - Do not send mail unless write safety is enabled locally.
317
+ - Prefer the configured sink recipients from local config; do not invent recipients.
318
+ - For send-like tests, use `--draft` unless the task explicitly requires a live send.
319
+ - When testing live sends, only send to recipients already configured locally for safe testing.
320
+
321
+ ## Examples
322
+
323
+ ```bash
324
+ surface account list
325
+ surface auth status
326
+ surface auth status gmx
327
+ surface session start --account uni
328
+ surface mail fetch-unread --account uni --limit 10
329
+ surface mail search --account gmx --mailbox inbox --limit 5
330
+ surface mail fetch-unread --account uni --session sess_01... --limit 10
331
+ surface mail search --account personal_2 --from alerts@example.com --subject 'discount' --mailbox inbox --label unread --limit 5
332
+ surface mail thread get thr_01... --refresh --session sess_01...
333
+ surface mail read msg_01... --refresh --session sess_01...
334
+ surface mail read msg_01... --mark-read
335
+ surface attachment list msg_01...
336
+ surface attachment download msg_01... att_01...
337
+ surface mail reply msg_01... --body 'Thanks' --draft
338
+ surface mail archive msg_01...
339
+ ```