From d5e12ab710e71d5c785c8a4d8177784f8a120bca Mon Sep 17 00:00:00 2001 From: only-cli Date: Sun, 23 Aug 2026 22:55:30 -0400 Subject: [PATCH] feat: add wikipedia site shortcuts Article, search, and non English wiki lookups via clis/wikipedia.org.json, reachable as oc wiki, oc wikipedia, or oc wikipedia.org. The article and lang commands use ?action=render, which returns the article HTML without the interlanguage sidebar and Tools menu that otherwise eat about half of a 500 token budget before any prose. Its links stay root relative, so oc do still follows them; the Parsoid endpoints render just as clean but emit ./Title hrefs that resolve against the API path and break link following. Search uses the normal results page. The api.php JSON search endpoint is cheaper on paper but distills to nothing today, since its results sit in a nested query.search array. Closes #21 --- README.md | 1 + clis/wikipedia.org.json | 8 ++++++++ src/sites.js | 1 + 3 files changed, 10 insertions(+) create mode 100644 clis/wikipedia.org.json diff --git a/README.md b/README.md index ce0c1b4..c2fdcfb 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Works on any mostly-static site with no per-site setup: news sites, blogs, docum | Stack Overflow | `oc so` (via Atom feeds and the Stack Exchange API) | `search `, `question `, `tag `, `user `, `recent` | | Yahoo Finance | `oc yahoo` | `quote `, `news `, `history `, `lookup `, `markets`, `gainers`, `losers`, `trending` | | YouTube | `oc yt` | `video `, `channel ` | +| Wikipedia | `oc wiki` (via `action=render`) | `article `, `search <query>`, `lang <code> <title>` | | AWS docs | `oc aws` (search via DuckDuckGo) | `guide <service> <page>`, `page <service> <guide> <page>`, `cli <command>`, `search <query>` | | Google Cloud docs | `oc gcp` (via docs.cloud.google.com, search via DuckDuckGo) | `docs <product>`, `page <product> <page>`, `gcloud <command>`, `search <query>` | | Microsoft Learn | `oc learn` (search via its RSS API) | `azure <page>`, `doc <path>`, `cli <command>`, `search <query>` | diff --git a/clis/wikipedia.org.json b/clis/wikipedia.org.json new file mode 100644 index 0000000..8f9b64f --- /dev/null +++ b/clis/wikipedia.org.json @@ -0,0 +1,8 @@ +{ + "domain": "wikipedia.org", + "commands": { + "article": { "open": "https://en.wikipedia.org/w/index.php?title={title}&action=render", "args": ["title"] }, + "search": { "open": "https://en.wikipedia.org/w/index.php?search={query}&fulltext=1&ns0=1", "args": ["query"] }, + "lang": { "open": "https://{code}.wikipedia.org/w/index.php?title={title}&action=render", "args": ["code", "title"] } + } +} diff --git a/src/sites.js b/src/sites.js index 575a835..eade056 100644 --- a/src/sites.js +++ b/src/sites.js @@ -24,6 +24,7 @@ const ALIASES = { aws: 'docs.aws.amazon.com', gcp: 'cloud.google.com', learn: 'learn.microsoft.com', + wiki: 'wikipedia.org', }; /** @typedef {{open: string, args?: string[]}} Shortcut */