@alan512/experienceengine 0.1.0 → 0.1.3

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 (215) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.mcp.json +4 -8
  3. package/LICENSE +21 -0
  4. package/README.md +158 -47
  5. package/README.zh-CN.md +178 -57
  6. package/dist/adapters/codex/instruction-template.d.ts +3 -0
  7. package/dist/adapters/codex/instruction-template.js +12 -0
  8. package/dist/adapters/codex/instruction-template.js.map +1 -0
  9. package/dist/adapters/codex/mcp-server.d.ts +38 -41
  10. package/dist/adapters/codex/mcp-server.js +107 -338
  11. package/dist/adapters/codex/mcp-server.js.map +1 -1
  12. package/dist/analyzer/llm-learning-gate.js +39 -0
  13. package/dist/analyzer/llm-learning-gate.js.map +1 -1
  14. package/dist/cli/commands/claude-hook.js +12 -3
  15. package/dist/cli/commands/claude-hook.js.map +1 -1
  16. package/dist/cli/commands/config.js +88 -2
  17. package/dist/cli/commands/config.js.map +1 -1
  18. package/dist/cli/commands/doctor.d.ts +4 -28
  19. package/dist/cli/commands/doctor.js +136 -68
  20. package/dist/cli/commands/doctor.js.map +1 -1
  21. package/dist/cli/commands/feedback.js +4 -0
  22. package/dist/cli/commands/feedback.js.map +1 -1
  23. package/dist/cli/commands/init.d.ts +28 -0
  24. package/dist/cli/commands/init.js +419 -0
  25. package/dist/cli/commands/init.js.map +1 -0
  26. package/dist/cli/commands/inspect.js +203 -37
  27. package/dist/cli/commands/inspect.js.map +1 -1
  28. package/dist/cli/commands/install.js +9 -0
  29. package/dist/cli/commands/install.js.map +1 -1
  30. package/dist/cli/commands/maintenance.js +1 -1
  31. package/dist/cli/commands/maintenance.js.map +1 -1
  32. package/dist/cli/commands/mcp-server.js +4 -0
  33. package/dist/cli/commands/mcp-server.js.map +1 -1
  34. package/dist/cli/commands/status.js +57 -7
  35. package/dist/cli/commands/status.js.map +1 -1
  36. package/dist/cli/dispatch.js +22 -7
  37. package/dist/cli/dispatch.js.map +1 -1
  38. package/dist/cli/state-model.d.ts +14 -0
  39. package/dist/cli/state-model.js +23 -0
  40. package/dist/cli/state-model.js.map +1 -0
  41. package/dist/config/config-schema.d.ts +32 -0
  42. package/dist/config/config-schema.js +26 -0
  43. package/dist/config/config-schema.js.map +1 -1
  44. package/dist/config/default-config.js +3 -0
  45. package/dist/config/default-config.js.map +1 -1
  46. package/dist/config/load-config.js +19 -1
  47. package/dist/config/load-config.js.map +1 -1
  48. package/dist/config/path-resolver.d.ts +0 -1
  49. package/dist/config/path-resolver.js +0 -2
  50. package/dist/config/path-resolver.js.map +1 -1
  51. package/dist/config/runtime-env.d.ts +8 -0
  52. package/dist/config/runtime-env.js +14 -0
  53. package/dist/config/runtime-env.js.map +1 -0
  54. package/dist/config/secrets-store.d.ts +15 -0
  55. package/dist/config/secrets-store.js +56 -0
  56. package/dist/config/secrets-store.js.map +1 -0
  57. package/dist/config/settings-store.d.ts +10 -0
  58. package/dist/config/settings-store.js +44 -0
  59. package/dist/config/settings-store.js.map +1 -1
  60. package/dist/controller/candidate-retriever.d.ts +35 -2
  61. package/dist/controller/candidate-retriever.js +189 -10
  62. package/dist/controller/candidate-retriever.js.map +1 -1
  63. package/dist/controller/injection-renderer.js +52 -1
  64. package/dist/controller/injection-renderer.js.map +1 -1
  65. package/dist/controller/injection-scorecard.d.ts +14 -2
  66. package/dist/controller/injection-scorecard.js +18 -1
  67. package/dist/controller/injection-scorecard.js.map +1 -1
  68. package/dist/controller/intervention-controller.d.ts +15 -2
  69. package/dist/controller/intervention-controller.js +173 -11
  70. package/dist/controller/intervention-controller.js.map +1 -1
  71. package/dist/controller/lexical-retriever.d.ts +14 -0
  72. package/dist/controller/lexical-retriever.js +117 -0
  73. package/dist/controller/lexical-retriever.js.map +1 -0
  74. package/dist/controller/model-reranker.d.ts +20 -0
  75. package/dist/controller/model-reranker.js +187 -0
  76. package/dist/controller/model-reranker.js.map +1 -0
  77. package/dist/controller/node-ranker.js +1 -0
  78. package/dist/controller/node-ranker.js.map +1 -1
  79. package/dist/controller/query-rewrite.d.ts +8 -0
  80. package/dist/controller/query-rewrite.js +69 -0
  81. package/dist/controller/query-rewrite.js.map +1 -0
  82. package/dist/controller/trigger-evaluator.d.ts +23 -2
  83. package/dist/controller/trigger-evaluator.js +57 -3
  84. package/dist/controller/trigger-evaluator.js.map +1 -1
  85. package/dist/distillation/experience-family.d.ts +4 -0
  86. package/dist/distillation/experience-family.js +14 -0
  87. package/dist/distillation/experience-family.js.map +1 -0
  88. package/dist/distillation/host-llm.d.ts +1 -0
  89. package/dist/distillation/host-llm.js +5 -1
  90. package/dist/distillation/host-llm.js.map +1 -1
  91. package/dist/distillation/llm-distiller.js +4 -0
  92. package/dist/distillation/llm-distiller.js.map +1 -1
  93. package/dist/distillation/merge-decider.js +4 -0
  94. package/dist/distillation/merge-decider.js.map +1 -1
  95. package/dist/distillation/prompt-contract.d.ts +1 -1
  96. package/dist/distillation/prompt-contract.js +3 -0
  97. package/dist/distillation/prompt-contract.js.map +1 -1
  98. package/dist/distillation/queue-worker.js +57 -7
  99. package/dist/distillation/queue-worker.js.map +1 -1
  100. package/dist/feedback/state-transition.js +9 -0
  101. package/dist/feedback/state-transition.js.map +1 -1
  102. package/dist/input/input-adapter.js +2 -1
  103. package/dist/input/input-adapter.js.map +1 -1
  104. package/dist/input/outcome-resolver.js +5 -5
  105. package/dist/input/outcome-resolver.js.map +1 -1
  106. package/dist/input/tasktype-resolver.js +2 -0
  107. package/dist/input/tasktype-resolver.js.map +1 -1
  108. package/dist/input/tool-event-significance.d.ts +5 -0
  109. package/dist/input/tool-event-significance.js +7 -0
  110. package/dist/input/tool-event-significance.js.map +1 -0
  111. package/dist/install/claude-code-doctor.d.ts +7 -2
  112. package/dist/install/claude-code-doctor.js +38 -9
  113. package/dist/install/claude-code-doctor.js.map +1 -1
  114. package/dist/install/claude-marketplace-state.d.ts +14 -0
  115. package/dist/install/claude-marketplace-state.js +47 -0
  116. package/dist/install/claude-marketplace-state.js.map +1 -0
  117. package/dist/install/codex-installer.d.ts +18 -0
  118. package/dist/install/codex-installer.js +91 -1
  119. package/dist/install/codex-installer.js.map +1 -1
  120. package/dist/install/openclaw-installer.d.ts +7 -0
  121. package/dist/install/openclaw-installer.js +16 -0
  122. package/dist/install/openclaw-installer.js.map +1 -1
  123. package/dist/install/public-install.d.ts +14 -4
  124. package/dist/install/public-install.js +20 -7
  125. package/dist/install/public-install.js.map +1 -1
  126. package/dist/interaction/repo-summary.d.ts +3 -17
  127. package/dist/interaction/repo-summary.js +10 -27
  128. package/dist/interaction/repo-summary.js.map +1 -1
  129. package/dist/interaction/service.d.ts +44 -95
  130. package/dist/interaction/service.js +333 -248
  131. package/dist/interaction/service.js.map +1 -1
  132. package/dist/maintenance/scope-merge.d.ts +0 -1
  133. package/dist/maintenance/scope-merge.js +0 -20
  134. package/dist/maintenance/scope-merge.js.map +1 -1
  135. package/dist/plugin/openclaw-plugin.d.ts +23 -0
  136. package/dist/plugin/openclaw-plugin.js +86 -6
  137. package/dist/plugin/openclaw-plugin.js.map +1 -1
  138. package/dist/plugin/openclaw-routine-interaction.d.ts +6 -0
  139. package/dist/plugin/openclaw-routine-interaction.js +296 -0
  140. package/dist/plugin/openclaw-routine-interaction.js.map +1 -0
  141. package/dist/runtime/service.d.ts +0 -1
  142. package/dist/runtime/service.js +20 -29
  143. package/dist/runtime/service.js.map +1 -1
  144. package/dist/store/sqlite/db.js +9 -0
  145. package/dist/store/sqlite/db.js.map +1 -1
  146. package/dist/store/sqlite/repositories/candidate-repo.js +8 -2
  147. package/dist/store/sqlite/repositories/candidate-repo.js.map +1 -1
  148. package/dist/store/sqlite/repositories/injection-repo.d.ts +1 -0
  149. package/dist/store/sqlite/repositories/injection-repo.js +11 -0
  150. package/dist/store/sqlite/repositories/injection-repo.js.map +1 -1
  151. package/dist/store/sqlite/repositories/input-record-repo.d.ts +2 -0
  152. package/dist/store/sqlite/repositories/input-record-repo.js +22 -0
  153. package/dist/store/sqlite/repositories/input-record-repo.js.map +1 -1
  154. package/dist/store/sqlite/repositories/node-repo.js +17 -2
  155. package/dist/store/sqlite/repositories/node-repo.js.map +1 -1
  156. package/dist/store/sqlite/repositories/task-run-repo.d.ts +2 -0
  157. package/dist/store/sqlite/repositories/task-run-repo.js +18 -2
  158. package/dist/store/sqlite/repositories/task-run-repo.js.map +1 -1
  159. package/dist/store/sqlite/schema.sql +9 -49
  160. package/dist/store/vector/api-embedding-provider.d.ts +2 -0
  161. package/dist/store/vector/api-embedding-provider.js +23 -19
  162. package/dist/store/vector/api-embedding-provider.js.map +1 -1
  163. package/dist/store/vector/embeddings.d.ts +1 -1
  164. package/dist/store/vector/embeddings.js +4 -1
  165. package/dist/store/vector/embeddings.js.map +1 -1
  166. package/dist/types/domain.d.ts +30 -46
  167. package/dist/types/plugin.d.ts +2 -1
  168. package/docs/releases/v0.1.2.md +3 -3
  169. package/docs/releases/v0.1.3.md +94 -0
  170. package/docs/user-guide.md +226 -123
  171. package/openclaw.plugin.json +1 -1
  172. package/package.json +3 -2
  173. package/plugins/claude-code-experienceengine/.claude-plugin/plugin.json +1 -1
  174. package/plugins/claude-code-experienceengine/.mcp.json +4 -3
  175. package/plugins/claude-code-experienceengine/scripts/claude-hook.sh +30 -1
  176. package/plugins/claude-code-experienceengine/scripts/install-deps.sh +41 -6
  177. package/dist/cli/commands/pack.d.ts +0 -1
  178. package/dist/cli/commands/pack.js +0 -321
  179. package/dist/cli/commands/pack.js.map +0 -1
  180. package/dist/compiler/agents-renderer.d.ts +0 -4
  181. package/dist/compiler/agents-renderer.js +0 -105
  182. package/dist/compiler/agents-renderer.js.map +0 -1
  183. package/dist/compiler/claude-renderer.d.ts +0 -2
  184. package/dist/compiler/claude-renderer.js +0 -40
  185. package/dist/compiler/claude-renderer.js.map +0 -1
  186. package/dist/compiler/codex-renderer.d.ts +0 -2
  187. package/dist/compiler/codex-renderer.js +0 -40
  188. package/dist/compiler/codex-renderer.js.map +0 -1
  189. package/dist/compiler/compiler.d.ts +0 -4
  190. package/dist/compiler/compiler.js +0 -87
  191. package/dist/compiler/compiler.js.map +0 -1
  192. package/dist/compiler/deployer.d.ts +0 -21
  193. package/dist/compiler/deployer.js +0 -64
  194. package/dist/compiler/deployer.js.map +0 -1
  195. package/dist/compiler/github-renderer.d.ts +0 -2
  196. package/dist/compiler/github-renderer.js +0 -63
  197. package/dist/compiler/github-renderer.js.map +0 -1
  198. package/dist/compiler/types.d.ts +0 -45
  199. package/dist/compiler/types.js +0 -2
  200. package/dist/compiler/types.js.map +0 -1
  201. package/dist/interaction/pack-actions-service.d.ts +0 -59
  202. package/dist/interaction/pack-actions-service.js +0 -172
  203. package/dist/interaction/pack-actions-service.js.map +0 -1
  204. package/dist/packs/fs-registry.d.ts +0 -27
  205. package/dist/packs/fs-registry.js +0 -216
  206. package/dist/packs/fs-registry.js.map +0 -1
  207. package/dist/packs/index-sync.d.ts +0 -9
  208. package/dist/packs/index-sync.js +0 -54
  209. package/dist/packs/index-sync.js.map +0 -1
  210. package/dist/packs/types.d.ts +0 -55
  211. package/dist/packs/types.js +0 -2
  212. package/dist/packs/types.js.map +0 -1
  213. package/dist/store/sqlite/repositories/pack-repo.d.ts +0 -16
  214. package/dist/store/sqlite/repositories/pack-repo.js +0 -192
  215. package/dist/store/sqlite/repositories/pack-repo.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "experienceengine",
3
3
  "description": "Context-aware experience intervention controller for Claude Code.",
4
- "version": "0.1.0",
4
+ "version": "0.1.3",
5
5
  "author": {
6
6
  "name": "ExperienceEngine"
7
7
  },
package/.mcp.json CHANGED
@@ -2,15 +2,11 @@
2
2
  "mcpServers": {
3
3
  "experienceengine": {
4
4
  "type": "stdio",
5
- "command": "node",
6
- "args": [
7
- "${CLAUDE_PLUGIN_ROOT}/dist/cli/index.js",
8
- "mcp-server"
9
- ],
5
+ "command": "/mnt/d/ExperienceEngineData/.experienceengine/bin/experienceengine-mcp-server",
6
+ "args": [],
10
7
  "env": {
11
- "NODE_PATH": "${CLAUDE_PLUGIN_DATA}/node_modules",
12
- "EXPERIENCE_ENGINE_HOME": "${CLAUDE_PLUGIN_DATA}/experienceengine-home"
8
+ "EXPERIENCE_ENGINE_HOME": "/home/seed/.experienceengine"
13
9
  }
14
10
  }
15
11
  }
16
- }
12
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alan-512
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -11,89 +11,183 @@ Supported hosts today:
11
11
  - `Claude Code`
12
12
  - `Codex`
13
13
 
14
- ## What It Does
14
+ OpenClaw compatibility:
15
+ - requires a working OpenClaw installation with native plugin support
16
+ - the documented OpenClaw path assumes `openclaw plugins install` and `openclaw gateway restart` are available
17
+ - Node.js `>=20` is required for the published package
15
18
 
16
- ExperienceEngine is not a general memory store and not a replacement context engine.
19
+ ## The Problem It Solves
17
20
 
18
- It focuses on four things:
19
- - capture task/tool/outcome signals from the host agent
20
- - compress useful prior experience into short `strategy` or `warning` nodes
21
- - decide whether to inject guidance for a similar task
22
- - update node state from real `helped` / `harmed` outcomes
21
+ Coding agents repeat the same mistakes for a simple reason: most sessions do not accumulate reusable execution experience in a governed way.
23
22
 
24
- ## Why It Is Not Just Memory
23
+ The usual failure modes are:
24
+ - a fix worked yesterday, but the next similar session starts from zero again
25
+ - memory systems keep adding facts and preferences, but they rarely retire low-value guidance
26
+ - as recalled memory grows, context gets heavier and the agent's attention gets diluted
25
27
 
26
- Most agent memory systems answer:
27
-
28
- - what facts should be remembered
29
- - what user preferences should be carried forward
30
- - what repository context should be loaded next time
31
-
32
- ExperienceEngine answers a different question:
33
-
34
- - when should prior experience intervene
28
+ ExperienceEngine is designed for that gap. It does not try to remember everything. It tries to decide:
29
+ - when prior experience should intervene
35
30
  - which `strategy` or `warning` should be injected
36
31
  - whether that intervention actually helped
37
32
  - whether the experience should stay active, cool down, or retire
38
33
 
39
- In practice:
40
- - memory keeps facts and preferences
41
- - ExperienceEngine governs reusable coding tactics and failure-avoidance guidance
34
+ **Memory does addition. ExperienceEngine does governance.**
35
+
36
+ ## ExperienceEngine vs Memory
37
+
38
+ | Question | Memory Systems | ExperienceEngine |
39
+ |---|---|---|
40
+ | Persist facts and preferences across sessions | Yes | Not the primary job |
41
+ | Capture repeated failure → fix → success paths | Partial, usually manual | Yes, from real task signals |
42
+ | Track whether a recalled item helped or harmed | Usually no | Yes, per intervention |
43
+ | Retire stale or harmful guidance automatically | Usually no | Yes, cooling and retirement are built in |
44
+ | Keep context small and intervention-focused | Not the main goal | Yes, it injects short task-specific guidance |
45
+
46
+ ## Where It Sits In The Agent Loop
47
+
48
+ ```text
49
+ User task
50
+ -> before_prompt_build: retrieve and inject matching experience
51
+ -> agent reasoning + tools: capture failures, retries, corrections, and outcomes
52
+ -> task finalization: distill new candidates into reusable experience
53
+ -> helped / harmed feedback: promote, cool, or retire nodes
54
+ ```
55
+
56
+ ExperienceEngine works at the context layer. It does not modify the host model's weights.
57
+
58
+ ## Experience Lifecycle
59
+
60
+ ```text
61
+ task signals
62
+ -> candidate
63
+ -> active
64
+ -> cooling
65
+ -> retired
66
+ ```
67
+
68
+ Each node moves through that lifecycle using real task outcomes, not just time-based cleanup. Helpful experience gets reinforced; harmful experience gets cooled or retired.
42
69
 
43
70
  ## What You Can Use Today
44
71
 
45
72
  Already available in the repository:
46
73
  - host integration for `OpenClaw`, `Claude Code`, and `Codex`
47
- - MCP-native interaction surfaces plus CLI fallback
74
+ - MCP-native interaction surfaces plus CLI/operator fallback
48
75
  - API-first semantic retrieval with graceful fallback:
49
76
  - OpenAI `text-embedding-3-small`
50
77
  - Gemini `gemini-embedding-001`
51
78
  - Jina `jina-embeddings-v3`
52
79
  - managed local embedding fallback
53
80
  - legacy hash-based fallback
54
- - quick inspection and feedback commands such as `ee inspect --last`, `ee helped`, and `ee harmed`
55
- - local Experience Pack workflow:
56
- - `draft`
57
- - `review`
58
- - `publish`
59
- - `rollback`
60
- - compiler and deploy workflow for host instruction files:
61
- - `AGENTS.md`
62
- - `CODEX.md`
63
- - `CLAUDE.md`
64
- - GitHub agent profile markdown
81
+ - host-agent driven inspection and feedback, with CLI fallback commands such as `ee inspect --last`, `ee helped`, and `ee harmed`
82
+
83
+ For a more detailed explanation of what ExperienceEngine records and how an experience node is structured, see:
84
+
85
+ - [Experience Model Overview](./docs/development/experience-model.md)
65
86
 
66
87
  ## Quick Start
67
88
 
68
89
  ExperienceEngine no longer treats the `ee` CLI as the first-install entrypoint.
69
90
 
70
- Install ExperienceEngine through the host-native command for the host you want to use:
91
+ Install ExperienceEngine through the host setup flow for the host you want to use:
71
92
 
72
93
  - `OpenClaw`
73
- - planned one-step command:
94
+ - host-native plugin install:
74
95
  - `openclaw plugins install @alan512/experienceengine`
75
- - current status:
76
- - blocked until the public npm package `@alan512/experienceengine` is published
96
+ - after installing, restart the OpenClaw gateway before the first real task:
97
+ - `openclaw gateway restart`
77
98
  - `Codex`
78
- - planned one-step command:
99
+ - EE-managed Codex setup:
100
+ - `ee install codex`
101
+ - native/manual fallback:
79
102
  - `codex mcp add experienceengine --env EXPERIENCE_ENGINE_HOME=$HOME/.experienceengine -- npx -y @alan512/experienceengine codex-mcp-server`
80
- - current status:
81
- - blocked until the public npm package `@alan512/experienceengine` is published
103
+ - after either path, start a new Codex session in the repo so the MCP wiring and `AGENTS.md` instruction block are picked up
82
104
  - `Claude Code`
83
- - add the bundled marketplace from GitHub:
105
+ - host-native marketplace install:
106
+ - add the bundled marketplace from GitHub:
84
107
  - `/plugin marketplace add https://github.com/Alan-512/ExperienceEngine.git`
85
108
  - install the bundled plugin:
86
109
  - `/plugin install experienceengine@experienceengine`
87
110
  - `ee install claude-code` remains the operator fallback when you need direct hooks + MCP wiring outside the marketplace flow
111
+ - after installation, start a new Claude Code session so the plugin hooks and bundled MCP config are loaded
112
+
113
+ Across all three hosts, the intended product journey is the same:
114
+
115
+ 1. install ExperienceEngine through the host-specific setup path
116
+ 2. initialize shared ExperienceEngine state with `ee init`
117
+ 3. restart or open a fresh host session until the repo is `Ready`
118
+ 4. keep routine review and feedback inside the host agent when the host supports it cleanly
119
+ 5. use `ee` as the operator fallback for validation, repair, and deeper inspection
120
+
121
+ The host-specific differences are real, but they sit underneath one shared model:
122
+
123
+ - installation mechanics differ by host
124
+ - routine interaction should feel similar wherever the host supports it
125
+ - CLI remains the explicit fallback and operator surface
126
+
127
+ ExperienceEngine now treats onboarding and value as two separate layers:
128
+
129
+ - `Setup state`
130
+ - `Installed`
131
+ - `Initialized`
132
+ - `Ready`
133
+ - `Value state`
134
+ - `Warming up`
135
+ - `First value reached`
88
136
 
89
- After the host-native installation completes, use:
137
+ These are not one linear ladder. A repo can already be `Ready` while still `Warming up`.
138
+
139
+ For routine use, ask the host agent naturally for ExperienceEngine state or feedback actions, for example:
140
+
141
+ - "What did ExperienceEngine just inject?"
142
+ - "Why did that ExperienceEngine hint match?"
143
+ - "Mark the last ExperienceEngine intervention as helpful or harmful."
144
+
145
+ OpenClaw now also supports these additional phase-2 routine questions in-session:
146
+
147
+ - "Is ExperienceEngine ready here?"
148
+ - "Is ExperienceEngine still warming up in this repo?"
149
+ - "Why didn't ExperienceEngine inject anything just now?"
150
+
151
+ For `OpenClaw`, `Codex`, and `Claude Code`, the common review-and-feedback follow-ups should stay in the host session first.
152
+ For the extra readiness, warm-up, and recent-silence questions above, only `OpenClaw` supports the in-session phase-2 path today.
153
+ Use CLI fallback whenever the host-side path is unavailable or you need explicit operator control.
154
+
155
+ Use the `ee` CLI only when you need explicit operator validation or troubleshooting:
90
156
 
91
157
  ```bash
158
+ ee init
92
159
  ee doctor <openclaw|claude-code|codex>
93
160
  ee status
94
161
  ee maintenance embedding-smoke
95
162
  ```
96
163
 
164
+ `ee init` is shared-product initialization, not host-specific setup.
165
+
166
+ - Run it once after your first host installation to configure:
167
+ - distillation provider/model/auth
168
+ - embedding mode/provider
169
+ - any shared provider secrets
170
+ - Later host installations reuse the same ExperienceEngine home, settings, and shared secrets.
171
+
172
+ After installation, ExperienceEngine should orient the user toward the next setup step:
173
+
174
+ - if host wiring is in place, the product is at least `Installed`
175
+ - after shared state is configured with `ee init`, the product is `Initialized`
176
+ - once the host or repo has reloaded correctly for real work, the product is `Ready`
177
+
178
+ `First value reached` should only be claimed after visible output from a real task run. A generic warm-up message or static onboarding text does not count as first value.
179
+
180
+ Minimal shared initialization example:
181
+
182
+ ```bash
183
+ ee init distillation --provider openai --model gpt-4.1-mini --auth-mode api_key
184
+ ee init secret OPENAI_API_KEY <your-api-key>
185
+ ee init embedding --mode api --api-provider openai --model text-embedding-3-small
186
+ ee init show
187
+ ```
188
+
189
+ If you prefer Gemini or Jina for embeddings, use the same `ee init embedding` flow with the matching provider and model.
190
+
97
191
  ## Prerequisites
98
192
 
99
193
  Before installing an adapter, make sure the host CLI already works on this machine:
@@ -111,19 +205,31 @@ ExperienceEngine now treats installation and operations as separate concerns:
111
205
  - installation belongs to the host
112
206
  - validation and maintenance belong to `ee`
113
207
 
114
- That means:
208
+ That means the user-facing concepts stay stable even though the host integrations differ:
115
209
 
116
- - `Codex` uses a Codex-native MCP integration flow
117
- - `Claude Code` uses Claude-native plugin assets and marketplace distribution
118
- - `OpenClaw` uses plugin/runtime integration
210
+ - `OpenClaw`
211
+ - installs through plugin/runtime integration
212
+ - keeps stronger CLI/operator support today
213
+ - `Claude Code`
214
+ - installs through Claude-native marketplace/plugin assets
215
+ - prefers MCP-native routine interaction inside the host session
216
+ - `Codex`
217
+ - uses the shared ExperienceEngine MCP server
218
+ - prefers MCP-native routine interaction inside the host session
219
+
220
+ Once installation is complete, the host agent remains the primary interaction surface.
119
221
 
120
- Once installation is complete, `ee` becomes the operational surface for:
222
+ `ee` is the operational surface for:
121
223
 
224
+ - shared provider/model initialization
122
225
  - health checks
123
226
  - repair guidance
124
227
  - status inspection
125
228
  - learning and intervention feedback
126
229
 
230
+ `ee status` is the daily product-progress view.
231
+ `ee doctor <host>` is the explicit validation and troubleshooting view.
232
+
127
233
  ## Advanced Per-Host Commands
128
234
 
129
235
  If you need explicit per-host control as an operator or while developing the product, these commands still exist:
@@ -182,4 +288,9 @@ See the full user guide here:
182
288
 
183
289
  - [ExperienceEngine User Guide](./docs/user-guide.md)
184
290
 
185
- The user guide covers installation, host-specific notes, first-run validation, pack workflows, compiler/deploy commands, troubleshooting, and maintenance operations.
291
+ The user guide covers installation, host-specific notes, first-run validation, troubleshooting, and maintenance operations.
292
+
293
+ ## License
294
+
295
+ This project is licensed under the MIT License.
296
+ See [LICENSE](./LICENSE).
package/README.zh-CN.md CHANGED
@@ -4,90 +4,188 @@
4
4
 
5
5
  ExperienceEngine 是一个面向编程 Agent 的本地经验介入层。
6
6
 
7
- 它会从真实编码任务中学习简短、任务相关的经验,在后续相似任务中注入这些经验,并记录这次介入到底是帮到了还是干扰了结果。
7
+ 它会从真实编码任务中学习简短、任务相关的经验,在后续相似任务中决定是否注入这些经验,并记录这次介入到底是帮到了还是干扰了结果。
8
8
 
9
- 当前已验证的宿主:
10
- - `OpenClaw`:runtime / plugin 集成
11
- - `Claude Code`:hooks + MCP 交互
12
- - `Codex`:MCP-first runtime 与交互
9
+ 当前支持的宿主:
10
+ - `OpenClaw`
11
+ - `Claude Code`
12
+ - `Codex`
13
13
 
14
- ## 它能做什么
14
+ OpenClaw 兼容要求:
15
+ - 需要本机已经有可正常工作的 OpenClaw,并且支持原生插件安装
16
+ - 下面的 OpenClaw 安装路径默认要求 `openclaw plugins install` 和 `openclaw gateway restart` 可用
17
+ - 发布包要求 Node.js `>=20`
15
18
 
16
- ExperienceEngine 不是通用记忆库,也不是 context engine 的替代品。
19
+ ## 它解决的问题
17
20
 
18
- 它主要做 4 件事:
19
- - 从宿主 Agent 捕获任务、工具和结果信号
20
- - 把有价值的经验压缩成短小的 `strategy` 或 `warning` 节点
21
- - 判断当前任务是否值得注入经验
22
- - 根据真实 `helped` / `harmed` 结果更新节点状态
21
+ Coding agent 会重复踩同类坑,通常不是因为模型不够聪明,而是因为它缺少**可治理的经验积累机制**。
23
22
 
24
- ## 它和 Memory 有什么不同
25
-
26
- 大多数 agent memory 系统解决的是:
27
-
28
- - 记住哪些事实
29
- - 记住哪些用户偏好
30
- - 下次会话该带上哪些仓库上下文
31
-
32
- ExperienceEngine 解决的是另一层问题:
23
+ 常见问题是:
24
+ - 上一轮任务的教训,在新会话里直接丢失
25
+ - memory 会一直加,但通常不会主动退役低价值内容
26
+ - 记住的东西越来越多,context 越来越重,agent 的注意力反而被稀释
33
27
 
28
+ ExperienceEngine 处理的正是这一层问题。它不试图记住一切,而是专门治理:
34
29
  - 什么时候该让历史经验介入
35
30
  - 该注入哪条 `strategy` 或 `warning`
36
31
  - 这次介入到底有没有帮到任务
37
32
  - 这条经验是否应该继续保留、降温或退役
38
33
 
39
- 简单说:
40
- - memory 更像“记住事实和偏好”
41
- - ExperienceEngine 更像“治理可复用的编码经验”
34
+ **Memory 做加法,EE 做治理。**
35
+
36
+ ## 它和 Memory 的区别
37
+
38
+ | 问题 | Memory 系统 | ExperienceEngine |
39
+ |---|---|---|
40
+ | 跨会话保留事实和偏好 | ✅ | 不是核心目标 |
41
+ | 记录失败 → 修复 → 成功的经验路径 | 部分解决,通常依赖手工记录 | ✅ 来自真实任务信号 |
42
+ | 知道某次注入到底有没有帮助 | ❌ 通常没有 | ✅ 有 helped / harmed 追踪 |
43
+ | 自动退役过时或有害经验 | ❌ 通常没有 | ✅ 有 cooling / retired 生命周期 |
44
+ | 把注入控制在短小、任务相关的 guidance | 不是核心目标 | ✅ 是核心设计 |
45
+
46
+ ## 它在 Agent Loop 里的位置
47
+
48
+ ```text
49
+ 用户任务
50
+ -> before_prompt_build:检索并注入匹配经验
51
+ -> agent 推理 + 工具调用:捕获失败、重试、纠正和结果
52
+ -> task finalize:把候选信号提炼成可复用经验
53
+ -> helped / harmed:提升、降温或退役节点
54
+ ```
55
+
56
+ ExperienceEngine 工作在 context 层,不会去修改宿主模型权重。
42
57
 
43
- ## 当前能直接使用的能力
58
+ ## 经验生命周期
59
+
60
+ ```text
61
+ 任务信号
62
+ -> candidate
63
+ -> active
64
+ -> cooling
65
+ -> retired
66
+ ```
67
+
68
+ 每条经验都依赖真实任务结果来演化,而不是简单按时间清理。帮到任务的经验会被强化,反复有害的经验会被降温或退役。
69
+
70
+ ## 当前已经能用什么
44
71
 
45
72
  当前仓库已经实现并可用:
46
73
  - `OpenClaw`、`Claude Code`、`Codex` 三个宿主接入
47
- - 基于 MCP 的主交互面,以及 CLI fallback
48
- - 基于本地 embedding 的检索
49
- - 快速查看与反馈:
74
+ - MCP 原生交互面,以及 CLI / 运维 fallback
75
+ - API-first 语义检索与平滑回退:
76
+ - OpenAI `text-embedding-3-small`
77
+ - Gemini `gemini-embedding-001`
78
+ - Jina `jina-embeddings-v3`
79
+ - 受管本地 embedding fallback
80
+ - legacy hash-based fallback
81
+ - 通过宿主 agent 直接查看和反馈经验,并保留 CLI fallback:
50
82
  - `ee inspect --last`
51
83
  - `ee helped`
52
84
  - `ee harmed`
53
- - 本机共享目录的 `Experience Pack` 工作流:
54
- - `draft`
55
- - `review`
56
- - `publish`
57
- - `rollback`
58
- - 面向宿主文件的编译与部署:
59
- - `AGENTS.md`
60
- - `CODEX.md`
61
- - `CLAUDE.md`
62
- - GitHub agent profile markdown
85
+
86
+ 如果你想看更细的 ExperienceNode 结构和治理字段,见:
87
+
88
+ - [Experience Model Overview](./docs/development/experience-model.md)
63
89
 
64
90
  ## 快速开始
65
91
 
66
- 从源码目录启动:
92
+ ExperienceEngine 现在采用**宿主侧安装优先**。
93
+
94
+ 也就是说,第一步安装命令属于你要使用的宿主,而不是 `ee` CLI。
95
+
96
+ - `OpenClaw`
97
+ - 宿主原生插件安装:
98
+ - `openclaw plugins install @alan512/experienceengine`
99
+ - 安装后先重启 OpenClaw gateway,再开始真实任务:
100
+ - `openclaw gateway restart`
101
+ - `Codex`
102
+ - EE 托管安装:
103
+ - `ee install codex`
104
+ - 原生 / 手工 fallback:
105
+ - `codex mcp add experienceengine --env EXPERIENCE_ENGINE_HOME=$HOME/.experienceengine -- npx -y @alan512/experienceengine codex-mcp-server`
106
+ - 无论走哪条路径,首次接入后都建议在仓库里开启一个新的 Codex 会话,让 MCP 配置和 `AGENTS.md` 指令块生效
107
+ - `Claude Code`
108
+ - 宿主原生 marketplace 安装:
109
+ - 先添加 GitHub marketplace:
110
+ - `/plugin marketplace add https://github.com/Alan-512/ExperienceEngine.git`
111
+ - 再安装插件:
112
+ - `/plugin install experienceengine@experienceengine`
113
+ - 如果你需要显式 hooks + MCP wiring,仍可用:
114
+ - `ee install claude-code`
115
+ - 安装后建议开启一个新的 Claude Code 会话,让插件 hooks 和 bundled MCP 配置生效
116
+
117
+ 宿主安装完成后,普通用户应继续直接和宿主 agent 交互。
118
+
119
+ 例如你可以直接问宿主 agent:
120
+
121
+ - “ExperienceEngine 刚刚注入了什么?”
122
+ - “显示最近一次 ExperienceEngine 介入。”
123
+ - “把刚才那次 ExperienceEngine 提示标记为 helpful。”
124
+
125
+ 只有在需要显式运维、排障或高级调试时,再使用:
67
126
 
68
127
  ```bash
69
- pnpm install
70
- pnpm build
71
- node dist/cli/index.js doctor codex
128
+ ee init
129
+ ee doctor <openclaw|claude-code|codex>
130
+ ee status
131
+ ee maintenance embedding-smoke
72
132
  ```
73
133
 
74
- 如果已经作为命令安装,可直接使用:
134
+ 这里的 `ee init` 属于 ExperienceEngine 的**共享初始化**,不是某个宿主自己的安装步骤。
135
+
136
+ - 第一次把 EE 接到任意一个宿主后,做一次初始化即可。它会统一引导你配置:
137
+ - distillation provider / model / auth
138
+ - embedding 模式 / provider
139
+ - 共享 provider secret
140
+ - 之后再安装新的宿主,会复用同一个 EE 数据目录、配置和共享 secret。
141
+
142
+ 最小共享初始化示例:
75
143
 
76
144
  ```bash
77
- ee doctor codex
145
+ ee init distillation --provider openai --model gpt-4.1-mini --auth-mode api_key
146
+ ee init secret OPENAI_API_KEY <your-api-key>
147
+ ee init embedding --mode api --api-provider openai --model text-embedding-3-small
148
+ ee init show
78
149
  ```
79
150
 
151
+ 如果你更想用 Gemini 或 Jina 做 embedding,可以沿用同样的 `ee init embedding` 流程,只替换 provider 和 model。
152
+
80
153
  ## 前置条件
81
154
 
82
- 在安装任一 adapter 前,请先确认对应宿主 CLI 已经能在当前机器正常工作:
155
+ 在安装任一宿主前,请先确认对应宿主 CLI 已经能在当前机器正常工作:
156
+
157
+ - `openclaw`
158
+ - `claude`
159
+ - `codex`
160
+
161
+ ExperienceEngine 不会替你安装这些宿主 CLI。它只负责把自己接入一个已经可用的宿主环境。
162
+
163
+ ## 安装模型
164
+
165
+ ExperienceEngine 现在把“安装”和“运维”明确分开:
166
+
167
+ - 安装属于宿主
168
+ - 验证、修复、状态查看属于 `ee`
169
+
170
+ 这意味着:
171
+
172
+ - `Codex` 走共享 ExperienceEngine MCP 服务,首次接入优先使用 `ee install codex`
173
+ - `Claude Code` 走 Claude 原生插件资产与 marketplace 分发
174
+ - `OpenClaw` 走 plugin/runtime 集成
175
+
176
+ 一旦安装完成,宿主 agent 仍然是主交互面。
83
177
 
84
- - `openclaw`:用于 OpenClaw adapter
85
- - `claude`:用于 Claude Code adapter
86
- - `codex`:用于 Codex adapter
178
+ `ee` CLI 主要负责:
87
179
 
88
- ExperienceEngine 不会替你安装这些宿主 CLI。它只会把自己接入一个已经可用的宿主环境。
180
+ - 共享 provider/model 初始化
181
+ - 健康检查
182
+ - 修复建议
183
+ - 状态查看
184
+ - 学习与介入反馈
89
185
 
90
- ## 按宿主安装
186
+ ## 高级按宿主命令
187
+
188
+ 如果你是运维者、开发者,或者想显式控制某个宿主,仍然可以使用:
91
189
 
92
190
  ```bash
93
191
  ee install openclaw
@@ -95,12 +193,12 @@ ee install claude-code
95
193
  ee install codex
96
194
  ```
97
195
 
98
- 说明:
99
- - `OpenClaw` 走 plugin/runtime 集成,管理面更多依赖 CLI fallback
100
- - `Claude Code` 会同时安装 hooks 和共享 MCP server
101
- - `Codex` 会安装共享 MCP server
102
- - `ee install ...` 和 `ee doctor ...` 现在会检查 `npm/pnpm` 是否使用非官方 registry;受管模型下载默认建议使用 `https://registry.npmjs.org`
103
- - `ee install ...` 成功后还会主动说明冷启动预期:采集会立刻开始,但正式经验通常需要同仓库内几次相似任务后才会出现
196
+ 这些命令仍然有效,但它们更适合作为:
197
+ - 运维 fallback
198
+ - 显式修复
199
+ - 产品开发期调试
200
+
201
+ 而不是默认公开安装路径。
104
202
 
105
203
  ## 数据目录
106
204
 
@@ -117,10 +215,33 @@ ee install codex
117
215
  - 受管本地 embedding 模型缓存,默认位于 `~/.experienceengine/models/embeddings`
118
216
  - 受管备份与导出快照
119
217
 
218
+ ## Embedding 默认行为
219
+
220
+ 当前默认行为:
221
+
222
+ - `embeddingProvider = "api"`
223
+ - provider 优先级:
224
+ - 设置了 `OPENAI_API_KEY` 时优先 OpenAI
225
+ - 设置了 `GEMINI_API_KEY` 时使用 Gemini
226
+ - 设置了 `JINA_API_KEY` 时使用 Jina
227
+ - 如果没有任何 API provider 可用,会自动回退到受管本地 embedding
228
+
229
+ 常用环境变量:
230
+
231
+ - `EXPERIENCE_ENGINE_EMBEDDING_PROVIDER=local`
232
+ - 强制完全本地 embedding
233
+ - `EXPERIENCE_ENGINE_EMBEDDING_API_PROVIDER=openai|gemini|jina`
234
+ - 强制指定某个 API embedding provider
235
+
120
236
  ## 用户手册
121
237
 
122
238
  完整用户文档见:
123
239
 
124
240
  - [ExperienceEngine 用户手册](./docs/user-guide.md)
125
241
 
126
- 用户手册里包含安装、宿主差异、首次验证、pack 工作流、compiler/deploy 命令、维护命令和故障排查说明。
242
+ 用户手册里包含安装、宿主差异、首次验证、维护命令和故障排查说明。
243
+
244
+ ## 许可证
245
+
246
+ 本项目采用 MIT License。
247
+ 详见 [LICENSE](./LICENSE)。
@@ -0,0 +1,3 @@
1
+ export declare const CODEX_EXPERIENCEENGINE_INSTRUCTION_START = "<!-- EXPERIENCEENGINE:CODEX-INSTRUCTION START -->";
2
+ export declare const CODEX_EXPERIENCEENGINE_INSTRUCTION_END = "<!-- EXPERIENCEENGINE:CODEX-INSTRUCTION END -->";
3
+ export declare const renderCodexExperienceEngineInstruction: () => string;
@@ -0,0 +1,12 @@
1
+ export const CODEX_EXPERIENCEENGINE_INSTRUCTION_START = "<!-- EXPERIENCEENGINE:CODEX-INSTRUCTION START -->";
2
+ export const CODEX_EXPERIENCEENGINE_INSTRUCTION_END = "<!-- EXPERIENCEENGINE:CODEX-INSTRUCTION END -->";
3
+ export const renderCodexExperienceEngineInstruction = () => [
4
+ "## ExperienceEngine workflow",
5
+ "Use ExperienceEngine for meaningful coding and debugging tasks.",
6
+ "- Call `experienceengine_lookup_hints` once near task start before making changes.",
7
+ "- In Codex, ask what ExperienceEngine just injected and ask why it matched in-session before CLI fallback.",
8
+ "- If injected guidance clearly helped or harmed the task, mark the guidance as helped or harmed in-session with `experienceengine_feedback_last` before CLI fallback.",
9
+ "- Use `experienceengine_record_tool_result` only for important tool outcomes that changed the task direction, and keep tool summaries concise.",
10
+ "- Call `experienceengine_finalize_task` before finishing each meaningful task. Skip it for lightweight wording-only, Q&A, or no-op turns. When useful, omit `prompt` and send only a concise `contextSummary`."
11
+ ].join("\n");
12
+ //# sourceMappingURL=instruction-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruction-template.js","sourceRoot":"","sources":["../../../src/adapters/codex/instruction-template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wCAAwC,GACnD,mDAAmD,CAAC;AACtD,MAAM,CAAC,MAAM,sCAAsC,GACjD,iDAAiD,CAAC;AAEpD,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAW,EAAE,CACjE;IACE,8BAA8B;IAC9B,iEAAiE;IACjE,oFAAoF;IACpF,4GAA4G;IAC5G,uKAAuK;IACvK,gJAAgJ;IAChJ,gNAAgN;CACjN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}