@jackwener/opencli 1.5.5 → 1.5.7
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/CHANGELOG.md +26 -0
- package/README.md +31 -4
- package/README.zh-CN.md +40 -5
- package/SKILL.md +1 -1
- package/dist/browser/cdp.d.ts +1 -0
- package/dist/browser/cdp.js +30 -27
- package/dist/browser/daemon-client.d.ts +11 -1
- package/dist/browser/daemon-client.js +3 -0
- package/dist/browser/dom-helpers.js +1 -0
- package/dist/browser/dom-helpers.test.js +14 -1
- package/dist/browser/mcp.js +18 -13
- package/dist/browser/page.d.ts +6 -0
- package/dist/browser/page.js +37 -2
- package/dist/browser/page.test.d.ts +1 -0
- package/dist/browser/page.test.js +44 -0
- package/dist/browser/stealth.js +198 -0
- package/dist/browser/stealth.test.d.ts +1 -0
- package/dist/browser/stealth.test.js +134 -0
- package/dist/browser.test.js +1 -1
- package/dist/build-manifest.d.ts +1 -0
- package/dist/build-manifest.js +5 -1
- package/dist/build-manifest.test.js +2 -0
- package/dist/cli-manifest.json +1821 -252
- package/dist/cli.js +20 -3
- package/dist/clis/antigravity/serve.d.ts +1 -1
- package/dist/clis/antigravity/serve.js +5 -8
- package/dist/clis/band/bands.d.ts +1 -0
- package/dist/clis/band/bands.js +72 -0
- package/dist/clis/band/mentions.d.ts +1 -0
- package/dist/clis/band/mentions.js +127 -0
- package/dist/clis/band/post.d.ts +1 -0
- package/dist/clis/band/post.js +175 -0
- package/dist/clis/band/posts.d.ts +1 -0
- package/dist/clis/band/posts.js +94 -0
- package/dist/clis/bilibili/subtitle.js +4 -0
- package/dist/clis/bilibili/subtitle.test.d.ts +1 -0
- package/dist/clis/bilibili/subtitle.test.js +48 -0
- package/dist/clis/chatwise/ask.js +0 -2
- package/dist/clis/chatwise/export.js +0 -2
- package/dist/clis/chatwise/history.js +0 -2
- package/dist/clis/chatwise/model.js +0 -2
- package/dist/clis/chatwise/new.js +1 -2
- package/dist/clis/chatwise/read.js +0 -2
- package/dist/clis/chatwise/screenshot.js +1 -2
- package/dist/clis/chatwise/send.js +0 -2
- package/dist/clis/chatwise/status.js +1 -2
- package/dist/clis/ctrip/search.d.ts +13 -0
- package/dist/clis/ctrip/search.js +73 -48
- package/dist/clis/ctrip/search.test.d.ts +1 -0
- package/dist/clis/ctrip/search.test.js +64 -0
- package/dist/clis/doubao/detail.d.ts +1 -0
- package/dist/clis/doubao/detail.js +33 -0
- package/dist/clis/doubao/detail.test.d.ts +1 -0
- package/dist/clis/doubao/detail.test.js +42 -0
- package/dist/clis/doubao/history.d.ts +1 -0
- package/dist/clis/doubao/history.js +28 -0
- package/dist/clis/doubao/history.test.d.ts +1 -0
- package/dist/clis/doubao/history.test.js +37 -0
- package/dist/clis/doubao/meeting-summary.d.ts +1 -0
- package/dist/clis/doubao/meeting-summary.js +39 -0
- package/dist/clis/doubao/meeting-transcript.d.ts +1 -0
- package/dist/clis/doubao/meeting-transcript.js +36 -0
- package/dist/clis/doubao/utils.d.ts +27 -0
- package/dist/clis/doubao/utils.js +317 -0
- package/dist/clis/doubao/utils.test.d.ts +1 -0
- package/dist/clis/doubao/utils.test.js +24 -0
- package/dist/clis/douyin/_shared/public-api.d.ts +33 -0
- package/dist/clis/douyin/_shared/public-api.js +29 -0
- package/dist/clis/douyin/_shared/sts2.js +8 -2
- package/dist/clis/douyin/_shared/sts2.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/sts2.test.js +27 -0
- package/dist/clis/douyin/activities.js +4 -2
- package/dist/clis/douyin/activities.test.js +34 -1
- package/dist/clis/douyin/collections.js +1 -1
- package/dist/clis/douyin/collections.test.js +24 -2
- package/dist/clis/douyin/draft.d.ts +8 -11
- package/dist/clis/douyin/draft.js +302 -185
- package/dist/clis/douyin/draft.test.d.ts +1 -1
- package/dist/clis/douyin/draft.test.js +357 -2
- package/dist/clis/douyin/hashtag.js +9 -2
- package/dist/clis/douyin/hashtag.test.js +35 -2
- package/dist/clis/douyin/profile.js +1 -1
- package/dist/clis/douyin/profile.test.js +36 -1
- package/dist/clis/douyin/user-videos.d.ts +5 -0
- package/dist/clis/douyin/user-videos.js +74 -0
- package/dist/clis/douyin/user-videos.test.d.ts +1 -0
- package/dist/clis/douyin/user-videos.test.js +108 -0
- package/dist/clis/douyin/videos.js +22 -5
- package/dist/clis/douyin/videos.test.js +45 -2
- package/dist/clis/facebook/search.test.d.ts +5 -0
- package/dist/clis/facebook/search.test.js +60 -0
- package/dist/clis/facebook/search.yaml +4 -3
- package/dist/clis/instagram/download.d.ts +16 -0
- package/dist/clis/instagram/download.js +225 -0
- package/dist/clis/instagram/download.test.d.ts +1 -0
- package/dist/clis/instagram/download.test.js +118 -0
- package/dist/clis/notebooklm/bind-current.d.ts +1 -0
- package/dist/clis/notebooklm/bind-current.js +29 -0
- package/dist/clis/notebooklm/bind-current.test.d.ts +1 -0
- package/dist/clis/notebooklm/bind-current.test.js +35 -0
- package/dist/clis/notebooklm/binding.test.d.ts +1 -0
- package/dist/clis/notebooklm/binding.test.js +44 -0
- package/dist/clis/notebooklm/compat.test.d.ts +3 -0
- package/dist/clis/notebooklm/compat.test.js +16 -0
- package/dist/clis/notebooklm/current.d.ts +1 -0
- package/dist/clis/notebooklm/current.js +28 -0
- package/dist/clis/notebooklm/get.d.ts +1 -0
- package/dist/clis/notebooklm/get.js +37 -0
- package/dist/clis/notebooklm/history.d.ts +1 -0
- package/dist/clis/notebooklm/history.js +25 -0
- package/dist/clis/notebooklm/history.test.d.ts +1 -0
- package/dist/clis/notebooklm/history.test.js +58 -0
- package/dist/clis/notebooklm/list.d.ts +1 -0
- package/dist/clis/notebooklm/list.js +35 -0
- package/dist/clis/notebooklm/note-list.d.ts +1 -0
- package/dist/clis/notebooklm/note-list.js +28 -0
- package/dist/clis/notebooklm/note-list.test.d.ts +1 -0
- package/dist/clis/notebooklm/note-list.test.js +56 -0
- package/dist/clis/notebooklm/notes-get.d.ts +1 -0
- package/dist/clis/notebooklm/notes-get.js +47 -0
- package/dist/clis/notebooklm/notes-get.test.d.ts +1 -0
- package/dist/clis/notebooklm/notes-get.test.js +72 -0
- package/dist/clis/notebooklm/rpc.d.ts +36 -0
- package/dist/clis/notebooklm/rpc.js +189 -0
- package/dist/clis/notebooklm/rpc.test.d.ts +1 -0
- package/dist/clis/notebooklm/rpc.test.js +105 -0
- package/dist/clis/notebooklm/shared.d.ts +87 -0
- package/dist/clis/notebooklm/shared.js +3 -0
- package/dist/clis/notebooklm/source-fulltext.d.ts +1 -0
- package/dist/clis/notebooklm/source-fulltext.js +44 -0
- package/dist/clis/notebooklm/source-fulltext.test.d.ts +1 -0
- package/dist/clis/notebooklm/source-fulltext.test.js +106 -0
- package/dist/clis/notebooklm/source-get.d.ts +1 -0
- package/dist/clis/notebooklm/source-get.js +40 -0
- package/dist/clis/notebooklm/source-get.test.d.ts +1 -0
- package/dist/clis/notebooklm/source-get.test.js +84 -0
- package/dist/clis/notebooklm/source-guide.d.ts +1 -0
- package/dist/clis/notebooklm/source-guide.js +44 -0
- package/dist/clis/notebooklm/source-guide.test.d.ts +1 -0
- package/dist/clis/notebooklm/source-guide.test.js +104 -0
- package/dist/clis/notebooklm/source-list.d.ts +1 -0
- package/dist/clis/notebooklm/source-list.js +30 -0
- package/dist/clis/notebooklm/status.d.ts +1 -0
- package/dist/clis/notebooklm/status.js +31 -0
- package/dist/clis/notebooklm/summary.d.ts +1 -0
- package/dist/clis/notebooklm/summary.js +30 -0
- package/dist/clis/notebooklm/summary.test.d.ts +1 -0
- package/dist/clis/notebooklm/summary.test.js +78 -0
- package/dist/clis/notebooklm/utils.d.ts +37 -0
- package/dist/clis/notebooklm/utils.js +739 -0
- package/dist/clis/notebooklm/utils.test.d.ts +1 -0
- package/dist/clis/notebooklm/utils.test.js +390 -0
- package/dist/clis/ones/common.d.ts +32 -0
- package/dist/clis/ones/common.js +144 -0
- package/dist/clis/ones/enrich-tasks.d.ts +5 -0
- package/dist/clis/ones/enrich-tasks.js +37 -0
- package/dist/clis/ones/login.d.ts +1 -0
- package/dist/clis/ones/login.js +80 -0
- package/dist/clis/ones/logout.d.ts +1 -0
- package/dist/clis/ones/logout.js +17 -0
- package/dist/clis/ones/me.d.ts +1 -0
- package/dist/clis/ones/me.js +30 -0
- package/dist/clis/ones/my-tasks.d.ts +1 -0
- package/dist/clis/ones/my-tasks.js +120 -0
- package/dist/clis/ones/resolve-labels.d.ts +10 -0
- package/dist/clis/ones/resolve-labels.js +64 -0
- package/dist/clis/ones/task-helpers.d.ts +29 -0
- package/dist/clis/ones/task-helpers.js +212 -0
- package/dist/clis/ones/task-helpers.test.d.ts +1 -0
- package/dist/clis/ones/task-helpers.test.js +12 -0
- package/dist/clis/ones/task.d.ts +1 -0
- package/dist/clis/ones/task.js +66 -0
- package/dist/clis/ones/tasks.d.ts +1 -0
- package/dist/clis/ones/tasks.js +79 -0
- package/dist/clis/ones/token-info.d.ts +1 -0
- package/dist/clis/ones/token-info.js +42 -0
- package/dist/clis/ones/worklog.d.ts +11 -0
- package/dist/clis/ones/worklog.js +267 -0
- package/dist/clis/ones/worklog.test.d.ts +1 -0
- package/dist/clis/ones/worklog.test.js +20 -0
- package/dist/clis/spotify/spotify.d.ts +1 -0
- package/dist/clis/spotify/spotify.js +316 -0
- package/dist/clis/spotify/utils.d.ts +21 -0
- package/dist/clis/spotify/utils.js +66 -0
- package/dist/clis/spotify/utils.test.d.ts +1 -0
- package/dist/clis/spotify/utils.test.js +67 -0
- package/dist/clis/substack/utils.d.ts +4 -0
- package/dist/clis/substack/utils.js +8 -2
- package/dist/clis/substack/utils.test.d.ts +1 -0
- package/dist/clis/substack/utils.test.js +46 -0
- package/dist/clis/tieba/commands.test.d.ts +4 -0
- package/dist/clis/tieba/commands.test.js +79 -0
- package/dist/clis/tieba/hot.d.ts +1 -0
- package/dist/clis/tieba/hot.js +48 -0
- package/dist/clis/tieba/posts.d.ts +1 -0
- package/dist/clis/tieba/posts.js +85 -0
- package/dist/clis/tieba/read.d.ts +1 -0
- package/dist/clis/tieba/read.js +140 -0
- package/dist/clis/tieba/search.d.ts +1 -0
- package/dist/clis/tieba/search.js +108 -0
- package/dist/clis/tieba/utils.d.ts +101 -0
- package/dist/clis/tieba/utils.js +240 -0
- package/dist/clis/tieba/utils.test.d.ts +1 -0
- package/dist/clis/tieba/utils.test.js +290 -0
- package/dist/clis/v2ex/hot.yaml +4 -1
- package/dist/clis/v2ex/latest.yaml +4 -1
- package/dist/clis/v2ex/topic.yaml +6 -1
- package/dist/clis/weixin/download.d.ts +9 -0
- package/dist/clis/weixin/download.js +76 -6
- package/dist/clis/weread/book.js +206 -13
- package/dist/clis/weread/commands.test.js +331 -0
- package/dist/clis/weread/private-api-regression.test.d.ts +1 -0
- package/dist/{weread-private-api-regression.test.js → clis/weread/private-api-regression.test.js} +92 -30
- package/dist/clis/weread/search-regression.test.d.ts +1 -0
- package/dist/clis/weread/search-regression.test.js +407 -0
- package/dist/clis/weread/search.js +143 -7
- package/dist/clis/weread/shelf.js +13 -95
- package/dist/clis/weread/utils.d.ts +56 -0
- package/dist/clis/weread/utils.js +234 -7
- package/dist/clis/weread/utils.test.js +71 -1
- package/dist/clis/xiaohongshu/comments.d.ts +3 -0
- package/dist/clis/xiaohongshu/comments.js +76 -17
- package/dist/clis/xiaohongshu/comments.test.js +70 -9
- package/dist/clis/xiaohongshu/download.d.ts +4 -1
- package/dist/clis/xiaohongshu/download.js +83 -22
- package/dist/clis/xiaohongshu/download.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/download.test.js +75 -0
- package/dist/clis/xiaohongshu/note-helpers.d.ts +12 -0
- package/dist/clis/xiaohongshu/note-helpers.js +23 -0
- package/dist/clis/xiaohongshu/note.d.ts +7 -0
- package/dist/clis/xiaohongshu/note.js +76 -0
- package/dist/clis/xiaohongshu/note.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/note.test.js +136 -0
- package/dist/clis/xiaohongshu/publish.d.ts +1 -1
- package/dist/clis/xiaohongshu/publish.js +78 -31
- package/dist/clis/xiaohongshu/publish.test.js +66 -1
- package/dist/clis/xiaohongshu/search.js +9 -0
- package/dist/clis/xiaohongshu/search.test.js +10 -4
- package/dist/clis/xiaohongshu/user-helpers.d.ts +1 -0
- package/dist/clis/xiaohongshu/user-helpers.js +2 -0
- package/dist/clis/xiaohongshu/user-helpers.test.js +18 -0
- package/dist/clis/xueqiu/comments.d.ts +118 -0
- package/dist/clis/xueqiu/comments.js +354 -0
- package/dist/clis/xueqiu/comments.test.d.ts +1 -0
- package/dist/clis/xueqiu/comments.test.js +696 -0
- package/dist/clis/youtube/search.js +57 -17
- package/dist/clis/youtube/transcript.js +2 -4
- package/dist/clis/youtube/utils.d.ts +9 -0
- package/dist/clis/youtube/utils.js +67 -3
- package/dist/clis/youtube/utils.test.d.ts +1 -0
- package/dist/clis/youtube/utils.test.js +37 -0
- package/dist/clis/youtube/video.js +16 -15
- package/dist/clis/zhihu/question.js +19 -17
- package/dist/clis/zhihu/question.test.d.ts +1 -0
- package/dist/clis/zhihu/question.test.js +54 -0
- package/dist/clis/zsxq/dynamics.d.ts +1 -0
- package/dist/clis/zsxq/dynamics.js +47 -0
- package/dist/clis/zsxq/groups.d.ts +1 -0
- package/dist/clis/zsxq/groups.js +32 -0
- package/dist/clis/zsxq/search.d.ts +1 -0
- package/dist/clis/zsxq/search.js +43 -0
- package/dist/clis/zsxq/search.test.d.ts +1 -0
- package/dist/clis/zsxq/search.test.js +24 -0
- package/dist/clis/zsxq/topic.d.ts +1 -0
- package/dist/clis/zsxq/topic.js +47 -0
- package/dist/clis/zsxq/topic.test.d.ts +1 -0
- package/dist/clis/zsxq/topic.test.js +29 -0
- package/dist/clis/zsxq/topics.d.ts +1 -0
- package/dist/clis/zsxq/topics.js +25 -0
- package/dist/clis/zsxq/topics.test.d.ts +1 -0
- package/dist/clis/zsxq/topics.test.js +24 -0
- package/dist/clis/zsxq/utils.d.ts +97 -0
- package/dist/clis/zsxq/utils.js +230 -0
- package/dist/commanderAdapter.js +10 -1
- package/dist/commanderAdapter.test.js +64 -0
- package/dist/commands/daemon.d.ts +9 -0
- package/dist/commands/daemon.js +124 -0
- package/dist/commands/daemon.test.d.ts +1 -0
- package/dist/commands/daemon.test.js +185 -0
- package/dist/completion.js +3 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/daemon.d.ts +1 -1
- package/dist/daemon.js +25 -14
- package/dist/daemon.test.d.ts +1 -0
- package/dist/daemon.test.js +65 -0
- package/dist/discovery.d.ts +9 -0
- package/dist/discovery.js +47 -2
- package/dist/electron-apps.d.ts +29 -0
- package/dist/electron-apps.js +65 -0
- package/dist/electron-apps.test.d.ts +1 -0
- package/dist/electron-apps.test.js +43 -0
- package/dist/engine.test.js +41 -9
- package/dist/execution.js +20 -16
- package/dist/external-clis.yaml +17 -0
- package/dist/idle-manager.d.ts +19 -0
- package/dist/idle-manager.js +54 -0
- package/dist/launcher.d.ts +36 -0
- package/dist/launcher.js +152 -0
- package/dist/launcher.test.d.ts +1 -0
- package/dist/launcher.test.js +57 -0
- package/dist/main.js +3 -3
- package/dist/registry.d.ts +1 -0
- package/dist/registry.js +31 -3
- package/dist/registry.test.js +13 -0
- package/dist/runtime.d.ts +5 -3
- package/dist/runtime.js +12 -5
- package/dist/serialization.d.ts +1 -0
- package/dist/serialization.js +3 -0
- package/dist/serialization.test.js +17 -1
- package/dist/tui.d.ts +7 -0
- package/dist/tui.js +52 -0
- package/dist/tui.test.d.ts +1 -0
- package/dist/tui.test.js +19 -0
- package/dist/types.d.ts +5 -0
- package/dist/weixin-download.test.js +14 -0
- package/docs/.vitepress/config.mts +4 -0
- package/docs/adapters/browser/band.md +63 -0
- package/docs/adapters/browser/notebooklm.md +69 -0
- package/docs/adapters/browser/ones.md +59 -0
- package/docs/adapters/browser/spotify.md +62 -0
- package/docs/adapters/browser/tieba.md +45 -0
- package/docs/adapters/browser/xiaohongshu.md +19 -10
- package/docs/adapters/browser/xueqiu.md +5 -0
- package/docs/adapters/browser/zsxq.md +49 -0
- package/docs/adapters/index.md +67 -63
- package/docs/adapters-doc/ones.md +32 -0
- package/docs/guide/browser-bridge.md +12 -0
- package/docs/guide/troubleshooting.md +9 -4
- package/docs/superpowers/plans/2026-03-31-daemon-lifecycle-redesign.md +857 -0
- package/docs/superpowers/specs/2026-03-31-daemon-lifecycle-redesign.md +208 -0
- package/docs/zh/guide/browser-bridge.md +12 -0
- package/extension/dist/background.js +794 -513
- package/extension/src/background.test.ts +202 -2
- package/extension/src/background.ts +189 -10
- package/extension/src/cdp.ts +54 -0
- package/extension/src/protocol.ts +11 -5
- package/package.json +1 -1
- package/scripts/postinstall.js +16 -0
- package/src/browser/cdp.ts +24 -17
- package/src/browser/daemon-client.ts +11 -1
- package/src/browser/dom-helpers.test.ts +15 -1
- package/src/browser/dom-helpers.ts +1 -0
- package/src/browser/mcp.ts +18 -13
- package/src/browser/page.test.ts +58 -0
- package/src/browser/page.ts +34 -2
- package/src/browser/stealth.test.ts +153 -0
- package/src/browser/stealth.ts +198 -0
- package/src/browser.test.ts +1 -1
- package/src/build-manifest.test.ts +2 -0
- package/src/build-manifest.ts +6 -1
- package/src/cli.ts +21 -3
- package/src/clis/antigravity/SKILL.md +3 -12
- package/src/clis/antigravity/serve.ts +5 -10
- package/src/clis/band/bands.ts +76 -0
- package/src/clis/band/mentions.ts +134 -0
- package/src/clis/band/post.ts +187 -0
- package/src/clis/band/posts.ts +106 -0
- package/src/clis/bilibili/subtitle.test.ts +60 -0
- package/src/clis/bilibili/subtitle.ts +4 -0
- package/src/clis/chatwise/ask.ts +0 -2
- package/src/clis/chatwise/export.ts +0 -2
- package/src/clis/chatwise/history.ts +0 -2
- package/src/clis/chatwise/model.ts +0 -2
- package/src/clis/chatwise/new.ts +1 -2
- package/src/clis/chatwise/read.ts +0 -2
- package/src/clis/chatwise/screenshot.ts +1 -2
- package/src/clis/chatwise/send.ts +0 -2
- package/src/clis/chatwise/status.ts +1 -2
- package/src/clis/ctrip/search.test.ts +73 -0
- package/src/clis/ctrip/search.ts +97 -47
- package/src/clis/doubao/detail.test.ts +53 -0
- package/src/clis/doubao/detail.ts +41 -0
- package/src/clis/doubao/history.test.ts +45 -0
- package/src/clis/doubao/history.ts +32 -0
- package/src/clis/doubao/meeting-summary.ts +53 -0
- package/src/clis/doubao/meeting-transcript.ts +48 -0
- package/src/clis/doubao/utils.test.ts +45 -0
- package/src/clis/doubao/utils.ts +371 -0
- package/src/clis/douyin/_shared/public-api.ts +84 -0
- package/src/clis/douyin/_shared/sts2.test.ts +31 -0
- package/src/clis/douyin/_shared/sts2.ts +11 -3
- package/src/clis/douyin/activities.test.ts +41 -1
- package/src/clis/douyin/activities.ts +12 -3
- package/src/clis/douyin/collections.test.ts +35 -2
- package/src/clis/douyin/collections.ts +1 -1
- package/src/clis/douyin/draft.test.ts +444 -2
- package/src/clis/douyin/draft.ts +382 -218
- package/src/clis/douyin/hashtag.test.ts +42 -2
- package/src/clis/douyin/hashtag.ts +11 -3
- package/src/clis/douyin/profile.test.ts +43 -1
- package/src/clis/douyin/profile.ts +9 -2
- package/src/clis/douyin/user-videos.test.ts +122 -0
- package/src/clis/douyin/user-videos.ts +101 -0
- package/src/clis/douyin/videos.test.ts +52 -2
- package/src/clis/douyin/videos.ts +49 -15
- package/src/clis/facebook/search.test.ts +70 -0
- package/src/clis/facebook/search.yaml +4 -3
- package/src/clis/instagram/download.test.ts +159 -0
- package/src/clis/instagram/download.ts +286 -0
- package/src/clis/notebooklm/bind-current.test.ts +43 -0
- package/src/clis/notebooklm/bind-current.ts +36 -0
- package/src/clis/notebooklm/binding.test.ts +53 -0
- package/src/clis/notebooklm/compat.test.ts +19 -0
- package/src/clis/notebooklm/current.ts +38 -0
- package/src/clis/notebooklm/get.ts +53 -0
- package/src/clis/notebooklm/history.test.ts +70 -0
- package/src/clis/notebooklm/history.ts +36 -0
- package/src/clis/notebooklm/list.ts +40 -0
- package/src/clis/notebooklm/note-list.test.ts +64 -0
- package/src/clis/notebooklm/note-list.ts +42 -0
- package/src/clis/notebooklm/notes-get.test.ts +88 -0
- package/src/clis/notebooklm/notes-get.ts +67 -0
- package/src/clis/notebooklm/rpc.test.ts +126 -0
- package/src/clis/notebooklm/rpc.ts +286 -0
- package/src/clis/notebooklm/shared.ts +98 -0
- package/src/clis/notebooklm/source-fulltext.test.ts +123 -0
- package/src/clis/notebooklm/source-fulltext.ts +69 -0
- package/src/clis/notebooklm/source-get.test.ts +100 -0
- package/src/clis/notebooklm/source-get.ts +60 -0
- package/src/clis/notebooklm/source-guide.test.ts +121 -0
- package/src/clis/notebooklm/source-guide.ts +69 -0
- package/src/clis/notebooklm/source-list.ts +45 -0
- package/src/clis/notebooklm/status.ts +34 -0
- package/src/clis/notebooklm/summary.test.ts +94 -0
- package/src/clis/notebooklm/summary.ts +45 -0
- package/src/clis/notebooklm/utils.test.ts +446 -0
- package/src/clis/notebooklm/utils.ts +893 -0
- package/src/clis/ones/common.ts +187 -0
- package/src/clis/ones/enrich-tasks.ts +47 -0
- package/src/clis/ones/login.ts +103 -0
- package/src/clis/ones/logout.ts +19 -0
- package/src/clis/ones/me.ts +34 -0
- package/src/clis/ones/my-tasks.ts +148 -0
- package/src/clis/ones/resolve-labels.ts +80 -0
- package/src/clis/ones/task-helpers.test.ts +14 -0
- package/src/clis/ones/task-helpers.ts +214 -0
- package/src/clis/ones/task.ts +79 -0
- package/src/clis/ones/tasks.ts +92 -0
- package/src/clis/ones/token-info.ts +46 -0
- package/src/clis/ones/worklog.test.ts +24 -0
- package/src/clis/ones/worklog.ts +306 -0
- package/src/clis/spotify/spotify.ts +328 -0
- package/src/clis/spotify/utils.test.ts +87 -0
- package/src/clis/spotify/utils.ts +92 -0
- package/src/clis/substack/utils.test.ts +54 -0
- package/src/clis/substack/utils.ts +10 -2
- package/src/clis/tieba/commands.test.ts +86 -0
- package/src/clis/tieba/hot.ts +52 -0
- package/src/clis/tieba/posts.ts +108 -0
- package/src/clis/tieba/read.ts +158 -0
- package/src/clis/tieba/search.ts +119 -0
- package/src/clis/tieba/utils.test.ts +322 -0
- package/src/clis/tieba/utils.ts +348 -0
- package/src/clis/v2ex/hot.yaml +4 -1
- package/src/clis/v2ex/latest.yaml +4 -1
- package/src/clis/v2ex/topic.yaml +6 -1
- package/src/clis/weixin/download.ts +95 -6
- package/src/clis/weread/book.ts +256 -13
- package/src/clis/weread/commands.test.ts +409 -0
- package/src/{weread-private-api-regression.test.ts → clis/weread/private-api-regression.test.ts} +108 -30
- package/src/clis/weread/search-regression.test.ts +440 -0
- package/src/clis/weread/search.ts +189 -9
- package/src/clis/weread/shelf.ts +20 -122
- package/src/clis/weread/utils.test.ts +81 -1
- package/src/clis/weread/utils.ts +293 -7
- package/src/clis/xiaohongshu/comments.test.ts +85 -9
- package/src/clis/xiaohongshu/comments.ts +76 -17
- package/src/clis/xiaohongshu/download.test.ts +96 -0
- package/src/clis/xiaohongshu/download.ts +83 -22
- package/src/clis/xiaohongshu/note-helpers.ts +25 -0
- package/src/clis/xiaohongshu/note.test.ts +164 -0
- package/src/clis/xiaohongshu/note.ts +86 -0
- package/src/clis/xiaohongshu/publish.test.ts +79 -1
- package/src/clis/xiaohongshu/publish.ts +84 -30
- package/src/clis/xiaohongshu/search.test.ts +11 -4
- package/src/clis/xiaohongshu/search.ts +13 -0
- package/src/clis/xiaohongshu/user-helpers.test.ts +23 -0
- package/src/clis/xiaohongshu/user-helpers.ts +4 -0
- package/src/clis/xueqiu/comments.test.ts +823 -0
- package/src/clis/xueqiu/comments.ts +461 -0
- package/src/clis/youtube/search.ts +57 -17
- package/src/clis/youtube/transcript.ts +2 -4
- package/src/clis/youtube/utils.test.ts +43 -0
- package/src/clis/youtube/utils.ts +69 -0
- package/src/clis/youtube/video.ts +16 -15
- package/src/clis/zhihu/question.test.ts +71 -0
- package/src/clis/zhihu/question.ts +27 -15
- package/src/clis/zsxq/dynamics.ts +60 -0
- package/src/clis/zsxq/groups.ts +41 -0
- package/src/clis/zsxq/search.test.ts +29 -0
- package/src/clis/zsxq/search.ts +54 -0
- package/src/clis/zsxq/topic.test.ts +34 -0
- package/src/clis/zsxq/topic.ts +68 -0
- package/src/clis/zsxq/topics.test.ts +29 -0
- package/src/clis/zsxq/topics.ts +36 -0
- package/src/clis/zsxq/utils.ts +351 -0
- package/src/commanderAdapter.test.ts +77 -0
- package/src/commanderAdapter.ts +8 -1
- package/src/commands/daemon.test.ts +238 -0
- package/src/commands/daemon.ts +135 -0
- package/src/completion.ts +2 -1
- package/src/constants.ts +3 -0
- package/src/daemon.test.ts +88 -0
- package/src/daemon.ts +26 -14
- package/src/discovery.ts +52 -2
- package/src/electron-apps.test.ts +50 -0
- package/src/electron-apps.ts +89 -0
- package/src/engine.test.ts +45 -9
- package/src/execution.ts +24 -19
- package/src/external-clis.yaml +17 -0
- package/src/idle-manager.ts +60 -0
- package/src/launcher.test.ts +67 -0
- package/src/launcher.ts +185 -0
- package/src/main.ts +3 -2
- package/src/registry.test.ts +15 -0
- package/src/registry.ts +32 -3
- package/src/runtime.ts +13 -7
- package/src/serialization.test.ts +19 -1
- package/src/serialization.ts +2 -0
- package/src/tui.test.ts +23 -0
- package/src/tui.ts +65 -0
- package/src/types.ts +5 -0
- package/src/weixin-download.test.ts +27 -0
- package/tests/e2e/band-auth.test.ts +20 -0
- package/tests/e2e/browser-auth-helpers.ts +18 -0
- package/tests/e2e/browser-auth.test.ts +35 -47
- package/tests/e2e/browser-public-extended.test.ts +6 -2
- package/tests/e2e/browser-public.test.ts +288 -0
- package/tests/e2e/management.test.ts +1 -1
- package/tests/e2e/plugin-management.test.ts +1 -1
- package/vitest.config.ts +1 -0
- package/chatwise-opencli.ps1 +0 -82
- package/dist/clis/chatwise/shared.d.ts +0 -2
- package/dist/clis/chatwise/shared.js +0 -6
- package/dist/weread-private-api-regression.test.d.ts +0 -1
- package/dist/weread-search-regression.test.d.ts +0 -1
- package/dist/weread-search-regression.test.js +0 -39
- package/src/clis/chatwise/shared.ts +0 -8
- package/src/weread-search-regression.test.ts +0 -44
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as os from 'node:os';
|
|
2
|
+
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import type { CliCommand } from '../../registry.js';
|
|
4
|
+
import { getRegistry } from '../../registry.js';
|
|
5
|
+
import { ArgumentError, AuthRequiredError, CliError, CommandExecutionError } from '../../errors.js';
|
|
6
|
+
import type { IPage } from '../../types.js';
|
|
7
|
+
|
|
8
|
+
const { mockHttpDownload, logSpy } = vi.hoisted(() => ({
|
|
9
|
+
mockHttpDownload: vi.fn(),
|
|
10
|
+
logSpy: vi.spyOn(console, 'log').mockImplementation(() => undefined),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
vi.mock('../../download/index.js', async () => {
|
|
14
|
+
const actual = await vi.importActual<object>('../../download/index.js');
|
|
15
|
+
return { ...actual, httpDownload: mockHttpDownload };
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
buildInstagramDownloadItems,
|
|
20
|
+
parseInstagramMediaTarget,
|
|
21
|
+
} = await import('./download.js');
|
|
22
|
+
|
|
23
|
+
let cmd: CliCommand;
|
|
24
|
+
|
|
25
|
+
beforeAll(() => {
|
|
26
|
+
cmd = getRegistry().get('instagram/download')!;
|
|
27
|
+
expect(cmd?.func).toBeTypeOf('function');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function createPageMock(evaluateResult: unknown): IPage {
|
|
31
|
+
return {
|
|
32
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
33
|
+
evaluate: vi.fn().mockResolvedValue(evaluateResult),
|
|
34
|
+
} as unknown as IPage;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('instagram download helpers', () => {
|
|
38
|
+
it('parses canonical and username-prefixed Instagram media URLs', () => {
|
|
39
|
+
expect(parseInstagramMediaTarget('https://www.instagram.com/reel/DWg8NuZEj9p/?utm_source=ig_web_copy_link')).toEqual({
|
|
40
|
+
kind: 'reel',
|
|
41
|
+
shortcode: 'DWg8NuZEj9p',
|
|
42
|
+
canonicalUrl: 'https://www.instagram.com/reel/DWg8NuZEj9p/',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(parseInstagramMediaTarget('https://www.instagram.com/nasa/p/DWUR_azCWbN/?img_index=1')).toEqual({
|
|
46
|
+
kind: 'p',
|
|
47
|
+
shortcode: 'DWUR_azCWbN',
|
|
48
|
+
canonicalUrl: 'https://www.instagram.com/p/DWUR_azCWbN/',
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('rejects unsupported URLs early', () => {
|
|
53
|
+
expect(() => parseInstagramMediaTarget('https://example.com/p/abc')).toThrow(ArgumentError);
|
|
54
|
+
expect(() => parseInstagramMediaTarget('https://www.instagram.com/stories/abc/123')).toThrow(ArgumentError);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('builds padded filenames and preserves known file extensions', () => {
|
|
58
|
+
expect(buildInstagramDownloadItems('DWUR_azCWbN', [
|
|
59
|
+
{ type: 'image', url: 'https://cdn.example.com/photo.webp?foo=1' },
|
|
60
|
+
{ type: 'video', url: 'https://cdn.example.com/video.mp4?bar=2' },
|
|
61
|
+
{ type: 'image', url: 'not-a-valid-url' },
|
|
62
|
+
])).toEqual([
|
|
63
|
+
{ type: 'image', url: 'https://cdn.example.com/photo.webp?foo=1', filename: 'DWUR_azCWbN_01.webp' },
|
|
64
|
+
{ type: 'video', url: 'https://cdn.example.com/video.mp4?bar=2', filename: 'DWUR_azCWbN_02.mp4' },
|
|
65
|
+
{ type: 'image', url: 'not-a-valid-url', filename: 'DWUR_azCWbN_03.jpg' },
|
|
66
|
+
]);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('instagram download command', () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
mockHttpDownload.mockReset();
|
|
73
|
+
logSpy.mockClear();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('rejects invalid URLs before browser work', async () => {
|
|
77
|
+
const page = createPageMock({ ok: true, items: [] });
|
|
78
|
+
await expect(cmd.func!(page, { url: 'https://example.com/not-instagram' })).rejects.toThrow(ArgumentError);
|
|
79
|
+
expect((page.goto as any).mock.calls).toHaveLength(0);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('maps auth failures to AuthRequiredError', async () => {
|
|
83
|
+
const page = createPageMock({ ok: false, errorCode: 'AUTH_REQUIRED', error: 'Instagram login required' });
|
|
84
|
+
await expect(cmd.func!(page, { url: 'https://www.instagram.com/p/DWUR_azCWbN/' })).rejects.toThrow(AuthRequiredError);
|
|
85
|
+
expect(mockHttpDownload).not.toHaveBeenCalled();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('maps rate limit failures to CliError with RATE_LIMITED code', async () => {
|
|
89
|
+
const page = createPageMock({ ok: false, errorCode: 'RATE_LIMITED', error: 'Please wait a few minutes' });
|
|
90
|
+
await expect(cmd.func!(page, { url: 'https://www.instagram.com/p/DWUR_azCWbN/' })).rejects.toMatchObject({ code: 'RATE_LIMITED' } satisfies Partial<CliError>);
|
|
91
|
+
expect(mockHttpDownload).not.toHaveBeenCalled();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('maps private/unavailable failures to CommandExecutionError', async () => {
|
|
95
|
+
const page = createPageMock({ ok: false, errorCode: 'PRIVATE_OR_UNAVAILABLE', error: 'Post may be private' });
|
|
96
|
+
await expect(cmd.func!(page, { url: 'https://www.instagram.com/p/DWUR_azCWbN/' })).rejects.toThrow(CommandExecutionError);
|
|
97
|
+
expect(mockHttpDownload).not.toHaveBeenCalled();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('throws when no downloadable media is found', async () => {
|
|
101
|
+
const page = createPageMock({ ok: true, shortcode: 'DWUR_azCWbN', items: [] });
|
|
102
|
+
await expect(cmd.func!(page, { url: 'https://www.instagram.com/p/DWUR_azCWbN/' })).rejects.toThrow(CommandExecutionError);
|
|
103
|
+
expect(mockHttpDownload).not.toHaveBeenCalled();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('downloads media and prints saved directory', async () => {
|
|
107
|
+
mockHttpDownload
|
|
108
|
+
.mockResolvedValueOnce({ success: true, size: 120_000 })
|
|
109
|
+
.mockResolvedValueOnce({ success: true, size: 8_200_000 });
|
|
110
|
+
|
|
111
|
+
const page = createPageMock({
|
|
112
|
+
ok: true,
|
|
113
|
+
shortcode: 'DWUR_azCWbN',
|
|
114
|
+
items: [
|
|
115
|
+
{ type: 'image', url: 'https://cdn.example.com/photo.webp?foo=1' },
|
|
116
|
+
{ type: 'video', url: 'https://cdn.example.com/video.mp4?bar=2' },
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const result = await cmd.func!(page, {
|
|
121
|
+
url: 'https://www.instagram.com/nasa/p/DWUR_azCWbN/?img_index=1',
|
|
122
|
+
path: './instagram-test',
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
expect(result).toBeNull();
|
|
126
|
+
expect((page.goto as any).mock.calls[0]?.[0]).toBe('https://www.instagram.com/p/DWUR_azCWbN/');
|
|
127
|
+
expect(mockHttpDownload).toHaveBeenNthCalledWith(1,
|
|
128
|
+
'https://cdn.example.com/photo.webp?foo=1',
|
|
129
|
+
expect.stringContaining('instagram-test/DWUR_azCWbN/DWUR_azCWbN_01.webp'),
|
|
130
|
+
expect.objectContaining({ timeout: 60000 }),
|
|
131
|
+
);
|
|
132
|
+
expect(mockHttpDownload).toHaveBeenNthCalledWith(2,
|
|
133
|
+
'https://cdn.example.com/video.mp4?bar=2',
|
|
134
|
+
expect.stringContaining('instagram-test/DWUR_azCWbN/DWUR_azCWbN_02.mp4'),
|
|
135
|
+
expect.objectContaining({ timeout: 120000 }),
|
|
136
|
+
);
|
|
137
|
+
expect(logSpy).toHaveBeenCalledWith('📁 saved: instagram-test/DWUR_azCWbN');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('uses a cross-platform Downloads default when path is omitted', async () => {
|
|
141
|
+
mockHttpDownload.mockResolvedValueOnce({ success: true, size: 120_000 });
|
|
142
|
+
|
|
143
|
+
const page = createPageMock({
|
|
144
|
+
ok: true,
|
|
145
|
+
shortcode: 'DWUR_azCWbN',
|
|
146
|
+
items: [
|
|
147
|
+
{ type: 'image', url: 'https://cdn.example.com/photo.webp?foo=1' },
|
|
148
|
+
],
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
await cmd.func!(page, { url: 'https://www.instagram.com/p/DWUR_azCWbN/' });
|
|
152
|
+
|
|
153
|
+
expect(mockHttpDownload).toHaveBeenCalledWith(
|
|
154
|
+
'https://cdn.example.com/photo.webp?foo=1',
|
|
155
|
+
expect.stringContaining(`${os.homedir()}/Downloads/Instagram/DWUR_azCWbN/DWUR_azCWbN_01.webp`),
|
|
156
|
+
expect.objectContaining({ timeout: 60000 }),
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { cli, Strategy } from '../../registry.js';
|
|
5
|
+
import { ArgumentError, AuthRequiredError, CliError, CommandExecutionError, EXIT_CODES } from '../../errors.js';
|
|
6
|
+
import { httpDownload } from '../../download/index.js';
|
|
7
|
+
import type { IPage } from '../../types.js';
|
|
8
|
+
|
|
9
|
+
const INSTAGRAM_GRAPHQL_DOC_ID = '8845758582119845';
|
|
10
|
+
const INSTAGRAM_GRAPHQL_APP_ID = '936619743392459';
|
|
11
|
+
const INSTAGRAM_HOST_SUFFIX = 'instagram.com';
|
|
12
|
+
const SUPPORTED_KINDS = new Set(['p', 'reel', 'tv']);
|
|
13
|
+
|
|
14
|
+
export interface InstagramMediaTarget {
|
|
15
|
+
kind: 'p' | 'reel' | 'tv';
|
|
16
|
+
shortcode: string;
|
|
17
|
+
canonicalUrl: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface InstagramPageMediaItem {
|
|
21
|
+
type: 'image' | 'video';
|
|
22
|
+
url: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface InstagramFetchResult {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
shortcode?: string;
|
|
28
|
+
owner?: string;
|
|
29
|
+
items?: InstagramPageMediaItem[];
|
|
30
|
+
errorCode?: string;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface DownloadedMediaItem extends InstagramPageMediaItem {
|
|
35
|
+
filename: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function displayPath(filePath: string): string {
|
|
39
|
+
const home = os.homedir();
|
|
40
|
+
return filePath.startsWith(home) ? `~${filePath.slice(home.length)}` : filePath;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export function parseInstagramMediaTarget(input: string): InstagramMediaTarget {
|
|
45
|
+
const raw = String(input || '').trim();
|
|
46
|
+
if (!raw) {
|
|
47
|
+
throw new ArgumentError(
|
|
48
|
+
'Instagram URL is required',
|
|
49
|
+
'Expected https://www.instagram.com/p/... or https://www.instagram.com/reel/...',
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let url: URL;
|
|
54
|
+
try {
|
|
55
|
+
url = new URL(raw);
|
|
56
|
+
} catch {
|
|
57
|
+
throw new ArgumentError(
|
|
58
|
+
`Invalid Instagram URL: ${raw}`,
|
|
59
|
+
'Expected https://www.instagram.com/p/<shortcode>/ or /reel/<shortcode>/',
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!['http:', 'https:'].includes(url.protocol)) {
|
|
64
|
+
throw new ArgumentError(`Unsupported URL protocol: ${url.protocol}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const host = url.hostname.toLowerCase();
|
|
68
|
+
if (host !== INSTAGRAM_HOST_SUFFIX && !host.endsWith(`.${INSTAGRAM_HOST_SUFFIX}`)) {
|
|
69
|
+
throw new ArgumentError(`Unsupported host: ${host}`, 'Only instagram.com URLs are supported');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const segments = url.pathname.split('/').filter(Boolean);
|
|
73
|
+
let kind: string | undefined;
|
|
74
|
+
let shortcode: string | undefined;
|
|
75
|
+
|
|
76
|
+
if (segments.length >= 2 && SUPPORTED_KINDS.has(segments[0]!)) {
|
|
77
|
+
kind = segments[0];
|
|
78
|
+
shortcode = segments[1];
|
|
79
|
+
} else if (segments.length >= 3 && SUPPORTED_KINDS.has(segments[1]!)) {
|
|
80
|
+
kind = segments[1];
|
|
81
|
+
shortcode = segments[2];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!kind || !shortcode) {
|
|
85
|
+
throw new ArgumentError(
|
|
86
|
+
`Unsupported Instagram media URL: ${raw}`,
|
|
87
|
+
'Only /p/<shortcode>/, /reel/<shortcode>/, and /tv/<shortcode>/ links are supported',
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
kind: kind as 'p' | 'reel' | 'tv',
|
|
93
|
+
shortcode,
|
|
94
|
+
canonicalUrl: `https://www.instagram.com/${kind}/${shortcode}/`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function buildInstagramDownloadItems(shortcode: string, items: InstagramPageMediaItem[]): DownloadedMediaItem[] {
|
|
99
|
+
return items
|
|
100
|
+
.filter((item) => item?.url)
|
|
101
|
+
.map((item, index) => {
|
|
102
|
+
const fallbackExt = item.type === 'video' ? '.mp4' : '.jpg';
|
|
103
|
+
let ext = fallbackExt;
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const pathname = new URL(item.url).pathname;
|
|
107
|
+
const candidateExt = path.extname(pathname).toLowerCase();
|
|
108
|
+
if (candidateExt && candidateExt.length <= 8) ext = candidateExt;
|
|
109
|
+
} catch {
|
|
110
|
+
ext = fallbackExt;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
type: item.type,
|
|
115
|
+
url: item.url,
|
|
116
|
+
filename: `${shortcode}_${String(index + 1).padStart(2, '0')}${ext}`,
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function buildInstagramFetchScript(shortcode: string): string {
|
|
122
|
+
return `
|
|
123
|
+
(async () => {
|
|
124
|
+
const shortcode = ${JSON.stringify(shortcode)};
|
|
125
|
+
const docId = ${JSON.stringify(INSTAGRAM_GRAPHQL_DOC_ID)};
|
|
126
|
+
const variables = {
|
|
127
|
+
shortcode,
|
|
128
|
+
fetch_tagged_user_count: null,
|
|
129
|
+
hoisted_comment_id: null,
|
|
130
|
+
hoisted_reply_id: null,
|
|
131
|
+
};
|
|
132
|
+
const url = 'https://www.instagram.com/graphql/query/?doc_id=' + docId + '&variables=' + encodeURIComponent(JSON.stringify(variables));
|
|
133
|
+
const res = await fetch(url, {
|
|
134
|
+
credentials: 'include',
|
|
135
|
+
headers: {
|
|
136
|
+
'Accept': 'application/json,text/plain,*/*',
|
|
137
|
+
'X-IG-App-ID': ${JSON.stringify(INSTAGRAM_GRAPHQL_APP_ID)},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
const rawText = await res.text();
|
|
141
|
+
|
|
142
|
+
let data = null;
|
|
143
|
+
try {
|
|
144
|
+
data = rawText ? JSON.parse(rawText) : null;
|
|
145
|
+
} catch {
|
|
146
|
+
return {
|
|
147
|
+
ok: false,
|
|
148
|
+
errorCode: 'COMMAND_EXEC',
|
|
149
|
+
error: 'Instagram returned non-JSON content while fetching media metadata',
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const message = typeof data?.message === 'string' ? data.message : '';
|
|
154
|
+
const lowered = (message || '').toLowerCase();
|
|
155
|
+
|
|
156
|
+
if (!res.ok) {
|
|
157
|
+
if (res.status === 401 || res.status === 403 || data?.require_login) {
|
|
158
|
+
return { ok: false, errorCode: 'AUTH_REQUIRED', error: message || ('HTTP ' + res.status) };
|
|
159
|
+
}
|
|
160
|
+
if (res.status === 429) {
|
|
161
|
+
return { ok: false, errorCode: 'RATE_LIMITED', error: message || 'HTTP 429' };
|
|
162
|
+
}
|
|
163
|
+
if (res.status === 404 || res.status === 410) {
|
|
164
|
+
return { ok: false, errorCode: 'PRIVATE_OR_UNAVAILABLE', error: message || ('HTTP ' + res.status) };
|
|
165
|
+
}
|
|
166
|
+
return { ok: false, errorCode: 'COMMAND_EXEC', error: message || ('HTTP ' + res.status) };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (data?.require_login) {
|
|
170
|
+
return { ok: false, errorCode: 'AUTH_REQUIRED', error: message || 'Instagram login required' };
|
|
171
|
+
}
|
|
172
|
+
if (lowered.includes('wait a few minutes') || lowered.includes('rate')) {
|
|
173
|
+
return { ok: false, errorCode: 'RATE_LIMITED', error: message || 'Instagram rate limit triggered' };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const media = data?.data?.xdt_shortcode_media;
|
|
177
|
+
if (!media) {
|
|
178
|
+
return {
|
|
179
|
+
ok: false,
|
|
180
|
+
errorCode: 'PRIVATE_OR_UNAVAILABLE',
|
|
181
|
+
error: message || 'Post may be private, unavailable, or inaccessible to the current browser session',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const nodes = Array.isArray(media?.edge_sidecar_to_children?.edges) && media.edge_sidecar_to_children.edges.length > 0
|
|
186
|
+
? media.edge_sidecar_to_children.edges.map((edge) => edge?.node).filter(Boolean)
|
|
187
|
+
: [media];
|
|
188
|
+
|
|
189
|
+
const items = nodes
|
|
190
|
+
.map((node) => ({
|
|
191
|
+
type: node?.is_video ? 'video' : 'image',
|
|
192
|
+
url: String(node?.is_video ? (node?.video_url || '') : (node?.display_url || '')),
|
|
193
|
+
}))
|
|
194
|
+
.filter((item) => item.url);
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
ok: true,
|
|
198
|
+
shortcode: media.shortcode || shortcode,
|
|
199
|
+
owner: media?.owner?.username || '',
|
|
200
|
+
items,
|
|
201
|
+
};
|
|
202
|
+
})()
|
|
203
|
+
`;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function ensurePage(page: IPage | null): IPage {
|
|
207
|
+
if (!page) throw new CommandExecutionError('Browser session required');
|
|
208
|
+
return page;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function normalizeFetchResult(result: unknown): InstagramFetchResult {
|
|
212
|
+
if (!result || typeof result !== 'object') {
|
|
213
|
+
throw new CommandExecutionError('Failed to fetch Instagram media metadata');
|
|
214
|
+
}
|
|
215
|
+
return result as InstagramFetchResult;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function handleFetchFailure(result: InstagramFetchResult): never {
|
|
219
|
+
const message = result.error || 'Instagram media fetch failed';
|
|
220
|
+
|
|
221
|
+
if (result.errorCode === 'AUTH_REQUIRED') {
|
|
222
|
+
throw new AuthRequiredError('instagram.com', message);
|
|
223
|
+
}
|
|
224
|
+
if (result.errorCode === 'RATE_LIMITED') {
|
|
225
|
+
throw new CliError(
|
|
226
|
+
'RATE_LIMITED',
|
|
227
|
+
message,
|
|
228
|
+
'Wait a few minutes and retry, or switch to a browser session with a warmer Instagram login state.',
|
|
229
|
+
EXIT_CODES.TEMPFAIL,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
if (result.errorCode === 'PRIVATE_OR_UNAVAILABLE') {
|
|
233
|
+
throw new CommandExecutionError(message, 'Open the post in a logged-in browser session and retry');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
throw new CommandExecutionError(message);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function downloadInstagramMedia(items: DownloadedMediaItem[], outputDir: string): Promise<void> {
|
|
240
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
241
|
+
|
|
242
|
+
for (const item of items) {
|
|
243
|
+
const destPath = path.join(outputDir, item.filename);
|
|
244
|
+
const result = await httpDownload(item.url, destPath, {
|
|
245
|
+
timeout: item.type === 'video' ? 120000 : 60000,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
if (!result.success) {
|
|
249
|
+
throw new CommandExecutionError(`Failed to download ${item.filename}: ${result.error || 'unknown error'}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
cli({
|
|
255
|
+
site: 'instagram',
|
|
256
|
+
name: 'download',
|
|
257
|
+
description: 'Download images and videos from Instagram posts and reels',
|
|
258
|
+
domain: 'www.instagram.com',
|
|
259
|
+
strategy: Strategy.COOKIE,
|
|
260
|
+
navigateBefore: false,
|
|
261
|
+
args: [
|
|
262
|
+
{ name: 'url', positional: true, required: true, help: 'Instagram post / reel / tv URL' },
|
|
263
|
+
{ name: 'path', default: path.join(os.homedir(), 'Downloads', 'Instagram'), help: 'Download directory' },
|
|
264
|
+
],
|
|
265
|
+
func: async (page, kwargs) => {
|
|
266
|
+
const browserPage = ensurePage(page);
|
|
267
|
+
const target = parseInstagramMediaTarget(String(kwargs.url ?? ''));
|
|
268
|
+
const outputRoot = String(kwargs.path ?? path.join(os.homedir(), 'Downloads', 'Instagram'));
|
|
269
|
+
|
|
270
|
+
await browserPage.goto(target.canonicalUrl);
|
|
271
|
+
|
|
272
|
+
const fetchResult = normalizeFetchResult(await browserPage.evaluate(buildInstagramFetchScript(target.shortcode)));
|
|
273
|
+
if (!fetchResult.ok) handleFetchFailure(fetchResult);
|
|
274
|
+
|
|
275
|
+
const shortcode = fetchResult.shortcode || target.shortcode;
|
|
276
|
+
const mediaItems = buildInstagramDownloadItems(shortcode, fetchResult.items || []);
|
|
277
|
+
if (mediaItems.length === 0) {
|
|
278
|
+
throw new CommandExecutionError('No downloadable media found');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const savedDir = path.join(outputRoot, shortcode);
|
|
282
|
+
await downloadInstagramMedia(mediaItems, savedDir);
|
|
283
|
+
console.log(`📁 saved: ${displayPath(savedDir)}`);
|
|
284
|
+
return null;
|
|
285
|
+
},
|
|
286
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const { mockBindCurrentTab } = vi.hoisted(() => ({
|
|
4
|
+
mockBindCurrentTab: vi.fn(),
|
|
5
|
+
}));
|
|
6
|
+
|
|
7
|
+
vi.mock('../../browser/daemon-client.js', () => ({
|
|
8
|
+
bindCurrentTab: mockBindCurrentTab,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
import { getRegistry } from '../../registry.js';
|
|
12
|
+
import './bind-current.js';
|
|
13
|
+
|
|
14
|
+
describe('notebooklm bind-current', () => {
|
|
15
|
+
const command = getRegistry().get('notebooklm/bind-current');
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
mockBindCurrentTab.mockReset();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('binds the current notebook tab into site:notebooklm', async () => {
|
|
22
|
+
mockBindCurrentTab.mockResolvedValue({
|
|
23
|
+
workspace: 'site:notebooklm',
|
|
24
|
+
tabId: 123,
|
|
25
|
+
title: 'Bound Notebook',
|
|
26
|
+
url: 'https://notebooklm.google.com/notebook/nb-live',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const result = await command!.func!({} as any, {});
|
|
30
|
+
|
|
31
|
+
expect(mockBindCurrentTab).toHaveBeenCalledWith('site:notebooklm', {
|
|
32
|
+
matchDomain: 'notebooklm.google.com',
|
|
33
|
+
matchPathPrefix: '/notebook/',
|
|
34
|
+
});
|
|
35
|
+
expect(result).toEqual([{
|
|
36
|
+
workspace: 'site:notebooklm',
|
|
37
|
+
tab_id: 123,
|
|
38
|
+
notebook_id: 'nb-live',
|
|
39
|
+
title: 'Bound Notebook',
|
|
40
|
+
url: 'https://notebooklm.google.com/notebook/nb-live',
|
|
41
|
+
}]);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
import { bindCurrentTab } from '../../browser/daemon-client.js';
|
|
3
|
+
import { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js';
|
|
4
|
+
import { parseNotebooklmIdFromUrl } from './utils.js';
|
|
5
|
+
|
|
6
|
+
cli({
|
|
7
|
+
site: NOTEBOOKLM_SITE,
|
|
8
|
+
name: 'bind-current',
|
|
9
|
+
aliases: ['use'],
|
|
10
|
+
description: 'Bind the current active NotebookLM notebook tab into the site:notebooklm workspace',
|
|
11
|
+
domain: NOTEBOOKLM_DOMAIN,
|
|
12
|
+
strategy: Strategy.COOKIE,
|
|
13
|
+
browser: true,
|
|
14
|
+
navigateBefore: false,
|
|
15
|
+
args: [],
|
|
16
|
+
columns: ['workspace', 'tab_id', 'notebook_id', 'title', 'url'],
|
|
17
|
+
func: async () => {
|
|
18
|
+
const result = await bindCurrentTab(`site:${NOTEBOOKLM_SITE}`, {
|
|
19
|
+
matchDomain: NOTEBOOKLM_DOMAIN,
|
|
20
|
+
matchPathPrefix: '/notebook/',
|
|
21
|
+
}) as {
|
|
22
|
+
tabId?: number;
|
|
23
|
+
workspace?: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return [{
|
|
29
|
+
workspace: result.workspace ?? `site:${NOTEBOOKLM_SITE}`,
|
|
30
|
+
tab_id: result.tabId ?? null,
|
|
31
|
+
notebook_id: result.url ? parseNotebooklmIdFromUrl(result.url) : '',
|
|
32
|
+
title: result.title ?? '',
|
|
33
|
+
url: result.url ?? '',
|
|
34
|
+
}];
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const { mockBindCurrentTab } = vi.hoisted(() => ({
|
|
4
|
+
mockBindCurrentTab: vi.fn(),
|
|
5
|
+
}));
|
|
6
|
+
|
|
7
|
+
vi.mock('../../browser/daemon-client.js', () => ({
|
|
8
|
+
bindCurrentTab: mockBindCurrentTab,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
import { ensureNotebooklmNotebookBinding } from './utils.js';
|
|
12
|
+
|
|
13
|
+
describe('notebooklm automatic binding', () => {
|
|
14
|
+
const originalEndpoint = process.env.OPENCLI_CDP_ENDPOINT;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
mockBindCurrentTab.mockReset();
|
|
18
|
+
if (originalEndpoint === undefined) delete process.env.OPENCLI_CDP_ENDPOINT;
|
|
19
|
+
else process.env.OPENCLI_CDP_ENDPOINT = originalEndpoint;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('does nothing when the current page is already a notebook page', async () => {
|
|
23
|
+
const page = {
|
|
24
|
+
getCurrentUrl: async () => 'https://notebooklm.google.com/notebook/nb-demo',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
await expect(ensureNotebooklmNotebookBinding(page as any)).resolves.toBe(false);
|
|
28
|
+
expect(mockBindCurrentTab).not.toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('best-effort binds a notebook page through the browser bridge when currently on home', async () => {
|
|
32
|
+
const page = {
|
|
33
|
+
getCurrentUrl: async () => 'https://notebooklm.google.com/',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
mockBindCurrentTab.mockResolvedValue({});
|
|
37
|
+
await expect(ensureNotebooklmNotebookBinding(page as any)).resolves.toBe(true);
|
|
38
|
+
expect(mockBindCurrentTab).toHaveBeenCalledWith('site:notebooklm', {
|
|
39
|
+
matchDomain: 'notebooklm.google.com',
|
|
40
|
+
matchPathPrefix: '/notebook/',
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('skips daemon binding in direct CDP mode', async () => {
|
|
45
|
+
process.env.OPENCLI_CDP_ENDPOINT = 'ws://127.0.0.1:9222/devtools/page/1';
|
|
46
|
+
const page = {
|
|
47
|
+
getCurrentUrl: async () => 'https://notebooklm.google.com/',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
await expect(ensureNotebooklmNotebookBinding(page as any)).resolves.toBe(false);
|
|
51
|
+
expect(mockBindCurrentTab).not.toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getRegistry } from '../../registry.js';
|
|
3
|
+
import './bind-current.js';
|
|
4
|
+
import './get.js';
|
|
5
|
+
import './note-list.js';
|
|
6
|
+
|
|
7
|
+
describe('notebooklm compatibility aliases', () => {
|
|
8
|
+
it('registers use as a compatibility alias for bind-current', () => {
|
|
9
|
+
expect(getRegistry().get('notebooklm/use')).toBe(getRegistry().get('notebooklm/bind-current'));
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('registers metadata as a compatibility alias for get', () => {
|
|
13
|
+
expect(getRegistry().get('notebooklm/metadata')).toBe(getRegistry().get('notebooklm/get'));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('registers notes-list as a compatibility alias for note-list', () => {
|
|
17
|
+
expect(getRegistry().get('notebooklm/notes-list')).toBe(getRegistry().get('notebooklm/note-list'));
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
import { EmptyResultError } from '../../errors.js';
|
|
3
|
+
import type { IPage } from '../../types.js';
|
|
4
|
+
import { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js';
|
|
5
|
+
import { ensureNotebooklmNotebookBinding, getNotebooklmPageState, readCurrentNotebooklm, requireNotebooklmSession } from './utils.js';
|
|
6
|
+
|
|
7
|
+
cli({
|
|
8
|
+
site: NOTEBOOKLM_SITE,
|
|
9
|
+
name: 'current',
|
|
10
|
+
description: 'Show metadata for the currently opened NotebookLM notebook tab',
|
|
11
|
+
domain: NOTEBOOKLM_DOMAIN,
|
|
12
|
+
strategy: Strategy.COOKIE,
|
|
13
|
+
browser: true,
|
|
14
|
+
navigateBefore: false,
|
|
15
|
+
args: [],
|
|
16
|
+
columns: ['id', 'title', 'url', 'source'],
|
|
17
|
+
func: async (page: IPage) => {
|
|
18
|
+
await ensureNotebooklmNotebookBinding(page);
|
|
19
|
+
await requireNotebooklmSession(page);
|
|
20
|
+
const state = await getNotebooklmPageState(page);
|
|
21
|
+
if (state.kind !== 'notebook') {
|
|
22
|
+
throw new EmptyResultError(
|
|
23
|
+
'opencli notebooklm current',
|
|
24
|
+
'Open a specific NotebookLM notebook tab first, then retry.',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const current = await readCurrentNotebooklm(page);
|
|
29
|
+
if (!current) {
|
|
30
|
+
throw new EmptyResultError(
|
|
31
|
+
'opencli notebooklm current',
|
|
32
|
+
'NotebookLM notebook metadata was not found on the current page.',
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return [current];
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
import type { IPage } from '../../types.js';
|
|
3
|
+
import { EmptyResultError } from '../../errors.js';
|
|
4
|
+
import { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js';
|
|
5
|
+
import {
|
|
6
|
+
ensureNotebooklmNotebookBinding,
|
|
7
|
+
getNotebooklmDetailViaRpc,
|
|
8
|
+
getNotebooklmPageState,
|
|
9
|
+
readCurrentNotebooklm,
|
|
10
|
+
requireNotebooklmSession,
|
|
11
|
+
} from './utils.js';
|
|
12
|
+
|
|
13
|
+
cli({
|
|
14
|
+
site: NOTEBOOKLM_SITE,
|
|
15
|
+
name: 'get',
|
|
16
|
+
aliases: ['metadata'],
|
|
17
|
+
description: 'Get rich metadata for the currently opened NotebookLM notebook',
|
|
18
|
+
domain: NOTEBOOKLM_DOMAIN,
|
|
19
|
+
strategy: Strategy.COOKIE,
|
|
20
|
+
browser: true,
|
|
21
|
+
navigateBefore: false,
|
|
22
|
+
args: [],
|
|
23
|
+
columns: ['id', 'title', 'emoji', 'source_count', 'created_at', 'updated_at', 'url', 'source'],
|
|
24
|
+
func: async (page: IPage) => {
|
|
25
|
+
await ensureNotebooklmNotebookBinding(page);
|
|
26
|
+
await requireNotebooklmSession(page);
|
|
27
|
+
const state = await getNotebooklmPageState(page);
|
|
28
|
+
if (state.kind !== 'notebook') {
|
|
29
|
+
throw new EmptyResultError(
|
|
30
|
+
'opencli notebooklm get',
|
|
31
|
+
'Open a specific NotebookLM notebook tab first, then retry.',
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const rpcRow = await getNotebooklmDetailViaRpc(page).catch(() => null);
|
|
36
|
+
if (rpcRow) return [rpcRow];
|
|
37
|
+
|
|
38
|
+
const current = await readCurrentNotebooklm(page);
|
|
39
|
+
if (!current) {
|
|
40
|
+
throw new EmptyResultError(
|
|
41
|
+
'opencli notebooklm get',
|
|
42
|
+
'NotebookLM notebook metadata was not found on the current page.',
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return [{
|
|
47
|
+
...current,
|
|
48
|
+
emoji: null,
|
|
49
|
+
source_count: null,
|
|
50
|
+
updated_at: null,
|
|
51
|
+
}];
|
|
52
|
+
},
|
|
53
|
+
});
|