@hmharness/evolution 0.14.27 → 0.18.15

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.
@@ -9,6 +9,11 @@ export interface Insight {
9
9
  /** P0 impact attribution: skills (incl. canaries) injected into this
10
10
  * session's system prompt - the join key for canary A/B comparison. */
11
11
  skillsInjected?: string[];
12
+ /** Plan C (2026-09-27): the workspace (project) this session ran in.
13
+ * Retrieval stays GLOBAL - a lesson learned in project A is reachable
14
+ * from project B - but the origin is stamped on the injected line so
15
+ * the model can weigh "same tooling, different codebase" advice. */
16
+ workspace?: string;
12
17
  }
13
18
  export declare function redactSecrets(text: string): string;
14
19
  export declare function recordInsight(home: string, insight: Insight): Promise<void>;
@@ -38,4 +43,5 @@ export declare const INSIGHT_SIM_FLOOR = 0.05;
38
43
  export declare function retrieveInsights(home: string, task: string, opts?: {
39
44
  topK?: number;
40
45
  pool?: number;
46
+ workspace?: string;
41
47
  }): Promise<string>;
package/dist/insights.js CHANGED
@@ -114,8 +114,12 @@ export function jaccard(a, b) {
114
114
  inter++;
115
115
  return inter / (a.size + b.size - inter);
116
116
  }
117
- function formatInsight(i) {
118
- return `- [${i.outcome}] ${i.task.slice(0, 60)} (turns ${i.turns}, tools ${i.toolsUsed.join(',') || 'none'})`;
117
+ function formatInsight(i, currentWorkspace) {
118
+ // cross-project origin stamp (plan C): lessons from ANOTHER project are
119
+ // still injected (global retrieval) but labelled, so the model knows the
120
+ // tooling lesson may not carry the codebase specifics with it
121
+ const from = i.workspace && currentWorkspace && i.workspace !== currentWorkspace ? ` [来自项目:${i.workspace}]` : '';
122
+ return `- [${i.outcome}] ${i.task.slice(0, 60)} (turns ${i.turns}, tools ${i.toolsUsed.join(',') || 'none'})${from}`;
119
123
  }
120
124
  /** Noise floor: below this similarity an insight is unrelated to the task.
121
125
  * With per-word bigrams the highest unrelated natural-language pairs score
@@ -150,7 +154,7 @@ export async function retrieveInsights(home, task, opts = {}) {
150
154
  return '';
151
155
  const q = bigrams(task);
152
156
  if (q.size === 0)
153
- return rows.slice(-topK).map(formatInsight).join('\n');
157
+ return rows.slice(-topK).map((r) => formatInsight(r, opts.workspace)).join('\n');
154
158
  // newest first within the pool, so idx IS the recency rank
155
159
  const newestFirst = [...rows].reverse();
156
160
  const scored = newestFirst
@@ -160,6 +164,6 @@ export async function retrieveInsights(home, task, opts = {}) {
160
164
  .slice(0, topK)
161
165
  .map((x) => x.r);
162
166
  if (scored.length === 0)
163
- return rows.slice(-topK).map(formatInsight).join('\n');
164
- return scored.map(formatInsight).join('\n');
167
+ return rows.slice(-topK).map((r) => formatInsight(r, opts.workspace)).join('\n');
168
+ return scored.map((r) => formatInsight(r, opts.workspace)).join('\n');
165
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/evolution",
3
- "version": "0.14.27",
3
+ "version": "0.18.15",
4
4
  "description": "hmharness evolution subsystem: persistent memory, insight capture, skill library, and the bench that gives evolution its fitness signal. First-class kernel citizen, not a plugin.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "build": "tsc -p tsconfig.build.json"
16
16
  },
17
17
  "dependencies": {
18
- "@hmharness/kernel": "*"
18
+ "@hmharness/kernel": "0.18.15"
19
19
  },
20
20
  "files": [
21
21
  "dist"