@hmharness/evolution 0.14.9 → 0.14.10

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 (40) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/reward-model.d.ts +62 -0
  4. package/dist/reward-model.js +184 -0
  5. package/package.json +1 -1
  6. package/dist/bench.d.ts.v2bak.v2bak +0 -44
  7. package/dist/bench.js.v2bak.v2bak +0 -156
  8. package/dist/candidates.d.ts.v2bak.v2bak +0 -114
  9. package/dist/candidates.js.v2bak.v2bak +0 -232
  10. package/dist/dataset.d.ts.v2bak.v2bak +0 -64
  11. package/dist/dataset.js.v2bak.v2bak +0 -184
  12. package/dist/evolve.d.ts.v2bak.v2bak +0 -98
  13. package/dist/evolve.js.v2bak.v2bak +0 -573
  14. package/dist/impact.d.ts.v2bak.v2bak +0 -77
  15. package/dist/impact.js.v2bak.v2bak +0 -214
  16. package/dist/index.d.ts.v2bak.v2bak +0 -16
  17. package/dist/index.js.v2bak.v2bak +0 -16
  18. package/dist/insights.d.ts.v2bak.v2bak +0 -18
  19. package/dist/insights.js.v2bak.v2bak +0 -80
  20. package/dist/knowledge.d.ts.v2bak.v2bak +0 -15
  21. package/dist/knowledge.js.v2bak.v2bak +0 -145
  22. package/dist/labels.d.ts.v2bak.v2bak +0 -20
  23. package/dist/labels.js.v2bak.v2bak +0 -57
  24. package/dist/memory.d.ts.v2bak.v2bak +0 -32
  25. package/dist/memory.js.v2bak.v2bak +0 -233
  26. package/dist/patches.d.ts.v2bak.v2bak +0 -83
  27. package/dist/patches.js.v2bak.v2bak +0 -253
  28. package/dist/radar.d.ts.v2bak.v2bak +0 -3
  29. package/dist/radar.js.v2bak.v2bak +0 -40
  30. package/dist/ranker.d.ts.v2bak.v2bak +0 -44
  31. package/dist/ranker.js.v2bak.v2bak +0 -55
  32. package/dist/readiness.d.ts.v2bak.v2bak +0 -15
  33. package/dist/readiness.js.v2bak.v2bak +0 -167
  34. package/dist/skillpayload.d.ts.v2bak.v2bak +0 -1
  35. package/dist/skillpayload.js.v2bak +0 -28
  36. package/dist/skillpayload.js.v2bak.v2bak.v2bak +0 -28
  37. package/dist/skills.d.ts.v2bak.v2bak +0 -54
  38. package/dist/skills.js.v2bak.v2bak +0 -321
  39. package/dist/workflows.d.ts.v2bak.v2bak +0 -28
  40. package/dist/workflows.js.v2bak.v2bak +0 -84
@@ -1,28 +0,0 @@
1
- /**
2
- * @hmharness/evolution - workflows (AWM: Agent Workflow Memory, arxiv 2409.07429)
3
- * Verified lesson from the paper: inducing commonly REUSED routines from
4
- * past task trajectories and injecting them on demand beats stacking raw
5
- * trajectories or per-mistake notes. Here the "repeated trajectory" signal
6
- * is insight clustering: the same task archetype occurring 3+ times
7
- * triggers one meta-model call that distills a PARAMETERIZED workflow
8
- * template ({{placeholders}}), which then flows through the EXISTING
9
- * draft -> poison-screen -> bench-gate pipeline. No new gate is opened -
10
- * a workflow is just a skill with a shape.
11
- */
12
- import { type ProviderConfig } from '@hmharness/kernel';
13
- import { type SkillProposal } from './evolve.ts';
14
- export interface WorkflowCluster {
15
- key: string;
16
- tasks: string[];
17
- outcomes: string[];
18
- }
19
- /** Find task archetypes that occurred >= minRepeat times in the recent
20
- * insight history - the AWM reuse signal. */
21
- export declare function findWorkflowClusters(home: string, minRepeat?: number, lookback?: number): Promise<WorkflowCluster[]>;
22
- /** Induce a parameterized workflow proposal from a cluster (one meta-model
23
- * call; falls back to null on any refusal/parse failure/poison hit). */
24
- export declare function induceWorkflow(provider: ProviderConfig, cluster: WorkflowCluster): Promise<SkillProposal | null>;
25
- /** The full AWM step for one evolution cycle: find fresh clusters and
26
- * induce at most one workflow proposal (budget-conscious; the existing
27
- * gate pipeline does the actual accept/reject). */
28
- export declare function workflowProposals(provider: ProviderConfig, home: string, say: (l: string) => void): Promise<SkillProposal[]>;
@@ -1,84 +0,0 @@
1
- /**
2
- * @hmharness/evolution - workflows (AWM: Agent Workflow Memory, arxiv 2409.07429)
3
- * Verified lesson from the paper: inducing commonly REUSED routines from
4
- * past task trajectories and injecting them on demand beats stacking raw
5
- * trajectories or per-mistake notes. Here the "repeated trajectory" signal
6
- * is insight clustering: the same task archetype occurring 3+ times
7
- * triggers one meta-model call that distills a PARAMETERIZED workflow
8
- * template ({{placeholders}}), which then flows through the EXISTING
9
- * draft -> poison-screen -> bench-gate pipeline. No new gate is opened -
10
- * a workflow is just a skill with a shape.
11
- */
12
- import { chat } from '@hmharness/kernel';
13
- import { readInsights } from "./insights.js";
14
- import { screenForPoison } from "./evolve.js";
15
- /** Cluster insights by task archetype: normalized prefix (first ~24 chars,
16
- * alphanumerics lowercased) groups "fix build error in module X" tasks. */
17
- function archetypeKey(task) {
18
- const norm = task.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff ]+/g, ' ').replace(/\s+/g, ' ').trim();
19
- return norm.split(' ').slice(0, 6).join(' ').slice(0, 32) || norm.slice(0, 24);
20
- }
21
- /** Find task archetypes that occurred >= minRepeat times in the recent
22
- * insight history - the AWM reuse signal. */
23
- export async function findWorkflowClusters(home, minRepeat = 3, lookback = 120) {
24
- const insights = await readInsights(home, lookback);
25
- const groups = new Map();
26
- for (const i of insights) {
27
- const key = archetypeKey(i.task);
28
- const g = groups.get(key) ?? { key, tasks: [], outcomes: [] };
29
- g.tasks.push(i.task.slice(0, 100));
30
- g.outcomes.push(i.outcome);
31
- groups.set(key, g);
32
- }
33
- return [...groups.values()].filter((g) => g.tasks.length >= minRepeat);
34
- }
35
- /** Induce a parameterized workflow proposal from a cluster (one meta-model
36
- * call; falls back to null on any refusal/parse failure/poison hit). */
37
- export async function induceWorkflow(provider, cluster) {
38
- const system = [
39
- 'You induce reusable workflow templates for a coding agent, from repeated task instances (Agent Workflow Memory).',
40
- 'Output ONE skill in the standard format. The body must be a parameterized routine: use {{placeholders}} for the varying parts (module names, error strings, targets) so the agent fills them per task.',
41
- 'Rules: name is kebab-case ending in "-workflow"; description is one line starting with the trigger condition ("when ..."); skill_md max 50 lines, concrete steps with real commands; no security/approval topics.',
42
- 'If the instances do not actually share a reusable routine, output exactly: NONE',
43
- 'Respond with ONLY JSON: {"name":"...","description":"...","skill_md":"..."} - no prose, no fences.',
44
- ].join('\n');
45
- const user = `Task archetype "${cluster.key}" occurred ${cluster.tasks.length}x:\n${cluster.tasks.map((t) => `- ${t}`).join('\n')}\n\nInduce the parameterized workflow.`;
46
- try {
47
- const r = await chat(provider, [
48
- { role: 'system', content: system },
49
- { role: 'user', content: user },
50
- ]);
51
- const raw = (r.message.content ?? '').trim();
52
- if (!raw || raw === 'NONE')
53
- return null;
54
- const m = raw.match(/\{[\s\S]*\}/);
55
- if (!m)
56
- return null;
57
- const o = JSON.parse(m[0]);
58
- if (typeof o.name !== 'string' || typeof o.skill_md !== 'string' || !o.name || !o.skill_md)
59
- return null;
60
- if (screenForPoison(o.skill_md))
61
- return null;
62
- return { name: o.name, description: o.description ?? '', skill_md: o.skill_md };
63
- }
64
- catch {
65
- return null;
66
- }
67
- }
68
- /** The full AWM step for one evolution cycle: find fresh clusters and
69
- * induce at most one workflow proposal (budget-conscious; the existing
70
- * gate pipeline does the actual accept/reject). */
71
- export async function workflowProposals(provider, home, say) {
72
- const clusters = await findWorkflowClusters(home, 3, 120);
73
- if (clusters.length === 0)
74
- return [];
75
- // already-proposed archetypes (by name convention <arch>-workflow) need no re-run
76
- say(`awm: ${clusters.length} repeated task archetype(s)`);
77
- const cluster = clusters.sort((a, b) => b.tasks.length - a.tasks.length)[0];
78
- const p = await induceWorkflow(provider, cluster);
79
- if (!p) {
80
- say('awm: no reusable routine induced');
81
- return [];
82
- }
83
- return [p];
84
- }