claude-smart 0.2.45 → 0.2.47

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 (353) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/README.md +47 -10
  3. package/bin/claude-smart.js +535 -23
  4. package/package.json +22 -3
  5. package/plugin/.claude-plugin/plugin.json +4 -2
  6. package/plugin/.codex-plugin/plugin.json +1 -1
  7. package/plugin/README.md +27 -6
  8. package/plugin/commands/clear-all.md +1 -0
  9. package/plugin/commands/dashboard.md +1 -0
  10. package/plugin/commands/learn.md +1 -0
  11. package/plugin/commands/restart.md +1 -0
  12. package/plugin/commands/show.md +1 -0
  13. package/plugin/dashboard/app/configure/env/page.tsx +40 -14
  14. package/plugin/dashboard/app/configure/server/page.tsx +51 -1
  15. package/plugin/dashboard/app/layout.tsx +20 -0
  16. package/plugin/dashboard/app/preferences/[id]/page.tsx +8 -8
  17. package/plugin/dashboard/app/skills/project/[id]/page.tsx +7 -3
  18. package/plugin/dashboard/app/skills/shared/[id]/page.tsx +10 -3
  19. package/plugin/dashboard/lib/claude-settings-file.ts +20 -10
  20. package/plugin/dashboard/lib/reflexio-client.ts +16 -0
  21. package/plugin/dashboard/lib/status.ts +10 -3
  22. package/plugin/dashboard/lib/types.ts +18 -6
  23. package/plugin/hooks/codex-hooks.json +0 -1
  24. package/plugin/opencode/assistant-buffer.ts +108 -0
  25. package/plugin/opencode/dist/assistant-buffer.js +96 -0
  26. package/plugin/opencode/dist/internal.js +12 -0
  27. package/plugin/opencode/dist/payload.js +85 -0
  28. package/plugin/opencode/dist/server.mjs +232 -0
  29. package/plugin/opencode/internal.ts +18 -0
  30. package/plugin/opencode/package.json +3 -0
  31. package/plugin/opencode/payload.ts +90 -0
  32. package/plugin/opencode/server.mts +251 -0
  33. package/plugin/opencode/tsconfig.json +13 -0
  34. package/plugin/pyproject.toml +25 -4
  35. package/plugin/scripts/_lib.sh +5 -1
  36. package/plugin/scripts/backend-service.sh +22 -2
  37. package/plugin/scripts/ensure-plugin-root.sh +4 -4
  38. package/plugin/scripts/hook_entry.sh +1 -1
  39. package/plugin/scripts/opencode-claude-compat +4 -0
  40. package/plugin/scripts/opencode-claude-compat.cmd +3 -0
  41. package/plugin/scripts/opencode-claude-compat.js +225 -0
  42. package/plugin/scripts/smart-install.sh +17 -9
  43. package/plugin/src/README.md +1 -1
  44. package/plugin/src/claude_smart/cli.py +498 -12
  45. package/plugin/src/claude_smart/context_format.py +9 -9
  46. package/plugin/src/claude_smart/cs_cite.py +66 -19
  47. package/plugin/src/claude_smart/env_config.py +12 -4
  48. package/plugin/src/claude_smart/events/session_start.py +26 -7
  49. package/plugin/src/claude_smart/events/stop.py +1 -1
  50. package/plugin/src/claude_smart/ids.py +1 -1
  51. package/plugin/src/claude_smart/reflexio_adapter.py +5 -5
  52. package/plugin/src/claude_smart/runtime.py +7 -1
  53. package/plugin/uv.lock +5 -5
  54. package/plugin/vendor/reflexio/.env.example +54 -30
  55. package/plugin/vendor/reflexio/README.md +17 -11
  56. package/plugin/vendor/reflexio/pyproject.toml +13 -1
  57. package/plugin/vendor/reflexio/reflexio/README.md +4 -1
  58. package/plugin/vendor/reflexio/reflexio/cli/README.md +9 -7
  59. package/plugin/vendor/reflexio/reflexio/cli/__main__.py +10 -1
  60. package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +22 -5
  61. package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +34 -4
  62. package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +12 -7
  63. package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +13 -6
  64. package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +212 -52
  65. package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +15 -2
  66. package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +292 -22
  67. package/plugin/vendor/reflexio/reflexio/cli/log_format.py +29 -4
  68. package/plugin/vendor/reflexio/reflexio/cli/run_services.py +17 -8
  69. package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +13 -10
  70. package/plugin/vendor/reflexio/reflexio/cli/utils.py +44 -1
  71. package/plugin/vendor/reflexio/reflexio/client/client.py +154 -13
  72. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +135 -257
  73. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/bin/openclaw-smart.js +13 -0
  74. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/package.json +15 -0
  75. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/README.md +38 -0
  76. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +151 -110
  77. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +20 -10
  78. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +28 -6
  79. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/pyproject.toml +42 -0
  80. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/_lib.sh +371 -0
  81. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-log-runner.sh +33 -0
  82. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-service.sh +271 -0
  83. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/cli.sh +68 -0
  84. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/dashboard-open.sh +15 -0
  85. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/ensure-plugin-root.sh +84 -0
  86. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/hook_entry.sh +106 -0
  87. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/npm-cli.js +219 -0
  88. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/smart-install.sh +269 -0
  89. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/clear-all/SKILL.md +8 -0
  90. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/dashboard/SKILL.md +8 -0
  91. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/learn/SKILL.md +10 -0
  92. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +15 -44
  93. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/restart/SKILL.md +6 -0
  94. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/show/SKILL.md +8 -0
  95. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/cli.py +634 -0
  96. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_format.py +224 -0
  97. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_inject.py +79 -0
  98. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/__init__.py +0 -0
  99. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/after_tool_call.py +160 -0
  100. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/agent_end.py +187 -0
  101. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_prompt_build.py +69 -0
  102. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_tool_call.py +30 -0
  103. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_end.py +36 -0
  104. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_start.py +130 -0
  105. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/hook.py +131 -0
  106. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/ids.py +94 -0
  107. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/internal_call.py +75 -0
  108. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/oc_cite.py +196 -0
  109. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/optimizer_assistant.py +272 -0
  110. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/publish.py +96 -0
  111. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/query_compose.py +66 -0
  112. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/reflexio_adapter.py +336 -0
  113. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/runtime.py +47 -0
  114. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/stall_banner.py +61 -0
  115. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/state.py +323 -0
  116. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/__init__.py +0 -0
  117. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/__init__.py +0 -0
  118. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_e2e_session_loop.py +190 -0
  119. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_publish_to_local_reflexio_integration.py +112 -0
  120. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_recursion_guard_integration.py +86 -0
  121. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_search_inject_integration.py +144 -0
  122. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_cli.py +184 -0
  123. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_after_tool_call.py +142 -0
  124. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_agent_end.py +233 -0
  125. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_prompt_build.py +116 -0
  126. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_tool_call.py +35 -0
  127. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_end.py +47 -0
  128. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_start.py +109 -0
  129. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_hook_dispatch.py +117 -0
  130. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_ids.py +41 -0
  131. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_internal_call.py +50 -0
  132. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_oc_cite.py +88 -0
  133. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_publish.py +48 -0
  134. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_query_compose.py +48 -0
  135. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_reflexio_adapter.py +188 -0
  136. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_runtime.py +41 -0
  137. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_state.py +235 -0
  138. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/__mocks__/plugin-entry-stub.ts +6 -0
  139. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_npm_cli.test.ts +56 -0
  140. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_shim_dispatch.test.ts +171 -0
  141. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tsconfig.build.json +18 -0
  142. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{tsconfig.json → plugin/tsconfig.json} +2 -2
  143. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/uv.lock +3835 -0
  144. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/vitest.config.ts +18 -0
  145. package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +246 -10
  146. package/plugin/vendor/reflexio/reflexio/lib/_base.py +15 -0
  147. package/plugin/vendor/reflexio/reflexio/lib/_config.py +11 -4
  148. package/plugin/vendor/reflexio/reflexio/lib/_generation.py +17 -5
  149. package/plugin/vendor/reflexio/reflexio/lib/_lineage_parity_readers.py +187 -0
  150. package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +224 -21
  151. package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +1 -1
  152. package/plugin/vendor/reflexio/reflexio/lib/_search.py +52 -25
  153. package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +11 -1
  154. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +1 -0
  155. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +127 -38
  156. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +4 -0
  157. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/governance.py +117 -0
  158. package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +64 -41
  159. package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +19 -0
  160. package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +12 -5
  161. package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +97 -3
  162. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +5 -1
  163. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +5 -1
  164. package/plugin/vendor/reflexio/reflexio/models/config_schema.py +104 -7
  165. package/plugin/vendor/reflexio/reflexio/models/structured_output.py +148 -0
  166. package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +3 -3
  167. package/plugin/vendor/reflexio/reflexio/server/README.md +58 -33
  168. package/plugin/vendor/reflexio/reflexio/server/__init__.py +29 -5
  169. package/plugin/vendor/reflexio/reflexio/server/__main__.py +2 -2
  170. package/plugin/vendor/reflexio/reflexio/server/api.py +899 -103
  171. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +7 -0
  172. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +4 -2
  173. package/plugin/vendor/reflexio/reflexio/server/auth.py +90 -0
  174. package/plugin/vendor/reflexio/reflexio/server/billing_meter.py +173 -0
  175. package/plugin/vendor/reflexio/reflexio/server/billing_signals.py +64 -0
  176. package/plugin/vendor/reflexio/reflexio/server/cache/reflexio_cache.py +46 -16
  177. package/plugin/vendor/reflexio/reflexio/server/env_utils.py +65 -0
  178. package/plugin/vendor/reflexio/reflexio/server/extensions.py +213 -0
  179. package/plugin/vendor/reflexio/reflexio/server/llm/embedding_service.py +19 -4
  180. package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +264 -77
  181. package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +69 -7
  182. package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +4 -4
  183. package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_provider.py +1 -1
  184. package/plugin/vendor/reflexio/reflexio/server/llm/providers/embedding_service_provider.py +75 -16
  185. package/plugin/vendor/reflexio/reflexio/server/llm/providers/openclaw_provider.py +280 -0
  186. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/cross_encoder_reranker.py +12 -1
  187. package/plugin/vendor/reflexio/reflexio/server/llm/token_accounting.py +48 -0
  188. package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +107 -17
  189. package/plugin/vendor/reflexio/reflexio/server/operation_limiter.py +360 -4
  190. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.6.0.prompt.md +1 -1
  191. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.7.0.prompt.md +85 -0
  192. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.2.0.prompt.md +1 -1
  193. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.3.0.prompt.md +253 -0
  194. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.2.prompt.md +1 -1
  195. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.3.prompt.md +74 -0
  196. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.3.prompt.md +1 -1
  197. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.3.0.prompt.md +266 -0
  198. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.4.0.prompt.md +278 -0
  199. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +1 -1
  200. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.4.0.prompt.md +137 -0
  201. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +1 -1
  202. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.3.0.prompt.md +34 -0
  203. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +5 -12
  204. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +5 -12
  205. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.2.0.prompt.md +155 -0
  206. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/tagging/v1.0.0.prompt.md +23 -0
  207. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +89 -32
  208. package/plugin/vendor/reflexio/reflexio/server/services/README.md +28 -11
  209. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/README.md +22 -0
  210. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/__init__.py +1 -0
  211. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +4 -2
  212. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +1 -0
  213. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/components/__init__.py +7 -0
  214. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluator.py → components/evaluator.py} +3 -16
  215. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +28 -72
  216. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{group_evaluation_runner.py → runner.py} +12 -10
  217. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{delayed_group_evaluator.py → scheduler.py} +10 -2
  218. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluation_service.py → service.py} +36 -1
  219. package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +160 -0
  220. package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +5 -0
  221. package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +1 -1
  222. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/README.md +9 -0
  223. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/components/__init__.py +0 -0
  224. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{rule_attribution.py → components/rule_attribution.py} +10 -9
  225. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +15 -24
  226. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +238 -164
  227. package/plugin/vendor/reflexio/reflexio/server/services/extraction/README.md +31 -0
  228. package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +13 -3
  229. package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +3 -2
  230. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +32 -118
  231. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +47 -16
  232. package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +105 -23
  233. package/plugin/vendor/reflexio/reflexio/server/services/governance/config.py +52 -0
  234. package/plugin/vendor/reflexio/reflexio/server/services/governance/service.py +378 -0
  235. package/plugin/vendor/reflexio/reflexio/server/services/governance/subject_refs.py +34 -0
  236. package/plugin/vendor/reflexio/reflexio/server/services/lineage/__init__.py +0 -0
  237. package/plugin/vendor/reflexio/reflexio/server/services/lineage/gc_scheduler.py +219 -0
  238. package/plugin/vendor/reflexio/reflexio/server/services/lineage/resolve.py +98 -0
  239. package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +26 -0
  240. package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +18 -11
  241. package/plugin/vendor/reflexio/reflexio/server/services/playbook/aggregation_prompt_processing.py +100 -0
  242. package/plugin/vendor/reflexio/reflexio/server/services/playbook/components/__init__.py +5 -0
  243. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_aggregator.py → components/aggregator.py} +334 -178
  244. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_consolidator.py → components/consolidator.py} +168 -62
  245. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_extractor.py → components/extractor.py} +5 -1
  246. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_edit_apply.py +74 -0
  247. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +33 -3
  248. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_generation_service.py → service.py} +121 -19
  249. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/README.md +10 -0
  250. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +2 -1
  251. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +178 -30
  252. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/README.md +9 -0
  253. package/plugin/vendor/reflexio/reflexio/server/services/profile/components/__init__.py +17 -0
  254. package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_deduplicator.py → components/consolidator.py} +7 -6
  255. package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_extractor.py → components/extractor.py} +31 -22
  256. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +6 -13
  257. package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_generation_service.py → service.py} +32 -50
  258. package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +4 -8
  259. package/plugin/vendor/reflexio/reflexio/server/services/reflection/components/__init__.py +7 -0
  260. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +12 -1
  261. package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_service.py → service.py} +36 -16
  262. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/recency.py +211 -0
  263. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +99 -6
  264. package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +36 -1
  265. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/README.md +8 -0
  266. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +1 -2
  267. package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +31 -0
  268. package/plugin/vendor/reflexio/reflexio/server/services/storage/governance_validation.py +681 -0
  269. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +9 -9
  270. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +16 -2
  271. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +4 -1
  272. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +644 -197
  273. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +106 -119
  274. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_governance.py +1965 -0
  275. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_lineage.py +630 -0
  276. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +38 -6
  277. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +31 -1369
  278. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +756 -210
  279. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +148 -34
  280. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +23 -9
  281. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +5 -2
  282. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/__init__.py +13 -0
  283. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_agent.py +952 -0
  284. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_eval_results.py +189 -0
  285. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_optimization.py +247 -0
  286. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_source_linkage.py +145 -0
  287. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_user.py +838 -0
  288. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +150 -23
  289. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +2 -8
  290. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +5 -0
  291. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +40 -57
  292. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_governance.py +148 -0
  293. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_lineage.py +215 -0
  294. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +20 -0
  295. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +4 -677
  296. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +134 -1
  297. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +62 -0
  298. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_retrieval_log.py +51 -0
  299. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +17 -0
  300. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/__init__.py +13 -0
  301. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_agent.py +365 -0
  302. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_eval_results.py +124 -0
  303. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_optimization.py +85 -0
  304. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_source_linkage.py +47 -0
  305. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_user.py +333 -0
  306. package/plugin/vendor/reflexio/reflexio/server/services/tagging/README.md +8 -0
  307. package/plugin/vendor/reflexio/reflexio/server/services/tagging/__init__.py +1 -0
  308. package/plugin/vendor/reflexio/reflexio/server/services/tagging/service.py +200 -0
  309. package/plugin/vendor/reflexio/reflexio/server/services/tagging/tagging_scheduler.py +149 -0
  310. package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +372 -34
  311. package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +2 -1
  312. package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +120 -1
  313. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +4 -0
  314. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/search_settings.json +5 -0
  315. package/plugin/vendor/reflexio/reflexio/server/tracing.py +30 -0
  316. package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +18 -0
  317. package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +61 -26
  318. package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +41 -4
  319. package/scripts/setup-claude-smart.sh +8 -3
  320. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +0 -517
  321. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +0 -473
  322. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +0 -2156
  323. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +0 -18
  324. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +0 -241
  325. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +0 -140
  326. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +0 -113
  327. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +0 -52
  328. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +0 -103
  329. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +0 -156
  330. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +0 -134
  331. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +0 -24
  332. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +0 -278
  333. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +0 -164
  334. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +0 -36
  335. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +0 -35
  336. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +0 -27
  337. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +0 -31
  338. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +0 -42
  339. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +0 -49
  340. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +0 -91
  341. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +0 -50
  342. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +0 -13
  343. package/plugin/vendor/reflexio/reflexio/server/_auth.py +0 -25
  344. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +0 -192
  345. package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +0 -303
  346. package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +0 -138
  347. package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +0 -1125
  348. /package/plugin/vendor/reflexio/reflexio/integrations/{__init__.py → openclaw/plugin/src/openclaw_smart/__init__.py} +0 -0
  349. /package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{types → plugin/types}/openclaw.d.ts +0 -0
  350. /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{distribution.py → components/distribution.py} +0 -0
  351. /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{hero_state.py → components/hero_state.py} +0 -0
  352. /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{shadow_aggregation.py → components/shadow_aggregation.py} +0 -0
  353. /package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_extractor.py → components/extractor.py} +0 -0
@@ -85,36 +85,83 @@ WHEN_TO_CITE_COMPACT = (
85
85
 
86
86
  _COMPACT_INTRO = f"_{WHEN_TO_CITE}"
87
87
 
88
+ # Public repo the citation marker attributes its learnings to. The cue rides
89
+ # along on every emitted marker so users see that the applied learning was
90
+ # generated by Reflexio (and can star the repo).
91
+ REFLEXIO_REPO_URL = "https://github.com/ReflexioAI/reflexio"
92
+ MARKER_PREFIX = "✨ claude-smart rule applied:"
93
+ _ATTRIBUTION_LABEL = "⚡Reflexio"
94
+
95
+
96
+ def _osc8_link(url: str, text: str) -> str:
97
+ """Wrap ``text`` in an OSC 8 terminal hyperlink pointing at ``url``."""
98
+ return f"\x1b]8;;{url}\x1b\\{text}\x1b]8;;\x1b\\"
99
+
100
+
101
+ def marker_attribution(link_style: str = "markdown") -> str:
102
+ """Return the trailing ``· ⚡Reflexio`` attribution, linked to the repo.
103
+
104
+ Args:
105
+ link_style (str): ``"markdown"`` for a markdown link, or ``"osc8"`` for
106
+ a terminal-native hyperlink. Unknown values fall back to markdown.
107
+
108
+ Returns:
109
+ str: The attribution segment, beginning with a leading separator.
110
+ """
111
+ if link_style == "osc8":
112
+ return f" · {_osc8_link(REFLEXIO_REPO_URL, _ATTRIBUTION_LABEL)}"
113
+ return f" · [{_ATTRIBUTION_LABEL}]({REFLEXIO_REPO_URL})"
114
+
115
+
116
+ def build_marker(body: str, link_style: str = "markdown") -> str:
117
+ """Build the full citation marker line, including the Reflexio attribution.
118
+
119
+ Single source of truth for the marker line so the prefix and attribution
120
+ cannot drift across the markdown / OSC 8 / compact render paths.
121
+
122
+ Args:
123
+ body (str): The linked memory title(s) — already formatted as markdown
124
+ or OSC 8 links, joined with `` | `` for multiple items.
125
+ link_style (str): ``"markdown"`` or ``"osc8"``; selects the attribution
126
+ link form.
127
+
128
+ Returns:
129
+ str: ``✨ claude-smart rule applied: <body> · ⚡Reflexio``.
130
+ """
131
+ return f"{MARKER_PREFIX} {body}{marker_attribution(link_style)}"
132
+
133
+
134
+ MARKDOWN_EXAMPLE_ONE = build_marker(
135
+ "[verify process state](http://localhost:3001/rules/s1-123)", "markdown"
136
+ )
137
+ _MARKDOWN_EXAMPLE_MULTI = build_marker(
138
+ "[git safety](http://localhost:3001/rules/s1-123) | "
139
+ "[brief answer preference](http://localhost:3001/rules/p1-pref)",
140
+ "markdown",
141
+ )
88
142
  _MARKDOWN_MARKER_PARAGRAPH = (
89
143
  "How to format: use human-readable linked titles, not raw ids. "
90
144
  "Format for one item: "
91
- "`✨ claude-smart rule applied: "
92
- "[verify process state](http://localhost:3001/rules/s1-123)`. "
145
+ f"`{MARKDOWN_EXAMPLE_ONE}`. "
93
146
  "For multiple items: "
94
- "`✨ claude-smart rule applied: "
95
- "[git safety](http://localhost:3001/rules/s1-123) | "
96
- "[brief answer preference](http://localhost:3001/rules/p1-pref)`. "
147
+ f"`{_MARKDOWN_EXAMPLE_MULTI}`. "
148
+ "Always end the marker with the ` · ⚡Reflexio` attribution shown — a link "
149
+ "to the reflexio repo — exactly as given. "
97
150
  "Separate multiple linked memories with the visible ` | ` separator. "
98
151
  "Use the dashboard URL shown beside each cited item; do not invent URLs. "
99
152
  "Do not include `[cs:…]` ids in the marker line. Never use the old "
100
153
  "`✨ 1 claude-smart learning applied [cs:...]` marker format._"
101
154
  )
102
155
 
103
- _OSC8_EXAMPLE_ONE = (
104
- "✨ claude-smart rule applied: "
105
- "\x1b]8;;http://localhost:3001/rules/s1-123\x1b\\"
106
- "verify process state"
107
- "\x1b]8;;\x1b\\"
156
+ _OSC8_EXAMPLE_ONE = build_marker(
157
+ _osc8_link("http://localhost:3001/rules/s1-123", "verify process state"),
158
+ "osc8",
108
159
  )
109
- _OSC8_EXAMPLE_MULTI = (
110
- "✨ claude-smart rule applied: "
111
- "\x1b]8;;http://localhost:3001/rules/s1-123\x1b\\"
112
- "git safety"
113
- "\x1b]8;;\x1b\\"
114
- " | "
115
- "\x1b]8;;http://localhost:3001/rules/p1-pref\x1b\\"
116
- "brief answer preference"
117
- "\x1b]8;;\x1b\\"
160
+ _OSC8_EXAMPLE_MULTI = build_marker(
161
+ _osc8_link("http://localhost:3001/rules/s1-123", "git safety")
162
+ + " | "
163
+ + _osc8_link("http://localhost:3001/rules/p1-pref", "brief answer preference"),
164
+ "osc8",
118
165
  )
119
166
  _OSC8_MARKER_PARAGRAPH = (
120
167
  "How to format: use human-readable OSC 8 terminal hyperlinks, not raw ids "
@@ -1,11 +1,19 @@
1
- """Shared ``~/.reflexio/.env`` helpers for claude-smart."""
1
+ """Shared ``~/.claude-smart/.env`` helpers for claude-smart.
2
+
3
+ claude-smart keeps its env under ``~/.claude-smart`` (not ``~/.reflexio``) so an
4
+ OSS reflexio backend sharing this machine never leaks its ``.env`` into
5
+ claude-smart. The data directory stays shared at ``~/.reflexio/data``. This path
6
+ must stay in sync with the ``REFLEXIO_ENV_FILE`` export in
7
+ ``scripts/backend-service.sh`` and the source path in
8
+ ``scripts/_lib.sh`` (``claude_smart_source_reflexio_env``).
9
+ """
2
10
 
3
11
  from __future__ import annotations
4
12
 
5
13
  import os
6
14
  from pathlib import Path
7
15
 
8
- REFLEXIO_ENV_PATH = Path.home() / ".reflexio" / ".env"
16
+ REFLEXIO_ENV_PATH = Path.home() / ".claude-smart" / ".env"
9
17
  MANAGED_REFLEXIO_URL = "https://www.reflexio.ai/"
10
18
  REFLEXIO_URL_ENV = "REFLEXIO_URL"
11
19
  REFLEXIO_API_KEY_ENV = "REFLEXIO_API_KEY"
@@ -60,7 +68,7 @@ def parse_env_line(line: str) -> tuple[str, str] | None:
60
68
 
61
69
 
62
70
  def load_reflexio_env(path: Path | None = None) -> None:
63
- """Load ``~/.reflexio/.env`` into ``os.environ`` without overriding values."""
71
+ """Load ``~/.claude-smart/.env`` into ``os.environ`` without overriding values."""
64
72
  path = path or REFLEXIO_ENV_PATH
65
73
  try:
66
74
  text = path.read_text()
@@ -111,7 +119,7 @@ def set_env_vars(path: Path, values: dict[str, str]) -> list[str]:
111
119
 
112
120
 
113
121
  def ensure_local_env_defaults(path: Path | None = None) -> list[str]:
114
- """Create or augment ``~/.reflexio/.env`` for claude-smart local mode.
122
+ """Create or augment ``~/.claude-smart/.env`` for claude-smart local mode.
115
123
 
116
124
  Existing active assignments win. This repairs first installs and deleted
117
125
  env files without clobbering explicit user overrides such as
@@ -5,8 +5,10 @@ from __future__ import annotations
5
5
  import json
6
6
  import os
7
7
  import sys
8
+ from contextlib import suppress
8
9
  from pathlib import Path
9
10
  from typing import Any
11
+ from urllib.parse import urlparse
10
12
 
11
13
  from claude_smart import hook
12
14
  from claude_smart.reflexio_adapter import Adapter
@@ -41,10 +43,12 @@ def _int_env(name: str, default: int) -> int:
41
43
 
42
44
  _CLAUDE_SMART_WINDOW_SIZE = _int_env("CLAUDE_SMART_WINDOW_SIZE", 5)
43
45
  _CLAUDE_SMART_STRIDE_SIZE = _int_env("CLAUDE_SMART_STRIDE_SIZE", 3)
44
- # Optimizer is on by default. Set this env var to "0" to skip pushing the
45
- # claude-smart optimizer defaults on SessionStart (kill switch).
46
- _DISABLE_OPTIMIZER_ENV = "CLAUDE_SMART_ENABLE_OPTIMIZER"
46
+ # Optimizer defaults are local-only by default because they store an absolute
47
+ # path to the claude-smart helper process. Set this env var to "1" to force
48
+ # enabling against a non-local Reflexio URL, or "0" to disable everywhere.
49
+ _OPTIMIZER_ENV = "CLAUDE_SMART_ENABLE_OPTIMIZER"
47
50
  _OPTIMIZER_TIMEOUT_SECONDS = 300
51
+ _LOCAL_REFLEXIO_HOSTS = {"", "localhost", "127.0.0.1", "::1"}
48
52
 
49
53
 
50
54
  def _adapter() -> Adapter:
@@ -109,7 +113,7 @@ def handle(payload: dict[str, Any]) -> None:
109
113
  window_size=_CLAUDE_SMART_WINDOW_SIZE,
110
114
  stride_size=_CLAUDE_SMART_STRIDE_SIZE,
111
115
  )
112
- if os.environ.get(_DISABLE_OPTIMIZER_ENV) != "0":
116
+ if _should_apply_optimizer_defaults(adapter):
113
117
  adapter.apply_optimizer_defaults(
114
118
  script_path=_optimizer_assistant_path(),
115
119
  timeout_seconds=_OPTIMIZER_TIMEOUT_SECONDS,
@@ -131,13 +135,28 @@ def handle(payload: dict[str, Any]) -> None:
131
135
  )
132
136
  sys.stdout.write("\n")
133
137
 
134
- try:
138
+ with suppress(Exception):
135
139
  adapter.mark_stall_notified()
136
- except Exception: # noqa: BLE001 — telemetry must not break session.
137
- pass
138
140
 
139
141
 
140
142
  def _optimizer_assistant_path() -> str:
141
143
  executable = Path(sys.executable)
142
144
  suffix = ".exe" if os.name == "nt" else ""
143
145
  return str(executable.with_name(f"claude-smart-optimizer-assistant{suffix}"))
146
+
147
+
148
+ def _should_apply_optimizer_defaults(adapter: Any) -> bool:
149
+ flag = os.environ.get(_OPTIMIZER_ENV, "").strip().lower()
150
+ if flag in {"0", "false", "no", "off"}:
151
+ return False
152
+ if flag in {"1", "true", "yes", "on"}:
153
+ return True
154
+ return _is_local_reflexio_url(getattr(adapter, "url", ""))
155
+
156
+
157
+ def _is_local_reflexio_url(url: str) -> bool:
158
+ if not url:
159
+ return True
160
+ parsed = urlparse(url)
161
+ host = parsed.hostname if parsed.scheme else url.split(":", 1)[0]
162
+ return (host or "").lower() in _LOCAL_REFLEXIO_HOSTS
@@ -377,7 +377,7 @@ def handle(payload: dict[str, Any]) -> tuple[publish.PublishStatus, int] | None:
377
377
  last_assistant_message = payload.get("last_assistant_message")
378
378
  assistant_text = (
379
379
  last_assistant_message
380
- if runtime.is_codex()
380
+ if (runtime.is_codex() or runtime.is_opencode())
381
381
  and isinstance(last_assistant_message, str)
382
382
  and last_assistant_message
383
383
  else _scan_transcript_for_assistant_text(entries)
@@ -77,7 +77,7 @@ def resolve_user_id(cwd: str | os.PathLike[str] | None = None) -> str:
77
77
  Honors the ``REFLEXIO_USER_ID`` env var as an explicit override (e.g. so a
78
78
  user can point multiple projects at a single Reflexio identity), and
79
79
  otherwise falls back to :func:`resolve_project_id`. The env var is
80
- loaded from ``~/.reflexio/.env`` before reading the process environment so
80
+ loaded from ``~/.claude-smart/.env`` before reading the process environment so
81
81
  CLI commands and hooks use the same identity resolution.
82
82
 
83
83
  Args:
@@ -6,16 +6,15 @@ Exists so hook handlers (a) don't import reflexio directly at module scope
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ import inspect
9
10
  import logging
10
11
  import os
11
- import inspect
12
12
  from collections.abc import Sequence
13
13
  from concurrent.futures import ThreadPoolExecutor
14
14
  from dataclasses import dataclass, field
15
15
  from typing import Any
16
16
 
17
- from claude_smart import env_config
18
- from claude_smart import runtime
17
+ from claude_smart import env_config, runtime
19
18
 
20
19
  _LOGGER = logging.getLogger(__name__)
21
20
 
@@ -174,8 +173,9 @@ class Adapter:
174
173
 
175
174
  Idempotent compare-then-write: reads ``Config``, only issues a
176
175
  ``set_config`` when the server-side values differ from the desired
177
- dict below. Called unconditionally from SessionStart; the caller's
178
- only escape hatch is ``CLAUDE_SMART_ENABLE_OPTIMIZER=0``.
176
+ dict below. SessionStart calls this only for local Reflexio URLs by
177
+ default; ``CLAUDE_SMART_ENABLE_OPTIMIZER=1`` forces hosted URLs, and
178
+ ``CLAUDE_SMART_ENABLE_OPTIMIZER=0`` disables it everywhere.
179
179
  """
180
180
  client = self._get_client()
181
181
  if client is None:
@@ -14,7 +14,8 @@ INTERNAL_ENV = "CLAUDE_SMART_INTERNAL"
14
14
 
15
15
  HOST_CLAUDE_CODE = "claude-code"
16
16
  HOST_CODEX = "codex"
17
- VALID_HOSTS = frozenset({HOST_CLAUDE_CODE, HOST_CODEX})
17
+ HOST_OPENCODE = "opencode"
18
+ VALID_HOSTS = frozenset({HOST_CLAUDE_CODE, HOST_CODEX, HOST_OPENCODE})
18
19
 
19
20
  _SHARED_AGENT_VERSION = "claude-code"
20
21
  _current_host: str | None = None
@@ -42,6 +43,11 @@ def is_codex() -> bool:
42
43
  return host() == HOST_CODEX
43
44
 
44
45
 
46
+ def is_opencode() -> bool:
47
+ """True when the current hook invocation came from OpenCode."""
48
+ return host() == HOST_OPENCODE
49
+
50
+
45
51
  def agent_version() -> str:
46
52
  """Reflexio agent version used for shared learning across hosts."""
47
53
  return _SHARED_AGENT_VERSION
package/plugin/uv.lock CHANGED
@@ -476,7 +476,7 @@ wheels = [
476
476
 
477
477
  [[package]]
478
478
  name = "claude-smart"
479
- version = "0.2.45"
479
+ version = "0.2.47"
480
480
  source = { editable = "." }
481
481
  dependencies = [
482
482
  { name = "chromadb" },
@@ -494,7 +494,7 @@ dev = [
494
494
  requires-dist = [
495
495
  { name = "chromadb", specifier = ">=0.5" },
496
496
  { name = "einops", specifier = ">=0.8.0" },
497
- { name = "reflexio-ai", specifier = ">=0.2.25" },
497
+ { name = "reflexio-ai", specifier = ">=0.2.27" },
498
498
  { name = "sqlite-vec", specifier = ">=0.1.6" },
499
499
  ]
500
500
 
@@ -2760,7 +2760,7 @@ wheels = [
2760
2760
 
2761
2761
  [[package]]
2762
2762
  name = "reflexio-ai"
2763
- version = "0.2.25"
2763
+ version = "0.2.27"
2764
2764
  source = { registry = "https://pypi.org/simple" }
2765
2765
  dependencies = [
2766
2766
  { name = "aiohttp" },
@@ -2800,9 +2800,9 @@ dependencies = [
2800
2800
  { name = "websocket-client" },
2801
2801
  { name = "xlsxwriter" },
2802
2802
  ]
2803
- sdist = { url = "https://files.pythonhosted.org/packages/0f/da/323d788e55db2041caf1ffbb52a3536b959ac12ee8e22d40e7d53da10e96/reflexio_ai-0.2.25.tar.gz", hash = "sha256:4435145c865e397a9e4fb86560fa9378ba9094e99646f9c2df65cb4de7dd4fac", size = 754836, upload-time = "2026-06-10T18:03:11.997Z" }
2803
+ sdist = { url = "https://files.pythonhosted.org/packages/85/22/64429eb84ae74aaa6d36f0a2e0d91a27b35ee33ef17c18411d54f08706ba/reflexio_ai-0.2.27.tar.gz", hash = "sha256:e433209ca848245e957943c6476f2bba32581de8804d535d25ca0596b0da0afd", size = 1112139, upload-time = "2026-06-30T06:26:21.88Z" }
2804
2804
  wheels = [
2805
- { url = "https://files.pythonhosted.org/packages/16/7c/ef6cfaf172eecc02d6834828c549c314d013b6b3019bf7186dc50eeb9c5c/reflexio_ai-0.2.25-py3-none-any.whl", hash = "sha256:927b20323cbfe6a32df2092ce617ed2abec78a57b8c70e61eff501862b455dca", size = 1024584, upload-time = "2026-06-10T18:03:13.525Z" },
2805
+ { url = "https://files.pythonhosted.org/packages/68/22/d65332c75b9072e8838d51f68354d8d17c7636aa1cf73a20cfc1147b4364/reflexio_ai-0.2.27-py3-none-any.whl", hash = "sha256:4598f4aaa61e3c755a04573ab9711a7b5673ebf268029b2cef21cdcd5d4abfcf", size = 1461400, upload-time = "2026-06-30T06:26:19.965Z" },
2806
2806
  ]
2807
2807
 
2808
2808
  [[package]]
@@ -1,17 +1,32 @@
1
- # .env
1
+ # =============================================================================
2
+ # Reflexio (open source) — example environment file
3
+ # =============================================================================
4
+ # Copy to `.env` and fill in the values you need. The open-source CLI runs with
5
+ # SQLite storage and no auth by default, so the only thing you must set is one
6
+ # LLM provider key.
7
+ #
8
+ # LEGEND:
9
+ # (optional) = safe to leave empty; code default shown
10
+ # options: = allowed values for a categorical variable
11
+ # =============================================================================
2
12
 
3
- # ====================
4
- # LLM API Keys
5
- # ====================
13
+ # =============================================================================
14
+ # 1. LLM PROVIDER KEYS
15
+ # =============================================================================
6
16
  # Set at least one API key. The system auto-detects available providers and
7
- # selects appropriate default models per role (generation, evaluation, should_run,
8
- # pre_retrieval, embedding). Provider priority when multiple keys are set:
9
- # Anthropic > Gemini > OpenRouter > DeepSeek > MiniMax > DashScope > xAI > Moonshot > ZAI > OpenAI
17
+ # selects appropriate default models per role (generation, evaluation,
18
+ # should_run, pre_retrieval, embedding).
19
+ #
20
+ # Provider priority when multiple keys are set:
21
+ # Anthropic > Gemini > OpenRouter > DeepSeek > MiniMax > DashScope > xAI >
22
+ # Moonshot > ZAI > OpenAI
10
23
  # For the embedding role, if the top-priority provider has no embedding support,
11
24
  # the next embedding-capable provider is used (currently OpenAI or Gemini).
25
+ #
12
26
  # Model resolution order (highest priority first):
13
27
  # 1. Org-level LLMConfig override
14
- # 2. Non-empty values in reflexio/server/site_var/site_var_sources/llm_model_setting.json
28
+ # 2. Non-empty values in
29
+ # reflexio/server/site_var/site_var_sources/llm_model_setting.json
15
30
  # 3. Auto-detected default for the primary available provider
16
31
  OPENAI_API_KEY=
17
32
  ANTHROPIC_API_KEY=
@@ -24,39 +39,48 @@ ZAI_API_KEY=
24
39
  MOONSHOT_API_KEY=
25
40
  XAI_API_KEY=
26
41
 
27
- # ====================
28
- # Observability (Optional)
29
- # ====================
30
- # Set to enable Braintrust LLM observability (https://www.braintrust.dev)
42
+ # =============================================================================
43
+ # 2. OBSERVABILITY (optional)
44
+ # =============================================================================
45
+ # Set to enable Braintrust LLM observability (https://www.braintrust.dev).
31
46
  # BRAINTRUST_API_KEY=
32
47
  # BRAINTRUST_PROJECT_NAME=reflexio
33
48
 
34
- # ====================
35
- # Local Storage Configuration
36
- # ====================
49
+ # =============================================================================
50
+ # 3. STORAGE
51
+ # =============================================================================
37
52
  # Local storage directory — houses disk-storage artifacts and the SQLite
38
- # database file (reflexio.db). Defaults to ~/.reflexio/data/.
53
+ # database file (reflexio.db). (optional; default ~/.reflexio/data/)
39
54
  LOCAL_STORAGE_PATH=
55
+ # Default org id for no-auth / local mode. Controls the request org, and hence
56
+ # the config file name (config_<org>.json) and the SQLite data scope. Override
57
+ # it to run a second local backend under a distinct org so the two don't collide
58
+ # on the same config file under ~/.reflexio/. (optional; default self-host-org)
59
+ REFLEXIO_DEFAULT_ORG_ID=self-host-org
40
60
 
41
- # ====================
42
- # Extraction
43
- # ====================
61
+ # =============================================================================
62
+ # 4. EXTRACTION
63
+ # =============================================================================
44
64
  # Per-interaction content token budget when formatting interactions into an
45
65
  # extraction/evaluation prompt. When an interaction's content exceeds this many
46
66
  # tokens, the first half and last half are kept (head + tail) and the middle is
47
- # elided. Set to <=0 to disable slicing (pass full content). Default 512.
67
+ # elided. (optional; default 512; set <= 0 to disable slicing and pass full
68
+ # content)
48
69
  REFLEXIO_MAX_INTERACTION_CONTENT_TOKENS=512
70
+ # Inactivity delay in seconds before a quiet session is evaluated by agent-success
71
+ # evaluation. (optional; default 600 = 10 minutes)
72
+ GROUP_EVALUATION_DELAY_SECONDS=600
49
73
 
50
- # ====================
51
- # Testing & Logging
52
- # ====================
53
- # Set to true to enable test environment mode
54
- IS_TEST_ENV=true
55
- # Set to enable debug logging to console
74
+ # =============================================================================
75
+ # 5. TESTING & LOGGING
76
+ # =============================================================================
77
+ # Verbose debug logging to console. options: true | false
56
78
  DEBUG_LOG_TO_CONSOLE=true
57
- # Mock LLM call response
79
+ # Mark the process as a test environment. options: true | false
80
+ IS_TEST_ENV=true
81
+ # Return canned LLM responses instead of calling providers. options: true | false
58
82
  MOCK_LLM_RESPONSE=false
59
- # Override the base directory for log files. The .reflexio/logs suffix is
60
- # always preserved, so e.g. REFLEXIO_LOG_DIR=/tmp/foo writes logs to
61
- # /tmp/foo/.reflexio/logs/. Defaults to $HOME (i.e. ~/.reflexio/logs/).
83
+ # Override the base directory for log files. The .reflexio/logs suffix is always
84
+ # preserved, so e.g. REFLEXIO_LOG_DIR=/tmp/foo writes logs to
85
+ # /tmp/foo/.reflexio/logs/. (optional; default $HOME -> ~/.reflexio/logs/)
62
86
  REFLEXIO_LOG_DIR=
@@ -7,12 +7,13 @@
7
7
 
8
8
  [![Python >= 3.12](https://img.shields.io/badge/python-%3E%3D3.12-blue)](https://www.python.org/)
9
9
  [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-green)](LICENSE)
10
- [![PyPI](https://img.shields.io/pypi/v/reflexio-client)](https://pypi.org/project/reflexio-client/)
10
+ [![PyPI](https://img.shields.io/pypi/v/reflexio-ai)](https://pypi.org/project/reflexio-ai/)
11
11
  [![Downloads](https://static.pepy.tech/badge/reflexio-ai/month)](https://pepy.tech/project/reflexio-ai)
12
12
  [![Search p50 57ms](https://img.shields.io/badge/search-57ms%20p50-brightgreen)](reflexio/benchmarks/retrieval_latency/results/report.md)
13
13
  [![GitHub stars](https://img.shields.io/github/stars/ReflexioAI/reflexio)](https://github.com/ReflexioAI/reflexio/stargazers)
14
+ [![Discord](https://img.shields.io/badge/Discord-Join%20community-5865F2?logo=discord&logoColor=white)](https://discord.gg/7fnCxahase)
14
15
 
15
- [Quick Start](#quick-start) · [Features](#features) · [Integrations](#integrations) · [SDK](#sdk-usage) · [CLI](reflexio/cli/README.md) · [Architecture](#architecture) · [Docs](https://www.reflexio.ai/docs) · [Contributing](#contributing)
16
+ [Quick Start](#quick-start) · [Features](#features) · [Integrations](#integrations) · [SDK](#sdk-usage) · [CLI](reflexio/cli/README.md) · [Architecture](#architecture) · [Docs](https://www.reflexio.ai/docs) · [Community](#community) · [Contributing](#contributing)
16
17
 
17
18
  </div>
18
19
 
@@ -85,6 +86,7 @@ Publish conversations from your agent, and Reflexio closes the self-improvement
85
86
  - [SDK Usage](#sdk-usage)
86
87
  - [Architecture](#architecture)
87
88
  - [Documentation](#documentation)
89
+ - [Community](#community)
88
90
  - [Contributing](#contributing)
89
91
  - [Star History](#star-history)
90
92
  - [License](#license)
@@ -116,7 +118,7 @@ Publish conversations from your agent, and Reflexio closes the self-improvement
116
118
  pip install reflexio-ai
117
119
 
118
120
  # start/stop services. data saved under ~/.reflexio
119
- reflexio services start # API (8081), Docs (8082), SQLite storage
121
+ reflexio services start # API (8061), Docs (8062), SQLite storage
120
122
  reflexio services stop # Stop all services
121
123
  ```
122
124
 
@@ -135,13 +137,13 @@ uv sync # Python (includes workspace packages
135
137
  npm --prefix docs install # API docs
136
138
 
137
139
  # start/stop services. data saved under ~/.reflexio
138
- uv run reflexio services start # API (8081), Docs (8082), SQLite storage
140
+ uv run reflexio services start # API (8061), Docs (8062), SQLite storage
139
141
  uv run reflexio services stop # Stop all services
140
142
  ```
141
143
 
142
144
  > Alternative: `python -m reflexio.cli services start` or `./run_services.sh`
143
145
 
144
- Once running, open **[http://localhost:8082](http://localhost:8082)** to interactively browse and try out the API.
146
+ Once running, open **[http://localhost:8062](http://localhost:8062)** to interactively browse and try out the API.
145
147
  <p align="center">
146
148
  <img src="docs/images/doc_website.png" width="800px" alt="Reflexio Doc Website">
147
149
  </p>
@@ -172,7 +174,7 @@ One conversation, two artifacts: a user profile (`production region is us-west-2
172
174
  import reflexio
173
175
 
174
176
  client = reflexio.ReflexioClient(
175
- url_endpoint="http://localhost:8081/"
177
+ url_endpoint="http://localhost:8061/"
176
178
  )
177
179
 
178
180
  # Publish a multi-turn conversation where the user corrects the agent —
@@ -222,7 +224,7 @@ Reflexio will automatically generate profiles and extract playbooks in the backg
222
224
  - Session-level evaluation triggered automatically (10 min after last request)
223
225
  - Shadow comparison mode: A/B test regular vs shadow agent responses
224
226
  - Tool usage analysis for blocking issue detection
225
- - **Causal measurement of Reflexio's impact** — session-level A/B grouping on the Evaluation page driven by `Request.metadata.reflexio_retrieval_enabled` (with per-turn shadow comparison in development)
227
+ - **Causal measurement of Reflexio's impact** — source-set comparison on the Evaluation page groups evaluated sessions by the first request's `source`
226
228
 
227
229
  [Read more about evaluation →](https://www.reflexio.ai/docs/examples/agent-evaluation)
228
230
 
@@ -242,10 +244,10 @@ Reflexio will automatically generate profiles and extract playbooks in the backg
242
244
 
243
245
  For detailed API documentation, see the [full API reference](https://www.reflexio.ai/docs/api-reference).
244
246
 
245
- Install the client:
247
+ Install the package:
246
248
 
247
249
  ```shell
248
- pip install reflexio-client
250
+ pip install reflexio-ai
249
251
  ```
250
252
 
251
253
  ### Basic usage
@@ -254,7 +256,7 @@ pip install reflexio-client
254
256
  import reflexio
255
257
 
256
258
  client = reflexio.ReflexioClient(
257
- url_endpoint="http://localhost:8081/"
259
+ url_endpoint="http://localhost:8061/"
258
260
  )
259
261
 
260
262
  # Publish interactions
@@ -265,7 +267,7 @@ client.publish_interaction(
265
267
  {"role": "assistant", "content": "..."},
266
268
  ],
267
269
  agent_version="v1", # optional: track agent versions
268
- session_id="session-abc", # optional: group requests into sessions
270
+ session_id="session-abc", # required: stable conversation/session id
269
271
  )
270
272
 
271
273
  # Search profiles
@@ -325,6 +327,10 @@ For comprehensive guides, examples, and API reference, visit the **[Reflexio Doc
325
327
 
326
328
  For coding agents adding Reflexio to another agent, see **[Integrating an AI Agent with Reflexio](AI_AGENT_INTEGRATION.md)**.
327
329
 
330
+ ## Community
331
+
332
+ Join the Reflexio community on Discord: [discord.gg/7fnCxahase](https://discord.gg/7fnCxahase).
333
+
328
334
  ## Contributing
329
335
 
330
336
  We welcome contributions! Please see [developer.md](developer.md) for guidelines.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "reflexio-ai"
3
- version = "0.2.24"
3
+ version = "0.2.27"
4
4
  description = "A Python library for the Reflexio"
5
5
  authors = [{name = "Reflexio Team"}]
6
6
  readme = "README.md"
@@ -139,6 +139,9 @@ markers = [
139
139
  "e2e: Full workflow tests with real storage and services",
140
140
  "requires_credentials: Tests that need API keys (costs money)",
141
141
  ]
142
+ filterwarnings = [
143
+ "ignore:This process \\(pid=.*\\) is multi-threaded, use of fork\\(\\) may lead to deadlocks in the child\\.:DeprecationWarning:multiprocessing\\.popen_fork",
144
+ ]
142
145
 
143
146
  [tool.coverage.run]
144
147
  # Measure branch coverage — ensures both if/else paths are tested, not just lines
@@ -217,6 +220,12 @@ ignore = [
217
220
  "reflexio/server/api.py" = ["B008", "ARG001", "ARG002"]
218
221
  "reflexio/server/api_endpoints/**" = ["B008", "ARG001", "ARG002"]
219
222
  "reflexio/integrations/**" = ["ARG002"]
223
+ # The openclaw plugin is a nested package; its tests/scripts/cli are not reached
224
+ # by the top-level "tests/**" / "reflexio/cli/**" globs above (those only match
225
+ # at the tree root), so mirror the same standard test/cli ignores here.
226
+ "reflexio/integrations/openclaw/plugin/tests/**" = ["S101", "ARG001", "ARG002", "ARG005", "PTH", "ANN", "S105", "S106", "S107", "S108", "S310", "N802", "N806"]
227
+ "reflexio/integrations/openclaw/plugin/scripts/**" = ["S101", "G004", "ANN", "S603", "S607"]
228
+ "reflexio/integrations/openclaw/plugin/src/openclaw_smart/cli.py" = ["S603", "S607"]
220
229
  "reflexio/server/services/configurator/test_config_storage.py" = ["S101", "ANN", "S108"]
221
230
  "demo/**" = ["S101", "PTH", "G004", "ANN"]
222
231
  "reflexio/server/services/storage/sqlite_storage/**" = ["S608"]
@@ -261,6 +270,9 @@ version_toml = ["pyproject.toml:project.version"]
261
270
  tag_format = "reflexio-v{version}"
262
271
  commit_message = "chore(release): reflexio v{version}"
263
272
  build_command = "pip install build && python -m build"
273
+ # Pre-1.0 convention: a breaking change bumps the MINOR (0.x.y -> 0.(x+1).0),
274
+ # not MAJOR. So the B3 Task 7 breaking removal releases as 0.3.0, not 1.0.0.
275
+ major_on_zero = false
264
276
 
265
277
  [tool.semantic_release.branches.main]
266
278
  match = "^(main|master)$"
@@ -102,6 +102,7 @@ Description: FastAPI backend server that processes user interactions to generate
102
102
 
103
103
  ### Main Entry Points
104
104
  - **API**: `api.py` - FastAPI routes
105
+ - **Extension Registry**: `extensions.py` - optional capability/service registration for OSS and enterprise integrations
105
106
  - **Endpoint Helpers**: `api_endpoints/` - Request handlers calling `Reflexio` (reflexio_lib)
106
107
  - **Core Service**: `services/generation_service.py` - Main orchestrator
107
108
 
@@ -140,7 +141,9 @@ client (Python SDK)
140
141
  - `evaluation_overview/` - Evaluation-page aggregates and hero metrics
141
142
  - `playbook_optimizer/` - Scenario-based playbook optimization experiments
142
143
  - `braintrust/` - Braintrust eval export/sync support
143
- - `storage/` - Abstract layer (SQLite prod, LocalJSON test)
144
+ - `lineage/` - Resolve current records and schedule tombstone garbage collection for superseded profile/playbook rows
145
+ - `governance/` - Subject-reference contracts and retention/barrier helpers used by storage and lineage
146
+ - `storage/` - Abstract layer (SQLite prod, LocalJSON test) with governance-aware write validation
144
147
  - `pre_retrieval/` - Query rewriting and document expansion helpers
145
148
  - `configurator/` - YAML config loader
146
149
  - **`site_var/`**: Global settings singleton