@alan512/experienceengine 0.2.0 → 0.3.0

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 (182) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.mcp.json +5 -6
  3. package/README.md +65 -54
  4. package/README.zh-CN.md +64 -53
  5. package/dist/adapters/codex/action-registry.d.ts +23 -1
  6. package/dist/adapters/codex/action-registry.js +73 -0
  7. package/dist/adapters/codex/action-registry.js.map +1 -1
  8. package/dist/adapters/codex/behavior-loop.d.ts +80 -0
  9. package/dist/adapters/codex/behavior-loop.js +189 -0
  10. package/dist/adapters/codex/behavior-loop.js.map +1 -0
  11. package/dist/adapters/codex/mcp-server.d.ts +27 -72
  12. package/dist/adapters/codex/mcp-server.js +36 -160
  13. package/dist/adapters/codex/mcp-server.js.map +1 -1
  14. package/dist/cli/commands/claude-hook.d.ts +4 -0
  15. package/dist/cli/commands/claude-hook.js +105 -21
  16. package/dist/cli/commands/claude-hook.js.map +1 -1
  17. package/dist/cli/commands/codex-hook.d.ts +22 -0
  18. package/dist/cli/commands/codex-hook.js +298 -0
  19. package/dist/cli/commands/codex-hook.js.map +1 -0
  20. package/dist/cli/commands/config.js +9 -1
  21. package/dist/cli/commands/config.js.map +1 -1
  22. package/dist/cli/commands/doctor.js +77 -2
  23. package/dist/cli/commands/doctor.js.map +1 -1
  24. package/dist/cli/commands/inspect.d.ts +1 -1
  25. package/dist/cli/commands/inspect.js +329 -4
  26. package/dist/cli/commands/inspect.js.map +1 -1
  27. package/dist/cli/commands/install.js +2 -0
  28. package/dist/cli/commands/install.js.map +1 -1
  29. package/dist/cli/commands/maintenance.js +4 -0
  30. package/dist/cli/commands/maintenance.js.map +1 -1
  31. package/dist/cli/commands/repair.js +33 -3
  32. package/dist/cli/commands/repair.js.map +1 -1
  33. package/dist/cli/commands/status.js +33 -0
  34. package/dist/cli/commands/status.js.map +1 -1
  35. package/dist/cli/dispatch.js +8 -3
  36. package/dist/cli/dispatch.js.map +1 -1
  37. package/dist/cli/index.js +0 -0
  38. package/dist/config/config-schema.d.ts +8 -0
  39. package/dist/config/config-schema.js +6 -0
  40. package/dist/config/config-schema.js.map +1 -1
  41. package/dist/config/default-config.js +1 -0
  42. package/dist/config/default-config.js.map +1 -1
  43. package/dist/config/load-config.js +3 -0
  44. package/dist/config/load-config.js.map +1 -1
  45. package/dist/controller/candidate-retriever.d.ts +5 -1
  46. package/dist/controller/candidate-retriever.js +237 -13
  47. package/dist/controller/candidate-retriever.js.map +1 -1
  48. package/dist/controller/injection-renderer.d.ts +2 -2
  49. package/dist/controller/injection-renderer.js +22 -3
  50. package/dist/controller/injection-renderer.js.map +1 -1
  51. package/dist/controller/injection-scorecard.js +3 -0
  52. package/dist/controller/injection-scorecard.js.map +1 -1
  53. package/dist/controller/intervention-controller.d.ts +2 -2
  54. package/dist/controller/intervention-controller.js +185 -25
  55. package/dist/controller/intervention-controller.js.map +1 -1
  56. package/dist/controller/model-reranker-mode.d.ts +4 -0
  57. package/dist/controller/model-reranker-mode.js +14 -0
  58. package/dist/controller/model-reranker-mode.js.map +1 -0
  59. package/dist/controller/model-reranker.d.ts +0 -1
  60. package/dist/controller/model-reranker.js +1 -13
  61. package/dist/controller/model-reranker.js.map +1 -1
  62. package/dist/controller/policy-enricher.d.ts +2 -1
  63. package/dist/controller/policy-enricher.js +71 -11
  64. package/dist/controller/policy-enricher.js.map +1 -1
  65. package/dist/controller/trigger-evaluator.d.ts +2 -1
  66. package/dist/controller/trigger-evaluator.js +24 -0
  67. package/dist/controller/trigger-evaluator.js.map +1 -1
  68. package/dist/evaluation/openclaw-scenarios.js +12 -5
  69. package/dist/evaluation/openclaw-scenarios.js.map +1 -1
  70. package/dist/experience-management/repo-policy.d.ts +53 -0
  71. package/dist/experience-management/repo-policy.js +175 -0
  72. package/dist/experience-management/repo-policy.js.map +1 -0
  73. package/dist/hybrid/capsule-builder.js +2 -0
  74. package/dist/hybrid/capsule-builder.js.map +1 -1
  75. package/dist/input/scope-resolver.js +16 -4
  76. package/dist/input/scope-resolver.js.map +1 -1
  77. package/dist/install/claude-cli.js +38 -21
  78. package/dist/install/claude-cli.js.map +1 -1
  79. package/dist/install/claude-code-doctor.js +8 -3
  80. package/dist/install/claude-code-doctor.js.map +1 -1
  81. package/dist/install/claude-code-installer.js +5 -2
  82. package/dist/install/claude-code-installer.js.map +1 -1
  83. package/dist/install/claude-runtime-target.d.ts +5 -0
  84. package/dist/install/claude-runtime-target.js +32 -2
  85. package/dist/install/claude-runtime-target.js.map +1 -1
  86. package/dist/install/codex-cli.d.ts +7 -0
  87. package/dist/install/codex-cli.js +43 -20
  88. package/dist/install/codex-cli.js.map +1 -1
  89. package/dist/install/codex-hooks.d.ts +42 -0
  90. package/dist/install/codex-hooks.js +258 -0
  91. package/dist/install/codex-hooks.js.map +1 -0
  92. package/dist/install/codex-installer.d.ts +28 -3
  93. package/dist/install/codex-installer.js +120 -9
  94. package/dist/install/codex-installer.js.map +1 -1
  95. package/dist/install/codex-runtime-target.d.ts +20 -0
  96. package/dist/install/codex-runtime-target.js +85 -17
  97. package/dist/install/codex-runtime-target.js.map +1 -1
  98. package/dist/install/openclaw-cli.d.ts +1 -0
  99. package/dist/install/openclaw-cli.js +52 -3
  100. package/dist/install/openclaw-cli.js.map +1 -1
  101. package/dist/install/openclaw-installer.d.ts +5 -0
  102. package/dist/install/openclaw-installer.js +24 -5
  103. package/dist/install/openclaw-installer.js.map +1 -1
  104. package/dist/interaction/repo-summary.d.ts +17 -0
  105. package/dist/interaction/repo-summary.js +33 -15
  106. package/dist/interaction/repo-summary.js.map +1 -1
  107. package/dist/interaction/retrieval-policy-inspection.d.ts +19 -0
  108. package/dist/interaction/retrieval-policy-inspection.js +33 -0
  109. package/dist/interaction/retrieval-policy-inspection.js.map +1 -0
  110. package/dist/interaction/service.d.ts +24 -1
  111. package/dist/interaction/service.js +186 -23
  112. package/dist/interaction/service.js.map +1 -1
  113. package/dist/maintenance/claude-validate-print.d.ts +8 -1
  114. package/dist/maintenance/claude-validate-print.js +52 -2
  115. package/dist/maintenance/claude-validate-print.js.map +1 -1
  116. package/dist/maintenance/experience-export-drafts.d.ts +56 -0
  117. package/dist/maintenance/experience-export-drafts.js +217 -0
  118. package/dist/maintenance/experience-export-drafts.js.map +1 -0
  119. package/dist/maintenance/experience-hygiene.d.ts +38 -0
  120. package/dist/maintenance/experience-hygiene.js +266 -0
  121. package/dist/maintenance/experience-hygiene.js.map +1 -0
  122. package/dist/maintenance/operator-review-flow.d.ts +81 -0
  123. package/dist/maintenance/operator-review-flow.js +172 -0
  124. package/dist/maintenance/operator-review-flow.js.map +1 -0
  125. package/dist/plugin/openclaw-plugin.d.ts +5 -0
  126. package/dist/plugin/runtime-helpers.js +43 -1
  127. package/dist/plugin/runtime-helpers.js.map +1 -1
  128. package/dist/runtime/prompt-service.d.ts +51 -0
  129. package/dist/runtime/prompt-service.js +209 -0
  130. package/dist/runtime/prompt-service.js.map +1 -0
  131. package/dist/runtime/service.d.ts +8 -2
  132. package/dist/runtime/service.js +234 -44
  133. package/dist/runtime/service.js.map +1 -1
  134. package/dist/store/sqlite/db.js +15 -0
  135. package/dist/store/sqlite/db.js.map +1 -1
  136. package/dist/store/sqlite/repositories/attribution-record-repo.d.ts +15 -0
  137. package/dist/store/sqlite/repositories/attribution-record-repo.js +111 -0
  138. package/dist/store/sqlite/repositories/attribution-record-repo.js.map +1 -0
  139. package/dist/store/sqlite/repositories/episode-repo.d.ts +14 -0
  140. package/dist/store/sqlite/repositories/episode-repo.js +84 -0
  141. package/dist/store/sqlite/repositories/episode-repo.js.map +1 -0
  142. package/dist/store/sqlite/repositories/injection-repo.d.ts +2 -0
  143. package/dist/store/sqlite/repositories/injection-repo.js +32 -5
  144. package/dist/store/sqlite/repositories/injection-repo.js.map +1 -1
  145. package/dist/store/sqlite/repositories/input-record-repo.d.ts +1 -0
  146. package/dist/store/sqlite/repositories/input-record-repo.js +23 -10
  147. package/dist/store/sqlite/repositories/input-record-repo.js.map +1 -1
  148. package/dist/store/sqlite/repositories/node-repo.d.ts +2 -0
  149. package/dist/store/sqlite/repositories/node-repo.js +19 -0
  150. package/dist/store/sqlite/repositories/node-repo.js.map +1 -1
  151. package/dist/store/sqlite/repositories/outcome-record-repo.d.ts +1 -0
  152. package/dist/store/sqlite/repositories/outcome-record-repo.js +11 -2
  153. package/dist/store/sqlite/repositories/outcome-record-repo.js.map +1 -1
  154. package/dist/store/sqlite/repositories/repo-policy-repo.d.ts +11 -0
  155. package/dist/store/sqlite/repositories/repo-policy-repo.js +87 -0
  156. package/dist/store/sqlite/repositories/repo-policy-repo.js.map +1 -0
  157. package/dist/store/sqlite/repositories/review-event-repo.d.ts +1 -0
  158. package/dist/store/sqlite/repositories/review-event-repo.js +11 -2
  159. package/dist/store/sqlite/repositories/review-event-repo.js.map +1 -1
  160. package/dist/store/sqlite/repositories/task-run-repo.d.ts +1 -0
  161. package/dist/store/sqlite/repositories/task-run-repo.js +11 -2
  162. package/dist/store/sqlite/repositories/task-run-repo.js.map +1 -1
  163. package/dist/store/sqlite/schema.sql +43 -0
  164. package/dist/store/vector/api-embedding-provider.js +14 -3
  165. package/dist/store/vector/api-embedding-provider.js.map +1 -1
  166. package/dist/store/vector/embeddings.js +7 -1
  167. package/dist/store/vector/embeddings.js.map +1 -1
  168. package/dist/types/domain.d.ts +105 -3
  169. package/dist/utils/text.js +5 -1
  170. package/dist/utils/text.js.map +1 -1
  171. package/docs/assets/readme/inspect-last-example.svg +37 -0
  172. package/docs/releases/v0.2.1.md +30 -0
  173. package/docs/releases/v0.3.0.md +17 -0
  174. package/docs/user-guide.md +91 -5
  175. package/openclaw.plugin.json +1 -1
  176. package/package.json +16 -14
  177. package/plugins/claude-code-experienceengine/.claude-plugin/plugin.json +1 -1
  178. package/plugins/claude-code-experienceengine/.mcp.json +3 -9
  179. package/plugins/claude-code-experienceengine/scripts/install-deps.sh +1 -1
  180. package/plugins/claude-code-experienceengine/scripts/mcp-server.sh +43 -0
  181. package/scripts/claude-plugin/claude-hook.sh +6 -1
  182. package/scripts/claude-plugin/mcp-server.sh +45 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "experienceengine",
3
3
  "description": "Context-aware experience intervention controller for Claude Code.",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "author": {
6
6
  "name": "ExperienceEngine"
7
7
  },
package/.mcp.json CHANGED
@@ -2,11 +2,10 @@
2
2
  "mcpServers": {
3
3
  "experienceengine": {
4
4
  "type": "stdio",
5
- "command": "/mnt/d/ExperienceEngineData/.experienceengine/bin/experienceengine-mcp-server",
6
- "args": [],
7
- "env": {
8
- "EXPERIENCE_ENGINE_HOME": "/home/seed/.experienceengine"
9
- }
5
+ "command": "bash",
6
+ "args": [
7
+ "${CLAUDE_PLUGIN_ROOT}/scripts/claude-plugin/mcp-server.sh"
8
+ ]
10
9
  }
11
10
  }
12
- }
11
+ }
package/README.md CHANGED
@@ -12,40 +12,30 @@ Supported hosts today: `OpenClaw`, `Claude Code`, `Codex`
12
12
 
13
13
  Without ExperienceEngine:
14
14
  - the agent repeats the same SQLite migration mistake in a similar repo
15
+ - it opens the DB before running the migration, then wastes turns retrying the wrong path
15
16
 
16
17
  With ExperienceEngine:
17
- - it injects a hint like: `Run the migration before opening the DB connection`
18
- - later you mark that intervention `helpful` or `harmful`
19
- - the experience can then become active, cool down, or retire
18
+ - at task start, it injects one short constraint like: `Run the migration before opening the DB connection`
19
+ - the host agent avoids the same failed path instead of rediscovering it from scratch
20
+ - after the task, ExperienceEngine usually updates that guidance automatically from the real outcome
21
+ - if the guidance later starts harming similar tasks, ExperienceEngine can cool, quarantine, or retire it
20
22
 
21
- ```text
22
- task signals -> distilled experience -> retrieval -> short intervention -> feedback -> governance
23
- ```
23
+ Task flow: `task signals -> distilled experience -> retrieval -> short intervention -> feedback -> governance`
24
24
 
25
25
  <details>
26
26
  <summary>Example host transcript</summary>
27
27
 
28
- ```text
29
28
  User: Fix the SQLite startup failure in this repo.
30
29
 
31
- ExperienceEngine:
32
- Hint: Run the migration before opening the DB connection.
30
+ Host agent: ExperienceEngine found a prior successful fix pattern in this repo: `Run the migration before opening the DB connection.` I’ll apply the migration first, then retry startup.
33
31
 
34
- Host agent:
35
- I’ll apply the migration first, then retry startup.
32
+ User: Why did that ExperienceEngine hint match?
36
33
 
37
- User:
38
- Why did that ExperienceEngine hint match?
34
+ Host agent: It matched a prior task in this repo with the same SQLite startup pattern and a successful migration-first fix.
39
35
 
40
- Host agent:
41
- It matched a prior task in this repo with the same SQLite startup pattern and a successful migration-first fix.
36
+ User: So ExperienceEngine is trying to keep me off the same bad path?
42
37
 
43
- User:
44
- Mark the last ExperienceEngine intervention as helpful.
45
-
46
- Host agent:
47
- Recorded. That experience gets stronger for similar future tasks.
48
- ```
38
+ Host agent: Yes. It reused a repo-local success pattern before the next tool call, and it will usually score the outcome automatically after this run.
49
39
 
50
40
  </details>
51
41
 
@@ -55,6 +45,12 @@ Host agent:
55
45
 
56
46
  Fastest host-specific install paths:
57
47
 
48
+ If you plan to use `ee init`, `ee install ...`, or other operator commands, install the CLI first:
49
+
50
+ ```bash
51
+ npm install -g @alan512/experienceengine
52
+ ```
53
+
58
54
  - `OpenClaw`
59
55
  - `openclaw plugins install @alan512/experienceengine`
60
56
  - `openclaw gateway restart`
@@ -91,7 +87,7 @@ Do not use ExperienceEngine if:
91
87
  |---|---|---|---|
92
88
  | `OpenClaw` | native plugin install | host-native | most complete today |
93
89
  | `Claude Code` | marketplace plugin, with `ee install claude-code` fallback | MCP + plugin hooks | supported |
94
- | `Codex` | `ee install codex`, with native MCP fallback | MCP-native | supported |
90
+ | `Codex` | `ee install codex`, with native MCP fallback | hooks + MCP | supported |
95
91
 
96
92
  ## Why It Exists
97
93
 
@@ -110,44 +106,50 @@ ExperienceEngine is designed for intervention governance, not general memory acc
110
106
  | Keep context small and intervention-focused | Not the main goal | Yes, it injects short task-specific guidance |
111
107
  | Generic document lookup | Common fit | Not the primary job |
112
108
 
109
+ ## Why It Is Not Just Another Memory Layer
110
+
111
+ ExperienceEngine is not trying to remember more things than the host. Its core job is to govern whether learned guidance should keep affecting future tasks.
112
+
113
+ - most learning work happens after the task, so the current task does not need to wait for the full experience pipeline
114
+ - each learned node moves through a lifecycle such as `candidate`, `active`, `cooling`, and `retired`
115
+ - delivery is governed separately from storage, so harmful guidance can be cooled, quarantined, or removed from normal live injection
116
+ - posttask review can revise whether a hint actually helped, harmed, or stayed uncertain
117
+ - delivery decisions are persisted even when no hint is shipped, so skipped turns can still be explained later
118
+ - high-match same-repo experience can move out of conservative delivery after successful reuse, while cross-repo reuse stays cautious unless there is stronger evidence
119
+ - the product goal is production-safe reuse, not maximum recall
120
+
113
121
  ## Where It Sits In The Agent Loop
114
122
 
115
123
  At a high level, ExperienceEngine operates around the agent loop like this:
116
124
 
117
- ```text
118
- User task
119
- -> before_prompt_build: retrieve and inject matching experience
120
- -> agent reasoning + tools: capture failures, retries, corrections, and outcomes
121
- -> task finalization: distill new candidates into reusable experience
122
- -> helped / harmed feedback: promote, cool, or retire nodes
123
- ```
125
+ - `User task`
126
+ - `before_prompt_build`: retrieve and inject matching experience
127
+ - `agent reasoning + tools`: capture failures, retries, corrections, and outcomes
128
+ - `task finalization`: distill new candidates into reusable experience
129
+ - `helped / harmed feedback`: promote, cool, or retire nodes
124
130
 
125
131
  ExperienceEngine works at the context layer. It does not modify the host model's weights.
126
132
 
127
133
  ## Experience Lifecycle
128
134
 
129
- ```text
130
- task signals
131
- -> candidate
132
- -> active
133
- -> cooling
134
- -> retired
135
- ```
135
+ `task signals -> candidate -> active -> cooling -> retired`
136
136
 
137
137
  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.
138
138
 
139
139
  ## What You Can Do Today
140
140
 
141
141
  - reuse short guidance from similar coding work
142
- - review why a hint matched
143
- - mark interventions helpful or harmful
144
- - inspect active, cooling, and retired experience
142
+ - review why a hint matched or why nothing injected
143
+ - let ExperienceEngine automatically reinforce, cool, quarantine, or retire guidance from real task outcomes
144
+ - override the last intervention as helpful or harmful when the automatic judgment needs correction
145
+ - inspect active, cooling, quarantined, and retired experience
145
146
  - run across `OpenClaw`, `Claude Code`, and `Codex`
146
147
 
147
148
  ### Under The Hood
148
149
 
149
150
  - MCP-native interaction surfaces plus CLI/operator fallback
150
151
  - semantic retrieval with API and local fallback
152
+ - deterministic match scorecards that separate same-repo confidence from broader cross-repo reuse
151
153
  - host-agent driven inspection and feedback, with CLI fallback commands such as `ee inspect --last`, `ee helped`, and `ee harmed`
152
154
 
153
155
  For a more detailed explanation of what ExperienceEngine records and how an experience node is structured, see:
@@ -157,17 +159,18 @@ For a more detailed explanation of what ExperienceEngine records and how an expe
157
159
  ## Current Status
158
160
 
159
161
  - Stable: core experience lifecycle, inspect/helped/harmed loop, host integrations, CLI/operator fallback
160
- - Good path today: `OpenClaw` native plugin install
162
+ - Recommended first path: use the host you already work in; `OpenClaw` currently has the deepest host-native integration
161
163
  - Evolving: retrieval tuning, provider strategy, advanced host UX
162
- - If you want the smoothest first experience today, start with `OpenClaw`.
164
+ - If you are starting from scratch and do not already have a preferred host, `OpenClaw` is the most complete native-plugin path.
163
165
 
164
166
  ## What First Success Looks Like
165
167
 
166
168
  After installation and initialization, the first visible signs of value are:
167
169
 
168
- - ExperienceEngine injects a short hint during a real task
169
- - the host can explain why that hint matched
170
- - feedback on the last intervention affects future reuse
170
+ - a repeated task avoids a previously known bad path instead of rediscovering it
171
+ - ExperienceEngine injects only a short repo-relevant constraint instead of bloating the prompt
172
+ - the host can explain why that hint matched or why nothing was injected
173
+ - the task outcome usually updates future delivery automatically
171
174
  - `ee inspect --last` shows the recent intervention and related node state
172
175
 
173
176
  ## Prerequisites
@@ -183,7 +186,8 @@ Before installing an adapter, make sure the host CLI already works on this machi
183
186
  OpenClaw notes:
184
187
  - requires a working OpenClaw installation with native plugin support
185
188
  - the documented OpenClaw path assumes `openclaw plugins install` and `openclaw gateway restart` are available
186
- - OpenClaw now uses the shared background learning loop by default
189
+ - ExperienceEngine resolves the real project root from OpenClaw hook payloads or nearby repo markers; if OpenClaw only reports its global workspace, ExperienceEngine isolates that session instead of reusing unrelated global-workspace experience
190
+ - OpenClaw uses the shared background learning loop by default
187
191
  - OpenClaw still keeps async hybrid posttask review disabled by default; `ee status` and `ee doctor openclaw` show that explicitly
188
192
 
189
193
  General package requirement:
@@ -207,7 +211,8 @@ Install ExperienceEngine through the host setup flow for the host you want to us
207
211
  - `ee install codex`
208
212
  - native/manual fallback:
209
213
  - see the advanced example below if you need direct MCP wiring
210
- - after either path, start a new Codex session in the repo so the MCP wiring and `AGENTS.md` instruction block are picked up
214
+ - after either path, start a new Codex session in the repo so project hooks, MCP wiring, and the `AGENTS.md` instruction block are picked up
215
+ - in mixed Windows Codex App + WSL Codex CLI setups, the project `.codex/hooks.json` can be shared by both runtimes, while MCP registration remains runtime/user-level in each Codex home
211
216
  - `Claude Code`
212
217
  - host-native marketplace install:
213
218
  - add the bundled marketplace from GitHub:
@@ -243,23 +248,26 @@ After installation, ExperienceEngine should orient the user toward the next setu
243
248
 
244
249
  Minimal shared initialization example:
245
250
 
246
- ```bash
247
- ee init distillation --provider openai --model gpt-4.1-mini --auth-mode api_key
248
- ee init secret OPENAI_API_KEY <your-api-key>
249
- ee init embedding --mode api --api-provider openai --model text-embedding-3-small
250
- ee init show
251
- ```
251
+ 1. `ee init distillation --provider openai --model gpt-4.1-mini --auth-mode api_key`
252
+ 2. `ee init secret OPENAI_API_KEY <your-api-key>`
253
+ 3. `ee init embedding --mode api --api-provider openai --model text-embedding-3-small`
254
+ 4. `ee init show`
252
255
 
253
256
  If you prefer Gemini or Jina for embeddings, use the same `ee init embedding` flow with the matching provider and model.
254
257
 
255
258
  ### Routine Use vs Operator Use
256
259
 
257
- For routine use, ask the host agent naturally for ExperienceEngine state or feedback actions, for example:
260
+ For routine use, ask the host agent naturally for ExperienceEngine state first. Automatic outcome attribution is the default path; manual feedback is mainly there when you want to correct that judgment.
261
+
262
+ Examples:
258
263
 
259
264
  - "What did ExperienceEngine just inject?"
260
265
  - "Why did that ExperienceEngine hint match?"
266
+ - "Why didn't ExperienceEngine inject anything just now?"
261
267
  - "Mark the last ExperienceEngine intervention as helpful or harmful."
262
268
 
269
+ In normal use, you should not need to manually score every intervention. ExperienceEngine is designed to learn from real task outcomes automatically, while still letting you override the result when the automatic judgment is wrong.
270
+
263
271
  OpenClaw also supports these additional readiness and recent-silence questions in-session:
264
272
 
265
273
  - "Is ExperienceEngine ready here?"
@@ -303,6 +311,8 @@ ExperienceEngine separates:
303
311
 
304
312
  The host remains the primary interaction surface.
305
313
  `ee` remains the explicit operator surface for setup, validation, repair, status, and maintenance.
314
+ For Codex, `ee status` and `ee doctor codex` also report whether the `ee` CLI fallback is available on `PATH`. Codex MCP wiring can still work when the CLI fallback is missing, but commands such as `ee inspect --last` need either a PATH-visible `ee` binary or an explicit package invocation.
315
+ For mixed Windows Codex App + WSL Codex CLI use, treat `.codex/hooks.json` as repo-owned hook wiring and `~/.codex/config.toml` as per-runtime MCP wiring. `ee repair codex` refreshes the project hook launcher and removes stale project-scoped ExperienceEngine MCP config so Windows App and WSL CLI do not fight over one config file.
306
316
 
307
317
  ## Advanced Per-Host Commands (Operator / Development Only)
308
318
 
@@ -328,7 +338,8 @@ codex mcp add experienceengine --env EXPERIENCE_ENGINE_HOME=$HOME/.experienceeng
328
338
  Notes:
329
339
  - `OpenClaw` uses plugin/runtime integration (not `src/adapters/`) and CLI fallback for management.
330
340
  - `Claude Code` installs both hooks and the shared ExperienceEngine MCP server.
331
- - `Codex` installs the shared ExperienceEngine MCP server.
341
+ - `Codex` installs Codex-native hooks plus the shared ExperienceEngine MCP server. `ee codex exec` remains the deterministic non-interactive fallback.
342
+ - Codex `UserPromptSubmit` stays synchronous because it owns prompt-time experience injection. `PostToolUse` and `Stop` are queued for background processing by default. `PreToolUse` is not registered by default; set `EXPERIENCE_ENGINE_CODEX_PRETOOL_HOOK_ENABLED=1` only for synchronous gating experiments.
332
343
  - `ee install ...` and `ee doctor ...` now warn if `npm` or `pnpm` uses a non-official registry, because managed model downloads are most reliable with `https://registry.npmjs.org`.
333
344
  - successful `ee install ...` also explains the cold-start expectation: capture starts immediately, but formal experience usually appears after a few similar tasks in the same repo.
334
345
 
package/README.zh-CN.md CHANGED
@@ -12,40 +12,30 @@ ExperienceEngine 是一个面向编程 Agent 的治理层。它复用真实执
12
12
 
13
13
  没有 ExperienceEngine:
14
14
  - agent 会在相似仓库里重复犯同样的 SQLite migration 错误
15
+ - 它会先打开数据库、再补 migration,然后在错误方向上浪费几轮
15
16
 
16
17
  有 ExperienceEngine:
17
- - 它会注入一条提示,例如:`先执行 migration,再打开数据库连接`
18
- - 后续你可以把这次介入标记为 `helpful` 或 `harmful`
19
- - 这条经验会据此进入 active、降温或退役
18
+ - 它会在真正调用工具之前注入一条很短的约束,例如:`先执行 migration,再打开数据库连接`
19
+ - 宿主 agent 会直接避开上次已经踩过的错路,而不是重新试错
20
+ - 任务结束后,ExperienceEngine 通常会根据真实结果自动更新这条 guidance
21
+ - 如果这条 guidance 后面开始伤害相似任务,ExperienceEngine 会把它降温、隔离或退役
20
22
 
21
- ```text
22
- 任务信号 -> 提炼经验 -> 检索 -> 短提示注入 -> 反馈 -> 治理
23
- ```
23
+ 任务流:`任务信号 -> 提炼经验 -> 检索 -> 短提示注入 -> 反馈 -> 治理`
24
24
 
25
25
  <details>
26
26
  <summary>宿主里的示例对话</summary>
27
27
 
28
- ```text
29
28
  用户:修一下这个仓库里的 SQLite 启动失败问题。
30
29
 
31
- ExperienceEngine
32
- Hint: 先执行 migration,再打开数据库连接。
30
+ 宿主 agent:ExperienceEngine 在这个仓库里找到了一个之前成功过的修复模式:`先执行 migration,再打开数据库连接。` 我会先补 migration,然后再重试启动。
33
31
 
34
- 宿主 agent:
35
- 我会先补 migration,然后再重试启动。
32
+ 用户:为什么这条 ExperienceEngine 提示会命中?
36
33
 
37
- 用户:
38
- 为什么这条 ExperienceEngine 提示会命中?
34
+ 宿主 agent:它匹配到了这个仓库里过去一次相同的 SQLite 启动失败,以及当时成功的 migration-first 修复路径。
39
35
 
40
- 宿主 agent:
41
- 它匹配到了这个仓库里过去一次相同的 SQLite 启动失败,以及当时成功的 migration-first 修复路径。
36
+ 用户:所以 ExperienceEngine 的作用,是提前把我从同样的错路上拉回来?
42
37
 
43
- 用户:
44
- 把刚才那次 ExperienceEngine 介入标记为 helpful。
45
-
46
- 宿主 agent:
47
- 已记录。之后遇到类似任务时,这条经验会更容易再次命中。
48
- ```
38
+ 宿主 agent:对。它在下一次工具调用前复用了这个仓库里的成功路径,而且这次任务结束后通常会自动判断这条经验到底帮到了还是干扰了结果。
49
39
 
50
40
  </details>
51
41
 
@@ -55,6 +45,12 @@ ExperienceEngine:
55
45
 
56
46
  最快的宿主安装路径:
57
47
 
48
+ 如果你需要使用 `ee init`、`ee install ...` 或其他 operator 命令,请先安装 CLI:
49
+
50
+ ```bash
51
+ npm install -g @alan512/experienceengine
52
+ ```
53
+
58
54
  - `OpenClaw`
59
55
  - `openclaw plugins install @alan512/experienceengine`
60
56
  - `openclaw gateway restart`
@@ -91,7 +87,7 @@ ExperienceEngine:
91
87
  |---|---|---|---|
92
88
  | `OpenClaw` | 原生插件安装 | 宿主原生 | 当前最完整 |
93
89
  | `Claude Code` | marketplace 插件,保留 `ee install claude-code` fallback | MCP + plugin hooks | 已支持 |
94
- | `Codex` | `ee install codex`,保留原生 MCP fallback | MCP 原生 | 已支持 |
90
+ | `Codex` | `ee install codex`,保留原生 MCP fallback | hooks + MCP | 已支持 |
95
91
 
96
92
  ## 为什么要做这个
97
93
 
@@ -110,44 +106,50 @@ ExperienceEngine 的目标不是通用 memory 累积,而是**介入治理**。
110
106
  | 保持提示短小、任务相关 | 不是核心目标 | 是 |
111
107
  | 通用文档检索 | 常见适用场景 | 不是核心目标 |
112
108
 
109
+ ## 为什么它不是另一层记忆
110
+
111
+ ExperienceEngine 不是想比宿主“记住更多东西”。它的核心价值,是持续治理一条已经学到的 guidance 还应不应该继续影响后续任务。
112
+
113
+ - 大部分学习动作发生在任务之后,所以当前任务不需要等待整条经验处理链路跑完
114
+ - 每条经验节点都会经历 `candidate`、`active`、`cooling`、`retired` 这样的生命周期
115
+ - “存下来” 和 “还能不能继续上线” 是分开的,所以有害 guidance 可以被降温、隔离,或者退出正常注入路径
116
+ - 任务结束后的审查会继续判断这条 hint 到底是帮到了、伤害了,还是仍然不确定
117
+ - 即使这次没有注入 hint,delivery decision 也会被记录下来,所以之后仍然能解释为什么跳过
118
+ - 同仓库高匹配经验在成功复用后可以从保守投放提升到正常投放;跨仓库复用默认仍保持保守,除非后续证据更强
119
+ - 这个产品追求的是“生产安全的经验复用”,不是“尽量多记、尽量多召回”
120
+
113
121
  ## 它在 Agent Loop 里的位置
114
122
 
115
123
  从高层看,ExperienceEngine 围绕 agent loop 的位置是这样的:
116
124
 
117
- ```text
118
- 用户任务
119
- -> before_prompt_build:检索并注入匹配经验
120
- -> agent 推理 + 工具调用:捕获失败、重试、修正和结果
121
- -> task finalize:把候选信号提炼成可复用经验
122
- -> helped / harmed:提升、降温或退役节点
123
- ```
125
+ - `用户任务`
126
+ - `before_prompt_build`:检索并注入匹配经验
127
+ - `agent 推理 + 工具调用`:捕获失败、重试、修正和结果
128
+ - `task finalize`:把候选信号提炼成可复用经验
129
+ - `helped / harmed`:提升、降温或退役节点
124
130
 
125
131
  ExperienceEngine 工作在 context 层,不会修改宿主模型权重。
126
132
 
127
133
  ## 经验生命周期
128
134
 
129
- ```text
130
- 任务信号
131
- -> candidate
132
- -> active
133
- -> cooling
134
- -> retired
135
- ```
135
+ `任务信号 -> candidate -> active -> cooling -> retired`
136
136
 
137
137
  每条经验都根据真实任务结果演化,而不是按时间粗暴清理。帮到任务的经验会被强化,反复有害的经验会被降温或退役。
138
138
 
139
139
  ## 现在能做什么
140
140
 
141
141
  - 在相似编码任务里复用短 guidance
142
- - 查看某条 hint 为什么命中
143
- - 把最近一次介入标记为 helpful harmful
144
- - 查看 active、cooling、retired 等生命周期状态
142
+ - 查看某条 hint 为什么命中,或者为什么这次没有注入
143
+ - ExperienceEngine 根据真实任务结果自动强化、降温、隔离或退役 guidance
144
+ - 当自动判断不准时,手动把最近一次介入标记为 helpful 或 harmful
145
+ - 查看 active、cooling、quarantined、retired 等生命周期状态
145
146
  - 在 `OpenClaw`、`Claude Code`、`Codex` 三个宿主中使用
146
147
 
147
148
  ### 底层实现
148
149
 
149
150
  - MCP 原生交互面,加上 CLI / operator fallback
150
151
  - 支持 API 与本地回退的语义检索
152
+ - 确定性的 match scorecard,用来区分同仓库高置信匹配和更宽泛的跨仓库复用
151
153
  - 宿主 agent 内可直接查看和反馈经验,CLI fallback 包括 `ee inspect --last`、`ee helped`、`ee harmed`
152
154
 
153
155
  如果你想看 ExperienceNode 结构和治理字段,见:
@@ -157,17 +159,18 @@ ExperienceEngine 工作在 context 层,不会修改宿主模型权重。
157
159
  ## 当前状态
158
160
 
159
161
  - Stable:核心经验生命周期、inspect/helped/harmed loop、宿主集成、CLI/operator fallback
160
- - 当前最顺滑的路径:`OpenClaw` 原生插件安装
162
+ - 推荐优先路径:使用你已经在用的宿主;如果从零开始,`OpenClaw` 目前是最完整的原生插件路径
161
163
  - 仍在演进:retrieval 调优、provider 策略、更高级的宿主 UX
162
- - 如果你想最快拿到第一份顺滑体验,建议先从 `OpenClaw` 开始
164
+ - 如果你还没有固定宿主,建议先从 `OpenClaw` 开始。
163
165
 
164
166
  ## 什么叫第一次真正成功
165
167
 
166
168
  安装并初始化后,第一次真正体现价值的信号通常是:
167
169
 
168
- - ExperienceEngine 在真实任务里注入了一条短 hint
169
- - 宿主能解释为什么这条 hint 会命中
170
- - 你对最近一次介入的反馈,会影响后续复用
170
+ - 一类重复任务不再重走之前已经犯过的错路
171
+ - ExperienceEngine 只注入一条很短、和当前仓库直接相关的约束,而不是把上下文塞满
172
+ - 宿主能解释为什么这条 hint 会命中,或者为什么这次没有注入
173
+ - 任务结果通常会自动影响以后是否继续投放这条经验
171
174
  - `ee inspect --last` 能看到最近的介入和相关节点状态
172
175
 
173
176
  ## 前置条件
@@ -183,6 +186,7 @@ ExperienceEngine 工作在 context 层,不会修改宿主模型权重。
183
186
  OpenClaw 说明:
184
187
  - 需要本机已有可正常工作的 OpenClaw,且支持原生插件安装
185
188
  - 下面的 OpenClaw 路径默认要求 `openclaw plugins install` 和 `openclaw gateway restart` 可用
189
+ - ExperienceEngine 会从 OpenClaw hook payload 或附近仓库标记解析真实项目根目录;如果 OpenClaw 只上报全局 workspace,ExperienceEngine 会把该会话隔离起来,避免复用不相干的全局 workspace 经验
186
190
 
187
191
  通用包要求:
188
192
  - 发布包要求 Node.js `>=20`
@@ -205,7 +209,8 @@ ExperienceEngine 现在不再把 `ee` CLI 当成适用于所有宿主的统一
205
209
  - `ee install codex`
206
210
  - 原生 / 手工 fallback:
207
211
  - 如果你需要直接 MCP wiring,可参考后面的高级示例
208
- - 无论走哪条路径,首次接入后都建议在仓库里开启一个新的 Codex 会话,让 MCP 配置和 `AGENTS.md` 指令块生效
212
+ - 无论走哪条路径,首次接入后都建议在仓库里开启一个新的 Codex 会话,让项目 hooks、MCP 配置和 `AGENTS.md` 指令块生效
213
+ - 如果同一个仓库同时用于 Windows Codex App 和 WSL Codex CLI,项目 `.codex/hooks.json` 可以共享;MCP 注册仍然属于每个运行时自己的 Codex home
209
214
  - `Claude Code`
210
215
  - 宿主原生 marketplace 安装:
211
216
  - 先添加 GitHub marketplace:
@@ -242,23 +247,26 @@ ExperienceEngine 现在不再把 `ee` CLI 当成适用于所有宿主的统一
242
247
 
243
248
  最小共享初始化示例:
244
249
 
245
- ```bash
246
- ee init distillation --provider openai --model gpt-4.1-mini --auth-mode api_key
247
- ee init secret OPENAI_API_KEY <your-api-key>
248
- ee init embedding --mode api --api-provider openai --model text-embedding-3-small
249
- ee init show
250
- ```
250
+ 1. `ee init distillation --provider openai --model gpt-4.1-mini --auth-mode api_key`
251
+ 2. `ee init secret OPENAI_API_KEY <your-api-key>`
252
+ 3. `ee init embedding --mode api --api-provider openai --model text-embedding-3-small`
253
+ 4. `ee init show`
251
254
 
252
255
  如果你更想用 Gemini 或 Jina 做 embedding,可以沿用同样的 `ee init embedding` 流程,只替换 provider 和 model。
253
256
 
254
257
  ### 日常使用与 Operator 使用
255
258
 
256
- 日常使用时,优先直接问宿主 agent,例如:
259
+ 日常使用时,优先直接问宿主 agent 当前的 ExperienceEngine 状态。默认主路径是自动结果归因;手动 feedback 主要用于你觉得自动判断不准时的纠偏。
260
+
261
+ 例如:
257
262
 
258
263
  - “ExperienceEngine 刚刚注入了什么?”
259
264
  - “为什么那条 ExperienceEngine 提示会命中?”
265
+ - “为什么这次 ExperienceEngine 没有注入?”
260
266
  - “把刚才那次 ExperienceEngine 介入标记为 helpful 或 harmful。”
261
267
 
268
+ 正常使用里,你不应该需要手动给每次介入都打分。ExperienceEngine 的默认路径是根据真实任务结果自动学习;只有当自动判断明显不对时,你再手动纠偏。
269
+
262
270
  OpenClaw 还支持这些 readiness / silence 问题:
263
271
 
264
272
  - “ExperienceEngine 这里 ready 了吗?”
@@ -302,6 +310,8 @@ ExperienceEngine 明确拆分:
302
310
 
303
311
  宿主仍然是主交互面。
304
312
  `ee` 仍然是显式的 operator 面,用于 setup、验证、修复、状态查看和维护。
313
+ 对于 Codex,`ee status` 和 `ee doctor codex` 还会显示 `ee` CLI fallback 是否在 `PATH` 上可用。Codex 的 MCP 接入在 CLI fallback 缺失时仍可能正常工作,但 `ee inspect --last` 这类命令需要 PATH 里有 `ee`,或者使用显式的包调用方式。
314
+ 如果同一个仓库同时用于 Windows Codex App 和 WSL Codex CLI,请把 `.codex/hooks.json` 当成仓库级 hook wiring,把 `~/.codex/config.toml` 当成每个运行时自己的 MCP wiring。`ee repair codex` 会刷新项目 hook launcher,并移除过期的项目级 ExperienceEngine MCP 配置,避免 Windows App 和 WSL CLI 争用同一个配置文件。
305
315
 
306
316
  ## 高级按宿主命令(仅限 Operator / 开发者)
307
317
 
@@ -327,7 +337,8 @@ codex mcp add experienceengine --env EXPERIENCE_ENGINE_HOME=$HOME/.experienceeng
327
337
  说明:
328
338
  - `OpenClaw` 走 plugin/runtime integration,而不是 `src/adapters/`
329
339
  - `Claude Code` 会安装 hooks 和共享 ExperienceEngine MCP 服务
330
- - `Codex` 会安装共享 ExperienceEngine MCP 服务
340
+ - `Codex` 会安装 Codex 原生 hooks 和共享 ExperienceEngine MCP 服务。`ee codex exec` 仍是确定性的非交互 fallback。
341
+ - Codex 的 `UserPromptSubmit` 保持同步,因为它负责 prompt-time experience injection。`PostToolUse` 和 `Stop` 默认排队后在后台处理。`PreToolUse` 默认不注册;只有同步 gating 实验需要时才设置 `EXPERIENCE_ENGINE_CODEX_PRETOOL_HOOK_ENABLED=1` 启用。
331
342
  - `ee install ...` 与 `ee doctor ...` 会在 `npm` / `pnpm` 使用非官方 registry 时给出提示,因为受管模型下载在 `https://registry.npmjs.org` 下最稳定
332
343
  - 成功执行 `ee install ...` 后,也会提醒冷启动预期:capture 会立刻开始,但 formal experience 一般需要在同一仓库里出现几次相似任务后才会形成
333
344
 
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod";
2
- import type { ExperienceNodeType, ExperienceState } from "../../types/domain.js";
2
+ import type { DeliveryState, ExperienceNodeType, ExperienceState, TaskType } from "../../types/domain.js";
3
+ import type { HygieneFindingType, HygieneSeverity } from "../../maintenance/experience-hygiene.js";
4
+ import type { ExportDraftRisk } from "../../maintenance/experience-export-drafts.js";
3
5
  export type CodexActionCategory = "inspect" | "state" | "admin" | "maintenance";
4
6
  export type CodexActionRiskLevel = "low" | "medium" | "high";
5
7
  export type CodexActionDefinition = {
@@ -29,6 +31,26 @@ type RegistryDeps = {
29
31
  nodeType: ExperienceNodeType;
30
32
  }) => Promise<unknown>;
31
33
  inspectLearningSummary: () => Promise<unknown>;
34
+ inspectReview: (args?: {
35
+ cwd?: string;
36
+ limit?: number;
37
+ }) => Promise<unknown>;
38
+ inspectHygiene: (args?: {
39
+ cwd?: string;
40
+ type?: HygieneFindingType;
41
+ severity?: HygieneSeverity;
42
+ limit?: number;
43
+ }) => Promise<unknown>;
44
+ inspectExportDrafts: (args?: {
45
+ cwd?: string;
46
+ nodeId?: string;
47
+ nodeType?: ExperienceNodeType;
48
+ taskFamily?: TaskType;
49
+ state?: ExperienceState;
50
+ deliveryState?: DeliveryState;
51
+ risk?: ExportDraftRisk;
52
+ limit?: number;
53
+ }) => Promise<unknown>;
32
54
  coolNode: (args: {
33
55
  nodeId: string;
34
56
  }) => Promise<unknown>;
@@ -208,6 +208,79 @@ export const createCodexActionRegistry = (deps) => {
208
208
  examplePayload: {},
209
209
  handler: async () => deps.interactionSurface.inspectLearningSummary()
210
210
  },
211
+ {
212
+ id: "inspect_operator_review",
213
+ title: "Inspect Operator Review",
214
+ summary: "Inspect the read-only operator review workflow across repo policy, hygiene, and export drafts, with drill-down references only.",
215
+ category: "inspect",
216
+ riskLevel: "low",
217
+ requiresConfirmation: false,
218
+ inputSchema: z.object({
219
+ cwd: z.string().min(1).optional(),
220
+ limit: z.number().int().positive().optional()
221
+ }),
222
+ examplePayload: { cwd: "/path/to/repo", limit: 5 },
223
+ handler: async ({ cwd, limit }) => deps.interactionSurface.inspectReview({
224
+ cwd: typeof cwd === "string" ? cwd : undefined,
225
+ limit: typeof limit === "number" ? limit : undefined
226
+ })
227
+ },
228
+ {
229
+ id: "inspect_experience_hygiene",
230
+ title: "Inspect Experience Hygiene",
231
+ summary: "Inspect read-only EE hygiene findings for stale, duplicate, conflicting, over-generalized, or drifted guidance.",
232
+ category: "inspect",
233
+ riskLevel: "low",
234
+ requiresConfirmation: false,
235
+ inputSchema: z.object({
236
+ type: z.enum([
237
+ "stale_experience",
238
+ "duplicate_guidance",
239
+ "conflicting_guidance",
240
+ "over_generalized_guidance",
241
+ "evidence_drift"
242
+ ]).optional(),
243
+ severity: z.enum(["high", "medium", "low"]).optional(),
244
+ cwd: z.string().min(1).optional(),
245
+ limit: z.number().int().positive().optional()
246
+ }),
247
+ examplePayload: { cwd: "/path/to/repo", severity: "high", limit: 10 },
248
+ handler: async ({ cwd, type, severity, limit }) => deps.interactionSurface.inspectHygiene({
249
+ cwd: typeof cwd === "string" ? cwd : undefined,
250
+ type: type,
251
+ severity: severity,
252
+ limit: typeof limit === "number" ? limit : undefined
253
+ })
254
+ },
255
+ {
256
+ id: "inspect_export_drafts",
257
+ title: "Inspect Export Drafts",
258
+ summary: "Inspect read-only review packages for guidance that may be exported outside local EE state.",
259
+ category: "inspect",
260
+ riskLevel: "low",
261
+ requiresConfirmation: false,
262
+ inputSchema: z.object({
263
+ cwd: z.string().min(1).optional(),
264
+ nodeId: z.string().min(1).optional(),
265
+ nodeType: z.enum(["strategy", "warning"]).optional(),
266
+ taskFamily: z.string().min(1).optional(),
267
+ state: z.enum(["candidate", "priority_candidate", "active", "cooling", "retired"]).optional(),
268
+ deliveryState: z.enum(["shadow_only", "conservative_only", "eligible", "quarantined"]).optional(),
269
+ risk: z.enum(["low", "medium", "high"]).optional(),
270
+ limit: z.number().int().positive().optional()
271
+ }),
272
+ examplePayload: { cwd: "/path/to/repo", state: "cooling", risk: "high", limit: 10 },
273
+ handler: async ({ cwd, nodeId, nodeType, taskFamily, state, deliveryState, risk, limit }) => deps.interactionSurface.inspectExportDrafts({
274
+ cwd: typeof cwd === "string" ? cwd : undefined,
275
+ nodeId: typeof nodeId === "string" ? nodeId : undefined,
276
+ nodeType: nodeType,
277
+ taskFamily: taskFamily,
278
+ state: state,
279
+ deliveryState: deliveryState,
280
+ risk: risk,
281
+ limit: typeof limit === "number" ? limit : undefined
282
+ })
283
+ },
211
284
  {
212
285
  id: "inspect_backup_inventory",
213
286
  title: "Inspect Backup Inventory",