@evomap/evolver 1.70.0-beta.1 → 1.70.0-beta.3
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/README.ja-JP.md +13 -0
- package/README.ko-KR.md +13 -0
- package/README.md +13 -0
- package/README.zh-CN.md +13 -0
- package/assets/gep/candidates.jsonl +3 -3
- package/assets/gep/genes.json +39 -1
- package/index.js +53 -3
- package/package.json +1 -1
- package/src/adapters/hookAdapter.js +3 -1
- package/src/adapters/kiro.js +203 -0
- package/src/adapters/scripts/evolver-session-start.js +62 -0
- package/src/atp/cliAutobuyPrompt.js +160 -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
- package/src/gep/validator/sandboxExecutor.js +53 -8
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* First-run prompt that introduces the ATP autoBuyer to interactive users.
|
|
5
|
+
*
|
|
6
|
+
* Triggers when ALL conditions hold:
|
|
7
|
+
* - process.stdin.isTTY === true (skipped under systemd, Docker, CI)
|
|
8
|
+
* - EVOLVER_ATP_AUTOBUY is not already set (neither on nor off)
|
|
9
|
+
* - ack file memory/atp-autobuy-ack.json does not exist (already decided)
|
|
10
|
+
*
|
|
11
|
+
* Outcomes:
|
|
12
|
+
* - user answers y -> enabled=true written, session opts in immediately
|
|
13
|
+
* - user answers n -> enabled=false written, prompt never shown again
|
|
14
|
+
* - user answers later -> no file written, prompt shown next time
|
|
15
|
+
* - any non-TTY/ack branch -> silent no-op
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require("fs");
|
|
19
|
+
const path = require("path");
|
|
20
|
+
const readline = require("readline");
|
|
21
|
+
|
|
22
|
+
const ACK_FILE_NAME = "atp-autobuy-ack.json";
|
|
23
|
+
|
|
24
|
+
function _getMemoryDir() {
|
|
25
|
+
try {
|
|
26
|
+
return require("../gep/paths").getMemoryDir();
|
|
27
|
+
} catch (_) {
|
|
28
|
+
return process.env.MEMORY_DIR || path.join(process.cwd(), "memory");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _getAckPath() {
|
|
33
|
+
return path.join(_getMemoryDir(), ACK_FILE_NAME);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _readAck() {
|
|
37
|
+
try {
|
|
38
|
+
const raw = fs.readFileSync(_getAckPath(), "utf8");
|
|
39
|
+
const parsed = JSON.parse(raw);
|
|
40
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
41
|
+
return parsed;
|
|
42
|
+
} catch (_) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _writeAck(enabled) {
|
|
48
|
+
const p = _getAckPath();
|
|
49
|
+
try {
|
|
50
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
51
|
+
const body = {
|
|
52
|
+
enabled: !!enabled,
|
|
53
|
+
acknowledged_at: new Date().toISOString(),
|
|
54
|
+
version: 1,
|
|
55
|
+
};
|
|
56
|
+
fs.writeFileSync(p, JSON.stringify(body, null, 2) + "\n", "utf8");
|
|
57
|
+
return true;
|
|
58
|
+
} catch (_) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @returns {"ack_present"|"env_set"|"non_tty"|"eligible"}
|
|
65
|
+
*/
|
|
66
|
+
function classify(env, stdin) {
|
|
67
|
+
const envVal = env && env.EVOLVER_ATP_AUTOBUY;
|
|
68
|
+
if (typeof envVal === "string" && envVal.trim().length > 0) {
|
|
69
|
+
return "env_set";
|
|
70
|
+
}
|
|
71
|
+
if (!stdin || !stdin.isTTY) {
|
|
72
|
+
return "non_tty";
|
|
73
|
+
}
|
|
74
|
+
if (_readAck()) {
|
|
75
|
+
return "ack_present";
|
|
76
|
+
}
|
|
77
|
+
return "eligible";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function _ask(question, { input, output }) {
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
const rl = readline.createInterface({ input, output });
|
|
83
|
+
rl.question(question, (answer) => {
|
|
84
|
+
rl.close();
|
|
85
|
+
resolve((answer || "").trim().toLowerCase());
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Synchronously decide whether to prompt (TTY + no ack + env unset) and,
|
|
92
|
+
* if prompting, block on user answer. Resolves with:
|
|
93
|
+
* { prompted: bool, decision: "yes"|"no"|"later"|null, reason: string }
|
|
94
|
+
*
|
|
95
|
+
* Should be called at most once per `evolver run` invocation, BEFORE the
|
|
96
|
+
* autoBuyer.start() branch in the run loop.
|
|
97
|
+
*
|
|
98
|
+
* @param {object} [opts]
|
|
99
|
+
* @param {NodeJS.ReadableStream} [opts.input]
|
|
100
|
+
* @param {NodeJS.WritableStream} [opts.output]
|
|
101
|
+
* @param {NodeJS.ProcessEnv} [opts.env]
|
|
102
|
+
* @param {(q: string, io: object) => Promise<string>} [opts.ask]
|
|
103
|
+
* @returns {Promise<{ prompted: boolean, decision: string|null, reason: string }>}
|
|
104
|
+
*/
|
|
105
|
+
async function runPrompt(opts) {
|
|
106
|
+
opts = opts || {};
|
|
107
|
+
const input = opts.input || process.stdin;
|
|
108
|
+
const output = opts.output || process.stdout;
|
|
109
|
+
const env = opts.env || process.env;
|
|
110
|
+
const ask = typeof opts.ask === "function" ? opts.ask : _ask;
|
|
111
|
+
|
|
112
|
+
const state = classify(env, input);
|
|
113
|
+
if (state !== "eligible") {
|
|
114
|
+
return { prompted: false, decision: null, reason: state };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
output.write("\n");
|
|
119
|
+
output.write("[ATP-AutoBuyer] Your evolver can automatically place small-priced\n");
|
|
120
|
+
output.write("ATP orders when it detects a capability gap (default OFF).\n");
|
|
121
|
+
output.write(" - daily hard cap: ATP_AUTOBUY_DAILY_CAP_CREDITS (default applies)\n");
|
|
122
|
+
output.write(" - per-order cap: ATP_AUTOBUY_PER_ORDER_CAP_CREDITS\n");
|
|
123
|
+
output.write(" - unset EVOLVER_ATP_AUTOBUY and restart to disable at any time.\n");
|
|
124
|
+
output.write("\n");
|
|
125
|
+
} catch (_) {
|
|
126
|
+
return { prompted: false, decision: null, reason: "io_error" };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let answer;
|
|
130
|
+
try {
|
|
131
|
+
answer = await ask("Enable autoBuyer for this session? [y/n/later] ", {
|
|
132
|
+
input,
|
|
133
|
+
output,
|
|
134
|
+
});
|
|
135
|
+
} catch (_) {
|
|
136
|
+
return { prompted: true, decision: null, reason: "ask_error" };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (answer === "y" || answer === "yes") {
|
|
140
|
+
_writeAck(true);
|
|
141
|
+
env.EVOLVER_ATP_AUTOBUY = "on";
|
|
142
|
+
return { prompted: true, decision: "yes", reason: "user_accepted" };
|
|
143
|
+
}
|
|
144
|
+
if (answer === "n" || answer === "no") {
|
|
145
|
+
_writeAck(false);
|
|
146
|
+
return { prompted: true, decision: "no", reason: "user_declined" };
|
|
147
|
+
}
|
|
148
|
+
return { prompted: true, decision: "later", reason: "user_postponed" };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = {
|
|
152
|
+
runPrompt,
|
|
153
|
+
classify,
|
|
154
|
+
__internals: {
|
|
155
|
+
ACK_FILE_NAME,
|
|
156
|
+
_readAck,
|
|
157
|
+
_writeAck,
|
|
158
|
+
_getAckPath,
|
|
159
|
+
},
|
|
160
|
+
};
|