darwin-agents 0.9.0 → 0.11.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 +105 -0
- package/README.md +87 -0
- package/dist/src/cli/evolution-flags.d.ts +4 -0
- package/dist/src/cli/evolution-flags.d.ts.map +1 -1
- package/dist/src/cli/evolution-flags.js +69 -1
- package/dist/src/cli/evolution-flags.js.map +1 -1
- package/dist/src/cli/evolve.d.ts +4 -0
- package/dist/src/cli/evolve.d.ts.map +1 -1
- package/dist/src/cli/evolve.js +21 -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 +17 -5
- package/dist/src/evolution/enabled-state.js.map +1 -1
- package/dist/src/evolution/feedback-filter.d.ts +54 -0
- package/dist/src/evolution/feedback-filter.d.ts.map +1 -0
- package/dist/src/evolution/feedback-filter.js +65 -0
- package/dist/src/evolution/feedback-filter.js.map +1 -0
- package/dist/src/evolution/loop.d.ts +70 -0
- package/dist/src/evolution/loop.d.ts.map +1 -1
- package/dist/src/evolution/loop.js +198 -20
- 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 +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +132 -6
- 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,111 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.11.0] — 2026-07-09
|
|
6
|
+
|
|
7
|
+
Two opt-in "budget discipline" knobs adapted from GEPA (verified against the
|
|
8
|
+
DSPy GEPA API and the gepa-ai engine source) to Darwin's forever-online loop.
|
|
9
|
+
The values mirror upstream's defaults; the mechanisms are Darwin's own
|
|
10
|
+
adaptation. Default behaviour is unchanged with the flags off.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`skipPerfectFeedback`** (adapted from GEPA's `skip_perfect_score`,
|
|
15
|
+
`src/evolution/feedback-filter.ts`). Upstream skips a whole reflection
|
|
16
|
+
iteration when an entire sampled minibatch is perfect; Darwin generalizes it
|
|
17
|
+
to per-report filtering, which it can afford because the critic scores on real
|
|
18
|
+
runs are already paid for. A run that already scored a perfect critic score
|
|
19
|
+
carries no improvement gradient — its "nothing to fix" report only dilutes the
|
|
20
|
+
pool. When `true`, such reports are dropped from **both** the legacy optimizer
|
|
21
|
+
feedback (`getRecentFeedback`) and the GEPA reflective feedback
|
|
22
|
+
(`getReflectiveFeedback`); skipped items do not count toward the feedback
|
|
23
|
+
window, so it fills with actionable reports. `perfectFeedbackScore` (default
|
|
24
|
+
10, the critic-scale max) sets the threshold — lower it to also skip
|
|
25
|
+
near-perfect runs. A non-finite score is never treated as perfect, so a
|
|
26
|
+
genuinely broken run still surfaces. If every recent run is perfect the
|
|
27
|
+
reflective path falls back to the legacy stats optimizer and the legacy path
|
|
28
|
+
proceeds on aggregate stats (so the loop keeps exploring). With `useDemos` on,
|
|
29
|
+
perfect runs are still used — harvested as demonstrations. CLI: `--skip-perfect`
|
|
30
|
+
/ `--no-skip-perfect`. Pure helpers (`isPerfectScore` /
|
|
31
|
+
`resolvePerfectFeedbackScore` / `filterPerfectFeedback`) are exported from the
|
|
32
|
+
package root.
|
|
33
|
+
- **`maxMergeInvocations`** (adapted from GEPA's `max_merge_invocations`, default
|
|
34
|
+
5 upstream). A per-agent **lifetime** cap on merge-derived challengers,
|
|
35
|
+
persisted in `DarwinState.mergeInvocations` (a process-scoped counter would
|
|
36
|
+
reset every cron tick and never trigger). The GEPA paper leaves merge-budget
|
|
37
|
+
allocation as open research; the reason Darwin needs a cap is its own — an
|
|
38
|
+
uncapped `mergeEveryK` cadence would merge forever and crowd out reflective
|
|
39
|
+
exploration late in an agent's life. The count is the number of merge
|
|
40
|
+
challengers actually **created** — a merge that fails the alignment guard is
|
|
41
|
+
not counted (it consumed no A/B slot) — and is written **only when a cap is
|
|
42
|
+
set**, so an uncapped `useMerge` agent's persisted state is unchanged from
|
|
43
|
+
v0.10. Once the cap is reached the merge branch is skipped and the loop falls
|
|
44
|
+
back to the reflective path for the rest of the agent's life (the budget does
|
|
45
|
+
not re-arm). Only consulted when `useMerge` is on. Left unset it is uncapped
|
|
46
|
+
(v0.10 behaviour); set it to `5` to match GEPA's default. CLI: `--max-merge <n>`
|
|
47
|
+
(non-negative integer; `0` disables merge).
|
|
48
|
+
|
|
49
|
+
### Notes
|
|
50
|
+
|
|
51
|
+
- Both knobs flow through the existing override machinery
|
|
52
|
+
(`EvolutionConfigOverride` + `OVERRIDE_KEYS` + `resolveEvolutionConfig` +
|
|
53
|
+
`describeOverride`/`describeConfig`), so they are CLI-settable, persist across
|
|
54
|
+
processes, and CLI overrides win over persisted ones.
|
|
55
|
+
- +24 tests (610 total, 609 pass / 1 pre-existing skip). `tsc`, `typecheck:tests`
|
|
56
|
+
and `build` clean. Default-path decisions unchanged; an uncapped agent writes
|
|
57
|
+
no new state.
|
|
58
|
+
|
|
59
|
+
## [0.10.0] — 2026-07-03
|
|
60
|
+
|
|
61
|
+
Two research-driven, opt-in evolution surfaces — a new challenger *source*
|
|
62
|
+
(demo injection) and a new parent-*selection* strategy for the existing
|
|
63
|
+
reflective challenger — both validated against the current state of the field
|
|
64
|
+
(GEPA upstream docs, DSPy SIMBA) before a line was written. Default behaviour
|
|
65
|
+
is byte-for-byte unchanged with the flags off.
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- **SIMBA-style demo injection** (`src/evolution/demos.ts` + `evolution.useDemos`).
|
|
70
|
+
DSPy's SIMBA optimizer improves programs two ways: appending self-reflective
|
|
71
|
+
*rules* (Darwin's reflector already covers that ground) and appending
|
|
72
|
+
successful past examples as *demonstrations*. This release adapts the second
|
|
73
|
+
strategy to the online loop: on every `demoEveryK`-th evolution cycle (default
|
|
74
|
+
4) the loop harvests the agent's own highest-scoring past runs (score ≥
|
|
75
|
+
`demoScoreThreshold`, default 8; at most one demo per task type for
|
|
76
|
+
diversity; `maxDemos` cap, default 2) and appends them as a marker-delimited
|
|
77
|
+
"Demonstrations" section. The demo-augmented prompt is a normal challenger —
|
|
78
|
+
same alignment guard, same A/B test, same safety gate; if demos don't help
|
|
79
|
+
this agent, the incumbent wins. **Zero LLM cost** (pure selection +
|
|
80
|
+
rendering on data Darwin already persists), works with or without `useGepa`,
|
|
81
|
+
idempotent via `<!-- darwin:demos:start/end -->` markers (a later cycle
|
|
82
|
+
*refreshes* the section, never stacks a second one). Pure helpers
|
|
83
|
+
(`selectDemoCandidates` / `buildDemoSection` / `applyDemoSection` /
|
|
84
|
+
`stripDemoSection`) are exported from the package root. CLI: `--demos` /
|
|
85
|
+
`--no-demos`.
|
|
86
|
+
|
|
87
|
+
- **Parent-selection strategies** (`src/evolution/selection.ts` +
|
|
88
|
+
`evolution.candidateSelection`) — GEPA `candidate_selection_strategy` parity
|
|
89
|
+
for the online loop. Historically the loop always reflected from the
|
|
90
|
+
currently-active prompt (a hill-climb that can sit on a local optimum).
|
|
91
|
+
Opt-in strategies pick the reflection parent from the agent's *scored
|
|
92
|
+
version history* instead: `'best'` (GEPA `current_best` — highest
|
|
93
|
+
scalarised composite), `'pareto'` (GEPA default — uniform sample from the
|
|
94
|
+
non-dominated front, keeping lineages alive that win on different
|
|
95
|
+
objectives), `'epsilon-greedy'` (explore with probability
|
|
96
|
+
`explorationEpsilon`, default 0.1, exploit otherwise). The RNG is
|
|
97
|
+
injectable via the new `DarwinLoopDeps.rng` for deterministic tests.
|
|
98
|
+
Precedence: `useCoverage` (GEPA Algorithm 2, the more specific selector)
|
|
99
|
+
wins when it finds a coverage parent. Only consulted when `useGepa` is on.
|
|
100
|
+
CLI: `--candidate-selection <active|best|pareto|epsilon-greedy>`.
|
|
101
|
+
|
|
102
|
+
### Internal
|
|
103
|
+
|
|
104
|
+
- `tryMergeVariant`'s version-history scoring extracted into a shared
|
|
105
|
+
`buildScoredHistory` (used by merge *and* parent selection) — behaviour
|
|
106
|
+
unchanged.
|
|
107
|
+
- `package.json` now lists Claude (Anthropic) as a contributor — see the
|
|
108
|
+
README's new **Credits** section for how this project is actually built.
|
|
109
|
+
|
|
5
110
|
## [0.9.0] — 2026-06-21
|
|
6
111
|
|
|
7
112
|
### Added
|
package/README.md
CHANGED
|
@@ -222,6 +222,76 @@ 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
|
+
|
|
258
|
+
### Budget discipline (v0.11, opt-in)
|
|
259
|
+
|
|
260
|
+
Two more knobs adapted from GEPA (the values mirror upstream; upstream ships
|
|
261
|
+
both on, here they are off unless you turn them on).
|
|
262
|
+
|
|
263
|
+
**Skip perfect feedback** (`skipPerfectFeedback`) adapts GEPA's
|
|
264
|
+
`skip_perfect_score`. Upstream skips a whole reflection iteration when an entire
|
|
265
|
+
sampled minibatch is perfect; Darwin generalizes it to per-report filtering,
|
|
266
|
+
which it can afford because the critic scores on real runs are already paid for.
|
|
267
|
+
A run that already scored a perfect critic score carries no improvement
|
|
268
|
+
gradient, so its "nothing to fix" report just dilutes the pool. When on,
|
|
269
|
+
perfect-score reports are dropped from *both* the legacy optimizer feedback and
|
|
270
|
+
the GEPA reflection minibatch (lower `perfectFeedbackScore` from the default 10
|
|
271
|
+
to also skip near-perfect runs). With `useDemos` on, those perfect runs still
|
|
272
|
+
get used — harvested as demonstrations instead.
|
|
273
|
+
|
|
274
|
+
**Merge budget** (`maxMergeInvocations`) adapts GEPA's `max_merge_invocations`
|
|
275
|
+
(default 5 upstream): a per-agent *lifetime* cap on how many merge-derived
|
|
276
|
+
challengers an agent may produce. The GEPA paper leaves merge-budget allocation
|
|
277
|
+
as open research; the reason Darwin needs a cap is its own — an uncapped
|
|
278
|
+
`mergeEveryK` cadence would merge forever, so late in an agent's life merges
|
|
279
|
+
would crowd out the reflective exploration that finds genuinely new strategies.
|
|
280
|
+
Once the cap is hit the loop falls back to the reflective path for good. Left
|
|
281
|
+
unset it is uncapped (the v0.10 behaviour); set it to `5` to match GEPA's
|
|
282
|
+
protective default.
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
evolution: {
|
|
286
|
+
enabled: true,
|
|
287
|
+
useGepa: true,
|
|
288
|
+
skipPerfectFeedback: true, // GEPA skip_perfect_score — focus feedback on failures
|
|
289
|
+
perfectFeedbackScore: 10, // score (1-10) counted as "perfect" (default 10)
|
|
290
|
+
useMerge: true,
|
|
291
|
+
maxMergeInvocations: 5, // GEPA max_merge_invocations — cap merge over the agent's life
|
|
292
|
+
},
|
|
293
|
+
```
|
|
294
|
+
|
|
225
295
|
## Built-in Agents
|
|
226
296
|
|
|
227
297
|
| Agent | What it does | Needs |
|
|
@@ -465,6 +535,10 @@ darwin run writer "Explain consensus" --gepa --pareto-gate
|
|
|
465
535
|
| `--pareto-gate` / `--no-pareto-gate` | Reject an A/B winner that regressed on any objective |
|
|
466
536
|
| `--coverage` / `--no-coverage` | Pick the reflection parent by per-task-type coverage breadth (GEPA Algorithm 2) |
|
|
467
537
|
| `--reflection-model <id>` | Use a stronger model for GEPA reflection (the documented leverage point) |
|
|
538
|
+
| `--demos` / `--no-demos` | SIMBA-style demo injection: the agent's best past runs as a challenger (v0.10) |
|
|
539
|
+
| `--candidate-selection <s>` | Reflection parent strategy: `active` \| `best` \| `pareto` \| `epsilon-greedy` (v0.10) |
|
|
540
|
+
| `--skip-perfect` / `--no-skip-perfect` | Drop perfect-score runs from optimizer feedback — GEPA `skip_perfect_score` (v0.11) |
|
|
541
|
+
| `--max-merge <n>` | Lifetime cap on merge-derived challengers — GEPA `max_merge_invocations` (v0.11) |
|
|
468
542
|
|
|
469
543
|
All default to **off** — the baseline single-objective evolution loop is
|
|
470
544
|
unchanged unless you opt in.
|
|
@@ -526,6 +600,19 @@ The safety gate prevents regressions. If a new variant scores >20% lower, Darwin
|
|
|
526
600
|
|
|
527
601
|
PRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
528
602
|
|
|
603
|
+
## Credits
|
|
604
|
+
|
|
605
|
+
Darwin is pair-built by a human and an AI, and we think that should be said
|
|
606
|
+
plainly rather than hidden. Matthias Meyer (StudioMeyer) sets direction, makes
|
|
607
|
+
the calls and reviews everything; most of the code is written by
|
|
608
|
+
[Claude](https://www.anthropic.com/claude) — currently **Claude Fable 5** —
|
|
609
|
+
working from research against the primary sources (the GEPA paper and
|
|
610
|
+
reference implementation, DSPy, the MCP spec) and gated by multi-agent code
|
|
611
|
+
review plus this repo's own test suite before anything ships. Claude is listed
|
|
612
|
+
as a contributor in `package.json`, and the commits it co-writes carry a
|
|
613
|
+
`Co-Authored-By` trailer. A framework about agents that improve themselves,
|
|
614
|
+
built with an agent — we find that fitting.
|
|
615
|
+
|
|
529
616
|
## About StudioMeyer
|
|
530
617
|
|
|
531
618
|
[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,10 @@
|
|
|
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)
|
|
17
|
+
* --skip-perfect / --no-skip-perfect (v0.11.0)
|
|
18
|
+
* --max-merge <n> (v0.11.0)
|
|
15
19
|
*/
|
|
16
20
|
import type { EvolutionConfigOverride } from '../types.js';
|
|
17
21
|
/** 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;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAU3D,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAqB1D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,uBAAuB,GAC9B,MAAM,CAoFR;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,CAY9E"}
|
|
@@ -12,7 +12,18 @@
|
|
|
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)
|
|
17
|
+
* --skip-perfect / --no-skip-perfect (v0.11.0)
|
|
18
|
+
* --max-merge <n> (v0.11.0)
|
|
15
19
|
*/
|
|
20
|
+
/** Valid values for `--candidate-selection` (v0.10.0). */
|
|
21
|
+
const CANDIDATE_SELECTION_VALUES = new Set([
|
|
22
|
+
'active',
|
|
23
|
+
'best',
|
|
24
|
+
'pareto',
|
|
25
|
+
'epsilon-greedy',
|
|
26
|
+
]);
|
|
16
27
|
/** True when `arg` is one of the evolution-config flags this module handles. */
|
|
17
28
|
export function isEvolutionConfigFlag(arg) {
|
|
18
29
|
switch (arg) {
|
|
@@ -25,6 +36,12 @@ export function isEvolutionConfigFlag(arg) {
|
|
|
25
36
|
case '--coverage':
|
|
26
37
|
case '--no-coverage':
|
|
27
38
|
case '--reflection-model':
|
|
39
|
+
case '--demos':
|
|
40
|
+
case '--no-demos':
|
|
41
|
+
case '--candidate-selection':
|
|
42
|
+
case '--skip-perfect':
|
|
43
|
+
case '--no-skip-perfect':
|
|
44
|
+
case '--max-merge':
|
|
28
45
|
return true;
|
|
29
46
|
default:
|
|
30
47
|
return false;
|
|
@@ -70,6 +87,53 @@ export function applyEvolutionFlag(arg, nextArg, target) {
|
|
|
70
87
|
return 1;
|
|
71
88
|
}
|
|
72
89
|
return 0;
|
|
90
|
+
case '--demos':
|
|
91
|
+
target.useDemos = true;
|
|
92
|
+
return 0;
|
|
93
|
+
case '--no-demos':
|
|
94
|
+
target.useDemos = false;
|
|
95
|
+
return 0;
|
|
96
|
+
case '--candidate-selection':
|
|
97
|
+
// Value is consumed either way (it was clearly meant as this flag's
|
|
98
|
+
// argument); it is only APPLIED when it names a known strategy — an
|
|
99
|
+
// unknown value warns instead of silently persisting a config the loop
|
|
100
|
+
// would then silently treat as 'active'.
|
|
101
|
+
if (nextArg !== undefined) {
|
|
102
|
+
if (CANDIDATE_SELECTION_VALUES.has(nextArg)) {
|
|
103
|
+
target.candidateSelection = nextArg;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.warn(`[darwin] --candidate-selection "${nextArg}" is not one of: ${[...CANDIDATE_SELECTION_VALUES].join(', ')} — ignored.`);
|
|
107
|
+
}
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
return 0;
|
|
111
|
+
case '--skip-perfect':
|
|
112
|
+
target.skipPerfectFeedback = true;
|
|
113
|
+
return 0;
|
|
114
|
+
case '--no-skip-perfect':
|
|
115
|
+
target.skipPerfectFeedback = false;
|
|
116
|
+
return 0;
|
|
117
|
+
case '--max-merge': {
|
|
118
|
+
// A missing value (end of argv) or a following FLAG (`--max-merge
|
|
119
|
+
// --force`) is a missing value, not this flag's argument — warn and do
|
|
120
|
+
// NOT consume the next token, so a following action flag still runs.
|
|
121
|
+
if (nextArg === undefined || nextArg.startsWith('--')) {
|
|
122
|
+
console.warn('[darwin] --max-merge needs a non-negative integer value — ignored.');
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
// Strict non-negative-integer match rejects '', ' ', '-3', '2.5', '0x10',
|
|
126
|
+
// '1e3', 'abc' (Number() would coerce several of those, e.g. Number('')
|
|
127
|
+
// === 0, silently disabling merge for the agent's life). The value token
|
|
128
|
+
// is consumed either way — it was clearly meant as this flag's argument.
|
|
129
|
+
if (/^\d+$/.test(nextArg.trim())) {
|
|
130
|
+
target.maxMergeInvocations = Number(nextArg.trim());
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
console.warn(`[darwin] --max-merge "${nextArg}" is not a non-negative integer — ignored.`);
|
|
134
|
+
}
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
73
137
|
default:
|
|
74
138
|
return 0;
|
|
75
139
|
}
|
|
@@ -101,6 +165,10 @@ export function hasAnyEvolutionFlag(override) {
|
|
|
101
165
|
override.useMerge !== undefined ||
|
|
102
166
|
override.paretoGate !== undefined ||
|
|
103
167
|
override.useCoverage !== undefined ||
|
|
104
|
-
override.reflectionModel !== undefined
|
|
168
|
+
override.reflectionModel !== undefined ||
|
|
169
|
+
override.useDemos !== undefined ||
|
|
170
|
+
override.candidateSelection !== undefined ||
|
|
171
|
+
override.skipPerfectFeedback !== undefined ||
|
|
172
|
+
override.maxMergeInvocations !== undefined);
|
|
105
173
|
}
|
|
106
174
|
//# 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;;;;;;;;;;;;;;;;;;GAkBG;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,CAAC;QAC7B,KAAK,gBAAgB,CAAC;QACtB,KAAK,mBAAmB,CAAC;QACzB,KAAK,aAAa;YAChB,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,CAA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ACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACrB,IAAI,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YAChE,CAAC,IAAI,QAAQ,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,mBAAmB,CAAC,QAAiC;IACnE,OAAO,CACL,QAAQ,CAAC,OAAO,KAAK,SAAS;QAC9B,QAAQ,CAAC,QAAQ,KAAK,SAAS;QAC/B,QAAQ,CAAC,UAAU,KAAK,SAAS;QACjC,QAAQ,CAAC,WAAW,KAAK,SAAS;QAClC,QAAQ,CAAC,eAAe,KAAK,SAAS;QACtC,QAAQ,CAAC,QAAQ,KAAK,SAAS;QAC/B,QAAQ,CAAC,kBAAkB,KAAK,SAAS;QACzC,QAAQ,CAAC,mBAAmB,KAAK,SAAS;QAC1C,QAAQ,CAAC,mBAAmB,KAAK,SAAS,CAC3C,CAAC;AACJ,CAAC"}
|
package/dist/src/cli/evolve.d.ts
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
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
|
|
22
|
+
* --skip-perfect / --no-skip-perfect drop perfect-score runs from optimizer feedback (v0.11)
|
|
23
|
+
* --max-merge <n> lifetime cap on merge-derived challengers (v0.11)
|
|
20
24
|
*/
|
|
21
25
|
export declare function evolveCommand(args: string[]): Promise<void>;
|
|
22
26
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAeH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkGjE"}
|
package/dist/src/cli/evolve.js
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
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
|
|
22
|
+
* --skip-perfect / --no-skip-perfect drop perfect-score runs from optimizer feedback (v0.11)
|
|
23
|
+
* --max-merge <n> lifetime cap on merge-derived challengers (v0.11)
|
|
20
24
|
*/
|
|
21
25
|
import { createMemory } from '../memory/index.js';
|
|
22
26
|
import { loadConfig } from '../core/agent.js';
|
|
@@ -135,6 +139,14 @@ function describeOverride(o) {
|
|
|
135
139
|
parts.push(`coverage=${o.useCoverage}`);
|
|
136
140
|
if (o.reflectionModel !== undefined)
|
|
137
141
|
parts.push(`reflectionModel=${o.reflectionModel}`);
|
|
142
|
+
if (o.useDemos !== undefined)
|
|
143
|
+
parts.push(`demos=${o.useDemos}`);
|
|
144
|
+
if (o.candidateSelection !== undefined)
|
|
145
|
+
parts.push(`candidateSelection=${o.candidateSelection}`);
|
|
146
|
+
if (o.skipPerfectFeedback !== undefined)
|
|
147
|
+
parts.push(`skipPerfect=${o.skipPerfectFeedback}`);
|
|
148
|
+
if (o.maxMergeInvocations !== undefined)
|
|
149
|
+
parts.push(`maxMerge=${o.maxMergeInvocations}`);
|
|
138
150
|
return parts.length > 0 ? parts.join(', ') : '(none)';
|
|
139
151
|
}
|
|
140
152
|
/** One-line summary of the effective advanced config for the status view. */
|
|
@@ -146,9 +158,18 @@ function describeConfig(evo) {
|
|
|
146
158
|
`merge=${evo.useMerge ?? false}`,
|
|
147
159
|
`paretoGate=${evo.paretoGate ?? false}`,
|
|
148
160
|
`coverage=${evo.useCoverage ?? false}`,
|
|
161
|
+
`demos=${evo.useDemos ?? false}`,
|
|
162
|
+
`skipPerfect=${evo.skipPerfectFeedback ?? false}`,
|
|
149
163
|
];
|
|
150
164
|
if (evo.reflectionModel)
|
|
151
165
|
parts.push(`reflectionModel=${evo.reflectionModel}`);
|
|
166
|
+
if (evo.candidateSelection && evo.candidateSelection !== 'active') {
|
|
167
|
+
parts.push(`candidateSelection=${evo.candidateSelection}`);
|
|
168
|
+
}
|
|
169
|
+
// maxMerge is genuinely optional (unset = uncapped), so it is shown only when
|
|
170
|
+
// set — unlike the always-shown booleans above.
|
|
171
|
+
if (evo.maxMergeInvocations !== undefined)
|
|
172
|
+
parts.push(`maxMerge=${evo.maxMergeInvocations}`);
|
|
152
173
|
return parts.join(', ');
|
|
153
174
|
}
|
|
154
175
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAA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CAAC,CAAC,QAAQ,CAAC;AACxD,CAAC;AAED,6EAA6E;AAC7E,SAAS,cAAc,CAAC,GAAgC;IACtD,IAAI,CAAC,GAAG;QAAE,OAAO,uBAAuB,CAAC;IACzC,MAAM,KAAK,GAAG;QACZ,QAAQ,GAAG,CAAC,OAAO,IAAI,KAAK,EAAE;QAC9B,SAAS,GAAG,CAAC,QAAQ,IAAI,KAAK,EAAE;QAChC,cAAc,GAAG,CAAC,UAAU,IAAI,KAAK,EAAE;QACvC,YAAY,GAAG,CAAC,WAAW,IAAI,KAAK,EAAE;QACtC,SAAS,GAAG,CAAC,QAAQ,IAAI,KAAK,EAAE;QAChC,eAAe,GAAG,CAAC,mBAAmB,IAAI,KAAK,EAAE;KAClD,CAAC;IACF,IAAI,GAAG,CAAC,eAAe;QAAE,KAAK,CAAC,IAAI,CAAC,mBAAmB,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9E,IAAI,GAAG,CAAC,kBAAkB,IAAI,GAAG,CAAC,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAClE,KAAK,CAAC,IAAI,CAAC,sBAAsB,GAAG,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,8EAA8E;IAC9E,gDAAgD;IAChD,IAAI,GAAG,CAAC,mBAAmB,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC7F,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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CZ,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAA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+
* 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,"file":"demos.d.ts","sourceRoot":"","sources":["../../../src/evolution/demos.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,E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