ask-marcel-office-cli 1.5.2 → 2.0.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 (32) hide show
  1. package/CHANGELOG.md +67 -3
  2. package/README.md +21 -58
  3. package/dist/cli.js +1532 -1722
  4. package/dist/commands.json +382 -273
  5. package/dist/composition/build-deps.d.ts +7 -8
  6. package/dist/composition/cli.d.ts +5 -4
  7. package/dist/domain/iso-datetime.d.ts +1 -1
  8. package/dist/index.js +1410 -1604
  9. package/dist/infra/auth.d.ts +6 -20
  10. package/dist/infra/browser-auth.d.ts +11 -12
  11. package/dist/infra/graph-client.d.ts +2 -2
  12. package/dist/presenter/error-hints.d.ts +9 -9
  13. package/dist/use-cases/commands/build-command.d.ts +1 -1
  14. package/dist/use-cases/commands/command-types.d.ts +5 -5
  15. package/dist/use-cases/commands/create-reply-draft.d.ts +14 -0
  16. package/dist/use-cases/commands/docs.d.ts +1 -1
  17. package/dist/use-cases/commands/get-schedule.d.ts +11 -0
  18. package/dist/use-cases/commands/graph-scopes.d.ts +1 -1
  19. package/dist/use-cases/commands/iso-datetime-schema.d.ts +1 -1
  20. package/dist/use-cases/commands/markdown-pipeline.d.ts +5 -5
  21. package/dist/use-cases/commands/option-descriptions.d.ts +1 -1
  22. package/dist/use-cases/commands/output-path.d.ts +4 -4
  23. package/dist/use-cases/commands/zip-archive-to-markdown.d.ts +1 -1
  24. package/dist/use-cases/ports/filesystem.d.ts +1 -1
  25. package/docs/COMMANDS.md +14 -12
  26. package/docs/USAGE.md +23 -23
  27. package/package.json +3 -4
  28. package/dist/composition/env.d.ts +0 -2
  29. package/dist/infra/system-browser-auth.d.ts +0 -35
  30. package/dist/infra/system-browser-loader.d.ts +0 -3
  31. package/dist/infra/token-callback-server.d.ts +0 -31
  32. package/docs/commands.json +0 -7676
package/CHANGELOG.md CHANGED
@@ -2,6 +2,68 @@
2
2
 
3
3
  All notable changes to `ask-marcel-office-cli` are documented here.
4
4
 
5
+ ## 2.0.0
6
+
7
+ Breaking auth simplification, a repo-wide privacy scrub (including a rewrite of
8
+ the full git history), two new commands, and a headless self-heal for the Teams
9
+ chat-substrate tokens.
10
+
11
+ ### BREAKING
12
+
13
+ - **The CLI binary is renamed `ask-marcel` → `ask-marcel-office`** (matching the
14
+ package name; the bare `ask-marcel` name is freed for future use and no longer
15
+ ships as an alias). Update shell scripts, agent prompts, and skills that invoke
16
+ the old name. npm removes the stale `ask-marcel` bin link on upgrade; if one
17
+ lingers (e.g. bun global installs), delete it manually.
18
+ - **`ask-marcel login --use-extension` is removed.** The companion browser
19
+ extension and the system-browser / localhost-callback capture path are gone
20
+ (`browser-extension/`, the `system-browser-auth` + `token-callback-server`
21
+ infra, and the `--use-extension` flag). `ask-marcel-office login` — a
22
+ Playwright-driven Edge/Chrome window that captures all four tokens in one
23
+ session — is the only login flow. The token cache format is unchanged;
24
+ existing sessions keep working without re-login.
25
+
26
+ ### Added
27
+
28
+ - **`get-schedule`** — free/busy availability for a comma-separated list of
29
+ people and/or meeting rooms over a time window
30
+ (`POST /me/calendar/getSchedule`, `Calendars.Read` — already on the basic
31
+ token). Returns each person's `availabilityView` slot string (0 free /
32
+ 1 tentative / 2 busy / 3 OOF / 4 working-elsewhere), the underlying busy
33
+ blocks, and their working hours. Both bounds accept the relative-date
34
+ vocabulary (`today`, `+1d`, `start-of-week`, …).
35
+ - **`create-reply-draft`** — create a threaded reply-all draft to an existing
36
+ message (`createReplyAll` + a body patch), so an agent can prepare a response
37
+ in-thread. Produces an UNSENT draft only — like `create-mail-draft` /
38
+ `update-mail-draft`, the CLI can never send. (Third and last write command.)
39
+ - **Teams substrate tokens now self-heal on the command path.** When a
40
+ chatsvcagg or ic3 token lapses (~hourly), the CLI redeems the shared Teams
41
+ refresh token for that substrate audience over HTTP — headless, no browser —
42
+ instead of dead-ending in a "run `ask-marcel-office login`" error. The four
43
+ Teams chat commands (`list-teams-chats-with-messages`, `list-teams-chat-messages`,
44
+ `get-teams-chat-message`, `find-chats-with-user`) plus `list-teams-chat-history`
45
+ now keep working for as long as your Graph token does, rather than dying an hour
46
+ into a session. Falls back to the interactive-login prompt only when no refresh
47
+ token is cached or Entra ID rejects the redemption. The elevated token
48
+ (historical-version downloads) is unaffected — a different app identity with no
49
+ shared-RT path — and still needs `login` when it lapses.
50
+
51
+ ### Changed
52
+
53
+ - The npm tarball no longer double-ships the ~500 KB command manifest:
54
+ `docs/commands.json` was dropped from `files[]` (the importable
55
+ `ask-marcel-office-cli/commands.json` subpath still resolves to
56
+ `dist/commands.json`, which remains). Unpacked size ~3.5 → ~3.0 MB.
57
+
58
+ ### Internal
59
+
60
+ - Privacy scrub: personal/tenant fixture data and internal audit-session
61
+ labels removed across source, tests, fixtures, and docs — and purged from
62
+ the entire git history (rewritten and force-pushed).
63
+ - Dead code removed: the single-token browser capture (`acquireToken`), two
64
+ orphan probe scripts, an unused env module; the four graph-client
65
+ auth-header closures collapsed into one factory.
66
+
5
67
  ## 1.5.2
6
68
 
7
69
  ### Fixed
@@ -29,9 +91,11 @@ All notable changes to `ask-marcel-office-cli` are documented here.
29
91
  each launched a _visible_ browser that "opens and closes within seconds" to
30
92
  silently re-capture — per command, per process, with no cross-process throttle —
31
93
  so after the short-lived elevated token (~59 min) expired, every elevated or
32
- Teams-chat command popped a window. The command-path auth now **fails fast** with
33
- an actionable "run `ask-marcel login`" instead; browser capture is reserved for
34
- the explicit `login` command, which re-captures all four tokens in one session.
94
+ Teams-chat command popped a window. The command-path auth now **self-heals** the
95
+ chat-substrate tokens with a headless refresh of the shared Teams RT (and, when
96
+ that can't renew them, fails fast with an actionable "run `ask-marcel-office
97
+ login`") instead; interactive browser capture is reserved for the explicit
98
+ `login` command, which re-captures all four tokens in one session.
35
99
 
36
100
  ## 1.5.0
37
101
 
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # ask-marcel-office-cli
2
2
 
3
- **A Microsoft Graph CLI built for LLMs.** 177 commands across Mail, Calendar, OneDrive, SharePoint, Excel, Teams chats, Planner / To-Do, OneNote, and directory — plus local-file tools (markdown conversion, image extraction) that need no sign-in at all. Sign in once with your Microsoft 365 account — no Azure app registration, no admin consent, no client secrets.
3
+ **A Microsoft Graph CLI built for LLMs.** 179 commands across Mail, Calendar, OneDrive, SharePoint, Excel, Teams chats, Planner / To-Do, OneNote, and directory — plus local-file tools (markdown conversion, image extraction) that need no sign-in at all. Sign in once with your Microsoft 365 account — no Azure app registration, no admin consent, no client secrets.
4
4
 
5
5
  ```bash
6
6
  npm i -g ask-marcel-office-cli
7
- ask-marcel login # browser opens once, token cached
8
- ask-marcel my-quick-context # who am I + my IDs, in one round trip
9
- ask-marcel list-mail-messages --top 5
7
+ ask-marcel-office login # browser opens once, token cached
8
+ ask-marcel-office my-quick-context # who am I + my IDs, in one round trip
9
+ ask-marcel-office list-mail-messages --top 5
10
10
  ```
11
11
 
12
12
  ---
@@ -19,13 +19,13 @@ LLM tool-loops keep hitting the same three walls with Microsoft Graph:
19
19
  2. **Default payloads are tuned for backend services, not context windows.** Listing endpoints return every field on every item, used-range Excel calls return four redundant 2D arrays, attachment endpoints inline base64 by default. An agent that reads "what's in my inbox" without trimming burns its budget on metadata it never needed.
20
20
  3. **Errors are opaque.** `BadRequest: Invalid filter clause` doesn't tell a model what to fix.
21
21
 
22
- `ask-marcel` fixes all three at the CLI layer, so the model just calls commands and reads back-pressure-friendly responses.
22
+ `ask-marcel-office` fixes all three at the CLI layer, so the model just calls commands and reads back-pressure-friendly responses.
23
23
 
24
24
  ## What you get
25
25
 
26
26
  ### Read-only by design
27
27
 
28
- **This is the most important property.** 173 GET endpoints + 2 POST (searches) + 1 POST (create draft) + 1 PATCH (update draft) = 177 commands. No `send-mail`, no `create-event`, no `upload-file`, no `delete-anything`. The only write operations are draft creation and update — a hallucinated command can at most create an unsent draft in your Drafts folder. Safe default for autonomous agents, MCP servers, and "let Claude poke around my mailbox" sessions where you can't fully review every tool call.
28
+ **This is the most important property.** 173 GET endpoints + 3 read-only POST (two searches + free/busy lookup) + 2 POST (create mail draft / create threaded reply draft) + 1 PATCH (update draft) = 179 commands. No `send-mail`, no `create-event`, no `upload-file`, no `delete-anything`. The only write operations are draft creation (a new mail or a threaded reply-all) and update — a hallucinated command can at most create an unsent draft in your Drafts folder. Safe default for autonomous agents, MCP servers, and "let Claude poke around my mailbox" sessions where you can't fully review every tool call.
29
29
 
30
30
  ### One call gets the full email context
31
31
 
@@ -68,21 +68,12 @@ The CLI follows any SharePoint media-transform redirect internally, so the LLM n
68
68
 
69
69
  No Azure app, no tenant admin. The CLI captures the same token the Teams web client uses — works for any Microsoft 365 account, personal or enterprise.
70
70
 
71
- **Login flow:** By default, the CLI uses Playwright to open a browser for authentication. Alternatively, you can use the [Ask Marcel Companion](./browser-extension/) browser extension for faster authentication.
71
+ **Login flow:** the CLI drives a Playwright-launched Edge/Chrome window through the Teams sign-in, captures the tokens, and caches them at `~/.ask-marcel/token-cache.json` (0600).
72
72
 
73
73
  ```bash
74
- ask-marcel login # default: Playwright browser
75
- ask-marcel login --use-extension # use browser extension (requires setup)
74
+ ask-marcel-office login
76
75
  ```
77
76
 
78
- **Browser extension setup (optional, one-time):**
79
-
80
- 1. Open `chrome://extensions/` (Chrome) or `edge://extensions/` (Edge)
81
- 2. Enable "Developer mode" (top-right toggle)
82
- 3. Click "Load unpacked" → select the `browser-extension/` folder from this repo
83
- 4. **Enable in incognito/inprivate mode:** Click the extension's "Details" button, then enable "Allow in incognito" (Chrome) or "Allow in InPrivate" (Edge). **This is required** — the CLI opens an incognito/inprivate window, and extensions are disabled there by default.
84
- 5. Done — use `ask-marcel login --use-extension` to authenticate via the extension
85
-
86
77
  ### Stable error envelope with actionable hints
87
78
 
88
79
  Every failure — Graph, CLI parser, Zod validation, substrate — comes back as `{ok: false, error, errorCode?, hint?, source, retryAfterSeconds?}`. The `hint` field tells the model *what to do next* (e.g. "string literals MUST use single quotes; embed one by doubling it") and `source` tells it where the failure came from. Curated rules for 20+ recurring Graph errors plus cross-resolver pointers (passed a Teams URL to `resolve-mail-link`? Hint says "re-run with `resolve-teams-link`"). When Graph throttles (HTTP 429, sometimes 503) the response's `Retry-After` is surfaced as `retryAfterSeconds` — the integer seconds to wait — so a caller running tenant-scale crawls can honor the server's backoff instead of guessing.
@@ -111,14 +102,14 @@ Two flag patterns avoid the round-trip:
111
102
  npm i -g ask-marcel-office-cli
112
103
 
113
104
  # authenticate (cached → refresh → browser fallback)
114
- ask-marcel login
105
+ ask-marcel-office login
115
106
 
116
107
  # the rest is read-only (the only writes are mail drafts) and discoverable from --help
117
- ask-marcel list-drives
118
- ask-marcel search-onedrive-files --drive-id "b!abc..." --query "Q3 budget"
119
- ask-marcel convert-mail-to-markdown --message-id "AAMkAD..."
120
- ask-marcel list-calendar-view --start-date-time today --end-date-time +7d
121
- ask-marcel convert-mail-attachment-to-pdf \
108
+ ask-marcel-office list-drives
109
+ ask-marcel-office search-onedrive-files --drive-id "b!abc..." --query "Q3 budget"
110
+ ask-marcel-office convert-mail-to-markdown --message-id "AAMkAD..."
111
+ ask-marcel-office list-calendar-view --start-date-time today --end-date-time +7d
112
+ ask-marcel-office convert-mail-attachment-to-pdf \
122
113
  --message-id "AAMkAD..." --attachment-id "AAMkAD...attach1" \
123
114
  --output-path /tmp/deck.pdf
124
115
  ```
@@ -129,11 +120,11 @@ Five discovery surfaces, each tuned for a different audience and token budget:
129
120
 
130
121
  | When you want | Run | Returns |
131
122
  |---|---|---|
132
- | Help with a single command | `ask-marcel <command> --help` | Required flags, optional flags, an example, pagination notes |
133
- | A scan of every command | `ask-marcel --help` | One-sentence summary per command, grouped by category |
134
- | The slim LLM-friendly index | `ask-marcel help-json --terse` | JSON manifest with heavy fields (options, response shape) stripped — best first-call for an agent meeting the CLI for the first time |
135
- | The slim index for one domain | `ask-marcel help-json --terse --category mail` | Same as above, filtered to one of 12 categories — keeps the response tiny when the agent already knows the domain |
136
- | Rich docs for one command | `ask-marcel docs <command>` | Full Markdown to stdout (response shape, examples, the underlying Graph endpoint, Microsoft Learn link) |
123
+ | Help with a single command | `ask-marcel-office <command> --help` | Required flags, optional flags, an example, pagination notes |
124
+ | A scan of every command | `ask-marcel-office --help` | One-sentence summary per command, grouped by category |
125
+ | The slim LLM-friendly index | `ask-marcel-office help-json --terse` | JSON manifest with heavy fields (options, response shape) stripped — best first-call for an agent meeting the CLI for the first time |
126
+ | The slim index for one domain | `ask-marcel-office help-json --terse --category mail` | Same as above, filtered to one of 12 categories — keeps the response tiny when the agent already knows the domain |
127
+ | Rich docs for one command | `ask-marcel-office docs <command>` | Full Markdown to stdout (response shape, examples, the underlying Graph endpoint, Microsoft Learn link) |
137
128
 
138
129
  Pair `help-json --terse --category <name>` with `docs <command>` for the canonical agent loop: scan the category, pick a command, fetch its full docs, then call it.
139
130
 
@@ -141,7 +132,7 @@ Pair `help-json --terse --category <name>` with `docs <command>` for the canonic
141
132
 
142
133
  Most agents already know how to read JSON from stdout. Two patterns work:
143
134
 
144
- **1. Drop in as a shell tool** — the agent learns the manifest, then runs `ask-marcel <command> --output json`. The slim defaults + structured error hints mean it can self-recover from typos.
135
+ **1. Drop in as a shell tool** — the agent learns the manifest, then runs `ask-marcel-office <command> --output json`. The slim defaults + structured error hints mean it can self-recover from typos.
145
136
 
146
137
  **2. Embed as a library** — every command is exported. Compose it inside your own MCP server, Claude Agent, or LangChain tool:
147
138
 
@@ -185,39 +176,11 @@ The `AuthManager` interface is two async methods that return `Result<T, AuthErro
185
176
 
186
177
  ## Deep docs
187
178
 
188
- - **[All 177 commands](docs/COMMANDS.md)** — per-category tables with required params + Graph endpoint
179
+ - **[All 179 commands](docs/COMMANDS.md)** — per-category tables with required params + Graph endpoint
189
180
  - **[Usage guide](docs/USAGE.md)** — output formats, OData passthrough, `--output-path`, pagination, library API, architecture, configuration, quality gates
190
181
  - **[Machine-readable manifest](docs/commands.json)** — JSON for programmatic discovery (LLM tool-loops, IDE plugins, MCP servers); also importable via `import manifest from 'ask-marcel-office-cli/commands.json'`
191
182
  - **[QA playbook](docs/QA-PLAYBOOK.md)** — the repeatable full-surface health-check procedure (offline gates, parameter matrix, conversion contracts, live Graph drift probes) used to audit each release
192
183
 
193
-
194
- ## Agent skill (progressive disclosure)
195
-
196
- A [Codex skill](https://docs.anthropic.com/en/docs/agents-and-tools/codex) lives at `.agents/skills/ask-marcel-office/` and teaches agents how to use the CLI without loading all 177 commands into context at once.
197
-
198
- **Structure**
199
-
200
- ```
201
- .agents/skills/ask-marcel-office/
202
- ├── SKILL.md # core workflow + category index
203
- └── references/ # per-domain command details, loaded on demand
204
- ├── marcel-mail.md (32 commands)
205
- ├── marcel-drive.md (30 commands)
206
- ├── marcel-calendar.md (23 commands)
207
- ├── marcel-sharepoint.md (18 commands)
208
- ├── marcel-user.md (15 commands)
209
- ├── marcel-tasks.md (15 commands)
210
- ├── marcel-excel.md (11 commands)
211
- ├── marcel-notes.md (11 commands)
212
- ├── marcel-chats.md (9 commands)
213
- ├── marcel-teams.md (7 commands)
214
- └── marcel-meta.md (6 commands)
215
- ```
216
-
217
- **How it works**
218
-
219
- `SKILL.md` contains the authentication flow, the discovery loop (`help-json --terse --category` → `docs <cmd>` → execute), key patterns (OData passthrough, relative dates, document conversion, pagination), and a category index. The full command reference for each domain lives in `references/marcel-<category>.md` and is loaded only when the agent needs that domain — keeping the context window lean.
220
-
221
184
  ## Roadmap
222
185
 
223
186
  Read-only stays the default forever. There's no fixed feature backlog — coverage grows out of real LLM workflows as they come up.