@ysgao/web-cli 0.1.5 → 0.3.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
@@ -63,7 +63,7 @@ want just to use the tool.
63
63
 
64
64
  ```bash
65
65
  node dist/index.js login <site> [--durationSeconds 90] [--save-credentials] [--forget-credentials]
66
- node dist/index.js search "<query>" [--site <site>]... [--allow-visible-login] [--disable-login-recovery] [--loginTimeoutSeconds 240] [--markdown [path]] [--out [path]] [--json] [--pretty]
66
+ node dist/index.js search "<query>" [--site <site>]... [--allow-visible-login] [--disable-login-recovery] [--loginTimeoutSeconds 240] [--fulltext-budget <seconds>] [--max-article-chars <n>] [--markdown [path]] [--out [path]] [--json] [--pretty]
67
67
  # always searches uptodate, clinicalkey, and googlemedsearch (the login-gated/medically-scoped
68
68
  # subscription sites this CLI targets); --site adds more. For anything outside medicine/anatomy/
69
69
  # substances/organisms, use `websearch` instead (general/open-web search, not restricted to a
@@ -76,6 +76,11 @@ node dist/index.js search "<query>" [--site <site>]... [--allow-visible-login] [
76
76
  # stdout-capturing wraps around the terminal output (a trailing "exit code" marker, a log prefix
77
77
  # on every line, stdout/stderr merged together) — the file at "outPath" is always pure, plain
78
78
  # JSON.parse-able JSON with nothing else in it. See "Writing a report/JSON result to disk" below.
79
+ # --fulltext-budget (default 5s, per site) stops waiting for a key reference's full text the
80
+ # site is still preparing (large book chapters can take 10s+ on the site's side) and DEFERS it;
81
+ # --max-article-chars (default 60000) cuts a long article to its outline + opening. Either way the
82
+ # entry gets `moreAvailable.command` — an exact `web-cli get <site> '<url>'` that fetches the
83
+ # complete text on demand. Pass 0 to either to turn it off. See "Faster searches" below.
79
84
  node dist/index.js get <site> <idOrUrl> [--allow-visible-login] [--disable-login-recovery] [--loginTimeoutSeconds 240]
80
85
  node dist/index.js websearch "<query>" [--engine google|bing|gemini] [--model <model>] [--maxResults <n>] [--fallbackWaitSeconds <n>]
81
86
  # general open-web search (NOT restricted to a fixed domain list, unlike the default `search`).
@@ -110,8 +115,8 @@ node dist/index.js observe --site <site> --intent <search|getArticle> --param "<
110
115
  node dist/index.js learned [--site <site>]
111
116
  node dist/index.js finalize [--markdown [path]] [--json] [--pretty] # reads {query, finalAnswer, summary?, keyReferences, answers} as JSON on stdin
112
117
  node dist/index.js render-markdown [--from <path>] [--markdown [path]] [--json] # renders a Markdown report from an ALREADY-RETRIEVED search result -- zero network calls
113
- node dist/index.js install-skill [--agent claude|codex|agents|all] [--project] [--force]
114
- node dist/index.js uninstall-skill [--agent claude|codex|agents|all] [--project] [--force]
118
+ node dist/index.js install-skill [--agent claude|codex|agents|dsh|all] [--project] [--force]
119
+ node dist/index.js uninstall-skill [--agent claude|codex|agents|dsh|all] [--project] [--force]
115
120
  ```
116
121
 
117
122
  (The commands above are written as `node dist/index.js ...` because that's what works from inside
@@ -119,30 +124,66 @@ a cloned, un-built-into-a-global-command checkout. If you installed via `npm ins
119
124
  @ysgao/web-cli` — the normal path, see **Quick Start** above — or ran `npm link` while developing
120
125
  this checkout, use the plain `web-cli ...` form instead; both resolve to the exact same CLI.)
121
126
 
122
- ### `install-skill`'s three targets
123
-
124
- `--agent` accepts `claude`, `codex`, `agents`, or `all` — omit it and `install-skill` registers
125
- whichever of these are actually present on your machine (falling back to `claude` if none are).
126
- `claude`/`codex` register with Claude Code (`~/.claude/skills`) and Codex (`~/.codex/prompts`)
127
- respectively. **`agents`** registers with `~/.agents/skills` (or `$DSH_AGENTS_HOME/skills`) —
128
- DeepSeek Harness's own bundled skill provider scans this location (and `~/.dsh/skills`) directly
129
- for its `skill` tool's catalog, and never looks at `~/.claude`/`~/.codex` at all. If you're driving
130
- this CLI from a DSH-based agent and it reports the `web-cli` skill as "unknown or no longer
131
- available" even though `install-skill` has already run, this is almost always why — re-run with
132
- `--agent agents` (or `--agent all`) to also cover it.
127
+ ### `install-skill`'s four targets — each a copy, refreshed on every run
128
+
129
+ `install-skill` **copies** the skill that ships inside the package (`skills/web-cli/`: `SKILL.md` +
130
+ `references/`) into each agent's skills folder as a real directory — never a symlink into the
131
+ package, and no generated pointer file. Re-running it after upgrading the CLI refreshes every copy
132
+ to the latest version (`"status":"updated"`); re-running with nothing changed reports
133
+ `already-current`. Each copy carries a small marker file (`.installed-by-web-cli.json`, recording
134
+ the package version and where it was copied from) — that's how a later run recognizes its own
135
+ outdated copy and refreshes it rather than mistaking it for a directory you wrote yourself. Delete
136
+ the marker if you want to take a copy over and edit it as your own: from then on `install-skill`
137
+ treats it as yours and leaves it alone unless you pass `--force`.
138
+
139
+ `--agent` accepts `claude`, `codex`, `agents`, `dsh`, or `all` (comma-separable) — omit it and
140
+ `install-skill` targets whichever of `claude`/`codex`/`dsh` are actually present on your machine
141
+ (falling back to `claude` if none are; `agents` is never auto-selected — see below):
142
+
143
+ - **`claude`** → `~/.claude/skills/web-cli/` (or `<cwd>/.claude/skills/web-cli/` with `--project`,
144
+ a self-contained copy you can commit).
145
+ - **`codex`** → `~/.codex/skills/web-cli/` (or `$CODEX_HOME/skills/web-cli/`) — Codex discovers
146
+ `SKILL.md` skills from this folder exactly like Claude Code does. Earlier versions of this tool
147
+ instead wrote a pointer prompt to `~/.codex/prompts/web-cli.md`, from before Codex had a skills
148
+ folder; `install-skill`/`uninstall-skill` both remove that legacy file if it's one of ours.
149
+ - **`agents`** → `~/.agents/skills/web-cli/` (or `$DSH_AGENTS_HOME/skills/`) — the cross-tool
150
+ "shared agent config root" DeepSeek Harness's bundled skill provider scans.
151
+ - **`dsh`** → `~/.dsh/skills/web-cli/` (or `$DSH_HOME/skills/`) — DSH's own dedicated home, the
152
+ directory where it also keeps its sessions/profile data, and where a user who manages all of
153
+ their DSH skills in one place typically already has the rest of them.
154
+
155
+ The two DSH targets both serve **DeepSeek Harness**, whose skill provider scans both user-level
156
+ roots for its `skill` tool's catalog — and never looks at `~/.claude`/`~/.codex` at all. They are
157
+ two genuinely different directories, not two spellings of one (`~/.agents` honors
158
+ `$DSH_AGENTS_HOME`; `~/.dsh` honors `$DSH_HOME`), so either can exist without the other and
159
+ neither stands in for the other. **`dsh` is the auto-detected DSH target; `agents` is
160
+ explicit-only** (`--agent agents` or `--agent all`): `~/.agents` is a cross-tool root that other
161
+ software creates and uses for its own purposes, so its mere existence says nothing about whether
162
+ you want this skill there — and since DSH scans both roots, installing into both automatically
163
+ would register the same skill with DSH twice on any machine that has both. If you're driving this
164
+ CLI from a DSH-based agent and it reports the `web-cli` skill as "unknown or no longer available"
165
+ even though `install-skill` has already run, this is almost always why — re-run with `--agent dsh`
166
+ (or `--agent all`) to cover it. If you previously copied `skills/web-cli/` into `~/.dsh/skills/` by
167
+ hand (the only option before the `dsh` target existed), `install-skill` recognizes a byte-identical
168
+ copy as its own and takes it over (adding the marker) without needing `--force`; a copy you've since
169
+ edited is left alone unless you pass `--force`.
170
+
171
+ Previous *symlink* installs from older versions of this tool — live or dangling after an
172
+ `npm rm -g` — are likewise recognized and replaced with a copy, no `--force` required.
133
173
 
134
174
  **On a brand-new machine (e.g. a fresh Termux:X11 proot-distro Debian install), a plain
135
- `install-skill` with no `--agent` flag can silently skip the `agents` target entirely** — its
136
- auto-detection (`detectAgents` in `src/skillInstall.ts`) only targets an agent whose home directory
137
- *already exists*, and `~/.agents` (or `$DSH_AGENTS_HOME`) won't exist yet if DSH itself, or some
138
- other tool that creates it, hasn't run there before. The command still reports success (typically
139
- `{"agent":"claude","status":"installed",...}`), which reads as "the skill is installed" — but
140
- nothing was ever written to `~/.agents/skills`, so DSH's `skill` tool still can't find it. Confirm
141
- which targets actually ran by checking the `results[].agent` list in the command's own JSON output,
142
- or just always pass `--agent all` explicitly when you specifically want DSH coverage rather than
143
- relying on auto-detection. After registering (or re-registering) the `agents` target, **start a new
144
- DSH session/chat** — the skill catalog a running agent sees is loaded once, at session start, so an
145
- already-open session won't pick up a skill installed mid-conversation.
175
+ `install-skill` with no `--agent` flag can silently skip the `dsh` target entirely** — its
176
+ auto-detection (`detectAgents` in `src/skillInstall.ts`) only targets an agent whose home
177
+ directory *already exists*, and `~/.dsh` (or `$DSH_HOME`) won't exist yet if DSH itself hasn't
178
+ run there before. The command still
179
+ reports success (typically `{"agent":"claude","status":"installed",...}`), which reads as "the
180
+ skill is installed" — but nothing was ever written to either DSH root, so DSH's `skill` tool still
181
+ can't find it. Confirm which targets actually ran by checking the `results[].agent` list in the
182
+ command's own JSON output, or just always pass `--agent all` explicitly when you specifically want
183
+ DSH coverage rather than relying on auto-detection. After registering (or re-registering) either
184
+ DSH target, **start a new DSH session/chat** — the skill catalog a running agent sees is loaded
185
+ once, at session start, so an already-open session won't pick up a skill installed
186
+ mid-conversation.
146
187
 
147
188
  ### `search`/`finalize`: JSON or a human-readable report, auto-detected from whether stdout is a terminal
148
189
 
@@ -537,12 +578,34 @@ it.
537
578
 
538
579
  Known sites are registered in `src/sites/index.ts`.
539
580
 
581
+
582
+ ## Faster searches: deferred and truncated full texts
583
+
584
+ `search` fetches full text for a handful of top hits per site. Measured live, one very large
585
+ ClinicalKey book chapter (2.5MB) took ~10s to the first byte — the site assembling it — and 0.05s to
586
+ download, so the only way to speed that up is to not wait for it. Two defaults, both on:
587
+
588
+ - **`--fulltext-budget <seconds>`** (default `5`, per site): once the budget elapses, article fetches
589
+ still in flight are cancelled and returned as `moreAvailable.reason: "deferred"` (no `article`;
590
+ title/url/snippet intact). At least one full text per site is always waited for, so a slow start
591
+ can't defer everything. `0` waits for every full text.
592
+ - **`--max-article-chars <n>`** (default `60000`): a longer article keeps its whole `outline` and the
593
+ start of its text, ending in a visible `[… truncated …]` line (`moreAvailable.reason: "truncated"`).
594
+ `0` never truncates.
595
+
596
+ Neither is a failure (neither appears in `agentTask.unrecoveredFailures`). Every such entry carries
597
+ `moreAvailable.command` — an exact, shell-quoted `web-cli get <site> '<url>'` that returns the
598
+ **complete** text (`get` is never budgeted or truncated) — and `agentTask.instructions` tells the
599
+ agent to run it when the snippet, outline or truncated text isn't enough. In one live comparison this
600
+ cut a search from ~9s to ~6s and the JSON result from 5.6MB to 0.8MB.
601
+
540
602
  ## Troubleshooting
541
603
 
542
604
  | Issue | Solution |
543
605
  |-------|----------|
544
606
  | Session expired | By default, nothing to do if a credential was saved (`web-cli login clinicalkey --save-credentials`) — it recovers silently. Otherwise pass `--allow-visible-login` to let a window open, or sign in ahead of time: `web-cli login clinicalkey` |
545
607
  | `SESSION_EXPIRED` returned | No credential was stored for the site, or the silent refresh didn't recover it (no visible window opens unless you passed `--allow-visible-login`, in which case it timed out). With `--disable-login-recovery`: recovery is fully disabled, by design |
608
+ | A key reference has `moreAvailable` instead of (or with a cut-short) `article.text` | Not a failure — see "Faster searches" below: run its `moreAvailable.command` to fetch the complete text |
546
609
  | Full text missing on a hit | Check `keyReferences[].fetchError`. `SESSION_EXPIRED` there means signed in but not entitled to that item; `DISCOVERY_FAILED` means the article endpoint needs re-learning |
547
610
  | Your own Chrome is open | Not a problem, and never was worth quitting it for — automation uses its own instance (see `src/discovery/chromeWrapperApp.ts`, and its regression tests in `test/chromeWrapperApp.test.ts`) |
548
611
  | Discovery failed | Run: `node dist/index.js observe --site uptodate --intent search --param "test"` — see **Manual discovery with `observe`** above for a full walkthrough |