@jackwener/opencli 0.4.2 → 0.4.4

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 (65) hide show
  1. package/{CLI-CREATOR.md → CLI-EXPLORER.md} +15 -11
  2. package/CLI-ONESHOT.md +216 -0
  3. package/LICENSE +28 -0
  4. package/README.md +114 -63
  5. package/README.zh-CN.md +115 -63
  6. package/SKILL.md +25 -6
  7. package/dist/browser.d.ts +53 -10
  8. package/dist/browser.js +491 -111
  9. package/dist/browser.test.d.ts +1 -0
  10. package/dist/browser.test.js +56 -0
  11. package/dist/build-manifest.js +4 -0
  12. package/dist/cli-manifest.json +279 -3
  13. package/dist/clis/boss/search.js +186 -30
  14. package/dist/clis/twitter/delete.d.ts +1 -0
  15. package/dist/clis/twitter/delete.js +73 -0
  16. package/dist/clis/twitter/followers.d.ts +1 -0
  17. package/dist/clis/twitter/followers.js +104 -0
  18. package/dist/clis/twitter/following.d.ts +1 -0
  19. package/dist/clis/twitter/following.js +90 -0
  20. package/dist/clis/twitter/like.d.ts +1 -0
  21. package/dist/clis/twitter/like.js +69 -0
  22. package/dist/clis/twitter/notifications.d.ts +1 -0
  23. package/dist/clis/twitter/notifications.js +109 -0
  24. package/dist/clis/twitter/post.d.ts +1 -0
  25. package/dist/clis/twitter/post.js +63 -0
  26. package/dist/clis/twitter/reply.d.ts +1 -0
  27. package/dist/clis/twitter/reply.js +57 -0
  28. package/dist/clis/v2ex/daily.d.ts +1 -0
  29. package/dist/clis/v2ex/daily.js +98 -0
  30. package/dist/clis/v2ex/me.d.ts +1 -0
  31. package/dist/clis/v2ex/me.js +99 -0
  32. package/dist/clis/v2ex/notifications.d.ts +1 -0
  33. package/dist/clis/v2ex/notifications.js +72 -0
  34. package/dist/doctor.d.ts +50 -0
  35. package/dist/doctor.js +372 -0
  36. package/dist/doctor.test.d.ts +1 -0
  37. package/dist/doctor.test.js +114 -0
  38. package/dist/main.js +47 -5
  39. package/dist/output.test.d.ts +1 -0
  40. package/dist/output.test.js +20 -0
  41. package/dist/registry.d.ts +4 -0
  42. package/dist/registry.js +1 -0
  43. package/dist/runtime.d.ts +3 -1
  44. package/dist/runtime.js +2 -2
  45. package/package.json +2 -2
  46. package/src/browser.test.ts +77 -0
  47. package/src/browser.ts +541 -99
  48. package/src/build-manifest.ts +4 -0
  49. package/src/clis/boss/search.ts +196 -29
  50. package/src/clis/twitter/delete.ts +78 -0
  51. package/src/clis/twitter/followers.ts +119 -0
  52. package/src/clis/twitter/following.ts +105 -0
  53. package/src/clis/twitter/like.ts +74 -0
  54. package/src/clis/twitter/notifications.ts +119 -0
  55. package/src/clis/twitter/post.ts +68 -0
  56. package/src/clis/twitter/reply.ts +62 -0
  57. package/src/clis/v2ex/daily.ts +105 -0
  58. package/src/clis/v2ex/me.ts +103 -0
  59. package/src/clis/v2ex/notifications.ts +77 -0
  60. package/src/doctor.test.ts +133 -0
  61. package/src/doctor.ts +424 -0
  62. package/src/main.ts +47 -4
  63. package/src/output.test.ts +27 -0
  64. package/src/registry.ts +5 -0
  65. package/src/runtime.ts +2 -1
@@ -0,0 +1,77 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { PlaywrightMCP, __test__ } from './browser.js';
3
+
4
+ describe('browser helpers', () => {
5
+ it('creates JSON-RPC requests with unique ids', () => {
6
+ const first = __test__.createJsonRpcRequest('tools/call', { name: 'browser_tabs' });
7
+ const second = __test__.createJsonRpcRequest('tools/call', { name: 'browser_snapshot' });
8
+
9
+ expect(second.id).toBe(first.id + 1);
10
+ expect(first.message).toContain(`"id":${first.id}`);
11
+ expect(second.message).toContain(`"id":${second.id}`);
12
+ });
13
+
14
+ it('extracts tab entries from string snapshots', () => {
15
+ const entries = __test__.extractTabEntries('Tab 0 https://example.com\nTab 1 Chrome Extension');
16
+
17
+ expect(entries).toEqual([
18
+ { index: 0, identity: 'https://example.com' },
19
+ { index: 1, identity: 'Chrome Extension' },
20
+ ]);
21
+ });
22
+
23
+ it('closes only tabs that were opened during the session', () => {
24
+ const tabsToClose = __test__.diffTabIndexes(
25
+ ['https://example.com', 'Chrome Extension'],
26
+ [
27
+ { index: 0, identity: 'https://example.com' },
28
+ { index: 1, identity: 'Chrome Extension' },
29
+ { index: 2, identity: 'https://target.example/page' },
30
+ { index: 3, identity: 'chrome-extension://bridge' },
31
+ ],
32
+ );
33
+
34
+ expect(tabsToClose).toEqual([3, 2]);
35
+ });
36
+
37
+ it('keeps only the tail of stderr buffers', () => {
38
+ expect(__test__.appendLimited('12345', '67890', 8)).toBe('34567890');
39
+ });
40
+
41
+ it('times out slow promises', async () => {
42
+ await expect(__test__.withTimeout(new Promise(() => {}), 10, 'timeout')).rejects.toThrow('timeout');
43
+ });
44
+ });
45
+
46
+ describe('PlaywrightMCP state', () => {
47
+ it('transitions to closed after close()', async () => {
48
+ const mcp = new PlaywrightMCP();
49
+
50
+ expect(mcp.state).toBe('idle');
51
+
52
+ await mcp.close();
53
+
54
+ expect(mcp.state).toBe('closed');
55
+ });
56
+
57
+ it('rejects connect() after the session has been closed', async () => {
58
+ const mcp = new PlaywrightMCP();
59
+ await mcp.close();
60
+
61
+ await expect(mcp.connect()).rejects.toThrow('Playwright MCP session is closed');
62
+ });
63
+
64
+ it('rejects connect() while already connecting', async () => {
65
+ const mcp = new PlaywrightMCP();
66
+ (mcp as any)._state = 'connecting';
67
+
68
+ await expect(mcp.connect()).rejects.toThrow('Playwright MCP is already connecting');
69
+ });
70
+
71
+ it('rejects connect() while closing', async () => {
72
+ const mcp = new PlaywrightMCP();
73
+ (mcp as any)._state = 'closing';
74
+
75
+ await expect(mcp.connect()).rejects.toThrow('Playwright MCP is closing');
76
+ });
77
+ });