feat(record): add live recording command for API capture#300
feat(record): add live recording command for API capture#300jackwener merged 2 commits intojackwener:mainfrom
Conversation
- Add `opencli record <url>` command that injects fetch/XHR interceptors into all tabs in the automation window, polls captured requests, and auto-generates YAML candidate adapters - Support multi-tab recording: new tabs discovered during polling are automatically injected - Add --timeout (default 60s) for agent-friendly non-blocking operation; stops on Enter, timeout, or SIGINT — whichever comes first - Fix idempotent re-injection: restores original fetch/XHR before re-patching so guard flag no longer blocks subsequent record runs - Add --poll interval option (default 2000ms) - Expand SKILL.md with full Record Workflow section: interceptor internals, page-type capture expectations, YAML→TS conversion guide, and troubleshooting table
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Really interesting concept — recording live API traffic to auto-generate adapters is a powerful complement to the existing SecurityCaptured data written to disk without redaction The interceptor captures all fetch/XHR responses and writes them verbatim to Interceptor Issuesfetch patch chain accumulation — If a page's XHR Existing CDP Mode Incompatibility
Generated YAML Issues
Cleanup & Robustness
Architecture
Tests573 lines of core infrastructure with zero test coverage. At minimum, the pure functions ( |
…hang & args interpolation
- XHR send(): add __rec_listener_added guard to prevent duplicate event
listeners when XHR is reused (abort → open → send)
- pathChain: when findArrayPath returns '' (root-level array), data access
is just 'data' not 'data?.' which was invalid JS syntax
- waitForEnter(): return cleanup fn so timeout path can close readline.Interface
preventing the process from hanging on stdin after auto-timeout
- buildRecordedYaml: replace search/page query param values with template
vars ({{args.keyword}}, {{args.page}}) so generated YAML actually uses
the declared args instead of hardcoding the recorded URL
|
感谢 @yee94 贡献 在合并前我直接在你的分支上做了几处 bug 修复:
再次感谢你的贡献! |
Summary
opencli record <url>command that injects fetch/XHR interceptors into all tabs in the automation window, polls captured requests every 2s, and auto-generates YAML candidate adapters--timeout(default 60s) for agent-friendly non-blocking operation; stops on Enter, timeout, or SIGINT — whichever comes firstrecordruns on the same tabSKILL.mdwith a full Record Workflow sectionNew options
Output