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,476 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Impeccable design hook — Cursor preToolUse write gate.
|
|
4
|
-
*
|
|
5
|
-
* Cursor's stop hook is not consistently dispatched by the headless agent, so
|
|
6
|
-
* this hook checks proposed Write/Edit content before it lands. It only denies
|
|
7
|
-
* writes when the real detector finds an issue in the proposed UI content.
|
|
8
|
-
*
|
|
9
|
-
* Contract: never break a turn accidentally. On malformed input or internal
|
|
10
|
-
* errors, allow the tool and exit 0.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import fs from 'node:fs';
|
|
14
|
-
import path from 'node:path';
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
ALLOWED_EXTS,
|
|
18
|
-
EDIT_COUNT_THRESHOLD,
|
|
19
|
-
GENERATED_PATH,
|
|
20
|
-
SENSITIVE_PATH,
|
|
21
|
-
appendDesignSystemNote,
|
|
22
|
-
designSystemOptions,
|
|
23
|
-
filterFindings,
|
|
24
|
-
loadDetector,
|
|
25
|
-
matchesAnyGlob,
|
|
26
|
-
persistCache,
|
|
27
|
-
readCache,
|
|
28
|
-
readConfig,
|
|
29
|
-
renderTemplate,
|
|
30
|
-
resolveProjectCwd,
|
|
31
|
-
truthy,
|
|
32
|
-
writeAuditLog,
|
|
33
|
-
} from './hook-lib.mjs';
|
|
34
|
-
|
|
35
|
-
async function readStdin() {
|
|
36
|
-
if (process.stdin.isTTY) return '';
|
|
37
|
-
const chunks = [];
|
|
38
|
-
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
39
|
-
return Buffer.concat(chunks).toString('utf-8');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function done(payload = null) {
|
|
43
|
-
if (payload) process.stdout.write(JSON.stringify(payload));
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function allow(extra = {}, payload = {}) {
|
|
48
|
-
writeAuditLog(process.env, {
|
|
49
|
-
ts: new Date().toISOString(),
|
|
50
|
-
event: 'preToolUse',
|
|
51
|
-
...extra,
|
|
52
|
-
});
|
|
53
|
-
return done({ permission: 'allow', ...payload });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function deny(message, audit) {
|
|
57
|
-
writeAuditLog(process.env, {
|
|
58
|
-
ts: new Date().toISOString(),
|
|
59
|
-
event: 'preToolUse',
|
|
60
|
-
blocked: true,
|
|
61
|
-
...audit,
|
|
62
|
-
});
|
|
63
|
-
return done({
|
|
64
|
-
permission: 'deny',
|
|
65
|
-
user_message: message,
|
|
66
|
-
agent_message: message,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function toolInput(event) {
|
|
71
|
-
return event?.tool_input && typeof event.tool_input === 'object' ? event.tool_input : {};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function proposedFilePath(event, cwd) {
|
|
75
|
-
const input = toolInput(event);
|
|
76
|
-
const raw = input.file_path || input.path || input.target_file || event?.file_path;
|
|
77
|
-
const candidate = typeof raw === 'string' && raw.trim()
|
|
78
|
-
? raw
|
|
79
|
-
: shellWriteDestination(shellCommand(input));
|
|
80
|
-
if (typeof candidate !== 'string' || !candidate.trim()) return '';
|
|
81
|
-
return path.isAbsolute(candidate) ? candidate : path.resolve(cwd, candidate);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function proposedContent(event, cwd, filePath) {
|
|
85
|
-
const input = toolInput(event);
|
|
86
|
-
for (const key of ['content', 'streamContent', 'text']) {
|
|
87
|
-
if (typeof input[key] === 'string') return input[key];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const editProjection = projectedEditContent(input, filePath, cwd);
|
|
91
|
-
if (editProjection !== undefined) return editProjection;
|
|
92
|
-
|
|
93
|
-
if (hasFragmentEditContent(input)) {
|
|
94
|
-
return { skipped: 'fragment-only-edit' };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const command = shellCommand(input);
|
|
98
|
-
const pythonContent = shellPythonWriteContent(command);
|
|
99
|
-
if (pythonContent) return pythonContent;
|
|
100
|
-
const shellContent = shellHereDocContent(command);
|
|
101
|
-
if (shellContent) return shellContent;
|
|
102
|
-
const copiedContent = shellCopiedFileContent(command, cwd);
|
|
103
|
-
if (copiedContent) return copiedContent;
|
|
104
|
-
return '';
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function hasFragmentEditContent(input) {
|
|
108
|
-
if (!input || typeof input !== 'object') return false;
|
|
109
|
-
if (typeof input.new_string === 'string' || typeof input.newString === 'string' || typeof input.new_str === 'string' || typeof input.replacement === 'string') {
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
return Array.isArray(input.edits) && input.edits.some((edit) => edit && typeof edit === 'object');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function projectedEditContent(input, filePath, cwd) {
|
|
116
|
-
if (!filePath) return undefined;
|
|
117
|
-
const singleOld = firstString(input, ['old_string', 'oldString', 'old_str', 'target']);
|
|
118
|
-
const singleNew = firstString(input, ['new_string', 'newString', 'new_str', 'replacement']);
|
|
119
|
-
if (singleOld !== undefined || singleNew !== undefined) {
|
|
120
|
-
if (singleOld === undefined || singleNew === undefined) return { skipped: 'fragment-only-edit' };
|
|
121
|
-
const original = readExistingProjectFile(filePath, cwd);
|
|
122
|
-
if (original === null) return { skipped: 'edit-original-unreadable' };
|
|
123
|
-
const projected = replaceOnce(original, singleOld, singleNew);
|
|
124
|
-
return projected === null ? { skipped: 'edit-old-string-missing' } : projected;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (!Array.isArray(input.edits)) return undefined;
|
|
128
|
-
const original = readExistingProjectFile(filePath, cwd);
|
|
129
|
-
if (original === null) return { skipped: 'edit-original-unreadable' };
|
|
130
|
-
|
|
131
|
-
let projected = original;
|
|
132
|
-
for (const edit of input.edits) {
|
|
133
|
-
if (!edit || typeof edit !== 'object') return { skipped: 'fragment-only-edit' };
|
|
134
|
-
const oldString = firstString(edit, ['old_string', 'oldString', 'old_str', 'target']);
|
|
135
|
-
const newString = firstString(edit, ['new_string', 'newString', 'new_str', 'replacement']);
|
|
136
|
-
if (oldString === undefined || newString === undefined) return { skipped: 'fragment-only-edit' };
|
|
137
|
-
const next = replaceOnce(projected, oldString, newString);
|
|
138
|
-
if (next === null) return { skipped: 'edit-old-string-missing' };
|
|
139
|
-
projected = next;
|
|
140
|
-
}
|
|
141
|
-
return projected;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function firstString(obj, keys) {
|
|
145
|
-
for (const key of keys) {
|
|
146
|
-
if (typeof obj?.[key] === 'string') return obj[key];
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function replaceOnce(original, oldString, newString) {
|
|
152
|
-
if (oldString === '') return null;
|
|
153
|
-
const index = original.indexOf(oldString);
|
|
154
|
-
if (index === -1) return null;
|
|
155
|
-
return `${original.slice(0, index)}${newString}${original.slice(index + oldString.length)}`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function readExistingProjectFile(filePath, cwd) {
|
|
159
|
-
if (!isInsideProject(filePath, cwd)) return null;
|
|
160
|
-
if (SENSITIVE_PATH.test(filePath) || GENERATED_PATH.test(filePath)) return null;
|
|
161
|
-
try {
|
|
162
|
-
const stat = fs.statSync(filePath);
|
|
163
|
-
if (!stat.isFile() || stat.size > 1024 * 1024) return null;
|
|
164
|
-
return fs.readFileSync(filePath, 'utf-8');
|
|
165
|
-
} catch {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function shellCommand(input) {
|
|
171
|
-
if (typeof input.command === 'string') return input.command;
|
|
172
|
-
if (input.args && typeof input.args.command === 'string') return input.args.command;
|
|
173
|
-
return '';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function shellRedirectPath(command) {
|
|
177
|
-
if (!command || typeof command !== 'string') return '';
|
|
178
|
-
const match = command.match(/(?:^|[\s;&|])(?:>>?|1>>?)\s*(?:"([^"]+)"|'([^']+)'|([^<>\s]+))/);
|
|
179
|
-
return (match?.[1] || match?.[2] || match?.[3] || '').trim();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function shellWriteDestination(command) {
|
|
183
|
-
return shellRedirectPath(command) || shellTeeDestination(command) || shellCopyPaths(command)?.dest || shellPythonWriteDestination(command) || '';
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function shellPythonWriteDestination(command) {
|
|
187
|
-
if (!/\bpython(?:3)?\b/.test(command || '')) return '';
|
|
188
|
-
const directPath = firstMatch(command, /(?:^|[^\w.])(?:pathlib\.)?Path\(\s*(["'])(.*?)\1\s*\)\s*\.write_text\s*\(/);
|
|
189
|
-
if (directPath) return directPath;
|
|
190
|
-
|
|
191
|
-
const pathsByVar = new Map();
|
|
192
|
-
const assignmentRe = /\b([A-Za-z_]\w*)\s*=\s*(?:pathlib\.)?Path\(\s*(["'])(.*?)\2\s*\)/g;
|
|
193
|
-
let assignment;
|
|
194
|
-
while ((assignment = assignmentRe.exec(command))) {
|
|
195
|
-
pathsByVar.set(assignment[1], assignment[3]);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const writeVarRe = /\b([A-Za-z_]\w*)\.write_text\s*\(/g;
|
|
199
|
-
let writeVar;
|
|
200
|
-
while ((writeVar = writeVarRe.exec(command))) {
|
|
201
|
-
const candidate = pathsByVar.get(writeVar[1]);
|
|
202
|
-
if (candidate) return candidate;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return firstMatch(command, /\bopen\(\s*(["'])(.*?)\1\s*,\s*(["'])[wax](?:\+)?b?\3/);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function firstMatch(value, re) {
|
|
209
|
-
const match = String(value || '').match(re);
|
|
210
|
-
return (match?.[2] || '').trim();
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function shellTeeDestination(command) {
|
|
214
|
-
const words = shellWords(command);
|
|
215
|
-
const teeIndex = words.findIndex((word) => path.basename(word) === 'tee');
|
|
216
|
-
if (teeIndex === -1) return '';
|
|
217
|
-
for (const word of words.slice(teeIndex + 1)) {
|
|
218
|
-
if (['&&', '||', ';', '|'].includes(word)) break;
|
|
219
|
-
if (word === '--') continue;
|
|
220
|
-
if (word.startsWith('-')) continue;
|
|
221
|
-
return word;
|
|
222
|
-
}
|
|
223
|
-
return '';
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function shellCopiedFileContent(command, cwd) {
|
|
227
|
-
const source = shellCopyPaths(command)?.source;
|
|
228
|
-
if (!source) return '';
|
|
229
|
-
const sourcePath = path.isAbsolute(source) ? source : path.resolve(cwd, source);
|
|
230
|
-
if (!isInsideProject(sourcePath, cwd)) return '';
|
|
231
|
-
if (SENSITIVE_PATH.test(sourcePath) || GENERATED_PATH.test(sourcePath)) return '';
|
|
232
|
-
try {
|
|
233
|
-
const stat = fs.statSync(sourcePath);
|
|
234
|
-
if (!stat.isFile() || stat.size > 1024 * 1024) return '';
|
|
235
|
-
return fs.readFileSync(sourcePath, 'utf-8');
|
|
236
|
-
} catch {
|
|
237
|
-
return '';
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function shellCopyPaths(command) {
|
|
242
|
-
const words = shellWords(command);
|
|
243
|
-
if (words.length < 3 || path.basename(words[0]) !== 'cp') return null;
|
|
244
|
-
const args = [];
|
|
245
|
-
for (const word of words.slice(1)) {
|
|
246
|
-
if (['&&', '||', ';', '|'].includes(word)) break;
|
|
247
|
-
if (word === '--') continue;
|
|
248
|
-
if (word.startsWith('-')) continue;
|
|
249
|
-
args.push(word);
|
|
250
|
-
}
|
|
251
|
-
if (args.length < 2) return null;
|
|
252
|
-
return { source: args[args.length - 2], dest: args[args.length - 1] };
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function shellWords(command) {
|
|
256
|
-
if (!command || typeof command !== 'string') return [];
|
|
257
|
-
const words = [];
|
|
258
|
-
const re = /"((?:\\"|[^"])*)"|'((?:\\'|[^'])*)'|([^\s]+)/g;
|
|
259
|
-
let match;
|
|
260
|
-
while ((match = re.exec(command))) {
|
|
261
|
-
words.push((match[1] ?? match[2] ?? match[3] ?? '').replace(/\\(["'])/g, '$1'));
|
|
262
|
-
}
|
|
263
|
-
return words;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function shellHereDocContent(command) {
|
|
267
|
-
if (!command || typeof command !== 'string') return '';
|
|
268
|
-
const markerMatch = command.match(/<<-?\s*['"]?([A-Za-z0-9_.-]+)['"]?[^\r\n]*\r?\n/);
|
|
269
|
-
if (!markerMatch) return '';
|
|
270
|
-
const marker = markerMatch[1];
|
|
271
|
-
const start = (markerMatch.index || 0) + markerMatch[0].length;
|
|
272
|
-
const rest = command.slice(start);
|
|
273
|
-
const endRe = new RegExp(`\\r?\\n${escapeRegExp(marker)}(?:\\r?\\n|$)`);
|
|
274
|
-
const end = rest.search(endRe);
|
|
275
|
-
return end >= 0 ? rest.slice(0, end) : '';
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function shellPythonWriteContent(command) {
|
|
279
|
-
if (!/\bpython(?:3)?\b/.test(command || '')) return '';
|
|
280
|
-
const script = shellHereDocContent(command) || command;
|
|
281
|
-
return pythonStringArg(script, /\.write_text\s*\(\s*/g) || pythonStringArg(script, /\.write\s*\(\s*/g);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function pythonStringArg(script, prefixRe) {
|
|
285
|
-
let prefix;
|
|
286
|
-
while ((prefix = prefixRe.exec(script))) {
|
|
287
|
-
const start = prefixRe.lastIndex;
|
|
288
|
-
const triple = script.slice(start, start + 3);
|
|
289
|
-
if (triple === "'''" || triple === '"""') {
|
|
290
|
-
const end = script.indexOf(triple, start + 3);
|
|
291
|
-
if (end !== -1) return script.slice(start + 3, end);
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
const quote = script[start];
|
|
295
|
-
if (quote !== '"' && quote !== "'") continue;
|
|
296
|
-
let out = '';
|
|
297
|
-
for (let i = start + 1; i < script.length; i++) {
|
|
298
|
-
const ch = script[i];
|
|
299
|
-
if (ch === '\\') {
|
|
300
|
-
out += script[i + 1] || '';
|
|
301
|
-
i += 1;
|
|
302
|
-
} else if (ch === quote) {
|
|
303
|
-
return out;
|
|
304
|
-
} else {
|
|
305
|
-
out += ch;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return '';
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function escapeRegExp(value) {
|
|
313
|
-
return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function relativePath(filePath, cwd) {
|
|
317
|
-
try {
|
|
318
|
-
const rel = path.relative(cwd, filePath);
|
|
319
|
-
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return filePath;
|
|
320
|
-
return rel.split(path.sep).join('/');
|
|
321
|
-
} catch {
|
|
322
|
-
return filePath;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function isInsideProject(filePath, cwd) {
|
|
327
|
-
try {
|
|
328
|
-
const rel = path.relative(cwd, filePath);
|
|
329
|
-
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
330
|
-
} catch {
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function cursorBlockMessage(findings, filePath, config, cwd) {
|
|
336
|
-
const rendered = renderTemplate(findings, filePath, config, { cwd });
|
|
337
|
-
const blocked = rendered.replace(
|
|
338
|
-
'[impeccable@1] Design hook findings requiring review',
|
|
339
|
-
'[impeccable@1] Impeccable design hook blocked this write before it landed. Design hook findings requiring review',
|
|
340
|
-
);
|
|
341
|
-
return blocked.length > 4000 ? `${blocked.slice(0, 3984)}\n...(truncated)` : blocked;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function findingSignature(findings) {
|
|
345
|
-
return findings
|
|
346
|
-
.map((finding) => `${finding.antipattern || 'unknown'}:${finding.line || 0}`)
|
|
347
|
-
.sort()
|
|
348
|
-
.join('|');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function bumpCursorDenial(cache, sessionId, filePath, findings) {
|
|
352
|
-
const session = cache.sessions[sessionId] || { updatedAt: Date.now(), files: {} };
|
|
353
|
-
cache.sessions[sessionId] = session;
|
|
354
|
-
session.updatedAt = Date.now();
|
|
355
|
-
const fileEntry = session.files[filePath] || { editCount: 0, findings: [] };
|
|
356
|
-
session.files[filePath] = fileEntry;
|
|
357
|
-
const key = findingSignature(findings);
|
|
358
|
-
fileEntry.cursorDenials = fileEntry.cursorDenials && typeof fileEntry.cursorDenials === 'object'
|
|
359
|
-
? fileEntry.cursorDenials
|
|
360
|
-
: {};
|
|
361
|
-
fileEntry.cursorDenials[key] = (fileEntry.cursorDenials[key] || 0) + 1;
|
|
362
|
-
return { key, count: fileEntry.cursorDenials[key] };
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
async function main() {
|
|
366
|
-
if (truthy(process.env.IMPECCABLE_HOOK_DISABLED)) {
|
|
367
|
-
return allow({ skipped: 'env-disabled' });
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
let event = null;
|
|
371
|
-
try {
|
|
372
|
-
const raw = await readStdin();
|
|
373
|
-
if (raw) event = JSON.parse(raw);
|
|
374
|
-
} catch {
|
|
375
|
-
return allow({ skipped: 'stdin-malformed' });
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (!event || typeof event !== 'object') {
|
|
379
|
-
return allow({ skipped: 'stdin-empty' });
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const cwd = resolveProjectCwd(event);
|
|
383
|
-
const started = Date.now();
|
|
384
|
-
const filePath = proposedFilePath(event, cwd);
|
|
385
|
-
const audit = {
|
|
386
|
-
harness: 'cursor',
|
|
387
|
-
cwd,
|
|
388
|
-
tool: event.tool_name || null,
|
|
389
|
-
file: filePath || null,
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
if (!filePath) return allow({ ...audit, skipped: 'no-file-path', durationMs: Date.now() - started });
|
|
393
|
-
if (!isInsideProject(filePath, cwd)) return allow({ ...audit, skipped: 'outside-project', durationMs: Date.now() - started });
|
|
394
|
-
if (SENSITIVE_PATH.test(filePath)) return allow({ ...audit, skipped: 'sensitive', durationMs: Date.now() - started });
|
|
395
|
-
if (GENERATED_PATH.test(filePath)) return allow({ ...audit, skipped: 'generated', durationMs: Date.now() - started });
|
|
396
|
-
|
|
397
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
398
|
-
audit.ext = ext;
|
|
399
|
-
if (!ALLOWED_EXTS.has(ext)) return allow({ ...audit, skipped: 'extension', durationMs: Date.now() - started });
|
|
400
|
-
|
|
401
|
-
const contentResult = proposedContent(event, cwd, filePath);
|
|
402
|
-
if (contentResult && typeof contentResult === 'object' && contentResult.skipped) {
|
|
403
|
-
return allow({ ...audit, skipped: contentResult.skipped, durationMs: Date.now() - started });
|
|
404
|
-
}
|
|
405
|
-
const content = typeof contentResult === 'string' ? contentResult : '';
|
|
406
|
-
if (!content) return allow({ ...audit, skipped: 'no-proposed-content', durationMs: Date.now() - started });
|
|
407
|
-
|
|
408
|
-
const config = readConfig(cwd);
|
|
409
|
-
if (config.enabled === false) return allow({ ...audit, skipped: 'config-disabled', durationMs: Date.now() - started });
|
|
410
|
-
|
|
411
|
-
const rel = relativePath(filePath, cwd);
|
|
412
|
-
if (matchesAnyGlob(rel, config.ignoreFiles) || matchesAnyGlob(filePath, config.ignoreFiles)) {
|
|
413
|
-
return allow({ ...audit, skipped: 'config-ignore-file', durationMs: Date.now() - started });
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const detector = await loadDetector();
|
|
417
|
-
if (!detector || typeof detector.detectText !== 'function') {
|
|
418
|
-
return allow({ ...audit, skipped: 'detector-missing', durationMs: Date.now() - started });
|
|
419
|
-
}
|
|
420
|
-
const scanOptions = designSystemOptions(config, detector, cwd);
|
|
421
|
-
|
|
422
|
-
let findings = [];
|
|
423
|
-
try {
|
|
424
|
-
findings = await detector.detectText(content, filePath, scanOptions);
|
|
425
|
-
} catch {
|
|
426
|
-
return allow({ ...audit, error: 'detector-threw', durationMs: Date.now() - started });
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
const filtered = filterFindings(findings || [], content, ext, config);
|
|
430
|
-
if (filtered.length === 0) {
|
|
431
|
-
return allow({
|
|
432
|
-
...audit,
|
|
433
|
-
findings: (findings || []).length,
|
|
434
|
-
blockedFindings: 0,
|
|
435
|
-
durationMs: Date.now() - started,
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
const message = appendDesignSystemNote(cursorBlockMessage(filtered, filePath, config, cwd), scanOptions);
|
|
440
|
-
const sessionId = event.session_id || event.conversation_id || 'unknown';
|
|
441
|
-
const cache = readCache(cwd);
|
|
442
|
-
const denial = bumpCursorDenial(cache, sessionId, filePath, filtered);
|
|
443
|
-
persistCache(cwd, cache);
|
|
444
|
-
if (denial.count > EDIT_COUNT_THRESHOLD) {
|
|
445
|
-
const warning = `${message}\n\nThis is the ${denial.count}th repeated denial for the same file and finding signature, so Impeccable is allowing this write to avoid a loop. Reconsider the issue immediately after the tool runs.`;
|
|
446
|
-
return allow({
|
|
447
|
-
...audit,
|
|
448
|
-
findings: (findings || []).length,
|
|
449
|
-
blockedFindings: filtered.length,
|
|
450
|
-
cursorDenialKey: denial.key,
|
|
451
|
-
cursorDenialCount: denial.count,
|
|
452
|
-
downgraded: true,
|
|
453
|
-
chars: warning.length,
|
|
454
|
-
durationMs: Date.now() - started,
|
|
455
|
-
}, {
|
|
456
|
-
user_message: warning,
|
|
457
|
-
agent_message: warning,
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
return deny(message, {
|
|
461
|
-
...audit,
|
|
462
|
-
findings: (findings || []).length,
|
|
463
|
-
blockedFindings: filtered.length,
|
|
464
|
-
cursorDenialKey: denial.key,
|
|
465
|
-
cursorDenialCount: denial.count,
|
|
466
|
-
chars: message.length,
|
|
467
|
-
durationMs: Date.now() - started,
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
main().catch((err) => {
|
|
472
|
-
if (process.env.IMPECCABLE_HOOK_DEBUG) {
|
|
473
|
-
process.stderr.write(`[impeccable-hook-before-edit] ${err}\n`);
|
|
474
|
-
}
|
|
475
|
-
done({ permission: 'allow' });
|
|
476
|
-
});
|