leniu-dev 2.0.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.
- package/.claude/agents/auto-test-generator.md +315 -0
- package/.claude/agents/bug-analyzer.md +103 -0
- package/.claude/agents/code-reviewer.md +122 -0
- package/.claude/agents/code-scanner.md +145 -0
- package/.claude/agents/image-reader.md +154 -0
- package/.claude/agents/loki-runner.md +80 -0
- package/.claude/agents/mysql-runner.md +81 -0
- package/.claude/agents/project-manager.md +159 -0
- package/.claude/agents/requirements-analyzer.md +175 -0
- package/.claude/agents/task-fetcher.md +75 -0
- package/.claude/audio/completed.wav +0 -0
- package/.claude/commands/add-todo.md +255 -0
- package/.claude/commands/auto-test.md +252 -0
- package/.claude/commands/check.md +210 -0
- package/.claude/commands/crud.md +454 -0
- package/.claude/commands/dev.md +532 -0
- package/.claude/commands/init-config.md +154 -0
- package/.claude/commands/init-docs.md +681 -0
- package/.claude/commands/next.md +281 -0
- package/.claude/commands/opsx-apply.md +147 -0
- package/.claude/commands/opsx-archive.md +105 -0
- package/.claude/commands/opsx-bulk-archive.md +237 -0
- package/.claude/commands/opsx-continue.md +109 -0
- package/.claude/commands/opsx-explore.md +281 -0
- package/.claude/commands/opsx-ff.md +92 -0
- package/.claude/commands/opsx-new.md +65 -0
- package/.claude/commands/opsx-onboard.md +397 -0
- package/.claude/commands/opsx-sync.md +129 -0
- package/.claude/commands/opsx-verify.md +159 -0
- package/.claude/commands/progress.md +264 -0
- package/.claude/commands/release.md +109 -0
- package/.claude/commands/start.md +199 -0
- package/.claude/commands/sync.md +307 -0
- package/.claude/commands/update-status.md +428 -0
- package/.claude/docs/Mixin/344/275/277/347/224/250/346/214/207/345/215/227.md +299 -0
- package/.claude/docs/README.md +167 -0
- package/.claude/docs//345/211/215/347/253/257/345/274/200/345/217/221/346/214/207/345/215/227.md +599 -0
- package/.claude/docs//345/220/216/347/253/257/345/274/200/345/217/221/346/214/207/345/215/227.md +726 -0
- package/.claude/docs//345/267/245/344/275/234/346/265/201/345/274/200/345/217/221/346/214/207/345/215/227.md +714 -0
- package/.claude/docs//345/267/245/345/205/267/347/261/273/344/275/277/347/224/250/346/214/207/345/215/227.md +463 -0
- package/.claude/docs//346/225/260/346/215/256/345/272/223/350/256/276/350/256/241/350/247/204/350/214/203.md +390 -0
- package/.claude/docs//346/226/260/345/212/237/350/203/275/345/274/200/345/217/221/346/265/201/347/250/213/350/247/204/350/214/203.md +688 -0
- package/.claude/docs//346/226/260/351/241/271/347/233/256/345/274/200/345/217/221/346/265/201/347/250/213.md +365 -0
- package/.claude/docs//346/241/206/346/236/266/350/257/264/346/230/216.md +393 -0
- package/.claude/docs//350/267/257/347/224/261/351/205/215/347/275/256/346/214/207/345/215/227.md +246 -0
- package/.claude/framework-config.json +73 -0
- package/.claude/hooks/lib/notify.js +310 -0
- package/.claude/hooks/pre-tool-use.js +117 -0
- package/.claude/hooks/skill-forced-eval.js +161 -0
- package/.claude/hooks/stop.js +55 -0
- package/.claude/notify-config.json +9 -0
- package/.claude/settings.json +57 -0
- package/.claude/skills/add-skill/SKILL.md +488 -0
- package/.claude/skills/analyze-requirements/SKILL.md +112 -0
- package/.claude/skills/api-development/SKILL.md +315 -0
- package/.claude/skills/architecture-design/SKILL.md +152 -0
- package/.claude/skills/auto-test/SKILL.md +625 -0
- package/.claude/skills/auto-test/references/api-conventions.md +260 -0
- package/.claude/skills/backend-annotations/SKILL.md +248 -0
- package/.claude/skills/banana-image/CHANGELOG.md +37 -0
- package/.claude/skills/banana-image/README.md +146 -0
- package/.claude/skills/banana-image/SKILL.md +171 -0
- package/.claude/skills/banana-image/assets/logo.png +0 -0
- package/.claude/skills/banana-image/references/advanced-usage.md +189 -0
- package/.claude/skills/banana-image/scripts/apply_template.py +125 -0
- package/.claude/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.claude/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.claude/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.claude/skills/banana-image/scripts/package.json +18 -0
- package/.claude/skills/banana-image/scripts/requirements.txt +10 -0
- package/.claude/skills/banana-image/templates/poster.json +22 -0
- package/.claude/skills/banana-image/templates/product.json +17 -0
- package/.claude/skills/banana-image/templates/social.json +22 -0
- package/.claude/skills/banana-image/templates/thumbnail.json +17 -0
- package/.claude/skills/brainstorm/SKILL.md +216 -0
- package/.claude/skills/bug-detective/SKILL.md +295 -0
- package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
- package/.claude/skills/chrome-cdp/SKILL.md +81 -0
- package/.claude/skills/chrome-cdp/scripts/cdp.mjs +838 -0
- package/.claude/skills/chrome-cdp/scripts/run-cdp.sh +7 -0
- package/.claude/skills/code-patterns/SKILL.md +163 -0
- package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.claude/skills/codex-code-review/SKILL.md +327 -0
- package/.claude/skills/collaborating-with-codex/SKILL.md +180 -0
- package/.claude/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.claude/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.claude/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.claude/skills/crud-development/SKILL.md +328 -0
- package/.claude/skills/data-permission/SKILL.md +221 -0
- package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.claude/skills/database-ops/SKILL.md +210 -0
- package/.claude/skills/error-handler/SKILL.md +310 -0
- package/.claude/skills/file-oss-management/SKILL.md +260 -0
- package/.claude/skills/file-oss-management/references/entities.md +105 -0
- package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
- package/.claude/skills/fix-bug/SKILL.md +269 -0
- package/.claude/skills/git-workflow/SKILL.md +179 -0
- package/.claude/skills/jenkins-deploy/SKILL.md +134 -0
- package/.claude/skills/jenkins-deploy/assets/env_param.template.json +51 -0
- package/.claude/skills/jenkins-deploy/assets/jk_build.py +400 -0
- package/.claude/skills/json-serialization/SKILL.md +341 -0
- package/.claude/skills/lanhu-design/SKILL.md +99 -0
- package/.claude/skills/leniu-api-development/SKILL.md +319 -0
- package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +383 -0
- package/.claude/skills/leniu-backend-annotations/SKILL.md +277 -0
- package/.claude/skills/leniu-brainstorm/SKILL.md +242 -0
- package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.claude/skills/leniu-code-patterns/SKILL.md +411 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +404 -0
- package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
- package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +341 -0
- package/.claude/skills/leniu-database-ops/SKILL.md +426 -0
- package/.claude/skills/leniu-error-handler/SKILL.md +462 -0
- package/.claude/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +237 -0
- package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
- package/.claude/skills/leniu-java-logging/SKILL.md +229 -0
- package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.claude/skills/leniu-java-mq/SKILL.md +338 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +267 -0
- package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.claude/skills/leniu-java-task/SKILL.md +367 -0
- package/.claude/skills/leniu-marketing-scenario/SKILL.md +448 -0
- package/.claude/skills/leniu-marketing-scenario/references/pay-meal-rules.md +197 -0
- package/.claude/skills/leniu-marketing-scenario/references/price-rules.md +286 -0
- package/.claude/skills/leniu-marketing-scenario/references/recharge-rules.md +188 -0
- package/.claude/skills/leniu-redis-cache/SKILL.md +331 -0
- package/.claude/skills/leniu-report-scenario/SKILL.md +508 -0
- package/.claude/skills/leniu-report-scenario/references/amount-handling.md +448 -0
- package/.claude/skills/leniu-report-scenario/references/analysis-module.md +64 -0
- package/.claude/skills/leniu-report-scenario/references/customization-table-fields.md +93 -0
- package/.claude/skills/leniu-report-scenario/references/customization.md +356 -0
- package/.claude/skills/leniu-report-scenario/references/data-permission.md +182 -0
- package/.claude/skills/leniu-report-scenario/references/export.md +553 -0
- package/.claude/skills/leniu-report-scenario/references/mealtime.md +197 -0
- package/.claude/skills/leniu-report-scenario/references/query-param.md +274 -0
- package/.claude/skills/leniu-report-scenario/references/report-tables.md +162 -0
- package/.claude/skills/leniu-report-scenario/references/standard-customization.md +112 -0
- package/.claude/skills/leniu-report-scenario/references/standard-table-fields.md +113 -0
- package/.claude/skills/leniu-report-scenario/references/total-line.md +179 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +306 -0
- package/.claude/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/.claude/skills/loki-log-query/SKILL.md +430 -0
- package/.claude/skills/mysql-debug/SKILL.md +406 -0
- package/.claude/skills/performance-doctor/SKILL.md +297 -0
- package/.claude/skills/project-navigator/SKILL.md +211 -0
- package/.claude/skills/redis-cache/SKILL.md +282 -0
- package/.claude/skills/redis-cache/references/listeners.md +23 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +277 -0
- package/.claude/skills/security-guard/SKILL.md +245 -0
- package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
- package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.claude/skills/sms-mail/SKILL.md +346 -0
- package/.claude/skills/sms-mail/references/mail-config.md +88 -0
- package/.claude/skills/sms-mail/references/sms-config.md +74 -0
- package/.claude/skills/social-login/SKILL.md +328 -0
- package/.claude/skills/social-login/references/provider-configs.md +118 -0
- package/.claude/skills/store-pc/SKILL.md +366 -0
- package/.claude/skills/sync-back-merge/SKILL.md +66 -0
- package/.claude/skills/task-tracker/SKILL.md +307 -0
- package/.claude/skills/tech-decision/SKILL.md +393 -0
- package/.claude/skills/tenant-management/SKILL.md +272 -0
- package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.claude/skills/test-development/SKILL.md +301 -0
- package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
- package/.claude/skills/ui-pc/SKILL.md +438 -0
- package/.claude/skills/utils-toolkit/SKILL.md +354 -0
- package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.claude/skills/websocket-sse/SKILL.md +350 -0
- package/.claude/skills/workflow-engine/SKILL.md +249 -0
- package/.claude/skills/yunxiao-task-management/SKILL.md +401 -0
- package/.claude/skills/yunxiao-task-management/templates//346/217/220/346/265/213/345/215/225/346/250/241/346/235/277.html +17 -0
- package/.claude/templates/env-config.md +27 -0
- package/.claude/templates//345/276/205/345/212/236/346/270/205/345/215/225/346/250/241/346/235/277.md +56 -0
- package/.claude/templates//351/234/200/346/261/202/346/226/207/346/241/243/346/250/241/346/235/277.md +85 -0
- package/.claude/templates//351/241/271/347/233/256/347/212/266/346/200/201/346/250/241/346/235/277.md +43 -0
- package/.codex/skills/add-skill/SKILL.md +488 -0
- package/.codex/skills/add-todo/SKILL.md +269 -0
- package/.codex/skills/analyze-requirements/SKILL.md +112 -0
- package/.codex/skills/api-development/SKILL.md +315 -0
- package/.codex/skills/architecture-design/SKILL.md +152 -0
- package/.codex/skills/auto-test/SKILL.md +453 -0
- package/.codex/skills/auto-test/references/api-conventions.md +260 -0
- package/.codex/skills/backend-annotations/SKILL.md +248 -0
- package/.codex/skills/banana-image/CHANGELOG.md +37 -0
- package/.codex/skills/banana-image/README.md +146 -0
- package/.codex/skills/banana-image/SKILL.md +171 -0
- package/.codex/skills/banana-image/assets/logo.png +0 -0
- package/.codex/skills/banana-image/references/advanced-usage.md +189 -0
- package/.codex/skills/banana-image/scripts/apply_template.py +125 -0
- package/.codex/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.codex/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.codex/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.codex/skills/banana-image/scripts/package.json +18 -0
- package/.codex/skills/banana-image/scripts/requirements.txt +10 -0
- package/.codex/skills/banana-image/templates/poster.json +22 -0
- package/.codex/skills/banana-image/templates/product.json +17 -0
- package/.codex/skills/banana-image/templates/social.json +22 -0
- package/.codex/skills/banana-image/templates/thumbnail.json +17 -0
- package/.codex/skills/brainstorm/SKILL.md +216 -0
- package/.codex/skills/bug-detective/SKILL.md +295 -0
- package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
- package/.codex/skills/check/SKILL.md +367 -0
- package/.codex/skills/code-patterns/SKILL.md +163 -0
- package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.codex/skills/collaborating-with-codex/SKILL.md +180 -0
- package/.codex/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.codex/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.codex/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.codex/skills/crud/SKILL.md +265 -0
- package/.codex/skills/crud-development/SKILL.md +328 -0
- package/.codex/skills/data-permission/SKILL.md +221 -0
- package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.codex/skills/database-ops/SKILL.md +210 -0
- package/.codex/skills/dev/SKILL.md +187 -0
- package/.codex/skills/error-handler/SKILL.md +310 -0
- package/.codex/skills/file-oss-management/SKILL.md +260 -0
- package/.codex/skills/file-oss-management/references/entities.md +105 -0
- package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
- package/.codex/skills/fix-bug/SKILL.md +269 -0
- package/.codex/skills/git-workflow/SKILL.md +179 -0
- package/.codex/skills/init-docs/SKILL.md +194 -0
- package/.codex/skills/jenkins-deploy/SKILL.md +134 -0
- package/.codex/skills/json-serialization/SKILL.md +341 -0
- package/.codex/skills/lanhu-design/SKILL.md +99 -0
- package/.codex/skills/leniu-api-development/SKILL.md +319 -0
- package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +383 -0
- package/.codex/skills/leniu-backend-annotations/SKILL.md +277 -0
- package/.codex/skills/leniu-brainstorm/SKILL.md +242 -0
- package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.codex/skills/leniu-code-patterns/SKILL.md +411 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +404 -0
- package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
- package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +341 -0
- package/.codex/skills/leniu-database-ops/SKILL.md +426 -0
- package/.codex/skills/leniu-error-handler/SKILL.md +462 -0
- package/.codex/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +237 -0
- package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
- package/.codex/skills/leniu-java-logging/SKILL.md +229 -0
- package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.codex/skills/leniu-java-mq/SKILL.md +338 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +267 -0
- package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.codex/skills/leniu-java-task/SKILL.md +367 -0
- package/.codex/skills/leniu-marketing-scenario/SKILL.md +448 -0
- package/.codex/skills/leniu-marketing-scenario/references/pay-meal-rules.md +197 -0
- package/.codex/skills/leniu-marketing-scenario/references/price-rules.md +286 -0
- package/.codex/skills/leniu-marketing-scenario/references/recharge-rules.md +188 -0
- package/.codex/skills/leniu-redis-cache/SKILL.md +331 -0
- package/.codex/skills/leniu-report-scenario/SKILL.md +508 -0
- package/.codex/skills/leniu-report-scenario/references/amount-handling.md +448 -0
- package/.codex/skills/leniu-report-scenario/references/analysis-module.md +64 -0
- package/.codex/skills/leniu-report-scenario/references/customization-table-fields.md +93 -0
- package/.codex/skills/leniu-report-scenario/references/customization.md +356 -0
- package/.codex/skills/leniu-report-scenario/references/data-permission.md +182 -0
- package/.codex/skills/leniu-report-scenario/references/export.md +553 -0
- package/.codex/skills/leniu-report-scenario/references/mealtime.md +197 -0
- package/.codex/skills/leniu-report-scenario/references/query-param.md +274 -0
- package/.codex/skills/leniu-report-scenario/references/report-tables.md +162 -0
- package/.codex/skills/leniu-report-scenario/references/standard-customization.md +112 -0
- package/.codex/skills/leniu-report-scenario/references/standard-table-fields.md +113 -0
- package/.codex/skills/leniu-report-scenario/references/total-line.md +179 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +306 -0
- package/.codex/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/.codex/skills/loki-log-query/SKILL.md +430 -0
- package/.codex/skills/loki-log-query/environments.json +45 -0
- package/.codex/skills/mysql-debug/SKILL.md +406 -0
- package/.codex/skills/next/SKILL.md +137 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +165 -0
- package/.codex/skills/openspec-archive-change/SKILL.md +122 -0
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +254 -0
- package/.codex/skills/openspec-continue-change/SKILL.md +126 -0
- package/.codex/skills/openspec-explore/SKILL.md +299 -0
- package/.codex/skills/openspec-ff-change/SKILL.md +109 -0
- package/.codex/skills/openspec-new-change/SKILL.md +82 -0
- package/.codex/skills/openspec-onboard/SKILL.md +414 -0
- package/.codex/skills/openspec-sync-specs/SKILL.md +146 -0
- package/.codex/skills/openspec-verify-change/SKILL.md +176 -0
- package/.codex/skills/performance-doctor/SKILL.md +297 -0
- package/.codex/skills/progress/SKILL.md +193 -0
- package/.codex/skills/project-navigator/SKILL.md +211 -0
- package/.codex/skills/redis-cache/SKILL.md +282 -0
- package/.codex/skills/redis-cache/references/listeners.md +23 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +277 -0
- package/.codex/skills/security-guard/SKILL.md +245 -0
- package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
- package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.codex/skills/skill-creator/LICENSE.txt +202 -0
- package/.codex/skills/skill-creator/SKILL.md +479 -0
- package/.codex/skills/skill-creator/agents/analyzer.md +274 -0
- package/.codex/skills/skill-creator/agents/comparator.md +202 -0
- package/.codex/skills/skill-creator/agents/grader.md +223 -0
- package/.codex/skills/skill-creator/assets/eval_review.html +146 -0
- package/.codex/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/.codex/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/.codex/skills/skill-creator/references/schemas.md +430 -0
- package/.codex/skills/skill-creator/scripts/__init__.py +0 -0
- package/.codex/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/.codex/skills/skill-creator/scripts/generate_report.py +326 -0
- package/.codex/skills/skill-creator/scripts/improve_description.py +248 -0
- package/.codex/skills/skill-creator/scripts/package_skill.py +136 -0
- package/.codex/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/.codex/skills/skill-creator/scripts/run_eval.py +310 -0
- package/.codex/skills/skill-creator/scripts/run_loop.py +332 -0
- package/.codex/skills/skill-creator/scripts/utils.py +47 -0
- package/.codex/skills/sms-mail/SKILL.md +346 -0
- package/.codex/skills/sms-mail/references/mail-config.md +88 -0
- package/.codex/skills/sms-mail/references/sms-config.md +74 -0
- package/.codex/skills/social-login/SKILL.md +328 -0
- package/.codex/skills/social-login/references/provider-configs.md +118 -0
- package/.codex/skills/start/SKILL.md +154 -0
- package/.codex/skills/store-pc/SKILL.md +366 -0
- package/.codex/skills/sync/SKILL.md +149 -0
- package/.codex/skills/sync-back-merge/SKILL.md +66 -0
- package/.codex/skills/task-tracker/SKILL.md +307 -0
- package/.codex/skills/tech-decision/SKILL.md +393 -0
- package/.codex/skills/tenant-management/SKILL.md +272 -0
- package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.codex/skills/test-development/SKILL.md +301 -0
- package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
- package/.codex/skills/ui-pc/SKILL.md +438 -0
- package/.codex/skills/update-status/SKILL.md +159 -0
- package/.codex/skills/utils-toolkit/SKILL.md +354 -0
- package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.codex/skills/websocket-sse/SKILL.md +350 -0
- package/.codex/skills/workflow-engine/SKILL.md +249 -0
- package/.codex/skills/yunxiao-task-management/SKILL.md +401 -0
- package/.codex/skills/yunxiao-task-management/templates//346/217/220/346/265/213/345/215/225/346/250/241/346/235/277.html +17 -0
- package/.cursor/agents/bug-analyzer.md +102 -0
- package/.cursor/agents/code-reviewer.md +122 -0
- package/.cursor/agents/code-scanner.md +145 -0
- package/.cursor/agents/image-reader.md +154 -0
- package/.cursor/agents/loki-runner.md +80 -0
- package/.cursor/agents/mysql-runner.md +81 -0
- package/.cursor/agents/project-manager.md +159 -0
- package/.cursor/agents/requirements-analyzer.md +141 -0
- package/.cursor/agents/task-fetcher.md +75 -0
- package/.cursor/audio/completed.wav +0 -0
- package/.cursor/commands/opsx-apply.md +152 -0
- package/.cursor/commands/opsx-archive.md +157 -0
- package/.cursor/commands/opsx-bulk-archive.md +242 -0
- package/.cursor/commands/opsx-continue.md +114 -0
- package/.cursor/commands/opsx-explore.md +174 -0
- package/.cursor/commands/opsx-ff.md +94 -0
- package/.cursor/commands/opsx-new.md +69 -0
- package/.cursor/commands/opsx-onboard.md +525 -0
- package/.cursor/commands/opsx-sync.md +134 -0
- package/.cursor/commands/opsx-verify.md +164 -0
- package/.cursor/hooks/cursor-pre-tool-use.js +122 -0
- package/.cursor/hooks/cursor-skill-eval.js +466 -0
- package/.cursor/hooks/lib/notify.js +310 -0
- package/.cursor/hooks/stop.js +55 -0
- package/.cursor/hooks.json +23 -0
- package/.cursor/mcp.json +22 -0
- package/.cursor/rules/skill-activation.mdc +99 -0
- package/.cursor/skills/add-skill/SKILL.md +488 -0
- package/.cursor/skills/analyze-requirements/SKILL.md +112 -0
- package/.cursor/skills/api-development/SKILL.md +315 -0
- package/.cursor/skills/architecture-design/SKILL.md +152 -0
- package/.cursor/skills/auto-test/SKILL.md +453 -0
- package/.cursor/skills/auto-test/references/api-conventions.md +260 -0
- package/.cursor/skills/backend-annotations/SKILL.md +248 -0
- package/.cursor/skills/banana-image/CHANGELOG.md +37 -0
- package/.cursor/skills/banana-image/README.md +146 -0
- package/.cursor/skills/banana-image/SKILL.md +171 -0
- package/.cursor/skills/banana-image/assets/logo.png +0 -0
- package/.cursor/skills/banana-image/references/advanced-usage.md +189 -0
- package/.cursor/skills/banana-image/scripts/apply_template.py +125 -0
- package/.cursor/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.cursor/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.cursor/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.cursor/skills/banana-image/scripts/package.json +18 -0
- package/.cursor/skills/banana-image/scripts/requirements.txt +10 -0
- package/.cursor/skills/banana-image/templates/poster.json +22 -0
- package/.cursor/skills/banana-image/templates/product.json +17 -0
- package/.cursor/skills/banana-image/templates/social.json +22 -0
- package/.cursor/skills/banana-image/templates/thumbnail.json +17 -0
- package/.cursor/skills/brainstorm/SKILL.md +216 -0
- package/.cursor/skills/bug-detective/SKILL.md +295 -0
- package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
- package/.cursor/skills/code-patterns/SKILL.md +163 -0
- package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.cursor/skills/collaborating-with-codex/SKILL.md +180 -0
- package/.cursor/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.cursor/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.cursor/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.cursor/skills/crud-development/SKILL.md +328 -0
- package/.cursor/skills/data-permission/SKILL.md +221 -0
- package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.cursor/skills/database-ops/SKILL.md +210 -0
- package/.cursor/skills/error-handler/SKILL.md +310 -0
- package/.cursor/skills/file-oss-management/SKILL.md +260 -0
- package/.cursor/skills/file-oss-management/references/entities.md +105 -0
- package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
- package/.cursor/skills/fix-bug/SKILL.md +269 -0
- package/.cursor/skills/git-workflow/SKILL.md +179 -0
- package/.cursor/skills/jenkins-deploy/SKILL.md +134 -0
- package/.cursor/skills/json-serialization/SKILL.md +341 -0
- package/.cursor/skills/lanhu-design/SKILL.md +99 -0
- package/.cursor/skills/leniu-api-development/SKILL.md +319 -0
- package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +383 -0
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +277 -0
- package/.cursor/skills/leniu-brainstorm/SKILL.md +242 -0
- package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.cursor/skills/leniu-code-patterns/SKILL.md +411 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +404 -0
- package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
- package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +341 -0
- package/.cursor/skills/leniu-database-ops/SKILL.md +426 -0
- package/.cursor/skills/leniu-error-handler/SKILL.md +462 -0
- package/.cursor/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +237 -0
- package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
- package/.cursor/skills/leniu-java-logging/SKILL.md +229 -0
- package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.cursor/skills/leniu-java-mq/SKILL.md +338 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +267 -0
- package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.cursor/skills/leniu-java-task/SKILL.md +367 -0
- package/.cursor/skills/leniu-marketing-scenario/SKILL.md +448 -0
- package/.cursor/skills/leniu-marketing-scenario/references/pay-meal-rules.md +197 -0
- package/.cursor/skills/leniu-marketing-scenario/references/price-rules.md +286 -0
- package/.cursor/skills/leniu-marketing-scenario/references/recharge-rules.md +188 -0
- package/.cursor/skills/leniu-redis-cache/SKILL.md +331 -0
- package/.cursor/skills/leniu-report-scenario/SKILL.md +508 -0
- package/.cursor/skills/leniu-report-scenario/references/amount-handling.md +448 -0
- package/.cursor/skills/leniu-report-scenario/references/analysis-module.md +64 -0
- package/.cursor/skills/leniu-report-scenario/references/customization-table-fields.md +93 -0
- package/.cursor/skills/leniu-report-scenario/references/customization.md +356 -0
- package/.cursor/skills/leniu-report-scenario/references/data-permission.md +182 -0
- package/.cursor/skills/leniu-report-scenario/references/export.md +553 -0
- package/.cursor/skills/leniu-report-scenario/references/mealtime.md +197 -0
- package/.cursor/skills/leniu-report-scenario/references/query-param.md +274 -0
- package/.cursor/skills/leniu-report-scenario/references/report-tables.md +162 -0
- package/.cursor/skills/leniu-report-scenario/references/standard-customization.md +112 -0
- package/.cursor/skills/leniu-report-scenario/references/standard-table-fields.md +113 -0
- package/.cursor/skills/leniu-report-scenario/references/total-line.md +179 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +306 -0
- package/.cursor/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/.cursor/skills/loki-log-query/SKILL.md +430 -0
- package/.cursor/skills/loki-log-query/environments.json +45 -0
- package/.cursor/skills/mysql-debug/SKILL.md +406 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +165 -0
- package/.cursor/skills/openspec-archive-change/SKILL.md +122 -0
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +254 -0
- package/.cursor/skills/openspec-continue-change/SKILL.md +126 -0
- package/.cursor/skills/openspec-explore/SKILL.md +299 -0
- package/.cursor/skills/openspec-ff-change/SKILL.md +109 -0
- package/.cursor/skills/openspec-new-change/SKILL.md +82 -0
- package/.cursor/skills/openspec-onboard/SKILL.md +414 -0
- package/.cursor/skills/openspec-sync-specs/SKILL.md +146 -0
- package/.cursor/skills/openspec-verify-change/SKILL.md +176 -0
- package/.cursor/skills/performance-doctor/SKILL.md +297 -0
- package/.cursor/skills/project-navigator/SKILL.md +211 -0
- package/.cursor/skills/redis-cache/SKILL.md +282 -0
- package/.cursor/skills/redis-cache/references/listeners.md +23 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +277 -0
- package/.cursor/skills/security-guard/SKILL.md +245 -0
- package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
- package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.cursor/skills/skill-creator/LICENSE.txt +202 -0
- package/.cursor/skills/skill-creator/SKILL.md +479 -0
- package/.cursor/skills/skill-creator/agents/analyzer.md +274 -0
- package/.cursor/skills/skill-creator/agents/comparator.md +202 -0
- package/.cursor/skills/skill-creator/agents/grader.md +223 -0
- package/.cursor/skills/skill-creator/assets/eval_review.html +146 -0
- package/.cursor/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/.cursor/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/.cursor/skills/skill-creator/references/schemas.md +430 -0
- package/.cursor/skills/skill-creator/scripts/__init__.py +0 -0
- package/.cursor/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/.cursor/skills/skill-creator/scripts/generate_report.py +326 -0
- package/.cursor/skills/skill-creator/scripts/improve_description.py +248 -0
- package/.cursor/skills/skill-creator/scripts/package_skill.py +136 -0
- package/.cursor/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/.cursor/skills/skill-creator/scripts/run_eval.py +310 -0
- package/.cursor/skills/skill-creator/scripts/run_loop.py +332 -0
- package/.cursor/skills/skill-creator/scripts/utils.py +47 -0
- package/.cursor/skills/sms-mail/SKILL.md +346 -0
- package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
- package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
- package/.cursor/skills/social-login/SKILL.md +328 -0
- package/.cursor/skills/social-login/references/provider-configs.md +118 -0
- package/.cursor/skills/store-pc/SKILL.md +366 -0
- package/.cursor/skills/sync-back-merge/SKILL.md +66 -0
- package/.cursor/skills/task-tracker/SKILL.md +307 -0
- package/.cursor/skills/tech-decision/SKILL.md +393 -0
- package/.cursor/skills/tenant-management/SKILL.md +272 -0
- package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.cursor/skills/test-development/SKILL.md +301 -0
- package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
- package/.cursor/skills/ui-pc/SKILL.md +438 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +354 -0
- package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.cursor/skills/websocket-sse/SKILL.md +350 -0
- package/.cursor/skills/workflow-engine/SKILL.md +249 -0
- package/.cursor/skills/yunxiao-task-management/SKILL.md +401 -0
- package/.cursor/skills/yunxiao-task-management/templates//346/217/220/346/265/213/345/215/225/346/250/241/346/235/277.html +17 -0
- package/.cursor/templates/env-config.md +27 -0
- package/AGENTS.md +275 -0
- package/CLAUDE.md +285 -0
- package/README.md +104 -0
- package/bin/index.js +3069 -0
- package/init.sh +178 -0
- package/package.json +40 -0
- package/scripts/build-skills.js +180 -0
- package/src/platform-map.json +100 -0
- package/src/skills/add-skill/SKILL.md +488 -0
- package/src/skills/add-todo/SKILL.md +269 -0
- package/src/skills/analyze-requirements/SKILL.md +112 -0
- package/src/skills/api-development/SKILL.md +315 -0
- package/src/skills/architecture-design/SKILL.md +152 -0
- package/src/skills/backend-annotations/SKILL.md +248 -0
- package/src/skills/banana-image/CHANGELOG.md +37 -0
- package/src/skills/banana-image/README.md +146 -0
- package/src/skills/banana-image/SKILL.md +171 -0
- package/src/skills/banana-image/assets/logo.png +0 -0
- package/src/skills/banana-image/references/advanced-usage.md +189 -0
- package/src/skills/banana-image/scripts/apply_template.py +125 -0
- package/src/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/src/skills/banana-image/scripts/batch_prep.py +82 -0
- package/src/skills/banana-image/scripts/package-lock.json +1437 -0
- package/src/skills/banana-image/scripts/package.json +18 -0
- package/src/skills/banana-image/scripts/requirements.txt +10 -0
- package/src/skills/banana-image/templates/poster.json +22 -0
- package/src/skills/banana-image/templates/product.json +17 -0
- package/src/skills/banana-image/templates/social.json +22 -0
- package/src/skills/banana-image/templates/thumbnail.json +17 -0
- package/src/skills/brainstorm/SKILL.md +216 -0
- package/src/skills/bug-detective/SKILL.md +295 -0
- package/src/skills/bug-detective/references/error-patterns.md +242 -0
- package/src/skills/check/SKILL.md +367 -0
- package/src/skills/code-patterns/SKILL.md +163 -0
- package/src/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/src/skills/codex-code-review/SKILL.md +327 -0
- package/src/skills/collaborating-with-codex/SKILL.md +180 -0
- package/src/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/src/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/src/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/src/skills/crud/SKILL.md +265 -0
- package/src/skills/crud-development/SKILL.md +328 -0
- package/src/skills/data-permission/SKILL.md +221 -0
- package/src/skills/data-permission/references/custom-data-scope.md +90 -0
- package/src/skills/database-ops/SKILL.md +210 -0
- package/src/skills/dev/SKILL.md +187 -0
- package/src/skills/error-handler/SKILL.md +310 -0
- package/src/skills/file-oss-management/SKILL.md +260 -0
- package/src/skills/file-oss-management/references/entities.md +105 -0
- package/src/skills/file-oss-management/references/service-impl.md +104 -0
- package/src/skills/fix-bug/SKILL.md +269 -0
- package/src/skills/git-workflow/SKILL.md +179 -0
- package/src/skills/init-docs/SKILL.md +194 -0
- package/src/skills/json-serialization/SKILL.md +341 -0
- package/src/skills/leniu-api-development/SKILL.md +319 -0
- package/src/skills/leniu-api-development/references/real-examples.md +273 -0
- package/src/skills/leniu-architecture-design/SKILL.md +383 -0
- package/src/skills/leniu-backend-annotations/SKILL.md +277 -0
- package/src/skills/leniu-brainstorm/SKILL.md +242 -0
- package/src/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/src/skills/leniu-code-patterns/SKILL.md +411 -0
- package/src/skills/leniu-crud-development/SKILL.md +404 -0
- package/src/skills/leniu-crud-development/references/templates.md +597 -0
- package/src/skills/leniu-customization-location/SKILL.md +410 -0
- package/src/skills/leniu-data-permission/SKILL.md +341 -0
- package/src/skills/leniu-database-ops/SKILL.md +426 -0
- package/src/skills/leniu-error-handler/SKILL.md +462 -0
- package/src/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/src/skills/leniu-java-code-style/SKILL.md +510 -0
- package/src/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/src/skills/leniu-java-entity/SKILL.md +237 -0
- package/src/skills/leniu-java-entity/references/templates.md +237 -0
- package/src/skills/leniu-java-export/SKILL.md +570 -0
- package/src/skills/leniu-java-logging/SKILL.md +229 -0
- package/src/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/src/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/src/skills/leniu-java-mq/SKILL.md +338 -0
- package/src/skills/leniu-java-mybatis/SKILL.md +267 -0
- package/src/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/src/skills/leniu-java-report-query-param/SKILL.md +291 -0
- package/src/skills/leniu-java-task/SKILL.md +367 -0
- package/src/skills/leniu-java-total-line/SKILL.md +196 -0
- package/src/skills/leniu-marketing-price-rule-customizer/SKILL.md +301 -0
- package/src/skills/leniu-marketing-recharge-rule-customizer/SKILL.md +285 -0
- package/src/skills/leniu-mealtime/SKILL.md +215 -0
- package/src/skills/leniu-redis-cache/SKILL.md +331 -0
- package/src/skills/leniu-report-customization/SKILL.md +415 -0
- package/src/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/src/skills/leniu-report-standard-customization/SKILL.md +391 -0
- package/src/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/src/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/src/skills/leniu-security-guard/SKILL.md +306 -0
- package/src/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/src/skills/loki-log-query/SKILL.md +400 -0
- package/src/skills/loki-log-query/environments.json +45 -0
- package/src/skills/mysql-debug/SKILL.md +400 -0
- package/src/skills/next/SKILL.md +137 -0
- package/src/skills/openspec-apply-change/SKILL.md +165 -0
- package/src/skills/openspec-archive-change/SKILL.md +122 -0
- package/src/skills/openspec-bulk-archive-change/SKILL.md +254 -0
- package/src/skills/openspec-continue-change/SKILL.md +126 -0
- package/src/skills/openspec-explore/SKILL.md +299 -0
- package/src/skills/openspec-ff-change/SKILL.md +109 -0
- package/src/skills/openspec-new-change/SKILL.md +82 -0
- package/src/skills/openspec-onboard/SKILL.md +414 -0
- package/src/skills/openspec-sync-specs/SKILL.md +146 -0
- package/src/skills/openspec-verify-change/SKILL.md +176 -0
- package/src/skills/performance-doctor/SKILL.md +297 -0
- package/src/skills/progress/SKILL.md +193 -0
- package/src/skills/project-navigator/SKILL.md +211 -0
- package/src/skills/redis-cache/SKILL.md +282 -0
- package/src/skills/redis-cache/references/listeners.md +23 -0
- package/src/skills/scheduled-jobs/SKILL.md +277 -0
- package/src/skills/security-guard/SKILL.md +245 -0
- package/src/skills/security-guard/references/encrypt-config.md +103 -0
- package/src/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/src/skills/skill-creator/LICENSE.txt +202 -0
- package/src/skills/skill-creator/SKILL.md +479 -0
- package/src/skills/skill-creator/agents/analyzer.md +274 -0
- package/src/skills/skill-creator/agents/comparator.md +202 -0
- package/src/skills/skill-creator/agents/grader.md +223 -0
- package/src/skills/skill-creator/assets/eval_review.html +146 -0
- package/src/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/src/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/src/skills/skill-creator/references/schemas.md +430 -0
- package/src/skills/skill-creator/scripts/__init__.py +0 -0
- package/src/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/src/skills/skill-creator/scripts/generate_report.py +326 -0
- package/src/skills/skill-creator/scripts/improve_description.py +248 -0
- package/src/skills/skill-creator/scripts/package_skill.py +136 -0
- package/src/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/src/skills/skill-creator/scripts/run_eval.py +310 -0
- package/src/skills/skill-creator/scripts/run_loop.py +332 -0
- package/src/skills/skill-creator/scripts/utils.py +47 -0
- package/src/skills/sms-mail/SKILL.md +346 -0
- package/src/skills/sms-mail/references/mail-config.md +88 -0
- package/src/skills/sms-mail/references/sms-config.md +74 -0
- package/src/skills/social-login/SKILL.md +328 -0
- package/src/skills/social-login/references/provider-configs.md +118 -0
- package/src/skills/start/SKILL.md +154 -0
- package/src/skills/store-pc/SKILL.md +366 -0
- package/src/skills/sync/SKILL.md +149 -0
- package/src/skills/sync-back-merge/SKILL.md +66 -0
- package/src/skills/task-tracker/SKILL.md +307 -0
- package/src/skills/tech-decision/SKILL.md +393 -0
- package/src/skills/tenant-management/SKILL.md +272 -0
- package/src/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/src/skills/test-development/SKILL.md +301 -0
- package/src/skills/test-development/references/parameterized-examples.md +119 -0
- package/src/skills/ui-pc/SKILL.md +438 -0
- package/src/skills/update-status/SKILL.md +159 -0
- package/src/skills/utils-toolkit/SKILL.md +354 -0
- package/src/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/src/skills/websocket-sse/SKILL.md +350 -0
- package/src/skills/workflow-engine/SKILL.md +249 -0
- package/src/skills/yunxiao-task-management/SKILL.md +401 -0
- package/src/skills/yunxiao-task-management/templates//346/217/220/346/265/213/345/215/225/346/250/241/346/235/277.html +17 -0
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// cdp - lightweight Chrome DevTools Protocol CLI
|
|
3
|
+
// Uses raw CDP over WebSocket, no Puppeteer dependency.
|
|
4
|
+
// Requires Node 22+ (built-in WebSocket).
|
|
5
|
+
//
|
|
6
|
+
// Per-tab persistent daemon: page commands go through a daemon that holds
|
|
7
|
+
// the CDP session open. Chrome's "Allow debugging" modal fires once per
|
|
8
|
+
// daemon (= once per tab). Daemons auto-exit after 20min idle.
|
|
9
|
+
|
|
10
|
+
import { readFileSync, writeFileSync, unlinkSync, existsSync, readdirSync } from 'fs';
|
|
11
|
+
import { homedir } from 'os';
|
|
12
|
+
import { resolve } from 'path';
|
|
13
|
+
import { spawn } from 'child_process';
|
|
14
|
+
import net from 'net';
|
|
15
|
+
|
|
16
|
+
const TIMEOUT = 15000;
|
|
17
|
+
const NAVIGATION_TIMEOUT = 30000;
|
|
18
|
+
const IDLE_TIMEOUT = 20 * 60 * 1000;
|
|
19
|
+
const DAEMON_CONNECT_RETRIES = 20;
|
|
20
|
+
const DAEMON_CONNECT_DELAY = 300;
|
|
21
|
+
const MIN_TARGET_PREFIX_LEN = 8;
|
|
22
|
+
const SOCK_PREFIX = '/tmp/cdp-';
|
|
23
|
+
const PAGES_CACHE = '/tmp/cdp-pages.json';
|
|
24
|
+
|
|
25
|
+
function sockPath(targetId) { return `${SOCK_PREFIX}${targetId}.sock`; }
|
|
26
|
+
|
|
27
|
+
function getWsUrl() {
|
|
28
|
+
const candidates = [
|
|
29
|
+
resolve(homedir(), 'Library/Application Support/Google/Chrome/DevToolsActivePort'),
|
|
30
|
+
resolve(homedir(), '.config/google-chrome/DevToolsActivePort'),
|
|
31
|
+
];
|
|
32
|
+
const portFile = candidates.find(path => existsSync(path));
|
|
33
|
+
if (!portFile) throw new Error(`Could not find DevToolsActivePort file in: ${candidates.join(', ')}`);
|
|
34
|
+
const lines = readFileSync(portFile, 'utf8').trim().split('\n');
|
|
35
|
+
return `ws://127.0.0.1:${lines[0]}${lines[1]}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
39
|
+
|
|
40
|
+
function listDaemonSockets() {
|
|
41
|
+
return readdirSync('/tmp')
|
|
42
|
+
.filter(f => f.startsWith('cdp-') && f.endsWith('.sock'))
|
|
43
|
+
.map(f => ({
|
|
44
|
+
targetId: f.slice(4, -5),
|
|
45
|
+
socketPath: `/tmp/${f}`,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function resolvePrefix(prefix, candidates, noun = 'target', missingHint = '') {
|
|
50
|
+
const upper = prefix.toUpperCase();
|
|
51
|
+
const matches = candidates.filter(candidate => candidate.toUpperCase().startsWith(upper));
|
|
52
|
+
if (matches.length === 0) {
|
|
53
|
+
const hint = missingHint ? ` ${missingHint}` : '';
|
|
54
|
+
throw new Error(`No ${noun} matching prefix "${prefix}".${hint}`);
|
|
55
|
+
}
|
|
56
|
+
if (matches.length > 1) {
|
|
57
|
+
throw new Error(`Ambiguous prefix "${prefix}" — matches ${matches.length} ${noun}s. Use more characters.`);
|
|
58
|
+
}
|
|
59
|
+
return matches[0];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getDisplayPrefixLength(targetIds) {
|
|
63
|
+
if (targetIds.length === 0) return MIN_TARGET_PREFIX_LEN;
|
|
64
|
+
const maxLen = Math.max(...targetIds.map(id => id.length));
|
|
65
|
+
for (let len = MIN_TARGET_PREFIX_LEN; len <= maxLen; len++) {
|
|
66
|
+
const prefixes = new Set(targetIds.map(id => id.slice(0, len).toUpperCase()));
|
|
67
|
+
if (prefixes.size === targetIds.length) return len;
|
|
68
|
+
}
|
|
69
|
+
return maxLen;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// CDP WebSocket client
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
class CDP {
|
|
77
|
+
#ws; #id = 0; #pending = new Map(); #eventHandlers = new Map(); #closeHandlers = [];
|
|
78
|
+
|
|
79
|
+
async connect(wsUrl) {
|
|
80
|
+
return new Promise((res, rej) => {
|
|
81
|
+
this.#ws = new WebSocket(wsUrl);
|
|
82
|
+
this.#ws.onopen = () => res();
|
|
83
|
+
this.#ws.onerror = (e) => rej(new Error('WebSocket error: ' + (e.message || e.type)));
|
|
84
|
+
this.#ws.onclose = () => this.#closeHandlers.forEach(h => h());
|
|
85
|
+
this.#ws.onmessage = (ev) => {
|
|
86
|
+
const msg = JSON.parse(ev.data);
|
|
87
|
+
if (msg.id && this.#pending.has(msg.id)) {
|
|
88
|
+
const { resolve, reject } = this.#pending.get(msg.id);
|
|
89
|
+
this.#pending.delete(msg.id);
|
|
90
|
+
if (msg.error) reject(new Error(msg.error.message));
|
|
91
|
+
else resolve(msg.result);
|
|
92
|
+
} else if (msg.method && this.#eventHandlers.has(msg.method)) {
|
|
93
|
+
for (const handler of [...this.#eventHandlers.get(msg.method)]) {
|
|
94
|
+
handler(msg.params || {}, msg);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
send(method, params = {}, sessionId) {
|
|
102
|
+
const id = ++this.#id;
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
this.#pending.set(id, { resolve, reject });
|
|
105
|
+
const msg = { id, method, params };
|
|
106
|
+
if (sessionId) msg.sessionId = sessionId;
|
|
107
|
+
this.#ws.send(JSON.stringify(msg));
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
if (this.#pending.has(id)) {
|
|
110
|
+
this.#pending.delete(id);
|
|
111
|
+
reject(new Error(`Timeout: ${method}`));
|
|
112
|
+
}
|
|
113
|
+
}, TIMEOUT);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
onEvent(method, handler) {
|
|
118
|
+
if (!this.#eventHandlers.has(method)) this.#eventHandlers.set(method, new Set());
|
|
119
|
+
const handlers = this.#eventHandlers.get(method);
|
|
120
|
+
handlers.add(handler);
|
|
121
|
+
return () => {
|
|
122
|
+
handlers.delete(handler);
|
|
123
|
+
if (handlers.size === 0) this.#eventHandlers.delete(method);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
waitForEvent(method, timeout = TIMEOUT) {
|
|
128
|
+
let settled = false;
|
|
129
|
+
let off;
|
|
130
|
+
let timer;
|
|
131
|
+
const promise = new Promise((resolve, reject) => {
|
|
132
|
+
off = this.onEvent(method, (params) => {
|
|
133
|
+
if (settled) return;
|
|
134
|
+
settled = true;
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
off();
|
|
137
|
+
resolve(params);
|
|
138
|
+
});
|
|
139
|
+
timer = setTimeout(() => {
|
|
140
|
+
if (settled) return;
|
|
141
|
+
settled = true;
|
|
142
|
+
off();
|
|
143
|
+
reject(new Error(`Timeout waiting for event: ${method}`));
|
|
144
|
+
}, timeout);
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
promise,
|
|
148
|
+
cancel() {
|
|
149
|
+
if (settled) return;
|
|
150
|
+
settled = true;
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
off?.();
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
onClose(handler) { this.#closeHandlers.push(handler); }
|
|
158
|
+
close() { this.#ws.close(); }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// Command implementations — return strings, take (cdp, sessionId)
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
async function getPages(cdp) {
|
|
166
|
+
const { targetInfos } = await cdp.send('Target.getTargets');
|
|
167
|
+
return targetInfos.filter(t => t.type === 'page' && !t.url.startsWith('chrome://'));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function formatPageList(pages) {
|
|
171
|
+
const prefixLen = getDisplayPrefixLength(pages.map(p => p.targetId));
|
|
172
|
+
return pages.map(p => {
|
|
173
|
+
const id = p.targetId.slice(0, prefixLen).padEnd(prefixLen);
|
|
174
|
+
const title = p.title.substring(0, 54).padEnd(54);
|
|
175
|
+
return `${id} ${title} ${p.url}`;
|
|
176
|
+
}).join('\n');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function shouldShowAxNode(node, compact = false) {
|
|
180
|
+
const role = node.role?.value || '';
|
|
181
|
+
const name = node.name?.value ?? '';
|
|
182
|
+
const value = node.value?.value;
|
|
183
|
+
if (compact && role === 'InlineTextBox') return false;
|
|
184
|
+
return role !== 'none' && role !== 'generic' && !(name === '' && (value === '' || value == null));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function formatAxNode(node, depth) {
|
|
188
|
+
const role = node.role?.value || '';
|
|
189
|
+
const name = node.name?.value ?? '';
|
|
190
|
+
const value = node.value?.value;
|
|
191
|
+
const indent = ' '.repeat(Math.min(depth, 10));
|
|
192
|
+
let line = `${indent}[${role}]`;
|
|
193
|
+
if (name !== '') line += ` ${name}`;
|
|
194
|
+
if (!(value === '' || value == null)) line += ` = ${JSON.stringify(value)}`;
|
|
195
|
+
return line;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function orderedAxChildren(node, nodesById, childrenByParent) {
|
|
199
|
+
const children = [];
|
|
200
|
+
const seen = new Set();
|
|
201
|
+
for (const childId of node.childIds || []) {
|
|
202
|
+
const child = nodesById.get(childId);
|
|
203
|
+
if (child && !seen.has(child.nodeId)) {
|
|
204
|
+
seen.add(child.nodeId);
|
|
205
|
+
children.push(child);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
for (const child of childrenByParent.get(node.nodeId) || []) {
|
|
209
|
+
if (!seen.has(child.nodeId)) {
|
|
210
|
+
seen.add(child.nodeId);
|
|
211
|
+
children.push(child);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return children;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function snapshotStr(cdp, sid, compact = false) {
|
|
218
|
+
const { nodes } = await cdp.send('Accessibility.getFullAXTree', {}, sid);
|
|
219
|
+
const nodesById = new Map(nodes.map(node => [node.nodeId, node]));
|
|
220
|
+
const childrenByParent = new Map();
|
|
221
|
+
for (const node of nodes) {
|
|
222
|
+
if (!node.parentId) continue;
|
|
223
|
+
if (!childrenByParent.has(node.parentId)) childrenByParent.set(node.parentId, []);
|
|
224
|
+
childrenByParent.get(node.parentId).push(node);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const lines = [];
|
|
228
|
+
const visited = new Set();
|
|
229
|
+
function visit(node, depth) {
|
|
230
|
+
if (!node || visited.has(node.nodeId)) return;
|
|
231
|
+
visited.add(node.nodeId);
|
|
232
|
+
if (shouldShowAxNode(node, compact)) lines.push(formatAxNode(node, depth));
|
|
233
|
+
for (const child of orderedAxChildren(node, nodesById, childrenByParent)) {
|
|
234
|
+
visit(child, depth + 1);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const roots = nodes.filter(node => !node.parentId || !nodesById.has(node.parentId));
|
|
239
|
+
for (const root of roots) visit(root, 0);
|
|
240
|
+
for (const node of nodes) visit(node, 0);
|
|
241
|
+
|
|
242
|
+
return lines.join('\n');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async function evalStr(cdp, sid, expression) {
|
|
246
|
+
await cdp.send('Runtime.enable', {}, sid);
|
|
247
|
+
const result = await cdp.send('Runtime.evaluate', {
|
|
248
|
+
expression, returnByValue: true, awaitPromise: true,
|
|
249
|
+
}, sid);
|
|
250
|
+
if (result.exceptionDetails) {
|
|
251
|
+
throw new Error(result.exceptionDetails.text || result.exceptionDetails.exception?.description);
|
|
252
|
+
}
|
|
253
|
+
const val = result.result.value;
|
|
254
|
+
return typeof val === 'object' ? JSON.stringify(val, null, 2) : String(val ?? '');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async function shotStr(cdp, sid, filePath) {
|
|
258
|
+
// Get device scale factor so we can report coordinate mapping
|
|
259
|
+
let dpr = 1;
|
|
260
|
+
try {
|
|
261
|
+
const metrics = await cdp.send('Page.getLayoutMetrics', {}, sid);
|
|
262
|
+
dpr = metrics.visualViewport?.clientWidth
|
|
263
|
+
? metrics.cssVisualViewport?.clientWidth
|
|
264
|
+
? Math.round((metrics.visualViewport.clientWidth / metrics.cssVisualViewport.clientWidth) * 100) / 100
|
|
265
|
+
: 1
|
|
266
|
+
: 1;
|
|
267
|
+
// Simpler: deviceScaleFactor is on the root Page metrics
|
|
268
|
+
const { deviceScaleFactor } = await cdp.send('Emulation.getDeviceMetricsOverride', {}, sid).catch(() => ({}));
|
|
269
|
+
if (deviceScaleFactor) dpr = deviceScaleFactor;
|
|
270
|
+
} catch {}
|
|
271
|
+
// Fallback: try to get DPR from JS
|
|
272
|
+
if (dpr === 1) {
|
|
273
|
+
try {
|
|
274
|
+
const raw = await evalStr(cdp, sid, 'window.devicePixelRatio');
|
|
275
|
+
const parsed = parseFloat(raw);
|
|
276
|
+
if (parsed > 0) dpr = parsed;
|
|
277
|
+
} catch {}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const { data } = await cdp.send('Page.captureScreenshot', { format: 'png' }, sid);
|
|
281
|
+
const out = filePath || '/tmp/screenshot.png';
|
|
282
|
+
writeFileSync(out, Buffer.from(data, 'base64'));
|
|
283
|
+
|
|
284
|
+
const lines = [out];
|
|
285
|
+
lines.push(`Screenshot saved. Device pixel ratio (DPR): ${dpr}`);
|
|
286
|
+
lines.push(`Coordinate mapping:`);
|
|
287
|
+
lines.push(` Screenshot pixels → CSS pixels (for CDP Input events): divide by ${dpr}`);
|
|
288
|
+
lines.push(` e.g. screenshot point (${Math.round(100 * dpr)}, ${Math.round(200 * dpr)}) → CSS (100, 200) → use clickxy <target> 100 200`);
|
|
289
|
+
if (dpr !== 1) {
|
|
290
|
+
lines.push(` On this ${dpr}x display: CSS px = screenshot px / ${dpr} ≈ screenshot px × ${Math.round(100/dpr)/100}`);
|
|
291
|
+
}
|
|
292
|
+
return lines.join('\n');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async function htmlStr(cdp, sid, selector) {
|
|
296
|
+
const expr = selector
|
|
297
|
+
? `document.querySelector(${JSON.stringify(selector)})?.outerHTML || 'Element not found'`
|
|
298
|
+
: `document.documentElement.outerHTML`;
|
|
299
|
+
return evalStr(cdp, sid, expr);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async function waitForDocumentReady(cdp, sid, timeoutMs = NAVIGATION_TIMEOUT) {
|
|
303
|
+
const deadline = Date.now() + timeoutMs;
|
|
304
|
+
let lastState = '';
|
|
305
|
+
let lastError;
|
|
306
|
+
while (Date.now() < deadline) {
|
|
307
|
+
try {
|
|
308
|
+
const state = await evalStr(cdp, sid, 'document.readyState');
|
|
309
|
+
lastState = state;
|
|
310
|
+
if (state === 'complete') return;
|
|
311
|
+
} catch (e) {
|
|
312
|
+
lastError = e;
|
|
313
|
+
}
|
|
314
|
+
await sleep(200);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (lastState) {
|
|
318
|
+
throw new Error(`Timed out waiting for navigation to finish (last readyState: ${lastState})`);
|
|
319
|
+
}
|
|
320
|
+
if (lastError) {
|
|
321
|
+
throw new Error(`Timed out waiting for navigation to finish (${lastError.message})`);
|
|
322
|
+
}
|
|
323
|
+
throw new Error('Timed out waiting for navigation to finish');
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async function navStr(cdp, sid, url) {
|
|
327
|
+
await cdp.send('Page.enable', {}, sid);
|
|
328
|
+
const loadEvent = cdp.waitForEvent('Page.loadEventFired', NAVIGATION_TIMEOUT);
|
|
329
|
+
const result = await cdp.send('Page.navigate', { url }, sid);
|
|
330
|
+
if (result.errorText) {
|
|
331
|
+
loadEvent.cancel();
|
|
332
|
+
throw new Error(result.errorText);
|
|
333
|
+
}
|
|
334
|
+
if (result.loaderId) {
|
|
335
|
+
await loadEvent.promise;
|
|
336
|
+
} else {
|
|
337
|
+
loadEvent.cancel();
|
|
338
|
+
}
|
|
339
|
+
await waitForDocumentReady(cdp, sid, 5000);
|
|
340
|
+
return `Navigated to ${url}`;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async function netStr(cdp, sid) {
|
|
344
|
+
const raw = await evalStr(cdp, sid, `JSON.stringify(performance.getEntriesByType('resource').map(e => ({
|
|
345
|
+
name: e.name.substring(0, 120), type: e.initiatorType,
|
|
346
|
+
duration: Math.round(e.duration), size: e.transferSize
|
|
347
|
+
})))`);
|
|
348
|
+
return JSON.parse(raw).map(e =>
|
|
349
|
+
`${String(e.duration).padStart(5)}ms ${String(e.size || '?').padStart(8)}B ${e.type.padEnd(8)} ${e.name}`
|
|
350
|
+
).join('\n');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Click element by CSS selector
|
|
354
|
+
async function clickStr(cdp, sid, selector) {
|
|
355
|
+
if (!selector) throw new Error('CSS selector required');
|
|
356
|
+
const expr = `
|
|
357
|
+
(function() {
|
|
358
|
+
const el = document.querySelector(${JSON.stringify(selector)});
|
|
359
|
+
if (!el) return { ok: false, error: 'Element not found: ' + ${JSON.stringify(selector)} };
|
|
360
|
+
el.scrollIntoView({ block: 'center' });
|
|
361
|
+
el.click();
|
|
362
|
+
return { ok: true, tag: el.tagName, text: el.textContent.trim().substring(0, 80) };
|
|
363
|
+
})()
|
|
364
|
+
`;
|
|
365
|
+
const result = await evalStr(cdp, sid, expr);
|
|
366
|
+
const r = JSON.parse(result);
|
|
367
|
+
if (!r.ok) throw new Error(r.error);
|
|
368
|
+
return `Clicked <${r.tag}> "${r.text}"`;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Click at CSS pixel coordinates using Input.dispatchMouseEvent
|
|
372
|
+
async function clickXyStr(cdp, sid, x, y) {
|
|
373
|
+
const cx = parseFloat(x);
|
|
374
|
+
const cy = parseFloat(y);
|
|
375
|
+
if (isNaN(cx) || isNaN(cy)) throw new Error('x and y must be numbers (CSS pixels)');
|
|
376
|
+
const base = { x: cx, y: cy, button: 'left', clickCount: 1, modifiers: 0 };
|
|
377
|
+
await cdp.send('Input.dispatchMouseEvent', { ...base, type: 'mouseMoved' }, sid);
|
|
378
|
+
await cdp.send('Input.dispatchMouseEvent', { ...base, type: 'mousePressed' }, sid);
|
|
379
|
+
await sleep(50);
|
|
380
|
+
await cdp.send('Input.dispatchMouseEvent', { ...base, type: 'mouseReleased' }, sid);
|
|
381
|
+
return `Clicked at CSS (${cx}, ${cy})`;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Type text using Input.insertText (works in cross-origin iframes, unlike eval)
|
|
385
|
+
async function typeStr(cdp, sid, text) {
|
|
386
|
+
if (text == null || text === '') throw new Error('text required');
|
|
387
|
+
await cdp.send('Input.insertText', { text }, sid);
|
|
388
|
+
return `Typed ${text.length} characters`;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Load-more: repeatedly click a button/selector until it disappears
|
|
392
|
+
async function loadAllStr(cdp, sid, selector, intervalMs = 1500) {
|
|
393
|
+
if (!selector) throw new Error('CSS selector required');
|
|
394
|
+
let clicks = 0;
|
|
395
|
+
const deadline = Date.now() + 5 * 60 * 1000; // 5-minute hard cap
|
|
396
|
+
while (Date.now() < deadline) {
|
|
397
|
+
const exists = await evalStr(cdp, sid,
|
|
398
|
+
`!!document.querySelector(${JSON.stringify(selector)})`
|
|
399
|
+
);
|
|
400
|
+
if (exists !== 'true') break;
|
|
401
|
+
const clickExpr = `
|
|
402
|
+
(function() {
|
|
403
|
+
const el = document.querySelector(${JSON.stringify(selector)});
|
|
404
|
+
if (!el) return false;
|
|
405
|
+
el.scrollIntoView({ block: 'center' });
|
|
406
|
+
el.click();
|
|
407
|
+
return true;
|
|
408
|
+
})()
|
|
409
|
+
`;
|
|
410
|
+
const clicked = await evalStr(cdp, sid, clickExpr);
|
|
411
|
+
if (clicked !== 'true') break;
|
|
412
|
+
clicks++;
|
|
413
|
+
await sleep(intervalMs);
|
|
414
|
+
}
|
|
415
|
+
return `Clicked "${selector}" ${clicks} time(s) until it disappeared`;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Send a raw CDP command and return the result as JSON
|
|
419
|
+
async function evalRawStr(cdp, sid, method, paramsJson) {
|
|
420
|
+
if (!method) throw new Error('CDP method required (e.g. "DOM.getDocument")');
|
|
421
|
+
let params = {};
|
|
422
|
+
if (paramsJson) {
|
|
423
|
+
try { params = JSON.parse(paramsJson); }
|
|
424
|
+
catch { throw new Error(`Invalid JSON params: ${paramsJson}`); }
|
|
425
|
+
}
|
|
426
|
+
const result = await cdp.send(method, params, sid);
|
|
427
|
+
return JSON.stringify(result, null, 2);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// ---------------------------------------------------------------------------
|
|
431
|
+
// Per-tab daemon
|
|
432
|
+
// ---------------------------------------------------------------------------
|
|
433
|
+
|
|
434
|
+
async function runDaemon(targetId) {
|
|
435
|
+
const sp = sockPath(targetId);
|
|
436
|
+
|
|
437
|
+
const cdp = new CDP();
|
|
438
|
+
try {
|
|
439
|
+
await cdp.connect(getWsUrl());
|
|
440
|
+
} catch (e) {
|
|
441
|
+
process.stderr.write(`Daemon: cannot connect to Chrome: ${e.message}\n`);
|
|
442
|
+
process.exit(1);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let sessionId;
|
|
446
|
+
try {
|
|
447
|
+
const res = await cdp.send('Target.attachToTarget', { targetId, flatten: true });
|
|
448
|
+
sessionId = res.sessionId;
|
|
449
|
+
} catch (e) {
|
|
450
|
+
process.stderr.write(`Daemon: attach failed: ${e.message}\n`);
|
|
451
|
+
cdp.close();
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// Shutdown helpers
|
|
456
|
+
let alive = true;
|
|
457
|
+
function shutdown() {
|
|
458
|
+
if (!alive) return;
|
|
459
|
+
alive = false;
|
|
460
|
+
server.close();
|
|
461
|
+
try { unlinkSync(sp); } catch {}
|
|
462
|
+
cdp.close();
|
|
463
|
+
process.exit(0);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Exit if target goes away or Chrome disconnects
|
|
467
|
+
cdp.onEvent('Target.targetDestroyed', (params) => {
|
|
468
|
+
if (params.targetId === targetId) shutdown();
|
|
469
|
+
});
|
|
470
|
+
cdp.onEvent('Target.detachedFromTarget', (params) => {
|
|
471
|
+
if (params.sessionId === sessionId) shutdown();
|
|
472
|
+
});
|
|
473
|
+
cdp.onClose(() => shutdown());
|
|
474
|
+
process.on('SIGTERM', shutdown);
|
|
475
|
+
process.on('SIGINT', shutdown);
|
|
476
|
+
|
|
477
|
+
// Idle timer
|
|
478
|
+
let idleTimer = setTimeout(shutdown, IDLE_TIMEOUT);
|
|
479
|
+
function resetIdle() {
|
|
480
|
+
clearTimeout(idleTimer);
|
|
481
|
+
idleTimer = setTimeout(shutdown, IDLE_TIMEOUT);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Handle a command
|
|
485
|
+
async function handleCommand({ cmd, args }) {
|
|
486
|
+
resetIdle();
|
|
487
|
+
try {
|
|
488
|
+
let result;
|
|
489
|
+
switch (cmd) {
|
|
490
|
+
case 'list': {
|
|
491
|
+
const pages = await getPages(cdp);
|
|
492
|
+
result = formatPageList(pages);
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
case 'list_raw': {
|
|
496
|
+
const pages = await getPages(cdp);
|
|
497
|
+
result = JSON.stringify(pages);
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
case 'snap': case 'snapshot': result = await snapshotStr(cdp, sessionId, true); break;
|
|
501
|
+
case 'eval': result = await evalStr(cdp, sessionId, args[0]); break;
|
|
502
|
+
case 'shot': case 'screenshot': result = await shotStr(cdp, sessionId, args[0]); break;
|
|
503
|
+
case 'html': result = await htmlStr(cdp, sessionId, args[0]); break;
|
|
504
|
+
case 'nav': case 'navigate': result = await navStr(cdp, sessionId, args[0]); break;
|
|
505
|
+
case 'net': case 'network': result = await netStr(cdp, sessionId); break;
|
|
506
|
+
case 'click': result = await clickStr(cdp, sessionId, args[0]); break;
|
|
507
|
+
case 'clickxy': result = await clickXyStr(cdp, sessionId, args[0], args[1]); break;
|
|
508
|
+
case 'type': result = await typeStr(cdp, sessionId, args[0]); break;
|
|
509
|
+
case 'loadall': result = await loadAllStr(cdp, sessionId, args[0], args[1] ? parseInt(args[1]) : 1500); break;
|
|
510
|
+
case 'evalraw': result = await evalRawStr(cdp, sessionId, args[0], args[1]); break;
|
|
511
|
+
case 'stop': return { ok: true, result: '', stopAfter: true };
|
|
512
|
+
default: return { ok: false, error: `Unknown command: ${cmd}` };
|
|
513
|
+
}
|
|
514
|
+
return { ok: true, result: result ?? '' };
|
|
515
|
+
} catch (e) {
|
|
516
|
+
return { ok: false, error: e.message };
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Unix socket server — NDJSON protocol
|
|
521
|
+
// Wire format: each message is one JSON object followed by \n (newline-delimited JSON).
|
|
522
|
+
// Request: { "id": <number>, "cmd": "<command>", "args": ["arg1", "arg2", ...] }
|
|
523
|
+
// Response: { "id": <number>, "ok": <boolean>, "result": "<string>" }
|
|
524
|
+
// or { "id": <number>, "ok": false, "error": "<message>" }
|
|
525
|
+
const server = net.createServer((conn) => {
|
|
526
|
+
let buf = '';
|
|
527
|
+
conn.on('data', (chunk) => {
|
|
528
|
+
buf += chunk.toString();
|
|
529
|
+
const lines = buf.split('\n');
|
|
530
|
+
buf = lines.pop(); // keep incomplete last line
|
|
531
|
+
for (const line of lines) {
|
|
532
|
+
if (!line.trim()) continue;
|
|
533
|
+
let req;
|
|
534
|
+
try {
|
|
535
|
+
req = JSON.parse(line);
|
|
536
|
+
} catch {
|
|
537
|
+
conn.write(JSON.stringify({ ok: false, error: 'Invalid JSON request', id: null }) + '\n');
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
handleCommand(req).then((res) => {
|
|
541
|
+
const payload = JSON.stringify({ ...res, id: req.id }) + '\n';
|
|
542
|
+
if (res.stopAfter) conn.end(payload, shutdown);
|
|
543
|
+
else conn.write(payload);
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
try { unlinkSync(sp); } catch {}
|
|
550
|
+
server.listen(sp);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// ---------------------------------------------------------------------------
|
|
554
|
+
// CLI ↔ daemon communication
|
|
555
|
+
// ---------------------------------------------------------------------------
|
|
556
|
+
|
|
557
|
+
function connectToSocket(sp) {
|
|
558
|
+
return new Promise((resolve, reject) => {
|
|
559
|
+
const conn = net.connect(sp);
|
|
560
|
+
conn.on('connect', () => resolve(conn));
|
|
561
|
+
conn.on('error', reject);
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
async function getOrStartTabDaemon(targetId) {
|
|
566
|
+
const sp = sockPath(targetId);
|
|
567
|
+
// Try existing daemon
|
|
568
|
+
try { return await connectToSocket(sp); } catch {}
|
|
569
|
+
|
|
570
|
+
// Clean stale socket
|
|
571
|
+
try { unlinkSync(sp); } catch {}
|
|
572
|
+
|
|
573
|
+
// Spawn daemon
|
|
574
|
+
const child = spawn(process.execPath, [process.argv[1], '_daemon', targetId], {
|
|
575
|
+
detached: true,
|
|
576
|
+
stdio: 'ignore',
|
|
577
|
+
});
|
|
578
|
+
child.unref();
|
|
579
|
+
|
|
580
|
+
// Wait for socket (includes time for user to click Allow)
|
|
581
|
+
for (let i = 0; i < DAEMON_CONNECT_RETRIES; i++) {
|
|
582
|
+
await sleep(DAEMON_CONNECT_DELAY);
|
|
583
|
+
try { return await connectToSocket(sp); } catch {}
|
|
584
|
+
}
|
|
585
|
+
throw new Error('Daemon failed to start — did you click Allow in Chrome?');
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function sendCommand(conn, req) {
|
|
589
|
+
return new Promise((resolve, reject) => {
|
|
590
|
+
let buf = '';
|
|
591
|
+
let settled = false;
|
|
592
|
+
|
|
593
|
+
const cleanup = () => {
|
|
594
|
+
conn.off('data', onData);
|
|
595
|
+
conn.off('error', onError);
|
|
596
|
+
conn.off('end', onEnd);
|
|
597
|
+
conn.off('close', onClose);
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const onData = (chunk) => {
|
|
601
|
+
buf += chunk.toString();
|
|
602
|
+
const idx = buf.indexOf('\n');
|
|
603
|
+
if (idx === -1) return;
|
|
604
|
+
settled = true;
|
|
605
|
+
cleanup();
|
|
606
|
+
resolve(JSON.parse(buf.slice(0, idx)));
|
|
607
|
+
conn.end();
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
const onError = (error) => {
|
|
611
|
+
if (settled) return;
|
|
612
|
+
settled = true;
|
|
613
|
+
cleanup();
|
|
614
|
+
reject(error);
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
const onEnd = () => {
|
|
618
|
+
if (settled) return;
|
|
619
|
+
settled = true;
|
|
620
|
+
cleanup();
|
|
621
|
+
reject(new Error('Connection closed before response'));
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
const onClose = () => {
|
|
625
|
+
if (settled) return;
|
|
626
|
+
settled = true;
|
|
627
|
+
cleanup();
|
|
628
|
+
reject(new Error('Connection closed before response'));
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
conn.on('data', onData);
|
|
632
|
+
conn.on('error', onError);
|
|
633
|
+
conn.on('end', onEnd);
|
|
634
|
+
conn.on('close', onClose);
|
|
635
|
+
req.id = 1;
|
|
636
|
+
conn.write(JSON.stringify(req) + '\n');
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Find any running daemon socket to reuse for list
|
|
641
|
+
function findAnyDaemonSocket() {
|
|
642
|
+
return listDaemonSockets()[0]?.socketPath || null;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// ---------------------------------------------------------------------------
|
|
646
|
+
// Stop daemons
|
|
647
|
+
// ---------------------------------------------------------------------------
|
|
648
|
+
|
|
649
|
+
async function stopDaemons(targetPrefix) {
|
|
650
|
+
const daemons = listDaemonSockets();
|
|
651
|
+
|
|
652
|
+
if (targetPrefix) {
|
|
653
|
+
const targetId = resolvePrefix(targetPrefix, daemons.map(d => d.targetId), 'daemon');
|
|
654
|
+
const daemon = daemons.find(d => d.targetId === targetId);
|
|
655
|
+
try {
|
|
656
|
+
const conn = await connectToSocket(daemon.socketPath);
|
|
657
|
+
await sendCommand(conn, { cmd: 'stop' });
|
|
658
|
+
} catch {
|
|
659
|
+
try { unlinkSync(daemon.socketPath); } catch {}
|
|
660
|
+
}
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
for (const daemon of daemons) {
|
|
665
|
+
try {
|
|
666
|
+
const conn = await connectToSocket(daemon.socketPath);
|
|
667
|
+
await sendCommand(conn, { cmd: 'stop' });
|
|
668
|
+
} catch {
|
|
669
|
+
try { unlinkSync(daemon.socketPath); } catch {}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// ---------------------------------------------------------------------------
|
|
675
|
+
// Main
|
|
676
|
+
// ---------------------------------------------------------------------------
|
|
677
|
+
|
|
678
|
+
const USAGE = `cdp - lightweight Chrome DevTools Protocol CLI (no Puppeteer)
|
|
679
|
+
|
|
680
|
+
Usage: cdp <command> [args]
|
|
681
|
+
|
|
682
|
+
list List open pages (shows unique target prefixes)
|
|
683
|
+
snap <target> Accessibility tree snapshot
|
|
684
|
+
eval <target> <expr> Evaluate JS expression
|
|
685
|
+
shot <target> [file] Screenshot (default: /tmp/screenshot.png); prints coordinate mapping
|
|
686
|
+
html <target> [selector] Get HTML (full page or CSS selector)
|
|
687
|
+
nav <target> <url> Navigate to URL and wait for load completion
|
|
688
|
+
net <target> Network performance entries
|
|
689
|
+
click <target> <selector> Click an element by CSS selector
|
|
690
|
+
clickxy <target> <x> <y> Click at CSS pixel coordinates (see coordinate note below)
|
|
691
|
+
type <target> <text> Type text at current focus via Input.insertText
|
|
692
|
+
Works in cross-origin iframes unlike eval-based approaches
|
|
693
|
+
loadall <target> <selector> [ms] Repeatedly click a "load more" button until it disappears
|
|
694
|
+
Optional interval in ms between clicks (default 1500)
|
|
695
|
+
evalraw <target> <method> [json] Send a raw CDP command; returns JSON result
|
|
696
|
+
e.g. evalraw <t> "DOM.getDocument" '{}'
|
|
697
|
+
stop [target] Stop daemon(s)
|
|
698
|
+
|
|
699
|
+
<target> is a unique targetId prefix from "cdp list". If a prefix is ambiguous,
|
|
700
|
+
use more characters.
|
|
701
|
+
|
|
702
|
+
COORDINATE SYSTEM
|
|
703
|
+
shot captures the viewport at the device's native resolution.
|
|
704
|
+
The screenshot image size = CSS pixels × DPR (device pixel ratio).
|
|
705
|
+
For CDP Input events (clickxy, etc.) you need CSS pixels, not image pixels.
|
|
706
|
+
|
|
707
|
+
CSS pixels = screenshot image pixels / DPR
|
|
708
|
+
|
|
709
|
+
shot prints the DPR and an example conversion for the current page.
|
|
710
|
+
Typical Retina (DPR=2): CSS px ≈ screenshot px × 0.5
|
|
711
|
+
If your viewer rescales the image further, account for that scaling too.
|
|
712
|
+
|
|
713
|
+
EVAL SAFETY NOTE
|
|
714
|
+
Avoid index-based DOM selection (querySelectorAll(...)[i]) across multiple
|
|
715
|
+
eval calls when the list can change between calls (e.g. after clicking
|
|
716
|
+
"Ignore" buttons on a feed — indices shift). Prefer stable selectors or
|
|
717
|
+
collect all data in a single eval.
|
|
718
|
+
|
|
719
|
+
DAEMON IPC (for advanced use / scripting)
|
|
720
|
+
Each tab runs a persistent daemon at Unix socket: /tmp/cdp-<fullTargetId>.sock
|
|
721
|
+
Protocol: newline-delimited JSON (one JSON object per line, UTF-8).
|
|
722
|
+
Request: {"id":<number>, "cmd":"<command>", "args":["arg1","arg2",...]}
|
|
723
|
+
Response: {"id":<number>, "ok":true, "result":"<string>"}
|
|
724
|
+
or {"id":<number>, "ok":false, "error":"<message>"}
|
|
725
|
+
Commands mirror the CLI: snap, eval, shot, html, nav, net, click, clickxy,
|
|
726
|
+
type, loadall, evalraw, stop. Use evalraw to send arbitrary CDP methods.
|
|
727
|
+
The socket disappears after 20 min of inactivity or when the tab closes.
|
|
728
|
+
`;
|
|
729
|
+
|
|
730
|
+
const NEEDS_TARGET = new Set([
|
|
731
|
+
'snap','snapshot','eval','shot','screenshot','html','nav','navigate',
|
|
732
|
+
'net','network','click','clickxy','type','loadall','evalraw',
|
|
733
|
+
]);
|
|
734
|
+
|
|
735
|
+
async function main() {
|
|
736
|
+
const [cmd, ...args] = process.argv.slice(2);
|
|
737
|
+
|
|
738
|
+
// Daemon mode (internal)
|
|
739
|
+
if (cmd === '_daemon') { await runDaemon(args[0]); return; }
|
|
740
|
+
|
|
741
|
+
if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
|
|
742
|
+
console.log(USAGE); process.exit(0);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// List — use existing daemon if available, otherwise direct
|
|
746
|
+
if (cmd === 'list' || cmd === 'ls') {
|
|
747
|
+
let pages;
|
|
748
|
+
const existingSock = findAnyDaemonSocket();
|
|
749
|
+
if (existingSock) {
|
|
750
|
+
try {
|
|
751
|
+
const conn = await connectToSocket(existingSock);
|
|
752
|
+
const resp = await sendCommand(conn, { cmd: 'list_raw' });
|
|
753
|
+
if (resp.ok) pages = JSON.parse(resp.result);
|
|
754
|
+
} catch {}
|
|
755
|
+
}
|
|
756
|
+
if (!pages) {
|
|
757
|
+
// No daemon running — connect directly (will trigger one Allow)
|
|
758
|
+
const cdp = new CDP();
|
|
759
|
+
await cdp.connect(getWsUrl());
|
|
760
|
+
pages = await getPages(cdp);
|
|
761
|
+
cdp.close();
|
|
762
|
+
}
|
|
763
|
+
writeFileSync(PAGES_CACHE, JSON.stringify(pages));
|
|
764
|
+
console.log(formatPageList(pages));
|
|
765
|
+
setTimeout(() => process.exit(0), 100);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// Stop
|
|
770
|
+
if (cmd === 'stop') {
|
|
771
|
+
await stopDaemons(args[0]);
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// Page commands — need target prefix
|
|
776
|
+
if (!NEEDS_TARGET.has(cmd)) {
|
|
777
|
+
console.error(`Unknown command: ${cmd}\n`);
|
|
778
|
+
console.log(USAGE);
|
|
779
|
+
process.exit(1);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const targetPrefix = args[0];
|
|
783
|
+
if (!targetPrefix) {
|
|
784
|
+
console.error('Error: target ID required. Run "cdp list" first.');
|
|
785
|
+
process.exit(1);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Resolve prefix → full targetId from cache or running daemon
|
|
789
|
+
let targetId;
|
|
790
|
+
const daemonTargetIds = listDaemonSockets().map(d => d.targetId);
|
|
791
|
+
const daemonMatches = daemonTargetIds.filter(id => id.toUpperCase().startsWith(targetPrefix.toUpperCase()));
|
|
792
|
+
|
|
793
|
+
if (daemonMatches.length > 0) {
|
|
794
|
+
targetId = resolvePrefix(targetPrefix, daemonTargetIds, 'daemon');
|
|
795
|
+
} else {
|
|
796
|
+
if (!existsSync(PAGES_CACHE)) {
|
|
797
|
+
console.error('No page list cached. Run "cdp list" first.');
|
|
798
|
+
process.exit(1);
|
|
799
|
+
}
|
|
800
|
+
const pages = JSON.parse(readFileSync(PAGES_CACHE, 'utf8'));
|
|
801
|
+
targetId = resolvePrefix(targetPrefix, pages.map(p => p.targetId), 'target', 'Run "cdp list".');
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
const conn = await getOrStartTabDaemon(targetId);
|
|
805
|
+
|
|
806
|
+
const cmdArgs = args.slice(1);
|
|
807
|
+
|
|
808
|
+
if (cmd === 'eval') {
|
|
809
|
+
const expr = cmdArgs.join(' ');
|
|
810
|
+
if (!expr) { console.error('Error: expression required'); process.exit(1); }
|
|
811
|
+
cmdArgs[0] = expr;
|
|
812
|
+
} else if (cmd === 'type') {
|
|
813
|
+
// Join all remaining args as text (allows spaces)
|
|
814
|
+
const text = cmdArgs.join(' ');
|
|
815
|
+
if (!text) { console.error('Error: text required'); process.exit(1); }
|
|
816
|
+
cmdArgs[0] = text;
|
|
817
|
+
} else if (cmd === 'evalraw') {
|
|
818
|
+
// args: [method, ...jsonParts] — join json parts in case of spaces
|
|
819
|
+
if (!cmdArgs[0]) { console.error('Error: CDP method required'); process.exit(1); }
|
|
820
|
+
if (cmdArgs.length > 2) cmdArgs[1] = cmdArgs.slice(1).join(' ');
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if ((cmd === 'nav' || cmd === 'navigate') && !cmdArgs[0]) {
|
|
824
|
+
console.error('Error: URL required');
|
|
825
|
+
process.exit(1);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
const response = await sendCommand(conn, { cmd, args: cmdArgs });
|
|
829
|
+
|
|
830
|
+
if (response.ok) {
|
|
831
|
+
if (response.result) console.log(response.result);
|
|
832
|
+
} else {
|
|
833
|
+
console.error('Error:', response.error);
|
|
834
|
+
process.exitCode = 1;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
main().catch(e => { console.error(e.message); process.exit(1); });
|