@ysgao/web-cli 0.2.0 → 0.3.1
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 +28 -1
- package/dist/index.js +592 -186
- package/package.json +1 -1
- package/skills/web-cli/SKILL.md +95 -4
package/package.json
CHANGED
package/skills/web-cli/SKILL.md
CHANGED
|
@@ -70,6 +70,42 @@ whatever ran this command; the file's path comes back as `outPath`, and the file
|
|
|
70
70
|
is plain, standard `JSON.parse`-able JSON with nothing else in it — no need to scan the file's head
|
|
71
71
|
for where the real JSON actually starts. See "Writing JSON output to disk (`--out`)" below.
|
|
72
72
|
|
|
73
|
+
### Do NOT write this command's output to disk by habit — not even via shell `>`/`2>` redirection
|
|
74
|
+
|
|
75
|
+
**Every command in this package already defaults to writing nothing to disk.** `--markdown`/`--out`
|
|
76
|
+
are both explicit, off-by-default opt-ins (see their own sections below) — plain `web-cli search
|
|
77
|
+
"<query>"` with no flags returns its result in this call's own stdout/stderr for the current turn
|
|
78
|
+
and touches the filesystem nowhere else (beyond its own small, hidden `~/.web-cli/` cache of
|
|
79
|
+
learned endpoints/sessions, which is not the search result itself).
|
|
80
|
+
|
|
81
|
+
**A real, repeatedly-observed failure mode is not a flag at all: running this command through a
|
|
82
|
+
shell/exec tool with its own stdout/stderr redirected straight into files** (e.g. `web-cli search
|
|
83
|
+
"..." --json > result.json 2> result.stderr.log`). This bypasses `--out`/`--markdown` entirely —
|
|
84
|
+
neither flag's own off-by-default design, predictable filename, nor always-reported
|
|
85
|
+
`outError`/`markdownError` ever comes into play — and silently leaves large JSON blobs sitting in
|
|
86
|
+
the working directory indefinitely (a single `keyReferences[].article.text` full-text dump
|
|
87
|
+
routinely runs from hundreds of KB to several MB; a handful of unrelated searches can leave
|
|
88
|
+
megabytes of stale, uncited files behind with no indication they're disposable). Confirmed live,
|
|
89
|
+
repeatedly, across multiple separate working directories, with no `--out`/`--markdown` involved at
|
|
90
|
+
all.
|
|
91
|
+
|
|
92
|
+
**Before routing this command through a shell/exec tool, default to reading its result directly
|
|
93
|
+
from that tool call's own return value for the current turn — do not redirect stdout/stderr into a
|
|
94
|
+
file** unless one of these genuinely applies:
|
|
95
|
+
|
|
96
|
+
- the result must survive past this turn/process (e.g. feeding a later, separate `web-cli
|
|
97
|
+
render-markdown`/`web-cli finalize` invocation, or a multi-step pipeline that re-reads the same
|
|
98
|
+
result in a future turn);
|
|
99
|
+
- the person you're working with explicitly asked for a saved file;
|
|
100
|
+
- your execution path is known to merge or re-frame captured output unreliably — and even then,
|
|
101
|
+
prefer this command's own `--out`/`--markdown` (which fail safely, report `outError`/
|
|
102
|
+
`markdownError`, and use a predictable, greppable filename) over a raw shell redirect, which has
|
|
103
|
+
none of those properties.
|
|
104
|
+
|
|
105
|
+
When a file genuinely is created for one of those reasons, treat it as retrieved content, not a
|
|
106
|
+
durable artifact — clean it up once the step that needed it is done, rather than leaving it in the
|
|
107
|
+
working directory indefinitely.
|
|
108
|
+
|
|
73
109
|
Run with no arguments (or `--help`) to see the full current command list; that is the source of
|
|
74
110
|
truth over anything below.
|
|
75
111
|
|
|
@@ -78,7 +114,7 @@ truth over anything below.
|
|
|
78
114
|
```
|
|
79
115
|
web-cli auth status [--site <site>]
|
|
80
116
|
web-cli login <site> [--durationSeconds 90]
|
|
81
|
-
web-cli search "<query>" [--site <site>]... [--allow-visible-login] [--disable-login-recovery] [--loginTimeoutSeconds 240] [--markdown [path]] [--out [path]] [--json] [--pretty]
|
|
117
|
+
web-cli 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]
|
|
82
118
|
web-cli get <site> <idOrUrl> [--allow-visible-login] [--disable-login-recovery] [--loginTimeoutSeconds 240]
|
|
83
119
|
web-cli websearch "<query>" [--engine google|bing|gemini] [--model <model>] [--maxResults <n>] [--fallbackWaitSeconds <n>] # general open-web search, google->bing->gemini chain
|
|
84
120
|
web-cli weather <location> # current conditions + 3-day forecast via wttr.in, no API key — ALWAYS use this for weather, never websearch
|
|
@@ -237,7 +273,9 @@ Concretely, after a `search` whose result you intend to answer a question from:
|
|
|
237
273
|
1. **Read `keyReferences` first** (see below) — these are the hits already judged worth a
|
|
238
274
|
full-text fetch. Read each entry's `article.text` where present; where it isn't
|
|
239
275
|
(`fetchError`/`fullTextUnparsed` — see `summary.keyReferences`), fall back to that entry's own
|
|
240
|
-
`snippet` rather than skipping it.
|
|
276
|
+
`snippet` rather than skipping it. **An entry with a `moreAvailable` field is incomplete on
|
|
277
|
+
purpose, not broken** — see "Deferred and truncated references" below: its `moreAvailable.command`
|
|
278
|
+
fetches the rest on demand, and you should run it when what you can see isn't enough to answer.
|
|
241
279
|
2. **Skim titles/snippets across every site's `parsed.hits`** for anything clearly relevant that
|
|
242
280
|
the 20%-capped `keyReferences` selection didn't happen to include — that selection is a
|
|
243
281
|
defensible default ranking, not proof nothing else in the hit list matters.
|
|
@@ -521,7 +559,10 @@ sites actually came back**, and **how much did they return**. Example:
|
|
|
521
559
|
"sitesFailed": [],
|
|
522
560
|
"hitsBySite": { "uptodate": 12, "clinicalkey": 40, "googlemedsearch": 8 },
|
|
523
561
|
"totalHits": 60,
|
|
524
|
-
"keyReferences": {
|
|
562
|
+
"keyReferences": {
|
|
563
|
+
"selected": 8, "fullTextFetched": 7, "fullTextFailed": 1, "fullTextUnparsed": 0,
|
|
564
|
+
"fullTextDeferred": 0, "fullTextTruncated": 2
|
|
565
|
+
}
|
|
525
566
|
}
|
|
526
567
|
```
|
|
527
568
|
|
|
@@ -539,7 +580,10 @@ succeeded but its raw response didn't match that site's parser — a parsing gap
|
|
|
539
580
|
empty result set; don't read `null` as zero. `keyReferences.fullTextUnparsed` is the same distinction
|
|
540
581
|
applied to a `keyReferences` entry: its `getArticle` fetch succeeded (no `fetchError`) but the
|
|
541
582
|
response wasn't recognized (no `article` either) — rare, but real, and distinct from a fetch that
|
|
542
|
-
outright failed.
|
|
583
|
+
outright failed. `fullTextDeferred` counts references whose full text was deliberately **not**
|
|
584
|
+
fetched because the full-text time budget ran out, and `fullTextTruncated` counts those among
|
|
585
|
+
`fullTextFetched` whose text was cut to the character ceiling — neither is a failure, both are
|
|
586
|
+
fetchable on demand (see "Deferred and truncated references").
|
|
543
587
|
|
|
544
588
|
### Progress on stderr while `search` is still running
|
|
545
589
|
|
|
@@ -660,6 +704,19 @@ expanded):
|
|
|
660
704
|
{ "site": "...", "title": "...", "url": "...", "fetchError": { "error": "...", "code": "..." } }
|
|
661
705
|
```
|
|
662
706
|
|
|
707
|
+
or, when the entry is **incomplete on purpose** (nothing failed — see the next section):
|
|
708
|
+
|
|
709
|
+
```json
|
|
710
|
+
{
|
|
711
|
+
"site": "clinicalkey", "title": "...", "url": "https://...", "snippet": "...",
|
|
712
|
+
"moreAvailable": {
|
|
713
|
+
"reason": "deferred",
|
|
714
|
+
"message": "Full text was NOT fetched in this search: ...",
|
|
715
|
+
"command": "web-cli get clinicalkey 'https://...'"
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
```
|
|
719
|
+
|
|
663
720
|
A `fetchError` never removes the entry or the site's own `results`/`parsed` — the title/url/snippet
|
|
664
721
|
selected are still valid even when the deeper full-text fetch didn't succeed; check for the
|
|
665
722
|
presence of `article` rather than assuming every `keyReferences` entry has one. `site` is included
|
|
@@ -667,6 +724,40 @@ on every entry (unlike a hit inside `sites.<site>.parsed.hits`, where the site i
|
|
|
667
724
|
its place in the response) precisely because this list is flattened across all sites searched — you
|
|
668
725
|
need it to know where each key reference was found.
|
|
669
726
|
|
|
727
|
+
### Deferred and truncated references: the rest is one command away
|
|
728
|
+
|
|
729
|
+
Two options keep a search fast and its result readable. Both leave the entry's `title`, `url` and
|
|
730
|
+
`snippet` intact, and both attach a **`moreAvailable`** field whose **`command`** is an exact,
|
|
731
|
+
ready-to-run shell command (the URL already quoted) that fetches that article's **complete** text
|
|
732
|
+
on demand: `web-cli get <site> '<url>'`.
|
|
733
|
+
|
|
734
|
+
- **`moreAvailable.reason: "deferred"`** — the entry has **no `article`**. Some sites build a very
|
|
735
|
+
large article (a ClinicalKey book chapter is ~2.5MB) slowly *on their side* — measured: ~10s
|
|
736
|
+
before the first byte, then a 0.05s download — so `search` stops waiting after the full-text time
|
|
737
|
+
budget (`--fulltext-budget`, default **5s** per site) rather than hold the whole result hostage.
|
|
738
|
+
It always waits for at least one full text per site, so a slow start can't defer everything.
|
|
739
|
+
- **`moreAvailable.reason: "truncated"`** — the entry has an `article`, but `article.text` is cut at
|
|
740
|
+
`--max-article-chars` (default **60,000**; `shownChars` of `totalChars` say how much) and ends with
|
|
741
|
+
a visible `[… truncated …]` line. `article.outline` is kept **whole**, so you can see every
|
|
742
|
+
section and judge whether the rest matters. The original `html` and `references` are dropped from
|
|
743
|
+
a truncated article; they come back with the full fetch.
|
|
744
|
+
|
|
745
|
+
**These are not failures.** They are not in `agentTask.unrecoveredFailures` and do not make the
|
|
746
|
+
search "incomplete coverage". What to do:
|
|
747
|
+
|
|
748
|
+
1. Read what you have — the snippet, the outline, the truncated text — and decide if it is enough.
|
|
749
|
+
2. If it is not, **run the entry's `moreAvailable.command`** for the one or two entries that matter
|
|
750
|
+
most. A large chapter can take 10–15s to come back, which is exactly why it wasn't waited for.
|
|
751
|
+
Don't fetch every deferred entry by reflex.
|
|
752
|
+
3. Read the full text from the result's `parsed.text` (the `get` result also carries the raw
|
|
753
|
+
response under `article`, which is large — read `parsed`, and don't redirect it to disk by habit;
|
|
754
|
+
see the warning near the top).
|
|
755
|
+
4. Until you have fetched it, treat that entry as incomplete and **say so** if your answer relies on
|
|
756
|
+
it. Cite its `url` as usual.
|
|
757
|
+
|
|
758
|
+
`--fulltext-budget 0` waits for every full text (the old behavior); `--max-article-chars 0` never
|
|
759
|
+
truncates. `get` itself is never budgeted or truncated.
|
|
760
|
+
|
|
670
761
|
**How selection works**: per site, the top `min(5, ceil(hits.length × 20%))` hits **in that site's
|
|
671
762
|
own returned order** (already its own relevance ranking) are selected — e.g. 10 UpToDate hits → 2
|
|
672
763
|
key references, 40 ClinicalKey hits → 5 (capped). No cross-site scoring/reweighting is applied; the
|