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,60 +0,0 @@
|
|
|
1
|
-
# Vendored from SkillRL (Apache-2.0 License)
|
|
2
|
-
# Original: agent_system/environments/env_package/alfworld/projection.py
|
|
3
|
-
|
|
4
|
-
from typing import List
|
|
5
|
-
import re
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def alfworld_projection(actions: List[str], action_pools: List[List[str]]):
|
|
9
|
-
"""Process raw model outputs into valid ALFWorld actions.
|
|
10
|
-
|
|
11
|
-
Extracts text from ``<action>...</action>`` tags and validates that
|
|
12
|
-
the response also contains ``<think>...</think>`` tags.
|
|
13
|
-
|
|
14
|
-
Parameters
|
|
15
|
-
----------
|
|
16
|
-
actions : list[str]
|
|
17
|
-
Raw model outputs, one per environment.
|
|
18
|
-
action_pools : list[list[str]]
|
|
19
|
-
Admissible action lists per environment (unused but kept for API compat).
|
|
20
|
-
|
|
21
|
-
Returns
|
|
22
|
-
-------
|
|
23
|
-
actions : list[str]
|
|
24
|
-
Cleaned action strings.
|
|
25
|
-
valids : list[int]
|
|
26
|
-
1 if the action was successfully parsed, 0 otherwise.
|
|
27
|
-
"""
|
|
28
|
-
valids = [0] * len(actions)
|
|
29
|
-
|
|
30
|
-
for i in range(len(actions)):
|
|
31
|
-
original_str = actions[i]
|
|
32
|
-
actions[i] = actions[i].lower()
|
|
33
|
-
|
|
34
|
-
start_tag = "<action>"
|
|
35
|
-
end_tag = "</action>"
|
|
36
|
-
start_idx = actions[i].find(start_tag)
|
|
37
|
-
end_idx = actions[i].find(end_tag)
|
|
38
|
-
try:
|
|
39
|
-
if start_idx == -1 or end_idx == -1:
|
|
40
|
-
actions[i] = actions[i][-30:]
|
|
41
|
-
continue
|
|
42
|
-
|
|
43
|
-
extracted_action = actions[i][start_idx + len(start_tag):end_idx].strip().lower()
|
|
44
|
-
actions[i] = extracted_action
|
|
45
|
-
valids[i] = 1
|
|
46
|
-
|
|
47
|
-
except Exception:
|
|
48
|
-
actions[i] = actions[i][-30:]
|
|
49
|
-
|
|
50
|
-
# Require <think>...</think>
|
|
51
|
-
think_start_idx = original_str.find("<think>")
|
|
52
|
-
think_end_idx = original_str.find("</think>")
|
|
53
|
-
if think_start_idx == -1 or think_end_idx == -1:
|
|
54
|
-
valids[i] = 0
|
|
55
|
-
|
|
56
|
-
# Reject responses containing Chinese characters
|
|
57
|
-
if re.search(r'[\u4e00-\u9fff]', original_str):
|
|
58
|
-
valids[i] = 0
|
|
59
|
-
|
|
60
|
-
return actions, valids
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Vendored from SkillRL (Apache-2.0 License)
|
|
2
|
-
# Original: agent_system/environments/prompts/alfworld.py
|
|
3
|
-
|
|
4
|
-
from skillopt.prompts import load_prompt
|
|
5
|
-
|
|
6
|
-
ALFWORLD_TEMPLATE_NO_HIS = load_prompt("rollout_no_history", env="alfworld")
|
|
7
|
-
ALFWORLD_TEMPLATE = load_prompt("rollout_with_history", env="alfworld")
|
|
8
|
-
ALFWORLD_TEMPLATE_WITH_MEMORY = load_prompt("rollout_with_memory", env="alfworld")
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
dataset:
|
|
2
|
-
data_path: '$ALFWORLD_DATA/json_2.1.1/train'
|
|
3
|
-
eval_id_data_path: '$ALFWORLD_DATA/json_2.1.1/valid_seen' # null/None to disable
|
|
4
|
-
eval_ood_data_path: '$ALFWORLD_DATA/json_2.1.1/valid_unseen' # null/None to disable
|
|
5
|
-
num_train_games: -1 # max training games (<=0 indicates full dataset)
|
|
6
|
-
num_eval_games: -1 # max evaluation games (<=0 indicates full dataset)
|
|
7
|
-
|
|
8
|
-
logic:
|
|
9
|
-
domain: '$ALFWORLD_DATA/logic/alfred.pddl' # PDDL domain file that defines the world dynamics
|
|
10
|
-
grammar: '$ALFWORLD_DATA/logic/alfred.twl2' # Grammar file that defines the text feedbacks
|
|
11
|
-
|
|
12
|
-
env:
|
|
13
|
-
type: 'AlfredTWEnv' # 'AlfredTWEnv' or 'AlfredThorEnv' or 'AlfredHybrid'
|
|
14
|
-
# regen_game_files: False # check if game is solvable by expert and save to game.tw-pddl file
|
|
15
|
-
domain_randomization: False # shuffle Textworld print order and object id nums
|
|
16
|
-
task_types: [1, 2, 3, 4, 5, 6] # task-type ids: 1 - Pick & Place, 2 - Examine in Light, 3 - Clean & Place, 4 - Heat & Place, 5 - Cool & Place, 6 - Pick Two & Place
|
|
17
|
-
expert_timeout_steps: 150 # max steps before timeout for expert to solve the task
|
|
18
|
-
expert_type: "handcoded" # 'handcoded' or 'planner'. Note: the planner is very slow for real-time use
|
|
19
|
-
goal_desc_human_anns_prob: 0.0 # prob of using human-annotated goal language instead of templated goals (1.0 indicates all human annotations from ALFRED)
|
|
20
|
-
|
|
21
|
-
hybrid:
|
|
22
|
-
start_eps: 100000 # starting episode of hybrid training, tw-only training upto this point
|
|
23
|
-
thor_prob: 0.5 # prob of AlfredThorEnv during hybrid training
|
|
24
|
-
eval_mode: "tw" # 'tw' or 'thor' - env used for evaluation during hybrid training
|
|
25
|
-
|
|
26
|
-
thor:
|
|
27
|
-
screen_width: 300 # width of THOR window
|
|
28
|
-
screen_height: 300 # height of THOR window
|
|
29
|
-
smooth_nav: False # smooth rotations, looks, and translations during navigation (very slow)
|
|
30
|
-
save_frames_to_disk: False # save frame PNGs to disk (useful for making videos)
|
|
31
|
-
save_frames_path: './videos/' # path to save frame PNGs
|
|
32
|
-
|
|
33
|
-
controller:
|
|
34
|
-
type: 'oracle' # 'oracle' or 'oracle_astar' or 'mrcnn' or 'mrcnn_astar' (aka BUTLER)
|
|
35
|
-
debug: False
|
|
36
|
-
load_receps: True # load receptacle locations from precomputed dict (if available)
|
|
37
|
-
|
|
38
|
-
mask_rcnn:
|
|
39
|
-
pretrained_model_path: '$ALFWORLD_DATA/detectors/mrcnn.pth'
|
|
40
|
-
|
|
41
|
-
general:
|
|
42
|
-
random_seed: 42
|
|
43
|
-
use_cuda: True # disable this when running on machine without cuda
|
|
44
|
-
visdom: False # plot training/eval curves, run with visdom server
|
|
45
|
-
task: 'alfred'
|
|
46
|
-
training_method: 'dagger' # 'dqn' or 'dagger'
|
|
47
|
-
save_path: './training/' # path to save pytorch models
|
|
48
|
-
observation_pool_capacity: 3 # k-size queue, 0 indicates no observation
|
|
49
|
-
hide_init_receptacles: False # remove initial observation containing navigable receptacles
|
|
50
|
-
|
|
51
|
-
training:
|
|
52
|
-
batch_size: 10
|
|
53
|
-
max_episode: 50000
|
|
54
|
-
smoothing_eps: 0.1
|
|
55
|
-
optimizer:
|
|
56
|
-
learning_rate: 0.001
|
|
57
|
-
clip_grad_norm: 5
|
|
58
|
-
|
|
59
|
-
evaluate:
|
|
60
|
-
run_eval: True
|
|
61
|
-
batch_size: 10
|
|
62
|
-
env:
|
|
63
|
-
type: "AlfredTWEnv"
|
|
64
|
-
|
|
65
|
-
checkpoint:
|
|
66
|
-
report_frequency: 1000 # report every N episode
|
|
67
|
-
experiment_tag: 'test' # name of experiment
|
|
68
|
-
load_pretrained: False # during test, enable this so that the agent load your pretrained model
|
|
69
|
-
load_from_tag: 'not loading anything' # name of pre-trained model to load in save_path
|
|
70
|
-
|
|
71
|
-
model:
|
|
72
|
-
encoder_layers: 1
|
|
73
|
-
decoder_layers: 1
|
|
74
|
-
encoder_conv_num: 5
|
|
75
|
-
block_hidden_dim: 64
|
|
76
|
-
n_heads: 1
|
|
77
|
-
dropout: 0.1
|
|
78
|
-
block_dropout: 0.1
|
|
79
|
-
recurrent: True
|
|
80
|
-
|
|
81
|
-
rl:
|
|
82
|
-
action_space: "admissible" # 'admissible' (candidates from text engine) or 'generation' (seq2seq-style generation) or 'beam_search_choice' or 'exhaustive' (not working)
|
|
83
|
-
max_target_length: 20 # max token length for seq2seq generation
|
|
84
|
-
beam_width: 10 # 1 means greedy
|
|
85
|
-
generate_top_k: 3
|
|
86
|
-
|
|
87
|
-
training:
|
|
88
|
-
max_nb_steps_per_episode: 50 # terminate after this many steps
|
|
89
|
-
learn_start_from_this_episode: 0 # delay updates until this epsiode
|
|
90
|
-
target_net_update_frequency: 500 # sync target net with online net per this many epochs
|
|
91
|
-
|
|
92
|
-
replay:
|
|
93
|
-
accumulate_reward_from_final: True
|
|
94
|
-
count_reward_lambda: 0.0 # 0 to disable
|
|
95
|
-
novel_object_reward_lambda: 0.0 # 0 to disable
|
|
96
|
-
discount_gamma_game_reward: 0.9
|
|
97
|
-
discount_gamma_count_reward: 0.5
|
|
98
|
-
discount_gamma_novel_object_reward: 0.5
|
|
99
|
-
replay_memory_capacity: 500000 # adjust this depending on your RAM size
|
|
100
|
-
replay_memory_priority_fraction: 0.5
|
|
101
|
-
update_per_k_game_steps: 5
|
|
102
|
-
replay_batch_size: 64
|
|
103
|
-
multi_step: 3
|
|
104
|
-
replay_sample_history_length: 4
|
|
105
|
-
replay_sample_update_from: 2
|
|
106
|
-
|
|
107
|
-
epsilon_greedy:
|
|
108
|
-
noisy_net: False # if this is true, then epsilon greedy is disabled
|
|
109
|
-
epsilon_anneal_episodes: 1000 # -1 if not annealing
|
|
110
|
-
epsilon_anneal_from: 0.3
|
|
111
|
-
epsilon_anneal_to: 0.1
|
|
112
|
-
|
|
113
|
-
dagger:
|
|
114
|
-
action_space: "generation" # 'admissible' (candidates from text engine) or 'generation' (seq2seq-style generation) or 'exhaustive' (not working)
|
|
115
|
-
max_target_length: 20 # max token length for seq2seq generation
|
|
116
|
-
beam_width: 10 # 1 means greedy
|
|
117
|
-
generate_top_k: 5
|
|
118
|
-
unstick_by_beam_search: False # use beam-search for failed actions, set True during evaluation
|
|
119
|
-
|
|
120
|
-
training:
|
|
121
|
-
max_nb_steps_per_episode: 50 # terminate after this many steps
|
|
122
|
-
|
|
123
|
-
fraction_assist:
|
|
124
|
-
fraction_assist_anneal_episodes: 50000
|
|
125
|
-
fraction_assist_anneal_from: 1.0
|
|
126
|
-
fraction_assist_anneal_to: 0.01
|
|
127
|
-
|
|
128
|
-
fraction_random:
|
|
129
|
-
fraction_random_anneal_episodes: 0
|
|
130
|
-
fraction_random_anneal_from: 0.0
|
|
131
|
-
fraction_random_anneal_to: 0.0
|
|
132
|
-
|
|
133
|
-
replay:
|
|
134
|
-
replay_memory_capacity: 500000
|
|
135
|
-
update_per_k_game_steps: 5
|
|
136
|
-
replay_batch_size: 64
|
|
137
|
-
replay_sample_history_length: 4
|
|
138
|
-
replay_sample_update_from: 2
|
|
139
|
-
|
|
140
|
-
vision_dagger:
|
|
141
|
-
model_type: "resnet" # 'resnet' (whole image features) or 'maskrcnn_whole' (whole image MaskRCNN feats) or 'maskrcnn' (top k MaskRCNN detection feats) or 'no_vision' (zero vision input)
|
|
142
|
-
resnet_fc_dim: 64
|
|
143
|
-
maskrcnn_top_k_boxes: 10 # top k box features
|
|
144
|
-
use_exploration_frame_feats: False # append feats from initial exploration (memory intensive!)
|
|
145
|
-
sequence_aggregation_method: "average" # 'sum' or 'average' or 'rnn'
|
package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/env_base.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# Vendored from SkillRL (Apache-2.0 License)
|
|
2
|
-
# Original: agent_system/environments/base.py
|
|
3
|
-
# Trimmed to only include what ALFWorld needs.
|
|
4
|
-
|
|
5
|
-
from typing import List, Tuple, Dict, Any
|
|
6
|
-
import numpy as np
|
|
7
|
-
from collections import defaultdict
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def to_numpy(data):
|
|
11
|
-
"""Convert data to numpy array."""
|
|
12
|
-
# Lazy-check for torch.Tensor to avoid hard dependency on torch
|
|
13
|
-
_torch_tensor = None
|
|
14
|
-
try:
|
|
15
|
-
import torch
|
|
16
|
-
_torch_tensor = torch.Tensor
|
|
17
|
-
except ImportError:
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
if _torch_tensor is not None and isinstance(data, _torch_tensor):
|
|
21
|
-
data = data.detach().cpu().numpy()
|
|
22
|
-
elif isinstance(data, np.ndarray):
|
|
23
|
-
pass
|
|
24
|
-
elif isinstance(data, (int, float, bool, Tuple, List)):
|
|
25
|
-
data = np.array(data)
|
|
26
|
-
else:
|
|
27
|
-
raise ValueError(f"Unsupported type: {type(data)})")
|
|
28
|
-
return data
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class EnvironmentManagerBase:
|
|
32
|
-
"""Base class for vectorized environment managers.
|
|
33
|
-
|
|
34
|
-
Manages a set of parallel environments, handles action projection,
|
|
35
|
-
observation post-processing, and history tracking.
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
def __init__(self, envs, projection_f, config):
|
|
39
|
-
self.envs = envs
|
|
40
|
-
self.projection_f = projection_f
|
|
41
|
-
self.config = config
|
|
42
|
-
|
|
43
|
-
def reset(self, kwargs) -> Dict[str, Any]:
|
|
44
|
-
obs, infos = self.envs.reset()
|
|
45
|
-
return {'text': None, 'image': obs, 'anchor': None}, infos
|
|
46
|
-
|
|
47
|
-
def step(self, text_actions: List[str]):
|
|
48
|
-
actions, valids = self.projection_f(text_actions)
|
|
49
|
-
next_obs, rewards, dones, infos = self.envs.step(actions)
|
|
50
|
-
|
|
51
|
-
next_observations = {
|
|
52
|
-
'text': None,
|
|
53
|
-
'image': next_obs,
|
|
54
|
-
'anchor': None,
|
|
55
|
-
}
|
|
56
|
-
for i, info in enumerate(infos):
|
|
57
|
-
info['is_action_valid'] = to_numpy(valids[i])
|
|
58
|
-
|
|
59
|
-
rewards = to_numpy(rewards)
|
|
60
|
-
dones = to_numpy(dones)
|
|
61
|
-
return next_observations, rewards, dones, infos
|
|
62
|
-
|
|
63
|
-
def close(self) -> None:
|
|
64
|
-
self.envs.close()
|
|
65
|
-
|
|
66
|
-
def success_evaluator(self, *args, **kwargs) -> Dict[str, np.ndarray]:
|
|
67
|
-
total_infos = kwargs['total_infos']
|
|
68
|
-
total_batch_list = kwargs['total_batch_list']
|
|
69
|
-
batch_size = len(total_batch_list)
|
|
70
|
-
|
|
71
|
-
success = defaultdict(list)
|
|
72
|
-
for bs in range(batch_size):
|
|
73
|
-
self._process_batch(bs, total_batch_list, total_infos, success)
|
|
74
|
-
assert len(success['success_rate']) == batch_size
|
|
75
|
-
return {key: np.array(value) for key, value in success.items()}
|
|
76
|
-
|
|
77
|
-
def _process_batch(self, batch_idx, total_batch_list, total_infos, success):
|
|
78
|
-
for i in reversed(range(len(total_batch_list[batch_idx]))):
|
|
79
|
-
batch_item = total_batch_list[batch_idx][i]
|
|
80
|
-
if batch_item['active_masks']:
|
|
81
|
-
info = total_infos[batch_idx][i]
|
|
82
|
-
won_value = float(info['won'])
|
|
83
|
-
success['success_rate'].append(won_value)
|
|
84
|
-
return
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
# Vendored from SkillRL (Apache-2.0 License)
|
|
2
|
-
# Original: agent_system/environments/env_manager.py
|
|
3
|
-
# Trimmed to only include AlfWorldEnvironmentManager and its helpers.
|
|
4
|
-
|
|
5
|
-
from typing import List, Dict, Any
|
|
6
|
-
from collections import defaultdict
|
|
7
|
-
import numpy as np
|
|
8
|
-
|
|
9
|
-
from skillopt.envs.alfworld.vendor.env_base import EnvironmentManagerBase, to_numpy
|
|
10
|
-
from skillopt.envs.alfworld.vendor.alfworld_prompts import (
|
|
11
|
-
ALFWORLD_TEMPLATE,
|
|
12
|
-
ALFWORLD_TEMPLATE_NO_HIS,
|
|
13
|
-
ALFWORLD_TEMPLATE_WITH_MEMORY,
|
|
14
|
-
)
|
|
15
|
-
from skillopt.envs.alfworld.vendor.memory import SimpleMemory
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def parse_gamefile(infos):
|
|
19
|
-
gamefile = []
|
|
20
|
-
for info in infos:
|
|
21
|
-
if 'extra.gamefile' in info:
|
|
22
|
-
gamefile.append(info['extra.gamefile'])
|
|
23
|
-
else:
|
|
24
|
-
gamefile.append(None)
|
|
25
|
-
return gamefile
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def set_gamefile(infos, gamefile):
|
|
29
|
-
for i in range(len(infos)):
|
|
30
|
-
if 'extra.gamefile' in infos[i]:
|
|
31
|
-
infos[i]['extra.gamefile'] = gamefile[i]
|
|
32
|
-
else:
|
|
33
|
-
infos[i]['extra.gamefile'] = None
|
|
34
|
-
return infos
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class AlfWorldEnvironmentManager(EnvironmentManagerBase):
|
|
38
|
-
"""Manages parallel ALFWorld environments with observation templating."""
|
|
39
|
-
|
|
40
|
-
def __init__(self, envs, projection_f, config):
|
|
41
|
-
self.memory = SimpleMemory()
|
|
42
|
-
self.retrieval_memory = None
|
|
43
|
-
super().__init__(envs, projection_f, config)
|
|
44
|
-
|
|
45
|
-
def reset(self, kwargs):
|
|
46
|
-
text_obs, image_obs, infos = self.envs.reset()
|
|
47
|
-
self.gamefile = parse_gamefile(infos)
|
|
48
|
-
self.memory.reset(batch_size=len(text_obs))
|
|
49
|
-
self.tasks = []
|
|
50
|
-
self.pre_text_obs = text_obs
|
|
51
|
-
self.extract_task(text_obs)
|
|
52
|
-
|
|
53
|
-
full_text_obs = self.build_text_obs(text_obs, self.envs.get_admissible_commands, init=True)
|
|
54
|
-
return {'text': full_text_obs, 'image': image_obs, 'anchor': text_obs}, infos
|
|
55
|
-
|
|
56
|
-
def step(self, text_actions: List[str]):
|
|
57
|
-
actions, valids = self.projection_f(text_actions, self.envs.get_admissible_commands)
|
|
58
|
-
text_obs, image_obs, rewards, dones, infos = self.envs.step(actions)
|
|
59
|
-
self.memory.store({'text_obs': self.pre_text_obs, 'action': actions})
|
|
60
|
-
self.pre_text_obs = text_obs
|
|
61
|
-
|
|
62
|
-
full_text_obs = self.build_text_obs(text_obs, self.envs.get_admissible_commands)
|
|
63
|
-
if infos[0].get("extra.gamefile") is None:
|
|
64
|
-
infos = set_gamefile(infos, self.gamefile)
|
|
65
|
-
|
|
66
|
-
for i, info in enumerate(infos):
|
|
67
|
-
info['is_action_valid'] = to_numpy(valids[i])
|
|
68
|
-
|
|
69
|
-
next_observations = {'text': full_text_obs, 'image': image_obs, 'anchor': text_obs}
|
|
70
|
-
rewards = to_numpy(rewards)
|
|
71
|
-
dones = to_numpy(dones)
|
|
72
|
-
return next_observations, rewards, dones, infos
|
|
73
|
-
|
|
74
|
-
def extract_task(self, text_obs: List[str]):
|
|
75
|
-
for obs in text_obs:
|
|
76
|
-
task_start = obs.find('Your task is to: ')
|
|
77
|
-
if task_start != -1:
|
|
78
|
-
self.tasks.append(obs[task_start + len('Your task is to: '):].strip())
|
|
79
|
-
else:
|
|
80
|
-
raise ValueError("Task description not found in text observation.")
|
|
81
|
-
|
|
82
|
-
def build_text_obs(self, text_obs: List[str], admissible_actions: List[List[str]], init: bool = False) -> List[str]:
|
|
83
|
-
postprocess_text_obs = []
|
|
84
|
-
if not init and self.config.env.history_length > 0:
|
|
85
|
-
memory_contexts, valid_lens = self.memory.fetch(
|
|
86
|
-
self.config.env.history_length,
|
|
87
|
-
obs_key="text_obs",
|
|
88
|
-
action_key="action",
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
for i in range(len(text_obs)):
|
|
92
|
-
reformatted_admissible_actions = "\n ".join(
|
|
93
|
-
f"'{s}'" for s in admissible_actions[i] if s != 'help'
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
if init or self.config.env.history_length <= 0:
|
|
97
|
-
obs = ALFWORLD_TEMPLATE_NO_HIS.format(
|
|
98
|
-
current_observation=text_obs[i],
|
|
99
|
-
admissible_actions=reformatted_admissible_actions,
|
|
100
|
-
)
|
|
101
|
-
else:
|
|
102
|
-
obs = ALFWORLD_TEMPLATE.format(
|
|
103
|
-
task_description=self.tasks[i],
|
|
104
|
-
step_count=len(self.memory[i]),
|
|
105
|
-
history_length=valid_lens[i],
|
|
106
|
-
action_history=memory_contexts[i],
|
|
107
|
-
current_step=len(self.memory[i]) + 1,
|
|
108
|
-
current_observation=text_obs[i],
|
|
109
|
-
admissible_actions=reformatted_admissible_actions,
|
|
110
|
-
)
|
|
111
|
-
postprocess_text_obs.append(obs)
|
|
112
|
-
return postprocess_text_obs
|
|
113
|
-
|
|
114
|
-
def _process_batch(self, batch_idx, total_batch_list, total_infos, success):
|
|
115
|
-
for i in reversed(range(len(total_batch_list[batch_idx]))):
|
|
116
|
-
batch_item = total_batch_list[batch_idx][i]
|
|
117
|
-
if batch_item['active_masks']:
|
|
118
|
-
info = total_infos[batch_idx][i]
|
|
119
|
-
won_value = float(info['won'])
|
|
120
|
-
success['success_rate'].append(won_value)
|
|
121
|
-
|
|
122
|
-
gamefile = info.get("extra.gamefile")
|
|
123
|
-
if gamefile:
|
|
124
|
-
self._process_gamefile(gamefile, won_value, success)
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
def _process_gamefile(self, gamefile, won_value, success):
|
|
128
|
-
tasks = [
|
|
129
|
-
"pick_and_place",
|
|
130
|
-
"pick_two_obj_and_place",
|
|
131
|
-
"look_at_obj_in_light",
|
|
132
|
-
"pick_heat_then_place_in_recep",
|
|
133
|
-
"pick_cool_then_place_in_recep",
|
|
134
|
-
"pick_clean_then_place_in_recep",
|
|
135
|
-
]
|
|
136
|
-
for task in tasks:
|
|
137
|
-
if task in gamefile:
|
|
138
|
-
success[f"{task}_success_rate"].append(won_value)
|
|
139
|
-
break
|
package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/memory.py
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# Vendored from SkillRL (Apache-2.0 License)
|
|
2
|
-
# Original: agent_system/memory/base.py + agent_system/memory/memory.py
|
|
3
|
-
# Merged into a single file for simplicity.
|
|
4
|
-
|
|
5
|
-
from abc import ABC, abstractmethod
|
|
6
|
-
from typing import List, Dict, Any, Tuple
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class BaseMemory(ABC):
|
|
10
|
-
"""Base class for memory management."""
|
|
11
|
-
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __len__(self):
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def __getitem__(self, idx: int):
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def reset(self, batch_size: int):
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
@abstractmethod
|
|
25
|
-
def store(self, record: Dict[str, List[Any]]):
|
|
26
|
-
pass
|
|
27
|
-
|
|
28
|
-
@abstractmethod
|
|
29
|
-
def fetch(self, step: int):
|
|
30
|
-
pass
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class SimpleMemory(BaseMemory):
|
|
34
|
-
"""Per-environment history buffer for storing observations and actions."""
|
|
35
|
-
|
|
36
|
-
def __init__(self):
|
|
37
|
-
self._data = None
|
|
38
|
-
self.keys = None
|
|
39
|
-
self.batch_size = 0
|
|
40
|
-
|
|
41
|
-
def __len__(self):
|
|
42
|
-
return len(self._data)
|
|
43
|
-
|
|
44
|
-
def __getitem__(self, idx):
|
|
45
|
-
return self._data[idx]
|
|
46
|
-
|
|
47
|
-
def reset(self, batch_size: int):
|
|
48
|
-
if self._data is not None:
|
|
49
|
-
self._data.clear()
|
|
50
|
-
self._data = [[] for _ in range(batch_size)]
|
|
51
|
-
self.batch_size = batch_size
|
|
52
|
-
self.keys = None
|
|
53
|
-
|
|
54
|
-
def store(self, record: Dict[str, List[Any]]):
|
|
55
|
-
if self.keys is None:
|
|
56
|
-
self.keys = list(record.keys())
|
|
57
|
-
assert self.keys == list(record.keys())
|
|
58
|
-
|
|
59
|
-
for env_idx in range(self.batch_size):
|
|
60
|
-
self._data[env_idx].append({k: record[k][env_idx] for k in self.keys})
|
|
61
|
-
|
|
62
|
-
def fetch(
|
|
63
|
-
self,
|
|
64
|
-
history_length: int,
|
|
65
|
-
obs_key: str = "text_obs",
|
|
66
|
-
action_key: str = "action",
|
|
67
|
-
) -> Tuple[List[str], List[int]]:
|
|
68
|
-
memory_contexts, valid_lengths = [], []
|
|
69
|
-
|
|
70
|
-
for env_idx in range(self.batch_size):
|
|
71
|
-
recent = self._data[env_idx][-history_length:]
|
|
72
|
-
valid_len = len(recent)
|
|
73
|
-
start_idx = len(self._data[env_idx]) - valid_len
|
|
74
|
-
|
|
75
|
-
lines = []
|
|
76
|
-
for j, rec in enumerate(recent):
|
|
77
|
-
step_num = start_idx + j + 1
|
|
78
|
-
act = rec[action_key]
|
|
79
|
-
obs = rec[obs_key]
|
|
80
|
-
lines.append(
|
|
81
|
-
f"[Observation {step_num}: '{obs}', Action {step_num}: '{act}']"
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
memory_contexts.append("\n".join(lines))
|
|
85
|
-
valid_lengths.append(valid_len)
|
|
86
|
-
|
|
87
|
-
return memory_contexts, valid_lengths
|