@ysgao/web-cli 0.1.4 → 0.1.5

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
@@ -34,25 +34,30 @@ per-site endpoint knowledge. Every command prints one JSON document to stdout on
34
34
 
35
35
  ## Quick Start
36
36
 
37
+ **Just want to use it?** Install the published package — this is the normal path for everyone
38
+ except someone actively developing this CLI's own source:
39
+
37
40
  ```bash
38
- npm install
39
- npm run build
41
+ npm install -g @ysgao/web-cli
40
42
 
41
43
  # Check authentication
42
- node dist/index.js auth status
44
+ web-cli auth status
43
45
 
44
46
  # Log in to a site (opens the dedicated automation Chrome profile)
45
- node dist/index.js login uptodate
47
+ web-cli login uptodate
46
48
 
47
49
  # Search medical sites
48
- node dist/index.js search "fever treatment"
50
+ web-cli search "fever treatment"
49
51
 
50
52
  # Get help
51
- node dist/index.js --help
53
+ web-cli --help
52
54
  ```
53
55
 
54
- Optionally, `npm link` after building to get a global `web-cli` command that live-updates on
55
- rebuild (see **Publishing** below).
56
+ Re-run `npm install -g @ysgao/web-cli` any time to pick up a newer published version.
57
+
58
+ **Developing this CLI's own source instead?** See **Publishing** below for the local, un-published
59
+ dev-install path (`npm link`) — a separate thing from the normal install above, and NOT what you
60
+ want just to use the tool.
56
61
 
57
62
  ## Commands
58
63
 
@@ -109,7 +114,10 @@ node dist/index.js install-skill [--agent claude|codex|agents|all] [--project] [
109
114
  node dist/index.js uninstall-skill [--agent claude|codex|agents|all] [--project] [--force]
110
115
  ```
111
116
 
112
- (Replace `node dist/index.js` with `web-cli` if you've run `npm link`.)
117
+ (The commands above are written as `node dist/index.js ...` because that's what works from inside
118
+ a cloned, un-built-into-a-global-command checkout. If you installed via `npm install -g
119
+ @ysgao/web-cli` — the normal path, see **Quick Start** above — or ran `npm link` while developing
120
+ this checkout, use the plain `web-cli ...` form instead; both resolve to the exact same CLI.)
113
121
 
114
122
  ### `install-skill`'s three targets
115
123
 
@@ -538,20 +546,35 @@ Known sites are registered in `src/sites/index.ts`.
538
546
  | 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 |
539
547
  | 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`) |
540
548
  | Discovery failed | Run: `node dist/index.js observe --site uptodate --intent search --param "test"` — see **Manual discovery with `observe`** above for a full walkthrough |
541
- | Build out of date | Run: `npm install && npm run build` |
549
+ | Installed version out of date (registry install) | Run: `npm install -g @ysgao/web-cli` again to pick up the newest published version |
550
+ | Build out of date (dev checkout) | Run: `npm install && npm run build` |
551
+ | `web-cli` still resolves to a local checkout instead of the published package | Check with `readlink -f "$(which web-cli)"` — if it points into a cloned repo rather than `.../node_modules/@ysgao/web-cli/...`, an `npm link` from earlier dev work is still active. Run `npm unlink -g @ysgao/web-cli` then `npm install -g @ysgao/web-cli` to switch to the real published package |
542
552
  | Platform-specific issues | See `KNOWN_ISSUES.md` |
543
553
 
544
554
  ## Publishing
545
555
 
546
- This package is **not published to npm** (see `CLAUDE.md` for why). For local use:
556
+ **This package IS published to npm, publicly, under `@ysgao/web-cli`** — see **Quick Start** above
557
+ for the normal way to get the `web-cli` command (`npm install -g @ysgao/web-cli`, no clone needed).
558
+ Everything below is only for someone developing this CLI's own source from a cloned checkout.
559
+
560
+ **Local dev install** (no registry round-trip — for iterating on this checkout itself):
547
561
 
548
562
  ```bash
549
563
  npm run build
550
- npm link # symlinks the `web-cli` command globally to this checkout's dist/index.js
564
+ npm link # symlinks the `web-cli` command globally to THIS checkout's dist/index.js
551
565
  ```
552
566
 
553
567
  After `npm link`, editing code + `npm run build` alone is enough for the global `web-cli` command
554
- to pick up the change. Undo with `npm unlink -g @ysgao/web-cli`.
568
+ to pick up the change — no relink needed. **Undo with `npm unlink -g @ysgao/web-cli` before
569
+ switching back to the real published package** (`npm install -g @ysgao/web-cli`) — a leftover link
570
+ silently shadows the registry version with whatever this checkout happens to contain, with no
571
+ warning that anything is out of the ordinary. Check which one is currently active with
572
+ `readlink -f "$(which web-cli)"`: it should point somewhere under
573
+ `.../node_modules/@ysgao/web-cli/...` for a real install, or into a cloned repo path if a link is
574
+ still active.
575
+
576
+ See `CLAUDE.md`'s own Publishing section for maintainer-facing detail on releasing a new version
577
+ (version-bump rules, the tarball sanity check, and a couple of hard-won registry/sandbox gotchas).
555
578
 
556
579
  ## Support
557
580
 
package/dist/index.js CHANGED
@@ -52024,6 +52024,7 @@ function articleKeyFrom(site, searchData, baseUrl) {
52024
52024
  }
52025
52025
  return hit.url ?? hit.id ?? null;
52026
52026
  }
52027
+ var PROBE_CANARY_QUERY = "pneumonia";
52027
52028
  async function probeWithJar(site, probeQuery, jar) {
52028
52029
  const config2 = getSiteConfig(site);
52029
52030
  const header = cookieJarToHeader(jar);
@@ -52041,7 +52042,16 @@ async function probeWithJar(site, probeQuery, jar) {
52041
52042
  if (!articleTemplate) {
52042
52043
  return "valid";
52043
52044
  }
52044
- const key = articleKeyFrom(site, searchData, config2.baseUrl);
52045
+ let key = articleKeyFrom(site, searchData, config2.baseUrl);
52046
+ if (!key && probeQuery !== PROBE_CANARY_QUERY) {
52047
+ let canaryData;
52048
+ try {
52049
+ canaryData = await callTemplate(renderTemplate(searchTemplate, PROBE_CANARY_QUERY), header);
52050
+ } catch (err) {
52051
+ return isAuthFailure(err) ? "expired" : "valid";
52052
+ }
52053
+ key = articleKeyFrom(site, canaryData, config2.baseUrl);
52054
+ }
52045
52055
  if (!key) {
52046
52056
  return "valid";
52047
52057
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ysgao/web-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Self-discovering REST API CLI for subscription medical-knowledge sites, driven by an AI agent",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
@@ -452,7 +452,16 @@ Concretely, when you see it (on a whole site's `sites.<site>.error`, or on one
452
452
  `web-cli auth status` reports whether cookies exist, but note that **cookies existing is not the
453
453
  same as being signed in** — ClinicalKey in particular hands out an anonymous session that satisfies
454
454
  search while still refusing full text. So a nonempty `auth status` does not guarantee full-text
455
- access; the authoritative check is whether the call you actually need succeeds. `auth status` also
455
+ access; the authoritative check is whether the call you actually need succeeds. A related trap,
456
+ confirmed live: ClinicalKey can also silently *demote* a previously signed-in session to that same
457
+ anonymous tier, in which case its search answers with a clean, error-free **`0` hits** for any
458
+ subscription-only query (open-access content still appears, so a common term still returns
459
+ something). `search`'s pre-flight now catches this by itself (it probes an article via a generic
460
+ canary query when your own query returned nothing, and re-logs in on the resulting refusal), so an
461
+ up-to-date `web-cli` recovers automatically — but if you ever see `hitsBySite.clinicalkey: 0` for
462
+ a query you'd expect ClinicalKey to cover, with no error and no `didYouMean`, treat it as a
463
+ possible demoted session rather than evidence the site has nothing: re-run once, and if it stays
464
+ at 0, `web-cli login clinicalkey --save-credentials` is the fix, not a different query. `auth status` also
456
465
  has no way to tell you whether a credential is saved for silent recovery — there is currently no
457
466
  read command for that; the only way to find out is to try a search (with no flags — this is simply
458
467
  the default) and see whether `SESSION_EXPIRED` appears (in which case either nothing is saved, or