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
@@ -1,274 +1,152 @@
1
- # Reflexio OpenClaw Federated Plugin
1
+ # openclaw-smart
2
2
 
3
- Connect [OpenClaw](https://openclaw.ai) agents to [Reflexio](https://github.com/reflexio-ai/reflexio) for automatic cross-session memory with multi-user support. Conversations are captured automatically to a local SQLite buffer, published to the Reflexio server on session end, and relevant profiles and playbooks are injected before every response via a hook.
3
+ openclaw-smart is the openClaw plugin counterpart of
4
+ [claude-smart](https://github.com/reflexio-ai/claude-smart): a thin TS shim
5
+ plus a Python (`openclaw_smart`) package that wires openClaw's plugin hooks
6
+ into a local [Reflexio](https://github.com/reflexio-ai/reflexio) backend
7
+ running at `http://localhost:8071/`. The port matches claude-smart so both
8
+ plugins share one bundled reflexio (one SQLite store, one extractor), and
9
+ leaves reflexio's own 8061 default free for developer use. Conversations
10
+ are buffered to a JSONL session log, published for extraction (skills +
11
+ preferences) via your own LLM, and the top-matching items are injected
12
+ back into every subsequent turn as `prependContext`. The plugin degrades
13
+ silently when the backend is unreachable.
4
14
 
5
- ## Table of Contents
15
+ ## Quick install
6
16
 
7
- - [How It Works](#how-it-works)
8
- - [Multi-User Architecture](#multi-user-architecture)
9
- - [Prerequisites](#prerequisites)
10
- - [Installation](#installation)
11
- - [First-Use Setup](#first-use-setup)
12
- - [Configuration](#configuration)
13
- - [Using `reflexio_publish` Tool](#using-reflexio_publish-tool)
14
- - [Cross-Session Retrieval](#cross-session-retrieval)
15
- - [File Structure](#file-structure)
16
- - [Comparison with openclaw-embedded](#comparison-with-openclaw-embedded)
17
- - [Uninstall](#uninstall)
18
- - [Manual Testing](#manual-testing)
19
-
20
- ## How It Works
21
-
22
- The plugin has three independent mechanisms:
23
-
24
- ### 1. Capture (Automatic via Hook)
25
-
26
- ```
27
- Each Turn (message:sent)
28
- └── Buffer (user message, agent response) → local SQLite (~/.reflexio/sessions.db)
29
-
30
- Session End (command:stop)
31
- └── Flush all buffered turns to Reflexio server via reflexio_publish CLI
32
- └── Server automatically:
33
- 1. Analyzes conversation via LLM pipeline
34
- 2. Extracts playbooks: behavior instructions with context (trigger, rationale, blocking_issue)
35
- 3. Extracts user profiles: preferences, expertise, communication patterns
36
- 4. Stores everything with vector embeddings for semantic search
37
- ```
38
-
39
- Correction detection happens **server-side via LLM** — the plugin does not detect corrections itself.
40
-
41
- ### 2. Retrieve (Automatic via Hook Injection)
42
-
43
- ```
44
- Per-message (message:received hook — automatic)
45
- └── Hook injects search results from reflexio search before every agent response
46
- └── Returns user playbooks + agent playbooks relevant to the current message
47
- └── Semantic search matches message content against playbook triggers
48
- ```
49
-
50
- Both user playbooks (corrections specific to this agent instance) and agent playbooks (shared corrections aggregated from all instances) are returned and injected as context.
51
-
52
- ### 3. Aggregate (Automatic, optional manual trigger)
53
-
54
- ```
55
- After each publish
56
- └── Aggregation runs in background automatically
57
- └── Clusters similar user playbooks across all agent instances
58
- └── Deduplicates and consolidates into shared agent playbooks
59
- └── New agent playbooks start as PENDING → can be reviewed → APPROVED/REJECTED
60
-
61
- Manual trigger
62
- └── reflexio agent-playbooks aggregate (CLI)
63
- ```
64
-
65
- Agent playbooks accumulate corrections from all agent instances, so every instance benefits from corrections made by any other instance.
66
-
67
- ## Multi-User Architecture
68
-
69
- Each OpenClaw agent (identified by its `agentId`) is treated as a distinct Reflexio user. This enables per-agent learning isolation alongside cross-agent shared learning:
70
-
71
- ```
72
- ~/.openclaw/
73
- ├── agents/
74
- │ ├── main/ → Reflexio user_id: "main"
75
- │ ├── work/ → Reflexio user_id: "work"
76
- │ └── ops/ → Reflexio user_id: "ops"
77
- ```
78
-
79
- - **User playbooks**: per-agent corrections, isolated by `agentId`. Mistakes made by `main` are tracked separately from mistakes made by `work`.
80
- - **Agent playbooks**: shared corrections aggregated from ALL agents. Once a correction is aggregated and approved, every instance sees it via `reflexio search`.
81
- - **`user_id`** is derived from the OpenClaw session key prefix (`agent:<id>:...`), with fallback to `openclaw`. There is no override — the hook is deliberately locked to automatic identity resolution to eliminate env-var reads.
82
-
83
-
84
- ## Prerequisites
85
-
86
- - [OpenClaw](https://openclaw.ai) installed and running
87
- - [Node.js](https://nodejs.org/) 18+ (for the plugin runtime)
88
- - The `reflexio` CLI on PATH: `pipx install reflexio-ai` (or `pip install --user reflexio-ai`)
89
- - An LLM API key for the Reflexio server (e.g., `OPENAI_API_KEY`) — required for playbook/profile extraction but read only by the server, never by the hook
90
-
91
- Supported LLM providers: OpenAI, Anthropic, Google Gemini, DeepSeek, OpenRouter, MiniMax, DashScope, xAI, Moonshot, ZAI, or any local LLM endpoint (Ollama, LM Studio, vLLM).
92
-
93
- ## Installation
94
-
95
- ### Option 1 — ClawHub (recommended)
17
+ Guided Reflexio setup:
96
18
 
97
19
  ```bash
98
- clawhub plugin install reflexio-federated
20
+ reflexio setup openclaw
99
21
  ```
100
22
 
101
- On first use, the plugin auto-installs the `reflexio-ai` CLI (via `pipx` or `pip`) and runs first-use setup.
102
-
103
- ### Option 2 — From Source (if you have `reflexio-ai` and Node.js installed)
23
+ Or install the OpenClaw plugin from npm:
104
24
 
105
25
  ```bash
106
- cd /path/to/reflexio/integrations/openclaw
107
- ./scripts/install.sh
26
+ npx openclaw-smart install
108
27
  ```
109
28
 
110
- This installs the plugin from source, registers it with OpenClaw, and restarts the gateway.
29
+ The unscoped `openclaw-smart` npm package is a thin `npx` alias around the
30
+ scoped plugin package, `@reflexioai/openclaw-smart`.
111
31
 
112
- ### Option 3 Manual (for development)
32
+ If your OpenClaw version supports npm package specs in its plugin installer,
33
+ you can also use the native installer directly:
113
34
 
114
35
  ```bash
115
- # Build the plugin
116
- cd /path/to/reflexio/integrations/openclaw/plugin
117
- npm install
118
- npm run typecheck
119
- npm run build # if applicable
120
-
121
- # Install via openclaw
122
- cd /path/to/reflexio/integrations/openclaw
123
- ./scripts/install.sh
124
- ```
125
-
126
- ## First-Use Setup
127
-
128
- On the first OpenClaw session after installation, the plugin automatically:
129
-
130
- 1. Detects if the `reflexio` CLI is installed; if not, installs it via `pipx`
131
- 2. Creates `~/.reflexio/` configuration directory if it doesn't exist
132
- 3. Prompts for LLM provider selection (OpenAI, Anthropic, Gemini, etc.) and API key
133
- 4. Configures the local storage backend (SQLite for local use, Supabase optional)
134
- 5. Starts the Reflexio server in the background at `http://127.0.0.1:8081`
135
- 6. Runs first search to verify setup is complete
136
-
137
- **No manual steps required** — everything is automatic and transparent to the user.
36
+ openclaw plugins install @reflexioai/openclaw-smart
37
+ ```
38
+
39
+ The guided `reflexio setup openclaw` command walks you through:
40
+
41
+ 1. Picking an LLM provider and storage backend (SQLite by default).
42
+ 2. Writing `OPENCLAW_BIN` + `OPENCLAW_SMART_USE_LOCAL_CLI=1` to
43
+ `~/.reflexio/.env` so the backend's `openclaw` LiteLLM provider knows
44
+ which CLI to spawn for extraction.
45
+ 3. Installing the bundled plugin into openClaw
46
+ (`openclaw plugins install <plugin_dir>`).
47
+ 4. Running the plugin's first-run installer (`scripts/smart-install.sh`)
48
+ so the next session doesn't pay a cold-install cost.
49
+ 5. Calling `openclaw plugins inspect reflexio-openclaw-smart` to verify
50
+ the plugin loaded.
51
+
52
+ `reflexio setup openclaw --uninstall [--purge]` reverses everything;
53
+ `--repair` re-runs only the first-run installer. The npm wrapper exposes
54
+ the same maintenance operations as `openclaw-smart uninstall [--purge]`
55
+ and `openclaw-smart repair`.
56
+
57
+ ## How it works
58
+
59
+ * **session_start** — pushes openclaw-smart's preferred extraction window /
60
+ stride and the shared-skill optimizer defaults to the reflexio backend.
61
+ Emits a stall banner (`prependContext`) if learning has been idle.
62
+ * **before_prompt_build** — appends the user prompt to the session JSONL
63
+ buffer, then runs an `/api/search` query against reflexio scoped to this
64
+ project. Top hits are rendered as markdown and emitted under
65
+ `prependContext` (per-turn, not cached).
66
+ * **before_tool_call / after_tool_call** — `before_*` is an observe-only
67
+ stub (openClaw does not honor injection at that point). `after_*`
68
+ redacts secrets, truncates oversized strings, normalizes camelCase
69
+ payloads to snake_case, and appends an `Assistant_tool` record.
70
+ * **agent_end** — reads `payload["messages"]`, appends the latest
71
+ assistant turn, then publishes everything since the last
72
+ `published_up_to` watermark (no force-extraction).
73
+ * **session_end** — drains the buffer one last time with
74
+ `force_extraction=True` so the session's learnings are available before
75
+ the next openClaw run.
76
+
77
+ The full design lives in
78
+ [`docs/superpowers/specs/2026-05-19-openclaw-smart-design.md`](../../../../docs/superpowers/specs/2026-05-19-openclaw-smart-design.md).
79
+
80
+ ## Skills
81
+
82
+ Six skill folders ship under `plugin/skills/` (`reflexio` is the always-on contract, the other five are user-invocable):
83
+
84
+ | Skill | Purpose |
85
+ | ----------- | -------------------------------------------------------------------------- |
86
+ | `reflexio` | Always-on contract: trust injected context, cite with `[oc:…]`, stay quiet |
87
+ | `learn` | Force-publish the current session for immediate extraction |
88
+ | `show` | Dump currently-known skills + preferences for this project as markdown |
89
+ | `dashboard` | Open the local reflexio web UI (`http://localhost:3001`, shared with claude-smart) |
90
+ | `restart` | Restart the local reflexio backend cleanly |
91
+ | `clear-all` | Delete all locally-stored skills + preferences (destructive, prompts) |
138
92
 
139
93
  ## Configuration
140
94
 
141
- This plugin stores all configuration in `plugin/openclaw.plugin.json` and reads the following tunable settings:
142
-
143
- ### `publish` — Conversation capture and publish behavior
144
-
145
- - `batch_size` (default: 10): Number of turns to buffer before mid-session publish. At session end, all remaining turns are flushed regardless.
146
- - `max_retries` (default: 3): Number of times to retry failed publish attempts.
147
- - `max_content_length` (default: 10000): Maximum character length per turn to avoid oversized payloads.
148
-
149
- ### `search` Context injection before each response
150
-
151
- - `timeout_ms` (default: 5000): Maximum time to wait for search results. If the server is slow, search times out and the agent proceeds without injected context (graceful degradation).
152
- - `top_k` (default: 5): Number of playbooks to return per search.
153
- - `min_prompt_length` (default: 5): Skip search for trivial inputs (< 5 chars, or yes/no/ok/sure/thanks).
154
-
155
- ### `server` — Reflexio server health and startup
156
-
157
- - `health_check_timeout_ms` (default: 3000): Time limit for server health checks. Used to determine if a restart is needed.
158
- - `stale_flag_ms` (default: 120000): Flag file age threshold. If a startup flag is older than 2 minutes, assume the previous startup attempt failed and try again.
159
-
160
- All settings are optional and have sensible defaults. To override, edit `plugin/openclaw.plugin.json` and restart the agent.
161
-
162
- ## Using `reflexio_publish` Tool
163
-
164
- Conversations are automatically published at session end. For high-signal moments, use the `reflexio_publish` tool to flush immediately:
165
-
166
- - **User corrects you** and confirms the fix (explicit "good" / "perfect" or moves on)
167
- - **You complete a key milestone** with non-obvious learnings
168
- - **High-friction session** with multiple corrections
169
-
170
- The Reflexio server handles extraction (profiles, playbooks) from the published conversations. You don't need to structure the data — just publish, and the server does the rest.
171
-
172
- ## Cross-Session Retrieval
173
-
174
- **Session 1 (cold start):** No playbooks exist yet. The agent works normally. At session end, the hook captures and publishes the full conversation. The Reflexio server's LLM pipeline analyzes it and extracts corrections or user preferences.
175
-
176
- **Session 2+:** Before each response, the hook runs `reflexio search` and injects matching playbooks and profiles as context. Over time:
177
-
178
- - Mistakes made once are not repeated (corrections match by trigger similarity)
179
- - User preferences are remembered (profiles extracted automatically)
180
- - The agent adapts its approach per-task based on accumulated playbooks
181
- - Corrections from one agent instance propagate to all instances via aggregation
182
-
183
- ## File Structure
184
-
185
- ```
186
- openclaw/
187
- ├── README.md ← This file
188
- ├── TESTING.md ← Manual testing guide
189
- ├── plugin/ ← Compiled plugin (OpenClaw extension)
190
- │ ├── openclaw.plugin.json ← Plugin manifest and config schema
191
- │ ├── package.json ← NPM metadata
192
- │ ├── lib/ ← Core libraries
193
- │ │ ├── user-id.ts ← Multi-user identity resolution
194
- │ │ ├── server.ts ← Server URL, health check, auto-start
195
- │ │ ├── sqlite-buffer.ts ← Turn buffering
196
- │ │ ├── publish.ts ← Publish and CLI spawn
197
- │ │ └── search.ts ← Search and result formatting
198
- │ ├── hook/ ← Hook event handlers
199
- │ │ ├── handler.ts ← Core hook logic (bootstrap, message events, command:stop)
200
- │ │ └── setup.ts ← First-use setup (CLI install, storage config)
201
- │ ├── skills/ ← Agent instruction and tooling
202
- │ │ └── reflexio/
203
- │ │ └── SKILL.md ← Teaches agent when/how to search and publish
204
- │ ├── rules/ ← Always-active behavioral constraints
205
- │ │ └── reflexio.md ← Follow injected context, manual fallback, transparency
206
- │ └── index.ts ← Plugin entry point (SDK registration)
207
- ├── hook/ ← Flat hook for manual installation
208
- │ ├── handler.ts ← Same as plugin/hook/handler.ts
209
- │ └── HOOK.md ← Hook metadata (see references/HOOK.md)
210
- ├── scripts/ ← Installation and uninstall
211
- │ ├── install.sh ← Plugin installation
212
- │ └── uninstall.sh ← Plugin removal (preserves user data)
213
- └── _old/ ← Legacy documentation and code (to be removed)
214
- ```
215
-
216
- ## Comparison with openclaw-embedded
217
-
218
- | Aspect | openclaw (federated) | openclaw-embedded |
219
- | -------------------- | ---------------------------------------- | --------------------------------------- |
220
- | Architecture | Federated (server-based) | Standalone (no server) |
221
- | Storage | Reflexio server + SQLite buffer | Local SQLite only |
222
- | Multi-user support | Yes — per-agentId user isolation | Single user per instance |
223
- | Cross-instance sync | Yes — via agent playbooks aggregation | No — isolated per instance |
224
- | Prerequisites | Reflexio CLI, LLM API key, Node.js | SQLite (no server, no API key needed) |
225
- | Best for | Teams, multiple agents, persistent core | Single agent, offline-first, lightweight |
226
- | Deployment | Reflexio server + OpenClaw agents | Standalone OpenClaw agent |
227
-
228
- **Use the federated plugin if:**
229
- - Multiple agents run on the same machine or team (shared learnings via aggregation)
230
- - Corrections from one agent should propagate to others
231
- - A persistent Reflexio server is acceptable
232
-
233
- **Use openclaw-embedded if:**
234
- - Single agent, offline-first operation required
235
- - No external dependencies or API keys
236
- - Lightweight, self-contained setup
237
-
238
- ## Uninstall
239
-
240
- ### Remove the plugin
241
-
242
- ```bash
243
- ./scripts/uninstall.sh
244
- ```
245
-
246
- This removes the plugin from OpenClaw, cleans up state files, and preserves user data in `~/.reflexio/`.
247
-
248
- ### Remove user data (optional)
249
-
250
- ```bash
251
- ./scripts/uninstall.sh --purge
252
- ```
253
-
254
- This also deletes `~/.reflexio/` entirely.
255
-
256
- ### Verify removal
257
-
258
- ```bash
259
- openclaw plugins list
260
- # Should not show reflexio-federated
261
- ```
262
-
263
- ## Manual Testing
264
-
265
- See [TESTING.md](TESTING.md) for a complete step-by-step manual testing guide covering:
266
- - Install verification
267
- - First-session auto-setup
268
- - Search injection
269
- - Conversation capture and publish
270
- - `reflexio_publish` tool usage
271
- - Cross-session retry
272
- - Multi-user isolation
273
- - Graceful degradation
274
- - Uninstall
95
+ Plugin-side config lives in `plugin/openclaw.plugin.json` (no env vars
96
+ required for normal use). The shell scripts honour these env knobs:
97
+
98
+ * `OPENCLAW_SMART_INTERNAL=1` — recursion guard. Set automatically by
99
+ `openclaw_provider._call_cli` when the reflexio backend's own
100
+ LiteLLM-routed extraction subprocess fires hooks back into openclaw-smart.
101
+ Any handler that sees this env in the payload short-circuits.
102
+ * `OPENCLAW_SMART_USE_LOCAL_CLI=1` — opt-in for the
103
+ `openclaw_provider` LiteLLM plugin on the reflexio side. Set by
104
+ `reflexio setup openclaw`.
105
+ * `OPENCLAW_BIN` absolute path to the openclaw CLI used by the local
106
+ LLM provider. Set by `reflexio setup openclaw`.
107
+ * `OPENCLAW_DEFAULT_MODEL` default model passed to
108
+ `openclaw infer model run` when no model is requested explicitly.
109
+ * `OPENCLAW_SMART_STATE_DIR` — overrides the JSONL session buffer
110
+ location (default `~/.openclaw-smart/sessions/`). Used by tests.
111
+ * `OPENCLAW_SMART_BACKEND_AUTOSTART=0` opt out of the
112
+ `session_start` backend auto-start.
113
+ * `OPENCLAW_PLUGIN_ROOT` — pointer used by slash commands;
114
+ `scripts/ensure-plugin-root.sh` symlinks `~/.reflexio/openclaw-plugin-root`
115
+ to the active install.
116
+
117
+ ## Recursion guard
118
+
119
+ The reflexio backend uses `openclaw_provider` (a LiteLLM CustomLLM) to
120
+ invoke the openclaw CLI for extraction. That CLI can in turn fire openClaw
121
+ hooks back into openclaw-smart, which would re-publish the extractor's
122
+ own prompt into reflexio a tight feedback loop that explodes the
123
+ buffer. The guard at `openclaw_smart.internal_call.is_internal_invocation`
124
+ detects this by:
125
+
126
+ 1. checking `OPENCLAW_SMART_INTERNAL=1` (set by the provider on spawn),
127
+ 2. checking whether `workspaceDir` lives inside the reflexio install dir.
128
+
129
+ When either is true the hook dispatcher exits with empty stdout
130
+ immediately no buffer writes, no search, no publish.
131
+
132
+ ## Multi-session limitation
133
+
134
+ The TS shim tracks one `activeSessionKey` per plugin instance to route
135
+ the `reflexio_publish` tool to the right session. In concurrent
136
+ multi-session use the last session-key seen wins. This matches
137
+ claude-smart's behaviour and is intentional — see spec §10.
138
+
139
+ ## Troubleshooting
140
+
141
+ * **Hook timing out / no inject** — check
142
+ `~/.openclaw-smart/backend.log` for reflexio startup errors. The
143
+ session-start backend autostart is best-effort; you can also start it
144
+ manually via `bash plugin/scripts/backend-service.sh start`.
145
+ * **`uv` not found** — re-run `bash plugin/scripts/smart-install.sh`; on
146
+ failure it writes the reason to `~/.openclaw-smart/install-failed`.
147
+ * **Stale plugin after a code change** — `reflexio setup openclaw --repair`
148
+ re-runs the first-run installer and clears the failure marker.
149
+ * **Recursion loop / sessions multiplying** — the extractor lost the
150
+ `OPENCLAW_SMART_INTERNAL=1` env. Confirm `openclaw_provider._call_cli`
151
+ is still passing it (see
152
+ `reflexio/server/llm/providers/openclaw_provider.py`).
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ // Unscoped npm alias for `npx openclaw-smart install`.
3
+
4
+ import { spawnSync } from "node:child_process";
5
+ import { createRequire } from "node:module";
6
+
7
+ const require = createRequire(import.meta.url);
8
+ const cli = require.resolve("@reflexioai/openclaw-smart/scripts/npm-cli.js");
9
+ const result = spawnSync(process.execPath, [cli, ...process.argv.slice(2)], {
10
+ stdio: "inherit",
11
+ });
12
+
13
+ process.exit(result.status ?? 1);
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "openclaw-smart",
3
+ "version": "0.1.0",
4
+ "description": "npx installer alias for @reflexioai/openclaw-smart.",
5
+ "type": "module",
6
+ "bin": {
7
+ "openclaw-smart": "./bin/openclaw-smart.js"
8
+ },
9
+ "files": [
10
+ "bin/**/*.js"
11
+ ],
12
+ "dependencies": {
13
+ "@reflexioai/openclaw-smart": "0.1.0"
14
+ }
15
+ }
@@ -0,0 +1,38 @@
1
+ # openclaw-smart
2
+
3
+ openClaw plugin: cross-session memory via a local Reflexio backend.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npx openclaw-smart install
9
+ ```
10
+
11
+ The unscoped `openclaw-smart` package is a thin alias for this scoped plugin
12
+ package, `@reflexioai/openclaw-smart`.
13
+
14
+ If your OpenClaw version supports npm package specs in `plugins install`, you
15
+ can install the plugin package directly:
16
+
17
+ ```bash
18
+ openclaw plugins install @reflexioai/openclaw-smart
19
+ ```
20
+
21
+ For users who already have Reflexio installed, the guided setup remains:
22
+
23
+ ```bash
24
+ reflexio setup openclaw
25
+ ```
26
+
27
+ ## Commands
28
+
29
+ ```bash
30
+ openclaw-smart install
31
+ openclaw-smart repair
32
+ openclaw-smart uninstall
33
+ openclaw-smart uninstall --purge
34
+ ```
35
+
36
+ `install` registers `reflexio-openclaw-smart` with OpenClaw, enables typed hook
37
+ access, writes `OPENCLAW_BIN` and `OPENCLAW_SMART_USE_LOCAL_CLI=1` to
38
+ `~/.reflexio/.env`, warms Python dependencies, and verifies the plugin is loaded.