claude-smart 0.2.42 → 0.2.44

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 (402) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/README.md +1 -1
  3. package/bin/claude-smart.js +2 -2
  4. package/package.json +9 -3
  5. package/plugin/.claude-plugin/plugin.json +9 -3
  6. package/plugin/.codex-plugin/plugin.json +1 -1
  7. package/plugin/README.md +23 -3
  8. package/plugin/pyproject.toml +3 -3
  9. package/plugin/scripts/_lib.sh +91 -0
  10. package/plugin/scripts/backend-service.sh +51 -4
  11. package/plugin/scripts/cli.sh +3 -1
  12. package/plugin/scripts/codex-hook.js +72 -4
  13. package/plugin/scripts/dashboard-build.sh +1 -0
  14. package/plugin/scripts/dashboard-service.sh +1 -0
  15. package/plugin/scripts/ensure-plugin-root.sh +1 -0
  16. package/plugin/scripts/hook_entry.sh +6 -3
  17. package/plugin/scripts/smart-install.sh +3 -2
  18. package/plugin/src/README.md +57 -0
  19. package/plugin/src/claude_smart/context_format.py +11 -12
  20. package/plugin/src/claude_smart/cs_cite.py +26 -12
  21. package/plugin/src/claude_smart/ids.py +13 -5
  22. package/plugin/uv.lock +126 -5
  23. package/plugin/vendor/reflexio/.env.example +62 -0
  24. package/plugin/vendor/reflexio/LICENSE +201 -0
  25. package/plugin/vendor/reflexio/README.md +338 -0
  26. package/plugin/vendor/reflexio/pyproject.toml +274 -0
  27. package/plugin/vendor/reflexio/reflexio/README.md +184 -0
  28. package/plugin/vendor/reflexio/reflexio/__init__.py +166 -0
  29. package/plugin/vendor/reflexio/reflexio/benchmarks/__init__.py +1 -0
  30. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/README.md +109 -0
  31. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/__init__.py +1 -0
  32. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/backends.py +175 -0
  33. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/bench.py +642 -0
  34. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/embed_cache.py +330 -0
  35. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/report.py +317 -0
  36. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/report.md +43 -0
  37. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/results.json +4478 -0
  38. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/scenarios.py +134 -0
  39. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/seed.py +255 -0
  40. package/plugin/vendor/reflexio/reflexio/cli/README.md +287 -0
  41. package/plugin/vendor/reflexio/reflexio/cli/__init__.py +0 -0
  42. package/plugin/vendor/reflexio/reflexio/cli/__main__.py +56 -0
  43. package/plugin/vendor/reflexio/reflexio/cli/_client.py +86 -0
  44. package/plugin/vendor/reflexio/reflexio/cli/app.py +127 -0
  45. package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +265 -0
  46. package/plugin/vendor/reflexio/reflexio/cli/codex_auth.py +503 -0
  47. package/plugin/vendor/reflexio/reflexio/cli/commands/__init__.py +0 -0
  48. package/plugin/vendor/reflexio/reflexio/cli/commands/admin_cmd.py +65 -0
  49. package/plugin/vendor/reflexio/reflexio/cli/commands/agent_playbooks.py +503 -0
  50. package/plugin/vendor/reflexio/reflexio/cli/commands/api.py +114 -0
  51. package/plugin/vendor/reflexio/reflexio/cli/commands/auth.py +109 -0
  52. package/plugin/vendor/reflexio/reflexio/cli/commands/config_cmd.py +511 -0
  53. package/plugin/vendor/reflexio/reflexio/cli/commands/doctor.py +127 -0
  54. package/plugin/vendor/reflexio/reflexio/cli/commands/embeddings.py +53 -0
  55. package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +478 -0
  56. package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +303 -0
  57. package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +289 -0
  58. package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +964 -0
  59. package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +285 -0
  60. package/plugin/vendor/reflexio/reflexio/cli/commands/status_cmd.py +143 -0
  61. package/plugin/vendor/reflexio/reflexio/cli/commands/user_playbooks.py +373 -0
  62. package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +284 -0
  63. package/plugin/vendor/reflexio/reflexio/cli/errors.py +217 -0
  64. package/plugin/vendor/reflexio/reflexio/cli/log_format.py +247 -0
  65. package/plugin/vendor/reflexio/reflexio/cli/output.py +867 -0
  66. package/plugin/vendor/reflexio/reflexio/cli/paths.py +41 -0
  67. package/plugin/vendor/reflexio/reflexio/cli/run_services.py +391 -0
  68. package/plugin/vendor/reflexio/reflexio/cli/state.py +204 -0
  69. package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +96 -0
  70. package/plugin/vendor/reflexio/reflexio/cli/utils.py +329 -0
  71. package/plugin/vendor/reflexio/reflexio/client/__init__.py +3 -0
  72. package/plugin/vendor/reflexio/reflexio/client/cache.py +150 -0
  73. package/plugin/vendor/reflexio/reflexio/client/client.py +2613 -0
  74. package/plugin/vendor/reflexio/reflexio/defaults.py +23 -0
  75. package/plugin/vendor/reflexio/reflexio/integrations/__init__.py +0 -0
  76. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/.clawhubignore +7 -0
  77. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +274 -0
  78. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +517 -0
  79. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +473 -0
  80. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +2156 -0
  81. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +18 -0
  82. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +241 -0
  83. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +140 -0
  84. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +130 -0
  85. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +113 -0
  86. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +52 -0
  87. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +103 -0
  88. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +156 -0
  89. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +134 -0
  90. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +41 -0
  91. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +17 -0
  92. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +24 -0
  93. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +48 -0
  94. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +278 -0
  95. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +164 -0
  96. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +36 -0
  97. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +35 -0
  98. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +27 -0
  99. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +31 -0
  100. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +42 -0
  101. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +49 -0
  102. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +91 -0
  103. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +50 -0
  104. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tsconfig.json +16 -0
  105. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/types/openclaw.d.ts +230 -0
  106. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +13 -0
  107. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/README.md +120 -0
  108. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/TESTING.md +168 -0
  109. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package-lock.json +1657 -0
  110. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package.json +16 -0
  111. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/HEARTBEAT.md +6 -0
  112. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/README.md +84 -0
  113. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/SKILL.md +194 -0
  114. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/_meta.json +6 -0
  115. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/agents/reflexio-extractor.md +45 -0
  116. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/handler.ts +214 -0
  117. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/setup.ts +55 -0
  118. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/index.ts +327 -0
  119. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/consolidate.ts +233 -0
  120. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/dedup.ts +80 -0
  121. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/io.ts +155 -0
  122. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/openclaw-cli.ts +67 -0
  123. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/search.ts +33 -0
  124. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-playbook.ts +76 -0
  125. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-profile.ts +79 -0
  126. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/openclaw.plugin.json +46 -0
  127. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/package.json +18 -0
  128. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/README.md +36 -0
  129. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/full_consolidation.md +56 -0
  130. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/playbook_extraction.md +217 -0
  131. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/profile_extraction.md +132 -0
  132. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-consolidate/SKILL.md +33 -0
  133. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-embedded/SKILL.md +194 -0
  134. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/HOOK.md +18 -0
  135. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/architecture.md +49 -0
  136. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/comparison.md +31 -0
  137. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/future-work.md +47 -0
  138. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/porting-notes.md +52 -0
  139. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/install.sh +52 -0
  140. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/uninstall.sh +36 -0
  141. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/consolidate.test.ts +135 -0
  142. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/dedup.test.ts +104 -0
  143. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/io.test.ts +175 -0
  144. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/search.test.ts +66 -0
  145. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/smoke-test.ts +140 -0
  146. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-playbook.test.ts +93 -0
  147. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-profile.test.ts +174 -0
  148. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tsconfig.json +16 -0
  149. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/types/openclaw.d.ts +230 -0
  150. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/vitest.config.ts +7 -0
  151. package/plugin/vendor/reflexio/reflexio/lib/__init__.py +23 -0
  152. package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +310 -0
  153. package/plugin/vendor/reflexio/reflexio/lib/_base.py +225 -0
  154. package/plugin/vendor/reflexio/reflexio/lib/_config.py +83 -0
  155. package/plugin/vendor/reflexio/reflexio/lib/_dashboard.py +266 -0
  156. package/plugin/vendor/reflexio/reflexio/lib/_generation.py +176 -0
  157. package/plugin/vendor/reflexio/reflexio/lib/_interactions.py +334 -0
  158. package/plugin/vendor/reflexio/reflexio/lib/_operations.py +153 -0
  159. package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +545 -0
  160. package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +52 -0
  161. package/plugin/vendor/reflexio/reflexio/lib/_search.py +167 -0
  162. package/plugin/vendor/reflexio/reflexio/lib/_storage_labels.py +103 -0
  163. package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +288 -0
  164. package/plugin/vendor/reflexio/reflexio/lib/reflexio_lib.py +27 -0
  165. package/plugin/vendor/reflexio/reflexio/models/__init__.py +0 -0
  166. package/plugin/vendor/reflexio/reflexio/models/api_schema/__init__.py +0 -0
  167. package/plugin/vendor/reflexio/reflexio/models/api_schema/braintrust_schema.py +141 -0
  168. package/plugin/vendor/reflexio/reflexio/models/api_schema/common.py +41 -0
  169. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +3 -0
  170. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +1112 -0
  171. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +63 -0
  172. package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +487 -0
  173. package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +28 -0
  174. package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +83 -0
  175. package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +768 -0
  176. package/plugin/vendor/reflexio/reflexio/models/api_schema/service_schemas.py +9 -0
  177. package/plugin/vendor/reflexio/reflexio/models/api_schema/stall_state_schema.py +32 -0
  178. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/__init__.py +3 -0
  179. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +177 -0
  180. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +129 -0
  181. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/enums.py +25 -0
  182. package/plugin/vendor/reflexio/reflexio/models/api_schema/validators.py +333 -0
  183. package/plugin/vendor/reflexio/reflexio/models/config_schema.py +908 -0
  184. package/plugin/vendor/reflexio/reflexio/models/py.typed +0 -0
  185. package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +90 -0
  186. package/plugin/vendor/reflexio/reflexio/server/README.md +622 -0
  187. package/plugin/vendor/reflexio/reflexio/server/__init__.py +210 -0
  188. package/plugin/vendor/reflexio/reflexio/server/__main__.py +132 -0
  189. package/plugin/vendor/reflexio/reflexio/server/_auth.py +25 -0
  190. package/plugin/vendor/reflexio/reflexio/server/api.py +2868 -0
  191. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/README.md +34 -0
  192. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/account_api.py +143 -0
  193. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/health_api.py +91 -0
  194. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/pending_tool_call_api.py +572 -0
  195. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +66 -0
  196. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/publisher_api.py +562 -0
  197. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +50 -0
  198. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/stall_state_api.py +100 -0
  199. package/plugin/vendor/reflexio/reflexio/server/cache/__init__.py +15 -0
  200. package/plugin/vendor/reflexio/reflexio/server/cache/reflexio_cache.py +208 -0
  201. package/plugin/vendor/reflexio/reflexio/server/correlation.py +46 -0
  202. package/plugin/vendor/reflexio/reflexio/server/llm/__init__.py +30 -0
  203. package/plugin/vendor/reflexio/reflexio/server/llm/embedding_service.py +359 -0
  204. package/plugin/vendor/reflexio/reflexio/server/llm/image_utils.py +55 -0
  205. package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +1871 -0
  206. package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +140 -0
  207. package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +479 -0
  208. package/plugin/vendor/reflexio/reflexio/server/llm/providers/__init__.py +1 -0
  209. package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_provider.py +1122 -0
  210. package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_stream_parser.py +197 -0
  211. package/plugin/vendor/reflexio/reflexio/server/llm/providers/embedding_service_provider.py +338 -0
  212. package/plugin/vendor/reflexio/reflexio/server/llm/providers/local_embedding_provider.py +213 -0
  213. package/plugin/vendor/reflexio/reflexio/server/llm/providers/nomic_embedding_provider.py +288 -0
  214. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/__init__.py +6 -0
  215. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/cross_encoder_reranker.py +187 -0
  216. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/llm_reranker.py +148 -0
  217. package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +716 -0
  218. package/plugin/vendor/reflexio/reflexio/server/operation_limiter.py +179 -0
  219. package/plugin/vendor/reflexio/reflexio/server/prompt/__init__.py +0 -0
  220. package/plugin/vendor/reflexio/reflexio/server/prompt/_dispatchers.py +54 -0
  221. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/README.md +121 -0
  222. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/agent_success_evaluation/v1.0.0.prompt.md +58 -0
  223. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/agent_success_evaluation_with_comparison/v1.0.0.prompt.md +76 -0
  224. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/answer_synthesis/v1.5.2.prompt.md +88 -0
  225. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/compress_session_for_query/v1.3.0.prompt.md +31 -0
  226. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/document_expansion/v1.0.0.prompt.md +20 -0
  227. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.0.0.prompt.md +53 -0
  228. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.1.0.prompt.md +57 -0
  229. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.2.0.prompt.md +68 -0
  230. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.3.0.prompt.md +70 -0
  231. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.4.0.prompt.md +77 -0
  232. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.5.0.prompt.md +82 -0
  233. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.6.0.prompt.md +83 -0
  234. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.1.0.prompt.md +193 -0
  235. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.2.0.prompt.md +206 -0
  236. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.0.0-deprecated.prompt.md +66 -0
  237. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.0.0.prompt.md +43 -0
  238. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.1.0.prompt.md +46 -0
  239. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.0.0-deprecated.prompt.md +64 -0
  240. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.0.0.prompt.md +39 -0
  241. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.1.0.prompt.md +39 -0
  242. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.2.0.prompt.md +47 -0
  243. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.0.prompt.md +58 -0
  244. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.1.prompt.md +69 -0
  245. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.2.prompt.md +71 -0
  246. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.0.2.prompt.md +254 -0
  247. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.1.0.prompt.md +274 -0
  248. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.0.prompt.md +283 -0
  249. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.2.prompt.md +234 -0
  250. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.3.prompt.md +244 -0
  251. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v1.0.0.prompt.md +73 -0
  252. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v2.0.0.prompt.md +86 -0
  253. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.0.0.prompt.md +97 -0
  254. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.1.0.prompt.md +119 -0
  255. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.2.0.prompt.md +123 -0
  256. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +137 -0
  257. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.0.0.prompt.md +14 -0
  258. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.1.0.prompt.md +24 -0
  259. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +29 -0
  260. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.0.0.prompt.md +11 -0
  261. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.1.0.prompt.md +21 -0
  262. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.2.0.prompt.md +25 -0
  263. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.0.0.prompt.md +37 -0
  264. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.1.0.prompt.md +40 -0
  265. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.2.0.prompt.md +36 -0
  266. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v1.0.0.prompt.md +45 -0
  267. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v2.0.0.prompt.md +81 -0
  268. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v3.0.0.prompt.md +80 -0
  269. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate_expert/v1.0.0.prompt.md +34 -0
  270. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_deduplication/v1.0.0.prompt.md +116 -0
  271. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate/v1.0.0.prompt.md +33 -0
  272. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate_override/v1.0.0.prompt.md +16 -0
  273. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +140 -0
  274. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +160 -0
  275. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_main/v1.0.0.prompt.md +14 -0
  276. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/query_reformulation/v1.0.0.prompt.md +19 -0
  277. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/rerank_relevance/v1.1.0.prompt.md +44 -0
  278. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_comparison/v1.0.0.prompt.md +43 -0
  279. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_content_evaluation/v1.0.0.prompt.md +33 -0
  280. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/feedback_extraction_main_v1.jsonl +10 -0
  281. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/profile_update_main_v1.jsonl +10 -0
  282. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +280 -0
  283. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_schema.py +11 -0
  284. package/plugin/vendor/reflexio/reflexio/server/services/README.md +58 -0
  285. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/_eval_health.py +131 -0
  286. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +60 -0
  287. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_service.py +228 -0
  288. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +87 -0
  289. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluator.py +372 -0
  290. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/delayed_group_evaluator.py +156 -0
  291. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/group_evaluation_runner.py +336 -0
  292. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +471 -0
  293. package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +1668 -0
  294. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/__init__.py +0 -0
  295. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_cron.py +196 -0
  296. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_encryption.py +101 -0
  297. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/client.py +167 -0
  298. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/service.py +281 -0
  299. package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +179 -0
  300. package/plugin/vendor/reflexio/reflexio/server/services/configurator/config_storage.py +62 -0
  301. package/plugin/vendor/reflexio/reflexio/server/services/configurator/configurator.py +87 -0
  302. package/plugin/vendor/reflexio/reflexio/server/services/configurator/local_file_config_storage.py +187 -0
  303. package/plugin/vendor/reflexio/reflexio/server/services/configurator/test_config_storage.py +162 -0
  304. package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +112 -0
  305. package/plugin/vendor/reflexio/reflexio/server/services/embedding_text.py +62 -0
  306. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/__init__.py +0 -0
  307. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/distribution.py +33 -0
  308. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +126 -0
  309. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +192 -0
  310. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/hero_state.py +75 -0
  311. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/rule_attribution.py +97 -0
  312. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +515 -0
  313. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/shadow_aggregation.py +90 -0
  314. package/plugin/vendor/reflexio/reflexio/server/services/extraction/__init__.py +0 -0
  315. package/plugin/vendor/reflexio/reflexio/server/services/extraction/agent_run_records.py +91 -0
  316. package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +303 -0
  317. package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +25 -0
  318. package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +358 -0
  319. package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +138 -0
  320. package/plugin/vendor/reflexio/reflexio/server/services/extraction/prior_answer_search.py +217 -0
  321. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +535 -0
  322. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_scheduler.py +171 -0
  323. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +779 -0
  324. package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +1125 -0
  325. package/plugin/vendor/reflexio/reflexio/server/services/extractor_config_utils.py +94 -0
  326. package/plugin/vendor/reflexio/reflexio/server/services/extractor_interaction_utils.py +251 -0
  327. package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +702 -0
  328. package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +835 -0
  329. package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +89 -0
  330. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_aggregator.py +1388 -0
  331. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_consolidator.py +1045 -0
  332. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_extractor.py +436 -0
  333. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_generation_service.py +808 -0
  334. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_constants.py +28 -0
  335. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +362 -0
  336. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/__init__.py +24 -0
  337. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/assistant_webhook.py +246 -0
  338. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/gepa_adapter.py +291 -0
  339. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/judge.py +97 -0
  340. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +96 -0
  341. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +645 -0
  342. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/rollout.py +35 -0
  343. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scenario_resolver.py +93 -0
  344. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scheduler.py +174 -0
  345. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/__init__.py +26 -0
  346. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_document_expander.py +179 -0
  347. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_query_reformulator.py +297 -0
  348. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_deduplicator.py +772 -0
  349. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_extractor.py +462 -0
  350. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service.py +737 -0
  351. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +290 -0
  352. package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +17 -0
  353. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_extractor.py +247 -0
  354. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service.py +803 -0
  355. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +146 -0
  356. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/__init__.py +0 -0
  357. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +80 -0
  358. package/plugin/vendor/reflexio/reflexio/server/services/search/__init__.py +0 -0
  359. package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +756 -0
  360. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/__init__.py +1 -0
  361. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/judge.py +184 -0
  362. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +81 -0
  363. package/plugin/vendor/reflexio/reflexio/server/services/storage/constants.py +2 -0
  364. package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +11 -0
  365. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +154 -0
  366. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention_mixin.py +155 -0
  367. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +59 -0
  368. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +1298 -0
  369. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +1945 -0
  370. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +600 -0
  371. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +346 -0
  372. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +1378 -0
  373. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +747 -0
  374. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +263 -0
  375. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +193 -0
  376. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_share_links.py +166 -0
  377. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +217 -0
  378. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +153 -0
  379. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +384 -0
  380. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +71 -0
  381. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +235 -0
  382. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +170 -0
  383. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +677 -0
  384. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +250 -0
  385. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +154 -0
  386. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +130 -0
  387. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_share_links.py +93 -0
  388. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_stall_state.py +76 -0
  389. package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +572 -0
  390. package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +77 -0
  391. package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +116 -0
  392. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_manager.py +263 -0
  393. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +13 -0
  394. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/llm_model_setting.json +7 -0
  395. package/plugin/vendor/reflexio/reflexio/server/tracing.py +158 -0
  396. package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +113 -0
  397. package/plugin/vendor/reflexio/reflexio/server/uvicorn_logging.py +76 -0
  398. package/plugin/vendor/reflexio/reflexio/test_support/__init__.py +1 -0
  399. package/plugin/vendor/reflexio/reflexio/test_support/llm_fixtures.py +62 -0
  400. package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +242 -0
  401. package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +129 -0
  402. package/plugin/vendor/reflexio/reflexio/test_support/skip_decorators.py +43 -0
@@ -0,0 +1,217 @@
1
+ ---
2
+ active: true
3
+ description: "Playbook extraction for Reflexio Embedded plugin (ported from playbook_extraction_context/v2.0.0)"
4
+ changelog: "Initial port (2026-04-16): 6-field output (trigger/instruction/pitfall/rationale/blocking_issue/content) collapsed to 3-field (When/What/Why); autoregressive ordering adapted to Why → What → When internally, emitted as When → What → Why; expert-mode branches (tool_can_use, blocking_issue kinds, agent_context) dropped; strengthened explicit requirement that a confirmation signal must follow any correction before writing a playbook."
5
+ variables:
6
+ - transcript
7
+ ---
8
+
9
+ You extract procedural rules (playbooks) from conversations where the user corrected the agent and the correction stuck. Your output becomes entries under `.reflexio/playbooks/`.
10
+
11
+ You are a self-improvement policy mining assistant for AI agents. Your job is to extract **generalizable Standard Operating Procedures (SOPs)** that the agent should adopt to avoid repeating mistakes.
12
+
13
+ You are NOT extracting:
14
+ - User facts (e.g., "User is building a React app") — those belong to the profile extractor.
15
+ - One-off preferences (e.g., "User likes blue buttons").
16
+ - Surface phrasing (e.g., "User said 'don't say that'").
17
+
18
+ You ARE extracting:
19
+ - **Behavioral Policies:** "When user intent is X, always do Y."
20
+ - **Correction Rules:** "When user encounters problem Z, avoid approach A."
21
+ - **Tool Usage Policies:**
22
+ - Tool selection: "When user intent is X, use tool Y instead of tool Z."
23
+ - Tool input optimization: "When using tool Y for intent X, set parameter P to value V."
24
+
25
+ ━━━━━━━━━━━━━━━━━━━━━━
26
+ ## When to write a playbook (strict)
27
+
28
+ A playbook is warranted only when **BOTH** of the following are observed in the transcript:
29
+
30
+ 1. **Correction.** The user tells the agent to change its approach. Typical phrases: "No, that's wrong", "Actually…", "Don't do X", "Not like that", "We don't use X here." This may also appear as agent self-correction (retrying a tool call with different inputs after poor results, or switching from one tool to another within the same task).
31
+ 2. **Confirmation.** After the agent adjusts, the user signals acceptance — either explicitly ("good", "perfect", "yes that's right", "thanks, that works") or implicitly (the user moves on to an unrelated topic for 1–2 turns without re-correcting).
32
+
33
+ **Do NOT write a playbook if you see a correction without a following confirmation.** The fix may itself be wrong; let the batch pass at session end reconsider. A correction with no subsequent signal of acceptance is insufficient evidence that the new behavior is correct.
34
+
35
+ In addition, for the candidate playbook to be valid, ALL of the following must be true:
36
+ 1. The agent performed an action, assumption, or default behavior.
37
+ 2. The user signaled this behavior was incorrect, inefficient, or misaligned.
38
+ 3. The correction implies a **better default workflow** for similar future requests.
39
+ 4. The rule can be phrased as: *"When [User Intent/Problem], the agent should [Policy]."*
40
+
41
+ ━━━━━━━━━━━━━━━━━━━━━━
42
+ ## Valid correction signals
43
+
44
+ Look for cross-turn causal patterns, not isolated messages. Valid signals include:
45
+ - User correcting or rejecting the agent's approach
46
+ - User redirecting the agent to a different mode or level of detail
47
+ - User expressing dissatisfaction with how the agent behaved
48
+ - User clarifying expectations that contradict the agent's behavior
49
+ - Agent retrying a tool call with different inputs after getting poor or irrelevant results (self-correction)
50
+ - Agent switching from one tool to another within the same task after inadequate results
51
+
52
+ You MUST identify the triggering agent behavior (assumption made, default chosen, constraint ignored, or question not asked).
53
+
54
+ ━━━━━━━━━━━━━━━━━━━━━━
55
+ ## The Skill Test (what makes a good trigger)
56
+
57
+ A valid **When** trigger must act as a **Skill Trigger** — it describes the **problem or situation**, NOT the user's explicitly stated preference.
58
+
59
+ - **BAD (Topic-based):** "User talks about Python code." (Too broad)
60
+ - **BAD (Interaction-based):** "User corrects the agent." (Too generic)
61
+ - **BAD (Echoing preference):** "User requests CLI tools or open-source solutions." (Just restates the user's explicit ask — the agent didn't need an SOP to follow direct instructions.)
62
+ - **GOOD (Intent-based):** "User requests help debugging a specific error trace."
63
+ - **GOOD (Problem-based):** "User's initial high-level request is ambiguous."
64
+ - **GOOD (Situation-based):** "User reports timeout or performance failures on large data transfers (>10TB)." (Captures the situation where the agent should default to CLI/chunking solutions.)
65
+
66
+ **Tautology Check.** If the trigger can be reduced to "user asks for X" and the action is "do X", the playbook is tautological. Re-derive: What was the *problem or situation* where the agent made the wrong default choice? Use THAT as the trigger.
67
+
68
+ ━━━━━━━━━━━━━━━━━━━━━━
69
+ ## Reasoning procedure (required)
70
+
71
+ Generate each playbook internally in the order **Why → What → When** (rationale conditions the action; both condition the trigger), but **emit** the sections in the document as **When → What → Why**:
72
+
73
+ 1. Identify user turns containing correction, rejection, or redirection.
74
+ 2. Trace backwards to the exact agent behavior that triggered it.
75
+ 3. Identify the violated implicit expectation — this is the seed of **Why**.
76
+ 4. Verify a confirmation signal follows within 1–2 turns. If not, abandon this candidate.
77
+ 5. Define the SOP action — this becomes **What**. Include DOs and DON'Ts only as they were actually observed in this conversation. Do not force DO/DON'T symmetry if only one side was learned; forcing symmetry leads to hallucinated pitfalls.
78
+ 6. Draft the SOP trigger — this becomes **When**. Apply the Skill Test and Tautology Check.
79
+ 7. Check that the trigger is the search anchor a future agent would retrieve on. Rewrite as a concise noun phrase describing the *situation*, not a sentence.
80
+ 8. Repeat steps 1–7 for **every distinct** behavioral issue you identified. Each independent policy becomes a separate entry in the output list.
81
+
82
+ ━━━━━━━━━━━━━━━━━━━━━━
83
+ ## Output format
84
+
85
+ Each playbook has three body sections: `## When`, `## What`, `## Why`.
86
+
87
+ - `## When` — One-sentence trigger phrase. This is the search anchor used for retrieval. Write as a noun phrase describing the *situation*, not a sentence. Apply the Skill Test.
88
+ - `## What` — 2–3 sentences of the actual procedural rule. Include DOs and DON'Ts as they were actually observed — do not force DO/DON'T symmetry if only one was learned.
89
+ - `## Why` — Rationale. Reference the specific correction+confirmation evidence from the transcript when helpful. Can be longer than the other sections — it is reference material, not recall content.
90
+
91
+ Return a JSON array of objects. If nothing to extract, return `[]`.
92
+
93
+ ```json
94
+ [
95
+ {
96
+ "topic_kebab": "commit-no-ai-attribution",
97
+ "when": "Composing a git commit message on this project.",
98
+ "what": "Write conventional, scope-prefixed messages. Do not add AI-attribution trailers like `Co-Authored-By`.",
99
+ "why": "On [date] the user corrected commits that included Co-Authored-By trailers. Project's git-conventions rule prohibits them. Correction stuck — the user's next request assumed the rule was internalized."
100
+ }
101
+ ]
102
+ ```
103
+
104
+ - `topic_kebab`: kebab-case slug, ≤ 48 chars, regex `^[a-z0-9][a-z0-9-]*$`. A compression of the situation the rule applies to (e.g., `commit-no-ai-attribution`, `debug-explain-root-cause-first`, `search-specific-query-first`).
105
+
106
+ ━━━━━━━━━━━━━━━━━━━━━━
107
+ ## Examples
108
+
109
+ **Example 1 (single entry):**
110
+ - **Agent:** Jumps directly into code generation.
111
+ - **User:** "Don't give me the code yet, explain the strategy first."
112
+ - **Agent:** Outlines strategy.
113
+ - **User:** "Good, now proceed." ← confirmation
114
+
115
+ ```json
116
+ [
117
+ {
118
+ "topic_kebab": "strategy-before-code",
119
+ "when": "User asks for architectural advice or complex implementation help.",
120
+ "what": "Outline the high-level strategy before generating code. Do not jump straight to code when the user has not explicitly asked for it.",
121
+ "why": "The agent assumed the user wanted code immediately, but the user needed to understand the approach first. Presenting strategy first prevents wasted effort on wrong approaches and gives the user the understanding they need to evaluate the plan."
122
+ }
123
+ ]
124
+ ```
125
+
126
+ **Example 2 (single entry):**
127
+ - **Agent:** Suggests `pip install …`.
128
+ - **User:** "Stop using pip, I'm using poetry."
129
+ - **Agent:** Reissues command as `poetry add …`.
130
+ - **User:** "Thanks." ← confirmation
131
+
132
+ ```json
133
+ [
134
+ {
135
+ "topic_kebab": "detect-package-manager",
136
+ "when": "User asks for package installation commands.",
137
+ "what": "Detect or ask for the project's package manager preference before suggesting install commands.",
138
+ "why": "The agent defaulted to pip without checking the project setup, which produced commands incompatible with the user's poetry-based workflow. Detecting the package manager first avoids this whole class of mistakes."
139
+ }
140
+ ]
141
+ ```
142
+
143
+ **Example 3 (tool input optimization via retry pattern):**
144
+ - **Agent:** `[used tool: search_docs({"query": "error"})]` → irrelevant results.
145
+ - **Agent:** `[used tool: search_docs({"query": "TypeError in async handler", "filter": "error_logs"})]` → relevant results.
146
+ - **User:** "Perfect, that's the one." ← confirmation
147
+
148
+ ```json
149
+ [
150
+ {
151
+ "topic_kebab": "search-specific-query-first",
152
+ "when": "Agent is searching docs for a specific error or issue the user reported.",
153
+ "what": "Use the exact error message and relevant filters as search parameters on the first attempt.",
154
+ "why": "On the first attempt the agent used a vague single-word query and wasted a round-trip. The second attempt, with the exact error text and an error_logs filter, succeeded immediately. Specific queries on the first call reduce latency and cost."
155
+ }
156
+ ]
157
+ ```
158
+
159
+ **Example 4 (avoiding tautological triggers):**
160
+ - **User:** Reports S3 sync timeout on 12 TB backup. Agent suggests UI settings. User says "I need CLI-based automation." Agent suggests a proprietary tool. User says "I want open-source only." Agent finally suggests rclone with chunking. User: "That works." ← confirmation
161
+
162
+ - **BAD (Tautological) — do NOT emit:**
163
+ ```json
164
+ [{"when": "User requests CLI or open-source automation tools.", "what": "Suggest CLI/open-source tools.", "why": "…"}]
165
+ ```
166
+ This just echoes the correction. The agent doesn't need an SOP to follow explicit instructions.
167
+
168
+ - **GOOD:**
169
+ ```json
170
+ [
171
+ {
172
+ "topic_kebab": "large-transfer-cli-chunking",
173
+ "when": "User reports timeout or performance failure transferring large datasets (>10 TB) to cloud storage.",
174
+ "what": "Default to CLI-based chunking / parallel transfer solutions (e.g., rclone) and provide config snippets.",
175
+ "why": "The agent defaulted to GUI settings and then to a proprietary tool for a large-data transfer problem, both of which the user rejected before rclone with chunking finally worked. CLI-based chunking is the standard solution for transfers at this scale — extract the *situation* (large transfer timeout), not the user's tool preference."
176
+ }
177
+ ]
178
+ ```
179
+
180
+ **Example 5 (multiple distinct entries from one conversation):**
181
+ - **Conversation:** Multi-turn debugging session. (a) User asks for help fixing a `TypeError` but the agent jumps straight to code rewrites instead of explaining the root cause; after the user says "explain first", agent does so, user says "good". (b) The agent apologizes ("I'm sorry for the confusion") every time it provides a factual correction, even when no mistake occurred; user says "stop apologizing, just tell me what's correct"; agent complies; session continues.
182
+
183
+ Both corrections have matching confirmations, so both become playbooks:
184
+
185
+ ```json
186
+ [
187
+ {
188
+ "topic_kebab": "debug-explain-root-cause-first",
189
+ "when": "User asks for help debugging a specific error trace.",
190
+ "what": "Explain the root cause of the error before proposing any code changes. Do not jump straight to rewriting code.",
191
+ "why": "The user needs to understand why the error occurred in order to evaluate the fix. Skipping the explanation leaves them without the context they need and leads to repeated back-and-forth."
192
+ },
193
+ {
194
+ "topic_kebab": "corrections-no-unnecessary-apology",
195
+ "when": "Agent provides a factual correction or updated diagnosis during a multi-turn session.",
196
+ "what": "Deliver the correction plainly. Do not preface routine corrections with an apology when no actual mistake occurred.",
197
+ "why": "Apologies on every refinement eroded user confidence. Reserve apologies for genuine errors so they retain meaning."
198
+ }
199
+ ]
200
+ ```
201
+
202
+ ━━━━━━━━━━━━━━━━━━━━━━
203
+ ## Rules for output fields
204
+
205
+ - The top-level response MUST be a JSON array (possibly empty).
206
+ - Each entry MUST have `topic_kebab`, `when`, `what`, `why`. All four are REQUIRED.
207
+ - `when` is the search anchor — keep it short, situation-focused, and Skill-Test-valid.
208
+ - `what` captures only DOs and DON'Ts that the conversation actually evidenced. Do NOT invent a symmetric DON'T for every DO (or vice versa).
209
+ - `why` must reference the specific agent behavior that triggered the correction AND confirm that a confirmation signal followed.
210
+ - Each entry must describe a **distinct, independent** policy — do not split one policy across entries, and do not merge two independent policies into one.
211
+ - If any candidate fails the confirmation gate, the Skill Test, or the Tautology Check, drop it.
212
+ - Vague, stylistic, or unanchored advice is invalid.
213
+ - **Never capture secrets or credentials in a playbook.** If a correction or execution trace contains API keys, tokens, passwords, or other credential material, redact that content from the `why` field before emitting the playbook. Do not emit a playbook whose `why` requires quoting credentials verbatim.
214
+
215
+ ## Transcript
216
+
217
+ {transcript}
@@ -0,0 +1,132 @@
1
+ ---
2
+ active: true
3
+ description: "Profile extraction for Reflexio Embedded plugin (ported from profile_update_instruction_start/v1.0.0)"
4
+ changelog: "Initial port (2026-04-16): output adapted from StructuredProfilesOutput JSON to list of {topic_kebab, content, ttl} suitable for the reflexio_write_profile tool; custom_features and metadata fields dropped; existing_profiles variable now injected from memory_search results rather than Reflexio server."
5
+ variables:
6
+ - existing_profiles_context
7
+ - transcript
8
+ ---
9
+
10
+ You extract durable user facts from conversations. Your output becomes entries under `.reflexio/profiles/`.
11
+
12
+ [Goal]
13
+ You are a user personalization learning assistant. Your job is to analyze user–agent interactions and extract **salient information about the user** that should shape how an AI agent communicates with and serves this user in future conversations.
14
+
15
+ A "profile" can be:
16
+ - **Factual information**: Direct facts about the user (name, birthday, occupation, location)
17
+ - **Work & expertise**: Professional role, technical skills, domain knowledge, tools used daily
18
+ - **Goals & projects**: Current objectives, ongoing projects, deadlines, milestones
19
+ - **Life circumstances**: Living situation, health considerations, family context, time constraints
20
+ - **Relationships & family**: Family members, pets, key people in their life
21
+ - **Domain / environment facts**: Stable facts about the user's working environment that the agent needs to know to serve them correctly — schema details (table names, column types, units of measurement), join paths, metric definitions the user enforces, tool quirks or limitations the user works around, file-format conventions, and similar reference knowledge. These are properties of the user's data or tooling, not of the agent's behavior.
22
+ - **Inferred personalization signals**: Patterns derived from behavior or multi-turn inference that would cause an agent to meaningfully change how it responds
23
+
24
+ Profiles may be extracted from:
25
+ - Explicit statements ("I prefer sushi")
26
+ - Implicit signals (implied preference/acceptance/rejection)
27
+ - Multi-turn inference (a stable pattern across multiple turns where the user never explicitly states a preference, but behavior suggests one)
28
+
29
+ **Scope boundary — what is NOT a profile:**
30
+ Profiles capture what is *true about the user or their world*. They do NOT capture
31
+ *what the agent should do differently next time*. If a learning is a behavioral
32
+ rule for the agent (e.g., "when the user asks about methodology, stop and propose
33
+ a corrected plan before re-running queries", "always explain root cause before
34
+ proposing code changes"), it belongs in the playbook extractor, not here. Extract
35
+ only the stable facts the agent needs to know; leave the action rules to playbooks.
36
+
37
+ [Your Task — Follow These Steps]
38
+
39
+ STEP 1: Analyze and reason through the user interactions below and compare them to the existing profiles shown in the `{existing_profiles_context}` section.
40
+
41
+ STEP 2: Decide what to extract:
42
+ - If the interaction reveals NEW information about the user that is NOT already stored in existing profiles → Extract it as a new profile
43
+ - If the information is already in existing profiles → Do NOT re-extract it
44
+ - If the interaction contains NO relevant profile information → Return an empty list
45
+
46
+ STEP 3: For each profile you extract, you must assign:
47
+ - `topic_kebab`: short kebab-case slug, ≤ 48 chars, regex `^[a-z0-9][a-z0-9-]*$`. A semantic compression of the fact (e.g., `diet-vegetarian`, `role-backend-engineer`, `schema-orders-gross-cents`).
48
+ - `content`: 1–3 sentences, one fact per entry, written as a standalone statement about the user.
49
+ - `ttl`: one of the values from the TTL table below.
50
+
51
+ [Time to Live — Choose One]
52
+ - `infinity` → Facts that rarely change (name, birthday, gender, phone number)
53
+ - `one_year` → Long-term preferences and slow-moving context (favorite color, hobby, long-lived schema facts)
54
+ - `one_quarter` → Seasonal preferences or quarter-scoped projects (winter activities, holiday traditions, Q-end deadlines)
55
+ - `one_month` → Regular preferences (food preferences, UI preferences)
56
+ - `one_week` → Short-term or situational preferences (current project, temporary need)
57
+ - `one_day` → Very short-lived context (today's deadline, scratch preference)
58
+
59
+ [Output Format]
60
+ Return a JSON array of objects. Each object represents one profile to write. If nothing to extract, return `[]`.
61
+
62
+ ```json
63
+ [
64
+ {
65
+ "topic_kebab": "diet-vegetarian",
66
+ "content": "User is vegetarian — no meat or fish.",
67
+ "ttl": "infinity"
68
+ }
69
+ ]
70
+ ```
71
+
72
+ [Examples With Explanations]
73
+
74
+ Example 1 — Extracting a new profile:
75
+ - Existing profiles: none related
76
+ - Interaction: "i like to eat pizza"
77
+ - Reasoning: User revealed a food preference. Not in existing profiles. Food preferences change monthly, so ttl is `one_month`.
78
+ ```json
79
+ [{"topic_kebab": "food-likes-pizza", "content": "User likes pizza.", "ttl": "one_month"}]
80
+ ```
81
+
82
+ Example 2 — Extracting a permanent profile:
83
+ - Interaction: "my name is John"
84
+ - Reasoning: User's name is a permanent fact. Use `infinity`.
85
+ ```json
86
+ [{"topic_kebab": "name-john", "content": "User's name is John.", "ttl": "infinity"}]
87
+ ```
88
+
89
+ Example 3 — Extracting work context and project:
90
+ - Existing profiles: none
91
+ - Interaction: "I'm a senior backend engineer at Acme Corp, currently migrating our payment service from monolith to microservices. The deadline is end of Q2."
92
+ - Reasoning: Role is long-lived; the migration project is quarter-scoped.
93
+ ```json
94
+ [
95
+ {"topic_kebab": "role-senior-backend-acme", "content": "User is a senior backend engineer at Acme Corp.", "ttl": "one_year"},
96
+ {"topic_kebab": "project-payments-microservices", "content": "User is migrating Acme's payment service from monolith to microservices, with an end-of-Q2 deadline.", "ttl": "one_quarter"}
97
+ ]
98
+ ```
99
+
100
+ Example 4 — No relevant information:
101
+ - Interaction: "what time is it?"
102
+ - Reasoning: Nothing to extract.
103
+ ```json
104
+ []
105
+ ```
106
+
107
+ Example 5 — Domain / environment fact surfaced through error correction:
108
+ - Existing profiles: none
109
+ - Interaction: Agent attempts `SUM(orders.total_amount)` and fails with "unknown column 'total_amount'". Runs `DESCRIBE orders` and discovers the column is actually `gross_cents`, stored as INTEGER in cents, not dollars. User confirms: "yes, gross_cents is in cents — you'll need to divide by 100 for dollar amounts."
110
+ - Reasoning: This is a stable fact about the user's data schema (column name, type, unit). Store as a long-lived domain fact.
111
+ ```json
112
+ [{"topic_kebab": "schema-orders-gross-cents", "content": "orders.gross_cents stores order revenue as INTEGER in cents (not dollars) — divide by 100 for dollar amounts.", "ttl": "one_year"}]
113
+ ```
114
+
115
+ Note: if the same session also surfaces a behavioral rule (e.g., "verify column types with DESCRIBE before aggregating"), that rule belongs in the playbook extractor, not here. This example captures only the fact.
116
+
117
+ [Important Reminders]
118
+ 1. Only extract profiles that represent salient, stable facts about the user or their world.
119
+ 2. If the information is already captured in existing profiles (see below), do NOT re-extract it.
120
+ 3. Always include `ttl` for new profiles; pick the shortest TTL that the fact will plausibly remain true for.
121
+ 4. Never output behavioral rules for the agent here — those belong to the playbook extractor.
122
+ 5. **Never extract secrets or credentials.** Do not create profile entries for API keys, access tokens, passwords, OAuth secrets, private keys, auth headers, `.env` values, connection strings, or any other credential-shaped content, even if the user pasted such content into the conversation. Treat those as noise; skip them.
123
+ 6. **Forget / delete / remove requests.** When the user explicitly asks to forget, delete, or stop remembering a stored fact (e.g. "forget that I like X", "remove my interest in Y", "don't remember that I work at Z"), emit a single profile entry whose `content` begins with "Requested removal of" and names the topic in positive form — for example, `"Requested removal of interest in self-improving agents from stored profiles"`. Do NOT rephrase the request as a new fact ("User is no longer interested in X", "User stopped caring about Y") — that looks like a fact update and will be merged into a zombie profile instead of erasing the original. The downstream deduplicator recognizes the "Requested removal of…" phrasing and uses it to delete the matching existing profile outright.
124
+ 7. Return `[]` when there is nothing new to extract.
125
+
126
+ ## Existing profiles for context (do NOT re-extract these)
127
+
128
+ {existing_profiles_context}
129
+
130
+ ## Transcript
131
+
132
+ {transcript}
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: reflexio-consolidate
3
+ description: "Run a full-sweep consolidation over all .reflexio/ files — TTL sweep + n-way cluster merge. Use when the user asks to 'clean up reflexio', 'consolidate memory', 'deduplicate playbooks', or suspects drift across sessions."
4
+ ---
5
+
6
+ # Reflexio Consolidate
7
+
8
+ User-invocable via `/skill reflexio-consolidate`. Same workflow that runs automatically via heartbeat (every 24h of active use), but on-demand.
9
+
10
+ ## What it does
11
+
12
+ 1. TTL sweep: delete expired profile files.
13
+ 2. For each of profiles and playbooks:
14
+ - Cluster similar files via `memory_search`.
15
+ - For clusters of 2+ members, call `llm-task` with `prompts/full_consolidation.md` to decide consolidate (one-fact-per-file) or keep-all.
16
+ - Apply decisions: write individual fact files, delete originals.
17
+
18
+ ## How to run
19
+
20
+ Call the `reflexio_run_consolidation` tool. It spawns the consolidator sub-agent and returns a `runId`.
21
+
22
+ After successful consolidation, call the `reflexio_consolidation_mark_done` tool to update the heartbeat timer.
23
+
24
+ ## When to use
25
+
26
+ - User asks to "consolidate", "clean up reflexio", "dedupe memory"
27
+ - User reports seeing duplicate or contradictory entries in retrieval
28
+ - Heartbeat check returns ALERT (automatic trigger)
29
+
30
+ ## When NOT to use
31
+
32
+ - Routine maintenance — heartbeat handles this automatically.
33
+ - Immediately after Flow A/B writes — shallow dedup at write time + Flow C at session end cover the fresh-extraction cases.
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: reflexio-embedded
3
+ description: "Captures user facts and procedural corrections into .reflexio/ so the agent learns across sessions. Use when: (1) user states a preference, fact, config, or constraint; (2) user corrects the agent and confirms the fix with an explicit 'good'/'perfect' or by moving on without re-correcting for 1-2 turns; (3) at start of a user turn, to retrieve relevant facts and playbooks from past sessions."
4
+ metadata:
5
+ ---
6
+
7
+ # Reflexio Embedded Skill
8
+
9
+ Captures user facts (profiles) and procedural corrections (playbooks) into `.reflexio/`, so the agent learns across sessions. All memory lives in Openclaw's native primitives — no external service required.
10
+
11
+ ## First-time setup per agent
12
+
13
+ If `.reflexio/.setup_complete_<agentId>` does NOT exist (where `<agentId>` is your current agent id), perform this one-time check. The setup step runs probing commands via `exec` and asks for approval before making changes.
14
+
15
+ **Steps:**
16
+
17
+ 1. Probe current config:
18
+ - `openclaw config get plugins.entries.active-memory.config.agents`
19
+ - `openclaw config get agents.defaults.memorySearch.extraPaths`
20
+ - `openclaw memory status --deep`
21
+
22
+ 2. If active-memory is not targeting this agent:
23
+ Ask user: *"To auto-inject relevant facts into each turn, I can enable active-memory for this agent. OK if I run `openclaw config set plugins.entries.active-memory.config.agents '[\"<agentId>\"]' --strict-json`?"*
24
+ On approval, run the command.
25
+
26
+ 3. If `.reflexio/` is not registered as an extraPath:
27
+ Ask user: *"I need to register .reflexio/ as a memory path. OK if I run `openclaw config set agents.defaults.memorySearch.extraPaths '[\".reflexio/\"]' --strict-json`?"*
28
+ On approval, run the command.
29
+
30
+ 4. If no embedding provider is configured (FTS-only mode):
31
+ Tell user: *"Vector search requires an embedding API key (OpenAI, Gemini, Voyage, or Mistral). The plugin works without one but retrieval quality drops. Would you like guidance on adding one?"*
32
+ If yes, guide them through `openclaw config set` or `openclaw configure`.
33
+
34
+ 5. On each decline, note the degraded mode but do not block:
35
+ - No active-memory → you must run `openclaw memory search` via exec at turn start (see "Retrieval" section below).
36
+ - No extraPath → WARN the user the plugin cannot function without this step.
37
+ - No embedding → continue with FTS-only.
38
+
39
+ 6. When all checks resolved (approved or accepted with warning): create the marker:
40
+ ```bash
41
+ mkdir -p .reflexio
42
+ touch .reflexio/.setup_complete_<agentId>
43
+ ```
44
+
45
+ **If exec is not available** (strict admin policy): fall back to telling the user the exact commands to run manually.
46
+
47
+ ## First-Use Initialisation
48
+
49
+ Before any write, ensure `.reflexio/` and its subdirectories exist. This is idempotent — safe to run every session:
50
+
51
+ ```bash
52
+ mkdir -p .reflexio/profiles .reflexio/playbooks
53
+ ```
54
+
55
+ Never overwrite existing files. Never write secrets, tokens, private keys, environment variables, or credentials into `.reflexio/` files. When capturing a fact involves a user-pasted snippet that contains credentials, redact first.
56
+
57
+ ## Quick Reference
58
+
59
+ | Situation | Action |
60
+ |-----------------------------------------------------------|--------------------------------------------|
61
+ | User states preference, fact, config, or constraint | `reflexio_write_profile` tool |
62
+ | User correction → you adjust → user confirms | `reflexio_write_playbook` tool |
63
+ | Start of user turn, need context | `reflexio_search` tool |
64
+ | Unsure whether to capture | Skip; batch pass at session-end has a second shot |
65
+
66
+ ## Detection Triggers
67
+
68
+ ### Profile signals (write immediately, same turn)
69
+
70
+ - **Preferences**: "I prefer X", "I like Y", "I don't like Z", "I always do Q"
71
+ - **Facts about self**: "I'm a [role]", "my timezone is X", "I've been doing Y for Z years"
72
+ - **Config**: "use X", "our team uses Y", "the repo is at Z"
73
+ - **Constraints**: "I'm vegetarian", "no dairy", "I can't X", "don't use Y"
74
+
75
+ For each such signal, call the `reflexio_write_profile` tool with a kebab-case topic slug and an appropriate TTL. See "TTL Selection" below.
76
+
77
+ ### Playbook signals (write AFTER confirmation)
78
+
79
+ Playbooks require a specific multi-turn pattern:
80
+
81
+ 1. **Correction**: *"No, that's wrong"*, *"Actually..."*, *"Don't do X"*, *"Not like that"*, *"We don't use X here"*.
82
+ 2. **You adjust**: you redo the work per the correction.
83
+ 3. **Confirmation** (required — without this, do NOT write a playbook):
84
+ - Explicit: *"good"*, *"perfect"*, *"yes that's right"*, *"correct"*.
85
+ - Implicit: the user moves to an unrelated topic without re-correcting for 1-2 more turns.
86
+
87
+ **Explicit don't-write rule**: if you see a correction without subsequent confirmation, do not write a playbook. The fix may be wrong; let the batch pass at session end re-evaluate.
88
+
89
+ ## Retrieval
90
+
91
+ ### When Active Memory is enabled
92
+
93
+ Your turn context may already contain Reflexio-prefixed entries injected by Active Memory. Incorporate them before responding. No tool call needed.
94
+
95
+ ### Fallback when Active Memory is absent
96
+
97
+ At the start of each user turn, call the `reflexio_search` tool with:
98
+ - query: "<user's message>"
99
+
100
+ The tool handles query preprocessing and memory search internally.
101
+ Incorporate any results into your response. Skip if the user's message is trivial.
102
+
103
+ **Important:** Do NOT use the `memory_search` tool (returns config, not results)
104
+ or `exec` with `openclaw memory search` — use the `reflexio_search` tool instead.
105
+
106
+ ## File Format
107
+
108
+ **Do NOT construct filenames or frontmatter by hand.** Use the registered tools (`reflexio_write_profile`, `reflexio_write_playbook`). They generate IDs, enforce the frontmatter schema, and write atomically.
109
+
110
+ ### Profile template (for mental model — the script emits this)
111
+
112
+ ```markdown
113
+ ---
114
+ type: profile
115
+ id: prof_<nanoid>
116
+ created: <ISO timestamp>
117
+ ttl: <enum>
118
+ expires: <ISO date or "never">
119
+ supersedes: [<old_id>] # optional, only after a merge
120
+ ---
121
+
122
+ <1-3 sentences, one fact per file>
123
+ ```
124
+
125
+ ### Playbook template
126
+
127
+ ```markdown
128
+ ---
129
+ type: playbook
130
+ id: pbk_<nanoid>
131
+ created: <ISO timestamp>
132
+ supersedes: [<old_id>] # optional
133
+ ---
134
+
135
+ ## When
136
+ <1-sentence trigger — this is the search anchor; make it a noun phrase>
137
+
138
+ ## What
139
+ <2-3 sentences of the procedural rule; DO / DON'T as actually observed>
140
+
141
+ ## Why
142
+ <rationale, can be longer — reference only, not recall content>
143
+ ```
144
+
145
+ ### How to invoke
146
+
147
+ **Profile:** Call the `reflexio_write_profile` tool with:
148
+ - slug: "diet-vegan"
149
+ - ttl: "infinity"
150
+ - body: "User is vegan. No meat, no fish, no dairy, no eggs."
151
+
152
+ **Playbook:** Call the `reflexio_write_playbook` tool with:
153
+ - slug: "commit-no-ai-attribution"
154
+ - body: "## When\nComposing a git commit message.\n\n## What\nNo AI-attribution trailers.\n\n## Why\nUser corrected this."
155
+
156
+ **Retrieve context:** Call the `reflexio_search` tool with:
157
+ - query: "user's question here"
158
+
159
+ All tools handle preprocessing, memory search, contradiction detection, and file operations internally. You only detect the signal, compose the content, and call the tool.
160
+
161
+ ## TTL Selection (profiles only)
162
+
163
+ - `infinity` — durable, non-perishable facts (diet, name, permanent preferences)
164
+ - `one_year` — stable but could plausibly change (address, role, team)
165
+ - `one_quarter` — current focus (active project, sprint theme)
166
+ - `one_month` — short-term context
167
+ - `one_week` / `one_day` — transient (today's agenda, this week's priorities)
168
+
169
+ Pick the most generous TTL that still reflects reality. When in doubt, prefer `infinity` — let dedup handle later contradictions via supersession.
170
+
171
+ ## Safety
172
+
173
+ - **Never write secrets.** No API keys, tokens, access tokens, private keys, environment variables, OAuth secrets, auth headers. If the user's message contains any of these, redact them before writing.
174
+ - **Redact pasted code.** User-pasted snippets often contain credentials. Strip them first.
175
+ - **PII.** Do not capture PII beyond what's operationally useful (name, timezone, role are fine; government IDs, addresses, phone numbers only if explicitly relevant).
176
+
177
+ ## Best Practices
178
+
179
+ 1. **Write immediately** on a clear signal. Don't queue to session-end — that's Flow C's job; you have a different role.
180
+ 2. **One fact per profile file.** Multi-fact files are harder to dedupe and easier to contradict.
181
+ 3. **Trigger phrase = search anchor.** Write `## When` as a noun phrase describing the situation, not a sentence. Retrieval hits on semantic similarity to this field.
182
+ 4. **Skip writing when uncertain.** Flow C has a second pass over the full transcript. It's better to let it handle ambiguous cases.
183
+ 5. **Prefer shorter TTL for transient facts.** Don't let "working on project X" accumulate as infinity-TTL cruft.
184
+
185
+ ## Opt-in Hook
186
+
187
+ This skill works standalone — your in-session Flow A (profile) and Flow B (playbook) writes populate `.reflexio/` without any hook.
188
+
189
+ The optional hook (`hook/` directory of this plugin) adds two capabilities:
190
+
191
+ 1. **TTL sweep at session start**: deletes expired profiles before Active Memory runs.
192
+ 2. **Session-end batch extraction (Flow C)**: on `session:compact:before`, `command:stop`, or `command:reset`, spawns a `reflexio-extractor` sub-agent that extracts profiles/playbooks from the full transcript and runs shallow pairwise dedup.
193
+
194
+ See this plugin's `README.md` for install instructions (runs via `./scripts/install.sh`). If the hook is not installed, Flows A+B still work.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: reflexio-embedded
3
+ description: "Reflexio Embedded hook: TTL sweep on bootstrap; spawn reflexio-extractor sub-agent at session boundaries."
4
+ metadata:
5
+ openclaw:
6
+ emoji: "🧠"
7
+ events:
8
+ - "before_agent_start"
9
+ - "before_compaction"
10
+ - "before_reset"
11
+ - "session_end"
12
+ ---
13
+
14
+ > **Note:** This file is no longer discovered by the Openclaw CLI. Hooks are
15
+ > now registered programmatically from `../index.ts` via
16
+ > `definePluginEntry({ register(api) { api.on(...) } })`. This doc is kept
17
+ > only for human reference; see `../index.ts` and `./handler.ts` for the
18
+ > actual behaviour.
@@ -0,0 +1,49 @@
1
+ # Architecture
2
+
3
+ Deep-dive for maintainers. For a design-level overview, see the spec at
4
+ `docs/superpowers/specs/2026-04-16-reflexio-openclaw-embedded-plugin-design.md`.
5
+
6
+ ## Three flows
7
+
8
+ | Flow | Trigger | Actor | Purpose |
9
+ |------|---------|-------|---------|
10
+ | A | User message signals a profile | Main agent (skill-guided) | Capture durable user facts mid-turn |
11
+ | B | Correction → adjust → confirmation | Main agent (skill-guided) | Capture procedural rules after confirmation |
12
+ | C | `session:compact:before`, `command:stop`, `command:reset` | `reflexio-extractor` sub-agent spawned via hook | Batch extract + shallow dedup over full transcript |
13
+ | Cron | Daily 3am | `reflexio-consolidator` sub-agent | Full n-way consolidation + TTL sweep |
14
+
15
+ ## File system invariants
16
+
17
+ - `.reflexio/profiles/*.md` and `.reflexio/playbooks/*.md` — the only user-owned data.
18
+ - All files are **immutable in place**. Dedup = delete old + create new (atomic via `.tmp` + rename).
19
+ - Every file has frontmatter with `type`, `id`, `created`. Profiles also have `ttl` and `expires`.
20
+ - `supersedes: [id1, id2]` — optional, records merge lineage.
21
+
22
+ ## Concurrency model
23
+
24
+ - Flow A + Flow B are create-only; no coordination.
25
+ - Flow C runs as a sub-agent spawned via `api.runtime.subagent.run()` — non-blocking, tracked by Openclaw's Background Tasks ledger.
26
+ - Parallel Flow C runs can occur; rare race resolves next cycle (later write wins, orphans swept by full consolidation).
27
+
28
+ ## Openclaw primitives leveraged
29
+
30
+ - **Memory engine** (`concepts/memory-builtin`): indexes `.md` files under `extraPaths`.
31
+ - **Active Memory** (`concepts/active-memory`): optional, injects retrieved context into turns.
32
+ - **Hooks** (`automation/hooks`): lifecycle events (bootstrap, compact, stop, reset).
33
+ - **Sub-agents** (`tools/subagents`): fire-and-forget work via `sessions_spawn` / `api.runtime.subagent.run()`.
34
+ - **LLM-task** (`tools/llm-task`): structured LLM calls with schema validation.
35
+ - **Cron** (`automation/cron-jobs`): daily consolidation.
36
+ - **Registered tools**: `reflexio_write_profile`, `reflexio_write_playbook`, and `reflexio_search` — the plugin's tool-based interface for writes and retrieval.
37
+
38
+ ## Prompt loading
39
+
40
+ Prompts live in `prompts/` and are loaded at runtime by sub-agents. Frontmatter follows Reflexio's prompt_bank convention (`active`, `description`, `changelog`, `variables`). When the sub-agent builds a `llm-task` call, it reads the relevant prompt file, substitutes variables from the event / memory_search results / candidate data, and sends the result to `llm-task` with an output schema.
41
+
42
+ ## Graceful degradation
43
+
44
+ | Missing prereq | Behavior |
45
+ |---|---|
46
+ | `active-memory` not enabled | SKILL.md instructs agent to run `memory_search` fallback at turn start |
47
+ | No embedding provider | Falls back to FTS/BM25 only; vector search unavailable but plugin functional |
48
+ | Registered tools unavailable | SKILL.md falls back to printed manual commands; install.sh exits with instructions |
49
+ | No `openclaw cron add` | install.sh prints warning; consolidation runs only on `/skill reflexio-consolidate` |