@jackwener/opencli 1.1.0 → 1.2.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/.agents/skills/cross-project-adapter-migration/SKILL.md +2 -2
- package/.github/pull_request_template.md +7 -0
- package/.github/workflows/doc-check.yml +36 -0
- package/.github/workflows/docs.yml +7 -42
- package/CHANGELOG.md +23 -0
- package/CLI-EXPLORER.md +9 -8
- package/CONTRIBUTING.md +39 -1
- package/README.md +33 -19
- package/README.zh-CN.md +64 -27
- package/SKILL.md +102 -33
- package/dist/browser/cdp.d.ts +4 -4
- package/dist/browser/cdp.js +45 -17
- package/dist/browser/daemon-client.d.ts +2 -1
- package/dist/browser/dom-helpers.js +38 -7
- package/dist/browser/dom-snapshot.d.ts +86 -0
- package/dist/browser/dom-snapshot.js +729 -0
- package/dist/browser/dom-snapshot.test.d.ts +11 -0
- package/dist/browser/dom-snapshot.test.js +212 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/page.d.ts +18 -25
- package/dist/browser/page.js +44 -5
- package/dist/build-manifest.d.ts +11 -4
- package/dist/build-manifest.js +79 -34
- package/dist/build-manifest.test.js +58 -2
- package/dist/cli-manifest.json +4273 -1771
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +255 -162
- package/dist/clis/apple-podcasts/commands.test.d.ts +2 -0
- package/dist/clis/apple-podcasts/commands.test.js +76 -0
- package/dist/clis/apple-podcasts/search.js +2 -2
- package/dist/clis/apple-podcasts/top.js +9 -2
- package/dist/clis/arxiv/search.js +1 -1
- package/dist/clis/barchart/greeks.js +1 -1
- package/dist/clis/barchart/options.js +1 -1
- package/dist/clis/barchart/quote.js +1 -1
- package/dist/clis/bilibili/download.js +1 -1
- package/dist/clis/bilibili/dynamic.js +1 -1
- package/dist/clis/bilibili/favorite.js +1 -1
- package/dist/clis/bilibili/feed.js +1 -1
- package/dist/clis/bilibili/following.js +2 -2
- package/dist/clis/bilibili/history.js +1 -1
- package/dist/clis/bilibili/me.js +1 -1
- package/dist/clis/bilibili/ranking.js +1 -1
- package/dist/clis/bilibili/search.js +3 -3
- package/dist/clis/bilibili/subtitle.js +2 -2
- package/dist/clis/bilibili/user-videos.js +2 -2
- package/dist/{bilibili.d.ts → clis/bilibili/utils.d.ts} +1 -1
- package/dist/clis/bloomberg/businessweek.js +17 -0
- package/dist/clis/bloomberg/economics.js +17 -0
- package/dist/clis/bloomberg/feeds.d.ts +1 -0
- package/dist/clis/bloomberg/feeds.js +15 -0
- package/dist/clis/bloomberg/industries.d.ts +1 -0
- package/dist/clis/bloomberg/industries.js +17 -0
- package/dist/clis/bloomberg/main.d.ts +1 -0
- package/dist/clis/bloomberg/main.js +17 -0
- package/dist/clis/bloomberg/markets.d.ts +1 -0
- package/dist/clis/bloomberg/markets.js +17 -0
- package/dist/clis/bloomberg/news.d.ts +1 -0
- package/dist/clis/bloomberg/news.js +105 -0
- package/dist/clis/bloomberg/opinions.d.ts +1 -0
- package/dist/clis/bloomberg/opinions.js +17 -0
- package/dist/clis/bloomberg/politics.d.ts +1 -0
- package/dist/clis/bloomberg/politics.js +17 -0
- package/dist/clis/bloomberg/tech.d.ts +1 -0
- package/dist/clis/bloomberg/tech.js +17 -0
- package/dist/clis/bloomberg/utils.d.ts +34 -0
- package/dist/clis/bloomberg/utils.js +364 -0
- package/dist/clis/bloomberg/utils.test.d.ts +1 -0
- package/dist/clis/bloomberg/utils.test.js +129 -0
- package/dist/clis/boss/batchgreet.js +12 -99
- package/dist/clis/boss/chatlist.js +9 -26
- package/dist/clis/boss/chatmsg.js +11 -42
- package/dist/clis/boss/common.d.ts +92 -0
- package/dist/clis/boss/common.js +223 -0
- package/dist/clis/boss/detail.js +8 -50
- package/dist/clis/boss/exchange.js +13 -79
- package/dist/clis/boss/greet.js +20 -147
- package/dist/clis/boss/invite.js +26 -121
- package/dist/clis/boss/joblist.js +6 -31
- package/dist/clis/boss/mark.js +12 -85
- package/dist/clis/boss/recommend.js +10 -49
- package/dist/clis/boss/resume.js +18 -118
- package/dist/clis/boss/search.js +13 -61
- package/dist/clis/boss/send.js +18 -152
- package/dist/clis/boss/stats.js +20 -71
- package/dist/clis/chaoxing/assignments.js +1 -1
- package/dist/clis/chaoxing/exams.js +1 -1
- package/dist/{chaoxing.d.ts → clis/chaoxing/utils.d.ts} +1 -1
- package/dist/{chaoxing.js → clis/chaoxing/utils.js} +0 -2
- package/dist/clis/chaoxing/utils.test.d.ts +1 -0
- package/dist/{chaoxing.test.js → clis/chaoxing/utils.test.js} +1 -1
- package/dist/clis/chatgpt/read.js +1 -1
- package/dist/clis/chatwise/export.js +1 -1
- package/dist/clis/chatwise/model.js +2 -2
- package/dist/clis/chatwise/screenshot.js +1 -1
- package/dist/clis/codex/export.js +1 -1
- package/dist/clis/codex/model.js +2 -2
- package/dist/clis/codex/screenshot.js +1 -1
- package/dist/clis/coupang/add-to-cart.js +3 -4
- package/dist/clis/coupang/search.js +2 -4
- package/dist/clis/coupang/utils.test.d.ts +1 -0
- package/dist/{coupang.test.js → clis/coupang/utils.test.js} +1 -1
- package/dist/clis/ctrip/search.js +1 -1
- package/dist/clis/cursor/export.js +1 -1
- package/dist/clis/cursor/model.js +2 -2
- package/dist/clis/cursor/screenshot.js +1 -1
- package/dist/clis/devto/tag.yaml +34 -0
- package/dist/clis/devto/top.yaml +29 -0
- package/dist/clis/devto/user.yaml +33 -0
- package/dist/clis/douban/book-hot.d.ts +1 -0
- package/dist/clis/douban/book-hot.js +14 -0
- package/dist/clis/douban/marks.d.ts +1 -0
- package/dist/clis/douban/marks.js +115 -0
- package/dist/clis/douban/movie-hot.d.ts +1 -0
- package/dist/clis/douban/movie-hot.js +14 -0
- package/dist/clis/douban/reviews.d.ts +1 -0
- package/dist/clis/douban/reviews.js +106 -0
- package/dist/clis/douban/search.d.ts +1 -0
- package/dist/clis/douban/search.js +16 -0
- package/dist/clis/douban/shared.d.ts +4 -0
- package/dist/clis/douban/shared.js +155 -0
- package/dist/clis/douban/subject.yaml +76 -0
- package/dist/clis/douban/top250.yaml +70 -0
- package/dist/clis/douban/utils.d.ts +35 -0
- package/dist/clis/douban/utils.js +48 -0
- package/dist/clis/facebook/add-friend.yaml +43 -0
- package/dist/clis/facebook/events.yaml +44 -0
- package/dist/clis/facebook/feed.yaml +63 -0
- package/dist/clis/facebook/friends.yaml +42 -0
- package/dist/clis/facebook/groups.yaml +50 -0
- package/dist/clis/facebook/join-group.yaml +44 -0
- package/dist/clis/facebook/memories.yaml +39 -0
- package/dist/clis/facebook/notifications.yaml +40 -0
- package/dist/clis/facebook/profile.yaml +37 -0
- package/dist/clis/facebook/search.yaml +46 -0
- package/dist/clis/google/news.d.ts +5 -0
- package/dist/clis/google/news.js +58 -0
- package/dist/clis/google/search.d.ts +10 -0
- package/dist/clis/google/search.js +127 -0
- package/dist/clis/google/suggest.d.ts +5 -0
- package/dist/clis/google/suggest.js +34 -0
- package/dist/clis/google/trends.d.ts +5 -0
- package/dist/clis/google/trends.js +38 -0
- package/dist/clis/google/utils.d.ts +9 -0
- package/dist/clis/google/utils.js +23 -0
- package/dist/clis/google/utils.test.d.ts +1 -0
- package/dist/clis/google/utils.test.js +75 -0
- package/dist/clis/grok/ask.d.ts +14 -0
- package/dist/clis/grok/ask.js +257 -65
- package/dist/clis/grok/ask.test.d.ts +1 -0
- package/dist/clis/grok/ask.test.js +36 -0
- package/dist/clis/instagram/comment.yaml +52 -0
- package/dist/clis/instagram/explore.yaml +43 -0
- package/dist/clis/instagram/follow.yaml +41 -0
- package/dist/clis/instagram/followers.yaml +51 -0
- package/dist/clis/instagram/following.yaml +51 -0
- package/dist/clis/instagram/like.yaml +46 -0
- package/dist/clis/instagram/profile.yaml +42 -0
- package/dist/clis/instagram/save.yaml +46 -0
- package/dist/clis/instagram/saved.yaml +40 -0
- package/dist/clis/instagram/search.yaml +43 -0
- package/dist/clis/instagram/unfollow.yaml +38 -0
- package/dist/clis/instagram/unlike.yaml +46 -0
- package/dist/clis/instagram/unsave.yaml +46 -0
- package/dist/clis/instagram/user.yaml +54 -0
- package/dist/clis/jike/comment.js +2 -3
- package/dist/clis/jike/create.js +1 -2
- package/dist/clis/jike/feed.js +0 -1
- package/dist/clis/jike/like.js +1 -2
- package/dist/clis/jike/notifications.js +0 -1
- package/dist/clis/jike/post.yaml +1 -0
- package/dist/clis/jike/repost.js +2 -3
- package/dist/clis/jike/search.js +2 -3
- package/dist/clis/jike/topic.yaml +1 -0
- package/dist/clis/jike/user.yaml +1 -0
- package/dist/clis/jimeng/generate.yaml +1 -0
- package/dist/clis/jimeng/history.yaml +0 -1
- package/dist/clis/linkedin/search.js +7 -7
- package/dist/clis/linux-do/category.yaml +2 -0
- package/dist/clis/linux-do/search.yaml +4 -3
- package/dist/clis/linux-do/topic.yaml +1 -0
- package/dist/clis/lobsters/active.yaml +29 -0
- package/dist/clis/lobsters/hot.yaml +29 -0
- package/dist/clis/lobsters/newest.yaml +29 -0
- package/dist/clis/lobsters/tag.yaml +34 -0
- package/dist/clis/medium/feed.d.ts +1 -0
- package/dist/clis/medium/feed.js +15 -0
- package/dist/clis/medium/search.d.ts +1 -0
- package/dist/clis/medium/search.js +15 -0
- package/dist/clis/medium/shared.d.ts +5 -0
- package/dist/clis/medium/shared.js +78 -0
- package/dist/clis/medium/user.d.ts +1 -0
- package/dist/clis/medium/user.js +15 -0
- package/dist/clis/notion/export.js +1 -1
- package/dist/clis/reddit/comment.js +3 -4
- package/dist/clis/reddit/read.js +4 -5
- package/dist/clis/reddit/save.js +2 -3
- package/dist/clis/reddit/saved.js +0 -1
- package/dist/clis/reddit/search.yaml +1 -0
- package/dist/clis/reddit/subreddit.yaml +1 -0
- package/dist/clis/reddit/subscribe.js +1 -2
- package/dist/clis/reddit/upvote.js +2 -3
- package/dist/clis/reddit/upvoted.js +0 -1
- package/dist/clis/reddit/user-comments.yaml +1 -0
- package/dist/clis/reddit/user-posts.yaml +1 -0
- package/dist/clis/reddit/user.yaml +1 -0
- package/dist/clis/reuters/search.js +1 -1
- package/dist/clis/sinablog/article.d.ts +1 -0
- package/dist/clis/sinablog/article.js +14 -0
- package/dist/clis/sinablog/hot.d.ts +1 -0
- package/dist/clis/sinablog/hot.js +14 -0
- package/dist/clis/sinablog/search.d.ts +1 -0
- package/dist/clis/sinablog/search.js +51 -0
- package/dist/clis/sinablog/shared.d.ts +7 -0
- package/dist/clis/sinablog/shared.js +187 -0
- package/dist/clis/sinablog/user.d.ts +1 -0
- package/dist/clis/sinablog/user.js +15 -0
- package/dist/clis/smzdm/search.js +2 -3
- package/dist/clis/stackoverflow/search.yaml +1 -0
- package/dist/clis/steam/top-sellers.yaml +29 -0
- package/dist/clis/substack/feed.d.ts +1 -0
- package/dist/clis/substack/feed.js +15 -0
- package/dist/clis/substack/publication.d.ts +1 -0
- package/dist/clis/substack/publication.js +15 -0
- package/dist/clis/substack/search.d.ts +1 -0
- package/dist/clis/substack/search.js +77 -0
- package/dist/clis/substack/shared.d.ts +4 -0
- package/dist/clis/substack/shared.js +129 -0
- package/dist/clis/tiktok/comment.yaml +66 -0
- package/dist/clis/tiktok/explore.yaml +39 -0
- package/dist/clis/tiktok/follow.yaml +39 -0
- package/dist/clis/tiktok/following.yaml +46 -0
- package/dist/clis/tiktok/friends.yaml +47 -0
- package/dist/clis/tiktok/like.yaml +38 -0
- package/dist/clis/tiktok/live.yaml +51 -0
- package/dist/clis/tiktok/notifications.yaml +52 -0
- package/dist/clis/tiktok/profile.yaml +45 -0
- package/dist/clis/tiktok/save.yaml +34 -0
- package/dist/clis/tiktok/search.yaml +46 -0
- package/dist/clis/tiktok/unfollow.yaml +44 -0
- package/dist/clis/tiktok/unlike.yaml +38 -0
- package/dist/clis/tiktok/unsave.yaml +36 -0
- package/dist/clis/tiktok/user.yaml +44 -0
- package/dist/clis/twitter/accept.js +2 -2
- package/dist/clis/twitter/article.js +2 -2
- package/dist/clis/twitter/block.d.ts +1 -0
- package/dist/clis/twitter/block.js +88 -0
- package/dist/clis/twitter/delete.js +1 -1
- package/dist/clis/twitter/download.d.ts +1 -1
- package/dist/clis/twitter/download.js +3 -3
- package/dist/clis/twitter/followers.js +1 -1
- package/dist/clis/twitter/following.js +1 -1
- package/dist/clis/twitter/hide-reply.d.ts +1 -0
- package/dist/clis/twitter/hide-reply.js +66 -0
- package/dist/clis/twitter/like.js +1 -1
- package/dist/clis/twitter/post.js +1 -1
- package/dist/clis/twitter/reply-dm.js +1 -1
- package/dist/clis/twitter/reply.js +2 -2
- package/dist/clis/twitter/search.js +1 -1
- package/dist/clis/twitter/thread.js +2 -2
- package/dist/clis/twitter/timeline.d.ts +23 -0
- package/dist/clis/twitter/timeline.js +42 -14
- package/dist/clis/twitter/timeline.test.d.ts +1 -0
- package/dist/clis/twitter/timeline.test.js +102 -0
- package/dist/clis/twitter/trending.d.ts +1 -0
- package/dist/clis/twitter/trending.js +91 -0
- package/dist/clis/twitter/unblock.d.ts +1 -0
- package/dist/clis/twitter/unblock.js +71 -0
- package/dist/clis/v2ex/topic.yaml +1 -0
- package/dist/clis/weibo/hot.js +0 -1
- package/dist/clis/weread/book.js +1 -1
- package/dist/clis/weread/highlights.js +1 -1
- package/dist/clis/weread/notes.js +1 -1
- package/dist/clis/weread/search.js +1 -1
- package/dist/clis/wikipedia/random.d.ts +1 -0
- package/dist/clis/wikipedia/random.js +19 -0
- package/dist/clis/wikipedia/search.js +4 -4
- package/dist/clis/wikipedia/summary.js +4 -9
- package/dist/clis/wikipedia/trending.d.ts +1 -0
- package/dist/clis/wikipedia/trending.js +35 -0
- package/dist/clis/wikipedia/utils.d.ts +28 -0
- package/dist/clis/wikipedia/utils.js +13 -0
- package/dist/clis/xiaohongshu/creator-note-detail.d.ts +15 -0
- package/dist/clis/xiaohongshu/creator-note-detail.js +69 -5
- package/dist/clis/xiaohongshu/creator-note-detail.test.js +82 -33
- package/dist/clis/xiaohongshu/creator-notes.js +35 -5
- package/dist/clis/xiaohongshu/creator-notes.test.js +37 -6
- package/dist/clis/xiaohongshu/creator-profile.js +0 -1
- package/dist/clis/xiaohongshu/creator-stats.js +0 -1
- package/dist/clis/xiaohongshu/download.js +2 -3
- package/dist/clis/xiaohongshu/feed.yaml +0 -1
- package/dist/clis/xiaohongshu/notifications.yaml +0 -1
- package/dist/clis/xiaohongshu/search.js +2 -2
- package/dist/clis/xiaohongshu/user.js +1 -2
- package/dist/clis/xueqiu/earnings-date.yaml +69 -0
- package/dist/clis/xueqiu/search.yaml +2 -1
- package/dist/clis/xueqiu/stock.yaml +2 -0
- package/dist/clis/yahoo-finance/quote.js +1 -2
- package/dist/clis/youtube/search.js +1 -1
- package/dist/clis/youtube/transcript.js +1 -1
- package/dist/clis/youtube/video.js +1 -1
- package/dist/clis/zhihu/download.js +1 -2
- package/dist/clis/zhihu/question.js +1 -1
- package/dist/clis/zhihu/search.yaml +4 -3
- package/dist/commanderAdapter.d.ts +21 -0
- package/dist/commanderAdapter.js +117 -0
- package/dist/{engine.d.ts → discovery.d.ts} +6 -4
- package/dist/{engine.js → discovery.js} +93 -104
- package/dist/doctor.js +3 -1
- package/dist/doctor.test.js +46 -2
- package/dist/download/index.d.ts +2 -6
- package/dist/download/index.js +19 -46
- package/dist/engine.test.d.ts +0 -3
- package/dist/engine.test.js +80 -11
- package/dist/execution.d.ts +24 -0
- package/dist/execution.js +153 -0
- package/dist/explore.d.ts +76 -3
- package/dist/explore.js +132 -111
- package/dist/external-clis.yaml +48 -0
- package/dist/external.d.ts +7 -2
- package/dist/external.js +11 -14
- package/dist/generate.d.ts +41 -2
- package/dist/generate.js +5 -4
- package/dist/main.js +2 -1
- package/dist/pipeline/executor.d.ts +2 -2
- package/dist/pipeline/executor.js +2 -2
- package/dist/pipeline/executor.test.js +33 -6
- package/dist/pipeline/registry.d.ts +1 -1
- package/dist/pipeline/steps/browser.d.ts +7 -7
- package/dist/pipeline/steps/browser.js +21 -7
- package/dist/pipeline/steps/fetch.d.ts +1 -1
- package/dist/pipeline/steps/fetch.js +11 -7
- package/dist/pipeline/steps/transform.d.ts +6 -5
- package/dist/pipeline/steps/transform.js +30 -9
- package/dist/pipeline/template.d.ts +6 -6
- package/dist/pipeline/template.js +43 -5
- package/dist/pipeline/template.test.js +18 -0
- package/dist/pipeline/transform.test.js +11 -0
- package/dist/plugin.d.ts +31 -0
- package/dist/plugin.js +216 -0
- package/dist/plugin.test.d.ts +4 -0
- package/dist/plugin.test.js +76 -0
- package/dist/registry-api.d.ts +11 -0
- package/dist/registry-api.js +9 -0
- package/dist/registry.d.ts +13 -0
- package/dist/registry.js +8 -1
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.js +8 -0
- package/dist/serialization.d.ts +34 -0
- package/dist/serialization.js +63 -0
- package/dist/synthesize.d.ts +94 -4
- package/dist/synthesize.js +5 -4
- package/dist/types.d.ts +43 -27
- package/dist/validate.js +8 -2
- package/docs/.vitepress/config.mts +20 -7
- package/docs/adapters/browser/arxiv.md +27 -0
- package/docs/adapters/browser/barchart.md +33 -0
- package/docs/adapters/browser/bilibili.md +9 -0
- package/docs/adapters/browser/bloomberg.md +70 -0
- package/docs/adapters/browser/chaoxing.md +39 -0
- package/docs/adapters/browser/devto.md +35 -0
- package/docs/adapters/browser/douban.md +38 -0
- package/docs/adapters/browser/facebook.md +36 -0
- package/docs/adapters/browser/google.md +62 -0
- package/docs/adapters/browser/grok.md +53 -0
- package/docs/adapters/browser/hf.md +42 -0
- package/docs/adapters/browser/instagram.md +46 -0
- package/docs/adapters/browser/jike.md +45 -0
- package/docs/adapters/browser/jimeng.md +39 -0
- package/docs/adapters/browser/linux-do.md +45 -0
- package/docs/adapters/browser/lobsters.md +32 -0
- package/docs/adapters/browser/medium.md +32 -0
- package/docs/adapters/browser/reddit.md +9 -0
- package/docs/adapters/browser/sinablog.md +36 -0
- package/docs/adapters/browser/sinafinance.md +35 -0
- package/docs/adapters/browser/stackoverflow.md +35 -0
- package/docs/adapters/browser/steam.md +26 -0
- package/docs/adapters/browser/substack.md +38 -0
- package/docs/adapters/browser/tiktok.md +68 -0
- package/docs/adapters/browser/twitter.md +3 -0
- package/docs/adapters/browser/weread.md +48 -0
- package/docs/adapters/browser/wikipedia.md +39 -0
- package/docs/adapters/browser/xiaohongshu.md +5 -1
- package/docs/adapters/browser/xueqiu.md +10 -0
- package/docs/adapters/browser/yahoo-finance.md +6 -5
- package/docs/adapters/desktop/antigravity.md +6 -0
- package/docs/adapters/desktop/chatgpt.md +5 -4
- package/docs/adapters/desktop/codex.md +5 -1
- package/docs/adapters/desktop/cursor.md +4 -0
- package/docs/adapters/desktop/discord.md +7 -7
- package/docs/adapters/index.md +14 -4
- package/docs/advanced/download.md +4 -4
- package/docs/developer/architecture.md +17 -4
- package/docs/guide/getting-started.md +1 -0
- package/docs/guide/plugins.md +153 -0
- package/docs/zh/guide/plugins.md +107 -0
- package/extension/src/background.ts +18 -11
- package/package.json +10 -5
- package/scripts/check-doc-coverage.sh +69 -0
- package/scripts/clean-dist.cjs +13 -0
- package/scripts/copy-yaml.cjs +7 -0
- package/src/browser/cdp.ts +77 -32
- package/src/browser/daemon-client.ts +2 -1
- package/src/browser/dom-helpers.ts +38 -7
- package/src/browser/dom-snapshot.test.ts +249 -0
- package/src/browser/dom-snapshot.ts +770 -0
- package/src/browser/index.ts +2 -0
- package/src/browser/page.ts +57 -20
- package/src/build-manifest.test.ts +70 -2
- package/src/build-manifest.ts +114 -40
- package/src/cli.ts +287 -139
- package/src/clis/apple-podcasts/commands.test.ts +95 -0
- package/src/clis/apple-podcasts/search.ts +2 -2
- package/src/clis/apple-podcasts/top.ts +12 -2
- package/src/clis/arxiv/search.ts +1 -1
- package/src/clis/barchart/greeks.ts +1 -1
- package/src/clis/barchart/options.ts +1 -1
- package/src/clis/barchart/quote.ts +1 -1
- package/src/clis/bilibili/download.ts +1 -1
- package/src/clis/bilibili/dynamic.ts +1 -1
- package/src/clis/bilibili/favorite.ts +1 -1
- package/src/clis/bilibili/feed.ts +1 -1
- package/src/clis/bilibili/following.ts +2 -2
- package/src/clis/bilibili/history.ts +1 -1
- package/src/clis/bilibili/me.ts +1 -1
- package/src/clis/bilibili/ranking.ts +1 -1
- package/src/clis/bilibili/search.ts +3 -3
- package/src/clis/bilibili/subtitle.ts +2 -2
- package/src/clis/bilibili/user-videos.ts +2 -2
- package/src/{bilibili.ts → clis/bilibili/utils.ts} +1 -1
- package/src/clis/bloomberg/businessweek.ts +18 -0
- package/src/clis/bloomberg/economics.ts +18 -0
- package/src/clis/bloomberg/feeds.ts +16 -0
- package/src/clis/bloomberg/industries.ts +18 -0
- package/src/clis/bloomberg/main.ts +18 -0
- package/src/clis/bloomberg/markets.ts +18 -0
- package/src/clis/bloomberg/news.ts +136 -0
- package/src/clis/bloomberg/opinions.ts +18 -0
- package/src/clis/bloomberg/politics.ts +18 -0
- package/src/clis/bloomberg/tech.ts +18 -0
- package/src/clis/bloomberg/utils.test.ts +135 -0
- package/src/clis/bloomberg/utils.ts +429 -0
- package/src/clis/boss/batchgreet.ts +16 -108
- package/src/clis/boss/chatlist.ts +13 -27
- package/src/clis/boss/chatmsg.ts +16 -40
- package/src/clis/boss/common.ts +287 -0
- package/src/clis/boss/detail.ts +9 -55
- package/src/clis/boss/exchange.ts +15 -89
- package/src/clis/boss/greet.ts +25 -162
- package/src/clis/boss/invite.ts +36 -133
- package/src/clis/boss/joblist.ts +7 -36
- package/src/clis/boss/mark.ts +13 -94
- package/src/clis/boss/recommend.ts +12 -57
- package/src/clis/boss/resume.ts +19 -124
- package/src/clis/boss/search.ts +14 -67
- package/src/clis/boss/send.ts +22 -162
- package/src/clis/boss/stats.ts +21 -76
- package/src/clis/chaoxing/assignments.ts +1 -1
- package/src/clis/chaoxing/exams.ts +1 -1
- package/src/{chaoxing.test.ts → clis/chaoxing/utils.test.ts} +1 -1
- package/src/{chaoxing.ts → clis/chaoxing/utils.ts} +1 -3
- package/src/clis/chatgpt/read.ts +1 -1
- package/src/clis/chatwise/export.ts +1 -1
- package/src/clis/chatwise/model.ts +2 -2
- package/src/clis/chatwise/screenshot.ts +1 -1
- package/src/clis/codex/export.ts +1 -1
- package/src/clis/codex/model.ts +2 -2
- package/src/clis/codex/screenshot.ts +1 -1
- package/src/clis/coupang/add-to-cart.ts +3 -4
- package/src/clis/coupang/search.ts +2 -4
- package/src/{coupang.test.ts → clis/coupang/utils.test.ts} +1 -1
- package/src/clis/ctrip/search.ts +1 -1
- package/src/clis/cursor/export.ts +1 -1
- package/src/clis/cursor/model.ts +2 -2
- package/src/clis/cursor/screenshot.ts +1 -1
- package/src/clis/devto/tag.yaml +34 -0
- package/src/clis/devto/top.yaml +29 -0
- package/src/clis/devto/user.yaml +33 -0
- package/src/clis/douban/book-hot.ts +15 -0
- package/src/clis/douban/marks.ts +135 -0
- package/src/clis/douban/movie-hot.ts +15 -0
- package/src/clis/douban/reviews.ts +127 -0
- package/src/clis/douban/search.ts +17 -0
- package/src/clis/douban/shared.ts +165 -0
- package/src/clis/douban/subject.yaml +76 -0
- package/src/clis/douban/top250.yaml +70 -0
- package/src/clis/douban/utils.ts +81 -0
- package/src/clis/facebook/add-friend.yaml +43 -0
- package/src/clis/facebook/events.yaml +44 -0
- package/src/clis/facebook/feed.yaml +63 -0
- package/src/clis/facebook/friends.yaml +42 -0
- package/src/clis/facebook/groups.yaml +50 -0
- package/src/clis/facebook/join-group.yaml +44 -0
- package/src/clis/facebook/memories.yaml +39 -0
- package/src/clis/facebook/notifications.yaml +40 -0
- package/src/clis/facebook/profile.yaml +37 -0
- package/src/clis/facebook/search.yaml +46 -0
- package/src/clis/google/news.ts +66 -0
- package/src/clis/google/search.ts +133 -0
- package/src/clis/google/suggest.ts +40 -0
- package/src/clis/google/trends.ts +44 -0
- package/src/clis/google/utils.test.ts +82 -0
- package/src/clis/google/utils.ts +24 -0
- package/src/clis/grok/ask.test.ts +53 -0
- package/src/clis/grok/ask.ts +300 -69
- package/src/clis/instagram/comment.yaml +52 -0
- package/src/clis/instagram/explore.yaml +43 -0
- package/src/clis/instagram/follow.yaml +41 -0
- package/src/clis/instagram/followers.yaml +51 -0
- package/src/clis/instagram/following.yaml +51 -0
- package/src/clis/instagram/like.yaml +46 -0
- package/src/clis/instagram/profile.yaml +42 -0
- package/src/clis/instagram/save.yaml +46 -0
- package/src/clis/instagram/saved.yaml +40 -0
- package/src/clis/instagram/search.yaml +43 -0
- package/src/clis/instagram/unfollow.yaml +38 -0
- package/src/clis/instagram/unlike.yaml +46 -0
- package/src/clis/instagram/unsave.yaml +46 -0
- package/src/clis/instagram/user.yaml +54 -0
- package/src/clis/jike/comment.ts +2 -3
- package/src/clis/jike/create.ts +1 -2
- package/src/clis/jike/feed.ts +0 -1
- package/src/clis/jike/like.ts +1 -2
- package/src/clis/jike/notifications.ts +0 -1
- package/src/clis/jike/post.yaml +1 -0
- package/src/clis/jike/repost.ts +2 -3
- package/src/clis/jike/search.ts +2 -3
- package/src/clis/jike/topic.yaml +1 -0
- package/src/clis/jike/user.yaml +1 -0
- package/src/clis/jimeng/generate.yaml +1 -0
- package/src/clis/jimeng/history.yaml +0 -1
- package/src/clis/linkedin/search.ts +7 -7
- package/src/clis/linux-do/category.yaml +2 -0
- package/src/clis/linux-do/search.yaml +4 -3
- package/src/clis/linux-do/topic.yaml +1 -0
- package/src/clis/lobsters/active.yaml +29 -0
- package/src/clis/lobsters/hot.yaml +29 -0
- package/src/clis/lobsters/newest.yaml +29 -0
- package/src/clis/lobsters/tag.yaml +34 -0
- package/src/clis/medium/feed.ts +16 -0
- package/src/clis/medium/search.ts +16 -0
- package/src/clis/medium/shared.ts +83 -0
- package/src/clis/medium/user.ts +16 -0
- package/src/clis/notion/export.ts +1 -1
- package/src/clis/reddit/comment.ts +3 -4
- package/src/clis/reddit/read.ts +4 -5
- package/src/clis/reddit/save.ts +2 -3
- package/src/clis/reddit/saved.ts +0 -1
- package/src/clis/reddit/search.yaml +1 -0
- package/src/clis/reddit/subreddit.yaml +1 -0
- package/src/clis/reddit/subscribe.ts +1 -2
- package/src/clis/reddit/upvote.ts +2 -3
- package/src/clis/reddit/upvoted.ts +0 -1
- package/src/clis/reddit/user-comments.yaml +1 -0
- package/src/clis/reddit/user-posts.yaml +1 -0
- package/src/clis/reddit/user.yaml +1 -0
- package/src/clis/reuters/search.ts +1 -1
- package/src/clis/sinablog/article.ts +15 -0
- package/src/clis/sinablog/hot.ts +15 -0
- package/src/clis/sinablog/search.ts +56 -0
- package/src/clis/sinablog/shared.ts +198 -0
- package/src/clis/sinablog/user.ts +16 -0
- package/src/clis/smzdm/search.ts +2 -3
- package/src/clis/stackoverflow/search.yaml +1 -0
- package/src/clis/steam/top-sellers.yaml +29 -0
- package/src/clis/substack/feed.ts +16 -0
- package/src/clis/substack/publication.ts +16 -0
- package/src/clis/substack/search.ts +91 -0
- package/src/clis/substack/shared.ts +132 -0
- package/src/clis/tiktok/comment.yaml +66 -0
- package/src/clis/tiktok/explore.yaml +39 -0
- package/src/clis/tiktok/follow.yaml +39 -0
- package/src/clis/tiktok/following.yaml +46 -0
- package/src/clis/tiktok/friends.yaml +47 -0
- package/src/clis/tiktok/like.yaml +38 -0
- package/src/clis/tiktok/live.yaml +51 -0
- package/src/clis/tiktok/notifications.yaml +52 -0
- package/src/clis/tiktok/profile.yaml +45 -0
- package/src/clis/tiktok/save.yaml +34 -0
- package/src/clis/tiktok/search.yaml +46 -0
- package/src/clis/tiktok/unfollow.yaml +44 -0
- package/src/clis/tiktok/unlike.yaml +38 -0
- package/src/clis/tiktok/unsave.yaml +36 -0
- package/src/clis/tiktok/user.yaml +44 -0
- package/src/clis/twitter/accept.ts +2 -2
- package/src/clis/twitter/article.ts +2 -2
- package/src/clis/twitter/block.ts +92 -0
- package/src/clis/twitter/delete.ts +1 -1
- package/src/clis/twitter/download.ts +3 -3
- package/src/clis/twitter/followers.ts +1 -1
- package/src/clis/twitter/following.ts +1 -1
- package/src/clis/twitter/hide-reply.ts +70 -0
- package/src/clis/twitter/like.ts +1 -1
- package/src/clis/twitter/post.ts +1 -1
- package/src/clis/twitter/reply-dm.ts +1 -1
- package/src/clis/twitter/reply.ts +2 -2
- package/src/clis/twitter/search.ts +1 -1
- package/src/clis/twitter/thread.ts +2 -2
- package/src/clis/twitter/timeline.test.ts +109 -0
- package/src/clis/twitter/timeline.ts +59 -19
- package/src/clis/twitter/trending.ts +113 -0
- package/src/clis/twitter/unblock.ts +75 -0
- package/src/clis/v2ex/topic.yaml +1 -0
- package/src/clis/weibo/hot.ts +0 -1
- package/src/clis/weread/book.ts +1 -1
- package/src/clis/weread/highlights.ts +1 -1
- package/src/clis/weread/notes.ts +1 -1
- package/src/clis/weread/search.ts +1 -1
- package/src/clis/wikipedia/random.ts +19 -0
- package/src/clis/wikipedia/search.ts +11 -5
- package/src/clis/wikipedia/summary.ts +4 -9
- package/src/clis/wikipedia/trending.ts +41 -0
- package/src/clis/wikipedia/utils.ts +31 -0
- package/src/clis/xiaohongshu/creator-note-detail.test.ts +84 -33
- package/src/clis/xiaohongshu/creator-note-detail.ts +89 -5
- package/src/clis/xiaohongshu/creator-notes.test.ts +41 -6
- package/src/clis/xiaohongshu/creator-notes.ts +44 -5
- package/src/clis/xiaohongshu/creator-profile.ts +0 -1
- package/src/clis/xiaohongshu/creator-stats.ts +0 -1
- package/src/clis/xiaohongshu/download.ts +2 -3
- package/src/clis/xiaohongshu/feed.yaml +0 -1
- package/src/clis/xiaohongshu/notifications.yaml +0 -1
- package/src/clis/xiaohongshu/search.ts +2 -2
- package/src/clis/xiaohongshu/user.ts +1 -2
- package/src/clis/xueqiu/earnings-date.yaml +69 -0
- package/src/clis/xueqiu/search.yaml +2 -1
- package/src/clis/xueqiu/stock.yaml +2 -0
- package/src/clis/yahoo-finance/quote.ts +1 -2
- package/src/clis/youtube/search.ts +1 -1
- package/src/clis/youtube/transcript.ts +1 -1
- package/src/clis/youtube/video.ts +1 -1
- package/src/clis/zhihu/download.ts +1 -2
- package/src/clis/zhihu/question.ts +1 -1
- package/src/clis/zhihu/search.yaml +4 -3
- package/src/commanderAdapter.ts +120 -0
- package/src/discovery.ts +277 -0
- package/src/doctor.test.ts +59 -2
- package/src/doctor.ts +4 -2
- package/src/download/index.ts +21 -54
- package/src/engine.test.ts +85 -11
- package/src/execution.ts +164 -0
- package/src/explore.ts +211 -117
- package/src/external-clis.yaml +9 -0
- package/src/external.ts +15 -12
- package/src/generate.ts +58 -9
- package/src/main.ts +2 -1
- package/src/pipeline/executor.test.ts +35 -6
- package/src/pipeline/executor.ts +11 -7
- package/src/pipeline/registry.ts +3 -3
- package/src/pipeline/steps/browser.ts +29 -15
- package/src/pipeline/steps/fetch.ts +18 -13
- package/src/pipeline/steps/transform.ts +40 -15
- package/src/pipeline/template.test.ts +18 -0
- package/src/pipeline/template.ts +86 -13
- package/src/pipeline/transform.test.ts +15 -2
- package/src/plugin.test.ts +86 -0
- package/src/plugin.ts +254 -0
- package/src/registry-api.ts +12 -0
- package/src/registry.ts +24 -1
- package/src/runtime.ts +9 -0
- package/src/serialization.ts +79 -0
- package/src/synthesize.ts +102 -21
- package/src/types.ts +45 -13
- package/src/validate.ts +19 -4
- package/tests/e2e/browser-public.test.ts +36 -0
- package/tests/e2e/public-commands.test.ts +119 -1
- package/dist/clis/feishu/new.d.ts +0 -1
- package/dist/clis/feishu/new.js +0 -27
- package/dist/clis/feishu/read.d.ts +0 -1
- package/dist/clis/feishu/read.js +0 -40
- package/dist/clis/feishu/search.d.ts +0 -1
- package/dist/clis/feishu/search.js +0 -30
- package/dist/clis/feishu/send.d.ts +0 -1
- package/dist/clis/feishu/send.js +0 -39
- package/dist/clis/feishu/status.d.ts +0 -1
- package/dist/clis/feishu/status.js +0 -28
- package/dist/clis/neteasemusic/like.d.ts +0 -1
- package/dist/clis/neteasemusic/like.js +0 -25
- package/dist/clis/neteasemusic/lyrics.d.ts +0 -1
- package/dist/clis/neteasemusic/lyrics.js +0 -47
- package/dist/clis/neteasemusic/next.d.ts +0 -1
- package/dist/clis/neteasemusic/next.js +0 -26
- package/dist/clis/neteasemusic/play.d.ts +0 -1
- package/dist/clis/neteasemusic/play.js +0 -26
- package/dist/clis/neteasemusic/playing.d.ts +0 -1
- package/dist/clis/neteasemusic/playing.js +0 -59
- package/dist/clis/neteasemusic/playlist.d.ts +0 -1
- package/dist/clis/neteasemusic/playlist.js +0 -46
- package/dist/clis/neteasemusic/prev.d.ts +0 -1
- package/dist/clis/neteasemusic/prev.js +0 -25
- package/dist/clis/neteasemusic/search.d.ts +0 -1
- package/dist/clis/neteasemusic/search.js +0 -52
- package/dist/clis/neteasemusic/status.d.ts +0 -1
- package/dist/clis/neteasemusic/status.js +0 -16
- package/dist/clis/neteasemusic/volume.d.ts +0 -1
- package/dist/clis/neteasemusic/volume.js +0 -54
- package/dist/clis/twitter/trending.yaml +0 -46
- package/dist/clis/wechat/chats.d.ts +0 -1
- package/dist/clis/wechat/chats.js +0 -28
- package/dist/clis/wechat/contacts.d.ts +0 -1
- package/dist/clis/wechat/contacts.js +0 -28
- package/dist/clis/wechat/read.d.ts +0 -1
- package/dist/clis/wechat/read.js +0 -58
- package/dist/clis/wechat/search.d.ts +0 -1
- package/dist/clis/wechat/search.js +0 -31
- package/dist/clis/wechat/send.d.ts +0 -1
- package/dist/clis/wechat/send.js +0 -42
- package/dist/clis/wechat/status.d.ts +0 -1
- package/dist/clis/wechat/status.js +0 -29
- package/dist/pipeline.d.ts +0 -7
- package/dist/pipeline.js +0 -7
- package/docs/adapters/browser/github.md +0 -26
- package/docs/adapters/desktop/feishu.md +0 -20
- package/docs/adapters/desktop/neteasemusic.md +0 -31
- package/docs/adapters/desktop/wechat.md +0 -28
- package/docs/public/CNAME +0 -1
- package/src/clis/antigravity/README.md +0 -5
- package/src/clis/antigravity/README.zh-CN.md +0 -51
- package/src/clis/chaoxing/README.md +0 -14
- package/src/clis/chaoxing/README.zh-CN.md +0 -35
- package/src/clis/chatgpt/README.md +0 -5
- package/src/clis/chatgpt/README.zh-CN.md +0 -44
- package/src/clis/chatwise/README.md +0 -5
- package/src/clis/chatwise/README.zh-CN.md +0 -38
- package/src/clis/codex/README.md +0 -5
- package/src/clis/codex/README.zh-CN.md +0 -33
- package/src/clis/cursor/README.md +0 -5
- package/src/clis/cursor/README.zh-CN.md +0 -33
- package/src/clis/discord-app/README.md +0 -5
- package/src/clis/discord-app/README.zh-CN.md +0 -28
- package/src/clis/feishu/README.md +0 -5
- package/src/clis/feishu/README.zh-CN.md +0 -20
- package/src/clis/feishu/new.ts +0 -32
- package/src/clis/feishu/read.ts +0 -48
- package/src/clis/feishu/search.ts +0 -35
- package/src/clis/feishu/send.ts +0 -46
- package/src/clis/feishu/status.ts +0 -34
- package/src/clis/neteasemusic/README.md +0 -5
- package/src/clis/neteasemusic/README.zh-CN.md +0 -31
- package/src/clis/neteasemusic/like.ts +0 -28
- package/src/clis/neteasemusic/lyrics.ts +0 -53
- package/src/clis/neteasemusic/next.ts +0 -30
- package/src/clis/neteasemusic/play.ts +0 -30
- package/src/clis/neteasemusic/playing.ts +0 -62
- package/src/clis/neteasemusic/playlist.ts +0 -51
- package/src/clis/neteasemusic/prev.ts +0 -29
- package/src/clis/neteasemusic/search.ts +0 -58
- package/src/clis/neteasemusic/status.ts +0 -18
- package/src/clis/neteasemusic/volume.ts +0 -61
- package/src/clis/notion/README.md +0 -5
- package/src/clis/notion/README.zh-CN.md +0 -29
- package/src/clis/twitter/trending.yaml +0 -46
- package/src/clis/wechat/README.md +0 -5
- package/src/clis/wechat/README.zh-CN.md +0 -28
- package/src/clis/wechat/chats.ts +0 -33
- package/src/clis/wechat/contacts.ts +0 -33
- package/src/clis/wechat/read.ts +0 -72
- package/src/clis/wechat/search.ts +0 -36
- package/src/clis/wechat/send.ts +0 -49
- package/src/clis/wechat/status.ts +0 -35
- package/src/engine.ts +0 -274
- package/src/pipeline.ts +0 -8
- /package/dist/{bilibili.js → clis/bilibili/utils.js} +0 -0
- /package/dist/{chaoxing.test.d.ts → clis/bloomberg/businessweek.d.ts} +0 -0
- /package/dist/{coupang.test.d.ts → clis/bloomberg/economics.d.ts} +0 -0
- /package/dist/{coupang.d.ts → clis/coupang/utils.d.ts} +0 -0
- /package/dist/{coupang.js → clis/coupang/utils.js} +0 -0
- /package/src/{coupang.ts → clis/coupang/utils.ts} +0 -0
package/src/explore.ts
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
import * as fs from 'node:fs';
|
|
10
10
|
import * as path from 'node:path';
|
|
11
11
|
import { DEFAULT_BROWSER_EXPLORE_TIMEOUT, browserSession, runWithTimeout } from './runtime.js';
|
|
12
|
+
import type { IBrowserFactory } from './runtime.js';
|
|
12
13
|
import { VOLATILE_PARAMS, SEARCH_PARAMS, PAGINATION_PARAMS, LIMIT_PARAMS, FIELD_ROLES } from './constants.js';
|
|
13
14
|
import { detectFramework } from './scripts/framework.js';
|
|
14
15
|
import { discoverStores } from './scripts/store.js';
|
|
15
16
|
import { interactFuzz } from './scripts/interact.js';
|
|
17
|
+
import type { IPage } from './types.js';
|
|
16
18
|
|
|
17
19
|
// ── Site name detection ────────────────────────────────────────────────────
|
|
18
20
|
|
|
@@ -68,7 +70,61 @@ interface InferredCapability {
|
|
|
68
70
|
name: string; description: string; strategy: string; confidence: number;
|
|
69
71
|
endpoint: string; itemPath: string | null;
|
|
70
72
|
recommendedColumns: string[];
|
|
71
|
-
recommendedArgs: Array<{ name: string; type: string; required: boolean; default?:
|
|
73
|
+
recommendedArgs: Array<{ name: string; type: string; required: boolean; default?: unknown }>;
|
|
74
|
+
storeHint?: { store: string; action: string };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ExploreManifest {
|
|
78
|
+
site: string;
|
|
79
|
+
target_url: string;
|
|
80
|
+
final_url: string;
|
|
81
|
+
title: string;
|
|
82
|
+
framework: Record<string, boolean>;
|
|
83
|
+
stores: Array<{ type: DiscoveredStore['type']; id: string; actions: string[] }>;
|
|
84
|
+
top_strategy: string;
|
|
85
|
+
explored_at?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ExploreAuthSummary {
|
|
89
|
+
top_strategy: string;
|
|
90
|
+
indicators: string[];
|
|
91
|
+
framework: Record<string, boolean>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ExploreEndpointArtifact {
|
|
95
|
+
pattern: string;
|
|
96
|
+
method: string;
|
|
97
|
+
url: string;
|
|
98
|
+
status: number | null;
|
|
99
|
+
contentType: string;
|
|
100
|
+
score: number;
|
|
101
|
+
queryParams: string[];
|
|
102
|
+
itemPath: string | null;
|
|
103
|
+
itemCount: number;
|
|
104
|
+
detectedFields: Record<string, string>;
|
|
105
|
+
authIndicators: string[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface ExploreResult {
|
|
109
|
+
site: string;
|
|
110
|
+
target_url: string;
|
|
111
|
+
final_url: string;
|
|
112
|
+
title: string;
|
|
113
|
+
framework: Record<string, boolean>;
|
|
114
|
+
stores: DiscoveredStore[];
|
|
115
|
+
top_strategy: string;
|
|
116
|
+
endpoint_count: number;
|
|
117
|
+
api_endpoint_count: number;
|
|
118
|
+
capabilities: InferredCapability[];
|
|
119
|
+
auth_indicators: string[];
|
|
120
|
+
out_dir: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface ExploreBundle {
|
|
124
|
+
manifest: ExploreManifest;
|
|
125
|
+
endpoints: ExploreEndpointArtifact[];
|
|
126
|
+
capabilities: InferredCapability[];
|
|
127
|
+
auth: ExploreAuthSummary;
|
|
72
128
|
}
|
|
73
129
|
|
|
74
130
|
/**
|
|
@@ -167,7 +223,11 @@ function flattenFields(obj: unknown, prefix: string, maxDepth: number): string[]
|
|
|
167
223
|
return names;
|
|
168
224
|
}
|
|
169
225
|
|
|
170
|
-
function
|
|
226
|
+
function isBooleanRecord(value: unknown): value is Record<string, boolean> {
|
|
227
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function scoreEndpoint(ep: { contentType: string; responseAnalysis: AnalyzedEndpoint['responseAnalysis']; pattern: string; status: number | null; hasSearchParam: boolean; hasPaginationParam: boolean; hasLimitParam: boolean }): number {
|
|
171
231
|
let s = 0;
|
|
172
232
|
if (ep.contentType.includes('json')) s += 10;
|
|
173
233
|
if (ep.responseAnalysis) { s += 5; s += Math.min(ep.responseAnalysis.itemCount, 10); s += Object.keys(ep.responseAnalysis.detectedFields).length * 2; }
|
|
@@ -223,17 +283,143 @@ export interface DiscoveredStore {
|
|
|
223
283
|
|
|
224
284
|
const INTERACT_FUZZ_JS = interactFuzz.toString();
|
|
225
285
|
|
|
286
|
+
// ── Analysis helpers (extracted from exploreUrl) ───────────────────────────
|
|
287
|
+
|
|
288
|
+
/** Filter, deduplicate, and score network endpoints. */
|
|
289
|
+
function analyzeEndpoints(networkEntries: NetworkEntry[]): { analyzed: AnalyzedEndpoint[]; totalCount: number } {
|
|
290
|
+
const seen = new Map<string, AnalyzedEndpoint>();
|
|
291
|
+
for (const entry of networkEntries) {
|
|
292
|
+
if (!entry.url) continue;
|
|
293
|
+
const ct = entry.contentType.toLowerCase();
|
|
294
|
+
if (ct.includes('image/') || ct.includes('font/') || ct.includes('css') || ct.includes('javascript') || ct.includes('wasm')) continue;
|
|
295
|
+
if (entry.status && entry.status >= 400) continue;
|
|
296
|
+
|
|
297
|
+
const pattern = urlToPattern(entry.url);
|
|
298
|
+
const key = `${entry.method}:${pattern}`;
|
|
299
|
+
if (seen.has(key)) continue;
|
|
300
|
+
|
|
301
|
+
const qp: string[] = [];
|
|
302
|
+
try { new URL(entry.url).searchParams.forEach((_v, k) => { if (!VOLATILE_PARAMS.has(k)) qp.push(k); }); } catch {}
|
|
303
|
+
|
|
304
|
+
const ep: AnalyzedEndpoint = {
|
|
305
|
+
pattern, method: entry.method, url: entry.url, status: entry.status, contentType: ct,
|
|
306
|
+
queryParams: qp, hasSearchParam: qp.some(p => SEARCH_PARAMS.has(p)),
|
|
307
|
+
hasPaginationParam: qp.some(p => PAGINATION_PARAMS.has(p)),
|
|
308
|
+
hasLimitParam: qp.some(p => LIMIT_PARAMS.has(p)),
|
|
309
|
+
authIndicators: detectAuthIndicators(entry.requestHeaders),
|
|
310
|
+
responseAnalysis: entry.responseBody ? analyzeResponseBody(entry.responseBody) : null,
|
|
311
|
+
score: 0,
|
|
312
|
+
};
|
|
313
|
+
ep.score = scoreEndpoint(ep);
|
|
314
|
+
seen.set(key, ep);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const analyzed = [...seen.values()].filter(ep => ep.score >= 5).sort((a, b) => b.score - a.score);
|
|
318
|
+
return { analyzed, totalCount: seen.size };
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** Infer CLI capabilities from analyzed endpoints. */
|
|
322
|
+
function inferCapabilitiesFromEndpoints(
|
|
323
|
+
endpoints: AnalyzedEndpoint[],
|
|
324
|
+
stores: DiscoveredStore[],
|
|
325
|
+
opts: { site?: string; goal?: string; url: string },
|
|
326
|
+
): { capabilities: InferredCapability[]; topStrategy: string; authIndicators: string[] } {
|
|
327
|
+
const capabilities: InferredCapability[] = [];
|
|
328
|
+
const usedNames = new Set<string>();
|
|
329
|
+
|
|
330
|
+
for (const ep of endpoints.slice(0, 8)) {
|
|
331
|
+
let capName = inferCapabilityName(ep.url, opts.goal);
|
|
332
|
+
if (usedNames.has(capName)) {
|
|
333
|
+
const suffix = ep.pattern.split('/').filter(s => s && !s.startsWith('{') && !s.includes('.')).pop();
|
|
334
|
+
capName = suffix ? `${capName}_${suffix}` : `${capName}_${usedNames.size}`;
|
|
335
|
+
}
|
|
336
|
+
usedNames.add(capName);
|
|
337
|
+
|
|
338
|
+
const cols: string[] = [];
|
|
339
|
+
if (ep.responseAnalysis) {
|
|
340
|
+
for (const role of ['title', 'url', 'author', 'score', 'time']) {
|
|
341
|
+
if (ep.responseAnalysis.detectedFields[role]) cols.push(role);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const args: InferredCapability['recommendedArgs'] = [];
|
|
346
|
+
if (ep.hasSearchParam) args.push({ name: 'keyword', type: 'str', required: true });
|
|
347
|
+
args.push({ name: 'limit', type: 'int', required: false, default: 20 });
|
|
348
|
+
if (ep.hasPaginationParam) args.push({ name: 'page', type: 'int', required: false, default: 1 });
|
|
349
|
+
|
|
350
|
+
const epStrategy = inferStrategy(ep.authIndicators);
|
|
351
|
+
let storeHint: { store: string; action: string } | undefined;
|
|
352
|
+
if ((epStrategy === 'intercept' || ep.authIndicators.includes('signature')) && stores.length > 0) {
|
|
353
|
+
for (const s of stores) {
|
|
354
|
+
const matchingAction = s.actions.find(a =>
|
|
355
|
+
capName.split('_').some(part => a.toLowerCase().includes(part)) ||
|
|
356
|
+
a.toLowerCase().includes('fetch') || a.toLowerCase().includes('get')
|
|
357
|
+
);
|
|
358
|
+
if (matchingAction) { storeHint = { store: s.id, action: matchingAction }; break; }
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
capabilities.push({
|
|
363
|
+
name: capName, description: `${opts.site ?? detectSiteName(opts.url)} ${capName}`,
|
|
364
|
+
strategy: storeHint ? 'store-action' : epStrategy,
|
|
365
|
+
confidence: Math.min(ep.score / 20, 1.0), endpoint: ep.pattern,
|
|
366
|
+
itemPath: ep.responseAnalysis?.itemPath ?? null,
|
|
367
|
+
recommendedColumns: cols.length ? cols : ['title', 'url'],
|
|
368
|
+
recommendedArgs: args,
|
|
369
|
+
...(storeHint ? { storeHint } : {}),
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const allAuth = new Set(endpoints.flatMap(ep => ep.authIndicators));
|
|
374
|
+
const topStrategy = allAuth.has('signature') ? 'intercept'
|
|
375
|
+
: allAuth.has('bearer') || allAuth.has('csrf') ? 'header'
|
|
376
|
+
: allAuth.size === 0 ? 'public' : 'cookie';
|
|
377
|
+
|
|
378
|
+
return { capabilities, topStrategy, authIndicators: [...allAuth] };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Write explore artifacts (manifest, endpoints, capabilities, auth, stores) to disk. */
|
|
382
|
+
async function writeExploreArtifacts(
|
|
383
|
+
targetDir: string,
|
|
384
|
+
result: Omit<ExploreResult, 'out_dir'>,
|
|
385
|
+
analyzedEndpoints: AnalyzedEndpoint[],
|
|
386
|
+
stores: DiscoveredStore[],
|
|
387
|
+
): Promise<void> {
|
|
388
|
+
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
389
|
+
const tasks = [
|
|
390
|
+
fs.promises.writeFile(path.join(targetDir, 'manifest.json'), JSON.stringify({
|
|
391
|
+
site: result.site, target_url: result.target_url, final_url: result.final_url, title: result.title,
|
|
392
|
+
framework: result.framework, stores: stores.map(s => ({ type: s.type, id: s.id, actions: s.actions })),
|
|
393
|
+
top_strategy: result.top_strategy, explored_at: new Date().toISOString(),
|
|
394
|
+
}, null, 2)),
|
|
395
|
+
fs.promises.writeFile(path.join(targetDir, 'endpoints.json'), JSON.stringify(analyzedEndpoints.map(ep => ({
|
|
396
|
+
pattern: ep.pattern, method: ep.method, url: ep.url, status: ep.status,
|
|
397
|
+
contentType: ep.contentType, score: ep.score, queryParams: ep.queryParams,
|
|
398
|
+
itemPath: ep.responseAnalysis?.itemPath ?? null, itemCount: ep.responseAnalysis?.itemCount ?? 0,
|
|
399
|
+
detectedFields: ep.responseAnalysis?.detectedFields ?? {}, authIndicators: ep.authIndicators,
|
|
400
|
+
})), null, 2)),
|
|
401
|
+
fs.promises.writeFile(path.join(targetDir, 'capabilities.json'), JSON.stringify(result.capabilities, null, 2)),
|
|
402
|
+
fs.promises.writeFile(path.join(targetDir, 'auth.json'), JSON.stringify({
|
|
403
|
+
top_strategy: result.top_strategy, indicators: result.auth_indicators, framework: result.framework,
|
|
404
|
+
}, null, 2)),
|
|
405
|
+
];
|
|
406
|
+
if (stores.length > 0) {
|
|
407
|
+
tasks.push(fs.promises.writeFile(path.join(targetDir, 'stores.json'), JSON.stringify(stores, null, 2)));
|
|
408
|
+
}
|
|
409
|
+
await Promise.all(tasks);
|
|
410
|
+
}
|
|
411
|
+
|
|
226
412
|
// ── Main explore function ──────────────────────────────────────────────────
|
|
227
413
|
|
|
228
414
|
export async function exploreUrl(
|
|
229
415
|
url: string,
|
|
230
416
|
opts: {
|
|
231
|
-
BrowserFactory: new () =>
|
|
417
|
+
BrowserFactory: new () => IBrowserFactory;
|
|
232
418
|
site?: string; goal?: string; authenticated?: boolean;
|
|
233
419
|
outDir?: string; waitSeconds?: number; query?: string;
|
|
234
420
|
clickLabels?: string[]; auto?: boolean; workspace?: string;
|
|
235
421
|
},
|
|
236
|
-
): Promise<
|
|
422
|
+
): Promise<ExploreResult> {
|
|
237
423
|
const waitSeconds = opts.waitSeconds ?? 3.0;
|
|
238
424
|
const exploreTimeout = Math.max(DEFAULT_BROWSER_EXPLORE_TIMEOUT, 45.0 + waitSeconds * 8.0);
|
|
239
425
|
|
|
@@ -306,7 +492,10 @@ export async function exploreUrl(
|
|
|
306
492
|
|
|
307
493
|
// Step 6: Detect framework
|
|
308
494
|
let framework: Record<string, boolean> = {};
|
|
309
|
-
try {
|
|
495
|
+
try {
|
|
496
|
+
const fw = await page.evaluate(FRAMEWORK_DETECT_JS);
|
|
497
|
+
if (isBooleanRecord(fw)) framework = fw;
|
|
498
|
+
} catch {}
|
|
310
499
|
|
|
311
500
|
// Step 6.5: Discover stores (Pinia / Vuex)
|
|
312
501
|
let stores: DiscoveredStore[] = [];
|
|
@@ -317,131 +506,31 @@ export async function exploreUrl(
|
|
|
317
506
|
} catch {}
|
|
318
507
|
}
|
|
319
508
|
|
|
320
|
-
// Step 7: Analyze endpoints
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (ct.includes('image/') || ct.includes('font/') || ct.includes('css') || ct.includes('javascript') || ct.includes('wasm')) continue;
|
|
326
|
-
if (entry.status && entry.status >= 400) continue;
|
|
327
|
-
|
|
328
|
-
const pattern = urlToPattern(entry.url);
|
|
329
|
-
const key = `${entry.method}:${pattern}`;
|
|
330
|
-
if (seen.has(key)) continue;
|
|
331
|
-
|
|
332
|
-
const qp: string[] = [];
|
|
333
|
-
try { new URL(entry.url).searchParams.forEach((_v, k) => { if (!VOLATILE_PARAMS.has(k)) qp.push(k); }); } catch {}
|
|
334
|
-
|
|
335
|
-
const ep: AnalyzedEndpoint = {
|
|
336
|
-
pattern, method: entry.method, url: entry.url, status: entry.status, contentType: ct,
|
|
337
|
-
queryParams: qp, hasSearchParam: qp.some(p => SEARCH_PARAMS.has(p)),
|
|
338
|
-
hasPaginationParam: qp.some(p => PAGINATION_PARAMS.has(p)),
|
|
339
|
-
hasLimitParam: qp.some(p => LIMIT_PARAMS.has(p)),
|
|
340
|
-
authIndicators: detectAuthIndicators(entry.requestHeaders),
|
|
341
|
-
responseAnalysis: entry.responseBody ? analyzeResponseBody(entry.responseBody) : null,
|
|
342
|
-
score: 0,
|
|
343
|
-
};
|
|
344
|
-
ep.score = scoreEndpoint(ep);
|
|
345
|
-
seen.set(key, ep);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const analyzedEndpoints = [...seen.values()].filter(ep => ep.score >= 5).sort((a, b) => b.score - a.score);
|
|
349
|
-
|
|
350
|
-
// Step 8: Infer capabilities
|
|
351
|
-
const capabilities: InferredCapability[] = [];
|
|
352
|
-
const usedNames = new Set<string>();
|
|
353
|
-
for (const ep of analyzedEndpoints.slice(0, 8)) {
|
|
354
|
-
let capName = inferCapabilityName(ep.url, opts.goal);
|
|
355
|
-
if (usedNames.has(capName)) {
|
|
356
|
-
const suffix = ep.pattern.split('/').filter(s => s && !s.startsWith('{') && !s.includes('.')).pop();
|
|
357
|
-
capName = suffix ? `${capName}_${suffix}` : `${capName}_${usedNames.size}`;
|
|
358
|
-
}
|
|
359
|
-
usedNames.add(capName);
|
|
360
|
-
|
|
361
|
-
const cols: string[] = [];
|
|
362
|
-
if (ep.responseAnalysis) {
|
|
363
|
-
for (const role of ['title', 'url', 'author', 'score', 'time']) {
|
|
364
|
-
if (ep.responseAnalysis.detectedFields[role]) cols.push(role);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const args: InferredCapability['recommendedArgs'] = [];
|
|
369
|
-
if (ep.hasSearchParam) args.push({ name: 'keyword', type: 'str', required: true });
|
|
370
|
-
args.push({ name: 'limit', type: 'int', required: false, default: 20 });
|
|
371
|
-
if (ep.hasPaginationParam) args.push({ name: 'page', type: 'int', required: false, default: 1 });
|
|
372
|
-
|
|
373
|
-
// Link store actions to capabilities when store-action strategy is recommended
|
|
374
|
-
const epStrategy = inferStrategy(ep.authIndicators);
|
|
375
|
-
let storeHint: { store: string; action: string } | undefined;
|
|
376
|
-
if ((epStrategy === 'intercept' || ep.authIndicators.includes('signature')) && stores.length > 0) {
|
|
377
|
-
// Try to find a store/action that matches this endpoint's purpose
|
|
378
|
-
for (const s of stores) {
|
|
379
|
-
const matchingAction = s.actions.find(a =>
|
|
380
|
-
capName.split('_').some(part => a.toLowerCase().includes(part)) ||
|
|
381
|
-
a.toLowerCase().includes('fetch') || a.toLowerCase().includes('get')
|
|
382
|
-
);
|
|
383
|
-
if (matchingAction) {
|
|
384
|
-
storeHint = { store: s.id, action: matchingAction };
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
capabilities.push({
|
|
391
|
-
name: capName, description: `${opts.site ?? detectSiteName(url)} ${capName}`,
|
|
392
|
-
strategy: storeHint ? 'store-action' : epStrategy,
|
|
393
|
-
confidence: Math.min(ep.score / 20, 1.0), endpoint: ep.pattern,
|
|
394
|
-
itemPath: ep.responseAnalysis?.itemPath ?? null,
|
|
395
|
-
recommendedColumns: cols.length ? cols : ['title', 'url'],
|
|
396
|
-
recommendedArgs: args,
|
|
397
|
-
...(storeHint ? { storeHint } : {}),
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// Step 9: Determine overall auth strategy
|
|
402
|
-
const allAuth = new Set(analyzedEndpoints.flatMap(ep => ep.authIndicators));
|
|
403
|
-
const topStrategy = allAuth.has('signature') ? 'intercept' : allAuth.has('bearer') || allAuth.has('csrf') ? 'header' : allAuth.size === 0 ? 'public' : 'cookie';
|
|
509
|
+
// Step 7+8: Analyze endpoints and infer capabilities
|
|
510
|
+
const { analyzed: analyzedEndpoints, totalCount } = analyzeEndpoints(networkEntries);
|
|
511
|
+
const { capabilities, topStrategy, authIndicators } = inferCapabilitiesFromEndpoints(
|
|
512
|
+
analyzedEndpoints, stores, { site: opts.site, goal: opts.goal, url },
|
|
513
|
+
);
|
|
404
514
|
|
|
515
|
+
// Step 9: Assemble result and write artifacts
|
|
405
516
|
const siteName = opts.site ?? detectSiteName(metadata.url || url);
|
|
406
517
|
const targetDir = opts.outDir ?? path.join('.opencli', 'explore', siteName);
|
|
407
|
-
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
408
518
|
|
|
409
519
|
const result = {
|
|
410
520
|
site: siteName, target_url: url, final_url: metadata.url, title: metadata.title,
|
|
411
521
|
framework, stores, top_strategy: topStrategy,
|
|
412
|
-
endpoint_count:
|
|
522
|
+
endpoint_count: totalCount,
|
|
413
523
|
api_endpoint_count: analyzedEndpoints.length,
|
|
414
|
-
capabilities, auth_indicators:
|
|
524
|
+
capabilities, auth_indicators: authIndicators,
|
|
415
525
|
};
|
|
416
526
|
|
|
417
|
-
|
|
418
|
-
const writeTasks = [];
|
|
419
|
-
writeTasks.push(fs.promises.writeFile(path.join(targetDir, 'manifest.json'), JSON.stringify({
|
|
420
|
-
site: siteName, target_url: url, final_url: metadata.url, title: metadata.title,
|
|
421
|
-
framework, stores: stores.map(s => ({ type: s.type, id: s.id, actions: s.actions })),
|
|
422
|
-
top_strategy: topStrategy, explored_at: new Date().toISOString(),
|
|
423
|
-
}, null, 2)));
|
|
424
|
-
writeTasks.push(fs.promises.writeFile(path.join(targetDir, 'endpoints.json'), JSON.stringify(analyzedEndpoints.map(ep => ({
|
|
425
|
-
pattern: ep.pattern, method: ep.method, url: ep.url, status: ep.status,
|
|
426
|
-
contentType: ep.contentType, score: ep.score, queryParams: ep.queryParams,
|
|
427
|
-
itemPath: ep.responseAnalysis?.itemPath ?? null, itemCount: ep.responseAnalysis?.itemCount ?? 0,
|
|
428
|
-
detectedFields: ep.responseAnalysis?.detectedFields ?? {}, authIndicators: ep.authIndicators,
|
|
429
|
-
})), null, 2)));
|
|
430
|
-
writeTasks.push(fs.promises.writeFile(path.join(targetDir, 'capabilities.json'), JSON.stringify(capabilities, null, 2)));
|
|
431
|
-
writeTasks.push(fs.promises.writeFile(path.join(targetDir, 'auth.json'), JSON.stringify({
|
|
432
|
-
top_strategy: topStrategy, indicators: [...allAuth], framework,
|
|
433
|
-
}, null, 2)));
|
|
434
|
-
if (stores.length > 0) {
|
|
435
|
-
writeTasks.push(fs.promises.writeFile(path.join(targetDir, 'stores.json'), JSON.stringify(stores, null, 2)));
|
|
436
|
-
}
|
|
437
|
-
await Promise.all(writeTasks);
|
|
438
|
-
|
|
527
|
+
await writeExploreArtifacts(targetDir, result, analyzedEndpoints, stores);
|
|
439
528
|
return { ...result, out_dir: targetDir };
|
|
440
529
|
})(), { timeout: exploreTimeout, label: `Explore ${url}` });
|
|
441
530
|
}, { workspace: opts.workspace });
|
|
442
531
|
}
|
|
443
532
|
|
|
444
|
-
export function renderExploreSummary(result:
|
|
533
|
+
export function renderExploreSummary(result: ExploreResult): string {
|
|
445
534
|
const lines = [
|
|
446
535
|
'opencli probe: OK', `Site: ${result.site}`, `URL: ${result.target_url}`,
|
|
447
536
|
`Title: ${result.title || '(none)'}`, `Strategy: ${result.top_strategy}`,
|
|
@@ -466,10 +555,15 @@ export function renderExploreSummary(result: Record<string, any>): string {
|
|
|
466
555
|
return lines.join('\n');
|
|
467
556
|
}
|
|
468
557
|
|
|
469
|
-
async function readPageMetadata(page:
|
|
558
|
+
async function readPageMetadata(page: IPage): Promise<{ url: string; title: string }> {
|
|
470
559
|
try {
|
|
471
560
|
const result = await page.evaluate(`() => ({ url: window.location.href, title: document.title || '' })`);
|
|
472
|
-
if (result && typeof result === 'object'
|
|
561
|
+
if (result && typeof result === 'object' && !Array.isArray(result)) {
|
|
562
|
+
return {
|
|
563
|
+
url: String((result as Record<string, unknown>).url ?? ''),
|
|
564
|
+
title: String((result as Record<string, unknown>).title ?? ''),
|
|
565
|
+
};
|
|
566
|
+
}
|
|
473
567
|
} catch {}
|
|
474
568
|
return { url: '', title: '' };
|
|
475
569
|
}
|
package/src/external-clis.yaml
CHANGED
|
@@ -37,3 +37,12 @@
|
|
|
37
37
|
tags: [docker, containers, devops]
|
|
38
38
|
install:
|
|
39
39
|
mac: "brew install --cask docker"
|
|
40
|
+
|
|
41
|
+
- name: gws
|
|
42
|
+
binary: gws
|
|
43
|
+
description: "Google Workspace CLI — Docs, Sheets, Drive, Gmail, Calendar"
|
|
44
|
+
homepage: "https://github.com/nicholasgasior/gws"
|
|
45
|
+
tags: [google, docs, sheets, drive, workspace]
|
|
46
|
+
install:
|
|
47
|
+
mac: "brew install gws"
|
|
48
|
+
default: "npm install -g @nicholasgasior/gws"
|
package/src/external.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import * as os from 'node:os';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { spawnSync, execSync } from 'node:child_process';
|
|
5
|
+
import { spawnSync, execSync, execFileSync } from 'node:child_process';
|
|
6
6
|
import yaml from 'js-yaml';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import { log } from './logger.js';
|
|
@@ -65,8 +65,7 @@ export function loadExternalClis(): ExternalCliConfig[] {
|
|
|
65
65
|
export function isBinaryInstalled(binary: string): boolean {
|
|
66
66
|
try {
|
|
67
67
|
const isWindows = os.platform() === 'win32';
|
|
68
|
-
|
|
69
|
-
execSync(`${cmd} ${binary}`, { stdio: 'ignore' });
|
|
68
|
+
execFileSync(isWindows ? 'where' : 'which', [binary], { stdio: 'ignore' });
|
|
70
69
|
return true;
|
|
71
70
|
} catch {
|
|
72
71
|
return false;
|
|
@@ -109,8 +108,8 @@ export function installExternalCli(cli: ExternalCliConfig): boolean {
|
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
|
|
112
|
-
export
|
|
113
|
-
const configs = loadExternalClis();
|
|
111
|
+
export function executeExternalCli(name: string, args: string[], preloaded?: ExternalCliConfig[]): void {
|
|
112
|
+
const configs = preloaded ?? loadExternalClis();
|
|
114
113
|
const cli = configs.find((c) => c.name === name);
|
|
115
114
|
if (!cli) {
|
|
116
115
|
throw new Error(`External CLI '${name}' not found in registry.`);
|
|
@@ -126,8 +125,7 @@ export async function executeExternalCli(name: string, args: string[]): Promise<
|
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
// 3. Passthrough execution
|
|
130
|
-
// We use spawnSync to properly inherit stdio and block until completion
|
|
128
|
+
// 3. Passthrough execution with stdio inherited
|
|
131
129
|
const result = spawnSync(cli.binary, args, { stdio: 'inherit' });
|
|
132
130
|
if (result.error) {
|
|
133
131
|
console.error(chalk.red(`Failed to execute '${cli.binary}': ${result.error.message}`));
|
|
@@ -140,7 +138,13 @@ export async function executeExternalCli(name: string, args: string[]): Promise<
|
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
140
|
|
|
143
|
-
export
|
|
141
|
+
export interface RegisterOptions {
|
|
142
|
+
binary?: string;
|
|
143
|
+
install?: string;
|
|
144
|
+
description?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function registerExternalCli(name: string, opts?: RegisterOptions): void {
|
|
144
148
|
const userPath = getUserRegistryPath();
|
|
145
149
|
const configDir = path.dirname(userPath);
|
|
146
150
|
|
|
@@ -162,13 +166,12 @@ export function registerExternalCli(name: string, binary?: string, install?: str
|
|
|
162
166
|
|
|
163
167
|
const newItem: ExternalCliConfig = {
|
|
164
168
|
name,
|
|
165
|
-
binary: binary || name,
|
|
169
|
+
binary: opts?.binary || name,
|
|
166
170
|
};
|
|
167
|
-
if (description) newItem.description = description;
|
|
168
|
-
if (install) newItem.install = { default: install };
|
|
171
|
+
if (opts?.description) newItem.description = opts.description;
|
|
172
|
+
if (opts?.install) newItem.install = { default: opts.install };
|
|
169
173
|
|
|
170
174
|
if (existingIndex >= 0) {
|
|
171
|
-
// Merge
|
|
172
175
|
items[existingIndex] = { ...items[existingIndex], ...newItem };
|
|
173
176
|
console.log(chalk.green(`Updated '${name}' in user registry.`));
|
|
174
177
|
} else {
|
package/src/generate.ts
CHANGED
|
@@ -9,10 +9,59 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { exploreUrl } from './explore.js';
|
|
12
|
-
import {
|
|
12
|
+
import type { IBrowserFactory } from './runtime.js';
|
|
13
|
+
import { synthesizeFromExplore, type SynthesizeCandidateSummary, type SynthesizeResult } from './synthesize.js';
|
|
13
14
|
|
|
14
15
|
// TODO: implement real CLI registration (copy candidate YAML to user clis dir)
|
|
15
|
-
|
|
16
|
+
interface RegisterCandidatesOptions {
|
|
17
|
+
target: string;
|
|
18
|
+
builtinClis?: string;
|
|
19
|
+
userClis?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface RegisterCandidatesResult {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
count: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface GenerateCliOptions {
|
|
29
|
+
url: string;
|
|
30
|
+
BrowserFactory: new () => IBrowserFactory;
|
|
31
|
+
builtinClis?: string;
|
|
32
|
+
userClis?: string;
|
|
33
|
+
goal?: string | null;
|
|
34
|
+
site?: string;
|
|
35
|
+
waitSeconds?: number;
|
|
36
|
+
top?: number;
|
|
37
|
+
register?: boolean;
|
|
38
|
+
workspace?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface GenerateCliResult {
|
|
42
|
+
ok: boolean;
|
|
43
|
+
goal?: string | null;
|
|
44
|
+
normalized_goal?: string | null;
|
|
45
|
+
site: string;
|
|
46
|
+
selected_candidate: SynthesizeCandidateSummary | null;
|
|
47
|
+
selected_command: string;
|
|
48
|
+
explore: {
|
|
49
|
+
endpoint_count: number;
|
|
50
|
+
api_endpoint_count: number;
|
|
51
|
+
capability_count: number;
|
|
52
|
+
top_strategy: string;
|
|
53
|
+
framework: Record<string, boolean>;
|
|
54
|
+
};
|
|
55
|
+
synthesize: {
|
|
56
|
+
candidate_count: number;
|
|
57
|
+
candidates: Array<Pick<SynthesizeCandidateSummary, 'name' | 'strategy' | 'confidence'>>;
|
|
58
|
+
};
|
|
59
|
+
register: RegisterCandidatesResult | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function registerCandidates(_opts: RegisterCandidatesOptions): RegisterCandidatesResult {
|
|
63
|
+
return { ok: true, count: 0 };
|
|
64
|
+
}
|
|
16
65
|
|
|
17
66
|
const CAPABILITY_ALIASES: Record<string, string[]> = {
|
|
18
67
|
search: ['search', '搜索', '查找', 'query', 'keyword'],
|
|
@@ -41,7 +90,7 @@ function normalizeGoal(goal?: string | null): string | null {
|
|
|
41
90
|
/**
|
|
42
91
|
* Select the best candidate matching the user's goal.
|
|
43
92
|
*/
|
|
44
|
-
function selectCandidate(candidates:
|
|
93
|
+
function selectCandidate(candidates: SynthesizeResult['candidates'], goal?: string | null): SynthesizeCandidateSummary | null {
|
|
45
94
|
if (!candidates.length) return null;
|
|
46
95
|
if (!goal) return candidates[0]; // highest confidence first
|
|
47
96
|
|
|
@@ -58,12 +107,12 @@ function selectCandidate(candidates: any[], goal?: string | null): any {
|
|
|
58
107
|
return partial ?? candidates[0];
|
|
59
108
|
}
|
|
60
109
|
|
|
61
|
-
export async function generateCliFromUrl(opts:
|
|
110
|
+
export async function generateCliFromUrl(opts: GenerateCliOptions): Promise<GenerateCliResult> {
|
|
62
111
|
// Step 1: Deep Explore
|
|
63
112
|
const exploreResult = await exploreUrl(opts.url, {
|
|
64
113
|
BrowserFactory: opts.BrowserFactory,
|
|
65
114
|
site: opts.site,
|
|
66
|
-
goal: normalizeGoal(opts.goal) ?? opts.goal,
|
|
115
|
+
goal: normalizeGoal(opts.goal) ?? opts.goal ?? undefined,
|
|
67
116
|
waitSeconds: opts.waitSeconds ?? 3,
|
|
68
117
|
workspace: opts.workspace,
|
|
69
118
|
});
|
|
@@ -75,10 +124,10 @@ export async function generateCliFromUrl(opts: any): Promise<any> {
|
|
|
75
124
|
|
|
76
125
|
// Step 3: Select best candidate for goal
|
|
77
126
|
const selected = selectCandidate(synthesizeResult.candidates ?? [], opts.goal);
|
|
78
|
-
const selectedSite =
|
|
127
|
+
const selectedSite = synthesizeResult.site ?? exploreResult.site;
|
|
79
128
|
|
|
80
129
|
// Step 4: Register (if requested)
|
|
81
|
-
let registerResult:
|
|
130
|
+
let registerResult: RegisterCandidatesResult | null = null;
|
|
82
131
|
if (opts.register !== false && synthesizeResult.candidate_count > 0) {
|
|
83
132
|
try {
|
|
84
133
|
registerResult = registerCandidates({
|
|
@@ -108,7 +157,7 @@ export async function generateCliFromUrl(opts: any): Promise<any> {
|
|
|
108
157
|
},
|
|
109
158
|
synthesize: {
|
|
110
159
|
candidate_count: synthesizeResult.candidate_count,
|
|
111
|
-
candidates: (synthesizeResult.candidates ?? []).map((c
|
|
160
|
+
candidates: (synthesizeResult.candidates ?? []).map((c) => ({
|
|
112
161
|
name: c.name,
|
|
113
162
|
strategy: c.strategy,
|
|
114
163
|
confidence: c.confidence,
|
|
@@ -118,7 +167,7 @@ export async function generateCliFromUrl(opts: any): Promise<any> {
|
|
|
118
167
|
};
|
|
119
168
|
}
|
|
120
169
|
|
|
121
|
-
export function renderGenerateSummary(r:
|
|
170
|
+
export function renderGenerateSummary(r: GenerateCliResult): string {
|
|
122
171
|
const lines = [
|
|
123
172
|
`opencli generate: ${r.ok ? 'OK' : 'FAIL'}`,
|
|
124
173
|
`Site: ${r.site}`,
|
package/src/main.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import * as os from 'node:os';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import { discoverClis } from './
|
|
9
|
+
import { discoverClis, discoverPlugins } from './discovery.js';
|
|
10
10
|
import { getCompletions } from './completion.js';
|
|
11
11
|
import { runCli } from './cli.js';
|
|
12
12
|
|
|
@@ -16,6 +16,7 @@ const BUILTIN_CLIS = path.resolve(__dirname, 'clis');
|
|
|
16
16
|
const USER_CLIS = path.join(os.homedir(), '.opencli', 'clis');
|
|
17
17
|
|
|
18
18
|
await discoverClis(BUILTIN_CLIS, USER_CLIS);
|
|
19
|
+
await discoverPlugins();
|
|
19
20
|
|
|
20
21
|
// ── Fast-path: handle --get-completions before commander parses ─────────
|
|
21
22
|
// Usage: opencli --get-completions --cursor <N> [word1 word2 ...]
|