@jackwener/opencli 1.6.10 → 1.7.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.
Files changed (36) hide show
  1. package/README.md +15 -2
  2. package/README.zh-CN.md +15 -2
  3. package/dist/clis/jianyu/detail.js +20 -0
  4. package/dist/clis/jianyu/search.d.ts +41 -4
  5. package/dist/clis/jianyu/search.js +458 -96
  6. package/dist/clis/jianyu/search.test.js +105 -0
  7. package/dist/clis/jianyu/shared/china-bid-search.d.ts +12 -0
  8. package/dist/clis/jianyu/shared/china-bid-search.js +165 -0
  9. package/dist/clis/jianyu/shared/procurement-contract.d.ts +68 -0
  10. package/dist/clis/jianyu/shared/procurement-contract.js +324 -0
  11. package/dist/clis/jianyu/shared/procurement-contract.test.d.ts +1 -0
  12. package/dist/clis/jianyu/shared/procurement-contract.test.js +72 -0
  13. package/dist/clis/jianyu/shared/procurement-detail.d.ts +6 -0
  14. package/dist/clis/jianyu/shared/procurement-detail.js +92 -0
  15. package/dist/clis/jianyu/shared/procurement-detail.test.d.ts +1 -0
  16. package/dist/clis/jianyu/shared/procurement-detail.test.js +72 -0
  17. package/dist/clis/xiaoe/catalog.js +36 -0
  18. package/dist/src/browser/bridge.js +1 -1
  19. package/dist/src/browser/daemon-client.d.ts +2 -1
  20. package/dist/src/browser/daemon-client.js +3 -1
  21. package/dist/src/browser/daemon-client.test.js +0 -3
  22. package/dist/src/browser.test.js +0 -1
  23. package/dist/src/cli.js +1 -9
  24. package/dist/src/commands/daemon.d.ts +2 -6
  25. package/dist/src/commands/daemon.js +2 -58
  26. package/dist/src/commands/daemon.test.js +24 -120
  27. package/dist/src/constants.d.ts +0 -2
  28. package/dist/src/constants.js +0 -2
  29. package/dist/src/daemon.d.ts +1 -1
  30. package/dist/src/daemon.js +2 -15
  31. package/dist/src/execution.js +5 -1
  32. package/package.json +2 -1
  33. package/dist/src/daemon.test.js +0 -65
  34. package/dist/src/idle-manager.d.ts +0 -19
  35. package/dist/src/idle-manager.js +0 -54
  36. /package/dist/{src/daemon.test.d.ts → clis/jianyu/detail.d.ts} +0 -0
package/README.md CHANGED
@@ -57,7 +57,6 @@ OpenCLI connects to Chrome/Chromium through a lightweight Browser Bridge extensi
57
57
 
58
58
  ```bash
59
59
  opencli doctor
60
- opencli daemon status
61
60
  ```
62
61
 
63
62
  ### 4. Run your first commands
@@ -75,7 +74,7 @@ Use OpenCLI directly when you want a reliable command instead of a live browser
75
74
  - `opencli list` shows every registered command.
76
75
  - `opencli <site> <command>` runs a built-in or generated adapter.
77
76
  - `opencli register mycli` exposes a local CLI through the same discovery surface.
78
- - `opencli daemon status` and `opencli doctor` help diagnose browser connectivity.
77
+ - `opencli doctor` helps diagnose browser connectivity.
79
78
 
80
79
  ## For AI Agents
81
80
 
@@ -142,6 +141,20 @@ OpenCLI is not only for websites. It can also:
142
141
 
143
142
  > **Important**: Browser-backed commands reuse your Chrome/Chromium login session. If you get empty data or permission-like failures, first confirm the site is already open and authenticated in Chrome/Chromium.
144
143
 
144
+ ## Configuration
145
+
146
+ | Variable | Default | Description |
147
+ |----------|---------|-------------|
148
+ | `OPENCLI_DAEMON_PORT` | `19825` | HTTP port for the daemon-extension bridge |
149
+ | `OPENCLI_WINDOW_FOCUSED` | `false` | Set to `1` to open automation windows in the foreground (useful for debugging) |
150
+ | `OPENCLI_BROWSER_CONNECT_TIMEOUT` | `30` | Seconds to wait for browser connection |
151
+ | `OPENCLI_BROWSER_COMMAND_TIMEOUT` | `60` | Seconds to wait for a single browser command |
152
+ | `OPENCLI_BROWSER_EXPLORE_TIMEOUT` | `120` | Seconds to wait for explore/record operations |
153
+ | `OPENCLI_CDP_ENDPOINT` | — | Chrome DevTools Protocol endpoint for remote browser or Electron apps |
154
+ | `OPENCLI_CDP_TARGET` | — | Filter CDP targets by URL substring (e.g. `detail.1688.com`) |
155
+ | `OPENCLI_VERBOSE` | `false` | Enable verbose logging (`-v` flag also works) |
156
+ | `OPENCLI_DIAGNOSTIC` | `false` | Set to `1` to capture structured diagnostic context on failures |
157
+
145
158
  ## Update
146
159
 
147
160
  ```bash
package/README.zh-CN.md CHANGED
@@ -45,7 +45,6 @@ OpenCLI 通过轻量 Browser Bridge 扩展和本地微型 daemon 与 Chrome/Chro
45
45
 
46
46
  ```bash
47
47
  opencli doctor
48
- opencli daemon status
49
48
  ```
50
49
 
51
50
  ### 4. 跑第一个命令
@@ -63,7 +62,7 @@ opencli bilibili hot --limit 5
63
62
  - `opencli list` 查看当前所有命令
64
63
  - `opencli <site> <command>` 调用内置或生成好的适配器
65
64
  - `opencli register mycli` 把本地 CLI 接入同一发现入口
66
- - `opencli doctor` / `opencli daemon status` 处理浏览器连通性问题
65
+ - `opencli doctor` 处理浏览器连通性问题
67
66
 
68
67
  ## 给 AI Agent
69
68
 
@@ -130,6 +129,20 @@ OpenCLI 不只是网站 CLI,还可以:
130
129
 
131
130
  > **重要**:浏览器型命令直接复用你的 Chrome/Chromium 登录态。如果拿到空数据或出现权限类失败,先确认目标站点已经在浏览器里打开并完成登录。
132
131
 
132
+ ## 配置
133
+
134
+ | 变量 | 默认值 | 说明 |
135
+ |------|--------|------|
136
+ | `OPENCLI_DAEMON_PORT` | `19825` | daemon-extension 通信端口 |
137
+ | `OPENCLI_WINDOW_FOCUSED` | `false` | 设为 `1` 时 automation 窗口在前台打开(适合调试) |
138
+ | `OPENCLI_BROWSER_CONNECT_TIMEOUT` | `30` | 浏览器连接超时(秒) |
139
+ | `OPENCLI_BROWSER_COMMAND_TIMEOUT` | `60` | 单个浏览器命令超时(秒) |
140
+ | `OPENCLI_BROWSER_EXPLORE_TIMEOUT` | `120` | explore/record 操作超时(秒) |
141
+ | `OPENCLI_CDP_ENDPOINT` | — | Chrome DevTools Protocol 端点,用于远程浏览器或 Electron 应用 |
142
+ | `OPENCLI_CDP_TARGET` | — | 按 URL 子串过滤 CDP target(如 `detail.1688.com`) |
143
+ | `OPENCLI_VERBOSE` | `false` | 启用详细日志(`-v` 也可以) |
144
+ | `OPENCLI_DIAGNOSTIC` | `false` | 设为 `1` 时在失败时输出结构化诊断上下文 |
145
+
133
146
  ## 更新
134
147
 
135
148
  ```bash
@@ -0,0 +1,20 @@
1
+ import { cli, Strategy } from '@jackwener/opencli/registry';
2
+ import { runProcurementDetail } from './shared/procurement-detail.js';
3
+ cli({
4
+ site: 'jianyu',
5
+ name: 'detail',
6
+ description: '读取剑鱼标讯详情页并抽取证据字段',
7
+ domain: 'www.jianyu360.cn',
8
+ strategy: Strategy.COOKIE,
9
+ browser: true,
10
+ args: [
11
+ { name: 'url', required: true, positional: true, help: 'Detail page URL from jianyu/search' },
12
+ { name: 'query', help: 'Optional query for evidence ranking' },
13
+ ],
14
+ columns: ['title', 'publish_time', 'content_type', 'project_code', 'budget_or_limit', 'deadline_or_open_time', 'url'],
15
+ func: async (page, kwargs) => runProcurementDetail(page, {
16
+ url: kwargs.url,
17
+ query: kwargs.query,
18
+ site: 'jianyu',
19
+ }),
20
+ });
@@ -1,14 +1,51 @@
1
- interface JianyuCandidate {
1
+ import { dedupeCandidates, normalizeDate } from './shared/china-bid-search.js';
2
+ interface JianyuSearchRow {
2
3
  title: string;
3
4
  url: string;
4
- date: string;
5
+ date?: string;
6
+ contextText?: string;
5
7
  }
6
8
  export declare function buildSearchUrl(query: string): string;
7
- export declare function normalizeDate(raw: string): string;
8
- declare function dedupeCandidates(items: JianyuCandidate[]): JianyuCandidate[];
9
+ declare function siteSearchCandidates(query: string): string[];
10
+ declare function filterNavigationRows(query: string, items: Array<{
11
+ title?: string;
12
+ url?: string;
13
+ date?: string;
14
+ contextText?: string;
15
+ }>): Array<{
16
+ title: string;
17
+ url: string;
18
+ date?: string;
19
+ contextText?: string;
20
+ }>;
21
+ declare function extractDateFromJianyuUrl(rawUrl: string): string;
22
+ declare function normalizeApiRow(item: unknown): {
23
+ title: string;
24
+ url: string;
25
+ date?: string;
26
+ contextText?: string;
27
+ } | null;
28
+ declare function parseSearchIndexMarkdown(markdown: string): Array<{
29
+ title: string;
30
+ url: string;
31
+ }>;
32
+ declare function unwrapDuckDuckGoUrl(rawUrl: string): string;
33
+ declare function fetchJianyuApiRows(page: any, query: string, limit: number): Promise<{
34
+ rows: JianyuSearchRow[];
35
+ challenge: boolean;
36
+ }>;
37
+ declare function collectApiRowsFromResponses(responses: unknown[]): JianyuSearchRow[];
9
38
  export declare const __test__: {
39
+ buildSearchCandidates: typeof siteSearchCandidates;
10
40
  buildSearchUrl: typeof buildSearchUrl;
11
41
  normalizeDate: typeof normalizeDate;
12
42
  dedupeCandidates: typeof dedupeCandidates;
43
+ filterNavigationRows: typeof filterNavigationRows;
44
+ parseSearchIndexMarkdown: typeof parseSearchIndexMarkdown;
45
+ unwrapDuckDuckGoUrl: typeof unwrapDuckDuckGoUrl;
46
+ extractDateFromJianyuUrl: typeof extractDateFromJianyuUrl;
47
+ normalizeApiRow: typeof normalizeApiRow;
48
+ fetchJianyuApiRows: typeof fetchJianyuApiRows;
49
+ collectApiRowsFromResponses: typeof collectApiRowsFromResponses;
13
50
  };
14
51
  export {};