expandai 0.0.6 → 0.1.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 CHANGED
@@ -20,10 +20,41 @@ npx -y expandai fetch https://example.com
20
20
  bunx expandai fetch https://example.com
21
21
  ```
22
22
 
23
+ ### Staging channel
24
+
25
+ Relevant merges to the Expand monorepo publish an immutable CLI build and move
26
+ the npm `staging` tag. Internal testing can use it without changing `latest`:
27
+
28
+ ```bash
29
+ EXPAND_API_URL="$EXPAND_STAGING_API_URL" \
30
+ EXPAND_API_KEY="$EXPAND_STAGING_API_KEY" \
31
+ npx -y expandai@staging fetch https://example.com
32
+ ```
33
+
34
+ The environment variables are explicit because installing from the `staging`
35
+ tag does not silently change the CLI's default production API.
36
+
37
+ ### Review builds
38
+
39
+ Deploying a pull request to the Review environment
40
+ (`.github/workflows/deploy-review.yaml`) also packs the CLI, the Node SDK, and
41
+ the Python SDK from that same revision into a `review-packages` workflow
42
+ artifact, and comments the install commands on the PR. Nothing is published to
43
+ npm or PyPI; the versions carry a `review` channel and the source commit so a
44
+ Review build never masquerades as a release:
45
+
46
+ ```bash
47
+ gh run download <run-id> --repo expandai/expand --name review-packages --dir review-packages
48
+ npm install --global ./review-packages/expandai-<version>.tgz
49
+ EXPAND_API_URL=https://api.review.expand.ai \
50
+ EXPAND_APP_URL=https://review.expand.ai \
51
+ expandai fetch https://example.com
52
+ ```
53
+
23
54
  ## Standalone binary
24
55
 
25
- A self-contained `expandai` executable is published with each release — no
26
- Node, Bun, or npm required at runtime. One command detects your platform,
56
+ Each release ships a self-contained `expandai` executable that needs no
57
+ Node, Bun, or npm at runtime. One command detects your platform,
27
58
  downloads the right binary from GitHub Releases, and drops it on your
28
59
  `PATH`:
29
60
 
@@ -39,21 +70,21 @@ expandai whoami
39
70
 
40
71
  The binary bundles everything `expandai mcp run`, `expandai hook claude-code`,
41
72
  and `expandai hook opencode` need at runtime, so the MCP server and webfetch
42
- hooks work straight from `PATH` — no `node`/`bun` needed in your agent's
43
- environment.
73
+ hooks work straight from `PATH`. Your agent's environment does not need
74
+ `node` or `bun`.
44
75
 
45
76
  ## Quick start
46
77
 
47
78
  ```bash
48
79
  expandai init # authorize and configure detected agents
49
80
  expandai fetch https://docs.example.com/api # full markdown
50
- expandai fetch https://docs.example.com/api --search auth # semantic snippets
81
+ expandai fetch https://docs.example.com/api --highlights auth # semantic snippets
51
82
  ```
52
83
 
53
- Human terminal use may omit the harness and scope; init detects supported
54
- harnesses, asks for scope, completes device browser authorization when
55
- needed, and configures every detected harness. Pass `--harness` to ensure the
56
- agent running the command is included even when it has no config directory yet.
84
+ Run by hand, `init` needs no arguments. It detects supported harnesses, asks
85
+ for scope, completes device browser authorization when needed, and configures
86
+ every harness it finds. Pass `--harness` so the agent running the command is
87
+ included even when it has no config directory yet.
57
88
 
58
89
  Agents and non-interactive VMs use the explicit machine form:
59
90
 
@@ -63,8 +94,8 @@ expandai init --harness <current-harness> --scope project --json
63
94
 
64
95
  If authorization is required, the JSON result contains a browser URL and a
65
96
  `userCode`. Put both in front of the user: they open the page, type the code in,
66
- and approve — nothing comes back to paste. After they approve, run the **same
67
- command again**; the CLI polls the approval up itself (RFC 8628). Machine mode
97
+ and approve. Nothing comes back to paste. After they approve, run the **same
98
+ command again**; the CLI polls for the approval itself (RFC 8628). Machine mode
68
99
  writes exactly one JSON result to stdout or one structured error to stderr, so
69
100
  agents never need to answer an interactive CLI prompt.
70
101
 
@@ -82,44 +113,45 @@ harness plus every other supported harness detected on the machine. The
82
113
  component commands below remain expert tools for migrations and targeted repair:
83
114
 
84
115
  1. **Hook** (Claude Code, OpenCode). `expandai hook install <host> <scope>`
85
- — best invisible upgrade: every native web fetch the agent issues comes
86
- back as ExpandAI markdown, no prompt changes required. Also wires the MCP
87
- server in the same step. See [Recommended: `hook install`](#recommended-hook-install).
116
+ upgrades the agent invisibly: every native web fetch it issues comes
117
+ back as ExpandAI markdown, no prompt changes required. The same step also
118
+ wires the MCP server. See [Recommended: `hook install`](#recommended-hook-install).
88
119
  2. **Skill** (all four harnesses). `expandai skill install <host> <scope>`
89
- — lightest-weight: drops a `SKILL.md` that teaches the agent when to
90
- reach for `expandai fetch`.
120
+ is the lightest option. It drops a `SKILL.md` that teaches the agent when
121
+ to reach for `expandai fetch`.
91
122
  3. **MCP server** (all four harnesses). `expandai mcp install <host> <scope>`
92
- — exposes the full `fetch` API (snippets, screenshots, structured
123
+ exposes the full `fetch` API (snippets, screenshots, structured
93
124
  extraction) as an MCP-callable tool.
94
125
 
95
- Combinations are fine — installing skill on top of hook, for example, nudges
96
- the agent to use `mcp__expandai__fetch` for refinement on top of the
97
- automatic substitution — but any single one is a complete setup.
126
+ Combinations are fine, and any single one is a complete setup. Installing the
127
+ skill on top of the hook, for example, nudges the agent to use
128
+ `mcp__expandai__fetch` for refinement on top of the automatic substitution.
98
129
 
99
130
  ### Scopes
100
131
 
101
132
  Every `install` / `uninstall` command takes a `<scope>` argument: `global`
102
133
  or `project`.
103
134
 
104
- - `global` — written under your `$HOME`. Applies to every session of the
135
+ - `global` writes under your `$HOME` and applies to every session of the
105
136
  harness, regardless of where the agent is launched. Pick this if you want
106
137
  ExpandAI on by default everywhere.
107
- - `project` — written under the current working directory. Applies only
138
+ - `project` writes under the current working directory and applies only
108
139
  when the harness is launched from inside that directory (or a
109
- subdirectory). Pick this when you want different projects to opt in
140
+ subdirectory). Pick this when different projects should opt in
110
141
  independently, or when the integration should live in version control
111
142
  alongside the project. The installed Claude profile uses the stable
112
143
  `expandai` command when it is on `PATH` and `npx -y expandai` otherwise;
113
144
  restart the harness if it has not inherited the global npm `PATH` yet.
114
145
 
115
- The exact files each scope touches differ per harness and per integration —
116
- see the path comment next to each `install` line in the sections below.
146
+ The exact files each scope touches differ per harness and per integration.
147
+ See the path comment next to each `install` line in the sections below.
117
148
 
118
149
  ## Authentication
119
150
 
120
151
  ```bash
121
152
  expandai login # OAuth device authorization or API key
122
- expandai whoami # show current auth state
153
+ expandai whoami # show account, organization, and authentication
154
+ expandai whoami --format json # machine-readable identity
123
155
  expandai logout # clear credentials and optionally remove installed integrations
124
156
  ```
125
157
 
@@ -128,8 +160,30 @@ Credentials are stored at `$XDG_CONFIG_HOME/expandai/config.json` (default
128
160
 
129
161
  Environment overrides:
130
162
 
131
- - `EXPAND_API_KEY` — overrides the stored auth method.
132
- - `EXPAND_API_URL` — overrides the API endpoint (defaults to `https://api.expand.ai`).
163
+ - `EXPAND_API_KEY` overrides the stored auth method.
164
+ - `EXPAND_API_URL` overrides the API endpoint (defaults to `https://api.expand.ai`).
165
+
166
+
167
+ ### Check which account you are using
168
+
169
+ Run `expandai whoami` to see your name, verified email when available, organization,
170
+ and authentication method. API keys identify the organization. The command never
171
+ prints access tokens, refresh tokens, or API keys.
172
+
173
+ Use `expandai whoami --format json` in scripts. A successful lookup returns
174
+ `authenticated: true`, optional `user`, `organization`, and `authentication`.
175
+ OAuth authentication includes `expiresAt` after any token refresh.
176
+
177
+ Without usable credentials, JSON returns `authenticated: false` and `mode: "preview"`,
178
+ or `mode: "unauthenticated"` when `EXPAND_NO_ANONYMOUS` disables preview access.
179
+ Rejected credentials return `mode: "credential-rejected"`; sign in again with `expandai login`.
180
+ If account lookup fails, `mode: "identity-unavailable"` preserves local authentication
181
+ details without claiming the server verified them. Text output retains the local
182
+ status and adds a short identity-unavailable note.
183
+
184
+ Deploy the API's `GET /v1/account` route before releasing this CLI version. Older
185
+ servers use the same identity-unavailable fallback.
186
+
133
187
 
134
188
  ## fetch
135
189
 
@@ -140,15 +194,15 @@ JavaScript-heavy SPAs and bot-protected sites that plain `curl` can't read.
140
194
  expandai fetch https://example.com # markdown (default)
141
195
  expandai fetch example.com # https:// is added automatically
142
196
  expandai fetch https://example.com --format json # full response with metadata
143
- expandai fetch https://docs.example.com/api --search "authentication"
197
+ expandai fetch https://docs.example.com/api --highlights "authentication"
144
198
  ```
145
199
 
146
200
  Flags:
147
201
 
148
- - `--format text|json` — output mode (default `text`).
149
- - `--search <query>` — semantic search. Returns relevant snippets instead of the full page.
150
- - `--max-results <n>` — snippet count when `--search` is set. Default `5`, max `50`.
151
- - `--min-score <n>` — minimum relevance score, `0`–`1`. Default `0.6`.
202
+ - `--format text|json` sets the output mode (default `text`).
203
+ - `--highlights <query>` runs Highlights and returns relevant snippets instead of the full page.
204
+ - `--max-results <n>` sets the snippet count when `--highlights` is set. Default `5`, max `50`.
205
+ - `--min-score <n>` sets the minimum relevance score, `0`–`1`. Default `0.6`.
152
206
 
153
207
  ## Recommended: `hook install`
154
208
 
@@ -167,11 +221,11 @@ expandai hook install claude-code global
167
221
  expandai hook install opencode project
168
222
  ```
169
223
 
170
- **Scope behavior:** `global` writes to the harness's user settings
224
+ **Scope behavior.** `global` writes to the harness's user settings
171
225
  (`~/.claude/settings.json` for Claude Code, `~/.config/opencode/plugins/` for
172
- OpenCode) — the substitution fires for every session of that harness on the
226
+ OpenCode), so the substitution fires for every session of that harness on the
173
227
  machine. `project` writes to per-directory equivalents
174
- (`<cwd>/.claude/settings.json`, `<cwd>/.opencode/plugins/`) — the
228
+ (`<cwd>/.claude/settings.json`, `<cwd>/.opencode/plugins/`), so the
175
229
  substitution only fires when the harness is launched from that directory.
176
230
 
177
231
  Claude Code hook entries use the portable `expandai` command when it resolves on
@@ -179,22 +233,22 @@ Claude Code hook entries use the portable `expandai` command when it resolves on
179
233
  sharing a project-scoped profile, and restart Claude Code if the current session
180
234
  has not inherited the updated `PATH`.
181
235
 
182
- ### Why both, not just one
236
+ ### Why both
183
237
 
184
238
  - The **runtime hook** makes the agent's native fetch path return ExpandAI
185
239
  markdown automatically, so even agents that haven't been told about
186
240
  expand.ai get clean rendered output for SPAs and bot-protected pages.
187
241
  No prompt changes required.
188
- - The **MCP server alone** requires the agent to consciously choose
242
+ - The **MCP server alone** requires the agent to choose
189
243
  `mcp__expandai__fetch` over its built-in tool, which it usually won't
190
244
  unless something nudges it (a skill, a prompt).
191
- - Together, default web access is upgraded transparently, and explicit
192
- refinement (snippets, screenshots, structured extraction) is still one
193
- MCP tool call away.
245
+ - Together they upgrade default web access transparently and keep explicit
246
+ refinement (snippets, screenshots, structured extraction) one MCP tool
247
+ call away.
194
248
 
195
249
  ### How the substitution actually works
196
250
 
197
- - **Claude Code** — `expandai hook install claude-code <scope>` writes a
251
+ - **Claude Code.** `expandai hook install claude-code <scope>` writes a
198
252
  `PreToolUse` matcher into `settings.json` that scopes to `WebFetch`. When
199
253
  the agent invokes `WebFetch`, the runner reads the SDK's hook payload from
200
254
  stdin, fetches the URL via expand.ai, and emits
@@ -202,7 +256,7 @@ has not inherited the updated `PATH`.
202
256
  blocks the native fetch; `additionalContext` is the documented channel for
203
257
  injecting content into the model's next turn, so the markdown still reaches
204
258
  the model in place of WebFetch's raw output.
205
- - **OpenCode** — `expandai hook install opencode <scope>` copies an
259
+ - **OpenCode.** `expandai hook install opencode <scope>` copies an
206
260
  `expandai-webfetch.js` plugin into `.opencode/plugins/`. The plugin hooks
207
261
  `tool.execute.after` on `webfetch`, shells out to `expandai hook opencode`
208
262
  with the URL (retrying through `npx -y expandai` when the binary is not
@@ -227,11 +281,11 @@ expandai skill install opencode global # ~/.config/opencode/skills/expanda
227
281
  expandai skill install codex project # <cwd>/.agents/skills/expandai/
228
282
  ```
229
283
 
230
- **Scope behavior:** `global` drops `SKILL.md` into the harness's user-level
284
+ **Scope behavior.** `global` drops `SKILL.md` into the harness's user-level
231
285
  skills directory, so the agent auto-discovers it in every session. `project`
232
286
  drops it into the cwd-level skills directory, so it's only discovered when
233
- the harness is launched from that directory — useful for committing the
234
- skill alongside a project so collaborators pick it up automatically.
287
+ the harness is launched from that directory. That is useful for committing
288
+ the skill alongside a project so collaborators pick it up automatically.
235
289
 
236
290
  ## MCP server
237
291
 
@@ -254,14 +308,14 @@ expandai mcp install codex global # ~/.codex/config.toml
254
308
  expandai mcp install codex project # <cwd>/.codex/config.toml
255
309
  ```
256
310
 
257
- **Scope behavior:** `global` writes the `expandai` entry to the harness's
258
- user-level MCP config — the server is discoverable in every session.
259
- `project` writes to the per-directory MCP config — the server is only
260
- discoverable when the harness is launched from that directory, and the
261
- config file is well-suited for checking into version control.
311
+ **Scope behavior.** `global` writes the `expandai` entry to the harness's
312
+ user-level MCP config, so the server is discoverable in every session.
313
+ `project` writes to the per-directory MCP config, so the server is only
314
+ discoverable when the harness is launched from that directory. That config
315
+ file is a good fit for version control.
262
316
 
263
317
  Profiles created by `expandai init` invoke the `expandai` command directly when
264
- it is on `PATH`, and fall back to `npx -y expandai` when it is not — so
318
+ it is on `PATH`, and fall back to `npx -y expandai` when it is not, so
265
319
  `npx expandai init` produces a working profile without a global install.
266
320
  Re-running init after a global install rewrites the entry to the direct command.
267
321
  For the fastest startup, install the package globally and make sure its bin
@@ -282,6 +336,16 @@ expandai uninstall skill # all skills across all hosts and sc
282
336
  `expandai logout` also offers an interactive multi-select cleanup when run in
283
337
  a TTY.
284
338
 
339
+ ## crawl and sync
340
+
341
+ `expandai crawl` and `expandai sync` mirror a site into a local Markdown folder.
342
+
343
+ ### Closed one-off crawls
344
+
345
+ A one-off crawl closes permanently when it finishes, fails, or is canceled. Repeating `expandai sync pull <dir>` drains any remaining events and returns without starting another run. To crawl again, create a new crawl in a new directory; `sync run` reports a closed-crawl error and preserves the existing mirror state. For continuous updates, enable sync when creating the crawl.
346
+
347
+ Sync initialization and recovery from an expired event checkpoint use a pinned catalog snapshot. After its final page, the mirror resumes the retained event log from the snapshot boundary.
348
+
285
349
  ## License
286
350
 
287
351
  Apache-2.0. See `LICENSE`.
@@ -2,7 +2,7 @@ import { Layer } from 'effect';
2
2
  export { CurrentRequestHeaders } from './RequestHeaders.js';
3
3
  export declare const ServerInfo: {
4
4
  readonly name: "expandai";
5
- readonly version: "0.0.6";
5
+ readonly version: "0.1.0";
6
6
  };
7
7
  export declare const makeServerLayer: (options?: {
8
8
  readonly includeDocs?: boolean;