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.
Files changed (301) hide show
  1. package/README.md +33 -23
  2. package/bin/cli.js +24 -67
  3. package/package.json +1 -1
  4. package/template/rules/knowledge/README.md +56 -0
  5. package/template/rules/knowledge/ant-design-vue.mdc +54 -0
  6. package/template/rules/knowledge/general.mdc +56 -0
  7. package/template/rules/knowledge/rust.mdc +55 -0
  8. package/template/rules/knowledge/shadcn-svelte.mdc +64 -0
  9. package/template/rules/knowledge/svelte.mdc +135 -0
  10. package/template/rules/knowledge/tailwind.mdc +66 -0
  11. package/template/rules/knowledge/tauri.mdc +65 -0
  12. package/template/rules/knowledge/typescript.mdc +41 -0
  13. package/template/rules/knowledge/vue.mdc +48 -0
  14. package/template/rules/ponytail.mdc +23 -98
  15. package/template/rules/self-evolve.mdc +24 -0
  16. package/template/skills/impeccable/SKILL.md +47 -174
  17. package/template/skills/skillopt-sleep/SKILL.md +32 -88
  18. package/template/skills/impeccable/agents/impeccable_asset_producer.toml +0 -92
  19. package/template/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
  20. package/template/skills/impeccable/agents/openai.yaml +0 -4
  21. package/template/skills/impeccable/reference/adapt.md +0 -311
  22. package/template/skills/impeccable/reference/animate.md +0 -201
  23. package/template/skills/impeccable/reference/audit.md +0 -133
  24. package/template/skills/impeccable/reference/bolder.md +0 -113
  25. package/template/skills/impeccable/reference/brand.md +0 -108
  26. package/template/skills/impeccable/reference/clarify.md +0 -288
  27. package/template/skills/impeccable/reference/codex.md +0 -105
  28. package/template/skills/impeccable/reference/colorize.md +0 -257
  29. package/template/skills/impeccable/reference/craft.md +0 -123
  30. package/template/skills/impeccable/reference/critique.md +0 -790
  31. package/template/skills/impeccable/reference/delight.md +0 -302
  32. package/template/skills/impeccable/reference/distill.md +0 -111
  33. package/template/skills/impeccable/reference/document.md +0 -429
  34. package/template/skills/impeccable/reference/extract.md +0 -69
  35. package/template/skills/impeccable/reference/harden.md +0 -347
  36. package/template/skills/impeccable/reference/hooks.md +0 -90
  37. package/template/skills/impeccable/reference/init.md +0 -172
  38. package/template/skills/impeccable/reference/interaction-design.md +0 -189
  39. package/template/skills/impeccable/reference/layout.md +0 -161
  40. package/template/skills/impeccable/reference/live.md +0 -720
  41. package/template/skills/impeccable/reference/onboard.md +0 -234
  42. package/template/skills/impeccable/reference/optimize.md +0 -258
  43. package/template/skills/impeccable/reference/overdrive.md +0 -130
  44. package/template/skills/impeccable/reference/polish.md +0 -241
  45. package/template/skills/impeccable/reference/product.md +0 -60
  46. package/template/skills/impeccable/reference/quieter.md +0 -99
  47. package/template/skills/impeccable/reference/shape.md +0 -165
  48. package/template/skills/impeccable/reference/typeset.md +0 -279
  49. package/template/skills/impeccable/scripts/command-metadata.json +0 -94
  50. package/template/skills/impeccable/scripts/context-signals.mjs +0 -225
  51. package/template/skills/impeccable/scripts/context.mjs +0 -961
  52. package/template/skills/impeccable/scripts/critique-storage.mjs +0 -242
  53. package/template/skills/impeccable/scripts/detect-csp.mjs +0 -198
  54. package/template/skills/impeccable/scripts/detect.mjs +0 -21
  55. package/template/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -1937
  56. package/template/skills/impeccable/scripts/detector/cli/main.mjs +0 -290
  57. package/template/skills/impeccable/scripts/detector/design-system.mjs +0 -750
  58. package/template/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -5138
  59. package/template/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -50
  60. package/template/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -277
  61. package/template/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -568
  62. package/template/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1015
  63. package/template/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -234
  64. package/template/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
  65. package/template/skills/impeccable/scripts/detector/findings.mjs +0 -12
  66. package/template/skills/impeccable/scripts/detector/node/file-system.mjs +0 -198
  67. package/template/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
  68. package/template/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -448
  69. package/template/skills/impeccable/scripts/detector/rules/checks.mjs +0 -2671
  70. package/template/skills/impeccable/scripts/detector/shared/color.mjs +0 -124
  71. package/template/skills/impeccable/scripts/detector/shared/constants.mjs +0 -101
  72. package/template/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
  73. package/template/skills/impeccable/scripts/detector/shared/page.mjs +0 -7
  74. package/template/skills/impeccable/scripts/hook-admin.mjs +0 -661
  75. package/template/skills/impeccable/scripts/hook-before-edit.mjs +0 -476
  76. package/template/skills/impeccable/scripts/hook-lib.mjs +0 -1632
  77. package/template/skills/impeccable/scripts/hook.mjs +0 -61
  78. package/template/skills/impeccable/scripts/lib/design-parser.mjs +0 -842
  79. package/template/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -638
  80. package/template/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -128
  81. package/template/skills/impeccable/scripts/lib/is-generated.mjs +0 -69
  82. package/template/skills/impeccable/scripts/lib/target-args.mjs +0 -42
  83. package/template/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -49
  84. package/template/skills/impeccable/scripts/live/completion.mjs +0 -19
  85. package/template/skills/impeccable/scripts/live/event-validation.mjs +0 -137
  86. package/template/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
  87. package/template/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
  88. package/template/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
  89. package/template/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
  90. package/template/skills/impeccable/scripts/live/session-store.mjs +0 -289
  91. package/template/skills/impeccable/scripts/live/svelte-component.mjs +0 -826
  92. package/template/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -274
  93. package/template/skills/impeccable/scripts/live/ui-core.mjs +0 -180
  94. package/template/skills/impeccable/scripts/live/vocabulary.mjs +0 -36
  95. package/template/skills/impeccable/scripts/live-accept.mjs +0 -812
  96. package/template/skills/impeccable/scripts/live-browser-dom.js +0 -146
  97. package/template/skills/impeccable/scripts/live-browser-session.js +0 -123
  98. package/template/skills/impeccable/scripts/live-browser.js +0 -11173
  99. package/template/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1241
  100. package/template/skills/impeccable/scripts/live-complete.mjs +0 -75
  101. package/template/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -683
  102. package/template/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
  103. package/template/skills/impeccable/scripts/live-inject.mjs +0 -583
  104. package/template/skills/impeccable/scripts/live-insert.mjs +0 -272
  105. package/template/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -363
  106. package/template/skills/impeccable/scripts/live-poll.mjs +0 -384
  107. package/template/skills/impeccable/scripts/live-resume.mjs +0 -94
  108. package/template/skills/impeccable/scripts/live-server.mjs +0 -1135
  109. package/template/skills/impeccable/scripts/live-status.mjs +0 -61
  110. package/template/skills/impeccable/scripts/live-target.mjs +0 -30
  111. package/template/skills/impeccable/scripts/live-wrap.mjs +0 -894
  112. package/template/skills/impeccable/scripts/live.mjs +0 -297
  113. package/template/skills/impeccable/scripts/modern-screenshot.umd.js +0 -14
  114. package/template/skills/impeccable/scripts/palette.mjs +0 -633
  115. package/template/skills/impeccable/scripts/pin.mjs +0 -214
  116. package/template/skills/skillopt-sleep/configs/_base_/default.yaml +0 -103
  117. package/template/skills/skillopt-sleep/configs/alfworld/default.yaml +0 -29
  118. package/template/skills/skillopt-sleep/configs/docvqa/default.yaml +0 -28
  119. package/template/skills/skillopt-sleep/configs/features/soft_gate.yaml +0 -47
  120. package/template/skills/skillopt-sleep/configs/livemathematicianbench/default.yaml +0 -22
  121. package/template/skills/skillopt-sleep/configs/officeqa/default.yaml +0 -34
  122. package/template/skills/skillopt-sleep/configs/searchqa/default.yaml +0 -32
  123. package/template/skills/skillopt-sleep/configs/spreadsheetbench/default.yaml +0 -34
  124. package/template/skills/skillopt-sleep/scripts/framework/skillopt/__init__.py +0 -28
  125. package/template/skills/skillopt-sleep/scripts/framework/skillopt/config.py +0 -282
  126. package/template/skills/skillopt-sleep/scripts/framework/skillopt/datasets/__init__.py +0 -7
  127. package/template/skills/skillopt-sleep/scripts/framework/skillopt/datasets/base.py +0 -512
  128. package/template/skills/skillopt-sleep/scripts/framework/skillopt/engine/__init__.py +0 -9
  129. package/template/skills/skillopt-sleep/scripts/framework/skillopt/engine/trainer.py +0 -2379
  130. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/__init__.py +0 -1
  131. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/README.md +0 -43
  132. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/config_template.yaml +0 -55
  133. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/env_template.py +0 -151
  134. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/_template/loader_template.py +0 -87
  135. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/__init__.py +0 -5
  136. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/adapter.py +0 -428
  137. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/dataloader.py +0 -123
  138. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/analyst_error.md +0 -55
  139. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/analyst_success.md +0 -33
  140. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/rollout_no_history.md +0 -8
  141. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/rollout_with_history.md +0 -9
  142. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/prompts/rollout_with_memory.md +0 -16
  143. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/reflect.py +0 -4
  144. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/rollout.py +0 -366
  145. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/skills/initial.md +0 -45
  146. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/__init__.py +0 -9
  147. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/alfworld_envs.py +0 -221
  148. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/alfworld_projection.py +0 -60
  149. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/alfworld_prompts.py +0 -8
  150. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/config_tw.yaml +0 -145
  151. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/env_base.py +0 -84
  152. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/env_manager.py +0 -139
  153. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/alfworld/vendor/memory.py +0 -87
  154. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/base.py +0 -329
  155. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/__init__.py +0 -1
  156. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/adapter.py +0 -90
  157. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/dataloader.py +0 -61
  158. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/evaluator.py +0 -113
  159. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/prompts/analyst_error.md +0 -35
  160. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/prompts/analyst_success.md +0 -24
  161. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/prompts/rollout_system.md +0 -12
  162. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/rollout.py +0 -391
  163. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/docvqa/skills/initial.md +0 -11
  164. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/__init__.py +0 -1
  165. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/adapter.py +0 -129
  166. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/dataloader.py +0 -308
  167. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/evaluator.py +0 -62
  168. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/prompts/analyst_error.md +0 -37
  169. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/prompts/analyst_success.md +0 -25
  170. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/prompts/rollout_system.md +0 -12
  171. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/reflect.py +0 -4
  172. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/rollout.py +0 -434
  173. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/livemathematicianbench/skills/initial.md +0 -16
  174. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/__init__.py +0 -1
  175. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/adapter.py +0 -112
  176. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/dataloader.py +0 -71
  177. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/evaluator.py +0 -46
  178. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/prompts/analyst_error.md +0 -37
  179. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/prompts/analyst_success.md +0 -25
  180. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/prompts/rollout_system.md +0 -15
  181. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/rollout.py +0 -799
  182. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/skills/initial.md +0 -15
  183. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/officeqa/tool_runtime.py +0 -552
  184. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/__init__.py +0 -1
  185. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/adapter.py +0 -96
  186. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/dataloader.py +0 -42
  187. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/evaluator.py +0 -100
  188. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/prompts/analyst_error.md +0 -46
  189. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/prompts/analyst_success.md +0 -32
  190. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/prompts/rollout_system.md +0 -13
  191. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/reflect.py +0 -4
  192. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/rollout.py +0 -494
  193. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/searchqa/skills/initial.md +0 -3
  194. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/__init__.py +0 -5
  195. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/adapter.py +0 -159
  196. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/codegen_agent.py +0 -731
  197. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/dataloader.py +0 -37
  198. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/evaluator.py +0 -158
  199. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/executor.py +0 -67
  200. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/analyst_error.md +0 -46
  201. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/analyst_success.md +0 -32
  202. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/codegen_system.md +0 -1
  203. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/critical_rules.md +0 -9
  204. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/prompts/react_system.md +0 -21
  205. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/react_agent.py +0 -395
  206. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/reflect.py +0 -4
  207. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/rollout.py +0 -979
  208. package/template/skills/skillopt-sleep/scripts/framework/skillopt/envs/spreadsheetbench/skills/initial.md +0 -56
  209. package/template/skills/skillopt-sleep/scripts/framework/skillopt/evaluation/__init__.py +0 -13
  210. package/template/skills/skillopt-sleep/scripts/framework/skillopt/evaluation/gate.py +0 -148
  211. package/template/skills/skillopt-sleep/scripts/framework/skillopt/gradient/__init__.py +0 -15
  212. package/template/skills/skillopt-sleep/scripts/framework/skillopt/gradient/aggregate.py +0 -253
  213. package/template/skills/skillopt-sleep/scripts/framework/skillopt/gradient/reflect.py +0 -635
  214. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/__init__.py +0 -514
  215. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/azure_openai.py +0 -915
  216. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/backend_config.py +0 -185
  217. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/claude_backend.py +0 -371
  218. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/codex_backend.py +0 -666
  219. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/codex_harness.py +0 -1057
  220. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/common.py +0 -229
  221. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/minimax_backend.py +0 -277
  222. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/qwen_backend.py +0 -456
  223. package/template/skills/skillopt-sleep/scripts/framework/skillopt/model/router.py +0 -236
  224. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/__init__.py +0 -15
  225. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/appendix.py +0 -156
  226. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/clip.py +0 -109
  227. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/lr_autonomous.py +0 -108
  228. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/meta_skill.py +0 -79
  229. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/rewrite.py +0 -59
  230. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/scheduler.py +0 -127
  231. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/select.py +0 -4
  232. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/skill.py +0 -201
  233. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/skill_aware.py +0 -206
  234. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/slow_update.py +0 -396
  235. package/template/skills/skillopt-sleep/scripts/framework/skillopt/optimizer/update_modes.py +0 -135
  236. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/__init__.py +0 -63
  237. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_error.md +0 -41
  238. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_error_full_rewrite.md +0 -32
  239. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_error_rewrite.md +0 -44
  240. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_success.md +0 -36
  241. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_success_full_rewrite.md +0 -30
  242. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/analyst_success_rewrite.md +0 -33
  243. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/lr_autonomous.md +0 -20
  244. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_failure.md +0 -30
  245. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_failure_full_rewrite.md +0 -28
  246. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_failure_rewrite.md +0 -26
  247. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_final.md +0 -33
  248. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_final_full_rewrite.md +0 -28
  249. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_final_rewrite.md +0 -25
  250. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_success.md +0 -28
  251. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_success_full_rewrite.md +0 -28
  252. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/merge_success_rewrite.md +0 -25
  253. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/meta_skill.md +0 -40
  254. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/ranking.md +0 -20
  255. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/ranking_rewrite.md +0 -15
  256. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/rewrite_skill.md +0 -25
  257. package/template/skills/skillopt-sleep/scripts/framework/skillopt/prompts/slow_update.md +0 -60
  258. package/template/skills/skillopt-sleep/scripts/framework/skillopt/scheduler/__init__.py +0 -8
  259. package/template/skills/skillopt-sleep/scripts/framework/skillopt/types.py +0 -306
  260. package/template/skills/skillopt-sleep/scripts/framework/skillopt/utils/__init__.py +0 -4
  261. package/template/skills/skillopt-sleep/scripts/framework/skillopt/utils/json_utils.py +0 -172
  262. package/template/skills/skillopt-sleep/scripts/framework/skillopt/utils/scoring.py +0 -28
  263. package/template/skills/skillopt-sleep/scripts/python/__init__.py +0 -20
  264. package/template/skills/skillopt-sleep/scripts/python/__main__.py +0 -343
  265. package/template/skills/skillopt-sleep/scripts/python/backend.py +0 -1371
  266. package/template/skills/skillopt-sleep/scripts/python/budget.py +0 -75
  267. package/template/skills/skillopt-sleep/scripts/python/config.py +0 -162
  268. package/template/skills/skillopt-sleep/scripts/python/consolidate.py +0 -238
  269. package/template/skills/skillopt-sleep/scripts/python/cycle.py +0 -291
  270. package/template/skills/skillopt-sleep/scripts/python/dream.py +0 -138
  271. package/template/skills/skillopt-sleep/scripts/python/experiments/__init__.py +0 -1
  272. package/template/skills/skillopt-sleep/scripts/python/experiments/gbrain_bench.py +0 -119
  273. package/template/skills/skillopt-sleep/scripts/python/experiments/personas.py +0 -86
  274. package/template/skills/skillopt-sleep/scripts/python/experiments/report.py +0 -132
  275. package/template/skills/skillopt-sleep/scripts/python/experiments/run_experiment.py +0 -178
  276. package/template/skills/skillopt-sleep/scripts/python/experiments/run_gbrain.py +0 -209
  277. package/template/skills/skillopt-sleep/scripts/python/experiments/run_transfer.py +0 -155
  278. package/template/skills/skillopt-sleep/scripts/python/experiments/sweep.py +0 -164
  279. package/template/skills/skillopt-sleep/scripts/python/gate.py +0 -50
  280. package/template/skills/skillopt-sleep/scripts/python/harvest.py +0 -304
  281. package/template/skills/skillopt-sleep/scripts/python/harvest_codex.py +0 -253
  282. package/template/skills/skillopt-sleep/scripts/python/harvest_sources.py +0 -41
  283. package/template/skills/skillopt-sleep/scripts/python/judges.py +0 -84
  284. package/template/skills/skillopt-sleep/scripts/python/llm_miner.py +0 -134
  285. package/template/skills/skillopt-sleep/scripts/python/memory.py +0 -129
  286. package/template/skills/skillopt-sleep/scripts/python/mine.py +0 -312
  287. package/template/skills/skillopt-sleep/scripts/python/replay.py +0 -146
  288. package/template/skills/skillopt-sleep/scripts/python/rollout.py +0 -153
  289. package/template/skills/skillopt-sleep/scripts/python/scheduler.py +0 -138
  290. package/template/skills/skillopt-sleep/scripts/python/slow_update.py +0 -142
  291. package/template/skills/skillopt-sleep/scripts/python/staging.py +0 -103
  292. package/template/skills/skillopt-sleep/scripts/python/state.py +0 -96
  293. package/template/skills/skillopt-sleep/scripts/python/tasks_file.py +0 -81
  294. package/template/skills/skillopt-sleep/scripts/python/types.py +0 -146
  295. package/template/skills/skillopt-sleep/scripts/shell/__init__.py +0 -0
  296. package/template/skills/skillopt-sleep/scripts/shell/eval_only.py +0 -466
  297. package/template/skills/skillopt-sleep/scripts/shell/materialize_searchqa.py +0 -148
  298. package/template/skills/skillopt-sleep/scripts/shell/run_alfworld.sh +0 -60
  299. package/template/skills/skillopt-sleep/scripts/shell/run_searchqa.sh +0 -40
  300. package/template/skills/skillopt-sleep/scripts/shell/run_spreadsheetbench.sh +0 -39
  301. package/template/skills/skillopt-sleep/scripts/shell/train.py +0 -556
@@ -1,961 +0,0 @@
1
- /**
2
- * Context loader: prints PRODUCT.md (and DESIGN.md if present) as one
3
- * markdown block on stdout, or exits with empty stdout when no PRODUCT.md
4
- * is found anywhere. The skill keys off "empty stdout" to branch into the
5
- * init flow.
6
- *
7
- * Path resolution (first match wins):
8
- * 1. Active project root, if PRODUCT.md or DESIGN.md is there
9
- * 2. Active project .agents/context/ then docs/
10
- * 3. Monorepo root context, using the same order, as a per-file fallback
11
- * 4. $IMPECCABLE_CONTEXT_DIR (absolute or cwd-relative) — power-user
12
- * escape hatch, only consulted when defaults are empty
13
- * 5. Active project root as a "nothing found" default
14
- *
15
- * `resolveContextDir()` and `loadContext()` are also exported for the
16
- * server-side scripts (live.mjs, live-server.mjs) that need the structured
17
- * shape rather than the markdown block.
18
- */
19
- import fs from 'node:fs';
20
- import os from 'node:os';
21
- import path from 'node:path';
22
- import { fileURLToPath } from 'node:url';
23
- import { parseTargetOptions } from './lib/target-args.mjs';
24
-
25
- const PRODUCT_NAMES = ['PRODUCT.md', 'Product.md', 'product.md'];
26
- const DESIGN_NAMES = ['DESIGN.md', 'Design.md', 'design.md'];
27
- const FALLBACK_DIRS = ['.agents/context', 'docs'];
28
- const MONOREPO_MARKER_FILES = ['pnpm-workspace.yaml', 'turbo.json', 'nx.json', 'lerna.json'];
29
- const MONOREPO_FALLBACK_PROJECT_DIRS = ['apps', 'packages'];
30
- const WORKSPACE_DISCOVERY_IGNORED_DIRS = new Set([
31
- 'node_modules',
32
- '.git',
33
- 'dist',
34
- 'build',
35
- '.next',
36
- '.nuxt',
37
- '.svelte-kit',
38
- '.turbo',
39
- '.cache',
40
- 'coverage',
41
- ]);
42
-
43
- // ─── Update check ──────────────────────────────────────────────────────────
44
- // Piggyback a lightweight skill-version check on the once-per-session boot.
45
- // When a newer skill ships, append an UPDATE_AVAILABLE directive so the agent
46
- // can offer `npx impeccable update`. Everything here is best-effort and
47
- // silent on failure: a network problem, sandbox, or missing cache must never
48
- // block context output or print an error.
49
-
50
- const UPDATE_HOST = (process.env.IMPECCABLE_UPDATE_HOST || 'https://impeccable.style').replace(/\/$/, '');
51
- const UPDATE_CACHE_PATH =
52
- process.env.IMPECCABLE_UPDATE_CACHE || path.join(os.homedir(), '.impeccable', 'update-check.json');
53
- const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // throttle the network poll to once a day
54
- const RENOTIFY_INTERVAL_MS = 7 * 24 * 60 * 60 * 1000; // don't re-surface the same version for a week
55
- const FETCH_TIMEOUT_MS = 1200;
56
-
57
- export function resolveContextDir(cwd = process.cwd(), options = {}) {
58
- return resolveContext(cwd, options).contextDir;
59
- }
60
-
61
- export function loadContext(cwd = process.cwd(), options = {}) {
62
- const resolved = resolveContext(cwd, options);
63
- const absCwd = path.resolve(cwd);
64
- const productPath = resolved.productPath;
65
- const designPath = resolved.designPath;
66
- const product = productPath ? safeRead(productPath) : null;
67
- const design = designPath ? safeRead(designPath) : null;
68
- return {
69
- hasProduct: !!product,
70
- product,
71
- productPath: productPath ? path.relative(absCwd, productPath) : null,
72
- hasDesign: !!design,
73
- design,
74
- designPath: designPath ? path.relative(absCwd, designPath) : null,
75
- contextDir: resolved.contextDir,
76
- productContextDir: productPath ? path.dirname(productPath) : null,
77
- designContextDir: designPath ? path.dirname(designPath) : null,
78
- projectRoot: resolved.projectRoot,
79
- repoRoot: resolved.repoRoot,
80
- isMonorepo: resolved.isMonorepo,
81
- };
82
- }
83
-
84
- function resolveContext(cwd = process.cwd(), options = {}) {
85
- const absCwd = path.resolve(cwd);
86
- const project = resolveProject(absCwd, options);
87
- const projectContextDir = resolveLocalContextDir(project.projectRoot);
88
- const rootContextDir = project.isMonorepo && project.repoRoot !== project.projectRoot
89
- ? resolveLocalContextDir(project.repoRoot)
90
- : null;
91
-
92
- let productPath =
93
- (projectContextDir ? firstExisting(projectContextDir, PRODUCT_NAMES) : null)
94
- || (rootContextDir ? firstExisting(rootContextDir, PRODUCT_NAMES) : null);
95
- let designPath =
96
- (projectContextDir ? firstExisting(projectContextDir, DESIGN_NAMES) : null)
97
- || (rootContextDir ? firstExisting(rootContextDir, DESIGN_NAMES) : null);
98
-
99
- let envContextDir = null;
100
- if (!productPath && !designPath) {
101
- envContextDir = resolveEnvContextDir(absCwd);
102
- if (envContextDir) {
103
- productPath = firstExisting(envContextDir, PRODUCT_NAMES);
104
- designPath = firstExisting(envContextDir, DESIGN_NAMES);
105
- }
106
- }
107
-
108
- return {
109
- contextDir: productPath
110
- ? path.dirname(productPath)
111
- : designPath
112
- ? path.dirname(designPath)
113
- : envContextDir || project.projectRoot,
114
- productPath,
115
- designPath,
116
- projectRoot: project.projectRoot,
117
- repoRoot: project.repoRoot,
118
- isMonorepo: project.isMonorepo,
119
- targetDir: project.targetDir,
120
- };
121
- }
122
-
123
- export function resolveProjectRoot(cwd = process.cwd(), options = {}) {
124
- return resolveProject(cwd, options).projectRoot;
125
- }
126
-
127
- export function resolveTargetSelection(cwd = process.cwd(), options = {}) {
128
- if (hasTargetOption(options)) return null;
129
- const project = resolveProject(cwd);
130
- if (
131
- !project.isMonorepo
132
- || !project.projectRoot
133
- || !project.repoRoot
134
- || path.resolve(project.projectRoot) !== path.resolve(project.repoRoot)
135
- ) {
136
- return null;
137
- }
138
- const targetCandidates = discoverTargetCandidates(project.repoRoot);
139
- // No discoverable child apps (e.g. `workspaces: ["."]`, a root-only workspace,
140
- // or a marker file with no apps/packages children): there is nothing to choose,
141
- // so treat the repo root as the active project rather than blocking on an empty
142
- // selection prompt that the user cannot answer.
143
- if (targetCandidates.length === 0) return null;
144
- return {
145
- targetPath: null,
146
- projectRoot: project.projectRoot,
147
- repoRoot: project.repoRoot,
148
- targetCandidates,
149
- };
150
- }
151
-
152
- function resolveProject(cwd = process.cwd(), options = {}) {
153
- const absCwd = path.resolve(cwd);
154
- const targetDir = resolveTargetDir(absCwd, options);
155
- let repoRoot = findMonorepoRoot(targetDir);
156
- if (!repoRoot && targetDir !== absCwd) {
157
- const cwdRepoRoot = findMonorepoRoot(absCwd);
158
- if (cwdRepoRoot && isPathInside(targetDir, cwdRepoRoot)) {
159
- repoRoot = cwdRepoRoot;
160
- }
161
- }
162
- if (!repoRoot) {
163
- return {
164
- targetDir,
165
- projectRoot: absCwd,
166
- repoRoot: absCwd,
167
- isMonorepo: false,
168
- };
169
- }
170
- return {
171
- targetDir,
172
- projectRoot: resolveWorkspaceProjectRoot(repoRoot, targetDir) || repoRoot,
173
- repoRoot,
174
- isMonorepo: true,
175
- };
176
- }
177
-
178
- function isPathInside(candidate, root) {
179
- const rel = path.relative(root, candidate);
180
- return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel);
181
- }
182
-
183
- function resolveLocalContextDir(root) {
184
- if (firstExisting(root, [...PRODUCT_NAMES, ...DESIGN_NAMES])) {
185
- return root;
186
- }
187
- for (const rel of FALLBACK_DIRS) {
188
- const candidate = path.resolve(root, rel);
189
- if (firstExisting(candidate, [...PRODUCT_NAMES, ...DESIGN_NAMES])) {
190
- return candidate;
191
- }
192
- }
193
- return null;
194
- }
195
-
196
- function resolveEnvContextDir(cwd) {
197
- const envDir = process.env.IMPECCABLE_CONTEXT_DIR;
198
- if (!envDir || !envDir.trim()) return null;
199
- const trimmed = envDir.trim();
200
- return path.isAbsolute(trimmed) ? trimmed : path.resolve(cwd, trimmed);
201
- }
202
-
203
- function resolveTargetDir(cwd, options = {}) {
204
- const targetPath = options && typeof options === 'object' ? options.targetPath : null;
205
- if (!targetPath || !String(targetPath).trim()) return cwd;
206
- const abs = path.isAbsolute(targetPath) ? targetPath : path.resolve(cwd, targetPath);
207
- try {
208
- const stat = fs.statSync(abs);
209
- return stat.isDirectory() ? abs : path.dirname(abs);
210
- } catch {
211
- return path.extname(abs) ? path.dirname(abs) : abs;
212
- }
213
- }
214
-
215
- function findMonorepoRoot(startDir) {
216
- let dir = path.resolve(startDir);
217
- const homeDir = path.resolve(os.homedir());
218
- while (true) {
219
- if (dir === homeDir) return null;
220
- // isMonorepoRoot is checked before hasGitBoundary on purpose: a workspace
221
- // root that also carries its own .git is still recognized. The trade-off is
222
- // deliberate — a directory with a monorepo *marker* but no workspace patterns
223
- // and no apps/packages children is not a monorepo root, so its .git stops
224
- // traversal and a further-up root is not searched. The nested .git is treated
225
- // as an independent project boundary, which is the intended isolation.
226
- if (isMonorepoRoot(dir)) return dir;
227
- if (hasGitBoundary(dir)) return null;
228
- const parent = path.dirname(dir);
229
- if (parent === dir) return null;
230
- dir = parent;
231
- }
232
- }
233
-
234
- function isMonorepoRoot(dir) {
235
- if (readWorkspacePatterns(dir).some((pattern) => !normalizeWorkspacePattern(pattern).startsWith('!'))) return true;
236
- if (!MONOREPO_MARKER_FILES.some((file) => fs.existsSync(path.join(dir, file)))) return false;
237
- return hasFallbackWorkspaceChildren(dir);
238
- }
239
-
240
- function hasGitBoundary(dir) {
241
- return fs.existsSync(path.join(dir, '.git'));
242
- }
243
-
244
- function hasFallbackWorkspaceChildren(dir) {
245
- for (const name of MONOREPO_FALLBACK_PROJECT_DIRS) {
246
- const base = path.join(dir, name);
247
- let entries;
248
- try {
249
- entries = fs.readdirSync(base, { withFileTypes: true });
250
- } catch {
251
- continue;
252
- }
253
- if (entries.some((entry) => entry.isDirectory() && !isIgnoredWorkspaceDiscoveryDir(entry.name))) return true;
254
- }
255
- return false;
256
- }
257
-
258
- function discoverTargetCandidates(repoRoot) {
259
- const roots = new Map();
260
- const patterns = readWorkspacePatterns(repoRoot);
261
- for (const pattern of patterns) {
262
- for (const root of discoverRootsForPattern(repoRoot, pattern)) {
263
- roots.set(path.relative(repoRoot, root).split(path.sep).join('/'), root);
264
- }
265
- }
266
- if (MONOREPO_MARKER_FILES.some((file) => fs.existsSync(path.join(repoRoot, file)))) {
267
- for (const name of MONOREPO_FALLBACK_PROJECT_DIRS) {
268
- const base = path.join(repoRoot, name);
269
- let entries;
270
- try {
271
- entries = fs.readdirSync(base, { withFileTypes: true });
272
- } catch {
273
- continue;
274
- }
275
- for (const entry of entries) {
276
- if (!entry.isDirectory() || isIgnoredWorkspaceDiscoveryDir(entry.name)) continue;
277
- const root = path.join(base, entry.name);
278
- roots.set(path.relative(repoRoot, root).split(path.sep).join('/'), root);
279
- }
280
- }
281
- }
282
- return [...roots.entries()]
283
- .filter(([rel]) => rel && !rel.startsWith('..'))
284
- // Honor negated workspace patterns (e.g. "!packages/internal"). resolveWorkspaceProjectRoot
285
- // sends an excluded package back to the repo root, so an excluded folder must not appear as a
286
- // selectable target — choosing it would silently resolve to the root instead.
287
- .filter(([rel]) => !isExcludedByWorkspacePattern(rel.split('/').filter(Boolean), patterns))
288
- .sort(([a], [b]) => a.localeCompare(b))
289
- .map(([rel, root]) => {
290
- const targetExample = findTargetExample(repoRoot, root);
291
- return {
292
- name: path.basename(root),
293
- path: rel,
294
- targetExample,
295
- ...resolveCandidateContextSummary(repoRoot, root, targetExample),
296
- };
297
- });
298
- }
299
-
300
- function resolveCandidateContextSummary(repoRoot, projectRoot, targetPath) {
301
- const ctx = resolveContext(repoRoot, { targetPath });
302
- return {
303
- productStatus: contextSourceStatus(ctx.productPath, repoRoot, projectRoot),
304
- productPath: contextSourcePath(ctx.productPath, repoRoot),
305
- designStatus: contextSourceStatus(ctx.designPath, repoRoot, projectRoot),
306
- designPath: contextSourcePath(ctx.designPath, repoRoot),
307
- };
308
- }
309
-
310
- // Selection candidates surface one of four statuses: 'child' (a canonical
311
- // PRODUCT.md/DESIGN.md directly in the app root), 'inherited' (resolved from the
312
- // repo root in a monorepo), 'missing' (no file found), and 'fallback'. 'fallback'
313
- // intentionally covers two non-canonical locations: a file inside the project
314
- // root but in a subdirectory (FALLBACK_DIRS, e.g. `.agents/context/`), and a file
315
- // outside both the project and repo roots (IMPECCABLE_CONTEXT_DIR override).
316
- function contextSourceStatus(filePath, repoRoot, projectRoot) {
317
- if (!filePath) return 'missing';
318
- const absPath = path.resolve(filePath);
319
- const absProjectRoot = path.resolve(projectRoot);
320
- const absRepoRoot = path.resolve(repoRoot);
321
- if (isPathInsideOrEqual(absPath, absProjectRoot)) {
322
- return path.dirname(absPath) === absProjectRoot ? 'child' : 'fallback';
323
- }
324
- if (absProjectRoot !== absRepoRoot && isPathInsideOrEqual(absPath, absRepoRoot)) {
325
- return 'inherited';
326
- }
327
- return 'fallback';
328
- }
329
-
330
- function contextSourcePath(filePath, repoRoot) {
331
- if (!filePath) return null;
332
- const rel = path.relative(repoRoot, filePath);
333
- if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) {
334
- return rel.split(path.sep).join('/');
335
- }
336
- return filePath;
337
- }
338
-
339
- function discoverRootsForPattern(repoRoot, rawPattern) {
340
- const pattern = normalizeWorkspacePattern(rawPattern);
341
- if (!pattern || pattern.startsWith('!')) return [];
342
- const segments = pattern.split('/').filter(Boolean);
343
- if (!segments.length) return [];
344
- const firstGlobIndex = segments.findIndex((segment) => segment.includes('*'));
345
- const literalPrefix = firstGlobIndex === -1 ? segments : segments.slice(0, firstGlobIndex);
346
- const base = path.join(repoRoot, ...literalPrefix);
347
- if (!fs.existsSync(base)) return [];
348
- if (segments.includes('**')) {
349
- const packageRoots = [];
350
- walkDirs(base, (dir) => {
351
- if (dir !== base && isCandidateProjectRoot(dir)) packageRoots.push(dir);
352
- });
353
- if (packageRoots.length) return packageRoots;
354
- return directChildDirs(base);
355
- }
356
- return expandSimplePattern(repoRoot, segments);
357
- }
358
-
359
- function expandSimplePattern(repoRoot, patternSegments, index = 0, current = repoRoot) {
360
- if (index >= patternSegments.length) return fs.existsSync(current) ? [current] : [];
361
- const segment = patternSegments[index];
362
- if (!segment.includes('*')) {
363
- return expandSimplePattern(repoRoot, patternSegments, index + 1, path.join(current, segment));
364
- }
365
- let entries;
366
- try {
367
- entries = fs.readdirSync(current, { withFileTypes: true });
368
- } catch {
369
- return [];
370
- }
371
- const roots = [];
372
- for (const entry of entries) {
373
- if (!entry.isDirectory() || isIgnoredWorkspaceDiscoveryDir(entry.name)) continue;
374
- if (!segmentMatches(segment, entry.name)) continue;
375
- roots.push(...expandSimplePattern(repoRoot, patternSegments, index + 1, path.join(current, entry.name)));
376
- }
377
- return roots;
378
- }
379
-
380
- function directChildDirs(dir) {
381
- try {
382
- return fs.readdirSync(dir, { withFileTypes: true })
383
- .filter((entry) => entry.isDirectory() && !isIgnoredWorkspaceDiscoveryDir(entry.name))
384
- .map((entry) => path.join(dir, entry.name));
385
- } catch {
386
- return [];
387
- }
388
- }
389
-
390
- function walkDirs(root, visit) {
391
- let entries;
392
- try {
393
- entries = fs.readdirSync(root, { withFileTypes: true });
394
- } catch {
395
- return;
396
- }
397
- for (const entry of entries) {
398
- if (!entry.isDirectory() || isIgnoredWorkspaceDiscoveryDir(entry.name)) continue;
399
- const dir = path.join(root, entry.name);
400
- visit(dir);
401
- walkDirs(dir, visit);
402
- }
403
- }
404
-
405
- function isCandidateProjectRoot(dir) {
406
- return !!(
407
- fs.existsSync(path.join(dir, 'package.json'))
408
- || firstExisting(dir, [...PRODUCT_NAMES, ...DESIGN_NAMES])
409
- || fs.existsSync(path.join(dir, 'src'))
410
- || fs.existsSync(path.join(dir, 'app'))
411
- || fs.existsSync(path.join(dir, 'pages'))
412
- || fs.existsSync(path.join(dir, 'public'))
413
- );
414
- }
415
-
416
- function isIgnoredWorkspaceDiscoveryDir(name) {
417
- return name.startsWith('.') || WORKSPACE_DISCOVERY_IGNORED_DIRS.has(name);
418
- }
419
-
420
- function findTargetExample(repoRoot, projectRoot) {
421
- const examples = [
422
- 'src/App.jsx',
423
- 'src/App.tsx',
424
- 'src/main.jsx',
425
- 'src/main.tsx',
426
- 'src/index.jsx',
427
- 'src/index.ts',
428
- 'app/page.tsx',
429
- 'pages/index.tsx',
430
- 'public/index.html',
431
- ];
432
- for (const rel of examples) {
433
- const abs = path.join(projectRoot, rel);
434
- if (fs.existsSync(abs)) return path.relative(repoRoot, abs).split(path.sep).join('/');
435
- }
436
- return path.relative(repoRoot, projectRoot).split(path.sep).join('/');
437
- }
438
-
439
- function resolveWorkspaceProjectRoot(repoRoot, targetDir) {
440
- const rel = path.relative(repoRoot, targetDir);
441
- if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return repoRoot;
442
- const relSegments = rel.split(path.sep).filter(Boolean);
443
- const patterns = readWorkspacePatterns(repoRoot);
444
- const excluded = isExcludedByWorkspacePattern(relSegments, patterns);
445
- if (!excluded) {
446
- for (const pattern of patterns) {
447
- const projectRoot = projectRootFromWorkspacePattern(repoRoot, relSegments, pattern);
448
- if (projectRoot) return projectRoot;
449
- }
450
- }
451
- if (excluded) return repoRoot;
452
- if (
453
- relSegments.length >= 2
454
- && MONOREPO_FALLBACK_PROJECT_DIRS.includes(relSegments[0])
455
- ) {
456
- return path.join(repoRoot, relSegments[0], relSegments[1]);
457
- }
458
- const nearest = nearestProjectLikeRoot(repoRoot, targetDir);
459
- if (nearest) return nearest;
460
- return repoRoot;
461
- }
462
-
463
- function isExcludedByWorkspacePattern(relSegments, patterns) {
464
- return patterns.some((rawPattern) => {
465
- const pattern = normalizeWorkspacePattern(rawPattern);
466
- if (!pattern.startsWith('!')) return false;
467
- return workspacePatternMatchesRel(pattern.slice(1), relSegments);
468
- });
469
- }
470
-
471
- function nearestProjectLikeRoot(repoRoot, targetDir) {
472
- let dir = path.resolve(targetDir);
473
- const stop = path.resolve(repoRoot);
474
- while (dir && dir !== stop) {
475
- if (
476
- firstExisting(dir, [...PRODUCT_NAMES, ...DESIGN_NAMES])
477
- || fs.existsSync(path.join(dir, 'package.json'))
478
- ) {
479
- return dir;
480
- }
481
- const parent = path.dirname(dir);
482
- if (parent === dir) break;
483
- dir = parent;
484
- }
485
- return null;
486
- }
487
-
488
- function nearestPackageRootBetween(repoRoot, targetDir, stopDir) {
489
- let dir = path.resolve(targetDir);
490
- const stop = path.resolve(stopDir || repoRoot);
491
- const root = path.resolve(repoRoot);
492
- while (dir && dir !== stop && isPathInsideOrEqual(dir, root)) {
493
- if (fs.existsSync(path.join(dir, 'package.json'))) return dir;
494
- const parent = path.dirname(dir);
495
- if (parent === dir) break;
496
- dir = parent;
497
- }
498
- return null;
499
- }
500
-
501
- function isPathInsideOrEqual(candidate, root) {
502
- return path.resolve(candidate) === path.resolve(root) || isPathInside(candidate, root);
503
- }
504
-
505
- function workspacePatternMatchesRel(pattern, relSegments) {
506
- const patternSegments = normalizeWorkspacePattern(pattern).split('/').filter(Boolean);
507
- if (!patternSegments.length) return false;
508
- if (patternSegments.includes('**')) {
509
- const firstGlobIndex = patternSegments.findIndex((segment) => segment.includes('*'));
510
- const literalPrefix = firstGlobIndex === -1
511
- ? patternSegments
512
- : patternSegments.slice(0, firstGlobIndex);
513
- if (relSegments.length < literalPrefix.length + 1) return false;
514
- for (let i = 0; i < literalPrefix.length; i++) {
515
- if (!segmentMatches(literalPrefix[i], relSegments[i])) return false;
516
- }
517
- return true;
518
- }
519
- if (relSegments.length < patternSegments.length) return false;
520
- for (let i = 0; i < patternSegments.length; i++) {
521
- if (!segmentMatches(patternSegments[i], relSegments[i])) return false;
522
- }
523
- return true;
524
- }
525
-
526
- function readWorkspacePatterns(repoRoot) {
527
- return [
528
- ...readPackageWorkspaces(repoRoot),
529
- ...readPnpmWorkspaces(repoRoot),
530
- ...readLernaWorkspaces(repoRoot),
531
- ].filter(Boolean);
532
- }
533
-
534
- function readPackageWorkspaces(repoRoot) {
535
- const pkg = readJson(path.join(repoRoot, 'package.json'));
536
- const workspaces = pkg?.workspaces;
537
- if (Array.isArray(workspaces)) return workspaces;
538
- if (Array.isArray(workspaces?.packages)) return workspaces.packages;
539
- return [];
540
- }
541
-
542
- function readLernaWorkspaces(repoRoot) {
543
- const lerna = readJson(path.join(repoRoot, 'lerna.json'));
544
- return Array.isArray(lerna?.packages) ? lerna.packages : [];
545
- }
546
-
547
- function readPnpmWorkspaces(repoRoot) {
548
- try {
549
- const body = fs.readFileSync(path.join(repoRoot, 'pnpm-workspace.yaml'), 'utf-8');
550
- const patterns = [];
551
- let inPackages = false;
552
- for (const line of body.split(/\r?\n/)) {
553
- const trimmed = stripYamlInlineComment(line).trim();
554
- if (!trimmed || trimmed.startsWith('#')) continue;
555
- const flowMatch = trimmed.match(/^packages:\s*\[(.*)\]\s*$/);
556
- if (flowMatch) {
557
- patterns.push(...parseYamlFlowList(flowMatch[1]));
558
- inPackages = false;
559
- continue;
560
- }
561
- if (/^packages:\s*$/.test(trimmed)) {
562
- inPackages = true;
563
- continue;
564
- }
565
- if (inPackages && /^[A-Za-z0-9_-]+:\s*/.test(trimmed)) break;
566
- if (inPackages) {
567
- const match = trimmed.match(/^-\s*(.+)$/);
568
- if (match) patterns.push(unquoteYamlValue(match[1]));
569
- }
570
- }
571
- return patterns;
572
- } catch {
573
- return [];
574
- }
575
- }
576
-
577
- function stripYamlInlineComment(line) {
578
- let quote = null;
579
- for (let i = 0; i < line.length; i++) {
580
- const ch = line[i];
581
- if ((ch === '"' || ch === "'") && line[i - 1] !== '\\') {
582
- quote = quote === ch ? null : quote || ch;
583
- continue;
584
- }
585
- if (ch === '#' && !quote) return line.slice(0, i);
586
- }
587
- return line;
588
- }
589
-
590
- function parseYamlFlowList(body) {
591
- const items = [];
592
- let quote = null;
593
- let current = '';
594
- for (let i = 0; i < body.length; i++) {
595
- const ch = body[i];
596
- if ((ch === '"' || ch === "'") && body[i - 1] !== '\\') {
597
- quote = quote === ch ? null : quote || ch;
598
- current += ch;
599
- continue;
600
- }
601
- if (ch === ',' && !quote) {
602
- const value = unquoteYamlValue(current);
603
- if (value) items.push(value);
604
- current = '';
605
- continue;
606
- }
607
- current += ch;
608
- }
609
- const value = unquoteYamlValue(current);
610
- if (value) items.push(value);
611
- return items;
612
- }
613
-
614
- function unquoteYamlValue(value) {
615
- return String(value || '')
616
- .trim()
617
- .replace(/^['"]|['"]$/g, '');
618
- }
619
-
620
- function readJson(filePath) {
621
- try {
622
- return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
623
- } catch {
624
- return null;
625
- }
626
- }
627
-
628
- function projectRootFromWorkspacePattern(repoRoot, relSegments, rawPattern) {
629
- const pattern = normalizeWorkspacePattern(rawPattern);
630
- if (!pattern || pattern.startsWith('!')) return null;
631
- const patternSegments = pattern.split('/').filter(Boolean);
632
- if (!patternSegments.length) return null;
633
- if (patternSegments.includes('**')) {
634
- return projectRootFromDoubleStarPattern(repoRoot, relSegments, patternSegments);
635
- }
636
- if (relSegments.length < patternSegments.length) return null;
637
- for (let i = 0; i < patternSegments.length; i++) {
638
- if (!segmentMatches(patternSegments[i], relSegments[i])) return null;
639
- }
640
- return path.join(repoRoot, ...relSegments.slice(0, patternSegments.length));
641
- }
642
-
643
- function projectRootFromDoubleStarPattern(repoRoot, relSegments, patternSegments) {
644
- const firstGlobIndex = patternSegments.findIndex((segment) => segment.includes('*'));
645
- const literalPrefix = firstGlobIndex === -1
646
- ? patternSegments
647
- : patternSegments.slice(0, firstGlobIndex);
648
- if (relSegments.length < literalPrefix.length + 1) return null;
649
- for (let i = 0; i < literalPrefix.length; i++) {
650
- if (!segmentMatches(literalPrefix[i], relSegments[i])) return null;
651
- }
652
- const prefixDir = path.join(repoRoot, ...literalPrefix);
653
- const targetDir = path.join(repoRoot, ...relSegments);
654
- const packageRoot = nearestPackageRootBetween(repoRoot, targetDir, prefixDir);
655
- if (packageRoot) return packageRoot;
656
- return path.join(repoRoot, ...relSegments.slice(0, literalPrefix.length + 1));
657
- }
658
-
659
- function normalizeWorkspacePattern(pattern) {
660
- return String(pattern || '')
661
- .trim()
662
- .replace(/^['"]|['"]$/g, '')
663
- .replace(/^\.\//, '')
664
- .replace(/\/+$/, '');
665
- }
666
-
667
- function segmentMatches(patternSegment, relSegment) {
668
- if (patternSegment === '*') return true;
669
- if (!patternSegment.includes('*')) return patternSegment === relSegment;
670
- const re = new RegExp(`^${escapeRegExp(patternSegment).replace(/\\\*/g, '[^/]*')}$`);
671
- return re.test(relSegment);
672
- }
673
-
674
- function firstExisting(dir, names) {
675
- for (const name of names) {
676
- const abs = path.join(dir, name);
677
- if (fs.existsSync(abs)) return abs;
678
- }
679
- return null;
680
- }
681
-
682
- function safeRead(p) {
683
- try {
684
- return fs.readFileSync(p, 'utf-8');
685
- } catch {
686
- return null;
687
- }
688
- }
689
-
690
- function escapeRegExp(value) {
691
- return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
692
- }
693
-
694
- /**
695
- * Pull the register (`brand` or `product`) out of PRODUCT.md by looking
696
- * for a `## Register` section and reading the first non-empty line that
697
- * follows it. Returns null when the file is legacy / register-less.
698
- */
699
- export function extractRegister(product) {
700
- if (!product) return null;
701
- const lines = product.split('\n');
702
- for (let i = 0; i < lines.length; i++) {
703
- if (/^##\s+Register\b/i.test(lines[i].trim())) {
704
- for (let j = i + 1; j < lines.length; j++) {
705
- const next = lines[j].trim();
706
- if (!next) continue;
707
- const word = next.toLowerCase();
708
- if (word === 'brand' || word === 'product') return word;
709
- return null;
710
- }
711
- }
712
- }
713
- return null;
714
- }
715
-
716
- /**
717
- * Read the installed skill's own version from the sibling SKILL.md frontmatter
718
- * (this file lives at `<skill>/scripts/context.mjs`). Returns null when the
719
- * frontmatter is missing or unreadable.
720
- */
721
- function readLocalSkillVersion() {
722
- try {
723
- const here = path.dirname(fileURLToPath(import.meta.url));
724
- const skillMd = path.join(here, '..', 'SKILL.md');
725
- const content = fs.readFileSync(skillMd, 'utf-8');
726
- const match = content.match(/^version:\s*(.+)$/m);
727
- return match ? match[1].trim().replace(/^["']|["']$/g, '') : null;
728
- } catch {
729
- return null;
730
- }
731
- }
732
-
733
- function readUpdateCache() {
734
- try {
735
- return JSON.parse(fs.readFileSync(UPDATE_CACHE_PATH, 'utf-8'));
736
- } catch {
737
- return {};
738
- }
739
- }
740
-
741
- function writeUpdateCache(cache) {
742
- try {
743
- fs.mkdirSync(path.dirname(UPDATE_CACHE_PATH), { recursive: true });
744
- fs.writeFileSync(UPDATE_CACHE_PATH, JSON.stringify(cache));
745
- } catch {
746
- // Best-effort: a read-only home dir just means we re-poll next session.
747
- }
748
- }
749
-
750
- /** Compare dotted numeric versions. Returns >0 when a is newer than b. */
751
- function compareSemver(a, b) {
752
- const pa = String(a).split('.').map(n => parseInt(n, 10) || 0);
753
- const pb = String(b).split('.').map(n => parseInt(n, 10) || 0);
754
- for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
755
- const diff = (pa[i] || 0) - (pb[i] || 0);
756
- if (diff !== 0) return diff;
757
- }
758
- return 0;
759
- }
760
-
761
- async function fetchLatestSkillVersion() {
762
- try {
763
- const res = await fetch(`${UPDATE_HOST}/api/version`, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
764
- if (!res.ok) return null;
765
- const data = await res.json();
766
- return typeof data?.skills === 'string' ? data.skills : null;
767
- } catch {
768
- return null; // offline, sandboxed, timed out, or bad JSON: all non-fatal
769
- }
770
- }
771
-
772
- function buildUpdateDirective(localVersion, latestVersion) {
773
- return (
774
- `UPDATE_AVAILABLE: A newer Impeccable skill is available ` +
775
- `(installed v${localVersion}, latest v${latestVersion}). ` +
776
- `Before continuing, ask the user once: "A newer Impeccable (v${latestVersion}) is available. ` +
777
- `Update now? It runs \`npx impeccable update\`." ` +
778
- `If they agree, run \`npx impeccable update\` (the update applies to the next session, not this one). ` +
779
- `Either way, continue the current task without waiting, and do not raise this again.`
780
- );
781
- }
782
-
783
- /**
784
- * Best-effort update directive for the boot output. Returns a string to append
785
- * or null. Polls the version endpoint at most once per day (cached globally in
786
- * the user's home dir) and re-surfaces a given version at most once per week so
787
- * the agent never nags. Opt out entirely with IMPECCABLE_NO_UPDATE_CHECK=1.
788
- */
789
- // Read the unified config's top-level `updateCheck` (local overrides shared).
790
- // Inlined rather than importing hook-lib so the boot path stays lightweight.
791
- function updateCheckDisabledByConfig(cwd = process.cwd()) {
792
- let value;
793
- for (const name of ['config.json', 'config.local.json']) {
794
- try {
795
- const raw = JSON.parse(fs.readFileSync(path.join(cwd, '.impeccable', name), 'utf-8'));
796
- if (raw && typeof raw === 'object' && typeof raw.updateCheck === 'boolean') value = raw.updateCheck;
797
- } catch { /* missing or malformed: ignore */ }
798
- }
799
- return value === false;
800
- }
801
-
802
- async function computeUpdateDirective(now = Date.now()) {
803
- try {
804
- if (process.env.IMPECCABLE_NO_UPDATE_CHECK) return null;
805
- if (updateCheckDisabledByConfig()) return null;
806
- const localVersion = readLocalSkillVersion();
807
- if (!localVersion) return null;
808
-
809
- const cache = readUpdateCache();
810
-
811
- // Poll the network only when the throttle window has elapsed. Stamp
812
- // lastCheck even on failure so an offline machine doesn't poll every boot.
813
- if (!cache.lastCheck || now - cache.lastCheck > CHECK_INTERVAL_MS) {
814
- const latest = await fetchLatestSkillVersion();
815
- cache.lastCheck = now;
816
- if (latest) cache.latestVersion = latest;
817
- writeUpdateCache(cache);
818
- }
819
-
820
- const latest = cache.latestVersion;
821
- if (!latest || compareSemver(latest, localVersion) <= 0) return null;
822
-
823
- // Anti-nag: surface a given version at most once per RENOTIFY window.
824
- if (cache.notifiedVersion === latest && cache.notifiedAt && now - cache.notifiedAt < RENOTIFY_INTERVAL_MS) {
825
- return null;
826
- }
827
- cache.notifiedVersion = latest;
828
- cache.notifiedAt = now;
829
- writeUpdateCache(cache);
830
-
831
- return buildUpdateDirective(localVersion, latest);
832
- } catch {
833
- return null;
834
- }
835
- }
836
-
837
- async function cli() {
838
- let cliOptions;
839
- try {
840
- cliOptions = parseCliOptions(process.argv.slice(2));
841
- } catch (err) {
842
- if (err?.name === 'TargetArgError') {
843
- process.stderr.write(`${err.message}\n`);
844
- process.exit(1);
845
- }
846
- throw err;
847
- }
848
- const targetProvided = hasTargetOption(cliOptions);
849
- const targetExists = targetProvided ? pathExistsForTarget(process.cwd(), cliOptions.targetPath) : null;
850
- const selection = resolveTargetSelection(process.cwd(), cliOptions);
851
- if (selection) {
852
- process.stdout.write(buildTargetSelectionDirective(selection) + '\n');
853
- process.exit(0);
854
- }
855
- const ctx = loadContext(process.cwd(), cliOptions);
856
- const updateDirective = await computeUpdateDirective();
857
-
858
- if (!ctx.hasProduct) {
859
- // Direct stdout message instead of relying on empty output as a signal
860
- // — cheap models miss the empty case more often than the explicit one.
861
- const parts = [
862
- 'NO_PRODUCT_MD: This project has no PRODUCT.md yet. ' +
863
- 'Stop the current task, load reference/init.md, and follow its ' +
864
- 'instructions to write PRODUCT.md before resuming.',
865
- ];
866
- parts.push(buildResolvedContextDirective(ctx, cliOptions, { targetExists }));
867
- if (shouldWarnMissingTarget(ctx, targetProvided, targetExists)) {
868
- parts.push(buildMissingTargetDirective());
869
- }
870
- if (updateDirective) parts.push(updateDirective);
871
- process.stdout.write(parts.join('\n\n---\n\n') + '\n');
872
- process.exit(0);
873
- }
874
- const parts = [`# PRODUCT.md\n\n${ctx.product.trim()}`];
875
- if (ctx.hasDesign) {
876
- parts.push(`# DESIGN.md\n\n${ctx.design.trim()}`);
877
- }
878
- parts.push(buildResolvedContextDirective(ctx, cliOptions, { targetExists }));
879
- if (shouldWarnMissingTarget(ctx, targetProvided, targetExists)) {
880
- parts.push(buildMissingTargetDirective());
881
- }
882
- const register = extractRegister(ctx.product);
883
- const next = register
884
- ? `NEXT STEP: This project's register is \`${register}\`. You MUST now read \`reference/${register}.md\` before producing any design output.`
885
- : `NEXT STEP: You MUST now read the matching register reference (\`reference/brand.md\` or \`reference/product.md\`) before producing any design output. Pick based on PRODUCT.md above.`;
886
- parts.push(next);
887
- if (updateDirective) parts.push(updateDirective);
888
- process.stdout.write(parts.join('\n\n---\n\n') + '\n');
889
- }
890
-
891
- function parseCliOptions(args) {
892
- return parseTargetOptions(args, { strict: true });
893
- }
894
-
895
- function hasTargetOption(options) {
896
- return !!(options && typeof options.targetPath === 'string' && options.targetPath.trim());
897
- }
898
-
899
- function pathExistsForTarget(cwd, targetPath) {
900
- const abs = path.isAbsolute(targetPath) ? targetPath : path.resolve(cwd, targetPath);
901
- return fs.existsSync(abs);
902
- }
903
-
904
- function buildResolvedContextDirective(ctx, options, { targetExists = null } = {}) {
905
- const targetPath = hasTargetOption(options) ? options.targetPath : null;
906
- return `RESOLVED_CONTEXT:\n${JSON.stringify({
907
- targetPath,
908
- ...(targetPath ? { targetExists } : {}),
909
- projectRoot: ctx.projectRoot,
910
- repoRoot: ctx.repoRoot,
911
- productPath: ctx.productPath,
912
- designPath: ctx.designPath,
913
- }, null, 2)}`;
914
- }
915
-
916
- function shouldWarnMissingTarget(ctx, targetProvided, targetExists = null) {
917
- if (ctx.isMonorepo && targetProvided && targetExists === false) return true;
918
- return !!(
919
- ctx.isMonorepo
920
- && (!targetProvided || targetExists === false)
921
- && ctx.projectRoot
922
- && ctx.repoRoot
923
- && path.resolve(ctx.projectRoot) === path.resolve(ctx.repoRoot)
924
- );
925
- }
926
-
927
- function buildMissingTargetDirective() {
928
- const script = process.argv[1] || 'context.mjs';
929
- return (
930
- 'MONOREPO_TARGET_REQUIRED: This is a monorepo and context.mjs ran without --target. ' +
931
- 'If the user named a file, route, or child app, do not answer from this output. ' +
932
- `Rerun \`node ${script} --target <path>\` and answer from that run's RESOLVED_CONTEXT fields.`
933
- );
934
- }
935
-
936
- function buildTargetSelectionDirective(selection) {
937
- return (
938
- `TARGET_SELECTION_REQUIRED:\n${JSON.stringify(selection, null, 2)}\n\n` +
939
- 'Show each app with its productStatus/productPath and designStatus/designPath so the user can see child overrides, inherited root files, fallback files, or missing files before choosing. ' +
940
- 'Ask the user which app Impeccable should use, then rerun Impeccable helper commands from that child app cwd using this same scripts directory. ' +
941
- 'Use `--target <path>` only as a fallback when changing cwd is not possible, or when the user explicitly named a file/path.'
942
- );
943
- }
944
-
945
- // Run cli() only when this module is the entry point. Compare realpaths
946
- // rather than endsWith(): a loose suffix match also fires for unrelated
947
- // scripts like `load-context.mjs`, and realpath tolerates symlinked
948
- // invocation (the test harness symlinks the skill dir).
949
- function invokedAsScript() {
950
- const arg = process.argv[1];
951
- if (!arg) return false;
952
- try {
953
- return fs.realpathSync(arg) === fs.realpathSync(fileURLToPath(import.meta.url));
954
- } catch {
955
- return false;
956
- }
957
- }
958
-
959
- if (invokedAsScript()) {
960
- cli();
961
- }