self-evolve-framework 1.6.0 → 1.6.1
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/README.md +33 -23
- package/bin/cli.js +24 -67
- package/package.json +1 -1
- package/template/rules/knowledge/README.md +56 -0
- package/template/rules/knowledge/ant-design-vue.mdc +54 -0
- package/template/rules/knowledge/general.mdc +56 -0
- package/template/rules/knowledge/rust.mdc +55 -0
- package/template/rules/knowledge/shadcn-svelte.mdc +64 -0
- package/template/rules/knowledge/svelte.mdc +135 -0
- package/template/rules/knowledge/tailwind.mdc +66 -0
- package/template/rules/knowledge/tauri.mdc +65 -0
- package/template/rules/knowledge/typescript.mdc +41 -0
- package/template/rules/knowledge/vue.mdc +48 -0
- package/template/rules/ponytail.mdc +23 -98
- package/template/rules/self-evolve.mdc +24 -0
- package/template/skills/impeccable/SKILL.md +47 -174
- package/template/skills/skillopt-sleep/SKILL.md +32 -88
- package/template/skills/impeccable/agents/impeccable_asset_producer.toml +0 -92
- package/template/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
- package/template/skills/impeccable/agents/openai.yaml +0 -4
- package/template/skills/impeccable/reference/adapt.md +0 -311
- package/template/skills/impeccable/reference/animate.md +0 -201
- package/template/skills/impeccable/reference/audit.md +0 -133
- package/template/skills/impeccable/reference/bolder.md +0 -113
- package/template/skills/impeccable/reference/brand.md +0 -108
- package/template/skills/impeccable/reference/clarify.md +0 -288
- package/template/skills/impeccable/reference/codex.md +0 -105
- package/template/skills/impeccable/reference/colorize.md +0 -257
- package/template/skills/impeccable/reference/craft.md +0 -123
- package/template/skills/impeccable/reference/critique.md +0 -790
- package/template/skills/impeccable/reference/delight.md +0 -302
- package/template/skills/impeccable/reference/distill.md +0 -111
- package/template/skills/impeccable/reference/document.md +0 -429
- package/template/skills/impeccable/reference/extract.md +0 -69
- package/template/skills/impeccable/reference/harden.md +0 -347
- package/template/skills/impeccable/reference/hooks.md +0 -90
- package/template/skills/impeccable/reference/init.md +0 -172
- package/template/skills/impeccable/reference/interaction-design.md +0 -189
- package/template/skills/impeccable/reference/layout.md +0 -161
- package/template/skills/impeccable/reference/live.md +0 -720
- package/template/skills/impeccable/reference/onboard.md +0 -234
- package/template/skills/impeccable/reference/optimize.md +0 -258
- package/template/skills/impeccable/reference/overdrive.md +0 -130
- package/template/skills/impeccable/reference/polish.md +0 -241
- package/template/skills/impeccable/reference/product.md +0 -60
- package/template/skills/impeccable/reference/quieter.md +0 -99
- package/template/skills/impeccable/reference/shape.md +0 -165
- package/template/skills/impeccable/reference/typeset.md +0 -279
- package/template/skills/impeccable/scripts/command-metadata.json +0 -94
- package/template/skills/impeccable/scripts/context-signals.mjs +0 -225
- package/template/skills/impeccable/scripts/context.mjs +0 -961
- package/template/skills/impeccable/scripts/critique-storage.mjs +0 -242
- package/template/skills/impeccable/scripts/detect-csp.mjs +0 -198
- package/template/skills/impeccable/scripts/detect.mjs +0 -21
- package/template/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -1937
- package/template/skills/impeccable/scripts/detector/cli/main.mjs +0 -290
- package/template/skills/impeccable/scripts/detector/design-system.mjs +0 -750
- package/template/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -5138
- package/template/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -50
- package/template/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -277
- package/template/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -568
- package/template/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1015
- package/template/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -234
- package/template/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
- package/template/skills/impeccable/scripts/detector/findings.mjs +0 -12
- package/template/skills/impeccable/scripts/detector/node/file-system.mjs +0 -198
- package/template/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
- package/template/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -448
- package/template/skills/impeccable/scripts/detector/rules/checks.mjs +0 -2671
- package/template/skills/impeccable/scripts/detector/shared/color.mjs +0 -124
- package/template/skills/impeccable/scripts/detector/shared/constants.mjs +0 -101
- package/template/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
- package/template/skills/impeccable/scripts/detector/shared/page.mjs +0 -7
- package/template/skills/impeccable/scripts/hook-admin.mjs +0 -661
- package/template/skills/impeccable/scripts/hook-before-edit.mjs +0 -476
- package/template/skills/impeccable/scripts/hook-lib.mjs +0 -1632
- package/template/skills/impeccable/scripts/hook.mjs +0 -61
- package/template/skills/impeccable/scripts/lib/design-parser.mjs +0 -842
- package/template/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -638
- package/template/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -128
- package/template/skills/impeccable/scripts/lib/is-generated.mjs +0 -69
- package/template/skills/impeccable/scripts/lib/target-args.mjs +0 -42
- package/template/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -49
- package/template/skills/impeccable/scripts/live/completion.mjs +0 -19
- package/template/skills/impeccable/scripts/live/event-validation.mjs +0 -137
- package/template/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
- package/template/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
- package/template/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
- package/template/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
- package/template/skills/impeccable/scripts/live/session-store.mjs +0 -289
- package/template/skills/impeccable/scripts/live/svelte-component.mjs +0 -826
- package/template/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -274
- package/template/skills/impeccable/scripts/live/ui-core.mjs +0 -180
- package/template/skills/impeccable/scripts/live/vocabulary.mjs +0 -36
- package/template/skills/impeccable/scripts/live-accept.mjs +0 -812
- package/template/skills/impeccable/scripts/live-browser-dom.js +0 -146
- package/template/skills/impeccable/scripts/live-browser-session.js +0 -123
- package/template/skills/impeccable/scripts/live-browser.js +0 -11173
- package/template/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1241
- package/template/skills/impeccable/scripts/live-complete.mjs +0 -75
- package/template/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -683
- package/template/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
- package/template/skills/impeccable/scripts/live-inject.mjs +0 -583
- package/template/skills/impeccable/scripts/live-insert.mjs +0 -272
- package/template/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -363
- package/template/skills/impeccable/scripts/live-poll.mjs +0 -384
- package/template/skills/impeccable/scripts/live-resume.mjs +0 -94
- package/template/skills/impeccable/scripts/live-server.mjs +0 -1135
- package/template/skills/impeccable/scripts/live-status.mjs +0 -61
- package/template/skills/impeccable/scripts/live-target.mjs +0 -30
- package/template/skills/impeccable/scripts/live-wrap.mjs +0 -894
- package/template/skills/impeccable/scripts/live.mjs +0 -297
- package/template/skills/impeccable/scripts/modern-screenshot.umd.js +0 -14
- package/template/skills/impeccable/scripts/palette.mjs +0 -633
- package/template/skills/impeccable/scripts/pin.mjs +0 -214
- package/template/skills/skillopt-sleep/configs/_base_/default.yaml +0 -103
- package/template/skills/skillopt-sleep/configs/alfworld/default.yaml +0 -29
- package/template/skills/skillopt-sleep/configs/docvqa/default.yaml +0 -28
- package/template/skills/skillopt-sleep/configs/features/soft_gate.yaml +0 -47
- package/template/skills/skillopt-sleep/configs/livemathematicianbench/default.yaml +0 -22
- package/template/skills/skillopt-sleep/configs/officeqa/default.yaml +0 -34
- package/template/skills/skillopt-sleep/configs/searchqa/default.yaml +0 -32
- package/template/skills/skillopt-sleep/configs/spreadsheetbench/default.yaml +0 -34
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/__init__.py +0 -28
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/config.py +0 -282
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/datasets/__init__.py +0 -7
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/datasets/base.py +0 -512
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/engine/__init__.py +0 -9
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/engine/trainer.py +0 -2379
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/__init__.py +0 -1
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/README.md +0 -43
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/config_template.yaml +0 -55
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/env_template.py +0 -151
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/loader_template.py +0 -87
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/__init__.py +0 -5
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/adapter.py +0 -428
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/dataloader.py +0 -123
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/analyst_error.md +0 -55
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/analyst_success.md +0 -33
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/rollout_no_history.md +0 -8
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/rollout_with_history.md +0 -9
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/rollout_with_memory.md +0 -16
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/reflect.py +0 -4
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/rollout.py +0 -366
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/skills/initial.md +0 -45
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/__init__.py +0 -9
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/alfworld_envs.py +0 -221
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/alfworld_projection.py +0 -60
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/alfworld_prompts.py +0 -8
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/config_tw.yaml +0 -145
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/env_base.py +0 -84
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/env_manager.py +0 -139
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/memory.py +0 -87
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/base.py +0 -329
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/__init__.py +0 -1
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/adapter.py +0 -90
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/dataloader.py +0 -61
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/evaluator.py +0 -113
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/prompts/analyst_error.md +0 -35
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/prompts/analyst_success.md +0 -24
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/prompts/rollout_system.md +0 -12
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/rollout.py +0 -391
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/skills/initial.md +0 -11
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/__init__.py +0 -1
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/adapter.py +0 -129
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/dataloader.py +0 -308
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/evaluator.py +0 -62
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/prompts/analyst_error.md +0 -37
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/prompts/analyst_success.md +0 -25
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/prompts/rollout_system.md +0 -12
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/reflect.py +0 -4
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/rollout.py +0 -434
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/skills/initial.md +0 -16
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/__init__.py +0 -1
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/adapter.py +0 -112
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/dataloader.py +0 -71
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/evaluator.py +0 -46
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/prompts/analyst_error.md +0 -37
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/prompts/analyst_success.md +0 -25
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/prompts/rollout_system.md +0 -15
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/rollout.py +0 -799
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/skills/initial.md +0 -15
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/tool_runtime.py +0 -552
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/__init__.py +0 -1
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/adapter.py +0 -96
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/dataloader.py +0 -42
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/evaluator.py +0 -100
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/prompts/analyst_error.md +0 -46
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/prompts/analyst_success.md +0 -32
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/prompts/rollout_system.md +0 -13
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/reflect.py +0 -4
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/rollout.py +0 -494
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/skills/initial.md +0 -3
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/__init__.py +0 -5
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/adapter.py +0 -159
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/codegen_agent.py +0 -731
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/dataloader.py +0 -37
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/evaluator.py +0 -158
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/executor.py +0 -67
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/analyst_error.md +0 -46
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/analyst_success.md +0 -32
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/codegen_system.md +0 -1
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/critical_rules.md +0 -9
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/react_system.md +0 -21
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/react_agent.py +0 -395
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/reflect.py +0 -4
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/rollout.py +0 -979
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/skills/initial.md +0 -56
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/evaluation/__init__.py +0 -13
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/evaluation/gate.py +0 -148
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/gradient/__init__.py +0 -15
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/gradient/aggregate.py +0 -253
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/gradient/reflect.py +0 -635
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/__init__.py +0 -514
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/azure_openai.py +0 -915
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/backend_config.py +0 -185
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/claude_backend.py +0 -371
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/codex_backend.py +0 -666
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/codex_harness.py +0 -1057
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/common.py +0 -229
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/minimax_backend.py +0 -277
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/qwen_backend.py +0 -456
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/router.py +0 -236
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/__init__.py +0 -15
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/appendix.py +0 -156
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/clip.py +0 -109
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/lr_autonomous.py +0 -108
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/meta_skill.py +0 -79
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/rewrite.py +0 -59
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/scheduler.py +0 -127
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/select.py +0 -4
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/skill.py +0 -201
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/skill_aware.py +0 -206
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/slow_update.py +0 -396
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/update_modes.py +0 -135
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/__init__.py +0 -63
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_error.md +0 -41
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_error_full_rewrite.md +0 -32
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_error_rewrite.md +0 -44
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_success.md +0 -36
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_success_full_rewrite.md +0 -30
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_success_rewrite.md +0 -33
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/lr_autonomous.md +0 -20
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_failure.md +0 -30
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_failure_full_rewrite.md +0 -28
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_failure_rewrite.md +0 -26
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_final.md +0 -33
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_final_full_rewrite.md +0 -28
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_final_rewrite.md +0 -25
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_success.md +0 -28
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_success_full_rewrite.md +0 -28
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_success_rewrite.md +0 -25
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/meta_skill.md +0 -40
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/ranking.md +0 -20
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/ranking_rewrite.md +0 -15
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/rewrite_skill.md +0 -25
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/slow_update.md +0 -60
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/scheduler/__init__.py +0 -8
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/types.py +0 -306
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/utils/__init__.py +0 -4
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/utils/json_utils.py +0 -172
- package/template/skills/skillopt-sleep/scripts/framework/skillopt/utils/scoring.py +0 -28
- package/template/skills/skillopt-sleep/scripts/python/__init__.py +0 -20
- package/template/skills/skillopt-sleep/scripts/python/__main__.py +0 -343
- package/template/skills/skillopt-sleep/scripts/python/backend.py +0 -1371
- package/template/skills/skillopt-sleep/scripts/python/budget.py +0 -75
- package/template/skills/skillopt-sleep/scripts/python/config.py +0 -162
- package/template/skills/skillopt-sleep/scripts/python/consolidate.py +0 -238
- package/template/skills/skillopt-sleep/scripts/python/cycle.py +0 -291
- package/template/skills/skillopt-sleep/scripts/python/dream.py +0 -138
- package/template/skills/skillopt-sleep/scripts/python/experiments/__init__.py +0 -1
- package/template/skills/skillopt-sleep/scripts/python/experiments/gbrain_bench.py +0 -119
- package/template/skills/skillopt-sleep/scripts/python/experiments/personas.py +0 -86
- package/template/skills/skillopt-sleep/scripts/python/experiments/report.py +0 -132
- package/template/skills/skillopt-sleep/scripts/python/experiments/run_experiment.py +0 -178
- package/template/skills/skillopt-sleep/scripts/python/experiments/run_gbrain.py +0 -209
- package/template/skills/skillopt-sleep/scripts/python/experiments/run_transfer.py +0 -155
- package/template/skills/skillopt-sleep/scripts/python/experiments/sweep.py +0 -164
- package/template/skills/skillopt-sleep/scripts/python/gate.py +0 -50
- package/template/skills/skillopt-sleep/scripts/python/harvest.py +0 -304
- package/template/skills/skillopt-sleep/scripts/python/harvest_codex.py +0 -253
- package/template/skills/skillopt-sleep/scripts/python/harvest_sources.py +0 -41
- package/template/skills/skillopt-sleep/scripts/python/judges.py +0 -84
- package/template/skills/skillopt-sleep/scripts/python/llm_miner.py +0 -134
- package/template/skills/skillopt-sleep/scripts/python/memory.py +0 -129
- package/template/skills/skillopt-sleep/scripts/python/mine.py +0 -312
- package/template/skills/skillopt-sleep/scripts/python/replay.py +0 -146
- package/template/skills/skillopt-sleep/scripts/python/rollout.py +0 -153
- package/template/skills/skillopt-sleep/scripts/python/scheduler.py +0 -138
- package/template/skills/skillopt-sleep/scripts/python/slow_update.py +0 -142
- package/template/skills/skillopt-sleep/scripts/python/staging.py +0 -103
- package/template/skills/skillopt-sleep/scripts/python/state.py +0 -96
- package/template/skills/skillopt-sleep/scripts/python/tasks_file.py +0 -81
- package/template/skills/skillopt-sleep/scripts/python/types.py +0 -146
- package/template/skills/skillopt-sleep/scripts/shell/__init__.py +0 -0
- package/template/skills/skillopt-sleep/scripts/shell/eval_only.py +0 -466
- package/template/skills/skillopt-sleep/scripts/shell/materialize_searchqa.py +0 -148
- package/template/skills/skillopt-sleep/scripts/shell/run_alfworld.sh +0 -60
- package/template/skills/skillopt-sleep/scripts/shell/run_searchqa.sh +0 -40
- package/template/skills/skillopt-sleep/scripts/shell/run_spreadsheetbench.sh +0 -39
- package/template/skills/skillopt-sleep/scripts/shell/train.py +0 -556
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { GENERIC_FONTS, OVERUSED_FONTS } from '../../shared/constants.mjs';
|
|
5
|
-
import {
|
|
6
|
-
checkSourceDesignSystem,
|
|
7
|
-
collectStaticDesignSystemFindings,
|
|
8
|
-
mergeDesignSystemFindings,
|
|
9
|
-
} from '../../design-system.mjs';
|
|
10
|
-
import { isFullPage } from '../../shared/page.mjs';
|
|
11
|
-
import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
|
|
12
|
-
import { finding } from '../../findings.mjs';
|
|
13
|
-
import { profileFindings, profileStep, profileStepAsync } from '../../profile/profiler.mjs';
|
|
14
|
-
import {
|
|
15
|
-
checkElementBorders,
|
|
16
|
-
checkElementClippedOverflow,
|
|
17
|
-
checkElementColors,
|
|
18
|
-
checkElementGlow,
|
|
19
|
-
checkElementGptBorderShadow,
|
|
20
|
-
checkElementHeroEyebrow,
|
|
21
|
-
checkElementIconTile,
|
|
22
|
-
checkElementItalicSerif,
|
|
23
|
-
checkElementMotion,
|
|
24
|
-
checkElementOversizedH1,
|
|
25
|
-
checkElementQuality,
|
|
26
|
-
checkCreamPalette,
|
|
27
|
-
checkHtmlPatterns,
|
|
28
|
-
checkPageLayout,
|
|
29
|
-
checkPageQualityFromDoc,
|
|
30
|
-
checkRepeatedSectionKickersFromDoc,
|
|
31
|
-
resolveBackground,
|
|
32
|
-
resolveBorderRadiusPx,
|
|
33
|
-
} from '../../rules/checks.mjs';
|
|
34
|
-
import { filterByProviders } from '../../registry/antipatterns.mjs';
|
|
35
|
-
import { detectText, runTextContentAnalyzers } from '../regex/detect-text.mjs';
|
|
36
|
-
import {
|
|
37
|
-
StaticDocument,
|
|
38
|
-
buildStaticStyleMap,
|
|
39
|
-
buildStaticWindow,
|
|
40
|
-
collectStaticCssText,
|
|
41
|
-
} from './css-cascade.mjs';
|
|
42
|
-
|
|
43
|
-
function checkStaticPageTypography(document, window) {
|
|
44
|
-
const findings = [];
|
|
45
|
-
const fonts = new Set();
|
|
46
|
-
const overusedFound = new Set();
|
|
47
|
-
for (const el of document.querySelectorAll('p, h1, h2, h3, h4, h5, h6, li, td, th, dd, blockquote, figcaption, a, button, label, span, div')) {
|
|
48
|
-
const hasText = el.childNodes.some(n => n.nodeType === 3 && n.textContent.trim().length > 0);
|
|
49
|
-
if (!hasText) continue;
|
|
50
|
-
const ff = window.getComputedStyle(el).fontFamily || '';
|
|
51
|
-
const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
|
|
52
|
-
const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
|
|
53
|
-
if (!primary) continue;
|
|
54
|
-
fonts.add(primary);
|
|
55
|
-
if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
|
|
56
|
-
}
|
|
57
|
-
for (const font of overusedFound) {
|
|
58
|
-
findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
|
|
59
|
-
}
|
|
60
|
-
if (fonts.size === 1 && document.querySelectorAll('*').length >= 20) {
|
|
61
|
-
findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
|
|
62
|
-
}
|
|
63
|
-
const sizes = new Set();
|
|
64
|
-
for (const el of document.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div')) {
|
|
65
|
-
const fontSize = parseFloat(window.getComputedStyle(el).fontSize);
|
|
66
|
-
if (fontSize >= 8 && fontSize < 200) sizes.add(Math.round(fontSize * 10) / 10);
|
|
67
|
-
}
|
|
68
|
-
if (sizes.size >= 3) {
|
|
69
|
-
const sorted = [...sizes].sort((a, b) => a - b);
|
|
70
|
-
const ratio = sorted[sorted.length - 1] / sorted[0];
|
|
71
|
-
if (ratio < 2.0) {
|
|
72
|
-
findings.push({ id: 'flat-type-hierarchy', snippet: `Sizes: ${sorted.map(s => s + 'px').join(', ')} (ratio ${ratio.toFixed(1)}:1)` });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return findings;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function checkElementBrokenImage(el) {
|
|
79
|
-
const src = (el.getAttribute && el.getAttribute('src')) ?? el.attribs?.src;
|
|
80
|
-
// Missing src attribute entirely
|
|
81
|
-
if (src === undefined || src === null) {
|
|
82
|
-
return [{ id: 'broken-image', snippet: '<img> with no src attribute' }];
|
|
83
|
-
}
|
|
84
|
-
const trimmed = String(src).trim();
|
|
85
|
-
// Empty or placeholder-only src values
|
|
86
|
-
if (trimmed === '' || trimmed === '#') {
|
|
87
|
-
return [{ id: 'broken-image', snippet: `<img src="${src}">` }];
|
|
88
|
-
}
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const STATIC_ELEMENT_RULES = [
|
|
93
|
-
{ id: 'border-rules', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementBorders(tag, style, null, resolveBorderRadiusPx(el, style, parseFloat(style.width) || 0, window)) },
|
|
94
|
-
{ id: 'color-rules', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementColors(el, style, tag, window, customPropMap, false) },
|
|
95
|
-
{ id: 'dark-glow', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementGlow(tag, style, resolveBackground(el.parentElement || el, window, customPropMap)) },
|
|
96
|
-
{ id: 'motion-rules', selector: '*', run: (el, tag, style) => checkElementMotion(tag, style) },
|
|
97
|
-
{ id: 'icon-tile-stack', selector: 'h1,h2,h3,h4,h5,h6', run: (el, tag, _style, window) => checkElementIconTile(el, tag, window) },
|
|
98
|
-
{ id: 'italic-serif-display', selector: 'h1,h2', run: (el, tag, style) => checkElementItalicSerif(el, style, tag) },
|
|
99
|
-
{ id: 'hero-eyebrow-chip', selector: 'h1', run: (el, tag, style, window, customPropMap) => checkElementHeroEyebrow(el, style, tag, window, customPropMap) },
|
|
100
|
-
{ id: 'broken-image', selector: 'img', run: (el) => checkElementBrokenImage(el) },
|
|
101
|
-
{ id: 'quality-rules', selector: '*', run: (el, tag, style, window) => checkElementQuality(el, style, tag, window) },
|
|
102
|
-
{ id: 'oversized-h1', selector: 'h1', run: (el, tag, style, window) => checkElementOversizedH1(el, style, tag, window) },
|
|
103
|
-
{ id: 'clipped-overflow-container', selector: '*', run: (el, tag, style, window) => checkElementClippedOverflow(el, style, tag, window) },
|
|
104
|
-
{ id: 'gpt-thin-border-wide-shadow', selector: '*', run: (el, tag, style) => checkElementGptBorderShadow(el, style) },
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
async function detectHtml(filePath, options = {}) {
|
|
108
|
-
const profile = options?.profile;
|
|
109
|
-
const html = profileStep(profile, {
|
|
110
|
-
engine: 'static-html',
|
|
111
|
-
phase: 'setup',
|
|
112
|
-
ruleId: 'read-html',
|
|
113
|
-
target: filePath,
|
|
114
|
-
}, () => fs.readFileSync(filePath, 'utf-8'));
|
|
115
|
-
|
|
116
|
-
let modules;
|
|
117
|
-
try {
|
|
118
|
-
modules = await profileStepAsync(profile, {
|
|
119
|
-
engine: 'static-html',
|
|
120
|
-
phase: 'setup',
|
|
121
|
-
ruleId: 'import-static-parser',
|
|
122
|
-
target: filePath,
|
|
123
|
-
}, async () => {
|
|
124
|
-
const [htmlparser2, cssSelect, csstree, domutils] = await Promise.all([
|
|
125
|
-
import('htmlparser2'),
|
|
126
|
-
import('css-select'),
|
|
127
|
-
import('css-tree'),
|
|
128
|
-
import('domutils'),
|
|
129
|
-
]);
|
|
130
|
-
return {
|
|
131
|
-
parseDocument: htmlparser2.parseDocument,
|
|
132
|
-
selectAll: cssSelect.selectAll,
|
|
133
|
-
selectOne: cssSelect.selectOne,
|
|
134
|
-
is: cssSelect.is,
|
|
135
|
-
csstree,
|
|
136
|
-
domutils,
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
} catch {
|
|
140
|
-
return detectText(html, filePath, options);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const resolvedPath = path.resolve(filePath);
|
|
144
|
-
const fileDir = path.dirname(resolvedPath);
|
|
145
|
-
const root = profileStep(profile, {
|
|
146
|
-
engine: 'static-html',
|
|
147
|
-
phase: 'parse-html',
|
|
148
|
-
ruleId: 'parse-document',
|
|
149
|
-
target: filePath,
|
|
150
|
-
}, () => modules.parseDocument(html, { lowerCaseAttributeNames: false, lowerCaseTags: true }));
|
|
151
|
-
|
|
152
|
-
const cssText = collectStaticCssText(root, fileDir, profile, filePath, modules);
|
|
153
|
-
const document = new StaticDocument(root, modules);
|
|
154
|
-
buildStaticStyleMap(root, document, cssText, modules, profile, filePath);
|
|
155
|
-
const window = buildStaticWindow(document);
|
|
156
|
-
|
|
157
|
-
const customPropMap = null;
|
|
158
|
-
|
|
159
|
-
const findings = [];
|
|
160
|
-
const runElementCheck = (ruleId, callback) => profile
|
|
161
|
-
? profileFindings(profile, { engine: 'static-html', phase: 'element', ruleId, target: filePath }, callback)
|
|
162
|
-
: callback();
|
|
163
|
-
|
|
164
|
-
const visitedByRule = new Map();
|
|
165
|
-
for (const rule of STATIC_ELEMENT_RULES) {
|
|
166
|
-
const elements = document.querySelectorAll(rule.selector);
|
|
167
|
-
visitedByRule.set(rule.id, elements.length);
|
|
168
|
-
for (const el of elements) {
|
|
169
|
-
const tag = el.tagName.toLowerCase();
|
|
170
|
-
const style = window.getComputedStyle(el);
|
|
171
|
-
for (const f of runElementCheck(rule.id, () => rule.run(el, tag, style, window, customPropMap))) {
|
|
172
|
-
findings.push(finding(f.id, filePath, f.snippet));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (options?.designSystem) {
|
|
178
|
-
const sourceDesignFindings = profileFindings(profile, {
|
|
179
|
-
engine: 'static-html',
|
|
180
|
-
phase: 'source',
|
|
181
|
-
ruleId: 'design-system',
|
|
182
|
-
target: filePath,
|
|
183
|
-
}, () => checkSourceDesignSystem(html, filePath, { designSystem: options.designSystem }));
|
|
184
|
-
const staticDesignFindings = profileFindings(profile, {
|
|
185
|
-
engine: 'static-html',
|
|
186
|
-
phase: 'page',
|
|
187
|
-
ruleId: 'design-system',
|
|
188
|
-
target: filePath,
|
|
189
|
-
}, () => collectStaticDesignSystemFindings(document, window, filePath, options.designSystem));
|
|
190
|
-
findings.push(...mergeDesignSystemFindings(staticDesignFindings, sourceDesignFindings));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (isFullPage(html)) {
|
|
194
|
-
const runPageCheck = (ruleId, callback) => profile
|
|
195
|
-
? profileFindings(profile, { engine: 'static-html', phase: 'page', ruleId, target: filePath }, callback)
|
|
196
|
-
: callback();
|
|
197
|
-
for (const f of runPageCheck('typography-rules', () => checkStaticPageTypography(document, window))) {
|
|
198
|
-
findings.push(finding(f.id, filePath, f.snippet));
|
|
199
|
-
}
|
|
200
|
-
for (const f of runPageCheck('repeated-section-kickers', () => checkRepeatedSectionKickersFromDoc(document, window))) {
|
|
201
|
-
findings.push(finding(f.id, filePath, f.snippet));
|
|
202
|
-
}
|
|
203
|
-
for (const f of runPageCheck('layout-rules', () => checkPageLayout(document, window))) {
|
|
204
|
-
findings.push(finding(f.id, filePath, f.snippet));
|
|
205
|
-
}
|
|
206
|
-
for (const f of runPageCheck('cream-palette', () => checkCreamPalette(document, window))) {
|
|
207
|
-
findings.push(finding(f.id, filePath, f.snippet));
|
|
208
|
-
}
|
|
209
|
-
for (const f of runPageCheck('skipped-heading', () => checkPageQualityFromDoc(document))) {
|
|
210
|
-
findings.push(finding(f.id, filePath, f.snippet));
|
|
211
|
-
}
|
|
212
|
-
for (const f of runPageCheck('html-patterns', () => checkHtmlPatterns(html).filter(item =>
|
|
213
|
-
item.id !== 'bounce-easing' && item.id !== 'layout-transition'
|
|
214
|
-
))) {
|
|
215
|
-
findings.push(finding(f.id, filePath, f.snippet));
|
|
216
|
-
}
|
|
217
|
-
// Text-content analyzers (em-dash overuse, marketing buzzwords,
|
|
218
|
-
// numbered section markers, aphoristic cadence) live in the regex
|
|
219
|
-
// engine. Call them from here so .html files get the same coverage
|
|
220
|
-
// as .css/.tsx files. These are scoped to text content only and
|
|
221
|
-
// don't overlap with static-html's element/page rules.
|
|
222
|
-
for (const f of runPageCheck('text-content', () => runTextContentAnalyzers(html, filePath, options))) {
|
|
223
|
-
findings.push(finding(f.antipattern, filePath, f.snippet));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const byProvider = filterByProviders(findings, options.providers);
|
|
228
|
-
// Static-HTML findings carry no line number, so only whole-file
|
|
229
|
-
// `impeccable-disable` directives apply here — exactly the standalone-document
|
|
230
|
-
// waiver this primitive targets. Bypassed by `--no-config` / `--no-inline-ignores`.
|
|
231
|
-
return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, html);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export { checkStaticPageTypography, STATIC_ELEMENT_RULES, detectHtml };
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
function sanitizeScreenshotClip(clip, viewport) {
|
|
2
|
-
if (!clip) return null;
|
|
3
|
-
const x = Math.max(0, Math.floor(clip.x || 0));
|
|
4
|
-
const y = Math.max(0, Math.floor(clip.y || 0));
|
|
5
|
-
const width = Math.min(
|
|
6
|
-
Math.max(1, Math.ceil(clip.width || 0)),
|
|
7
|
-
Math.max(1, viewport?.width || 1600),
|
|
8
|
-
);
|
|
9
|
-
const height = Math.min(
|
|
10
|
-
Math.max(1, Math.ceil(clip.height || 0)),
|
|
11
|
-
320,
|
|
12
|
-
);
|
|
13
|
-
if (width < 1 || height < 1) return null;
|
|
14
|
-
return { x, y, width, height };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function compareScreenshotContrast(page, beforeBase64, afterBase64, candidate) {
|
|
18
|
-
return page.evaluate(async ({ beforeBase64, afterBase64, candidate }) => {
|
|
19
|
-
const loadImage = (base64) => new Promise((resolve, reject) => {
|
|
20
|
-
const img = new Image();
|
|
21
|
-
img.onload = () => resolve(img);
|
|
22
|
-
img.onerror = () => reject(new Error('Could not decode contrast screenshot'));
|
|
23
|
-
img.src = `data:image/png;base64,${base64}`;
|
|
24
|
-
});
|
|
25
|
-
const [before, after] = await Promise.all([loadImage(beforeBase64), loadImage(afterBase64)]);
|
|
26
|
-
const width = Math.min(before.width, after.width);
|
|
27
|
-
const height = Math.min(before.height, after.height);
|
|
28
|
-
if (width < 1 || height < 1) return null;
|
|
29
|
-
|
|
30
|
-
const canvas = document.createElement('canvas');
|
|
31
|
-
canvas.width = width;
|
|
32
|
-
canvas.height = height;
|
|
33
|
-
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
34
|
-
if (!ctx) return null;
|
|
35
|
-
|
|
36
|
-
ctx.drawImage(before, 0, 0, width, height);
|
|
37
|
-
const beforePixels = ctx.getImageData(0, 0, width, height).data;
|
|
38
|
-
ctx.clearRect(0, 0, width, height);
|
|
39
|
-
ctx.drawImage(after, 0, 0, width, height);
|
|
40
|
-
const afterPixels = ctx.getImageData(0, 0, width, height).data;
|
|
41
|
-
|
|
42
|
-
const luminance = ({ r, g, b }) => {
|
|
43
|
-
const convert = c => {
|
|
44
|
-
const v = c / 255;
|
|
45
|
-
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
46
|
-
};
|
|
47
|
-
return 0.2126 * convert(r) + 0.7152 * convert(g) + 0.0722 * convert(b);
|
|
48
|
-
};
|
|
49
|
-
const ratio = (a, b) => {
|
|
50
|
-
const l1 = luminance(a);
|
|
51
|
-
const l2 = luminance(b);
|
|
52
|
-
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const cssTextColor = candidate.textColor && !candidate.preferRenderedForeground
|
|
56
|
-
? {
|
|
57
|
-
r: candidate.textColor.r,
|
|
58
|
-
g: candidate.textColor.g,
|
|
59
|
-
b: candidate.textColor.b,
|
|
60
|
-
}
|
|
61
|
-
: null;
|
|
62
|
-
const ratios = [];
|
|
63
|
-
let glyphPixels = 0;
|
|
64
|
-
let strongestDelta = 0;
|
|
65
|
-
for (let i = 0; i < beforePixels.length; i += 4) {
|
|
66
|
-
const delta = Math.abs(beforePixels[i] - afterPixels[i])
|
|
67
|
-
+ Math.abs(beforePixels[i + 1] - afterPixels[i + 1])
|
|
68
|
-
+ Math.abs(beforePixels[i + 2] - afterPixels[i + 2])
|
|
69
|
-
+ Math.abs(beforePixels[i + 3] - afterPixels[i + 3]);
|
|
70
|
-
strongestDelta = Math.max(strongestDelta, delta);
|
|
71
|
-
if (delta < 10) continue;
|
|
72
|
-
glyphPixels++;
|
|
73
|
-
const fg = cssTextColor || {
|
|
74
|
-
r: beforePixels[i],
|
|
75
|
-
g: beforePixels[i + 1],
|
|
76
|
-
b: beforePixels[i + 2],
|
|
77
|
-
};
|
|
78
|
-
const bg = {
|
|
79
|
-
r: afterPixels[i],
|
|
80
|
-
g: afterPixels[i + 1],
|
|
81
|
-
b: afterPixels[i + 2],
|
|
82
|
-
};
|
|
83
|
-
ratios.push(ratio(fg, bg));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (ratios.length < 8) {
|
|
87
|
-
return {
|
|
88
|
-
glyphPixels,
|
|
89
|
-
strongestDelta,
|
|
90
|
-
worstRatio: null,
|
|
91
|
-
p10Ratio: null,
|
|
92
|
-
medianRatio: null,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
ratios.sort((a, b) => a - b);
|
|
97
|
-
const pick = pct => ratios[Math.min(ratios.length - 1, Math.max(0, Math.floor((pct / 100) * ratios.length)))];
|
|
98
|
-
return {
|
|
99
|
-
glyphPixels,
|
|
100
|
-
strongestDelta,
|
|
101
|
-
worstRatio: ratios[0],
|
|
102
|
-
p10Ratio: pick(10),
|
|
103
|
-
medianRatio: pick(50),
|
|
104
|
-
};
|
|
105
|
-
}, { beforeBase64, afterBase64, candidate });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function captureVisualContrastCandidate(page, candidate, viewport) {
|
|
109
|
-
const clip = sanitizeScreenshotClip(candidate.clip, viewport);
|
|
110
|
-
if (!clip) return null;
|
|
111
|
-
|
|
112
|
-
const beforeBase64 = await page.screenshot({
|
|
113
|
-
encoding: 'base64',
|
|
114
|
-
clip,
|
|
115
|
-
captureBeyondViewport: true,
|
|
116
|
-
});
|
|
117
|
-
const token = `impeccable-contrast-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
118
|
-
const applied = await page.evaluate(({ selector, token, backgroundClipText }) => {
|
|
119
|
-
let el;
|
|
120
|
-
try {
|
|
121
|
-
el = document.querySelector(selector);
|
|
122
|
-
} catch {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
if (!el) return false;
|
|
126
|
-
let style = document.getElementById('impeccable-visual-contrast-hide-style');
|
|
127
|
-
if (!style) {
|
|
128
|
-
style = document.createElement('style');
|
|
129
|
-
style.id = 'impeccable-visual-contrast-hide-style';
|
|
130
|
-
style.textContent = [
|
|
131
|
-
'[data-impeccable-visual-contrast-target] {',
|
|
132
|
-
' color: transparent !important;',
|
|
133
|
-
' -webkit-text-fill-color: transparent !important;',
|
|
134
|
-
' text-shadow: none !important;',
|
|
135
|
-
'}',
|
|
136
|
-
'[data-impeccable-visual-contrast-target][data-impeccable-bgclip-text="true"] {',
|
|
137
|
-
' background-image: none !important;',
|
|
138
|
-
'}',
|
|
139
|
-
].join('\n');
|
|
140
|
-
document.head.appendChild(style);
|
|
141
|
-
}
|
|
142
|
-
el.setAttribute('data-impeccable-visual-contrast-target', token);
|
|
143
|
-
if (backgroundClipText) el.setAttribute('data-impeccable-bgclip-text', 'true');
|
|
144
|
-
return true;
|
|
145
|
-
}, {
|
|
146
|
-
selector: candidate.selector,
|
|
147
|
-
token,
|
|
148
|
-
backgroundClipText: candidate.backgroundClipText,
|
|
149
|
-
});
|
|
150
|
-
if (!applied) return null;
|
|
151
|
-
|
|
152
|
-
let afterBase64;
|
|
153
|
-
try {
|
|
154
|
-
afterBase64 = await page.screenshot({
|
|
155
|
-
encoding: 'base64',
|
|
156
|
-
clip,
|
|
157
|
-
captureBeyondViewport: true,
|
|
158
|
-
});
|
|
159
|
-
} finally {
|
|
160
|
-
await page.evaluate(({ selector }) => {
|
|
161
|
-
try {
|
|
162
|
-
const el = document.querySelector(selector);
|
|
163
|
-
if (el) {
|
|
164
|
-
el.removeAttribute('data-impeccable-visual-contrast-target');
|
|
165
|
-
el.removeAttribute('data-impeccable-bgclip-text');
|
|
166
|
-
}
|
|
167
|
-
} catch {
|
|
168
|
-
// Ignore invalid or stale selectors during cleanup.
|
|
169
|
-
}
|
|
170
|
-
}, { selector: candidate.selector }).catch(() => {});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const metrics = await compareScreenshotContrast(page, beforeBase64, afterBase64, candidate);
|
|
174
|
-
if (!metrics || !Number.isFinite(metrics.p10Ratio) || metrics.glyphPixels < 8) return null;
|
|
175
|
-
const measuredRatio = metrics.p10Ratio;
|
|
176
|
-
if (measuredRatio >= candidate.threshold) return null;
|
|
177
|
-
const textLabel = candidate.text ? ` "${candidate.text}"` : '';
|
|
178
|
-
const reasonLabel = (candidate.reasons || []).slice(0, 3).join(', ') || 'visual background';
|
|
179
|
-
return {
|
|
180
|
-
id: 'low-contrast',
|
|
181
|
-
snippet: `pixel contrast ${measuredRatio.toFixed(1)}:1 median ${metrics.medianRatio.toFixed(1)}:1 (need ${candidate.threshold}:1) on ${reasonLabel}${textLabel}`,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export {
|
|
186
|
-
sanitizeScreenshotClip,
|
|
187
|
-
compareScreenshotContrast,
|
|
188
|
-
captureVisualContrastCandidate,
|
|
189
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { getAntipattern } from './registry/antipatterns.mjs';
|
|
2
|
-
|
|
3
|
-
function getAP(id) {
|
|
4
|
-
return getAntipattern(id);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function finding(id, filePath, snippet, line = 0) {
|
|
8
|
-
const ap = getAP(id);
|
|
9
|
-
return { antipattern: id, name: ap.name, description: ap.description, severity: ap.severity || 'warning', file: filePath, line, snippet };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { getAP, finding };
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
// File walker
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
const SKIP_DIRS = new Set([
|
|
9
|
-
'node_modules', '.git', 'dist', 'build', '.next', '.nuxt', '.output',
|
|
10
|
-
'.svelte-kit', '__pycache__', '.turbo', '.vercel',
|
|
11
|
-
]);
|
|
12
|
-
|
|
13
|
-
const SCANNABLE_EXTENSIONS = new Set([
|
|
14
|
-
'.html', '.htm', '.css', '.scss', '.sass', '.less',
|
|
15
|
-
'.jsx', '.tsx', '.js', '.ts',
|
|
16
|
-
'.vue', '.svelte', '.astro',
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
|
-
const HTML_EXTENSIONS = new Set(['.html', '.htm']);
|
|
20
|
-
|
|
21
|
-
function walkDir(dir) {
|
|
22
|
-
const files = [];
|
|
23
|
-
let entries;
|
|
24
|
-
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return files; }
|
|
25
|
-
for (const entry of entries) {
|
|
26
|
-
if (SKIP_DIRS.has(entry.name)) continue;
|
|
27
|
-
const full = path.join(dir, entry.name);
|
|
28
|
-
if (entry.isDirectory()) files.push(...walkDir(full));
|
|
29
|
-
else if (SCANNABLE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) files.push(full);
|
|
30
|
-
}
|
|
31
|
-
return files;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
// Import graph (multi-file awareness)
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
|
|
39
|
-
function resolveImport(specifier, fromDir, fileSet) {
|
|
40
|
-
if (!/^[./]/.test(specifier)) return null; // skip bare specifiers
|
|
41
|
-
const base = path.resolve(fromDir, specifier);
|
|
42
|
-
if (fileSet.has(base)) return base;
|
|
43
|
-
for (const ext of SCANNABLE_EXTENSIONS) {
|
|
44
|
-
const withExt = base + ext;
|
|
45
|
-
if (fileSet.has(withExt)) return withExt;
|
|
46
|
-
}
|
|
47
|
-
// index file convention
|
|
48
|
-
for (const ext of SCANNABLE_EXTENSIONS) {
|
|
49
|
-
const indexFile = path.join(base, 'index' + ext);
|
|
50
|
-
if (fileSet.has(indexFile)) return indexFile;
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function buildImportGraph(files) {
|
|
56
|
-
const fileSet = new Set(files);
|
|
57
|
-
const graph = new Map();
|
|
58
|
-
|
|
59
|
-
for (const file of files) {
|
|
60
|
-
const content = fs.readFileSync(file, 'utf-8');
|
|
61
|
-
const dir = path.dirname(file);
|
|
62
|
-
const imports = new Set();
|
|
63
|
-
|
|
64
|
-
// ES imports: import ... from '...' and import '...'
|
|
65
|
-
const esRe = /import\s+(?:[\s\S]*?from\s+)?['"]([^'"]+)['"]/g;
|
|
66
|
-
let m;
|
|
67
|
-
while ((m = esRe.exec(content)) !== null) {
|
|
68
|
-
const resolved = resolveImport(m[1], dir, fileSet);
|
|
69
|
-
if (resolved) imports.add(resolved);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// CSS @import
|
|
73
|
-
const cssRe = /@import\s+(?:url\(\s*)?['"]?([^'");\s]+)['"]?\s*\)?/g;
|
|
74
|
-
while ((m = cssRe.exec(content)) !== null) {
|
|
75
|
-
const resolved = resolveImport(m[1], dir, fileSet);
|
|
76
|
-
if (resolved) imports.add(resolved);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// SCSS @use / @forward
|
|
80
|
-
const scssRe = /@(?:use|forward)\s+['"]([^'"]+)['"]/g;
|
|
81
|
-
while ((m = scssRe.exec(content)) !== null) {
|
|
82
|
-
const resolved = resolveImport(m[1], dir, fileSet);
|
|
83
|
-
if (resolved) imports.add(resolved);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
graph.set(file, imports);
|
|
87
|
-
}
|
|
88
|
-
return graph;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// ---------------------------------------------------------------------------
|
|
92
|
-
// Framework dev server detection
|
|
93
|
-
// ---------------------------------------------------------------------------
|
|
94
|
-
|
|
95
|
-
const FRAMEWORK_CONFIGS = [
|
|
96
|
-
{ name: 'Next.js', files: ['next.config.js', 'next.config.mjs', 'next.config.ts'], defaultPort: 3000,
|
|
97
|
-
portRe: /port\s*[:=]\s*(\d+)/,
|
|
98
|
-
fingerprint: { header: 'x-powered-by', value: /next/i } },
|
|
99
|
-
{ name: 'SvelteKit', files: ['svelte.config.js', 'svelte.config.ts'], defaultPort: 5173,
|
|
100
|
-
portRe: /port\s*[:=]\s*(\d+)/,
|
|
101
|
-
fingerprint: { header: 'x-sveltekit-page', value: null } },
|
|
102
|
-
{ name: 'Nuxt', files: ['nuxt.config.js', 'nuxt.config.ts'], defaultPort: 3000,
|
|
103
|
-
portRe: /port\s*[:=]\s*(\d+)/,
|
|
104
|
-
fingerprint: { header: 'x-powered-by', value: /nuxt/i } },
|
|
105
|
-
{ name: 'Vite', files: ['vite.config.js', 'vite.config.ts', 'vite.config.mjs'], defaultPort: 5173,
|
|
106
|
-
portRe: /port\s*[:=]\s*(\d+)/,
|
|
107
|
-
fingerprint: { body: /@vite\/client/ } },
|
|
108
|
-
{ name: 'Astro', files: ['astro.config.js', 'astro.config.ts', 'astro.config.mjs'], defaultPort: 4321,
|
|
109
|
-
portRe: /port\s*[:=]\s*(\d+)/,
|
|
110
|
-
fingerprint: { body: /astro/i } },
|
|
111
|
-
{ name: 'Angular', files: ['angular.json'], defaultPort: 4200,
|
|
112
|
-
portRe: /"port"\s*:\s*(\d+)/,
|
|
113
|
-
fingerprint: { body: /ng-version/i } },
|
|
114
|
-
{ name: 'Remix', files: ['remix.config.js', 'remix.config.ts'], defaultPort: 3000,
|
|
115
|
-
portRe: /port\s*[:=]\s*(\d+)/,
|
|
116
|
-
fingerprint: { header: 'x-powered-by', value: /remix/i } },
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
function detectFrameworkConfig(dir) {
|
|
120
|
-
let entries;
|
|
121
|
-
try { entries = fs.readdirSync(dir); } catch { return null; }
|
|
122
|
-
const entrySet = new Set(entries);
|
|
123
|
-
|
|
124
|
-
for (const cfg of FRAMEWORK_CONFIGS) {
|
|
125
|
-
const match = cfg.files.find(f => entrySet.has(f));
|
|
126
|
-
if (!match) continue;
|
|
127
|
-
|
|
128
|
-
const configPath = path.join(dir, match);
|
|
129
|
-
let port = cfg.defaultPort;
|
|
130
|
-
try {
|
|
131
|
-
const content = fs.readFileSync(configPath, 'utf-8');
|
|
132
|
-
const portMatch = content.match(cfg.portRe);
|
|
133
|
-
if (portMatch) port = parseInt(portMatch[1], 10);
|
|
134
|
-
} catch { /* use default */ }
|
|
135
|
-
|
|
136
|
-
return { name: cfg.name, port, configPath, fingerprint: cfg.fingerprint };
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Check if a port is listening and optionally verify it matches the expected framework.
|
|
143
|
-
* Returns { listening: true, matched: true/false } or { listening: false }.
|
|
144
|
-
*/
|
|
145
|
-
async function isPortListening(port, fingerprint = null) {
|
|
146
|
-
if (!fingerprint) {
|
|
147
|
-
// Simple TCP probe fallback
|
|
148
|
-
const net = await import('node:net');
|
|
149
|
-
return new Promise((resolve) => {
|
|
150
|
-
const sock = net.default.createConnection({ port, host: '127.0.0.1' });
|
|
151
|
-
sock.setTimeout(500);
|
|
152
|
-
sock.on('connect', () => { sock.destroy(); resolve({ listening: true, matched: true }); });
|
|
153
|
-
sock.on('error', () => resolve({ listening: false }));
|
|
154
|
-
sock.on('timeout', () => { sock.destroy(); resolve({ listening: false }); });
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// HTTP probe with fingerprint matching
|
|
159
|
-
try {
|
|
160
|
-
const controller = new AbortController();
|
|
161
|
-
const timeout = setTimeout(() => controller.abort(), 2000);
|
|
162
|
-
const res = await fetch(`http://localhost:${port}/`, { signal: controller.signal, redirect: 'follow' });
|
|
163
|
-
clearTimeout(timeout);
|
|
164
|
-
|
|
165
|
-
// Check header fingerprint
|
|
166
|
-
if (fingerprint.header) {
|
|
167
|
-
const val = res.headers.get(fingerprint.header);
|
|
168
|
-
if (val && (!fingerprint.value || fingerprint.value.test(val))) {
|
|
169
|
-
return { listening: true, matched: true };
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Check body fingerprint
|
|
174
|
-
if (fingerprint.body) {
|
|
175
|
-
const body = await res.text();
|
|
176
|
-
if (fingerprint.body.test(body)) {
|
|
177
|
-
return { listening: true, matched: true };
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Port is listening but doesn't match the expected framework
|
|
182
|
-
return { listening: true, matched: false };
|
|
183
|
-
} catch {
|
|
184
|
-
return { listening: false };
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export {
|
|
189
|
-
SKIP_DIRS,
|
|
190
|
-
SCANNABLE_EXTENSIONS,
|
|
191
|
-
HTML_EXTENSIONS,
|
|
192
|
-
walkDir,
|
|
193
|
-
resolveImport,
|
|
194
|
-
buildImportGraph,
|
|
195
|
-
FRAMEWORK_CONFIGS,
|
|
196
|
-
detectFrameworkConfig,
|
|
197
|
-
isPortListening,
|
|
198
|
-
};
|