@jackwener/opencli 1.7.15 → 1.7.16

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.
Files changed (94) hide show
  1. package/README.md +9 -6
  2. package/README.zh-CN.md +9 -6
  3. package/cli-manifest.json +161 -31
  4. package/clis/chatgpt/ask.js +2 -1
  5. package/clis/chatgpt/detail.js +6 -1
  6. package/clis/chatgpt/read.js +2 -1
  7. package/clis/chatgpt/send.js +2 -1
  8. package/clis/chatgpt/utils.js +54 -12
  9. package/clis/chatgpt/utils.test.js +36 -1
  10. package/clis/claude/ask.js +22 -7
  11. package/clis/claude/detail.js +9 -2
  12. package/clis/claude/new.js +8 -2
  13. package/clis/claude/read.js +2 -1
  14. package/clis/claude/send.js +8 -3
  15. package/clis/claude/utils.js +27 -4
  16. package/clis/deepseek/ask.js +21 -8
  17. package/clis/deepseek/detail.js +9 -1
  18. package/clis/deepseek/new.js +13 -2
  19. package/clis/deepseek/read.js +2 -1
  20. package/clis/deepseek/utils.js +8 -1
  21. package/clis/linkedin/search.js +8 -11
  22. package/clis/maimai/search-talents.js +10 -6
  23. package/clis/openreview/author.js +58 -0
  24. package/clis/openreview/openreview.test.js +83 -1
  25. package/clis/openreview/utils.js +14 -0
  26. package/clis/reddit/comment.js +1 -0
  27. package/clis/reddit/frontpage.js +1 -0
  28. package/clis/reddit/popular.js +1 -0
  29. package/clis/reddit/read.js +2 -0
  30. package/clis/reddit/read.test.js +4 -0
  31. package/clis/reddit/save.js +1 -0
  32. package/clis/reddit/saved.js +1 -0
  33. package/clis/reddit/search.js +1 -0
  34. package/clis/reddit/subreddit.js +1 -0
  35. package/clis/reddit/subscribe.js +1 -0
  36. package/clis/reddit/upvote.js +1 -0
  37. package/clis/reddit/upvoted.js +1 -0
  38. package/clis/reddit/user-comments.js +1 -0
  39. package/clis/reddit/user-posts.js +1 -0
  40. package/clis/reddit/user.js +1 -0
  41. package/clis/twitter/article.js +7 -4
  42. package/clis/twitter/bookmark-folder.js +3 -5
  43. package/clis/twitter/bookmark-folder.test.js +5 -2
  44. package/clis/twitter/bookmark-folders.js +3 -5
  45. package/clis/twitter/bookmark-folders.test.js +3 -1
  46. package/clis/twitter/bookmarks.js +3 -5
  47. package/clis/twitter/download.js +1 -0
  48. package/clis/twitter/followers.js +1 -0
  49. package/clis/twitter/following.js +3 -6
  50. package/clis/twitter/following.test.js +2 -1
  51. package/clis/twitter/likes.js +3 -5
  52. package/clis/twitter/list-add.js +4 -3
  53. package/clis/twitter/list-add.test.js +23 -1
  54. package/clis/twitter/list-remove.js +4 -3
  55. package/clis/twitter/list-remove.test.js +23 -1
  56. package/clis/twitter/list-tweets.js +3 -5
  57. package/clis/twitter/lists.js +3 -5
  58. package/clis/twitter/notifications.js +1 -0
  59. package/clis/twitter/profile.js +7 -4
  60. package/clis/twitter/search.js +1 -0
  61. package/clis/twitter/thread.js +5 -7
  62. package/clis/twitter/timeline.js +5 -7
  63. package/clis/twitter/trending.js +4 -4
  64. package/clis/twitter/tweets.js +3 -6
  65. package/clis/youtube/like.js +6 -2
  66. package/clis/youtube/subscribe.js +6 -2
  67. package/clis/youtube/unlike.js +6 -2
  68. package/clis/youtube/unsubscribe.js +6 -2
  69. package/clis/youtube/utils.js +19 -13
  70. package/clis/youtube/utils.test.js +17 -1
  71. package/dist/src/browser/bridge.d.ts +1 -0
  72. package/dist/src/browser/bridge.js +1 -1
  73. package/dist/src/browser/cdp.d.ts +1 -0
  74. package/dist/src/browser/daemon-client.d.ts +2 -2
  75. package/dist/src/browser/daemon-client.js +6 -3
  76. package/dist/src/browser/daemon-client.test.js +10 -0
  77. package/dist/src/browser/page.d.ts +2 -1
  78. package/dist/src/browser/page.js +5 -1
  79. package/dist/src/cli.js +70 -2
  80. package/dist/src/cli.test.js +139 -7
  81. package/dist/src/commanderAdapter.js +7 -0
  82. package/dist/src/doctor.js +2 -2
  83. package/dist/src/doctor.test.js +4 -4
  84. package/dist/src/execution.d.ts +2 -0
  85. package/dist/src/execution.js +31 -6
  86. package/dist/src/execution.test.js +43 -16
  87. package/dist/src/external-clis.yaml +24 -0
  88. package/dist/src/help.d.ts +1 -0
  89. package/dist/src/help.js +29 -0
  90. package/dist/src/main.js +4 -14
  91. package/dist/src/runtime.d.ts +3 -0
  92. package/dist/src/runtime.js +1 -0
  93. package/dist/src/types.d.ts +1 -1
  94. package/package.json +1 -1
package/dist/src/help.js CHANGED
@@ -28,6 +28,20 @@ const COMMON_OPTIONS = [
28
28
  help: 'display help for command',
29
29
  },
30
30
  ];
31
+ const BROWSER_COMMON_OPTIONS = [
32
+ {
33
+ flags: '--window <mode>',
34
+ name: 'window',
35
+ help: 'Browser window mode: foreground or background',
36
+ choices: ['foreground', 'background'],
37
+ },
38
+ {
39
+ flags: '--keep-tab <bool>',
40
+ name: 'keep-tab',
41
+ help: 'Keep the browser tab lease after the command finishes',
42
+ choices: ['true', 'false'],
43
+ },
44
+ ];
31
45
  function normalizeStructuredHelpFormat(value) {
32
46
  const normalized = value?.toLowerCase();
33
47
  if (normalized === 'yaml' || normalized === 'yml')
@@ -307,6 +321,7 @@ function compactCommand(cmd) {
307
321
  ...(cmd.aliases?.length ? { aliases: cmd.aliases } : {}),
308
322
  positionals: positionals(cmd).map(compactArg),
309
323
  command_options: commandOptions(cmd).map(compactArg),
324
+ ...(cmd.browser ? { browser_common_options: BROWSER_COMMON_OPTIONS.map(compactCommonOption) } : {}),
310
325
  example: formatCommandExample(cmd),
311
326
  ...(cmd.browserSession ? { browserSession: cmd.browserSession } : {}),
312
327
  ...(cmd.defaultFormat ? { defaultFormat: cmd.defaultFormat } : {}),
@@ -353,6 +368,7 @@ export function siteHelpData(site, commands) {
353
368
  command_count: unique.length,
354
369
  commands: unique.map(cmd => compactCommand(cmd)),
355
370
  common_options: COMMON_OPTIONS.map(compactCommonOption),
371
+ ...(unique.some(cmd => cmd.browser) ? { browser_common_options: BROWSER_COMMON_OPTIONS.map(compactCommonOption) } : {}),
356
372
  next: [
357
373
  `opencli ${site} <command> --help -f yaml`,
358
374
  `opencli ${site} <command> -f yaml`,
@@ -364,6 +380,7 @@ export function commandHelpData(cmd) {
364
380
  site: cmd.site,
365
381
  ...compactCommand(cmd),
366
382
  common_options: COMMON_OPTIONS.map(compactCommonOption),
383
+ ...(cmd.browser ? { browser_common_options: BROWSER_COMMON_OPTIONS.map(compactCommonOption) } : {}),
367
384
  output_formats: ['table', 'plain', 'yaml', 'json', 'md', 'csv'],
368
385
  };
369
386
  }
@@ -394,6 +411,15 @@ export function formatCommonOptionsHelpText() {
394
411
  });
395
412
  return ['Common options:', ...formatRows(rows)].join('\n');
396
413
  }
414
+ export function formatBrowserCommonOptionsHelpText() {
415
+ const rows = BROWSER_COMMON_OPTIONS.map(option => {
416
+ const details = [option.help];
417
+ if ('choices' in option)
418
+ details.push(`choices: ${option.choices.join(', ')}`);
419
+ return [option.flags, details.join(' ')];
420
+ });
421
+ return ['Browser common options:', ...formatRows(rows)].join('\n');
422
+ }
397
423
  export function formatSiteHelpText(site, commands) {
398
424
  const unique = [...new Map(commands.map(cmd => [fullName(cmd), cmd])).values()]
399
425
  .sort((a, b) => a.name.localeCompare(b.name));
@@ -406,6 +432,7 @@ export function formatSiteHelpText(site, commands) {
406
432
  ...formatRows(unique.map(cmd => [formatCommandListTerm(cmd), formatSiteCommandDescription(cmd)])),
407
433
  '',
408
434
  formatCommonOptionsHelpText(),
435
+ ...(unique.some(cmd => cmd.browser) ? ['', formatBrowserCommonOptionsHelpText()] : []),
409
436
  '',
410
437
  `Agent tip: use 'opencli ${site} --help -f yaml' to get all command args/options in one structured response.`,
411
438
  '',
@@ -434,6 +461,8 @@ export function formatCommandHelpText(cmd) {
434
461
  lines.push('Command options:', ...formatRows(optionRows), '');
435
462
  }
436
463
  lines.push(formatCommonOptionsHelpText(), '');
464
+ if (cmd.browser)
465
+ lines.push(formatBrowserCommonOptionsHelpText(), '');
437
466
  const meta = [];
438
467
  meta.push(`Access: ${cmd.access}`);
439
468
  meta.push(`Browser: ${cmd.browser ? 'yes' : 'no'}`);
package/dist/src/main.js CHANGED
@@ -27,21 +27,11 @@ const __dirname = path.dirname(__filename);
27
27
  // Use findPackageRoot so the path works both in dev (src/main.ts) and prod (dist/src/main.js).
28
28
  const BUILTIN_CLIS = path.join(findPackageRoot(__filename), 'clis');
29
29
  const USER_CLIS = path.join(os.homedir(), '.opencli', 'clis');
30
- // ── Session lifecycle flags ──────────────────────────────────────────────
31
- // `--live` / `--focus` / `--reuse` are top-level-ish toggles that tweak the automation
32
- // window's lifecycle. We strip them from argv before Commander runs so they
33
- // can be placed anywhere and work on any subcommand (adapter or browser).
30
+ // ── Browser reuse flag ───────────────────────────────────────────────────
31
+ // `--reuse` is a runtime-level browser session override rather than an adapter
32
+ // arg. Strip it before Commander runs and expose it through an explicit env
33
+ // name. Window/keep-tab are registered on browser-backed commands directly.
34
34
  {
35
- const liveIdx = process.argv.indexOf('--live');
36
- if (liveIdx !== -1) {
37
- process.env.OPENCLI_LIVE = '1';
38
- process.argv.splice(liveIdx, 1);
39
- }
40
- const focusIdx = process.argv.indexOf('--focus');
41
- if (focusIdx !== -1) {
42
- process.env.OPENCLI_WINDOW_FOCUSED = '1';
43
- process.argv.splice(focusIdx, 1);
44
- }
45
35
  const reuseIdx = process.argv.findIndex(arg => arg === '--reuse' || arg.startsWith('--reuse='));
46
36
  if (reuseIdx !== -1) {
47
37
  const arg = process.argv[reuseIdx];
@@ -6,6 +6,7 @@ import type { IPage } from './types.js';
6
6
  export declare function getBrowserFactory(site?: string): new () => IBrowserFactory;
7
7
  export declare const DEFAULT_BROWSER_CONNECT_TIMEOUT: number;
8
8
  export declare const DEFAULT_BROWSER_COMMAND_TIMEOUT: number;
9
+ export type BrowserWindowMode = 'foreground' | 'background';
9
10
  /**
10
11
  * Timeout with seconds unit. Used for high-level command timeouts.
11
12
  */
@@ -28,6 +29,7 @@ export interface IBrowserFactory {
28
29
  cdpEndpoint?: string;
29
30
  contextId?: string;
30
31
  idleTimeout?: number;
32
+ windowMode?: BrowserWindowMode;
31
33
  }): Promise<IPage>;
32
34
  close(): Promise<void>;
33
35
  }
@@ -36,4 +38,5 @@ export declare function browserSession<T>(BrowserFactory: new () => IBrowserFact
36
38
  cdpEndpoint?: string;
37
39
  contextId?: string;
38
40
  idleTimeout?: number;
41
+ windowMode?: BrowserWindowMode;
39
42
  }): Promise<T>;
@@ -54,6 +54,7 @@ export async function browserSession(BrowserFactory, fn, opts = {}) {
54
54
  cdpEndpoint: opts.cdpEndpoint,
55
55
  contextId: opts.contextId,
56
56
  idleTimeout: opts.idleTimeout,
57
+ windowMode: opts.windowMode,
57
58
  });
58
59
  return await fn(page);
59
60
  }
@@ -68,7 +68,7 @@ export interface BrowserSessionInfo {
68
68
  owned?: boolean;
69
69
  ownership?: 'owned' | 'borrowed';
70
70
  lifecycle?: 'ephemeral' | 'persistent' | 'pinned';
71
- surface?: 'dedicated-container' | 'borrowed-user-tab';
71
+ windowRole?: 'interactive' | 'automation' | 'borrowed-user';
72
72
  contextId?: string;
73
73
  tabCount?: number;
74
74
  idleMsRemaining?: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackwener/opencli",
3
- "version": "1.7.15",
3
+ "version": "1.7.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },