darwin-agents 0.9.0 → 0.10.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.
- package/CHANGELOG.md +51 -0
- package/README.md +48 -0
- package/dist/src/cli/evolution-flags.d.ts +2 -0
- package/dist/src/cli/evolution-flags.d.ts.map +1 -1
- package/dist/src/cli/evolution-flags.js +36 -1
- package/dist/src/cli/evolution-flags.js.map +1 -1
- package/dist/src/cli/evolve.d.ts +2 -0
- package/dist/src/cli/evolve.d.ts.map +1 -1
- package/dist/src/cli/evolve.js +10 -0
- package/dist/src/cli/evolve.js.map +1 -1
- package/dist/src/cli/index.js +2 -0
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/evolution/demos.d.ts +128 -0
- package/dist/src/evolution/demos.d.ts.map +1 -0
- package/dist/src/evolution/demos.js +196 -0
- package/dist/src/evolution/demos.js.map +1 -0
- package/dist/src/evolution/enabled-state.d.ts +5 -5
- package/dist/src/evolution/enabled-state.d.ts.map +1 -1
- package/dist/src/evolution/enabled-state.js +10 -5
- package/dist/src/evolution/enabled-state.js.map +1 -1
- package/dist/src/evolution/loop.d.ts +36 -0
- package/dist/src/evolution/loop.d.ts.map +1 -1
- package/dist/src/evolution/loop.js +118 -19
- package/dist/src/evolution/loop.js.map +1 -1
- package/dist/src/evolution/selection.d.ts +73 -0
- package/dist/src/evolution/selection.d.ts.map +1 -0
- package/dist/src/evolution/selection.js +121 -0
- package/dist/src/evolution/selection.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +67 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.10.0] — 2026-07-03
|
|
6
|
+
|
|
7
|
+
Two research-driven, opt-in evolution surfaces — a new challenger *source*
|
|
8
|
+
(demo injection) and a new parent-*selection* strategy for the existing
|
|
9
|
+
reflective challenger — both validated against the current state of the field
|
|
10
|
+
(GEPA upstream docs, DSPy SIMBA) before a line was written. Default behaviour
|
|
11
|
+
is byte-for-byte unchanged with the flags off.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **SIMBA-style demo injection** (`src/evolution/demos.ts` + `evolution.useDemos`).
|
|
16
|
+
DSPy's SIMBA optimizer improves programs two ways: appending self-reflective
|
|
17
|
+
*rules* (Darwin's reflector already covers that ground) and appending
|
|
18
|
+
successful past examples as *demonstrations*. This release adapts the second
|
|
19
|
+
strategy to the online loop: on every `demoEveryK`-th evolution cycle (default
|
|
20
|
+
4) the loop harvests the agent's own highest-scoring past runs (score ≥
|
|
21
|
+
`demoScoreThreshold`, default 8; at most one demo per task type for
|
|
22
|
+
diversity; `maxDemos` cap, default 2) and appends them as a marker-delimited
|
|
23
|
+
"Demonstrations" section. The demo-augmented prompt is a normal challenger —
|
|
24
|
+
same alignment guard, same A/B test, same safety gate; if demos don't help
|
|
25
|
+
this agent, the incumbent wins. **Zero LLM cost** (pure selection +
|
|
26
|
+
rendering on data Darwin already persists), works with or without `useGepa`,
|
|
27
|
+
idempotent via `<!-- darwin:demos:start/end -->` markers (a later cycle
|
|
28
|
+
*refreshes* the section, never stacks a second one). Pure helpers
|
|
29
|
+
(`selectDemoCandidates` / `buildDemoSection` / `applyDemoSection` /
|
|
30
|
+
`stripDemoSection`) are exported from the package root. CLI: `--demos` /
|
|
31
|
+
`--no-demos`.
|
|
32
|
+
|
|
33
|
+
- **Parent-selection strategies** (`src/evolution/selection.ts` +
|
|
34
|
+
`evolution.candidateSelection`) — GEPA `candidate_selection_strategy` parity
|
|
35
|
+
for the online loop. Historically the loop always reflected from the
|
|
36
|
+
currently-active prompt (a hill-climb that can sit on a local optimum).
|
|
37
|
+
Opt-in strategies pick the reflection parent from the agent's *scored
|
|
38
|
+
version history* instead: `'best'` (GEPA `current_best` — highest
|
|
39
|
+
scalarised composite), `'pareto'` (GEPA default — uniform sample from the
|
|
40
|
+
non-dominated front, keeping lineages alive that win on different
|
|
41
|
+
objectives), `'epsilon-greedy'` (explore with probability
|
|
42
|
+
`explorationEpsilon`, default 0.1, exploit otherwise). The RNG is
|
|
43
|
+
injectable via the new `DarwinLoopDeps.rng` for deterministic tests.
|
|
44
|
+
Precedence: `useCoverage` (GEPA Algorithm 2, the more specific selector)
|
|
45
|
+
wins when it finds a coverage parent. Only consulted when `useGepa` is on.
|
|
46
|
+
CLI: `--candidate-selection <active|best|pareto|epsilon-greedy>`.
|
|
47
|
+
|
|
48
|
+
### Internal
|
|
49
|
+
|
|
50
|
+
- `tryMergeVariant`'s version-history scoring extracted into a shared
|
|
51
|
+
`buildScoredHistory` (used by merge *and* parent selection) — behaviour
|
|
52
|
+
unchanged.
|
|
53
|
+
- `package.json` now lists Claude (Anthropic) as a contributor — see the
|
|
54
|
+
README's new **Credits** section for how this project is actually built.
|
|
55
|
+
|
|
5
56
|
## [0.9.0] — 2026-06-21
|
|
6
57
|
|
|
7
58
|
### Added
|
package/README.md
CHANGED
|
@@ -222,6 +222,39 @@ bias. With only one key they collapse onto a single family (note: `claude-cli`
|
|
|
222
222
|
and `anthropic-api` are the *same* family) — Darwin now warns, and hard-fails
|
|
223
223
|
under `DARWIN_REQUIRE_CROSS_FAMILY=1` for strict / CI setups.
|
|
224
224
|
|
|
225
|
+
### Demo injection + parent selection (v0.10, opt-in)
|
|
226
|
+
|
|
227
|
+
Two more challenger surfaces, both borrowed from the strongest ideas in the
|
|
228
|
+
field and adapted to the online loop. Both are off by default.
|
|
229
|
+
|
|
230
|
+
**Demo injection** (`useDemos`) is DSPy SIMBA's `append_a_demo` strategy: on
|
|
231
|
+
every `demoEveryK`-th cycle (default 4) the loop harvests the agent's *own
|
|
232
|
+
highest-scoring past runs* (score ≥ 8, one per task type, capped at
|
|
233
|
+
`maxDemos`) and appends them to the prompt as a marker-delimited
|
|
234
|
+
"Demonstrations" section. Zero LLM cost — pure selection over data Darwin
|
|
235
|
+
already stores — and the demo-augmented prompt is a normal challenger: same
|
|
236
|
+
alignment guard, same A/B test, same rollback. If showing the agent its own
|
|
237
|
+
best work doesn't measurably help, the incumbent wins and nothing changes.
|
|
238
|
+
|
|
239
|
+
**Parent selection** (`candidateSelection`) is GEPA's
|
|
240
|
+
`candidate_selection_strategy`: instead of always mutating the currently-active
|
|
241
|
+
prompt (a hill-climb), reflect from `'best'` (highest composite in the version
|
|
242
|
+
history), `'pareto'` (uniform sample from the history's Pareto front — keeps
|
|
243
|
+
lineages alive that win on *different* objectives), or `'epsilon-greedy'`
|
|
244
|
+
(explore with probability `explorationEpsilon`). Requires `useGepa`.
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
evolution: {
|
|
248
|
+
enabled: true,
|
|
249
|
+
useDemos: true, // SIMBA-style demos as a challenger source
|
|
250
|
+
demoEveryK: 4, // cadence (offset from mergeEveryK: 3)
|
|
251
|
+
maxDemos: 2,
|
|
252
|
+
useGepa: true,
|
|
253
|
+
candidateSelection: 'pareto', // or 'best' | 'epsilon-greedy' | 'active'
|
|
254
|
+
explorationEpsilon: 0.1, // only for 'epsilon-greedy'
|
|
255
|
+
},
|
|
256
|
+
```
|
|
257
|
+
|
|
225
258
|
## Built-in Agents
|
|
226
259
|
|
|
227
260
|
| Agent | What it does | Needs |
|
|
@@ -465,6 +498,8 @@ darwin run writer "Explain consensus" --gepa --pareto-gate
|
|
|
465
498
|
| `--pareto-gate` / `--no-pareto-gate` | Reject an A/B winner that regressed on any objective |
|
|
466
499
|
| `--coverage` / `--no-coverage` | Pick the reflection parent by per-task-type coverage breadth (GEPA Algorithm 2) |
|
|
467
500
|
| `--reflection-model <id>` | Use a stronger model for GEPA reflection (the documented leverage point) |
|
|
501
|
+
| `--demos` / `--no-demos` | SIMBA-style demo injection: the agent's best past runs as a challenger (v0.10) |
|
|
502
|
+
| `--candidate-selection <s>` | Reflection parent strategy: `active` \| `best` \| `pareto` \| `epsilon-greedy` (v0.10) |
|
|
468
503
|
|
|
469
504
|
All default to **off** — the baseline single-objective evolution loop is
|
|
470
505
|
unchanged unless you opt in.
|
|
@@ -526,6 +561,19 @@ The safety gate prevents regressions. If a new variant scores >20% lower, Darwin
|
|
|
526
561
|
|
|
527
562
|
PRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
528
563
|
|
|
564
|
+
## Credits
|
|
565
|
+
|
|
566
|
+
Darwin is pair-built by a human and an AI, and we think that should be said
|
|
567
|
+
plainly rather than hidden. Matthias Meyer (StudioMeyer) sets direction, makes
|
|
568
|
+
the calls and reviews everything; most of the code is written by
|
|
569
|
+
[Claude](https://www.anthropic.com/claude) — currently **Claude Fable 5** —
|
|
570
|
+
working from research against the primary sources (the GEPA paper and
|
|
571
|
+
reference implementation, DSPy, the MCP spec) and gated by multi-agent code
|
|
572
|
+
review plus this repo's own test suite before anything ships. Claude is listed
|
|
573
|
+
as a contributor in `package.json`, and the commits it co-writes carry a
|
|
574
|
+
`Co-Authored-By` trailer. A framework about agents that improve themselves,
|
|
575
|
+
built with an agent — we find that fitting.
|
|
576
|
+
|
|
529
577
|
## About StudioMeyer
|
|
530
578
|
|
|
531
579
|
[StudioMeyer](https://studiomeyer.io) is an AI and design studio based in Palma de Mallorca, working with clients worldwide. We build custom websites and AI infrastructure for small and medium businesses. Production stack on Claude Agent SDK, MCP and n8n, with Sentry, Langfuse and LangGraph for observability and an in-house guard layer.
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* --pareto-gate / --no-pareto-gate
|
|
13
13
|
* --coverage / --no-coverage
|
|
14
14
|
* --reflection-model <model-id>
|
|
15
|
+
* --demos / --no-demos (v0.10.0)
|
|
16
|
+
* --candidate-selection <active|best|pareto|epsilon-greedy> (v0.10.0)
|
|
15
17
|
*/
|
|
16
18
|
import type { EvolutionConfigOverride } from '../types.js';
|
|
17
19
|
/** True when `arg` is one of the evolution-config flags this module handles. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evolution-flags.d.ts","sourceRoot":"","sources":["../../../src/cli/evolution-flags.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"evolution-flags.d.ts","sourceRoot":"","sources":["../../../src/cli/evolution-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAU3D,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAkB1D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,uBAAuB,GAC9B,MAAM,CAyDR;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IACzD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAaA;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAU9E"}
|
|
@@ -12,7 +12,16 @@
|
|
|
12
12
|
* --pareto-gate / --no-pareto-gate
|
|
13
13
|
* --coverage / --no-coverage
|
|
14
14
|
* --reflection-model <model-id>
|
|
15
|
+
* --demos / --no-demos (v0.10.0)
|
|
16
|
+
* --candidate-selection <active|best|pareto|epsilon-greedy> (v0.10.0)
|
|
15
17
|
*/
|
|
18
|
+
/** Valid values for `--candidate-selection` (v0.10.0). */
|
|
19
|
+
const CANDIDATE_SELECTION_VALUES = new Set([
|
|
20
|
+
'active',
|
|
21
|
+
'best',
|
|
22
|
+
'pareto',
|
|
23
|
+
'epsilon-greedy',
|
|
24
|
+
]);
|
|
16
25
|
/** True when `arg` is one of the evolution-config flags this module handles. */
|
|
17
26
|
export function isEvolutionConfigFlag(arg) {
|
|
18
27
|
switch (arg) {
|
|
@@ -25,6 +34,9 @@ export function isEvolutionConfigFlag(arg) {
|
|
|
25
34
|
case '--coverage':
|
|
26
35
|
case '--no-coverage':
|
|
27
36
|
case '--reflection-model':
|
|
37
|
+
case '--demos':
|
|
38
|
+
case '--no-demos':
|
|
39
|
+
case '--candidate-selection':
|
|
28
40
|
return true;
|
|
29
41
|
default:
|
|
30
42
|
return false;
|
|
@@ -70,6 +82,27 @@ export function applyEvolutionFlag(arg, nextArg, target) {
|
|
|
70
82
|
return 1;
|
|
71
83
|
}
|
|
72
84
|
return 0;
|
|
85
|
+
case '--demos':
|
|
86
|
+
target.useDemos = true;
|
|
87
|
+
return 0;
|
|
88
|
+
case '--no-demos':
|
|
89
|
+
target.useDemos = false;
|
|
90
|
+
return 0;
|
|
91
|
+
case '--candidate-selection':
|
|
92
|
+
// Value is consumed either way (it was clearly meant as this flag's
|
|
93
|
+
// argument); it is only APPLIED when it names a known strategy — an
|
|
94
|
+
// unknown value warns instead of silently persisting a config the loop
|
|
95
|
+
// would then silently treat as 'active'.
|
|
96
|
+
if (nextArg !== undefined) {
|
|
97
|
+
if (CANDIDATE_SELECTION_VALUES.has(nextArg)) {
|
|
98
|
+
target.candidateSelection = nextArg;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.warn(`[darwin] --candidate-selection "${nextArg}" is not one of: ${[...CANDIDATE_SELECTION_VALUES].join(', ')} — ignored.`);
|
|
102
|
+
}
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
return 0;
|
|
73
106
|
default:
|
|
74
107
|
return 0;
|
|
75
108
|
}
|
|
@@ -101,6 +134,8 @@ export function hasAnyEvolutionFlag(override) {
|
|
|
101
134
|
override.useMerge !== undefined ||
|
|
102
135
|
override.paretoGate !== undefined ||
|
|
103
136
|
override.useCoverage !== undefined ||
|
|
104
|
-
override.reflectionModel !== undefined
|
|
137
|
+
override.reflectionModel !== undefined ||
|
|
138
|
+
override.useDemos !== undefined ||
|
|
139
|
+
override.candidateSelection !== undefined);
|
|
105
140
|
}
|
|
106
141
|
//# sourceMappingURL=evolution-flags.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evolution-flags.js","sourceRoot":"","sources":["../../../src/cli/evolution-flags.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"evolution-flags.js","sourceRoot":"","sources":["../../../src/cli/evolution-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,0DAA0D;AAC1D,MAAM,0BAA0B,GAAwB,IAAI,GAAG,CAAC;IAC9D,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,gBAAgB;CACjB,CAAC,CAAC;AAEH,gFAAgF;AAChF,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB,KAAK,SAAS,CAAC;QACf,KAAK,YAAY,CAAC;QAClB,KAAK,eAAe,CAAC;QACrB,KAAK,kBAAkB,CAAC;QACxB,KAAK,YAAY,CAAC;QAClB,KAAK,eAAe,CAAC;QACrB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,SAAS,CAAC;QACf,KAAK,YAAY,CAAC;QAClB,KAAK,uBAAuB;YAC1B,OAAO,IAAI,CAAC;QACd;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAW,EACX,OAA2B,EAC3B,MAA+B;IAE/B,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,QAAQ;YACX,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;YACtB,OAAO,CAAC,CAAC;QACX,KAAK,WAAW;YACd,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC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A/B activation gate
|
|
18
18
|
* --coverage / --no-coverage instance-wise coverage selection
|
|
19
19
|
* --reflection-model <id> stronger reflection model for GEPA
|
|
20
|
+
* --demos / --no-demos SIMBA-style demo injection (v0.10)
|
|
21
|
+
* --candidate-selection <s> reflection parent: active|best|pareto|epsilon-greedy
|
|
20
22
|
*/
|
|
21
23
|
export declare function evolveCommand(args: string[]): Promise<void>;
|
|
22
24
|
//# sourceMappingURL=evolve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evolve.d.ts","sourceRoot":"","sources":["../../../src/cli/evolve.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"evolve.d.ts","sourceRoot":"","sources":["../../../src/cli/evolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAeH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkGjE"}
|
package/dist/src/cli/evolve.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* --pareto-gate / --no-pareto-gate multi-objective A/B activation gate
|
|
18
18
|
* --coverage / --no-coverage instance-wise coverage selection
|
|
19
19
|
* --reflection-model <id> stronger reflection model for GEPA
|
|
20
|
+
* --demos / --no-demos SIMBA-style demo injection (v0.10)
|
|
21
|
+
* --candidate-selection <s> reflection parent: active|best|pareto|epsilon-greedy
|
|
20
22
|
*/
|
|
21
23
|
import { createMemory } from '../memory/index.js';
|
|
22
24
|
import { loadConfig } from '../core/agent.js';
|
|
@@ -135,6 +137,10 @@ function describeOverride(o) {
|
|
|
135
137
|
parts.push(`coverage=${o.useCoverage}`);
|
|
136
138
|
if (o.reflectionModel !== undefined)
|
|
137
139
|
parts.push(`reflectionModel=${o.reflectionModel}`);
|
|
140
|
+
if (o.useDemos !== undefined)
|
|
141
|
+
parts.push(`demos=${o.useDemos}`);
|
|
142
|
+
if (o.candidateSelection !== undefined)
|
|
143
|
+
parts.push(`candidateSelection=${o.candidateSelection}`);
|
|
138
144
|
return parts.length > 0 ? parts.join(', ') : '(none)';
|
|
139
145
|
}
|
|
140
146
|
/** One-line summary of the effective advanced config for the status view. */
|
|
@@ -146,9 +152,13 @@ function describeConfig(evo) {
|
|
|
146
152
|
`merge=${evo.useMerge ?? false}`,
|
|
147
153
|
`paretoGate=${evo.paretoGate ?? false}`,
|
|
148
154
|
`coverage=${evo.useCoverage ?? false}`,
|
|
155
|
+
`demos=${evo.useDemos ?? false}`,
|
|
149
156
|
];
|
|
150
157
|
if (evo.reflectionModel)
|
|
151
158
|
parts.push(`reflectionModel=${evo.reflectionModel}`);
|
|
159
|
+
if (evo.candidateSelection && evo.candidateSelection !== 'active') {
|
|
160
|
+
parts.push(`candidateSelection=${evo.candidateSelection}`);
|
|
161
|
+
}
|
|
152
162
|
return parts.join(', ');
|
|
153
163
|
}
|
|
154
164
|
//# sourceMappingURL=evolve.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evolve.js","sourceRoot":"","sources":["../../../src/cli/evolve.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"evolve.js","sourceRoot":"","sources":["../../../src/cli/evolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGtF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc;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AAG,CAAC,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAClE,KAAK,CAAC,IAAI,CAAC,sBAAsB,GAAG,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/src/cli/index.js
CHANGED
|
@@ -59,6 +59,8 @@ const HELP = `
|
|
|
59
59
|
--pareto-gate / --no-pareto-gate multi-objective A/B activation gate
|
|
60
60
|
--coverage / --no-coverage instance-wise coverage selection
|
|
61
61
|
--reflection-model <id> stronger reflection model for GEPA
|
|
62
|
+
--demos / --no-demos SIMBA-style demo injection (v0.10)
|
|
63
|
+
--candidate-selection <s> reflection parent: active|best|pareto|epsilon-greedy
|
|
62
64
|
`;
|
|
63
65
|
async function main() {
|
|
64
66
|
const args = process.argv.slice(2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,IAAI,GAAG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO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AW,EAAE,CAAC;gBACpB,MAAM;YACR;gBACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;gBAC7C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,qBAAsB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Demo injection (v0.10.0) — SIMBA-style "append a demo" challenger source.
|
|
3
|
+
*
|
|
4
|
+
* DSPy's SIMBA optimizer (Stochastic Introspective Mini-Batch Ascent) improves
|
|
5
|
+
* programs through two complementary strategies: appending self-reflective
|
|
6
|
+
* RULES (Darwin's reflector already covers that ground) and appending
|
|
7
|
+
* successful past examples as DEMONSTRATIONS. This module is Darwin's
|
|
8
|
+
* adaptation of the second strategy to the online evolution loop:
|
|
9
|
+
*
|
|
10
|
+
* 1. Harvest the agent's own highest-scoring past runs from memory
|
|
11
|
+
* (score ≥ threshold, successful, non-trivial output).
|
|
12
|
+
* 2. Prefer diversity: at most one demo per task type, best-scoring first.
|
|
13
|
+
* 3. Render them as a clearly-delimited "Demonstrations" section and
|
|
14
|
+
* append it to (or refresh it inside) the current prompt.
|
|
15
|
+
*
|
|
16
|
+
* The demo-augmented prompt is a CHALLENGER like any other — it goes through
|
|
17
|
+
* the same alignment guard, the same A/B test, and the same safety gate as a
|
|
18
|
+
* reflective or merged mutation. If demos don't actually help this agent, the
|
|
19
|
+
* incumbent wins and nothing changes.
|
|
20
|
+
*
|
|
21
|
+
* Design notes:
|
|
22
|
+
* - Zero LLM cost. Selection and rendering are pure string/array work on
|
|
23
|
+
* data Darwin already persists (task, output, score, taskType). This makes
|
|
24
|
+
* demos the cheapest challenger source in the loop.
|
|
25
|
+
* - Idempotent via markers. The section is wrapped in
|
|
26
|
+
* `<!-- darwin:demos:start/end -->` comments so a later demo cycle
|
|
27
|
+
* REPLACES the previous section instead of stacking a second one, and
|
|
28
|
+
* {@link stripDemoSection} can remove it cleanly.
|
|
29
|
+
* - Demo text comes from the agent's OWN prior outputs (already produced
|
|
30
|
+
* under this prompt lineage), not from an external input channel. Excerpts
|
|
31
|
+
* are length-capped and fenced, but callers embedding third-party data in
|
|
32
|
+
* tasks should be aware demos quote past tasks verbatim.
|
|
33
|
+
* - Determinism. Given the same experiment list and options, selection and
|
|
34
|
+
* rendering are fully deterministic (stable sort, no randomness) — the
|
|
35
|
+
* loop's no-op check ("would this produce the same prompt?") stays cheap.
|
|
36
|
+
*/
|
|
37
|
+
import type { DarwinExperiment } from "../types.js";
|
|
38
|
+
/** One harvested demonstration, ready for rendering. */
|
|
39
|
+
export interface DemoCandidate {
|
|
40
|
+
/** The task the agent was given. */
|
|
41
|
+
task: string;
|
|
42
|
+
/** The agent's (high-scoring) output. */
|
|
43
|
+
output: string;
|
|
44
|
+
/** Critic score (1-10) that qualified this run as a demo. */
|
|
45
|
+
score: number;
|
|
46
|
+
/** Task category the run was classified under. */
|
|
47
|
+
taskType: string;
|
|
48
|
+
}
|
|
49
|
+
/** Options for {@link selectDemoCandidates}. */
|
|
50
|
+
export interface DemoSelectionOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Maximum number of demos to keep (default {@link DEFAULT_MAX_DEMOS}).
|
|
53
|
+
* SIMBA defaults to 4 per predictor; Darwin defaults lower (2) because the
|
|
54
|
+
* online loop appends demos to a single system prompt and prompt length
|
|
55
|
+
* correlates NEGATIVELY with reliability (documented v2-prompt incident).
|
|
56
|
+
*/
|
|
57
|
+
maxDemos?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Minimum critic score for a run to qualify (default
|
|
60
|
+
* {@link DEFAULT_DEMO_SCORE_THRESHOLD}). Mirrors the closed-loop feedback
|
|
61
|
+
* convention where ≥ 8 marks a high-quality pattern.
|
|
62
|
+
*/
|
|
63
|
+
scoreThreshold?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Minimum output length (chars) for a run to qualify (default
|
|
66
|
+
* {@link DEFAULT_DEMO_MIN_OUTPUT_CHARS}). Filters out degenerate/truncated
|
|
67
|
+
* outputs that scored well on a technicality.
|
|
68
|
+
*/
|
|
69
|
+
minOutputChars?: number;
|
|
70
|
+
}
|
|
71
|
+
/** Options for {@link buildDemoSection}. */
|
|
72
|
+
export interface DemoRenderOptions {
|
|
73
|
+
/** Cap on the quoted task text, chars (default {@link DEFAULT_DEMO_TASK_CHARS}). */
|
|
74
|
+
maxTaskChars?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Cap on each quoted output excerpt, chars (default
|
|
77
|
+
* {@link DEFAULT_DEMO_OUTPUT_CHARS}). Truncation prefers a sentence/newline
|
|
78
|
+
* boundary, same policy as the reflector's output cleaning.
|
|
79
|
+
*/
|
|
80
|
+
maxOutputChars?: number;
|
|
81
|
+
}
|
|
82
|
+
export declare const DEFAULT_MAX_DEMOS = 2;
|
|
83
|
+
export declare const DEFAULT_DEMO_SCORE_THRESHOLD = 8;
|
|
84
|
+
export declare const DEFAULT_DEMO_MIN_OUTPUT_CHARS = 200;
|
|
85
|
+
export declare const DEFAULT_DEMO_TASK_CHARS = 240;
|
|
86
|
+
export declare const DEFAULT_DEMO_OUTPUT_CHARS = 900;
|
|
87
|
+
/** Start marker — everything between the markers is Darwin-managed. */
|
|
88
|
+
export declare const DEMO_SECTION_START = "<!-- darwin:demos:start -->";
|
|
89
|
+
/** End marker. */
|
|
90
|
+
export declare const DEMO_SECTION_END = "<!-- darwin:demos:end -->";
|
|
91
|
+
/**
|
|
92
|
+
* Harvest demo candidates from an agent's experiment history.
|
|
93
|
+
*
|
|
94
|
+
* Filter: successful runs with a critic score ≥ `scoreThreshold` and an
|
|
95
|
+
* output of at least `minOutputChars`. Diversity: at most ONE demo per task
|
|
96
|
+
* type (the best-scoring run of that type, recency as tie-break) so two demos
|
|
97
|
+
* never showcase the same narrow strength. Order: score descending, then
|
|
98
|
+
* most-recent first — fully deterministic.
|
|
99
|
+
*/
|
|
100
|
+
export declare function selectDemoCandidates(experiments: ReadonlyArray<DarwinExperiment>, options?: DemoSelectionOptions): DemoCandidate[];
|
|
101
|
+
/**
|
|
102
|
+
* Render demo candidates as a marker-delimited prompt section.
|
|
103
|
+
*
|
|
104
|
+
* Returns an empty string for an empty demo list so callers can treat
|
|
105
|
+
* "nothing to inject" uniformly.
|
|
106
|
+
*/
|
|
107
|
+
export declare function buildDemoSection(demos: ReadonlyArray<DemoCandidate>, options?: DemoRenderOptions): string;
|
|
108
|
+
/**
|
|
109
|
+
* Apply a rendered demo section to a prompt.
|
|
110
|
+
*
|
|
111
|
+
* If the prompt already contains a marker-delimited demo section it is
|
|
112
|
+
* REPLACED in place (demos stay fresh, never stack); otherwise the section is
|
|
113
|
+
* appended after a blank line. An empty `section` returns the prompt with any
|
|
114
|
+
* existing demo section stripped — passing "no demos" acts as removal.
|
|
115
|
+
*
|
|
116
|
+
* The replacement uses a FUNCTION replacer: with a string replacer,
|
|
117
|
+
* `$&` / `$'` / `` $` `` / `$$` inside the section (an agent output quoting
|
|
118
|
+
* JS-regex or shell docs contains exactly these) would be interpreted as
|
|
119
|
+
* replacement patterns and garble the prompt on every refresh cycle.
|
|
120
|
+
*/
|
|
121
|
+
export declare function applyDemoSection(prompt: string, section: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Remove the marker-delimited demo section (if any), collapsing the blank
|
|
124
|
+
* line that {@link applyDemoSection} inserted. Prompts without a section are
|
|
125
|
+
* returned unchanged.
|
|
126
|
+
*/
|
|
127
|
+
export declare function stripDemoSection(prompt: string): string;
|
|
128
|
+
//# sourceMappingURL=demos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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