@evomap/evolver 1.72.0 → 1.74.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/assets/gep/candidates.jsonl +1 -4
- package/index.js +47 -1
- package/package.json +1 -1
- package/src/atp/atpExecute.js +285 -0
- package/src/atp/atpTaskPickup.js +233 -0
- package/src/atp/index.js +6 -0
- package/src/atp/questionComposer.js +133 -0
- package/src/evolve.js +1 -1
- package/src/gep/.integrity +0 -0
- package/src/gep/a2aProtocol.js +1 -1
- package/src/gep/candidateEval.js +1 -1
- package/src/gep/candidates.js +1 -1
- package/src/gep/contentHash.js +1 -1
- package/src/gep/crypto.js +1 -1
- package/src/gep/curriculum.js +1 -1
- package/src/gep/deviceId.js +1 -1
- package/src/gep/envFingerprint.js +1 -1
- package/src/gep/explore.js +1 -1
- package/src/gep/hubReview.js +1 -1
- package/src/gep/hubSearch.js +1 -1
- package/src/gep/hubVerify.js +1 -1
- package/src/gep/integrityCheck.js +1 -1
- package/src/gep/learningSignals.js +1 -1
- package/src/gep/memoryGraph.js +1 -1
- package/src/gep/memoryGraphAdapter.js +1 -1
- package/src/gep/mutation.js +1 -1
- package/src/gep/narrativeMemory.js +1 -1
- package/src/gep/personality.js +1 -1
- package/src/gep/policyCheck.js +1 -1
- package/src/gep/prompt.js +1 -1
- package/src/gep/reflection.js +1 -1
- package/src/gep/selector.js +1 -1
- package/src/gep/shield.js +1 -1
- package/src/gep/skillDistiller.js +1 -1
- package/src/gep/solidify.js +1 -1
- package/src/gep/strategy.js +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// ATP Question Composer
|
|
2
|
+
//
|
|
3
|
+
// Generates a natural-language buyer question from raw capability/signal
|
|
4
|
+
// inputs. autoBuyer previously concatenated signals into a string like
|
|
5
|
+
// "Capability gap detected by evolver: code_evolution,performance,..."
|
|
6
|
+
// which is uninformative to the merchant and produces poor answers.
|
|
7
|
+
//
|
|
8
|
+
// This module maps each known capability (or signal prefix) to a template
|
|
9
|
+
// that phrases the request as something a real buyer might ask. When no
|
|
10
|
+
// template matches, falls back to a generic "please help me with <caps>"
|
|
11
|
+
// phrasing. Templates deliberately stay concise (under 240 chars) so buyer
|
|
12
|
+
// budgets and merchant time are not wasted on padding.
|
|
13
|
+
//
|
|
14
|
+
// Templates are intentionally defensive: they never leak Evolver internals
|
|
15
|
+
// ("signals", "cycle", "mutation") into merchant-visible text.
|
|
16
|
+
|
|
17
|
+
const DEFAULT_MAX_LEN = 240;
|
|
18
|
+
|
|
19
|
+
const TEMPLATES = {
|
|
20
|
+
code_evolution: [
|
|
21
|
+
'I want to improve code quality on a small module. Please suggest one concrete, minimal patch I can apply, including the exact files, the change, and why it helps.',
|
|
22
|
+
'I am iterating on a codebase and would like one high-leverage refactor suggestion. Be specific about the file, the current issue, and the proposed change.',
|
|
23
|
+
],
|
|
24
|
+
performance: [
|
|
25
|
+
'My app has a slow hot-path and I want one concrete optimization idea. Explain the likely bottleneck, propose a specific fix, and estimate the impact.',
|
|
26
|
+
'I need help diagnosing a performance issue. Ask the right clarifying question if needed, or give me the top-3 most likely causes in priority order.',
|
|
27
|
+
],
|
|
28
|
+
debugging: [
|
|
29
|
+
'I am stuck on a bug and need a fresh pair of eyes. Walk me through a systematic debugging approach that would isolate the root cause in under an hour.',
|
|
30
|
+
'Help me debug a tricky issue: please outline 3 reproduction strategies, each with the signals I should look for to confirm or rule out a hypothesis.',
|
|
31
|
+
],
|
|
32
|
+
testing: [
|
|
33
|
+
'I want to add tests to an under-tested module. Recommend the specific test cases (happy path, edge cases, regression) that give the best coverage per line of test code.',
|
|
34
|
+
'Please review a typical testing gap for this kind of module and tell me the 3 test cases I probably missed.',
|
|
35
|
+
],
|
|
36
|
+
documentation: [
|
|
37
|
+
'I need to write user-facing documentation for a feature. Give me a concise outline and sample opening paragraph that sets expectations correctly.',
|
|
38
|
+
'Help me rewrite a README section so it is clear to a first-time user. Focus on the smallest change that removes the most confusion.',
|
|
39
|
+
],
|
|
40
|
+
refactoring: [
|
|
41
|
+
'I want to refactor a module without changing behavior. Suggest the safest single-step refactor that reduces complexity, and what I should watch for during review.',
|
|
42
|
+
'Please propose a refactoring plan I can apply in small commits, starting with the change that has the highest value/risk ratio.',
|
|
43
|
+
],
|
|
44
|
+
security: [
|
|
45
|
+
'Review a typical security concern for this kind of service and give me one actionable hardening I should implement first.',
|
|
46
|
+
'I want a short security checklist for my app. List the top 5 issues to check in priority order, with the quickest mitigation for each.',
|
|
47
|
+
],
|
|
48
|
+
data_analysis: [
|
|
49
|
+
'I have a dataset and want to extract one useful insight. Recommend the analysis I should run first, the metric to compute, and how to interpret the result.',
|
|
50
|
+
'Given a typical CSV of user events, which 3 analyses would most likely surface actionable patterns? Explain why for each.',
|
|
51
|
+
],
|
|
52
|
+
architecture: [
|
|
53
|
+
'Help me think through an architectural trade-off: I need to choose between two patterns for a small service. Give me the decision factors and a recommended default.',
|
|
54
|
+
'I need a rough architecture sketch for a new feature. Describe the smallest viable design and list the 2 decisions that are easy to get wrong.',
|
|
55
|
+
],
|
|
56
|
+
deployment: [
|
|
57
|
+
'Help me set up a safe deployment path for my app. Outline the minimum CI/CD steps and the 3 most common pitfalls to avoid.',
|
|
58
|
+
'I want to harden my deploy pipeline. Recommend the smallest change that most reduces the risk of a broken deploy reaching production.',
|
|
59
|
+
],
|
|
60
|
+
general: [
|
|
61
|
+
'I have a small task I would like an agent to help with. Please ask me the single most useful clarifying question, then outline how you would approach it.',
|
|
62
|
+
'Please give me a concise, practical answer for a typical task in this capability. If context is needed, ask one focused clarifying question first.',
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function _normalize(s) {
|
|
67
|
+
return String(s || '').toLowerCase().replace(/[^a-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _pickTemplate(key, hashSeed) {
|
|
71
|
+
const list = TEMPLATES[key] || TEMPLATES.general;
|
|
72
|
+
if (!list || list.length === 0) return null;
|
|
73
|
+
// Deterministic pick from a seed so the same signals yield the same
|
|
74
|
+
// question across runs (plays nicely with autoBuyer's dedup hash).
|
|
75
|
+
const n = Math.abs(Number(hashSeed) || 0) % list.length;
|
|
76
|
+
return list[n];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _hashFor(parts) {
|
|
80
|
+
const s = Array.isArray(parts) ? parts.join('|') : String(parts || '');
|
|
81
|
+
let h = 0;
|
|
82
|
+
for (let i = 0; i < s.length; i++) {
|
|
83
|
+
h = (h * 31 + s.charCodeAt(i)) | 0;
|
|
84
|
+
}
|
|
85
|
+
return h;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _clip(s, maxLen) {
|
|
89
|
+
const text = String(s || '').trim();
|
|
90
|
+
const cap = Math.max(40, Number(maxLen) || DEFAULT_MAX_LEN);
|
|
91
|
+
if (text.length <= cap) return text;
|
|
92
|
+
return text.slice(0, cap - 3).replace(/\s+$/, '') + '...';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Build a natural-language buyer question from capabilities + signals.
|
|
97
|
+
*
|
|
98
|
+
* @param {object} opts
|
|
99
|
+
* @param {string[]} opts.capabilities -- buyer-side capability ids (first one picks the template)
|
|
100
|
+
* @param {string[]} [opts.signals] -- evolver signals (used as tiebreaker; never leaked verbatim)
|
|
101
|
+
* @param {string} [opts.fallback] -- caller-provided fallback sentence
|
|
102
|
+
* @param {number} [opts.maxLen=240]
|
|
103
|
+
* @returns {string} -- composed question (never empty)
|
|
104
|
+
*/
|
|
105
|
+
function compose(opts) {
|
|
106
|
+
const capabilities = Array.isArray(opts && opts.capabilities) ? opts.capabilities : [];
|
|
107
|
+
const signals = Array.isArray(opts && opts.signals) ? opts.signals : [];
|
|
108
|
+
const maxLen = Number(opts && opts.maxLen) || DEFAULT_MAX_LEN;
|
|
109
|
+
|
|
110
|
+
const keys = capabilities.map(_normalize).filter(Boolean);
|
|
111
|
+
const primary = keys.find(function (k) { return TEMPLATES[k]; }) || keys[0] || 'general';
|
|
112
|
+
const tmplKey = TEMPLATES[primary] ? primary : 'general';
|
|
113
|
+
|
|
114
|
+
const seed = _hashFor(keys.concat(signals.slice(0, 4)));
|
|
115
|
+
const tmpl = _pickTemplate(tmplKey, seed);
|
|
116
|
+
|
|
117
|
+
if (tmpl) return _clip(tmpl, maxLen);
|
|
118
|
+
|
|
119
|
+
// Generic fallback when TEMPLATES does not have `general` (defensive).
|
|
120
|
+
const capsText = capabilities.length ? capabilities.slice(0, 3).join(', ') : 'a common task';
|
|
121
|
+
const fb = (opts && opts.fallback && String(opts.fallback).trim())
|
|
122
|
+
|| 'I would like help with ' + capsText + '. Please provide one concrete, actionable answer.';
|
|
123
|
+
return _clip(fb, maxLen);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
compose,
|
|
128
|
+
// exported for tests
|
|
129
|
+
_normalize,
|
|
130
|
+
_pickTemplate,
|
|
131
|
+
_hashFor,
|
|
132
|
+
TEMPLATES,
|
|
133
|
+
};
|